123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- // 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_alloc_size = 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_alloc_size = sizeof(struct ipq4019_usb_phy),
- };
|