diff mbox

[U-Boot,v4,1/5] net: fec_mxc: add 1000 Mbps selection

Message ID 1328228569-5794-1-git-send-email-troy.kisky@boundarydevices.com
State Accepted
Delegated to: Stefano Babic
Headers show

Commit Message

Troy Kisky Feb. 3, 2012, 12:22 a.m. UTC
Define CONFIG_FEC_QUIRK_ENET_MAC and add to
board files mx6qarm2 and mx6qsabrelite.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Acked-by: Dirk Behme <dirk.behme@de.bosch.com>
---
 drivers/net/fec_mxc.c           |   21 +++++++++++++++++++--
 drivers/net/fec_mxc.h           |    2 ++
 include/configs/mx6qarm2.h      |    1 +
 include/configs/mx6qsabrelite.h |    1 +
 4 files changed, 23 insertions(+), 2 deletions(-)

This patch series is against Stefano's u-boot-imx 
Patches 2/3 and 5 have changes from version 3

Comments

Dirk Behme Feb. 5, 2012, 6:32 a.m. UTC | #1
On 03.02.2012 01:22, Troy Kisky wrote:
> Define CONFIG_FEC_QUIRK_ENET_MAC and add to
> board files mx6qarm2 and mx6qsabrelite.
>
> Signed-off-by: Troy Kisky<troy.kisky@boundarydevices.com>
> Acked-by: Dirk Behme<dirk.behme@de.bosch.com>
> ---

...

In case someone wants to test this on a mx6qarm2 or any other 
mx51/53/28 board: I pushed this whole v4 patch series to a test branch 
'u-boot-imx-net-test.git'

https://github.com/dirkbehme/u-boot-imx6/commits/u-boot-imx-net-test.git

based on the recent u-boot-imx.git [1].

Best regards

Dirk

[1]

http://git.denx.de/?p=u-boot/u-boot-imx.git;a=summary
"i.mx: i.mx5: update imx_get_mac_from_fuse function"
8e3b8e8bb6845263d048f4f79c1923a8d4b31b55
Stefano Babic Feb. 6, 2012, 10:47 a.m. UTC | #2
On 03/02/2012 01:22, Troy Kisky wrote:
> Define CONFIG_FEC_QUIRK_ENET_MAC and add to
> board files mx6qarm2 and mx6qsabrelite.
> 
> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
> Acked-by: Dirk Behme <dirk.behme@de.bosch.com>
> ---
>  drivers/net/fec_mxc.c           |   21 +++++++++++++++++++--
>  drivers/net/fec_mxc.h           |    2 ++
>  include/configs/mx6qarm2.h      |    1 +
>  include/configs/mx6qsabrelite.h |    1 +
>  4 files changed, 23 insertions(+), 2 deletions(-)
> 
> This patch series is against Stefano's u-boot-imx 
> Patches 2/3 and 5 have changes from version 3

Hi Troy,

> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index ed73353..7c42b87 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -379,13 +379,14 @@ static int fec_set_hwaddr(struct eth_device *dev)
>  static int fec_open(struct eth_device *edev)
>  {
>  	struct fec_priv *fec = (struct fec_priv *)edev->priv;
> +	int speed;
>  
>  	debug("fec_open: fec_open(dev)\n");
>  	/* full-duplex, heartbeat disabled */
>  	writel(1 << 2, &fec->eth->x_cntrl);
>  	fec->rbd_index = 0;
>  
> -#if defined(CONFIG_MX6Q)
> +#ifdef CONFIG_FEC_QUIRK_ENET_MAC
>  	/* Enable ENET HW endian SWAP */
>  	writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_DBSWAP,
>  		&fec->eth->ecntrl);
> @@ -428,9 +429,25 @@ static int fec_open(struct eth_device *edev)
>  #endif
>  
>  	miiphy_wait_aneg(edev);
> -	miiphy_speed(edev->name, fec->phy_id);
> +	speed = miiphy_speed(edev->name, fec->phy_id);
>  	miiphy_duplex(edev->name, fec->phy_id);
>  
> +#ifdef CONFIG_FEC_QUIRK_ENET_MAC
> +	{

It seems to me that QUIRK_ENET_MAC depends on the SOC, and not on the
boards. All imx6 boards must set it. If this is right, what about to put
this setup (as FEC_QUIRK_ENET_MAC) inside the imx-regs.h file ? All imx6
boards will automatically use it.

Best regards,
Stefano Babic
Troy Kisky Feb. 7, 2012, 1:29 a.m. UTC | #3
On 2/6/2012 3:47 AM, Stefano Babic wrote:
> On 03/02/2012 01:22, Troy Kisky wrote:
>> Define CONFIG_FEC_QUIRK_ENET_MAC and add to
>> board files mx6qarm2 and mx6qsabrelite.
>>
>> Signed-off-by: Troy Kisky<troy.kisky@boundarydevices.com>
>> Acked-by: Dirk Behme<dirk.behme@de.bosch.com>
>> ---
>>   drivers/net/fec_mxc.c           |   21 +++++++++++++++++++--
>>   drivers/net/fec_mxc.h           |    2 ++
>>   include/configs/mx6qarm2.h      |    1 +
>>   include/configs/mx6qsabrelite.h |    1 +
>>   4 files changed, 23 insertions(+), 2 deletions(-)
>>
>> This patch series is against Stefano's u-boot-imx
>> Patches 2/3 and 5 have changes from version 3
> Hi Troy,
>
>> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
>> index ed73353..7c42b87 100644
>> --- a/drivers/net/fec_mxc.c
>> +++ b/drivers/net/fec_mxc.c
>> @@ -379,13 +379,14 @@ static int fec_set_hwaddr(struct eth_device *dev)
>>   static int fec_open(struct eth_device *edev)
>>   {
>>   	struct fec_priv *fec = (struct fec_priv *)edev->priv;
>> +	int speed;
>>
>>   	debug("fec_open: fec_open(dev)\n");
>>   	/* full-duplex, heartbeat disabled */
>>   	writel(1<<  2,&fec->eth->x_cntrl);
>>   	fec->rbd_index = 0;
>>
>> -#if defined(CONFIG_MX6Q)
>> +#ifdef CONFIG_FEC_QUIRK_ENET_MAC
>>   	/* Enable ENET HW endian SWAP */
>>   	writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_DBSWAP,
>>   		&fec->eth->ecntrl);
>> @@ -428,9 +429,25 @@ static int fec_open(struct eth_device *edev)
>>   #endif
>>
>>   	miiphy_wait_aneg(edev);
>> -	miiphy_speed(edev->name, fec->phy_id);
>> +	speed = miiphy_speed(edev->name, fec->phy_id);
>>   	miiphy_duplex(edev->name, fec->phy_id);
>>
>> +#ifdef CONFIG_FEC_QUIRK_ENET_MAC
>> +	{
> It seems to me that QUIRK_ENET_MAC depends on the SOC, and not on the
> boards. All imx6 boards must set it. If this is right, what about to put
> this setup (as FEC_QUIRK_ENET_MAC) inside the imx-regs.h file ? All imx6
> boards will automatically use it.
>
> Best regards,
> Stefano Babic
>
Sounds right to me.

Thanks
Troy
diff mbox

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index ed73353..7c42b87 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -379,13 +379,14 @@  static int fec_set_hwaddr(struct eth_device *dev)
 static int fec_open(struct eth_device *edev)
 {
 	struct fec_priv *fec = (struct fec_priv *)edev->priv;
+	int speed;
 
 	debug("fec_open: fec_open(dev)\n");
 	/* full-duplex, heartbeat disabled */
 	writel(1 << 2, &fec->eth->x_cntrl);
 	fec->rbd_index = 0;
 
-#if defined(CONFIG_MX6Q)
+#ifdef CONFIG_FEC_QUIRK_ENET_MAC
 	/* Enable ENET HW endian SWAP */
 	writel(readl(&fec->eth->ecntrl) | FEC_ECNTRL_DBSWAP,
 		&fec->eth->ecntrl);
@@ -428,9 +429,25 @@  static int fec_open(struct eth_device *edev)
 #endif
 
 	miiphy_wait_aneg(edev);
-	miiphy_speed(edev->name, fec->phy_id);
+	speed = miiphy_speed(edev->name, fec->phy_id);
 	miiphy_duplex(edev->name, fec->phy_id);
 
+#ifdef CONFIG_FEC_QUIRK_ENET_MAC
+	{
+		u32 ecr = readl(&fec->eth->ecntrl) & ~FEC_ECNTRL_SPEED;
+		u32 rcr = (readl(&fec->eth->r_cntrl) &
+				~(FEC_RCNTRL_RMII | FEC_RCNTRL_RMII_10T)) |
+				FEC_RCNTRL_RGMII | FEC_RCNTRL_MII_MODE;
+		if (speed == _1000BASET)
+			ecr |= FEC_ECNTRL_SPEED;
+		else if (speed != _100BASET)
+			rcr |= FEC_RCNTRL_RMII_10T;
+		writel(ecr, &fec->eth->ecntrl);
+		writel(rcr, &fec->eth->r_cntrl);
+	}
+#endif
+	debug("%s:Speed=%i\n", __func__, speed);
+
 	/*
 	 * Enable SmartDMA receive task
 	 */
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 9825eab..af33d21 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -198,6 +198,7 @@  struct ethernet_regs {
 #define FEC_RCNTRL_FCE			0x00000020
 #define FEC_RCNTRL_RGMII		0x00000040
 #define FEC_RCNTRL_RMII			0x00000100
+#define FEC_RCNTRL_RMII_10T		0x00000200
 
 #define FEC_TCNTRL_GTS			0x00000001
 #define FEC_TCNTRL_HBC			0x00000002
@@ -207,6 +208,7 @@  struct ethernet_regs {
 
 #define FEC_ECNTRL_RESET		0x00000001	/* reset the FEC */
 #define FEC_ECNTRL_ETHER_EN		0x00000002	/* enable the FEC */
+#define FEC_ECNTRL_SPEED		0x00000020
 #define FEC_ECNTRL_DBSWAP		0x00000100
 
 #define FEC_X_WMRK_STRFWD		0x00000100
diff --git a/include/configs/mx6qarm2.h b/include/configs/mx6qarm2.h
index 0962d3c..495a32a 100644
--- a/include/configs/mx6qarm2.h
+++ b/include/configs/mx6qarm2.h
@@ -61,6 +61,7 @@ 
 #define CONFIG_CMD_MII
 #define CONFIG_CMD_NET
 #define	CONFIG_FEC_MXC
+#define CONFIG_FEC_QUIRK_ENET_MAC
 #define	CONFIG_MII
 #define IMX_FEC_BASE			ENET_BASE_ADDR
 #define	CONFIG_FEC_XCV_TYPE		RGMII
diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h
index d650ee3..2e9775a 100644
--- a/include/configs/mx6qsabrelite.h
+++ b/include/configs/mx6qsabrelite.h
@@ -61,6 +61,7 @@ 
 #define CONFIG_CMD_MII
 #define CONFIG_CMD_NET
 #define	CONFIG_FEC_MXC
+#define CONFIG_FEC_QUIRK_ENET_MAC
 #define	CONFIG_MII
 #define IMX_FEC_BASE			ENET_BASE_ADDR
 #define	CONFIG_FEC_XCV_TYPE		RGMII