diff options
Diffstat (limited to 'drivers/phy')
-rw-r--r-- | drivers/phy/Kconfig | 3 | ||||
-rw-r--r-- | drivers/phy/phy-core.c | 76 | ||||
-rw-r--r-- | drivers/phy/phy-exynos-dp-video.c | 8 | ||||
-rw-r--r-- | drivers/phy/phy-exynos-mipi-video.c | 10 | ||||
-rw-r--r-- | drivers/phy/phy-mvebu-sata.c | 10 | ||||
-rw-r--r-- | drivers/phy/phy-omap-usb2.c | 10 | ||||
-rw-r--r-- | drivers/phy/phy-twl4030-usb.c | 10 |
7 files changed, 93 insertions, 34 deletions
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index afa2354f6600..c7a551c2d5f1 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig | |||
@@ -5,7 +5,7 @@ | |||
5 | menu "PHY Subsystem" | 5 | menu "PHY Subsystem" |
6 | 6 | ||
7 | config GENERIC_PHY | 7 | config GENERIC_PHY |
8 | tristate "PHY Core" | 8 | bool "PHY Core" |
9 | help | 9 | help |
10 | Generic PHY support. | 10 | Generic PHY support. |
11 | 11 | ||
@@ -61,6 +61,7 @@ config PHY_EXYNOS_DP_VIDEO | |||
61 | config BCM_KONA_USB2_PHY | 61 | config BCM_KONA_USB2_PHY |
62 | tristate "Broadcom Kona USB2 PHY Driver" | 62 | tristate "Broadcom Kona USB2 PHY Driver" |
63 | depends on GENERIC_PHY | 63 | depends on GENERIC_PHY |
64 | depends on HAS_IOMEM | ||
64 | help | 65 | help |
65 | Enable this to support the Broadcom Kona USB 2.0 PHY. | 66 | Enable this to support the Broadcom Kona USB 2.0 PHY. |
66 | 67 | ||
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 645c867c1257..6c738376daff 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c | |||
@@ -162,6 +162,9 @@ int phy_init(struct phy *phy) | |||
162 | { | 162 | { |
163 | int ret; | 163 | int ret; |
164 | 164 | ||
165 | if (!phy) | ||
166 | return 0; | ||
167 | |||
165 | ret = phy_pm_runtime_get_sync(phy); | 168 | ret = phy_pm_runtime_get_sync(phy); |
166 | if (ret < 0 && ret != -ENOTSUPP) | 169 | if (ret < 0 && ret != -ENOTSUPP) |
167 | return ret; | 170 | return ret; |
@@ -173,6 +176,8 @@ int phy_init(struct phy *phy) | |||
173 | dev_err(&phy->dev, "phy init failed --> %d\n", ret); | 176 | dev_err(&phy->dev, "phy init failed --> %d\n", ret); |
174 | goto out; | 177 | goto out; |
175 | } | 178 | } |
179 | } else { | ||
180 | ret = 0; /* Override possible ret == -ENOTSUPP */ | ||
176 | } | 181 | } |
177 | ++phy->init_count; | 182 | ++phy->init_count; |
178 | 183 | ||
@@ -187,6 +192,9 @@ int phy_exit(struct phy *phy) | |||
187 | { | 192 | { |
188 | int ret; | 193 | int ret; |
189 | 194 | ||
195 | if (!phy) | ||
196 | return 0; | ||
197 | |||
190 | ret = phy_pm_runtime_get_sync(phy); | 198 | ret = phy_pm_runtime_get_sync(phy); |
191 | if (ret < 0 && ret != -ENOTSUPP) | 199 | if (ret < 0 && ret != -ENOTSUPP) |
192 | return ret; | 200 | return ret; |
@@ -212,6 +220,9 @@ int phy_power_on(struct phy *phy) | |||
212 | { | 220 | { |
213 | int ret; | 221 | int ret; |
214 | 222 | ||
223 | if (!phy) | ||
224 | return 0; | ||
225 | |||
215 | ret = phy_pm_runtime_get_sync(phy); | 226 | ret = phy_pm_runtime_get_sync(phy); |
216 | if (ret < 0 && ret != -ENOTSUPP) | 227 | if (ret < 0 && ret != -ENOTSUPP) |
217 | return ret; | 228 | return ret; |
@@ -223,6 +234,8 @@ int phy_power_on(struct phy *phy) | |||
223 | dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); | 234 | dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); |
224 | goto out; | 235 | goto out; |
225 | } | 236 | } |
237 | } else { | ||
238 | ret = 0; /* Override possible ret == -ENOTSUPP */ | ||
226 | } | 239 | } |
227 | ++phy->power_count; | 240 | ++phy->power_count; |
228 | mutex_unlock(&phy->mutex); | 241 | mutex_unlock(&phy->mutex); |
@@ -240,6 +253,9 @@ int phy_power_off(struct phy *phy) | |||
240 | { | 253 | { |
241 | int ret; | 254 | int ret; |
242 | 255 | ||
256 | if (!phy) | ||
257 | return 0; | ||
258 | |||
243 | mutex_lock(&phy->mutex); | 259 | mutex_lock(&phy->mutex); |
244 | if (phy->power_count == 1 && phy->ops->power_off) { | 260 | if (phy->power_count == 1 && phy->ops->power_off) { |
245 | ret = phy->ops->power_off(phy); | 261 | ret = phy->ops->power_off(phy); |
@@ -308,7 +324,7 @@ err0: | |||
308 | */ | 324 | */ |
309 | void phy_put(struct phy *phy) | 325 | void phy_put(struct phy *phy) |
310 | { | 326 | { |
311 | if (IS_ERR(phy)) | 327 | if (!phy || IS_ERR(phy)) |
312 | return; | 328 | return; |
313 | 329 | ||
314 | module_put(phy->ops->owner); | 330 | module_put(phy->ops->owner); |
@@ -328,6 +344,9 @@ void devm_phy_put(struct device *dev, struct phy *phy) | |||
328 | { | 344 | { |
329 | int r; | 345 | int r; |
330 | 346 | ||
347 | if (!phy) | ||
348 | return; | ||
349 | |||
331 | r = devres_destroy(dev, devm_phy_release, devm_phy_match, phy); | 350 | r = devres_destroy(dev, devm_phy_release, devm_phy_match, phy); |
332 | dev_WARN_ONCE(dev, r, "couldn't find PHY resource\n"); | 351 | dev_WARN_ONCE(dev, r, "couldn't find PHY resource\n"); |
333 | } | 352 | } |
@@ -389,17 +408,11 @@ struct phy *phy_get(struct device *dev, const char *string) | |||
389 | index = of_property_match_string(dev->of_node, "phy-names", | 408 | index = of_property_match_string(dev->of_node, "phy-names", |
390 | string); | 409 | string); |
391 | phy = of_phy_get(dev, index); | 410 | phy = of_phy_get(dev, index); |
392 | if (IS_ERR(phy)) { | ||
393 | dev_err(dev, "unable to find phy\n"); | ||
394 | return phy; | ||
395 | } | ||
396 | } else { | 411 | } else { |
397 | phy = phy_lookup(dev, string); | 412 | phy = phy_lookup(dev, string); |
398 | if (IS_ERR(phy)) { | ||
399 | dev_err(dev, "unable to find phy\n"); | ||
400 | return phy; | ||
401 | } | ||
402 | } | 413 | } |
414 | if (IS_ERR(phy)) | ||
415 | return phy; | ||
403 | 416 | ||
404 | if (!try_module_get(phy->ops->owner)) | 417 | if (!try_module_get(phy->ops->owner)) |
405 | return ERR_PTR(-EPROBE_DEFER); | 418 | return ERR_PTR(-EPROBE_DEFER); |
@@ -411,6 +424,27 @@ struct phy *phy_get(struct device *dev, const char *string) | |||
411 | EXPORT_SYMBOL_GPL(phy_get); | 424 | EXPORT_SYMBOL_GPL(phy_get); |
412 | 425 | ||
413 | /** | 426 | /** |
427 | * phy_optional_get() - lookup and obtain a reference to an optional phy. | ||
428 | * @dev: device that requests this phy | ||
429 | * @string: the phy name as given in the dt data or the name of the controller | ||
430 | * port for non-dt case | ||
431 | * | ||
432 | * Returns the phy driver, after getting a refcount to it; or | ||
433 | * NULL if there is no such phy. The caller is responsible for | ||
434 | * calling phy_put() to release that count. | ||
435 | */ | ||
436 | struct phy *phy_optional_get(struct device *dev, const char *string) | ||
437 | { | ||
438 | struct phy *phy = phy_get(dev, string); | ||
439 | |||
440 | if (PTR_ERR(phy) == -ENODEV) | ||
441 | phy = NULL; | ||
442 | |||
443 | return phy; | ||
444 | } | ||
445 | EXPORT_SYMBOL_GPL(phy_optional_get); | ||
446 | |||
447 | /** | ||
414 | * devm_phy_get() - lookup and obtain a reference to a phy. | 448 | * devm_phy_get() - lookup and obtain a reference to a phy. |
415 | * @dev: device that requests this phy | 449 | * @dev: device that requests this phy |
416 | * @string: the phy name as given in the dt data or phy device name | 450 | * @string: the phy name as given in the dt data or phy device name |
@@ -441,6 +475,30 @@ struct phy *devm_phy_get(struct device *dev, const char *string) | |||
441 | EXPORT_SYMBOL_GPL(devm_phy_get); | 475 | EXPORT_SYMBOL_GPL(devm_phy_get); |
442 | 476 | ||
443 | /** | 477 | /** |
478 | * devm_phy_optional_get() - lookup and obtain a reference to an optional phy. | ||
479 | * @dev: device that requests this phy | ||
480 | * @string: the phy name as given in the dt data or phy device name | ||
481 | * for non-dt case | ||
482 | * | ||
483 | * Gets the phy using phy_get(), and associates a device with it using | ||
484 | * devres. On driver detach, release function is invoked on the devres | ||
485 | * data, then, devres data is freed. This differs to devm_phy_get() in | ||
486 | * that if the phy does not exist, it is not considered an error and | ||
487 | * -ENODEV will not be returned. Instead the NULL phy is returned, | ||
488 | * which can be passed to all other phy consumer calls. | ||
489 | */ | ||
490 | struct phy *devm_phy_optional_get(struct device *dev, const char *string) | ||
491 | { | ||
492 | struct phy *phy = devm_phy_get(dev, string); | ||
493 | |||
494 | if (PTR_ERR(phy) == -ENODEV) | ||
495 | phy = NULL; | ||
496 | |||
497 | return phy; | ||
498 | } | ||
499 | EXPORT_SYMBOL_GPL(devm_phy_optional_get); | ||
500 | |||
501 | /** | ||
444 | * phy_create() - create a new phy | 502 | * phy_create() - create a new phy |
445 | * @dev: device that is creating the new phy | 503 | * @dev: device that is creating the new phy |
446 | * @ops: function pointers for performing phy operations | 504 | * @ops: function pointers for performing phy operations |
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c index 1dbe6ce7b2ce..0786fef842e7 100644 --- a/drivers/phy/phy-exynos-dp-video.c +++ b/drivers/phy/phy-exynos-dp-video.c | |||
@@ -76,10 +76,6 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev) | |||
76 | if (IS_ERR(state->regs)) | 76 | if (IS_ERR(state->regs)) |
77 | return PTR_ERR(state->regs); | 77 | return PTR_ERR(state->regs); |
78 | 78 | ||
79 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | ||
80 | if (IS_ERR(phy_provider)) | ||
81 | return PTR_ERR(phy_provider); | ||
82 | |||
83 | phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL); | 79 | phy = devm_phy_create(dev, &exynos_dp_video_phy_ops, NULL); |
84 | if (IS_ERR(phy)) { | 80 | if (IS_ERR(phy)) { |
85 | dev_err(dev, "failed to create Display Port PHY\n"); | 81 | dev_err(dev, "failed to create Display Port PHY\n"); |
@@ -87,6 +83,10 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev) | |||
87 | } | 83 | } |
88 | phy_set_drvdata(phy, state); | 84 | phy_set_drvdata(phy, state); |
89 | 85 | ||
86 | phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); | ||
87 | if (IS_ERR(phy_provider)) | ||
88 | return PTR_ERR(phy_provider); | ||
89 | |||
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c index 0c5efab11af1..7f139326a642 100644 --- a/drivers/phy/phy-exynos-mipi-video.c +++ b/drivers/phy/phy-exynos-mipi-video.c | |||
@@ -134,11 +134,6 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev) | |||
134 | dev_set_drvdata(dev, state); | 134 | dev_set_drvdata(dev, state); |
135 | spin_lock_init(&state->slock); | 135 | spin_lock_init(&state->slock); |
136 | 136 | ||
137 | phy_provider = devm_of_phy_provider_register(dev, | ||
138 | exynos_mipi_video_phy_xlate); | ||
139 | if (IS_ERR(phy_provider)) | ||
140 | return PTR_ERR(phy_provider); | ||
141 | |||
142 | for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { | 137 | for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) { |
143 | struct phy *phy = devm_phy_create(dev, | 138 | struct phy *phy = devm_phy_create(dev, |
144 | &exynos_mipi_video_phy_ops, NULL); | 139 | &exynos_mipi_video_phy_ops, NULL); |
@@ -152,6 +147,11 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev) | |||
152 | phy_set_drvdata(phy, &state->phys[i]); | 147 | phy_set_drvdata(phy, &state->phys[i]); |
153 | } | 148 | } |
154 | 149 | ||
150 | phy_provider = devm_of_phy_provider_register(dev, | ||
151 | exynos_mipi_video_phy_xlate); | ||
152 | if (IS_ERR(phy_provider)) | ||
153 | return PTR_ERR(phy_provider); | ||
154 | |||
155 | return 0; | 155 | return 0; |
156 | } | 156 | } |
157 | 157 | ||
diff --git a/drivers/phy/phy-mvebu-sata.c b/drivers/phy/phy-mvebu-sata.c index d43786f62437..d70ecd6a1b3f 100644 --- a/drivers/phy/phy-mvebu-sata.c +++ b/drivers/phy/phy-mvebu-sata.c | |||
@@ -99,17 +99,17 @@ static int phy_mvebu_sata_probe(struct platform_device *pdev) | |||
99 | if (IS_ERR(priv->clk)) | 99 | if (IS_ERR(priv->clk)) |
100 | return PTR_ERR(priv->clk); | 100 | return PTR_ERR(priv->clk); |
101 | 101 | ||
102 | phy_provider = devm_of_phy_provider_register(&pdev->dev, | ||
103 | of_phy_simple_xlate); | ||
104 | if (IS_ERR(phy_provider)) | ||
105 | return PTR_ERR(phy_provider); | ||
106 | |||
107 | phy = devm_phy_create(&pdev->dev, &phy_mvebu_sata_ops, NULL); | 102 | phy = devm_phy_create(&pdev->dev, &phy_mvebu_sata_ops, NULL); |
108 | if (IS_ERR(phy)) | 103 | if (IS_ERR(phy)) |
109 | return PTR_ERR(phy); | 104 | return PTR_ERR(phy); |
110 | 105 | ||
111 | phy_set_drvdata(phy, priv); | 106 | phy_set_drvdata(phy, priv); |
112 | 107 | ||
108 | phy_provider = devm_of_phy_provider_register(&pdev->dev, | ||
109 | of_phy_simple_xlate); | ||
110 | if (IS_ERR(phy_provider)) | ||
111 | return PTR_ERR(phy_provider); | ||
112 | |||
113 | /* The boot loader may of left it on. Turn it off. */ | 113 | /* The boot loader may of left it on. Turn it off. */ |
114 | phy_mvebu_sata_power_off(phy); | 114 | phy_mvebu_sata_power_off(phy); |
115 | 115 | ||
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index bfc5c337f99a..7699752fba11 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c | |||
@@ -177,11 +177,6 @@ static int omap_usb2_probe(struct platform_device *pdev) | |||
177 | phy->phy.otg = otg; | 177 | phy->phy.otg = otg; |
178 | phy->phy.type = USB_PHY_TYPE_USB2; | 178 | phy->phy.type = USB_PHY_TYPE_USB2; |
179 | 179 | ||
180 | phy_provider = devm_of_phy_provider_register(phy->dev, | ||
181 | of_phy_simple_xlate); | ||
182 | if (IS_ERR(phy_provider)) | ||
183 | return PTR_ERR(phy_provider); | ||
184 | |||
185 | control_node = of_parse_phandle(node, "ctrl-module", 0); | 180 | control_node = of_parse_phandle(node, "ctrl-module", 0); |
186 | if (!control_node) { | 181 | if (!control_node) { |
187 | dev_err(&pdev->dev, "Failed to get control device phandle\n"); | 182 | dev_err(&pdev->dev, "Failed to get control device phandle\n"); |
@@ -214,6 +209,11 @@ static int omap_usb2_probe(struct platform_device *pdev) | |||
214 | 209 | ||
215 | phy_set_drvdata(generic_phy, phy); | 210 | phy_set_drvdata(generic_phy, phy); |
216 | 211 | ||
212 | phy_provider = devm_of_phy_provider_register(phy->dev, | ||
213 | of_phy_simple_xlate); | ||
214 | if (IS_ERR(phy_provider)) | ||
215 | return PTR_ERR(phy_provider); | ||
216 | |||
217 | phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); | 217 | phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k"); |
218 | if (IS_ERR(phy->wkupclk)) { | 218 | if (IS_ERR(phy->wkupclk)) { |
219 | dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); | 219 | dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n"); |
diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index daf65e68aaab..c3ace1db8136 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c | |||
@@ -695,11 +695,6 @@ static int twl4030_usb_probe(struct platform_device *pdev) | |||
695 | otg->set_host = twl4030_set_host; | 695 | otg->set_host = twl4030_set_host; |
696 | otg->set_peripheral = twl4030_set_peripheral; | 696 | otg->set_peripheral = twl4030_set_peripheral; |
697 | 697 | ||
698 | phy_provider = devm_of_phy_provider_register(twl->dev, | ||
699 | of_phy_simple_xlate); | ||
700 | if (IS_ERR(phy_provider)) | ||
701 | return PTR_ERR(phy_provider); | ||
702 | |||
703 | phy = devm_phy_create(twl->dev, &ops, init_data); | 698 | phy = devm_phy_create(twl->dev, &ops, init_data); |
704 | if (IS_ERR(phy)) { | 699 | if (IS_ERR(phy)) { |
705 | dev_dbg(&pdev->dev, "Failed to create PHY\n"); | 700 | dev_dbg(&pdev->dev, "Failed to create PHY\n"); |
@@ -708,6 +703,11 @@ static int twl4030_usb_probe(struct platform_device *pdev) | |||
708 | 703 | ||
709 | phy_set_drvdata(phy, twl); | 704 | phy_set_drvdata(phy, twl); |
710 | 705 | ||
706 | phy_provider = devm_of_phy_provider_register(twl->dev, | ||
707 | of_phy_simple_xlate); | ||
708 | if (IS_ERR(phy_provider)) | ||
709 | return PTR_ERR(phy_provider); | ||
710 | |||
711 | /* init spinlock for workqueue */ | 711 | /* init spinlock for workqueue */ |
712 | spin_lock_init(&twl->lock); | 712 | spin_lock_init(&twl->lock); |
713 | 713 | ||