drivers/usbdev/cdcecm.c: Adds USB Device Support for CDC/ECM
This commit is contained in:
parent
d219182588
commit
aad8f6e45f
@ -674,3 +674,166 @@ menuconfig RNDIS
|
||||
This option is not automatically selected because it may be that
|
||||
you have an additional network device that requires the early
|
||||
up_netinitialize() call.
|
||||
|
||||
menuconfig NET_CDCECM
|
||||
bool "CDC-ECM Ethernet-over-USB"
|
||||
default n
|
||||
select NETDEVICES
|
||||
select NET
|
||||
select NET_ETHERNET
|
||||
---help---
|
||||
References:
|
||||
- "Universal Serial Bus - Communications Class - Subclass
|
||||
Specification for Ethernet Control Model Devices,
|
||||
Revision 1.2, Feburary 9, 2007"
|
||||
|
||||
This option may require CONFIG_NETDEV_LATEINIT=y, otherwise the
|
||||
power-up initialization may call the non-existent up_netinitialize().
|
||||
This option is not automatically selected because it may be that
|
||||
you have an additional network device that requires the early
|
||||
up_netinitialize() call.
|
||||
|
||||
if NET_CDCECM
|
||||
|
||||
menuconfig CDCECM_COMPOSITE
|
||||
bool "CDC/ECM composite support"
|
||||
default n
|
||||
depends on USBDEV_COMPOSITE
|
||||
---help---
|
||||
Configure the CDC Ethernet Control Model driver as part of a
|
||||
composite driver (only if USBDEV_COMPOSITE is also defined)
|
||||
|
||||
if !CDCECM_COMPOSITE
|
||||
|
||||
# In a composite device the EP0 config comes from the composite device
|
||||
# and the EP-Number is configured dynamically via composite_initialize
|
||||
|
||||
config CDCECM_EP0MAXPACKET
|
||||
int "Endpoint 0 max packet size"
|
||||
default 64
|
||||
---help---
|
||||
Endpoint 0 max packet size. Default 64.
|
||||
|
||||
config CDCECM_EPINTIN
|
||||
int "Interrupt IN endpoint number"
|
||||
default 1
|
||||
---help---
|
||||
The logical 7-bit address of a hardware endpoint that supports
|
||||
interrupt IN operation. Default 1.
|
||||
|
||||
endif # !CDCECM_COMPOSITE
|
||||
|
||||
config CDCECM_EPINTIN_FSSIZE
|
||||
int "Interupt IN full speed MAXPACKET size"
|
||||
default 16
|
||||
---help---
|
||||
Max package size for the interrupt IN endpoint if full speed mode.
|
||||
Default 16.
|
||||
|
||||
if USBDEV_DUALSPEED
|
||||
|
||||
config CDCECM_EPINTIN_HSSIZE
|
||||
int "Interupt IN high speed MAXPACKET size"
|
||||
default 64
|
||||
---help---
|
||||
Max package size for the interrupt IN endpoint if high speed mode.
|
||||
Default 64.
|
||||
|
||||
endif # USBDEV_DUALSPEED
|
||||
|
||||
if !CDCECM_COMPOSITE
|
||||
|
||||
# In a composite device the EP-Number is configured dynamically via
|
||||
# composite_initialize
|
||||
|
||||
config CDCECM_EPBULKOUT
|
||||
int "Bulk OUT endpoint number"
|
||||
default 5
|
||||
---help---
|
||||
The logical 7-bit address of a hardware endpoint that supports
|
||||
bulk OUT operation. Default: 5
|
||||
|
||||
endif # !CDCECM_COMPOSITE
|
||||
|
||||
config CDCECM_EPBULKOUT_FSSIZE
|
||||
int "Bulk OUT full speed MAXPACKET size"
|
||||
default 64
|
||||
---help---
|
||||
Max package size for the bulk OUT endpoint if full speed mode.
|
||||
Default 64.
|
||||
|
||||
if USBDEV_DUALSPEED
|
||||
|
||||
config CDCECM_EPBULKOUT_HSSIZE
|
||||
int "Bulk OUT out high speed MAXPACKET size"
|
||||
default 512
|
||||
---help---
|
||||
Max package size for the bulk OUT endpoint if high speed mode.
|
||||
Default 512.
|
||||
|
||||
endif # USBDEV_DUALSPEED
|
||||
|
||||
if !CDCECM_COMPOSITE
|
||||
|
||||
# In a composite device the EP-Number is configured dynamically via
|
||||
# composite_initialize
|
||||
|
||||
config CDCECM_EPBULKIN
|
||||
int "Bulk IN endpoint number"
|
||||
default 2
|
||||
---help---
|
||||
The logical 7-bit address of a hardware endpoint that supports
|
||||
bulk IN operation. Default: 2
|
||||
|
||||
endif # !CDCECM_COMPOSITE
|
||||
|
||||
config CDCECM_EPBULKIN_FSSIZE
|
||||
int "Bulk IN full speed MAXPACKET size"
|
||||
default 64
|
||||
---help---
|
||||
Max package size for the bulk IN endpoint if full speed mode.
|
||||
Default 64.
|
||||
|
||||
if USBDEV_DUALSPEED
|
||||
|
||||
config CDCECM_EPBULKIN_HSSIZE
|
||||
int "Bulk IN high speed MAXPACKET size"
|
||||
default 512
|
||||
---help---
|
||||
Max package size for the bulk IN endpoint if high speed mode.
|
||||
Default 512.
|
||||
|
||||
endif # USBDEV_DUALSPEED
|
||||
|
||||
if !CDCECM_COMPOSITE
|
||||
|
||||
# In a composite device the Vendor- and Product-ID is given by the composite
|
||||
# device
|
||||
|
||||
config CDCECM_VENDORID
|
||||
hex "Vendor ID"
|
||||
default 0x0525
|
||||
---help---
|
||||
The vendor ID code/string. Default 0x0525 and "NuttX"
|
||||
0x0525 is the Netchip vendor and should not be used in any
|
||||
products. This default VID was selected for compatibility with
|
||||
the Linux CDC ECM default VID.
|
||||
|
||||
config CDCECM_PRODUCTID
|
||||
hex "Product ID"
|
||||
default 0xa4a2
|
||||
---help---
|
||||
The product ID code/string. Default 0xa4a2 and "CDC/ECM Ethernet"
|
||||
0xa4a2 was selected for compatibility with the Linux CDC ECM
|
||||
default PID.
|
||||
|
||||
config CDCECM_VENDORSTR
|
||||
string "Vendor string"
|
||||
default "NuttX"
|
||||
|
||||
config CDCECM_PRODUCTSTR
|
||||
string "Product string"
|
||||
default "CDC/ECM Ethernet"
|
||||
|
||||
endif # !CDCECM_COMPOSITE
|
||||
endif # CDCECM
|
||||
|
@ -61,6 +61,10 @@ ifeq ($(CONFIG_RNDIS),y)
|
||||
CSRCS += rndis.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_CDCECM),y)
|
||||
CSRCS += cdcecm.c
|
||||
endif
|
||||
|
||||
CSRCS += usbdev_trace.c usbdev_trprintf.c
|
||||
|
||||
# Include USB device build support
|
||||
|
2367
drivers/usbdev/cdcecm.c
Normal file
2367
drivers/usbdev/cdcecm.c
Normal file
File diff suppressed because it is too large
Load Diff
79
drivers/usbdev/cdcecm.h
Normal file
79
drivers/usbdev/cdcecm.h
Normal file
@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
* drivers/usbdev/cdcecm.h
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Michael Jung <mijung@gmx.net>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __DRIVERS_USBDEV_CDCECM_H
|
||||
#define __DRIVERS_USBDEV_CDCECM_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/usb/cdcecm.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CDCECM_VERSIONNO (0x0100)
|
||||
#define CDCECM_MXDESCLEN (80)
|
||||
#define CDCECM_MAXSTRLEN (CDCECM_MXDESCLEN - 2)
|
||||
#define CDCECM_NCONFIGS (1)
|
||||
#define CDCECM_NINTERFACES (2)
|
||||
#define CDCECM_NUM_EPS (3)
|
||||
|
||||
#define CDCECM_MANUFACTURERSTRID (1)
|
||||
#define CDCECM_PRODUCTSTRID (2)
|
||||
#define CDCECM_SERIALSTRID (3)
|
||||
#define CDCECM_CONFIGSTRID (4)
|
||||
#define CDCECM_MACSTRID (5)
|
||||
#define CDCECM_NSTRIDS (5)
|
||||
|
||||
#define CDCECM_STR_LANGUAGE (0x0409) /* en-us */
|
||||
|
||||
#define CDCECM_CONFIGID_NONE (0)
|
||||
#define CDCECM_CONFIGID (1)
|
||||
|
||||
#define CDCECM_SELFPOWERED (0)
|
||||
#define CDCECM_REMOTEWAKEUP (0)
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#endif /* __DRIVERS_USBDEV_CDCECM_H */
|
120
include/nuttx/usb/cdcecm.h
Normal file
120
include/nuttx/usb/cdcecm.h
Normal file
@ -0,0 +1,120 @@
|
||||
/*******************************************************************************
|
||||
* include/nuttx/usb/cdcecm.h
|
||||
*
|
||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Michael Jung <mijung@gmx.net>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_USB_CDCECM_H
|
||||
#define __INCLUDE_NUTTX_USB_CDCECM_H
|
||||
|
||||
/******************************************************************************
|
||||
* Included Files
|
||||
******************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_CDCECM_COMPOSITE
|
||||
# include <nuttx/usb/composite.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Preprocessor definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define CDCECM_EP_INTIN_IDX (0)
|
||||
#define CDCECM_EP_BULKIN_IDX (1)
|
||||
#define CDCECM_EP_BULKOUT_IDX (2)
|
||||
|
||||
/******************************************************************************
|
||||
* Public Data
|
||||
******************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
# define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
* Public Functions
|
||||
******************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_initialize
|
||||
*
|
||||
* Description:
|
||||
* Register CDC/ECM USB device interface. Register the corresponding network
|
||||
* driver to NuttX and bring up the network.
|
||||
*
|
||||
* Input Parameters:
|
||||
* minor - Device minor number.
|
||||
* handle - An optional opaque reference to the CDC/ECM class object that
|
||||
* may subsequently be used with cdcecm_uninitialize().
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) means that the driver was successfully registered. On any
|
||||
* failure, a negated errno value is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if !defined(CONFIG_CDCECM_COMPOSITE)
|
||||
int cdcecm_initialize(int minor, FAR void **handle);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cdcecm_get_composite_devdesc
|
||||
*
|
||||
* Description:
|
||||
* Helper function to fill in some constants into the composite
|
||||
* configuration struct.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Pointer to the configuration struct we should fill
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_CDCECM_COMPOSITE
|
||||
void cdcecm_get_composite_devdesc(struct composite_devdesc_s *dev);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_USB_CDCECM_H */
|
Loading…
Reference in New Issue
Block a user