1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
5 * Derived from linux/arch/mips/bcm63xx/usb-common.c:
6 * Copyright 2008 Maxime Bizon <mbizon@freebox.fr>
7 * Copyright 2013 Florian Fainelli <florian@openwrt.org>
12 #include <generic-phy.h>
15 #include <dm/device.h>
17 /* USBH Swap Control register */
18 #define USBH_SWAP_REG 0x00
19 #define USBH_SWAP_OHCI_DATA BIT(0)
20 #define USBH_SWAP_OHCI_ENDIAN BIT(1)
21 #define USBH_SWAP_EHCI_DATA BIT(3)
22 #define USBH_SWAP_EHCI_ENDIAN BIT(4)
24 /* USBH Test register */
25 #define USBH_TEST_REG 0x24
26 #define USBH_TEST_PORT_CTL 0x1c0020
28 struct bcm6358_usbh_priv {
32 static int bcm6358_usbh_init(struct phy *phy)
34 struct bcm6358_usbh_priv *priv = dev_get_priv(phy->dev);
36 /* configure to work in native cpu endian */
37 clrsetbits_be32(priv->regs + USBH_SWAP_REG,
38 USBH_SWAP_EHCI_ENDIAN | USBH_SWAP_OHCI_ENDIAN,
39 USBH_SWAP_EHCI_DATA | USBH_SWAP_OHCI_DATA);
41 /* test port control */
42 writel_be(USBH_TEST_PORT_CTL, priv->regs + USBH_TEST_REG);
47 static struct phy_ops bcm6358_usbh_ops = {
48 .init = bcm6358_usbh_init,
51 static const struct udevice_id bcm6358_usbh_ids[] = {
52 { .compatible = "brcm,bcm6358-usbh" },
56 static int bcm6358_usbh_probe(struct udevice *dev)
58 struct bcm6358_usbh_priv *priv = dev_get_priv(dev);
59 struct reset_ctl rst_ctl;
62 priv->regs = dev_remap_addr(dev);
67 ret = reset_get_by_index(dev, 0, &rst_ctl);
71 ret = reset_deassert(&rst_ctl);
75 ret = reset_free(&rst_ctl);
82 U_BOOT_DRIVER(bcm6358_usbh) = {
83 .name = "bcm6358-usbh",
85 .of_match = bcm6358_usbh_ids,
86 .ops = &bcm6358_usbh_ops,
87 .priv_auto_alloc_size = sizeof(struct bcm6358_usbh_priv),
88 .probe = bcm6358_usbh_probe,