diff mbox

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

Message ID 1327616505-11669-1-git-send-email-troy.kisky@boundarydevices.com
State Changes Requested
Delegated to: Stefano Babic
Headers show

Commit Message

Troy Kisky Jan. 26, 2012, 10:21 p.m. UTC
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 drivers/net/fec_mxc.c |   18 +++++++++++++++++-
 drivers/net/fec_mxc.h |    2 ++
 2 files changed, 19 insertions(+), 1 deletions(-)

Comments

Dirk Behme Jan. 27, 2012, 10:25 a.m. UTC | #1
On 26.01.2012 23:21, Troy Kisky wrote:
> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

Whole patch series:

Acked-by: Dirk Behme <dirk.behme@de.bosch.com>

Many thanks!

Dirk
Andy Fleming Jan. 30, 2012, 1:56 a.m. UTC | #2
> diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
> index 3affda8..3fffe79 100644
> --- a/drivers/net/fec_mxc.c
> +++ b/drivers/net/fec_mxc.c
> @@ -378,6 +378,7 @@ 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 */
> @@ -427,8 +428,23 @@ 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_MX6Q

What does this ifdef mean? Can you come up with a name that reflects
the actual configuration difference (ie - it supports gigabit, or it
has the extended whatsit register). When, invariably, the MX7Q (or
whatever) comes out, some unfortunate soul is going to have to figure
out which of the various ifdefs applies *only* to MX6Q, and which
apply also to the new chip.

Even better if this is something that can be determined at runtime.

Andy
diff mbox

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3affda8..3fffe79 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -378,6 +378,7 @@  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 */
@@ -427,8 +428,23 @@  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_MX6Q
+	{
+		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 39337bf..1d6ab06 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