Lines Matching +full:hsic +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0
3 * host.c - ChipIdea USB host controller driver
40 struct ehci_ci_priv *priv = (struct ehci_ci_priv *)ehci->priv; in ehci_ci_portpower()
41 struct device *dev = hcd->self.controller; in ehci_ci_portpower()
44 int port = HCS_N_PORTS(ehci->hcs_params); in ehci_ci_portpower()
46 if (priv->reg_vbus && enable != priv->enabled) { in ehci_ci_portpower()
49 "Not support multi-port regulator control\n"); in ehci_ci_portpower()
53 ret = regulator_enable(priv->reg_vbus); in ehci_ci_portpower()
55 ret = regulator_disable(priv->reg_vbus); in ehci_ci_portpower()
62 priv->enabled = enable; in ehci_ci_portpower()
65 if (ci->platdata->flags & CI_HDRC_PHY_VBUS_CONTROL) { in ehci_ci_portpower()
67 usb_phy_vbus_on(ci->usb_phy); in ehci_ci_portpower()
69 usb_phy_vbus_off(ci->usb_phy); in ehci_ci_portpower()
72 if (enable && (ci->platdata->phy_mode == USBPHY_INTERFACE_MODE_HSIC)) { in ehci_ci_portpower()
74 * Marvell 28nm HSIC PHY requires forcing the port to HS mode. in ehci_ci_portpower()
75 * As HSIC is always HS, this should be safe for others. in ehci_ci_portpower()
85 struct device *dev = hcd->self.controller; in ehci_ci_reset()
94 ehci->need_io_watchdog = 0; in ehci_ci_reset()
96 if (ci->platdata->notify_event) { in ehci_ci_reset()
97 ret = ci->platdata->notify_event(ci, in ehci_ci_reset()
116 return usb_hcd_irq(ci->irq, ci->hcd); in host_irq()
127 return -ENODEV; in host_start()
129 hcd = __usb_create_hcd(&ci_ehci_hc_driver, ci->dev->parent, in host_start()
130 ci->dev, dev_name(ci->dev), NULL); in host_start()
132 return -ENOMEM; in host_start()
134 dev_set_drvdata(ci->dev, ci); in host_start()
135 hcd->rsrc_start = ci->hw_bank.phys; in host_start()
136 hcd->rsrc_len = ci->hw_bank.size; in host_start()
137 hcd->regs = ci->hw_bank.abs; in host_start()
138 hcd->has_tt = 1; in host_start()
140 hcd->power_budget = ci->platdata->power_budget; in host_start()
141 hcd->tpl_support = ci->platdata->tpl_support; in host_start()
142 if (ci->phy || ci->usb_phy) { in host_start()
143 hcd->skip_phy_initialization = 1; in host_start()
144 if (ci->usb_phy) in host_start()
145 hcd->usb_phy = ci->usb_phy; in host_start()
149 ehci->caps = ci->hw_bank.cap; in host_start()
150 ehci->has_hostpc = ci->hw_bank.lpm; in host_start()
151 ehci->has_tdi_phy_lpm = ci->hw_bank.lpm; in host_start()
152 ehci->imx28_write_fix = ci->imx28_write_fix; in host_start()
153 ehci->has_ci_pec_bug = ci->has_portsc_pec_bug; in host_start()
155 priv = (struct ehci_ci_priv *)ehci->priv; in host_start()
156 priv->reg_vbus = NULL; in host_start()
158 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) { in host_start()
159 if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) { in host_start()
160 ret = regulator_enable(ci->platdata->reg_vbus); in host_start()
162 dev_err(ci->dev, in host_start()
168 priv->reg_vbus = ci->platdata->reg_vbus; in host_start()
172 if (ci->platdata->pins_host) in host_start()
173 pinctrl_select_state(ci->platdata->pctl, in host_start()
174 ci->platdata->pins_host); in host_start()
176 ci->hcd = hcd; in host_start()
180 ci->hcd = NULL; in host_start()
183 struct usb_otg *otg = &ci->otg; in host_start()
186 otg->host = &hcd->self; in host_start()
187 hcd->self.otg_port = 1; in host_start()
190 if (ci->platdata->notify_event && in host_start()
191 (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC)) in host_start()
192 ci->platdata->notify_event in host_start()
199 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && in host_start()
200 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) in host_start()
201 regulator_disable(ci->platdata->reg_vbus); in host_start()
210 struct usb_hcd *hcd = ci->hcd; in host_stop()
213 if (ci->platdata->notify_event) in host_stop()
214 ci->platdata->notify_event(ci, in host_stop()
217 ci->role = CI_ROLE_END; in host_stop()
218 synchronize_irq(ci->irq); in host_stop()
220 if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && in host_stop()
221 (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) in host_stop()
222 regulator_disable(ci->platdata->reg_vbus); in host_stop()
224 ci->hcd = NULL; in host_stop()
225 ci->otg.host = NULL; in host_stop()
227 if (ci->platdata->pins_host && ci->platdata->pins_default) in host_stop()
228 pinctrl_select_state(ci->platdata->pctl, in host_stop()
229 ci->platdata->pins_default); in host_stop()
235 if (ci->role == CI_ROLE_HOST && ci->hcd) in ci_hdrc_host_destroy()
250 unsigned int ports = HCS_N_PORTS(ehci->hcs_params); in ci_ehci_hub_control()
256 struct device *dev = hcd->self.controller; in ci_ehci_hub_control()
260 port_index -= (port_index > 0); in ci_ehci_hub_control()
261 status_reg = &ehci->regs->port_status[port_index]; in ci_ehci_hub_control()
263 spin_lock_irqsave(&ehci->lock, flags); in ci_ehci_hub_control()
265 if (ci->platdata->hub_control) { in ci_ehci_hub_control()
266 retval = ci->platdata->hub_control(ci, typeReq, wValue, wIndex, in ci_ehci_hub_control()
274 retval = -EPIPE; in ci_ehci_hub_control()
280 retval = -EPIPE; in ci_ehci_hub_control()
296 if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { in ci_ehci_hub_control()
297 if (ci->platdata->notify_event) in ci_ehci_hub_control()
298 ci->platdata->notify_event(ci, in ci_ehci_hub_control()
306 set_bit(port_index, &ehci->suspended_ports); in ci_ehci_hub_control()
321 spin_unlock_irqrestore(&ehci->lock, flags); in ci_ehci_hub_control()
326 spin_unlock_irqrestore(&ehci->lock, flags); in ci_ehci_hub_control()
332 struct device *dev = hcd->self.controller; in ci_ehci_bus_suspend()
342 port = HCS_N_PORTS(ehci->hcs_params); in ci_ehci_bus_suspend()
343 while (port--) { in ci_ehci_bus_suspend()
344 u32 __iomem *reg = &ehci->regs->port_status[port]; in ci_ehci_bus_suspend()
355 * high speed device will enter full speed mode. in ci_ehci_bus_suspend()
358 tmp = ehci_readl(ehci, &ehci->regs->command); in ci_ehci_bus_suspend()
360 ehci_writel(ehci, tmp, &ehci->regs->command); in ci_ehci_bus_suspend()
366 * Need to clear WKCN and WKOC for imx HSIC, in ci_ehci_bus_suspend()
369 if (ci->platdata->flags & CI_HDRC_IMX_IS_HSIC) { in ci_ehci_bus_suspend()
386 if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER)) in ci_hdrc_free_dma_aligned_buffer()
388 urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER; in ci_hdrc_free_dma_aligned_buffer()
390 temp = container_of(urb->transfer_buffer, in ci_hdrc_free_dma_aligned_buffer()
392 urb->transfer_buffer = temp->original_buffer; in ci_hdrc_free_dma_aligned_buffer()
397 if (usb_pipeisoc(urb->pipe)) in ci_hdrc_free_dma_aligned_buffer()
398 length = urb->transfer_buffer_length; in ci_hdrc_free_dma_aligned_buffer()
400 length = urb->actual_length; in ci_hdrc_free_dma_aligned_buffer()
402 memcpy(temp->original_buffer, temp->data, length); in ci_hdrc_free_dma_aligned_buffer()
412 if (urb->num_sgs || urb->sg || urb->transfer_buffer_length == 0) in ci_hdrc_alloc_dma_aligned_buffer()
414 if (IS_ALIGNED((uintptr_t)urb->transfer_buffer, 4) in ci_hdrc_alloc_dma_aligned_buffer()
415 && IS_ALIGNED(urb->transfer_buffer_length, 4)) in ci_hdrc_alloc_dma_aligned_buffer()
418 temp = kmalloc(sizeof(*temp) + ALIGN(urb->transfer_buffer_length, 4), mem_flags); in ci_hdrc_alloc_dma_aligned_buffer()
420 return -ENOMEM; in ci_hdrc_alloc_dma_aligned_buffer()
423 memcpy(temp->data, urb->transfer_buffer, in ci_hdrc_alloc_dma_aligned_buffer()
424 urb->transfer_buffer_length); in ci_hdrc_alloc_dma_aligned_buffer()
426 temp->original_buffer = urb->transfer_buffer; in ci_hdrc_alloc_dma_aligned_buffer()
427 urb->transfer_buffer = temp->data; in ci_hdrc_alloc_dma_aligned_buffer()
428 urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER; in ci_hdrc_alloc_dma_aligned_buffer()
458 ehci_suspend(ci->hcd, device_may_wakeup(ci->dev)); in ci_hdrc_host_suspend()
463 ehci_resume(ci->hcd, power_lost); in ci_hdrc_host_resume()
472 return -ENXIO; in ci_hdrc_host_init()
474 rdrv = devm_kzalloc(ci->dev, sizeof(struct ci_role_driver), GFP_KERNEL); in ci_hdrc_host_init()
476 return -ENOMEM; in ci_hdrc_host_init()
478 rdrv->start = host_start; in ci_hdrc_host_init()
479 rdrv->stop = host_stop; in ci_hdrc_host_init()
481 rdrv->suspend = ci_hdrc_host_suspend; in ci_hdrc_host_init()
482 rdrv->resume = ci_hdrc_host_resume; in ci_hdrc_host_init()
484 rdrv->irq = host_irq; in ci_hdrc_host_init()
485 rdrv->name = "host"; in ci_hdrc_host_init()
486 ci->roles[CI_ROLE_HOST] = rdrv; in ci_hdrc_host_init()
488 if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA) { in ci_hdrc_host_init()