diff options
author | Heikki Krogerus <heikki.krogerus@linux.intel.com> | 2012-02-13 06:24:06 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-02-13 06:35:25 -0500 |
commit | 7e062c0f8888001d28cf74da0c3d16a651bd7489 (patch) | |
tree | 459a77a6f9eab6e4b0d584d744d5feb39832a21f /drivers | |
parent | 144713f34727801d55d8858e0f549118b9f691c4 (diff) |
usb: otg: fsl: 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: Li Yang <leoli@freescale.com>
Reviewed-by: Marek Vasut <marek.vasut@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/otg/fsl_otg.c | 113 | ||||
-rw-r--r-- | drivers/usb/otg/fsl_otg.h | 2 | ||||
-rw-r--r-- | drivers/usb/otg/otg_fsm.c | 22 | ||||
-rw-r--r-- | drivers/usb/otg/otg_fsm.h | 2 |
4 files changed, 75 insertions, 64 deletions
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c index 66db2a117444..be4a63e8302f 100644 --- a/drivers/usb/otg/fsl_otg.c +++ b/drivers/usb/otg/fsl_otg.c | |||
@@ -275,7 +275,7 @@ void b_srp_end(unsigned long foo) | |||
275 | fsl_otg_dischrg_vbus(0); | 275 | fsl_otg_dischrg_vbus(0); |
276 | srp_wait_done = 1; | 276 | srp_wait_done = 1; |
277 | 277 | ||
278 | if ((fsl_otg_dev->otg.state == OTG_STATE_B_SRP_INIT) && | 278 | if ((fsl_otg_dev->phy.state == OTG_STATE_B_SRP_INIT) && |
279 | fsl_otg_dev->fsm.b_sess_vld) | 279 | fsl_otg_dev->fsm.b_sess_vld) |
280 | fsl_otg_dev->fsm.b_srp_done = 1; | 280 | fsl_otg_dev->fsm.b_srp_done = 1; |
281 | } | 281 | } |
@@ -288,7 +288,7 @@ void b_srp_end(unsigned long foo) | |||
288 | void a_wait_enum(unsigned long foo) | 288 | 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->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(a_wait_enum_tmr); |
293 | else | 293 | else |
294 | otg_statemachine(&fsl_otg_dev->fsm); | 294 | otg_statemachine(&fsl_otg_dev->fsm); |
@@ -452,14 +452,14 @@ void otg_reset_controller(void) | |||
452 | /* Call suspend/resume routines in host driver */ | 452 | /* Call suspend/resume routines in host driver */ |
453 | int fsl_otg_start_host(struct otg_fsm *fsm, int on) | 453 | int fsl_otg_start_host(struct otg_fsm *fsm, int on) |
454 | { | 454 | { |
455 | struct usb_phy *xceiv = fsm->transceiver; | 455 | struct usb_otg *otg = fsm->otg; |
456 | struct device *dev; | 456 | struct device *dev; |
457 | struct fsl_otg *otg_dev = container_of(xceiv, struct fsl_otg, otg); | 457 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
458 | u32 retval = 0; | 458 | u32 retval = 0; |
459 | 459 | ||
460 | if (!xceiv->host) | 460 | if (!otg->host) |
461 | return -ENODEV; | 461 | return -ENODEV; |
462 | dev = xceiv->host->controller; | 462 | dev = otg->host->controller; |
463 | 463 | ||
464 | /* | 464 | /* |
465 | * Update a_vbus_vld state as a_vbus_vld int is disabled | 465 | * Update a_vbus_vld state as a_vbus_vld int is disabled |
@@ -518,14 +518,14 @@ end: | |||
518 | */ | 518 | */ |
519 | int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) | 519 | int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) |
520 | { | 520 | { |
521 | struct usb_phy *xceiv = fsm->transceiver; | 521 | struct usb_otg *otg = fsm->otg; |
522 | struct device *dev; | 522 | struct device *dev; |
523 | 523 | ||
524 | if (!xceiv->gadget || !xceiv->gadget->dev.parent) | 524 | if (!otg->gadget || !otg->gadget->dev.parent) |
525 | return -ENODEV; | 525 | return -ENODEV; |
526 | 526 | ||
527 | VDBG("gadget %s\n", on ? "on" : "off"); | 527 | VDBG("gadget %s\n", on ? "on" : "off"); |
528 | dev = xceiv->gadget->dev.parent; | 528 | dev = otg->gadget->dev.parent; |
529 | 529 | ||
530 | if (on) { | 530 | if (on) { |
531 | if (dev->driver->resume) | 531 | if (dev->driver->resume) |
@@ -542,14 +542,14 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) | |||
542 | * Called by initialization code of host driver. Register host controller | 542 | * Called by initialization code of host driver. Register host controller |
543 | * to the OTG. Suspend host for OTG role detection. | 543 | * to the OTG. Suspend host for OTG role detection. |
544 | */ | 544 | */ |
545 | static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) | 545 | static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
546 | { | 546 | { |
547 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 547 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
548 | 548 | ||
549 | if (!otg_p || otg_dev != fsl_otg_dev) | 549 | if (!otg || otg_dev != fsl_otg_dev) |
550 | return -ENODEV; | 550 | return -ENODEV; |
551 | 551 | ||
552 | otg_p->host = host; | 552 | otg->host = host; |
553 | 553 | ||
554 | otg_dev->fsm.a_bus_drop = 0; | 554 | otg_dev->fsm.a_bus_drop = 0; |
555 | otg_dev->fsm.a_bus_req = 1; | 555 | otg_dev->fsm.a_bus_req = 1; |
@@ -557,8 +557,8 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) | |||
557 | if (host) { | 557 | if (host) { |
558 | VDBG("host off......\n"); | 558 | VDBG("host off......\n"); |
559 | 559 | ||
560 | otg_p->host->otg_port = fsl_otg_initdata.otg_port; | 560 | otg->host->otg_port = fsl_otg_initdata.otg_port; |
561 | otg_p->host->is_b_host = otg_dev->fsm.id; | 561 | otg->host->is_b_host = otg_dev->fsm.id; |
562 | /* | 562 | /* |
563 | * must leave time for khubd to finish its thing | 563 | * must leave time for khubd to finish its thing |
564 | * before yanking the host driver out from under it, | 564 | * before yanking the host driver out from under it, |
@@ -574,7 +574,7 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) | |||
574 | /* Mini-A cable connected */ | 574 | /* Mini-A cable connected */ |
575 | struct otg_fsm *fsm = &otg_dev->fsm; | 575 | struct otg_fsm *fsm = &otg_dev->fsm; |
576 | 576 | ||
577 | otg_p->state = OTG_STATE_UNDEFINED; | 577 | otg->phy->state = OTG_STATE_UNDEFINED; |
578 | fsm->protocol = PROTO_UNDEF; | 578 | fsm->protocol = PROTO_UNDEF; |
579 | } | 579 | } |
580 | } | 580 | } |
@@ -587,29 +587,29 @@ static int fsl_otg_set_host(struct usb_phy *otg_p, struct usb_bus *host) | |||
587 | } | 587 | } |
588 | 588 | ||
589 | /* Called by initialization code of udc. Register udc to OTG. */ | 589 | /* Called by initialization code of udc. Register udc to OTG. */ |
590 | static int fsl_otg_set_peripheral(struct usb_phy *otg_p, | 590 | static int fsl_otg_set_peripheral(struct usb_otg *otg, |
591 | struct usb_gadget *gadget) | 591 | struct usb_gadget *gadget) |
592 | { | 592 | { |
593 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 593 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
594 | 594 | ||
595 | VDBG("otg_dev 0x%x\n", (int)otg_dev); | 595 | VDBG("otg_dev 0x%x\n", (int)otg_dev); |
596 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); | 596 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); |
597 | 597 | ||
598 | if (!otg_p || otg_dev != fsl_otg_dev) | 598 | if (!otg || otg_dev != fsl_otg_dev) |
599 | return -ENODEV; | 599 | return -ENODEV; |
600 | 600 | ||
601 | if (!gadget) { | 601 | if (!gadget) { |
602 | if (!otg_dev->otg.default_a) | 602 | if (!otg->default_a) |
603 | otg_p->gadget->ops->vbus_draw(otg_p->gadget, 0); | 603 | otg->gadget->ops->vbus_draw(otg->gadget, 0); |
604 | usb_gadget_vbus_disconnect(otg_dev->otg.gadget); | 604 | usb_gadget_vbus_disconnect(otg->gadget); |
605 | otg_dev->otg.gadget = 0; | 605 | otg->gadget = 0; |
606 | otg_dev->fsm.b_bus_req = 0; | 606 | otg_dev->fsm.b_bus_req = 0; |
607 | otg_statemachine(&otg_dev->fsm); | 607 | otg_statemachine(&otg_dev->fsm); |
608 | return 0; | 608 | return 0; |
609 | } | 609 | } |
610 | 610 | ||
611 | otg_p->gadget = gadget; | 611 | otg->gadget = gadget; |
612 | otg_p->gadget->is_a_peripheral = !otg_dev->fsm.id; | 612 | otg->gadget->is_a_peripheral = !otg_dev->fsm.id; |
613 | 613 | ||
614 | otg_dev->fsm.b_bus_req = 1; | 614 | otg_dev->fsm.b_bus_req = 1; |
615 | 615 | ||
@@ -625,11 +625,11 @@ static int fsl_otg_set_peripheral(struct usb_phy *otg_p, | |||
625 | } | 625 | } |
626 | 626 | ||
627 | /* Set OTG port power, only for B-device */ | 627 | /* Set OTG port power, only for B-device */ |
628 | static int fsl_otg_set_power(struct usb_phy *otg_p, unsigned mA) | 628 | static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA) |
629 | { | 629 | { |
630 | if (!fsl_otg_dev) | 630 | if (!fsl_otg_dev) |
631 | return -ENODEV; | 631 | return -ENODEV; |
632 | if (otg_p->state == OTG_STATE_B_PERIPHERAL) | 632 | if (phy->state == OTG_STATE_B_PERIPHERAL) |
633 | pr_info("FSL OTG: Draw %d mA\n", mA); | 633 | pr_info("FSL OTG: Draw %d mA\n", mA); |
634 | 634 | ||
635 | return 0; | 635 | return 0; |
@@ -658,12 +658,12 @@ static void fsl_otg_event(struct work_struct *work) | |||
658 | } | 658 | } |
659 | 659 | ||
660 | /* B-device start SRP */ | 660 | /* B-device start SRP */ |
661 | static int fsl_otg_start_srp(struct usb_phy *otg_p) | 661 | static int fsl_otg_start_srp(struct usb_otg *otg) |
662 | { | 662 | { |
663 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 663 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
664 | 664 | ||
665 | if (!otg_p || otg_dev != fsl_otg_dev | 665 | if (!otg || otg_dev != fsl_otg_dev |
666 | || otg_p->state != OTG_STATE_B_IDLE) | 666 | || otg->phy->state != OTG_STATE_B_IDLE) |
667 | return -ENODEV; | 667 | return -ENODEV; |
668 | 668 | ||
669 | otg_dev->fsm.b_bus_req = 1; | 669 | otg_dev->fsm.b_bus_req = 1; |
@@ -673,11 +673,11 @@ static int fsl_otg_start_srp(struct usb_phy *otg_p) | |||
673 | } | 673 | } |
674 | 674 | ||
675 | /* A_host suspend will call this function to start hnp */ | 675 | /* A_host suspend will call this function to start hnp */ |
676 | static int fsl_otg_start_hnp(struct usb_phy *otg_p) | 676 | static int fsl_otg_start_hnp(struct usb_otg *otg) |
677 | { | 677 | { |
678 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 678 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
679 | 679 | ||
680 | if (!otg_p || otg_dev != fsl_otg_dev) | 680 | if (!otg || otg_dev != fsl_otg_dev) |
681 | return -ENODEV; | 681 | return -ENODEV; |
682 | 682 | ||
683 | DBG("start_hnp...n"); | 683 | DBG("start_hnp...n"); |
@@ -698,7 +698,7 @@ static int fsl_otg_start_hnp(struct usb_phy *otg_p) | |||
698 | irqreturn_t fsl_otg_isr(int irq, void *dev_id) | 698 | irqreturn_t fsl_otg_isr(int irq, void *dev_id) |
699 | { | 699 | { |
700 | struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm; | 700 | struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm; |
701 | struct usb_phy *otg = &((struct fsl_otg *)dev_id)->otg; | 701 | struct usb_otg *otg = ((struct fsl_otg *)dev_id)->phy.otg; |
702 | u32 otg_int_src, otg_sc; | 702 | u32 otg_int_src, otg_sc; |
703 | 703 | ||
704 | otg_sc = fsl_readl(&usb_dr_regs->otgsc); | 704 | otg_sc = fsl_readl(&usb_dr_regs->otgsc); |
@@ -774,6 +774,12 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
774 | if (!fsl_otg_tc) | 774 | if (!fsl_otg_tc) |
775 | return -ENOMEM; | 775 | return -ENOMEM; |
776 | 776 | ||
777 | fsl_otg_tc->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL); | ||
778 | if (!fsl_otg_tc->phy.otg) { | ||
779 | kfree(fsl_otg_tc); | ||
780 | return -ENOMEM; | ||
781 | } | ||
782 | |||
777 | INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event); | 783 | INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event); |
778 | 784 | ||
779 | INIT_LIST_HEAD(&active_timers); | 785 | INIT_LIST_HEAD(&active_timers); |
@@ -788,17 +794,19 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
788 | fsl_otg_tc->fsm.ops = &fsl_otg_ops; | 794 | fsl_otg_tc->fsm.ops = &fsl_otg_ops; |
789 | 795 | ||
790 | /* initialize the otg structure */ | 796 | /* initialize the otg structure */ |
791 | fsl_otg_tc->otg.label = DRIVER_DESC; | 797 | fsl_otg_tc->phy.label = DRIVER_DESC; |
792 | fsl_otg_tc->otg.set_host = fsl_otg_set_host; | 798 | fsl_otg_tc->phy.set_power = fsl_otg_set_power; |
793 | fsl_otg_tc->otg.set_peripheral = fsl_otg_set_peripheral; | 799 | |
794 | fsl_otg_tc->otg.set_power = fsl_otg_set_power; | 800 | fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy; |
795 | fsl_otg_tc->otg.start_hnp = fsl_otg_start_hnp; | 801 | fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host; |
796 | fsl_otg_tc->otg.start_srp = fsl_otg_start_srp; | 802 | fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral; |
803 | fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp; | ||
804 | fsl_otg_tc->phy.otg->start_srp = fsl_otg_start_srp; | ||
797 | 805 | ||
798 | fsl_otg_dev = fsl_otg_tc; | 806 | fsl_otg_dev = fsl_otg_tc; |
799 | 807 | ||
800 | /* Store the otg transceiver */ | 808 | /* Store the otg transceiver */ |
801 | status = otg_set_transceiver(&fsl_otg_tc->otg); | 809 | status = usb_set_transceiver(&fsl_otg_tc->phy); |
802 | if (status) { | 810 | if (status) { |
803 | pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n"); | 811 | pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n"); |
804 | goto err; | 812 | goto err; |
@@ -807,6 +815,7 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
807 | return 0; | 815 | return 0; |
808 | err: | 816 | err: |
809 | fsl_otg_uninit_timers(); | 817 | fsl_otg_uninit_timers(); |
818 | kfree(fsl_otg_tc->phy.otg); | ||
810 | kfree(fsl_otg_tc); | 819 | kfree(fsl_otg_tc); |
811 | return status; | 820 | return status; |
812 | } | 821 | } |
@@ -815,19 +824,19 @@ err: | |||
815 | int usb_otg_start(struct platform_device *pdev) | 824 | int usb_otg_start(struct platform_device *pdev) |
816 | { | 825 | { |
817 | struct fsl_otg *p_otg; | 826 | struct fsl_otg *p_otg; |
818 | struct usb_phy *otg_trans = otg_get_transceiver(); | 827 | struct usb_phy *otg_trans = usb_get_transceiver(); |
819 | struct otg_fsm *fsm; | 828 | struct otg_fsm *fsm; |
820 | int status; | 829 | int status; |
821 | struct resource *res; | 830 | struct resource *res; |
822 | u32 temp; | 831 | u32 temp; |
823 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 832 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; |
824 | 833 | ||
825 | p_otg = container_of(otg_trans, struct fsl_otg, otg); | 834 | p_otg = container_of(otg_trans, struct fsl_otg, phy); |
826 | fsm = &p_otg->fsm; | 835 | fsm = &p_otg->fsm; |
827 | 836 | ||
828 | /* Initialize the state machine structure with default values */ | 837 | /* Initialize the state machine structure with default values */ |
829 | SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED); | 838 | SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED); |
830 | fsm->transceiver = &p_otg->otg; | 839 | fsm->otg = p_otg->phy.otg; |
831 | 840 | ||
832 | /* We don't require predefined MEM/IRQ resource index */ | 841 | /* We don't require predefined MEM/IRQ resource index */ |
833 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 842 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -857,9 +866,10 @@ int usb_otg_start(struct platform_device *pdev) | |||
857 | status = request_irq(p_otg->irq, fsl_otg_isr, | 866 | status = request_irq(p_otg->irq, fsl_otg_isr, |
858 | IRQF_SHARED, driver_name, p_otg); | 867 | IRQF_SHARED, driver_name, p_otg); |
859 | if (status) { | 868 | if (status) { |
860 | dev_dbg(p_otg->otg.dev, "can't get IRQ %d, error %d\n", | 869 | dev_dbg(p_otg->phy.dev, "can't get IRQ %d, error %d\n", |
861 | p_otg->irq, status); | 870 | p_otg->irq, status); |
862 | iounmap(p_otg->dr_mem_map); | 871 | iounmap(p_otg->dr_mem_map); |
872 | kfree(p_otg->phy.otg); | ||
863 | kfree(p_otg); | 873 | kfree(p_otg); |
864 | return status; | 874 | return status; |
865 | } | 875 | } |
@@ -919,10 +929,10 @@ int usb_otg_start(struct platform_device *pdev) | |||
919 | * Also: record initial state of ID pin | 929 | * Also: record initial state of ID pin |
920 | */ | 930 | */ |
921 | if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { | 931 | if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { |
922 | p_otg->otg.state = OTG_STATE_UNDEFINED; | 932 | p_otg->phy.state = OTG_STATE_UNDEFINED; |
923 | p_otg->fsm.id = 1; | 933 | p_otg->fsm.id = 1; |
924 | } else { | 934 | } else { |
925 | p_otg->otg.state = OTG_STATE_A_IDLE; | 935 | p_otg->phy.state = OTG_STATE_A_IDLE; |
926 | p_otg->fsm.id = 0; | 936 | p_otg->fsm.id = 0; |
927 | } | 937 | } |
928 | 938 | ||
@@ -978,7 +988,7 @@ static int show_fsl_usb2_otg_state(struct device *dev, | |||
978 | /* State */ | 988 | /* State */ |
979 | t = scnprintf(next, size, | 989 | t = scnprintf(next, size, |
980 | "OTG state: %s\n\n", | 990 | "OTG state: %s\n\n", |
981 | otg_state_string(fsl_otg_dev->otg.state)); | 991 | otg_state_string(fsl_otg_dev->phy.state)); |
982 | size -= t; | 992 | size -= t; |
983 | next += t; | 993 | next += t; |
984 | 994 | ||
@@ -1124,12 +1134,13 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev) | |||
1124 | { | 1134 | { |
1125 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 1135 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; |
1126 | 1136 | ||
1127 | otg_set_transceiver(NULL); | 1137 | usb_set_transceiver(NULL); |
1128 | free_irq(fsl_otg_dev->irq, fsl_otg_dev); | 1138 | free_irq(fsl_otg_dev->irq, fsl_otg_dev); |
1129 | 1139 | ||
1130 | iounmap((void *)usb_dr_regs); | 1140 | iounmap((void *)usb_dr_regs); |
1131 | 1141 | ||
1132 | fsl_otg_uninit_timers(); | 1142 | fsl_otg_uninit_timers(); |
1143 | kfree(fsl_otg_dev->phy.otg); | ||
1133 | kfree(fsl_otg_dev); | 1144 | kfree(fsl_otg_dev); |
1134 | 1145 | ||
1135 | device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); | 1146 | device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); |
diff --git a/drivers/usb/otg/fsl_otg.h b/drivers/usb/otg/fsl_otg.h index caec254ad819..ca266280895d 100644 --- a/drivers/usb/otg/fsl_otg.h +++ b/drivers/usb/otg/fsl_otg.h | |||
@@ -369,7 +369,7 @@ inline struct fsl_otg_timer *otg_timer_initializer | |||
369 | } | 369 | } |
370 | 370 | ||
371 | struct fsl_otg { | 371 | struct fsl_otg { |
372 | struct usb_phy otg; | 372 | struct usb_phy phy; |
373 | struct otg_fsm fsm; | 373 | struct otg_fsm fsm; |
374 | struct usb_dr_mmap *dr_mem_map; | 374 | struct usb_dr_mmap *dr_mem_map; |
375 | struct delayed_work otg_event; | 375 | struct delayed_work otg_event; |
diff --git a/drivers/usb/otg/otg_fsm.c b/drivers/usb/otg/otg_fsm.c index 09117387d2a4..ade131a8ae5e 100644 --- a/drivers/usb/otg/otg_fsm.c +++ b/drivers/usb/otg/otg_fsm.c | |||
@@ -117,10 +117,10 @@ void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) | |||
117 | int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | 117 | int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) |
118 | { | 118 | { |
119 | state_changed = 1; | 119 | state_changed = 1; |
120 | if (fsm->transceiver->state == new_state) | 120 | if (fsm->otg->phy->state == new_state) |
121 | return 0; | 121 | return 0; |
122 | VDBG("Set state: %s\n", otg_state_string(new_state)); | 122 | VDBG("Set state: %s\n", otg_state_string(new_state)); |
123 | otg_leave_state(fsm, fsm->transceiver->state); | 123 | otg_leave_state(fsm, fsm->otg->phy->state); |
124 | switch (new_state) { | 124 | switch (new_state) { |
125 | case OTG_STATE_B_IDLE: | 125 | case OTG_STATE_B_IDLE: |
126 | otg_drv_vbus(fsm, 0); | 126 | otg_drv_vbus(fsm, 0); |
@@ -155,8 +155,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | |||
155 | otg_loc_conn(fsm, 0); | 155 | otg_loc_conn(fsm, 0); |
156 | otg_loc_sof(fsm, 1); | 156 | otg_loc_sof(fsm, 1); |
157 | otg_set_protocol(fsm, PROTO_HOST); | 157 | otg_set_protocol(fsm, PROTO_HOST); |
158 | usb_bus_start_enum(fsm->transceiver->host, | 158 | usb_bus_start_enum(fsm->otg->host, |
159 | fsm->transceiver->host->otg_port); | 159 | fsm->otg->host->otg_port); |
160 | break; | 160 | break; |
161 | case OTG_STATE_A_IDLE: | 161 | case OTG_STATE_A_IDLE: |
162 | otg_drv_vbus(fsm, 0); | 162 | otg_drv_vbus(fsm, 0); |
@@ -221,7 +221,7 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | |||
221 | break; | 221 | break; |
222 | } | 222 | } |
223 | 223 | ||
224 | fsm->transceiver->state = new_state; | 224 | fsm->otg->phy->state = new_state; |
225 | return 0; | 225 | return 0; |
226 | } | 226 | } |
227 | 227 | ||
@@ -233,7 +233,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
233 | 233 | ||
234 | spin_lock_irqsave(&fsm->lock, flags); | 234 | spin_lock_irqsave(&fsm->lock, flags); |
235 | 235 | ||
236 | state = fsm->transceiver->state; | 236 | state = fsm->otg->phy->state; |
237 | state_changed = 0; | 237 | state_changed = 0; |
238 | /* State machine state change judgement */ | 238 | /* State machine state change judgement */ |
239 | 239 | ||
@@ -248,7 +248,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
248 | case OTG_STATE_B_IDLE: | 248 | case OTG_STATE_B_IDLE: |
249 | if (!fsm->id) | 249 | if (!fsm->id) |
250 | otg_set_state(fsm, OTG_STATE_A_IDLE); | 250 | otg_set_state(fsm, OTG_STATE_A_IDLE); |
251 | else if (fsm->b_sess_vld && fsm->transceiver->gadget) | 251 | else if (fsm->b_sess_vld && fsm->otg->gadget) |
252 | otg_set_state(fsm, OTG_STATE_B_PERIPHERAL); | 252 | otg_set_state(fsm, OTG_STATE_B_PERIPHERAL); |
253 | else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp) | 253 | else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp) |
254 | otg_set_state(fsm, OTG_STATE_B_SRP_INIT); | 254 | otg_set_state(fsm, OTG_STATE_B_SRP_INIT); |
@@ -260,7 +260,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
260 | case OTG_STATE_B_PERIPHERAL: | 260 | case OTG_STATE_B_PERIPHERAL: |
261 | if (!fsm->id || !fsm->b_sess_vld) | 261 | if (!fsm->id || !fsm->b_sess_vld) |
262 | otg_set_state(fsm, OTG_STATE_B_IDLE); | 262 | otg_set_state(fsm, OTG_STATE_B_IDLE); |
263 | else if (fsm->b_bus_req && fsm->transceiver-> | 263 | else if (fsm->b_bus_req && fsm->otg-> |
264 | gadget->b_hnp_enable && fsm->a_bus_suspend) | 264 | gadget->b_hnp_enable && fsm->a_bus_suspend) |
265 | otg_set_state(fsm, OTG_STATE_B_WAIT_ACON); | 265 | otg_set_state(fsm, OTG_STATE_B_WAIT_ACON); |
266 | break; | 266 | break; |
@@ -302,7 +302,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
302 | break; | 302 | break; |
303 | case OTG_STATE_A_HOST: | 303 | case OTG_STATE_A_HOST: |
304 | if ((!fsm->a_bus_req || fsm->a_suspend_req) && | 304 | if ((!fsm->a_bus_req || fsm->a_suspend_req) && |
305 | fsm->transceiver->host->b_hnp_enable) | 305 | fsm->otg->host->b_hnp_enable) |
306 | otg_set_state(fsm, OTG_STATE_A_SUSPEND); | 306 | otg_set_state(fsm, OTG_STATE_A_SUSPEND); |
307 | else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop) | 307 | else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop) |
308 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); | 308 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); |
@@ -310,9 +310,9 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
310 | otg_set_state(fsm, OTG_STATE_A_VBUS_ERR); | 310 | otg_set_state(fsm, OTG_STATE_A_VBUS_ERR); |
311 | break; | 311 | break; |
312 | case OTG_STATE_A_SUSPEND: | 312 | case OTG_STATE_A_SUSPEND: |
313 | if (!fsm->b_conn && fsm->transceiver->host->b_hnp_enable) | 313 | if (!fsm->b_conn && fsm->otg->host->b_hnp_enable) |
314 | otg_set_state(fsm, OTG_STATE_A_PERIPHERAL); | 314 | otg_set_state(fsm, OTG_STATE_A_PERIPHERAL); |
315 | else if (!fsm->b_conn && !fsm->transceiver->host->b_hnp_enable) | 315 | else if (!fsm->b_conn && !fsm->otg->host->b_hnp_enable) |
316 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); | 316 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); |
317 | else if (fsm->a_bus_req || fsm->b_bus_resume) | 317 | else if (fsm->a_bus_req || fsm->b_bus_resume) |
318 | otg_set_state(fsm, OTG_STATE_A_HOST); | 318 | otg_set_state(fsm, OTG_STATE_A_HOST); |
diff --git a/drivers/usb/otg/otg_fsm.h b/drivers/usb/otg/otg_fsm.h index 5e589ae9a199..c30a2e1d9e46 100644 --- a/drivers/usb/otg/otg_fsm.h +++ b/drivers/usb/otg/otg_fsm.h | |||
@@ -82,7 +82,7 @@ struct otg_fsm { | |||
82 | int loc_sof; | 82 | int loc_sof; |
83 | 83 | ||
84 | struct otg_fsm_ops *ops; | 84 | struct otg_fsm_ops *ops; |
85 | struct usb_phy *transceiver; | 85 | struct usb_otg *otg; |
86 | 86 | ||
87 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ | 87 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ |
88 | int protocol; | 88 | int protocol; |