From 76ee9cf35cff371cb1e8ddb5142ee4c624ef1cd2 Mon Sep 17 00:00:00 2001 From: Gernot Walser Date: Wed, 15 Jul 2026 08:38:05 +0200 Subject: [PATCH 1/2] renesas/rusb2: add support for RA MCUs with USBFS device-only support Renesas RA MCUs with with usb device-only support have a different hardware implementation, which has already been implemented for RA2A1 and also works for others like RA4E2. This introduces define RUSB2_RA_USBFS_DEVICE_ONLY for MCUs with this implementation and sets correct pipe allocation and FIFO register aliases for all supported MCUs instead of RA2A1 only. Tested on RA4E2 with HID Gamepad Device. --- src/portable/renesas/rusb2/dcd_rusb2.c | 6 +++--- src/portable/renesas/rusb2/hcd_rusb2.c | 4 ++++ src/portable/renesas/rusb2/rusb2_common.h | 4 ++-- src/portable/renesas/rusb2/rusb2_ra.h | 4 ++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/portable/renesas/rusb2/dcd_rusb2.c b/src/portable/renesas/rusb2/dcd_rusb2.c index f0ef9738b9..cfc65e6824 100644 --- a/src/portable/renesas/rusb2/dcd_rusb2.c +++ b/src/portable/renesas/rusb2/dcd_rusb2.c @@ -51,10 +51,10 @@ static dcd_data_t _dcd; // - Pipes 3 to 5: Bulk // - Pipes 6 to 9: Interrupt // -// Note: for small mcu such as -// - RA2A1: only pipe 4-7 are available, and no support for ISO +// Note: for small mcu which only support device mode +// only pipe 4-7 are available, and no support for ISO static unsigned find_pipe(unsigned xfer_type) { - #if defined(BSP_MCU_GROUP_RA2A1) + #ifdef RUSB2_RA_USBFS_DEVICE_ONLY const uint8_t pipe_idx_arr[4][2] = { { 0, 0 }, // Control { 0, 0 }, // Isochronous not supported diff --git a/src/portable/renesas/rusb2/hcd_rusb2.c b/src/portable/renesas/rusb2/hcd_rusb2.c index 849551d278..e4a7b970bc 100644 --- a/src/portable/renesas/rusb2/hcd_rusb2.c +++ b/src/portable/renesas/rusb2/hcd_rusb2.c @@ -11,6 +11,10 @@ #if CFG_TUH_ENABLED && defined(TUP_USBIP_RUSB2) +#ifdef RUSB RUSB2_RA_USBFS_DEVICE_ONLY +#error "Host mode not supported for this device" +#endif + #include "host/hcd.h" #include "host/usbh.h" #include "rusb2_common.h" diff --git a/src/portable/renesas/rusb2/rusb2_common.h b/src/portable/renesas/rusb2/rusb2_common.h index 90abdf4b95..7d7cb3b5f1 100644 --- a/src/portable/renesas/rusb2/rusb2_common.h +++ b/src/portable/renesas/rusb2/rusb2_common.h @@ -14,8 +14,8 @@ #elif TU_CHECK_MCU(OPT_MCU_RAXXX) #include "rusb2_ra.h" - // Hack for D0FIFO definitions on RA Cortex-M23 - #if defined(RENESAS_CORTEX_M23) + // Hack for D0FIFO definitions on RA with usb device support only + #ifdef RUSB2_RA_USBFS_DEVICE_ONLY #define D0FIFO CFIFO #define D0FIFOSEL CFIFOSEL #define D0FIFOSEL_b CFIFOSEL_b diff --git a/src/portable/renesas/rusb2/rusb2_ra.h b/src/portable/renesas/rusb2/rusb2_ra.h index e5945ffe21..48e7233e66 100644 --- a/src/portable/renesas/rusb2/rusb2_ra.h +++ b/src/portable/renesas/rusb2/rusb2_ra.h @@ -38,6 +38,10 @@ extern "C" { // //--------------------------------------------------------------------+ +#if defined(BSP_MCU_GROUP_RA2A1) || defined(BSP_MCU_GROUP_RA2L2) || defined(BSP_MCU_GROUP_RA4E2) || defined(BSP_MCU_GROUP_RA6E2) || defined(BSP_MCU_GROUP_RA6T3) +#define RUSB2_RA_USBFS_DEVICE_ONLY +#endif + typedef struct { uint32_t reg_base; int32_t irqnum; From 2b5b3ed686a049e8a80356c5fdce70fc2227d612 Mon Sep 17 00:00:00 2001 From: Gernot Walser Date: Wed, 15 Jul 2026 17:24:48 +0200 Subject: [PATCH 2/2] Fixed typo in host driver static assertion --- src/portable/renesas/rusb2/hcd_rusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/portable/renesas/rusb2/hcd_rusb2.c b/src/portable/renesas/rusb2/hcd_rusb2.c index e4a7b970bc..b5e51e2c4b 100644 --- a/src/portable/renesas/rusb2/hcd_rusb2.c +++ b/src/portable/renesas/rusb2/hcd_rusb2.c @@ -11,7 +11,7 @@ #if CFG_TUH_ENABLED && defined(TUP_USBIP_RUSB2) -#ifdef RUSB RUSB2_RA_USBFS_DEVICE_ONLY +#ifdef RUSB2_RA_USBFS_DEVICE_ONLY #error "Host mode not supported for this device" #endif