[PATCH] usb: gadget: pxa25x: prevent ixp4xx + pxa25x combination

From: Arnd Bergmann

Date: Thu Sep 17 2026 - 12:15:34 EST


From: Arnd Bergmann <arnd@xxxxxxxx>

The USB gadget driver is one of the holdouts of Arm single-platform
support that conflicts with a multiplatform kernel. Trying to
build this for both Intel PXA and IXP fails with:

drivers/usb/gadget/udc/pxa25x_udc.c:144:9: error: 'UDCCS_IO_ROF' redefined [-Werror]
144 | #define UDCCS_IO_ROF (1 << 2) /* Receive overflow */
| ^~~~~~~~~~~~
drivers/usb/gadget/udc/pxa25x_udc.c:141:9: note: this is the location of the previous definition
141 | #define UDCCS_IO_ROF (1 << 3) /* Receive overflow */
| ^~~~~~~~~~~~
drivers/usb/gadget/udc/pxa25x_udc.c:232:2: error: #error "Can't configure both IXP and PXA"
232 | #error "Can't configure both IXP and PXA"

Until recently this was not a problem, as ixp4xx was only big-endian
and pxa is only little-endian, so these could never be in the same
kernel image.

As this has changed recently, an allmodconfig kernel for ARMv5 runs
into the above failure. I don't think this is an important scenario
in practice, especially as pxa25x support is already rather broken,
so prevent this configuration using a Kconfig dependency, and
rework the driver to allow a combined ixp4xx/pxa3xx kernel that
only uses this driver on ixp.

Cc: Linus Walleij <linusw@xxxxxxxxxx>
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
drivers/usb/gadget/udc/Kconfig | 1 +
drivers/usb/gadget/udc/pxa25x_udc.c | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
index 7ddbc2606686..5142f70b6f3a 100644
--- a/drivers/usb/gadget/udc/Kconfig
+++ b/drivers/usb/gadget/udc/Kconfig
@@ -126,6 +126,7 @@ config USB_OMAP
config USB_PXA25X
tristate "PXA 25x or IXP 4xx"
depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX
+ depends on !(PXA25x && ARCH_IXP4XX)
depends on HAS_IOMEM
help
Intel's PXA 25x series XScale ARM-5TE processors include
diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c
index 594d67193763..7e158ca73fa1 100644
--- a/drivers/usb/gadget/udc/pxa25x_udc.c
+++ b/drivers/usb/gadget/udc/pxa25x_udc.c
@@ -140,7 +140,7 @@
#ifdef CONFIG_ARCH_IXP4XX /* FIXME: is this right?, datasheed says '2' */
#define UDCCS_IO_ROF (1 << 3) /* Receive overflow */
#endif
-#ifdef CONFIG_ARCH_PXA
+#ifdef CONFIG_PXA25x
#define UDCCS_IO_ROF (1 << 2) /* Receive overflow */
#endif
#define UDCCS_IO_DME (1 << 3) /* DMA enable */
@@ -228,7 +228,7 @@ static const char ep0name [] = "ep0";
#ifdef CONFIG_ARCH_IXP4XX

/* cpu-specific register addresses are compiled in to this code */
-#ifdef CONFIG_ARCH_PXA
+#ifdef CONFIG_PXA25x
#error "Can't configure both IXP and PXA"
#endif

@@ -2230,7 +2230,7 @@ static struct pxa25x_udc memory = {

#define CP15R0_VENDOR_MASK 0xffffe000

-#if defined(CONFIG_ARCH_PXA)
+#if defined(CONFIG_PXA25x)
#define CP15R0_XSCALE_VALUE 0x69052000 /* intel/arm/xscale */

#elif defined(CONFIG_ARCH_IXP4XX)
@@ -2282,7 +2282,7 @@ static int pxa25x_udc_probe(struct platform_device *pdev)

/* trigger chiprev-specific logic */
switch (chiprev & CP15R0_PRODREV_MASK) {
-#if defined(CONFIG_ARCH_PXA)
+#if defined(CONFIG_PXA25x)
case PXA255_A0:
dev->has_cfr = 1;
break;
--
2.53.0