diff options
-rw-r--r-- | drivers/usb/dwc3/dwc3-exynos.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index ed22d722884e..0ed85834bfec 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/usb/usb_phy_generic.h> | 27 | #include <linux/usb/usb_phy_generic.h> |
28 | #include <linux/of.h> | 28 | #include <linux/of.h> |
29 | #include <linux/of_platform.h> | 29 | #include <linux/of_platform.h> |
30 | #include <linux/regulator/consumer.h> | ||
30 | 31 | ||
31 | struct dwc3_exynos { | 32 | struct dwc3_exynos { |
32 | struct platform_device *usb2_phy; | 33 | struct platform_device *usb2_phy; |
@@ -34,6 +35,8 @@ struct dwc3_exynos { | |||
34 | struct device *dev; | 35 | struct device *dev; |
35 | 36 | ||
36 | struct clk *clk; | 37 | struct clk *clk; |
38 | struct regulator *vdd33; | ||
39 | struct regulator *vdd10; | ||
37 | }; | 40 | }; |
38 | 41 | ||
39 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | 42 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) |
@@ -144,20 +147,46 @@ static int dwc3_exynos_probe(struct platform_device *pdev) | |||
144 | 147 | ||
145 | clk_prepare_enable(exynos->clk); | 148 | clk_prepare_enable(exynos->clk); |
146 | 149 | ||
150 | exynos->vdd33 = devm_regulator_get(dev, "vdd33"); | ||
151 | if (IS_ERR(exynos->vdd33)) { | ||
152 | ret = PTR_ERR(exynos->vdd33); | ||
153 | goto err2; | ||
154 | } | ||
155 | ret = regulator_enable(exynos->vdd33); | ||
156 | if (ret) { | ||
157 | dev_err(dev, "Failed to enable VDD33 supply\n"); | ||
158 | goto err2; | ||
159 | } | ||
160 | |||
161 | exynos->vdd10 = devm_regulator_get(dev, "vdd10"); | ||
162 | if (IS_ERR(exynos->vdd10)) { | ||
163 | ret = PTR_ERR(exynos->vdd10); | ||
164 | goto err3; | ||
165 | } | ||
166 | ret = regulator_enable(exynos->vdd10); | ||
167 | if (ret) { | ||
168 | dev_err(dev, "Failed to enable VDD10 supply\n"); | ||
169 | goto err3; | ||
170 | } | ||
171 | |||
147 | if (node) { | 172 | if (node) { |
148 | ret = of_platform_populate(node, NULL, NULL, dev); | 173 | ret = of_platform_populate(node, NULL, NULL, dev); |
149 | if (ret) { | 174 | if (ret) { |
150 | dev_err(dev, "failed to add dwc3 core\n"); | 175 | dev_err(dev, "failed to add dwc3 core\n"); |
151 | goto err2; | 176 | goto err4; |
152 | } | 177 | } |
153 | } else { | 178 | } else { |
154 | dev_err(dev, "no device node, failed to add dwc3 core\n"); | 179 | dev_err(dev, "no device node, failed to add dwc3 core\n"); |
155 | ret = -ENODEV; | 180 | ret = -ENODEV; |
156 | goto err2; | 181 | goto err4; |
157 | } | 182 | } |
158 | 183 | ||
159 | return 0; | 184 | return 0; |
160 | 185 | ||
186 | err4: | ||
187 | regulator_disable(exynos->vdd10); | ||
188 | err3: | ||
189 | regulator_disable(exynos->vdd33); | ||
161 | err2: | 190 | err2: |
162 | clk_disable_unprepare(clk); | 191 | clk_disable_unprepare(clk); |
163 | err1: | 192 | err1: |
@@ -174,6 +203,9 @@ static int dwc3_exynos_remove(struct platform_device *pdev) | |||
174 | 203 | ||
175 | clk_disable_unprepare(exynos->clk); | 204 | clk_disable_unprepare(exynos->clk); |
176 | 205 | ||
206 | regulator_disable(exynos->vdd33); | ||
207 | regulator_disable(exynos->vdd10); | ||
208 | |||
177 | return 0; | 209 | return 0; |
178 | } | 210 | } |
179 | 211 | ||
@@ -192,12 +224,27 @@ static int dwc3_exynos_suspend(struct device *dev) | |||
192 | 224 | ||
193 | clk_disable(exynos->clk); | 225 | clk_disable(exynos->clk); |
194 | 226 | ||
227 | regulator_disable(exynos->vdd33); | ||
228 | regulator_disable(exynos->vdd10); | ||
229 | |||
195 | return 0; | 230 | return 0; |
196 | } | 231 | } |
197 | 232 | ||
198 | static int dwc3_exynos_resume(struct device *dev) | 233 | static int dwc3_exynos_resume(struct device *dev) |
199 | { | 234 | { |
200 | struct dwc3_exynos *exynos = dev_get_drvdata(dev); | 235 | struct dwc3_exynos *exynos = dev_get_drvdata(dev); |
236 | int ret; | ||
237 | |||
238 | ret = regulator_enable(exynos->vdd33); | ||
239 | if (ret) { | ||
240 | dev_err(dev, "Failed to enable VDD33 supply\n"); | ||
241 | return ret; | ||
242 | } | ||
243 | ret = regulator_enable(exynos->vdd10); | ||
244 | if (ret) { | ||
245 | dev_err(dev, "Failed to enable VDD10 supply\n"); | ||
246 | return ret; | ||
247 | } | ||
201 | 248 | ||
202 | clk_enable(exynos->clk); | 249 | clk_enable(exynos->clk); |
203 | 250 | ||