omap: phy: dra7-evm PHY fixes for 3.16
Subsystems (2)
v2 cover omap: phy: dra7-evm PHY fixes for 3.16
Hi,
On DRA7-evm, the VDDA_1V8_PHY supply must be always-on for proper functioning of the PHYs on the SoC.
The 3.3V USB supply (ldousb_reg) can be turned OFF when the High Speed USB PHYs are not in use. We add regulator support in the PHY framework core to manage the PHY's regulator during PHY power on/off.
Finally we add the 3.3V regulator information to the USB2 PHYs.
This series should get the USB and SATA working again on 3.16 on DRA7-evm.
cheers,
-roger
Changelog:
v2:
- removed if (!NULL) check around regulator_put()
- added more technical information in commit message about 1V8_PHY power line
- added pm_runtime_disable in omap_usb2_remove()
---
Roger Quadros (6):
ARM: dts: dra7-evm: Make VDDA_1V8_PHY supply always on
phy: core: Fix error path in phy_create()
phy: core: Support regulator supply for PHY power
phy: core: Add phy-supply to DT binding documentation
phy: omap-usb2: Balance pm_runtime_enable() on probe failure and
remove
ARM: dts: dra7-evm: Add regulator information to USB2 PHYs
.../devicetree/bindings/phy/phy-bindings.txt | 4 +++ arch/arm/boot/dts/dra7-evm.dts | 9 ++++++ drivers/phy/phy-core.c | 33 ++++++++++++++++++++-- drivers/phy/phy-omap-usb2.c | 7 +++-- include/linux/phy/phy.h | 2 ++ 5 files changed, 50 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.3.2
PATCH v2 1/6 ARM: dts: dra7-evm: Make VDDA_1V8_PHY supply always on
After clarification from the hardware team it was found that this 1.8V PHY supply can't be switched OFF when SoC is Active.
Since the PHY IPs don't contain isolation logic built in the design to allow the power rail to be switched off, there is a very high risk of IP reliability and additional leakage paths which can result in additional power consumption.
The only scenario where this rail can be switched off is part of Power on reset sequencing, but it needs to be kept always-on during operation.
This patch is required for proper functionality of USB, SATA and PCIe on DRA7-evm.
--- arch/arm/boot/dts/dra7-evm.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm/boot/dts/dra7-evm.dts +1 -0
@@ -240,6 +240,7 @@ regulator-name = "ldo3"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; + regulator-always-on; regulator-boot-on; };
Signature · 1 line
1.8.3.2
PATCH v2 2/6 phy: core: Fix error path in phy_create()
In reply to Roger QuadrosPrevent resources from being freed twice in case device_add() call fails within phy_create(). Also use ida_simple_remove() instead of ida_remove() as we had used ida_simple_get() to allocate the ida.
--- drivers/phy/phy-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/phy/phy-core.c +4 -3
@@ -614,8 +614,9 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops,return phy; put_dev: -put_device (&phy->dev); -ida_remove (&phy_ida, phy->id); +put_device (&phy->dev);/* calls phy_release() which frees resources */ +return ERR_PTR (ret); + free_phy:kfree (phy);return ERR_PTR (ret);
@@ -799,7 +800,7 @@ static void phy_release(struct device *dev) phy =to_phy (dev);dev_vdbg (dev,"releasing '%s'\n" ,dev_name (dev)); -ida_remove (&phy_ida, phy->id); +ida_simple_remove (&phy_ida, phy->id);kfree (phy); }
Signature · 1 line
1.8.3.2
PATCH v2 3/6 phy: core: Support regulator supply for PHY power
In reply to Roger QuadrosSome PHYs can be powered by an external power regulator. e.g. USB_HS PHY on DRA7 SoC. Make the PHY core support a power regulator.
--- drivers/phy/phy-core.c | 26 ++++++++++++++++++++++++++ include/linux/phy/phy.h | 2 ++ 2 files changed, 28 insertions(+)
drivers/phy/phy-core.c +26 -0
@@ -21,6 +21,7 @@#include <linux/phy/phy.h> #include <linux/idr.h> #include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> static struct class *phy_class;static DEFINE_MUTEX (phy_provider_mutex);
@@ -226,6 +227,12 @@ int phy_power_on(struct phy *phy)if (!phy)return 0 ; +if (phy->pwr) { + ret =regulator_enable (phy->pwr); +if (ret) +return ret; + } + ret =phy_pm_runtime_get_sync (phy);if (ret <0 && ret != -ENOTSUPP )return ret;
@@ -247,6 +254,8 @@ int phy_power_on(struct phy *phy) out:mutex_unlock (&phy->mutex);phy_pm_runtime_put_sync (phy); +if (phy->pwr) +regulator_disable (phy->pwr);return ret; }
@@ -272,6 +281,9 @@ int phy_power_off(struct phy *phy)mutex_unlock (&phy->mutex);phy_pm_runtime_put (phy); +if (phy->pwr) +regulator_disable (phy->pwr); +return 0 ; }EXPORT_SYMBOL_GPL (phy_power_off);
@@ -588,6 +600,16 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, goto free_phy; } +/* phy-supply */ + phy->pwr =regulator_get_optional (dev,"phy" ); +if (IS_ERR (phy->pwr)) { +if (PTR_ERR (phy->pwr) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto free_ida; + } + phy->pwr =NULL ; + } +device_initialize (&phy->dev);mutex_init (&phy->mutex);
@@ -617,6 +639,9 @@ put_dev:put_device (&phy->dev);/* calls phy_release() which frees resources */ return ERR_PTR (ret); +free_ida: +ida_simple_remove (&phy_ida, phy->id); + free_phy:kfree (phy);return ERR_PTR (ret);
@@ -800,6 +825,7 @@ static void phy_release(struct device *dev) phy =to_phy (dev);dev_vdbg (dev,"releasing '%s'\n" ,dev_name (dev)); +regulator_put (phy->pwr);ida_simple_remove (&phy_ida, phy->id);kfree (phy); }
include/linux/phy/phy.h +2 -0
@@ -18,6 +18,7 @@#include <linux/of.h> #include <linux/device.h> #include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> struct phy ;
@@ -65,6 +66,7 @@ struct phy {int init_count;int power_count;struct phy_attrs attrs; +struct regulator *pwr; };/**
Signature · 1 line
1.8.3.2
PATCH v2 4/6 phy: core: Add phy-supply to DT binding documentation
In reply to Roger Quadrosphy-supply is a phandle to the regulator that provides power to the PHY. This regulator is managed during the PHY power on/off sequence by the phy core driver.
--- Documentation/devicetree/bindings/phy/phy-bindings.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/phy/phy-bindings.txt +4 -0
@@ -10,6 +10,10 @@ Required Properties: provider can use the values in cells to find the appropriate PHY. +Optional Properties: +phy-supply: Phandle to a regulator that provides power to the PHY. This + regulator will be managed during the PHY power on/off sequence. + For example: phys: phy {
Signature · 1 line
1.8.3.2
PATCH v2 5/6 phy: omap-usb2: Balance pm_runtime_enable() on probe failure and remove
In reply to Roger QuadrosIf probe fails then we need to call pm_runtime_disable() to balance out the previous pm_runtime_enable() call. Else it will cause unbalanced pm_runtime_enable() call in the succeding probe call.
This anomaly was observed when the call to devm_phy_create() failed with -EPROBE_DEFER.
Balance out the pm_runtime_enable() call in .remove() as well.
--- drivers/phy/phy-omap-usb2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/phy/phy-omap-usb2.c +5 -2
@@ -262,7 +262,6 @@ static int omap_usb2_probe(struct platform_device *pdev) otg->phy = &phy->phy;platform_set_drvdata (pdev, phy); -pm_runtime_enable (phy->dev); generic_phy =devm_phy_create (phy->dev, &ops,NULL );if (IS_ERR (generic_phy))
@@ -270,10 +269,13 @@ static int omap_usb2_probe(struct platform_device *pdev)phy_set_drvdata (generic_phy, phy); +pm_runtime_enable (phy->dev); phy_provider =devm_of_phy_provider_register (phy->dev, of_phy_simple_xlate); -if (IS_ERR (phy_provider)) +if (IS_ERR (phy_provider)) { +pm_runtime_disable (phy->dev);return PTR_ERR (phy_provider); + } phy->wkupclk =devm_clk_get (phy->dev,"wkupclk" );if (IS_ERR (phy->wkupclk)) {
@@ -317,6 +319,7 @@ static int omap_usb2_remove(struct platform_device *pdev)if (!IS_ERR (phy->optclk))clk_unprepare (phy->optclk);usb_remove_phy (&phy->phy); +pm_runtime_disable (phy->dev);return 0 ; }
Signature · 1 line
1.8.3.2
PATCH v2 6/6 ARM: dts: dra7-evm: Add regulator information to USB2 PHYs
In reply to Roger QuadrosThe ldousb_reg regulator provides power to the USB1 and USB2 High Speed PHYs.
--- arch/arm/boot/dts/dra7-evm.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/dra7-evm.dts +8 -0
@@ -496,3 +496,11 @@ }; }; }; + +&usb2_phy1 { + phy-supply = <&ldousb_reg>; +}; + +&usb2_phy2 { + phy-supply = <&ldousb_reg>; +};
Signature · 1 line
1.8.3.2
Re: [PATCH v2 1/6] ARM: dts: dra7-evm: Make VDDA_1V8_PHY supply always on
In reply to Roger QuadrosQuoted 11 lines · Roger Quadros
After clarification from the hardware team it was found that this 1.8V PHY supply can't be switched OFF when SoC is Active.
Since the PHY IPs don't contain isolation logic built in the design to allow the power rail to be switched off, there is a very high risk of IP reliability and additional leakage paths which can result in additional power consumption.
The only scenario where this rail can be switched off is part of Power on reset sequencing, but it needs to be kept always-on during operation.
Quoted 6 lines
This patch is required for proper functionality of USB, SATA and PCIe on DRA7-evm.
CC Rajendra Nayak <[email protected]>CC Tero Kristo <[email protected]>Signed-off-by Roger Quadros <[email protected]>
Best that you queue this with the series:
Quoted 19 lines
--- arch/arm/boot/dts/dra7-evm.dts | 1 + 1 file changed, 1 insertion(+)arch/arm/boot/dts/dra7-evm.dts +1
-0@@ -240,6 +240,7 @@ regulator-name = "ldo3"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; + regulator-always-on; regulator-boot-on; };Signature · 1 line
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 6/6] ARM: dts: dra7-evm: Add regulator information to USB2 PHYs
In reply to Roger QuadrosQuoted 4 lines · Roger Quadros
The
ldousb_regregulator provides power to the USB1 and USB2 High Speed PHYs.Signed-off-by Roger Quadros <[email protected]>
This too:
Quoted 23 lines
--- arch/arm/boot/dts/dra7-evm.dts | 8 ++++++++ 1 file changed, 8 insertions(+)arch/arm/boot/dts/dra7-evm.dts +8
-0@@ -496,3 +496,11 @@ }; }; }; + +&usb2_phy1 { + phy-supply = <&ldousb_reg>; +}; + +&usb2_phy2 { + phy-supply = <&ldousb_reg>; +};Signature · 1 line
1.8.3.2
Re: [PATCH v2 1/6] ARM: dts: dra7-evm: Make VDDA_1V8_PHY supply always on
In reply to Tony LindgrenHi Tony,
Quoted 12 lines · Tony Lindgren
Quoted 11 lines · Roger Quadros
After clarification from the hardware team it was found that this 1.8V PHY supply can't be switched OFF when SoC is Active.
Since the PHY IPs don't contain isolation logic built in the design to allow the power rail to be switched off, there is a very high risk of IP reliability and additional leakage paths which can result in additional power consumption.
The only scenario where this rail can be switched off is part of Power on reset sequencing, but it needs to be kept always-on during operation.
Quoted 8 lines
Quoted 6 lines
This patch is required for proper functionality of USB, SATA and PCIe on DRA7-evm.
CC Rajendra Nayak <[email protected]>CC Tero Kristo <[email protected]>Signed-off-by Roger Quadros <[email protected]>Best that you queue this with the series:
This patch doesn't have any dependency with the others and we're not even sure if this series will hit 3.16.
But this 1V8 regulator _is_ required for normal operation of the SoC, whether the PHYs are in use or not.
Can you please queue just this patch for SoC fixes for 3.16? Thanks.
cheers,
-roger
Quoted 22 lines
Acked-by Tony Lindgren <[email protected]>Quoted 19 lines
--- arch/arm/boot/dts/dra7-evm.dts | 1 + 1 file changed, 1 insertion(+)arch/arm/boot/dts/dra7-evm.dts +1
-0@@ -240,6 +240,7 @@ regulator-name = "ldo3"; regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; + regulator-always-on; regulator-boot-on; };Signature · 1 line
1.8.3.2
Re: [PATCH v2 1/6] ARM: dts: dra7-evm: Make VDDA_1V8_PHY supply always on
Quoted 24 lines · Roger Quadros
Hi Tony,
Quoted 12 lines · Tony Lindgren
Quoted 11 lines · Roger Quadros
After clarification from the hardware team it was found that this 1.8V PHY supply can't be switched OFF when SoC is Active.
Since the PHY IPs don't contain isolation logic built in the design to allow the power rail to be switched off, there is a very high risk of IP reliability and additional leakage paths which can result in additional power consumption.
The only scenario where this rail can be switched off is part of Power on reset sequencing, but it needs to be kept always-on during operation.
Quoted 8 lines
Quoted 6 lines
This patch is required for proper functionality of USB, SATA and PCIe on DRA7-evm.
CC Rajendra Nayak <[email protected]>CC Tero Kristo <[email protected]>Signed-off-by Roger Quadros <[email protected]>Best that you queue this with the series:
Quoted 7 lines
This patch doesn't have any dependency with the others and we're not even sure if this series will hit 3.16.
But this 1V8 regulator _is_ required for normal operation of the SoC, whether the PHYs are in use or not.
Can you please queue just this patch for SoC fixes for 3.16? Thanks.
OK will do.
Regards,
Tony