u-boot/drivers/phy/qcom/phy-qcom-ipq4019-usb.c
Tom Rini d678a59d2d Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
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 c8ffd1356d, reversing
changes made to 2ee6f3a5f7.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>
2024-05-19 08:16:36 -06:00

146 lines
2.9 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 Sartura Ltd.
*
* Author: Robert Marko <robert.marko@sartura.hr>
*
* Based on Linux driver
*/
#include <clk.h>
#include <common.h>
#include <dm.h>
#include <generic-phy.h>
#include <log.h>
#include <reset.h>
#include <asm/io.h>
#include <linux/delay.h>
struct ipq4019_usb_phy {
phys_addr_t base;
struct reset_ctl por_rst;
struct reset_ctl srif_rst;
};
static int ipq4019_ss_phy_power_off(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
reset_assert(&phy->por_rst);
mdelay(10);
return 0;
}
static int ipq4019_ss_phy_power_on(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
ipq4019_ss_phy_power_off(_phy);
reset_deassert(&phy->por_rst);
return 0;
}
static struct phy_ops ipq4019_usb_ss_phy_ops = {
.power_on = ipq4019_ss_phy_power_on,
.power_off = ipq4019_ss_phy_power_off,
};
static int ipq4019_usb_ss_phy_probe(struct udevice *dev)
{
struct ipq4019_usb_phy *phy = dev_get_priv(dev);
int ret;
phy->base = dev_read_addr(dev);
if (phy->base == FDT_ADDR_T_NONE)
return -EINVAL;
ret = reset_get_by_name(dev, "por_rst", &phy->por_rst);
if (ret)
return ret;
return 0;
}
static const struct udevice_id ipq4019_usb_ss_phy_ids[] = {
{ .compatible = "qcom,usb-ss-ipq4019-phy" },
{ }
};
U_BOOT_DRIVER(ipq4019_usb_ss_phy) = {
.name = "ipq4019-usb-ss-phy",
.id = UCLASS_PHY,
.of_match = ipq4019_usb_ss_phy_ids,
.ops = &ipq4019_usb_ss_phy_ops,
.probe = ipq4019_usb_ss_phy_probe,
.priv_auto = sizeof(struct ipq4019_usb_phy),
};
static int ipq4019_hs_phy_power_off(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
reset_assert(&phy->por_rst);
mdelay(10);
reset_assert(&phy->srif_rst);
mdelay(10);
return 0;
}
static int ipq4019_hs_phy_power_on(struct phy *_phy)
{
struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
ipq4019_hs_phy_power_off(_phy);
reset_deassert(&phy->srif_rst);
mdelay(10);
reset_deassert(&phy->por_rst);
return 0;
}
static struct phy_ops ipq4019_usb_hs_phy_ops = {
.power_on = ipq4019_hs_phy_power_on,
.power_off = ipq4019_hs_phy_power_off,
};
static int ipq4019_usb_hs_phy_probe(struct udevice *dev)
{
struct ipq4019_usb_phy *phy = dev_get_priv(dev);
int ret;
phy->base = dev_read_addr(dev);
if (phy->base == FDT_ADDR_T_NONE)
return -EINVAL;
ret = reset_get_by_name(dev, "por_rst", &phy->por_rst);
if (ret)
return ret;
ret = reset_get_by_name(dev, "srif_rst", &phy->srif_rst);
if (ret)
return ret;
return 0;
}
static const struct udevice_id ipq4019_usb_hs_phy_ids[] = {
{ .compatible = "qcom,usb-hs-ipq4019-phy" },
{ }
};
U_BOOT_DRIVER(ipq4019_usb_hs_phy) = {
.name = "ipq4019-usb-hs-phy",
.id = UCLASS_PHY,
.of_match = ipq4019_usb_hs_phy_ids,
.ops = &ipq4019_usb_hs_phy_ops,
.probe = ipq4019_usb_hs_phy_probe,
.priv_auto = sizeof(struct ipq4019_usb_phy),
};