aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/usb/nop-usb-xceiv.h24
-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/tegra_usb_phy.h80
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
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/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/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 */