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;
44 static void sun9i_usb_phy_passby(struct sun9i_usb_phy *phy, int enable)
52 if (phy->type == USBPHY_INTERFACE_MODE_HSIC)
56 reg_value = readl(phy->pmu);
63 writel(reg_value, phy->pmu);
66 static int sun9i_usb_phy_init(struct phy *_phy)
68 struct sun9i_usb_phy *phy = phy_get_drvdata(_phy);
71 ret = clk_prepare_enable(phy->clk);
75 ret = clk_prepare_enable(phy->hsic_clk);
79 ret = reset_control_deassert(phy->reset);
83 sun9i_usb_phy_passby(phy, 1);
87 clk_disable_unprepare(phy->hsic_clk);
90 clk_disable_unprepare(phy->clk);
96 static int sun9i_usb_phy_exit(struct phy *_phy)
98 struct sun9i_usb_phy *phy = phy_get_drvdata(_phy);
100 sun9i_usb_phy_passby(phy, 0);
101 reset_control_assert(phy->reset);
102 clk_disable_unprepare(phy->hsic_clk);
103 clk_disable_unprepare(phy->clk);
116 struct sun9i_usb_phy *phy;
121 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
122 if (!phy)
125 phy->type = of_usb_get_phy_mode(np);
126 if (phy->type == USBPHY_INTERFACE_MODE_HSIC) {
127 phy->clk = devm_clk_get(dev, "hsic_480M");
128 if (IS_ERR(phy->clk)) {
130 return PTR_ERR(phy->clk);
133 phy->hsic_clk = devm_clk_get(dev, "hsic_12M");
134 if (IS_ERR(phy->hsic_clk)) {
136 return PTR_ERR(phy->hsic_clk);
139 phy->reset = devm_reset_control_get(dev, "hsic");
140 if (IS_ERR(phy->reset)) {
142 return PTR_ERR(phy->reset);
145 phy->clk = devm_clk_get(dev, "phy");
146 if (IS_ERR(phy->clk)) {
147 dev_err(dev, "failed to get phy clock\n");
148 return PTR_ERR(phy->clk);
151 phy->reset = devm_reset_control_get(dev, "phy");
152 if (IS_ERR(phy->reset)) {
154 return PTR_ERR(phy->reset);
158 phy->pmu = devm_platform_ioremap_resource(pdev, 0);
159 if (IS_ERR(phy->pmu))
160 return PTR_ERR(phy->pmu);
162 phy->phy = devm_phy_create(dev, NULL, &sun9i_usb_phy_ops);
163 if (IS_ERR(phy->phy)) {
164 dev_err(dev, "failed to create PHY\n");
165 return PTR_ERR(phy->phy);
168 phy_set_drvdata(phy->phy, phy);
175 { .compatible = "allwinner,sun9i-a80-usb-phy" },
184 .name = "sun9i-usb-phy",
189 MODULE_DESCRIPTION("Allwinner sun9i USB phy driver");