|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2. More...
Go to the source code of this file.
Data Structures | |
| struct | r_usb_regs_t |
| USB FS / HS register window (device-mode subset). More... | |
Functions | |
| static volatile r_usb_regs_t * | ra8_usb_fs (void) |
| Compile-time offset and size insurance for r_usb_regs_t. | |
| static volatile r_usb_regs_t * | ra8_usb_hs (void) |
| Get pointer to the USB HS controller register block. | |
| static volatile uint16_t * | ra8_usbhs_pllsta (void) |
| Get pointer to USBHS PLLSTA register (read-only). | |
| static volatile uint16_t * | ra8_usbhs_physet (void) |
| Get pointer to USBHS PHYSET register. | |
| static volatile uint16_t * | ra8_usbhs_lpsts (void) |
| Get pointer to USBHS LPSTS register. | |
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2.
RA8D2 has two USB controllers:
Both use the Renesas "USB2_B" IP (common across RA / RZ / RX). The register layouts are identical between the two instances for the device-side bring-up subset modelled here; HS-only registers (PHYSET, LPSTS, PLLSTA, ...) live past offset 0x90 and are not consumed by the device-mode driver yet.
Device and host mode share the same register block; the mode bit is in SYSCFG.DCFM. This driver targets device mode only.
| Offset | Name | Width | Purpose |
|---|---|---|---|
| 0x000 | SYSCFG | 16 | System Configuration |
| 0x002 | BUSWAIT | 16 | CPU bus wait |
| 0x004 | SYSSTS0 | 16 | System Status 0 |
| 0x008 | DVSTCTR0 | 16 | Device State Control 0 |
| 0x014 | CFIFO | 16 | Control FIFO port |
| 0x018 | D0FIFO | 16 | DMA FIFO 0 |
| 0x01C | D1FIFO | 16 | DMA FIFO 1 |
| 0x020 | CFIFOSEL | 16 | Control FIFO select |
| 0x022 | CFIFOCTR | 16 | Control FIFO control (FRDY/BVAL/BCLR) |
| 0x028 | D0FIFOSEL | 16 | DMA FIFO 0 select |
| 0x02A | D0FIFOCTR | 16 | DMA FIFO 0 control |
| 0x02C | D1FIFOSEL | 16 | DMA FIFO 1 select |
| 0x02E | D1FIFOCTR | 16 | DMA FIFO 1 control |
| 0x030 | INTENB0 | 16 | Interrupt Enable 0 |
| 0x032 | INTENB1 | 16 | Interrupt Enable 1 |
| 0x036 | BRDYENB | 16 | BRDY Interrupt Enable |
| 0x038 | NRDYENB | 16 | NRDY Interrupt Enable |
| 0x03A | BEMPENB | 16 | BEMP Interrupt Enable |
| 0x03C | SOFCFG | 16 | SOF Output Configuration |
| 0x040 | INTSTS0 | 16 | Interrupt Status 0 |
| 0x042 | INTSTS1 | 16 | Interrupt Status 1 |
| 0x046 | BRDYSTS | 16 | BRDY Interrupt Status |
| 0x048 | NRDYSTS | 16 | NRDY Interrupt Status |
| 0x04A | BEMPSTS | 16 | BEMP Interrupt Status |
| 0x04C | FRMNUM | 16 | Frame Number |
| 0x050 | USBADDR | 16 | USB Address |
| 0x054 | USBREQ | 16 | USB Request Type / bRequest |
| 0x056 | USBVAL | 16 | USB Request wValue |
| 0x058 | USBINDX | 16 | USB Request wIndex |
| 0x05A | USBLENG | 16 | USB Request wLength |
| 0x05C | DCPCFG | 16 | DCP Config |
| 0x05E | DCPMAXP | 16 | DCP Max Packet |
| 0x060 | DCPCTR | 16 | DCP Control (PID/CCPL/SUREQ) |
| 0x064 | PIPESEL | 16 | Pipe window select |
| 0x068 | PIPECFG | 16 | Selected pipe Config |
| 0x06A | PIPEBUF | 16 | Selected pipe Buffer |
| 0x06C | PIPEMAXP | 16 | Selected pipe Max Packet |
| 0x06E | PIPEPERI | 16 | Selected pipe Period |
| 0x070 | PIPECTR[9] | 16x9 | PIPE1..PIPE9 Control |
Definition in file ra8_usb_regs.h.
| enum ra8_usb_addr_field_t : uint16_t |
USBADDR field masks.
| Enumerator | |
|---|---|
| k_ra8_usbaddr_addr_mask | 7-bit USB address [6:0]. |
Definition at line 632 of file ra8_usb_regs.h.
| enum ra8_usb_addr_t : uintptr_t |
Per-instance base addresses for the two USB controllers.
Sourced from HUM Ch 36 "USB 2.0 Full-Speed Module (USBFS)" p 1965 and HUM Ch 37 "USB 2.0 High-Speed Module (USBHS)" p 2059.
| Enumerator | |
|---|---|
| k_ra8_usb_fs0_base_addr | USB Full-Speed base. |
| k_ra8_usb_hs0_base_addr | USB High-Speed base. (anon). |
Definition at line 87 of file ra8_usb_regs.h.
| enum ra8_usb_ctsq_t : uint16_t |
Control-transfer-stage values reported in INTSTS0.CTSQ[2:0].
Definition at line 527 of file ra8_usb_regs.h.
| enum ra8_usb_dcpcfg_bit_t : uint8_t |
DCPCFG bit positions used by the control-transfer engine.
In host mode DIR selects the data-stage token direction the controller issues on the DCP: 0 = IN (host receives, e.g. GET_DESCRIPTOR), 1 = OUT (host transmits, e.g. DFU_DNLOAD). The default DCPCFG = 0 issues IN tokens, so a control-WRITE data stage MUST set DIR before sending or the device sees an IN token in its write-data stage and flags CTSQ = SQER.
| Enumerator | |
|---|---|
| k_ra8_dcpcfg_bit_dir | Transfer direction (host: 0 = IN, 1 = OUT). |
Definition at line 568 of file ra8_usb_regs.h.
| enum ra8_usb_dcpctr_bit_t : uint8_t |
DCPCTR bit positions used by the device-mode driver.
Definition at line 546 of file ra8_usb_regs.h.
| enum ra8_usb_dvsq_t : uint16_t |
Device-state values reported in INTSTS0.DVSQ[2:0].
Read these as (INTSTS0 & k_ra8_intsts0_mask_dvsq) == <value>.
Definition at line 512 of file ra8_usb_regs.h.
| enum ra8_usb_fifoctr_field_t : uint16_t |
CFIFOCTR / DxFIFOCTR field masks.
| Enumerator | |
|---|---|
| k_ra8_fifoctr_dtln | Data length (write-bytes-rem). |
| k_ra8_fifoctr_frdy | FIFO ready. |
| k_ra8_fifoctr_bclr | Buffer clear. |
| k_ra8_fifoctr_bval | Buffer valid. |
Definition at line 616 of file ra8_usb_regs.h.
| enum ra8_usb_fifosel_field_t : uint16_t |
CFIFOSEL / DxFIFOSEL field masks.
Definition at line 593 of file ra8_usb_regs.h.
| enum ra8_usb_intenb0_bit_t : uint8_t |
INTENB0 / INTSTS0 bit positions (the layouts match).
Definition at line 447 of file ra8_usb_regs.h.
| enum ra8_usb_intenb0_mask_t : uint16_t |
INTENB0 aggregate masks (HUM Ch 36.2.10 p 1980).
Definition at line 480 of file ra8_usb_regs.h.
| enum ra8_usb_intsts0_mask_t : uint16_t |
INTSTS0 multi-bit field masks.
| Enumerator | |
|---|---|
| k_ra8_intsts0_mask_ctsq | Control transfer stage. |
| k_ra8_intsts0_mask_valid | SETUP packet detect flag. |
| k_ra8_intsts0_mask_dvsq | Device state. |
| k_ra8_intsts0_mask_vbsts | VBUS input port level. |
Definition at line 498 of file ra8_usb_regs.h.
| enum ra8_usb_intsts1_bit_t : uint8_t |
INTSTS1 / INTENB1 host-mode bit positions (HUM Ch 36.2.11/15).
Host-side bus events. SACK / SIGN report the outcome of a SETUP transaction started with DCPCTR.SUREQ: SACK latches when the device ACKs the SETUP, SIGN when three transmission attempts fail.
Definition at line 466 of file ra8_usb_regs.h.
| enum ra8_usb_limits_t : uint8_t |
Pipe / endpoint count constants.
Definition at line 106 of file ra8_usb_regs.h.
| enum ra8_usb_offset_t : uint16_t |
Byte offsets of the named USB register fields within r_usb_regs_t.
Sourced from HUM Ch 36 (USBFS, p 1965) and HUM Ch 37 (USBHS, p 2059). Both controllers share the same device-mode register layout in this offset window, so a single set of constants covers both instances.
Definition at line 189 of file ra8_usb_regs.h.
| enum ra8_usb_pid_t : uint16_t |
Response PID values written into the low two bits of DCPCTR / PIPECTR.
| Enumerator | |
|---|---|
| k_ra8_pid_nak | NAK response. |
| k_ra8_pid_buf | BUF response (transmit/receive). |
| k_ra8_pid_stall | STALL response. |
| k_ra8_pid_mask | PID[1:0] field mask. |
Definition at line 577 of file ra8_usb_regs.h.
| enum ra8_usb_pipebuf_field_t : uint16_t |
PIPEBUF field masks / shifts.
Layout: BUFSIZE[14:10] | BUFNMB[7:0]. Buffer block is 64 bytes; the pipe's FIFO region is (BUFSIZE+1) * 64 bytes starting at BUFNMB * 64. With PIPECFG.DBLB the region is split into two equal halves of (BUFSIZE+1)/2 * 64 bytes each, so a 1024-byte region (BUFSIZE=15) holds 2x512 packets for HS bulk MPS=512.
Definition at line 672 of file ra8_usb_regs.h.
| enum ra8_usb_pipecfg_field_t : uint16_t |
PIPECFG field masks / shifts used by the driver.
Definition at line 645 of file ra8_usb_regs.h.
| enum ra8_usb_pipectr_bit_t : uint16_t |
PIPECTR bit positions / fields used by the driver.
Definition at line 688 of file ra8_usb_regs.h.
| enum ra8_usb_size_t : uint16_t |
Total byte size of the modelled USB register window.
The device-mode subset ends at PIPECTR[9] (last halfword at offset 0x080..0x081). HS-only registers past 0x090 (PHYSET, LPCTRL, LPSTS, BCCTRL, ...) are intentionally not modelled.
| Enumerator | |
|---|---|
| k_ra8_usb_window_bytes | 0x070 + (9 * 2) = 0x082 bytes. |
Definition at line 239 of file ra8_usb_regs.h.
| enum ra8_usb_syscfg_bit_t : uint8_t |
SYSCFG bit positions.
Definition at line 428 of file ra8_usb_regs.h.
| enum ra8_usbhs_buswait_t : uint16_t |
BUSWAIT canonical value (HUM Ch 37 "BUSWAIT").
FSP r_usb_preg_access.c uses USB_CFG_BUSWAIT | USB_BWAIT_B11_B8_WRITE where the b11-b8 "reserved must-write" pattern is 0x0F00 and the wait field defaults to 4 cycles (USB_BWAIT_4 == 0x0F04) on RA8.
| Enumerator | |
|---|---|
| k_ra8_buswait_default | 4-wait + b11-b8 reserved-write. |
Definition at line 415 of file ra8_usb_regs.h.
| enum ra8_usbhs_lpsts_bit_t : uint16_t |
LPSTS bit positions (HUM Ch 37 "LPSTS" register).
| Enumerator | |
|---|---|
| k_ra8_lpsts_suspendm | b14: UTMI SuspendM (1=run). |
Definition at line 394 of file ra8_usb_regs.h.
| enum ra8_usbhs_offset_t : uint16_t |
Byte offsets of USBHS-only registers not modelled in r_usb_regs_t.
These exist only on the HS instance (HUM Ch 37) and are required for embedded-PHY bring-up. They sit either inside reserved gaps of the shared device-mode struct (PLLSTA at 0x06, PHYSET at 0x3E) or past it (LPSTS at 0x102). Accessed via base + offset rather than struct fields to keep the shared r_usb_regs_t layout common between FS and HS instances.
| Enumerator | |
|---|---|
| k_ra8_usbhs_off_pllsta | PLLSTA : PLL lock flag. |
| k_ra8_usbhs_off_physet | PHYSET : embedded-PHY setup. |
| k_ra8_usbhs_off_lpsts | LPSTS : SUSPENDM gate. |
Definition at line 347 of file ra8_usb_regs.h.
| enum ra8_usbhs_physet_bit_t : uint16_t |
PHYSET bit positions and masks (HUM Ch 37 "PHYSET" register).
Definition at line 378 of file ra8_usb_regs.h.
| enum ra8_usbhs_pllsta_bit_t : uint16_t |
PLLSTA bit positions (HUM Ch 37 "PLLSTA" register).
| Enumerator | |
|---|---|
| k_ra8_pllsta_plllock | b0 : PHY PLL locked flag. |
Definition at line 402 of file ra8_usb_regs.h.
|
inlinestatic |
Compile-time offset and size insurance for r_usb_regs_t.
Mirrors HUM Ch 36 / Ch 37 byte-for-byte. If any field drifts (a reserved gap is mis-sized, or a halfword-versus-word width slips), these assertions fire at compile time before any test runs – silent register-bank corruption (writing the wrong USB pipe, or stomping on the next peripheral) is avoided.
Both USB FS (HUM Ch 36, p 1965) and USB HS (HUM Ch 37, p 2059) share the same device-mode register layout in this window, so one set of offset assertions covers both controller instances.
Get pointer to the USB FS controller register block.
Definition at line 315 of file ra8_usb_regs.h.
References k_ra8_usb_fs0_base_addr.
Referenced by internal_ctrt_handle_valid(), internal_irq_complete_in(), internal_pick_regs(), priv_dvst_default_state(), priv_handle_ctrl_out_data(), priv_irq_dvst_prelude(), and priv_pick().
|
inlinestatic |
Get pointer to the USB HS controller register block.
Definition at line 322 of file ra8_usb_regs.h.
References k_ra8_usb_hs0_base_addr.
Referenced by demo_worker_capture_echo_probes(), intenb0_watchdog_entry(), internal_ack_spurious(), internal_ctrt_handle_valid(), internal_irq_complete_in(), internal_pick_regs(), priv_dvst_default_state(), priv_handle_ctrl_out_data(), priv_irq_dvst_prelude(), priv_is_hs(), priv_pick(), and ux_dcd_ra8_usb_initialize().
|
inlinestatic |
Get pointer to USBHS LPSTS register.
Definition at line 369 of file ra8_usb_regs.h.
References k_ra8_usb_hs0_base_addr, and k_ra8_usbhs_off_lpsts.
Referenced by demo_worker_capture_echo_probes(), priv_usbhs_phy_bringup(), ra8_usb_device_attach(), ra8_usb_device_init(), and ux_dcd_ra8_usb_initialize().
|
inlinestatic |
Get pointer to USBHS PHYSET register.
Definition at line 362 of file ra8_usb_regs.h.
References k_ra8_usb_hs0_base_addr, and k_ra8_usbhs_off_physet.
Referenced by priv_usbhs_phy_bringup().
|
inlinestatic |
Get pointer to USBHS PLLSTA register (read-only).
Definition at line 355 of file ra8_usb_regs.h.
References k_ra8_usb_hs0_base_addr, and k_ra8_usbhs_off_pllsta.
Referenced by internal_usbhs_wait_pll_lock_short().