Lines Matching +full:hsic +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
3 * host.c - ChipIdea USB host controller driver
41 struct ehci_ci_priv *priv = (struct ehci_ci_priv *)ehci->priv; in ehci_ci_portpower()
42 struct device *dev = hcd->self.controller; in ehci_ci_portpower()
45 int port = HCS_N_PORTS(ehci->hcs_params); in ehci_ci_portpower()
47 if (priv->reg_vbus && enable != priv->enabled) { in ehci_ci_portpower()
50 "Not support multi-port regulator control\n"); in ehci_ci_portpower()
54 ret = regulator_enable(priv->reg_vbus); in ehci_ci_portpower()
56 ret = regulator_disable(priv->reg_vbus); in ehci_ci_portpower()
63 priv->enabled = enable; in ehci_ci_portpower()
66 if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) { in ehci_ci_portpower()
68 usb_phy_vbus_on(ci->usb_phy); in ehci_ci_portpower()
70 usb_phy_vbus_off(ci->usb_phy); in ehci_ci_portpower()
73 if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) { in ehci_ci_portpower()
75 * Marvell 28nm HSIC PHY requires forcing the port to HS mode. in ehci_ci_portpower()
76 * As HSIC is always HS, this should be safe for others. in ehci_ci_portpower()
86 struct device *dev = hcd->self.controller; in ehci_ci_reset()
95 ehci->need_io_watchdog = 0; in ehci_ci_reset()
97 if (ci->platdata->notify_event) { in ehci_ci_reset()
98 ret = ci->platdata->notify_event(ci, in ehci_ci_reset()
117 return usb_hcd_irq(ci->irq, ci->hcd); in host_irq()
128 return -ENODEV; in host_start()
130 hcd = __usb_create_hcd(&ci_ehci_hc_driver, ci->dev->parent, in host_start()
131 ci->dev, dev_name(ci->dev), NULL); in host_start()
133 return -ENOMEM; in host_start()
135 dev_set_drvdata(ci->dev, ci); in host_start()
136 hcd->rsrc_start = ci->hw_bank.phys; in host_start()
137 hcd->rsrc_len = ci->hw_bank.size; in host_start()
138 hcd->regs = ci->hw_bank.abs; in host_start()
139 hcd->has_tt = 1; in host_start()
141 hcd->power_budget = ci->platdata->power_budget; in host_start()
142 hcd->tpl_support = ci->platdata->tpl_support; in host_start()
143 if (ci->phy || ci->usb_phy) { in host_start()
144 hcd->skip_phy_initialization = 1; in host_start()
145 if (ci->usb_phy) in host_start()
146 hcd->usb_phy = ci->usb_phy; in host_start()
150 ehci->caps = ci->hw_bank.cap; in host_start()
151 ehci->has_hostpc = ci->hw_bank.lpm; in host_start()
152 ehci->has_tdi_phy_lpm = ci->hw_bank.lpm; in host_start()
153 ehci->imx28_write_fix = ci->imx28_write_fix; in host_start()
154 ehci->has_ci_pec_bug = ci->has_portsc_pec_bug; in host_start()
156 priv = (struct ehci_ci_priv *)ehci->priv; in host_start()
157 priv->reg_vbus = NULL; in host_start()
159 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) { in host_start()
160 if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) { in host_start()
161 ret = regulator_enable(ci->platdata->reg_vbus); in host_start()
163 dev_err(ci->dev, in host_start()
169 priv->reg_vbus = ci->platdata->reg_vbus; in host_start()
173 if (ci->platdata->pins_host) in host_start()
174 pinctrl_select_state(ci->platdata->pctl, in host_start()
175 ci->platdata->pins_host); in host_start()
177 ci->hcd = hcd; in host_start()
181 ci->hcd = NULL; in host_start()
184 struct usb_otg *otg = &ci->otg; in host_start()
187 otg->host = &hcd->self; in host_start()
188 hcd->self.otg_port = 1; in host_start()
191 if (ci->platdata->notify_event && in host_start()
192 (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC)) in host_start()
193 ci->platdata->notify_event in host_start()
200 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && in host_start()
201 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) in host_start()
202 regulator_disable(ci->platdata->reg_vbus); in host_start()
211 struct usb_hcd *hcd = ci->hcd; in host_stop()
214 if (ci->platdata->notify_event) in host_stop()
215 ci->platdata->notify_event(ci, in host_stop()
218 ci->role = CI_ROLE_END; in host_stop()
219 synchronize_irq(ci->irq); in host_stop()
221 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && in host_stop()
222 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) in host_stop()
223 regulator_disable(ci->platdata->reg_vbus); in host_stop()
225 ci->hcd = NULL; in host_stop()
226 ci->otg.host = NULL; in host_stop()
228 if (ci->platdata->pins_host && ci->platdata->pins_default) in host_stop()
229 pinctrl_select_state(ci->platdata->pctl, in host_stop()
230 ci->platdata->pins_default); in host_stop()
236 if (ci->role == CI_ROLE_HOST && ci->hcd) in ci_hdrc_host_destroy()
251 unsigned int ports = HCS_N_PORTS(ehci->hcs_params); in ci_ehci_hub_control()
257 struct device *dev = hcd->self.controller; in ci_ehci_hub_control()
261 * Avoid out-of-bounds values while calculating the port index in ci_ehci_hub_control()
265 port_index = (wIndex - 1) & 0xff; in ci_ehci_hub_control()
268 status_reg = &ehci->regs->port_status[port_index]; in ci_ehci_hub_control()
270 spin_lock_irqsave(&ehci->lock, flags); in ci_ehci_hub_control()
272 if (ci->platdata->hub_control) { in ci_ehci_hub_control()
273 retval = ci->platdata->hub_control(ci, typeReq, wValue, wIndex, in ci_ehci_hub_control()
281 retval = -EPIPE; in ci_ehci_hub_control()
287 retval = -EPIPE; in ci_ehci_hub_control()
303 if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { in ci_ehci_hub_control()
304 if (ci->platdata->notify_event) in ci_ehci_hub_control()
305 ci->platdata->notify_event(ci, in ci_ehci_hub_control()
313 set_bit(port_index, &ehci->suspended_ports); in ci_ehci_hub_control()
328 spin_unlock_irqrestore(&ehci->lock, flags); in ci_ehci_hub_control()
333 spin_unlock_irqrestore(&ehci->lock, flags); in ci_ehci_hub_control()
339 struct device *dev = hcd->self.controller; in ci_ehci_bus_suspend()
349 port = HCS_N_PORTS(ehci->hcs_params); in ci_ehci_bus_suspend()
350 while (port--) { in ci_ehci_bus_suspend()
351 u32 __iomem *reg = &ehci->regs->port_status[port]; in ci_ehci_bus_suspend()
362 * high speed device will enter full speed mode. in ci_ehci_bus_suspend()
365 tmp = ehci_readl(ehci, &ehci->regs->command); in ci_ehci_bus_suspend()
367 ehci_writel(ehci, tmp, &ehci->regs->command); in ci_ehci_bus_suspend()
373 * Need to clear WKCN and WKOC for imx HSIC, in ci_ehci_bus_suspend()
376 if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { in ci_ehci_bus_suspend()
393 if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER)) in ci_hdrc_free_dma_aligned_buffer()
395 urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER; in ci_hdrc_free_dma_aligned_buffer()
397 temp = container_of(urb->transfer_buffer, in ci_hdrc_free_dma_aligned_buffer()
399 urb->transfer_buffer = temp->original_buffer; in ci_hdrc_free_dma_aligned_buffer()
404 if (usb_pipeisoc(urb->pipe)) in ci_hdrc_free_dma_aligned_buffer()
405 length = urb->transfer_buffer_length; in ci_hdrc_free_dma_aligned_buffer()
407 length = urb->actual_length; in ci_hdrc_free_dma_aligned_buffer()
409 memcpy(temp->original_buffer, temp->data, length); in ci_hdrc_free_dma_aligned_buffer()
419 if (urb->num_sgs || urb->sg || urb->transfer_buffer_length == 0) in ci_hdrc_alloc_dma_aligned_buffer()
421 if (IS_ALIGNED((uintptr_t)urb->transfer_buffer, 4) in ci_hdrc_alloc_dma_aligned_buffer()
422 && IS_ALIGNED(urb->transfer_buffer_length, 4)) in ci_hdrc_alloc_dma_aligned_buffer()
425 temp = kmalloc(sizeof(*temp) + ALIGN(urb->transfer_buffer_length, 4), mem_flags); in ci_hdrc_alloc_dma_aligned_buffer()
427 return -ENOMEM; in ci_hdrc_alloc_dma_aligned_buffer()
430 memcpy(temp->data, urb->transfer_buffer, in ci_hdrc_alloc_dma_aligned_buffer()
431 urb->transfer_buffer_length); in ci_hdrc_alloc_dma_aligned_buffer()
433 temp->original_buffer = urb->transfer_buffer; in ci_hdrc_alloc_dma_aligned_buffer()
434 urb->transfer_buffer = temp->data; in ci_hdrc_alloc_dma_aligned_buffer()
435 urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER; in ci_hdrc_alloc_dma_aligned_buffer()
465 ehci_suspend(ci->hcd, device_may_wakeup(ci->dev)); in ci_hdrc_host_suspend()
470 ehci_resume(ci->hcd, power_lost); in ci_hdrc_host_resume()
479 return -ENXIO; in ci_hdrc_host_init()
481 rdrv = devm_kzalloc(ci->dev, sizeof(struct ci_role_driver), GFP_KERNEL); in ci_hdrc_host_init()
483 return -ENOMEM; in ci_hdrc_host_init()
485 rdrv->start = host_start; in ci_hdrc_host_init()
486 rdrv->stop = host_stop; in ci_hdrc_host_init()
488 rdrv->suspend = ci_hdrc_host_suspend; in ci_hdrc_host_init()
489 rdrv->resume = ci_hdrc_host_resume; in ci_hdrc_host_init()
491 rdrv->irq = host_irq; in ci_hdrc_host_init()
492 rdrv->name = "host"; in ci_hdrc_host_init()
493 ci->roles[CI_ROLE_HOST] = rdrv; in ci_hdrc_host_init()
495 if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA) { in ci_hdrc_host_init()