aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/gadget/ether.c33
-rw-r--r--drivers/usb/gadget/file_storage.c33
-rw-r--r--drivers/usb/gadget/gadget_chips.h55
-rw-r--r--drivers/usb/gadget/serial.c51
-rw-r--r--drivers/usb/gadget/zero.c48
5 files changed, 92 insertions, 128 deletions
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 8509e955007..49459e33e95 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -2181,6 +2181,7 @@ eth_bind (struct usb_gadget *gadget)
2181 u8 cdc = 1, zlp = 1, rndis = 1; 2181 u8 cdc = 1, zlp = 1, rndis = 1;
2182 struct usb_ep *in_ep, *out_ep, *status_ep = NULL; 2182 struct usb_ep *in_ep, *out_ep, *status_ep = NULL;
2183 int status = -ENOMEM; 2183 int status = -ENOMEM;
2184 int gcnum;
2184 2185
2185 /* these flags are only ever cleared; compiler take note */ 2186 /* these flags are only ever cleared; compiler take note */
2186#ifndef DEV_CONFIG_CDC 2187#ifndef DEV_CONFIG_CDC
@@ -2194,44 +2195,26 @@ eth_bind (struct usb_gadget *gadget)
2194 * standard protocol is _strongly_ preferred for interop purposes. 2195 * standard protocol is _strongly_ preferred for interop purposes.
2195 * (By everyone except Microsoft.) 2196 * (By everyone except Microsoft.)
2196 */ 2197 */
2197 if (gadget_is_net2280 (gadget)) { 2198 if (gadget_is_pxa (gadget)) {
2198 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0201);
2199 } else if (gadget_is_dummy (gadget)) {
2200 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0202);
2201 } else if (gadget_is_pxa (gadget)) {
2202 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0203);
2203 /* pxa doesn't support altsettings */ 2199 /* pxa doesn't support altsettings */
2204 cdc = 0; 2200 cdc = 0;
2205 } else if (gadget_is_sh(gadget)) { 2201 } else if (gadget_is_sh(gadget)) {
2206 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0204);
2207 /* sh doesn't support multiple interfaces or configs */ 2202 /* sh doesn't support multiple interfaces or configs */
2208 cdc = 0; 2203 cdc = 0;
2209 rndis = 0; 2204 rndis = 0;
2210 } else if (gadget_is_sa1100 (gadget)) { 2205 } else if (gadget_is_sa1100 (gadget)) {
2211 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0205);
2212 /* hardware can't write zlps */ 2206 /* hardware can't write zlps */
2213 zlp = 0; 2207 zlp = 0;
2214 /* sa1100 CAN do CDC, without status endpoint ... we use 2208 /* sa1100 CAN do CDC, without status endpoint ... we use
2215 * non-CDC to be compatible with ARM Linux-2.4 "usb-eth". 2209 * non-CDC to be compatible with ARM Linux-2.4 "usb-eth".
2216 */ 2210 */
2217 cdc = 0; 2211 cdc = 0;
2218 } else if (gadget_is_goku (gadget)) { 2212 }
2219 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0206); 2213
2220 } else if (gadget_is_mq11xx (gadget)) { 2214 gcnum = usb_gadget_controller_number (gadget);
2221 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0207); 2215 if (gcnum >= 0)
2222 } else if (gadget_is_omap (gadget)) { 2216 device_desc.bcdDevice = cpu_to_le16 (0x0200 + gcnum);
2223 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0208); 2217 else {
2224 } else if (gadget_is_lh7a40x(gadget)) {
2225 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0209);
2226 } else if (gadget_is_n9604(gadget)) {
2227 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210);
2228 } else if (gadget_is_pxa27x(gadget)) {
2229 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211);
2230 } else if (gadget_is_s3c2410(gadget)) {
2231 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212);
2232 } else if (gadget_is_at91(gadget)) {
2233 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213);
2234 } else {
2235 /* can't assume CDC works. don't want to default to 2218 /* can't assume CDC works. don't want to default to
2236 * anything less functional on CDC-capable hardware, 2219 * anything less functional on CDC-capable hardware,
2237 * so we fail in this case. 2220 * so we fail in this case.
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 4f57085619b..a41d9d4baee 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3713,6 +3713,7 @@ static void fsg_unbind(struct usb_gadget *gadget)
3713static int __init check_parameters(struct fsg_dev *fsg) 3713static int __init check_parameters(struct fsg_dev *fsg)
3714{ 3714{
3715 int prot; 3715 int prot;
3716 int gcnum;
3716 3717
3717 /* Store the default values */ 3718 /* Store the default values */
3718 mod_data.transport_type = USB_PR_BULK; 3719 mod_data.transport_type = USB_PR_BULK;
@@ -3724,33 +3725,13 @@ static int __init check_parameters(struct fsg_dev *fsg)
3724 mod_data.can_stall = 0; 3725 mod_data.can_stall = 0;
3725 3726
3726 if (mod_data.release == 0xffff) { // Parameter wasn't set 3727 if (mod_data.release == 0xffff) { // Parameter wasn't set
3727 if (gadget_is_net2280(fsg->gadget))
3728 mod_data.release = 0x0301;
3729 else if (gadget_is_dummy(fsg->gadget))
3730 mod_data.release = 0x0302;
3731 else if (gadget_is_pxa(fsg->gadget))
3732 mod_data.release = 0x0303;
3733 else if (gadget_is_sh(fsg->gadget))
3734 mod_data.release = 0x0304;
3735
3736 /* The sa1100 controller is not supported */ 3728 /* The sa1100 controller is not supported */
3737 3729 if (gadget_is_sa1100(fsg->gadget))
3738 else if (gadget_is_goku(fsg->gadget)) 3730 gcnum = -1;
3739 mod_data.release = 0x0306; 3731 else
3740 else if (gadget_is_mq11xx(fsg->gadget)) 3732 gcnum = usb_gadget_controller_number(fsg->gadget);
3741 mod_data.release = 0x0307; 3733 if (gcnum >= 0)
3742 else if (gadget_is_omap(fsg->gadget)) 3734 mod_data.release = 0x0300 + gcnum;
3743 mod_data.release = 0x0308;
3744 else if (gadget_is_lh7a40x(fsg->gadget))
3745 mod_data.release = 0x0309;
3746 else if (gadget_is_n9604(fsg->gadget))
3747 mod_data.release = 0x0310;
3748 else if (gadget_is_pxa27x(fsg->gadget))
3749 mod_data.release = 0x0311;
3750 else if (gadget_is_s3c2410(gadget))
3751 mod_data.release = 0x0312;
3752 else if (gadget_is_at91(fsg->gadget))
3753 mod_data.release = 0x0313;
3754 else { 3735 else {
3755 WARN(fsg, "controller '%s' not recognized\n", 3736 WARN(fsg, "controller '%s' not recognized\n",
3756 fsg->gadget->name); 3737 fsg->gadget->name);
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
index ea2eb52c766..8cbae21d84b 100644
--- a/drivers/usb/gadget/gadget_chips.h
+++ b/drivers/usb/gadget/gadget_chips.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * This could eventually work like the ARM mach_is_*() stuff, driven by 6 * This could eventually work like the ARM mach_is_*() stuff, driven by
7 * some config file that gets updated as new hardware is supported. 7 * some config file that gets updated as new hardware is supported.
8 * (And avoiding the runtime comparisons in typical one-choice cases.)
8 * 9 *
9 * NOTE: some of these controller drivers may not be available yet. 10 * NOTE: some of these controller drivers may not be available yet.
10 */ 11 */
@@ -86,7 +87,61 @@
86#define gadget_is_at91(g) 0 87#define gadget_is_at91(g) 0
87#endif 88#endif
88 89
90#ifdef CONFIG_USB_GADGET_IMX
91#define gadget_is_imx(g) !strcmp("imx_udc", (g)->name)
92#else
93#define gadget_is_imx(g) 0
94#endif
95
89// CONFIG_USB_GADGET_SX2 96// CONFIG_USB_GADGET_SX2
90// CONFIG_USB_GADGET_AU1X00 97// CONFIG_USB_GADGET_AU1X00
91// ... 98// ...
92 99
100
101/**
102 * usb_gadget_controller_number - support bcdDevice id convention
103 * @gadget: the controller being driven
104 *
105 * Return a 2-digit BCD value associated with the peripheral controller,
106 * suitable for use as part of a bcdDevice value, or a negative error code.
107 *
108 * NOTE: this convention is purely optional, and has no meaning in terms of
109 * any USB specification. If you want to use a different convention in your
110 * gadget driver firmware -- maybe a more formal revision ID -- feel free.
111 *
112 * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!)
113 * to change their behavior accordingly. For example it might help avoiding
114 * some chip bug.
115 */
116static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
117{
118 if (gadget_is_net2280(gadget))
119 return 0x01;
120 else if (gadget_is_dummy(gadget))
121 return 0x02;
122 else if (gadget_is_pxa(gadget))
123 return 0x03;
124 else if (gadget_is_sh(gadget))
125 return 0x04;
126 else if (gadget_is_sa1100(gadget))
127 return 0x05;
128 else if (gadget_is_goku(gadget))
129 return 0x06;
130 else if (gadget_is_mq11xx(gadget))
131 return 0x07;
132 else if (gadget_is_omap(gadget))
133 return 0x08;
134 else if (gadget_is_lh7a40x(gadget))
135 return 0x09;
136 else if (gadget_is_n9604(gadget))
137 return 0x10;
138 else if (gadget_is_pxa27x(gadget))
139 return 0x11;
140 else if (gadget_is_s3c2410(gadget))
141 return 0x12;
142 else if (gadget_is_at91(gadget))
143 return 0x13;
144 else if (gadget_is_imx(gadget))
145 return 0x14;
146 return -ENOENT;
147}
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 9e4f1c6935a..c925d9222f5 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -1422,49 +1422,20 @@ static int gs_bind(struct usb_gadget *gadget)
1422 int ret; 1422 int ret;
1423 struct usb_ep *ep; 1423 struct usb_ep *ep;
1424 struct gs_dev *dev; 1424 struct gs_dev *dev;
1425 int gcnum;
1425 1426
1426 /* device specific */ 1427 /* Some controllers can't support CDC ACM:
1427 if (gadget_is_net2280(gadget)) { 1428 * - sh doesn't support multiple interfaces or configs;
1428 gs_device_desc.bcdDevice = 1429 * - sa1100 doesn't have a third interrupt endpoint
1429 __constant_cpu_to_le16(GS_VERSION_NUM|0x0001); 1430 */
1430 } else if (gadget_is_pxa(gadget)) { 1431 if (gadget_is_sh(gadget) || gadget_is_sa1100(gadget))
1431 gs_device_desc.bcdDevice =
1432 __constant_cpu_to_le16(GS_VERSION_NUM|0x0002);
1433 } else if (gadget_is_sh(gadget)) {
1434 gs_device_desc.bcdDevice =
1435 __constant_cpu_to_le16(GS_VERSION_NUM|0x0003);
1436 /* sh doesn't support multiple interfaces or configs */
1437 use_acm = 0; 1432 use_acm = 0;
1438 } else if (gadget_is_sa1100(gadget)) { 1433
1439 gs_device_desc.bcdDevice = 1434 gcnum = usb_gadget_controller_number(gadget);
1440 __constant_cpu_to_le16(GS_VERSION_NUM|0x0004); 1435 if (gcnum >= 0)
1441 /* sa1100 doesn't support necessary endpoints */
1442 use_acm = 0;
1443 } else if (gadget_is_goku(gadget)) {
1444 gs_device_desc.bcdDevice =
1445 __constant_cpu_to_le16(GS_VERSION_NUM|0x0005);
1446 } else if (gadget_is_mq11xx(gadget)) {
1447 gs_device_desc.bcdDevice =
1448 __constant_cpu_to_le16(GS_VERSION_NUM|0x0006);
1449 } else if (gadget_is_omap(gadget)) {
1450 gs_device_desc.bcdDevice =
1451 __constant_cpu_to_le16(GS_VERSION_NUM|0x0007);
1452 } else if (gadget_is_lh7a40x(gadget)) {
1453 gs_device_desc.bcdDevice =
1454 __constant_cpu_to_le16(GS_VERSION_NUM|0x0008);
1455 } else if (gadget_is_n9604(gadget)) {
1456 gs_device_desc.bcdDevice =
1457 __constant_cpu_to_le16(GS_VERSION_NUM|0x0009);
1458 } else if (gadget_is_pxa27x(gadget)) {
1459 gs_device_desc.bcdDevice =
1460 __constant_cpu_to_le16(GS_VERSION_NUM|0x0011);
1461 } else if (gadget_is_s3c2410(gadget)) {
1462 gs_device_desc.bcdDevice =
1463 __constant_cpu_to_le16(GS_VERSION_NUM|0x0012);
1464 } else if (gadget_is_at91(gadget)) {
1465 gs_device_desc.bcdDevice = 1436 gs_device_desc.bcdDevice =
1466 __constant_cpu_to_le16(GS_VERSION_NUM|0x0013); 1437 cpu_to_le16(GS_VERSION_NUM | gcnum);
1467 } else { 1438 else {
1468 printk(KERN_WARNING "gs_bind: controller '%s' not recognized\n", 1439 printk(KERN_WARNING "gs_bind: controller '%s' not recognized\n",
1469 gadget->name); 1440 gadget->name);
1470 /* unrecognized, but safe unless bulk is REALLY quirky */ 1441 /* unrecognized, but safe unless bulk is REALLY quirky */
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index bb9b2d94eed..6890e773b2a 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1139,6 +1139,13 @@ zero_bind (struct usb_gadget *gadget)
1139{ 1139{
1140 struct zero_dev *dev; 1140 struct zero_dev *dev;
1141 struct usb_ep *ep; 1141 struct usb_ep *ep;
1142 int gcnum;
1143
1144 /* FIXME this can't yet work right with SH ... it has only
1145 * one configuration, numbered one.
1146 */
1147 if (gadget_is_sh(gadget))
1148 return -ENODEV;
1142 1149
1143 /* Bulk-only drivers like this one SHOULD be able to 1150 /* Bulk-only drivers like this one SHOULD be able to
1144 * autoconfigure on any sane usb controller driver, 1151 * autoconfigure on any sane usb controller driver,
@@ -1161,43 +1168,10 @@ autoconf_fail:
1161 EP_OUT_NAME = ep->name; 1168 EP_OUT_NAME = ep->name;
1162 ep->driver_data = ep; /* claim */ 1169 ep->driver_data = ep; /* claim */
1163 1170
1164 1171 gcnum = usb_gadget_controller_number (gadget);
1165 /* 1172 if (gcnum >= 0)
1166 * DRIVER POLICY CHOICE: you may want to do this differently. 1173 device_desc.bcdDevice = cpu_to_le16 (0x0200 + gcnum);
1167 * One thing to avoid is reusing a bcdDevice revision code 1174 else {
1168 * with different host-visible configurations or behavior
1169 * restrictions -- using ep1in/ep2out vs ep1out/ep3in, etc
1170 */
1171 if (gadget_is_net2280 (gadget)) {
1172 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0201);
1173 } else if (gadget_is_pxa (gadget)) {
1174 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0203);
1175#if 0
1176 } else if (gadget_is_sh(gadget)) {
1177 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0204);
1178 /* SH has only one configuration; see "loopdefault" */
1179 device_desc.bNumConfigurations = 1;
1180 /* FIXME make 1 == default.bConfigurationValue */
1181#endif
1182 } else if (gadget_is_sa1100 (gadget)) {
1183 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0205);
1184 } else if (gadget_is_goku (gadget)) {
1185 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0206);
1186 } else if (gadget_is_mq11xx (gadget)) {
1187 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0207);
1188 } else if (gadget_is_omap (gadget)) {
1189 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0208);
1190 } else if (gadget_is_lh7a40x(gadget)) {
1191 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0209);
1192 } else if (gadget_is_n9604(gadget)) {
1193 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0210);
1194 } else if (gadget_is_pxa27x(gadget)) {
1195 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0211);
1196 } else if (gadget_is_s3c2410(gadget)) {
1197 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0212);
1198 } else if (gadget_is_at91(gadget)) {
1199 device_desc.bcdDevice = __constant_cpu_to_le16 (0x0213);
1200 } else {
1201 /* gadget zero is so simple (for now, no altsettings) that 1175 /* gadget zero is so simple (for now, no altsettings) that
1202 * it SHOULD NOT have problems with bulk-capable hardware. 1176 * it SHOULD NOT have problems with bulk-capable hardware.
1203 * so warn about unrcognized controllers, don't panic. 1177 * so warn about unrcognized controllers, don't panic.