aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/blackfin.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-01 06:22:05 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-07 02:19:39 -0500
commit743411b3f3e96e8ac4cae73551a0a95392fed1ea (patch)
tree485f2f1f92768df7b1cc2d44cf3b8d4cc3cdaf3b /drivers/usb/musb/blackfin.c
parent3ca8abb84522f4b773678726db6ebd6fc277bc96 (diff)
usb: musb: make all glue layer export struct musb_platform_ops
preparing to a big refactor on musb code. We need to be able to compile in all glue layers (or at least all ARM-based ones) together and have a working binary. While preparing for that, we move every glue layer to export only one symbol, which is a struct musb_platform_ops, and make all other functions static. Later patches will come to allow for compiling all glue layers together and have a working binary. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/blackfin.c')
-rw-r--r--drivers/usb/musb/blackfin.c106
1 files changed, 73 insertions, 33 deletions
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
index e8cbcc59c419..9874501d6429 100644
--- a/drivers/usb/musb/blackfin.c
+++ b/drivers/usb/musb/blackfin.c
@@ -277,7 +277,7 @@ static void musb_conn_timer_handler(unsigned long _musb)
277 DBG(4, "state is %s\n", otg_state_string(musb)); 277 DBG(4, "state is %s\n", otg_state_string(musb));
278} 278}
279 279
280void musb_platform_enable(struct musb *musb) 280static void bfin_musb_enable(struct musb *musb)
281{ 281{
282 if (!is_otg_enabled(musb) && is_host_enabled(musb)) { 282 if (!is_otg_enabled(musb) && is_host_enabled(musb)) {
283 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); 283 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
@@ -285,11 +285,11 @@ void musb_platform_enable(struct musb *musb)
285 } 285 }
286} 286}
287 287
288void musb_platform_disable(struct musb *musb) 288static void bfin_musb_disable(struct musb *musb)
289{ 289{
290} 290}
291 291
292static void bfin_set_vbus(struct musb *musb, int is_on) 292static void bfin_musb_set_vbus(struct musb *musb, int is_on)
293{ 293{
294 int value = musb->config->gpio_vrsel_active; 294 int value = musb->config->gpio_vrsel_active;
295 if (!is_on) 295 if (!is_on)
@@ -302,51 +302,29 @@ static void bfin_set_vbus(struct musb *musb, int is_on)
302 musb_readb(musb->mregs, MUSB_DEVCTL)); 302 musb_readb(musb->mregs, MUSB_DEVCTL));
303} 303}
304 304
305static int bfin_set_power(struct otg_transceiver *x, unsigned mA) 305static int bfin_musb_set_power(struct otg_transceiver *x, unsigned mA)
306{ 306{
307 return 0; 307 return 0;
308} 308}
309 309
310void musb_platform_try_idle(struct musb *musb, unsigned long timeout) 310static void bfin_musb_try_idle(struct musb *musb, unsigned long timeout)
311{ 311{
312 if (!is_otg_enabled(musb) && is_host_enabled(musb)) 312 if (!is_otg_enabled(musb) && is_host_enabled(musb))
313 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY); 313 mod_timer(&musb_conn_timer, jiffies + TIMER_DELAY);
314} 314}
315 315
316int musb_platform_get_vbus_status(struct musb *musb) 316static int bfin_musb_get_vbus_status(struct musb *musb)
317{ 317{
318 return 0; 318 return 0;
319} 319}
320 320
321int musb_platform_set_mode(struct musb *musb, u8 musb_mode) 321static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode)
322{ 322{
323 return -EIO; 323 return -EIO;
324} 324}
325 325
326int __init musb_platform_init(struct musb *musb) 326static void bfin_musb_reg_init(struct musb *musb)
327{ 327{
328
329 /*
330 * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE
331 * and OTG HOST modes, while rev 1.1 and greater require PE7 to
332 * be low for DEVICE mode and high for HOST mode. We set it high
333 * here because we are in host mode
334 */
335
336 if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) {
337 printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d \n",
338 musb->config->gpio_vrsel);
339 return -ENODEV;
340 }
341 gpio_direction_output(musb->config->gpio_vrsel, 0);
342
343 usb_nop_xceiv_register();
344 musb->xceiv = otg_get_transceiver();
345 if (!musb->xceiv) {
346 gpio_free(musb->config->gpio_vrsel);
347 return -ENODEV;
348 }
349
350 if (ANOMALY_05000346) { 328 if (ANOMALY_05000346) {
351 bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value); 329 bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value);
352 SSYNC(); 330 SSYNC();
@@ -380,21 +358,69 @@ int __init musb_platform_init(struct musb *musb)
380 EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA | 358 EP2_RX_ENA | EP3_RX_ENA | EP4_RX_ENA |
381 EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA); 359 EP5_RX_ENA | EP6_RX_ENA | EP7_RX_ENA);
382 SSYNC(); 360 SSYNC();
361}
362
363static int bfin_musb_init(struct musb *musb)
364{
365
366 /*
367 * Rev 1.0 BF549 EZ-KITs require PE7 to be high for both DEVICE
368 * and OTG HOST modes, while rev 1.1 and greater require PE7 to
369 * be low for DEVICE mode and high for HOST mode. We set it high
370 * here because we are in host mode
371 */
372
373 if (gpio_request(musb->config->gpio_vrsel, "USB_VRSEL")) {
374 printk(KERN_ERR "Failed ro request USB_VRSEL GPIO_%d\n",
375 musb->config->gpio_vrsel);
376 return -ENODEV;
377 }
378 gpio_direction_output(musb->config->gpio_vrsel, 0);
379
380 usb_nop_xceiv_register();
381 musb->xceiv = otg_get_transceiver();
382 if (!musb->xceiv) {
383 gpio_free(musb->config->gpio_vrsel);
384 return -ENODEV;
385 }
386
387 bfin_musb_reg_init(musb);
383 388
384 if (is_host_enabled(musb)) { 389 if (is_host_enabled(musb)) {
385 musb->board_set_vbus = bfin_set_vbus; 390 musb->board_set_vbus = bfin_musb_set_vbus;
386 setup_timer(&musb_conn_timer, 391 setup_timer(&musb_conn_timer,
387 musb_conn_timer_handler, (unsigned long) musb); 392 musb_conn_timer_handler, (unsigned long) musb);
388 } 393 }
389 if (is_peripheral_enabled(musb)) 394 if (is_peripheral_enabled(musb))
390 musb->xceiv->set_power = bfin_set_power; 395 musb->xceiv->set_power = bfin_musb_set_power;
391 396
392 musb->isr = blackfin_interrupt; 397 musb->isr = blackfin_interrupt;
393 398
394 return 0; 399 return 0;
395} 400}
396 401
397int musb_platform_exit(struct musb *musb) 402#ifdef CONFIG_PM
403void musb_platform_save_context(struct musb *musb,
404 struct musb_context_registers *musb_context)
405{
406 if (is_host_active(musb))
407 /*
408 * During hibernate gpio_vrsel will change from high to low
409 * low which will generate wakeup event resume the system
410 * immediately. Set it to 0 before hibernate to avoid this
411 * wakeup event.
412 */
413 gpio_set_value(musb->config->gpio_vrsel, 0);
414}
415
416void musb_platform_restore_context(struct musb *musb,
417 struct musb_context_registers *musb_context)
418{
419 bfin_musb_reg_init(musb);
420}
421#endif
422
423static int bfin_musb_exit(struct musb *musb)
398{ 424{
399 gpio_free(musb->config->gpio_vrsel); 425 gpio_free(musb->config->gpio_vrsel);
400 426
@@ -402,3 +428,17 @@ int musb_platform_exit(struct musb *musb)
402 usb_nop_xceiv_unregister(); 428 usb_nop_xceiv_unregister();
403 return 0; 429 return 0;
404} 430}
431
432const struct musb_platform_ops musb_ops = {
433 .init = bfin_musb_init,
434 .exit = bfin_musb_exit,
435
436 .enable = bfin_musb_enable,
437 .disable = bfin_musb_disable,
438
439 .set_mode = bfin_musb_set_mode,
440 .try_idle = bfin_musb_try_idle,
441
442 .vbus_status = bfin_musb_vbus_status,
443 .set_vbus = bfin_musb_set_vbus,
444};