netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi
@ 2010-01-14  8:13 Liu Yu
  2010-01-14  8:13 ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Liu Yu
  2010-02-01 21:46 ` [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Grant Likely
  0 siblings, 2 replies; 11+ messages in thread
From: Liu Yu @ 2010-01-14  8:13 UTC (permalink / raw)
  To: galak, davem; +Cc: netdev, Liu Yu, linuxppc-dev

After these change, when need to work in rtbi mode,
just change phy-connection-type to "rtbi".

Also, this work can be done by u-boot.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
 arch/powerpc/boot/dts/mpc8569mds.dts |   47 ++++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8569mds.dts b/arch/powerpc/boot/dts/mpc8569mds.dts
index 795eb36..8b72eaf 100644
--- a/arch/powerpc/boot/dts/mpc8569mds.dts
+++ b/arch/powerpc/boot/dts/mpc8569mds.dts
@@ -535,6 +535,7 @@
 			rx-clock-name = "none";
 			tx-clock-name = "clk12";
 			pio-handle = <&pio1>;
+			tbi-handle = <&tbi1>;
 			phy-handle = <&qe_phy0>;
 			phy-connection-type = "rgmii-id";
 		};
@@ -579,7 +580,7 @@
 				reg = <0x6>;
 				device_type = "ethernet-phy";
 			};
-			tbi-phy@11 {
+			tbi1: tbi-phy@11 {
 				reg = <0x11>;
 				device_type = "tbi-phy";
 			};
@@ -590,7 +591,7 @@
 			reg = <0x3520 0x18>;
 			compatible = "fsl,ucc-mdio";
 
-			tbi0: tbi-phy@15 {
+			tbi6: tbi-phy@15 {
 			reg = <0x15>;
 			device_type = "tbi-phy";
 			};
@@ -600,7 +601,7 @@
 			#size-cells = <0>;
 			reg = <0x3720 0x38>;
 			compatible = "fsl,ucc-mdio";
-			tbi1: tbi-phy@17 {
+			tbi8: tbi-phy@17 {
 				reg = <0x17>;
 				device_type = "tbi-phy";
 			};
@@ -617,10 +618,22 @@
 			rx-clock-name = "none";
 			tx-clock-name = "clk12";
 			pio-handle = <&pio3>;
+			tbi-handle = <&tbi3>;
 			phy-handle = <&qe_phy2>;
 			phy-connection-type = "rgmii-id";
 		};
 
+		mdio@2320 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x2320 0x18>;
+			compatible = "fsl,ucc-mdio";
+			tbi3: tbi-phy@11 {
+				reg = <0x11>;
+				device_type = "tbi-phy";
+			};
+		};
+
 		enet1: ucc@3000 {
 			device_type = "network";
 			compatible = "ucc_geth";
@@ -632,10 +645,22 @@
 			rx-clock-name = "none";
 			tx-clock-name = "clk17";
 			pio-handle = <&pio2>;
+			tbi-handle = <&tbi2>;
 			phy-handle = <&qe_phy1>;
 			phy-connection-type = "rgmii-id";
 		};
 
+		mdio@3120 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x3120 0x18>;
+			compatible = "fsl,ucc-mdio";
+			tbi2: tbi-phy@11 {
+				reg = <0x11>;
+				device_type = "tbi-phy";
+			};
+		};
+
 		enet3: ucc@3200 {
 			device_type = "network";
 			compatible = "ucc_geth";
@@ -647,10 +672,22 @@
 			rx-clock-name = "none";
 			tx-clock-name = "clk17";
 			pio-handle = <&pio4>;
+			tbi-handle = <&tbi4>;
 			phy-handle = <&qe_phy3>;
 			phy-connection-type = "rgmii-id";
 		};
 
+		mdio@3320 {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x3320 0x18>;
+			compatible = "fsl,ucc-mdio";
+			tbi4: tbi-phy@11 {
+				reg = <0x11>;
+				device_type = "tbi-phy";
+			};
+		};
+
 		enet5: ucc@3400 {
 			device_type = "network";
 			compatible = "ucc_geth";
@@ -661,7 +698,7 @@
 			local-mac-address = [ 00 00 00 00 00 00 ];
 			rx-clock-name = "none";
 			tx-clock-name = "none";
-			tbi-handle = <&tbi0>;
+			tbi-handle = <&tbi6>;
 			phy-handle = <&qe_phy5>;
 			phy-connection-type = "sgmii";
 		};
@@ -676,7 +713,7 @@
 			local-mac-address = [ 00 00 00 00 00 00 ];
 			rx-clock-name = "none";
 			tx-clock-name = "none";
-			tbi-handle = <&tbi1>;
+			tbi-handle = <&tbi8>;
 			phy-handle = <&qe_phy7>;
 			phy-connection-type = "sgmii";
 		};
-- 
1.6.4

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

* [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode
  2010-01-14  8:13 [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Liu Yu
@ 2010-01-14  8:13 ` Liu Yu
  2010-01-14  8:13   ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Liu Yu
  2010-02-01 21:57   ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Grant Likely
  2010-02-01 21:46 ` [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Grant Likely
  1 sibling, 2 replies; 11+ messages in thread
From: Liu Yu @ 2010-01-14  8:13 UTC (permalink / raw)
  To: galak, davem; +Cc: netdev, Liu Yu, linuxppc-dev

Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
 arch/powerpc/platforms/85xx/mpc85xx_mds.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index c5028a2..0872e4a 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -237,6 +237,8 @@ static void __init mpc85xx_mds_setup_arch(void)
 		} else if (machine_is(mpc8569_mds)) {
 #define BCSR7_UCC12_GETHnRST	(0x1 << 2)
 #define BCSR8_UEM_MARVELL_RST	(0x1 << 1)
+#define BCSR_UCC_RGMII		(0x1 << 6)
+#define BCSR_UCC_RTBI		(0x1 << 5)
 			/*
 			 * U-Boot mangles interrupt polarity for Marvell PHYs,
 			 * so reset built-in and UEM Marvell PHYs, this puts
@@ -247,6 +249,28 @@ static void __init mpc85xx_mds_setup_arch(void)
 
 			setbits8(&bcsr_regs[7], BCSR7_UCC12_GETHnRST);
 			clrbits8(&bcsr_regs[8], BCSR8_UEM_MARVELL_RST);
+
+			for (np = NULL; (np = of_find_compatible_node(np,
+							"network",
+							"ucc_geth")) != NULL;) {
+				const unsigned int *prop;
+				int ucc_num;
+
+				prop = of_get_property(np, "cell-index", NULL);
+				if (prop == NULL)
+					continue;
+
+				ucc_num = *prop - 1;
+
+				prop = of_get_property(np, "phy-connection-type", NULL);
+				if (prop == NULL)
+					continue;
+
+				if (strcmp("rtbi", (const char *)prop) == 0)
+					clrsetbits_8(&bcsr_regs[7 + ucc_num],
+						BCSR_UCC_RGMII, BCSR_UCC_RTBI);
+			}
+
 		}
 		iounmap(bcsr_regs);
 	}
-- 
1.6.4

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

* [PATCH 3/4] ucc_geth: update the tbi-phy setting
  2010-01-14  8:13 ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Liu Yu
@ 2010-01-14  8:13   ` Liu Yu
  2010-01-14  8:13     ` [PATCH 4/4] phy: add RTBI mode for m88e1111 Liu Yu
  2010-02-01 22:00     ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Grant Likely
  2010-02-01 21:57   ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Grant Likely
  1 sibling, 2 replies; 11+ messages in thread
From: Liu Yu @ 2010-01-14  8:13 UTC (permalink / raw)
  To: galak, davem; +Cc: netdev, Liu Yu, linuxppc-dev

Old method only set tbi-phy for eth0.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
 drivers/net/ucc_geth.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 750d86d..0e72013 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -37,6 +37,7 @@
 #include <asm/qe.h>
 #include <asm/ucc.h>
 #include <asm/ucc_fast.h>
+#include <asm/machdep.h>
 
 #include "ucc_geth.h"
 #include "fsl_pq_mdio.h"
@@ -1334,7 +1335,7 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
 	struct ucc_geth __iomem *ug_regs;
 	struct ucc_fast __iomem *uf_regs;
 	int ret_val;
-	u32 upsmr, maccfg2, tbiBaseAddress;
+	u32 upsmr, maccfg2;
 	u16 value;
 
 	ugeth_vdbg("%s: IN", __func__);
@@ -1389,14 +1390,20 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
 	/* Note that this depends on proper setting in utbipar register. */
 	if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) ||
 	    (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
-		tbiBaseAddress = in_be32(&ug_regs->utbipar);
-		tbiBaseAddress &= UTBIPAR_PHY_ADDRESS_MASK;
-		tbiBaseAddress >>= UTBIPAR_PHY_ADDRESS_SHIFT;
-		value = ugeth->phydev->bus->read(ugeth->phydev->bus,
-				(u8) tbiBaseAddress, ENET_TBI_MII_CR);
+		struct ucc_geth_info *ug_info = ugeth->ug_info;
+		struct phy_device *tbiphy;
+
+		if (!ug_info->tbi_node)
+			ugeth_warn("TBI mode requires that the device "
+				"tree specify a tbi-handle\n");
+
+		tbiphy = of_phy_find_device(ug_info->tbi_node);
+		if (!tbiphy)
+			ugeth_warn("Could not get TBI device\n");
+
+		value = phy_read(tbiphy, ENET_TBI_MII_CR);
 		value &= ~0x1000;	/* Turn off autonegotiation */
-		ugeth->phydev->bus->write(ugeth->phydev->bus,
-				(u8) tbiBaseAddress, ENET_TBI_MII_CR, value);
+		phy_write(tbiphy, ENET_TBI_MII_CR, value);
 	}
 
 	init_check_frame_length_mode(ug_info->lengthCheckRx, &ug_regs->maccfg2);
-- 
1.6.4

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

* [PATCH 4/4] phy: add RTBI mode for m88e1111
  2010-01-14  8:13   ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Liu Yu
@ 2010-01-14  8:13     ` Liu Yu
  2010-01-14 16:20       ` Kumar Gala
  2010-02-01 22:00     ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Grant Likely
  1 sibling, 1 reply; 11+ messages in thread
From: Liu Yu @ 2010-01-14  8:13 UTC (permalink / raw)
  To: galak, davem; +Cc: netdev, Liu Yu, linuxppc-dev

Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
 drivers/net/phy/marvell.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 6f69b9b..65ed385 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -63,6 +63,7 @@
 #define MII_M1111_HWCFG_MODE_COPPER_RGMII	0xb
 #define MII_M1111_HWCFG_MODE_FIBER_RGMII	0x3
 #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK	0x4
+#define MII_M1111_HWCFG_MODE_COPPER_RTBI	0x9
 #define MII_M1111_HWCFG_FIBER_COPPER_AUTO	0x8000
 #define MII_M1111_HWCFG_FIBER_COPPER_RES	0x2000
 
@@ -269,6 +270,43 @@ static int m88e1111_config_init(struct phy_device *phydev)
 			return err;
 	}
 
+	if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
+		temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
+		if (temp < 0)
+			return temp;
+		temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
+		err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
+		if (err < 0)
+			return err;
+
+		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
+		if (temp < 0)
+			return temp;
+		temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
+		temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
+		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
+		if (err < 0)
+			return err;
+
+		/* soft reset */
+		err = phy_write(phydev, MII_BMCR, BMCR_RESET);
+		if (err < 0)
+			return err;
+		do
+			temp = phy_read(phydev, MII_BMCR);
+		while (temp & BMCR_RESET);
+
+		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
+		if (temp < 0)
+			return temp;
+		temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
+		temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
+		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
+		if (err < 0)
+			return err;
+	}
+
+
 	err = phy_write(phydev, MII_BMCR, BMCR_RESET);
 	if (err < 0)
 		return err;
-- 
1.6.4

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

* Re: [PATCH 4/4] phy: add RTBI mode for m88e1111
  2010-01-14  8:13     ` [PATCH 4/4] phy: add RTBI mode for m88e1111 Liu Yu
@ 2010-01-14 16:20       ` Kumar Gala
  2010-01-15  2:49         ` Liu Yu-B13201
  0 siblings, 1 reply; 11+ messages in thread
From: Kumar Gala @ 2010-01-14 16:20 UTC (permalink / raw)
  To: Liu Yu; +Cc: davem, linuxppc-dev, netdev


On Jan 14, 2010, at 2:13 AM, Liu Yu wrote:

> Signed-off-by: Liu Yu <yu.liu@freescale.com>
> ---
> drivers/net/phy/marvell.c |   38 ++++++++++++++++++++++++++++++++++++++
> 1 files changed, 38 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index 6f69b9b..65ed385 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -63,6 +63,7 @@
> #define MII_M1111_HWCFG_MODE_COPPER_RGMII	0xb
> #define MII_M1111_HWCFG_MODE_FIBER_RGMII	0x3
> #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK	0x4
> +#define MII_M1111_HWCFG_MODE_COPPER_RTBI	0x9
> #define MII_M1111_HWCFG_FIBER_COPPER_AUTO	0x8000
> #define MII_M1111_HWCFG_FIBER_COPPER_RES	0x2000
> 
> @@ -269,6 +270,43 @@ static int m88e1111_config_init(struct phy_device *phydev)
> 			return err;
> 	}
> 
> +	if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
> +		temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
> +		if (temp < 0)
> +			return temp;
> +		temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
> +		err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
> +		if (err < 0)
> +			return err;
> +
> +		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
> +		if (temp < 0)
> +			return temp;
> +		temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
> +		temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;

Does this magic 0x7 have some meaning?

> +		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
> +		if (err < 0)
> +			return err;
> +
> +		/* soft reset */
> +		err = phy_write(phydev, MII_BMCR, BMCR_RESET);
> +		if (err < 0)
> +			return err;
> +		do
> +			temp = phy_read(phydev, MII_BMCR);
> +		while (temp & BMCR_RESET);
> +
> +		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
> +		if (temp < 0)
> +			return temp;
> +		temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
> +		temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
> +		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
> +		if (err < 0)
> +			return err;
> +	}
> +
> +
> 	err = phy_write(phydev, MII_BMCR, BMCR_RESET);
> 	if (err < 0)
> 		return err;
> -- 
> 1.6.4


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

* RE: [PATCH 4/4] phy: add RTBI mode for m88e1111
  2010-01-14 16:20       ` Kumar Gala
@ 2010-01-15  2:49         ` Liu Yu-B13201
  2010-01-21  9:18           ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Liu Yu-B13201 @ 2010-01-15  2:49 UTC (permalink / raw)
  To: Kumar Gala; +Cc: davem, linuxppc-dev, netdev

 

> -----Original Message-----
> From: Kumar Gala [mailto:galak@kernel.crashing.org] 
> Sent: Friday, January 15, 2010 12:20 AM
> To: Liu Yu-B13201
> Cc: davem@davemloft.net; linuxppc-dev@lists.ozlabs.org; 
> netdev@vger.kernel.org
> Subject: Re: [PATCH 4/4] phy: add RTBI mode for m88e1111
> 
> 
> On Jan 14, 2010, at 2:13 AM, Liu Yu wrote:
> 
> > Signed-off-by: Liu Yu <yu.liu@freescale.com>
> > ---
> > drivers/net/phy/marvell.c |   38 
> ++++++++++++++++++++++++++++++++++++++
> > 1 files changed, 38 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> > index 6f69b9b..65ed385 100644
> > --- a/drivers/net/phy/marvell.c
> > +++ b/drivers/net/phy/marvell.c
> > @@ -63,6 +63,7 @@
> > #define MII_M1111_HWCFG_MODE_COPPER_RGMII	0xb
> > #define MII_M1111_HWCFG_MODE_FIBER_RGMII	0x3
> > #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK	0x4
> > +#define MII_M1111_HWCFG_MODE_COPPER_RTBI	0x9
> > #define MII_M1111_HWCFG_FIBER_COPPER_AUTO	0x8000
> > #define MII_M1111_HWCFG_FIBER_COPPER_RES	0x2000
> > 
> > @@ -269,6 +270,43 @@ static int m88e1111_config_init(struct 
> phy_device *phydev)
> > 			return err;
> > 	}
> > 
> > +	if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
> > +		temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
> > +		if (temp < 0)
> > +			return temp;
> > +		temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
> > +		err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
> > +		if (err < 0)
> > +			return err;
> > +
> > +		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
> > +		if (temp < 0)
> > +			return temp;
> > +		temp &= ~(MII_M1111_HWCFG_MODE_MASK | 
> MII_M1111_HWCFG_FIBER_COPPER_RES);
> > +		temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
> 
> Does this magic 0x7 have some meaning?
> 

Hrr...  it's GMII to fibre mode.
Document 88E1111_erata_RevB2  chapter 4.35 describ the reason.
Without this sometimes phys couldnot work.

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

* Re: [PATCH 4/4] phy: add RTBI mode for m88e1111
  2010-01-15  2:49         ` Liu Yu-B13201
@ 2010-01-21  9:18           ` David Miller
  0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2010-01-21  9:18 UTC (permalink / raw)
  To: B13201; +Cc: galak, linuxppc-dev, netdev

From: "Liu Yu-B13201" <B13201@freescale.com>
Date: Fri, 15 Jan 2010 10:49:37 +0800

>> -----Original Message-----
>> From: Kumar Gala [mailto:galak@kernel.crashing.org] 
>> Sent: Friday, January 15, 2010 12:20 AM
>> To: Liu Yu-B13201
>> Cc: davem@davemloft.net; linuxppc-dev@lists.ozlabs.org; 
>> netdev@vger.kernel.org
>> Subject: Re: [PATCH 4/4] phy: add RTBI mode for m88e1111
>> 
>> 
>> Does this magic 0x7 have some meaning?
>> 
> 
> Hrr...  it's GMII to fibre mode.
> Document 88E1111_erata_RevB2  chapter 4.35 describ the reason.
> Without this sometimes phys couldnot work.

Just FYI, I've applied all of these patches to net-next-2.6

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

* Re: [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi
  2010-01-14  8:13 [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Liu Yu
  2010-01-14  8:13 ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Liu Yu
@ 2010-02-01 21:46 ` Grant Likely
  1 sibling, 0 replies; 11+ messages in thread
From: Grant Likely @ 2010-02-01 21:46 UTC (permalink / raw)
  To: Liu Yu; +Cc: netdev, linuxppc-dev, davem

On Thu, Jan 14, 2010 at 1:13 AM, Liu Yu <yu.liu@freescale.com> wrote:
> After these change, when need to work in rtbi mode,
> just change phy-connection-type to "rtbi".
>
> Also, this work can be done by u-boot.
>
> Signed-off-by: Liu Yu <yu.liu@freescale.com>

Looks okay by me,
Acked-by: Grant Likely <grant.likely@secretlab.ca>

> ---
>  arch/powerpc/boot/dts/mpc8569mds.dts |   47 ++++++++++++++++++++++++++++++---
>  1 files changed, 42 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/boot/dts/mpc8569mds.dts b/arch/powerpc/boot/dts/mpc8569mds.dts
> index 795eb36..8b72eaf 100644
> --- a/arch/powerpc/boot/dts/mpc8569mds.dts
> +++ b/arch/powerpc/boot/dts/mpc8569mds.dts
> @@ -535,6 +535,7 @@
>                        rx-clock-name = "none";
>                        tx-clock-name = "clk12";
>                        pio-handle = <&pio1>;
> +                       tbi-handle = <&tbi1>;
>                        phy-handle = <&qe_phy0>;
>                        phy-connection-type = "rgmii-id";
>                };
> @@ -579,7 +580,7 @@
>                                reg = <0x6>;
>                                device_type = "ethernet-phy";
>                        };
> -                       tbi-phy@11 {
> +                       tbi1: tbi-phy@11 {
>                                reg = <0x11>;
>                                device_type = "tbi-phy";
>                        };
> @@ -590,7 +591,7 @@
>                        reg = <0x3520 0x18>;
>                        compatible = "fsl,ucc-mdio";
>
> -                       tbi0: tbi-phy@15 {
> +                       tbi6: tbi-phy@15 {
>                        reg = <0x15>;
>                        device_type = "tbi-phy";
>                        };
> @@ -600,7 +601,7 @@
>                        #size-cells = <0>;
>                        reg = <0x3720 0x38>;
>                        compatible = "fsl,ucc-mdio";
> -                       tbi1: tbi-phy@17 {
> +                       tbi8: tbi-phy@17 {
>                                reg = <0x17>;
>                                device_type = "tbi-phy";
>                        };
> @@ -617,10 +618,22 @@
>                        rx-clock-name = "none";
>                        tx-clock-name = "clk12";
>                        pio-handle = <&pio3>;
> +                       tbi-handle = <&tbi3>;
>                        phy-handle = <&qe_phy2>;
>                        phy-connection-type = "rgmii-id";
>                };
>
> +               mdio@2320 {
> +                       #address-cells = <1>;
> +                       #size-cells = <0>;
> +                       reg = <0x2320 0x18>;
> +                       compatible = "fsl,ucc-mdio";
> +                       tbi3: tbi-phy@11 {
> +                               reg = <0x11>;
> +                               device_type = "tbi-phy";
> +                       };
> +               };
> +
>                enet1: ucc@3000 {
>                        device_type = "network";
>                        compatible = "ucc_geth";
> @@ -632,10 +645,22 @@
>                        rx-clock-name = "none";
>                        tx-clock-name = "clk17";
>                        pio-handle = <&pio2>;
> +                       tbi-handle = <&tbi2>;
>                        phy-handle = <&qe_phy1>;
>                        phy-connection-type = "rgmii-id";
>                };
>
> +               mdio@3120 {
> +                       #address-cells = <1>;
> +                       #size-cells = <0>;
> +                       reg = <0x3120 0x18>;
> +                       compatible = "fsl,ucc-mdio";
> +                       tbi2: tbi-phy@11 {
> +                               reg = <0x11>;
> +                               device_type = "tbi-phy";
> +                       };
> +               };
> +
>                enet3: ucc@3200 {
>                        device_type = "network";
>                        compatible = "ucc_geth";
> @@ -647,10 +672,22 @@
>                        rx-clock-name = "none";
>                        tx-clock-name = "clk17";
>                        pio-handle = <&pio4>;
> +                       tbi-handle = <&tbi4>;
>                        phy-handle = <&qe_phy3>;
>                        phy-connection-type = "rgmii-id";
>                };
>
> +               mdio@3320 {
> +                       #address-cells = <1>;
> +                       #size-cells = <0>;
> +                       reg = <0x3320 0x18>;
> +                       compatible = "fsl,ucc-mdio";
> +                       tbi4: tbi-phy@11 {
> +                               reg = <0x11>;
> +                               device_type = "tbi-phy";
> +                       };
> +               };
> +
>                enet5: ucc@3400 {
>                        device_type = "network";
>                        compatible = "ucc_geth";
> @@ -661,7 +698,7 @@
>                        local-mac-address = [ 00 00 00 00 00 00 ];
>                        rx-clock-name = "none";
>                        tx-clock-name = "none";
> -                       tbi-handle = <&tbi0>;
> +                       tbi-handle = <&tbi6>;
>                        phy-handle = <&qe_phy5>;
>                        phy-connection-type = "sgmii";
>                };
> @@ -676,7 +713,7 @@
>                        local-mac-address = [ 00 00 00 00 00 00 ];
>                        rx-clock-name = "none";
>                        tx-clock-name = "none";
> -                       tbi-handle = <&tbi1>;
> +                       tbi-handle = <&tbi8>;
>                        phy-handle = <&qe_phy7>;
>                        phy-connection-type = "sgmii";
>                };
> --
> 1.6.4
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode
  2010-01-14  8:13 ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Liu Yu
  2010-01-14  8:13   ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Liu Yu
@ 2010-02-01 21:57   ` Grant Likely
  2010-02-02  5:57     ` Liu Yu-B13201
  1 sibling, 1 reply; 11+ messages in thread
From: Grant Likely @ 2010-02-01 21:57 UTC (permalink / raw)
  To: Liu Yu; +Cc: galak, davem, netdev, linuxppc-dev

On Thu, Jan 14, 2010 at 1:13 AM, Liu Yu <yu.liu@freescale.com> wrote:
> Signed-off-by: Liu Yu <yu.liu@freescale.com>
> ---
>  arch/powerpc/platforms/85xx/mpc85xx_mds.c |   24 ++++++++++++++++++++++++
>  1 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> index c5028a2..0872e4a 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> @@ -237,6 +237,8 @@ static void __init mpc85xx_mds_setup_arch(void)
>                } else if (machine_is(mpc8569_mds)) {
>  #define BCSR7_UCC12_GETHnRST   (0x1 << 2)
>  #define BCSR8_UEM_MARVELL_RST  (0x1 << 1)
> +#define BCSR_UCC_RGMII         (0x1 << 6)
> +#define BCSR_UCC_RTBI          (0x1 << 5)
>                        /*
>                         * U-Boot mangles interrupt polarity for Marvell PHYs,
>                         * so reset built-in and UEM Marvell PHYs, this puts
> @@ -247,6 +249,28 @@ static void __init mpc85xx_mds_setup_arch(void)
>
>                        setbits8(&bcsr_regs[7], BCSR7_UCC12_GETHnRST);
>                        clrbits8(&bcsr_regs[8], BCSR8_UEM_MARVELL_RST);
> +
> +                       for (np = NULL; (np = of_find_compatible_node(np,
> +                                                       "network",

Don't match on the 'type' field.  Replace "network" with NULL and just
rely on "ucc_geth" for matching.

> +                                                       "ucc_geth")) != NULL;) {
> +                               const unsigned int *prop;

u32 please.

Also, rather than reusing 'prop' for both char* and u32 values, which
forces you to use ugly casts, use 2 local variables here.

> +                               int ucc_num;
> +
> +                               prop = of_get_property(np, "cell-index", NULL);
> +                               if (prop == NULL)
> +                                       continue;
> +
> +                               ucc_num = *prop - 1;

Ugh.  No bounds checking...

> +
> +                               prop = of_get_property(np, "phy-connection-type", NULL);
> +                               if (prop == NULL)
> +                                       continue;
> +
> +                               if (strcmp("rtbi", (const char *)prop) == 0)

(This is the ugly cast I was talking about.)

> +                                       clrsetbits_8(&bcsr_regs[7 + ucc_num],

...not having bounds checking could result in badness in this array index.

This patch is dangerous as written.

Finally, while using cell-index seems convenient, I think it would be
better to have a lookup table of the index into the BCSR register
block from the UCC base address, which also gives you implicit bounds
checking.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* Re: [PATCH 3/4] ucc_geth: update the tbi-phy setting
  2010-01-14  8:13   ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Liu Yu
  2010-01-14  8:13     ` [PATCH 4/4] phy: add RTBI mode for m88e1111 Liu Yu
@ 2010-02-01 22:00     ` Grant Likely
  1 sibling, 0 replies; 11+ messages in thread
From: Grant Likely @ 2010-02-01 22:00 UTC (permalink / raw)
  To: Liu Yu; +Cc: galak, davem, netdev, linuxppc-dev

On Thu, Jan 14, 2010 at 1:13 AM, Liu Yu <yu.liu@freescale.com> wrote:
> Old method only set tbi-phy for eth0.
>
> Signed-off-by: Liu Yu <yu.liu@freescale.com>
> ---
>  drivers/net/ucc_geth.c |   23 +++++++++++++++--------
>  1 files changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
> index 750d86d..0e72013 100644
> --- a/drivers/net/ucc_geth.c
> +++ b/drivers/net/ucc_geth.c
> @@ -37,6 +37,7 @@
>  #include <asm/qe.h>
>  #include <asm/ucc.h>
>  #include <asm/ucc_fast.h>
> +#include <asm/machdep.h>
>
>  #include "ucc_geth.h"
>  #include "fsl_pq_mdio.h"
> @@ -1334,7 +1335,7 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
>        struct ucc_geth __iomem *ug_regs;
>        struct ucc_fast __iomem *uf_regs;
>        int ret_val;
> -       u32 upsmr, maccfg2, tbiBaseAddress;
> +       u32 upsmr, maccfg2;
>        u16 value;
>
>        ugeth_vdbg("%s: IN", __func__);
> @@ -1389,14 +1390,20 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
>        /* Note that this depends on proper setting in utbipar register. */
>        if ((ugeth->phy_interface == PHY_INTERFACE_MODE_TBI) ||
>            (ugeth->phy_interface == PHY_INTERFACE_MODE_RTBI)) {
> -               tbiBaseAddress = in_be32(&ug_regs->utbipar);
> -               tbiBaseAddress &= UTBIPAR_PHY_ADDRESS_MASK;
> -               tbiBaseAddress >>= UTBIPAR_PHY_ADDRESS_SHIFT;
> -               value = ugeth->phydev->bus->read(ugeth->phydev->bus,
> -                               (u8) tbiBaseAddress, ENET_TBI_MII_CR);
> +               struct ucc_geth_info *ug_info = ugeth->ug_info;
> +               struct phy_device *tbiphy;
> +
> +               if (!ug_info->tbi_node)
> +                       ugeth_warn("TBI mode requires that the device "
> +                               "tree specify a tbi-handle\n");

Shouldn't the driver avoid calling of_phy_find_device() if this error
path is taken?

> +
> +               tbiphy = of_phy_find_device(ug_info->tbi_node);
> +               if (!tbiphy)
> +                       ugeth_warn("Could not get TBI device\n");
> +
> +               value = phy_read(tbiphy, ENET_TBI_MII_CR);

Ditto here; the code unconditionally tries to read the tbiphy, even if
it isn't there.

Looks wrong.

g.

>                value &= ~0x1000;       /* Turn off autonegotiation */
> -               ugeth->phydev->bus->write(ugeth->phydev->bus,
> -                               (u8) tbiBaseAddress, ENET_TBI_MII_CR, value);
> +               phy_write(tbiphy, ENET_TBI_MII_CR, value);
>        }
>
>        init_check_frame_length_mode(ug_info->lengthCheckRx, &ug_regs->maccfg2);
> --
> 1.6.4
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>



-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

* RE: [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode
  2010-02-01 21:57   ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Grant Likely
@ 2010-02-02  5:57     ` Liu Yu-B13201
  0 siblings, 0 replies; 11+ messages in thread
From: Liu Yu-B13201 @ 2010-02-02  5:57 UTC (permalink / raw)
  To: Grant Likely; +Cc: galak, davem, netdev, linuxppc-dev


Thanks.
As the patchset is accepted.
Will commit another one to fix them.

 
> -----Original Message-----
> From: glikely@secretlab.ca [mailto:glikely@secretlab.ca] On 
> Behalf Of Grant Likely
> Sent: Tuesday, February 02, 2010 5:58 AM
> To: Liu Yu-B13201
> Cc: galak@kernel.crashing.org; davem@davemloft.net; 
> netdev@vger.kernel.org; linuxppc-dev@lists.ozlabs.org
> Subject: Re: [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode
> 
> On Thu, Jan 14, 2010 at 1:13 AM, Liu Yu <yu.liu@freescale.com> wrote:
> > Signed-off-by: Liu Yu <yu.liu@freescale.com>
> > ---
> >  arch/powerpc/platforms/85xx/mpc85xx_mds.c |   24 
> ++++++++++++++++++++++++
> >  1 files changed, 24 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c 
> b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> > index c5028a2..0872e4a 100644
> > --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> > +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> > @@ -237,6 +237,8 @@ static void __init mpc85xx_mds_setup_arch(void)
> >                } else if (machine_is(mpc8569_mds)) {
> >  #define BCSR7_UCC12_GETHnRST   (0x1 << 2)
> >  #define BCSR8_UEM_MARVELL_RST  (0x1 << 1)
> > +#define BCSR_UCC_RGMII         (0x1 << 6)
> > +#define BCSR_UCC_RTBI          (0x1 << 5)
> >                        /*
> >                         * U-Boot mangles interrupt polarity 
> for Marvell PHYs,
> >                         * so reset built-in and UEM Marvell 
> PHYs, this puts
> > @@ -247,6 +249,28 @@ static void __init mpc85xx_mds_setup_arch(void)
> >
> >                        setbits8(&bcsr_regs[7], 
> BCSR7_UCC12_GETHnRST);
> >                        clrbits8(&bcsr_regs[8], 
> BCSR8_UEM_MARVELL_RST);
> > +
> > +                       for (np = NULL; (np = 
> of_find_compatible_node(np,
> > +                                                       "network",
> 
> Don't match on the 'type' field.  Replace "network" with NULL and just
> rely on "ucc_geth" for matching.
> 
> > +                                                       
> "ucc_geth")) != NULL;) {
> > +                               const unsigned int *prop;
> 
> u32 please.
> 
> Also, rather than reusing 'prop' for both char* and u32 values, which
> forces you to use ugly casts, use 2 local variables here.
> 
> > +                               int ucc_num;
> > +
> > +                               prop = of_get_property(np, 
> "cell-index", NULL);
> > +                               if (prop == NULL)
> > +                                       continue;
> > +
> > +                               ucc_num = *prop - 1;
> 
> Ugh.  No bounds checking...
> 
> > +
> > +                               prop = of_get_property(np, 
> "phy-connection-type", NULL);
> > +                               if (prop == NULL)
> > +                                       continue;
> > +
> > +                               if (strcmp("rtbi", (const 
> char *)prop) == 0)
> 
> (This is the ugly cast I was talking about.)
> 
> > +                                       
> clrsetbits_8(&bcsr_regs[7 + ucc_num],
> 
> ...not having bounds checking could result in badness in this 
> array index.
> 
> This patch is dangerous as written.
> 
> Finally, while using cell-index seems convenient, I think it would be
> better to have a lookup table of the index into the BCSR register
> block from the UCC base address, which also gives you implicit bounds
> checking.
> 
> g.
> 
> -- 
> Grant Likely, B.Sc., P.Eng.
> Secret Lab Technologies Ltd.
> 
> 

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

end of thread, other threads:[~2010-02-02  5:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-14  8:13 [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Liu Yu
2010-01-14  8:13 ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Liu Yu
2010-01-14  8:13   ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Liu Yu
2010-01-14  8:13     ` [PATCH 4/4] phy: add RTBI mode for m88e1111 Liu Yu
2010-01-14 16:20       ` Kumar Gala
2010-01-15  2:49         ` Liu Yu-B13201
2010-01-21  9:18           ` David Miller
2010-02-01 22:00     ` [PATCH 3/4] ucc_geth: update the tbi-phy setting Grant Likely
2010-02-01 21:57   ` [PATCH 2/4] mpc8569mds: Add bscr setting for rtbi mode Grant Likely
2010-02-02  5:57     ` Liu Yu-B13201
2010-02-01 21:46 ` [PATCH 1/4] dts/mpc8569mds: Cleanup tbi phy to support rtbi Grant Likely

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).