aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/phy
diff options
context:
space:
mode:
authorAntoine Tenart <antoine.tenart@free-electrons.com>2014-10-30 13:41:13 -0400
committerFelipe Balbi <balbi@ti.com>2014-11-03 11:01:25 -0500
commite47d92545c2972bcf3711e7db80f481e402163c7 (patch)
treea84db324fbd565aaa371bc0ef5677456541877e3 /drivers/usb/phy
parenta2655e4a8edb66d21b0967940172e83a51d30ef3 (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>
Diffstat (limited to 'drivers/usb/phy')
-rw-r--r--drivers/usb/phy/phy-ab8500-usb.c10
-rw-r--r--drivers/usb/phy/phy-fsl-usb.c10
-rw-r--r--drivers/usb/phy/phy-generic.c4
-rw-r--r--drivers/usb/phy/phy-gpio-vbus-usb.c10
-rw-r--r--drivers/usb/phy/phy-isp1301-omap.c94
-rw-r--r--drivers/usb/phy/phy-msm-usb.c34
-rw-r--r--drivers/usb/phy/phy-mv-usb.c46
-rw-r--r--drivers/usb/phy/phy-tahvo.c24
8 files changed, 116 insertions, 116 deletions
diff --git a/drivers/usb/phy/phy-ab8500-usb.c b/drivers/usb/phy/phy-ab8500-usb.c
index 11ab2c45e462..2d5250143ce1 100644
--- a/drivers/usb/phy/phy-ab8500-usb.c
+++ b/drivers/usb/phy/phy-ab8500-usb.c
@@ -446,7 +446,7 @@ static int ab9540_usb_link_status_update(struct ab8500_usb *ab,
446 if (event != UX500_MUSB_RIDB) 446 if (event != UX500_MUSB_RIDB)
447 event = UX500_MUSB_NONE; 447 event = UX500_MUSB_NONE;
448 /* Fallback to default B_IDLE as nothing is connected. */ 448 /* Fallback to default B_IDLE as nothing is connected. */
449 ab->phy.state = OTG_STATE_B_IDLE; 449 ab->phy.otg->state = OTG_STATE_B_IDLE;
450 break; 450 break;
451 451
452 case USB_LINK_ACA_RID_C_NM_9540: 452 case USB_LINK_ACA_RID_C_NM_9540:
@@ -584,7 +584,7 @@ static int ab8540_usb_link_status_update(struct ab8500_usb *ab,
584 * Fallback to default B_IDLE as nothing 584 * Fallback to default B_IDLE as nothing
585 * is connected 585 * is connected
586 */ 586 */
587 ab->phy.state = OTG_STATE_B_IDLE; 587 ab->phy.otg->state = OTG_STATE_B_IDLE;
588 break; 588 break;
589 589
590 case USB_LINK_ACA_RID_C_NM_8540: 590 case USB_LINK_ACA_RID_C_NM_8540:
@@ -693,7 +693,7 @@ static int ab8505_usb_link_status_update(struct ab8500_usb *ab,
693 * Fallback to default B_IDLE as nothing 693 * Fallback to default B_IDLE as nothing
694 * is connected 694 * is connected
695 */ 695 */
696 ab->phy.state = OTG_STATE_B_IDLE; 696 ab->phy.otg->state = OTG_STATE_B_IDLE;
697 break; 697 break;
698 698
699 case USB_LINK_ACA_RID_C_NM_8505: 699 case USB_LINK_ACA_RID_C_NM_8505:
@@ -776,7 +776,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab,
776 if (event != UX500_MUSB_RIDB) 776 if (event != UX500_MUSB_RIDB)
777 event = UX500_MUSB_NONE; 777 event = UX500_MUSB_NONE;
778 /* Fallback to default B_IDLE as nothing is connected */ 778 /* Fallback to default B_IDLE as nothing is connected */
779 ab->phy.state = OTG_STATE_B_IDLE; 779 ab->phy.otg->state = OTG_STATE_B_IDLE;
780 break; 780 break;
781 781
782 case USB_LINK_ACA_RID_C_NM_8500: 782 case USB_LINK_ACA_RID_C_NM_8500:
@@ -1380,7 +1380,7 @@ static int ab8500_usb_probe(struct platform_device *pdev)
1380 ab->phy.label = "ab8500"; 1380 ab->phy.label = "ab8500";
1381 ab->phy.set_suspend = ab8500_usb_set_suspend; 1381 ab->phy.set_suspend = ab8500_usb_set_suspend;
1382 ab->phy.set_power = ab8500_usb_set_power; 1382 ab->phy.set_power = ab8500_usb_set_power;
1383 ab->phy.state = OTG_STATE_UNDEFINED; 1383 ab->phy.otg->state = OTG_STATE_UNDEFINED;
1384 1384
1385 otg->phy = &ab->phy; 1385 otg->phy = &ab->phy;
1386 otg->set_host = ab8500_usb_set_host; 1386 otg->set_host = ab8500_usb_set_host;
diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
index f1ea5990a50a..15d7a81eece5 100644
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -623,7 +623,7 @@ static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
623 /* Mini-A cable connected */ 623 /* Mini-A cable connected */
624 struct otg_fsm *fsm = &otg_dev->fsm; 624 struct otg_fsm *fsm = &otg_dev->fsm;
625 625
626 otg->phy->state = OTG_STATE_UNDEFINED; 626 otg.state = OTG_STATE_UNDEFINED;
627 fsm->protocol = PROTO_UNDEF; 627 fsm->protocol = PROTO_UNDEF;
628 } 628 }
629 } 629 }
@@ -681,7 +681,7 @@ static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA)
681{ 681{
682 if (!fsl_otg_dev) 682 if (!fsl_otg_dev)
683 return -ENODEV; 683 return -ENODEV;
684 if (phy->state == OTG_STATE_B_PERIPHERAL) 684 if (phy->otg.state == OTG_STATE_B_PERIPHERAL)
685 pr_info("FSL OTG: Draw %d mA\n", mA); 685 pr_info("FSL OTG: Draw %d mA\n", mA);
686 686
687 return 0; 687 return 0;
@@ -714,7 +714,7 @@ static int fsl_otg_start_srp(struct usb_otg *otg)
714{ 714{
715 struct fsl_otg *otg_dev; 715 struct fsl_otg *otg_dev;
716 716
717 if (!otg || otg->phy->state != OTG_STATE_B_IDLE) 717 if (!otg || otg.state != OTG_STATE_B_IDLE)
718 return -ENODEV; 718 return -ENODEV;
719 719
720 otg_dev = container_of(otg->phy, struct fsl_otg, phy); 720 otg_dev = container_of(otg->phy, struct fsl_otg, phy);
@@ -989,10 +989,10 @@ int usb_otg_start(struct platform_device *pdev)
989 * Also: record initial state of ID pin 989 * Also: record initial state of ID pin
990 */ 990 */
991 if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { 991 if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) {
992 p_otg->phy.state = OTG_STATE_UNDEFINED; 992 p_otg->phy->otg.state = OTG_STATE_UNDEFINED;
993 p_otg->fsm.id = 1; 993 p_otg->fsm.id = 1;
994 } else { 994 } else {
995 p_otg->phy.state = OTG_STATE_A_IDLE; 995 p_otg->phy->otg.state = OTG_STATE_A_IDLE;
996 p_otg->fsm.id = 0; 996 p_otg->fsm.id = 0;
997 } 997 }
998 998
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 7594e5069ae5..280a3458ff6b 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -123,7 +123,7 @@ static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
123 } 123 }
124 124
125 otg->gadget = gadget; 125 otg->gadget = gadget;
126 otg->phy->state = OTG_STATE_B_IDLE; 126 otg->state = OTG_STATE_B_IDLE;
127 return 0; 127 return 0;
128} 128}
129 129
@@ -225,9 +225,9 @@ int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_generic *nop,
225 nop->phy.dev = nop->dev; 225 nop->phy.dev = nop->dev;
226 nop->phy.label = "nop-xceiv"; 226 nop->phy.label = "nop-xceiv";
227 nop->phy.set_suspend = nop_set_suspend; 227 nop->phy.set_suspend = nop_set_suspend;
228 nop->phy.state = OTG_STATE_UNDEFINED;
229 nop->phy.type = type; 228 nop->phy.type = type;
230 229
230 nop->phy.otg->state = OTG_STATE_UNDEFINED;
231 nop->phy.otg->phy = &nop->phy; 231 nop->phy.otg->phy = &nop->phy;
232 nop->phy.otg->set_host = nop_set_host; 232 nop->phy.otg->set_host = nop_set_host;
233 nop->phy.otg->set_peripheral = nop_set_peripheral; 233 nop->phy.otg->set_peripheral = nop_set_peripheral;
diff --git a/drivers/usb/phy/phy-gpio-vbus-usb.c b/drivers/usb/phy/phy-gpio-vbus-usb.c
index f4b14bd97e14..7a6be3e5dc23 100644
--- a/drivers/usb/phy/phy-gpio-vbus-usb.c
+++ b/drivers/usb/phy/phy-gpio-vbus-usb.c
@@ -121,7 +121,7 @@ static void gpio_vbus_work(struct work_struct *work)
121 121
122 if (vbus) { 122 if (vbus) {
123 status = USB_EVENT_VBUS; 123 status = USB_EVENT_VBUS;
124 gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; 124 gpio_vbus->phy.otg->state = OTG_STATE_B_PERIPHERAL;
125 gpio_vbus->phy.last_event = status; 125 gpio_vbus->phy.last_event = status;
126 usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); 126 usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget);
127 127
@@ -143,7 +143,7 @@ static void gpio_vbus_work(struct work_struct *work)
143 143
144 usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); 144 usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget);
145 status = USB_EVENT_NONE; 145 status = USB_EVENT_NONE;
146 gpio_vbus->phy.state = OTG_STATE_B_IDLE; 146 gpio_vbus->phy.otg->state = OTG_STATE_B_IDLE;
147 gpio_vbus->phy.last_event = status; 147 gpio_vbus->phy.last_event = status;
148 148
149 atomic_notifier_call_chain(&gpio_vbus->phy.notifier, 149 atomic_notifier_call_chain(&gpio_vbus->phy.notifier,
@@ -196,7 +196,7 @@ static int gpio_vbus_set_peripheral(struct usb_otg *otg,
196 set_vbus_draw(gpio_vbus, 0); 196 set_vbus_draw(gpio_vbus, 0);
197 197
198 usb_gadget_vbus_disconnect(otg->gadget); 198 usb_gadget_vbus_disconnect(otg->gadget);
199 otg->phy->state = OTG_STATE_UNDEFINED; 199 otg->state = OTG_STATE_UNDEFINED;
200 200
201 otg->gadget = NULL; 201 otg->gadget = NULL;
202 return 0; 202 return 0;
@@ -218,7 +218,7 @@ static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA)
218 218
219 gpio_vbus = container_of(phy, struct gpio_vbus_data, phy); 219 gpio_vbus = container_of(phy, struct gpio_vbus_data, phy);
220 220
221 if (phy->state == OTG_STATE_B_PERIPHERAL) 221 if (phy->otg->state == OTG_STATE_B_PERIPHERAL)
222 set_vbus_draw(gpio_vbus, mA); 222 set_vbus_draw(gpio_vbus, mA);
223 return 0; 223 return 0;
224} 224}
@@ -269,8 +269,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
269 gpio_vbus->phy.dev = gpio_vbus->dev; 269 gpio_vbus->phy.dev = gpio_vbus->dev;
270 gpio_vbus->phy.set_power = gpio_vbus_set_power; 270 gpio_vbus->phy.set_power = gpio_vbus_set_power;
271 gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend; 271 gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend;
272 gpio_vbus->phy.state = OTG_STATE_UNDEFINED;
273 272
273 gpio_vbus->phy.otg->state = OTG_STATE_UNDEFINED;
274 gpio_vbus->phy.otg->phy = &gpio_vbus->phy; 274 gpio_vbus->phy.otg->phy = &gpio_vbus->phy;
275 gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral; 275 gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral;
276 276
diff --git a/drivers/usb/phy/phy-isp1301-omap.c b/drivers/usb/phy/phy-isp1301-omap.c
index 8eea56d3ded6..24f84cbbed57 100644
--- a/drivers/usb/phy/phy-isp1301-omap.c
+++ b/drivers/usb/phy/phy-isp1301-omap.c
@@ -234,7 +234,7 @@ isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits)
234 234
235static inline const char *state_name(struct isp1301 *isp) 235static inline const char *state_name(struct isp1301 *isp)
236{ 236{
237 return usb_otg_state_string(isp->phy.state); 237 return usb_otg_state_string(isp->phy.otg->state);
238} 238}
239 239
240/*-------------------------------------------------------------------------*/ 240/*-------------------------------------------------------------------------*/
@@ -249,7 +249,7 @@ static inline const char *state_name(struct isp1301 *isp)
249 249
250static void power_down(struct isp1301 *isp) 250static void power_down(struct isp1301 *isp)
251{ 251{
252 isp->phy.state = OTG_STATE_UNDEFINED; 252 isp->phy.otg->state = OTG_STATE_UNDEFINED;
253 253
254 // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN); 254 // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN);
255 isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND); 255 isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND);
@@ -339,7 +339,7 @@ static void a_idle(struct isp1301 *isp, const char *tag)
339{ 339{
340 u32 l; 340 u32 l;
341 341
342 if (isp->phy.state == OTG_STATE_A_IDLE) 342 if (isp->phy.otg->state == OTG_STATE_A_IDLE)
343 return; 343 return;
344 344
345 isp->phy.otg->default_a = 1; 345 isp->phy.otg->default_a = 1;
@@ -351,7 +351,7 @@ static void a_idle(struct isp1301 *isp, const char *tag)
351 isp->phy.otg->gadget->is_a_peripheral = 1; 351 isp->phy.otg->gadget->is_a_peripheral = 1;
352 gadget_suspend(isp); 352 gadget_suspend(isp);
353 } 353 }
354 isp->phy.state = OTG_STATE_A_IDLE; 354 isp->phy.otg->state = OTG_STATE_A_IDLE;
355 l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; 355 l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS;
356 omap_writel(l, OTG_CTRL); 356 omap_writel(l, OTG_CTRL);
357 isp->last_otg_ctrl = l; 357 isp->last_otg_ctrl = l;
@@ -363,7 +363,7 @@ static void b_idle(struct isp1301 *isp, const char *tag)
363{ 363{
364 u32 l; 364 u32 l;
365 365
366 if (isp->phy.state == OTG_STATE_B_IDLE) 366 if (isp->phy.otg->state == OTG_STATE_B_IDLE)
367 return; 367 return;
368 368
369 isp->phy.otg->default_a = 0; 369 isp->phy.otg->default_a = 0;
@@ -375,7 +375,7 @@ static void b_idle(struct isp1301 *isp, const char *tag)
375 isp->phy.otg->gadget->is_a_peripheral = 0; 375 isp->phy.otg->gadget->is_a_peripheral = 0;
376 gadget_suspend(isp); 376 gadget_suspend(isp);
377 } 377 }
378 isp->phy.state = OTG_STATE_B_IDLE; 378 isp->phy.otg->state = OTG_STATE_B_IDLE;
379 l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; 379 l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS;
380 omap_writel(l, OTG_CTRL); 380 omap_writel(l, OTG_CTRL);
381 isp->last_otg_ctrl = l; 381 isp->last_otg_ctrl = l;
@@ -474,7 +474,7 @@ static void check_state(struct isp1301 *isp, const char *tag)
474 default: 474 default:
475 break; 475 break;
476 } 476 }
477 if (isp->phy.state == state && !extra) 477 if (isp->phy.otg->state == state && !extra)
478 return; 478 return;
479 pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, 479 pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag,
480 usb_otg_state_string(state), fsm, state_name(isp), 480 usb_otg_state_string(state), fsm, state_name(isp),
@@ -498,23 +498,23 @@ static void update_otg1(struct isp1301 *isp, u8 int_src)
498 498
499 if (int_src & INTR_SESS_VLD) 499 if (int_src & INTR_SESS_VLD)
500 otg_ctrl |= OTG_ASESSVLD; 500 otg_ctrl |= OTG_ASESSVLD;
501 else if (isp->phy.state == OTG_STATE_A_WAIT_VFALL) { 501 else if (isp->phy.otg->state == OTG_STATE_A_WAIT_VFALL) {
502 a_idle(isp, "vfall"); 502 a_idle(isp, "vfall");
503 otg_ctrl &= ~OTG_CTRL_BITS; 503 otg_ctrl &= ~OTG_CTRL_BITS;
504 } 504 }
505 if (int_src & INTR_VBUS_VLD) 505 if (int_src & INTR_VBUS_VLD)
506 otg_ctrl |= OTG_VBUSVLD; 506 otg_ctrl |= OTG_VBUSVLD;
507 if (int_src & INTR_ID_GND) { /* default-A */ 507 if (int_src & INTR_ID_GND) { /* default-A */
508 if (isp->phy.state == OTG_STATE_B_IDLE 508 if (isp->phy.otg->state == OTG_STATE_B_IDLE
509 || isp->phy.state 509 || isp->phy.otg->state
510 == OTG_STATE_UNDEFINED) { 510 == OTG_STATE_UNDEFINED) {
511 a_idle(isp, "init"); 511 a_idle(isp, "init");
512 return; 512 return;
513 } 513 }
514 } else { /* default-B */ 514 } else { /* default-B */
515 otg_ctrl |= OTG_ID; 515 otg_ctrl |= OTG_ID;
516 if (isp->phy.state == OTG_STATE_A_IDLE 516 if (isp->phy.otg->state == OTG_STATE_A_IDLE
517 || isp->phy.state == OTG_STATE_UNDEFINED) { 517 || isp->phy.otg->state == OTG_STATE_UNDEFINED) {
518 b_idle(isp, "init"); 518 b_idle(isp, "init");
519 return; 519 return;
520 } 520 }
@@ -548,14 +548,14 @@ static void otg_update_isp(struct isp1301 *isp)
548 isp->last_otg_ctrl = otg_ctrl; 548 isp->last_otg_ctrl = otg_ctrl;
549 otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS; 549 otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS;
550 550
551 switch (isp->phy.state) { 551 switch (isp->phy.otg->state) {
552 case OTG_STATE_B_IDLE: 552 case OTG_STATE_B_IDLE:
553 case OTG_STATE_B_PERIPHERAL: 553 case OTG_STATE_B_PERIPHERAL:
554 case OTG_STATE_B_SRP_INIT: 554 case OTG_STATE_B_SRP_INIT:
555 if (!(otg_ctrl & OTG_PULLUP)) { 555 if (!(otg_ctrl & OTG_PULLUP)) {
556 // if (otg_ctrl & OTG_B_HNPEN) { 556 // if (otg_ctrl & OTG_B_HNPEN) {
557 if (isp->phy.otg->gadget->b_hnp_enable) { 557 if (isp->phy.otg->gadget->b_hnp_enable) {
558 isp->phy.state = OTG_STATE_B_WAIT_ACON; 558 isp->phy.otg->state = OTG_STATE_B_WAIT_ACON;
559 pr_debug(" --> b_wait_acon\n"); 559 pr_debug(" --> b_wait_acon\n");
560 } 560 }
561 goto pulldown; 561 goto pulldown;
@@ -585,7 +585,7 @@ pulldown:
585 if (!(isp->phy.otg->host)) 585 if (!(isp->phy.otg->host))
586 otg_ctrl &= ~OTG_DRV_VBUS; 586 otg_ctrl &= ~OTG_DRV_VBUS;
587 587
588 switch (isp->phy.state) { 588 switch (isp->phy.otg->state) {
589 case OTG_STATE_A_SUSPEND: 589 case OTG_STATE_A_SUSPEND:
590 if (otg_ctrl & OTG_DRV_VBUS) { 590 if (otg_ctrl & OTG_DRV_VBUS) {
591 set |= OTG1_VBUS_DRV; 591 set |= OTG1_VBUS_DRV;
@@ -596,7 +596,7 @@ pulldown:
596 596
597 /* FALLTHROUGH */ 597 /* FALLTHROUGH */
598 case OTG_STATE_A_VBUS_ERR: 598 case OTG_STATE_A_VBUS_ERR:
599 isp->phy.state = OTG_STATE_A_WAIT_VFALL; 599 isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
600 pr_debug(" --> a_wait_vfall\n"); 600 pr_debug(" --> a_wait_vfall\n");
601 /* FALLTHROUGH */ 601 /* FALLTHROUGH */
602 case OTG_STATE_A_WAIT_VFALL: 602 case OTG_STATE_A_WAIT_VFALL:
@@ -605,7 +605,7 @@ pulldown:
605 break; 605 break;
606 case OTG_STATE_A_IDLE: 606 case OTG_STATE_A_IDLE:
607 if (otg_ctrl & OTG_DRV_VBUS) { 607 if (otg_ctrl & OTG_DRV_VBUS) {
608 isp->phy.state = OTG_STATE_A_WAIT_VRISE; 608 isp->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
609 pr_debug(" --> a_wait_vrise\n"); 609 pr_debug(" --> a_wait_vrise\n");
610 } 610 }
611 /* FALLTHROUGH */ 611 /* FALLTHROUGH */
@@ -625,17 +625,17 @@ pulldown:
625 if (otg_change & OTG_PULLUP) { 625 if (otg_change & OTG_PULLUP) {
626 u32 l; 626 u32 l;
627 627
628 switch (isp->phy.state) { 628 switch (isp->phy.otg->state) {
629 case OTG_STATE_B_IDLE: 629 case OTG_STATE_B_IDLE:
630 if (clr & OTG1_DP_PULLUP) 630 if (clr & OTG1_DP_PULLUP)
631 break; 631 break;
632 isp->phy.state = OTG_STATE_B_PERIPHERAL; 632 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
633 pr_debug(" --> b_peripheral\n"); 633 pr_debug(" --> b_peripheral\n");
634 break; 634 break;
635 case OTG_STATE_A_SUSPEND: 635 case OTG_STATE_A_SUSPEND:
636 if (clr & OTG1_DP_PULLUP) 636 if (clr & OTG1_DP_PULLUP)
637 break; 637 break;
638 isp->phy.state = OTG_STATE_A_PERIPHERAL; 638 isp->phy.otg->state = OTG_STATE_A_PERIPHERAL;
639 pr_debug(" --> a_peripheral\n"); 639 pr_debug(" --> a_peripheral\n");
640 break; 640 break;
641 default: 641 default:
@@ -673,7 +673,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
673 * remote wakeup (SRP, normal) using their own timer 673 * remote wakeup (SRP, normal) using their own timer
674 * to give "check cable and A-device" messages. 674 * to give "check cable and A-device" messages.
675 */ 675 */
676 if (isp->phy.state == OTG_STATE_B_SRP_INIT) 676 if (isp->phy.otg->state == OTG_STATE_B_SRP_INIT)
677 b_idle(isp, "srp_timeout"); 677 b_idle(isp, "srp_timeout");
678 678
679 omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); 679 omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC);
@@ -691,7 +691,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
691 omap_writel(otg_ctrl, OTG_CTRL); 691 omap_writel(otg_ctrl, OTG_CTRL);
692 692
693 /* subset of b_peripheral()... */ 693 /* subset of b_peripheral()... */
694 isp->phy.state = OTG_STATE_B_PERIPHERAL; 694 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
695 pr_debug(" --> b_peripheral\n"); 695 pr_debug(" --> b_peripheral\n");
696 696
697 omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); 697 omap_writew(B_HNP_FAIL, OTG_IRQ_SRC);
@@ -703,7 +703,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
703 state_name(isp), omap_readl(OTG_CTRL)); 703 state_name(isp), omap_readl(OTG_CTRL));
704 704
705 isp1301_defer_work(isp, WORK_UPDATE_OTG); 705 isp1301_defer_work(isp, WORK_UPDATE_OTG);
706 switch (isp->phy.state) { 706 switch (isp->phy.otg->state) {
707 case OTG_STATE_A_IDLE: 707 case OTG_STATE_A_IDLE:
708 if (!otg->host) 708 if (!otg->host)
709 break; 709 break;
@@ -734,7 +734,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
734 otg_ctrl |= OTG_BUSDROP; 734 otg_ctrl |= OTG_BUSDROP;
735 otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; 735 otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS;
736 omap_writel(otg_ctrl, OTG_CTRL); 736 omap_writel(otg_ctrl, OTG_CTRL);
737 isp->phy.state = OTG_STATE_A_WAIT_VFALL; 737 isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
738 738
739 omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); 739 omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC);
740 ret = IRQ_HANDLED; 740 ret = IRQ_HANDLED;
@@ -748,7 +748,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
748 otg_ctrl |= OTG_BUSDROP; 748 otg_ctrl |= OTG_BUSDROP;
749 otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; 749 otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS;
750 omap_writel(otg_ctrl, OTG_CTRL); 750 omap_writel(otg_ctrl, OTG_CTRL);
751 isp->phy.state = OTG_STATE_A_VBUS_ERR; 751 isp->phy.otg->state = OTG_STATE_A_VBUS_ERR;
752 752
753 omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); 753 omap_writew(A_VBUS_ERR, OTG_IRQ_SRC);
754 ret = IRQ_HANDLED; 754 ret = IRQ_HANDLED;
@@ -769,7 +769,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
769 769
770 /* role is peripheral */ 770 /* role is peripheral */
771 if (otg_ctrl & OTG_DRIVER_SEL) { 771 if (otg_ctrl & OTG_DRIVER_SEL) {
772 switch (isp->phy.state) { 772 switch (isp->phy.otg->state) {
773 case OTG_STATE_A_IDLE: 773 case OTG_STATE_A_IDLE:
774 b_idle(isp, __func__); 774 b_idle(isp, __func__);
775 break; 775 break;
@@ -786,18 +786,18 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp)
786 } 786 }
787 787
788 if (otg->host) { 788 if (otg->host) {
789 switch (isp->phy.state) { 789 switch (isp->phy.otg->state) {
790 case OTG_STATE_B_WAIT_ACON: 790 case OTG_STATE_B_WAIT_ACON:
791 isp->phy.state = OTG_STATE_B_HOST; 791 isp->phy.otg->state = OTG_STATE_B_HOST;
792 pr_debug(" --> b_host\n"); 792 pr_debug(" --> b_host\n");
793 kick = 1; 793 kick = 1;
794 break; 794 break;
795 case OTG_STATE_A_WAIT_BCON: 795 case OTG_STATE_A_WAIT_BCON:
796 isp->phy.state = OTG_STATE_A_HOST; 796 isp->phy.otg->state = OTG_STATE_A_HOST;
797 pr_debug(" --> a_host\n"); 797 pr_debug(" --> a_host\n");
798 break; 798 break;
799 case OTG_STATE_A_PERIPHERAL: 799 case OTG_STATE_A_PERIPHERAL:
800 isp->phy.state = OTG_STATE_A_WAIT_BCON; 800 isp->phy.otg->state = OTG_STATE_A_WAIT_BCON;
801 pr_debug(" --> a_wait_bcon\n"); 801 pr_debug(" --> a_wait_bcon\n");
802 break; 802 break;
803 default: 803 default:
@@ -937,7 +937,7 @@ static void b_peripheral(struct isp1301 *isp)
937 /* UDC driver just set OTG_BSESSVLD */ 937 /* UDC driver just set OTG_BSESSVLD */
938 isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP); 938 isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP);
939 isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN); 939 isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN);
940 isp->phy.state = OTG_STATE_B_PERIPHERAL; 940 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
941 pr_debug(" --> b_peripheral\n"); 941 pr_debug(" --> b_peripheral\n");
942 dump_regs(isp, "2periph"); 942 dump_regs(isp, "2periph");
943#endif 943#endif
@@ -947,7 +947,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
947{ 947{
948 struct usb_otg *otg = isp->phy.otg; 948 struct usb_otg *otg = isp->phy.otg;
949 u8 isp_stat, isp_bstat; 949 u8 isp_stat, isp_bstat;
950 enum usb_otg_state state = isp->phy.state; 950 enum usb_otg_state state = isp->phy.otg->state;
951 951
952 if (stat & INTR_BDIS_ACON) 952 if (stat & INTR_BDIS_ACON)
953 pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); 953 pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp));
@@ -970,7 +970,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
970 * when HNP is used. 970 * when HNP is used.
971 */ 971 */
972 if (isp_stat & INTR_VBUS_VLD) 972 if (isp_stat & INTR_VBUS_VLD)
973 isp->phy.state = OTG_STATE_A_HOST; 973 isp->phy.otg->state = OTG_STATE_A_HOST;
974 break; 974 break;
975 case OTG_STATE_A_WAIT_VFALL: 975 case OTG_STATE_A_WAIT_VFALL:
976 if (!(isp_stat & INTR_SESS_VLD)) 976 if (!(isp_stat & INTR_SESS_VLD))
@@ -978,7 +978,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
978 break; 978 break;
979 default: 979 default:
980 if (!(isp_stat & INTR_VBUS_VLD)) 980 if (!(isp_stat & INTR_VBUS_VLD))
981 isp->phy.state = OTG_STATE_A_VBUS_ERR; 981 isp->phy.otg->state = OTG_STATE_A_VBUS_ERR;
982 break; 982 break;
983 } 983 }
984 isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); 984 isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS);
@@ -1007,7 +1007,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
1007 if (otg->default_a) { 1007 if (otg->default_a) {
1008 switch (state) { 1008 switch (state) {
1009 default: 1009 default:
1010 isp->phy.state = OTG_STATE_A_WAIT_VFALL; 1010 isp->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
1011 break; 1011 break;
1012 case OTG_STATE_A_WAIT_VFALL: 1012 case OTG_STATE_A_WAIT_VFALL:
1013 state = OTG_STATE_A_IDLE; 1013 state = OTG_STATE_A_IDLE;
@@ -1020,7 +1020,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
1020 host_suspend(isp); 1020 host_suspend(isp);
1021 isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1, 1021 isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1,
1022 MC1_BDIS_ACON_EN); 1022 MC1_BDIS_ACON_EN);
1023 isp->phy.state = OTG_STATE_B_IDLE; 1023 isp->phy.otg->state = OTG_STATE_B_IDLE;
1024 l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; 1024 l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK;
1025 l &= ~OTG_CTRL_BITS; 1025 l &= ~OTG_CTRL_BITS;
1026 omap_writel(l, OTG_CTRL); 1026 omap_writel(l, OTG_CTRL);
@@ -1031,7 +1031,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
1031 } 1031 }
1032 isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); 1032 isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS);
1033 1033
1034 switch (isp->phy.state) { 1034 switch (isp->phy.otg->state) {
1035 case OTG_STATE_B_PERIPHERAL: 1035 case OTG_STATE_B_PERIPHERAL:
1036 case OTG_STATE_B_WAIT_ACON: 1036 case OTG_STATE_B_WAIT_ACON:
1037 case OTG_STATE_B_HOST: 1037 case OTG_STATE_B_HOST:
@@ -1071,7 +1071,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat)
1071 } 1071 }
1072 } 1072 }
1073 1073
1074 if (state != isp->phy.state) 1074 if (state != isp->phy.otg->state)
1075 pr_debug(" isp, %s -> %s\n", 1075 pr_debug(" isp, %s -> %s\n",
1076 usb_otg_state_string(state), state_name(isp)); 1076 usb_otg_state_string(state), state_name(isp));
1077 1077
@@ -1129,10 +1129,10 @@ isp1301_work(struct work_struct *work)
1129 * skip A_WAIT_VRISE; hc transitions invisibly 1129 * skip A_WAIT_VRISE; hc transitions invisibly
1130 * skip A_WAIT_BCON; same. 1130 * skip A_WAIT_BCON; same.
1131 */ 1131 */
1132 switch (isp->phy.state) { 1132 switch (isp->phy.otg->state) {
1133 case OTG_STATE_A_WAIT_BCON: 1133 case OTG_STATE_A_WAIT_BCON:
1134 case OTG_STATE_A_WAIT_VRISE: 1134 case OTG_STATE_A_WAIT_VRISE:
1135 isp->phy.state = OTG_STATE_A_HOST; 1135 isp->phy.otg->state = OTG_STATE_A_HOST;
1136 pr_debug(" --> a_host\n"); 1136 pr_debug(" --> a_host\n");
1137 otg_ctrl = omap_readl(OTG_CTRL); 1137 otg_ctrl = omap_readl(OTG_CTRL);
1138 otg_ctrl |= OTG_A_BUSREQ; 1138 otg_ctrl |= OTG_A_BUSREQ;
@@ -1141,7 +1141,7 @@ isp1301_work(struct work_struct *work)
1141 omap_writel(otg_ctrl, OTG_CTRL); 1141 omap_writel(otg_ctrl, OTG_CTRL);
1142 break; 1142 break;
1143 case OTG_STATE_B_WAIT_ACON: 1143 case OTG_STATE_B_WAIT_ACON:
1144 isp->phy.state = OTG_STATE_B_HOST; 1144 isp->phy.otg->state = OTG_STATE_B_HOST;
1145 pr_debug(" --> b_host (acon)\n"); 1145 pr_debug(" --> b_host (acon)\n");
1146 break; 1146 break;
1147 case OTG_STATE_B_HOST: 1147 case OTG_STATE_B_HOST:
@@ -1368,7 +1368,7 @@ isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget)
1368 } 1368 }
1369 1369
1370 power_up(isp); 1370 power_up(isp);
1371 isp->phy.state = OTG_STATE_B_IDLE; 1371 isp->phy.otg->state = OTG_STATE_B_IDLE;
1372 1372
1373 if (machine_is_omap_h2() || machine_is_omap_h3()) 1373 if (machine_is_omap_h2() || machine_is_omap_h3())
1374 isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); 1374 isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0);
@@ -1403,7 +1403,7 @@ isp1301_set_power(struct usb_phy *dev, unsigned mA)
1403{ 1403{
1404 if (!the_transceiver) 1404 if (!the_transceiver)
1405 return -ENODEV; 1405 return -ENODEV;
1406 if (dev->state == OTG_STATE_B_PERIPHERAL) 1406 if (dev->otg->state == OTG_STATE_B_PERIPHERAL)
1407 enable_vbus_draw(the_transceiver, mA); 1407 enable_vbus_draw(the_transceiver, mA);
1408 return 0; 1408 return 0;
1409} 1409}
@@ -1414,7 +1414,7 @@ isp1301_start_srp(struct usb_otg *otg)
1414 struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); 1414 struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy);
1415 u32 otg_ctrl; 1415 u32 otg_ctrl;
1416 1416
1417 if (isp != the_transceiver || isp->phy.state != OTG_STATE_B_IDLE) 1417 if (isp != the_transceiver || isp->phy.otg->state != OTG_STATE_B_IDLE)
1418 return -ENODEV; 1418 return -ENODEV;
1419 1419
1420 otg_ctrl = omap_readl(OTG_CTRL); 1420 otg_ctrl = omap_readl(OTG_CTRL);
@@ -1424,7 +1424,7 @@ isp1301_start_srp(struct usb_otg *otg)
1424 otg_ctrl |= OTG_B_BUSREQ; 1424 otg_ctrl |= OTG_B_BUSREQ;
1425 otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK; 1425 otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK;
1426 omap_writel(otg_ctrl, OTG_CTRL); 1426 omap_writel(otg_ctrl, OTG_CTRL);
1427 isp->phy.state = OTG_STATE_B_SRP_INIT; 1427 isp->phy.otg->state = OTG_STATE_B_SRP_INIT;
1428 1428
1429 pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), 1429 pr_debug("otg: SRP, %s ... %06x\n", state_name(isp),
1430 omap_readl(OTG_CTRL)); 1430 omap_readl(OTG_CTRL));
@@ -1452,9 +1452,9 @@ isp1301_start_hnp(struct usb_otg *otg)
1452 /* We want hardware to manage most HNP protocol timings. 1452 /* We want hardware to manage most HNP protocol timings.
1453 * So do this part as early as possible... 1453 * So do this part as early as possible...
1454 */ 1454 */
1455 switch (isp->phy.state) { 1455 switch (isp->phy.otg->state) {
1456 case OTG_STATE_B_HOST: 1456 case OTG_STATE_B_HOST:
1457 isp->phy.state = OTG_STATE_B_PERIPHERAL; 1457 isp->phy.otg->state = OTG_STATE_B_PERIPHERAL;
1458 /* caller will suspend next */ 1458 /* caller will suspend next */
1459 break; 1459 break;
1460 case OTG_STATE_A_HOST: 1460 case OTG_STATE_A_HOST:
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 471e69dbcca0..18015b7c8afc 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -721,11 +721,11 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
721 } 721 }
722 722
723 if (!host) { 723 if (!host) {
724 if (otg->phy->state == OTG_STATE_A_HOST) { 724 if (otg->state == OTG_STATE_A_HOST) {
725 pm_runtime_get_sync(otg->phy->dev); 725 pm_runtime_get_sync(otg->phy->dev);
726 msm_otg_start_host(otg->phy, 0); 726 msm_otg_start_host(otg->phy, 0);
727 otg->host = NULL; 727 otg->host = NULL;
728 otg->phy->state = OTG_STATE_UNDEFINED; 728 otg->state = OTG_STATE_UNDEFINED;
729 schedule_work(&motg->sm_work); 729 schedule_work(&motg->sm_work);
730 } else { 730 } else {
731 otg->host = NULL; 731 otg->host = NULL;
@@ -794,11 +794,11 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
794 } 794 }
795 795
796 if (!gadget) { 796 if (!gadget) {
797 if (otg->phy->state == OTG_STATE_B_PERIPHERAL) { 797 if (otg->state == OTG_STATE_B_PERIPHERAL) {
798 pm_runtime_get_sync(otg->phy->dev); 798 pm_runtime_get_sync(otg->phy->dev);
799 msm_otg_start_peripheral(otg->phy, 0); 799 msm_otg_start_peripheral(otg->phy, 0);
800 otg->gadget = NULL; 800 otg->gadget = NULL;
801 otg->phy->state = OTG_STATE_UNDEFINED; 801 otg->state = OTG_STATE_UNDEFINED;
802 schedule_work(&motg->sm_work); 802 schedule_work(&motg->sm_work);
803 } else { 803 } else {
804 otg->gadget = NULL; 804 otg->gadget = NULL;
@@ -1170,12 +1170,12 @@ static void msm_otg_sm_work(struct work_struct *w)
1170 struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); 1170 struct msm_otg *motg = container_of(w, struct msm_otg, sm_work);
1171 struct usb_otg *otg = motg->phy.otg; 1171 struct usb_otg *otg = motg->phy.otg;
1172 1172
1173 switch (otg->phy->state) { 1173 switch (otg->state) {
1174 case OTG_STATE_UNDEFINED: 1174 case OTG_STATE_UNDEFINED:
1175 dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n"); 1175 dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n");
1176 msm_otg_reset(otg->phy); 1176 msm_otg_reset(otg->phy);
1177 msm_otg_init_sm(motg); 1177 msm_otg_init_sm(motg);
1178 otg->phy->state = OTG_STATE_B_IDLE; 1178 otg->state = OTG_STATE_B_IDLE;
1179 /* FALL THROUGH */ 1179 /* FALL THROUGH */
1180 case OTG_STATE_B_IDLE: 1180 case OTG_STATE_B_IDLE:
1181 dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n"); 1181 dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n");
@@ -1183,7 +1183,7 @@ static void msm_otg_sm_work(struct work_struct *w)
1183 /* disable BSV bit */ 1183 /* disable BSV bit */
1184 writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); 1184 writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC);
1185 msm_otg_start_host(otg->phy, 1); 1185 msm_otg_start_host(otg->phy, 1);
1186 otg->phy->state = OTG_STATE_A_HOST; 1186 otg->state = OTG_STATE_A_HOST;
1187 } else if (test_bit(B_SESS_VLD, &motg->inputs)) { 1187 } else if (test_bit(B_SESS_VLD, &motg->inputs)) {
1188 switch (motg->chg_state) { 1188 switch (motg->chg_state) {
1189 case USB_CHG_STATE_UNDEFINED: 1189 case USB_CHG_STATE_UNDEFINED:
@@ -1199,13 +1199,13 @@ static void msm_otg_sm_work(struct work_struct *w)
1199 msm_otg_notify_charger(motg, 1199 msm_otg_notify_charger(motg,
1200 IDEV_CHG_MAX); 1200 IDEV_CHG_MAX);
1201 msm_otg_start_peripheral(otg->phy, 1); 1201 msm_otg_start_peripheral(otg->phy, 1);
1202 otg->phy->state 1202 otg->state
1203 = OTG_STATE_B_PERIPHERAL; 1203 = OTG_STATE_B_PERIPHERAL;
1204 break; 1204 break;
1205 case USB_SDP_CHARGER: 1205 case USB_SDP_CHARGER:
1206 msm_otg_notify_charger(motg, IUNIT); 1206 msm_otg_notify_charger(motg, IUNIT);
1207 msm_otg_start_peripheral(otg->phy, 1); 1207 msm_otg_start_peripheral(otg->phy, 1);
1208 otg->phy->state 1208 otg->state
1209 = OTG_STATE_B_PERIPHERAL; 1209 = OTG_STATE_B_PERIPHERAL;
1210 break; 1210 break;
1211 default: 1211 default:
@@ -1230,7 +1230,7 @@ static void msm_otg_sm_work(struct work_struct *w)
1230 motg->chg_type = USB_INVALID_CHARGER; 1230 motg->chg_type = USB_INVALID_CHARGER;
1231 } 1231 }
1232 1232
1233 if (otg->phy->state == OTG_STATE_B_IDLE) 1233 if (otg->state == OTG_STATE_B_IDLE)
1234 pm_runtime_put_sync(otg->phy->dev); 1234 pm_runtime_put_sync(otg->phy->dev);
1235 break; 1235 break;
1236 case OTG_STATE_B_PERIPHERAL: 1236 case OTG_STATE_B_PERIPHERAL:
@@ -1241,7 +1241,7 @@ static void msm_otg_sm_work(struct work_struct *w)
1241 msm_otg_start_peripheral(otg->phy, 0); 1241 msm_otg_start_peripheral(otg->phy, 0);
1242 motg->chg_state = USB_CHG_STATE_UNDEFINED; 1242 motg->chg_state = USB_CHG_STATE_UNDEFINED;
1243 motg->chg_type = USB_INVALID_CHARGER; 1243 motg->chg_type = USB_INVALID_CHARGER;
1244 otg->phy->state = OTG_STATE_B_IDLE; 1244 otg->state = OTG_STATE_B_IDLE;
1245 msm_otg_reset(otg->phy); 1245 msm_otg_reset(otg->phy);
1246 schedule_work(w); 1246 schedule_work(w);
1247 } 1247 }
@@ -1250,7 +1250,7 @@ static void msm_otg_sm_work(struct work_struct *w)
1250 dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n"); 1250 dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n");
1251 if (test_bit(ID, &motg->inputs)) { 1251 if (test_bit(ID, &motg->inputs)) {
1252 msm_otg_start_host(otg->phy, 0); 1252 msm_otg_start_host(otg->phy, 0);
1253 otg->phy->state = OTG_STATE_B_IDLE; 1253 otg->state = OTG_STATE_B_IDLE;
1254 msm_otg_reset(otg->phy); 1254 msm_otg_reset(otg->phy);
1255 schedule_work(w); 1255 schedule_work(w);
1256 } 1256 }
@@ -1303,7 +1303,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
1303 struct msm_otg *motg = s->private; 1303 struct msm_otg *motg = s->private;
1304 struct usb_otg *otg = motg->phy.otg; 1304 struct usb_otg *otg = motg->phy.otg;
1305 1305
1306 switch (otg->phy->state) { 1306 switch (otg->state) {
1307 case OTG_STATE_A_HOST: 1307 case OTG_STATE_A_HOST:
1308 seq_puts(s, "host\n"); 1308 seq_puts(s, "host\n");
1309 break; 1309 break;
@@ -1353,7 +1353,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
1353 1353
1354 switch (req_mode) { 1354 switch (req_mode) {
1355 case USB_DR_MODE_UNKNOWN: 1355 case USB_DR_MODE_UNKNOWN:
1356 switch (otg->phy->state) { 1356 switch (otg->state) {
1357 case OTG_STATE_A_HOST: 1357 case OTG_STATE_A_HOST:
1358 case OTG_STATE_B_PERIPHERAL: 1358 case OTG_STATE_B_PERIPHERAL:
1359 set_bit(ID, &motg->inputs); 1359 set_bit(ID, &motg->inputs);
@@ -1364,7 +1364,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
1364 } 1364 }
1365 break; 1365 break;
1366 case USB_DR_MODE_PERIPHERAL: 1366 case USB_DR_MODE_PERIPHERAL:
1367 switch (otg->phy->state) { 1367 switch (otg->state) {
1368 case OTG_STATE_B_IDLE: 1368 case OTG_STATE_B_IDLE:
1369 case OTG_STATE_A_HOST: 1369 case OTG_STATE_A_HOST:
1370 set_bit(ID, &motg->inputs); 1370 set_bit(ID, &motg->inputs);
@@ -1375,7 +1375,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
1375 } 1375 }
1376 break; 1376 break;
1377 case USB_DR_MODE_HOST: 1377 case USB_DR_MODE_HOST:
1378 switch (otg->phy->state) { 1378 switch (otg->state) {
1379 case OTG_STATE_B_IDLE: 1379 case OTG_STATE_B_IDLE:
1380 case OTG_STATE_B_PERIPHERAL: 1380 case OTG_STATE_B_PERIPHERAL:
1381 clear_bit(ID, &motg->inputs); 1381 clear_bit(ID, &motg->inputs);
@@ -1769,7 +1769,7 @@ static int msm_otg_runtime_idle(struct device *dev)
1769 * This 1 sec delay also prevents entering into LPM immediately 1769 * This 1 sec delay also prevents entering into LPM immediately
1770 * after asynchronous interrupt. 1770 * after asynchronous interrupt.
1771 */ 1771 */
1772 if (otg->phy->state != OTG_STATE_UNDEFINED) 1772 if (otg->state != OTG_STATE_UNDEFINED)
1773 pm_schedule_suspend(dev, 1000); 1773 pm_schedule_suspend(dev, 1000);
1774 1774
1775 return -EAGAIN; 1775 return -EAGAIN;
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index c9517d8bda8d..ee87aa7144db 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -339,68 +339,68 @@ static void mv_otg_update_state(struct mv_otg *mvotg)
339{ 339{
340 struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; 340 struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl;
341 struct usb_phy *phy = &mvotg->phy; 341 struct usb_phy *phy = &mvotg->phy;
342 int old_state = phy->state; 342 int old_state = mvotg->phy.otg->state;
343 343
344 switch (old_state) { 344 switch (old_state) {
345 case OTG_STATE_UNDEFINED: 345 case OTG_STATE_UNDEFINED:
346 phy->state = OTG_STATE_B_IDLE; 346 mvotg->phy.otg->state = OTG_STATE_B_IDLE;
347 /* FALL THROUGH */ 347 /* FALL THROUGH */
348 case OTG_STATE_B_IDLE: 348 case OTG_STATE_B_IDLE:
349 if (otg_ctrl->id == 0) 349 if (otg_ctrl->id == 0)
350 phy->state = OTG_STATE_A_IDLE; 350 mvotg->phy.otg->state = OTG_STATE_A_IDLE;
351 else if (otg_ctrl->b_sess_vld) 351 else if (otg_ctrl->b_sess_vld)
352 phy->state = OTG_STATE_B_PERIPHERAL; 352 mvotg->phy.otg->state = OTG_STATE_B_PERIPHERAL;
353 break; 353 break;
354 case OTG_STATE_B_PERIPHERAL: 354 case OTG_STATE_B_PERIPHERAL:
355 if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) 355 if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0)
356 phy->state = OTG_STATE_B_IDLE; 356 mvotg->phy.otg->state = OTG_STATE_B_IDLE;
357 break; 357 break;
358 case OTG_STATE_A_IDLE: 358 case OTG_STATE_A_IDLE:
359 if (otg_ctrl->id) 359 if (otg_ctrl->id)
360 phy->state = OTG_STATE_B_IDLE; 360 mvotg->phy.otg->state = OTG_STATE_B_IDLE;
361 else if (!(otg_ctrl->a_bus_drop) && 361 else if (!(otg_ctrl->a_bus_drop) &&
362 (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) 362 (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det))
363 phy->state = OTG_STATE_A_WAIT_VRISE; 363 mvotg->phy.otg->state = OTG_STATE_A_WAIT_VRISE;
364 break; 364 break;
365 case OTG_STATE_A_WAIT_VRISE: 365 case OTG_STATE_A_WAIT_VRISE:
366 if (otg_ctrl->a_vbus_vld) 366 if (otg_ctrl->a_vbus_vld)
367 phy->state = OTG_STATE_A_WAIT_BCON; 367 mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
368 break; 368 break;
369 case OTG_STATE_A_WAIT_BCON: 369 case OTG_STATE_A_WAIT_BCON:
370 if (otg_ctrl->id || otg_ctrl->a_bus_drop 370 if (otg_ctrl->id || otg_ctrl->a_bus_drop
371 || otg_ctrl->a_wait_bcon_timeout) { 371 || otg_ctrl->a_wait_bcon_timeout) {
372 mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); 372 mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
373 mvotg->otg_ctrl.a_wait_bcon_timeout = 0; 373 mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
374 phy->state = OTG_STATE_A_WAIT_VFALL; 374 mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
375 otg_ctrl->a_bus_req = 0; 375 otg_ctrl->a_bus_req = 0;
376 } else if (!otg_ctrl->a_vbus_vld) { 376 } else if (!otg_ctrl->a_vbus_vld) {
377 mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); 377 mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
378 mvotg->otg_ctrl.a_wait_bcon_timeout = 0; 378 mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
379 phy->state = OTG_STATE_A_VBUS_ERR; 379 mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
380 } else if (otg_ctrl->b_conn) { 380 } else if (otg_ctrl->b_conn) {
381 mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); 381 mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER);
382 mvotg->otg_ctrl.a_wait_bcon_timeout = 0; 382 mvotg->otg_ctrl.a_wait_bcon_timeout = 0;
383 phy->state = OTG_STATE_A_HOST; 383 mvotg->phy.otg->state = OTG_STATE_A_HOST;
384 } 384 }
385 break; 385 break;
386 case OTG_STATE_A_HOST: 386 case OTG_STATE_A_HOST:
387 if (otg_ctrl->id || !otg_ctrl->b_conn 387 if (otg_ctrl->id || !otg_ctrl->b_conn
388 || otg_ctrl->a_bus_drop) 388 || otg_ctrl->a_bus_drop)
389 phy->state = OTG_STATE_A_WAIT_BCON; 389 mvotg->phy.otg->state = OTG_STATE_A_WAIT_BCON;
390 else if (!otg_ctrl->a_vbus_vld) 390 else if (!otg_ctrl->a_vbus_vld)
391 phy->state = OTG_STATE_A_VBUS_ERR; 391 mvotg->phy.otg->state = OTG_STATE_A_VBUS_ERR;
392 break; 392 break;
393 case OTG_STATE_A_WAIT_VFALL: 393 case OTG_STATE_A_WAIT_VFALL:
394 if (otg_ctrl->id 394 if (otg_ctrl->id
395 || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) 395 || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld)
396 || otg_ctrl->a_bus_req) 396 || otg_ctrl->a_bus_req)
397 phy->state = OTG_STATE_A_IDLE; 397 mvotg->phy.otg->state = OTG_STATE_A_IDLE;
398 break; 398 break;
399 case OTG_STATE_A_VBUS_ERR: 399 case OTG_STATE_A_VBUS_ERR:
400 if (otg_ctrl->id || otg_ctrl->a_clr_err 400 if (otg_ctrl->id || otg_ctrl->a_clr_err
401 || otg_ctrl->a_bus_drop) { 401 || otg_ctrl->a_bus_drop) {
402 otg_ctrl->a_clr_err = 0; 402 otg_ctrl->a_clr_err = 0;
403 phy->state = OTG_STATE_A_WAIT_VFALL; 403 mvotg->phy.otg->state = OTG_STATE_A_WAIT_VFALL;
404 } 404 }
405 break; 405 break;
406 default: 406 default:
@@ -420,8 +420,8 @@ static void mv_otg_work(struct work_struct *work)
420run: 420run:
421 /* work queue is single thread, or we need spin_lock to protect */ 421 /* work queue is single thread, or we need spin_lock to protect */
422 phy = &mvotg->phy; 422 phy = &mvotg->phy;
423 otg = phy->otg; 423 otg = mvotg->phy.otg;
424 old_state = phy->state; 424 old_state = otg->state;
425 425
426 if (!mvotg->active) 426 if (!mvotg->active)
427 return; 427 return;
@@ -429,12 +429,12 @@ run:
429 mv_otg_update_inputs(mvotg); 429 mv_otg_update_inputs(mvotg);
430 mv_otg_update_state(mvotg); 430 mv_otg_update_state(mvotg);
431 431
432 if (old_state != phy->state) { 432 if (old_state != mvotg->phy.otg->state) {
433 dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", 433 dev_info(&mvotg->pdev->dev, "change from state %s to %s\n",
434 state_string[old_state], 434 state_string[old_state],
435 state_string[phy->state]); 435 state_string[mvotg->phy.otg->state]);
436 436
437 switch (phy->state) { 437 switch (mvotg->phy.otg->state) {
438 case OTG_STATE_B_IDLE: 438 case OTG_STATE_B_IDLE:
439 otg->default_a = 0; 439 otg->default_a = 0;
440 if (old_state == OTG_STATE_B_PERIPHERAL) 440 if (old_state == OTG_STATE_B_PERIPHERAL)
@@ -545,8 +545,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr,
545 return -1; 545 return -1;
546 546
547 /* We will use this interface to change to A device */ 547 /* We will use this interface to change to A device */
548 if (mvotg->phy.state != OTG_STATE_B_IDLE 548 if (mvotg->phy.otg->state != OTG_STATE_B_IDLE
549 && mvotg->phy.state != OTG_STATE_A_IDLE) 549 && mvotg->phy.otg->state != OTG_STATE_A_IDLE)
550 return -1; 550 return -1;
551 551
552 /* The clock may disabled and we need to set irq for ID detected */ 552 /* The clock may disabled and we need to set irq for ID detected */
@@ -715,9 +715,9 @@ static int mv_otg_probe(struct platform_device *pdev)
715 mvotg->phy.dev = &pdev->dev; 715 mvotg->phy.dev = &pdev->dev;
716 mvotg->phy.otg = otg; 716 mvotg->phy.otg = otg;
717 mvotg->phy.label = driver_name; 717 mvotg->phy.label = driver_name;
718 mvotg->phy.state = OTG_STATE_UNDEFINED;
719 718
720 otg->phy = &mvotg->phy; 719 otg->phy = &mvotg->phy;
720 otg->state = OTG_STATE_UNDEFINED;
721 otg->set_host = mv_otg_set_host; 721 otg->set_host = mv_otg_set_host;
722 otg->set_peripheral = mv_otg_set_peripheral; 722 otg->set_peripheral = mv_otg_set_peripheral;
723 otg->set_vbus = mv_otg_set_vbus; 723 otg->set_vbus = mv_otg_set_vbus;
diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
index cc61ee44b911..04ece535c2f8 100644
--- a/drivers/usb/phy/phy-tahvo.c
+++ b/drivers/usb/phy/phy-tahvo.c
@@ -81,33 +81,33 @@ static void check_vbus_state(struct tahvo_usb *tu)
81 81
82 reg = retu_read(rdev, TAHVO_REG_IDSR); 82 reg = retu_read(rdev, TAHVO_REG_IDSR);
83 if (reg & TAHVO_STAT_VBUS) { 83 if (reg & TAHVO_STAT_VBUS) {
84 switch (tu->phy.state) { 84 switch (tu->phy.otg->state) {
85 case OTG_STATE_B_IDLE: 85 case OTG_STATE_B_IDLE:
86 /* Enable the gadget driver */ 86 /* Enable the gadget driver */
87 if (tu->phy.otg->gadget) 87 if (tu->phy.otg->gadget)
88 usb_gadget_vbus_connect(tu->phy.otg->gadget); 88 usb_gadget_vbus_connect(tu->phy.otg->gadget);
89 tu->phy.state = OTG_STATE_B_PERIPHERAL; 89 tu->phy.otg->state = OTG_STATE_B_PERIPHERAL;
90 break; 90 break;
91 case OTG_STATE_A_IDLE: 91 case OTG_STATE_A_IDLE:
92 /* 92 /*
93 * Session is now valid assuming the USB hub is driving 93 * Session is now valid assuming the USB hub is driving
94 * Vbus. 94 * Vbus.
95 */ 95 */
96 tu->phy.state = OTG_STATE_A_HOST; 96 tu->phy.otg->state = OTG_STATE_A_HOST;
97 break; 97 break;
98 default: 98 default:
99 break; 99 break;
100 } 100 }
101 dev_info(&tu->pt_dev->dev, "USB cable connected\n"); 101 dev_info(&tu->pt_dev->dev, "USB cable connected\n");
102 } else { 102 } else {
103 switch (tu->phy.state) { 103 switch (tu->phy.otg->state) {
104 case OTG_STATE_B_PERIPHERAL: 104 case OTG_STATE_B_PERIPHERAL:
105 if (tu->phy.otg->gadget) 105 if (tu->phy.otg->gadget)
106 usb_gadget_vbus_disconnect(tu->phy.otg->gadget); 106 usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
107 tu->phy.state = OTG_STATE_B_IDLE; 107 tu->phy.otg->state = OTG_STATE_B_IDLE;
108 break; 108 break;
109 case OTG_STATE_A_HOST: 109 case OTG_STATE_A_HOST:
110 tu->phy.state = OTG_STATE_A_IDLE; 110 tu->phy.otg->state = OTG_STATE_A_IDLE;
111 break; 111 break;
112 default: 112 default:
113 break; 113 break;
@@ -132,14 +132,14 @@ static void tahvo_usb_become_host(struct tahvo_usb *tu)
132 /* Power up the transceiver in USB host mode */ 132 /* Power up the transceiver in USB host mode */
133 retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND | 133 retu_write(rdev, TAHVO_REG_USBR, USBR_REGOUT | USBR_NSUSPEND |
134 USBR_MASTER_SW2 | USBR_MASTER_SW1); 134 USBR_MASTER_SW2 | USBR_MASTER_SW1);
135 tu->phy.state = OTG_STATE_A_IDLE; 135 tu->phy.otg->state = OTG_STATE_A_IDLE;
136 136
137 check_vbus_state(tu); 137 check_vbus_state(tu);
138} 138}
139 139
140static void tahvo_usb_stop_host(struct tahvo_usb *tu) 140static void tahvo_usb_stop_host(struct tahvo_usb *tu)
141{ 141{
142 tu->phy.state = OTG_STATE_A_IDLE; 142 tu->phy.otg->state = OTG_STATE_A_IDLE;
143} 143}
144 144
145static void tahvo_usb_become_peripheral(struct tahvo_usb *tu) 145static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
@@ -151,7 +151,7 @@ static void tahvo_usb_become_peripheral(struct tahvo_usb *tu)
151 /* Power up transceiver and set it in USB peripheral mode */ 151 /* Power up transceiver and set it in USB peripheral mode */
152 retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT | 152 retu_write(rdev, TAHVO_REG_USBR, USBR_SLAVE_CONTROL | USBR_REGOUT |
153 USBR_NSUSPEND | USBR_SLAVE_SW); 153 USBR_NSUSPEND | USBR_SLAVE_SW);
154 tu->phy.state = OTG_STATE_B_IDLE; 154 tu->phy.otg->state = OTG_STATE_B_IDLE;
155 155
156 check_vbus_state(tu); 156 check_vbus_state(tu);
157} 157}
@@ -160,7 +160,7 @@ static void tahvo_usb_stop_peripheral(struct tahvo_usb *tu)
160{ 160{
161 if (tu->phy.otg->gadget) 161 if (tu->phy.otg->gadget)
162 usb_gadget_vbus_disconnect(tu->phy.otg->gadget); 162 usb_gadget_vbus_disconnect(tu->phy.otg->gadget);
163 tu->phy.state = OTG_STATE_B_IDLE; 163 tu->phy.otg->state = OTG_STATE_B_IDLE;
164} 164}
165 165
166static void tahvo_usb_power_off(struct tahvo_usb *tu) 166static void tahvo_usb_power_off(struct tahvo_usb *tu)
@@ -173,7 +173,7 @@ static void tahvo_usb_power_off(struct tahvo_usb *tu)
173 173
174 /* Power off transceiver */ 174 /* Power off transceiver */
175 retu_write(rdev, TAHVO_REG_USBR, 0); 175 retu_write(rdev, TAHVO_REG_USBR, 0);
176 tu->phy.state = OTG_STATE_UNDEFINED; 176 tu->phy.otg->state = OTG_STATE_UNDEFINED;
177} 177}
178 178
179static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend) 179static int tahvo_usb_set_suspend(struct usb_phy *dev, int suspend)
@@ -379,7 +379,7 @@ static int tahvo_usb_probe(struct platform_device *pdev)
379 /* Create OTG interface */ 379 /* Create OTG interface */
380 tahvo_usb_power_off(tu); 380 tahvo_usb_power_off(tu);
381 tu->phy.dev = &pdev->dev; 381 tu->phy.dev = &pdev->dev;
382 tu->phy.state = OTG_STATE_UNDEFINED; 382 tu->phy.otg->state = OTG_STATE_UNDEFINED;
383 tu->phy.label = DRIVER_NAME; 383 tu->phy.label = DRIVER_NAME;
384 tu->phy.set_suspend = tahvo_usb_set_suspend; 384 tu->phy.set_suspend = tahvo_usb_set_suspend;
385 385