diff options
author | Anton Tikhomirov <av.tikhomirov@samsung.com> | 2013-10-02 23:42:04 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-10-04 10:44:44 -0400 |
commit | da8cc16724da2965c94ca15e1377cb9939776dda (patch) | |
tree | 5adbb04d75a23aa202109dd2f25668634ea9177c /drivers | |
parent | f8cffc84a2ff8efc2ecca6128485877109e499f5 (diff) |
usb: phy: Pass OTG FSM pointer to callback functions
struct otg_fsm may be embedded to device's context structure.
The callbacks may require pointer to struct otg_fsm to obtain
necessary data for its operation (example: regulator reference
for drv_vbus()).
Signed-off-by: Anton Tikhomirov <av.tikhomirov@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/phy/phy-fsl-usb.c | 30 | ||||
-rw-r--r-- | drivers/usb/phy/phy-fsl-usb.h | 4 | ||||
-rw-r--r-- | drivers/usb/phy/phy-fsm-usb.h | 28 |
3 files changed, 31 insertions, 31 deletions
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c index fa7c9f9628b5..8b34694ac48f 100644 --- a/drivers/usb/phy/phy-fsl-usb.c +++ b/drivers/usb/phy/phy-fsl-usb.c | |||
@@ -134,7 +134,7 @@ int write_ulpi(u8 addr, u8 data) | |||
134 | /* Operations that will be called from OTG Finite State Machine */ | 134 | /* Operations that will be called from OTG Finite State Machine */ |
135 | 135 | ||
136 | /* Charge vbus for vbus pulsing in SRP */ | 136 | /* Charge vbus for vbus pulsing in SRP */ |
137 | void fsl_otg_chrg_vbus(int on) | 137 | void fsl_otg_chrg_vbus(struct otg_fsm *fsm, int on) |
138 | { | 138 | { |
139 | u32 tmp; | 139 | u32 tmp; |
140 | 140 | ||
@@ -170,7 +170,7 @@ void fsl_otg_dischrg_vbus(int on) | |||
170 | } | 170 | } |
171 | 171 | ||
172 | /* A-device driver vbus, controlled through PP bit in PORTSC */ | 172 | /* A-device driver vbus, controlled through PP bit in PORTSC */ |
173 | void fsl_otg_drv_vbus(int on) | 173 | void fsl_otg_drv_vbus(struct otg_fsm *fsm, int on) |
174 | { | 174 | { |
175 | u32 tmp; | 175 | u32 tmp; |
176 | 176 | ||
@@ -188,7 +188,7 @@ void fsl_otg_drv_vbus(int on) | |||
188 | * Pull-up D+, signalling connect by periperal. Also used in | 188 | * Pull-up D+, signalling connect by periperal. Also used in |
189 | * data-line pulsing in SRP | 189 | * data-line pulsing in SRP |
190 | */ | 190 | */ |
191 | void fsl_otg_loc_conn(int on) | 191 | void fsl_otg_loc_conn(struct otg_fsm *fsm, int on) |
192 | { | 192 | { |
193 | u32 tmp; | 193 | u32 tmp; |
194 | 194 | ||
@@ -207,7 +207,7 @@ void fsl_otg_loc_conn(int on) | |||
207 | * port. In host mode, controller will automatically send SOF. | 207 | * port. In host mode, controller will automatically send SOF. |
208 | * Suspend will block the data on the port. | 208 | * Suspend will block the data on the port. |
209 | */ | 209 | */ |
210 | void fsl_otg_loc_sof(int on) | 210 | void fsl_otg_loc_sof(struct otg_fsm *fsm, int on) |
211 | { | 211 | { |
212 | u32 tmp; | 212 | u32 tmp; |
213 | 213 | ||
@@ -222,7 +222,7 @@ void fsl_otg_loc_sof(int on) | |||
222 | } | 222 | } |
223 | 223 | ||
224 | /* Start SRP pulsing by data-line pulsing, followed with v-bus pulsing. */ | 224 | /* Start SRP pulsing by data-line pulsing, followed with v-bus pulsing. */ |
225 | void fsl_otg_start_pulse(void) | 225 | void fsl_otg_start_pulse(struct otg_fsm *fsm) |
226 | { | 226 | { |
227 | u32 tmp; | 227 | u32 tmp; |
228 | 228 | ||
@@ -235,7 +235,7 @@ void fsl_otg_start_pulse(void) | |||
235 | fsl_otg_loc_conn(1); | 235 | fsl_otg_loc_conn(1); |
236 | #endif | 236 | #endif |
237 | 237 | ||
238 | fsl_otg_add_timer(b_data_pulse_tmr); | 238 | fsl_otg_add_timer(fsm, b_data_pulse_tmr); |
239 | } | 239 | } |
240 | 240 | ||
241 | void b_data_pulse_end(unsigned long foo) | 241 | void b_data_pulse_end(unsigned long foo) |
@@ -252,14 +252,14 @@ void b_data_pulse_end(unsigned long foo) | |||
252 | void fsl_otg_pulse_vbus(void) | 252 | void fsl_otg_pulse_vbus(void) |
253 | { | 253 | { |
254 | srp_wait_done = 0; | 254 | srp_wait_done = 0; |
255 | fsl_otg_chrg_vbus(1); | 255 | fsl_otg_chrg_vbus(&fsl_otg_dev->fsm, 1); |
256 | /* start the timer to end vbus charge */ | 256 | /* start the timer to end vbus charge */ |
257 | fsl_otg_add_timer(b_vbus_pulse_tmr); | 257 | fsl_otg_add_timer(&fsl_otg_dev->fsm, b_vbus_pulse_tmr); |
258 | } | 258 | } |
259 | 259 | ||
260 | void b_vbus_pulse_end(unsigned long foo) | 260 | void b_vbus_pulse_end(unsigned long foo) |
261 | { | 261 | { |
262 | fsl_otg_chrg_vbus(0); | 262 | fsl_otg_chrg_vbus(&fsl_otg_dev->fsm, 0); |
263 | 263 | ||
264 | /* | 264 | /* |
265 | * As USB3300 using the same a_sess_vld and b_sess_vld voltage | 265 | * As USB3300 using the same a_sess_vld and b_sess_vld voltage |
@@ -267,7 +267,7 @@ void b_vbus_pulse_end(unsigned long foo) | |||
267 | * residual voltage of vbus pulsing and A device pull up | 267 | * residual voltage of vbus pulsing and A device pull up |
268 | */ | 268 | */ |
269 | fsl_otg_dischrg_vbus(1); | 269 | fsl_otg_dischrg_vbus(1); |
270 | fsl_otg_add_timer(b_srp_wait_tmr); | 270 | fsl_otg_add_timer(&fsl_otg_dev->fsm, b_srp_wait_tmr); |
271 | } | 271 | } |
272 | 272 | ||
273 | void b_srp_end(unsigned long foo) | 273 | void b_srp_end(unsigned long foo) |
@@ -289,7 +289,7 @@ void a_wait_enum(unsigned long foo) | |||
289 | { | 289 | { |
290 | VDBG("a_wait_enum timeout\n"); | 290 | VDBG("a_wait_enum timeout\n"); |
291 | if (!fsl_otg_dev->phy.otg->host->b_hnp_enable) | 291 | if (!fsl_otg_dev->phy.otg->host->b_hnp_enable) |
292 | fsl_otg_add_timer(a_wait_enum_tmr); | 292 | fsl_otg_add_timer(&fsl_otg_dev->fsm, a_wait_enum_tmr); |
293 | else | 293 | else |
294 | otg_statemachine(&fsl_otg_dev->fsm); | 294 | otg_statemachine(&fsl_otg_dev->fsm); |
295 | } | 295 | } |
@@ -376,7 +376,7 @@ void fsl_otg_uninit_timers(void) | |||
376 | } | 376 | } |
377 | 377 | ||
378 | /* Add timer to timer list */ | 378 | /* Add timer to timer list */ |
379 | void fsl_otg_add_timer(void *gtimer) | 379 | void fsl_otg_add_timer(struct otg_fsm *fsm, void *gtimer) |
380 | { | 380 | { |
381 | struct fsl_otg_timer *timer = gtimer; | 381 | struct fsl_otg_timer *timer = gtimer; |
382 | struct fsl_otg_timer *tmp_timer; | 382 | struct fsl_otg_timer *tmp_timer; |
@@ -395,7 +395,7 @@ void fsl_otg_add_timer(void *gtimer) | |||
395 | } | 395 | } |
396 | 396 | ||
397 | /* Remove timer from the timer list; clear timeout status */ | 397 | /* Remove timer from the timer list; clear timeout status */ |
398 | void fsl_otg_del_timer(void *gtimer) | 398 | void fsl_otg_del_timer(struct otg_fsm *fsm, void *gtimer) |
399 | { | 399 | { |
400 | struct fsl_otg_timer *timer = gtimer; | 400 | struct fsl_otg_timer *timer = gtimer; |
401 | struct fsl_otg_timer *tmp_timer, *del_tmp; | 401 | struct fsl_otg_timer *tmp_timer, *del_tmp; |
@@ -468,7 +468,7 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on) | |||
468 | retval = dev->driver->pm->resume(dev); | 468 | retval = dev->driver->pm->resume(dev); |
469 | if (fsm->id) { | 469 | if (fsm->id) { |
470 | /* default-b */ | 470 | /* default-b */ |
471 | fsl_otg_drv_vbus(1); | 471 | fsl_otg_drv_vbus(fsm, 1); |
472 | /* | 472 | /* |
473 | * Workaround: b_host can't driver | 473 | * Workaround: b_host can't driver |
474 | * vbus, but PP in PORTSC needs to | 474 | * vbus, but PP in PORTSC needs to |
@@ -493,7 +493,7 @@ int fsl_otg_start_host(struct otg_fsm *fsm, int on) | |||
493 | retval = dev->driver->pm->suspend(dev); | 493 | retval = dev->driver->pm->suspend(dev); |
494 | if (fsm->id) | 494 | if (fsm->id) |
495 | /* default-b */ | 495 | /* default-b */ |
496 | fsl_otg_drv_vbus(0); | 496 | fsl_otg_drv_vbus(fsm, 0); |
497 | } | 497 | } |
498 | otg_dev->host_working = 0; | 498 | otg_dev->host_working = 0; |
499 | } | 499 | } |
diff --git a/drivers/usb/phy/phy-fsl-usb.h b/drivers/usb/phy/phy-fsl-usb.h index e1859b8ef567..7365170a2f23 100644 --- a/drivers/usb/phy/phy-fsl-usb.h +++ b/drivers/usb/phy/phy-fsl-usb.h | |||
@@ -401,6 +401,6 @@ struct fsl_otg_config { | |||
401 | #define GET_A_BUS_REQ _IOR(OTG_IOCTL_MAGIC, 8, int) | 401 | #define GET_A_BUS_REQ _IOR(OTG_IOCTL_MAGIC, 8, int) |
402 | #define GET_B_BUS_REQ _IOR(OTG_IOCTL_MAGIC, 9, int) | 402 | #define GET_B_BUS_REQ _IOR(OTG_IOCTL_MAGIC, 9, int) |
403 | 403 | ||
404 | void fsl_otg_add_timer(void *timer); | 404 | void fsl_otg_add_timer(struct otg_fsm *fsm, void *timer); |
405 | void fsl_otg_del_timer(void *timer); | 405 | void fsl_otg_del_timer(struct otg_fsm *fsm, void *timer); |
406 | void fsl_otg_pulse_vbus(void); | 406 | void fsl_otg_pulse_vbus(void); |
diff --git a/drivers/usb/phy/phy-fsm-usb.h b/drivers/usb/phy/phy-fsm-usb.h index fbe586206f33..75344bec4679 100644 --- a/drivers/usb/phy/phy-fsm-usb.h +++ b/drivers/usb/phy/phy-fsm-usb.h | |||
@@ -83,13 +83,13 @@ struct otg_fsm { | |||
83 | }; | 83 | }; |
84 | 84 | ||
85 | struct otg_fsm_ops { | 85 | struct otg_fsm_ops { |
86 | void (*chrg_vbus)(int on); | 86 | void (*chrg_vbus)(struct otg_fsm *fsm, int on); |
87 | void (*drv_vbus)(int on); | 87 | void (*drv_vbus)(struct otg_fsm *fsm, int on); |
88 | void (*loc_conn)(int on); | 88 | void (*loc_conn)(struct otg_fsm *fsm, int on); |
89 | void (*loc_sof)(int on); | 89 | void (*loc_sof)(struct otg_fsm *fsm, int on); |
90 | void (*start_pulse)(void); | 90 | void (*start_pulse)(struct otg_fsm *fsm); |
91 | void (*add_timer)(void *timer); | 91 | void (*add_timer)(struct otg_fsm *fsm, void *timer); |
92 | void (*del_timer)(void *timer); | 92 | void (*del_timer)(struct otg_fsm *fsm, void *timer); |
93 | int (*start_host)(struct otg_fsm *fsm, int on); | 93 | int (*start_host)(struct otg_fsm *fsm, int on); |
94 | int (*start_gadget)(struct otg_fsm *fsm, int on); | 94 | int (*start_gadget)(struct otg_fsm *fsm, int on); |
95 | }; | 95 | }; |
@@ -97,14 +97,14 @@ struct otg_fsm_ops { | |||
97 | 97 | ||
98 | static inline void otg_chrg_vbus(struct otg_fsm *fsm, int on) | 98 | static inline void otg_chrg_vbus(struct otg_fsm *fsm, int on) |
99 | { | 99 | { |
100 | fsm->ops->chrg_vbus(on); | 100 | fsm->ops->chrg_vbus(fsm, on); |
101 | } | 101 | } |
102 | 102 | ||
103 | static inline void otg_drv_vbus(struct otg_fsm *fsm, int on) | 103 | static inline void otg_drv_vbus(struct otg_fsm *fsm, int on) |
104 | { | 104 | { |
105 | if (fsm->drv_vbus != on) { | 105 | if (fsm->drv_vbus != on) { |
106 | fsm->drv_vbus = on; | 106 | fsm->drv_vbus = on; |
107 | fsm->ops->drv_vbus(on); | 107 | fsm->ops->drv_vbus(fsm, on); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
@@ -112,7 +112,7 @@ static inline void otg_loc_conn(struct otg_fsm *fsm, int on) | |||
112 | { | 112 | { |
113 | if (fsm->loc_conn != on) { | 113 | if (fsm->loc_conn != on) { |
114 | fsm->loc_conn = on; | 114 | fsm->loc_conn = on; |
115 | fsm->ops->loc_conn(on); | 115 | fsm->ops->loc_conn(fsm, on); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
@@ -120,23 +120,23 @@ static inline void otg_loc_sof(struct otg_fsm *fsm, int on) | |||
120 | { | 120 | { |
121 | if (fsm->loc_sof != on) { | 121 | if (fsm->loc_sof != on) { |
122 | fsm->loc_sof = on; | 122 | fsm->loc_sof = on; |
123 | fsm->ops->loc_sof(on); | 123 | fsm->ops->loc_sof(fsm, on); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | static inline void otg_start_pulse(struct otg_fsm *fsm) | 127 | static inline void otg_start_pulse(struct otg_fsm *fsm) |
128 | { | 128 | { |
129 | fsm->ops->start_pulse(); | 129 | fsm->ops->start_pulse(fsm); |
130 | } | 130 | } |
131 | 131 | ||
132 | static inline void otg_add_timer(struct otg_fsm *fsm, void *timer) | 132 | static inline void otg_add_timer(struct otg_fsm *fsm, void *timer) |
133 | { | 133 | { |
134 | fsm->ops->add_timer(timer); | 134 | fsm->ops->add_timer(fsm, timer); |
135 | } | 135 | } |
136 | 136 | ||
137 | static inline void otg_del_timer(struct otg_fsm *fsm, void *timer) | 137 | static inline void otg_del_timer(struct otg_fsm *fsm, void *timer) |
138 | { | 138 | { |
139 | fsm->ops->del_timer(timer); | 139 | fsm->ops->del_timer(fsm, timer); |
140 | } | 140 | } |
141 | 141 | ||
142 | int otg_statemachine(struct otg_fsm *fsm); | 142 | int otg_statemachine(struct otg_fsm *fsm); |