diff --git a/arch/arm/src/sama5/sam_ohci.c b/arch/arm/src/sama5/sam_ohci.c index 040163a9cc4..40ff3dea096 100644 --- a/arch/arm/src/sama5/sam_ohci.c +++ b/arch/arm/src/sama5/sam_ohci.c @@ -63,7 +63,7 @@ #include "chip.h" #include "sam_periphclks.h" -#include "sam_ohci.h" +#include "sam_usbhost.h" #include "chip/sam_pmc.h" #include "chip/sam_sfr.h" #include "chip/sam_ohci.h" @@ -333,7 +333,7 @@ static int sam_ctrltd(struct sam_ohci_s *priv, uint32_t dirpid, /* Interrupt handling **********************************************************/ -static int sam_usbinterrupt(int irq, FAR void *context); +static int sam_ohci_interrupt(int irq, FAR void *context); /* USB host controller operations **********************************************/ @@ -1326,14 +1326,14 @@ static int sam_ctrltd(struct sam_ohci_s *priv, uint32_t dirpid, uint8_t *buffer, } /******************************************************************************* - * Name: sam_usbinterrupt + * Name: sam_ohci_interrupt * * Description: * USB interrupt handler * *******************************************************************************/ -static int sam_usbinterrupt(int irq, FAR void *context) +static int sam_ohci_interrupt(int irq, FAR void *context) { struct sam_ohci_s *priv = &g_usbhost; uint32_t intst; @@ -2409,7 +2409,7 @@ static inline void sam_ep0init(struct sam_ohci_s *priv) * Initialize USB OHCI host controller hardware. * * Input Parameters: - * controller -- If the device supports more than USB host controller, then + * controller -- If the device supports more than one OHCI interface, then * this identifies which controller is being intialized. Normally, this * is just zero. * @@ -2572,7 +2572,7 @@ FAR struct usbhost_driver_s *sam_ohci_initialize(int controller) /* Attach USB host controller interrupt handler */ - if (irq_attach(SAM_IRQ_UHPHS, sam_usbinterrupt) != 0) + if (irq_attach(SAM_IRQ_UHPHS, sam_ohci_interrupt) != 0) { udbg("Failed to attach IRQ\n"); return NULL; @@ -2586,6 +2586,12 @@ FAR struct usbhost_driver_s *sam_ohci_initialize(int controller) regval = sam_getreg(SAM_USBHOST_RHPORTST1); priv->connected = ((regval & OHCI_RHPORTST_CCS) != 0); + /* Drive Vbus +5V (the smoke test). Should be done elsewhere in OTG + * mode. + */ + + sam_usbhost_vbusdrive(SAM_OHCI_IFACE, true); + /* Enable interrupts at the interrupt controller */ up_enable_irq(SAM_IRQ_UHPHS); /* enable USB interrupt */ diff --git a/arch/arm/src/sama5/sam_ohci.h b/arch/arm/src/sama5/sam_usbhost.h similarity index 65% rename from arch/arm/src/sama5/sam_ohci.h rename to arch/arm/src/sama5/sam_usbhost.h index fc7713576ae..c64664daf0f 100644 --- a/arch/arm/src/sama5/sam_ohci.h +++ b/arch/arm/src/sama5/sam_usbhost.h @@ -1,5 +1,5 @@ /************************************************************************************ - * arch/arm/src/lpc17xx/lpc17_usbhost.h + * arch/arm/src/sama5/sam_usbhost.h * * Copyright (C) 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -33,8 +33,8 @@ * ************************************************************************************/ -#ifndef __ARCH_ARM_SRC_LPC17XX_LPC17_USBHOST_H -#define __ARCH_ARM_SRC_LPC17XX_LPC17_USBHOST_H +#ifndef __ARCH_ARM_SRC_SAMA5_SAM_USBHOST_H +#define __ARCH_ARM_SRC_SAMA5_SAM_USBHOST_H /************************************************************************************ * Included Files @@ -42,9 +42,17 @@ #include +#ifdef CONFIG_USBHOST + /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ +/* This is the interface argument for call outs to board-specific functions which + * need to know which USB host interface is being used. + */ + +#define SAM_EHCI_IFACE 0 +#define SAM_OHCI_IFACE 1 /************************************************************************************ * Public Types @@ -80,7 +88,7 @@ extern "C" * Initialize USB OHCI host controller hardware. * * Input Parameters: - * controller -- If the device supports more than USB host controller, then + * controller -- If the device supports more than one USB OHCI interface, then * this identifies which controller is being intialized. Normally, this * is just zero. * @@ -98,15 +106,66 @@ extern "C" * *******************************************************************************/ -#ifdef CONFIG_USBHOST +#ifdef CONFIG_SAMA5_OHCI struct usbhost_driver_s; FAR struct usbhost_driver_s *sam_ohci_initialize(int controller); #endif +/******************************************************************************* + * Name: sam_ehci_initialize + * + * Description: + * Initialize USB EHCI host controller hardware. + * + * Input Parameters: + * controller -- If the device supports more than one EHCI interface, then + * this identifies which controller is being intialized. Normally, this + * is just zero. + * + * Returned Value: + * And instance of the USB host interface. The controlling task should + * use this interface to (1) call the wait() method to wait for a device + * to be connected, and (2) call the enumerate() method to bind the device + * to a class driver. + * + * Assumptions: + * - This function should called in the initialization sequence in order + * to initialize the USB device functionality. + * - Class drivers should be initialized prior to calling this function. + * Otherwise, there is a race condition if the device is already connected. + * + *******************************************************************************/ + +#ifdef CONFIG_SAMA5_EHCI +struct usbhost_driver_s; +FAR struct usbhost_driver_s *sam_ehci_initialize(int controller); +#endif + +/*********************************************************************************** + * Name: sam_usbhost_vbusdrive + * + * Description: + * Enable/disable driving of VBUS 5V output. This function must be provided by + * each platform that implements the OHCI or EHCI host interface + * + * Input Parameters: + * iface - Selects USB host interface: + * 0 = EHCI + * 1 = OHCI + * enable - true: enable VBUS power; false: disable VBUS power + * + * Returned Value: + * None + * + ***********************************************************************************/ + +void sam_usbhost_vbusdrive(int iface, bool enable); + #undef EXTERN #if defined(__cplusplus) } #endif #endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_SRC_LPC17XX_LPC17_USBHOST_H */ +#endif /* CONFIG_USBHOST */ +#endif /* __ARCH_ARM_SRC_SAMA5_SAM_USBHOST_H */