FunctionAddress no longer hard-coded
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3231 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
964e5cc2f2
commit
1b2c057215
@ -929,10 +929,12 @@ static int lpc17_enumerate(FAR struct usbhost_driver_s *drvr)
|
|||||||
lpc17_putreg(OHCI_RHPORTST_PRSC, LPC17_USBHOST_RHPORTST1);
|
lpc17_putreg(OHCI_RHPORTST_PRSC, LPC17_USBHOST_RHPORTST1);
|
||||||
up_mdelay(200);
|
up_mdelay(200);
|
||||||
|
|
||||||
/* Let the common usbhost_enumerate do all of the real work */
|
/* Let the common usbhost_enumerate do all of the real work. Note that the
|
||||||
|
* FunctionAddress (USB address) is hardcoded to one.
|
||||||
|
*/
|
||||||
|
|
||||||
uvdbg("Enumerate the device\n");
|
uvdbg("Enumerate the device\n");
|
||||||
return usbhost_enumerate(drvr, &priv->class);
|
return usbhost_enumerate(drvr, 1, &priv->class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@ -1239,7 +1241,7 @@ static int lpc17_transfer(FAR struct usbhost_driver_s *drvr,
|
|||||||
|
|
||||||
/* Get the direction of the endpoint */
|
/* Get the direction of the endpoint */
|
||||||
|
|
||||||
if (ep->in)
|
if (ep->in != 0)
|
||||||
{
|
{
|
||||||
ed->ctrl |= ED_CONTROL_D_IN;
|
ed->ctrl |= ED_CONTROL_D_IN;
|
||||||
dirpid = GTD_STATUS_DP_IN;
|
dirpid = GTD_STATUS_DP_IN;
|
||||||
|
@ -72,7 +72,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int desclen,
|
|||||||
struct usbhost_id_s *id);
|
struct usbhost_id_s *id);
|
||||||
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
|
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
|
||||||
const uint8_t *configdesc, int desclen,
|
const uint8_t *configdesc, int desclen,
|
||||||
struct usbhost_id_s *id,
|
struct usbhost_id_s *id, uint8_t funcaddr,
|
||||||
FAR struct usbhost_class_s **class);
|
FAR struct usbhost_class_s **class);
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -235,7 +235,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int cfglen,
|
|||||||
|
|
||||||
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
|
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
|
||||||
const uint8_t *configdesc, int desclen,
|
const uint8_t *configdesc, int desclen,
|
||||||
struct usbhost_id_s *id,
|
struct usbhost_id_s *id, uint8_t funcaddr,
|
||||||
FAR struct usbhost_class_s **class)
|
FAR struct usbhost_class_s **class)
|
||||||
{
|
{
|
||||||
FAR struct usbhost_class_s *devclass;
|
FAR struct usbhost_class_s *devclass;
|
||||||
@ -264,7 +264,7 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
|
|||||||
{
|
{
|
||||||
/* Then bind the newly instantiated class instance */
|
/* Then bind the newly instantiated class instance */
|
||||||
|
|
||||||
ret = CLASS_CONNECT(devclass, configdesc, desclen);
|
ret = CLASS_CONNECT(devclass, configdesc, desclen, funcaddr);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
udbg("CLASS_CONNECT failed: %d\n", ret);
|
udbg("CLASS_CONNECT failed: %d\n", ret);
|
||||||
@ -301,6 +301,11 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* drvr - The USB host driver instance obtained as a parameter from the call to
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
||||||
* the class create() method.
|
* the class create() method.
|
||||||
|
* funcaddr - The USB address of the function containing the endpoint that EP0
|
||||||
|
* controls
|
||||||
|
* class - If the class driver for the device is successful located
|
||||||
|
* and bound to the driver, the allocated class instance is returned into
|
||||||
|
* this caller-provided memory location.
|
||||||
*
|
*
|
||||||
* Returned Values:
|
* Returned Values:
|
||||||
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
||||||
@ -313,7 +318,7 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
|
|||||||
*
|
*
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
int usbhost_enumerate(FAR struct usbhost_driver_s *drvr,
|
int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
|
||||||
FAR struct usbhost_class_s **class)
|
FAR struct usbhost_class_s **class)
|
||||||
{
|
{
|
||||||
struct usb_ctrlreq_s *ctrlreq;
|
struct usb_ctrlreq_s *ctrlreq;
|
||||||
@ -498,7 +503,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr,
|
|||||||
* will begin configuring the device.
|
* will begin configuring the device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = usbhost_classbind(drvr, buffer, cfglen, &id, class);
|
ret = usbhost_classbind(drvr, buffer, cfglen, &id, funcaddr, class);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
udbg("ERROR: usbhost_classbind returned %d\n", ret);
|
udbg("ERROR: usbhost_classbind returned %d\n", ret);
|
||||||
|
@ -213,7 +213,8 @@ static struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *drvr,
|
|||||||
/* struct usbhost_class_s methods */
|
/* struct usbhost_class_s methods */
|
||||||
|
|
||||||
static int usbhost_connect(FAR struct usbhost_class_s *class,
|
static int usbhost_connect(FAR struct usbhost_class_s *class,
|
||||||
FAR const uint8_t *configdesc, int desclen);
|
FAR const uint8_t *configdesc, int desclen,
|
||||||
|
uint8_t funcaddr);
|
||||||
static int usbhost_disconnected(FAR struct usbhost_class_s *class);
|
static int usbhost_disconnected(FAR struct usbhost_class_s *class);
|
||||||
|
|
||||||
/* struct block_operations methods */
|
/* struct block_operations methods */
|
||||||
@ -1391,6 +1392,8 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d
|
|||||||
* class - The USB host class entry previously obtained from a call to create().
|
* class - The USB host class entry previously obtained from a call to create().
|
||||||
* configdesc - A pointer to a uint8_t buffer container the configuration descripor.
|
* configdesc - A pointer to a uint8_t buffer container the configuration descripor.
|
||||||
* desclen - The length in bytes of the configuration descriptor.
|
* desclen - The length in bytes of the configuration descriptor.
|
||||||
|
* funcaddr - The USB address of the function containing the endpoint that EP0
|
||||||
|
* controls
|
||||||
*
|
*
|
||||||
* Returned Values:
|
* Returned Values:
|
||||||
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
||||||
@ -1404,7 +1407,8 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int usbhost_connect(FAR struct usbhost_class_s *class,
|
static int usbhost_connect(FAR struct usbhost_class_s *class,
|
||||||
FAR const uint8_t *configdesc, int desclen)
|
FAR const uint8_t *configdesc, int desclen,
|
||||||
|
uint8_t funcaddr)
|
||||||
{
|
{
|
||||||
FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class;
|
FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class;
|
||||||
FAR struct usb_cfgdesc_s *cfgdesc;
|
FAR struct usb_cfgdesc_s *cfgdesc;
|
||||||
@ -1490,8 +1494,8 @@ static int usbhost_connect(FAR struct usbhost_class_s *class,
|
|||||||
/* Save the bulk OUT endpoint information */
|
/* Save the bulk OUT endpoint information */
|
||||||
|
|
||||||
priv->bulkout.addr = epdesc->addr & USB_EP_ADDR_NUMBER_MASK;
|
priv->bulkout.addr = epdesc->addr & USB_EP_ADDR_NUMBER_MASK;
|
||||||
priv->bulkout.in = false;
|
priv->bulkout.in = 0;
|
||||||
priv->bulkout.funcaddr = 1;
|
priv->bulkout.funcaddr = funcaddr;
|
||||||
priv->bulkout.mxpacketsize = usbhost_getle16(epdesc->mxpacketsize);
|
priv->bulkout.mxpacketsize = usbhost_getle16(epdesc->mxpacketsize);
|
||||||
uvdbg("Bulk OUT EP addr:%d mxpacketsize:%d\n",
|
uvdbg("Bulk OUT EP addr:%d mxpacketsize:%d\n",
|
||||||
priv->bulkout.addr, priv->bulkout.mxpacketsize);
|
priv->bulkout.addr, priv->bulkout.mxpacketsize);
|
||||||
@ -1511,8 +1515,8 @@ static int usbhost_connect(FAR struct usbhost_class_s *class,
|
|||||||
/* Save the bulk IN endpoint information */
|
/* Save the bulk IN endpoint information */
|
||||||
|
|
||||||
priv->bulkin.addr = epdesc->addr & USB_EP_ADDR_NUMBER_MASK;
|
priv->bulkin.addr = epdesc->addr & USB_EP_ADDR_NUMBER_MASK;
|
||||||
priv->bulkin.in = true;
|
priv->bulkin.in = 1;
|
||||||
priv->bulkin.funcaddr = 1;
|
priv->bulkin.funcaddr = funcaddr;
|
||||||
priv->bulkin.mxpacketsize = usbhost_getle16(epdesc->mxpacketsize);
|
priv->bulkin.mxpacketsize = usbhost_getle16(epdesc->mxpacketsize);
|
||||||
uvdbg("Bulk IN EP addr:%d mxpacketsize:%d\n",
|
uvdbg("Bulk IN EP addr:%d mxpacketsize:%d\n",
|
||||||
priv->bulkin.addr, priv->bulkin.mxpacketsize);
|
priv->bulkin.addr, priv->bulkin.mxpacketsize);
|
||||||
|
@ -106,6 +106,8 @@
|
|||||||
* class - The USB host class entry previously obtained from a call to create().
|
* class - The USB host class entry previously obtained from a call to create().
|
||||||
* configdesc - A pointer to a uint8_t buffer container the configuration descripor.
|
* configdesc - A pointer to a uint8_t buffer container the configuration descripor.
|
||||||
* desclen - The length in bytes of the configuration descriptor.
|
* desclen - The length in bytes of the configuration descriptor.
|
||||||
|
* funcaddr - The USB address of the function containing the endpoint that EP0
|
||||||
|
* controls
|
||||||
*
|
*
|
||||||
* Returned Values:
|
* Returned Values:
|
||||||
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
* On success, zero (OK) is returned. On a failure, a negated errno value is
|
||||||
@ -118,7 +120,8 @@
|
|||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#define CLASS_CONNECT(class,configdesc,desclen) ((class)->connect(class,configdesc,desclen))
|
#define CLASS_CONNECT(class,configdesc,desclen,funcaddr) \
|
||||||
|
((class)->connect(class,configdesc,desclen, funcaddr))
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: CLASS_DISCONNECTED
|
* Name: CLASS_DISCONNECTED
|
||||||
@ -430,7 +433,8 @@ struct usbhost_class_s
|
|||||||
* initialize properly (such as endpoint selections).
|
* initialize properly (such as endpoint selections).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int (*connect)(FAR struct usbhost_class_s *class, FAR const uint8_t *configdesc, int desclen);
|
int (*connect)(FAR struct usbhost_class_s *class, FAR const uint8_t *configdesc,
|
||||||
|
int desclen, uint8_t funcaddr);
|
||||||
|
|
||||||
/* This method informs the class that the USB device has been disconnected. */
|
/* This method informs the class that the USB device has been disconnected. */
|
||||||
|
|
||||||
@ -521,9 +525,11 @@ struct usbhost_driver_s
|
|||||||
|
|
||||||
struct usbhost_epdesc_s
|
struct usbhost_epdesc_s
|
||||||
{
|
{
|
||||||
uint8_t addr; /* Endpoint address */
|
uint8_t addr : 4; /* Endpoint address */
|
||||||
bool in; /* Direction: TRUE = IN */
|
uint8_t pad1 : 3;
|
||||||
uint8_t funcaddr; /* USB address of function containing endpoint */
|
uint8_t in : 1; /* Direction: 1->IN */
|
||||||
|
uint8_t funcaddr : 7; /* USB address of function containing endpoint */
|
||||||
|
uint8_t pad2 : 1;
|
||||||
uint16_t mxpacketsize; /* Max packetsize */
|
uint16_t mxpacketsize; /* Max packetsize */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -653,6 +659,8 @@ EXTERN FAR struct usbhost_driver_s *usbhost_initialize(int controller);
|
|||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* drvr - The USB host driver instance obtained as a parameter from the call to
|
* drvr - The USB host driver instance obtained as a parameter from the call to
|
||||||
* the class create() method.
|
* the class create() method.
|
||||||
|
* funcaddr - The USB address of the function containing the endpoint that EP0
|
||||||
|
* controls
|
||||||
* class - If the class driver for the device is successful located
|
* class - If the class driver for the device is successful located
|
||||||
* and bound to the driver, the allocated class instance is returned into
|
* and bound to the driver, the allocated class instance is returned into
|
||||||
* this caller-provided memory location.
|
* this caller-provided memory location.
|
||||||
@ -669,6 +677,7 @@ EXTERN FAR struct usbhost_driver_s *usbhost_initialize(int controller);
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
EXTERN int usbhost_enumerate(FAR struct usbhost_driver_s *drvr,
|
EXTERN int usbhost_enumerate(FAR struct usbhost_driver_s *drvr,
|
||||||
|
uint8_t funcaddr,
|
||||||
FAR struct usbhost_class_s **class);
|
FAR struct usbhost_class_s **class);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
Loading…
Reference in New Issue
Block a user