Lines Matching +full:tpl +full:- +full:support
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>
103 ci->hw_bank.regmap[i] = in hw_alloc_regmap()
104 (i <= CAP_LAST ? ci->hw_bank.cap : ci->hw_bank.op) + in hw_alloc_regmap()
108 ci->hw_bank.regmap[i] = ci->hw_bank.op + in hw_alloc_regmap()
109 4 * (i - OP_ENDPTCTRL) + in hw_alloc_regmap()
168 return -EINVAL; in hw_port_test_set()
200 enum ci_hw_regs reg = ci->hw_bank.lpm ? OP_DEVLC : OP_PORTSC; in ci_hdrc_enter_lpm_common()
201 bool lpm = !!(hw_read(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm))); in ci_hdrc_enter_lpm_common()
204 hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm), in ci_hdrc_enter_lpm_common()
205 PORTSC_PHCD(ci->hw_bank.lpm)); in ci_hdrc_enter_lpm_common()
207 hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm), in ci_hdrc_enter_lpm_common()
213 return ci->platdata->enter_lpm(ci, enable); in ci_hdrc_enter_lpm()
221 ci->hw_bank.abs = base; in hw_device_init()
223 ci->hw_bank.cap = ci->hw_bank.abs; in hw_device_init()
224 ci->hw_bank.cap += ci->platdata->capoffset; in hw_device_init()
225 ci->hw_bank.op = ci->hw_bank.cap + (ioread32(ci->hw_bank.cap) & 0xff); in hw_device_init()
230 ci->hw_bank.lpm = reg; in hw_device_init()
233 ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs; in hw_device_init()
234 ci->hw_bank.size += OP_LAST; in hw_device_init()
235 ci->hw_bank.size /= sizeof(u32); in hw_device_init()
239 ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */ in hw_device_init()
241 if (ci->hw_ep_max > ENDPT_MAX) in hw_device_init()
242 return -ENODEV; in hw_device_init()
252 ci->rev = ci_get_revision(ci); in hw_device_init()
254 dev_dbg(ci->dev, in hw_device_init()
256 ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op); in hw_device_init()
271 switch (ci->platdata->phy_mode) { in hw_phymode_configure()
297 if (ci->hw_bank.lpm) { in hw_phymode_configure()
320 if (ci->phy) { in _ci_usb_phy_init()
321 ret = phy_init(ci->phy); in _ci_usb_phy_init()
325 ret = phy_power_on(ci->phy); in _ci_usb_phy_init()
327 phy_exit(ci->phy); in _ci_usb_phy_init()
331 ret = usb_phy_init(ci->usb_phy); in _ci_usb_phy_init()
344 if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL) in ci_usb_phy_exit()
347 if (ci->phy) { in ci_usb_phy_exit()
348 phy_power_off(ci->phy); in ci_usb_phy_exit()
349 phy_exit(ci->phy); in ci_usb_phy_exit()
351 usb_phy_shutdown(ci->usb_phy); in ci_usb_phy_exit()
365 if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL) in ci_usb_phy_init()
368 switch (ci->platdata->phy_mode) { in ci_usb_phy_init()
409 phy_set_mode(ci->phy, PHY_MODE_USB_DEVICE); in ci_platform_configure()
411 if (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING) in ci_platform_configure()
417 phy_set_mode(ci->phy, PHY_MODE_USB_HOST); in ci_platform_configure()
419 if (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING) in ci_platform_configure()
424 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) { in ci_platform_configure()
425 if (ci->hw_bank.lpm) in ci_platform_configure()
431 if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA) in ci_platform_configure()
434 hw_write(ci, OP_USBCMD, 0xff0000, ci->platdata->itc_setting << 16); in ci_platform_configure()
436 if (ci->platdata->flags & CI_HDRC_OVERRIDE_AHB_BURST) in ci_platform_configure()
438 ci->platdata->ahb_burst_config); in ci_platform_configure()
442 if (ci->platdata->flags & CI_HDRC_OVERRIDE_TX_BURST) in ci_platform_configure()
444 ci->platdata->tx_burst_size << __ffs(TX_BURST_MASK)); in ci_platform_configure()
446 if (ci->platdata->flags & CI_HDRC_OVERRIDE_RX_BURST) in ci_platform_configure()
448 ci->platdata->rx_burst_size); in ci_platform_configure()
466 return -ETIMEDOUT; in hw_controller_reset()
488 dev_err(ci->dev, "error resetting controller, ret=%d\n", ret); in hw_device_reset()
492 if (ci->platdata->notify_event) { in hw_device_reset()
493 ret = ci->platdata->notify_event(ci, in hw_device_reset()
506 dev_err(ci->dev, "cannot enter in %s device mode\n", in hw_device_reset()
507 ci_role(ci)->name); in hw_device_reset()
508 dev_err(ci->dev, "lpm = %i\n", ci->hw_bank.lpm); in hw_device_reset()
509 return -ENODEV; in hw_device_reset()
523 if (ci->in_lpm) { in ci_irq()
525 ci->wakeup_int = true; in ci_irq()
526 pm_runtime_get(ci->dev); in ci_irq()
530 if (ci->is_otg) { in ci_irq()
543 if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) { in ci_irq()
544 ci->id_event = true; in ci_irq()
555 if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) { in ci_irq()
556 ci->b_sess_valid_event = true; in ci_irq()
564 if (ci->role != CI_ROLE_END) in ci_irq()
565 ret = ci_role(ci)->irq(ci); in ci_irq()
574 struct ci_hdrc *ci = cbl->ci; in ci_cable_notifier()
576 cbl->connected = event; in ci_cable_notifier()
577 cbl->changed = true; in ci_cable_notifier()
579 ci_irq(ci->irq, ci); in ci_cable_notifier()
589 spin_lock_irqsave(&ci->lock, flags); in ci_usb_role_switch_get()
591 spin_unlock_irqrestore(&ci->lock, flags); in ci_usb_role_switch_get()
605 if ((ci_role != CI_ROLE_END && !ci->roles[ci_role]) || in ci_usb_role_switch_set()
609 pm_runtime_get_sync(ci->dev); in ci_usb_role_switch_set()
611 spin_lock_irqsave(&ci->lock, flags); in ci_usb_role_switch_set()
613 cable = &ci->platdata->vbus_extcon; in ci_usb_role_switch_set()
615 cable = &ci->platdata->id_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()
620 ci_irq(ci->irq, ci); in ci_usb_role_switch_set()
621 spin_unlock_irqrestore(&ci->lock, flags); in ci_usb_role_switch_set()
622 if (ci->wq && role != USB_ROLE_NONE) in ci_usb_role_switch_set()
623 flush_workqueue(ci->wq); in ci_usb_role_switch_set()
624 spin_lock_irqsave(&ci->lock, flags); in ci_usb_role_switch_set()
631 cable = &ci->platdata->vbus_extcon; in ci_usb_role_switch_set()
633 cable = &ci->platdata->id_extcon; in ci_usb_role_switch_set()
636 cable->changed = true; in ci_usb_role_switch_set()
637 cable->connected = true; in ci_usb_role_switch_set()
638 ci_irq(ci->irq, ci); in ci_usb_role_switch_set()
640 spin_unlock_irqrestore(&ci->lock, flags); in ci_usb_role_switch_set()
641 pm_runtime_put_sync(ci->dev); in ci_usb_role_switch_set()
659 if (!platdata->phy_mode) in ci_get_platdata()
660 platdata->phy_mode = of_usb_get_phy_mode(dev->of_node); in ci_get_platdata()
662 if (!platdata->dr_mode) in ci_get_platdata()
663 platdata->dr_mode = usb_get_dr_mode(dev); in ci_get_platdata()
665 if (platdata->dr_mode == USB_DR_MODE_UNKNOWN) in ci_get_platdata()
666 platdata->dr_mode = USB_DR_MODE_OTG; in ci_get_platdata()
668 if (platdata->dr_mode != USB_DR_MODE_PERIPHERAL) { in ci_get_platdata()
670 platdata->reg_vbus = devm_regulator_get_optional(dev, "vbus"); in ci_get_platdata()
671 if (PTR_ERR(platdata->reg_vbus) == -EPROBE_DEFER) { in ci_get_platdata()
672 return -EPROBE_DEFER; in ci_get_platdata()
673 } else if (PTR_ERR(platdata->reg_vbus) == -ENODEV) { in ci_get_platdata()
675 platdata->reg_vbus = NULL; in ci_get_platdata()
676 } else if (IS_ERR(platdata->reg_vbus)) { in ci_get_platdata()
678 PTR_ERR(platdata->reg_vbus)); in ci_get_platdata()
679 return PTR_ERR(platdata->reg_vbus); in ci_get_platdata()
681 /* Get TPL support */ in ci_get_platdata()
682 if (!platdata->tpl_support) in ci_get_platdata()
683 platdata->tpl_support = in ci_get_platdata()
684 of_usb_host_tpl_support(dev->of_node); in ci_get_platdata()
687 if (platdata->dr_mode == USB_DR_MODE_OTG) { in ci_get_platdata()
688 /* We can support HNP and SRP of OTG 2.0 */ in ci_get_platdata()
689 platdata->ci_otg_caps.otg_rev = 0x0200; in ci_get_platdata()
690 platdata->ci_otg_caps.hnp_support = true; in ci_get_platdata()
691 platdata->ci_otg_caps.srp_support = true; in ci_get_platdata()
694 ret = of_usb_update_otg_caps(dev->of_node, in ci_get_platdata()
695 &platdata->ci_otg_caps); in ci_get_platdata()
701 platdata->flags |= CI_HDRC_FORCE_FULLSPEED; in ci_get_platdata()
703 of_property_read_u32(dev->of_node, "phy-clkgate-delay-us", in ci_get_platdata()
704 &platdata->phy_clkgate_delay_us); in ci_get_platdata()
706 platdata->itc_setting = 1; in ci_get_platdata()
708 of_property_read_u32(dev->of_node, "itc-setting", in ci_get_platdata()
709 &platdata->itc_setting); in ci_get_platdata()
711 ret = of_property_read_u32(dev->of_node, "ahb-burst-config", in ci_get_platdata()
712 &platdata->ahb_burst_config); in ci_get_platdata()
714 platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST; in ci_get_platdata()
715 } else if (ret != -EINVAL) { in ci_get_platdata()
716 dev_err(dev, "failed to get ahb-burst-config\n"); in ci_get_platdata()
720 ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword", in ci_get_platdata()
721 &platdata->tx_burst_size); in ci_get_platdata()
723 platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST; in ci_get_platdata()
724 } else if (ret != -EINVAL) { in ci_get_platdata()
725 dev_err(dev, "failed to get tx-burst-size-dword\n"); in ci_get_platdata()
729 ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword", in ci_get_platdata()
730 &platdata->rx_burst_size); in ci_get_platdata()
732 platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST; in ci_get_platdata()
733 } else if (ret != -EINVAL) { in ci_get_platdata()
734 dev_err(dev, "failed to get rx-burst-size-dword\n"); in ci_get_platdata()
738 if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL)) in ci_get_platdata()
739 platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA; in ci_get_platdata()
741 ext_id = ERR_PTR(-ENODEV); in ci_get_platdata()
742 ext_vbus = ERR_PTR(-ENODEV); in ci_get_platdata()
743 if (of_property_read_bool(dev->of_node, "extcon")) { in ci_get_platdata()
746 if (IS_ERR(ext_vbus) && PTR_ERR(ext_vbus) != -ENODEV) in ci_get_platdata()
750 if (IS_ERR(ext_id) && PTR_ERR(ext_id) != -ENODEV) in ci_get_platdata()
754 cable = &platdata->vbus_extcon; in ci_get_platdata()
755 cable->nb.notifier_call = ci_cable_notifier; in ci_get_platdata()
756 cable->edev = ext_vbus; in ci_get_platdata()
759 ret = extcon_get_state(cable->edev, EXTCON_USB); in ci_get_platdata()
761 cable->connected = true; in ci_get_platdata()
763 cable->connected = false; in ci_get_platdata()
766 cable = &platdata->id_extcon; in ci_get_platdata()
767 cable->nb.notifier_call = ci_cable_notifier; in ci_get_platdata()
768 cable->edev = ext_id; in ci_get_platdata()
771 ret = extcon_get_state(cable->edev, EXTCON_USB_HOST); in ci_get_platdata()
773 cable->connected = true; in ci_get_platdata()
775 cable->connected = false; in ci_get_platdata()
778 if (device_property_read_bool(dev, "usb-role-switch")) in ci_get_platdata()
779 ci_role_switch.fwnode = dev->fwnode; in ci_get_platdata()
781 platdata->pctl = devm_pinctrl_get(dev); in ci_get_platdata()
782 if (!IS_ERR(platdata->pctl)) { in ci_get_platdata()
785 p = pinctrl_lookup_state(platdata->pctl, "default"); in ci_get_platdata()
787 platdata->pins_default = p; in ci_get_platdata()
789 p = pinctrl_lookup_state(platdata->pctl, "host"); in ci_get_platdata()
791 platdata->pins_host = p; in ci_get_platdata()
793 p = pinctrl_lookup_state(platdata->pctl, "device"); in ci_get_platdata()
795 platdata->pins_device = p; in ci_get_platdata()
798 if (!platdata->enter_lpm) in ci_get_platdata()
799 platdata->enter_lpm = ci_hdrc_enter_lpm_common; in ci_get_platdata()
809 id = &ci->platdata->id_extcon; in ci_extcon_register()
810 id->ci = ci; in ci_extcon_register()
811 if (!IS_ERR_OR_NULL(id->edev)) { in ci_extcon_register()
812 ret = devm_extcon_register_notifier(ci->dev, id->edev, in ci_extcon_register()
813 EXTCON_USB_HOST, &id->nb); in ci_extcon_register()
815 dev_err(ci->dev, "register ID failed\n"); in ci_extcon_register()
820 vbus = &ci->platdata->vbus_extcon; in ci_extcon_register()
821 vbus->ci = ci; in ci_extcon_register()
822 if (!IS_ERR_OR_NULL(vbus->edev)) { in ci_extcon_register()
823 ret = devm_extcon_register_notifier(ci->dev, vbus->edev, in ci_extcon_register()
824 EXTCON_USB, &vbus->nb); in ci_extcon_register()
826 dev_err(ci->dev, "register VBUS failed\n"); in ci_extcon_register()
853 ret = -ENOMEM; in ci_hdrc_add_device()
857 pdev->dev.parent = dev; in ci_hdrc_add_device()
883 int id = pdev->id; in ci_hdrc_remove_device()
905 if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) in ci_hdrc_query_available_role()
907 else if (ci->roles[CI_ROLE_HOST]) in ci_hdrc_query_available_role()
909 else if (ci->roles[CI_ROLE_GADGET]) in ci_hdrc_query_available_role()
920 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) in ci_role_destroy()
926 if (ci->platdata->flags & CI_HDRC_DUAL_ROLE_NOT_OTG) in ci_get_otg_capable()
927 ci->is_otg = false; in ci_get_otg_capable()
929 ci->is_otg = (hw_read(ci, CAP_DCCPARAMS, in ci_get_otg_capable()
932 if (ci->is_otg) { in ci_get_otg_capable()
933 dev_dbg(ci->dev, "It is OTG capable controller\n"); in ci_get_otg_capable()
945 if (ci->role != CI_ROLE_END) in role_show()
946 return sprintf(buf, "%s\n", ci_role(ci)->name); in role_show()
958 if (!(ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET])) { in role_store()
959 dev_warn(dev, "Current configuration is not dual-role, quit\n"); in role_store()
960 return -EPERM; in role_store()
964 if (!strncmp(buf, ci->roles[role]->name, in role_store()
965 strlen(ci->roles[role]->name))) in role_store()
968 if (role == CI_ROLE_END || role == ci->role) in role_store()
969 return -EINVAL; in role_store()
972 disable_irq(ci->irq); in role_store()
975 if (!ret && ci->role == CI_ROLE_GADGET) in role_store()
977 enable_irq(ci->irq); in role_store()
992 struct device *dev = &pdev->dev; in ci_hdrc_probe()
1001 return -ENODEV; in ci_hdrc_probe()
1011 return -ENOMEM; in ci_hdrc_probe()
1013 spin_lock_init(&ci->lock); in ci_hdrc_probe()
1014 ci->dev = dev; in ci_hdrc_probe()
1015 ci->platdata = dev_get_platdata(dev); in ci_hdrc_probe()
1016 ci->imx28_write_fix = !!(ci->platdata->flags & in ci_hdrc_probe()
1018 ci->supports_runtime_pm = !!(ci->platdata->flags & in ci_hdrc_probe()
1025 return -ENODEV; in ci_hdrc_probe()
1032 if (ci->platdata->phy) { in ci_hdrc_probe()
1033 ci->phy = ci->platdata->phy; in ci_hdrc_probe()
1034 } else if (ci->platdata->usb_phy) { in ci_hdrc_probe()
1035 ci->usb_phy = ci->platdata->usb_phy; in ci_hdrc_probe()
1038 ci->phy = devm_phy_get(dev->parent, "usb-phy"); in ci_hdrc_probe()
1040 if (PTR_ERR(ci->phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1041 ret = -EPROBE_DEFER; in ci_hdrc_probe()
1043 } else if (IS_ERR(ci->phy)) { in ci_hdrc_probe()
1044 ci->phy = NULL; in ci_hdrc_probe()
1047 /* Look for a legacy USB PHY from device-tree next */ in ci_hdrc_probe()
1048 if (!ci->phy) { in ci_hdrc_probe()
1049 ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent, in ci_hdrc_probe()
1052 if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1053 ret = -EPROBE_DEFER; in ci_hdrc_probe()
1055 } else if (IS_ERR(ci->usb_phy)) { in ci_hdrc_probe()
1056 ci->usb_phy = NULL; in ci_hdrc_probe()
1061 if (!ci->phy && !ci->usb_phy) { in ci_hdrc_probe()
1062 ci->usb_phy = devm_usb_get_phy(dev->parent, in ci_hdrc_probe()
1065 if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1066 ret = -EPROBE_DEFER; in ci_hdrc_probe()
1068 } else if (IS_ERR(ci->usb_phy)) { in ci_hdrc_probe()
1069 ci->usb_phy = NULL; in ci_hdrc_probe()
1074 if (!ci->phy && !ci->usb_phy) { in ci_hdrc_probe()
1075 ret = -ENXIO; in ci_hdrc_probe()
1086 ci->hw_bank.phys = res->start; in ci_hdrc_probe()
1088 ci->irq = platform_get_irq(pdev, 0); in ci_hdrc_probe()
1089 if (ci->irq < 0) { in ci_hdrc_probe()
1090 ret = ci->irq; in ci_hdrc_probe()
1096 dr_mode = ci->platdata->dr_mode; in ci_hdrc_probe()
1101 if (ret == -ENXIO) in ci_hdrc_probe()
1102 dev_info(dev, "doesn't support host\n"); in ci_hdrc_probe()
1111 if (ret == -ENXIO) in ci_hdrc_probe()
1112 dev_info(dev, "doesn't support gadget\n"); in ci_hdrc_probe()
1118 if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1120 ret = -ENODEV; in ci_hdrc_probe()
1124 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1134 ci->role_switch = usb_role_switch_register(dev, in ci_hdrc_probe()
1136 if (IS_ERR(ci->role_switch)) { in ci_hdrc_probe()
1137 ret = PTR_ERR(ci->role_switch); in ci_hdrc_probe()
1142 if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1143 if (ci->is_otg) { in ci_hdrc_probe()
1144 ci->role = ci_otg_role(ci); in ci_hdrc_probe()
1149 * If the controller is not OTG capable, but support in ci_hdrc_probe()
1153 ci->role = CI_ROLE_GADGET; in ci_hdrc_probe()
1156 ci->role = ci->roles[CI_ROLE_HOST] in ci_hdrc_probe()
1163 if (ci->role == CI_ROLE_GADGET) { in ci_hdrc_probe()
1169 ret = ci_role_start(ci, ci->role); in ci_hdrc_probe()
1172 ci_role(ci)->name); in ci_hdrc_probe()
1177 ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED, in ci_hdrc_probe()
1178 ci->platdata->name, ci); in ci_hdrc_probe()
1186 if (ci->supports_runtime_pm) { in ci_hdrc_probe()
1187 pm_runtime_set_active(&pdev->dev); in ci_hdrc_probe()
1188 pm_runtime_enable(&pdev->dev); in ci_hdrc_probe()
1189 pm_runtime_set_autosuspend_delay(&pdev->dev, 2000); in ci_hdrc_probe()
1190 pm_runtime_mark_last_busy(ci->dev); in ci_hdrc_probe()
1191 pm_runtime_use_autosuspend(&pdev->dev); in ci_hdrc_probe()
1197 device_set_wakeup_capable(&pdev->dev, true); in ci_hdrc_probe()
1203 if (ci->role_switch) in ci_hdrc_probe()
1204 usb_role_switch_unregister(ci->role_switch); in ci_hdrc_probe()
1206 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) in ci_hdrc_probe()
1224 if (ci->role_switch) in ci_hdrc_remove()
1225 usb_role_switch_unregister(ci->role_switch); in ci_hdrc_remove()
1227 if (ci->supports_runtime_pm) { in ci_hdrc_remove()
1228 pm_runtime_get_sync(&pdev->dev); in ci_hdrc_remove()
1229 pm_runtime_disable(&pdev->dev); in ci_hdrc_remove()
1230 pm_runtime_put_noidle(&pdev->dev); in ci_hdrc_remove()
1246 if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) && in ci_otg_fsm_suspend_for_srp()
1258 if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) && in ci_otg_fsm_wakeup_by_srp()
1259 (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) { in ci_otg_fsm_wakeup_by_srp()
1261 ci->fsm.a_srp_det = 1; in ci_otg_fsm_wakeup_by_srp()
1262 ci->fsm.a_bus_drop = 0; in ci_otg_fsm_wakeup_by_srp()
1264 ci->fsm.id = 1; in ci_otg_fsm_wakeup_by_srp()
1272 disable_irq(ci->irq); in ci_controller_suspend()
1274 if (ci->platdata->phy_clkgate_delay_us) in ci_controller_suspend()
1275 usleep_range(ci->platdata->phy_clkgate_delay_us, in ci_controller_suspend()
1276 ci->platdata->phy_clkgate_delay_us + 50); in ci_controller_suspend()
1277 usb_phy_set_suspend(ci->usb_phy, 1); in ci_controller_suspend()
1278 ci->in_lpm = true; in ci_controller_suspend()
1279 enable_irq(ci->irq); in ci_controller_suspend()
1293 cable_id = &ci->platdata->id_extcon; in ci_extcon_wakeup_int()
1294 cable_vbus = &ci->platdata->vbus_extcon; in ci_extcon_wakeup_int()
1296 if (!IS_ERR(cable_id->edev) && ci->is_otg && in ci_extcon_wakeup_int()
1298 ci_irq(ci->irq, ci); in ci_extcon_wakeup_int()
1300 if (!IS_ERR(cable_vbus->edev) && ci->is_otg && in ci_extcon_wakeup_int()
1302 ci_irq(ci->irq, ci); in ci_extcon_wakeup_int()
1312 if (!ci->in_lpm) { in ci_controller_resume()
1323 if (ci->usb_phy) { in ci_controller_resume()
1324 usb_phy_set_suspend(ci->usb_phy, 0); in ci_controller_resume()
1325 usb_phy_set_wakeup(ci->usb_phy, false); in ci_controller_resume()
1329 ci->in_lpm = false; in ci_controller_resume()
1330 if (ci->wakeup_int) { in ci_controller_resume()
1331 ci->wakeup_int = false; in ci_controller_resume()
1332 pm_runtime_mark_last_busy(ci->dev); in ci_controller_resume()
1333 pm_runtime_put_autosuspend(ci->dev); in ci_controller_resume()
1334 enable_irq(ci->irq); in ci_controller_resume()
1348 if (ci->wq) in ci_suspend()
1349 flush_workqueue(ci->wq); in ci_suspend()
1356 if (ci->in_lpm) in ci_suspend()
1359 if (ci->in_lpm) { in ci_suspend()
1368 usb_phy_set_wakeup(ci->usb_phy, true); in ci_suspend()
1369 enable_irq_wake(ci->irq); in ci_suspend()
1383 disable_irq_wake(ci->irq); in ci_resume()
1389 if (ci->supports_runtime_pm) { in ci_resume()
1405 if (ci->in_lpm) { in ci_runtime_suspend()
1413 usb_phy_set_wakeup(ci->usb_phy, true); in ci_runtime_suspend()