mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-25 19:07:46 +00:00
net: stmmac: dwmac-rk: Use standard devicetree property for phy regulator
Currently, dwmac-rk uses a custom propety "phy_regulator" to get the name of the right regulator to use to power on or power off the phy. This commit converts the driver to use phy-supply devicetree property and the corresponding API, it cleans the code a bit and make it simpler to maintain. This also replaces the property phy_regulator by the standard property phy-supply in rk3288-evb-rk808.dts. Signed-off-by: Romain Perier <romain.perier@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
68c3a884d7
commit
2e12f53663
@ -161,7 +161,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
&gmac {
|
&gmac {
|
||||||
phy_regulator = "vcc_phy";
|
phy-supply = <&vcc_phy>;
|
||||||
phy-mode = "rgmii";
|
phy-mode = "rgmii";
|
||||||
clock_in_out = "input";
|
clock_in_out = "input";
|
||||||
snps,reset-gpio = <&gpio4 7 0>;
|
snps,reset-gpio = <&gpio4 7 0>;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
struct rk_priv_data {
|
struct rk_priv_data {
|
||||||
struct platform_device *pdev;
|
struct platform_device *pdev;
|
||||||
int phy_iface;
|
int phy_iface;
|
||||||
char regulator[32];
|
struct regulator *regulator;
|
||||||
|
|
||||||
bool clk_enabled;
|
bool clk_enabled;
|
||||||
bool clock_input;
|
bool clock_input;
|
||||||
@ -287,46 +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)
|
static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)
|
||||||
{
|
{
|
||||||
struct regulator *ldo;
|
struct regulator *ldo = bsp_priv->regulator;
|
||||||
char *ldostr = bsp_priv->regulator;
|
|
||||||
int ret;
|
int ret;
|
||||||
struct device *dev = &bsp_priv->pdev->dev;
|
struct device *dev = &bsp_priv->pdev->dev;
|
||||||
|
|
||||||
if (!ldostr) {
|
if (!ldo) {
|
||||||
dev_err(dev, "%s: no ldo found\n", __func__);
|
dev_err(dev, "%s: no regulator found\n", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldo = regulator_get(NULL, ldostr);
|
if (enable) {
|
||||||
if (!ldo) {
|
ret = regulator_enable(ldo);
|
||||||
dev_err(dev, "\n%s get ldo %s failed\n", __func__, ldostr);
|
if (ret)
|
||||||
|
dev_err(dev, "%s: fail to enable phy-supply\n",
|
||||||
|
__func__);
|
||||||
} else {
|
} else {
|
||||||
if (enable) {
|
ret = regulator_disable(ldo);
|
||||||
if (!regulator_is_enabled(ldo)) {
|
if (ret)
|
||||||
ret = regulator_enable(ldo);
|
dev_err(dev, "%s: fail to disable phy-supply\n",
|
||||||
if (ret != 0)
|
__func__);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -346,14 +325,14 @@ static void *rk_gmac_setup(struct platform_device *pdev)
|
|||||||
|
|
||||||
bsp_priv->phy_iface = of_get_phy_mode(dev->of_node);
|
bsp_priv->phy_iface = of_get_phy_mode(dev->of_node);
|
||||||
|
|
||||||
ret = of_property_read_string(dev->of_node, "phy_regulator", &strings);
|
bsp_priv->regulator = devm_regulator_get_optional(dev, "phy");
|
||||||
if (ret) {
|
if (IS_ERR(bsp_priv->regulator)) {
|
||||||
dev_warn(dev, "%s: Can not read property: phy_regulator.\n",
|
if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) {
|
||||||
__func__);
|
dev_err(dev, "phy regulator is not available yet, deferred probing\n");
|
||||||
} else {
|
return ERR_PTR(-EPROBE_DEFER);
|
||||||
dev_info(dev, "%s: PHY power controlled by regulator(%s).\n",
|
}
|
||||||
__func__, strings);
|
dev_err(dev, "no regulator found\n");
|
||||||
strcpy(bsp_priv->regulator, strings);
|
bsp_priv->regulator = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
|
ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);
|
||||||
|
Loading…
Reference in New Issue
Block a user