Skip to contentSkip to conversation

powerpc/44x: Add more changes for APM821XX EMAC driver

PATCH Superseded Duc Dang 4 participants 13 messages Feb 17, 2012 – Mar 6, 2012

Subsystems (4)
lore
Share & tools
lore

Duc Dang

author
#0 lore raw

PATCH 2/2 powerpc/44x: Add more changes for APM821XX EMAC driver

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not
support half duplex mode.

Add changes to support configuring jumbo frame for APM821XX EMAC.

---
 drivers/net/ethernet/ibm/emac/core.c |   26 +++++++++++++++++++++++++-
 drivers/net/ethernet/ibm/emac/core.h |   13 +++++++++++--
 drivers/net/ethernet/ibm/emac/emac.h |    5 ++++-
 3 files changed, 40 insertions(+), 4 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +25 -1
index ed79b2d..de620f1 100644
@@ -434,6 +434,11 @@ static inline u32 emac_iff2rmr(struct net_device *ndev)
 	else if (!netdev_mc_empty(ndev))
 		r |= EMAC_RMR_MAE;
 
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) {
+		r &= ~EMAC4_RMR_MJS_MASK;
+		r |= EMAC4_RMR_MJS(ndev->mtu);
+	}
+
 	return r;
 }
 
@@ -965,6 +970,7 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	int rx_sync_size = emac_rx_sync_size(new_mtu);
 	int rx_skb_size = emac_rx_skb_size(new_mtu);
 	int i, ret = 0;
+	int mr1_jumbo_bit_change = 0;
 
 	mutex_lock(&dev->link_lock);
 	emac_netif_stop(dev);
@@ -1013,7 +1019,14 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	}
  skip:
 	/* Check if we need to change "Jumbo" bit in MR1 */
-	if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) {
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE))
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ||
+				(dev->ndev->mtu > ETH_DATA_LEN);
+	else
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^
+				(dev->ndev->mtu > ETH_DATA_LEN);
+
+	if (mr1_jumbo_bit_change) {
 		/* This is to prevent starting RX channel in emac_rx_enable() */
 		set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags);
 
@@ -2471,6 +2484,7 @@ static int __devinit emac_init_phy(struct emac_instance *dev)
 
 	/* Disable any PHY features not supported by the platform */
 	dev->phy.def->features &= ~dev->phy_feat_exc;
+	dev->phy.features &= ~dev->phy_feat_exc;
 
 	/* Setup initial link parameters */
 	if (dev->phy.features & SUPPORTED_Autoneg) {
@@ -2568,6 +2582,10 @@ static int __devinit emac_init_config(struct emac_instance *dev)
 		if (of_device_is_compatible(np, "ibm,emac-405ex") ||
 		    of_device_is_compatible(np, "ibm,emac-405exr"))
 			dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX;
+		if (of_device_is_compatible(np, "ibm,emac-apm821xx"))
+			dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE
+					| EMAC_FTR_APM821XX_NO_HALF_DUPLEX
+					| EMAC_FTR_460EX_PHY_CLK_FIX);
 	} else if (of_device_is_compatible(np, "ibm,emac4")) {
 		dev->features |= EMAC_FTR_EMAC4;
 		if (of_device_is_compatible(np, "ibm,emac-440gx"))
@@ -2818,6 +2836,12 @@ static int __devinit emac_probe(struct platform_device *ofdev)
 	dev->stop_timeout = STOP_TIMEOUT_100;
 	INIT_DELAYED_WORK(&dev->link_work, emac_link_timer);
 
+	/* Some SoCs like APM821xx does not support Half Duplex mode. */
+	if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX))
+		dev->phy_feat_exc = (SUPPORTED_1000baseT_Half
+					| SUPPORTED_100baseT_Half
+					| SUPPORTED_10baseT_Half);
+
 	/* Find PHY if any */
 	err = emac_init_phy(dev);
 	if (err != 0)
drivers/net/ethernet/ibm/emac/core.h +11 -2
index fa3ec57..9dea85a 100644
@@ -325,7 +325,14 @@ struct emac_instance {
  * Set if we need phy clock workaround for 460ex or 460gt
  */
 #define EMAC_FTR_460EX_PHY_CLK_FIX	0x00000400
-
+/*
+ * APM821xx requires Jumbo frame size set explicitly
+ */
+#define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE	0x00000800
+/*
+ * APM821xx does not support Half Duplex mode
+ */
+#define EMAC_FTR_APM821XX_NO_HALF_DUPLEX	0x00001000
 
 /* Right now, we don't quite handle the always/possible masks on the
  * most optimal way as we don't have a way to say something like
@@ -353,7 +360,9 @@ enum {
 	    EMAC_FTR_NO_FLOW_CONTROL_40x |
 #endif
 	EMAC_FTR_460EX_PHY_CLK_FIX |
-	EMAC_FTR_440EP_PHY_CLK_FIX,
+	EMAC_FTR_440EP_PHY_CLK_FIX |
+	EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+	EMAC_FTR_APM821XX_NO_HALF_DUPLEX,
 };
 
 static inline int emac_has_feature(struct emac_instance *dev,
drivers/net/ethernet/ibm/emac/emac.h +4 -1
index 1568278..36bcd69 100644
@@ -212,7 +212,10 @@ struct emac_regs {
 #define EMAC4_RMR_RFAF_64_1024		0x00000006
 #define EMAC4_RMR_RFAF_128_2048		0x00000007
 #define EMAC4_RMR_BASE			EMAC4_RMR_RFAF_128_2048
-
+#if defined(CONFIG_APM821xx)
+#define EMAC4_RMR_MJS_MASK              0x0001fff8
+#define EMAC4_RMR_MJS(s)                (((s) << 3) & EMAC4_RMR_MJS_MASK)
+#endif
 /* EMACx_ISR & EMACx_ISER */
 #define EMAC4_ISR_TXPE			0x20000000
 #define EMAC4_ISR_RXPE			0x10000000
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 10 lines · Duc Dang

This patch includes:

 Configure EMAC PHY clock source (clock from PHY or internal clock).

 Do not advertise PHY half duplex capability as APM821XX EMAC does not support half duplex mode.

 Add changes to support configuring jumbo frame for APM821XX EMAC.

This should have been sent to netdev. CC'ing them now.

Ben and David, I can take this change through the 4xx tree if it looks OK to both of you. The pre-requisite DTS patch will go through my tree, so it might make sense to keep them together.

josh

Quoted 133 lines
---
 drivers/net/ethernet/ibm/emac/core.c |   26 +++++++++++++++++++++++++-
 drivers/net/ethernet/ibm/emac/core.h |   13 +++++++++++--
 drivers/net/ethernet/ibm/emac/emac.h |    5 ++++-
 3 files changed, 40 insertions(+), 4 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +25 -1
index ed79b2d..de620f1 100644
@@ -434,6 +434,11 @@ static inline u32 emac_iff2rmr(struct net_device *ndev)
 	else if (!netdev_mc_empty(ndev))
 		r |= EMAC_RMR_MAE;
 
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) {
+		r &= ~EMAC4_RMR_MJS_MASK;
+		r |= EMAC4_RMR_MJS(ndev->mtu);
+	}
+
 	return r;
 }
 
@@ -965,6 +970,7 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	int rx_sync_size = emac_rx_sync_size(new_mtu);
 	int rx_skb_size = emac_rx_skb_size(new_mtu);
 	int i, ret = 0;
+	int mr1_jumbo_bit_change = 0;
 
 	mutex_lock(&dev->link_lock);
 	emac_netif_stop(dev);
@@ -1013,7 +1019,14 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	}
  skip:
 	/* Check if we need to change "Jumbo" bit in MR1 */
-	if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) {
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE))
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ||
+				(dev->ndev->mtu > ETH_DATA_LEN);
+	else
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^
+				(dev->ndev->mtu > ETH_DATA_LEN);
+
+	if (mr1_jumbo_bit_change) {
 		/* This is to prevent starting RX channel in emac_rx_enable() */
 		set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags);
 
@@ -2471,6 +2484,7 @@ static int __devinit emac_init_phy(struct emac_instance *dev)
 
 	/* Disable any PHY features not supported by the platform */
 	dev->phy.def->features &= ~dev->phy_feat_exc;
+	dev->phy.features &= ~dev->phy_feat_exc;
 
 	/* Setup initial link parameters */
 	if (dev->phy.features & SUPPORTED_Autoneg) {
@@ -2568,6 +2582,10 @@ static int __devinit emac_init_config(struct emac_instance *dev)
 		if (of_device_is_compatible(np, "ibm,emac-405ex") ||
 		    of_device_is_compatible(np, "ibm,emac-405exr"))
 			dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX;
+		if (of_device_is_compatible(np, "ibm,emac-apm821xx"))
+			dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE
+					| EMAC_FTR_APM821XX_NO_HALF_DUPLEX
+					| EMAC_FTR_460EX_PHY_CLK_FIX);
 	} else if (of_device_is_compatible(np, "ibm,emac4")) {
 		dev->features |= EMAC_FTR_EMAC4;
 		if (of_device_is_compatible(np, "ibm,emac-440gx"))
@@ -2818,6 +2836,12 @@ static int __devinit emac_probe(struct platform_device *ofdev)
 	dev->stop_timeout = STOP_TIMEOUT_100;
 	INIT_DELAYED_WORK(&dev->link_work, emac_link_timer);
 
+	/* Some SoCs like APM821xx does not support Half Duplex mode. */
+	if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX))
+		dev->phy_feat_exc = (SUPPORTED_1000baseT_Half
+					| SUPPORTED_100baseT_Half
+					| SUPPORTED_10baseT_Half);
+
 	/* Find PHY if any */
 	err = emac_init_phy(dev);
 	if (err != 0)
drivers/net/ethernet/ibm/emac/core.h +11 -2
index fa3ec57..9dea85a 100644
@@ -325,7 +325,14 @@ struct emac_instance {
  * Set if we need phy clock workaround for 460ex or 460gt
  */
 #define EMAC_FTR_460EX_PHY_CLK_FIX	0x00000400
-
+/*
+ * APM821xx requires Jumbo frame size set explicitly
+ */
+#define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE	0x00000800
+/*
+ * APM821xx does not support Half Duplex mode
+ */
+#define EMAC_FTR_APM821XX_NO_HALF_DUPLEX	0x00001000
 
 /* Right now, we don't quite handle the always/possible masks on the
  * most optimal way as we don't have a way to say something like
@@ -353,7 +360,9 @@ enum {
 	    EMAC_FTR_NO_FLOW_CONTROL_40x |
 #endif
 	EMAC_FTR_460EX_PHY_CLK_FIX |
-	EMAC_FTR_440EP_PHY_CLK_FIX,
+	EMAC_FTR_440EP_PHY_CLK_FIX |
+	EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+	EMAC_FTR_APM821XX_NO_HALF_DUPLEX,
 };
 
 static inline int emac_has_feature(struct emac_instance *dev,
drivers/net/ethernet/ibm/emac/emac.h +4 -2
index 1568278..36bcd69 100644
@@ -212,7 +212,10 @@ struct emac_regs {
 #define EMAC4_RMR_RFAF_64_1024		0x00000006
 #define EMAC4_RMR_RFAF_128_2048		0x00000007
 #define EMAC4_RMR_BASE			EMAC4_RMR_RFAF_128_2048
-
+#if defined(CONFIG_APM821xx)
+#define EMAC4_RMR_MJS_MASK              0x0001fff8
+#define EMAC4_RMR_MJS(s)                (((s) << 3) & EMAC4_RMR_MJS_MASK)
+#endif
 /* EMACx_ISR & EMACx_ISER */
 #define EMAC4_ISR_TXPE			0x20000000
 #define EMAC4_ISR_RXPE			0x10000000
--

1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

maintainer
#2 lore raw

From: Josh Boyer <[email protected]>
Date: Wed, 29 Feb 2012 08:43:46 -0500

Quoted 10 lines · Duc Dang
Quoted 9 lines

This patch includes:

 Configure EMAC PHY clock source (clock from PHY or internal clock).

 Do not advertise PHY half duplex capability as APM821XX EMAC does not support half duplex mode.

 Add changes to support configuring jumbo frame for APM821XX EMAC.

Quoted 7 lines
Quoted 1 line

This should have been sent to netdev. CC'ing them now.

Ben and David, I can take this change through the 4xx tree if it looks OK to both of you. The pre-requisite DTS patch will go through my tree, so it might make sense to keep them together.

Well the patch has coding style problems, for one:

Quoted 3 lines

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_init_config(struct emac_instance *dev) · line 2588

Quoted 3 lines
drivers/net/ethernet/ibm/emac/core.c +3 -0
+			dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE
+					| EMAC_FTR_APM821XX_NO_HALF_DUPLEX
+					| EMAC_FTR_460EX_PHY_CLK_FIX);

Should be:

Quoted 3 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+			dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+					  EMAC_FTR_APM821XX_NO_HALF_DUPLEX |
+					  EMAC_FTR_460EX_PHY_CLK_FIX);

And this:

Quoted 3 lines

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_probe(struct platform_device *ofdev) · line 2843

Quoted 3 lines
drivers/net/ethernet/ibm/emac/core.c +3 -0
+		dev->phy_feat_exc = (SUPPORTED_1000baseT_Half
+					| SUPPORTED_100baseT_Half
+					| SUPPORTED_10baseT_Half);

Should be:

Quoted 3 lines
Quoted 3 lines
(quoted diff) +3 -0
+		dev->phy_feat_exc = (SUPPORTED_1000baseT_Half |
+				     SUPPORTED_100baseT_Half |
+				     SUPPORTED_10baseT_Half);
author
#3 lore raw

Thanks, David and Josh.

Except the coding style problem that David mentioned, do you have other comment about my patch set?

Regards,
Duc Dang.

Quoted 38 lines · David Miller

From: Josh Boyer <[email protected]>
Date: Wed, 29 Feb 2012 08:43:46 -0500

Quoted 8 lines · Duc Dang
Quoted 7 lines

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not
support half duplex mode.

Quoted 7 lines
Quoted 3 lines

Add changes to support configuring jumbo frame for APM821XX EMAC.

This should have been sent to netdev. CC'ing them now.

Ben and David, I can take this change through the 4xx tree if it looks

OK to

Quoted 1 line

both of you. The pre-requisite DTS patch will go through my tree, so it

might

Quoted 1 line

make sense to keep them together.

Well the patch has coding style problems, for one:

Quoted 1 line
Quoted 1 line

+ dev->features |=

(EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE

Quoted 2 lines

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_init_config(struct emac_instance *dev) · line 2588

Quoted 2 lines
drivers/net/ethernet/ibm/emac/core.c +2 -0
+                                    | EMAC_FTR_APM821XX_NO_HALF_DUPLEX
+                                    | EMAC_FTR_460EX_PHY_CLK_FIX);

Should be:

Quoted 1 line
Quoted 1 line

+ dev->features |=

(EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |

Quoted 1 line
Quoted 1 line

+ EMAC_FTR_APM821XX_NO_HALF_DUPLEX

|

Quoted 1 line
Quoted 1 line

+ EMAC_FTR_460EX_PHY_CLK_FIX);

Quoted 12 lines

And this:

Quoted 3 lines

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_probe(struct platform_device *ofdev) · line 2843

Quoted 3 lines
drivers/net/ethernet/ibm/emac/core.c +3 -0
+            dev->phy_feat_exc = (SUPPORTED_1000baseT_Half
+                                    | SUPPORTED_100baseT_Half
+                                    | SUPPORTED_10baseT_Half);

Should be:

Quoted 3 lines
Quoted 3 lines
(quoted diff) +3 -0
+            dev->phy_feat_exc = (SUPPORTED_1000baseT_Half |
+                                 SUPPORTED_100baseT_Half |
+                                 SUPPORTED_10baseT_Half);

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

author
#4 lore raw

PATCH v2 1/2 powerpc/44x: Add new compatible value for EMAC node of APM821XX dts file.

In reply to Duc Dang

This compatible value will be used to distinguish some special features of APM821XX EMAC: no half duplex mode support, configuring jumbo frame.

---
v2:
No change since v1 patch set. Added for completeness.

 arch/powerpc/boot/dts/bluestone.dts |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/boot/dts/bluestone.dts +1 -1
index 2a56a0d..74876f7 100644
@@ -222,7 +222,7 @@
 
 			EMAC0: ethernet@ef600c00 {
 				device_type = "network";
-				compatible = "ibm,emac4sync";
+				compatible = "ibm,emac-apm821xx", "ibm,emac4sync";
 				interrupt-parent = <&EMAC0>;
 				interrupts = <0x0 0x1>;
 				#interrupt-cells = <1>;
Signature · 1 line
1.7.5.4
author
#5 lore raw

PATCH v2 2/2 powerpc/44x: Add more changes for APM821XX EMAC driver

In reply to Duc Dang

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not
support half duplex mode.

Add changes to support configuring jumbo frame for APM821XX EMAC.

---
v2:
Fix coding style problems.

 drivers/net/ethernet/ibm/emac/core.c |   26 +++++++++++++++++++++++++-
 drivers/net/ethernet/ibm/emac/core.h |   13 +++++++++++--
 drivers/net/ethernet/ibm/emac/emac.h |    5 ++++-
 3 files changed, 40 insertions(+), 4 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +25 -1
index 2abce96..ad671c5 100644
@@ -434,6 +434,11 @@ static inline u32 emac_iff2rmr(struct net_device *ndev)
 	else if (!netdev_mc_empty(ndev))
 		r |= EMAC_RMR_MAE;
 
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) {
+		r &= ~EMAC4_RMR_MJS_MASK;
+		r |= EMAC4_RMR_MJS(ndev->mtu);
+	}
+
 	return r;
 }
 
@@ -965,6 +970,7 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	int rx_sync_size = emac_rx_sync_size(new_mtu);
 	int rx_skb_size = emac_rx_skb_size(new_mtu);
 	int i, ret = 0;
+	int mr1_jumbo_bit_change = 0;
 
 	mutex_lock(&dev->link_lock);
 	emac_netif_stop(dev);
@@ -1013,7 +1019,14 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	}
  skip:
 	/* Check if we need to change "Jumbo" bit in MR1 */
-	if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) {
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE))
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ||
+				(dev->ndev->mtu > ETH_DATA_LEN);
+	else
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^
+				(dev->ndev->mtu > ETH_DATA_LEN);
+
+	if (mr1_jumbo_bit_change) {
 		/* This is to prevent starting RX channel in emac_rx_enable() */
 		set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags);
 
@@ -2471,6 +2484,7 @@ static int __devinit emac_init_phy(struct emac_instance *dev)
 
 	/* Disable any PHY features not supported by the platform */
 	dev->phy.def->features &= ~dev->phy_feat_exc;
+	dev->phy.features &= ~dev->phy_feat_exc;
 
 	/* Setup initial link parameters */
 	if (dev->phy.features & SUPPORTED_Autoneg) {
@@ -2568,6 +2582,10 @@ static int __devinit emac_init_config(struct emac_instance *dev)
 		if (of_device_is_compatible(np, "ibm,emac-405ex") ||
 		    of_device_is_compatible(np, "ibm,emac-405exr"))
 			dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX;
+		if (of_device_is_compatible(np, "ibm,emac-apm821xx"))
+			dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+					EMAC_FTR_APM821XX_NO_HALF_DUPLEX |
+					EMAC_FTR_460EX_PHY_CLK_FIX);
 	} else if (of_device_is_compatible(np, "ibm,emac4")) {
 		dev->features |= EMAC_FTR_EMAC4;
 		if (of_device_is_compatible(np, "ibm,emac-440gx"))
@@ -2818,6 +2836,12 @@ static int __devinit emac_probe(struct platform_device *ofdev)
 	dev->stop_timeout = STOP_TIMEOUT_100;
 	INIT_DELAYED_WORK(&dev->link_work, emac_link_timer);
 
+	/* Some SoCs like APM821xx does not support Half Duplex mode. */
+	if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX))
+		dev->phy_feat_exc = (SUPPORTED_1000baseT_Half |
+					SUPPORTED_100baseT_Half |
+					SUPPORTED_10baseT_Half);
+
 	/* Find PHY if any */
 	err = emac_init_phy(dev);
 	if (err != 0)
drivers/net/ethernet/ibm/emac/core.h +11 -2
index fa3ec57..9dea85a 100644
@@ -325,7 +325,14 @@ struct emac_instance {
  * Set if we need phy clock workaround for 460ex or 460gt
  */
 #define EMAC_FTR_460EX_PHY_CLK_FIX	0x00000400
-
+/*
+ * APM821xx requires Jumbo frame size set explicitly
+ */
+#define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE	0x00000800
+/*
+ * APM821xx does not support Half Duplex mode
+ */
+#define EMAC_FTR_APM821XX_NO_HALF_DUPLEX	0x00001000
 
 /* Right now, we don't quite handle the always/possible masks on the
  * most optimal way as we don't have a way to say something like
@@ -353,7 +360,9 @@ enum {
 	    EMAC_FTR_NO_FLOW_CONTROL_40x |
 #endif
 	EMAC_FTR_460EX_PHY_CLK_FIX |
-	EMAC_FTR_440EP_PHY_CLK_FIX,
+	EMAC_FTR_440EP_PHY_CLK_FIX |
+	EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+	EMAC_FTR_APM821XX_NO_HALF_DUPLEX,
 };
 
 static inline int emac_has_feature(struct emac_instance *dev,
drivers/net/ethernet/ibm/emac/emac.h +4 -1
index 1568278..36bcd69 100644
@@ -212,7 +212,10 @@ struct emac_regs {
 #define EMAC4_RMR_RFAF_64_1024		0x00000006
 #define EMAC4_RMR_RFAF_128_2048		0x00000007
 #define EMAC4_RMR_BASE			EMAC4_RMR_RFAF_128_2048
-
+#if defined(CONFIG_APM821xx)
+#define EMAC4_RMR_MJS_MASK              0x0001fff8
+#define EMAC4_RMR_MJS(s)                (((s) << 3) & EMAC4_RMR_MJS_MASK)
+#endif
 /* EMACx_ISR & EMACx_ISER */
 #define EMAC4_ISR_TXPE			0x20000000
 #define EMAC4_ISR_RXPE			0x10000000
Signature · 1 line
1.7.5.4
#6 lore raw
Quoted 47 lines · On Monday 05 March 2012 05:03:44 Duc Dang wrote:

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not
support half duplex mode.

Add changes to support configuring jumbo frame for APM821XX EMAC.

---
v2:
Fix coding style problems.

 drivers/net/ethernet/ibm/emac/core.c |   26 +++++++++++++++++++++++++-
 drivers/net/ethernet/ibm/emac/core.h |   13 +++++++++++--
 drivers/net/ethernet/ibm/emac/emac.h |    5 ++++-
 3 files changed, 40 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/ibm/emac/core.c index 2abce96..ad671c5 100644

drivers/net/ethernet/ibm/emac/core.c +6 -0
@@ -434,6 +434,11 @@ static inline u32 emac_iff2rmr(struct net_device
 *ndev) else if (!netdev_mc_empty(ndev))
 		r |= EMAC_RMR_MAE;
 
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) {
+		r &= ~EMAC4_RMR_MJS_MASK;
+		r |= EMAC4_RMR_MJS(ndev->mtu);
+	}
+
 	return r;
 }
 
@@ -965,6 +970,7 @@ static int emac_resize_rx_ring(struct emac_instance
 *dev, int new_mtu) int rx_sync_size = emac_rx_sync_size(new_mtu);
 	int rx_skb_size = emac_rx_skb_size(new_mtu);
 	int i, ret = 0;
+	int mr1_jumbo_bit_change = 0;
 
 	mutex_lock(&dev->link_lock);
 	emac_netif_stop(dev);
@@ -1013,7 +1019,14 @@ static int emac_resize_rx_ring(struct emac_instance
 *dev, int new_mtu) }
  skip:
 	/* Check if we need to change "Jumbo" bit in MR1 */

drivers/net/ethernet/ibm/emac/core.c static int emac_resize_rx_ring(struct emac_instance · line 1030

Quoted 10 lines
drivers/net/ethernet/ibm/emac/core.c +8 -1
-	if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) {
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE))
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ||
+				(dev->ndev->mtu > ETH_DATA_LEN);
+	else
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^
+				(dev->ndev->mtu > ETH_DATA_LEN);
+
+	if (mr1_jumbo_bit_change) {
 		/* This is to prevent starting RX channel in emac_rx_enable() 

*/

Quoted 13 lines
drivers/net/ethernet/ibm/emac/core.c +1 -0
 		set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags);
 
@@ -2471,6 +2484,7 @@ static int __devinit emac_init_phy(struct
 emac_instance *dev)
 
 	/* Disable any PHY features not supported by the platform */
 	dev->phy.def->features &= ~dev->phy_feat_exc;
+	dev->phy.features &= ~dev->phy_feat_exc;
 
 	/* Setup initial link parameters */
drivers/net/ethernet/ibm/emac/core.c +0 -0
 	if (dev->phy.features & SUPPORTED_Autoneg) {
@@ -2568,6 +2582,10 @@ static int __devinit emac_init_config(struct

emac_instance *dev) if (of_device_is_compatible(np, "ibm,emac-405ex") ||

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_init_config(struct emac_instance *dev)

Quoted 4 lines
drivers/net/ethernet/ibm/emac/core.c +2 -0
 		    of_device_is_compatible(np, "ibm,emac-405exr"))
 			dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX;
+		if (of_device_is_compatible(np, "ibm,emac-apm821xx"))
+			dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE 

|

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_init_config(struct emac_instance *dev) · line 2588

Quoted 2 lines
drivers/net/ethernet/ibm/emac/core.c +2 -0
+					EMAC_FTR_APM821XX_NO_HALF_DUPLEX |
+					EMAC_FTR_460EX_PHY_CLK_FIX);

Nitpick: Parentheses for multi line statement please.

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_probe(struct · line 2844

Quoted 13 lines
drivers/net/ethernet/ibm/emac/core.c +6 -0
 	} else if (of_device_is_compatible(np, "ibm,emac4")) {
 		dev->features |= EMAC_FTR_EMAC4;
 		if (of_device_is_compatible(np, "ibm,emac-440gx"))
@@ -2818,6 +2836,12 @@ static int __devinit emac_probe(struct
 platform_device *ofdev) dev->stop_timeout = STOP_TIMEOUT_100;
 	INIT_DELAYED_WORK(&dev->link_work, emac_link_timer);
 
+	/* Some SoCs like APM821xx does not support Half Duplex mode. */
+	if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX))
+		dev->phy_feat_exc = (SUPPORTED_1000baseT_Half |
+					SUPPORTED_100baseT_Half |
+					SUPPORTED_10baseT_Half);
+

Nitpick: Parentheses for multi line statement please.

Quoted 39 lines
drivers/net/ethernet/ibm/emac/core.c +0 -0
 	/* Find PHY if any */
 	err = emac_init_phy(dev);
 	if (err != 0)
(quoted diff) +0 -0

b/drivers/net/ethernet/ibm/emac/core.h index fa3ec57..9dea85a 100644

drivers/net/ethernet/ibm/emac/core.h +11 -2
@@ -325,7 +325,14 @@ struct emac_instance {
  * Set if we need phy clock workaround for 460ex or 460gt
  */
 #define EMAC_FTR_460EX_PHY_CLK_FIX	0x00000400
-
+/*
+ * APM821xx requires Jumbo frame size set explicitly
+ */
+#define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE	0x00000800
+/*
+ * APM821xx does not support Half Duplex mode
+ */
+#define EMAC_FTR_APM821XX_NO_HALF_DUPLEX	0x00001000
 
 /* Right now, we don't quite handle the always/possible masks on the
  * most optimal way as we don't have a way to say something like
@@ -353,7 +360,9 @@ enum {
 	    EMAC_FTR_NO_FLOW_CONTROL_40x |
 #endif
 	EMAC_FTR_460EX_PHY_CLK_FIX |
-	EMAC_FTR_440EP_PHY_CLK_FIX,
+	EMAC_FTR_440EP_PHY_CLK_FIX |
+	EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+	EMAC_FTR_APM821XX_NO_HALF_DUPLEX,
 };
 
 static inline int emac_has_feature(struct emac_instance *dev,
(quoted diff) +0 -0

b/drivers/net/ethernet/ibm/emac/emac.h index 1568278..36bcd69 100644

drivers/net/ethernet/ibm/emac/emac.h struct emac_regs { · line 218

Quoted 8 lines
drivers/net/ethernet/ibm/emac/emac.h +4 -1
@@ -212,7 +212,10 @@ struct emac_regs {
 #define EMAC4_RMR_RFAF_64_1024		0x00000006
 #define EMAC4_RMR_RFAF_128_2048		0x00000007
 #define EMAC4_RMR_BASE			EMAC4_RMR_RFAF_128_2048
-
+#if defined(CONFIG_APM821xx)
+#define EMAC4_RMR_MJS_MASK              0x0001fff8
+#define EMAC4_RMR_MJS(s)                (((s) << 3) & EMAC4_RMR_MJS_MASK)
+#endif

Is this "#if defined" really needed? If not, I suggest you drop it.

Thanks,
Stefan

author
#7 lore raw

Thanks, Stefan.

Please see my answer bellow.

Regards,
Duc Dang.

Quoted 80 lines · Stefan Roese

drivers/net/ethernet/ibm/emac/core.c static int emac_resize_rx_ring(struct

Quoted 44 lines · On Monday 05 March 2012 05:03:44 Duc Dang wrote:

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not
support half duplex mode.

Add changes to support configuring jumbo frame for APM821XX EMAC.

---
v2:
Fix coding style problems.

 drivers/net/ethernet/ibm/emac/core.c |   26 +++++++++++++++++++++++++-
 drivers/net/ethernet/ibm/emac/core.h |   13 +++++++++++--
 drivers/net/ethernet/ibm/emac/emac.h |    5 ++++-
 3 files changed, 40 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/net/ethernet/ibm/emac/core.c index 2abce96..ad671c5 100644

drivers/net/ethernet/ibm/emac/core.c +6 -0
@@ -434,6 +434,11 @@ static inline u32 emac_iff2rmr(struct net_device
 *ndev) else if (!netdev_mc_empty(ndev))
              r |= EMAC_RMR_MAE;
 
+     if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) {
+             r &= ~EMAC4_RMR_MJS_MASK;
+             r |= EMAC4_RMR_MJS(ndev->mtu);
+     }
+
      return r;
 }
 
@@ -965,6 +970,7 @@ static int emac_resize_rx_ring(struct emac_instance
 *dev, int new_mtu) int rx_sync_size = emac_rx_sync_size(new_mtu);
      int rx_skb_size = emac_rx_skb_size(new_mtu);
      int i, ret = 0;
+     int mr1_jumbo_bit_change = 0;
 
      mutex_lock(&dev->link_lock);
      emac_netif_stop(dev);
@@ -1013,7 +1019,14 @@ static int emac_resize_rx_ring(struct

emac_instance

drivers/net/ethernet/ibm/emac/core.c static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)

Quoted 13 lines
drivers/net/ethernet/ibm/emac/core.c +8 -1
 *dev, int new_mtu) }
  skip:
      /* Check if we need to change "Jumbo" bit in MR1 */
-     if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) {
+     if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE))
+             mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ||
+                             (dev->ndev->mtu > ETH_DATA_LEN);
+     else
+             mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^
+                             (dev->ndev->mtu > ETH_DATA_LEN);
+
+     if (mr1_jumbo_bit_change) {
              /* This is to prevent starting RX channel in

emac_rx_enable()
*/

Quoted 15 lines
drivers/net/ethernet/ibm/emac/core.c +1 -0
              set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags);
 
@@ -2471,6 +2484,7 @@ static int __devinit emac_init_phy(struct
 emac_instance *dev)
 
      /* Disable any PHY features not supported by the platform */
      dev->phy.def->features &= ~dev->phy_feat_exc;
+     dev->phy.features &= ~dev->phy_feat_exc;
 
      /* Setup initial link parameters */
      if (dev->phy.features & SUPPORTED_Autoneg) {
drivers/net/ethernet/ibm/emac/core.c +0 -0
@@ -2568,6 +2582,10 @@ static int __devinit emac_init_config(struct

emac_instance *dev) if (of_device_is_compatible(np, "ibm,emac-405ex") ||

                  of_device_is_compatible(np, "ibm,emac-405exr"))
                      dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX;

drivers/net/ethernet/ibm/emac/core.c

Quoted 2 lines
drivers/net/ethernet/ibm/emac/core.c +2 -0
+             if (of_device_is_compatible(np, "ibm,emac-apm821xx"))
+                     dev->features |=

(EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE
|

Quoted 5 lines

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_init_config(struct emac_instance *dev) · line 2588

Quoted 2 lines
drivers/net/ethernet/ibm/emac/core.c +2 -0
+                                     EMAC_FTR_APM821XX_NO_HALF_DUPLEX |
+                                     EMAC_FTR_460EX_PHY_CLK_FIX);

Nitpick: Parentheses for multi line statement please.

[Duc Dang] I wil add parentheses as you suggested.

Quoted 69 lines
      } else if (of_device_is_compatible(np, "ibm,emac4")) {

drivers/net/ethernet/ibm/emac/core.c static int __devinit emac_probe(struct · line 2844

Quoted 12 lines
              dev->features |= EMAC_FTR_EMAC4;
              if (of_device_is_compatible(np, "ibm,emac-440gx"))
drivers/net/ethernet/ibm/emac/core.c +6 -0
@@ -2818,6 +2836,12 @@ static int __devinit emac_probe(struct
 platform_device *ofdev) dev->stop_timeout = STOP_TIMEOUT_100;
      INIT_DELAYED_WORK(&dev->link_work, emac_link_timer);
 
+     /* Some SoCs like APM821xx does not support Half Duplex mode. */
+     if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX))
+             dev->phy_feat_exc = (SUPPORTED_1000baseT_Half |
+                                     SUPPORTED_100baseT_Half |
+                                     SUPPORTED_10baseT_Half);
+

Nitpick: Parentheses for multi line statement please.

Quoted 39 lines
drivers/net/ethernet/ibm/emac/core.c +0 -0
      /* Find PHY if any */
      err = emac_init_phy(dev);
      if (err != 0)
(quoted diff) +0 -0

b/drivers/net/ethernet/ibm/emac/core.h index fa3ec57..9dea85a 100644

drivers/net/ethernet/ibm/emac/core.h +11 -2
@@ -325,7 +325,14 @@ struct emac_instance {
  * Set if we need phy clock workaround for 460ex or 460gt
  */
 #define EMAC_FTR_460EX_PHY_CLK_FIX   0x00000400
-
+/*
+ * APM821xx requires Jumbo frame size set explicitly
+ */
+#define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE   0x00000800
+/*
+ * APM821xx does not support Half Duplex mode
+ */
+#define EMAC_FTR_APM821XX_NO_HALF_DUPLEX     0x00001000
 
 /* Right now, we don't quite handle the always/possible masks on the
  * most optimal way as we don't have a way to say something like
@@ -353,7 +360,9 @@ enum {
          EMAC_FTR_NO_FLOW_CONTROL_40x |
 #endif
      EMAC_FTR_460EX_PHY_CLK_FIX |
-     EMAC_FTR_440EP_PHY_CLK_FIX,
+     EMAC_FTR_440EP_PHY_CLK_FIX |
+     EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+     EMAC_FTR_APM821XX_NO_HALF_DUPLEX,
 };
 
 static inline int emac_has_feature(struct emac_instance *dev,
(quoted diff) +0 -0

b/drivers/net/ethernet/ibm/emac/emac.h index 1568278..36bcd69 100644

drivers/net/ethernet/ibm/emac/emac.h struct emac_regs { · line 217

Quoted 7 lines
drivers/net/ethernet/ibm/emac/emac.h +3 -1
@@ -212,7 +212,10 @@ struct emac_regs {
 #define EMAC4_RMR_RFAF_64_1024               0x00000006
 #define EMAC4_RMR_RFAF_128_2048              0x00000007
 #define EMAC4_RMR_BASE                       EMAC4_RMR_RFAF_128_2048
-
+#if defined(CONFIG_APM821xx)
+#define EMAC4_RMR_MJS_MASK              0x0001fff8
+#define EMAC4_RMR_MJS(s)                (((s) << 3) &

EMAC4_RMR_MJS_MASK)

drivers/net/ethernet/ibm/emac/emac.h struct emac_regs { · line 218

Quoted 1 line
drivers/net/ethernet/ibm/emac/emac.h +1 -0
+#endif

Is this "#if defined" really needed? If not, I suggest you drop it.

Quoted 9 lines

[Duc Dang] Only APM821XX and later SoCs have this register field, but it is no harm to drop the #if defined as 460EX/460GT/405EX have this register field as reserved. So I will drop it.

Thanks,
Stefan

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

author
#8 lore raw

PATCH v3 1/2 powerpc/44x: Add new compatible value for EMAC node of APM821XX dts file.

In reply to Duc Dang

This compatible value will be used to distinguish some special features of APM821XX EMAC: no half duplex mode support, configuring jumbo frame.

---
v3:
No change since v1/v2 patch sets. Added for completeness.

 arch/powerpc/boot/dts/bluestone.dts |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/boot/dts/bluestone.dts +1 -1
index 2a56a0d..74876f7 100644
@@ -222,7 +222,7 @@
 
 			EMAC0: ethernet@ef600c00 {
 				device_type = "network";
-				compatible = "ibm,emac4sync";
+				compatible = "ibm,emac-apm821xx", "ibm,emac4sync";
 				interrupt-parent = <&EMAC0>;
 				interrupts = <0x0 0x1>;
 				#interrupt-cells = <1>;
Signature · 1 line
1.7.5.4
author
#11 lore raw

PATCH v3 2/2 powerpc/44x: Add more changes for APM821XX EMAC driver

In reply to Duc Dang

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not support half duplex mode.

Add changes to support configuring jumbo frame for APM821XX EMAC.

---
v3:
Add parentheses for multi-line statements.
Drop #if defined(CONFIG_APM821xx) in emac.h.

 drivers/net/ethernet/ibm/emac/core.c |   29 ++++++++++++++++++++++++++++-
 drivers/net/ethernet/ibm/emac/core.h |   13 +++++++++++--
 drivers/net/ethernet/ibm/emac/emac.h |    2 ++
 3 files changed, 41 insertions(+), 3 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +28 -1
index 2abce96..cc51842 100644
@@ -434,6 +434,11 @@ static inline u32 emac_iff2rmr(struct net_device *ndev)
 	else if (!netdev_mc_empty(ndev))
 		r |= EMAC_RMR_MAE;
 
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) {
+		r &= ~EMAC4_RMR_MJS_MASK;
+		r |= EMAC4_RMR_MJS(ndev->mtu);
+	}
+
 	return r;
 }
 
@@ -965,6 +970,7 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	int rx_sync_size = emac_rx_sync_size(new_mtu);
 	int rx_skb_size = emac_rx_skb_size(new_mtu);
 	int i, ret = 0;
+	int mr1_jumbo_bit_change = 0;
 
 	mutex_lock(&dev->link_lock);
 	emac_netif_stop(dev);
@@ -1013,7 +1019,15 @@ static int emac_resize_rx_ring(struct emac_instance *dev, int new_mtu)
 	}
  skip:
 	/* Check if we need to change "Jumbo" bit in MR1 */
-	if ((new_mtu > ETH_DATA_LEN) ^ (dev->ndev->mtu > ETH_DATA_LEN)) {
+	if (emac_has_feature(dev, EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE)) {
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ||
+				(dev->ndev->mtu > ETH_DATA_LEN);
+	} else {
+		mr1_jumbo_bit_change = (new_mtu > ETH_DATA_LEN) ^
+				(dev->ndev->mtu > ETH_DATA_LEN);
+	}
+
+	if (mr1_jumbo_bit_change) {
 		/* This is to prevent starting RX channel in emac_rx_enable() */
 		set_bit(MAL_COMMAC_RX_STOPPED, &dev->commac.flags);
 
@@ -2471,6 +2485,7 @@ static int __devinit emac_init_phy(struct emac_instance *dev)
 
 	/* Disable any PHY features not supported by the platform */
 	dev->phy.def->features &= ~dev->phy_feat_exc;
+	dev->phy.features &= ~dev->phy_feat_exc;
 
 	/* Setup initial link parameters */
 	if (dev->phy.features & SUPPORTED_Autoneg) {
@@ -2568,6 +2583,11 @@ static int __devinit emac_init_config(struct emac_instance *dev)
 		if (of_device_is_compatible(np, "ibm,emac-405ex") ||
 		    of_device_is_compatible(np, "ibm,emac-405exr"))
 			dev->features |= EMAC_FTR_440EP_PHY_CLK_FIX;
+		if (of_device_is_compatible(np, "ibm,emac-apm821xx")) {
+			dev->features |= (EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+					EMAC_FTR_APM821XX_NO_HALF_DUPLEX |
+					EMAC_FTR_460EX_PHY_CLK_FIX);
+		}
 	} else if (of_device_is_compatible(np, "ibm,emac4")) {
 		dev->features |= EMAC_FTR_EMAC4;
 		if (of_device_is_compatible(np, "ibm,emac-440gx"))
@@ -2818,6 +2838,13 @@ static int __devinit emac_probe(struct platform_device *ofdev)
 	dev->stop_timeout = STOP_TIMEOUT_100;
 	INIT_DELAYED_WORK(&dev->link_work, emac_link_timer);
 
+	/* Some SoCs like APM821xx does not support Half Duplex mode. */
+	if (emac_has_feature(dev, EMAC_FTR_APM821XX_NO_HALF_DUPLEX)) {
+		dev->phy_feat_exc = (SUPPORTED_1000baseT_Half |
+					SUPPORTED_100baseT_Half |
+					SUPPORTED_10baseT_Half);
+	}
+	
 	/* Find PHY if any */
 	err = emac_init_phy(dev);
 	if (err != 0)
drivers/net/ethernet/ibm/emac/core.h +11 -2
index fa3ec57..9dea85a 100644
@@ -325,7 +325,14 @@ struct emac_instance {
  * Set if we need phy clock workaround for 460ex or 460gt
  */
 #define EMAC_FTR_460EX_PHY_CLK_FIX	0x00000400
-
+/*
+ * APM821xx requires Jumbo frame size set explicitly
+ */
+#define EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE	0x00000800
+/*
+ * APM821xx does not support Half Duplex mode
+ */
+#define EMAC_FTR_APM821XX_NO_HALF_DUPLEX	0x00001000
 
 /* Right now, we don't quite handle the always/possible masks on the
  * most optimal way as we don't have a way to say something like
@@ -353,7 +360,9 @@ enum {
 	    EMAC_FTR_NO_FLOW_CONTROL_40x |
 #endif
 	EMAC_FTR_460EX_PHY_CLK_FIX |
-	EMAC_FTR_440EP_PHY_CLK_FIX,
+	EMAC_FTR_440EP_PHY_CLK_FIX |
+	EMAC_APM821XX_REQ_JUMBO_FRAME_SIZE |
+	EMAC_FTR_APM821XX_NO_HALF_DUPLEX,
 };
 
 static inline int emac_has_feature(struct emac_instance *dev,
drivers/net/ethernet/ibm/emac/emac.h +2 -0
index 1568278..c9090a4 100644
@@ -212,6 +212,8 @@ struct emac_regs {
 #define EMAC4_RMR_RFAF_64_1024		0x00000006
 #define EMAC4_RMR_RFAF_128_2048		0x00000007
 #define EMAC4_RMR_BASE			EMAC4_RMR_RFAF_128_2048
+#define EMAC4_RMR_MJS_MASK              0x0001fff8
+#define EMAC4_RMR_MJS(s)                (((s) << 3) & EMAC4_RMR_MJS_MASK)
 
 /* EMACx_ISR & EMACx_ISER */
 #define EMAC4_ISR_TXPE			0x20000000
Signature · 1 line
1.7.5.4
maintainer Applied
#9 lore raw

Re: [PATCH v3 1/2] powerpc/44x: Add new compatible value for EMAC node of APM821XX dts file.

In reply to Duc Dang

From: Duc Dang <[email protected]>
Date: Mon, 5 Mar 2012 17:57:42 +0700

Quoted 3 lines

This compatible value will be used to distinguish some special features of APM821XX EMAC: no half duplex mode support, configuring jumbo frame.

Applied.

maintainer
#12 lore raw
In reply to Duc Dang

From: Duc Dang <[email protected]>
Date: Mon, 5 Mar 2012 17:58:22 +0700

Quoted 9 lines

This patch includes:

Configure EMAC PHY clock source (clock from PHY or internal clock).

Do not advertise PHY half duplex capability as APM821XX EMAC does not support half duplex mode.

Add changes to support configuring jumbo frame for APM821XX EMAC.

Applied with coding style fixes.

#10 lore raw

Re: [PATCH v3 1/2] powerpc/44x: Add new compatible value for EMAC node of APM821XX dts file.

In reply to David Miller
Quoted 8 lines · David Miller

From: Duc Dang <[email protected]>
Date: Mon,  5 Mar 2012 17:57:42 +0700

Quoted 3 lines

This compatible value will be used to distinguish some special features of APM821XX EMAC: no half duplex mode support, configuring jumbo frame.

Applied.

So I guess we're taking these through your tree? I guess that works out well enough since the other patches I was going to send to Ben aren't panning out anyway.

josh