diff options
Diffstat (limited to 'drivers/usb/phy/phy-mv-usb.c')
-rw-r--r-- | drivers/usb/phy/phy-mv-usb.c | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index 7d80c54f0ac6..b234d46cd58b 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c | |||
@@ -56,7 +56,7 @@ static char *state_string[] = { | |||
56 | 56 | ||
57 | static int mv_otg_set_vbus(struct usb_otg *otg, bool on) | 57 | static int mv_otg_set_vbus(struct usb_otg *otg, bool on) |
58 | { | 58 | { |
59 | struct mv_otg *mvotg = container_of(otg->phy, struct mv_otg, phy); | 59 | struct mv_otg *mvotg = container_of(otg->usb_phy, struct mv_otg, phy); |
60 | if (mvotg->pdata->set_vbus == NULL) | 60 | if (mvotg->pdata->set_vbus == NULL) |
61 | return -ENODEV; | 61 | return -ENODEV; |
62 | 62 | ||
@@ -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) | |||
420 | run: | 420 | run: |
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,22 +429,24 @@ 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) |
441 | mv_otg_start_periphrals(mvotg, 0); | 441 | mv_otg_start_periphrals(mvotg, 0); |
442 | mv_otg_reset(mvotg); | 442 | mv_otg_reset(mvotg); |
443 | mv_otg_disable(mvotg); | 443 | mv_otg_disable(mvotg); |
444 | usb_phy_set_event(&mvotg->phy, USB_EVENT_NONE); | ||
444 | break; | 445 | break; |
445 | case OTG_STATE_B_PERIPHERAL: | 446 | case OTG_STATE_B_PERIPHERAL: |
446 | mv_otg_enable(mvotg); | 447 | mv_otg_enable(mvotg); |
447 | mv_otg_start_periphrals(mvotg, 1); | 448 | mv_otg_start_periphrals(mvotg, 1); |
449 | usb_phy_set_event(&mvotg->phy, USB_EVENT_ENUMERATED); | ||
448 | break; | 450 | break; |
449 | case OTG_STATE_A_IDLE: | 451 | case OTG_STATE_A_IDLE: |
450 | otg->default_a = 1; | 452 | otg->default_a = 1; |
@@ -545,8 +547,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr, | |||
545 | return -1; | 547 | return -1; |
546 | 548 | ||
547 | /* We will use this interface to change to A device */ | 549 | /* We will use this interface to change to A device */ |
548 | if (mvotg->phy.state != OTG_STATE_B_IDLE | 550 | if (mvotg->phy.otg->state != OTG_STATE_B_IDLE |
549 | && mvotg->phy.state != OTG_STATE_A_IDLE) | 551 | && mvotg->phy.otg->state != OTG_STATE_A_IDLE) |
550 | return -1; | 552 | return -1; |
551 | 553 | ||
552 | /* The clock may disabled and we need to set irq for ID detected */ | 554 | /* The clock may disabled and we need to set irq for ID detected */ |
@@ -686,10 +688,8 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
686 | } | 688 | } |
687 | 689 | ||
688 | mvotg = devm_kzalloc(&pdev->dev, sizeof(*mvotg), GFP_KERNEL); | 690 | mvotg = devm_kzalloc(&pdev->dev, sizeof(*mvotg), GFP_KERNEL); |
689 | if (!mvotg) { | 691 | if (!mvotg) |
690 | dev_err(&pdev->dev, "failed to allocate memory!\n"); | ||
691 | return -ENOMEM; | 692 | return -ENOMEM; |
692 | } | ||
693 | 693 | ||
694 | otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); | 694 | otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL); |
695 | if (!otg) | 695 | if (!otg) |
@@ -717,9 +717,9 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
717 | mvotg->phy.dev = &pdev->dev; | 717 | mvotg->phy.dev = &pdev->dev; |
718 | mvotg->phy.otg = otg; | 718 | mvotg->phy.otg = otg; |
719 | mvotg->phy.label = driver_name; | 719 | mvotg->phy.label = driver_name; |
720 | mvotg->phy.state = OTG_STATE_UNDEFINED; | ||
721 | 720 | ||
722 | otg->phy = &mvotg->phy; | 721 | otg->state = OTG_STATE_UNDEFINED; |
722 | otg->usb_phy = &mvotg->phy; | ||
723 | otg->set_host = mv_otg_set_host; | 723 | otg->set_host = mv_otg_set_host; |
724 | otg->set_peripheral = mv_otg_set_peripheral; | 724 | otg->set_peripheral = mv_otg_set_peripheral; |
725 | otg->set_vbus = mv_otg_set_vbus; | 725 | otg->set_vbus = mv_otg_set_vbus; |