From 4aada752496d89ea3e2ff504cfe3e4cb9093aa97 Mon Sep 17 00:00:00 2001 From: TimJTi <56726697+TimJTi@users.noreply.github.com> Date: Wed, 8 Feb 2023 17:23:04 +0000 Subject: [PATCH] Changes to allow board-specific DRP/OTG support Update sam_udphs.c --- arch/arm/src/sama5/Kconfig | 2 +- arch/arm/src/sama5/sam_ehci.c | 16 +++++++--------- arch/arm/src/sama5/sam_ohci.c | 16 +++++++--------- arch/arm/src/sama5/sam_udphs.c | 3 ++- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/arch/arm/src/sama5/Kconfig b/arch/arm/src/sama5/Kconfig index b0dfd1ba3b..ebe96de7ea 100644 --- a/arch/arm/src/sama5/Kconfig +++ b/arch/arm/src/sama5/Kconfig @@ -3827,7 +3827,7 @@ if SAMA5_OHCI || SAMA5_EHCI config SAMA5_UHPHS_RHPORT1 bool "Use Port A" default y - depends on !SAMA5_UDPHS + depends on !SAMA5_UDPHS || SAMA5_USB_DRP config SAMA5_UHPHS_RHPORT2 bool "Use Port B" diff --git a/arch/arm/src/sama5/sam_ehci.c b/arch/arm/src/sama5/sam_ehci.c index 9e4455b513..222a96f3eb 100644 --- a/arch/arm/src/sama5/sam_ehci.c +++ b/arch/arm/src/sama5/sam_ehci.c @@ -110,17 +110,15 @@ #undef CONFIG_USBHOST_ISOC_DISABLE #define CONFIG_USBHOST_ISOC_DISABLE 1 -/* If UDPHS is enabled, then don't use port A */ - -#ifdef CONFIG_SAMA5_UDPHS -# undef CONFIG_SAMA5_UHPHS_RHPORT1 -#endif - -/* For now, suppress use of PORTA in any event. I use that for SAM-BA and - * would prefer that the board not try to drive VBUS on that port! +/* Suppress use of PORTA unless board-specific dual-role-port support + * has been included. Generally port A is used as a device-only port, + * typically for SAM-BA and the possibility of enabling host VBUS power + * for this port would be a BAD idea */ -#undef CONFIG_SAMA5_UHPHS_RHPORT1 +#if defined(CONFIG_SAMA5_UDPHS) && !defined(CONFIG_SAMA5_USBA_DRP) +# undef CONFIG_SAMA5_UHPHS_RHPORT1 +#endif /* Driver-private Definitions ***********************************************/ diff --git a/arch/arm/src/sama5/sam_ohci.c b/arch/arm/src/sama5/sam_ohci.c index 72059b480a..631d851879 100644 --- a/arch/arm/src/sama5/sam_ohci.c +++ b/arch/arm/src/sama5/sam_ohci.c @@ -124,17 +124,15 @@ #define SAM_BUFALLOC (CONFIG_SAMA5_OHCI_TDBUFFERS * CONFIG_SAMA5_OHCI_TDBUFSIZE) -/* If UDPHS is enabled, then don't use port A */ - -#ifdef CONFIG_SAMA5_UDPHS -# undef CONFIG_SAMA5_UHPHS_RHPORT1 -#endif - -/* For now, suppress use of PORTA in any event. I use that for SAM-BA and - * would prefer that the board not try to drive VBUS on that port! +/* Suppress use of PORTA unless board-specific dual-role-port support + * has been included. Generally port A is used as a device-only port, + * typically for SAM-BA and the possibility of enabling host VBUS power + * for this port would be a BAD idea */ -#undef CONFIG_SAMA5_UHPHS_RHPORT1 +#if defined(CONFIG_SAMA5_UDPHS) && !defined(CONFIG_SAMA5_USBA_DRP) +# undef CONFIG_SAMA5_UHPHS_RHPORT1 +#endif /* Debug */ diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c index de8b318337..85f5ddaf2b 100644 --- a/arch/arm/src/sama5/sam_udphs.c +++ b/arch/arm/src/sama5/sam_udphs.c @@ -4055,6 +4055,7 @@ static int sam_selfpowered(struct usbdev_s *dev, bool selfpowered) static int sam_pullup(struct usbdev_s *dev, bool enable) { +#ifndef CONFIG_SAMA5_USB_DRP struct sam_usbdev_s *priv = (struct sam_usbdev_s *)dev; uint32_t regval; @@ -4102,7 +4103,7 @@ static int sam_pullup(struct usbdev_s *dev, bool enable) priv->devstate = UDPHS_DEVSTATE_POWERED; } } - +#endif /* CONFIG_SAMA5_USB_DRP */ return OK; }