1 // SPDX-License-Identifier: GPL-2.0+
5 * Derived from linux/arch/mips/bcm63xx/usb-common.c:
12 #include <generic-phy.h>
17 #include <dm/device.h>
18 #include <linux/bitops.h>
20 /* USBH Swap Control register */
21 #define USBH_SWAP_REG 0x00
22 #define USBH_SWAP_OHCI_DATA BIT(0)
23 #define USBH_SWAP_OHCI_ENDIAN BIT(1)
24 #define USBH_SWAP_EHCI_DATA BIT(3)
25 #define USBH_SWAP_EHCI_ENDIAN BIT(4)
27 /* USBH Test register */
28 #define USBH_TEST_REG 0x24
29 #define USBH_TEST_PORT_CTL 0x1c0020
31 struct bcm6358_usbh_priv {
35 static int bcm6358_usbh_init(struct phy *phy)
37 struct bcm6358_usbh_priv *priv = dev_get_priv(phy->dev);
39 /* configure to work in native cpu endian */
40 clrsetbits_be32(priv->regs + USBH_SWAP_REG,
41 USBH_SWAP_EHCI_ENDIAN | USBH_SWAP_OHCI_ENDIAN,
42 USBH_SWAP_EHCI_DATA | USBH_SWAP_OHCI_DATA);
44 /* test port control */
45 writel_be(USBH_TEST_PORT_CTL, priv->regs + USBH_TEST_REG);
50 static struct phy_ops bcm6358_usbh_ops = {
51 .init = bcm6358_usbh_init,
54 static const struct udevice_id bcm6358_usbh_ids[] = {
55 { .compatible = "brcm,bcm6358-usbh" },
59 static int bcm6358_usbh_probe(struct udevice *dev)
61 struct bcm6358_usbh_priv *priv = dev_get_priv(dev);
62 struct reset_ctl rst_ctl;
65 priv->regs = dev_remap_addr(dev);
70 ret = reset_get_by_index(dev, 0, &rst_ctl);
74 ret = reset_deassert(&rst_ctl);
78 ret = reset_free(&rst_ctl);
85 U_BOOT_DRIVER(bcm6358_usbh) = {
86 .name = "bcm6358-usbh",
88 .of_match = bcm6358_usbh_ids,
89 .ops = &bcm6358_usbh_ops,
90 .priv_auto = sizeof(struct bcm6358_usbh_priv),
91 .probe = bcm6358_usbh_probe,