* [PATCH v2 1/4] net: fec: handle optional clk_ptp more gracefully
2013-03-18 8:26 [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling Shawn Guo
@ 2013-03-18 8:26 ` Shawn Guo
2013-03-18 8:26 ` [PATCH v2 2/4] net: freescale: fec: add support for optional enet_out clk Shawn Guo
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2013-03-18 8:26 UTC (permalink / raw)
To: linux-arm-kernel
When the optional clk_ptp is absent, we can just set it to NULL, and
clk API will just handle it gracefully. It saves us from checking
clk_ptp whenever calling into clk API.
Also since clk_ptp is optional, the "ret" variable shouldn't be set
in case that the clock is absent.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index fccc3bf..d2a9851 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1804,14 +1804,13 @@ fec_probe(struct platform_device *pdev)
fep->bufdesc_ex =
pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX;
if (IS_ERR(fep->clk_ptp)) {
- ret = PTR_ERR(fep->clk_ptp);
+ fep->clk_ptp = NULL;
fep->bufdesc_ex = 0;
}
clk_prepare_enable(fep->clk_ahb);
clk_prepare_enable(fep->clk_ipg);
- if (!IS_ERR(fep->clk_ptp))
- clk_prepare_enable(fep->clk_ptp);
+ clk_prepare_enable(fep->clk_ptp);
reg_phy = devm_regulator_get(&pdev->dev, "phy");
if (!IS_ERR(reg_phy)) {
@@ -1876,8 +1875,7 @@ failed_irq:
failed_regulator:
clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_ipg);
- if (!IS_ERR(fep->clk_ptp))
- clk_disable_unprepare(fep->clk_ptp);
+ clk_disable_unprepare(fep->clk_ptp);
failed_pin:
failed_clk:
iounmap(fep->hwp);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/4] net: freescale: fec: add support for optional enet_out clk
2013-03-18 8:26 [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling Shawn Guo
2013-03-18 8:26 ` [PATCH v2 1/4] net: fec: handle optional clk_ptp more gracefully Shawn Guo
@ 2013-03-18 8:26 ` Shawn Guo
2013-03-18 8:26 ` [PATCH v2 3/4] ARM: dts: mxs: add enet_out clock to devicetree Shawn Guo
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2013-03-18 8:26 UTC (permalink / raw)
To: linux-arm-kernel
From: Wolfram Sang <w.sang@pengutronix.de>
Some MX28 boards need the internal enet_out clock to be enabled. So, do
this in the driver iff the clock was referenced via devicetree.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
drivers/net/ethernet/freescale/fec.c | 10 ++++++++++
drivers/net/ethernet/freescale/fec.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/drivers/net/ethernet/freescale/fec.c b/drivers/net/ethernet/freescale/fec.c
index d2a9851..2297283 100644
--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -1800,6 +1800,11 @@ fec_probe(struct platform_device *pdev)
goto failed_clk;
}
+ /* enet_out is optional, depends on board */
+ fep->clk_enet_out = devm_clk_get(&pdev->dev, "enet_out");
+ if (IS_ERR(fep->clk_enet_out))
+ fep->clk_enet_out = NULL;
+
fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp");
fep->bufdesc_ex =
pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX;
@@ -1810,6 +1815,7 @@ fec_probe(struct platform_device *pdev)
clk_prepare_enable(fep->clk_ahb);
clk_prepare_enable(fep->clk_ipg);
+ clk_prepare_enable(fep->clk_enet_out);
clk_prepare_enable(fep->clk_ptp);
reg_phy = devm_regulator_get(&pdev->dev, "phy");
@@ -1875,6 +1881,7 @@ failed_irq:
failed_regulator:
clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_ipg);
+ clk_disable_unprepare(fep->clk_enet_out);
clk_disable_unprepare(fep->clk_ptp);
failed_pin:
failed_clk:
@@ -1901,6 +1908,7 @@ fec_drv_remove(struct platform_device *pdev)
clk_disable_unprepare(fep->clk_ptp);
if (fep->ptp_clock)
ptp_clock_unregister(fep->ptp_clock);
+ clk_disable_unprepare(fep->clk_enet_out);
clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_ipg);
for (i = 0; i < FEC_IRQ_NUM; i++) {
@@ -1931,6 +1939,7 @@ fec_suspend(struct device *dev)
fec_stop(ndev);
netif_device_detach(ndev);
}
+ clk_disable_unprepare(fep->clk_enet_out);
clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_ipg);
@@ -1943,6 +1952,7 @@ fec_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev);
struct fec_enet_private *fep = netdev_priv(ndev);
+ clk_prepare_enable(fep->clk_enet_out);
clk_prepare_enable(fep->clk_ahb);
clk_prepare_enable(fep->clk_ipg);
if (netif_running(ndev)) {
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index 01579b8..becb7bd 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -208,6 +208,7 @@ struct fec_enet_private {
struct clk *clk_ipg;
struct clk *clk_ahb;
+ struct clk *clk_enet_out;
struct clk *clk_ptp;
/* The saved address of a sent-in-place packet/buffer, for skfree(). */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/4] ARM: dts: mxs: add enet_out clock to devicetree
2013-03-18 8:26 [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling Shawn Guo
2013-03-18 8:26 ` [PATCH v2 1/4] net: fec: handle optional clk_ptp more gracefully Shawn Guo
2013-03-18 8:26 ` [PATCH v2 2/4] net: freescale: fec: add support for optional enet_out clk Shawn Guo
@ 2013-03-18 8:26 ` Shawn Guo
2013-03-18 8:26 ` [PATCH v2 4/4] ARM: mxs: remove unneeded enet_out clk initialization Shawn Guo
2013-03-18 16:57 ` [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2013-03-18 8:26 UTC (permalink / raw)
To: linux-arm-kernel
From: Wolfram Sang <w.sang@pengutronix.de>
Put the clock to the devicetree, so the driver can take care of it
later. Then, we don't have to do the enabling as a workaround in board
init.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
[shawn.guo: add enet_out into imx28.dtsi and overwrite it for m28evk]
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
arch/arm/boot/dts/imx28-m28evk.dts | 2 ++
arch/arm/boot/dts/imx28.dtsi | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/imx28-m28evk.dts b/arch/arm/boot/dts/imx28-m28evk.dts
index 6ce3d17..3d2e1a4 100644
--- a/arch/arm/boot/dts/imx28-m28evk.dts
+++ b/arch/arm/boot/dts/imx28-m28evk.dts
@@ -221,6 +221,8 @@
phy-mode = "rmii";
pinctrl-names = "default";
pinctrl-0 = <&mac0_pins_a>;
+ clocks = <&clks 57>, <&clks 57>;
+ clock-names = "ipg", "ahb";
status = "okay";
};
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index 7ba4966..dc1203d 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -940,8 +940,8 @@
compatible = "fsl,imx28-fec";
reg = <0x800f0000 0x4000>;
interrupts = <101>;
- clocks = <&clks 57>, <&clks 57>;
- clock-names = "ipg", "ahb";
+ clocks = <&clks 57>, <&clks 57>, <&clks 64>;
+ clock-names = "ipg", "ahb", "enet_out";
status = "disabled";
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 4/4] ARM: mxs: remove unneeded enet_out clk initialization
2013-03-18 8:26 [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling Shawn Guo
` (2 preceding siblings ...)
2013-03-18 8:26 ` [PATCH v2 3/4] ARM: dts: mxs: add enet_out clock to devicetree Shawn Guo
@ 2013-03-18 8:26 ` Shawn Guo
2013-03-18 16:57 ` [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2013-03-18 8:26 UTC (permalink / raw)
To: linux-arm-kernel
With fec driver taking care of enet_out clk, most of board setup
do not need to enable enet_out clk. So remove them.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
arch/arm/mach-mxs/mach-mxs.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/arch/arm/mach-mxs/mach-mxs.c b/arch/arm/mach-mxs/mach-mxs.c
index 0521867..026edfc 100644
--- a/arch/arm/mach-mxs/mach-mxs.c
+++ b/arch/arm/mach-mxs/mach-mxs.c
@@ -271,7 +271,6 @@ static inline void enable_clk_enet_out(void)
static void __init imx28_evk_init(void)
{
- enable_clk_enet_out();
update_fec_mac_prop(OUI_FSL);
mxsfb_pdata.mode_list = mx28evk_video_modes;
@@ -299,11 +298,6 @@ static void __init m28evk_init(void)
mxsfb_pdata.ld_intf_width = STMLCDIF_18BIT;
}
-static void __init sc_sps1_init(void)
-{
- enable_clk_enet_out();
-}
-
static int apx4devkit_phy_fixup(struct phy_device *phy)
{
phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
@@ -400,13 +394,11 @@ static void __init tx28_post_init(void)
static void __init cfa10049_init(void)
{
- enable_clk_enet_out();
update_fec_mac_prop(OUI_CRYSTALFONTZ);
}
static void __init cfa10037_init(void)
{
- enable_clk_enet_out();
update_fec_mac_prop(OUI_CRYSTALFONTZ);
mxsfb_pdata.mode_list = cfa10049_video_modes;
@@ -417,8 +409,6 @@ static void __init cfa10037_init(void)
static void __init apf28_init(void)
{
- enable_clk_enet_out();
-
mxsfb_pdata.mode_list = apf28dev_video_modes;
mxsfb_pdata.mode_count = ARRAY_SIZE(apf28dev_video_modes);
mxsfb_pdata.default_bpp = 16;
@@ -441,8 +431,6 @@ static void __init mxs_machine_init(void)
cfa10049_init();
else if (of_machine_is_compatible("armadeus,imx28-apf28"))
apf28_init();
- else if (of_machine_is_compatible("schulercontrol,imx28-sps1"))
- sc_sps1_init();
of_platform_populate(NULL, of_default_bus_match_table,
mxs_auxdata_lookup, NULL);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling
2013-03-18 8:26 [PATCH v2 0/4] ARM: mxs: sanitize enet_out clock handling Shawn Guo
` (3 preceding siblings ...)
2013-03-18 8:26 ` [PATCH v2 4/4] ARM: mxs: remove unneeded enet_out clk initialization Shawn Guo
@ 2013-03-18 16:57 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2013-03-18 16:57 UTC (permalink / raw)
To: linux-arm-kernel
From: Shawn Guo <shawn.guo@linaro.org>
Date: Mon, 18 Mar 2013 16:26:21 +0800
> If the series looks good to you, I hope I can have your ACK on the
> first 2 patches to have the series go via arm-soc tree for sake of
> git bisect. Alternatively, please apply the first 2 on your tree
> for 3.10 and we will queue the platform patches for 3.11.
Feel free to apply these to arm-soc:
Acked-by: David S. Miller <davem@davemloft.net>
^ permalink raw reply [flat|nested] 6+ messages in thread