Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * USB device controllers have lots of quirks. Use these macros in |
| 3 | * gadget drivers or other code that needs to deal with them, and which |
| 4 | * autoconfigures instead of using early binding to the hardware. |
| 5 | * |
David Brownell | 1c05ad4 | 2006-01-25 08:45:59 -0800 | [diff] [blame] | 6 | * This SHOULD eventually work like the ARM mach_is_*() stuff, driven by |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * some config file that gets updated as new hardware is supported. |
David Brownell | 1c05ad4 | 2006-01-25 08:45:59 -0800 | [diff] [blame] | 8 | * (And avoiding all runtime comparisons in typical one-choice configs!) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * |
| 10 | * NOTE: some of these controller drivers may not be available yet. |
| 11 | */ |
| 12 | #ifdef CONFIG_USB_GADGET_NET2280 |
| 13 | #define gadget_is_net2280(g) !strcmp("net2280", (g)->name) |
| 14 | #else |
| 15 | #define gadget_is_net2280(g) 0 |
| 16 | #endif |
| 17 | |
| 18 | #ifdef CONFIG_USB_GADGET_DUMMY_HCD |
| 19 | #define gadget_is_dummy(g) !strcmp("dummy_udc", (g)->name) |
| 20 | #else |
| 21 | #define gadget_is_dummy(g) 0 |
| 22 | #endif |
| 23 | |
| 24 | #ifdef CONFIG_USB_GADGET_PXA2XX |
| 25 | #define gadget_is_pxa(g) !strcmp("pxa2xx_udc", (g)->name) |
| 26 | #else |
| 27 | #define gadget_is_pxa(g) 0 |
| 28 | #endif |
| 29 | |
| 30 | #ifdef CONFIG_USB_GADGET_GOKU |
| 31 | #define gadget_is_goku(g) !strcmp("goku_udc", (g)->name) |
| 32 | #else |
| 33 | #define gadget_is_goku(g) 0 |
| 34 | #endif |
| 35 | |
| 36 | #ifdef CONFIG_USB_GADGET_SUPERH |
| 37 | #define gadget_is_sh(g) !strcmp("sh_udc", (g)->name) |
| 38 | #else |
| 39 | #define gadget_is_sh(g) 0 |
| 40 | #endif |
| 41 | |
| 42 | #ifdef CONFIG_USB_GADGET_SA1100 |
| 43 | #define gadget_is_sa1100(g) !strcmp("sa1100_udc", (g)->name) |
| 44 | #else |
| 45 | #define gadget_is_sa1100(g) 0 |
| 46 | #endif |
| 47 | |
| 48 | #ifdef CONFIG_USB_GADGET_LH7A40X |
| 49 | #define gadget_is_lh7a40x(g) !strcmp("lh7a40x_udc", (g)->name) |
| 50 | #else |
| 51 | #define gadget_is_lh7a40x(g) 0 |
| 52 | #endif |
| 53 | |
| 54 | #ifdef CONFIG_USB_GADGET_MQ11XX |
| 55 | #define gadget_is_mq11xx(g) !strcmp("mq11xx_udc", (g)->name) |
| 56 | #else |
| 57 | #define gadget_is_mq11xx(g) 0 |
| 58 | #endif |
| 59 | |
| 60 | #ifdef CONFIG_USB_GADGET_OMAP |
| 61 | #define gadget_is_omap(g) !strcmp("omap_udc", (g)->name) |
| 62 | #else |
| 63 | #define gadget_is_omap(g) 0 |
| 64 | #endif |
| 65 | |
| 66 | #ifdef CONFIG_USB_GADGET_N9604 |
| 67 | #define gadget_is_n9604(g) !strcmp("n9604_udc", (g)->name) |
| 68 | #else |
| 69 | #define gadget_is_n9604(g) 0 |
| 70 | #endif |
| 71 | |
| 72 | #ifdef CONFIG_USB_GADGET_PXA27X |
| 73 | #define gadget_is_pxa27x(g) !strcmp("pxa27x_udc", (g)->name) |
| 74 | #else |
| 75 | #define gadget_is_pxa27x(g) 0 |
| 76 | #endif |
| 77 | |
Håvard Skinnemoen | 1f5b9cc | 2007-01-17 11:03:29 -0800 | [diff] [blame] | 78 | #ifdef CONFIG_USB_GADGET_HUSB2DEV |
| 79 | #define gadget_is_husb2dev(g) !strcmp("husb2_udc", (g)->name) |
| 80 | #else |
| 81 | #define gadget_is_husb2dev(g) 0 |
| 82 | #endif |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | #ifdef CONFIG_USB_GADGET_S3C2410 |
| 85 | #define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name) |
| 86 | #else |
| 87 | #define gadget_is_s3c2410(g) 0 |
| 88 | #endif |
| 89 | |
| 90 | #ifdef CONFIG_USB_GADGET_AT91 |
| 91 | #define gadget_is_at91(g) !strcmp("at91_udc", (g)->name) |
| 92 | #else |
| 93 | #define gadget_is_at91(g) 0 |
| 94 | #endif |
| 95 | |
David Brownell | 91e79c9 | 2005-07-13 15:18:30 -0700 | [diff] [blame] | 96 | #ifdef CONFIG_USB_GADGET_IMX |
| 97 | #define gadget_is_imx(g) !strcmp("imx_udc", (g)->name) |
| 98 | #else |
| 99 | #define gadget_is_imx(g) 0 |
| 100 | #endif |
| 101 | |
Li Yang | d2eef1f | 2007-04-23 10:37:36 -0700 | [diff] [blame] | 102 | #ifdef CONFIG_USB_GADGET_FSL_USB2 |
| 103 | #define gadget_is_fsl_usb2(g) !strcmp("fsl-usb2-udc", (g)->name) |
| 104 | #else |
| 105 | #define gadget_is_fsl_usb2(g) 0 |
| 106 | #endif |
| 107 | |
David Brownell | 1c05ad4 | 2006-01-25 08:45:59 -0800 | [diff] [blame] | 108 | /* Mentor high speed function controller */ |
| 109 | #ifdef CONFIG_USB_GADGET_MUSBHSFC |
| 110 | #define gadget_is_musbhsfc(g) !strcmp("musbhsfc_udc", (g)->name) |
| 111 | #else |
| 112 | #define gadget_is_musbhsfc(g) 0 |
| 113 | #endif |
| 114 | |
David Brownell | 4279541 | 2006-04-02 10:18:34 -0800 | [diff] [blame] | 115 | /* Mentor high speed "dual role" controller, in peripheral role */ |
| 116 | #ifdef CONFIG_USB_GADGET_MUSB_HDRC |
| 117 | #define gadget_is_musbhdrc(g) !strcmp("musb_hdrc", (g)->name) |
David Brownell | 1c05ad4 | 2006-01-25 08:45:59 -0800 | [diff] [blame] | 118 | #else |
| 119 | #define gadget_is_musbhdrc(g) 0 |
| 120 | #endif |
| 121 | |
| 122 | #ifdef CONFIG_USB_GADGET_MPC8272 |
| 123 | #define gadget_is_mpc8272(g) !strcmp("mpc8272_udc", (g)->name) |
| 124 | #else |
| 125 | #define gadget_is_mpc8272(g) 0 |
| 126 | #endif |
| 127 | |
Yoshihiro Shimoda | 4cf2503 | 2007-05-10 13:18:23 +0900 | [diff] [blame^] | 128 | #ifdef CONFIG_USB_GADGET_M66592 |
| 129 | #define gadget_is_m66592(g) !strcmp("m66592_udc", (g)->name) |
| 130 | #else |
| 131 | #define gadget_is_m66592(g) 0 |
| 132 | #endif |
| 133 | |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | // CONFIG_USB_GADGET_SX2 |
| 136 | // CONFIG_USB_GADGET_AU1X00 |
| 137 | // ... |
| 138 | |
David Brownell | 91e79c9 | 2005-07-13 15:18:30 -0700 | [diff] [blame] | 139 | |
| 140 | /** |
| 141 | * usb_gadget_controller_number - support bcdDevice id convention |
| 142 | * @gadget: the controller being driven |
| 143 | * |
| 144 | * Return a 2-digit BCD value associated with the peripheral controller, |
| 145 | * suitable for use as part of a bcdDevice value, or a negative error code. |
| 146 | * |
| 147 | * NOTE: this convention is purely optional, and has no meaning in terms of |
| 148 | * any USB specification. If you want to use a different convention in your |
| 149 | * gadget driver firmware -- maybe a more formal revision ID -- feel free. |
| 150 | * |
| 151 | * Hosts see these bcdDevice numbers, and are allowed (but not encouraged!) |
| 152 | * to change their behavior accordingly. For example it might help avoiding |
| 153 | * some chip bug. |
| 154 | */ |
| 155 | static inline int usb_gadget_controller_number(struct usb_gadget *gadget) |
| 156 | { |
| 157 | if (gadget_is_net2280(gadget)) |
| 158 | return 0x01; |
| 159 | else if (gadget_is_dummy(gadget)) |
| 160 | return 0x02; |
| 161 | else if (gadget_is_pxa(gadget)) |
| 162 | return 0x03; |
| 163 | else if (gadget_is_sh(gadget)) |
| 164 | return 0x04; |
| 165 | else if (gadget_is_sa1100(gadget)) |
| 166 | return 0x05; |
| 167 | else if (gadget_is_goku(gadget)) |
| 168 | return 0x06; |
| 169 | else if (gadget_is_mq11xx(gadget)) |
| 170 | return 0x07; |
| 171 | else if (gadget_is_omap(gadget)) |
| 172 | return 0x08; |
| 173 | else if (gadget_is_lh7a40x(gadget)) |
| 174 | return 0x09; |
| 175 | else if (gadget_is_n9604(gadget)) |
| 176 | return 0x10; |
| 177 | else if (gadget_is_pxa27x(gadget)) |
| 178 | return 0x11; |
| 179 | else if (gadget_is_s3c2410(gadget)) |
| 180 | return 0x12; |
| 181 | else if (gadget_is_at91(gadget)) |
| 182 | return 0x13; |
| 183 | else if (gadget_is_imx(gadget)) |
| 184 | return 0x14; |
David Brownell | 1c05ad4 | 2006-01-25 08:45:59 -0800 | [diff] [blame] | 185 | else if (gadget_is_musbhsfc(gadget)) |
| 186 | return 0x15; |
| 187 | else if (gadget_is_musbhdrc(gadget)) |
| 188 | return 0x16; |
| 189 | else if (gadget_is_mpc8272(gadget)) |
| 190 | return 0x17; |
Håvard Skinnemoen | 1f5b9cc | 2007-01-17 11:03:29 -0800 | [diff] [blame] | 191 | else if (gadget_is_husb2dev(gadget)) |
| 192 | return 0x18; |
Li Yang | d2eef1f | 2007-04-23 10:37:36 -0700 | [diff] [blame] | 193 | else if (gadget_is_fsl_usb2(gadget)) |
| 194 | return 0x19; |
Yoshihiro Shimoda | 4cf2503 | 2007-05-10 13:18:23 +0900 | [diff] [blame^] | 195 | else if (gadget_is_m66592(gadget)) |
| 196 | return 0x20; |
David Brownell | 91e79c9 | 2005-07-13 15:18:30 -0700 | [diff] [blame] | 197 | return -ENOENT; |
| 198 | } |