36static const char*
s_tag =
"USB";
61typedef enum : uint32_t {
97typedef enum : uint8_t {
110typedef enum : uint8_t {
217 __asm__
volatile(
"nop");
280#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
325 uint16_t v = *physet_reg;
366 volatile uint16_t* lpsts,
367 uint16_t clksel_value)
571 bool scke_ready =
false;
575#if defined(RA8_OFF_TARGET) && defined(UNIT_TEST)
577 const bool observed = ra8_fake_mmio_poll(®->
SYSCFG, i, scke_set);
579 const bool observed = scke_set;
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_hw_timeout
Hardware timed out waiting for a flag or handshake.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Bounded wait-flag primitives for RA8D2 HAL drivers.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_error(tag, message)
RA8 log error.
SysTick-based tick counter, delay and timestamp helpers.
void ra8_delay_ms(uint32_t ms)
Busy-wait for at least ms milliseconds.
Native USB controller driver public API (device + host modes).
Cross-TU surface for the ra8_usb driver split.
@ k_ra8_usb_dcp_max_packet
EP0 default packet size.
static ra8_err_t internal_usbhs_wait_pll_lock_short(void)
Bounded PHY PLL-lock poll for a single CLKSEL attempt.
ra8_usbhs_phy_step_t
Sentinel values for the per-step USBHS PHY bring-up probe.
@ k_ra8_usbhs_phy_step_dirpd_clear
PHY analog powered.
@ k_ra8_usbhs_phy_step_pll_released
PHY PLLRESET cleared.
@ k_ra8_usbhs_phy_step_clksel_12
PHYSET CLKSEL forced to 12.
@ k_ra8_usbhs_phy_step_hse_set
SYSCFG.HSE asserted.
@ k_ra8_usbhs_phy_step_suspendm_set
LPSTS SUSPENDM=1.
@ k_ra8_usbhs_phy_step_pll_locked
PLLSTA.PLLLOCK observed.
@ k_ra8_usbhs_phy_step_usbe_set
SYSCFG DRPD=0 USBE=1.
static ra8_err_t internal_usbhs_try_clksel(volatile uint16_t *physet, volatile uint16_t *lpsts, uint16_t clksel_value)
One iteration of the CLKSEL bisect: try a single codepoint.
static volatile uint16_t s_clksel_attempt_pllsta[4]
Per-attempt PLLSTA capture array for the bisect harness.
static volatile uint8_t s_clksel_winner
Diagnostic capture of the PHYSET.CLKSEL[1:0] codepoint that produced PLL lock during the bisect harne...
static void internal_usb_delay_1us(void)
Microsecond busy-wait helper for USB PHY bring-up.
ra8_err_t priv_usbhs_phy_bringup(volatile r_usb_regs_t *reg)
USBHS embedded-PHY bring-up (HUM Figure 37.2 p 2121).
static void internal_usbhs_arm_phy_reset(volatile uint16_t *physet_reg, uint16_t clksel_value)
Drive PHYSET into "PHY in reset" with the given CLKSEL field.
static volatile uint16_t s_usbhs_pllsta_probe
Diagnostic capture of PLLSTA at end of PHY bring-up.
ra8_usbhs_init_local_t
Local sentinels used by the USBHS PHY bring-up sequence.
@ k_ra8_usbhs_probe_hi_shift
RA8 usbhs probe hi shift.
@ k_ra8_usbhs_scke_poll_limit
RA8 usbhs scke poll limit.
@ k_ra8_usbhs_pll_lock_poll_limit
RA8 usbhs pll lock poll limit.
@ k_ra8_usbhs_delay_1us_iters
RA8 usbhs delay 1us iters.
@ k_ra8_usbhs_probe_lo_mask
RA8 usbhs probe lo mask.
@ k_ra8_usbhs_pll_lock_attempt_limit
RA8 usbhs pll lock attempt limit.
ra8_usbhs_clksel_attempt_t
Iteration order for the CLKSEL[1:0] bisect harness.
@ k_ra8_usbhs_clksel_attempts_n
RA8 usbhs clksel attempts n.
@ k_ra8_usbhs_clksel_no_winner
Sentinel: bisect exhausted.
static volatile uint8_t s_phy_step_probe
Diagnostic step counter for the USBHS PHY bring-up sequence.
static volatile uint32_t s_usbhs_init_probe
Diagnostic capture of staged USBHS bring-up register values.
void priv_usb_init_common(volatile r_usb_regs_t *reg)
Programme the post-SYSCFG common registers (FIFO, DCP, INTENB).
static void internal_usbhs_enable_syscfg(volatile r_usb_regs_t *reg)
Drive USBHS SYSCFG DRPD=0, USBE=1 after PLLRESET is released.
ra8_err_t priv_usbfs_module_bringup(volatile r_usb_regs_t *reg)
USBFS module bring-up (FSP hw_usb_pmodule_init IP0 branch).
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2.
static volatile uint16_t * ra8_usbhs_lpsts(void)
Get pointer to USBHS LPSTS register.
@ k_ra8_lpsts_suspendm
b14: UTMI SuspendM (1=run).
@ k_ra8_pllsta_plllock
b0 : PHY PLL locked flag.
@ k_ra8_physet_clksel
b5-4: input clock select mask.
@ k_ra8_physet_pllreset
b1 : PHY PLL reset.
@ k_ra8_physet_repsel_16
b9-8: 16-cycle terminator.
@ k_ra8_physet_clksel_24
b5-4 = 11b: 24 MHz reference.
@ k_ra8_physet_dirpd
b0 : PHY power-down (1=PD).
@ k_ra8_syscfg_bit_usbe
USB module enable.
@ k_ra8_syscfg_bit_hse
HS enable (HS instance only).
@ k_ra8_syscfg_bit_drpd
D+/D- pull-down (host).
@ k_ra8_syscfg_bit_scke
USB clock enable.
static volatile uint16_t * ra8_usbhs_physet(void)
Get pointer to USBHS PHYSET register.
static volatile uint16_t * ra8_usbhs_pllsta(void)
Get pointer to USBHS PLLSTA register (read-only).
@ k_ra8_fifosel_mbw_16
16-bit FIFO access width.
@ k_ra8_int0_bit_bemp
Buffer-empty interrupt.
@ k_ra8_int0_bit_dvst
Device-state transition.
@ k_ra8_int0_bit_brdy
Buffer-ready interrupt.
@ k_ra8_int0_bit_ctrt
Control-transfer-stage transition.
@ k_ra8_int0_bit_vbse
VBUS change.
@ k_ra8_int0_bit_nrdy
Buffer-not-ready interrupt.
@ k_ra8_buswait_default
4-wait + b11-b8 reserved-write.
USB FS / HS register window (device-mode subset).
volatile uint16_t NRDYENB
+0x038 NRDY Interrupt Enable.
volatile uint16_t DCPCTR
+0x060 DCP Control.
volatile uint16_t CFIFOSEL
+0x020 Control FIFO select.
volatile uint16_t DCPMAXP
+0x05E DCP Max Packet.
volatile uint16_t INTENB0
+0x030 Interrupt Enable 0.
volatile uint16_t INTSTS0
+0x040 Interrupt Status 0.
volatile uint16_t SYSCFG
+0x000 System Configuration.
volatile uint16_t BRDYENB
+0x036 BRDY Interrupt Enable.
volatile uint16_t BUSWAIT
+0x002 CPU bus wait.
volatile uint16_t INTENB1
+0x032 Interrupt Enable 1.
volatile uint16_t DCPCFG
+0x05C DCP Configuration.
volatile uint16_t D0FIFOSEL
+0x028 DMA FIFO 0 select.
volatile uint16_t BEMPENB
+0x03A BEMP Interrupt Enable.
volatile uint16_t D1FIFOSEL
+0x02C DMA FIFO 1 select.