diff options
Diffstat (limited to 'drivers/usb/otg/isp1301_omap.c')
-rw-r--r-- | drivers/usb/otg/isp1301_omap.c | 234 |
1 files changed, 122 insertions, 112 deletions
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c index 8c86787c2f09..70cf5d7bca48 100644 --- a/drivers/usb/otg/isp1301_omap.c +++ b/drivers/usb/otg/isp1301_omap.c | |||
@@ -52,7 +52,7 @@ MODULE_DESCRIPTION("ISP1301 USB OTG Transceiver Driver"); | |||
52 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
53 | 53 | ||
54 | struct isp1301 { | 54 | struct isp1301 { |
55 | struct otg_transceiver otg; | 55 | struct usb_phy phy; |
56 | struct i2c_client *client; | 56 | struct i2c_client *client; |
57 | void (*i2c_release)(struct device *dev); | 57 | void (*i2c_release)(struct device *dev); |
58 | 58 | ||
@@ -236,7 +236,7 @@ isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits) | |||
236 | 236 | ||
237 | static inline const char *state_name(struct isp1301 *isp) | 237 | static inline const char *state_name(struct isp1301 *isp) |
238 | { | 238 | { |
239 | return otg_state_string(isp->otg.state); | 239 | return otg_state_string(isp->phy.state); |
240 | } | 240 | } |
241 | 241 | ||
242 | /*-------------------------------------------------------------------------*/ | 242 | /*-------------------------------------------------------------------------*/ |
@@ -251,7 +251,7 @@ static inline const char *state_name(struct isp1301 *isp) | |||
251 | 251 | ||
252 | static void power_down(struct isp1301 *isp) | 252 | static void power_down(struct isp1301 *isp) |
253 | { | 253 | { |
254 | isp->otg.state = OTG_STATE_UNDEFINED; | 254 | isp->phy.state = OTG_STATE_UNDEFINED; |
255 | 255 | ||
256 | // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN); | 256 | // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN); |
257 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND); | 257 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND); |
@@ -280,13 +280,13 @@ static int host_suspend(struct isp1301 *isp) | |||
280 | #else | 280 | #else |
281 | struct device *dev; | 281 | struct device *dev; |
282 | 282 | ||
283 | if (!isp->otg.host) | 283 | if (!isp->phy.otg->host) |
284 | return -ENODEV; | 284 | return -ENODEV; |
285 | 285 | ||
286 | /* Currently ASSUMES only the OTG port matters; | 286 | /* Currently ASSUMES only the OTG port matters; |
287 | * other ports could be active... | 287 | * other ports could be active... |
288 | */ | 288 | */ |
289 | dev = isp->otg.host->controller; | 289 | dev = isp->phy.otg->host->controller; |
290 | return dev->driver->suspend(dev, 3, 0); | 290 | return dev->driver->suspend(dev, 3, 0); |
291 | #endif | 291 | #endif |
292 | } | 292 | } |
@@ -298,20 +298,20 @@ static int host_resume(struct isp1301 *isp) | |||
298 | #else | 298 | #else |
299 | struct device *dev; | 299 | struct device *dev; |
300 | 300 | ||
301 | if (!isp->otg.host) | 301 | if (!isp->phy.otg->host) |
302 | return -ENODEV; | 302 | return -ENODEV; |
303 | 303 | ||
304 | dev = isp->otg.host->controller; | 304 | dev = isp->phy.otg->host->controller; |
305 | return dev->driver->resume(dev, 0); | 305 | return dev->driver->resume(dev, 0); |
306 | #endif | 306 | #endif |
307 | } | 307 | } |
308 | 308 | ||
309 | static int gadget_suspend(struct isp1301 *isp) | 309 | static int gadget_suspend(struct isp1301 *isp) |
310 | { | 310 | { |
311 | isp->otg.gadget->b_hnp_enable = 0; | 311 | isp->phy.otg->gadget->b_hnp_enable = 0; |
312 | isp->otg.gadget->a_hnp_support = 0; | 312 | isp->phy.otg->gadget->a_hnp_support = 0; |
313 | isp->otg.gadget->a_alt_hnp_support = 0; | 313 | isp->phy.otg->gadget->a_alt_hnp_support = 0; |
314 | return usb_gadget_vbus_disconnect(isp->otg.gadget); | 314 | return usb_gadget_vbus_disconnect(isp->phy.otg->gadget); |
315 | } | 315 | } |
316 | 316 | ||
317 | /*-------------------------------------------------------------------------*/ | 317 | /*-------------------------------------------------------------------------*/ |
@@ -341,19 +341,19 @@ static void a_idle(struct isp1301 *isp, const char *tag) | |||
341 | { | 341 | { |
342 | u32 l; | 342 | u32 l; |
343 | 343 | ||
344 | if (isp->otg.state == OTG_STATE_A_IDLE) | 344 | if (isp->phy.state == OTG_STATE_A_IDLE) |
345 | return; | 345 | return; |
346 | 346 | ||
347 | isp->otg.default_a = 1; | 347 | isp->phy.otg->default_a = 1; |
348 | if (isp->otg.host) { | 348 | if (isp->phy.otg->host) { |
349 | isp->otg.host->is_b_host = 0; | 349 | isp->phy.otg->host->is_b_host = 0; |
350 | host_suspend(isp); | 350 | host_suspend(isp); |
351 | } | 351 | } |
352 | if (isp->otg.gadget) { | 352 | if (isp->phy.otg->gadget) { |
353 | isp->otg.gadget->is_a_peripheral = 1; | 353 | isp->phy.otg->gadget->is_a_peripheral = 1; |
354 | gadget_suspend(isp); | 354 | gadget_suspend(isp); |
355 | } | 355 | } |
356 | isp->otg.state = OTG_STATE_A_IDLE; | 356 | isp->phy.state = OTG_STATE_A_IDLE; |
357 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 357 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
358 | omap_writel(l, OTG_CTRL); | 358 | omap_writel(l, OTG_CTRL); |
359 | isp->last_otg_ctrl = l; | 359 | isp->last_otg_ctrl = l; |
@@ -365,19 +365,19 @@ static void b_idle(struct isp1301 *isp, const char *tag) | |||
365 | { | 365 | { |
366 | u32 l; | 366 | u32 l; |
367 | 367 | ||
368 | if (isp->otg.state == OTG_STATE_B_IDLE) | 368 | if (isp->phy.state == OTG_STATE_B_IDLE) |
369 | return; | 369 | return; |
370 | 370 | ||
371 | isp->otg.default_a = 0; | 371 | isp->phy.otg->default_a = 0; |
372 | if (isp->otg.host) { | 372 | if (isp->phy.otg->host) { |
373 | isp->otg.host->is_b_host = 1; | 373 | isp->phy.otg->host->is_b_host = 1; |
374 | host_suspend(isp); | 374 | host_suspend(isp); |
375 | } | 375 | } |
376 | if (isp->otg.gadget) { | 376 | if (isp->phy.otg->gadget) { |
377 | isp->otg.gadget->is_a_peripheral = 0; | 377 | isp->phy.otg->gadget->is_a_peripheral = 0; |
378 | gadget_suspend(isp); | 378 | gadget_suspend(isp); |
379 | } | 379 | } |
380 | isp->otg.state = OTG_STATE_B_IDLE; | 380 | isp->phy.state = OTG_STATE_B_IDLE; |
381 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 381 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
382 | omap_writel(l, OTG_CTRL); | 382 | omap_writel(l, OTG_CTRL); |
383 | isp->last_otg_ctrl = l; | 383 | isp->last_otg_ctrl = l; |
@@ -478,7 +478,7 @@ static void check_state(struct isp1301 *isp, const char *tag) | |||
478 | default: | 478 | default: |
479 | break; | 479 | break; |
480 | } | 480 | } |
481 | if (isp->otg.state == state && !extra) | 481 | if (isp->phy.state == state && !extra) |
482 | return; | 482 | return; |
483 | pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, | 483 | pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, |
484 | otg_state_string(state), fsm, state_name(isp), | 484 | otg_state_string(state), fsm, state_name(isp), |
@@ -502,22 +502,23 @@ static void update_otg1(struct isp1301 *isp, u8 int_src) | |||
502 | 502 | ||
503 | if (int_src & INTR_SESS_VLD) | 503 | if (int_src & INTR_SESS_VLD) |
504 | otg_ctrl |= OTG_ASESSVLD; | 504 | otg_ctrl |= OTG_ASESSVLD; |
505 | else if (isp->otg.state == OTG_STATE_A_WAIT_VFALL) { | 505 | else if (isp->phy.state == OTG_STATE_A_WAIT_VFALL) { |
506 | a_idle(isp, "vfall"); | 506 | a_idle(isp, "vfall"); |
507 | otg_ctrl &= ~OTG_CTRL_BITS; | 507 | otg_ctrl &= ~OTG_CTRL_BITS; |
508 | } | 508 | } |
509 | if (int_src & INTR_VBUS_VLD) | 509 | if (int_src & INTR_VBUS_VLD) |
510 | otg_ctrl |= OTG_VBUSVLD; | 510 | otg_ctrl |= OTG_VBUSVLD; |
511 | if (int_src & INTR_ID_GND) { /* default-A */ | 511 | if (int_src & INTR_ID_GND) { /* default-A */ |
512 | if (isp->otg.state == OTG_STATE_B_IDLE | 512 | if (isp->phy.state == OTG_STATE_B_IDLE |
513 | || isp->otg.state == OTG_STATE_UNDEFINED) { | 513 | || isp->phy.state |
514 | == OTG_STATE_UNDEFINED) { | ||
514 | a_idle(isp, "init"); | 515 | a_idle(isp, "init"); |
515 | return; | 516 | return; |
516 | } | 517 | } |
517 | } else { /* default-B */ | 518 | } else { /* default-B */ |
518 | otg_ctrl |= OTG_ID; | 519 | otg_ctrl |= OTG_ID; |
519 | if (isp->otg.state == OTG_STATE_A_IDLE | 520 | if (isp->phy.state == OTG_STATE_A_IDLE |
520 | || isp->otg.state == OTG_STATE_UNDEFINED) { | 521 | || isp->phy.state == OTG_STATE_UNDEFINED) { |
521 | b_idle(isp, "init"); | 522 | b_idle(isp, "init"); |
522 | return; | 523 | return; |
523 | } | 524 | } |
@@ -551,14 +552,14 @@ static void otg_update_isp(struct isp1301 *isp) | |||
551 | isp->last_otg_ctrl = otg_ctrl; | 552 | isp->last_otg_ctrl = otg_ctrl; |
552 | otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS; | 553 | otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS; |
553 | 554 | ||
554 | switch (isp->otg.state) { | 555 | switch (isp->phy.state) { |
555 | case OTG_STATE_B_IDLE: | 556 | case OTG_STATE_B_IDLE: |
556 | case OTG_STATE_B_PERIPHERAL: | 557 | case OTG_STATE_B_PERIPHERAL: |
557 | case OTG_STATE_B_SRP_INIT: | 558 | case OTG_STATE_B_SRP_INIT: |
558 | if (!(otg_ctrl & OTG_PULLUP)) { | 559 | if (!(otg_ctrl & OTG_PULLUP)) { |
559 | // if (otg_ctrl & OTG_B_HNPEN) { | 560 | // if (otg_ctrl & OTG_B_HNPEN) { |
560 | if (isp->otg.gadget->b_hnp_enable) { | 561 | if (isp->phy.otg->gadget->b_hnp_enable) { |
561 | isp->otg.state = OTG_STATE_B_WAIT_ACON; | 562 | isp->phy.state = OTG_STATE_B_WAIT_ACON; |
562 | pr_debug(" --> b_wait_acon\n"); | 563 | pr_debug(" --> b_wait_acon\n"); |
563 | } | 564 | } |
564 | goto pulldown; | 565 | goto pulldown; |
@@ -585,10 +586,10 @@ pulldown: | |||
585 | else clr |= ISP; \ | 586 | else clr |= ISP; \ |
586 | } while (0) | 587 | } while (0) |
587 | 588 | ||
588 | if (!(isp->otg.host)) | 589 | if (!(isp->phy.otg->host)) |
589 | otg_ctrl &= ~OTG_DRV_VBUS; | 590 | otg_ctrl &= ~OTG_DRV_VBUS; |
590 | 591 | ||
591 | switch (isp->otg.state) { | 592 | switch (isp->phy.state) { |
592 | case OTG_STATE_A_SUSPEND: | 593 | case OTG_STATE_A_SUSPEND: |
593 | if (otg_ctrl & OTG_DRV_VBUS) { | 594 | if (otg_ctrl & OTG_DRV_VBUS) { |
594 | set |= OTG1_VBUS_DRV; | 595 | set |= OTG1_VBUS_DRV; |
@@ -599,7 +600,7 @@ pulldown: | |||
599 | 600 | ||
600 | /* FALLTHROUGH */ | 601 | /* FALLTHROUGH */ |
601 | case OTG_STATE_A_VBUS_ERR: | 602 | case OTG_STATE_A_VBUS_ERR: |
602 | isp->otg.state = OTG_STATE_A_WAIT_VFALL; | 603 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; |
603 | pr_debug(" --> a_wait_vfall\n"); | 604 | pr_debug(" --> a_wait_vfall\n"); |
604 | /* FALLTHROUGH */ | 605 | /* FALLTHROUGH */ |
605 | case OTG_STATE_A_WAIT_VFALL: | 606 | case OTG_STATE_A_WAIT_VFALL: |
@@ -608,7 +609,7 @@ pulldown: | |||
608 | break; | 609 | break; |
609 | case OTG_STATE_A_IDLE: | 610 | case OTG_STATE_A_IDLE: |
610 | if (otg_ctrl & OTG_DRV_VBUS) { | 611 | if (otg_ctrl & OTG_DRV_VBUS) { |
611 | isp->otg.state = OTG_STATE_A_WAIT_VRISE; | 612 | isp->phy.state = OTG_STATE_A_WAIT_VRISE; |
612 | pr_debug(" --> a_wait_vrise\n"); | 613 | pr_debug(" --> a_wait_vrise\n"); |
613 | } | 614 | } |
614 | /* FALLTHROUGH */ | 615 | /* FALLTHROUGH */ |
@@ -628,17 +629,17 @@ pulldown: | |||
628 | if (otg_change & OTG_PULLUP) { | 629 | if (otg_change & OTG_PULLUP) { |
629 | u32 l; | 630 | u32 l; |
630 | 631 | ||
631 | switch (isp->otg.state) { | 632 | switch (isp->phy.state) { |
632 | case OTG_STATE_B_IDLE: | 633 | case OTG_STATE_B_IDLE: |
633 | if (clr & OTG1_DP_PULLUP) | 634 | if (clr & OTG1_DP_PULLUP) |
634 | break; | 635 | break; |
635 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 636 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
636 | pr_debug(" --> b_peripheral\n"); | 637 | pr_debug(" --> b_peripheral\n"); |
637 | break; | 638 | break; |
638 | case OTG_STATE_A_SUSPEND: | 639 | case OTG_STATE_A_SUSPEND: |
639 | if (clr & OTG1_DP_PULLUP) | 640 | if (clr & OTG1_DP_PULLUP) |
640 | break; | 641 | break; |
641 | isp->otg.state = OTG_STATE_A_PERIPHERAL; | 642 | isp->phy.state = OTG_STATE_A_PERIPHERAL; |
642 | pr_debug(" --> a_peripheral\n"); | 643 | pr_debug(" --> a_peripheral\n"); |
643 | break; | 644 | break; |
644 | default: | 645 | default: |
@@ -659,6 +660,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
659 | u32 otg_ctrl; | 660 | u32 otg_ctrl; |
660 | int ret = IRQ_NONE; | 661 | int ret = IRQ_NONE; |
661 | struct isp1301 *isp = _isp; | 662 | struct isp1301 *isp = _isp; |
663 | struct usb_otg *otg = isp->phy.otg; | ||
662 | 664 | ||
663 | /* update ISP1301 transceiver from OTG controller */ | 665 | /* update ISP1301 transceiver from OTG controller */ |
664 | if (otg_irq & OPRT_CHG) { | 666 | if (otg_irq & OPRT_CHG) { |
@@ -675,7 +677,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
675 | * remote wakeup (SRP, normal) using their own timer | 677 | * remote wakeup (SRP, normal) using their own timer |
676 | * to give "check cable and A-device" messages. | 678 | * to give "check cable and A-device" messages. |
677 | */ | 679 | */ |
678 | if (isp->otg.state == OTG_STATE_B_SRP_INIT) | 680 | if (isp->phy.state == OTG_STATE_B_SRP_INIT) |
679 | b_idle(isp, "srp_timeout"); | 681 | b_idle(isp, "srp_timeout"); |
680 | 682 | ||
681 | omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); | 683 | omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); |
@@ -693,7 +695,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
693 | omap_writel(otg_ctrl, OTG_CTRL); | 695 | omap_writel(otg_ctrl, OTG_CTRL); |
694 | 696 | ||
695 | /* subset of b_peripheral()... */ | 697 | /* subset of b_peripheral()... */ |
696 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 698 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
697 | pr_debug(" --> b_peripheral\n"); | 699 | pr_debug(" --> b_peripheral\n"); |
698 | 700 | ||
699 | omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); | 701 | omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); |
@@ -705,9 +707,9 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
705 | state_name(isp), omap_readl(OTG_CTRL)); | 707 | state_name(isp), omap_readl(OTG_CTRL)); |
706 | 708 | ||
707 | isp1301_defer_work(isp, WORK_UPDATE_OTG); | 709 | isp1301_defer_work(isp, WORK_UPDATE_OTG); |
708 | switch (isp->otg.state) { | 710 | switch (isp->phy.state) { |
709 | case OTG_STATE_A_IDLE: | 711 | case OTG_STATE_A_IDLE: |
710 | if (!isp->otg.host) | 712 | if (!otg->host) |
711 | break; | 713 | break; |
712 | isp1301_defer_work(isp, WORK_HOST_RESUME); | 714 | isp1301_defer_work(isp, WORK_HOST_RESUME); |
713 | otg_ctrl = omap_readl(OTG_CTRL); | 715 | otg_ctrl = omap_readl(OTG_CTRL); |
@@ -736,7 +738,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
736 | otg_ctrl |= OTG_BUSDROP; | 738 | otg_ctrl |= OTG_BUSDROP; |
737 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; | 739 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; |
738 | omap_writel(otg_ctrl, OTG_CTRL); | 740 | omap_writel(otg_ctrl, OTG_CTRL); |
739 | isp->otg.state = OTG_STATE_A_WAIT_VFALL; | 741 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; |
740 | 742 | ||
741 | omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); | 743 | omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); |
742 | ret = IRQ_HANDLED; | 744 | ret = IRQ_HANDLED; |
@@ -750,7 +752,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
750 | otg_ctrl |= OTG_BUSDROP; | 752 | otg_ctrl |= OTG_BUSDROP; |
751 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; | 753 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; |
752 | omap_writel(otg_ctrl, OTG_CTRL); | 754 | omap_writel(otg_ctrl, OTG_CTRL); |
753 | isp->otg.state = OTG_STATE_A_VBUS_ERR; | 755 | isp->phy.state = OTG_STATE_A_VBUS_ERR; |
754 | 756 | ||
755 | omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); | 757 | omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); |
756 | ret = IRQ_HANDLED; | 758 | ret = IRQ_HANDLED; |
@@ -771,7 +773,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
771 | 773 | ||
772 | /* role is peripheral */ | 774 | /* role is peripheral */ |
773 | if (otg_ctrl & OTG_DRIVER_SEL) { | 775 | if (otg_ctrl & OTG_DRIVER_SEL) { |
774 | switch (isp->otg.state) { | 776 | switch (isp->phy.state) { |
775 | case OTG_STATE_A_IDLE: | 777 | case OTG_STATE_A_IDLE: |
776 | b_idle(isp, __func__); | 778 | b_idle(isp, __func__); |
777 | break; | 779 | break; |
@@ -787,19 +789,19 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
787 | omap_writel(otg_ctrl | OTG_A_BUSREQ, OTG_CTRL); | 789 | omap_writel(otg_ctrl | OTG_A_BUSREQ, OTG_CTRL); |
788 | } | 790 | } |
789 | 791 | ||
790 | if (isp->otg.host) { | 792 | if (otg->host) { |
791 | switch (isp->otg.state) { | 793 | switch (isp->phy.state) { |
792 | case OTG_STATE_B_WAIT_ACON: | 794 | case OTG_STATE_B_WAIT_ACON: |
793 | isp->otg.state = OTG_STATE_B_HOST; | 795 | isp->phy.state = OTG_STATE_B_HOST; |
794 | pr_debug(" --> b_host\n"); | 796 | pr_debug(" --> b_host\n"); |
795 | kick = 1; | 797 | kick = 1; |
796 | break; | 798 | break; |
797 | case OTG_STATE_A_WAIT_BCON: | 799 | case OTG_STATE_A_WAIT_BCON: |
798 | isp->otg.state = OTG_STATE_A_HOST; | 800 | isp->phy.state = OTG_STATE_A_HOST; |
799 | pr_debug(" --> a_host\n"); | 801 | pr_debug(" --> a_host\n"); |
800 | break; | 802 | break; |
801 | case OTG_STATE_A_PERIPHERAL: | 803 | case OTG_STATE_A_PERIPHERAL: |
802 | isp->otg.state = OTG_STATE_A_WAIT_BCON; | 804 | isp->phy.state = OTG_STATE_A_WAIT_BCON; |
803 | pr_debug(" --> a_wait_bcon\n"); | 805 | pr_debug(" --> a_wait_bcon\n"); |
804 | break; | 806 | break; |
805 | default: | 807 | default: |
@@ -813,8 +815,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
813 | ret = IRQ_HANDLED; | 815 | ret = IRQ_HANDLED; |
814 | 816 | ||
815 | if (kick) | 817 | if (kick) |
816 | usb_bus_start_enum(isp->otg.host, | 818 | usb_bus_start_enum(otg->host, otg->host->otg_port); |
817 | isp->otg.host->otg_port); | ||
818 | } | 819 | } |
819 | 820 | ||
820 | check_state(isp, __func__); | 821 | check_state(isp, __func__); |
@@ -930,7 +931,7 @@ static void b_peripheral(struct isp1301 *isp) | |||
930 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 931 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
931 | omap_writel(l, OTG_CTRL); | 932 | omap_writel(l, OTG_CTRL); |
932 | 933 | ||
933 | usb_gadget_vbus_connect(isp->otg.gadget); | 934 | usb_gadget_vbus_connect(isp->phy.otg->gadget); |
934 | 935 | ||
935 | #ifdef CONFIG_USB_OTG | 936 | #ifdef CONFIG_USB_OTG |
936 | enable_vbus_draw(isp, 8); | 937 | enable_vbus_draw(isp, 8); |
@@ -940,7 +941,7 @@ static void b_peripheral(struct isp1301 *isp) | |||
940 | /* UDC driver just set OTG_BSESSVLD */ | 941 | /* UDC driver just set OTG_BSESSVLD */ |
941 | isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP); | 942 | isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP); |
942 | isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN); | 943 | isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN); |
943 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 944 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
944 | pr_debug(" --> b_peripheral\n"); | 945 | pr_debug(" --> b_peripheral\n"); |
945 | dump_regs(isp, "2periph"); | 946 | dump_regs(isp, "2periph"); |
946 | #endif | 947 | #endif |
@@ -948,8 +949,9 @@ static void b_peripheral(struct isp1301 *isp) | |||
948 | 949 | ||
949 | static void isp_update_otg(struct isp1301 *isp, u8 stat) | 950 | static void isp_update_otg(struct isp1301 *isp, u8 stat) |
950 | { | 951 | { |
952 | struct usb_otg *otg = isp->phy.otg; | ||
951 | u8 isp_stat, isp_bstat; | 953 | u8 isp_stat, isp_bstat; |
952 | enum usb_otg_state state = isp->otg.state; | 954 | enum usb_otg_state state = isp->phy.state; |
953 | 955 | ||
954 | if (stat & INTR_BDIS_ACON) | 956 | if (stat & INTR_BDIS_ACON) |
955 | pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); | 957 | pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); |
@@ -957,7 +959,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
957 | /* start certain state transitions right away */ | 959 | /* start certain state transitions right away */ |
958 | isp_stat = isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE); | 960 | isp_stat = isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE); |
959 | if (isp_stat & INTR_ID_GND) { | 961 | if (isp_stat & INTR_ID_GND) { |
960 | if (isp->otg.default_a) { | 962 | if (otg->default_a) { |
961 | switch (state) { | 963 | switch (state) { |
962 | case OTG_STATE_B_IDLE: | 964 | case OTG_STATE_B_IDLE: |
963 | a_idle(isp, "idle"); | 965 | a_idle(isp, "idle"); |
@@ -972,7 +974,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
972 | * when HNP is used. | 974 | * when HNP is used. |
973 | */ | 975 | */ |
974 | if (isp_stat & INTR_VBUS_VLD) | 976 | if (isp_stat & INTR_VBUS_VLD) |
975 | isp->otg.state = OTG_STATE_A_HOST; | 977 | isp->phy.state = OTG_STATE_A_HOST; |
976 | break; | 978 | break; |
977 | case OTG_STATE_A_WAIT_VFALL: | 979 | case OTG_STATE_A_WAIT_VFALL: |
978 | if (!(isp_stat & INTR_SESS_VLD)) | 980 | if (!(isp_stat & INTR_SESS_VLD)) |
@@ -980,7 +982,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
980 | break; | 982 | break; |
981 | default: | 983 | default: |
982 | if (!(isp_stat & INTR_VBUS_VLD)) | 984 | if (!(isp_stat & INTR_VBUS_VLD)) |
983 | isp->otg.state = OTG_STATE_A_VBUS_ERR; | 985 | isp->phy.state = OTG_STATE_A_VBUS_ERR; |
984 | break; | 986 | break; |
985 | } | 987 | } |
986 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); | 988 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); |
@@ -989,14 +991,14 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
989 | case OTG_STATE_B_PERIPHERAL: | 991 | case OTG_STATE_B_PERIPHERAL: |
990 | case OTG_STATE_B_HOST: | 992 | case OTG_STATE_B_HOST: |
991 | case OTG_STATE_B_WAIT_ACON: | 993 | case OTG_STATE_B_WAIT_ACON: |
992 | usb_gadget_vbus_disconnect(isp->otg.gadget); | 994 | usb_gadget_vbus_disconnect(otg->gadget); |
993 | break; | 995 | break; |
994 | default: | 996 | default: |
995 | break; | 997 | break; |
996 | } | 998 | } |
997 | if (state != OTG_STATE_A_IDLE) | 999 | if (state != OTG_STATE_A_IDLE) |
998 | a_idle(isp, "id"); | 1000 | a_idle(isp, "id"); |
999 | if (isp->otg.host && state == OTG_STATE_A_IDLE) | 1001 | if (otg->host && state == OTG_STATE_A_IDLE) |
1000 | isp1301_defer_work(isp, WORK_HOST_RESUME); | 1002 | isp1301_defer_work(isp, WORK_HOST_RESUME); |
1001 | isp_bstat = 0; | 1003 | isp_bstat = 0; |
1002 | } | 1004 | } |
@@ -1006,10 +1008,10 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1006 | /* if user unplugged mini-A end of cable, | 1008 | /* if user unplugged mini-A end of cable, |
1007 | * don't bypass A_WAIT_VFALL. | 1009 | * don't bypass A_WAIT_VFALL. |
1008 | */ | 1010 | */ |
1009 | if (isp->otg.default_a) { | 1011 | if (otg->default_a) { |
1010 | switch (state) { | 1012 | switch (state) { |
1011 | default: | 1013 | default: |
1012 | isp->otg.state = OTG_STATE_A_WAIT_VFALL; | 1014 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; |
1013 | break; | 1015 | break; |
1014 | case OTG_STATE_A_WAIT_VFALL: | 1016 | case OTG_STATE_A_WAIT_VFALL: |
1015 | state = OTG_STATE_A_IDLE; | 1017 | state = OTG_STATE_A_IDLE; |
@@ -1022,7 +1024,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1022 | host_suspend(isp); | 1024 | host_suspend(isp); |
1023 | isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1, | 1025 | isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1, |
1024 | MC1_BDIS_ACON_EN); | 1026 | MC1_BDIS_ACON_EN); |
1025 | isp->otg.state = OTG_STATE_B_IDLE; | 1027 | isp->phy.state = OTG_STATE_B_IDLE; |
1026 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; | 1028 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; |
1027 | l &= ~OTG_CTRL_BITS; | 1029 | l &= ~OTG_CTRL_BITS; |
1028 | omap_writel(l, OTG_CTRL); | 1030 | omap_writel(l, OTG_CTRL); |
@@ -1033,7 +1035,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1033 | } | 1035 | } |
1034 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); | 1036 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); |
1035 | 1037 | ||
1036 | switch (isp->otg.state) { | 1038 | switch (isp->phy.state) { |
1037 | case OTG_STATE_B_PERIPHERAL: | 1039 | case OTG_STATE_B_PERIPHERAL: |
1038 | case OTG_STATE_B_WAIT_ACON: | 1040 | case OTG_STATE_B_WAIT_ACON: |
1039 | case OTG_STATE_B_HOST: | 1041 | case OTG_STATE_B_HOST: |
@@ -1055,7 +1057,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1055 | omap_writel(l, OTG_CTRL); | 1057 | omap_writel(l, OTG_CTRL); |
1056 | /* FALLTHROUGH */ | 1058 | /* FALLTHROUGH */ |
1057 | case OTG_STATE_B_IDLE: | 1059 | case OTG_STATE_B_IDLE: |
1058 | if (isp->otg.gadget && (isp_bstat & OTG_B_SESS_VLD)) { | 1060 | if (otg->gadget && (isp_bstat & OTG_B_SESS_VLD)) { |
1059 | #ifdef CONFIG_USB_OTG | 1061 | #ifdef CONFIG_USB_OTG |
1060 | update_otg1(isp, isp_stat); | 1062 | update_otg1(isp, isp_stat); |
1061 | update_otg2(isp, isp_bstat); | 1063 | update_otg2(isp, isp_bstat); |
@@ -1073,7 +1075,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1073 | } | 1075 | } |
1074 | } | 1076 | } |
1075 | 1077 | ||
1076 | if (state != isp->otg.state) | 1078 | if (state != isp->phy.state) |
1077 | pr_debug(" isp, %s -> %s\n", | 1079 | pr_debug(" isp, %s -> %s\n", |
1078 | otg_state_string(state), state_name(isp)); | 1080 | otg_state_string(state), state_name(isp)); |
1079 | 1081 | ||
@@ -1131,10 +1133,10 @@ isp1301_work(struct work_struct *work) | |||
1131 | * skip A_WAIT_VRISE; hc transitions invisibly | 1133 | * skip A_WAIT_VRISE; hc transitions invisibly |
1132 | * skip A_WAIT_BCON; same. | 1134 | * skip A_WAIT_BCON; same. |
1133 | */ | 1135 | */ |
1134 | switch (isp->otg.state) { | 1136 | switch (isp->phy.state) { |
1135 | case OTG_STATE_A_WAIT_BCON: | 1137 | case OTG_STATE_A_WAIT_BCON: |
1136 | case OTG_STATE_A_WAIT_VRISE: | 1138 | case OTG_STATE_A_WAIT_VRISE: |
1137 | isp->otg.state = OTG_STATE_A_HOST; | 1139 | isp->phy.state = OTG_STATE_A_HOST; |
1138 | pr_debug(" --> a_host\n"); | 1140 | pr_debug(" --> a_host\n"); |
1139 | otg_ctrl = omap_readl(OTG_CTRL); | 1141 | otg_ctrl = omap_readl(OTG_CTRL); |
1140 | otg_ctrl |= OTG_A_BUSREQ; | 1142 | otg_ctrl |= OTG_A_BUSREQ; |
@@ -1143,7 +1145,7 @@ isp1301_work(struct work_struct *work) | |||
1143 | omap_writel(otg_ctrl, OTG_CTRL); | 1145 | omap_writel(otg_ctrl, OTG_CTRL); |
1144 | break; | 1146 | break; |
1145 | case OTG_STATE_B_WAIT_ACON: | 1147 | case OTG_STATE_B_WAIT_ACON: |
1146 | isp->otg.state = OTG_STATE_B_HOST; | 1148 | isp->phy.state = OTG_STATE_B_HOST; |
1147 | pr_debug(" --> b_host (acon)\n"); | 1149 | pr_debug(" --> b_host (acon)\n"); |
1148 | break; | 1150 | break; |
1149 | case OTG_STATE_B_HOST: | 1151 | case OTG_STATE_B_HOST: |
@@ -1204,6 +1206,7 @@ static void isp1301_release(struct device *dev) | |||
1204 | /* ugly -- i2c hijacks our memory hook to wait_for_completion() */ | 1206 | /* ugly -- i2c hijacks our memory hook to wait_for_completion() */ |
1205 | if (isp->i2c_release) | 1207 | if (isp->i2c_release) |
1206 | isp->i2c_release(dev); | 1208 | isp->i2c_release(dev); |
1209 | kfree(isp->phy.otg); | ||
1207 | kfree (isp); | 1210 | kfree (isp); |
1208 | } | 1211 | } |
1209 | 1212 | ||
@@ -1274,9 +1277,9 @@ static int isp1301_otg_enable(struct isp1301 *isp) | |||
1274 | 1277 | ||
1275 | /* add or disable the host device+driver */ | 1278 | /* add or disable the host device+driver */ |
1276 | static int | 1279 | static int |
1277 | isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | 1280 | isp1301_set_host(struct usb_otg *otg, struct usb_bus *host) |
1278 | { | 1281 | { |
1279 | struct isp1301 *isp = container_of(otg, struct isp1301, otg); | 1282 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1280 | 1283 | ||
1281 | if (!otg || isp != the_transceiver) | 1284 | if (!otg || isp != the_transceiver) |
1282 | return -ENODEV; | 1285 | return -ENODEV; |
@@ -1284,21 +1287,21 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
1284 | if (!host) { | 1287 | if (!host) { |
1285 | omap_writew(0, OTG_IRQ_EN); | 1288 | omap_writew(0, OTG_IRQ_EN); |
1286 | power_down(isp); | 1289 | power_down(isp); |
1287 | isp->otg.host = NULL; | 1290 | otg->host = NULL; |
1288 | return 0; | 1291 | return 0; |
1289 | } | 1292 | } |
1290 | 1293 | ||
1291 | #ifdef CONFIG_USB_OTG | 1294 | #ifdef CONFIG_USB_OTG |
1292 | isp->otg.host = host; | 1295 | otg->host = host; |
1293 | dev_dbg(&isp->client->dev, "registered host\n"); | 1296 | dev_dbg(&isp->client->dev, "registered host\n"); |
1294 | host_suspend(isp); | 1297 | host_suspend(isp); |
1295 | if (isp->otg.gadget) | 1298 | if (otg->gadget) |
1296 | return isp1301_otg_enable(isp); | 1299 | return isp1301_otg_enable(isp); |
1297 | return 0; | 1300 | return 0; |
1298 | 1301 | ||
1299 | #elif !defined(CONFIG_USB_GADGET_OMAP) | 1302 | #elif !defined(CONFIG_USB_GADGET_OMAP) |
1300 | // FIXME update its refcount | 1303 | // FIXME update its refcount |
1301 | isp->otg.host = host; | 1304 | otg->host = host; |
1302 | 1305 | ||
1303 | power_up(isp); | 1306 | power_up(isp); |
1304 | 1307 | ||
@@ -1330,9 +1333,9 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
1330 | } | 1333 | } |
1331 | 1334 | ||
1332 | static int | 1335 | static int |
1333 | isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | 1336 | isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) |
1334 | { | 1337 | { |
1335 | struct isp1301 *isp = container_of(otg, struct isp1301, otg); | 1338 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1336 | #ifndef CONFIG_USB_OTG | 1339 | #ifndef CONFIG_USB_OTG |
1337 | u32 l; | 1340 | u32 l; |
1338 | #endif | 1341 | #endif |
@@ -1342,24 +1345,24 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1342 | 1345 | ||
1343 | if (!gadget) { | 1346 | if (!gadget) { |
1344 | omap_writew(0, OTG_IRQ_EN); | 1347 | omap_writew(0, OTG_IRQ_EN); |
1345 | if (!isp->otg.default_a) | 1348 | if (!otg->default_a) |
1346 | enable_vbus_draw(isp, 0); | 1349 | enable_vbus_draw(isp, 0); |
1347 | usb_gadget_vbus_disconnect(isp->otg.gadget); | 1350 | usb_gadget_vbus_disconnect(otg->gadget); |
1348 | isp->otg.gadget = NULL; | 1351 | otg->gadget = NULL; |
1349 | power_down(isp); | 1352 | power_down(isp); |
1350 | return 0; | 1353 | return 0; |
1351 | } | 1354 | } |
1352 | 1355 | ||
1353 | #ifdef CONFIG_USB_OTG | 1356 | #ifdef CONFIG_USB_OTG |
1354 | isp->otg.gadget = gadget; | 1357 | otg->gadget = gadget; |
1355 | dev_dbg(&isp->client->dev, "registered gadget\n"); | 1358 | dev_dbg(&isp->client->dev, "registered gadget\n"); |
1356 | /* gadget driver may be suspended until vbus_connect () */ | 1359 | /* gadget driver may be suspended until vbus_connect () */ |
1357 | if (isp->otg.host) | 1360 | if (otg->host) |
1358 | return isp1301_otg_enable(isp); | 1361 | return isp1301_otg_enable(isp); |
1359 | return 0; | 1362 | return 0; |
1360 | 1363 | ||
1361 | #elif !defined(CONFIG_USB_OHCI_HCD) && !defined(CONFIG_USB_OHCI_HCD_MODULE) | 1364 | #elif !defined(CONFIG_USB_OHCI_HCD) && !defined(CONFIG_USB_OHCI_HCD_MODULE) |
1362 | isp->otg.gadget = gadget; | 1365 | otg->gadget = gadget; |
1363 | // FIXME update its refcount | 1366 | // FIXME update its refcount |
1364 | 1367 | ||
1365 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; | 1368 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; |
@@ -1368,7 +1371,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1368 | omap_writel(l, OTG_CTRL); | 1371 | omap_writel(l, OTG_CTRL); |
1369 | 1372 | ||
1370 | power_up(isp); | 1373 | power_up(isp); |
1371 | isp->otg.state = OTG_STATE_B_IDLE; | 1374 | isp->phy.state = OTG_STATE_B_IDLE; |
1372 | 1375 | ||
1373 | if (machine_is_omap_h2() || machine_is_omap_h3()) | 1376 | if (machine_is_omap_h2() || machine_is_omap_h3()) |
1374 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); | 1377 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); |
@@ -1399,7 +1402,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1399 | /*-------------------------------------------------------------------------*/ | 1402 | /*-------------------------------------------------------------------------*/ |
1400 | 1403 | ||
1401 | static int | 1404 | static int |
1402 | isp1301_set_power(struct otg_transceiver *dev, unsigned mA) | 1405 | isp1301_set_power(struct usb_phy *dev, unsigned mA) |
1403 | { | 1406 | { |
1404 | if (!the_transceiver) | 1407 | if (!the_transceiver) |
1405 | return -ENODEV; | 1408 | return -ENODEV; |
@@ -1409,13 +1412,13 @@ isp1301_set_power(struct otg_transceiver *dev, unsigned mA) | |||
1409 | } | 1412 | } |
1410 | 1413 | ||
1411 | static int | 1414 | static int |
1412 | isp1301_start_srp(struct otg_transceiver *dev) | 1415 | isp1301_start_srp(struct usb_otg *otg) |
1413 | { | 1416 | { |
1414 | struct isp1301 *isp = container_of(dev, struct isp1301, otg); | 1417 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1415 | u32 otg_ctrl; | 1418 | u32 otg_ctrl; |
1416 | 1419 | ||
1417 | if (!dev || isp != the_transceiver | 1420 | if (!otg || isp != the_transceiver |
1418 | || isp->otg.state != OTG_STATE_B_IDLE) | 1421 | || isp->phy.state != OTG_STATE_B_IDLE) |
1419 | return -ENODEV; | 1422 | return -ENODEV; |
1420 | 1423 | ||
1421 | otg_ctrl = omap_readl(OTG_CTRL); | 1424 | otg_ctrl = omap_readl(OTG_CTRL); |
@@ -1425,7 +1428,7 @@ isp1301_start_srp(struct otg_transceiver *dev) | |||
1425 | otg_ctrl |= OTG_B_BUSREQ; | 1428 | otg_ctrl |= OTG_B_BUSREQ; |
1426 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK; | 1429 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK; |
1427 | omap_writel(otg_ctrl, OTG_CTRL); | 1430 | omap_writel(otg_ctrl, OTG_CTRL); |
1428 | isp->otg.state = OTG_STATE_B_SRP_INIT; | 1431 | isp->phy.state = OTG_STATE_B_SRP_INIT; |
1429 | 1432 | ||
1430 | pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), | 1433 | pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), |
1431 | omap_readl(OTG_CTRL)); | 1434 | omap_readl(OTG_CTRL)); |
@@ -1436,27 +1439,26 @@ isp1301_start_srp(struct otg_transceiver *dev) | |||
1436 | } | 1439 | } |
1437 | 1440 | ||
1438 | static int | 1441 | static int |
1439 | isp1301_start_hnp(struct otg_transceiver *dev) | 1442 | isp1301_start_hnp(struct usb_otg *otg) |
1440 | { | 1443 | { |
1441 | #ifdef CONFIG_USB_OTG | 1444 | #ifdef CONFIG_USB_OTG |
1442 | struct isp1301 *isp = container_of(dev, struct isp1301, otg); | 1445 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1443 | u32 l; | 1446 | u32 l; |
1444 | 1447 | ||
1445 | if (!dev || isp != the_transceiver) | 1448 | if (!otg || isp != the_transceiver) |
1446 | return -ENODEV; | 1449 | return -ENODEV; |
1447 | if (isp->otg.default_a && (isp->otg.host == NULL | 1450 | if (otg->default_a && (otg->host == NULL || !otg->host->b_hnp_enable)) |
1448 | || !isp->otg.host->b_hnp_enable)) | ||
1449 | return -ENOTCONN; | 1451 | return -ENOTCONN; |
1450 | if (!isp->otg.default_a && (isp->otg.gadget == NULL | 1452 | if (!otg->default_a && (otg->gadget == NULL |
1451 | || !isp->otg.gadget->b_hnp_enable)) | 1453 | || !otg->gadget->b_hnp_enable)) |
1452 | return -ENOTCONN; | 1454 | return -ENOTCONN; |
1453 | 1455 | ||
1454 | /* We want hardware to manage most HNP protocol timings. | 1456 | /* We want hardware to manage most HNP protocol timings. |
1455 | * So do this part as early as possible... | 1457 | * So do this part as early as possible... |
1456 | */ | 1458 | */ |
1457 | switch (isp->otg.state) { | 1459 | switch (isp->phy.state) { |
1458 | case OTG_STATE_B_HOST: | 1460 | case OTG_STATE_B_HOST: |
1459 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 1461 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
1460 | /* caller will suspend next */ | 1462 | /* caller will suspend next */ |
1461 | break; | 1463 | break; |
1462 | case OTG_STATE_A_HOST: | 1464 | case OTG_STATE_A_HOST: |
@@ -1466,7 +1468,7 @@ isp1301_start_hnp(struct otg_transceiver *dev) | |||
1466 | MC1_BDIS_ACON_EN); | 1468 | MC1_BDIS_ACON_EN); |
1467 | #endif | 1469 | #endif |
1468 | /* caller must suspend then clear A_BUSREQ */ | 1470 | /* caller must suspend then clear A_BUSREQ */ |
1469 | usb_gadget_vbus_connect(isp->otg.gadget); | 1471 | usb_gadget_vbus_connect(otg->gadget); |
1470 | l = omap_readl(OTG_CTRL); | 1472 | l = omap_readl(OTG_CTRL); |
1471 | l |= OTG_A_SETB_HNPEN; | 1473 | l |= OTG_A_SETB_HNPEN; |
1472 | omap_writel(l, OTG_CTRL); | 1474 | omap_writel(l, OTG_CTRL); |
@@ -1503,6 +1505,12 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1503 | if (!isp) | 1505 | if (!isp) |
1504 | return 0; | 1506 | return 0; |
1505 | 1507 | ||
1508 | isp->phy.otg = kzalloc(sizeof *isp->phy.otg, GFP_KERNEL); | ||
1509 | if (!isp->phy.otg) { | ||
1510 | kfree(isp); | ||
1511 | return 0; | ||
1512 | } | ||
1513 | |||
1506 | INIT_WORK(&isp->work, isp1301_work); | 1514 | INIT_WORK(&isp->work, isp1301_work); |
1507 | init_timer(&isp->timer); | 1515 | init_timer(&isp->timer); |
1508 | isp->timer.function = isp1301_timer; | 1516 | isp->timer.function = isp1301_timer; |
@@ -1576,14 +1584,15 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1576 | goto fail; | 1584 | goto fail; |
1577 | } | 1585 | } |
1578 | 1586 | ||
1579 | isp->otg.dev = &i2c->dev; | 1587 | isp->phy.dev = &i2c->dev; |
1580 | isp->otg.label = DRIVER_NAME; | 1588 | isp->phy.label = DRIVER_NAME; |
1589 | isp->phy.set_power = isp1301_set_power, | ||
1581 | 1590 | ||
1582 | isp->otg.set_host = isp1301_set_host, | 1591 | isp->phy.otg->phy = &isp->phy; |
1583 | isp->otg.set_peripheral = isp1301_set_peripheral, | 1592 | isp->phy.otg->set_host = isp1301_set_host, |
1584 | isp->otg.set_power = isp1301_set_power, | 1593 | isp->phy.otg->set_peripheral = isp1301_set_peripheral, |
1585 | isp->otg.start_srp = isp1301_start_srp, | 1594 | isp->phy.otg->start_srp = isp1301_start_srp, |
1586 | isp->otg.start_hnp = isp1301_start_hnp, | 1595 | isp->phy.otg->start_hnp = isp1301_start_hnp, |
1587 | 1596 | ||
1588 | enable_vbus_draw(isp, 0); | 1597 | enable_vbus_draw(isp, 0); |
1589 | power_down(isp); | 1598 | power_down(isp); |
@@ -1601,7 +1610,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1601 | dev_dbg(&i2c->dev, "scheduled timer, %d min\n", TIMER_MINUTES); | 1610 | dev_dbg(&i2c->dev, "scheduled timer, %d min\n", TIMER_MINUTES); |
1602 | #endif | 1611 | #endif |
1603 | 1612 | ||
1604 | status = otg_set_transceiver(&isp->otg); | 1613 | status = usb_set_transceiver(&isp->phy); |
1605 | if (status < 0) | 1614 | if (status < 0) |
1606 | dev_err(&i2c->dev, "can't register transceiver, %d\n", | 1615 | dev_err(&i2c->dev, "can't register transceiver, %d\n", |
1607 | status); | 1616 | status); |
@@ -1609,6 +1618,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1609 | return 0; | 1618 | return 0; |
1610 | 1619 | ||
1611 | fail: | 1620 | fail: |
1621 | kfree(isp->phy.otg); | ||
1612 | kfree(isp); | 1622 | kfree(isp); |
1613 | return -ENODEV; | 1623 | return -ENODEV; |
1614 | } | 1624 | } |
@@ -1639,7 +1649,7 @@ subsys_initcall(isp_init); | |||
1639 | static void __exit isp_exit(void) | 1649 | static void __exit isp_exit(void) |
1640 | { | 1650 | { |
1641 | if (the_transceiver) | 1651 | if (the_transceiver) |
1642 | otg_set_transceiver(NULL); | 1652 | usb_set_transceiver(NULL); |
1643 | i2c_del_driver(&isp1301_driver); | 1653 | i2c_del_driver(&isp1301_driver); |
1644 | } | 1654 | } |
1645 | module_exit(isp_exit); | 1655 | module_exit(isp_exit); |