linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add field to struct ocp_func_emac_data for platform-specific unsupported PHY features
@ 2005-08-05 23:26 Wade Farnsworth
  2005-08-08 23:44 ` Matt Porter
  0 siblings, 1 reply; 5+ messages in thread
From: Wade Farnsworth @ 2005-08-05 23:26 UTC (permalink / raw)
  To: linuxppc-embedded, Matt Porter

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

Hello all,

This patch adds a field to struct ocp_func_emac_data that allows
platform-specific unsupported PHY features to be passed in to the
ibm_emac ethernet driver.

This patch also adds some logic for the Bamboo eval board to populate
this field based on the dip switches on the board.  This is a workaround
for the improperly biased RJ-45 sockets on the Rev. 0 Bamboo.  See the
comments in bamboo.c for more information on this bug.

-Wade Farnsworth

Signed-off by: Wade Farnsworth <wfarnsworth@mvista.com>

[-- Attachment #2: ibm-emac-phy-feat-unsupp-ppc.patch --]
[-- Type: text/plain, Size: 3116 bytes --]

--- linux-2.6/arch/ppc/platforms/4xx/bamboo.c	2005-08-03 13:33:41.000000000 -0700
+++ linux-2.6-dev/arch/ppc/platforms/4xx/bamboo.c	2005-08-02 10:51:00.000000000 -0700
@@ -123,33 +123,69 @@ bamboo_map_irq(struct pci_dev *dev, unsi
 
 static void __init bamboo_set_emacdata(void)
 {
-	unsigned char * selection1_base;
+	u8 * base_addr;
 	struct ocp_def *def;
 	struct ocp_func_emac_data *emacdata;
-	u8 selection1_val;
+	u8 val;
 	int mode;
+	u32 unsupported = 0;
 
-	selection1_base = ioremap64(BAMBOO_FPGA_SELECTION1_REG_ADDR, 16);
-	selection1_val = readb(selection1_base);
-	iounmap((void *) selection1_base);
-	if (BAMBOO_SEL_MII(selection1_val))
+	base_addr = ioremap64(BAMBOO_FPGA_SELECTION1_REG_ADDR, 16);
+	val = readb(base_addr);
+	iounmap((void *) base_addr);
+	if (BAMBOO_SEL_MII(val))
 		mode = PHY_MODE_MII;
-	else if (BAMBOO_SEL_RMII(selection1_val))
+	else if (BAMBOO_SEL_RMII(val))
 		mode = PHY_MODE_RMII;
 	else
 		mode = PHY_MODE_SMII;
 
-	/* Set mac_addr and phy mode for each EMAC */
+	/*
+	 * SW2 on the Bamboo is used for ethernet configuration and is accessed
+	 * via the CONFIG2 register in the FPGA.  If the ANEG pin is set,
+	 * overwrite the supported features with the settings in SW2.
+	 *
+	 * This is used as a workaround for the improperly biased RJ-45 sockets
+	 * on the Rev. 0 Bamboo.  By default only 10baseT is functional.
+	 * Removing inductors L17 and L18 from the board allows 100baseT, but
+	 * disables 10baseT.  The Rev. 1 has no such limitations.
+	 */
+
+	base_addr = ioremap64(BAMBOO_FPGA_CONFIG2_REG_ADDR, 8);
+	val = readb(base_addr);
+	iounmap((void *) base_addr);
+	if (!BAMBOO_AUTONEGOTIATE(val)) {
+		unsupported |= SUPPORTED_Autoneg;
+		if (BAMBOO_FORCE_100Mbps(val)) {
+			unsupported |= SUPPORTED_10baseT_Full;
+			unsupported |= SUPPORTED_10baseT_Half;
+			if (BAMBOO_FULL_DUPLEX_EN(val))
+				unsupported |= SUPPORTED_100baseT_Half;
+			else
+				unsupported |= SUPPORTED_100baseT_Full;
+		} else {
+			unsupported |= SUPPORTED_100baseT_Full;
+			unsupported |= SUPPORTED_100baseT_Half;
+			if (BAMBOO_FULL_DUPLEX_EN(val))
+				unsupported |= SUPPORTED_10baseT_Half;
+			else
+				unsupported |= SUPPORTED_10baseT_Full;
+		}
+	}
+	
+	/* Set mac_addr, phy mode and unsupported phy features for each EMAC */
 
 	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 0);
 	emacdata = def->additions;
 	memcpy(emacdata->mac_addr, __res.bi_enetaddr, 6);
 	emacdata->phy_mode = mode;
+	emacdata->feat_unsupp = unsupported;
 
 	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 1);
 	emacdata = def->additions;
 	memcpy(emacdata->mac_addr, __res.bi_enet1addr, 6);
 	emacdata->phy_mode = mode;
+	emacdata->feat_unsupp = unsupported;
 }
 
 static int
--- linux-2.6/include/asm-ppc/ibm_ocp.h	2005-08-03 13:34:08.000000000 -0700
+++ linux-2.6-dev/include/asm-ppc/ibm_ocp.h	2005-08-02 10:49:42.000000000 -0700
@@ -67,6 +67,7 @@ struct ocp_func_emac_data {
 	int	phy_mode;	/* PHY type or configurable mode */
 	u8	mac_addr[6];	/* EMAC mac address */
 	u32	phy_map;	/* EMAC phy map */
+	u32	feat_unsupp;	/* Unsupported phy features */
 };
 
 /* Sysfs support */

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

* Re: [PATCH] add field to struct ocp_func_emac_data for platform-specific unsupported PHY features
  2005-08-05 23:26 [PATCH] add field to struct ocp_func_emac_data for platform-specific unsupported PHY features Wade Farnsworth
@ 2005-08-08 23:44 ` Matt Porter
  2005-08-11 20:42   ` Wade Farnsworth
  0 siblings, 1 reply; 5+ messages in thread
From: Matt Porter @ 2005-08-08 23:44 UTC (permalink / raw)
  To: Wade Farnsworth; +Cc: linuxppc-embedded

On Fri, Aug 05, 2005 at 04:26:30PM -0700, Wade Farnsworth wrote:
>  static int
> --- linux-2.6/include/asm-ppc/ibm_ocp.h	2005-08-03 13:34:08.000000000 -0700
> +++ linux-2.6-dev/include/asm-ppc/ibm_ocp.h	2005-08-02 10:49:42.000000000 -0700
> @@ -67,6 +67,7 @@ struct ocp_func_emac_data {
>  	int	phy_mode;	/* PHY type or configurable mode */
>  	u8	mac_addr[6];	/* EMAC mac address */
>  	u32	phy_map;	/* EMAC phy map */
> +	u32	feat_unsupp;	/* Unsupported phy features */

Could you update this field (and related usages) to be "phy_ftr_exc"?
For "Excluded phy features".  Eugene and I discussed this on IRC and
think it's a better name...for one it starts with the phy_ prefix like
other related phy data. Except for that, it's ready for upstream.

Thanks,
Matt

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

* Re: [PATCH] add field to struct ocp_func_emac_data for platform-specific unsupported PHY features
  2005-08-08 23:44 ` Matt Porter
@ 2005-08-11 20:42   ` Wade Farnsworth
  2005-08-13 19:32     ` Eugene Surovegin
  0 siblings, 1 reply; 5+ messages in thread
From: Wade Farnsworth @ 2005-08-11 20:42 UTC (permalink / raw)
  To: Matt Porter; +Cc: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

On Mon, 2005-08-08 at 16:44, Matt Porter wrote:
(snip)
> 
> Could you update this field (and related usages) to be "phy_ftr_exc"?
> For "Excluded phy features".  Eugene and I discussed this on IRC and
> think it's a better name...for one it starts with the phy_ prefix like
> other related phy data. Except for that, it's ready for upstream.
> 
> Thanks,
> Matt

Here is the updated patch with the field renamed to "phy_ftr_exc"
instead of "feat_unsupp".

-Wade Farnsworth

Signed-off-by: Wade Farnsworth <wfarnsworth@mvista.com>

[-- Attachment #2: ibm-emac-phy-feat-exc-ppc.patch --]
[-- Type: text/x-patch, Size: 3264 bytes --]

diff -upr linux-2.6/arch/ppc/platforms/4xx/bamboo.c linux-2.6-dev/arch/ppc/platforms/4xx/bamboo.c
--- linux-2.6/arch/ppc/platforms/4xx/bamboo.c	2005-08-11 13:29:30.000000000 -0700
+++ linux-2.6-dev/arch/ppc/platforms/4xx/bamboo.c	2005-08-11 13:15:59.000000000 -0700
@@ -123,33 +123,69 @@ bamboo_map_irq(struct pci_dev *dev, unsi
 
 static void __init bamboo_set_emacdata(void)
 {
-	unsigned char * selection1_base;
+	u8 * base_addr;
 	struct ocp_def *def;
 	struct ocp_func_emac_data *emacdata;
-	u8 selection1_val;
+	u8 val;
 	int mode;
+	u32 excluded = 0;
 
-	selection1_base = ioremap64(BAMBOO_FPGA_SELECTION1_REG_ADDR, 16);
-	selection1_val = readb(selection1_base);
-	iounmap((void *) selection1_base);
-	if (BAMBOO_SEL_MII(selection1_val))
+	base_addr = ioremap64(BAMBOO_FPGA_SELECTION1_REG_ADDR, 16);
+	val = readb(base_addr);
+	iounmap((void *) base_addr);
+	if (BAMBOO_SEL_MII(val))
 		mode = PHY_MODE_MII;
-	else if (BAMBOO_SEL_RMII(selection1_val))
+	else if (BAMBOO_SEL_RMII(val))
 		mode = PHY_MODE_RMII;
 	else
 		mode = PHY_MODE_SMII;
 
-	/* Set mac_addr and phy mode for each EMAC */
+	/*
+	 * SW2 on the Bamboo is used for ethernet configuration and is accessed
+	 * via the CONFIG2 register in the FPGA.  If the ANEG pin is set,
+	 * overwrite the supported features with the settings in SW2.
+	 *
+	 * This is used as a workaround for the improperly biased RJ-45 sockets
+	 * on the Rev. 0 Bamboo.  By default only 10baseT is functional.
+	 * Removing inductors L17 and L18 from the board allows 100baseT, but
+	 * disables 10baseT.  The Rev. 1 has no such limitations.
+	 */
+
+	base_addr = ioremap64(BAMBOO_FPGA_CONFIG2_REG_ADDR, 8);
+	val = readb(base_addr);
+	iounmap((void *) base_addr);
+	if (!BAMBOO_AUTONEGOTIATE(val)) {
+		excluded |= SUPPORTED_Autoneg;
+		if (BAMBOO_FORCE_100Mbps(val)) {
+			excluded |= SUPPORTED_10baseT_Full;
+			excluded |= SUPPORTED_10baseT_Half;
+			if (BAMBOO_FULL_DUPLEX_EN(val))
+				excluded |= SUPPORTED_100baseT_Half;
+			else
+				excluded |= SUPPORTED_100baseT_Full;
+		} else {
+			excluded |= SUPPORTED_100baseT_Full;
+			excluded |= SUPPORTED_100baseT_Half;
+			if (BAMBOO_FULL_DUPLEX_EN(val))
+				excluded |= SUPPORTED_10baseT_Half;
+			else
+				excluded |= SUPPORTED_10baseT_Full;
+		}
+	}
+	
+	/* Set mac_addr, phy mode and unsupported phy features for each EMAC */
 
 	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 0);
 	emacdata = def->additions;
 	memcpy(emacdata->mac_addr, __res.bi_enetaddr, 6);
 	emacdata->phy_mode = mode;
+	emacdata->phy_feat_exc = excluded;
 
 	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 1);
 	emacdata = def->additions;
 	memcpy(emacdata->mac_addr, __res.bi_enet1addr, 6);
 	emacdata->phy_mode = mode;
+	emacdata->phy_feat_exc = excluded;
 }
 
 static int
diff -upr linux-2.6/include/asm-ppc/ibm_ocp.h linux-2.6-dev/include/asm-ppc/ibm_ocp.h
--- linux-2.6/include/asm-ppc/ibm_ocp.h	2005-08-11 13:30:02.000000000 -0700
+++ linux-2.6-dev/include/asm-ppc/ibm_ocp.h	2005-08-11 13:12:34.000000000 -0700
@@ -67,6 +67,7 @@ struct ocp_func_emac_data {
 	int	phy_mode;	/* PHY type or configurable mode */
 	u8	mac_addr[6];	/* EMAC mac address */
 	u32	phy_map;	/* EMAC phy map */
+	u32	phy_feat_exc;	/* Excluded PHY features */
 };
 
 /* Sysfs support */

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

* Re: [PATCH] add field to struct ocp_func_emac_data for platform-specific unsupported PHY features
  2005-08-11 20:42   ` Wade Farnsworth
@ 2005-08-13 19:32     ` Eugene Surovegin
  2005-08-13 19:35       ` Eugene Surovegin
  0 siblings, 1 reply; 5+ messages in thread
From: Eugene Surovegin @ 2005-08-13 19:32 UTC (permalink / raw)
  To: Wade Farnsworth; +Cc: linuxppc-embedded

On Thu, Aug 11, 2005 at 01:42:07PM -0700, Wade Farnsworth wrote:

[snip]

> diff -upr linux-2.6/include/asm-ppc/ibm_ocp.h linux-2.6-dev/include/asm-ppc/ibm_ocp.h
> --- linux-2.6/include/asm-ppc/ibm_ocp.h	2005-08-11 13:30:02.000000000 -0700
> +++ linux-2.6-dev/include/asm-ppc/ibm_ocp.h	2005-08-11 13:12:34.000000000 -0700
> @@ -67,6 +67,7 @@ struct ocp_func_emac_data {
>  	int	phy_mode;	/* PHY type or configurable mode */
>  	u8	mac_addr[6];	/* EMAC mac address */
>  	u32	phy_map;	/* EMAC phy map */
> +	u32	phy_feat_exc;	/* Excluded PHY features */
>  };
>  
>  /* Sysfs support */

Please, update OCP_SYSFS_EMAC_DATA() macro as well.

-- 
Eugene

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

* Re: [PATCH] add field to struct ocp_func_emac_data for platform-specific unsupported PHY features
  2005-08-13 19:32     ` Eugene Surovegin
@ 2005-08-13 19:35       ` Eugene Surovegin
  0 siblings, 0 replies; 5+ messages in thread
From: Eugene Surovegin @ 2005-08-13 19:35 UTC (permalink / raw)
  To: Wade Farnsworth, Matt Porter, linuxppc-embedded

On Sat, Aug 13, 2005 at 12:32:21PM -0700, Eugene Surovegin wrote:
> On Thu, Aug 11, 2005 at 01:42:07PM -0700, Wade Farnsworth wrote:
> 
> [snip]
> 
> > diff -upr linux-2.6/include/asm-ppc/ibm_ocp.h linux-2.6-dev/include/asm-ppc/ibm_ocp.h
> > --- linux-2.6/include/asm-ppc/ibm_ocp.h	2005-08-11 13:30:02.000000000 -0700
> > +++ linux-2.6-dev/include/asm-ppc/ibm_ocp.h	2005-08-11 13:12:34.000000000 -0700
> > @@ -67,6 +67,7 @@ struct ocp_func_emac_data {
> >  	int	phy_mode;	/* PHY type or configurable mode */
> >  	u8	mac_addr[6];	/* EMAC mac address */
> >  	u32	phy_map;	/* EMAC phy map */
> > +	u32	phy_feat_exc;	/* Excluded PHY features */
> >  };
> >  
> >  /* Sysfs support */
> 
> Please, update OCP_SYSFS_EMAC_DATA() macro as well.

Also, I just noticed, Matt suggested different name for this member 
two e-mails ago :)

-- 
Eugene

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

end of thread, other threads:[~2005-08-13 19:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-05 23:26 [PATCH] add field to struct ocp_func_emac_data for platform-specific unsupported PHY features Wade Farnsworth
2005-08-08 23:44 ` Matt Porter
2005-08-11 20:42   ` Wade Farnsworth
2005-08-13 19:32     ` Eugene Surovegin
2005-08-13 19:35       ` Eugene Surovegin

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