2 * Copyright (C) 2018 Ã
\81lvaro Fernández Rojas <noltari@gmail.com>
4 * Derived from linux/arch/mips/bcm63xx/usb-common.c:
5 * Copyright 2008 Maxime Bizon <mbizon@freebox.fr>
6 * Copyright 2013 Florian Fainelli <florian@openwrt.org>
8 * SPDX-License-Identifier: GPL-2.0+
13 #include <generic-phy.h>
16 #include <dm/device.h>
18 /* USBH Swap Control register */
19 #define USBH_SWAP_REG 0x00
20 #define USBH_SWAP_OHCI_DATA BIT(0)
21 #define USBH_SWAP_OHCI_ENDIAN BIT(1)
22 #define USBH_SWAP_EHCI_DATA BIT(3)
23 #define USBH_SWAP_EHCI_ENDIAN BIT(4)
25 /* USBH Test register */
26 #define USBH_TEST_REG 0x24
27 #define USBH_TEST_PORT_CTL 0x1c0020
29 struct bcm6358_usbh_priv {
33 static int bcm6358_usbh_init(struct phy *phy)
35 struct bcm6358_usbh_priv *priv = dev_get_priv(phy->dev);
37 /* configure to work in native cpu endian */
38 clrsetbits_be32(priv->regs + USBH_SWAP_REG,
39 USBH_SWAP_EHCI_ENDIAN | USBH_SWAP_OHCI_ENDIAN,
40 USBH_SWAP_EHCI_DATA | USBH_SWAP_OHCI_DATA);
42 /* test port control */
43 writel_be(USBH_TEST_PORT_CTL, priv->regs + USBH_TEST_REG);
48 static struct phy_ops bcm6358_usbh_ops = {
49 .init = bcm6358_usbh_init,
52 static const struct udevice_id bcm6358_usbh_ids[] = {
53 { .compatible = "brcm,bcm6358-usbh" },
57 static int bcm6358_usbh_probe(struct udevice *dev)
59 struct bcm6358_usbh_priv *priv = dev_get_priv(dev);
60 struct reset_ctl rst_ctl;
65 addr = devfdt_get_addr_size_index(dev, 0, &size);
66 if (addr == FDT_ADDR_T_NONE)
69 priv->regs = ioremap(addr, size);
72 ret = reset_get_by_index(dev, 0, &rst_ctl);
76 ret = reset_deassert(&rst_ctl);
80 ret = reset_free(&rst_ctl);
87 U_BOOT_DRIVER(bcm6358_usbh) = {
88 .name = "bcm6358-usbh",
90 .of_match = bcm6358_usbh_ids,
91 .ops = &bcm6358_usbh_ops,
92 .priv_auto_alloc_size = sizeof(struct bcm6358_usbh_priv),
93 .probe = bcm6358_usbh_probe,