1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2019 Sartura Ltd.
5 * Author: Robert Marko <robert.marko@sartura.hr>
7 * Based on Linux driver
13 #include <generic-phy.h>
17 #include <linux/delay.h>
19 struct ipq4019_usb_phy {
21 struct reset_ctl por_rst;
22 struct reset_ctl srif_rst;
25 static int ipq4019_ss_phy_power_off(struct phy *_phy)
27 struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
29 reset_assert(&phy->por_rst);
35 static int ipq4019_ss_phy_power_on(struct phy *_phy)
37 struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
39 ipq4019_ss_phy_power_off(_phy);
41 reset_deassert(&phy->por_rst);
46 static struct phy_ops ipq4019_usb_ss_phy_ops = {
47 .power_on = ipq4019_ss_phy_power_on,
48 .power_off = ipq4019_ss_phy_power_off,
51 static int ipq4019_usb_ss_phy_probe(struct udevice *dev)
53 struct ipq4019_usb_phy *phy = dev_get_priv(dev);
56 phy->base = dev_read_addr(dev);
57 if (phy->base == FDT_ADDR_T_NONE)
60 ret = reset_get_by_name(dev, "por_rst", &phy->por_rst);
67 static const struct udevice_id ipq4019_usb_ss_phy_ids[] = {
68 { .compatible = "qcom,usb-ss-ipq4019-phy" },
72 U_BOOT_DRIVER(ipq4019_usb_ss_phy) = {
73 .name = "ipq4019-usb-ss-phy",
75 .of_match = ipq4019_usb_ss_phy_ids,
76 .ops = &ipq4019_usb_ss_phy_ops,
77 .probe = ipq4019_usb_ss_phy_probe,
78 .priv_auto = sizeof(struct ipq4019_usb_phy),
81 static int ipq4019_hs_phy_power_off(struct phy *_phy)
83 struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
85 reset_assert(&phy->por_rst);
88 reset_assert(&phy->srif_rst);
94 static int ipq4019_hs_phy_power_on(struct phy *_phy)
96 struct ipq4019_usb_phy *phy = dev_get_priv(_phy->dev);
98 ipq4019_hs_phy_power_off(_phy);
100 reset_deassert(&phy->srif_rst);
103 reset_deassert(&phy->por_rst);
108 static struct phy_ops ipq4019_usb_hs_phy_ops = {
109 .power_on = ipq4019_hs_phy_power_on,
110 .power_off = ipq4019_hs_phy_power_off,
113 static int ipq4019_usb_hs_phy_probe(struct udevice *dev)
115 struct ipq4019_usb_phy *phy = dev_get_priv(dev);
118 phy->base = dev_read_addr(dev);
119 if (phy->base == FDT_ADDR_T_NONE)
122 ret = reset_get_by_name(dev, "por_rst", &phy->por_rst);
126 ret = reset_get_by_name(dev, "srif_rst", &phy->srif_rst);
133 static const struct udevice_id ipq4019_usb_hs_phy_ids[] = {
134 { .compatible = "qcom,usb-hs-ipq4019-phy" },
138 U_BOOT_DRIVER(ipq4019_usb_hs_phy) = {
139 .name = "ipq4019-usb-hs-phy",
141 .of_match = ipq4019_usb_hs_phy_ids,
142 .ops = &ipq4019_usb_hs_phy_ops,
143 .probe = ipq4019_usb_hs_phy_probe,
144 .priv_auto = sizeof(struct ipq4019_usb_phy),