[PATCH 0/3] fec driver updates

STALE5186d

Revision v1 of 2 in this series.

8 messages, 3 authors, 2012-06-26 · open the first message on its own page

[PATCH 0/3] fec driver updates

From: Shawn Guo <hidden>
Date: 2012-06-26 08:45:05

The series makes a few updates on fec driver to make it work better
for device tree boot.

Shawn Guo (3):
  net: fec: reset phy after pinctrl setup
  net: fec: enable regulator for fec phy
  net: fec: add phy-reset-interval for device tree probe

 Documentation/devicetree/bindings/net/fsl-fec.txt |    5 ++++-
 drivers/net/ethernet/freescale/fec.c              |   21 ++++++++++++++++++---
 2 files changed, 22 insertions(+), 4 deletions(-)

-- 
1.7.5.4

[PATCH 1/3] net: fec: reset phy after pinctrl setup

From: Shawn Guo <hidden>
Date: 2012-06-26 08:45:06

In case that bootloader or platform initialization does not set up
fec pins, the fec_reset_phy will not be able to succeed, because
fec_reset_phy is currently called before devm_pinctrl_get_select_default.
Move fec_reset_phy call to the place between devm_pinctrl_get_select_default
and fec_enet_init to have above case be taken care.

Signed-off-by: Shawn Guo <redacted>
---
 drivers/net/ethernet/freescale/fec.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index ff7f4c5..e868a37 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1593,8 +1593,6 @@ fec_probe(struct platform_device *pdev)
 		fep->phy_interface = ret;
 	}
 
-	fec_reset_phy(pdev);
-
 	for (i = 0; i < FEC_IRQ_NUM; i++) {
 		irq = platform_get_irq(pdev, i);
 		if (irq < 0) {
@@ -1634,6 +1632,8 @@ fec_probe(struct platform_device *pdev)
 	clk_prepare_enable(fep->clk_ahb);
 	clk_prepare_enable(fep->clk_ipg);
 
+	fec_reset_phy(pdev);
+
 	ret = fec_enet_init(ndev);
 	if (ret)
 		goto failed_init;
-- 
1.7.5.4

[PATCH 2/3] net: fec: enable regulator for fec phy

From: Shawn Guo <hidden>
Date: 2012-06-26 08:45:07

If bootloader or platform initialization code does not enable the
power supply to fec phy, we need to do it in fec driver before calling
fec_reset_phy to have the phy powered on.

Signed-off-by: Shawn Guo <redacted>
---
 drivers/net/ethernet/freescale/fec.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index e868a37..4dce9e3 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -49,6 +49,7 @@
 #include <linux/of_gpio.h>
 #include <linux/of_net.h>
 #include <linux/pinctrl/consumer.h>
+#include <linux/regulator/consumer.h>
 
 #include <asm/cacheflush.h>
 
@@ -1546,6 +1547,7 @@ fec_probe(struct platform_device *pdev)
 	const struct of_device_id *of_id;
 	static int dev_id;
 	struct pinctrl *pinctrl;
+	struct regulator *reg_phy;
 
 	of_id = of_match_device(fec_dt_ids, &pdev->dev);
 	if (of_id)
@@ -1632,6 +1634,16 @@ fec_probe(struct platform_device *pdev)
 	clk_prepare_enable(fep->clk_ahb);
 	clk_prepare_enable(fep->clk_ipg);
 
+	reg_phy = devm_regulator_get(&pdev->dev, "phy");
+	if (!IS_ERR(reg_phy)) {
+		ret = regulator_enable(reg_phy);
+		if (ret) {
+			dev_err(&pdev->dev,
+				"Failed to enable phy regulator: %d\n", ret);
+			goto failed_regulator;
+		}
+	}
+
 	fec_reset_phy(pdev);
 
 	ret = fec_enet_init(ndev);
@@ -1655,6 +1667,7 @@ failed_register:
 	fec_enet_mii_remove(fep);
 failed_mii_init:
 failed_init:
+failed_regulator:
 	clk_disable_unprepare(fep->clk_ahb);
 	clk_disable_unprepare(fep->clk_ipg);
 failed_pin:
-- 
1.7.5.4

[PATCH 3/3] net: fec: add phy-reset-interval for device tree probe

From: Shawn Guo <hidden>
Date: 2012-06-26 08:45:08

Different boards may require different phy reset interval time.  Add
property phy-reset-interval for device tree probe, so that the boards
that need a longer interval time can specify it in their device tree.

Along with the update to phy related stuff, it also makes a minor fix
on phy-reset-gpios in binding document to have it be optional to match
the driver code.

Signed-off-by: Shawn Guo <redacted>
---
 Documentation/devicetree/bindings/net/fsl-fec.txt |    5 ++++-
 drivers/net/ethernet/freescale/fec.c              |    4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
index 7ab9e1a..74a4ce7 100644
--- a/Documentation/devicetree/bindings/net/fsl-fec.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
@@ -7,10 +7,13 @@ Required properties:
 - phy-mode : String, operation mode of the PHY interface.
   Supported values are: "mii", "gmii", "sgmii", "tbi", "rmii",
   "rgmii", "rgmii-id", "rgmii-rxid", "rgmii-txid", "rtbi", "smii".
-- phy-reset-gpios : Should specify the gpio for phy reset
 
 Optional properties:
 - local-mac-address : 6 bytes, mac address
+- phy-reset-gpios : Should specify the gpio for phy reset
+- phy-reset-interval : Reset interval time in milliseconds.  Should present
+  only if property "phy-reset-gpios" is available.  When "phy-reset-gpios"
+  is available, missing the property will have the interval be 1 millisecond.
 
 Example:
 
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index 4dce9e3..86ecaae 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1507,18 +1507,20 @@ static int __devinit fec_get_phy_mode_dt(struct platform_device *pdev)
 static void __devinit fec_reset_phy(struct platform_device *pdev)
 {
 	int err, phy_reset;
+	int msec = 1;
 	struct device_node *np = pdev->dev.of_node;
 
 	if (!np)
 		return;
 
+	of_property_read_u32(np, "phy-reset-interval", &msec);
 	phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
 	err = gpio_request_one(phy_reset, GPIOF_OUT_INIT_LOW, "phy-reset");
 	if (err) {
 		pr_debug("FEC: failed to get gpio phy-reset: %d\n", err);
 		return;
 	}
-	msleep(1);
+	msleep(msec);
 	gpio_set_value(phy_reset, 1);
 }
 #else /* CONFIG_OF */
-- 
1.7.5.4

[PATCH 3/3] net: fec: add phy-reset-interval for device tree probe

From: Lothar Waßmann <hidden>
Date: 2012-06-26 09:11:35

Hi,

Shawn Guo writes:
Different boards may require different phy reset interval time.  Add
property phy-reset-interval for device tree probe, so that the boards
that need a longer interval time can specify it in their device tree.
'phy-reset-duration' would be a more appropriate name.


Lothar Waßmann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info@karo-electronics.de
___________________________________________________________

[PATCH 3/3] net: fec: add phy-reset-interval for device tree probe

From: Shawn Guo <hidden>
Date: 2012-06-26 11:15:37

On Tue, Jun 26, 2012 at 11:11:35AM +0200, Lothar Waßmann wrote:
Hi,

Shawn Guo writes:
quoted
Different boards may require different phy reset interval time.  Add
property phy-reset-interval for device tree probe, so that the boards
that need a longer interval time can specify it in their device tree.
'phy-reset-duration' would be a more appropriate name.
Ok, point taken.  Thanks.

-- 
Regards,
Shawn

[PATCH 3/3] net: fec: add phy-reset-interval for device tree probe

From: florian@openwrt.org (Florian Fainelli)
Date: 2012-06-26 11:55:05

Hi,

On Tuesday 26 June 2012 16:45:08 Shawn Guo wrote:
quoted hunk
Different boards may require different phy reset interval time.  Add
property phy-reset-interval for device tree probe, so that the boards
that need a longer interval time can specify it in their device tree.

Along with the update to phy related stuff, it also makes a minor fix
on phy-reset-gpios in binding document to have it be optional to match
the driver code.

Signed-off-by: Shawn Guo <redacted>
---
 Documentation/devicetree/bindings/net/fsl-fec.txt |    5 ++++-
 drivers/net/ethernet/freescale/fec.c              |    4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt 
b/Documentation/devicetree/bindings/net/fsl-fec.txt
quoted hunk
index 7ab9e1a..74a4ce7 100644
--- a/Documentation/devicetree/bindings/net/fsl-fec.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
@@ -7,10 +7,13 @@ Required properties:
 - phy-mode : String, operation mode of the PHY interface.
   Supported values are: "mii", "gmii", "sgmii", "tbi", "rmii",
   "rgmii", "rgmii-id", "rgmii-rxid", "rgmii-txid", "rtbi", "smii".
-- phy-reset-gpios : Should specify the gpio for phy reset
 
 Optional properties:
 - local-mac-address : 6 bytes, mac address
+- phy-reset-gpios : Should specify the gpio for phy reset
+- phy-reset-interval : Reset interval time in milliseconds.  Should present
+  only if property "phy-reset-gpios" is available.  When "phy-reset-gpios"
+  is available, missing the property will have the interval be 1 
millisecond.
quoted hunk
 
 Example:
 
diff --git a/drivers/net/ethernet/freescale/fec.c 
b/drivers/net/ethernet/freescale/fec.c
quoted hunk
index 4dce9e3..86ecaae 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1507,18 +1507,20 @@ static int __devinit fec_get_phy_mode_dt(struct 
platform_device *pdev)
 static void __devinit fec_reset_phy(struct platform_device *pdev)
 {
 	int err, phy_reset;
+	int msec = 1;
 	struct device_node *np = pdev->dev.of_node;
 
 	if (!np)
 		return;
 
+	of_property_read_u32(np, "phy-reset-interval", &msec);
 	phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
 	err = gpio_request_one(phy_reset, GPIOF_OUT_INIT_LOW, "phy-reset");
 	if (err) {
 		pr_debug("FEC: failed to get gpio phy-reset: %d\n", err);
 		return;
 	}
-	msleep(1);
+	msleep(msec);
You might want to check the value of the property here to make sure it is in 
the msleep() acceptable range.
 	gpio_set_value(phy_reset, 1);
 }
 #else /* CONFIG_OF */
-- 
1.7.5.4


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[PATCH 3/3] net: fec: add phy-reset-interval for device tree probe

From: Shawn Guo <hidden>
Date: 2012-06-26 12:13:36

On Tue, Jun 26, 2012 at 01:55:05PM +0200, Florian Fainelli wrote:
quoted
+	of_property_read_u32(np, "phy-reset-interval", &msec);
 	phy_reset = of_get_named_gpio(np, "phy-reset-gpios", 0);
 	err = gpio_request_one(phy_reset, GPIOF_OUT_INIT_LOW, "phy-reset");
 	if (err) {
 		pr_debug("FEC: failed to get gpio phy-reset: %d\n", err);
 		return;
 	}
-	msleep(1);
+	msleep(msec);
You might want to check the value of the property here to make sure it is in 
the msleep() acceptable range.
Sounds good.  I think a sensible reset duration should be less one
second, so let's force 1000 ms to be the possible max one?

-- 
Regards,
Shawn
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help