Lines Matching full:phy

3  * Allwinner sun9i USB phy driver
7 * Based on phy-sun4i-usb.c from
18 #include <linux/phy/phy.h>
36 struct phy *phy; member
44 static void sun9i_usb_phy_passby(struct sun9i_usb_phy *phy, int enable) in sun9i_usb_phy_passby() argument
52 if (phy->type == USBPHY_INTERFACE_MODE_HSIC) in sun9i_usb_phy_passby()
56 reg_value = readl(phy->pmu); in sun9i_usb_phy_passby()
63 writel(reg_value, phy->pmu); in sun9i_usb_phy_passby()
66 static int sun9i_usb_phy_init(struct phy *_phy) in sun9i_usb_phy_init()
68 struct sun9i_usb_phy *phy = phy_get_drvdata(_phy); in sun9i_usb_phy_init() local
71 ret = clk_prepare_enable(phy->clk); in sun9i_usb_phy_init()
75 ret = clk_prepare_enable(phy->hsic_clk); in sun9i_usb_phy_init()
79 ret = reset_control_deassert(phy->reset); in sun9i_usb_phy_init()
83 sun9i_usb_phy_passby(phy, 1); in sun9i_usb_phy_init()
87 clk_disable_unprepare(phy->hsic_clk); in sun9i_usb_phy_init()
90 clk_disable_unprepare(phy->clk); in sun9i_usb_phy_init()
96 static int sun9i_usb_phy_exit(struct phy *_phy) in sun9i_usb_phy_exit()
98 struct sun9i_usb_phy *phy = phy_get_drvdata(_phy); in sun9i_usb_phy_exit() local
100 sun9i_usb_phy_passby(phy, 0); in sun9i_usb_phy_exit()
101 reset_control_assert(phy->reset); in sun9i_usb_phy_exit()
102 clk_disable_unprepare(phy->hsic_clk); in sun9i_usb_phy_exit()
103 clk_disable_unprepare(phy->clk); in sun9i_usb_phy_exit()
116 struct sun9i_usb_phy *phy; in sun9i_usb_phy_probe() local
122 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); in sun9i_usb_phy_probe()
123 if (!phy) in sun9i_usb_phy_probe()
126 phy->type = of_usb_get_phy_mode(np); in sun9i_usb_phy_probe()
127 if (phy->type == USBPHY_INTERFACE_MODE_HSIC) { in sun9i_usb_phy_probe()
128 phy->clk = devm_clk_get(dev, "hsic_480M"); in sun9i_usb_phy_probe()
129 if (IS_ERR(phy->clk)) { in sun9i_usb_phy_probe()
131 return PTR_ERR(phy->clk); in sun9i_usb_phy_probe()
134 phy->hsic_clk = devm_clk_get(dev, "hsic_12M"); in sun9i_usb_phy_probe()
135 if (IS_ERR(phy->hsic_clk)) { in sun9i_usb_phy_probe()
137 return PTR_ERR(phy->hsic_clk); in sun9i_usb_phy_probe()
140 phy->reset = devm_reset_control_get(dev, "hsic"); in sun9i_usb_phy_probe()
141 if (IS_ERR(phy->reset)) { in sun9i_usb_phy_probe()
143 return PTR_ERR(phy->reset); in sun9i_usb_phy_probe()
146 phy->clk = devm_clk_get(dev, "phy"); in sun9i_usb_phy_probe()
147 if (IS_ERR(phy->clk)) { in sun9i_usb_phy_probe()
148 dev_err(dev, "failed to get phy clock\n"); in sun9i_usb_phy_probe()
149 return PTR_ERR(phy->clk); in sun9i_usb_phy_probe()
152 phy->reset = devm_reset_control_get(dev, "phy"); in sun9i_usb_phy_probe()
153 if (IS_ERR(phy->reset)) { in sun9i_usb_phy_probe()
155 return PTR_ERR(phy->reset); in sun9i_usb_phy_probe()
160 phy->pmu = devm_ioremap_resource(dev, res); in sun9i_usb_phy_probe()
161 if (IS_ERR(phy->pmu)) in sun9i_usb_phy_probe()
162 return PTR_ERR(phy->pmu); in sun9i_usb_phy_probe()
164 phy->phy = devm_phy_create(dev, NULL, &sun9i_usb_phy_ops); in sun9i_usb_phy_probe()
165 if (IS_ERR(phy->phy)) { in sun9i_usb_phy_probe()
166 dev_err(dev, "failed to create PHY\n"); in sun9i_usb_phy_probe()
167 return PTR_ERR(phy->phy); in sun9i_usb_phy_probe()
170 phy_set_drvdata(phy->phy, phy); in sun9i_usb_phy_probe()
177 { .compatible = "allwinner,sun9i-a80-usb-phy" },
186 .name = "sun9i-usb-phy",
191 MODULE_DESCRIPTION("Allwinner sun9i USB phy driver");