2010-12-14 16:35:10 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/usbhost/usbhost_storage.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <nuttx/usb/usb.h>
|
|
|
|
#include <nuttx/usb/usbhost.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static struct usbhost_class_s *usbhost_create(struct usbhost_driver_s *drvr);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct usbhost_registry_s g_storage =
|
|
|
|
{
|
2010-12-14 19:02:49 +00:00
|
|
|
NULL, /* flink */
|
|
|
|
usbhost_create, /* create */
|
|
|
|
1, /* nids */
|
2010-12-14 16:35:10 +00:00
|
|
|
{
|
2010-12-14 19:02:49 +00:00
|
|
|
{
|
|
|
|
USB_CLASS_MASS_STORAGE, /* id[0].base */
|
|
|
|
SUBSTRG_SUBCLASS_SCSI, /* id[0].subclass */
|
|
|
|
USBSTRG_PROTO_BULKONLY, /* id[0].proto */
|
|
|
|
0, /* id[0].vid */
|
|
|
|
0 /* id[0].pid */
|
|
|
|
}
|
2010-12-14 16:35:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: usbhost_create
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function implements the create() method of struct usb_registry_s.
|
|
|
|
* The create() method is a callback into the class implementation. It is
|
|
|
|
* used to (1) create a new instance of the USB host class state and to (2)
|
|
|
|
* bind a USB host driver "session" to the class instance. Use of this
|
|
|
|
* create() method will support environments where there may be multiple
|
|
|
|
* USB ports and multiple USB devices simultaneously connected.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* drvr - An instance of struct usbhost_driver_s that the class
|
|
|
|
* implementation will "bind" to its state structure and will
|
|
|
|
* subsequently use to communicate with the USB host driver.
|
2010-12-14 19:02:49 +00:00
|
|
|
* id - In the case where the device supports multiple base classes,
|
|
|
|
* subclasses, or protocols, this specifies which to configure for.
|
2010-12-14 16:35:10 +00:00
|
|
|
*
|
|
|
|
* Returned Values:
|
|
|
|
* On success, this function will return a non-NULL instance of struct
|
|
|
|
* usbhost_class_s that can be used by the USB host driver to communicate
|
|
|
|
* with the USB host class. NULL is returned on failure; this function
|
|
|
|
* will fail only if the drvr input parameter is NULL or if there are
|
|
|
|
* insufficient resources to create another USB host class instance.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2010-12-14 19:02:49 +00:00
|
|
|
static struct usbhost_class_s *usbhost_create(struct usbhost_driver_s *drvr,
|
|
|
|
const struct usbhost_id_s *id)
|
2010-12-14 16:35:10 +00:00
|
|
|
{
|
|
|
|
#warning "Not implemented"
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: usbhost_storageinit
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize the USB host storage class. This function should be called
|
|
|
|
* be platform-specific code in order to initialize and register support
|
|
|
|
* for the USB host storage class.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Values:
|
|
|
|
* On success this function will return zero (OK); A negated errno value
|
|
|
|
* will be returned on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int usbhost_storageinit(void)
|
|
|
|
{
|
|
|
|
/* Advertise our availability to support mass storage devices */
|
|
|
|
|
|
|
|
return usbhost_registerclass(&g_storage);
|
|
|
|
}
|
|
|
|
|