• Home
  • Raw
  • Download

Lines Matching refs:ci

124 static void hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)  in hw_alloc_regmap()  argument
129 ci->hw_bank.regmap[i] = in hw_alloc_regmap()
130 (i <= CAP_LAST ? ci->hw_bank.cap : ci->hw_bank.op) + in hw_alloc_regmap()
134 ci->hw_bank.regmap[i] = ci->hw_bank.op + in hw_alloc_regmap()
142 static enum ci_revision ci_get_revision(struct ci_hdrc *ci) in ci_get_revision() argument
144 int ver = hw_read_id_reg(ci, ID_ID, VERSION) >> __ffs(VERSION); in ci_get_revision()
148 rev = hw_read_id_reg(ci, ID_ID, REVISION) in ci_get_revision()
165 u32 hw_read_intr_enable(struct ci_hdrc *ci) in hw_read_intr_enable() argument
167 return hw_read(ci, OP_USBINTR, ~0); in hw_read_intr_enable()
177 u32 hw_read_intr_status(struct ci_hdrc *ci) in hw_read_intr_status() argument
179 return hw_read(ci, OP_USBSTS, ~0); in hw_read_intr_status()
188 int hw_port_test_set(struct ci_hdrc *ci, u8 mode) in hw_port_test_set() argument
195 hw_write(ci, OP_PORTSC, PORTSC_PTC, mode << __ffs(PORTSC_PTC)); in hw_port_test_set()
206 u8 hw_port_test_get(struct ci_hdrc *ci) in hw_port_test_get() argument
208 return hw_read(ci, OP_PORTSC, PORTSC_PTC) >> __ffs(PORTSC_PTC); in hw_port_test_get()
223 static void ci_hdrc_enter_lpm(struct ci_hdrc *ci, bool enable) in ci_hdrc_enter_lpm() argument
225 enum ci_hw_regs reg = ci->hw_bank.lpm ? OP_DEVLC : OP_PORTSC; in ci_hdrc_enter_lpm()
226 bool lpm = !!(hw_read(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm))); in ci_hdrc_enter_lpm()
229 hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm), in ci_hdrc_enter_lpm()
230 PORTSC_PHCD(ci->hw_bank.lpm)); in ci_hdrc_enter_lpm()
232 hw_write(ci, reg, PORTSC_PHCD(ci->hw_bank.lpm), in ci_hdrc_enter_lpm()
236 static int hw_device_init(struct ci_hdrc *ci, void __iomem *base) in hw_device_init() argument
241 ci->hw_bank.abs = base; in hw_device_init()
243 ci->hw_bank.cap = ci->hw_bank.abs; in hw_device_init()
244 ci->hw_bank.cap += ci->platdata->capoffset; in hw_device_init()
245 ci->hw_bank.op = ci->hw_bank.cap + (ioread32(ci->hw_bank.cap) & 0xff); in hw_device_init()
247 hw_alloc_regmap(ci, false); in hw_device_init()
248 reg = hw_read(ci, CAP_HCCPARAMS, HCCPARAMS_LEN) >> in hw_device_init()
250 ci->hw_bank.lpm = reg; in hw_device_init()
252 hw_alloc_regmap(ci, !!reg); in hw_device_init()
253 ci->hw_bank.size = ci->hw_bank.op - ci->hw_bank.abs; in hw_device_init()
254 ci->hw_bank.size += OP_LAST; in hw_device_init()
255 ci->hw_bank.size /= sizeof(u32); in hw_device_init()
257 reg = hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DEN) >> in hw_device_init()
259 ci->hw_ep_max = reg * 2; /* cache hw ENDPT_MAX */ in hw_device_init()
261 if (ci->hw_ep_max > ENDPT_MAX) in hw_device_init()
264 ci_hdrc_enter_lpm(ci, false); in hw_device_init()
267 hw_write(ci, OP_USBINTR, 0xffffffff, 0); in hw_device_init()
270 hw_write(ci, OP_USBSTS, 0xffffffff, 0xffffffff); in hw_device_init()
272 ci->rev = ci_get_revision(ci); in hw_device_init()
274 dev_dbg(ci->dev, in hw_device_init()
276 ci->rev, ci->hw_bank.lpm, ci->hw_bank.cap, ci->hw_bank.op); in hw_device_init()
287 void hw_phymode_configure(struct ci_hdrc *ci) in hw_phymode_configure() argument
291 switch (ci->platdata->phy_mode) { in hw_phymode_configure()
317 if (ci->hw_bank.lpm) { in hw_phymode_configure()
318 hw_write(ci, OP_DEVLC, DEVLC_PTS(7) | DEVLC_PTW, lpm); in hw_phymode_configure()
320 hw_write(ci, OP_DEVLC, DEVLC_STS, DEVLC_STS); in hw_phymode_configure()
322 hw_write(ci, OP_PORTSC, PORTSC_PTS(7) | PORTSC_PTW, portsc); in hw_phymode_configure()
324 hw_write(ci, OP_PORTSC, PORTSC_STS, PORTSC_STS); in hw_phymode_configure()
336 static int _ci_usb_phy_init(struct ci_hdrc *ci) in _ci_usb_phy_init() argument
340 if (ci->phy) { in _ci_usb_phy_init()
341 ret = phy_init(ci->phy); in _ci_usb_phy_init()
345 ret = phy_power_on(ci->phy); in _ci_usb_phy_init()
347 phy_exit(ci->phy); in _ci_usb_phy_init()
351 ret = usb_phy_init(ci->usb_phy); in _ci_usb_phy_init()
362 static void ci_usb_phy_exit(struct ci_hdrc *ci) in ci_usb_phy_exit() argument
364 if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL) in ci_usb_phy_exit()
367 if (ci->phy) { in ci_usb_phy_exit()
368 phy_power_off(ci->phy); in ci_usb_phy_exit()
369 phy_exit(ci->phy); in ci_usb_phy_exit()
371 usb_phy_shutdown(ci->usb_phy); in ci_usb_phy_exit()
381 static int ci_usb_phy_init(struct ci_hdrc *ci) in ci_usb_phy_init() argument
385 if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL) in ci_usb_phy_init()
388 switch (ci->platdata->phy_mode) { in ci_usb_phy_init()
392 ret = _ci_usb_phy_init(ci); in ci_usb_phy_init()
397 hw_phymode_configure(ci); in ci_usb_phy_init()
401 hw_phymode_configure(ci); in ci_usb_phy_init()
402 ret = _ci_usb_phy_init(ci); in ci_usb_phy_init()
407 ret = _ci_usb_phy_init(ci); in ci_usb_phy_init()
421 void ci_platform_configure(struct ci_hdrc *ci) in ci_platform_configure() argument
425 is_device_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_DC; in ci_platform_configure()
426 is_host_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_HC; in ci_platform_configure()
429 phy_set_mode(ci->phy, PHY_MODE_USB_DEVICE); in ci_platform_configure()
431 if (ci->platdata->flags & CI_HDRC_DISABLE_DEVICE_STREAMING) in ci_platform_configure()
432 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, in ci_platform_configure()
437 phy_set_mode(ci->phy, PHY_MODE_USB_HOST); in ci_platform_configure()
439 if (ci->platdata->flags & CI_HDRC_DISABLE_HOST_STREAMING) in ci_platform_configure()
440 hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, in ci_platform_configure()
444 if (ci->platdata->flags & CI_HDRC_FORCE_FULLSPEED) { in ci_platform_configure()
445 if (ci->hw_bank.lpm) in ci_platform_configure()
446 hw_write(ci, OP_DEVLC, DEVLC_PFSC, DEVLC_PFSC); in ci_platform_configure()
448 hw_write(ci, OP_PORTSC, PORTSC_PFSC, PORTSC_PFSC); in ci_platform_configure()
451 if (ci->platdata->flags & CI_HDRC_SET_NON_ZERO_TTHA) in ci_platform_configure()
452 hw_write(ci, OP_TTCTRL, TTCTRL_TTHA_MASK, TTCTRL_TTHA); in ci_platform_configure()
454 hw_write(ci, OP_USBCMD, 0xff0000, ci->platdata->itc_setting << 16); in ci_platform_configure()
456 if (ci->platdata->flags & CI_HDRC_OVERRIDE_AHB_BURST) in ci_platform_configure()
457 hw_write_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK, in ci_platform_configure()
458 ci->platdata->ahb_burst_config); in ci_platform_configure()
461 if (!hw_read_id_reg(ci, ID_SBUSCFG, AHBBRST_MASK)) { in ci_platform_configure()
462 if (ci->platdata->flags & CI_HDRC_OVERRIDE_TX_BURST) in ci_platform_configure()
463 hw_write(ci, OP_BURSTSIZE, TX_BURST_MASK, in ci_platform_configure()
464 ci->platdata->tx_burst_size << __ffs(TX_BURST_MASK)); in ci_platform_configure()
466 if (ci->platdata->flags & CI_HDRC_OVERRIDE_RX_BURST) in ci_platform_configure()
467 hw_write(ci, OP_BURSTSIZE, RX_BURST_MASK, in ci_platform_configure()
468 ci->platdata->rx_burst_size); in ci_platform_configure()
478 static int hw_controller_reset(struct ci_hdrc *ci) in hw_controller_reset() argument
482 hw_write(ci, OP_USBCMD, USBCMD_RST, USBCMD_RST); in hw_controller_reset()
483 while (hw_read(ci, OP_USBCMD, USBCMD_RST)) { in hw_controller_reset()
498 int hw_device_reset(struct ci_hdrc *ci) in hw_device_reset() argument
503 hw_write(ci, OP_ENDPTFLUSH, ~0, ~0); in hw_device_reset()
504 hw_write(ci, OP_USBCMD, USBCMD_RS, 0); in hw_device_reset()
506 ret = hw_controller_reset(ci); in hw_device_reset()
508 dev_err(ci->dev, "error resetting controller, ret=%d\n", ret); in hw_device_reset()
512 if (ci->platdata->notify_event) { in hw_device_reset()
513 ret = ci->platdata->notify_event(ci, in hw_device_reset()
520 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_IDLE); in hw_device_reset()
521 hw_write(ci, OP_USBMODE, USBMODE_CM, USBMODE_CM_DC); in hw_device_reset()
523 hw_write(ci, OP_USBMODE, USBMODE_SLOM, USBMODE_SLOM); in hw_device_reset()
525 if (hw_read(ci, OP_USBMODE, USBMODE_CM) != USBMODE_CM_DC) { in hw_device_reset()
526 dev_err(ci->dev, "cannot enter in %s device mode\n", in hw_device_reset()
527 ci_role(ci)->name); in hw_device_reset()
528 dev_err(ci->dev, "lpm = %i\n", ci->hw_bank.lpm); in hw_device_reset()
532 ci_platform_configure(ci); in hw_device_reset()
539 struct ci_hdrc *ci = data; in ci_irq() local
543 if (ci->in_lpm) { in ci_irq()
545 ci->wakeup_int = true; in ci_irq()
546 pm_runtime_get(ci->dev); in ci_irq()
550 if (ci->is_otg) { in ci_irq()
551 otgsc = hw_read_otgsc(ci, ~0); in ci_irq()
552 if (ci_otg_is_fsm_mode(ci)) { in ci_irq()
553 ret = ci_otg_fsm_irq(ci); in ci_irq()
563 if (ci->is_otg && (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) { in ci_irq()
564 ci->id_event = true; in ci_irq()
566 hw_write_otgsc(ci, OTGSC_IDIS, OTGSC_IDIS); in ci_irq()
567 ci_otg_queue_work(ci); in ci_irq()
575 if (ci->is_otg && (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) { in ci_irq()
576 ci->b_sess_valid_event = true; in ci_irq()
578 hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS); in ci_irq()
579 ci_otg_queue_work(ci); in ci_irq()
584 if (ci->role != CI_ROLE_END) in ci_irq()
585 ret = ci_role(ci)->irq(ci); in ci_irq()
594 struct ci_hdrc *ci = cbl->ci; in ci_cable_notifier() local
599 ci_irq(ci->irq, ci); in ci_cable_notifier()
605 struct ci_hdrc *ci = dev_get_drvdata(dev); in ci_usb_role_switch_get() local
609 spin_lock_irqsave(&ci->lock, flags); in ci_usb_role_switch_get()
610 role = ci_role_to_usb_role(ci); in ci_usb_role_switch_get()
611 spin_unlock_irqrestore(&ci->lock, flags); in ci_usb_role_switch_get()
618 struct ci_hdrc *ci = dev_get_drvdata(dev); in ci_usb_role_switch_set() local
620 enum usb_role current_role = ci_role_to_usb_role(ci); in ci_usb_role_switch_set()
626 pm_runtime_get_sync(ci->dev); in ci_usb_role_switch_set()
628 spin_lock_irqsave(&ci->lock, flags); in ci_usb_role_switch_set()
630 cable = &ci->platdata->vbus_extcon; in ci_usb_role_switch_set()
632 cable = &ci->platdata->id_extcon; in ci_usb_role_switch_set()
637 ci_irq(ci->irq, ci); in ci_usb_role_switch_set()
638 spin_unlock_irqrestore(&ci->lock, flags); in ci_usb_role_switch_set()
639 if (ci->wq && role != USB_ROLE_NONE) in ci_usb_role_switch_set()
640 flush_workqueue(ci->wq); in ci_usb_role_switch_set()
641 spin_lock_irqsave(&ci->lock, flags); in ci_usb_role_switch_set()
648 cable = &ci->platdata->vbus_extcon; in ci_usb_role_switch_set()
650 cable = &ci->platdata->id_extcon; in ci_usb_role_switch_set()
655 ci_irq(ci->irq, ci); in ci_usb_role_switch_set()
657 spin_unlock_irqrestore(&ci->lock, flags); in ci_usb_role_switch_set()
658 pm_runtime_put_sync(ci->dev); in ci_usb_role_switch_set()
817 static int ci_extcon_register(struct ci_hdrc *ci) in ci_extcon_register() argument
822 id = &ci->platdata->id_extcon; in ci_extcon_register()
823 id->ci = ci; in ci_extcon_register()
825 ret = devm_extcon_register_notifier(ci->dev, id->edev, in ci_extcon_register()
828 dev_err(ci->dev, "register ID failed\n"); in ci_extcon_register()
833 vbus = &ci->platdata->vbus_extcon; in ci_extcon_register()
834 vbus->ci = ci; in ci_extcon_register()
836 ret = devm_extcon_register_notifier(ci->dev, vbus->edev, in ci_extcon_register()
839 dev_err(ci->dev, "register VBUS failed\n"); in ci_extcon_register()
902 static inline void ci_role_destroy(struct ci_hdrc *ci) in ci_role_destroy() argument
904 ci_hdrc_gadget_destroy(ci); in ci_role_destroy()
905 ci_hdrc_host_destroy(ci); in ci_role_destroy()
906 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) in ci_role_destroy()
907 ci_hdrc_otg_destroy(ci); in ci_role_destroy()
910 static void ci_get_otg_capable(struct ci_hdrc *ci) in ci_get_otg_capable() argument
912 if (ci->platdata->flags & CI_HDRC_DUAL_ROLE_NOT_OTG) in ci_get_otg_capable()
913 ci->is_otg = false; in ci_get_otg_capable()
915 ci->is_otg = (hw_read(ci, CAP_DCCPARAMS, in ci_get_otg_capable()
918 if (ci->is_otg) { in ci_get_otg_capable()
919 dev_dbg(ci->dev, "It is OTG capable controller\n"); in ci_get_otg_capable()
921 hw_write_otgsc(ci, OTGSC_INT_EN_BITS | OTGSC_INT_STATUS_BITS, in ci_get_otg_capable()
929 struct ci_hdrc *ci = dev_get_drvdata(dev); in role_show() local
931 if (ci->role != CI_ROLE_END) in role_show()
932 return sprintf(buf, "%s\n", ci_role(ci)->name); in role_show()
940 struct ci_hdrc *ci = dev_get_drvdata(dev); in role_store() local
944 if (!(ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET])) { in role_store()
950 if (!strncmp(buf, ci->roles[role]->name, in role_store()
951 strlen(ci->roles[role]->name))) in role_store()
954 if (role == CI_ROLE_END || role == ci->role) in role_store()
958 disable_irq(ci->irq); in role_store()
959 ci_role_stop(ci); in role_store()
960 ret = ci_role_start(ci, role); in role_store()
961 if (!ret && ci->role == CI_ROLE_GADGET) in role_store()
962 ci_handle_vbus_change(ci); in role_store()
963 enable_irq(ci->irq); in role_store()
974 ATTRIBUTE_GROUPS(ci);
979 struct ci_hdrc *ci; in ci_hdrc_probe() local
995 ci = devm_kzalloc(dev, sizeof(*ci), GFP_KERNEL); in ci_hdrc_probe()
996 if (!ci) in ci_hdrc_probe()
999 spin_lock_init(&ci->lock); in ci_hdrc_probe()
1000 ci->dev = dev; in ci_hdrc_probe()
1001 ci->platdata = dev_get_platdata(dev); in ci_hdrc_probe()
1002 ci->imx28_write_fix = !!(ci->platdata->flags & in ci_hdrc_probe()
1004 ci->supports_runtime_pm = !!(ci->platdata->flags & in ci_hdrc_probe()
1006 platform_set_drvdata(pdev, ci); in ci_hdrc_probe()
1008 ret = hw_device_init(ci, base); in ci_hdrc_probe()
1014 ret = ci_ulpi_init(ci); in ci_hdrc_probe()
1018 if (ci->platdata->phy) { in ci_hdrc_probe()
1019 ci->phy = ci->platdata->phy; in ci_hdrc_probe()
1020 } else if (ci->platdata->usb_phy) { in ci_hdrc_probe()
1021 ci->usb_phy = ci->platdata->usb_phy; in ci_hdrc_probe()
1024 ci->phy = devm_phy_get(dev->parent, "usb-phy"); in ci_hdrc_probe()
1026 if (PTR_ERR(ci->phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1029 } else if (IS_ERR(ci->phy)) { in ci_hdrc_probe()
1030 ci->phy = NULL; in ci_hdrc_probe()
1034 if (!ci->phy) { in ci_hdrc_probe()
1035 ci->usb_phy = devm_usb_get_phy_by_phandle(dev->parent, in ci_hdrc_probe()
1038 if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1041 } else if (IS_ERR(ci->usb_phy)) { in ci_hdrc_probe()
1042 ci->usb_phy = NULL; in ci_hdrc_probe()
1047 if (!ci->phy && !ci->usb_phy) { in ci_hdrc_probe()
1048 ci->usb_phy = devm_usb_get_phy(dev->parent, in ci_hdrc_probe()
1051 if (PTR_ERR(ci->usb_phy) == -EPROBE_DEFER) { in ci_hdrc_probe()
1054 } else if (IS_ERR(ci->usb_phy)) { in ci_hdrc_probe()
1055 ci->usb_phy = NULL; in ci_hdrc_probe()
1060 if (!ci->phy && !ci->usb_phy) { in ci_hdrc_probe()
1066 ret = ci_usb_phy_init(ci); in ci_hdrc_probe()
1072 ci->hw_bank.phys = res->start; in ci_hdrc_probe()
1074 ci->irq = platform_get_irq(pdev, 0); in ci_hdrc_probe()
1075 if (ci->irq < 0) { in ci_hdrc_probe()
1076 ret = ci->irq; in ci_hdrc_probe()
1080 ci_get_otg_capable(ci); in ci_hdrc_probe()
1082 dr_mode = ci->platdata->dr_mode; in ci_hdrc_probe()
1085 ret = ci_hdrc_host_init(ci); in ci_hdrc_probe()
1095 ret = ci_hdrc_gadget_init(ci); in ci_hdrc_probe()
1104 if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1110 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1111 ret = ci_hdrc_otg_init(ci); in ci_hdrc_probe()
1119 ci->role_switch = usb_role_switch_register(dev, in ci_hdrc_probe()
1121 if (IS_ERR(ci->role_switch)) { in ci_hdrc_probe()
1122 ret = PTR_ERR(ci->role_switch); in ci_hdrc_probe()
1127 if (ci->roles[CI_ROLE_HOST] && ci->roles[CI_ROLE_GADGET]) { in ci_hdrc_probe()
1128 if (ci->is_otg) { in ci_hdrc_probe()
1129 ci->role = ci_otg_role(ci); in ci_hdrc_probe()
1131 hw_write_otgsc(ci, OTGSC_IDIE, OTGSC_IDIE); in ci_hdrc_probe()
1138 ci->role = CI_ROLE_GADGET; in ci_hdrc_probe()
1141 ci->role = ci->roles[CI_ROLE_HOST] in ci_hdrc_probe()
1146 if (!ci_otg_is_fsm_mode(ci)) { in ci_hdrc_probe()
1148 if (ci->role == CI_ROLE_GADGET) in ci_hdrc_probe()
1149 ci_handle_vbus_change(ci); in ci_hdrc_probe()
1151 ret = ci_role_start(ci, ci->role); in ci_hdrc_probe()
1154 ci_role(ci)->name); in ci_hdrc_probe()
1159 ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED, in ci_hdrc_probe()
1160 ci->platdata->name, ci); in ci_hdrc_probe()
1164 ret = ci_extcon_register(ci); in ci_hdrc_probe()
1168 if (ci->supports_runtime_pm) { in ci_hdrc_probe()
1172 pm_runtime_mark_last_busy(ci->dev); in ci_hdrc_probe()
1176 if (ci_otg_is_fsm_mode(ci)) in ci_hdrc_probe()
1177 ci_hdrc_otg_fsm_start(ci); in ci_hdrc_probe()
1180 dbg_create_files(ci); in ci_hdrc_probe()
1185 if (ci->role_switch) in ci_hdrc_probe()
1186 usb_role_switch_unregister(ci->role_switch); in ci_hdrc_probe()
1188 if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) in ci_hdrc_probe()
1189 ci_hdrc_otg_destroy(ci); in ci_hdrc_probe()
1191 ci_hdrc_gadget_destroy(ci); in ci_hdrc_probe()
1193 ci_hdrc_host_destroy(ci); in ci_hdrc_probe()
1195 ci_usb_phy_exit(ci); in ci_hdrc_probe()
1197 ci_ulpi_exit(ci); in ci_hdrc_probe()
1204 struct ci_hdrc *ci = platform_get_drvdata(pdev); in ci_hdrc_remove() local
1206 if (ci->role_switch) in ci_hdrc_remove()
1207 usb_role_switch_unregister(ci->role_switch); in ci_hdrc_remove()
1209 if (ci->supports_runtime_pm) { in ci_hdrc_remove()
1215 dbg_remove_files(ci); in ci_hdrc_remove()
1216 ci_role_destroy(ci); in ci_hdrc_remove()
1217 ci_hdrc_enter_lpm(ci, true); in ci_hdrc_remove()
1218 ci_usb_phy_exit(ci); in ci_hdrc_remove()
1219 ci_ulpi_exit(ci); in ci_hdrc_remove()
1226 static void ci_otg_fsm_suspend_for_srp(struct ci_hdrc *ci) in ci_otg_fsm_suspend_for_srp() argument
1228 if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) && in ci_otg_fsm_suspend_for_srp()
1229 !hw_read_otgsc(ci, OTGSC_ID)) { in ci_otg_fsm_suspend_for_srp()
1230 hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_PP, in ci_otg_fsm_suspend_for_srp()
1232 hw_write(ci, OP_PORTSC, PORTSC_W1C_BITS | PORTSC_WKCN, in ci_otg_fsm_suspend_for_srp()
1238 static void ci_otg_fsm_wakeup_by_srp(struct ci_hdrc *ci) in ci_otg_fsm_wakeup_by_srp() argument
1240 if ((ci->fsm.otg->state == OTG_STATE_A_IDLE) && in ci_otg_fsm_wakeup_by_srp()
1241 (ci->fsm.a_bus_drop == 1) && (ci->fsm.a_bus_req == 0)) { in ci_otg_fsm_wakeup_by_srp()
1242 if (!hw_read_otgsc(ci, OTGSC_ID)) { in ci_otg_fsm_wakeup_by_srp()
1243 ci->fsm.a_srp_det = 1; in ci_otg_fsm_wakeup_by_srp()
1244 ci->fsm.a_bus_drop = 0; in ci_otg_fsm_wakeup_by_srp()
1246 ci->fsm.id = 1; in ci_otg_fsm_wakeup_by_srp()
1248 ci_otg_queue_work(ci); in ci_otg_fsm_wakeup_by_srp()
1252 static void ci_controller_suspend(struct ci_hdrc *ci) in ci_controller_suspend() argument
1254 disable_irq(ci->irq); in ci_controller_suspend()
1255 ci_hdrc_enter_lpm(ci, true); in ci_controller_suspend()
1256 if (ci->platdata->phy_clkgate_delay_us) in ci_controller_suspend()
1257 usleep_range(ci->platdata->phy_clkgate_delay_us, in ci_controller_suspend()
1258 ci->platdata->phy_clkgate_delay_us + 50); in ci_controller_suspend()
1259 usb_phy_set_suspend(ci->usb_phy, 1); in ci_controller_suspend()
1260 ci->in_lpm = true; in ci_controller_suspend()
1261 enable_irq(ci->irq); in ci_controller_suspend()
1266 struct ci_hdrc *ci = dev_get_drvdata(dev); in ci_controller_resume() local
1271 if (!ci->in_lpm) { in ci_controller_resume()
1276 ci_hdrc_enter_lpm(ci, false); in ci_controller_resume()
1278 ret = ci_ulpi_resume(ci); in ci_controller_resume()
1282 if (ci->usb_phy) { in ci_controller_resume()
1283 usb_phy_set_suspend(ci->usb_phy, 0); in ci_controller_resume()
1284 usb_phy_set_wakeup(ci->usb_phy, false); in ci_controller_resume()
1288 ci->in_lpm = false; in ci_controller_resume()
1289 if (ci->wakeup_int) { in ci_controller_resume()
1290 ci->wakeup_int = false; in ci_controller_resume()
1291 pm_runtime_mark_last_busy(ci->dev); in ci_controller_resume()
1292 pm_runtime_put_autosuspend(ci->dev); in ci_controller_resume()
1293 enable_irq(ci->irq); in ci_controller_resume()
1294 if (ci_otg_is_fsm_mode(ci)) in ci_controller_resume()
1295 ci_otg_fsm_wakeup_by_srp(ci); in ci_controller_resume()
1304 struct ci_hdrc *ci = dev_get_drvdata(dev); in ci_suspend() local
1306 if (ci->wq) in ci_suspend()
1307 flush_workqueue(ci->wq); in ci_suspend()
1314 if (ci->in_lpm) in ci_suspend()
1317 if (ci->in_lpm) { in ci_suspend()
1323 if (ci_otg_is_fsm_mode(ci)) in ci_suspend()
1324 ci_otg_fsm_suspend_for_srp(ci); in ci_suspend()
1326 usb_phy_set_wakeup(ci->usb_phy, true); in ci_suspend()
1327 enable_irq_wake(ci->irq); in ci_suspend()
1330 ci_controller_suspend(ci); in ci_suspend()
1337 struct ci_hdrc *ci = dev_get_drvdata(dev); in ci_resume() local
1341 disable_irq_wake(ci->irq); in ci_resume()
1347 if (ci->supports_runtime_pm) { in ci_resume()
1359 struct ci_hdrc *ci = dev_get_drvdata(dev); in ci_runtime_suspend() local
1363 if (ci->in_lpm) { in ci_runtime_suspend()
1368 if (ci_otg_is_fsm_mode(ci)) in ci_runtime_suspend()
1369 ci_otg_fsm_suspend_for_srp(ci); in ci_runtime_suspend()
1371 usb_phy_set_wakeup(ci->usb_phy, true); in ci_runtime_suspend()
1372 ci_controller_suspend(ci); in ci_runtime_suspend()