Lines Matching +full:usb +full:- +full:ehci

1 // SPDX-License-Identifier: GPL-2.0
3 * drivers/usb/host/ehci-orion.c
13 #include <linux/platform_data/usb-ehci-orion.h>
18 #include <linux/usb.h>
19 #include <linux/usb/hcd.h>
21 #include <linux/dma-mapping.h>
23 #include "ehci.h"
25 #define rdl(off) readl_relaxed(hcd->regs + (off))
26 #define wrl(off, val) writel_relaxed((val), hcd->regs + (off))
59 #define DRIVER_DESC "EHCI orion driver"
61 #define hcd_to_orion_priv(h) ((struct orion_ehci_hcd *)hcd_to_ehci(h)->priv)
68 static const char hcd_name[] = "ehci-orion";
73 * Implement Orion USB controller specification guidelines
91 * GL# USB-10: Set IPG for non start of frame packets in orion_usb_phy_v1_setup()
97 * GL# USB-9: USB 2.0 Power Control in orion_usb_phy_v1_setup()
103 * GL# USB-1: USB PHY Tx Control - force calibration to '8' in orion_usb_phy_v1_setup()
109 * GL# USB-3 GL# USB-9: USB PHY Rx Control in orion_usb_phy_v1_setup()
116 * GL# USB-3 GL# USB-9: USB PHY IVREF Control in orion_usb_phy_v1_setup()
122 * GL# USB-3 GL# USB-9: USB PHY Test Group Control in orion_usb_phy_v1_setup()
135 * GL# USB-5 Streaming disable REG_USB_MODE[4]=1 in orion_usb_phy_v1_setup()
137 * GL# USB-4 Setup USB Host mode in orion_usb_phy_v1_setup()
153 for (i = 0; i < dram->num_cs; i++) { in ehci_orion_conf_mbus_windows()
154 const struct mbus_dram_window *cs = dram->cs + i; in ehci_orion_conf_mbus_windows()
156 wrl(USB_WINDOW_CTRL(i), ((cs->size - 1) & 0xffff0000) | in ehci_orion_conf_mbus_windows()
157 (cs->mbus_attr << 8) | in ehci_orion_conf_mbus_windows()
158 (dram->mbus_dram_target_id << 4) | 1); in ehci_orion_conf_mbus_windows()
159 wrl(USB_WINDOW_BASE(i), cs->base); in ehci_orion_conf_mbus_windows()
165 struct device *dev = hcd->self.controller; in ehci_orion_drv_reset()
176 * sbuscfg reg has to be set after usb controller reset, otherwise in ehci_orion_drv_reset()
179 if (of_device_is_compatible(dev->of_node, "marvell,armada-3700-ehci")) in ehci_orion_drv_reset()
209 struct orion_ehci_data *pd = dev_get_platdata(&pdev->dev); in ehci_orion_drv_probe()
213 struct ehci_hcd *ehci; in ehci_orion_drv_probe() local
220 return -ENODEV; in ehci_orion_drv_probe()
222 pr_debug("Initializing Orion-SoC USB Host Controller\n"); in ehci_orion_drv_probe()
226 err = -ENODEV; in ehci_orion_drv_probe()
231 * Right now device-tree probed devices don't get dma_mask in ehci_orion_drv_probe()
232 * set. Since shared usb code relies on it, set it here for in ehci_orion_drv_probe()
235 err = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in ehci_orion_drv_probe()
240 regs = devm_ioremap_resource(&pdev->dev, res); in ehci_orion_drv_probe()
247 &pdev->dev, dev_name(&pdev->dev)); in ehci_orion_drv_probe()
249 err = -ENOMEM; in ehci_orion_drv_probe()
253 hcd->rsrc_start = res->start; in ehci_orion_drv_probe()
254 hcd->rsrc_len = resource_size(res); in ehci_orion_drv_probe()
255 hcd->regs = regs; in ehci_orion_drv_probe()
257 ehci = hcd_to_ehci(hcd); in ehci_orion_drv_probe()
258 ehci->caps = hcd->regs + 0x100; in ehci_orion_drv_probe()
259 hcd->has_tt = 1; in ehci_orion_drv_probe()
266 priv->clk = devm_clk_get(&pdev->dev, NULL); in ehci_orion_drv_probe()
267 if (!IS_ERR(priv->clk)) { in ehci_orion_drv_probe()
268 err = clk_prepare_enable(priv->clk); in ehci_orion_drv_probe()
273 priv->phy = devm_phy_optional_get(&pdev->dev, "usb"); in ehci_orion_drv_probe()
274 if (IS_ERR(priv->phy)) { in ehci_orion_drv_probe()
275 err = PTR_ERR(priv->phy); in ehci_orion_drv_probe()
276 if (err != -ENOSYS) in ehci_orion_drv_probe()
281 * (Re-)program MBUS remapping windows if we are asked to. in ehci_orion_drv_probe()
288 * setup Orion USB controller. in ehci_orion_drv_probe()
290 if (pdev->dev.of_node) in ehci_orion_drv_probe()
293 phy_version = pd->phy_version; in ehci_orion_drv_probe()
296 case EHCI_PHY_NA: /* dont change USB phy settings */ in ehci_orion_drv_probe()
304 dev_warn(&pdev->dev, "USB phy version isn't supported.\n"); in ehci_orion_drv_probe()
311 device_wakeup_enable(hcd->self.controller); in ehci_orion_drv_probe()
315 if (!IS_ERR(priv->clk)) in ehci_orion_drv_probe()
316 clk_disable_unprepare(priv->clk); in ehci_orion_drv_probe()
320 dev_err(&pdev->dev, "init %s fail, %d\n", in ehci_orion_drv_probe()
321 dev_name(&pdev->dev), err); in ehci_orion_drv_probe()
333 if (!IS_ERR(priv->clk)) in ehci_orion_drv_remove()
334 clk_disable_unprepare(priv->clk); in ehci_orion_drv_remove()
342 { .compatible = "marvell,orion-ehci", },
343 { .compatible = "marvell,armada-3700-ehci", },
353 .name = "orion-ehci",
362 return -ENODEV; in ehci_orion_init()
378 MODULE_ALIAS("platform:orion-ehci");