diff options
Diffstat (limited to 'drivers/usb/phy/phy-msm-usb.c')
-rw-r--r-- | drivers/usb/phy/phy-msm-usb.c | 107 |
1 files changed, 52 insertions, 55 deletions
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index 29be0e654ecc..000fd892455f 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c | |||
@@ -708,7 +708,7 @@ static void msm_otg_start_host(struct usb_phy *phy, int on) | |||
708 | 708 | ||
709 | static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | 709 | static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
710 | { | 710 | { |
711 | struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy); | 711 | struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy); |
712 | struct usb_hcd *hcd; | 712 | struct usb_hcd *hcd; |
713 | 713 | ||
714 | /* | 714 | /* |
@@ -716,16 +716,16 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
716 | * only peripheral configuration. | 716 | * only peripheral configuration. |
717 | */ | 717 | */ |
718 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) { | 718 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) { |
719 | dev_info(otg->phy->dev, "Host mode is not supported\n"); | 719 | dev_info(otg->usb_phy->dev, "Host mode is not supported\n"); |
720 | return -ENODEV; | 720 | return -ENODEV; |
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->usb_phy->dev); |
726 | msm_otg_start_host(otg->phy, 0); | 726 | msm_otg_start_host(otg->usb_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; |
@@ -738,14 +738,14 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
738 | hcd->power_budget = motg->pdata->power_budget; | 738 | hcd->power_budget = motg->pdata->power_budget; |
739 | 739 | ||
740 | otg->host = host; | 740 | otg->host = host; |
741 | dev_dbg(otg->phy->dev, "host driver registered w/ tranceiver\n"); | 741 | dev_dbg(otg->usb_phy->dev, "host driver registered w/ tranceiver\n"); |
742 | 742 | ||
743 | /* | 743 | /* |
744 | * Kick the state machine work, if peripheral is not supported | 744 | * Kick the state machine work, if peripheral is not supported |
745 | * or peripheral is already registered with us. | 745 | * or peripheral is already registered with us. |
746 | */ | 746 | */ |
747 | if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) { | 747 | if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) { |
748 | pm_runtime_get_sync(otg->phy->dev); | 748 | pm_runtime_get_sync(otg->usb_phy->dev); |
749 | schedule_work(&motg->sm_work); | 749 | schedule_work(&motg->sm_work); |
750 | } | 750 | } |
751 | 751 | ||
@@ -782,23 +782,23 @@ static void msm_otg_start_peripheral(struct usb_phy *phy, int on) | |||
782 | static int msm_otg_set_peripheral(struct usb_otg *otg, | 782 | static int msm_otg_set_peripheral(struct usb_otg *otg, |
783 | struct usb_gadget *gadget) | 783 | struct usb_gadget *gadget) |
784 | { | 784 | { |
785 | struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy); | 785 | struct msm_otg *motg = container_of(otg->usb_phy, struct msm_otg, phy); |
786 | 786 | ||
787 | /* | 787 | /* |
788 | * Fail peripheral registration if this board can support | 788 | * Fail peripheral registration if this board can support |
789 | * only host configuration. | 789 | * only host configuration. |
790 | */ | 790 | */ |
791 | if (motg->pdata->mode == USB_DR_MODE_HOST) { | 791 | if (motg->pdata->mode == USB_DR_MODE_HOST) { |
792 | dev_info(otg->phy->dev, "Peripheral mode is not supported\n"); | 792 | dev_info(otg->usb_phy->dev, "Peripheral mode is not supported\n"); |
793 | return -ENODEV; | 793 | return -ENODEV; |
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->usb_phy->dev); |
799 | msm_otg_start_peripheral(otg->phy, 0); | 799 | msm_otg_start_peripheral(otg->usb_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; |
@@ -807,14 +807,15 @@ static int msm_otg_set_peripheral(struct usb_otg *otg, | |||
807 | return 0; | 807 | return 0; |
808 | } | 808 | } |
809 | otg->gadget = gadget; | 809 | otg->gadget = gadget; |
810 | dev_dbg(otg->phy->dev, "peripheral driver registered w/ tranceiver\n"); | 810 | dev_dbg(otg->usb_phy->dev, |
811 | "peripheral driver registered w/ tranceiver\n"); | ||
811 | 812 | ||
812 | /* | 813 | /* |
813 | * Kick the state machine work, if host is not supported | 814 | * Kick the state machine work, if host is not supported |
814 | * or host is already registered with us. | 815 | * or host is already registered with us. |
815 | */ | 816 | */ |
816 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) { | 817 | if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) { |
817 | pm_runtime_get_sync(otg->phy->dev); | 818 | pm_runtime_get_sync(otg->usb_phy->dev); |
818 | schedule_work(&motg->sm_work); | 819 | schedule_work(&motg->sm_work); |
819 | } | 820 | } |
820 | 821 | ||
@@ -1170,20 +1171,20 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1170 | struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); | 1171 | struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); |
1171 | struct usb_otg *otg = motg->phy.otg; | 1172 | struct usb_otg *otg = motg->phy.otg; |
1172 | 1173 | ||
1173 | switch (otg->phy->state) { | 1174 | switch (otg->state) { |
1174 | case OTG_STATE_UNDEFINED: | 1175 | case OTG_STATE_UNDEFINED: |
1175 | dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n"); | 1176 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_UNDEFINED state\n"); |
1176 | msm_otg_reset(otg->phy); | 1177 | msm_otg_reset(otg->usb_phy); |
1177 | msm_otg_init_sm(motg); | 1178 | msm_otg_init_sm(motg); |
1178 | otg->phy->state = OTG_STATE_B_IDLE; | 1179 | otg->state = OTG_STATE_B_IDLE; |
1179 | /* FALL THROUGH */ | 1180 | /* FALL THROUGH */ |
1180 | case OTG_STATE_B_IDLE: | 1181 | case OTG_STATE_B_IDLE: |
1181 | dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n"); | 1182 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_IDLE state\n"); |
1182 | if (!test_bit(ID, &motg->inputs) && otg->host) { | 1183 | if (!test_bit(ID, &motg->inputs) && otg->host) { |
1183 | /* disable BSV bit */ | 1184 | /* disable BSV bit */ |
1184 | writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); | 1185 | writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); |
1185 | msm_otg_start_host(otg->phy, 1); | 1186 | msm_otg_start_host(otg->usb_phy, 1); |
1186 | otg->phy->state = OTG_STATE_A_HOST; | 1187 | otg->state = OTG_STATE_A_HOST; |
1187 | } else if (test_bit(B_SESS_VLD, &motg->inputs)) { | 1188 | } else if (test_bit(B_SESS_VLD, &motg->inputs)) { |
1188 | switch (motg->chg_state) { | 1189 | switch (motg->chg_state) { |
1189 | case USB_CHG_STATE_UNDEFINED: | 1190 | case USB_CHG_STATE_UNDEFINED: |
@@ -1198,14 +1199,16 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1198 | case USB_CDP_CHARGER: | 1199 | case USB_CDP_CHARGER: |
1199 | msm_otg_notify_charger(motg, | 1200 | msm_otg_notify_charger(motg, |
1200 | IDEV_CHG_MAX); | 1201 | IDEV_CHG_MAX); |
1201 | msm_otg_start_peripheral(otg->phy, 1); | 1202 | msm_otg_start_peripheral(otg->usb_phy, |
1202 | otg->phy->state | 1203 | 1); |
1204 | otg->state | ||
1203 | = OTG_STATE_B_PERIPHERAL; | 1205 | = OTG_STATE_B_PERIPHERAL; |
1204 | break; | 1206 | break; |
1205 | case USB_SDP_CHARGER: | 1207 | case USB_SDP_CHARGER: |
1206 | msm_otg_notify_charger(motg, IUNIT); | 1208 | msm_otg_notify_charger(motg, IUNIT); |
1207 | msm_otg_start_peripheral(otg->phy, 1); | 1209 | msm_otg_start_peripheral(otg->usb_phy, |
1208 | otg->phy->state | 1210 | 1); |
1211 | otg->state | ||
1209 | = OTG_STATE_B_PERIPHERAL; | 1212 | = OTG_STATE_B_PERIPHERAL; |
1210 | break; | 1213 | break; |
1211 | default: | 1214 | default: |
@@ -1222,36 +1225,36 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1222 | * is incremented in charger detection work. | 1225 | * is incremented in charger detection work. |
1223 | */ | 1226 | */ |
1224 | if (cancel_delayed_work_sync(&motg->chg_work)) { | 1227 | if (cancel_delayed_work_sync(&motg->chg_work)) { |
1225 | pm_runtime_put_sync(otg->phy->dev); | 1228 | pm_runtime_put_sync(otg->usb_phy->dev); |
1226 | msm_otg_reset(otg->phy); | 1229 | msm_otg_reset(otg->usb_phy); |
1227 | } | 1230 | } |
1228 | msm_otg_notify_charger(motg, 0); | 1231 | msm_otg_notify_charger(motg, 0); |
1229 | motg->chg_state = USB_CHG_STATE_UNDEFINED; | 1232 | motg->chg_state = USB_CHG_STATE_UNDEFINED; |
1230 | motg->chg_type = USB_INVALID_CHARGER; | 1233 | motg->chg_type = USB_INVALID_CHARGER; |
1231 | } | 1234 | } |
1232 | 1235 | ||
1233 | if (otg->phy->state == OTG_STATE_B_IDLE) | 1236 | if (otg->state == OTG_STATE_B_IDLE) |
1234 | pm_runtime_put_sync(otg->phy->dev); | 1237 | pm_runtime_put_sync(otg->usb_phy->dev); |
1235 | break; | 1238 | break; |
1236 | case OTG_STATE_B_PERIPHERAL: | 1239 | case OTG_STATE_B_PERIPHERAL: |
1237 | dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n"); | 1240 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_B_PERIPHERAL state\n"); |
1238 | if (!test_bit(B_SESS_VLD, &motg->inputs) || | 1241 | if (!test_bit(B_SESS_VLD, &motg->inputs) || |
1239 | !test_bit(ID, &motg->inputs)) { | 1242 | !test_bit(ID, &motg->inputs)) { |
1240 | msm_otg_notify_charger(motg, 0); | 1243 | msm_otg_notify_charger(motg, 0); |
1241 | msm_otg_start_peripheral(otg->phy, 0); | 1244 | msm_otg_start_peripheral(otg->usb_phy, 0); |
1242 | motg->chg_state = USB_CHG_STATE_UNDEFINED; | 1245 | motg->chg_state = USB_CHG_STATE_UNDEFINED; |
1243 | motg->chg_type = USB_INVALID_CHARGER; | 1246 | motg->chg_type = USB_INVALID_CHARGER; |
1244 | otg->phy->state = OTG_STATE_B_IDLE; | 1247 | otg->state = OTG_STATE_B_IDLE; |
1245 | msm_otg_reset(otg->phy); | 1248 | msm_otg_reset(otg->usb_phy); |
1246 | schedule_work(w); | 1249 | schedule_work(w); |
1247 | } | 1250 | } |
1248 | break; | 1251 | break; |
1249 | case OTG_STATE_A_HOST: | 1252 | case OTG_STATE_A_HOST: |
1250 | dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n"); | 1253 | dev_dbg(otg->usb_phy->dev, "OTG_STATE_A_HOST state\n"); |
1251 | if (test_bit(ID, &motg->inputs)) { | 1254 | if (test_bit(ID, &motg->inputs)) { |
1252 | msm_otg_start_host(otg->phy, 0); | 1255 | msm_otg_start_host(otg->usb_phy, 0); |
1253 | otg->phy->state = OTG_STATE_B_IDLE; | 1256 | otg->state = OTG_STATE_B_IDLE; |
1254 | msm_otg_reset(otg->phy); | 1257 | msm_otg_reset(otg->usb_phy); |
1255 | schedule_work(w); | 1258 | schedule_work(w); |
1256 | } | 1259 | } |
1257 | break; | 1260 | break; |
@@ -1303,7 +1306,7 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused) | |||
1303 | struct msm_otg *motg = s->private; | 1306 | struct msm_otg *motg = s->private; |
1304 | struct usb_otg *otg = motg->phy.otg; | 1307 | struct usb_otg *otg = motg->phy.otg; |
1305 | 1308 | ||
1306 | switch (otg->phy->state) { | 1309 | switch (otg->state) { |
1307 | case OTG_STATE_A_HOST: | 1310 | case OTG_STATE_A_HOST: |
1308 | seq_puts(s, "host\n"); | 1311 | seq_puts(s, "host\n"); |
1309 | break; | 1312 | break; |
@@ -1353,7 +1356,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1353 | 1356 | ||
1354 | switch (req_mode) { | 1357 | switch (req_mode) { |
1355 | case USB_DR_MODE_UNKNOWN: | 1358 | case USB_DR_MODE_UNKNOWN: |
1356 | switch (otg->phy->state) { | 1359 | switch (otg->state) { |
1357 | case OTG_STATE_A_HOST: | 1360 | case OTG_STATE_A_HOST: |
1358 | case OTG_STATE_B_PERIPHERAL: | 1361 | case OTG_STATE_B_PERIPHERAL: |
1359 | set_bit(ID, &motg->inputs); | 1362 | set_bit(ID, &motg->inputs); |
@@ -1364,7 +1367,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1364 | } | 1367 | } |
1365 | break; | 1368 | break; |
1366 | case USB_DR_MODE_PERIPHERAL: | 1369 | case USB_DR_MODE_PERIPHERAL: |
1367 | switch (otg->phy->state) { | 1370 | switch (otg->state) { |
1368 | case OTG_STATE_B_IDLE: | 1371 | case OTG_STATE_B_IDLE: |
1369 | case OTG_STATE_A_HOST: | 1372 | case OTG_STATE_A_HOST: |
1370 | set_bit(ID, &motg->inputs); | 1373 | set_bit(ID, &motg->inputs); |
@@ -1375,7 +1378,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1375 | } | 1378 | } |
1376 | break; | 1379 | break; |
1377 | case USB_DR_MODE_HOST: | 1380 | case USB_DR_MODE_HOST: |
1378 | switch (otg->phy->state) { | 1381 | switch (otg->state) { |
1379 | case OTG_STATE_B_IDLE: | 1382 | case OTG_STATE_B_IDLE: |
1380 | case OTG_STATE_B_PERIPHERAL: | 1383 | case OTG_STATE_B_PERIPHERAL: |
1381 | clear_bit(ID, &motg->inputs); | 1384 | clear_bit(ID, &motg->inputs); |
@@ -1388,7 +1391,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1388 | goto out; | 1391 | goto out; |
1389 | } | 1392 | } |
1390 | 1393 | ||
1391 | pm_runtime_get_sync(otg->phy->dev); | 1394 | pm_runtime_get_sync(otg->usb_phy->dev); |
1392 | schedule_work(&motg->sm_work); | 1395 | schedule_work(&motg->sm_work); |
1393 | out: | 1396 | out: |
1394 | return status; | 1397 | return status; |
@@ -1505,10 +1508,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) | |||
1505 | } | 1508 | } |
1506 | 1509 | ||
1507 | pdata->phy_init_seq = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); | 1510 | pdata->phy_init_seq = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); |
1508 | if (!pdata->phy_init_seq) { | 1511 | if (!pdata->phy_init_seq) |
1509 | dev_warn(&pdev->dev, "No space for PHY init sequence\n"); | ||
1510 | return 0; | 1512 | return 0; |
1511 | } | ||
1512 | 1513 | ||
1513 | ret = of_property_read_u32_array(node, "qcom,phy-init-sequence", | 1514 | ret = of_property_read_u32_array(node, "qcom,phy-init-sequence", |
1514 | pdata->phy_init_seq, words); | 1515 | pdata->phy_init_seq, words); |
@@ -1530,10 +1531,8 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1530 | void __iomem *phy_select; | 1531 | void __iomem *phy_select; |
1531 | 1532 | ||
1532 | motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL); | 1533 | motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL); |
1533 | if (!motg) { | 1534 | if (!motg) |
1534 | dev_err(&pdev->dev, "unable to allocate msm_otg\n"); | ||
1535 | return -ENOMEM; | 1535 | return -ENOMEM; |
1536 | } | ||
1537 | 1536 | ||
1538 | pdata = dev_get_platdata(&pdev->dev); | 1537 | pdata = dev_get_platdata(&pdev->dev); |
1539 | if (!pdata) { | 1538 | if (!pdata) { |
@@ -1546,10 +1545,8 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1546 | 1545 | ||
1547 | motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), | 1546 | motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg), |
1548 | GFP_KERNEL); | 1547 | GFP_KERNEL); |
1549 | if (!motg->phy.otg) { | 1548 | if (!motg->phy.otg) |
1550 | dev_err(&pdev->dev, "unable to allocate msm_otg\n"); | ||
1551 | return -ENOMEM; | 1549 | return -ENOMEM; |
1552 | } | ||
1553 | 1550 | ||
1554 | phy = &motg->phy; | 1551 | phy = &motg->phy; |
1555 | phy->dev = &pdev->dev; | 1552 | phy->dev = &pdev->dev; |
@@ -1674,7 +1671,7 @@ static int msm_otg_probe(struct platform_device *pdev) | |||
1674 | 1671 | ||
1675 | phy->io_ops = &msm_otg_io_ops; | 1672 | phy->io_ops = &msm_otg_io_ops; |
1676 | 1673 | ||
1677 | phy->otg->phy = &motg->phy; | 1674 | phy->otg->usb_phy = &motg->phy; |
1678 | phy->otg->set_host = msm_otg_set_host; | 1675 | phy->otg->set_host = msm_otg_set_host; |
1679 | phy->otg->set_peripheral = msm_otg_set_peripheral; | 1676 | phy->otg->set_peripheral = msm_otg_set_peripheral; |
1680 | 1677 | ||
@@ -1775,7 +1772,7 @@ static int msm_otg_runtime_idle(struct device *dev) | |||
1775 | * This 1 sec delay also prevents entering into LPM immediately | 1772 | * This 1 sec delay also prevents entering into LPM immediately |
1776 | * after asynchronous interrupt. | 1773 | * after asynchronous interrupt. |
1777 | */ | 1774 | */ |
1778 | if (otg->phy->state != OTG_STATE_UNDEFINED) | 1775 | if (otg->state != OTG_STATE_UNDEFINED) |
1779 | pm_schedule_suspend(dev, 1000); | 1776 | pm_schedule_suspend(dev, 1000); |
1780 | 1777 | ||
1781 | return -EAGAIN; | 1778 | return -EAGAIN; |