diff options
| author | Antoine Tenart <antoine.tenart@free-electrons.com> | 2014-10-30 13:41:13 -0400 |
|---|---|---|
| committer | Felipe Balbi <balbi@ti.com> | 2014-11-03 11:01:25 -0500 |
| commit | e47d92545c2972bcf3711e7db80f481e402163c7 (patch) | |
| tree | a84db324fbd565aaa371bc0ef5677456541877e3 | |
| parent | a2655e4a8edb66d21b0967940172e83a51d30ef3 (diff) | |
usb: move the OTG state from the USB PHY to the OTG structure
Before using the PHY framework instead of the USB PHY one, we need to
move the OTG state into another place, since it won't be available when
USB PHY isn't used. This patch moves the OTG state into the OTG
structure, and makes all the needed modifications in the drivers
using the OTG state.
[ balbi@ti.com : fix build regressions with phy-tahvo.c, musb_dsps.c,
phy-isp1301-omap, and chipidea's debug.c ]
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
Acked-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
27 files changed, 312 insertions, 315 deletions
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 8c842980834a..9f4093590f4c 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c | |||
| @@ -80,11 +80,9 @@ static int omap_usb_start_srp(struct usb_otg *otg) | |||
| 80 | 80 | ||
| 81 | static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | 81 | static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host) |
| 82 | { | 82 | { |
| 83 | struct usb_phy *phy = otg->phy; | ||
| 84 | |||
| 85 | otg->host = host; | 83 | otg->host = host; |
| 86 | if (!host) | 84 | if (!host) |
| 87 | phy->state = OTG_STATE_UNDEFINED; | 85 | otg->state = OTG_STATE_UNDEFINED; |
| 88 | 86 | ||
| 89 | return 0; | 87 | return 0; |
| 90 | } | 88 | } |
| @@ -92,11 +90,9 @@ static int omap_usb_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
| 92 | static int omap_usb_set_peripheral(struct usb_otg *otg, | 90 | static int omap_usb_set_peripheral(struct usb_otg *otg, |
| 93 | struct usb_gadget *gadget) | 91 | struct usb_gadget *gadget) |
| 94 | { | 92 | { |
| 95 | struct usb_phy *phy = otg->phy; | ||
| 96 | |||
| 97 | otg->gadget = gadget; | 93 | otg->gadget = gadget; |
| 98 | if (!gadget) | 94 | if (!gadget) |
| 99 | phy->state = OTG_STATE_UNDEFINED; | 95 | otg->state = OTG_STATE_UNDEFINED; |
| 100 | 96 | ||
| 101 | return 0; | 97 | return 0; |
| 102 | } | 98 | } |
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 795d6538d630..f038804d13dd 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c | |||
| @@ -220,7 +220,7 @@ static int ci_otg_show(struct seq_file *s, void *unused) | |||
| 220 | 220 | ||
| 221 | /* ------ State ----- */ | 221 | /* ------ State ----- */ |
| 222 | seq_printf(s, "OTG state: %s\n\n", | 222 | seq_printf(s, "OTG state: %s\n\n", |
| 223 | usb_otg_state_string(ci->transceiver->state)); | 223 | usb_otg_state_string(ci->transceiver->otg->state)); |
| 224 | 224 | ||
| 225 | /* ------ State Machine Variables ----- */ | 225 | /* ------ State Machine Variables ----- */ |
| 226 | seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop); | 226 | seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop); |
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index caaabc58021e..8cb2508a6b71 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c | |||
| @@ -328,7 +328,7 @@ static void b_ssend_srp_tmout_func(void *ptr, unsigned long indicator) | |||
| 328 | set_tmout(ci, indicator); | 328 | set_tmout(ci, indicator); |
| 329 | 329 | ||
| 330 | /* only vbus fall below B_sess_vld in b_idle state */ | 330 | /* only vbus fall below B_sess_vld in b_idle state */ |
| 331 | if (ci->transceiver->state == OTG_STATE_B_IDLE) | 331 | if (ci->fsm.otg->state == OTG_STATE_B_IDLE) |
| 332 | ci_otg_queue_work(ci); | 332 | ci_otg_queue_work(ci); |
| 333 | } | 333 | } |
| 334 | 334 | ||
| @@ -582,11 +582,11 @@ int ci_otg_fsm_work(struct ci_hdrc *ci) | |||
| 582 | * when there is no gadget class driver | 582 | * when there is no gadget class driver |
| 583 | */ | 583 | */ |
| 584 | if (ci->fsm.id && !(ci->driver) && | 584 | if (ci->fsm.id && !(ci->driver) && |
| 585 | ci->transceiver->state < OTG_STATE_A_IDLE) | 585 | ci->fsm.otg->state < OTG_STATE_A_IDLE) |
| 586 | return 0; | 586 | return 0; |
| 587 | 587 | ||
| 588 | if (otg_statemachine(&ci->fsm)) { | 588 | if (otg_statemachine(&ci->fsm)) { |
| 589 | if (ci->transceiver->state == OTG_STATE_A_IDLE) { | 589 | if (ci->fsm.otg->state == OTG_STATE_A_IDLE) { |
| 590 | /* | 590 | /* |
| 591 | * Further state change for cases: | 591 | * Further state change for cases: |
| 592 | * a_idle to b_idle; or | 592 | * a_idle to b_idle; or |
| @@ -600,7 +600,7 @@ int ci_otg_fsm_work(struct ci_hdrc *ci) | |||
| 600 | ci_otg_queue_work(ci); | 600 | ci_otg_queue_work(ci); |
| 601 | if (ci->id_event) | 601 | if (ci->id_event) |
| 602 | ci->id_event = false; | 602 | ci->id_event = false; |
| 603 | } else if (ci->transceiver->state == OTG_STATE_B_IDLE) { | 603 | } else if (ci->fsm.otg->state == OTG_STATE_B_IDLE) { |
| 604 | if (ci->fsm.b_sess_vld) { | 604 | if (ci->fsm.b_sess_vld) { |
| 605 | ci->fsm.power_up = 0; | 605 | ci->fsm.power_up = 0; |
| 606 | /* | 606 | /* |
| @@ -627,7 +627,7 @@ static void ci_otg_fsm_event(struct ci_hdrc *ci) | |||
| 627 | otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV); | 627 | otg_bsess_vld = hw_read_otgsc(ci, OTGSC_BSV); |
| 628 | port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS); | 628 | port_conn = hw_read(ci, OP_PORTSC, PORTSC_CCS); |
| 629 | 629 | ||
| 630 | switch (ci->transceiver->state) { | 630 | switch (ci->fsm.otg->state) { |
| 631 | case OTG_STATE_A_WAIT_BCON: | 631 | case OTG_STATE_A_WAIT_BCON: |
| 632 | if (port_conn) { | 632 | if (port_conn) { |
| 633 | fsm->b_conn = 1; | 633 | fsm->b_conn = 1; |
| @@ -794,7 +794,7 @@ int ci_hdrc_otg_fsm_init(struct ci_hdrc *ci) | |||
| 794 | ci->transceiver->otg = ci->fsm.otg; | 794 | ci->transceiver->otg = ci->fsm.otg; |
| 795 | ci->fsm.power_up = 1; | 795 | ci->fsm.power_up = 1; |
| 796 | ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0; | 796 | ci->fsm.id = hw_read_otgsc(ci, OTGSC_ID) ? 1 : 0; |
| 797 | ci->transceiver->state = OTG_STATE_UNDEFINED; | 797 | ci->fsm.otg->state = OTG_STATE_UNDEFINED; |
| 798 | ci->fsm.ops = &ci_otg_ops; | 798 | ci->fsm.ops = &ci_otg_ops; |
| 799 | 799 | ||
| 800 | mutex_init(&ci->fsm.lock); | 800 | mutex_init(&ci->fsm.lock); |
diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c index 98e8340a5bb1..c6b35b77dab7 100644 --- a/drivers/usb/common/usb-otg-fsm.c +++ b/drivers/usb/common/usb-otg-fsm.c | |||
| @@ -124,10 +124,10 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) | |||
| 124 | static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | 124 | static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) |
| 125 | { | 125 | { |
| 126 | state_changed = 1; | 126 | state_changed = 1; |
| 127 | if (fsm->otg->phy->state == new_state) | 127 | if (fsm->otg->state == new_state) |
| 128 | return 0; | 128 | return 0; |
| 129 | VDBG("Set state: %s\n", usb_otg_state_string(new_state)); | 129 | VDBG("Set state: %s\n", usb_otg_state_string(new_state)); |
| 130 | otg_leave_state(fsm, fsm->otg->phy->state); | 130 | otg_leave_state(fsm, fsm->otg->state); |
| 131 | switch (new_state) { | 131 | switch (new_state) { |
| 132 | case OTG_STATE_B_IDLE: | 132 | case OTG_STATE_B_IDLE: |
| 133 | otg_drv_vbus(fsm, 0); | 133 | otg_drv_vbus(fsm, 0); |
| @@ -236,7 +236,7 @@ static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | |||
| 236 | break; | 236 | break; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | fsm->otg->phy->state = new_state; | 239 | fsm->otg->state = new_state; |
| 240 | return 0; | 240 | return 0; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| @@ -247,7 +247,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
| 247 | 247 | ||
| 248 | mutex_lock(&fsm->lock); | 248 | mutex_lock(&fsm->lock); |
| 249 | |||
