Lines Matching +full:needs +full:- +full:reset +full:- +full:on +full:- +full:resume
1 // SPDX-License-Identifier: GPL-2.0
3 * host.c - ChipIdea USB host controller driver
35 struct ehci_ci_priv *priv = (struct ehci_ci_priv *)ehci->priv; in ehci_ci_portpower()
36 struct device *dev = hcd->self.controller; in ehci_ci_portpower()
39 int port = HCS_N_PORTS(ehci->hcs_params); in ehci_ci_portpower()
41 if (priv->reg_vbus && enable != priv->enabled) { in ehci_ci_portpower()
44 "Not support multi-port regulator control\n"); in ehci_ci_portpower()
48 ret = regulator_enable(priv->reg_vbus); in ehci_ci_portpower()
50 ret = regulator_disable(priv->reg_vbus); in ehci_ci_portpower()
57 priv->enabled = enable; in ehci_ci_portpower()
60 if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) { in ehci_ci_portpower()
73 struct device *dev = hcd->self.controller; in ehci_ci_reset()
82 ehci->need_io_watchdog = 0; in ehci_ci_reset()
84 if (ci->platdata->notify_event) { in ehci_ci_reset()
85 ret = ci->platdata->notify_event(ci, in ehci_ci_reset()
99 .reset = ehci_ci_reset,
104 return usb_hcd_irq(ci->irq, ci->hcd); in host_irq()
115 return -ENODEV; in host_start()
117 hcd = __usb_create_hcd(&ci_ehci_hc_driver, ci->dev->parent, in host_start()
118 ci->dev, dev_name(ci->dev), NULL); in host_start()
120 return -ENOMEM; in host_start()
122 dev_set_drvdata(ci->dev, ci); in host_start()
123 hcd->rsrc_start = ci->hw_bank.phys; in host_start()
124 hcd->rsrc_len = ci->hw_bank.size; in host_start()
125 hcd->regs = ci->hw_bank.abs; in host_start()
126 hcd->has_tt = 1; in host_start()
128 hcd->power_budget = ci->platdata->power_budget; in host_start()
129 hcd->tpl_support = ci->platdata->tpl_support; in host_start()
130 if (ci->phy || ci->usb_phy) { in host_start()
131 hcd->skip_phy_initialization = 1; in host_start()
132 if (ci->usb_phy) in host_start()
133 hcd->usb_phy = ci->usb_phy; in host_start()
137 ehci->caps = ci->hw_bank.cap; in host_start()
138 ehci->has_hostpc = ci->hw_bank.lpm; in host_start()
139 ehci->has_tdi_phy_lpm = ci->hw_bank.lpm; in host_start()
140 ehci->imx28_write_fix = ci->imx28_write_fix; in host_start()
142 priv = (struct ehci_ci_priv *)ehci->priv; in host_start()
143 priv->reg_vbus = NULL; in host_start()
145 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) { in host_start()
146 if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) { in host_start()
147 ret = regulator_enable(ci->platdata->reg_vbus); in host_start()
149 dev_err(ci->dev, in host_start()
155 priv->reg_vbus = ci->platdata->reg_vbus; in host_start()
159 if (ci->platdata->pins_host) in host_start()
160 pinctrl_select_state(ci->platdata->pctl, in host_start()
161 ci->platdata->pins_host); in host_start()
167 struct usb_otg *otg = &ci->otg; in host_start()
169 ci->hcd = hcd; in host_start()
172 otg->host = &hcd->self; in host_start()
173 hcd->self.otg_port = 1; in host_start()
176 if (ci->platdata->notify_event && in host_start()
177 (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC)) in host_start()
178 ci->platdata->notify_event in host_start()
185 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && in host_start()
186 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) in host_start()
187 regulator_disable(ci->platdata->reg_vbus); in host_start()
196 struct usb_hcd *hcd = ci->hcd; in host_stop()
199 if (ci->platdata->notify_event) in host_stop()
200 ci->platdata->notify_event(ci, in host_stop()
203 ci->role = CI_ROLE_END; in host_stop()
204 synchronize_irq(ci->irq); in host_stop()
206 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && in host_stop()
207 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) in host_stop()
208 regulator_disable(ci->platdata->reg_vbus); in host_stop()
210 ci->hcd = NULL; in host_stop()
211 ci->otg.host = NULL; in host_stop()
213 if (ci->platdata->pins_host && ci->platdata->pins_default) in host_stop()
214 pinctrl_select_state(ci->platdata->pctl, in host_stop()
215 ci->platdata->pins_default); in host_stop()
221 if (ci->role == CI_ROLE_HOST && ci->hcd) in ci_hdrc_host_destroy()
225 /* The below code is based on tegra ehci driver */
240 struct device *dev = hcd->self.controller; in ci_ehci_hub_control()
243 status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1]; in ci_ehci_hub_control()
245 spin_lock_irqsave(&ehci->lock, flags); in ci_ehci_hub_control()
250 retval = -EPIPE; in ci_ehci_hub_control()
266 if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { in ci_ehci_hub_control()
267 if (ci->platdata->notify_event) in ci_ehci_hub_control()
268 ci->platdata->notify_event(ci, in ci_ehci_hub_control()
276 set_bit((wIndex & 0xff) - 1, &ehci->suspended_ports); in ci_ehci_hub_control()
281 * After resume has finished, it needs do some post resume in ci_ehci_hub_control()
286 /* Make sure the resume has finished, it should be finished */ in ci_ehci_hub_control()
288 ehci_err(ehci, "timeout waiting for resume\n"); in ci_ehci_hub_control()
291 spin_unlock_irqrestore(&ehci->lock, flags); in ci_ehci_hub_control()
296 spin_unlock_irqrestore(&ehci->lock, flags); in ci_ehci_hub_control()
302 struct device *dev = hcd->self.controller; in ci_ehci_bus_suspend()
312 port = HCS_N_PORTS(ehci->hcs_params); in ci_ehci_bus_suspend()
313 while (port--) { in ci_ehci_bus_suspend()
314 u32 __iomem *reg = &ehci->regs->port_status[port]; in ci_ehci_bus_suspend()
319 * For chipidea, the resume signal will be ended in ci_ehci_bus_suspend()
321 * usbcmd.rs may not be set before the resume has in ci_ehci_bus_suspend()
322 * ended if other resume paths consumes too much in ci_ehci_bus_suspend()
324 * send out within 3ms after resume ends, then the in ci_ehci_bus_suspend()
328 tmp = ehci_readl(ehci, &ehci->regs->command); in ci_ehci_bus_suspend()
330 ehci_writel(ehci, tmp, &ehci->regs->command); in ci_ehci_bus_suspend()
332 * It needs a short delay between set RS bit and PHCD. in ci_ehci_bus_suspend()
339 if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { in ci_ehci_bus_suspend()
357 return -ENXIO; in ci_hdrc_host_init()
359 rdrv = devm_kzalloc(ci->dev, sizeof(struct ci_role_driver), GFP_KERNEL); in ci_hdrc_host_init()
361 return -ENOMEM; in ci_hdrc_host_init()
363 rdrv->start = host_start; in ci_hdrc_host_init()
364 rdrv->stop = host_stop; in ci_hdrc_host_init()
365 rdrv->irq = host_irq; in ci_hdrc_host_init()
366 rdrv->name = "host"; in ci_hdrc_host_init()
367 ci->roles[CI_ROLE_HOST] = rdrv; in ci_hdrc_host_init()