summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-01-24 17:17:16 -0800
committerDavid S. Miller <davem@davemloft.net>2015-01-24 17:17:16 -0800
commit5ec274250d55a3fb27caf994e891f86a9529a2cb (patch)
treef9c0107746b4a9c633ca31d05bf1d1aafe266fe8
parent38124b14a0f87ea7fcef50ec28072dd06d12b8e6 (diff)
parent384dd55d007073b84e38a24b39b9948fe980ca59 (diff)
Merge branch 'stmmac-dwmac-rk'
Romain Perier says: ==================== net: stmmac: dwmac-rk: Fix phy regulator issues This series fixes few issues in dwmac-rk: 1. Voltage settings was hardcoded into the driver for the phy regulator. The driver now uses the default voltage settings found in the devicetree, which are applied throught the regulator framework. 2. The regulator name used to power on or power off the phy was put in the devicetree variable "phy_regulator", which is not standard and added a lot of code for nothing. The driver now uses the devicetree property "phy-supply" and the corresponding functions to manipulate this regulator. The corresponding devicetree files are also updated. As this new binding for rk3288 has not been released with any official kernel yet (not until 3.20), I don't need to care about keeping compatibility with the old non standard property. ==================== Tested-by: Heiko Stuebner <heiko@sntech.de> Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/devicetree/bindings/net/rockchip-dwmac.txt1
-rw-r--r--arch/arm/boot/dts/rk3288-evb-rk808.dts2
-rw-r--r--arch/arm/boot/dts/rk3288-evb.dtsi2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c64
4 files changed, 25 insertions, 44 deletions
diff --git a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
index 2362dcd5afc9..21fd199e89b5 100644
--- a/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
+++ b/Documentation/devicetree/bindings/net/rockchip-dwmac.txt
@@ -33,6 +33,7 @@ Required properties:
Optional properties:
- tx_delay: Delay value for TXD timing. Range value is 0~0x7F, 0x30 as default.
- rx_delay: Delay value for RXD timing. Range value is 0~0x7F, 0x10 as default.
+ - phy-supply: phandle to a regulator if the PHY needs one
Example:
diff --git a/arch/arm/boot/dts/rk3288-evb-rk808.dts b/arch/arm/boot/dts/rk3288-evb-rk808.dts
index 831a7aa85136..e1d3eeb8f094 100644
--- a/arch/arm/boot/dts/rk3288-evb-rk808.dts
+++ b/arch/arm/boot/dts/rk3288-evb-rk808.dts
@@ -161,7 +161,7 @@
};
&gmac {
- phy_regulator = "vcc_phy";
+ phy-supply = <&vcc_phy>;
phy-mode = "rgmii";
clock_in_out = "input";
snps,reset-gpio = <&gpio4 7 0>;
diff --git a/arch/arm/boot/dts/rk3288-evb.dtsi b/arch/arm/boot/dts/rk3288-evb.dtsi
index 048cb170c884..98f51140a8c6 100644
--- a/arch/arm/boot/dts/rk3288-evb.dtsi
+++ b/arch/arm/boot/dts/rk3288-evb.dtsi
@@ -98,6 +98,8 @@
pinctrl-names = "default";
pinctrl-0 = <&eth_phy_pwr>;
regulator-name = "vcc_phy";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
};
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index 35f9b86bc9e5..6249a4ec08f0 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -32,7 +32,7 @@
struct rk_priv_data {
struct platform_device *pdev;
int phy_iface;
- char regulator[32];
+ struct regulator *regulator;
bool clk_enabled;
bool clock_input;
@@ -287,47 +287,25 @@ static int gmac_clk_enable(struct rk_priv_data *bsp_priv, bool enable)
static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
{
- struct regulator *ldo;
- char *ldostr = bsp_priv->regulator;
+ struct regulator *ldo = bsp_priv->regulator;
int ret;
struct device *dev = &bsp_priv->pdev->dev;
- if (!ldostr) {
- dev_err(dev, "%s: no ldo found\n", __func__);
+ if (!ldo) {
+ dev_err(dev, "%s: no regulator found\n", __func__);
return -1;
}
- ldo = regulator_get(NULL, ldostr);
- if (!ldo) {
- dev_err(dev, "\n%s get ldo %s failed\n", __func__, ldostr);
+ if (enable) {
+ ret = regulator_enable(ldo);
+ if (ret)
+ dev_err(dev, "%s: fail to enable phy-supply\n",
+ __func__);
} else {
- if (enable) {
- if (!regulator_is_enabled(ldo)) {
- regulator_set_voltage(ldo, 3300000, 3300000);
- ret = regulator_enable(ldo);
- if (ret != 0)
- dev_err(dev, "%s: fail to enable %s\n",
- __func__, ldostr);
- else
- dev_info(dev, "turn on ldo done.\n");
- } else {
- dev_warn(dev, "%s is enabled before enable",
- ldostr);
- }
- } else {
- if (regulator_is_enabled(ldo)) {
- ret = regulator_disable(ldo);
- if (ret != 0)
- dev_err(dev, "%s: fail to disable %s\n",
- __func__, ldostr);
- else
- dev_info(dev, "turn off ldo done.\n");
- } else {
- dev_warn(dev, "%s is disabled before disable",
- ldostr);
- }
- }
- regulator_put(ldo);
+ ret = regulator_disable(ldo);
+ if (ret)
+ dev_err(dev, "%s: fail to disable phy-supply\n",
+ __func__);
}
return 0;
@@ -347,14 +325,14 @@ static void *rk_gmac_setup(struct platform_device *pdev)
bsp_priv->phy_iface = of_get_phy_mode(dev->of_node);
- ret = of_property_read_string(dev->of_node, "phy_regulator", &strings);
- if (ret) {
- dev_warn(dev, "%s: Can not read property: phy_regulator.\n",
- __func__);
- } else {
- dev_info(dev, "%s: PHY power controlled by regulator(%s).\n",
- __func__, strings);
- strcpy(bsp_priv->regulator, strings);
+ bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
+ if (IS_ERR(bsp_priv->regulator)) {
+ if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) {
+ dev_err(dev, "phy regulator is not available yet, deferred probing\n");
+ return ERR_PTR(-EPROBE_DEFER);
+ }
+ dev_err(dev, "no regulator found\n");
+ bsp_priv->regulator = NULL;
}
ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);