linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] make cadence ethernet drivers build on any architecture
@ 2012-10-21 14:23 Joachim Eastwood
  2012-10-21 14:23 ` [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB Joachim Eastwood
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

This series makes the at91_ether and macb driver build-able on any architecture.

Patch 1 removes the HAVE_NET_MACB from the cadence Kconfig and this allow macb to be built on any architecture. The macb driver requires no other modifications.

Patch 3 moves a bootloader quirk for CSB337 from at91_ether into CSB337 board setup. This allow us to remove the last mach include and build this driver on any architecture. It also make it easier to share the address setup between at91_ether and macb.

Patch 4-5 removes the now unused HAVE_NET_MACB config symbol from AT91/AVR32 Kconfig.


Note that patch 3 is not tested on a real CSB337 board. I only tested it on an other AT91RM9200 board to verify the logic that reverses the address byte order works.

The next series will make the at91_ether driver use address setting and statistics from macb. There is also a clean up of print outs plus some comment/style fixes.

Joachim Eastwood (5):
  net/cadence: get rid of HAVE_NET_MACB
  net/at91_ether: select MACB in Kconfig
  net/at91_ether: move eth addr quirk into csb337 board setup
  ARM: AT91: Remove HAVE_NET_MACB
  AVR32: Remove HAVE_NET_MACB

 arch/arm/mach-at91/Kconfig                |  4 ----
 arch/arm/mach-at91/board-csb337.c         | 35 +++++++++++++++++++++++++++++++
 arch/avr32/Kconfig                        |  1 -
 drivers/net/ethernet/cadence/Kconfig      |  8 +------
 drivers/net/ethernet/cadence/Makefile     |  2 +-
 drivers/net/ethernet/cadence/at91_ether.c | 26 ++++++-----------------
 6 files changed, 43 insertions(+), 33 deletions(-)

-- 
1.7.12.4

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

* [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB
  2012-10-21 14:23 [PATCH 0/5] make cadence ethernet drivers build on any architecture Joachim Eastwood
@ 2012-10-21 14:23 ` Joachim Eastwood
  2012-10-21 18:30   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 23:27   ` David Miller
  2012-10-21 14:23 ` [PATCH 2/5] net/at91_ether: select MACB in Kconfig Joachim Eastwood
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

macb is a platform driver and there is nothing that prevents
this driver from being built on non-ARM/AVR32 platforms.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/cadence/Kconfig | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
index 57f78abe..5d1ea30 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -2,13 +2,9 @@
 # Atmel device configuration
 #
 
-config HAVE_NET_MACB
-	bool
-
 config NET_CADENCE
 	bool "Cadence devices"
 	default y
-	depends on HAVE_NET_MACB || (ARM && ARCH_AT91RM9200)
 	---help---
 	  If you have a network (Ethernet) card belonging to this class, say Y.
 	  Make sure you know the name of your card. Read the Ethernet-HOWTO,
@@ -34,7 +30,6 @@ config ARM_AT91_ETHER
 
 config MACB
 	tristate "Cadence MACB/GEM support"
-	depends on HAVE_NET_MACB
 	select PHYLIB
 	---help---
 	  The Cadence MACB ethernet interface is found on many Atmel AT32 and
-- 
1.7.12.4

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

* [PATCH 2/5] net/at91_ether: select MACB in Kconfig
  2012-10-21 14:23 [PATCH 0/5] make cadence ethernet drivers build on any architecture Joachim Eastwood
  2012-10-21 14:23 ` [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB Joachim Eastwood
@ 2012-10-21 14:23 ` Joachim Eastwood
  2012-10-21 18:31   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 14:23 ` [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup Joachim Eastwood
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now that HAVE_NET_MACB is gone let's just select MACB to
satisfy the dependecies in at91_ether.

PHYLIB will then by selected by MACB.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/cadence/Kconfig  | 2 +-
 drivers/net/ethernet/cadence/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
index 5d1ea30..f6d0956 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -23,7 +23,7 @@ config ARM_AT91_ETHER
 	tristate "AT91RM9200 Ethernet support"
 	depends on ARM && ARCH_AT91RM9200
 	select NET_CORE
-	select PHYLIB
+	select MACB
 	---help---
 	  If you wish to compile a kernel for the AT91RM9200 and enable
 	  ethernet support, then you should always answer Y to this.
diff --git a/drivers/net/ethernet/cadence/Makefile b/drivers/net/ethernet/cadence/Makefile
index 798b1e0..9068b83 100644
--- a/drivers/net/ethernet/cadence/Makefile
+++ b/drivers/net/ethernet/cadence/Makefile
@@ -2,5 +2,5 @@
 # Makefile for the Atmel network device drivers.
 #
 
-obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o macb.o
+obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o
 obj-$(CONFIG_MACB) += macb.o
-- 
1.7.12.4

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

* [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup
  2012-10-21 14:23 [PATCH 0/5] make cadence ethernet drivers build on any architecture Joachim Eastwood
  2012-10-21 14:23 ` [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB Joachim Eastwood
  2012-10-21 14:23 ` [PATCH 2/5] net/at91_ether: select MACB in Kconfig Joachim Eastwood
@ 2012-10-21 14:23 ` Joachim Eastwood
  2012-10-21 18:25   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 18:34   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 14:23 ` [PATCH 4/5] ARM: AT91: Remove HAVE_NET_MACB Joachim Eastwood
  2012-10-21 14:23 ` [PATCH 5/5] AVR32: " Joachim Eastwood
  4 siblings, 2 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

Move Ethernet address byte order fix for csb337 into it's board
setup.

This will allow us to remove the last mach include from at91_ether
and also to share the address setup with the macb driver.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 arch/arm/mach-at91/board-csb337.c         | 35 +++++++++++++++++++++++++++++++
 drivers/net/ethernet/cadence/Kconfig      |  1 -
 drivers/net/ethernet/cadence/at91_ether.c | 26 ++++++-----------------
 3 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index 3e37437..5522132 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -217,6 +217,40 @@ static struct gpio_led csb_leds[] = {
 	}
 };
 
+/*
+ * MicroMonitor (uMon) on the CSB337 store the ethernet address in the
+ * wrong byte order (and continues to do so, for bug-compatibility).
+ */
+#define MACB_SA1B	0x0098
+#define MACB_SA1T	0x009c
+static void __init csb337_fix_eth_addr(void)
+{
+	void __iomem *emac;
+	u32 lo, hi, tmp;
+	int i;
+
+	emac = ioremap(AT91RM9200_BASE_EMAC, SZ_16K);
+	if (!emac) {
+		printk(KERN_ERR "csb337: unable to fixup Ethernet address\n");
+		return;
+	}
+
+	/* Fix byte order on all 4 address registers */
+	for (i = 0; i < 4; i++) {
+		lo = readl(emac + MACB_SA1B + i * 8);
+		hi = readl(emac + MACB_SA1T + i * 8);
+
+		tmp = (lo & 0xff) << 8 | (lo & 0xff00) >> 8;
+		writel(tmp, emac + MACB_SA1T + i * 8);
+
+		tmp = (hi & 0xff) << 8 | (hi & 0xff00) >> 8
+			| (lo & 0xff0000) << 8
+			| (lo & 0xff000000) >> 8;
+		writel(tmp, emac + MACB_SA1B + i * 8);
+	}
+
+	iounmap(emac);
+}
 
 static void __init csb337_board_init(void)
 {
@@ -225,6 +259,7 @@ static void __init csb337_board_init(void)
 	at91_register_uart(0, 0, 0);
 	at91_add_device_serial();
 	/* Ethernet */
+	csb337_fix_eth_addr();
 	at91_add_device_eth(&csb337_eth_data);
 	/* USB Host */
 	at91_add_device_usbh(&csb337_usbh_data);
diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
index f6d0956..40172d1 100644
--- a/drivers/net/ethernet/cadence/Kconfig
+++ b/drivers/net/ethernet/cadence/Kconfig
@@ -21,7 +21,6 @@ if NET_CADENCE
 
 config ARM_AT91_ETHER
 	tristate "AT91RM9200 Ethernet support"
-	depends on ARM && ARCH_AT91RM9200
 	select NET_CORE
 	select MACB
 	---help---
diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
index 375d272..5ed1a63 100644
--- a/drivers/net/ethernet/cadence/at91_ether.c
+++ b/drivers/net/ethernet/cadence/at91_ether.c
@@ -32,8 +32,6 @@
 #include <linux/phy.h>
 #include <linux/io.h>
 
-#include <asm/mach-types.h>
-
 #include "macb.h"
 
 #define DRV_NAME	"at91_ether"
@@ -55,30 +53,18 @@
  *   U-Boot on the AT91RM9200-DK do not do this.
  *
  * - Likewise it must store the addresses in the correct byte order.
- *   MicroMonitor (uMon) on the CSB337 does this incorrectly (and
- *   continues to do so, for bug-compatibility).
  */
 
 static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo)
 {
 	char addr[6];
 
-	if (machine_is_csb337()) {
-		addr[5] = (lo & 0xff);			/* The CSB337 bootloader stores the MAC the wrong-way around */
-		addr[4] = (lo & 0xff00) >> 8;
-		addr[3] = (lo & 0xff0000) >> 16;
-		addr[2] = (lo & 0xff000000) >> 24;
-		addr[1] = (hi & 0xff);
-		addr[0] = (hi & 0xff00) >> 8;
-	}
-	else {
-		addr[0] = (lo & 0xff);
-		addr[1] = (lo & 0xff00) >> 8;
-		addr[2] = (lo & 0xff0000) >> 16;
-		addr[3] = (lo & 0xff000000) >> 24;
-		addr[4] = (hi & 0xff);
-		addr[5] = (hi & 0xff00) >> 8;
-	}
+	addr[0] = (lo & 0xff);
+	addr[1] = (lo & 0xff00) >> 8;
+	addr[2] = (lo & 0xff0000) >> 16;
+	addr[3] = (lo & 0xff000000) >> 24;
+	addr[4] = (hi & 0xff);
+	addr[5] = (hi & 0xff00) >> 8;
 
 	if (is_valid_ether_addr(addr)) {
 		memcpy(dev->dev_addr, &addr, 6);
-- 
1.7.12.4

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

* [PATCH 4/5] ARM: AT91: Remove HAVE_NET_MACB
  2012-10-21 14:23 [PATCH 0/5] make cadence ethernet drivers build on any architecture Joachim Eastwood
                   ` (2 preceding siblings ...)
  2012-10-21 14:23 ` [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup Joachim Eastwood
@ 2012-10-21 14:23 ` Joachim Eastwood
  2012-10-21 14:23 ` [PATCH 5/5] AVR32: " Joachim Eastwood
  4 siblings, 0 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

HAVE_NET_MACB has already been removed from the driver itself
so removed it from mach Kconfig as well.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 arch/arm/mach-at91/Kconfig | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index d846b6e..72020fb 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -45,7 +45,6 @@ config SOC_AT91RM9200
 config SOC_AT91SAM9260
 	bool "AT91SAM9260, AT91SAM9XE or AT91SAM9G20"
 	select HAVE_AT91_DBGU0
-	select HAVE_NET_MACB
 	select SOC_AT91SAM9
 	help
 	  Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE
@@ -63,7 +62,6 @@ config SOC_AT91SAM9263
 	bool "AT91SAM9263"
 	select HAVE_AT91_DBGU1
 	select HAVE_FB_ATMEL
-	select HAVE_NET_MACB
 	select SOC_AT91SAM9
 
 config SOC_AT91SAM9RL
@@ -76,7 +74,6 @@ config SOC_AT91SAM9G45
 	bool "AT91SAM9G45 or AT91SAM9M10 families"
 	select HAVE_AT91_DBGU1
 	select HAVE_FB_ATMEL
-	select HAVE_NET_MACB
 	select SOC_AT91SAM9
 	help
 	  Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
@@ -86,7 +83,6 @@ config SOC_AT91SAM9X5
 	bool "AT91SAM9x5 family"
 	select HAVE_AT91_DBGU0
 	select HAVE_FB_ATMEL
-	select HAVE_NET_MACB
 	select SOC_AT91SAM9
 	help
 	  Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
-- 
1.7.12.4

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

* [PATCH 5/5] AVR32: Remove HAVE_NET_MACB
  2012-10-21 14:23 [PATCH 0/5] make cadence ethernet drivers build on any architecture Joachim Eastwood
                   ` (3 preceding siblings ...)
  2012-10-21 14:23 ` [PATCH 4/5] ARM: AT91: Remove HAVE_NET_MACB Joachim Eastwood
@ 2012-10-21 14:23 ` Joachim Eastwood
  4 siblings, 0 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

HAVE_NET_MACB has already been removed from the driver itself
so removed it from arch Kconfig as well.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 arch/avr32/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index 06e73bf..09f9fa8 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -80,7 +80,6 @@ config PLATFORM_AT32AP
 	select ARCH_REQUIRE_GPIOLIB
 	select GENERIC_ALLOCATOR
 	select HAVE_FB_ATMEL
-	select HAVE_NET_MACB
 
 #
 # CPU types
-- 
1.7.12.4

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

* [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup
  2012-10-21 14:23 ` [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup Joachim Eastwood
@ 2012-10-21 18:25   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 20:39     ` Joachim Eastwood
  2012-10-21 18:34   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 17+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-21 18:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
> Move Ethernet address byte order fix for csb337 into it's board
> setup.
> 
> This will allow us to remove the last mach include from at91_ether
> and also to share the address setup with the macb driver.
no the at91rm9200 move to DT this is not compatible with it

you need to pass ths in info via platform_data

and do not touch driver code related stuff in boards

Best Regards,
J.
> 
> Signed-off-by: Joachim Eastwood <manabian@gmail.com>
> ---
>  arch/arm/mach-at91/board-csb337.c         | 35 +++++++++++++++++++++++++++++++
>  drivers/net/ethernet/cadence/Kconfig      |  1 -
>  drivers/net/ethernet/cadence/at91_ether.c | 26 ++++++-----------------
>  3 files changed, 41 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
> index 3e37437..5522132 100644
> --- a/arch/arm/mach-at91/board-csb337.c
> +++ b/arch/arm/mach-at91/board-csb337.c
> @@ -217,6 +217,40 @@ static struct gpio_led csb_leds[] = {
>  	}
>  };
>  
> +/*
> + * MicroMonitor (uMon) on the CSB337 store the ethernet address in the
> + * wrong byte order (and continues to do so, for bug-compatibility).
> + */
> +#define MACB_SA1B	0x0098
> +#define MACB_SA1T	0x009c
> +static void __init csb337_fix_eth_addr(void)
> +{
> +	void __iomem *emac;
> +	u32 lo, hi, tmp;
> +	int i;
> +
> +	emac = ioremap(AT91RM9200_BASE_EMAC, SZ_16K);
> +	if (!emac) {
> +		printk(KERN_ERR "csb337: unable to fixup Ethernet address\n");
> +		return;
> +	}
> +
> +	/* Fix byte order on all 4 address registers */
> +	for (i = 0; i < 4; i++) {
> +		lo = readl(emac + MACB_SA1B + i * 8);
> +		hi = readl(emac + MACB_SA1T + i * 8);
> +
> +		tmp = (lo & 0xff) << 8 | (lo & 0xff00) >> 8;
> +		writel(tmp, emac + MACB_SA1T + i * 8);
> +
> +		tmp = (hi & 0xff) << 8 | (hi & 0xff00) >> 8
> +			| (lo & 0xff0000) << 8
> +			| (lo & 0xff000000) >> 8;
> +		writel(tmp, emac + MACB_SA1B + i * 8);
> +	}
> +
> +	iounmap(emac);
> +}
>  
>  static void __init csb337_board_init(void)
>  {
> @@ -225,6 +259,7 @@ static void __init csb337_board_init(void)
>  	at91_register_uart(0, 0, 0);
>  	at91_add_device_serial();
>  	/* Ethernet */
> +	csb337_fix_eth_addr();
>  	at91_add_device_eth(&csb337_eth_data);
>  	/* USB Host */
>  	at91_add_device_usbh(&csb337_usbh_data);
> diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
> index f6d0956..40172d1 100644
> --- a/drivers/net/ethernet/cadence/Kconfig
> +++ b/drivers/net/ethernet/cadence/Kconfig
> @@ -21,7 +21,6 @@ if NET_CADENCE
>  
>  config ARM_AT91_ETHER
>  	tristate "AT91RM9200 Ethernet support"
> -	depends on ARM && ARCH_AT91RM9200
>  	select NET_CORE
>  	select MACB
>  	---help---
> diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
> index 375d272..5ed1a63 100644
> --- a/drivers/net/ethernet/cadence/at91_ether.c
> +++ b/drivers/net/ethernet/cadence/at91_ether.c
> @@ -32,8 +32,6 @@
>  #include <linux/phy.h>
>  #include <linux/io.h>
>  
> -#include <asm/mach-types.h>
> -
>  #include "macb.h"
>  
>  #define DRV_NAME	"at91_ether"
> @@ -55,30 +53,18 @@
>   *   U-Boot on the AT91RM9200-DK do not do this.
>   *
>   * - Likewise it must store the addresses in the correct byte order.
> - *   MicroMonitor (uMon) on the CSB337 does this incorrectly (and
> - *   continues to do so, for bug-compatibility).
>   */
>  
>  static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo)
>  {
>  	char addr[6];
>  
> -	if (machine_is_csb337()) {
> -		addr[5] = (lo & 0xff);			/* The CSB337 bootloader stores the MAC the wrong-way around */
> -		addr[4] = (lo & 0xff00) >> 8;
> -		addr[3] = (lo & 0xff0000) >> 16;
> -		addr[2] = (lo & 0xff000000) >> 24;
> -		addr[1] = (hi & 0xff);
> -		addr[0] = (hi & 0xff00) >> 8;
> -	}
> -	else {
> -		addr[0] = (lo & 0xff);
> -		addr[1] = (lo & 0xff00) >> 8;
> -		addr[2] = (lo & 0xff0000) >> 16;
> -		addr[3] = (lo & 0xff000000) >> 24;
> -		addr[4] = (hi & 0xff);
> -		addr[5] = (hi & 0xff00) >> 8;
> -	}
> +	addr[0] = (lo & 0xff);
> +	addr[1] = (lo & 0xff00) >> 8;
> +	addr[2] = (lo & 0xff0000) >> 16;
> +	addr[3] = (lo & 0xff000000) >> 24;
> +	addr[4] = (hi & 0xff);
> +	addr[5] = (hi & 0xff00) >> 8;
>  
>  	if (is_valid_ether_addr(addr)) {
>  		memcpy(dev->dev_addr, &addr, 6);
> -- 
> 1.7.12.4
> 

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

* [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB
  2012-10-21 14:23 ` [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB Joachim Eastwood
@ 2012-10-21 18:30   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 20:26     ` Joachim Eastwood
  2012-10-21 23:27   ` David Miller
  1 sibling, 1 reply; 17+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-21 18:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
> macb is a platform driver and there is nothing that prevents
> this driver from being built on non-ARM/AVR32 platforms.
if you want to drop the HAVE_NET_MACB you need to drop it everywher in one
patch

Best Regards,
J.
> 
> Signed-off-by: Joachim Eastwood <manabian@gmail.com>
> ---
>  drivers/net/ethernet/cadence/Kconfig | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
> index 57f78abe..5d1ea30 100644
> --- a/drivers/net/ethernet/cadence/Kconfig
> +++ b/drivers/net/ethernet/cadence/Kconfig
> @@ -2,13 +2,9 @@
>  # Atmel device configuration
>  #
>  
> -config HAVE_NET_MACB
> -	bool
> -
>  config NET_CADENCE
>  	bool "Cadence devices"
>  	default y
> -	depends on HAVE_NET_MACB || (ARM && ARCH_AT91RM9200)
>  	---help---
>  	  If you have a network (Ethernet) card belonging to this class, say Y.
>  	  Make sure you know the name of your card. Read the Ethernet-HOWTO,
> @@ -34,7 +30,6 @@ config ARM_AT91_ETHER
>  
>  config MACB
>  	tristate "Cadence MACB/GEM support"
> -	depends on HAVE_NET_MACB
>  	select PHYLIB
>  	---help---
>  	  The Cadence MACB ethernet interface is found on many Atmel AT32 and
> -- 
> 1.7.12.4
> 

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

* [PATCH 2/5] net/at91_ether: select MACB in Kconfig
  2012-10-21 14:23 ` [PATCH 2/5] net/at91_ether: select MACB in Kconfig Joachim Eastwood
@ 2012-10-21 18:31   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 20:27     ` Joachim Eastwood
  0 siblings, 1 reply; 17+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-21 18:31 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
> Now that HAVE_NET_MACB is gone let's just select MACB to
> satisfy the dependecies in at91_ether.
> 
> PHYLIB will then by selected by MACB.
> 
> Signed-off-by: Joachim Eastwood <manabian@gmail.com>
> ---
>  drivers/net/ethernet/cadence/Kconfig  | 2 +-
>  drivers/net/ethernet/cadence/Makefile | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
> index 5d1ea30..f6d0956 100644
> --- a/drivers/net/ethernet/cadence/Kconfig
> +++ b/drivers/net/ethernet/cadence/Kconfig
> @@ -23,7 +23,7 @@ config ARM_AT91_ETHER
>  	tristate "AT91RM9200 Ethernet support"
>  	depends on ARM && ARCH_AT91RM9200
>  	select NET_CORE
> -	select PHYLIB
> +	select MACB
no the ether and macb are two diferrent drivers for 2 IPs from cadence

the ehter does not need the macb

Best Regards,
J.
>  	---help---
>  	  If you wish to compile a kernel for the AT91RM9200 and enable
>  	  ethernet support, then you should always answer Y to this.
> diff --git a/drivers/net/ethernet/cadence/Makefile b/drivers/net/ethernet/cadence/Makefile
> index 798b1e0..9068b83 100644
> --- a/drivers/net/ethernet/cadence/Makefile
> +++ b/drivers/net/ethernet/cadence/Makefile
> @@ -2,5 +2,5 @@
>  # Makefile for the Atmel network device drivers.
>  #
>  
> -obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o macb.o
> +obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o
>  obj-$(CONFIG_MACB) += macb.o
> -- 
> 1.7.12.4
> 

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

* [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup
  2012-10-21 14:23 ` [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup Joachim Eastwood
  2012-10-21 18:25   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-21 18:34   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-21 20:30     ` Joachim Eastwood
  1 sibling, 1 reply; 17+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-10-21 18:34 UTC (permalink / raw)
  To: linux-arm-kernel

On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
> Move Ethernet address byte order fix for csb337 into it's board
> setup.
> 
> This will allow us to remove the last mach include from at91_ether
> and also to share the address setup with the macb driver.
no the current drivers expect mach/board.h, mach/at91rm9200_emac.h, asm/gpio.h

waht you did will not even compile on non at91 platform

Did you even compile it on non at91?

Best Regards,
J.
> 
> Signed-off-by: Joachim Eastwood <manabian@gmail.com>
> ---
>  arch/arm/mach-at91/board-csb337.c         | 35 +++++++++++++++++++++++++++++++
>  drivers/net/ethernet/cadence/Kconfig      |  1 -
>  drivers/net/ethernet/cadence/at91_ether.c | 26 ++++++-----------------
>  3 files changed, 41 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
> index 3e37437..5522132 100644
> --- a/arch/arm/mach-at91/board-csb337.c
> +++ b/arch/arm/mach-at91/board-csb337.c
> @@ -217,6 +217,40 @@ static struct gpio_led csb_leds[] = {
>  	}
>  };
>  
> +/*
> + * MicroMonitor (uMon) on the CSB337 store the ethernet address in the
> + * wrong byte order (and continues to do so, for bug-compatibility).
> + */
> +#define MACB_SA1B	0x0098
> +#define MACB_SA1T	0x009c
> +static void __init csb337_fix_eth_addr(void)
> +{
> +	void __iomem *emac;
> +	u32 lo, hi, tmp;
> +	int i;
> +
> +	emac = ioremap(AT91RM9200_BASE_EMAC, SZ_16K);
> +	if (!emac) {
> +		printk(KERN_ERR "csb337: unable to fixup Ethernet address\n");
> +		return;
> +	}
> +
> +	/* Fix byte order on all 4 address registers */
> +	for (i = 0; i < 4; i++) {
> +		lo = readl(emac + MACB_SA1B + i * 8);
> +		hi = readl(emac + MACB_SA1T + i * 8);
> +
> +		tmp = (lo & 0xff) << 8 | (lo & 0xff00) >> 8;
> +		writel(tmp, emac + MACB_SA1T + i * 8);
> +
> +		tmp = (hi & 0xff) << 8 | (hi & 0xff00) >> 8
> +			| (lo & 0xff0000) << 8
> +			| (lo & 0xff000000) >> 8;
> +		writel(tmp, emac + MACB_SA1B + i * 8);
> +	}
> +
> +	iounmap(emac);
> +}
>  
>  static void __init csb337_board_init(void)
>  {
> @@ -225,6 +259,7 @@ static void __init csb337_board_init(void)
>  	at91_register_uart(0, 0, 0);
>  	at91_add_device_serial();
>  	/* Ethernet */
> +	csb337_fix_eth_addr();
>  	at91_add_device_eth(&csb337_eth_data);
>  	/* USB Host */
>  	at91_add_device_usbh(&csb337_usbh_data);
> diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
> index f6d0956..40172d1 100644
> --- a/drivers/net/ethernet/cadence/Kconfig
> +++ b/drivers/net/ethernet/cadence/Kconfig
> @@ -21,7 +21,6 @@ if NET_CADENCE
>  
>  config ARM_AT91_ETHER
>  	tristate "AT91RM9200 Ethernet support"
> -	depends on ARM && ARCH_AT91RM9200
>  	select NET_CORE
>  	select MACB
>  	---help---
> diff --git a/drivers/net/ethernet/cadence/at91_ether.c b/drivers/net/ethernet/cadence/at91_ether.c
> index 375d272..5ed1a63 100644
> --- a/drivers/net/ethernet/cadence/at91_ether.c
> +++ b/drivers/net/ethernet/cadence/at91_ether.c
> @@ -32,8 +32,6 @@
>  #include <linux/phy.h>
>  #include <linux/io.h>
>  
> -#include <asm/mach-types.h>
> -
>  #include "macb.h"
>  
>  #define DRV_NAME	"at91_ether"
> @@ -55,30 +53,18 @@
>   *   U-Boot on the AT91RM9200-DK do not do this.
>   *
>   * - Likewise it must store the addresses in the correct byte order.
> - *   MicroMonitor (uMon) on the CSB337 does this incorrectly (and
> - *   continues to do so, for bug-compatibility).
>   */
>  
>  static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo)
>  {
>  	char addr[6];
>  
> -	if (machine_is_csb337()) {
> -		addr[5] = (lo & 0xff);			/* The CSB337 bootloader stores the MAC the wrong-way around */
> -		addr[4] = (lo & 0xff00) >> 8;
> -		addr[3] = (lo & 0xff0000) >> 16;
> -		addr[2] = (lo & 0xff000000) >> 24;
> -		addr[1] = (hi & 0xff);
> -		addr[0] = (hi & 0xff00) >> 8;
> -	}
> -	else {
> -		addr[0] = (lo & 0xff);
> -		addr[1] = (lo & 0xff00) >> 8;
> -		addr[2] = (lo & 0xff0000) >> 16;
> -		addr[3] = (lo & 0xff000000) >> 24;
> -		addr[4] = (hi & 0xff);
> -		addr[5] = (hi & 0xff00) >> 8;
> -	}
> +	addr[0] = (lo & 0xff);
> +	addr[1] = (lo & 0xff00) >> 8;
> +	addr[2] = (lo & 0xff0000) >> 16;
> +	addr[3] = (lo & 0xff000000) >> 24;
> +	addr[4] = (hi & 0xff);
> +	addr[5] = (hi & 0xff00) >> 8;
>  
>  	if (is_valid_ether_addr(addr)) {
>  		memcpy(dev->dev_addr, &addr, 6);
> -- 
> 1.7.12.4
> 

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

* [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB
  2012-10-21 18:30   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-21 20:26     ` Joachim Eastwood
  0 siblings, 0 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 20:26 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Oct 21, 2012 at 8:30 PM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
>> macb is a platform driver and there is nothing that prevents
>> this driver from being built on non-ARM/AVR32 platforms.
> if you want to drop the HAVE_NET_MACB you need to drop it everywher in one
> patch

Breaking it up in several patches doesn't seem to cause any build
failures and I did this in case the patches were going into different
git trees.

regards
Joachim Eastwood

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

* [PATCH 2/5] net/at91_ether: select MACB in Kconfig
  2012-10-21 18:31   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-21 20:27     ` Joachim Eastwood
  0 siblings, 0 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 20:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Oct 21, 2012 at 8:31 PM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
>> Now that HAVE_NET_MACB is gone let's just select MACB to
>> satisfy the dependecies in at91_ether.
>>
>> PHYLIB will then by selected by MACB.
>>
>> Signed-off-by: Joachim Eastwood <manabian@gmail.com>
>> ---
>>  drivers/net/ethernet/cadence/Kconfig  | 2 +-
>>  drivers/net/ethernet/cadence/Makefile | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
>> index 5d1ea30..f6d0956 100644
>> --- a/drivers/net/ethernet/cadence/Kconfig
>> +++ b/drivers/net/ethernet/cadence/Kconfig
>> @@ -23,7 +23,7 @@ config ARM_AT91_ETHER
>>       tristate "AT91RM9200 Ethernet support"
>>       depends on ARM && ARCH_AT91RM9200
>>       select NET_CORE
>> -     select PHYLIB
>> +     select MACB
> no the ether and macb are two diferrent drivers for 2 IPs from cadence
>
> the ehter does not need the macb

The at91_ether in net-next does.

regards
Joachim Eastwood

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

* [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup
  2012-10-21 18:34   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-21 20:30     ` Joachim Eastwood
  0 siblings, 0 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 20:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Oct 21, 2012 at 8:34 PM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
>> Move Ethernet address byte order fix for csb337 into it's board
>> setup.
>>
>> This will allow us to remove the last mach include from at91_ether
>> and also to share the address setup with the macb driver.
> no the current drivers expect mach/board.h, mach/at91rm9200_emac.h, asm/gpio.h
>
> waht you did will not even compile on non at91 platform
>
> Did you even compile it on non at91?

This is the last mach include in the at91_ether driver in net-next.
And, yes, after this patch it complies fine for at least x86_64.

regards
Joachim Eastwood

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

* [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup
  2012-10-21 18:25   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-21 20:39     ` Joachim Eastwood
  0 siblings, 0 replies; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-21 20:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Oct 21, 2012 at 8:25 PM, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> On 16:23 Sun 21 Oct     , Joachim Eastwood wrote:
>> Move Ethernet address byte order fix for csb337 into it's board
>> setup.
>>
>> This will allow us to remove the last mach include from at91_ether
>> and also to share the address setup with the macb driver.
> no the at91rm9200 move to DT this is not compatible with it
>
> you need to pass ths in info via platform_data
>
> and do not touch driver code related stuff in boards

I know the board code is a bit nasty.
If it's unacceptable I'll cook up a flag and pass it by platform_data,
something like "reverse_eth_addr". Still it will only ever be used on
the csb337 board.

regards
Joachim Eastwood

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

* [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB
  2012-10-21 14:23 ` [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB Joachim Eastwood
  2012-10-21 18:30   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-21 23:27   ` David Miller
  2012-10-22  6:59     ` Joachim Eastwood
  1 sibling, 1 reply; 17+ messages in thread
From: David Miller @ 2012-10-21 23:27 UTC (permalink / raw)
  To: linux-arm-kernel


You do know that this is going to generate warnings on 64-bit
platforms?

I was hoping you would have noticed and corrected this before
enabling the driver everywhere, I guess my expectations were
way too high :-/

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

* [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB
  2012-10-21 23:27   ` David Miller
@ 2012-10-22  6:59     ` Joachim Eastwood
  2012-10-22  7:10       ` David Miller
  0 siblings, 1 reply; 17+ messages in thread
From: Joachim Eastwood @ 2012-10-22  6:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 22, 2012 at 1:27 AM, David Miller <davem@davemloft.net> wrote:
>
> You do know that this is going to generate warnings on 64-bit
> platforms?
>
> I was hoping you would have noticed and corrected this before
> enabling the driver everywhere, I guess my expectations were
> way too high :-/

ah, sorry.

Yes, macb seem to generate some integer overflows on ~0UL on 64-bit. I
have a patch that turns ~0UL into -1.

I can repost the series with fix included. Do you want me to do that?

regards
Joachim Eastwood

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

* [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB
  2012-10-22  6:59     ` Joachim Eastwood
@ 2012-10-22  7:10       ` David Miller
  0 siblings, 0 replies; 17+ messages in thread
From: David Miller @ 2012-10-22  7:10 UTC (permalink / raw)
  To: linux-arm-kernel

From: Joachim  Eastwood <manabian@gmail.com>
Date: Mon, 22 Oct 2012 08:59:17 +0200

> On Mon, Oct 22, 2012 at 1:27 AM, David Miller <davem@davemloft.net> wrote:
>>
>> You do know that this is going to generate warnings on 64-bit
>> platforms?
>>
>> I was hoping you would have noticed and corrected this before
>> enabling the driver everywhere, I guess my expectations were
>> way too high :-/
> 
> ah, sorry.
> 
> Yes, macb seem to generate some integer overflows on ~0UL on 64-bit. I
> have a patch that turns ~0UL into -1.
> 
> I can repost the series with fix included. Do you want me to do that?

Yes, please do.

Thanks.

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

end of thread, other threads:[~2012-10-22  7:10 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-21 14:23 [PATCH 0/5] make cadence ethernet drivers build on any architecture Joachim Eastwood
2012-10-21 14:23 ` [PATCH 1/5] net/cadence: get rid of HAVE_NET_MACB Joachim Eastwood
2012-10-21 18:30   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-21 20:26     ` Joachim Eastwood
2012-10-21 23:27   ` David Miller
2012-10-22  6:59     ` Joachim Eastwood
2012-10-22  7:10       ` David Miller
2012-10-21 14:23 ` [PATCH 2/5] net/at91_ether: select MACB in Kconfig Joachim Eastwood
2012-10-21 18:31   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-21 20:27     ` Joachim Eastwood
2012-10-21 14:23 ` [PATCH 3/5] net/at91_ether: move eth addr quirk into csb337 board setup Joachim Eastwood
2012-10-21 18:25   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-21 20:39     ` Joachim Eastwood
2012-10-21 18:34   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-21 20:30     ` Joachim Eastwood
2012-10-21 14:23 ` [PATCH 4/5] ARM: AT91: Remove HAVE_NET_MACB Joachim Eastwood
2012-10-21 14:23 ` [PATCH 5/5] AVR32: " Joachim Eastwood

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