diff options
Diffstat (limited to 'include/linux/usb')
| -rw-r--r-- | include/linux/usb/nop-usb-xceiv.h | 24 | ||||
| -rw-r--r-- | include/linux/usb/omap_usb.h | 46 | ||||
| -rw-r--r-- | include/linux/usb/otg.h | 236 | ||||
| -rw-r--r-- | include/linux/usb/phy.h | 233 | ||||
| -rw-r--r-- | include/linux/usb/phy_companion.h | 34 | ||||
| -rw-r--r-- | include/linux/usb/tegra_usb_phy.h | 80 |
6 files changed, 418 insertions, 235 deletions
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 | |||
| 6 | struct 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 */ | ||
| 12 | extern void usb_nop_xceiv_register(void); | ||
| 13 | extern void usb_nop_xceiv_unregister(void); | ||
| 14 | #else | ||
| 15 | static inline void usb_nop_xceiv_register(void) | ||
| 16 | { | ||
| 17 | } | ||
| 18 | |||
| 19 | static 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/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 | |||
| 24 | struct 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) | ||
| 38 | extern int omap_usb2_set_comparator(struct phy_companion *comparator); | ||
| 39 | #else | ||
| 40 | static 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 */ | ||
| 15 | enum 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 | |||
| 38 | enum 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 */ | ||
| 47 | enum usb_phy_type { | ||
| 48 | USB_PHY_TYPE_UNDEFINED, | ||
| 49 | USB_PHY_TYPE_USB2, | ||
| 50 | USB_PHY_TYPE_USB3, | ||
| 51 | }; | ||
| 52 | |||
| 53 | struct usb_phy; | ||
| 54 | |||
| 55 | /* for transceivers connected thru an ULPI interface, the user must | ||
| 56 | * provide access ops | ||
| 57 | */ | ||
| 58 | struct 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 | ||
| 63 | struct usb_otg { | 14 | struct 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 | */ | ||
| 94 | struct 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 */ | ||
| 138 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); | ||
| 139 | extern 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 */ | ||
| 143 | extern void usb_nop_xceiv_register(void); | ||
| 144 | extern void usb_nop_xceiv_unregister(void); | ||
| 145 | #else | ||
| 146 | static inline void usb_nop_xceiv_register(void) | ||
| 147 | { | ||
| 148 | } | ||
| 149 | |||
| 150 | static inline void usb_nop_xceiv_unregister(void) | ||
| 151 | { | ||
| 152 | } | ||
| 153 | #endif | ||
| 154 | |||
| 155 | /* helpers for direct access thru low-level io interface */ | ||
| 156 | static 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 | |||
| 164 | static 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 | |||
| 172 | static inline int | ||
| 173 | usb_phy_init(struct usb_phy *x) | ||
| 174 | { | ||
| 175 | if (x->init) | ||
| 176 | return x->init(x); | ||
| 177 | |||
| 178 | return 0; | ||
| 179 | } | ||
| 180 | |||
| 181 | static inline void | ||
| 182 | usb_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 |
| 190 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); | ||
| 191 | extern struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
| 192 | enum usb_phy_type type); | ||
| 193 | extern void usb_put_phy(struct usb_phy *); | ||
| 194 | extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); | ||
| 195 | extern const char *otg_state_string(enum usb_otg_state state); | 40 | extern const char *otg_state_string(enum usb_otg_state state); |
| 196 | #else | 41 | #else |
| 197 | static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) | ||
| 198 | { | ||
| 199 | return NULL; | ||
| 200 | } | ||
| 201 | |||
| 202 | static inline struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
| 203 | enum usb_phy_type type) | ||
| 204 | { | ||
| 205 | return NULL; | ||
| 206 | } | ||
| 207 | |||
| 208 | static inline void usb_put_phy(struct usb_phy *x) | ||
| 209 | { | ||
| 210 | } | ||
| 211 | |||
| 212 | static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) | ||
| 213 | { | ||
| 214 | } | ||
| 215 | |||
| 216 | static inline const char *otg_state_string(enum usb_otg_state state) | 42 | static 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 | ||
| 264 | static inline int | 90 | static inline int |
| 265 | usb_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 */ | ||
| 273 | static inline int | ||
| 274 | usb_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 | |||
| 282 | static inline int | ||
| 283 | usb_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 | |||
| 291 | static inline int | ||
| 292 | usb_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 | |||
| 300 | static inline int | ||
| 301 | otg_start_srp(struct usb_otg *otg) | 91 | otg_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 */ | ||
| 310 | static inline int | ||
| 311 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
| 312 | { | ||
| 313 | return atomic_notifier_chain_register(&x->notifier, nb); | ||
| 314 | } | ||
| 315 | |||
| 316 | static inline void | ||
| 317 | usb_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) */ |
| 323 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); | 100 | extern int usb_bus_start_enum(struct usb_bus *bus, unsigned port_num); |
| 324 | 101 | ||
| 325 | static 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 | |||
| 14 | enum 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 */ | ||
| 23 | enum 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 */ | ||
| 30 | enum 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 | |||
| 53 | struct usb_phy; | ||
| 54 | struct usb_otg; | ||
| 55 | |||
| 56 | /* for transceivers connected thru an ULPI interface, the user must | ||
| 57 | * provide access ops | ||
| 58 | */ | ||
| 59 | struct 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 | |||
| 64 | struct 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 */ | ||
| 108 | extern int usb_add_phy(struct usb_phy *, enum usb_phy_type type); | ||
| 109 | extern void usb_remove_phy(struct usb_phy *); | ||
| 110 | |||
| 111 | /* helpers for direct access thru low-level io interface */ | ||
| 112 | static 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 | |||
| 120 | static 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 | |||
| 128 | static inline int | ||
| 129 | usb_phy_init(struct usb_phy *x) | ||
| 130 | { | ||
| 131 | if (x->init) | ||
| 132 | return x->init(x); | ||
| 133 | |||
| 134 | return 0; | ||
| 135 | } | ||
| 136 | |||
| 137 | static inline void | ||
| 138 | usb_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 | ||
| 146 | extern struct usb_phy *usb_get_phy(enum usb_phy_type type); | ||
| 147 | extern struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
| 148 | enum usb_phy_type type); | ||
| 149 | extern void usb_put_phy(struct usb_phy *); | ||
| 150 | extern void devm_usb_put_phy(struct device *dev, struct usb_phy *x); | ||
| 151 | #else | ||
| 152 | static inline struct usb_phy *usb_get_phy(enum usb_phy_type type) | ||
| 153 | { | ||
| 154 | return NULL; | ||
| 155 | } | ||
| 156 | |||
| 157 | static inline struct usb_phy *devm_usb_get_phy(struct device *dev, | ||
| 158 | enum usb_phy_type type) | ||
| 159 | { | ||
| 160 | return NULL; | ||
| 161 | } | ||
| 162 | |||
| 163 | static inline void usb_put_phy(struct usb_phy *x) | ||
| 164 | { | ||
| 165 | } | ||
| 166 | |||
| 167 | static inline void devm_usb_put_phy(struct device *dev, struct usb_phy *x) | ||
| 168 | { | ||
| 169 | } | ||
| 170 | |||
| 171 | #endif | ||
| 172 | |||
| 173 | static inline int | ||
| 174 | usb_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 */ | ||
| 182 | static inline int | ||
| 183 | usb_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 | |||
| 191 | static inline int | ||
| 192 | usb_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 | |||
| 200 | static inline int | ||
| 201 | usb_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 */ | ||
| 210 | static inline int | ||
| 211 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
| 212 | { | ||
| 213 | return atomic_notifier_chain_register(&x->notifier, nb); | ||
| 214 | } | ||
| 215 | |||
| 216 | static inline void | ||
| 217 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) | ||
| 218 | { | ||
| 219 | atomic_notifier_chain_unregister(&x->notifier, nb); | ||
| 220 | } | ||
| 221 | |||
| 222 | static 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 */ | ||
| 25 | struct 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/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 | |||
| 21 | struct 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 | |||
| 31 | struct tegra_ulpi_config { | ||
| 32 | int reset_gpio; | ||
| 33 | const char *clk; | ||
| 34 | }; | ||
| 35 | |||
| 36 | enum 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 | |||
| 42 | enum tegra_usb_phy_mode { | ||
| 43 | TEGRA_USB_PHY_MODE_DEVICE, | ||
| 44 | TEGRA_USB_PHY_MODE_HOST, | ||
| 45 | }; | ||
| 46 | |||
| 47 | struct tegra_xtal_freq; | ||
| 48 | |||
| 49 | struct 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 | |||
| 64 | struct 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 | |||
| 67 | void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy); | ||
| 68 | |||
| 69 | void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy); | ||
| 70 | |||
| 71 | void tegra_usb_phy_preresume(struct tegra_usb_phy *phy); | ||
| 72 | |||
| 73 | void tegra_usb_phy_postresume(struct tegra_usb_phy *phy); | ||
| 74 | |||
| 75 | void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy, | ||
| 76 | enum tegra_usb_phy_port_speed port_speed); | ||
| 77 | |||
| 78 | void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy); | ||
| 79 | |||
| 80 | #endif /* __TEGRA_USB_PHY_H */ | ||
