aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/gadget_chips.h
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2005-07-13 18:18:30 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-08 19:22:16 -0400
commit91e79c91fab10f5790159d8d0c1d16da2a9653f9 (patch)
treea557a39bfe9dce508317baf7cd2e5217ac6f0c5d /drivers/usb/gadget/gadget_chips.h
parent81671ddb7e24e9d1f84812dba8ed810935f77d40 (diff)
[PATCH] USB: Gadget library: centralize gadget controller numbers
This patch centralizes the assignment of bcdDevice numbers for different gadget controllers. This won't improve the object code at all, but it does save a lot of repetitive and error-prone source code ... and will simplify the work of supporting a new controller driver, since most new gadget drivers will no longer need patches (unless some hardware quirks limit USB protocol messaging). Added minor cleanups and identifer hooks for the UDC in the Freescale iMX series processors. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/gadget_chips.h')
-rw-r--r--drivers/usb/gadget/gadget_chips.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h
index ea2eb52c766d..8cbae21d84b9 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}