32 if (
s_usb.setup_valid) {
42 s_usb.reg[w] = (uint16_t)(
s_usb.reg[w] | (uint16_t)(1U << bit));
121 return (uint16_t)(b->len - b->rd);
139 for (
unsigned i = 0U; (i < size) && (b->rd < b->len); i++) {
159 for (
unsigned i = 0U; (i < size) && (b->len < (uint16_t)
sizeof(b->data)); i++) {
217 switch ((uint16_t)off) {
231 return (uint16_t)0x0003U;
255 const uint16_t v16 = (uint16_t)value;
256 switch ((uint16_t)off) {
273 s_usb.setup_valid =
false;
282uint64_t
board_usb_read(uc_engine* uc, uint64_t addr,
unsigned size,
bool* handled)
297void board_usb_write(uc_engine* uc, uint64_t addr,
unsigned size, uint64_t value,
bool* handled)
304 const uint64_t off = addr - (uint64_t)
k_usb_base;
void board_usbhs_host_reg_write(uc_engine *uc, uint64_t off, unsigned size, uint64_t value)
Host-model register write by window byte offset (role routing).
uint64_t board_usbhs_host_reg_read(uc_engine *uc, uint64_t off, unsigned size)
Host-model register read by window byte offset (role routing).
void board_usb_roles_swap(uc_engine *uc)
Swap the self-loop window<->model bindings (enter Config B).
void priv_usb_reg_write(uint64_t off, uint32_t value, unsigned size)
Write one device-controller register; off is the byte offset into the window.
static uint8_t internal_cfifo_pipe(void)
Currently-selected CFIFO pipe number (CFIFOSEL.CURPIPE[3:0]).
void priv_usb_raise_irq(uc_engine *uc)
Raise the device controller interrupt (USBFS_INT, or USBHS after a role swap).
static usb_out_buf_t * internal_cfifo_out_buf(void)
The device-OUT staging buffer CFIFOSEL currently points at.
void board_usb_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value, bool *handled)
Dispatch an MMIO write inside the USBFS register window.
static uint32_t internal_cfifo_read_port(unsigned size)
Service a CFIFO data-port read: drain one unit (1..4 bytes) from the OUT buffer.
uint16_t priv_usb_intsts0(void)
INTSTS0 value the device reads: event bits OR computed fields.
static uint16_t internal_cfifoctr_read(void)
CFIFOCTR read value: FRDY always ready, DTLN = OUT bytes available.
static void internal_cfifo_write_port(uint32_t value, unsigned size)
Service a CFIFO data-port write: append one unit (1..4 bytes) to the IN buffer.
void priv_usb_intsts0_set(uint8_t bit)
Set an INTSTS0 event bit in the shadow (host asserts it).
static usb_in_buf_t * internal_cfifo_in_buf(void)
The device-IN staging buffer CFIFOSEL currently points at.
static bool internal_cfifo_is_in(void)
True when CFIFOSEL selects the IN direction (device writes / fills).
static uint16_t internal_cfifo_dtln(void)
Bytes still available for the device to read on the selected OUT buf.
uint64_t board_usb_read(uc_engine *uc, uint64_t addr, unsigned size, bool *handled)
Dispatch an MMIO read inside the USBFS register window.
static void internal_cfifoctr_write(uint16_t value)
Apply a CFIFOCTR write: BCLR clears the buffer, BVAL commits an IN.
uint32_t priv_usb_reg_read(uint64_t off, unsigned size)
Read one device-controller register; off is the byte offset into the window.
Module-private state + interfaces shared by the board_usb TUs.
bool s_external_host
Bridge host owns the bus (core).
usb_state_t s_usb
Controller + FIFO state (core).
@ k_usb_rhst_fs
Link settled at full speed after the bus reset.
@ k_usb_base
USBFS base (HUM Ch 36, p 1965).
@ k_usb_span
Modelled window (PIPECTR end < 0x90).
@ k_usb_pipe_count
DCP (0) + PIPE1..PIPE9.
uint32_t s_usb_irqs
USB interrupts raised (core).
@ k_usb_cfifo_hh
CFIFOHH alias offset from CFIFO (+0x3).
@ k_usb_cfifo_h
CFIFOH alias offset from CFIFO (+0x2).
@ k_usb_byte_mask
One-byte mask.
@ k_usb_byte_bits
Bits per byte.
static uint32_t internal_usb_word(uint64_t off)
Word index into the 16-bit register shadow for a window offset.
bool s_roles_swapped
Self-loop role polarity (core).
uint16_t g_dev_irq_event
Device ICU event number (core).
board_usb_irq_raiser_t s_raise
ICU pend callback (core).
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Event Link Controller (ELC) register layout for the Renesas RA8D2.
USB Full-Speed + High-Speed controller layout for the Renesas RA8D2.
@ k_ra8_syscfg_bit_dcfm
1 = host mode, 0 = device.
@ k_ra8_usb_off_syssts0
SYSSTS0 : System status 0.
@ k_ra8_usb_off_dvstctr0
DVSTCTR0 : Device state ctrl.
@ k_ra8_usb_off_cfifosel
CFIFOSEL : Control FIFO select.
@ k_ra8_usb_off_cfifo
CFIFO : Control FIFO port.
@ k_ra8_usb_off_intsts0
INTSTS0 : Interrupt Status 0.
@ k_ra8_usb_off_cfifoctr
CFIFOCTR : Control FIFO control.
@ k_ra8_usb_off_syscfg
SYSCFG : System config.
@ k_ra8_usb_off_frmnum
FRMNUM : Frame number.
@ k_ra8_fifoctr_frdy
FIFO ready.
@ k_ra8_fifoctr_bclr
Buffer clear.
@ k_ra8_fifoctr_dtln
Data length (write-bytes-rem).
@ k_ra8_fifoctr_bval
Buffer valid.
@ k_ra8_fifosel_isel
CFIFO direction (DCP only).
@ k_ra8_fifosel_curpipe
Current pipe select [3:0].
@ k_ra8_intsts0_mask_dvsq
Device state.
@ k_ra8_intsts0_mask_valid
SETUP packet detect flag.
@ k_ra8_intsts0_mask_vbsts
VBUS input port level.
@ k_ra8_intsts0_mask_ctsq
Control transfer stage.
@ 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_dvsq_powered
Powered (no reset yet).
One pipe's device-visible IN staging buffer (device -> host payload).
bool valid
BVAL pulsed: ready for the host.
One pipe's host-visible OUT staging buffer (host -> device payload).