Lines Matching +full:srp +full:- +full:capable
1 // SPDX-License-Identifier: GPL-2.0
3 * core.c - ChipIdea USB IP core family device controller
5 * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved.
12 * - Four transfers are supported, usbtest is passed
13 * - USB Certification for gadget: CH9 and Mass Storage are passed
14 * - Low power mode
15 * - USB wakeup
19 #include <linux/dma-mapping.h>
105 ci->hw_bank.regmap[i] = in hw_alloc_regmap()
106 (i <= CAP_LAST ? ci->hw_bank.cap : ci->hw_bank.op) + in hw_alloc_regmap()
110 ci->hw_bank.regmap[i] = ci->hw_bank.op + in hw_alloc_regmap()
111 4 * (i - OP_ENDPTCTRL) + in hw_alloc_regmap()
170 return -EINVAL; in hw_port_test_set()
202 enum ci_hw_regs reg = ci->hw_bank.lpm ? OP_DEVLC : OP_PORTSC; in ci_hdrc_enter_lpm_common()
203 bool lpm = !!(hw_read(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm))); in ci_hdrc_enter_lpm_common()
206 hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm), in ci_hdrc_enter_lpm_common()
207 PORTSC_PHCD(ci->hw_bank.lpm)); in ci_hdrc_enter_lpm_common()
209 hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm), in ci_hdrc_enter_lpm_common()
215 return ci->platdata->enter_lpm(ci, enable); in ci_hdrc_enter_lpm()
223 ci->hw_bank.abs = base; in hw_device_init()
225 ci->hw_bank.cap = ci->hw_bank.abs; in hw_device_init()
226 ci->hw_bank.cap += ci->platdata->capoffset; in hw_device_init()
227 ci->hw_bank.op = ci->hw_bank.cap + (ioread32(ci->hw_bank.cap) & 0xff); in hw_device_init()
232 ci->hw_bank.lpm = reg; in hw_device_init()
235 ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs; in hw_device_init()
236 ci->hw_bank.size += OP_LAST; in hw_device_init()
237 ci->hw_bank.size /= sizeof(u32); in hw_device_init()
241 ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */ in hw_device_init()
243 if (ci->hw_ep_max > ENDPT_MAX) in hw_device_init()
244 return -ENODEV; in hw_device_init()
254 ci->rev = ci_get_revision(ci); in hw_device_init()
256 dev_dbg(ci->dev, in hw_device_init()
258 ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op); in hw_device_init()
273 switch (ci->platdata->phy_mode) { in hw_phymode_configure()
299 if (ci->hw_bank.lpm) { in hw_phymode_configure()
322 if (ci->phy) { in _ci_usb_phy_init()
323 ret = phy_init(ci->phy); in _ci_usb_phy_init()
327 ret = phy_power_on(ci->phy); in _ci_usb_phy_init()
329 phy_exit(ci->phy); in _ci_usb_phy_init()
333 ret = usb_phy_init(ci->usb_phy); in _ci_usb_phy_init()
346 if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL) in ci_usb_phy_exit()
349 if (ci->phy) { in ci_usb_phy_exit()
350 phy_power_off(ci->phy); in ci_usb_phy_exit()
351 phy_exit(ci->phy); in ci_usb_phy_exit()
353 usb_phy_shutdown(ci->usb_phy); in ci_usb_phy_exit()
367 if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL) in ci_usb_phy_init()
370 switch (ci->platdata->phy_mode) { in ci_usb_phy_init()
411 phy_set_mode(ci->phy, PHY_MODE_USB_DEVICE); in ci_platform_configure()
413 if (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING) in ci_platform_configure()
419 phy_set_mode(ci->phy, PHY_MODE_USB_HOST); in ci_platform_configure()
421 if (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING) in ci_platform_configure()
426 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) { in ci_platform_configure()
427 if (ci->hw_bank.lpm) in ci_platform_configure()
433 if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA) in ci_platform_configure()
436 hw_write(ci, OP_USBCMD, 0xff0000, ci->platdata->itc_setting << 16); in ci_platform_configure()
438 if (ci->platdata->flags & CI_HDRC_OVERRIDE_AHB_BURST) in ci_platform_configure()
440 ci->platdata->ahb_burst_config); in ci_platform_configure()
444 if (ci->platdata->flags & CI_HDRC_OVERRIDE_TX_BURST) in ci_platform_configure()
446 ci->platdata->tx_burst_size << __ffs(TX_BURST_MASK)); in ci_platform_configure()
448 if (ci->platdata->flags & CI_HDRC_OVERRIDE_RX_BURST) in ci_platform_configure()
450 ci->platdata->rx_burst_size); in ci_platform_configure()
468 return -ETIMEDOUT; in hw_controller_reset()
490 dev_err(ci->dev, "error resetting controller, ret=%d\n", ret); in hw_device_reset()
494 if (ci->platdata->notify_event) { in hw_device_reset()
495 ret = ci->platdata->notify_event(ci, in hw_device_reset()
508 dev_err(ci->dev, "cannot enter in %s device mode\n", in hw_device_reset()
509 ci_role(ci)->name); in hw_device_reset()
510 dev_err(ci->dev, "lpm = %i\n", ci->hw_bank.lpm); in hw_device_reset()
511 return -ENODEV; in hw_device_reset()
525 if (ci->in_lpm) { in ci_irq_handler()
527 ci->wakeup_int = true; in ci_irq_handler()
528 pm_runtime_get(ci->dev); in ci_irq_handler()
532 if (ci->is_otg) { in ci_irq_handler()
545 if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) { in ci_irq_handler()
546 ci->id_event = true; in ci_irq_handler()
557 if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) { in ci_irq_handler()
558 ci->b_sess_valid_event = true; in ci_irq_handler()
566 if (ci->role != CI_ROLE_END) in ci_irq_handler()
567 ret = ci_role(ci)->irq(ci); in ci_irq_handler()
577 ci_irq_handler(ci->irq, ci); in ci_irq()
585 struct ci_hdrc *ci = cbl->ci; in ci_cable_notifier()
587 cbl->connected = event; in ci_cable_notifier()
588 cbl->changed = true; in ci_cable_notifier()
600 spin_lock_irqsave(&ci->lock, flags); in ci_usb_role_switch_get()
602 spin_unlock_irqrestore(&ci->lock, flags); in ci_usb_role_switch_get()
614 cable = &ci->platdata->id_extcon; in ci_usb_role_switch_set()
615 cable->changed = true; in ci_usb_role_switch_set()
616 cable->connected = true; in ci_usb_role_switch_set()
617 cable = &ci->platdata->vbus_extcon; in ci_usb_role_switch_set()
618 cable->changed = true; in ci_usb_role_switch_set()
619 cable->connected = false; in ci_usb_role_switch_set()
621 cable = &ci->platdata->id_extcon; in ci_usb_role_switch_set()
622 cable->changed = true; in ci_usb_role_switch_set()
623 cable->connected = false; in ci_usb_role_switch_set()
624 cable = &ci->platdata->vbus_extcon; in ci_usb_role_switch_set()
625 cable->changed = true; in ci_usb_role_switch_set()
626 cable->connected = true; in ci_usb_role_switch_set()
628 cable = &ci->platdata->id_extcon; in ci_usb_role_switch_set()
629 cable->changed = true; in ci_usb_role_switch_set()
630 cable->connected = false; in ci_usb_role_switch_set()
631 cable = &ci->platdata->vbus_extcon; in ci_usb_role_switch_set()
632 cable->changed = true; in ci_usb_role_switch_set()
633 cable->connected = false; in ci_usb_role_switch_set()
644 if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) { in ci_get_role()
645 if (ci->is_otg) { in ci_get_role()
650 * If the controller is not OTG capable, but support in ci_get_role()
657 role = ci->roles[CI_ROLE_HOST] ? CI_ROLE_HOST in ci_get_role()
677 if (!platdata->phy_mode) in ci_get_platdata()
678 platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); in ci_get_platdata()
680 if (!platdata->dr_mode) in ci_get_platdata()
681 platdata->dr_mode = usb_get_dr_mode(dev); in ci_get_platdata()
683 if (platdata->dr_mode == USB_DR_MODE_UNKNOWN) in ci_get_platdata()
684 platdata->dr_mode = USB_DR_MODE_OTG; in ci_get_platdata()
686 if (platdata->dr_mode != USB_DR_MODE_PERIPHERAL) { in ci_get_platdata()
688 platdata->reg_vbus = devm_regulator_get_optional(dev, "vbus"); in ci_get_platdata()
689 if (PTR_ERR(platdata->reg_vbus) == -EPROBE_DEFER) { in ci_get_platdata()
690 return -EPROBE_DEFER; in ci_get_platdata()
691 } else if (PTR_ERR(platdata->reg_vbus) == -ENODEV) { in ci_get_platdata()
693 platdata->reg_vbus = NULL; in ci_get_platdata()
694 } else if (IS_ERR(platdata->reg_vbus)) { in ci_get_platdata()
696 PTR_ERR(platdata->reg_vbus)); in ci_get_platdata()
697 return PTR_ERR(platdata->reg_vbus); in ci_get_platdata()
700 if (!platdata->tpl_support) in ci_get_platdata()
701 platdata->tpl_support = in ci_get_platdata()
702 of_usb_host_tpl_support(dev->of_node); in ci_get_platdata()
705 if (platdata->dr_mode == USB_DR_MODE_OTG) { in ci_get_platdata()
706 /* We can support HNP and SRP of OTG 2.0 */ in ci_get_platdata()
707 platdata->ci_otg_caps.otg_rev = 0x0200; in ci_get_platdata()
708 platdata->ci_otg_caps.hnp_support = true; in ci_get_platdata()
709 platdata->ci_otg_caps.srp_support = true; in ci_get_platdata()
712 ret = of_usb_update_otg_caps(dev->of_node, in ci_get_platdata()
713 &platdata->ci_otg_caps); in ci_get_platdata()
719 platdata->flags |= CI_HDRC_FORCE_FULLSPEED; in ci_get_platdata()
721 of_property_read_u32(dev->of_node, "phy-clkgate-delay-us", in ci_get_platdata()
722 &platdata->phy_clkgate_delay_us); in ci_get_platdata()
724 platdata->itc_setting = 1; in ci_get_platdata()
726 of_property_read_u32(dev->of_node, "itc-setting", in ci_get_platdata()
727 &platdata->itc_setting); in ci_get_platdata()
729 ret = of_property_read_u32(dev->of_node, "ahb-burst-config", in ci_get_platdata()
730 &platdata->ahb_burst_config); in ci_get_platdata()
732 platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST; in ci_get_platdata()
733 } else if (ret != -EINVAL) { in ci_get_platdata()
734 dev_err(dev, "failed to get ahb-burst-config\n"); in ci_get_platdata()
738 ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword", in ci_get_platdata()
739 &platdata->tx_burst_size); in ci_get_platdata()
741 platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST; in ci_get_platdata()
742 } else if (ret != -EINVAL) { in ci_get_platdata()
743 dev_err(dev, "failed to get tx-burst-size-dword\n"); in ci_get_platdata()
747 ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword", in ci_get_platdata()
748 &platdata->rx_burst_size); in ci_get_platdata()
750 platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST; in ci_get_platdata()
751 } else if (ret != -EINVAL) { in ci_get_platdata()
752 dev_err(dev, "failed to get rx-burst-size-dword\n"); in ci_get_platdata()
756 if (of_property_read_bool(dev->of_node, "non-zero-ttctrl-ttha")) in ci_get_platdata()
757 platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA; in ci_get_platdata()
759 ext_id = ERR_PTR(-ENODEV); in ci_get_platdata()
760 ext_vbus = ERR_PTR(-ENODEV); in ci_get_platdata()
761 if (of_property_read_bool(dev->of_node, "extcon")) { in ci_get_platdata()
764 if (IS_ERR(ext_vbus) && PTR_ERR(ext_vbus) != -ENODEV) in ci_get_platdata()
768 if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV) in ci_get_platdata()
772 cable = &platdata->vbus_extcon; in ci_get_platdata()
773 cable->nb.notifier_call = ci_cable_notifier; in ci_get_platdata()
774 cable->edev = ext_vbus; in ci_get_platdata()
777 ret = extcon_get_state(cable->edev, EXTCON_USB); in ci_get_platdata()
779 cable->connected = true; in ci_get_platdata()
781 cable->connected = false; in ci_get_platdata()
784 cable = &platdata->id_extcon; in ci_get_platdata()
785 cable->nb.notifier_call = ci_cable_notifier; in ci_get_platdata()
786 cable->edev = ext_id; in ci_get_platdata()
789 ret = extcon_get_state(cable->edev, EXTCON_USB_HOST); in ci_get_platdata()
791 cable->connected = true; in ci_get_platdata()
793 cable->connected = false; in ci_get_platdata()
796 if (device_property_read_bool(dev, "usb-role-switch")) in ci_get_platdata()
797 ci_role_switch.fwnode = dev->fwnode; in ci_get_platdata()
799 platdata->pctl = devm_pinctrl_get(dev); in ci_get_platdata()
800 if (!IS_ERR(platdata->pctl)) { in ci_get_platdata()
803 p = pinctrl_lookup_state(platdata->pctl, "default"); in ci_get_platdata()
805 platdata->pins_default = p; in ci_get_platdata()
807 p = pinctrl_lookup_state(platdata->pctl, "host"); in ci_get_platdata()
809 platdata->pins_host = p; in ci_get_platdata()
811 p = pinctrl_lookup_state(platdata->pctl, "device"); in ci_get_platdata()
813 platdata->pins_device = p; in ci_get_platdata()
816 if (!platdata->enter_lpm) in ci_get_platdata()
817 platdata->enter_lpm = ci_hdrc_enter_lpm_common; in ci_get_platdata()
827 id = &ci->platdata->id_extcon; in ci_extcon_register()
828 id->ci = ci; in ci_extcon_register()
829 if (!IS_ERR_OR_NULL(id->edev)) { in ci_extcon_register()
830 ret = devm_extcon_register_notifier(ci->dev, id->edev, in ci_extcon_register()
831 EXTCON_USB_HOST, &id->nb); in ci_extcon_register()
833 dev_err(ci->dev, "register ID failed\n"); in ci_extcon_register()
838 vbus = &ci->platdata->vbus_extcon; in ci_extcon_register()
839 vbus->ci = ci; in ci_extcon_register()
840 if (!IS_ERR_OR_NULL(vbus->edev)) { in ci_extcon_register()
841 ret = devm_extcon_register_notifier(ci->dev, vbus->edev, in ci_extcon_register()
842 EXTCON_USB, &vbus->nb); in ci_extcon_register()
844 dev_err(ci->dev, "register VBUS failed\n"); in ci_extcon_register()
871 ret = -ENOMEM; in ci_hdrc_add_device()
875 pdev->dev.parent = dev; in ci_hdrc_add_device()
876 device_set_of_node_from_dev(&pdev->dev, dev); in ci_hdrc_add_device()
902 int id = pdev->id; in ci_hdrc_remove_device()
924 if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) in ci_hdrc_query_available_role()
926 else if (ci->roles[CI_ROLE_HOST]) in ci_hdrc_query_available_role()
928 else if (ci->roles[CI_ROLE_GADGET]) in ci_hdrc_query_available_role()
939 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) in ci_role_destroy()
945 if (ci->platdata->flags & CI_HDRC_DUAL_ROLE_NOT_OTG) in ci_get_otg_capable()
946 ci->is_otg = false; in ci_get_otg_capable()
948 ci->is_otg = (hw_read(ci, CAP_DCCPARAMS, in ci_get_otg_capable()
951 if (ci->is_otg) { in ci_get_otg_capable()
952 dev_dbg(ci->dev, "It is OTG capable controller\n"); in ci_get_otg_capable()
964 if (ci->role != CI_ROLE_END) in role_show()
965 return sprintf(buf, "%s\n", ci_role(ci)->name); in role_show()
977 if (!(ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET])) { in role_store()
978 dev_warn(dev, "Current configuration is not dual-role, quit\n"); in role_store()
979 return -EPERM; in role_store()
983 if (!strncmp(buf, ci->roles[role]->name, in role_store()
984 strlen(ci->roles[role]->name))) in role_store()
988 return -EINVAL; in role_store()
990 mutex_lock(&ci->mutex); in role_store()
992 if (role == ci->role) { in role_store()
993 mutex_unlock(&ci->mutex); in role_store()
998 disable_irq(ci->irq); in role_store()
1001 if (!ret && ci->role == CI_ROLE_GADGET) in role_store()
1003 enable_irq(ci->irq); in role_store()
1005 mutex_unlock(&ci->mutex); in role_store()
1019 struct device *dev = &pdev->dev; in ci_hdrc_probe()
1028 return -ENODEV; in ci_hdrc_probe()
1037 return -ENOMEM; in ci_hdrc_probe()
1039 spin_lock_init(&ci->lock); in ci_hdrc_probe()
1040 mutex_init(&ci->mutex); in ci_hdrc_probe()
1041 ci->dev = dev; in ci_hdrc_probe()
1042 ci->platdata = dev_get_platdata(dev); in ci_hdrc_probe()
1043 ci->imx28_write_fix = !!(ci->platdata->flags & in ci_hdrc_probe()
1045 ci->supports_runtime_pm = !!(ci->platdata->flags & in ci_hdrc_probe()
1047 ci->has_portsc_pec_bug = !!(ci->platdata->flags & in ci_hdrc_probe()
1054 return -ENODEV; in ci_hdrc_probe()
1061 if (ci->platdata->phy) { in ci_hdrc_probe()
1062 ci->phy = ci->platdata->phy; in ci_hdrc_probe()
1063 } else if (ci->platdata->usb_phy) { in ci_hdrc_probe()
1064 ci->usb_phy = ci->platdata->usb_phy; in ci_hdrc_probe()
1067 ci->phy = devm_phy_get(dev->parent, "usb-phy"); in ci_hdrc_probe()
1069 if (PTR_ERR(ci->phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1070 ret = -EPROBE_DEFER; in ci_hdrc_probe()
1072 } else if (IS_ERR(ci->phy)) { in ci_hdrc_probe()
1073 ci->phy = NULL; in ci_hdrc_probe()
1076 /* Look for a legacy USB PHY from device-tree next */ in ci_hdrc_probe()
1077 if (!ci->phy) { in ci_hdrc_probe()
1078 ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent, in ci_hdrc_probe()
1081 if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1082 ret = -EPROBE_DEFER; in ci_hdrc_probe()
1084 } else if (IS_ERR(ci->usb_phy)) { in ci_hdrc_probe()
1085 ci->usb_phy = NULL; in ci_hdrc_probe()
1090 if (!ci->phy && !ci->usb_phy) { in ci_hdrc_probe()
1091 ci->usb_phy = devm_usb_get_phy(dev->parent, in ci_hdrc_probe()
1094 if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1095 ret = -EPROBE_DEFER; in ci_hdrc_probe()
1097 } else if (IS_ERR(ci->usb_phy)) { in ci_hdrc_probe()
1098 ci->usb_phy = NULL; in ci_hdrc_probe()
1103 if (!ci->phy && !ci->usb_phy) { in ci_hdrc_probe()
1104 ret = -ENXIO; in ci_hdrc_probe()
1115 ci->hw_bank.phys = res->start; in ci_hdrc_probe()
1117 ci->irq = platform_get_irq(pdev, 0); in ci_hdrc_probe()
1118 if (ci->irq < 0) { in ci_hdrc_probe()
1119 ret = ci->irq; in ci_hdrc_probe()
1125 dr_mode = ci->platdata->dr_mode; in ci_hdrc_probe()
1130 if (ret == -ENXIO) in ci_hdrc_probe()
1140 if (ret == -ENXIO) in ci_hdrc_probe()
1147 if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1149 ret = -ENODEV; in ci_hdrc_probe()
1153 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1163 ci->role_switch = usb_role_switch_register(dev, in ci_hdrc_probe()
1165 if (IS_ERR(ci->role_switch)) { in ci_hdrc_probe()
1166 ret = PTR_ERR(ci->role_switch); in ci_hdrc_probe()
1171 ci->role = ci_get_role(ci); in ci_hdrc_probe()
1174 if (ci->role == CI_ROLE_GADGET) { in ci_hdrc_probe()
1180 ret = ci_role_start(ci, ci->role); in ci_hdrc_probe()
1183 ci_role(ci)->name); in ci_hdrc_probe()
1188 ret = devm_request_irq(dev, ci->irq, ci_irq_handler, IRQF_SHARED, in ci_hdrc_probe()
1189 ci->platdata->name, ci); in ci_hdrc_probe()
1197 if (ci->supports_runtime_pm) { in ci_hdrc_probe()
1198 pm_runtime_set_active(&pdev->dev); in ci_hdrc_probe()
1199 pm_runtime_enable(&pdev->dev); in ci_hdrc_probe()
1200 pm_runtime_set_autosuspend_delay(&pdev->dev, 2000); in ci_hdrc_probe()
1201 pm_runtime_mark_last_busy(ci->dev); in ci_hdrc_probe()
1202 pm_runtime_use_autosuspend(&pdev->dev); in ci_hdrc_probe()
1208 device_set_wakeup_capable(&pdev->dev, true); in ci_hdrc_probe()
1214 if (ci->role_switch) in ci_hdrc_probe()
1215 usb_role_switch_unregister(ci->role_switch); in ci_hdrc_probe()
1217 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) in ci_hdrc_probe()
1235 if (ci->role_switch) in ci_hdrc_remove()
1236 usb_role_switch_unregister(ci->role_switch); in ci_hdrc_remove()
1238 if (ci->supports_runtime_pm) { in ci_hdrc_remove()
1239 pm_runtime_get_sync(&pdev->dev); in ci_hdrc_remove()
1240 pm_runtime_disable(&pdev->dev); in ci_hdrc_remove()
1241 pm_runtime_put_noidle(&pdev->dev); in ci_hdrc_remove()
1252 /* Prepare wakeup by SRP before suspend */
1255 if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) && in ci_otg_fsm_suspend_for_srp()
1264 /* Handle SRP when wakeup by data pulse */
1267 if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) && in ci_otg_fsm_wakeup_by_srp()
1268 (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) { in ci_otg_fsm_wakeup_by_srp()
1270 ci->fsm.a_srp_det = 1; in ci_otg_fsm_wakeup_by_srp()
1271 ci->fsm.a_bus_drop = 0; in ci_otg_fsm_wakeup_by_srp()
1273 ci->fsm.id = 1; in ci_otg_fsm_wakeup_by_srp()
1281 disable_irq(ci->irq); in ci_controller_suspend()
1283 if (ci->platdata->phy_clkgate_delay_us) in ci_controller_suspend()
1284 usleep_range(ci->platdata->phy_clkgate_delay_us, in ci_controller_suspend()
1285 ci->platdata->phy_clkgate_delay_us + 50); in ci_controller_suspend()
1286 usb_phy_set_suspend(ci->usb_phy, 1); in ci_controller_suspend()
1287 ci->in_lpm = true; in ci_controller_suspend()
1288 enable_irq(ci->irq); in ci_controller_suspend()
1302 cable_id = &ci->platdata->id_extcon; in ci_extcon_wakeup_int()
1303 cable_vbus = &ci->platdata->vbus_extcon; in ci_extcon_wakeup_int()
1305 if ((!IS_ERR(cable_id->edev) || ci->role_switch) in ci_extcon_wakeup_int()
1306 && ci->is_otg && in ci_extcon_wakeup_int()
1310 if ((!IS_ERR(cable_vbus->edev) || ci->role_switch) in ci_extcon_wakeup_int()
1311 && ci->is_otg && in ci_extcon_wakeup_int()
1323 if (!ci->in_lpm) { in ci_controller_resume()
1334 if (ci->usb_phy) { in ci_controller_resume()
1335 usb_phy_set_suspend(ci->usb_phy, 0); in ci_controller_resume()
1336 usb_phy_set_wakeup(ci->usb_phy, false); in ci_controller_resume()
1340 ci->in_lpm = false; in ci_controller_resume()
1341 if (ci->wakeup_int) { in ci_controller_resume()
1342 ci->wakeup_int = false; in ci_controller_resume()
1343 pm_runtime_mark_last_busy(ci->dev); in ci_controller_resume()
1344 pm_runtime_put_autosuspend(ci->dev); in ci_controller_resume()
1345 enable_irq(ci->irq); in ci_controller_resume()
1359 if (ci->wq) in ci_suspend()
1360 flush_workqueue(ci->wq); in ci_suspend()
1367 if (ci->in_lpm) in ci_suspend()
1370 if (ci->in_lpm) { in ci_suspend()
1376 if (ci->role != CI_ROLE_END && ci_role(ci)->suspend) in ci_suspend()
1377 ci_role(ci)->suspend(ci); in ci_suspend()
1383 usb_phy_set_wakeup(ci->usb_phy, true); in ci_suspend()
1384 enable_irq_wake(ci->irq); in ci_suspend()
1396 disable_irq_nosync(ci->irq); in ci_handle_power_lost()
1400 if (ci->role != role) { in ci_handle_power_lost()
1403 if (ci->is_otg && hw_read_otgsc(ci, OTGSC_BSV)) in ci_handle_power_lost()
1404 usb_gadget_vbus_connect(&ci->gadget); in ci_handle_power_lost()
1408 enable_irq(ci->irq); in ci_handle_power_lost()
1425 disable_irq_wake(ci->irq); in ci_resume()
1432 /* shutdown and re-init for phy */ in ci_resume()
1438 if (ci->role != CI_ROLE_END && ci_role(ci)->resume) in ci_resume()
1439 ci_role(ci)->resume(ci, power_lost); in ci_resume()
1444 if (ci->supports_runtime_pm) { in ci_resume()
1460 if (ci->in_lpm) { in ci_runtime_suspend()
1468 usb_phy_set_wakeup(ci->usb_phy, true); in ci_runtime_suspend()