diff options
author | Brian Niebuhr <bniebuhr@efjohnson.com> | 2009-08-14 11:04:22 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-23 09:46:35 -0400 |
commit | 9b39e9ddedeef48569f8aac60a7b4c1fbb127c7d (patch) | |
tree | d2cc583190e18fa03298e84093c3346e1646007c /drivers/usb/gadget/ether.c | |
parent | 877accca79b706afe5d78b9a92cf4f22919fb2b0 (diff) |
USB: gadget: Add EEM gadget driver
This patch adds a CDC EEM ethernet gadget driver. CDC EEM is a newer
USB ethernet specification that uses a simpler interface than the older
CDC ECM. This makes CDC EEM usable by a wider set of USB hardware.
By default the ethernet gadget will still use CDC ECM/Subset, but kernel
configuration and/or a module parameter will allow alternative use of
the CDC EEM protocol.
Changes since last version:
- Brought in missing RNDIS changes that caused compile error
- Modified 'sentinel CRC' checking to match EEM host driver
Signed-off-by: Brian Niebuhr <bniebuhr@efjohnson.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/ether.c')
-rw-r--r-- | drivers/usb/gadget/ether.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index bd102f5052ba..f37de283d0ab 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -61,6 +61,11 @@ | |||
61 | * simpler, Microsoft pushes their own approach: RNDIS. The published | 61 | * simpler, Microsoft pushes their own approach: RNDIS. The published |
62 | * RNDIS specs are ambiguous and appear to be incomplete, and are also | 62 | * RNDIS specs are ambiguous and appear to be incomplete, and are also |
63 | * needlessly complex. They borrow more from CDC ACM than CDC ECM. | 63 | * needlessly complex. They borrow more from CDC ACM than CDC ECM. |
64 | * | ||
65 | * While CDC ECM, CDC Subset, and RNDIS are designed to extend the ethernet | ||
66 | * interface to the target, CDC EEM was designed to use ethernet over the USB | ||
67 | * link between the host and target. CDC EEM is implemented as an alternative | ||
68 | * to those other protocols when that communication model is more appropriate | ||
64 | */ | 69 | */ |
65 | 70 | ||
66 | #define DRIVER_DESC "Ethernet Gadget" | 71 | #define DRIVER_DESC "Ethernet Gadget" |
@@ -114,6 +119,7 @@ static inline bool has_rndis(void) | |||
114 | #include "f_rndis.c" | 119 | #include "f_rndis.c" |
115 | #include "rndis.c" | 120 | #include "rndis.c" |
116 | #endif | 121 | #endif |
122 | #include "f_eem.c" | ||
117 | #include "u_ether.c" | 123 | #include "u_ether.c" |
118 | 124 | ||
119 | /*-------------------------------------------------------------------------*/ | 125 | /*-------------------------------------------------------------------------*/ |
@@ -150,6 +156,10 @@ static inline bool has_rndis(void) | |||
150 | #define RNDIS_VENDOR_NUM 0x0525 /* NetChip */ | 156 | #define RNDIS_VENDOR_NUM 0x0525 /* NetChip */ |
151 | #define RNDIS_PRODUCT_NUM 0xa4a2 /* Ethernet/RNDIS Gadget */ | 157 | #define RNDIS_PRODUCT_NUM 0xa4a2 /* Ethernet/RNDIS Gadget */ |
152 | 158 | ||
159 | /* For EEM gadgets */ | ||
160 | #define EEM_VENDOR_NUM 0x0525 /* INVALID - NEEDS TO BE ALLOCATED */ | ||
161 | #define EEM_PRODUCT_NUM 0xa4a1 /* INVALID - NEEDS TO BE ALLOCATED */ | ||
162 | |||
153 | /*-------------------------------------------------------------------------*/ | 163 | /*-------------------------------------------------------------------------*/ |
154 | 164 | ||
155 | static struct usb_device_descriptor device_desc = { | 165 | static struct usb_device_descriptor device_desc = { |
@@ -246,8 +256,16 @@ static struct usb_configuration rndis_config_driver = { | |||
246 | 256 | ||
247 | /*-------------------------------------------------------------------------*/ | 257 | /*-------------------------------------------------------------------------*/ |
248 | 258 | ||
259 | #ifdef CONFIG_USB_ETH_EEM | ||
260 | static int use_eem = 1; | ||
261 | #else | ||
262 | static int use_eem; | ||
263 | #endif | ||
264 | module_param(use_eem, bool, 0); | ||
265 | MODULE_PARM_DESC(use_eem, "use CDC EEM mode"); | ||
266 | |||
249 | /* | 267 | /* |
250 | * We _always_ have an ECM or CDC Subset configuration. | 268 | * We _always_ have an ECM, CDC Subset, or EEM configuration. |
251 | */ | 269 | */ |
252 | static int __init eth_do_config(struct usb_configuration *c) | 270 | static int __init eth_do_config(struct usb_configuration *c) |
253 | { | 271 | { |
@@ -258,7 +276,9 @@ static int __init eth_do_config(struct usb_configuration *c) | |||
258 | c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; | 276 | c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; |
259 | } | 277 | } |
260 | 278 | ||
261 | if (can_support_ecm(c->cdev->gadget)) | 279 | if (use_eem) |
280 | return eem_bind_config(c); | ||
281 | else if (can_support_ecm(c->cdev->gadget)) | ||
262 | return ecm_bind_config(c, hostaddr); | 282 | return ecm_bind_config(c, hostaddr); |
263 | else | 283 | else |
264 | return geth_bind_config(c, hostaddr); | 284 | return geth_bind_config(c, hostaddr); |
@@ -286,7 +306,12 @@ static int __init eth_bind(struct usb_composite_dev *cdev) | |||
286 | return status; | 306 | return status; |
287 | 307 | ||
288 | /* set up main config label and device descriptor */ | 308 | /* set up main config label and device descriptor */ |
289 | if (can_support_ecm(cdev->gadget)) { | 309 | if (use_eem) { |
310 | /* EEM */ | ||
311 | eth_config_driver.label = "CDC Ethernet (EEM)"; | ||
312 | device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM); | ||
313 | device_desc.idProduct = cpu_to_le16(EEM_PRODUCT_NUM); | ||
314 | } else if (can_support_ecm(cdev->gadget)) { | ||
290 | /* ECM */ | 315 | /* ECM */ |
291 | eth_config_driver.label = "CDC Ethernet (ECM)"; | 316 | eth_config_driver.label = "CDC Ethernet (ECM)"; |
292 | } else { | 317 | } else { |