Separate wait() and enumerate() methods from struct usbhost_driver_s and move to new interface, struct usbhost_connection_s. This is part of the necessary restructuring of the USB host interface to support multiple root hub ports.

This commit is contained in:
Gregory Nutt
2013-08-13 15:03:46 -06:00
parent a65ac5bc72
commit 1700d06d89
21 changed files with 169 additions and 133 deletions
+5 -1
View File
@@ -5391,4 +5391,8 @@
in up_putc(). I think all architectures have this re-entrancy in up_putc(). I think all architectures have this re-entrancy
than can result in serial interrupt being disabled, but I have only than can result in serial interrupt being disabled, but I have only
seen the symptom on SAMA5 (2013-8-13). seen the symptom on SAMA5 (2013-8-13).
* includes/nuttx/usb/usbhost.h and many other affected files: Separate
wait() and enumerate() methods from struct usbhost_driver_s and move
to new interface, struct usbhost_connection_s. This is part of the
necessary restructuring of the USB host interface to support multiple
root hub ports (2013-8-13).
+8 -6
View File
@@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec"> <h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i> <i>NuttX RTOS Porting Guide</i>
</font></big></h1> </font></big></h1>
<p>Last Updated: August 12, 2013</p> <p>Last Updated: August 13, 2013</p>
</td> </td>
</tr> </tr>
</table> </table>
@@ -3426,9 +3426,11 @@ extern void up_ledoff(int led);
</li> </li>
<li> <li>
<p> <p>
<b><code>struct usbhost_driver_s</code></b>. <b><code>struct usbhost_driver_s</code> and <code>struct usbhost_connection_s</code></b>.
Each USB host controller driver must implement an instance of <code>struct usbhost_driver_s</code>. Each USB host controller driver must implement an instance of <code>struct usbhost_driver_s</code> and <code>struct usbhost_connection_s</code>:
This structure is defined in <code>include/nuttx/usb/usbhost.h</code>. <code>struct usbhost_driver_s</code> provides the interface between the USB host driver and the USB class driver;
<code>struct usbhost_connection_s</code> provides the interface between the USB host driver and platform-specific connection management and device enumeration logoc.
These structures are defined in <code>include/nuttx/usb/usbhost.h</code>.
</p> </p>
<p> <p>
<b>Examples</b>: <b>Examples</b>:
@@ -3471,7 +3473,7 @@ extern void up_ledoff(int led);
<ul> <ul>
<li> <li>
<p> <p>
<code>int (*wait)(FAR struct usbhost_driver_s *drvr, FAR const bool *connected);</code> <code>int (*wait)(FAR struct usbhost_connection_s *drvr, FAR const bool *connected);</code>
</p> </p>
<p> <p>
Wait for a device to be connected or disconnected. Wait for a device to be connected or disconnected.
@@ -3479,7 +3481,7 @@ extern void up_ledoff(int led);
</li> </li>
<li> <li>
<p> <p>
<code>int (*enumerate)(FAR struct usbhost_driver_s *drvr, int rhpndx);</code> <code>int (*enumerate)(FAR struct usbhost_connection_s *drvr, int rhpndx);</code>
</p> </p>
<p> <p>
Enumerate the device connected to a root hub port. Enumerate the device connected to a root hub port.
+21 -14
View File
@@ -294,8 +294,9 @@ static int lpc17_usbinterrupt(int irq, FAR void *context);
/* USB host controller operations **********************************************/ /* USB host controller operations **********************************************/
static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected); static int lpc17_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected);
static int lpc17_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx); static int lpc17_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx);
static int lpc17_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, static int lpc17_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
uint16_t maxpacketsize); uint16_t maxpacketsize);
static int lpc17_epalloc(FAR struct usbhost_driver_s *drvr, static int lpc17_epalloc(FAR struct usbhost_driver_s *drvr,
@@ -334,8 +335,6 @@ static struct lpc17_usbhost_s g_usbhost =
{ {
.drvr = .drvr =
{ {
.wait = lpc17_wait,
.enumerate = lpc17_enumerate,
.ep0configure = lpc17_ep0configure, .ep0configure = lpc17_ep0configure,
.epalloc = lpc17_epalloc, .epalloc = lpc17_epalloc,
.epfree = lpc17_epfree, .epfree = lpc17_epfree,
@@ -351,6 +350,14 @@ static struct lpc17_usbhost_s g_usbhost =
.class = NULL, .class = NULL,
}; };
/* This is the connection/enumeration interact */
static struct usbhost_connection_s g_usbconn =
{
.wait = lpc17_wait,
.enumerate = lpc17_enumerate,
};
/* This is a free list of EDs and TD buffers */ /* This is a free list of EDs and TD buffers */
static struct lpc17_list_s *g_edfree; /* List of unused EDs */ static struct lpc17_list_s *g_edfree; /* List of unused EDs */
@@ -1516,8 +1523,8 @@ static int lpc17_usbinterrupt(int irq, FAR void *context)
* Wait for a device to be connected or disconneced. * Wait for a device to be connected or disconneced.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to * conn - The USB host connection instance obtained as a parameter from the call to
* the class create() method. * the USB driver initialization logic.
* connected - A pointer to a boolean value: TRUE: Wait for device to be * connected - A pointer to a boolean value: TRUE: Wait for device to be
* connected; FALSE: wait for device to be disconnected * connected; FALSE: wait for device to be disconnected
* *
@@ -1533,9 +1540,9 @@ static int lpc17_usbinterrupt(int irq, FAR void *context)
* *
*******************************************************************************/ *******************************************************************************/
static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected) static int lpc17_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected)
{ {
struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)drvr; struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)&g_usbhost;
irqstate_t flags; irqstate_t flags;
/* Are we already connected? */ /* Are we already connected? */
@@ -1569,8 +1576,8 @@ static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
* charge of the sequence of operations. * charge of the sequence of operations.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to * conn - The USB host connection instance obtained as a parameter from the call to
* the class create() method. * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n. * rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
* *
* Returned Values: * Returned Values:
@@ -1584,9 +1591,9 @@ static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
* *
*******************************************************************************/ *******************************************************************************/
static int lpc17_enumerate(FAR struct usbhost_driver_s *drvr, int rphndx) static int lpc17_enumerate(FAR struct usbhost_connection_s *conn, int rphndx)
{ {
struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)drvr; struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)&g_usbhost;
DEBUGASSERT(priv && rhpndx == 0); DEBUGASSERT(priv && rhpndx == 0);
/* Are we connected to a device? The caller should have called the wait() /* Are we connected to a device? The caller should have called the wait()
@@ -2479,7 +2486,7 @@ static inline void lpc17_ep0init(struct lpc17_usbhost_s *priv)
* *
*******************************************************************************/ *******************************************************************************/
FAR struct usbhost_driver_s *usbhost_initialize(int controller) FAR struct usbhost_connection_s *usbhost_initialize(int controller)
{ {
struct lpc17_usbhost_s *priv = &g_usbhost; struct lpc17_usbhost_s *priv = &g_usbhost;
uint32_t regval; uint32_t regval;
@@ -2707,5 +2714,5 @@ FAR struct usbhost_driver_s *usbhost_initialize(int controller)
udbg("USB host Initialized, Device connected:%s\n", udbg("USB host Initialized, Device connected:%s\n",
priv->connected ? "YES" : "NO"); priv->connected ? "YES" : "NO");
return &priv->drvr; return &g_usbconn;
} }
+2 -2
View File
@@ -93,8 +93,8 @@ extern "C"
*******************************************************************************/ *******************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
struct usbhost_driver_s; struct usbhost_connection_s;
FAR struct usbhost_driver_s *usbhost_initialize(int controller); FAR struct usbhost_connection_s *usbhost_initialize(int controller);
#endif #endif
#undef EXTERN #undef EXTERN
+21 -13
View File
@@ -351,8 +351,9 @@ static int sam_ohci_interrupt(int irq, FAR void *context);
/* USB host controller operations **********************************************/ /* USB host controller operations **********************************************/
static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected); static int sam_wait(FAR struct usbhost_connection_s *conn, FAR const bool *connected);
static int sam_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx); static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx);
static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
uint16_t maxpacketsize); uint16_t maxpacketsize);
static int sam_epalloc(FAR struct usbhost_driver_s *drvr, static int sam_epalloc(FAR struct usbhost_driver_s *drvr,
@@ -391,8 +392,6 @@ static struct sam_ohci_s g_usbhost =
{ {
.drvr = .drvr =
{ {
.wait = sam_wait,
.enumerate = sam_enumerate,
.ep0configure = sam_ep0configure, .ep0configure = sam_ep0configure,
.epalloc = sam_epalloc, .epalloc = sam_epalloc,
.epfree = sam_epfree, .epfree = sam_epfree,
@@ -407,6 +406,14 @@ static struct sam_ohci_s g_usbhost =
}, },
}; };
/* This is the connection/enumeration interact */
static struct usbhost_connection_s g_usbconn =
{
.wait = sam_wait,
.enumerate = sam_enumerate,
};
/* This is a free list of EDs and TD buffers */ /* This is a free list of EDs and TD buffers */
static struct sam_list_s *g_edfree; /* List of unused EDs */ static struct sam_list_s *g_edfree; /* List of unused EDs */
@@ -1630,8 +1637,8 @@ static int sam_ohci_interrupt(int irq, FAR void *context)
* Wait for a device to be connected or disconnected to/from a root hub port. * Wait for a device to be connected or disconnected to/from a root hub port.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call * conn - The USB host connection instance obtained as a parameter from the call to
* to the class create() method. * the USB driver initialization logic.
* connected - A pointer to an array of 3 boolean values corresponding to * connected - A pointer to an array of 3 boolean values corresponding to
* root hubs 1, 2, and 3. For each boolean value: TRUE: Wait for a device * root hubs 1, 2, and 3. For each boolean value: TRUE: Wait for a device
* to be connected on the root hub; FALSE: wait for device to be * to be connected on the root hub; FALSE: wait for device to be
@@ -1651,9 +1658,10 @@ static int sam_ohci_interrupt(int irq, FAR void *context)
* *
*******************************************************************************/ *******************************************************************************/
static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected) static int sam_wait(FAR struct usbhost_connection_s *conn,
FAR const bool *connected)
{ {
struct sam_ohci_s *priv = (struct sam_ohci_s *)drvr; struct sam_ohci_s *priv = &g_usbhost;
irqstate_t flags; irqstate_t flags;
int rhpndx; int rhpndx;
@@ -1707,8 +1715,8 @@ static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected
* charge of the sequence of operations. * charge of the sequence of operations.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to * conn - The USB host connection instance obtained as a parameter from the call to
* the class create() method. * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n. * rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
* *
* Returned Values: * Returned Values:
@@ -1722,9 +1730,9 @@ static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected
* *
*******************************************************************************/ *******************************************************************************/
static int sam_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx) static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx)
{ {
struct sam_ohci_s *priv = (struct sam_ohci_s *)drvr; struct sam_ohci_s *priv = &g_usbhost;
struct sam_rhport_s *rhport; struct sam_rhport_s *rhport;
uint32_t regaddr; uint32_t regaddr;
@@ -2734,5 +2742,5 @@ FAR struct usbhost_driver_s *sam_ohci_initialize(int controller)
up_enable_irq(SAM_IRQ_UHPHS); /* enable USB interrupt */ up_enable_irq(SAM_IRQ_UHPHS); /* enable USB interrupt */
uvdbg("USB OHCI Initialized\n"); uvdbg("USB OHCI Initialized\n");
return &priv->drvr; return &g_usbconn;
} }
+2 -2
View File
@@ -107,8 +107,8 @@ extern "C"
*******************************************************************************/ *******************************************************************************/
#ifdef CONFIG_SAMA5_OHCI #ifdef CONFIG_SAMA5_OHCI
struct usbhost_driver_s; struct usbhost_connection_s;
FAR struct usbhost_driver_s *sam_ohci_initialize(int controller); FAR struct usbhost_connection_s *sam_ohci_initialize(int controller);
#endif #endif
/******************************************************************************* /*******************************************************************************
+2 -2
View File
@@ -99,8 +99,8 @@ extern "C"
*******************************************************************************/ *******************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
struct usbhost_driver_s; struct usbhost_connection_s;
FAR struct usbhost_driver_s *stm32_otgfshost_initialize(int controller); FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller);
#endif #endif
/************************************************************************************ /************************************************************************************
+21 -14
View File
@@ -358,8 +358,9 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx);
/* USB host controller operations **********************************************/ /* USB host controller operations **********************************************/
static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected); static int stm32_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected);
static int stm32_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx); static int stm32_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx);
static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
uint16_t maxpacketsize); uint16_t maxpacketsize);
static int stm32_epalloc(FAR struct usbhost_driver_s *drvr, static int stm32_epalloc(FAR struct usbhost_driver_s *drvr,
@@ -406,8 +407,6 @@ static struct stm32_usbhost_s g_usbhost =
{ {
.drvr = .drvr =
{ {
.wait = stm32_wait,
.enumerate = stm32_enumerate,
.ep0configure = stm32_ep0configure, .ep0configure = stm32_ep0configure,
.epalloc = stm32_epalloc, .epalloc = stm32_epalloc,
.epfree = stm32_epfree, .epfree = stm32_epfree,
@@ -423,6 +422,14 @@ static struct stm32_usbhost_s g_usbhost =
.class = NULL, .class = NULL,
}; };
/* This is the connection/enumeration interact */
static struct usbhost_connection_s g_usbconn =
{
.wait = stm32_wait,
.enumerate = stm32_enumerate,
};
/******************************************************************************* /*******************************************************************************
* Public Data * Public Data
*******************************************************************************/ *******************************************************************************/
@@ -3011,8 +3018,8 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx)
* Wait for a device to be connected or disconneced. * Wait for a device to be connected or disconneced.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to * conn - The USB host connection instance obtained as a parameter from the call to
* the class create() method. * the USB driver initialization logic.
* connected - A pointer to a boolean value. TRUE: Wait for device to be * connected - A pointer to a boolean value. TRUE: Wait for device to be
* connected; FALSE: wait for device to be disconnected * connected; FALSE: wait for device to be disconnected
* *
@@ -3028,9 +3035,9 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx)
* *
*******************************************************************************/ *******************************************************************************/
static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected) static int stm32_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected)
{ {
FAR struct stm32_usbhost_s *priv = (FAR struct stm32_usbhost_s *)drvr; FAR struct stm32_usbhost_s *priv = &g_usbhost;
irqstate_t flags; irqstate_t flags;
/* Are we already connected? */ /* Are we already connected? */
@@ -3064,8 +3071,8 @@ static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
* charge of the sequence of operations. * charge of the sequence of operations.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to * conn - The USB host connection instance obtained as a parameter from the call to
* the class create() method. * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n. * rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
* *
* Returned Values: * Returned Values:
@@ -3079,9 +3086,9 @@ static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
* *
*******************************************************************************/ *******************************************************************************/
static int stm32_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx) static int stm32_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx)
{ {
struct stm32_usbhost_s *priv = (struct stm32_usbhost_s *)drvr; FAR struct stm32_usbhost_s *priv = &g_usbhost;
uint32_t regval; uint32_t regval;
int chidx; int chidx;
int ret; int ret;
@@ -4222,7 +4229,7 @@ static inline int stm32_hw_initialize(FAR struct stm32_usbhost_s *priv)
* *
*******************************************************************************/ *******************************************************************************/
FAR struct usbhost_driver_s *stm32_otgfshost_initialize(int controller) FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller)
{ {
/* At present, there is only support for a single OTG FS host. Hence it is /* At present, there is only support for a single OTG FS host. Hence it is
* pre-allocated as g_usbhost. However, in most code, the private data * pre-allocated as g_usbhost. However, in most code, the private data
@@ -4296,7 +4303,7 @@ FAR struct usbhost_driver_s *stm32_otgfshost_initialize(int controller)
/* Enable interrupts at the interrupt controller */ /* Enable interrupts at the interrupt controller */
up_enable_irq(STM32_IRQ_OTGFS); up_enable_irq(STM32_IRQ_OTGFS);
return &priv->drvr; return &g_usbconn;
} }
#endif /* CONFIG_USBHOST && CONFIG_STM32_OTGFS */ #endif /* CONFIG_USBHOST && CONFIG_STM32_OTGFS */
+5 -5
View File
@@ -83,7 +83,7 @@
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -109,7 +109,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -121,7 +121,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -187,8 +187,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n"); uvdbg("Initialize USB host\n");
g_drvr = stm32_otgfshost_initialize(0); g_usbconn = stm32_otgfshost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -82,7 +82,7 @@
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n"); uvdbg("Initialize USB host\n");
g_drvr = stm32_otgfshost_initialize(0); g_usbconn = stm32_otgfshost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -143,7 +143,7 @@
****************************************************************************/ ****************************************************************************/
#ifdef NSH_HAVEUSBHOST #ifdef NSH_HAVEUSBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -169,7 +169,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -181,7 +181,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -279,8 +279,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n"); message("nsh_usbhostinitialize: Initialize USB host\n");
g_drvr = usbhost_initialize(0); g_usbconn = usbhost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -164,7 +164,7 @@
****************************************************************************/ ****************************************************************************/
#ifdef NSH_HAVE_USBHOST #ifdef NSH_HAVE_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
#ifdef NSH_HAVE_MMCSD #ifdef NSH_HAVE_MMCSD
static FAR struct sdio_dev_s *g_sdiodev; static FAR struct sdio_dev_s *g_sdiodev;
@@ -193,7 +193,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -205,7 +205,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -336,8 +336,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n"); message("nsh_usbhostinitialize: Initialize USB host\n");
g_drvr = usbhost_initialize(0); g_usbconn = usbhost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -171,7 +171,7 @@
****************************************************************************/ ****************************************************************************/
#ifdef NSH_HAVEUSBHOST #ifdef NSH_HAVEUSBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -197,7 +197,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -209,7 +209,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -300,8 +300,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n"); message("nsh_usbhostinitialize: Initialize USB host\n");
g_drvr = usbhost_initialize(0); g_usbconn = usbhost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -170,7 +170,7 @@
****************************************************************************/ ****************************************************************************/
#ifdef NSH_HAVEUSBHOST #ifdef NSH_HAVEUSBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -196,7 +196,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -208,7 +208,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -308,8 +308,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n"); message("nsh_usbhostinitialize: Initialize USB host\n");
g_drvr = usbhost_initialize(0); g_usbconn = usbhost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+11 -11
View File
@@ -77,10 +77,10 @@
/* Retained device driver handles */ /* Retained device driver handles */
#ifdef CONFIG_SAMA5_OHCI #ifdef CONFIG_SAMA5_OHCI
static struct usbhost_driver_s *g_ohci; static struct usbhost_connection_s *g_ohciconn;
#endif #endif
#ifdef CONFIG_SAMA5_EHCI #ifdef CONFIG_SAMA5_EHCI
static struct usbhost_driver_s *g_ehci; static struct usbhost_connection_s *g_ehciconn;
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -96,7 +96,7 @@ static struct usbhost_driver_s *g_ehci;
************************************************************************************/ ************************************************************************************/
#if HAVE_USBHOST #if HAVE_USBHOST
static int usbhost_waiter(struct usbhost_driver_s *dev) static int usbhost_waiter(struct usbhost_connection_s *dev)
{ {
bool connected[SAM_USBHOST_NRHPORT] = {false, false, false}; bool connected[SAM_USBHOST_NRHPORT] = {false, false, false};
int rhpndx; int rhpndx;
@@ -106,7 +106,7 @@ static int usbhost_waiter(struct usbhost_driver_s *dev)
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
rhpndx = DRVR_WAIT(dev, connected); rhpndx = CONN_WAIT(dev, connected);
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_USBHOST_NRHPORT); DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_USBHOST_NRHPORT);
connected[rhpndx] = !connected[rhpndx]; connected[rhpndx] = !connected[rhpndx];
@@ -120,7 +120,7 @@ static int usbhost_waiter(struct usbhost_driver_s *dev)
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(dev, rhpndx); (void)CONN_ENUMERATE(dev, rhpndx);
} }
} }
@@ -141,7 +141,7 @@ static int usbhost_waiter(struct usbhost_driver_s *dev)
#ifdef CONFIG_SAMA5_OHCI #ifdef CONFIG_SAMA5_OHCI
static int ohci_waiter(int argc, char *argv[]) static int ohci_waiter(int argc, char *argv[])
{ {
return usbhost_waiter(g_ohci); return usbhost_waiter(g_ohciconn);
} }
#endif #endif
@@ -156,7 +156,7 @@ static int ohci_waiter(int argc, char *argv[])
#ifdef CONFIG_SAMA5_EHCI #ifdef CONFIG_SAMA5_EHCI
static int ehci_waiter(int argc, char *argv[]) static int ehci_waiter(int argc, char *argv[])
{ {
return usbhost_waiter(g_ehci); return usbhost_waiter(g_ehciconn);
} }
#endif #endif
@@ -287,8 +287,8 @@ int sam_usbhost_initialize(void)
#ifdef CONFIG_SAMA5_OHCI #ifdef CONFIG_SAMA5_OHCI
/* Get an instance of the USB OHCI interface */ /* Get an instance of the USB OHCI interface */
g_ohci = sam_ohci_initialize(0); g_ohciconn = sam_ohci_initialize(0);
if (!g_ohci) if (!g_ohciconn)
{ {
udbg("ERROR: sam_ohci_initialize failed\n"); udbg("ERROR: sam_ohci_initialize failed\n");
return -ENODEV; return -ENODEV;
@@ -308,8 +308,8 @@ int sam_usbhost_initialize(void)
#ifdef CONFIG_SAMA5_EHCI #ifdef CONFIG_SAMA5_EHCI
/* Get an instance of the USB EHCI interface */ /* Get an instance of the USB EHCI interface */
g_ehci = sam_ehci_initialize(0); g_ehciconn = sam_ehci_initialize(0);
if (!g_ehci) if (!g_ehciconn)
{ {
udbg("ERROR: sam_ehci_initialize failed\n"); udbg("ERROR: sam_ehci_initialize failed\n");
return -ENODEV; return -ENODEV;
+5 -5
View File
@@ -82,7 +82,7 @@
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n"); uvdbg("Initialize USB host\n");
g_drvr = stm32_otgfshost_initialize(0); g_usbconn = stm32_otgfshost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -82,7 +82,7 @@
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n"); uvdbg("Initialize USB host\n");
g_drvr = stm32_otgfshost_initialize(0); g_usbconn = stm32_otgfshost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -82,7 +82,7 @@
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n"); uvdbg("Initialize USB host\n");
g_drvr = stm32_otgfshost_initialize(0); g_usbconn = stm32_otgfshost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -82,7 +82,7 @@
************************************************************************************/ ************************************************************************************/
#ifdef CONFIG_USBHOST #ifdef CONFIG_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/************************************************************************************ /************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n"); uvdbg("Initialize USB host\n");
g_drvr = stm32_otgfshost_initialize(0); g_usbconn = stm32_otgfshost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+5 -5
View File
@@ -162,7 +162,7 @@
****************************************************************************/ ****************************************************************************/
#ifdef NSH_HAVE_USBHOST #ifdef NSH_HAVE_USBHOST
static struct usbhost_driver_s *g_drvr; static struct usbhost_connection_s *g_usbconn;
#endif #endif
/**************************************************************************** /****************************************************************************
@@ -188,7 +188,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Wait for the device to change state */ /* Wait for the device to change state */
ret = DRVR_WAIT(g_drvr, &connected); ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK); DEBUGASSERT(ret == OK);
connected = !connected; connected = !connected;
@@ -200,7 +200,7 @@ static int nsh_waiter(int argc, char *argv[])
{ {
/* Yes.. enumerate the newly connected device */ /* Yes.. enumerate the newly connected device */
(void)DRVR_ENUMERATE(g_drvr, 0); (void)CONN_ENUMERATE(g_usbconn, 0);
} }
} }
@@ -300,8 +300,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */ /* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n"); message("nsh_usbhostinitialize: Initialize USB host\n");
g_drvr = usbhost_initialize(0); g_usbconn = usbhost_initialize(0);
if (g_drvr) if (g_usbconn)
{ {
/* Start a thread to handle device connection. */ /* Start a thread to handle device connection. */
+21 -13
View File
@@ -152,14 +152,14 @@
#define CLASS_DISCONNECTED(class) ((class)->disconnected(class)) #define CLASS_DISCONNECTED(class) ((class)->disconnected(class))
/******************************************************************************* /*******************************************************************************
* Name: DRVR_WAIT * Name: CONN_WAIT
* *
* Description: * Description:
* Wait for a device to be connected or disconnected to/from a root hub port. * Wait for a device to be connected or disconnected to/from a root hub port.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call * conn - The USB host connection instance obtained as a parameter from the call to
* to the class create() method. * the USB driver initialization logic.
* connected - A pointer to an array of n boolean values corresponding to * connected - A pointer to an array of n boolean values corresponding to
* root hubs 1 through n. For each boolean value: TRUE: Wait for a device * root hubs 1 through n. For each boolean value: TRUE: Wait for a device
* to be connected on the root hub; FALSE: wait for device to be * to be connected on the root hub; FALSE: wait for device to be
@@ -178,10 +178,10 @@
* *
*******************************************************************************/ *******************************************************************************/
#define DRVR_WAIT(drvr, connected) ((drvr)->wait(drvr,connected)) #define CONN_WAIT(conn, connected) ((conn)->wait(conn,connected))
/************************************************************************************ /************************************************************************************
* Name: DRVR_ENUMERATE * Name: CONN_ENUMERATE
* *
* Description: * Description:
* Enumerate the connected device. As part of this enumeration process, * Enumerate the connected device. As part of this enumeration process,
@@ -194,8 +194,8 @@
* charge of the sequence of operations. * charge of the sequence of operations.
* *
* Input Parameters: * Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to * conn - The USB host connection instance obtained as a parameter from the call to
* the class create() method. * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n. * rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
* *
* Returned Values: * Returned Values:
@@ -207,7 +207,7 @@
* *
************************************************************************************/ ************************************************************************************/
#define DRVR_ENUMERATE(drvr,rhpndx) ((drvr)->enumerate(drvr,rhpndx)) #define CONN_ENUMERATE(conn,rhpndx) ((conn)->enumerate(conn,rhpndx))
/************************************************************************************ /************************************************************************************
* Name: DRVR_EP0CONFIGURE * Name: DRVR_EP0CONFIGURE
@@ -586,15 +586,16 @@ struct usbhost_epdesc_s
typedef FAR void *usbhost_ep_t; typedef FAR void *usbhost_ep_t;
/* struct usbhost_driver_s provides access to the USB host driver from the /* struct usbhost_connection_s provides as interface between platform-specific
* USB host class implementation. * connection monitoring and the USB host driver connectin and enumeration
* logic.
*/ */
struct usbhost_driver_s struct usbhost_connection_s
{ {
/* Wait for a device to connect or disconnect. */ /* Wait for a device to connect or disconnect. */
int (*wait)(FAR struct usbhost_driver_s *drvr, FAR const bool *connected); int (*wait)(FAR struct usbhost_connection_s *drvr, FAR const bool *connected);
/* Enumerate the device connected on a root hub port. As part of this /* Enumerate the device connected on a root hub port. As part of this
* enumeration process, the driver will (1) get the device's configuration * enumeration process, the driver will (1) get the device's configuration
@@ -606,8 +607,15 @@ struct usbhost_driver_s
* in charge of the sequence of operations. * in charge of the sequence of operations.
*/ */
int (*enumerate)(FAR struct usbhost_driver_s *drvr, int rhpndx); int (*enumerate)(FAR struct usbhost_connection_s *drvr, int rhpndx);
};
/* struct usbhost_driver_s provides access to the USB host driver from the
* USB host class implementation.
*/
struct usbhost_driver_s
{
/* Configure endpoint 0. This method is normally used internally by the /* Configure endpoint 0. This method is normally used internally by the
* enumerate() method but is made available at the interface to support * enumerate() method but is made available at the interface to support
* an external implementation of the enumeration logic. * an external implementation of the enumeration logic.