mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-09-19 21:01:51 +02:00
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <jonas@kwiboo.se> Signed-off-by: Tom Rini <trini@konsulko.com>
109 lines
2.0 KiB
C
109 lines
2.0 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (c) 2021 Nuvoton Technology Corp.
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <generic-phy.h>
|
|
#include <reset.h>
|
|
#include <asm/io.h>
|
|
#include <dm/device_compat.h>
|
|
#include <linux/delay.h>
|
|
#include "ohci.h"
|
|
|
|
struct npcm_ohci_priv {
|
|
ohci_t ohci;
|
|
struct phy phy;
|
|
};
|
|
|
|
static int npcm_ohci_setup_phy(struct udevice *dev, struct phy *phy)
|
|
{
|
|
int ret;
|
|
|
|
if (!phy)
|
|
return 0;
|
|
|
|
ret = generic_phy_get_by_index(dev, 0, phy);
|
|
if (ret) {
|
|
if (ret != -ENOENT) {
|
|
dev_err(dev, "failed to get usb phy\n");
|
|
return ret;
|
|
}
|
|
} else {
|
|
ret = generic_phy_init(phy);
|
|
if (ret) {
|
|
dev_err(dev, "failed to init usb phy\n");
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int npcm_ohci_init(struct udevice *dev)
|
|
{
|
|
struct npcm_ohci_priv *priv = dev_get_priv(dev);
|
|
struct reset_ctl reset;
|
|
int ret;
|
|
|
|
ret = reset_get_by_index(dev, 0, &reset);
|
|
if (ret && ret != -ENOENT && ret != -ENOTSUPP) {
|
|
dev_err(dev, "failed to get reset\n");
|
|
return ret;
|
|
}
|
|
|
|
/* reset controller */
|
|
if (reset_valid(&reset))
|
|
reset_assert(&reset);
|
|
|
|
/* setup phy */
|
|
ret = npcm_ohci_setup_phy(dev, &priv->phy);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* release controller from reset */
|
|
if (reset_valid(&reset))
|
|
reset_deassert(&reset);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int npcm_ohci_probe(struct udevice *dev)
|
|
{
|
|
struct ohci_regs *regs = dev_read_addr_ptr(dev);
|
|
int ret;
|
|
|
|
ret = npcm_ohci_init(dev);
|
|
if (ret)
|
|
return ret;
|
|
|
|
return ohci_register(dev, regs);
|
|
}
|
|
|
|
static int npcm_ohci_remove(struct udevice *dev)
|
|
{
|
|
struct npcm_ohci_priv *priv = dev_get_priv(dev);
|
|
|
|
generic_phy_exit(&priv->phy);
|
|
|
|
return ohci_deregister(dev);
|
|
}
|
|
|
|
static const struct udevice_id npcm_ohci_ids[] = {
|
|
{ .compatible = "nuvoton,npcm845-ohci" },
|
|
{ .compatible = "nuvoton,npcm750-ohci" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(ohci_npcm) = {
|
|
.name = "ohci_npcm",
|
|
.id = UCLASS_USB,
|
|
.of_match = npcm_ohci_ids,
|
|
.probe = npcm_ohci_probe,
|
|
.remove = npcm_ohci_remove,
|
|
.ops = &ohci_usb_ops,
|
|
.priv_auto = sizeof(struct npcm_ohci_priv),
|
|
.flags = DM_FLAG_ALLOC_PRIV_DMA,
|
|
};
|