linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i.MX6 ethernet phy fixup
@ 2013-06-20 15:34 Sascha Hauer
  2013-06-20 15:34 ` [PATCH 1/3] ARM: i.MX6: call ksz9021 phy fixup for all i.MX6 boards Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-06-20 15:34 UTC (permalink / raw)
  To: linux-arm-kernel

All i.MX6 boards with gigabit phy I'm aware of have the same fixup
in U-Boot for adjusting the rx/tx delay lines. In the kernel we
only have a fixup for the sabrelite board. Instead of adding individual
board hooks for each new boards I think we should just do register
the fixups unconditionally on i.MX for each known phy type.

This makes ethernet work on the different boards even when the bootloader
misses to do it (or Linux resets the phy during startup of the ethernet
interface).

I suspect this series is only the tip of the iceberg as I also see other
boards having to adjust the rx/tx delay lines. The proper fix would probably
be some phy level callbacks to adjust these values.

Sascha

----------------------------------------------------------------
Sascha Hauer (3):
      ARM: i.MX6: call ksz9021 phy fixup for all i.MX6 boards
      ARM: i.MX6: add ethernet phy fixup for AR8031
      ARM: i.MX6: add ethernet phy fixup for KSZ9031

 arch/arm/mach-imx/mach-imx6q.c | 60 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] ARM: i.MX6: call ksz9021 phy fixup for all i.MX6 boards
  2013-06-20 15:34 [PATCH] i.MX6 ethernet phy fixup Sascha Hauer
@ 2013-06-20 15:34 ` Sascha Hauer
  2013-06-20 15:34 ` [PATCH 2/3] ARM: i.MX6: add ethernet phy fixup for AR8031 Sascha Hauer
  2013-06-20 15:34 ` [PATCH 3/3] ARM: i.MX6: add ethernet phy fixup for KSZ9031 Sascha Hauer
  2 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-06-20 15:34 UTC (permalink / raw)
  To: linux-arm-kernel

In current U-Boot the sabrelite, nitrogen6x and titanium all need
the same fixup for the ksz9021 phy. Instead of limiting the fixup
to a single board apply them for all.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/mach-imx6q.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 5536fd8..e5f4a5b 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -137,12 +137,12 @@ put_clk:
 		clk_put(cko1);
 }
 
-static void __init imx6q_sabrelite_init(void)
+static void __init imx6q_enet_phy_init(void)
 {
-	if (IS_BUILTIN(CONFIG_PHYLIB))
+	if (IS_BUILTIN(CONFIG_PHYLIB)) {
 		phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
 				ksz9021rn_phy_fixup);
-	imx6q_sabrelite_cko1_setup();
+	}
 }
 
 static void __init imx6q_1588_init(void)
@@ -164,7 +164,9 @@ static void __init imx6q_usb_init(void)
 static void __init imx6q_init_machine(void)
 {
 	if (of_machine_is_compatible("fsl,imx6q-sabrelite"))
-		imx6q_sabrelite_init();
+		imx6q_sabrelite_cko1_setup();
+
+	imx6q_enet_phy_init();
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ARM: i.MX6: add ethernet phy fixup for AR8031
  2013-06-20 15:34 [PATCH] i.MX6 ethernet phy fixup Sascha Hauer
  2013-06-20 15:34 ` [PATCH 1/3] ARM: i.MX6: call ksz9021 phy fixup for all i.MX6 boards Sascha Hauer
@ 2013-06-20 15:34 ` Sascha Hauer
  2013-06-20 17:13   ` Michael Heimpold
  2013-06-20 15:34 ` [PATCH 3/3] ARM: i.MX6: add ethernet phy fixup for KSZ9031 Sascha Hauer
  2 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2013-06-20 15:34 UTC (permalink / raw)
  To: linux-arm-kernel

The AR8031 is used on the i.MX6 based sabreSD, sabreauto and wandboard.
All need the same fixup, so add it for all i.MX6.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/mach-imx6q.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index e5f4a5b..69fae87 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -113,6 +113,29 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
 	return 0;
 }
 
+static int ar8031_phy_fixup(struct phy_device *dev)
+{
+	u16 val;
+
+	/* To enable AR8031 ouput a 125MHz clk from CLK_25M */
+	phy_write(dev, 0xd, 0x7);
+	phy_write(dev, 0xe, 0x8016);
+	phy_write(dev, 0xd, 0x4007);
+
+	val = phy_read(dev, 0xe);
+	val &= 0xffe3;
+	val |= 0x18;
+	phy_write(dev, 0xe, val);
+
+	/* introduce tx clock delay */
+	phy_write(dev, 0x1d, 0x5);
+	val = phy_read(dev, 0x1e);
+	val |= 0x0100;
+	phy_write(dev, 0x1e, val);
+
+	return 0;
+}
+
 static void __init imx6q_sabrelite_cko1_setup(void)
 {
 	struct clk *cko1_sel, *ahb, *cko1;
@@ -137,11 +160,15 @@ put_clk:
 		clk_put(cko1);
 }
 
+#define PHY_ID_AR8031	0x004dd074
+
 static void __init imx6q_enet_phy_init(void)
 {
 	if (IS_BUILTIN(CONFIG_PHYLIB)) {
 		phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
 				ksz9021rn_phy_fixup);
+		phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
+				ar8031_phy_fixup);
 	}
 }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] ARM: i.MX6: add ethernet phy fixup for KSZ9031
  2013-06-20 15:34 [PATCH] i.MX6 ethernet phy fixup Sascha Hauer
  2013-06-20 15:34 ` [PATCH 1/3] ARM: i.MX6: call ksz9021 phy fixup for all i.MX6 boards Sascha Hauer
  2013-06-20 15:34 ` [PATCH 2/3] ARM: i.MX6: add ethernet phy fixup for AR8031 Sascha Hauer
@ 2013-06-20 15:34 ` Sascha Hauer
  2 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2013-06-20 15:34 UTC (permalink / raw)
  To: linux-arm-kernel

The KSZ9031 is used on the i.MX6 based Data Modul eDM-QMX6
board. It needs the same fixup to the rx/tx delays as other
i.MX6 boards.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/mach-imx6q.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 69fae87..2f02875 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -113,6 +113,27 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
 	return 0;
 }
 
+static void mmd_write_reg(struct phy_device *dev, int device, int reg, int val)
+{
+	phy_write(dev, 0x0d, device);
+	phy_write(dev, 0x0e, reg);
+	phy_write(dev, 0x0d, (1 << 14) | device);
+	phy_write(dev, 0x0e, val);
+}
+
+static int ksz9031rn_phy_fixup(struct phy_device *dev)
+{
+	/*
+	 * min rx data delay, max rx/tx clock delay,
+	 * min rx/tx control delay
+	 */
+	mmd_write_reg(dev, 2, 4, 0);
+	mmd_write_reg(dev, 2, 5, 0);
+	mmd_write_reg(dev, 2, 8, 0x003ff);
+
+	return 0;
+}
+
 static int ar8031_phy_fixup(struct phy_device *dev)
 {
 	u16 val;
@@ -167,6 +188,8 @@ static void __init imx6q_enet_phy_init(void)
 	if (IS_BUILTIN(CONFIG_PHYLIB)) {
 		phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
 				ksz9021rn_phy_fixup);
+		phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK,
+				ksz9031rn_phy_fixup);
 		phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
 				ar8031_phy_fixup);
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ARM: i.MX6: add ethernet phy fixup for AR8031
  2013-06-20 15:34 ` [PATCH 2/3] ARM: i.MX6: add ethernet phy fixup for AR8031 Sascha Hauer
@ 2013-06-20 17:13   ` Michael Heimpold
  2013-06-21  5:40     ` Shawn Guo
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heimpold @ 2013-06-20 17:13 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

Am Donnerstag, 20. Juni 2013, 17:34:32 schrieb Sascha Hauer:
> The AR8031 is used on the i.MX6 based sabreSD, sabreauto and wandboard.
> All need the same fixup, so add it for all i.MX6.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  arch/arm/mach-imx/mach-imx6q.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
> index e5f4a5b..69fae87 100644
> --- a/arch/arm/mach-imx/mach-imx6q.c
> +++ b/arch/arm/mach-imx/mach-imx6q.c
> @@ -113,6 +113,29 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
>  	return 0;
>  }
>  
> +static int ar8031_phy_fixup(struct phy_device *dev)
> +{
> +	u16 val;
> +
> +	/* To enable AR8031 ouput a 125MHz clk from CLK_25M */

Typo? "ouput" -> "output"

> +	phy_write(dev, 0xd, 0x7);
> +	phy_write(dev, 0xe, 0x8016);
> +	phy_write(dev, 0xd, 0x4007);
> +
> +	val = phy_read(dev, 0xe);
> +	val &= 0xffe3;
> +	val |= 0x18;
> +	phy_write(dev, 0xe, val);
> +
> +	/* introduce tx clock delay */
> +	phy_write(dev, 0x1d, 0x5);
> +	val = phy_read(dev, 0x1e);
> +	val |= 0x0100;
> +	phy_write(dev, 0x1e, val);
> +
> +	return 0;
> +}
> +
>  static void __init imx6q_sabrelite_cko1_setup(void)
>  {
>  	struct clk *cko1_sel, *ahb, *cko1;
> @@ -137,11 +160,15 @@ put_clk:
>  		clk_put(cko1);
>  }
>  
> +#define PHY_ID_AR8031	0x004dd074
> +
>  static void __init imx6q_enet_phy_init(void)
>  {
>  	if (IS_BUILTIN(CONFIG_PHYLIB)) {
>  		phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
>  				ksz9021rn_phy_fixup);
> +		phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffff,
> +				ar8031_phy_fixup);
>  	}
>  }
>  
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ARM: i.MX6: add ethernet phy fixup for AR8031
  2013-06-20 17:13   ` Michael Heimpold
@ 2013-06-21  5:40     ` Shawn Guo
  0 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2013-06-21  5:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 20, 2013 at 07:13:41PM +0200, Michael Heimpold wrote:
> Hi,
> 
> Am Donnerstag, 20. Juni 2013, 17:34:32 schrieb Sascha Hauer:
> > The AR8031 is used on the i.MX6 based sabreSD, sabreauto and wandboard.
> > All need the same fixup, so add it for all i.MX6.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  arch/arm/mach-imx/mach-imx6q.c | 27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> > 
> > diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
> > index e5f4a5b..69fae87 100644
> > --- a/arch/arm/mach-imx/mach-imx6q.c
> > +++ b/arch/arm/mach-imx/mach-imx6q.c
> > @@ -113,6 +113,29 @@ static int ksz9021rn_phy_fixup(struct phy_device *phydev)
> >  	return 0;
> >  }
> >  
> > +static int ar8031_phy_fixup(struct phy_device *dev)
> > +{
> > +	u16 val;
> > +
> > +	/* To enable AR8031 ouput a 125MHz clk from CLK_25M */
> 
> Typo? "ouput" -> "output"
> 
I fixed it up and applied the series.

Shawn

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-06-21  5:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-20 15:34 [PATCH] i.MX6 ethernet phy fixup Sascha Hauer
2013-06-20 15:34 ` [PATCH 1/3] ARM: i.MX6: call ksz9021 phy fixup for all i.MX6 boards Sascha Hauer
2013-06-20 15:34 ` [PATCH 2/3] ARM: i.MX6: add ethernet phy fixup for AR8031 Sascha Hauer
2013-06-20 17:13   ` Michael Heimpold
2013-06-21  5:40     ` Shawn Guo
2013-06-20 15:34 ` [PATCH 3/3] ARM: i.MX6: add ethernet phy fixup for KSZ9031 Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).