aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2012-02-13 06:24:13 -0500
committerFelipe Balbi <balbi@ti.com>2012-02-13 06:35:56 -0500
commit298b083cf9dd2efd9bb7020107ab0077135051e0 (patch)
tree8b91a484f0bba706830fdb8c06ff9157b1f5bb8a
parent46b8f6b0eb9a9df137c76ea04564c3648fdc63d4 (diff)
usb: otg: ulpi: Start using struct usb_otg
Use struct usb_otg members with OTG specific functions instead of usb_phy members. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Igor Grinberg <grinberg@compulab.co.il> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--arch/arm/mach-pxa/pxa3xx-ulpi.c6
-rw-r--r--arch/arm/plat-mxc/include/mach/ulpi.h2
-rw-r--r--arch/arm/plat-mxc/ulpi.c2
-rw-r--r--drivers/usb/otg/ulpi.c114
-rw-r--r--drivers/usb/otg/ulpi_viewport.c2
-rw-r--r--include/linux/usb/ulpi.h4
6 files changed, 71 insertions, 59 deletions
diff --git a/arch/arm/mach-pxa/pxa3xx-ulpi.c b/arch/arm/mach-pxa/pxa3xx-ulpi.c
index 960d0ac50418..a13f33565623 100644
--- a/arch/arm/mach-pxa/pxa3xx-ulpi.c
+++ b/arch/arm/mach-pxa/pxa3xx-ulpi.c
@@ -111,7 +111,7 @@ static int pxa310_ulpi_write(struct usb_phy *otg, u32 val, u32 reg)
111 return pxa310_ulpi_poll(); 111 return pxa310_ulpi_poll();
112} 112}
113 113
114struct otg_io_access_ops pxa310_ulpi_access_ops = { 114struct usb_phy_io_ops pxa310_ulpi_access_ops = {
115 .read = pxa310_ulpi_read, 115 .read = pxa310_ulpi_read,
116 .write = pxa310_ulpi_write, 116 .write = pxa310_ulpi_write,
117}; 117};
@@ -139,7 +139,7 @@ static int pxa310_start_otg_host_transcvr(struct usb_bus *host)
139 139
140 pxa310_otg_transceiver_rtsm(); 140 pxa310_otg_transceiver_rtsm();
141 141
142 err = otg_init(u2d->otg); 142 err = usb_phy_init(u2d->otg);
143 if (err) { 143 if (err) {
144 pr_err("OTG transceiver init failed"); 144 pr_err("OTG transceiver init failed");
145 return err; 145 return err;
@@ -191,7 +191,7 @@ static void pxa310_stop_otg_hc(void)
191 191
192 otg_set_host(u2d->otg, NULL); 192 otg_set_host(u2d->otg, NULL);
193 otg_set_vbus(u2d->otg, 0); 193 otg_set_vbus(u2d->otg, 0);
194 otg_shutdown(u2d->otg); 194 usb_phy_shutdown(u2d->otg);
195} 195}
196 196
197static void pxa310_u2d_setup_otg_hc(void) 197static void pxa310_u2d_setup_otg_hc(void)
diff --git a/arch/arm/plat-mxc/include/mach/ulpi.h b/arch/arm/plat-mxc/include/mach/ulpi.h
index d39d94a170e7..42bdaca6d7d9 100644
--- a/arch/arm/plat-mxc/include/mach/ulpi.h
+++ b/arch/arm/plat-mxc/include/mach/ulpi.h
@@ -10,7 +10,7 @@ static inline struct usb_phy *imx_otg_ulpi_create(unsigned int flags)
10} 10}
11#endif 11#endif
12 12
13extern struct otg_io_access_ops mxc_ulpi_access_ops; 13extern struct usb_phy_io_ops mxc_ulpi_access_ops;
14 14
15#endif /* __MACH_ULPI_H */ 15#endif /* __MACH_ULPI_H */
16 16
diff --git a/arch/arm/plat-mxc/ulpi.c b/arch/arm/plat-mxc/ulpi.c
index 8eeeb6b979c4..d2963427184f 100644
--- a/arch/arm/plat-mxc/ulpi.c
+++ b/arch/arm/plat-mxc/ulpi.c
@@ -106,7 +106,7 @@ static int ulpi_write(struct usb_phy *otg, u32 val, u32 reg)
106 return ulpi_poll(view, ULPIVW_RUN); 106 return ulpi_poll(view, ULPIVW_RUN);
107} 107}
108 108
109struct otg_io_access_ops mxc_ulpi_access_ops = { 109struct usb_phy_io_ops mxc_ulpi_access_ops = {
110 .read = ulpi_read, 110 .read = ulpi_read,
111 .write = ulpi_write, 111 .write = ulpi_write,
112}; 112};
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c
index 51841ed829ab..217339dd7a90 100644
--- a/drivers/usb/otg/ulpi.c
+++ b/drivers/usb/otg/ulpi.c
@@ -49,31 +49,31 @@ static struct ulpi_info ulpi_ids[] = {
49 ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"), 49 ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"),
50}; 50};
51 51
52static int ulpi_set_otg_flags(struct usb_phy *otg) 52static int ulpi_set_otg_flags(struct usb_phy *phy)
53{ 53{
54 unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN | 54 unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN |
55 ULPI_OTG_CTRL_DM_PULLDOWN; 55 ULPI_OTG_CTRL_DM_PULLDOWN;
56 56
57 if (otg->flags & ULPI_OTG_ID_PULLUP) 57 if (phy->flags & ULPI_OTG_ID_PULLUP)
58 flags |= ULPI_OTG_CTRL_ID_PULLUP; 58 flags |= ULPI_OTG_CTRL_ID_PULLUP;
59 59
60 /* 60 /*
61 * ULPI Specification rev.1.1 default 61 * ULPI Specification rev.1.1 default
62 * for Dp/DmPulldown is enabled. 62 * for Dp/DmPulldown is enabled.
63 */ 63 */
64 if (otg->flags & ULPI_OTG_DP_PULLDOWN_DIS) 64 if (phy->flags & ULPI_OTG_DP_PULLDOWN_DIS)
65 flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN; 65 flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN;
66 66
67 if (otg->flags & ULPI_OTG_DM_PULLDOWN_DIS) 67 if (phy->flags & ULPI_OTG_DM_PULLDOWN_DIS)
68 flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN; 68 flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN;
69 69
70 if (otg->flags & ULPI_OTG_EXTVBUSIND) 70 if (phy->flags & ULPI_OTG_EXTVBUSIND)
71 flags |= ULPI_OTG_CTRL_EXTVBUSIND; 71 flags |= ULPI_OTG_CTRL_EXTVBUSIND;
72 72
73 return otg_io_write(otg, flags, ULPI_OTG_CTRL); 73 return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL);
74} 74}
75 75
76static int ulpi_set_fc_flags(struct usb_phy *otg) 76static int ulpi_set_fc_flags(struct usb_phy *phy)
77{ 77{
78 unsigned int flags = 0; 78 unsigned int flags = 0;
79 79
@@ -81,27 +81,27 @@ static int ulpi_set_fc_flags(struct usb_phy *otg)
81 * ULPI Specification rev.1.1 default 81 * ULPI Specification rev.1.1 default
82 * for XcvrSelect is Full Speed. 82 * for XcvrSelect is Full Speed.
83 */ 83 */
84 if (otg->flags & ULPI_FC_HS) 84 if (phy->flags & ULPI_FC_HS)
85 flags |= ULPI_FUNC_CTRL_HIGH_SPEED; 85 flags |= ULPI_FUNC_CTRL_HIGH_SPEED;
86 else if (otg->flags & ULPI_FC_LS) 86 else if (phy->flags & ULPI_FC_LS)
87 flags |= ULPI_FUNC_CTRL_LOW_SPEED; 87 flags |= ULPI_FUNC_CTRL_LOW_SPEED;
88 else if (otg->flags & ULPI_FC_FS4LS) 88 else if (phy->flags & ULPI_FC_FS4LS)
89 flags |= ULPI_FUNC_CTRL_FS4LS; 89 flags |= ULPI_FUNC_CTRL_FS4LS;
90 else 90 else
91 flags |= ULPI_FUNC_CTRL_FULL_SPEED; 91 flags |= ULPI_FUNC_CTRL_FULL_SPEED;
92 92
93 if (otg->flags & ULPI_FC_TERMSEL) 93 if (phy->flags & ULPI_FC_TERMSEL)
94 flags |= ULPI_FUNC_CTRL_TERMSELECT; 94 flags |= ULPI_FUNC_CTRL_TERMSELECT;
95 95
96 /* 96 /*
97 * ULPI Specification rev.1.1 default 97 * ULPI Specification rev.1.1 default
98 * for OpMode is Normal Operation. 98 * for OpMode is Normal Operation.
99 */ 99 */
100 if (otg->flags & ULPI_FC_OP_NODRV) 100 if (phy->flags & ULPI_FC_OP_NODRV)
101 flags |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; 101 flags |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
102 else if (otg->flags & ULPI_FC_OP_DIS_NRZI) 102 else if (phy->flags & ULPI_FC_OP_DIS_NRZI)
103 flags |= ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI; 103 flags |= ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI;
104 else if (otg->flags & ULPI_FC_OP_NSYNC_NEOP) 104 else if (phy->flags & ULPI_FC_OP_NSYNC_NEOP)
105 flags |= ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP; 105 flags |= ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP;
106 else 106 else
107 flags |= ULPI_FUNC_CTRL_OPMODE_NORMAL; 107 flags |= ULPI_FUNC_CTRL_OPMODE_NORMAL;
@@ -112,54 +112,54 @@ static int ulpi_set_fc_flags(struct usb_phy *otg)
112 */ 112 */
113 flags |= ULPI_FUNC_CTRL_SUSPENDM; 113 flags |= ULPI_FUNC_CTRL_SUSPENDM;
114 114
115 return otg_io_write(otg, flags, ULPI_FUNC_CTRL); 115 return usb_phy_io_write(phy, flags, ULPI_FUNC_CTRL);
116} 116}
117 117
118static int ulpi_set_ic_flags(struct usb_phy *otg) 118static int ulpi_set_ic_flags(struct usb_phy *phy)
119{ 119{
120 unsigned int flags = 0; 120 unsigned int flags = 0;
121 121
122 if (otg->flags & ULPI_IC_AUTORESUME) 122 if (phy->flags & ULPI_IC_AUTORESUME)
123 flags |= ULPI_IFC_CTRL_AUTORESUME; 123 flags |= ULPI_IFC_CTRL_AUTORESUME;
124 124
125 if (otg->flags & ULPI_IC_EXTVBUS_INDINV) 125 if (phy->flags & ULPI_IC_EXTVBUS_INDINV)
126 flags |= ULPI_IFC_CTRL_EXTERNAL_VBUS; 126 flags |= ULPI_IFC_CTRL_EXTERNAL_VBUS;
127 127
128 if (otg->flags & ULPI_IC_IND_PASSTHRU) 128 if (phy->flags & ULPI_IC_IND_PASSTHRU)
129 flags |= ULPI_IFC_CTRL_PASSTHRU; 129 flags |= ULPI_IFC_CTRL_PASSTHRU;
130 130
131 if (otg->flags & ULPI_IC_PROTECT_DIS) 131 if (phy->flags & ULPI_IC_PROTECT_DIS)
132 flags |= ULPI_IFC_CTRL_PROTECT_IFC_DISABLE; 132 flags |= ULPI_IFC_CTRL_PROTECT_IFC_DISABLE;
133 133
134 return otg_io_write(otg, flags, ULPI_IFC_CTRL); 134 return usb_phy_io_write(phy, flags, ULPI_IFC_CTRL);
135} 135}
136 136
137static int ulpi_set_flags(struct usb_phy *otg) 137static int ulpi_set_flags(struct usb_phy *phy)
138{ 138{
139 int ret; 139 int ret;
140 140
141 ret = ulpi_set_otg_flags(otg); 141 ret = ulpi_set_otg_flags(phy);
142 if (ret) 142 if (ret)
143 return ret; 143 return ret;
144 144
145 ret = ulpi_set_ic_flags(otg); 145 ret = ulpi_set_ic_flags(phy);
146 if (ret) 146 if (ret)
147 return ret; 147 return ret;
148 148
149 return ulpi_set_fc_flags(otg); 149 return ulpi_set_fc_flags(phy);
150} 150}
151 151
152static int ulpi_check_integrity(struct usb_phy *otg) 152static int ulpi_check_integrity(struct usb_phy *phy)
153{ 153{
154 int ret, i; 154 int ret, i;
155 unsigned int val = 0x55; 155 unsigned int val = 0x55;
156 156
157 for (i = 0; i < 2; i++) { 157 for (i = 0; i < 2; i++) {
158 ret = otg_io_write(otg, val, ULPI_SCRATCH); 158 ret = usb_phy_io_write(phy, val, ULPI_SCRATCH);
159 if (ret < 0) 159 if (ret < 0)
160 return ret; 160 return ret;
161 161
162 ret = otg_io_read(otg, ULPI_SCRATCH); 162 ret = usb_phy_io_read(phy, ULPI_SCRATCH);
163 if (ret < 0) 163 if (ret < 0)
164 return ret; 164 return ret;
165 165
@@ -175,13 +175,13 @@ static int ulpi_check_integrity(struct usb_phy *otg)
175 return 0; 175 return 0;
176} 176}
177 177
178static int ulpi_init(struct usb_phy *otg) 178static int ulpi_init(struct usb_phy *phy)
179{ 179{
180 int i, vid, pid, ret; 180 int i, vid, pid, ret;
181 u32 ulpi_id = 0; 181 u32 ulpi_id = 0;
182 182
183 for (i = 0; i < 4; i++) { 183 for (i = 0; i < 4; i++) {
184 ret = otg_io_read(otg, ULPI_PRODUCT_ID_HIGH - i); 184 ret = usb_phy_io_read(phy, ULPI_PRODUCT_ID_HIGH - i);
185 if (ret < 0) 185 if (ret < 0)
186 return ret; 186 return ret;
187 ulpi_id = (ulpi_id << 8) | ret; 187 ulpi_id = (ulpi_id << 8) | ret;
@@ -199,16 +199,17 @@ static int ulpi_init(struct usb_phy *otg)
199 } 199 }
200 } 200 }
201 201
202 ret = ulpi_check_integrity(otg); 202 ret = ulpi_check_integrity(phy);
203 if (ret) 203 if (ret)
204 return ret; 204 return ret;
205 205
206 return ulpi_set_flags(otg); 206 return ulpi_set_flags(phy);
207} 207}
208 208
209static int ulpi_set_host(struct usb_phy *otg, struct usb_bus *host) 209static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host)
210{ 210{
211 unsigned int flags = otg_io_read(otg, ULPI_IFC_CTRL); 211 struct usb_phy *phy = otg->phy;
212 unsigned int flags = usb_phy_io_read(phy, ULPI_IFC_CTRL);
212 213
213 if (!host) { 214 if (!host) {
214 otg->host = NULL; 215 otg->host = NULL;
@@ -221,51 +222,62 @@ static int ulpi_set_host(struct usb_phy *otg, struct usb_bus *host)
221 ULPI_IFC_CTRL_3_PIN_SERIAL_MODE | 222 ULPI_IFC_CTRL_3_PIN_SERIAL_MODE |
222 ULPI_IFC_CTRL_CARKITMODE); 223 ULPI_IFC_CTRL_CARKITMODE);
223 224
224 if (otg->flags & ULPI_IC_6PIN_SERIAL) 225 if (phy->flags & ULPI_IC_6PIN_SERIAL)
225 flags |= ULPI_IFC_CTRL_6_PIN_SERIAL_MODE; 226 flags |= ULPI_IFC_CTRL_6_PIN_SERIAL_MODE;
226 else if (otg->flags & ULPI_IC_3PIN_SERIAL) 227 else if (phy->flags & ULPI_IC_3PIN_SERIAL)
227 flags |= ULPI_IFC_CTRL_3_PIN_SERIAL_MODE; 228 flags |= ULPI_IFC_CTRL_3_PIN_SERIAL_MODE;
228 else if (otg->flags & ULPI_IC_CARKIT) 229 else if (phy->flags & ULPI_IC_CARKIT)
229 flags |= ULPI_IFC_CTRL_CARKITMODE; 230 flags |= ULPI_IFC_CTRL_CARKITMODE;
230 231
231 return otg_io_write(otg, flags, ULPI_IFC_CTRL); 232 return usb_phy_io_write(phy, flags, ULPI_IFC_CTRL);
232} 233}
233 234
234static int ulpi_set_vbus(struct usb_phy *otg, bool on) 235static int ulpi_set_vbus(struct usb_otg *otg, bool on)
235{ 236{
236 unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL); 237 struct usb_phy *phy = otg->phy;
238 unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL);
237 239
238 flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); 240 flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT);
239 241
240 if (on) { 242 if (on) {
241 if (otg->flags & ULPI_OTG_DRVVBUS) 243 if (phy->flags & ULPI_OTG_DRVVBUS)
242 flags |= ULPI_OTG_CTRL_DRVVBUS; 244 flags |= ULPI_OTG_CTRL_DRVVBUS;
243 245
244 if (otg->flags & ULPI_OTG_DRVVBUS_EXT) 246 if (phy->flags & ULPI_OTG_DRVVBUS_EXT)
245 flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; 247 flags |= ULPI_OTG_CTRL_DRVVBUS_EXT;
246 } 248 }
247 249
248 return otg_io_write(otg, flags, ULPI_OTG_CTRL); 250 return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL);
249} 251}
250 252
251struct usb_phy * 253struct usb_phy *
252otg_ulpi_create(struct otg_io_access_ops *ops, 254otg_ulpi_create(struct usb_phy_io_ops *ops,
253 unsigned int flags) 255 unsigned int flags)
254{ 256{
255 struct usb_phy *otg; 257 struct usb_phy *phy;
258 struct usb_otg *otg;
259
260 phy = kzalloc(sizeof(*phy), GFP_KERNEL);
261 if (!phy)
262 return NULL;
256 263
257 otg = kzalloc(sizeof(*otg), GFP_KERNEL); 264 otg = kzalloc(sizeof(*otg), GFP_KERNEL);
258 if (!otg) 265 if (!otg) {
266 kfree(phy);
259 return NULL; 267 return NULL;
268 }
269
270 phy->label = "ULPI";
271 phy->flags = flags;
272 phy->io_ops = ops;
273 phy->otg = otg;
274 phy->init = ulpi_init;
260 275
261 otg->label = "ULPI"; 276 otg->phy = phy;
262 otg->flags = flags;
263 otg->io_ops = ops;
264 otg->init = ulpi_init;
265 otg->set_host = ulpi_set_host; 277 otg->set_host = ulpi_set_host;
266 otg->set_vbus = ulpi_set_vbus; 278 otg->set_vbus = ulpi_set_vbus;
267 279
268 return otg; 280 return phy;
269} 281}
270EXPORT_SYMBOL_GPL(otg_ulpi_create); 282EXPORT_SYMBOL_GPL(otg_ulpi_create);
271 283
diff --git a/drivers/usb/otg/ulpi_viewport.c b/drivers/usb/otg/ulpi_viewport.c
index e7b311b960bd..c5ba7e5423fc 100644
--- a/drivers/usb/otg/ulpi_viewport.c
+++ b/drivers/usb/otg/ulpi_viewport.c
@@ -74,7 +74,7 @@ static int ulpi_viewport_write(struct usb_phy *otg, u32 val, u32 reg)
74 return ulpi_viewport_wait(view, ULPI_VIEW_RUN); 74 return ulpi_viewport_wait(view, ULPI_VIEW_RUN);
75} 75}
76 76
77struct otg_io_access_ops ulpi_viewport_access_ops = { 77struct usb_phy_io_ops ulpi_viewport_access_ops = {
78 .read = ulpi_viewport_read, 78 .read = ulpi_viewport_read,
79 .write = ulpi_viewport_write, 79 .write = ulpi_viewport_write,
80}; 80};
diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h
index 51ebf72bc449..6f033a415ecb 100644
--- a/include/linux/usb/ulpi.h
+++ b/include/linux/usb/ulpi.h
@@ -181,12 +181,12 @@
181 181
182/*-------------------------------------------------------------------------*/ 182/*-------------------------------------------------------------------------*/
183 183
184struct usb_phy *otg_ulpi_create(struct otg_io_access_ops *ops, 184struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops,
185 unsigned int flags); 185 unsigned int flags);
186 186
187#ifdef CONFIG_USB_ULPI_VIEWPORT 187#ifdef CONFIG_USB_ULPI_VIEWPORT
188/* access ops for controllers with a viewport register */ 188/* access ops for controllers with a viewport register */
189extern struct otg_io_access_ops ulpi_viewport_access_ops; 189extern struct usb_phy_io_ops ulpi_viewport_access_ops;
190#endif 190#endif
191 191
192#endif /* __LINUX_USB_ULPI_H */ 192#endif /* __LINUX_USB_ULPI_H */