Patchwork [3/4] fec: add support for Freescale i.MX25 PDK (3DS)

login
register
mail settings
Submitter Baruch Siach
Date Dec. 16, 2009, 6:34 a.m.
Message ID <20091216063402.GA13160@jasper.tkos.co.il>
Download mbox | patch
Permalink /patch/41235/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Baruch Siach - Dec. 16, 2009, 6:34 a.m.
Hi Greg,

On Wed, Dec 16, 2009 at 10:13:56AM +1000, Greg Ungerer wrote:
> Baruch Siach wrote:
> >On Tue, Dec 15, 2009 at 09:52:24PM +1000, Greg Ungerer wrote:
> >>On 12/15/2009 06:31 PM, Baruch Siach wrote:
> >>>+#ifndef CONFIG_M5272
> >>I would suggest making this conditional on FEC_MIIGSK_ENR.
> >>Although the CONFIG_M5272 is the only case here currently,
> >>that may change over the years. And using this here may not
> >>be obvious to the causual code reader, since the register
> >>offset definitions don't explicitly key on CONFIG_M5272.
> >
> >OK, I'll change this conditional.
> >
> >Can I take this as an Ack from you?
> 
> With that conditional check changed, sure:
> 
> Acked-by:  Greg Ungerer <gerg@uclinux.org>

Thanks. The updated patch below.

baruch

From 2d0751f868519978603b16baa197bfb9f9ec9e2e Mon Sep 17 00:00:00 2001
Message-Id: <2d0751f868519978603b16baa197bfb9f9ec9e2e.1260945080.git.baruch@tkos.co.il>
From: Baruch Siach <baruch@tkos.co.il>
Date: Mon, 14 Dec 2009 10:36:50 +0200
Subject: [PATCH] fec: add support for PHY interface platform data

The i.MX25 PDK uses RMII to communicate with its PHY. This patch adds the
ability to configure RMII, based on platform data.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Acked-by:  Greg Ungerer <gerg@uclinux.org>
---
 drivers/net/fec.c   |   22 ++++++++++++++++++++++
 drivers/net/fec.h   |    2 ++
 include/linux/fec.h |   21 +++++++++++++++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/fec.h
Greg Ungerer - Dec. 16, 2009, 6:49 a.m.
Hi Baruch,

Baruch Siach wrote:
> Hi Greg,
> 
> On Wed, Dec 16, 2009 at 10:13:56AM +1000, Greg Ungerer wrote:
>> Baruch Siach wrote:
>>> On Tue, Dec 15, 2009 at 09:52:24PM +1000, Greg Ungerer wrote:
>>>> On 12/15/2009 06:31 PM, Baruch Siach wrote:
>>>>> +#ifndef CONFIG_M5272
>>>> I would suggest making this conditional on FEC_MIIGSK_ENR.
>>>> Although the CONFIG_M5272 is the only case here currently,
>>>> that may change over the years. And using this here may not
>>>> be obvious to the causual code reader, since the register
>>>> offset definitions don't explicitly key on CONFIG_M5272.
>>> OK, I'll change this conditional.
>>>
>>> Can I take this as an Ack from you?
>> With that conditional check changed, sure:
>>
>> Acked-by:  Greg Ungerer <gerg@uclinux.org>
> 
> Thanks. The updated patch below.
> 
> baruch
> 
>>From 2d0751f868519978603b16baa197bfb9f9ec9e2e Mon Sep 17 00:00:00 2001
> Message-Id: <2d0751f868519978603b16baa197bfb9f9ec9e2e.1260945080.git.baruch@tkos.co.il>
> From: Baruch Siach <baruch@tkos.co.il>
> Date: Mon, 14 Dec 2009 10:36:50 +0200
> Subject: [PATCH] fec: add support for PHY interface platform data
> 
> The i.MX25 PDK uses RMII to communicate with its PHY. This patch adds the
> ability to configure RMII, based on platform data.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> Acked-by:  Greg Ungerer <gerg@uclinux.org>
> ---
>  drivers/net/fec.c   |   22 ++++++++++++++++++++++
>  drivers/net/fec.h   |    2 ++
>  include/linux/fec.h |   21 +++++++++++++++++++++
>  3 files changed, 45 insertions(+), 0 deletions(-)
>  create mode 100644 include/linux/fec.h
> 
> diff --git a/drivers/net/fec.c b/drivers/net/fec.c
> index 16a1d58..a7cfe0d 100644
> --- a/drivers/net/fec.c
> +++ b/drivers/net/fec.c
> @@ -40,6 +40,7 @@
>  #include <linux/irq.h>
>  #include <linux/clk.h>
>  #include <linux/platform_device.h>
> +#include <linux/fec.h>
>  
>  #include <asm/cacheflush.h>
>  
> @@ -198,6 +199,7 @@ struct fec_enet_private {
>  	uint	phy_speed;
>  	phy_info_t const	*phy;
>  	struct work_struct phy_task;
> +	phy_interface_t	phy_interface;
>  
>  	uint	sequence_done;
>  	uint	mii_phy_task_queued;
> @@ -1810,6 +1812,21 @@ fec_restart(struct net_device *dev, int duplex)
>  	/* Set MII speed */
>  	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
>  
> +#ifdef FEC_MIIGSK_ENR
> +	if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) {
> +		/* disable the gasket and wait */
> +		writel(0, fep->hwp + FEC_MIIGSK_ENR);
> +		while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
> +			udelay(1);
> +
> +		/* configure the gasket: RMII, 50 MHz, no loopback, no echo */
> +		writel(1, fep->hwp + FEC_MIIGSK_CFGR);
> +
> +		/* re-enable the gasket */
> +		writel(2, fep->hwp + FEC_MIIGSK_ENR);
> +	}
> +#endif
> +
>  	/* And last, enable the transmit and receive processing */
>  	writel(2, fep->hwp + FEC_ECNTRL);
>  	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
> @@ -1847,6 +1864,7 @@ static int __devinit
>  fec_probe(struct platform_device *pdev)
>  {
>  	struct fec_enet_private *fep;
> +	struct fec_platform_data *pdata;
>  	struct net_device *ndev;
>  	int i, irq, ret = 0;
>  	struct resource *r;
> @@ -1879,6 +1897,10 @@ fec_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ndev);
>  
> +	pdata = pdev->dev.platform_data;
> +	if (pdata)
> +		fep->phy_interface = pdata->phy;
> +
>  	/* This device has up to three irqs on some platforms */
>  	for (i = 0; i < 3; i++) {
>  		irq = platform_get_irq(pdev, i);
> diff --git a/drivers/net/fec.h b/drivers/net/fec.h
> index cc47f3f..2c48b25 100644
> --- a/drivers/net/fec.h
> +++ b/drivers/net/fec.h
> @@ -43,6 +43,8 @@
>  #define FEC_R_DES_START		0x180 /* Receive descriptor ring */
>  #define FEC_X_DES_START		0x184 /* Transmit descriptor ring */
>  #define FEC_R_BUFF_SIZE		0x188 /* Maximum receive buff size */
> +#define FEC_MIIGSK_CFGR		0x300 /* MIIGSK Configuration reg */
> +#define FEC_MIIGSK_ENR		0x308 /* MIIGSK Enable reg */
>  
>  #else
>  
> diff --git a/include/linux/fec.h b/include/linux/fec.h
> new file mode 100644
> index 0000000..5d3523d
> --- /dev/null
> +++ b/include/linux/fec.h
> @@ -0,0 +1,21 @@
> +/* include/linux/fec.h
> + *
> + * Copyright (c) 2009 Orex Computed Radiography
> + *   Baruch Siach <baruch@tkos.co.il>
> + *
> + * Header file for the FEC platform data
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +#ifndef __LINUX_FEC_H__
> +#define __LINUX_FEC_H__
> +
> +#include <linux/phy.h>
> +
> +struct fec_platform_data {
> +	phy_interface_t phy;
> +};
> +
> +#endif

Can't this go in drivers/net/fec.h with the other fec data structs?

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com
--
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
Baruch Siach - Dec. 16, 2009, 7:07 a.m.
On Wed, Dec 16, 2009 at 04:49:32PM +1000, Greg Ungerer wrote:
> 
> Hi Baruch,
> 
> Baruch Siach wrote:

[snip]

> >diff --git a/include/linux/fec.h b/include/linux/fec.h
> >new file mode 100644
> >index 0000000..5d3523d
> >--- /dev/null
> >+++ b/include/linux/fec.h
> >@@ -0,0 +1,21 @@
> >+/* include/linux/fec.h
> >+ *
> >+ * Copyright (c) 2009 Orex Computed Radiography
> >+ *   Baruch Siach <baruch@tkos.co.il>
> >+ *
> >+ * Header file for the FEC platform data
> >+ *
> >+ * This program is free software; you can redistribute it and/or modify
> >+ * it under the terms of the GNU General Public License version 2 as
> >+ * published by the Free Software Foundation.
> >+ */
> >+#ifndef __LINUX_FEC_H__
> >+#define __LINUX_FEC_H__
> >+
> >+#include <linux/phy.h>
> >+
> >+struct fec_platform_data {
> >+	phy_interface_t phy;
> >+};
> >+
> >+#endif
> 
> Can't this go in drivers/net/fec.h with the other fec data structs?

No. The platform code (arch/arm/mach-mx25/mx25pdk.c in my case) must be able 
to use this struct to pass the necessary information to the driver. See for 
example include/linux/smsc911x.h, include/linux/smc91*.h, etc.

baruch
Baruch Siach - Jan. 5, 2010, 8:24 a.m.
On Wed, Dec 16, 2009 at 08:34:06AM +0200, Baruch Siach wrote:
> Hi Greg,

[snip]

> Thanks. The updated patch below.

Ping?

How should take care of this?

The platform code for i.MX25 PDK is going via Sascha's tree, and it depends on 
this patch to compile.

baruch

> From 2d0751f868519978603b16baa197bfb9f9ec9e2e Mon Sep 17 00:00:00 2001
> Message-Id: <2d0751f868519978603b16baa197bfb9f9ec9e2e.1260945080.git.baruch@tkos.co.il>
> From: Baruch Siach <baruch@tkos.co.il>
> Date: Mon, 14 Dec 2009 10:36:50 +0200
> Subject: [PATCH] fec: add support for PHY interface platform data
> 
> The i.MX25 PDK uses RMII to communicate with its PHY. This patch adds the
> ability to configure RMII, based on platform data.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> Acked-by:  Greg Ungerer <gerg@uclinux.org>
> ---
>  drivers/net/fec.c   |   22 ++++++++++++++++++++++
>  drivers/net/fec.h   |    2 ++
>  include/linux/fec.h |   21 +++++++++++++++++++++
>  3 files changed, 45 insertions(+), 0 deletions(-)
>  create mode 100644 include/linux/fec.h
> 
> diff --git a/drivers/net/fec.c b/drivers/net/fec.c
> index 16a1d58..a7cfe0d 100644
> --- a/drivers/net/fec.c
> +++ b/drivers/net/fec.c
> @@ -40,6 +40,7 @@
>  #include <linux/irq.h>
>  #include <linux/clk.h>
>  #include <linux/platform_device.h>
> +#include <linux/fec.h>
>  
>  #include <asm/cacheflush.h>
>  
> @@ -198,6 +199,7 @@ struct fec_enet_private {
>  	uint	phy_speed;
>  	phy_info_t const	*phy;
>  	struct work_struct phy_task;
> +	phy_interface_t	phy_interface;
>  
>  	uint	sequence_done;
>  	uint	mii_phy_task_queued;
> @@ -1810,6 +1812,21 @@ fec_restart(struct net_device *dev, int duplex)
>  	/* Set MII speed */
>  	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
>  
> +#ifdef FEC_MIIGSK_ENR
> +	if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) {
> +		/* disable the gasket and wait */
> +		writel(0, fep->hwp + FEC_MIIGSK_ENR);
> +		while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
> +			udelay(1);
> +
> +		/* configure the gasket: RMII, 50 MHz, no loopback, no echo */
> +		writel(1, fep->hwp + FEC_MIIGSK_CFGR);
> +
> +		/* re-enable the gasket */
> +		writel(2, fep->hwp + FEC_MIIGSK_ENR);
> +	}
> +#endif
> +
>  	/* And last, enable the transmit and receive processing */
>  	writel(2, fep->hwp + FEC_ECNTRL);
>  	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
> @@ -1847,6 +1864,7 @@ static int __devinit
>  fec_probe(struct platform_device *pdev)
>  {
>  	struct fec_enet_private *fep;
> +	struct fec_platform_data *pdata;
>  	struct net_device *ndev;
>  	int i, irq, ret = 0;
>  	struct resource *r;
> @@ -1879,6 +1897,10 @@ fec_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ndev);
>  
> +	pdata = pdev->dev.platform_data;
> +	if (pdata)
> +		fep->phy_interface = pdata->phy;
> +
>  	/* This device has up to three irqs on some platforms */
>  	for (i = 0; i < 3; i++) {
>  		irq = platform_get_irq(pdev, i);
> diff --git a/drivers/net/fec.h b/drivers/net/fec.h
> index cc47f3f..2c48b25 100644
> --- a/drivers/net/fec.h
> +++ b/drivers/net/fec.h
> @@ -43,6 +43,8 @@
>  #define FEC_R_DES_START		0x180 /* Receive descriptor ring */
>  #define FEC_X_DES_START		0x184 /* Transmit descriptor ring */
>  #define FEC_R_BUFF_SIZE		0x188 /* Maximum receive buff size */
> +#define FEC_MIIGSK_CFGR		0x300 /* MIIGSK Configuration reg */
> +#define FEC_MIIGSK_ENR		0x308 /* MIIGSK Enable reg */
>  
>  #else
>  
> diff --git a/include/linux/fec.h b/include/linux/fec.h
> new file mode 100644
> index 0000000..5d3523d
> --- /dev/null
> +++ b/include/linux/fec.h
> @@ -0,0 +1,21 @@
> +/* include/linux/fec.h
> + *
> + * Copyright (c) 2009 Orex Computed Radiography
> + *   Baruch Siach <baruch@tkos.co.il>
> + *
> + * Header file for the FEC platform data
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +#ifndef __LINUX_FEC_H__
> +#define __LINUX_FEC_H__
> +
> +#include <linux/phy.h>
> +
> +struct fec_platform_data {
> +	phy_interface_t phy;
> +};
> +
> +#endif
> -- 
> 1.6.5
> 
> 
> -- 
>                                                      ~. .~   Tk Open Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
>    - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Ungerer - Jan. 11, 2010, 3:25 a.m.
Hi Baruch,

Baruch Siach wrote:
> On Wed, Dec 16, 2009 at 08:34:06AM +0200, Baruch Siach wrote:
>> Hi Greg,
> 
> [snip]
> 
>> Thanks. The updated patch below.
> 
> Ping?
> 
> How should take care of this?
> 
> The platform code for i.MX25 PDK is going via Sascha's tree, and it depends on 
> this patch to compile.

I assumed it would go via the net git tree?

Regards
Greg



>> From 2d0751f868519978603b16baa197bfb9f9ec9e2e Mon Sep 17 00:00:00 2001
>> Message-Id: <2d0751f868519978603b16baa197bfb9f9ec9e2e.1260945080.git.baruch@tkos.co.il>
>> From: Baruch Siach <baruch@tkos.co.il>
>> Date: Mon, 14 Dec 2009 10:36:50 +0200
>> Subject: [PATCH] fec: add support for PHY interface platform data
>>
>> The i.MX25 PDK uses RMII to communicate with its PHY. This patch adds the
>> ability to configure RMII, based on platform data.
>>
>> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
>> Acked-by:  Greg Ungerer <gerg@uclinux.org>
>> ---
>>  drivers/net/fec.c   |   22 ++++++++++++++++++++++
>>  drivers/net/fec.h   |    2 ++
>>  include/linux/fec.h |   21 +++++++++++++++++++++
>>  3 files changed, 45 insertions(+), 0 deletions(-)
>>  create mode 100644 include/linux/fec.h
>>
>> diff --git a/drivers/net/fec.c b/drivers/net/fec.c
>> index 16a1d58..a7cfe0d 100644
>> --- a/drivers/net/fec.c
>> +++ b/drivers/net/fec.c
>> @@ -40,6 +40,7 @@
>>  #include <linux/irq.h>
>>  #include <linux/clk.h>
>>  #include <linux/platform_device.h>
>> +#include <linux/fec.h>
>>  
>>  #include <asm/cacheflush.h>
>>  
>> @@ -198,6 +199,7 @@ struct fec_enet_private {
>>  	uint	phy_speed;
>>  	phy_info_t const	*phy;
>>  	struct work_struct phy_task;
>> +	phy_interface_t	phy_interface;
>>  
>>  	uint	sequence_done;
>>  	uint	mii_phy_task_queued;
>> @@ -1810,6 +1812,21 @@ fec_restart(struct net_device *dev, int duplex)
>>  	/* Set MII speed */
>>  	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
>>  
>> +#ifdef FEC_MIIGSK_ENR
>> +	if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) {
>> +		/* disable the gasket and wait */
>> +		writel(0, fep->hwp + FEC_MIIGSK_ENR);
>> +		while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
>> +			udelay(1);
>> +
>> +		/* configure the gasket: RMII, 50 MHz, no loopback, no echo */
>> +		writel(1, fep->hwp + FEC_MIIGSK_CFGR);
>> +
>> +		/* re-enable the gasket */
>> +		writel(2, fep->hwp + FEC_MIIGSK_ENR);
>> +	}
>> +#endif
>> +
>>  	/* And last, enable the transmit and receive processing */
>>  	writel(2, fep->hwp + FEC_ECNTRL);
>>  	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
>> @@ -1847,6 +1864,7 @@ static int __devinit
>>  fec_probe(struct platform_device *pdev)
>>  {
>>  	struct fec_enet_private *fep;
>> +	struct fec_platform_data *pdata;
>>  	struct net_device *ndev;
>>  	int i, irq, ret = 0;
>>  	struct resource *r;
>> @@ -1879,6 +1897,10 @@ fec_probe(struct platform_device *pdev)
>>  
>>  	platform_set_drvdata(pdev, ndev);
>>  
>> +	pdata = pdev->dev.platform_data;
>> +	if (pdata)
>> +		fep->phy_interface = pdata->phy;
>> +
>>  	/* This device has up to three irqs on some platforms */
>>  	for (i = 0; i < 3; i++) {
>>  		irq = platform_get_irq(pdev, i);
>> diff --git a/drivers/net/fec.h b/drivers/net/fec.h
>> index cc47f3f..2c48b25 100644
>> --- a/drivers/net/fec.h
>> +++ b/drivers/net/fec.h
>> @@ -43,6 +43,8 @@
>>  #define FEC_R_DES_START		0x180 /* Receive descriptor ring */
>>  #define FEC_X_DES_START		0x184 /* Transmit descriptor ring */
>>  #define FEC_R_BUFF_SIZE		0x188 /* Maximum receive buff size */
>> +#define FEC_MIIGSK_CFGR		0x300 /* MIIGSK Configuration reg */
>> +#define FEC_MIIGSK_ENR		0x308 /* MIIGSK Enable reg */
>>  
>>  #else
>>  
>> diff --git a/include/linux/fec.h b/include/linux/fec.h
>> new file mode 100644
>> index 0000000..5d3523d
>> --- /dev/null
>> +++ b/include/linux/fec.h
>> @@ -0,0 +1,21 @@
>> +/* include/linux/fec.h
>> + *
>> + * Copyright (c) 2009 Orex Computed Radiography
>> + *   Baruch Siach <baruch@tkos.co.il>
>> + *
>> + * Header file for the FEC platform data
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +#ifndef __LINUX_FEC_H__
>> +#define __LINUX_FEC_H__
>> +
>> +#include <linux/phy.h>
>> +
>> +struct fec_platform_data {
>> +	phy_interface_t phy;
>> +};
>> +
>> +#endif
>> -- 
>> 1.6.5
>>
>>
>> -- 
>>                                                      ~. .~   Tk Open Systems
>> =}------------------------------------------------ooO--U--Ooo------------{=
>>    - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Baruch Siach - Jan. 25, 2010, 11:21 a.m.
Hi Greg, netdev,

On Wed, Dec 16, 2009 at 08:34:06AM +0200, Baruch Siach wrote:
> On Wed, Dec 16, 2009 at 10:13:56AM +1000, Greg Ungerer wrote:
> > Baruch Siach wrote:
> > >On Tue, Dec 15, 2009 at 09:52:24PM +1000, Greg Ungerer wrote:
> > >>On 12/15/2009 06:31 PM, Baruch Siach wrote:
> > >>>+#ifndef CONFIG_M5272
> > >>I would suggest making this conditional on FEC_MIIGSK_ENR.
> > >>Although the CONFIG_M5272 is the only case here currently,
> > >>that may change over the years. And using this here may not
> > >>be obvious to the causual code reader, since the register
> > >>offset definitions don't explicitly key on CONFIG_M5272.
> > >
> > >OK, I'll change this conditional.
> > >
> > >Can I take this as an Ack from you?
> > 
> > With that conditional check changed, sure:
> > 
> > Acked-by:  Greg Ungerer <gerg@uclinux.org>
> 
> Thanks. The updated patch below.

I'm really sorry to bug on this again, but since the platform code is already 
upstream the i.MX25 code doesn't build without this patch (include/linux/fec.h 
missing). So, someone please pick up this patch, preferably prior to .33.

baruch

> From 2d0751f868519978603b16baa197bfb9f9ec9e2e Mon Sep 17 00:00:00 2001
> Message-Id: <2d0751f868519978603b16baa197bfb9f9ec9e2e.1260945080.git.baruch@tkos.co.il>
> From: Baruch Siach <baruch@tkos.co.il>
> Date: Mon, 14 Dec 2009 10:36:50 +0200
> Subject: [PATCH] fec: add support for PHY interface platform data
> 
> The i.MX25 PDK uses RMII to communicate with its PHY. This patch adds the
> ability to configure RMII, based on platform data.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> Acked-by:  Greg Ungerer <gerg@uclinux.org>
> ---
>  drivers/net/fec.c   |   22 ++++++++++++++++++++++
>  drivers/net/fec.h   |    2 ++
>  include/linux/fec.h |   21 +++++++++++++++++++++
>  3 files changed, 45 insertions(+), 0 deletions(-)
>  create mode 100644 include/linux/fec.h
> 
> diff --git a/drivers/net/fec.c b/drivers/net/fec.c
> index 16a1d58..a7cfe0d 100644
> --- a/drivers/net/fec.c
> +++ b/drivers/net/fec.c
> @@ -40,6 +40,7 @@
>  #include <linux/irq.h>
>  #include <linux/clk.h>
>  #include <linux/platform_device.h>
> +#include <linux/fec.h>
>  
>  #include <asm/cacheflush.h>
>  
> @@ -198,6 +199,7 @@ struct fec_enet_private {
>  	uint	phy_speed;
>  	phy_info_t const	*phy;
>  	struct work_struct phy_task;
> +	phy_interface_t	phy_interface;
>  
>  	uint	sequence_done;
>  	uint	mii_phy_task_queued;
> @@ -1810,6 +1812,21 @@ fec_restart(struct net_device *dev, int duplex)
>  	/* Set MII speed */
>  	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
>  
> +#ifdef FEC_MIIGSK_ENR
> +	if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) {
> +		/* disable the gasket and wait */
> +		writel(0, fep->hwp + FEC_MIIGSK_ENR);
> +		while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
> +			udelay(1);
> +
> +		/* configure the gasket: RMII, 50 MHz, no loopback, no echo */
> +		writel(1, fep->hwp + FEC_MIIGSK_CFGR);
> +
> +		/* re-enable the gasket */
> +		writel(2, fep->hwp + FEC_MIIGSK_ENR);
> +	}
> +#endif
> +
>  	/* And last, enable the transmit and receive processing */
>  	writel(2, fep->hwp + FEC_ECNTRL);
>  	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
> @@ -1847,6 +1864,7 @@ static int __devinit
>  fec_probe(struct platform_device *pdev)
>  {
>  	struct fec_enet_private *fep;
> +	struct fec_platform_data *pdata;
>  	struct net_device *ndev;
>  	int i, irq, ret = 0;
>  	struct resource *r;
> @@ -1879,6 +1897,10 @@ fec_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, ndev);
>  
> +	pdata = pdev->dev.platform_data;
> +	if (pdata)
> +		fep->phy_interface = pdata->phy;
> +
>  	/* This device has up to three irqs on some platforms */
>  	for (i = 0; i < 3; i++) {
>  		irq = platform_get_irq(pdev, i);
> diff --git a/drivers/net/fec.h b/drivers/net/fec.h
> index cc47f3f..2c48b25 100644
> --- a/drivers/net/fec.h
> +++ b/drivers/net/fec.h
> @@ -43,6 +43,8 @@
>  #define FEC_R_DES_START		0x180 /* Receive descriptor ring */
>  #define FEC_X_DES_START		0x184 /* Transmit descriptor ring */
>  #define FEC_R_BUFF_SIZE		0x188 /* Maximum receive buff size */
> +#define FEC_MIIGSK_CFGR		0x300 /* MIIGSK Configuration reg */
> +#define FEC_MIIGSK_ENR		0x308 /* MIIGSK Enable reg */
>  
>  #else
>  
> diff --git a/include/linux/fec.h b/include/linux/fec.h
> new file mode 100644
> index 0000000..5d3523d
> --- /dev/null
> +++ b/include/linux/fec.h
> @@ -0,0 +1,21 @@
> +/* include/linux/fec.h
> + *
> + * Copyright (c) 2009 Orex Computed Radiography
> + *   Baruch Siach <baruch@tkos.co.il>
> + *
> + * Header file for the FEC platform data
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +#ifndef __LINUX_FEC_H__
> +#define __LINUX_FEC_H__
> +
> +#include <linux/phy.h>
> +
> +struct fec_platform_data {
> +	phy_interface_t phy;
> +};
> +
> +#endif
> -- 
> 1.6.5
> 
> 
> -- 
>                                                      ~. .~   Tk Open Systems
> =}------------------------------------------------ooO--U--Ooo------------{=
>    - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Jean-Christophe DUBOIS - May 19, 2010, 3:15 p.m.
le lundi 25 janvier 2010 Baruch Siach a écrit
> Hi Greg, netdev,
> 
> On Wed, Dec 16, 2009 at 08:34:06AM +0200, Baruch Siach wrote:
> > On Wed, Dec 16, 2009 at 10:13:56AM +1000, Greg Ungerer wrote:
> > > Baruch Siach wrote:
> > > >On Tue, Dec 15, 2009 at 09:52:24PM +1000, Greg Ungerer wrote:
> > > >>On 12/15/2009 06:31 PM, Baruch Siach wrote:
> > > >>>+#ifndef CONFIG_M5272
> > > >>
> > > >>I would suggest making this conditional on FEC_MIIGSK_ENR.
> > > >>Although the CONFIG_M5272 is the only case here currently,
> > > >>that may change over the years. And using this here may not
> > > >>be obvious to the causual code reader, since the register
> > > >>offset definitions don't explicitly key on CONFIG_M5272.
> > > >
> > > >OK, I'll change this conditional.
> > > >
> > > >Can I take this as an Ack from you?
> > > 
> > > With that conditional check changed, sure:
> > > 
> > > Acked-by:  Greg Ungerer <gerg@uclinux.org>
> > 
> > Thanks. The updated patch below.
> 
> I'm really sorry to bug on this again, but since the platform code is
> already upstream the i.MX25 code doesn't build without this patch
> (include/linux/fec.h missing). So, someone please pick up this patch,
> preferably prior to .33.
> 
> baruch

I am just wondering if somebody is going to pick up this patch 
(http://patchwork.ozlabs.org/patch/41235/) so that it finds its way on 
mainline.

The i.MX25 PDK platform (3DStack) has been broken for 2 kernel releases (as 
the actual code depend on this). Is there hope that this patch is picked up by 
somebody in order to get merged to main line someday?

Or is it not acceptable in this state for some reason?

Either the FEC changes need to be merged (possibly with some modification if 
there are issues) or the part depending on it in the ARM tree need to be 
reverted. We should not stay in this non coherent state.

JC
--
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
Sascha Hauer - May 20, 2010, 6:46 a.m.
On Wed, May 19, 2010 at 05:15:52PM +0200, Jean-Christophe Dubois wrote:
> le lundi 25 janvier 2010 Baruch Siach a écrit
> > Hi Greg, netdev,
> > 
> > On Wed, Dec 16, 2009 at 08:34:06AM +0200, Baruch Siach wrote:
> > > On Wed, Dec 16, 2009 at 10:13:56AM +1000, Greg Ungerer wrote:
> > > > Baruch Siach wrote:
> > > > >On Tue, Dec 15, 2009 at 09:52:24PM +1000, Greg Ungerer wrote:
> > > > >>On 12/15/2009 06:31 PM, Baruch Siach wrote:
> > > > >>>+#ifndef CONFIG_M5272
> > > > >>
> > > > >>I would suggest making this conditional on FEC_MIIGSK_ENR.
> > > > >>Although the CONFIG_M5272 is the only case here currently,
> > > > >>that may change over the years. And using this here may not
> > > > >>be obvious to the causual code reader, since the register
> > > > >>offset definitions don't explicitly key on CONFIG_M5272.
> > > > >
> > > > >OK, I'll change this conditional.
> > > > >
> > > > >Can I take this as an Ack from you?
> > > > 
> > > > With that conditional check changed, sure:
> > > > 
> > > > Acked-by:  Greg Ungerer <gerg@uclinux.org>
> > > 
> > > Thanks. The updated patch below.
> > 
> > I'm really sorry to bug on this again, but since the platform code is
> > already upstream the i.MX25 code doesn't build without this patch
> > (include/linux/fec.h missing). So, someone please pick up this patch,
> > preferably prior to .33.
> > 
> > baruch
> 
> I am just wondering if somebody is going to pick up this patch 
> (http://patchwork.ozlabs.org/patch/41235/) so that it finds its way on 
> mainline.

I'm much in favour of this patch. David?

Sascha
David Miller - May 20, 2010, 6:49 a.m.
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Thu, 20 May 2010 08:46:43 +0200

> On Wed, May 19, 2010 at 05:15:52PM +0200, Jean-Christophe Dubois wrote:
>> 
>> I am just wondering if somebody is going to pick up this patch 
>> (http://patchwork.ozlabs.org/patch/41235/) so that it finds its way on 
>> mainline.
> 
> I'm much in favour of this patch. David?

I put it back into my queue.
--
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

diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index 16a1d58..a7cfe0d 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -40,6 +40,7 @@ 
 #include <linux/irq.h>
 #include <linux/clk.h>
 #include <linux/platform_device.h>
+#include <linux/fec.h>
 
 #include <asm/cacheflush.h>
 
@@ -198,6 +199,7 @@  struct fec_enet_private {
 	uint	phy_speed;
 	phy_info_t const	*phy;
 	struct work_struct phy_task;
+	phy_interface_t	phy_interface;
 
 	uint	sequence_done;
 	uint	mii_phy_task_queued;
@@ -1810,6 +1812,21 @@  fec_restart(struct net_device *dev, int duplex)
 	/* Set MII speed */
 	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
 
+#ifdef FEC_MIIGSK_ENR
+	if (fep->phy_interface == PHY_INTERFACE_MODE_RMII) {
+		/* disable the gasket and wait */
+		writel(0, fep->hwp + FEC_MIIGSK_ENR);
+		while (readl(fep->hwp + FEC_MIIGSK_ENR) & 4)
+			udelay(1);
+
+		/* configure the gasket: RMII, 50 MHz, no loopback, no echo */
+		writel(1, fep->hwp + FEC_MIIGSK_CFGR);
+
+		/* re-enable the gasket */
+		writel(2, fep->hwp + FEC_MIIGSK_ENR);
+	}
+#endif
+
 	/* And last, enable the transmit and receive processing */
 	writel(2, fep->hwp + FEC_ECNTRL);
 	writel(0, fep->hwp + FEC_R_DES_ACTIVE);
@@ -1847,6 +1864,7 @@  static int __devinit
 fec_probe(struct platform_device *pdev)
 {
 	struct fec_enet_private *fep;
+	struct fec_platform_data *pdata;
 	struct net_device *ndev;
 	int i, irq, ret = 0;
 	struct resource *r;
@@ -1879,6 +1897,10 @@  fec_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, ndev);
 
+	pdata = pdev->dev.platform_data;
+	if (pdata)
+		fep->phy_interface = pdata->phy;
+
 	/* This device has up to three irqs on some platforms */
 	for (i = 0; i < 3; i++) {
 		irq = platform_get_irq(pdev, i);
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index cc47f3f..2c48b25 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -43,6 +43,8 @@ 
 #define FEC_R_DES_START		0x180 /* Receive descriptor ring */
 #define FEC_X_DES_START		0x184 /* Transmit descriptor ring */
 #define FEC_R_BUFF_SIZE		0x188 /* Maximum receive buff size */
+#define FEC_MIIGSK_CFGR		0x300 /* MIIGSK Configuration reg */
+#define FEC_MIIGSK_ENR		0x308 /* MIIGSK Enable reg */
 
 #else
 
diff --git a/include/linux/fec.h b/include/linux/fec.h
new file mode 100644
index 0000000..5d3523d
--- /dev/null
+++ b/include/linux/fec.h
@@ -0,0 +1,21 @@ 
+/* include/linux/fec.h
+ *
+ * Copyright (c) 2009 Orex Computed Radiography
+ *   Baruch Siach <baruch@tkos.co.il>
+ *
+ * Header file for the FEC platform data
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __LINUX_FEC_H__
+#define __LINUX_FEC_H__
+
+#include <linux/phy.h>
+
+struct fec_platform_data {
+	phy_interface_t phy;
+};
+
+#endif