aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 16:23:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 16:23:01 -0400
commitd9a807461fc8cc0d6ba589ea0730d139122af012 (patch)
tree9d8c7a044659d821748dd40718a22557c04e4299 /include
parent3498d13b8090c0b0ef911409fbc503a7c4cca6ef (diff)
parent70c048a238c780c226eb4b115ebaa908cb3b34ec (diff)
Merge tag 'usb-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB changes from Greg Kroah-Hartman: "Here is the big USB pull request for 3.7-rc1 There are lots of gadget driver changes (including copying a bunch of files into the drivers/staging/ccg/ directory so that the other gadget drivers can be fixed up properly without breaking that driver), and we remove the old obsolete ub.c driver from the tree. There are also the usual XHCI set of updates, and other various driver changes and updates. We also are trying hard to remove the old dbg() macro, but the final bits of that removal will be coming in through the networking tree before we can delete it for good. All of these patches have been in the linux-next tree. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" Fix up several annoying - but fairly mindless - conflicts due to the termios structure having moved into the tty device, and often clashing with dbg -> dev_dbg conversion. * tag 'usb-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (339 commits) USB: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc USB: uas: fix gcc warning USB: uas: fix locking USB: Fix race condition when removing host controllers USB: uas: add locking USB: uas: fix abort USB: uas: remove aborted field, replace with status bit. USB: uas: fix task management USB: uas: keep track of command urbs xhci: Intel Panther Point BEI quirk. powerpc/usb: remove checking PHY_CLK_VALID for UTMI PHY USB: ftdi_sio: add TIAO USB Multi-Protocol Adapter (TUMPA) support Revert "usb : Add sysfs files to control port power." USB: serial: remove vizzini driver usb: host: xhci: Fix Null pointer dereferencing with 71c731a for non-x86 systems Increase XHCI suspend timeout to 16ms USB: ohci-at91: fix null pointer in ohci_hcd_at91_overcurrent_irq USB: sierra_ms: don't keep unused variable fsl/usb: Add support for USB controller version 2.4 USB: qcaux: add Pantech vendor class match ...
Diffstat (limited to 'include')
-rw-r--r--include/linux/bcd.h17
-rw-r--r--include/linux/fsl_devices.h2
-rw-r--r--include/linux/usb.h32
-rw-r--r--include/linux/usb/ch11.h4
-rw-r--r--include/linux/usb/composite.h97
-rw-r--r--include/linux/usb/ehci_def.h35
-rw-r--r--include/linux/usb/ehci_pdriver.h8
-rw-r--r--include/linux/usb/ezusb.h16
-rw-r--r--include/linux/usb/gadget.h33
-rw-r--r--include/linux/usb/hcd.h4
-rw-r--r--include/linux/usb/nop-usb-xceiv.h24
-rw-r--r--include/linux/usb/ohci_pdriver.h8
-rw-r--r--include/linux/usb/omap_usb.h46
-rw-r--r--include/linux/usb/otg.h236
-rw-r--r--include/linux/usb/phy.h233
-rw-r--r--include/linux/usb/phy_companion.h34
-rw-r--r--include/linux/usb/quirks.h4
-rw-r--r--include/linux/usb/serial.h32
-rw-r--r--include/linux/usb/tegra_usb_phy.h80
-rw-r--r--include/linux/usb_usual.h24
-rw-r--r--include/linux/usbdevice_fs.h14
-rw-r--r--include/xen/interface/physdev.h16
22 files changed, 652 insertions, 347 deletions
diff --git a/include/linux/bcd.h b/include/linux/bcd.h
index 22ea563ba3eb..18fff11fb3ea 100644
--- a/include/linux/bcd.h
+++ b/include/linux/bcd.h
@@ -3,7 +3,20 @@
3 3
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5 5
6unsigned bcd2bin(unsigned char val) __attribute_const__; 6#define bcd2bin(x) \
7unsigned char bin2bcd(unsigned val) __attribute_const__; 7 (__builtin_constant_p((u8 )(x)) ? \
8 const_bcd2bin(x) : \
9 _bcd2bin(x))
10
11#define bin2bcd(x) \
12 (__builtin_constant_p((u8 )(x)) ? \
13 const_bin2bcd(x) : \
14 _bin2bcd(x))
15
16#define const_bcd2bin(x) (((x) & 0x0f) + ((x) >> 4) * 10)
17#define const_bin2bcd(x) ((((x) / 10) << 4) + (x) % 10)
18
19unsigned _bcd2bin(unsigned char val) __attribute_const__;
20unsigned char _bin2bcd(unsigned val) __attribute_const__;
8 21
9#endif /* _BCD_H */ 22#endif /* _BCD_H */
diff --git a/include/linux/fsl_devices.h b/include/linux/fsl_devices.h
index 15be561e7397..a82296af413f 100644
--- a/include/linux/fsl_devices.h
+++ b/include/linux/fsl_devices.h
@@ -19,9 +19,11 @@
19 19
20#define FSL_UTMI_PHY_DLY 10 /*As per P1010RM, delay for UTMI 20#define FSL_UTMI_PHY_DLY 10 /*As per P1010RM, delay for UTMI
21 PHY CLK to become stable - 10ms*/ 21 PHY CLK to become stable - 10ms*/
22#define FSL_USB_PHY_CLK_TIMEOUT 10000 /* uSec */
22#define FSL_USB_VER_OLD 0 23#define FSL_USB_VER_OLD 0
23#define FSL_USB_VER_1_6 1 24#define FSL_USB_VER_1_6 1
24#define FSL_USB_VER_2_2 2 25#define FSL_USB_VER_2_2 2
26#define FSL_USB_VER_2_4 3
25 27
26#include <linux/types.h> 28#include <linux/types.h>
27 29
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 30d1ae38eab1..07915a32fb9d 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -384,6 +384,13 @@ enum usb_device_removable {
384 USB_DEVICE_FIXED, 384 USB_DEVICE_FIXED,
385}; 385};
386 386
387enum usb_port_connect_type {
388 USB_PORT_CONNECT_TYPE_UNKNOWN = 0,
389 USB_PORT_CONNECT_TYPE_HOT_PLUG,
390 USB_PORT_CONNECT_TYPE_HARD_WIRED,
391 USB_PORT_NOT_USED,
392};
393
387/* 394/*
388 * USB 3.0 Link Power Management (LPM) parameters. 395 * USB 3.0 Link Power Management (LPM) parameters.
389 * 396 *
@@ -469,7 +476,6 @@ struct usb3_lpm_parameters {
469 * access from userspace 476 * access from userspace
470 * @usbfs_dentry: usbfs dentry entry for the device 477 * @usbfs_dentry: usbfs dentry entry for the device
471 * @maxchild: number of ports if hub 478 * @maxchild: number of ports if hub
472 * @children: child devices - USB devices that are attached to this hub
473 * @quirks: quirks of the whole device 479 * @quirks: quirks of the whole device
474 * @urbnum: number of URBs submitted for the whole device 480 * @urbnum: number of URBs submitted for the whole device
475 * @active_duration: total time device is not suspended 481 * @active_duration: total time device is not suspended
@@ -543,7 +549,6 @@ struct usb_device {
543 struct list_head filelist; 549 struct list_head filelist;
544 550
545 int maxchild; 551 int maxchild;
546 struct usb_device **children;
547 552
548 u32 quirks; 553 u32 quirks;
549 atomic_t urbnum; 554 atomic_t urbnum;
@@ -572,6 +577,19 @@ static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
572 577
573extern struct usb_device *usb_get_dev(struct usb_device *dev); 578extern struct usb_device *usb_get_dev(struct usb_device *dev);
574extern void usb_put_dev(struct usb_device *dev); 579extern void usb_put_dev(struct usb_device *dev);
580extern struct usb_device *usb_hub_find_child(struct usb_device *hdev,
581 int port1);
582
583/**
584 * usb_hub_for_each_child - iterate over all child devices on the hub
585 * @hdev: USB device belonging to the usb hub
586 * @port1: portnum associated with child device
587 * @child: child device pointer
588 */
589#define usb_hub_for_each_child(hdev, port1, child) \
590 for (port1 = 1, child = usb_hub_find_child(hdev, port1); \
591 port1 <= hdev->maxchild; \
592 child = usb_hub_find_child(hdev, ++port1))
575 593
576/* USB device locking */ 594/* USB device locking */
577#define usb_lock_device(udev) device_lock(&(udev)->dev) 595#define usb_lock_device(udev) device_lock(&(udev)->dev)
@@ -584,6 +602,16 @@ extern int usb_lock_device_for_reset(struct usb_device *udev,
584extern int usb_reset_device(struct usb_device *dev); 602extern int usb_reset_device(struct usb_device *dev);
585extern void usb_queue_reset_device(struct usb_interface *dev); 603extern void usb_queue_reset_device(struct usb_interface *dev);
586 604
605#ifdef CONFIG_ACPI
606extern int usb_acpi_set_power_state(struct usb_device *hdev, int index,
607 bool enable);
608extern bool usb_acpi_power_manageable(struct usb_device *hdev, int index);
609#else
610static inline int usb_acpi_set_power_state(struct usb_device *hdev, int index,
611 bool enable) { return 0; }
612static inline bool usb_acpi_power_manageable(struct usb_device *hdev, int index)
613 { return true; }
614#endif
587 615
588/* USB autosuspend and autoresume */ 616/* USB autosuspend and autoresume */
589#ifdef CONFIG_USB_SUSPEND 617#ifdef CONFIG_USB_SUSPEND
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h
index b6c2863b2c94..7692dc69ccf7 100644
--- a/include/linux/usb/ch11.h
+++ b/include/linux/usb/ch11.h
@@ -236,8 +236,8 @@ struct usb_hub_descriptor {
236 236
237 struct { 237 struct {
238 __u8 bHubHdrDecLat; 238 __u8 bHubHdrDecLat;
239 __u16 wHubDelay; 239 __le16 wHubDelay;
240 __u16 DeviceRemovable; 240 __le16 DeviceRemovable;
241 } __attribute__ ((packed)) ss; 241 } __attribute__ ((packed)) ss;
242 } u; 242 } u;
243} __attribute__ ((packed)); 243} __attribute__ ((packed));
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 9d8c3b634493..f8dda0621800 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -34,6 +34,8 @@
34 * the composite model the host can use both functions at the same time. 34 * the composite model the host can use both functions at the same time.
35 */ 35 */
36 36
37#include <linux/bcd.h>
38#include <linux/version.h>
37#include <linux/usb/ch9.h> 39#include <linux/usb/ch9.h>
38#include <linux/usb/gadget.h> 40#include <linux/usb/gadget.h>
39 41
@@ -46,6 +48,9 @@
46 */ 48 */
47#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */ 49#define USB_GADGET_DELAYED_STATUS 0x7fff /* Impossibly large value */
48 50
51/* big enough to hold our biggest descriptor */
52#define USB_COMP_EP0_BUFSIZ 1024
53
49struct usb_configuration; 54struct usb_configuration;
50 55
51/** 56/**
@@ -245,24 +250,31 @@ int usb_add_config(struct usb_composite_dev *,
245void usb_remove_config(struct usb_composite_dev *, 250void usb_remove_config(struct usb_composite_dev *,
246 struct usb_configuration *); 251 struct usb_configuration *);
247 252
253/* predefined index for usb_composite_driver */
254enum {
255 USB_GADGET_MANUFACTURER_IDX = 0,
256 USB_GADGET_PRODUCT_IDX,
257 USB_GADGET_SERIAL_IDX,
258 USB_GADGET_FIRST_AVAIL_IDX,
259};
260
248/** 261/**
249 * struct usb_composite_driver - groups configurations into a gadget 262 * struct usb_composite_driver - groups configurations into a gadget
250 * @name: For diagnostics, identifies the driver. 263 * @name: For diagnostics, identifies the driver.
251 * @iProduct: Used as iProduct override if @dev->iProduct is not set.
252 * If NULL value of @name is taken.
253 * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
254 * not set. If NULL a default "<system> <release> with <udc>" value
255 * will be used.
256 * @iSerialNumber: Used as iSerialNumber override if @dev->iSerialNumber is
257 * not set.
258 * @dev: Template descriptor for the device, including default device 264 * @dev: Template descriptor for the device, including default device
259 * identifiers. 265 * identifiers.
260 * @strings: tables of strings, keyed by identifiers assigned during bind() 266 * @strings: tables of strings, keyed by identifiers assigned during @bind
261 * and language IDs provided in control requests 267 * and language IDs provided in control requests. Note: The first entries
268 * are predefined. The first entry that may be used is
269 * USB_GADGET_FIRST_AVAIL_IDX
262 * @max_speed: Highest speed the driver supports. 270 * @max_speed: Highest speed the driver supports.
263 * @needs_serial: set to 1 if the gadget needs userspace to provide 271 * @needs_serial: set to 1 if the gadget needs userspace to provide
264 * a serial number. If one is not provided, warning will be printed. 272 * a serial number. If one is not provided, warning will be printed.
265 * @unbind: Reverses bind; called as a side effect of unregistering 273 * @bind: (REQUIRED) Used to allocate resources that are shared across the
274 * whole device, such as string IDs, and add its configurations using
275 * @usb_add_config(). This may fail by returning a negative errno
276 * value; it should return zero on successful initialization.
277 * @unbind: Reverses @bind; called as a side effect of unregistering
266 * this driver. 278 * this driver.
267 * @disconnect: optional driver disconnect method 279 * @disconnect: optional driver disconnect method
268 * @suspend: Notifies when the host stops sending USB traffic, 280 * @suspend: Notifies when the host stops sending USB traffic,
@@ -271,9 +283,9 @@ void usb_remove_config(struct usb_composite_dev *,
271 * before function notifications 283 * before function notifications
272 * 284 *
273 * Devices default to reporting self powered operation. Devices which rely 285 * Devices default to reporting self powered operation. Devices which rely
274 * on bus powered operation should report this in their @bind() method. 286 * on bus powered operation should report this in their @bind method.
275 * 287 *
276 * Before returning from bind, various fields in the template descriptor 288 * Before returning from @bind, various fields in the template descriptor
277 * may be overridden. These include the idVendor/idProduct/bcdDevice values 289 * may be overridden. These include the idVendor/idProduct/bcdDevice values
278 * normally to bind the appropriate host side driver, and the three strings 290 * normally to bind the appropriate host side driver, and the three strings
279 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user 291 * (iManufacturer, iProduct, iSerialNumber) normally used to provide user
@@ -283,14 +295,12 @@ void usb_remove_config(struct usb_composite_dev *,
283 */ 295 */
284struct usb_composite_driver { 296struct usb_composite_driver {
285 const char *name; 297 const char *name;
286 const char *iProduct;
287 const char *iManufacturer;
288 const char *iSerialNumber;
289 const struct usb_device_descriptor *dev; 298 const struct usb_device_descriptor *dev;
290 struct usb_gadget_strings **strings; 299 struct usb_gadget_strings **strings;
291 enum usb_device_speed max_speed; 300 enum usb_device_speed max_speed;
292 unsigned needs_serial:1; 301 unsigned needs_serial:1;
293 302
303 int (*bind)(struct usb_composite_dev *cdev);
294 int (*unbind)(struct usb_composite_dev *); 304 int (*unbind)(struct usb_composite_dev *);
295 305
296 void (*disconnect)(struct usb_composite_dev *); 306 void (*disconnect)(struct usb_composite_dev *);
@@ -298,10 +308,10 @@ struct usb_composite_driver {
298 /* global suspend hooks */ 308 /* global suspend hooks */
299 void (*suspend)(struct usb_composite_dev *); 309 void (*suspend)(struct usb_composite_dev *);
300 void (*resume)(struct usb_composite_dev *); 310 void (*resume)(struct usb_composite_dev *);
311 struct usb_gadget_driver gadget_driver;
301}; 312};
302 313
303extern int usb_composite_probe(struct usb_composite_driver *driver, 314extern int usb_composite_probe(struct usb_composite_driver *driver);
304 int (*bind)(struct usb_composite_dev *cdev));
305extern void usb_composite_unregister(struct usb_composite_driver *driver); 315extern void usb_composite_unregister(struct usb_composite_driver *driver);
306extern void usb_composite_setup_continue(struct usb_composite_dev *cdev); 316extern void usb_composite_setup_continue(struct usb_composite_dev *cdev);
307 317
@@ -310,7 +320,6 @@ extern void usb_composite_setup_continue(struct usb_composite_dev *cdev);
310 * struct usb_composite_device - represents one composite usb gadget 320 * struct usb_composite_device - represents one composite usb gadget
311 * @gadget: read-only, abstracts the gadget's usb peripheral controller 321 * @gadget: read-only, abstracts the gadget's usb peripheral controller
312 * @req: used for control responses; buffer is pre-allocated 322 * @req: used for control responses; buffer is pre-allocated
313 * @bufsiz: size of buffer pre-allocated in @req
314 * @config: the currently active configuration 323 * @config: the currently active configuration
315 * 324 *
316 * One of these devices is allocated and initialized before the 325 * One of these devices is allocated and initialized before the
@@ -341,7 +350,6 @@ extern void usb_composite_setup_continue(struct usb_composite_dev *cdev);
341struct usb_composite_dev { 350struct usb_composite_dev {
342 struct usb_gadget *gadget; 351 struct usb_gadget *gadget;
343 struct usb_request *req; 352 struct usb_request *req;
344 unsigned bufsiz;
345 353
346 struct usb_configuration *config; 354 struct usb_configuration *config;
347 355
@@ -352,9 +360,7 @@ struct usb_composite_dev {
352 struct list_head configs; 360 struct list_head configs;
353 struct usb_composite_driver *driver; 361 struct usb_composite_driver *driver;
354 u8 next_string_id; 362 u8 next_string_id;
355 u8 manufacturer_override; 363 char *def_manufacturer;
356 u8 product_override;
357 u8 serial_override;
358 364
359 /* the gadget driver won't enable the data pullup 365 /* the gadget driver won't enable the data pullup
360 * while the deactivation count is nonzero. 366 * while the deactivation count is nonzero.
@@ -375,6 +381,53 @@ extern int usb_string_ids_tab(struct usb_composite_dev *c,
375 struct usb_string *str); 381 struct usb_string *str);
376extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); 382extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
377 383
384/*
385 * Some systems will need runtime overrides for the product identifiers
386 * published in the device descriptor, either numbers or strings or both.
387 * String parameters are in UTF-8 (superset of ASCII's 7 bit characters).
388 */
389struct usb_composite_overwrite {
390 u16 idVendor;
391 u16 idProduct;
392 u16 bcdDevice;
393 char *serial_number;
394 char *manufacturer;
395 char *product;
396};
397#define USB_GADGET_COMPOSITE_OPTIONS() \
398 static struct usb_composite_overwrite coverwrite; \
399 \
400 module_param_named(idVendor, coverwrite.idVendor, ushort, S_IRUGO); \
401 MODULE_PARM_DESC(idVendor, "USB Vendor ID"); \
402 \
403 module_param_named(idProduct, coverwrite.idProduct, ushort, S_IRUGO); \
404 MODULE_PARM_DESC(idProduct, "USB Product ID"); \
405 \
406 module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, S_IRUGO); \
407 MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); \
408 \
409 module_param_named(iSerialNumber, coverwrite.serial_number, charp, \
410 S_IRUGO); \
411 MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); \
412 \
413 module_param_named(iManufacturer, coverwrite.manufacturer, charp, \
414 S_IRUGO); \
415 MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \
416 \
417 module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \
418 MODULE_PARM_DESC(iProduct, "USB Product string")
419
420void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
421 struct usb_composite_overwrite *covr);
422
423static inline u16 get_default_bcdDevice(void)
424{
425 u16 bcdDevice;
426
427 bcdDevice = bin2bcd((LINUX_VERSION_CODE >> 16 & 0xff)) << 8;
428 bcdDevice |= bin2bcd((LINUX_VERSION_CODE >> 8 & 0xff));
429 return bcdDevice;
430}
378 431
379/* messaging utils */ 432/* messaging utils */
380#define DBG(d, fmt, args...) \ 433#define DBG(d, fmt, args...) \
diff --git a/include/linux/usb/ehci_def.h b/include/linux/usb/ehci_def.h
index de4b9ed5d5dd..daec99af5d54 100644
--- a/include/linux/usb/ehci_def.h
+++ b/include/linux/usb/ehci_def.h
@@ -171,18 +171,18 @@ struct ehci_regs {
171#define USBMODE_CM_HC (3<<0) /* host controller mode */ 171#define USBMODE_CM_HC (3<<0) /* host controller mode */
172#define USBMODE_CM_IDLE (0<<0) /* idle state */ 172#define USBMODE_CM_IDLE (0<<0) /* idle state */
173 173
174 u32 reserved4[7]; 174 u32 reserved4[6];
175 175
176/* Moorestown has some non-standard registers, partially due to the fact that 176/* Moorestown has some non-standard registers, partially due to the fact that
177 * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to 177 * its EHCI controller has both TT and LPM support. HOSTPCx are extensions to
178 * PORTSCx 178 * PORTSCx
179 */ 179 */
180 /* HOSTPC: offset 0x84 */ 180 /* HOSTPC: offset 0x84 */
181 u32 hostpc[0]; /* HOSTPC extension */ 181 u32 hostpc[1]; /* HOSTPC extension */
182#define HOSTPC_PHCD (1<<22) /* Phy clock disable */ 182#define HOSTPC_PHCD (1<<22) /* Phy clock disable */
183#define HOSTPC_PSPD (3<<25) /* Port speed detection */ 183#define HOSTPC_PSPD (3<<25) /* Port speed detection */
184 184
185 u32 reserved5[17]; 185 u32 reserved5[16];
186 186
187 /* USBMODE_EX: offset 0xc8 */ 187 /* USBMODE_EX: offset 0xc8 */
188 u32 usbmode_ex; /* USB Device mode extension */ 188 u32 usbmode_ex; /* USB Device mode extension */
@@ -221,18 +221,35 @@ extern int __init early_dbgp_init(char *s);
221extern struct console early_dbgp_console; 221extern struct console early_dbgp_console;
222#endif /* CONFIG_EARLY_PRINTK_DBGP */ 222#endif /* CONFIG_EARLY_PRINTK_DBGP */
223 223
224struct usb_hcd;
225
226#ifdef CONFIG_XEN_DOM0
227extern int xen_dbgp_reset_prep(struct usb_hcd *);
228extern int xen_dbgp_external_startup(struct usb_hcd *);
229#else
230static inline int xen_dbgp_reset_prep(struct usb_hcd *hcd)
231{
232 return 1; /* Shouldn't this be 0? */
233}
234
235static inline int xen_dbgp_external_startup(struct usb_hcd *hcd)
236{
237 return -1;
238}
239#endif
240
224#ifdef CONFIG_EARLY_PRINTK_DBGP 241#ifdef CONFIG_EARLY_PRINTK_DBGP
225/* Call backs from ehci host driver to ehci debug driver */ 242/* Call backs from ehci host driver to ehci debug driver */
226extern int dbgp_external_startup(void); 243extern int dbgp_external_startup(struct usb_hcd *);
227extern int dbgp_reset_prep(void); 244extern int dbgp_reset_prep(struct usb_hcd *hcd);
228#else 245#else
229static inline int dbgp_reset_prep(void) 246static inline int dbgp_reset_prep(struct usb_hcd *hcd)
230{ 247{
231 return 1; 248 return xen_dbgp_reset_prep(hcd);
232} 249}
233static inline int dbgp_external_startup(void) 250static inline int dbgp_external_startup(struct usb_hcd *hcd)
234{ 251{
235 return -1; 252 return xen_dbgp_external_startup(hcd);
236} 253}
237#endif 254#endif
238 255
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h
index 1894f42fe3f7..c9d09f8b7ff2 100644
--- a/include/linux/usb/ehci_pdriver.h
+++ b/include/linux/usb/ehci_pdriver.h
@@ -41,6 +41,14 @@ struct usb_ehci_pdata {
41 unsigned big_endian_mmio:1; 41 unsigned big_endian_mmio:1;
42 unsigned port_power_on:1; 42 unsigned port_power_on:1;
43 unsigned port_power_off:1; 43 unsigned port_power_off:1;
44
45 /* Turn on all power and clocks */
46 int (*power_on)(struct platform_device *pdev);
47 /* Turn off all power and clocks */
48 void (*power_off)(struct platform_device *pdev);
49 /* Turn on only VBUS suspend power and hotplug detection,
50 * turn off everything else */
51 void (*power_suspend)(struct platform_device *pdev);
44}; 52};
45 53
46#endif /* __USB_CORE_EHCI_PDRIVER_H */ 54#endif /* __USB_CORE_EHCI_PDRIVER_H */
diff --git a/include/linux/usb/ezusb.h b/include/linux/usb/ezusb.h
new file mode 100644
index 000000000000..fc618d8d1e92
--- /dev/null
+++ b/include/linux/usb/ezusb.h
@@ -0,0 +1,16 @@
1#ifndef __EZUSB_H
2#define __EZUSB_H
3
4
5extern int ezusb_writememory(struct usb_device *dev, int address,
6 unsigned char *data, int length, __u8 bRequest);
7
8extern int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit);
9extern int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit);
10
11extern int ezusb_fx1_ihex_firmware_download(struct usb_device *dev,
12 const char *firmware_path);
13extern int ezusb_fx2_ihex_firmware_download(struct usb_device *dev,
14 const char *firmware_path);
15
16#endif /* __EZUSB_H */
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 9517466ababb..5b6e50888248 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -474,7 +474,8 @@ struct usb_gadget_ops {
474 474
475 /* Those two are deprecated */ 475 /* Those two are deprecated */
476 int (*start)(struct usb_gadget_driver *, 476 int (*start)(struct usb_gadget_driver *,
477 int (*bind)(struct usb_gadget *)); 477 int (*bind)(struct usb_gadget *,
478 struct usb_gadget_driver *driver));
478 int (*stop)(struct usb_gadget_driver *); 479 int (*stop)(struct usb_gadget_driver *);
479}; 480};
480 481
@@ -502,6 +503,8 @@ struct usb_gadget_ops {
502 * @name: Identifies the controller hardware type. Used in diagnostics 503 * @name: Identifies the controller hardware type. Used in diagnostics
503 * and sometimes configuration. 504 * and sometimes configuration.
504 * @dev: Driver model state for this abstract device. 505 * @dev: Driver model state for this abstract device.
506 * @out_epnum: last used out ep number
507 * @in_epnum: last used in ep number
505 * 508 *
506 * Gadgets have a mostly-portable "gadget driver" implementing device 509 * Gadgets have a mostly-portable "gadget driver" implementing device
507 * functions, handling all usb configurations and interfaces. Gadget 510 * functions, handling all usb configurations and interfaces. Gadget
@@ -536,6 +539,8 @@ struct usb_gadget {
536 unsigned a_alt_hnp_support:1; 539 unsigned a_alt_hnp_support:1;
537 const char *name; 540 const char *name;
538 struct device dev; 541 struct device dev;
542 unsigned out_epnum;
543 unsigned in_epnum;
539}; 544};
540 545
541static inline void set_gadget_data(struct usb_gadget *gadget, void *data) 546static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
@@ -558,14 +563,7 @@ static inline struct usb_gadget *dev_to_usb_gadget(struct device *dev)
558 */ 563 */
559static inline int gadget_is_dualspeed(struct usb_gadget *g) 564static inline int gadget_is_dualspeed(struct usb_gadget *g)
560{ 565{
561#ifdef CONFIG_USB_GADGET_DUALSPEED 566 return g->max_speed >= USB_SPEED_HIGH;
562 /* runtime test would check "g->max_speed" ... that might be
563 * useful to work around hardware bugs, but is mostly pointless
564 */
565 return 1;
566#else
567 return 0;
568#endif
569} 567}
570 568
571/** 569/**
@@ -575,15 +573,7 @@ static inline int gadget_is_dualspeed(struct usb_gadget *g)
575 */ 573 */
576static inline int gadget_is_superspeed(struct usb_gadget *g) 574static inline int gadget_is_superspeed(struct usb_gadget *g)
577{ 575{
578#ifdef CONFIG_USB_GADGET_SUPERSPEED 576 return g->max_speed >= USB_SPEED_SUPER;
579 /*
580 * runtime test would check "g->max_speed" ... that might be
581 * useful to work around hardware bugs, but is mostly pointless
582 */
583 return 1;
584#else
585 return 0;
586#endif
587} 577}
588 578
589/** 579/**
@@ -781,6 +771,7 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
781 * when the host is disconnected. May be called in_interrupt; this 771 * when the host is disconnected. May be called in_interrupt; this
782 * may not sleep. Some devices can't detect disconnect, so this might 772 * may not sleep. Some devices can't detect disconnect, so this might
783 * not be called except as part of controller shutdown. 773 * not be called except as part of controller shutdown.
774 * @bind: the driver's bind callback
784 * @unbind: Invoked when the driver is unbound from a gadget, 775 * @unbind: Invoked when the driver is unbound from a gadget,
785 * usually from rmmod (after a disconnect is reported). 776 * usually from rmmod (after a disconnect is reported).
786 * Called in a context that permits sleeping. 777 * Called in a context that permits sleeping.
@@ -835,6 +826,8 @@ static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
835struct usb_gadget_driver { 826struct usb_gadget_driver {
836 char *function; 827 char *function;
837 enum usb_device_speed max_speed; 828 enum usb_device_speed max_speed;
829 int (*bind)(struct usb_gadget *gadget,
830 struct usb_gadget_driver *driver);
838 void (*unbind)(struct usb_gadget *); 831 void (*unbind)(struct usb_gadget *);
839 int (*setup)(struct usb_gadget *, 832 int (*setup)(struct usb_gadget *,
840 const struct usb_ctrlrequest *); 833 const struct usb_ctrlrequest *);
@@ -860,7 +853,6 @@ struct usb_gadget_driver {
860/** 853/**
861 * usb_gadget_probe_driver - probe a gadget driver 854 * usb_gadget_probe_driver - probe a gadget driver
862 * @driver: the driver being registered 855 * @driver: the driver being registered
863 * @bind: the driver's bind callback
864 * Context: can sleep 856 * Context: can sleep
865 * 857 *
866 * Call this in your gadget driver's module initialization function, 858 * Call this in your gadget driver's module initialization function,
@@ -869,8 +861,7 @@ struct usb_gadget_driver {
869 * registration call returns. It's expected that the @bind() function will 861 * registration call returns. It's expected that the @bind() function will
870 * be in init sections. 862 * be in init sections.
871 */ 863 */
872int usb_gadget_probe_driver(struct usb_gadget_driver *driver, 864int usb_gadget_probe_driver(struct usb_gadget_driver *driver);
873 int (*bind)(struct usb_gadget *));
874 865
875/** 866/**
876 * usb_gadget_unregister_driver - unregister a gadget driver 867 * usb_gadget_unregister_driver - unregister a gadget driver
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index c5fdb148fc02..608050b2545f 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -135,8 +135,8 @@ struct usb_hcd {
135 135
136 unsigned int irq; /* irq allocated */ 136 unsigned int irq; /* irq allocated */
137 void __iomem *regs; /* device memory/io */ 137 void __iomem *regs; /* device memory/io */
138 u64 rsrc_start; /* memory/io resource start */ 138 resource_size_t rsrc_start; /* memory/io resource start */
139 u64 rsrc_len; /* memory/io resource length */ 139 resource_size_t rsrc_len; /* memory/io resource length */
140 unsigned power_budget; /* in mA, 0 = no limit */ 140 unsigned power_budget; /* in mA, 0 = no limit */
141 141
142 /* bandwidth_mutex should be taken before adding or removing 142 /* bandwidth_mutex should be taken before adding or removing
diff --git a/include/linux/usb/nop-usb-xceiv.h b/include/linux/usb/nop-usb-xceiv.h
new file mode 100644
index 000000000000..28884c717411
--- /dev/null
+++ b/include/linux/usb/nop-usb-xceiv.h
@@ -0,0 +1,24 @@
1#ifndef __LINUX_USB_NOP_XCEIV_H
2#define __LINUX_USB_NOP_XCEIV_H
3
4#include <linux/usb/otg.h>
5
6struct nop_usb_xceiv_platform_data {
7 enum usb_phy_type type;
8};
9
10#if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE))
11/* sometimes transceivers are accessed only through e.g. ULPI */
12extern void usb_nop_xceiv_register(void);
13extern void usb_nop_xceiv_unregister(void);
14#else
15static inline void usb_nop_xceiv_register(void)
16{
17}
18
19static inline void usb_nop_xceiv_unregister(void)
20{
21}
22#endif
23
24#endif /* __LINUX_USB_NOP_XCEIV_H */
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h
index 2808f2a9cce8..74e7755168b7 100644
--- a/include/linux/usb/ohci_pdriver.h
+++ b/include/linux/usb/ohci_pdriver.h
@@ -33,6 +33,14 @@ struct usb_ohci_pdata {
33 unsigned big_endian_desc:1; 33 unsigned big_endian_desc:1;
34 unsigned big_endian_mmio:1; 34 unsigned big_endian_mmio:1;
35 unsigned no_big_frame_no:1; 35 unsigned no_big_frame_no:1;
36
37 /* Turn on all power and clocks */
38 int (*power_on)(struct platform_device *pdev);
39 /* Turn off all power and clocks */
40 void (*power_off)(struct platform_device *pdev);
41 /* Turn on only VBUS suspend power and hotplug detection,
42 * turn off everything else */
43 void (*power_suspend)(struct platform_device *pdev);
36}; 44};
37 45
38#endif /* __USB_CORE_OHCI_PDRIVER_H */ 46#endif /* __USB_CORE_OHCI_PDRIVER_H */
diff --git a/include/linux/usb/omap_usb.h b/include/linux/usb/omap_usb.h
new file mode 100644
index 000000000000..0ea17f8ae820
--- /dev/null
+++ b/include/linux/usb/omap_usb.h
@@ -0,0 +1,46 @@
1/*
2 * omap_usb.h -- omap usb2 phy header file
3 *
4 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Author: Kishon Vijay Abraham I <kishon@ti.com>
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef __DRIVERS_OMAP_USB2_H
20#define __DRIVERS_OMAP_USB2_H
21
22#include <linux/usb/otg.h>
23
24struct omap_usb {
25 struct usb_phy phy;
26 struct phy_companion *comparator;
27 struct device *dev;
28 u32 __iomem *control_dev;
29 struct clk *wkupclk;
30 u8 is_suspended:1;
31};
32
33#define PHY_PD 0x1
34
35#define phy_to_omapusb(x) container_of((x), struct omap_usb, phy)
36
37#if defined(CONFIG_OMAP_USB2) || defined(CONFIG_OMAP_USB2_MODULE)
38extern int omap_usb2_set_comparator(struct phy_companion *comparator);
39#else
40static inline int omap_usb2_set_comparator(struct phy_companion *comparator)
41{
42 return -ENODEV;
43}
44#endif
45
46#endif /* __DRIVERS_OMAP_USB_H */
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 45824be0a2f9..e8a5fe87c6bd 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -9,56 +9,7 @@
9#ifndef __LINUX_USB_OTG_H 9#ifndef __LINUX_USB_OTG_H
10#define __LINUX_USB_OTG_H 10#define __LINUX_USB_OTG_H
11 11
12#include <linux/notifier.h> 12#include <linux/usb/phy.h>
13
14/* OTG defines lots of enumeration states before device reset */
15enum usb_otg_state {
16 OTG_STATE_UNDEFINED = 0,
17
18 /* single-role peripheral, and dual-role default-b */
19 OTG_STATE_B_IDLE,
20 OTG_STATE_B_SRP_INIT,
21 OTG_STATE_B_PERIPHERAL,
22
23 /* extra dual-role default-b states */
24 OTG_STATE_B_WAIT_ACON,
25 OTG_STATE_B_HOST,
26
27 /* dual-role default-a */
28 OTG_STATE_A_IDLE,
29 OTG_STATE_A_WAIT_VRISE,
30 OTG_STATE_A_WAIT_BCON,
31 OTG_STATE_A_HOST,
32 OTG_STATE_A_SUSPEND,
33 OTG_STATE_A_PERIPHERAL,
34 OTG_STATE_A_WAIT_VFALL,
35 OTG_STATE_A_VBUS_ERR,
36};
37
38enum usb_phy_events {
39 USB_EVENT_NONE, /* no events or cable disconnected */
40 USB_EVENT_VBUS, /* vbus valid event */
41 USB_EVENT_ID, /* id was grounded */
42 USB_EVENT_CHARGER, /* usb dedicated charger */
43 USB_EVENT_ENUMERATED, /* gadget driver enumerated */
44};
45
46/* associate a type with PHY */
47enum usb_phy_type {
48 USB_PHY_TYPE_UNDEFINED,
49 USB_PHY_TYPE_USB2,
50 USB_PHY_TYPE_USB3,
51};
52
53struct usb_phy;
54
55/* for transceivers connected thru an ULPI interface, the user must
56 * provide access ops
57 */
58struct usb_phy_io_ops {
59 int (*read)(struct usb_phy *x, u32 reg);
60 int (*write)(struct usb_phy *x, u32 val, u32 reg);
61};
62 13
63struct usb_otg { 14struct usb_otg {
64 u8 default_a; 15 u8 default_a;
@@ -85,134 +36,9 @@ struct usb_otg {
85 36
86}; 37};
87 38
88/*
89 * the otg driver needs to interact with both device side and host side
90 * usb controllers. it decides which controller is active at a given
91 * moment, using the transceiver, ID signal, HNP and sometimes static
92 * configuration information (including "board isn't wired for otg").
93 */
94struct usb_phy {
95 struct device *dev;
96 const char *label;
97 unsigned int flags;
98
99 enum usb_phy_type type;
100 enum usb_otg_state state;
101 enum usb_phy_events last_event;
102
103 struct usb_otg *otg;
104
105 struct device *io_dev;
106 struct usb_phy_io_ops *io_ops;
107 void __iomem *io_priv;
108
109 /* for notification of usb_phy_events */
110 struct atomic_notifier_head notifier;
111
112 /* to pass extra port status to the root hub */
113 u16 port_status;
114 u16 port_change;
115
116 /* to support controllers that have multiple transceivers */
117 struct list_head head;
118
119 /* initialize/shutdown the OTG controller */
120 int (*init)(struct usb_phy *x);
121 void (*shutdown)(struct usb_phy *x);
122
123 /* effective for B devices, ignored for A-peripheral */
124 int (*set_power)(struct usb_phy *x,
125 unsigned mA);
126
127 /* for non-OTG B devices: set transceiver into suspend mode */
128 int (*set_suspend)(struct usb_phy *x,
129 int suspend);
130
131 /* notify phy connect status change */
132 int (*notify_connect)(struct usb_phy *x, int port);
133 int (*notify_disconnect)(struct usb_phy *x, int port);
134};
135
136
137/* for board-specific init logic */
138extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type);
139extern void usb_remove_phy(struct usb_phy *);
140
141#if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE))
142/* sometimes transceivers are accessed only through e.g. ULPI */
143extern void usb_nop_xceiv_register(void);
144extern void usb_nop_xceiv_unregister(void);
145#else
146static inline void usb_nop_xceiv_register(void)
147{
148}
149
150static inline void usb_nop_xceiv_unregister(void)
151{
152}
153#endif
154
155/* helpers for direct access thru low-level io interface */
156static inline int usb_phy_io_read(struct usb_phy *x, u32 reg)
157{
158 if (x->io_ops && x->io_ops->read)
159 return x->io_ops->read(x, reg);
160
161 return -EINVAL;
162}
163
164static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg)
165{
166 if (x->io_ops && x->io_ops->write)
167 return x->io_ops->write(x, val, reg);
168
169 return -EINVAL;
170}
171
172static inline int
173usb_phy_init(struct usb_phy *x)
174{
175 if (x->init)
176 return x->init(x);
177
178 return 0;
179}
180
181static inline void
182usb_phy_shutdown(struct usb_phy *x)
183{
184 if (x->shutdown)
185 x->shutdown(x);
186}
187
188/* for usb host and peripheral controller drivers */
189#ifdef CONFIG_USB_OTG_UTILS 39#ifdef CONFIG_USB_OTG_UTILS
190extern struct usb_phy *usb_get_phy(enum usb_phy_type type);
191extern struct usb_phy *devm_usb_get_phy(struct device *dev,
192 enum usb_phy_type type);
193extern void usb_put_phy(struct usb_phy *);
194extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
195extern const char *otg_state_string(enum usb_otg_state state); 40extern const char *otg_state_string(enum usb_otg_state state);
196#else 41#else
197static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
198{
199 return NULL;
200}
201
202static inline struct usb_phy *devm_usb_get_phy(struct device *dev,
203 enum usb_phy_type type)
204{
205 return NULL;
206}
207
208static inline void usb_put_phy(struct usb_phy *x)
209{
210}
211
212static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x)
213{
214}
215
216static inline const char *otg_state_string(enum usb_otg_state state) 42static inline const char *otg_state_string(enum usb_otg_state state)
217{ 43{
218 return NULL; 44 return NULL;
@@ -262,42 +88,6 @@ otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph)
262} 88}
263 89
264static inline int 90static inline int
265usb_phy_set_power(struct usb_phy *x, unsigned mA)
266{
267 if (x && x->set_power)
268 return x->set_power(x, mA);
269 return 0;
270}
271
272/* Context: can sleep */
273static inline int
274usb_phy_set_suspend(struct usb_phy *x, int suspend)
275{
276 if (x->set_suspend != NULL)
277 return x->set_suspend(x, suspend);
278 else
279 return 0;
280}
281
282static inline int
283usb_phy_notify_connect(struct usb_phy *x, int port)
284{
285 if (x->notify_connect)
286 return x->notify_connect(x, port);
287 else
288 return 0;
289}
290
291static inline int
292usb_phy_notify_disconnect(struct usb_phy *x, int port)
293{
294 if (x->notify_disconnect)
295 return x->notify_disconnect(x, port);
296 else
297 return 0;
298}
299
300static inline int
301otg_start_srp(struct usb_otg *otg) 91otg_start_srp(struct usb_otg *otg)
302{ 92{
303 if (otg && otg->start_srp) 93 if (otg && otg->start_srp)
@@ -306,31 +96,7 @@ otg_start_srp(struct usb_otg *otg)
306 return -ENOTSUPP; 96 return -ENOTSUPP;
307} 97}
308 98
309/* notifiers */
310static inline int
311usb_register_notifier(struct usb_phy *x, struct notifier_block *nb)
312{
313 return atomic_notifier_chain_register(&x->notifier, nb);
314}
315
316static inline void
317usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb)
318{
319 atomic_notifier_chain_unregister(&x->notifier, nb);
320}
321
322/* for OTG controller drivers (and maybe other stuff) */ 99/* for OTG controller drivers (and maybe other stuff) */
323extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); 100extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num);
324 101
325static inline const char *usb_phy_type_string(enum usb_phy_type type)
326{
327 switch (type) {
328 case USB_PHY_TYPE_USB2:
329 return "USB2 PHY";
330 case USB_PHY_TYPE_USB3:
331 return "USB3 PHY";
332 default:
333 return "UNKNOWN PHY TYPE";
334 }
335}
336#endif /* __LINUX_USB_OTG_H */ 102#endif /* __LINUX_USB_OTG_H */
diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
new file mode 100644
index 000000000000..06b5bae35b29
--- /dev/null
+++ b/include/linux/usb/phy.h
@@ -0,0 +1,233 @@
1/* USB OTG (On The Go) defines */
2/*
3 *
4 * These APIs may be used between USB controllers. USB device drivers
5 * (for either host or peripheral roles) don't use these calls; they
6 * continue to use just usb_device and usb_gadget.
7 */
8
9#ifndef __LINUX_USB_PHY_H
10#define __LINUX_USB_PHY_H
11
12#include <linux/notifier.h>
13
14enum usb_phy_events {
15 USB_EVENT_NONE, /* no events or cable disconnected */
16 USB_EVENT_VBUS, /* vbus valid event */
17 USB_EVENT_ID, /* id was grounded */
18 USB_EVENT_CHARGER, /* usb dedicated charger */
19 USB_EVENT_ENUMERATED, /* gadget driver enumerated */
20};
21
22/* associate a type with PHY */
23enum usb_phy_type {
24 USB_PHY_TYPE_UNDEFINED,
25 USB_PHY_TYPE_USB2,
26 USB_PHY_TYPE_USB3,
27};
28
29/* OTG defines lots of enumeration states before device reset */
30enum usb_otg_state {
31 OTG_STATE_UNDEFINED = 0,
32
33 /* single-role peripheral, and dual-role default-b */
34 OTG_STATE_B_IDLE,
35 OTG_STATE_B_SRP_INIT,
36 OTG_STATE_B_PERIPHERAL,
37
38 /* extra dual-role default-b states */
39 OTG_STATE_B_WAIT_ACON,
40 OTG_STATE_B_HOST,
41
42 /* dual-role default-a */
43 OTG_STATE_A_IDLE,
44 OTG_STATE_A_WAIT_VRISE,
45 OTG_STATE_A_WAIT_BCON,
46 OTG_STATE_A_HOST,
47 OTG_STATE_A_SUSPEND,
48 OTG_STATE_A_PERIPHERAL,
49 OTG_STATE_A_WAIT_VFALL,
50 OTG_STATE_A_VBUS_ERR,
51};
52
53struct usb_phy;
54struct usb_otg;
55
56/* for transceivers connected thru an ULPI interface, the user must
57 * provide access ops
58 */
59struct usb_phy_io_ops {
60 int (*read)(struct usb_phy *x, u32 reg);
61 int (*write)(struct usb_phy *x, u32 val, u32 reg);
62};
63
64struct usb_phy {
65 struct device *dev;
66 const char *label;
67 unsigned int flags;
68
69 enum usb_phy_type type;
70 enum usb_otg_state state;
71 enum usb_phy_events last_event;
72
73 struct usb_otg *otg;
74
75 struct device *io_dev;
76 struct usb_phy_io_ops *io_ops;
77 void __iomem *io_priv;
78
79 /* for notification of usb_phy_events */
80 struct atomic_notifier_head notifier;
81
82 /* to pass extra port status to the root hub */
83 u16 port_status;
84 u16 port_change;
85
86 /* to support controllers that have multiple transceivers */
87 struct list_head head;
88
89 /* initialize/shutdown the OTG controller */
90 int (*init)(struct usb_phy *x);
91 void (*shutdown)(struct usb_phy *x);
92
93 /* effective for B devices, ignored for A-peripheral */
94 int (*set_power)(struct usb_phy *x,
95 unsigned mA);
96
97 /* for non-OTG B devices: set transceiver into suspend mode */
98 int (*set_suspend)(struct usb_phy *x,
99 int suspend);
100
101 /* notify phy connect status change */
102 int (*notify_connect)(struct usb_phy *x, int port);
103 int (*notify_disconnect)(struct usb_phy *x, int port);
104};
105
106
107/* for board-specific init logic */
108extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type);
109extern void usb_remove_phy(struct usb_phy *);
110
111/* helpers for direct access thru low-level io interface */
112static inline int usb_phy_io_read(struct usb_phy *x, u32 reg)
113{
114 if (x->io_ops && x->io_ops->read)
115 return x->io_ops->read(x, reg);
116
117 return -EINVAL;
118}
119
120static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg)
121{
122 if (x->io_ops && x->io_ops->write)
123 return x->io_ops->write(x, val, reg);
124
125 return -EINVAL;
126}
127
128static inline int
129usb_phy_init(struct usb_phy *x)
130{
131 if (x->init)
132 return x->init(x);
133
134 return 0;
135}
136
137static inline void
138usb_phy_shutdown(struct usb_phy *x)
139{
140 if (x->shutdown)
141 x->shutdown(x);
142}
143
144/* for usb host and peripheral controller drivers */
145#ifdef CONFIG_USB_OTG_UTILS
146extern struct usb_phy *usb_get_phy(enum usb_phy_type type);
147extern struct usb_phy *devm_usb_get_phy(struct device *dev,
148 enum usb_phy_type type);
149extern void usb_put_phy(struct usb_phy *);
150extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x);
151#else
152static inline struct usb_phy *usb_get_phy(enum usb_phy_type type)
153{
154 return NULL;
155}
156
157static inline struct usb_phy *devm_usb_get_phy(struct device *dev,
158 enum usb_phy_type type)
159{
160 return NULL;
161}
162
163static inline void usb_put_phy(struct usb_phy *x)
164{
165}
166
167static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x)
168{
169}
170
171#endif
172
173static inline int
174usb_phy_set_power(struct usb_phy *x, unsigned mA)
175{
176 if (x && x->set_power)
177 return x->set_power(x, mA);
178 return 0;
179}
180
181/* Context: can sleep */
182static inline int
183usb_phy_set_suspend(struct usb_phy *x, int suspend)
184{
185 if (x->set_suspend != NULL)
186 return x->set_suspend(x, suspend);
187 else
188 return 0;
189}
190
191static inline int
192usb_phy_notify_connect(struct usb_phy *x, int port)
193{
194 if (x->notify_connect)
195 return x->notify_connect(x, port);
196 else
197 return 0;
198}
199
200static inline int
201usb_phy_notify_disconnect(struct usb_phy *x, int port)
202{
203 if (x->notify_disconnect)
204 return x->notify_disconnect(x, port);
205 else
206 return 0;
207}
208
209/* notifiers */
210static inline int
211usb_register_notifier(struct usb_phy *x, struct notifier_block *nb)
212{
213 return atomic_notifier_chain_register(&x->notifier, nb);
214}
215
216static inline void
217usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb)
218{
219 atomic_notifier_chain_unregister(&x->notifier, nb);
220}
221
222static inline const char *usb_phy_type_string(enum usb_phy_type type)
223{
224 switch (type) {
225 case USB_PHY_TYPE_USB2:
226 return "USB2 PHY";
227 case USB_PHY_TYPE_USB3:
228 return "USB3 PHY";
229 default:
230 return "UNKNOWN PHY TYPE";
231 }
232}
233#endif /* __LINUX_USB_PHY_H */
diff --git a/include/linux/usb/phy_companion.h b/include/linux/usb/phy_companion.h
new file mode 100644
index 000000000000..edd2ec23d282
--- /dev/null
+++ b/include/linux/usb/phy_companion.h
@@ -0,0 +1,34 @@
1/*
2 * phy-companion.h -- phy companion to indicate the comparator part of PHY
3 *
4 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Author: Kishon Vijay Abraham I <kishon@ti.com>
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef __DRIVERS_PHY_COMPANION_H
20#define __DRIVERS_PHY_COMPANION_H
21
22#include <linux/usb/otg.h>
23
24/* phy_companion to take care of VBUS, ID and srp capabilities */
25struct phy_companion {
26
27 /* effective for A-peripheral, ignored for B devices */
28 int (*set_vbus)(struct phy_companion *x, bool enabled);
29
30 /* for B devices only: start session with A-Host */
31 int (*start_srp)(struct phy_companion *x);
32};
33
34#endif /* __DRIVERS_PHY_COMPANION_H */
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 3e93de7ecbc3..52f944dfe2fd 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -19,8 +19,8 @@
19/* device can't handle its Configuration or Interface strings */ 19/* device can't handle its Configuration or Interface strings */
20#define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008 20#define USB_QUIRK_CONFIG_INTF_STRINGS 0x00000008
21 21
22/*device will morph if reset, don't use reset for handling errors */ 22/* device can't be reset(e.g morph devices), don't use reset */
23#define USB_QUIRK_RESET_MORPHS 0x00000010 23#define USB_QUIRK_RESET 0x00000010
24 24
25/* device has more interface descriptions than the bNumInterfaces count, 25/* device has more interface descriptions than the bNumInterfaces count,
26 and can't handle talking to these interfaces */ 26 and can't handle talking to these interfaces */
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 86c0b451745d..ef9be7e1e190 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -301,17 +301,13 @@ extern void usb_serial_port_softint(struct usb_serial_port *port);
301extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 301extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
302extern int usb_serial_resume(struct usb_interface *intf); 302extern int usb_serial_resume(struct usb_interface *intf);
303 303
304extern int ezusb_writememory(struct usb_serial *serial, int address,
305 unsigned char *data, int length, __u8 bRequest);
306extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit);
307
308/* USB Serial console functions */ 304/* USB Serial console functions */
309#ifdef CONFIG_USB_SERIAL_CONSOLE 305#ifdef CONFIG_USB_SERIAL_CONSOLE
310extern void usb_serial_console_init(int debug, int minor); 306extern void usb_serial_console_init(int minor);
311extern void usb_serial_console_exit(void); 307extern void usb_serial_console_exit(void);
312extern void usb_serial_console_disconnect(struct usb_serial *serial); 308extern void usb_serial_console_disconnect(struct usb_serial *serial);
313#else 309#else
314static inline void usb_serial_console_init(int debug, int minor) { } 310static inline void usb_serial_console_init(int minor) { }
315static inline void usb_serial_console_exit(void) { } 311static inline void usb_serial_console_exit(void) { }
316static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} 312static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
317#endif 313#endif
@@ -333,7 +329,7 @@ extern void usb_serial_generic_throttle(struct tty_struct *tty);
333extern void usb_serial_generic_unthrottle(struct tty_struct *tty); 329extern void usb_serial_generic_unthrottle(struct tty_struct *tty);
334extern void usb_serial_generic_disconnect(struct usb_serial *serial); 330extern void usb_serial_generic_disconnect(struct usb_serial *serial);
335extern void usb_serial_generic_release(struct usb_serial *serial); 331extern void usb_serial_generic_release(struct usb_serial *serial);
336extern int usb_serial_generic_register(int debug); 332extern int usb_serial_generic_register(void);
337extern void usb_serial_generic_deregister(void); 333extern void usb_serial_generic_deregister(void);
338extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port, 334extern int usb_serial_generic_submit_read_urbs(struct usb_serial_port *port,
339 gfp_t mem_flags); 335 gfp_t mem_flags);
@@ -355,30 +351,14 @@ extern struct usb_serial_driver usb_serial_generic_device;
355extern struct bus_type usb_serial_bus_type; 351extern struct bus_type usb_serial_bus_type;
356extern struct tty_driver *usb_serial_tty_driver; 352extern struct tty_driver *usb_serial_tty_driver;
357 353
358static inline void usb_serial_debug_data(int debug, 354static inline void usb_serial_debug_data(struct device *dev,
359 struct device *dev,
360 const char *function, int size, 355 const char *function, int size,
361 const unsigned char *data) 356 const unsigned char *data)
362{ 357{
363 int i; 358 dev_dbg(dev, "%s - length = %d, data = %*ph\n",
364 359 function, size, size, data);
365 if (debug) {
366 dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ",
367 function, size);
368 for (i = 0; i < size; ++i)
369 printk("%.2x ", data[i]);
370 printk("\n");
371 }
372} 360}
373 361
374/* Use our own dbg macro */
375#undef dbg
376#define dbg(format, arg...) \
377do { \
378 if (debug) \
379 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
380} while (0)
381
382/* 362/*
383 * Macro for reporting errors in write path to avoid inifinite loop 363 * Macro for reporting errors in write path to avoid inifinite loop
384 * when port is used as a console. 364 * when port is used as a console.
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
new file mode 100644
index 000000000000..176b1ca06ae4
--- /dev/null
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -0,0 +1,80 @@
1/*
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __TEGRA_USB_PHY_H
16#define __TEGRA_USB_PHY_H
17
18#include <linux/clk.h>
19#include <linux/usb/otg.h>
20
21struct tegra_utmip_config {
22 u8 hssync_start_delay;
23 u8 elastic_limit;
24 u8 idle_wait_delay;
25 u8 term_range_adj;
26 u8 xcvr_setup;
27 u8 xcvr_lsfslew;
28 u8 xcvr_lsrslew;
29};
30
31struct tegra_ulpi_config {
32 int reset_gpio;
33 const char *clk;
34};
35
36enum tegra_usb_phy_port_speed {
37 TEGRA_USB_PHY_PORT_SPEED_FULL = 0,
38 TEGRA_USB_PHY_PORT_SPEED_LOW,
39 TEGRA_USB_PHY_PORT_SPEED_HIGH,
40};
41
42enum tegra_usb_phy_mode {
43 TEGRA_USB_PHY_MODE_DEVICE,
44 TEGRA_USB_PHY_MODE_HOST,
45};
46
47struct tegra_xtal_freq;
48
49struct tegra_usb_phy {
50 int instance;
51 const struct tegra_xtal_freq *freq;
52 void __iomem *regs;
53 void __iomem *pad_regs;
54 struct clk *clk;
55 struct clk *pll_u;
56 struct clk *pad_clk;
57 enum tegra_usb_phy_mode mode;
58 void *config;
59 struct usb_phy *ulpi;
60 struct usb_phy u_phy;
61 struct device *dev;
62};
63
64struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
65 void __iomem *regs, void *config, enum tegra_usb_phy_mode phy_mode);
66
67void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy);
68
69void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy);
70
71void tegra_usb_phy_preresume(struct tegra_usb_phy *phy);
72
73void tegra_usb_phy_postresume(struct tegra_usb_phy *phy);
74
75void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy,
76 enum tegra_usb_phy_port_speed port_speed);
77
78void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy);
79
80#endif /* __TEGRA_USB_PHY_H */
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index e84e769aaddc..bf99cd01be20 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -72,33 +72,9 @@
72enum { US_DO_ALL_FLAGS }; 72enum { US_DO_ALL_FLAGS };
73#undef US_FLAG 73#undef US_FLAG
74 74
75/*
76 * The bias field for libusual and friends.
77 */
78#define USB_US_TYPE_NONE 0
79#define USB_US_TYPE_STOR 1 /* usb-storage */
80#define USB_US_TYPE_UB 2 /* ub */
81
82#define USB_US_TYPE(flags) (((flags) >> 24) & 0xFF)
83#define USB_US_ORIG_FLAGS(flags) ((flags) & 0x00FFFFFF)
84
85#include <linux/usb/storage.h> 75#include <linux/usb/storage.h>
86 76
87/*
88 */
89extern int usb_usual_ignore_device(struct usb_interface *intf); 77extern int usb_usual_ignore_device(struct usb_interface *intf);
90extern struct usb_device_id usb_storage_usb_ids[]; 78extern struct usb_device_id usb_storage_usb_ids[];
91 79
92#ifdef CONFIG_USB_LIBUSUAL
93
94extern void usb_usual_set_present(int type);
95extern void usb_usual_clear_present(int type);
96extern int usb_usual_check_type(const struct usb_device_id *, int type);
97#else
98
99#define usb_usual_set_present(t) do { } while(0)
100#define usb_usual_clear_present(t) do { } while(0)
101#define usb_usual_check_type(id, t) (0)
102#endif /* CONFIG_USB_LIBUSUAL */
103
104#endif /* __LINUX_USB_USUAL_H */ 80#endif /* __LINUX_USB_USUAL_H */
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 3b74666be027..4abe28e41cbc 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -131,6 +131,19 @@ struct usbdevfs_hub_portinfo {
131#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04 131#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
132#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08 132#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
133 133
134/* USBDEVFS_DISCONNECT_CLAIM flags & struct */
135
136/* disconnect-and-claim if the driver matches the driver field */
137#define USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER 0x01
138/* disconnect-and-claim except when the driver matches the driver field */
139#define USBDEVFS_DISCONNECT_CLAIM_EXCEPT_DRIVER 0x02
140
141struct usbdevfs_disconnect_claim {
142 unsigned int interface;
143 unsigned int flags;
144 char driver[USBDEVFS_MAXDRIVERNAME + 1];
145};
146
134#ifdef __KERNEL__ 147#ifdef __KERNEL__
135#ifdef CONFIG_COMPAT 148#ifdef CONFIG_COMPAT
136#include <linux/compat.h> 149#include <linux/compat.h>
@@ -211,5 +224,6 @@ struct usbdevfs_ioctl32 {
211#define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int) 224#define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int)
212#define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int) 225#define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int)
213#define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32) 226#define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32)
227#define USBDEVFS_DISCONNECT_CLAIM _IOR('U', 27, struct usbdevfs_disconnect_claim)
214 228
215#endif /* _LINUX_USBDEVICE_FS_H */ 229#endif /* _LINUX_USBDEVICE_FS_H */
diff --git a/include/xen/interface/physdev.h b/include/xen/interface/physdev.h
index 9ce788d8cf49..bfa1d50fe15b 100644
--- a/include/xen/interface/physdev.h
+++ b/include/xen/interface/physdev.h
@@ -258,6 +258,22 @@ struct physdev_pci_device {
258 uint8_t devfn; 258 uint8_t devfn;
259}; 259};
260 260
261#define PHYSDEVOP_DBGP_RESET_PREPARE 1
262#define PHYSDEVOP_DBGP_RESET_DONE 2
263
264#define PHYSDEVOP_DBGP_BUS_UNKNOWN 0
265#define PHYSDEVOP_DBGP_BUS_PCI 1
266
267#define PHYSDEVOP_dbgp_op 29
268struct physdev_dbgp_op {
269 /* IN */
270 uint8_t op;
271 uint8_t bus;
272 union {
273 struct physdev_pci_device pci;
274 } u;
275};
276
261/* 277/*
262 * Notify that some PIRQ-bound event channels have been unmasked. 278 * Notify that some PIRQ-bound event channels have been unmasked.
263 * ** This command is obsolete since interface version 0x00030202 and is ** 279 * ** This command is obsolete since interface version 0x00030202 and is **