netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] macb: add support for Cadence GEM
@ 2011-03-10 10:10 Jamie Iles
  2011-03-10 10:10 ` [PATCH 1/8] macb: unify at91 and avr32 platform data Jamie Iles
                   ` (7 more replies)
  0 siblings, 8 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

This patch series extends the Atmel MACB driver to support the Cadence
GEM (Gigabit Ethernet MAC) to support 10/100 operation.  The GEM is
based on the MACB block but has a few moved registers and bitfields.
This patch series attempts to use the MACB accessors where block
functionallity is identical and only overrides to GEM specific
acccessors when needed.

This has been runtested on a board with a Cadence GEM and compile tested
for all at91 configurations and a number of avr32 configurations.

Jamie Iles (8):
  macb: unify at91 and avr32 platform data
  macb: detect hclk presence from platform data
  macb: convert printk to pr_ and friends
  macb: initial support for Cadence GEM
  macb: handle HW address registers for GEM devices
  macb: support higher rate GEM MDIO clock divisors
  macb: support statistics for GEM devices
  macb: support data bus widths > 32 bits

 arch/arm/mach-at91/at572d940hf_devices.c    |    6 +-
 arch/arm/mach-at91/at91cap9_devices.c       |    6 +-
 arch/arm/mach-at91/at91rm9200_devices.c     |    6 +-
 arch/arm/mach-at91/at91sam9260_devices.c    |    6 +-
 arch/arm/mach-at91/at91sam9263_devices.c    |    6 +-
 arch/arm/mach-at91/at91sam9g45_devices.c    |    6 +-
 arch/arm/mach-at91/board-1arm.c             |    2 +-
 arch/arm/mach-at91/board-afeb-9260v1.c      |    2 +-
 arch/arm/mach-at91/board-at572d940hf_ek.c   |    2 +-
 arch/arm/mach-at91/board-cam60.c            |    2 +-
 arch/arm/mach-at91/board-cap9adk.c          |    2 +-
 arch/arm/mach-at91/board-carmeva.c          |    2 +-
 arch/arm/mach-at91/board-cpu9krea.c         |    2 +-
 arch/arm/mach-at91/board-cpuat91.c          |    2 +-
 arch/arm/mach-at91/board-csb337.c           |    2 +-
 arch/arm/mach-at91/board-csb637.c           |    2 +-
 arch/arm/mach-at91/board-eb9200.c           |    2 +-
 arch/arm/mach-at91/board-ecbat91.c          |    2 +-
 arch/arm/mach-at91/board-eco920.c           |    2 +-
 arch/arm/mach-at91/board-foxg20.c           |    2 +-
 arch/arm/mach-at91/board-gsia18s.c          |    2 +-
 arch/arm/mach-at91/board-kafa.c             |    2 +-
 arch/arm/mach-at91/board-kb9202.c           |    2 +-
 arch/arm/mach-at91/board-neocore926.c       |    2 +-
 arch/arm/mach-at91/board-pcontrol-g20.c     |    2 +-
 arch/arm/mach-at91/board-picotux200.c       |    2 +-
 arch/arm/mach-at91/board-qil-a9260.c        |    2 +-
 arch/arm/mach-at91/board-rm9200dk.c         |    2 +-
 arch/arm/mach-at91/board-rm9200ek.c         |    2 +-
 arch/arm/mach-at91/board-sam9-l9260.c       |    2 +-
 arch/arm/mach-at91/board-sam9260ek.c        |    2 +-
 arch/arm/mach-at91/board-sam9263ek.c        |    2 +-
 arch/arm/mach-at91/board-sam9g20ek.c        |    2 +-
 arch/arm/mach-at91/board-sam9m10g45ek.c     |    2 +-
 arch/arm/mach-at91/board-snapper9260.c      |    2 +-
 arch/arm/mach-at91/board-stamp9g20.c        |    2 +-
 arch/arm/mach-at91/board-usb-a9260.c        |    2 +-
 arch/arm/mach-at91/board-usb-a9263.c        |    2 +-
 arch/arm/mach-at91/board-yl-9200.c          |    2 +-
 arch/arm/mach-at91/include/mach/board.h     |   14 +-
 arch/avr32/mach-at32ap/at32ap700x.c         |    2 +
 arch/avr32/mach-at32ap/include/mach/board.h |    5 +-
 drivers/net/Kconfig                         |    8 +-
 drivers/net/macb.c                          |  294 +++++++++++++++++++--------
 drivers/net/macb.h                          |   90 ++++++++-
 include/linux/platform_data/macb.h          |   17 ++
 46 files changed, 381 insertions(+), 151 deletions(-)
 create mode 100644 include/linux/platform_data/macb.h

-- 
1.7.4


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

* [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-10 13:06   ` Nicolas Ferre
  2011-03-10 10:10 ` [PATCH 2/8] macb: detect hclk presence from " Jamie Iles
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

Both at91 and avr32 defines its own platform data structure for
the macb driver and both share common structures though at91
includes a currently unused phy_irq_pin.  Create a common
eth_platform_data for macb that both at91 and avr32 can use.  In
future we can use this to support other architectures that use the
same IP block with the macb driver.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 arch/arm/mach-at91/at572d940hf_devices.c    |    6 +++---
 arch/arm/mach-at91/at91cap9_devices.c       |    6 +++---
 arch/arm/mach-at91/at91rm9200_devices.c     |    6 +++---
 arch/arm/mach-at91/at91sam9260_devices.c    |    6 +++---
 arch/arm/mach-at91/at91sam9263_devices.c    |    6 +++---
 arch/arm/mach-at91/at91sam9g45_devices.c    |    6 +++---
 arch/arm/mach-at91/board-1arm.c             |    2 +-
 arch/arm/mach-at91/board-afeb-9260v1.c      |    2 +-
 arch/arm/mach-at91/board-at572d940hf_ek.c   |    2 +-
 arch/arm/mach-at91/board-cam60.c            |    2 +-
 arch/arm/mach-at91/board-cap9adk.c          |    2 +-
 arch/arm/mach-at91/board-carmeva.c          |    2 +-
 arch/arm/mach-at91/board-cpu9krea.c         |    2 +-
 arch/arm/mach-at91/board-cpuat91.c          |    2 +-
 arch/arm/mach-at91/board-csb337.c           |    2 +-
 arch/arm/mach-at91/board-csb637.c           |    2 +-
 arch/arm/mach-at91/board-eb9200.c           |    2 +-
 arch/arm/mach-at91/board-ecbat91.c          |    2 +-
 arch/arm/mach-at91/board-eco920.c           |    2 +-
 arch/arm/mach-at91/board-foxg20.c           |    2 +-
 arch/arm/mach-at91/board-gsia18s.c          |    2 +-
 arch/arm/mach-at91/board-kafa.c             |    2 +-
 arch/arm/mach-at91/board-kb9202.c           |    2 +-
 arch/arm/mach-at91/board-neocore926.c       |    2 +-
 arch/arm/mach-at91/board-pcontrol-g20.c     |    2 +-
 arch/arm/mach-at91/board-picotux200.c       |    2 +-
 arch/arm/mach-at91/board-qil-a9260.c        |    2 +-
 arch/arm/mach-at91/board-rm9200dk.c         |    2 +-
 arch/arm/mach-at91/board-rm9200ek.c         |    2 +-
 arch/arm/mach-at91/board-sam9-l9260.c       |    2 +-
 arch/arm/mach-at91/board-sam9260ek.c        |    2 +-
 arch/arm/mach-at91/board-sam9263ek.c        |    2 +-
 arch/arm/mach-at91/board-sam9g20ek.c        |    2 +-
 arch/arm/mach-at91/board-sam9m10g45ek.c     |    2 +-
 arch/arm/mach-at91/board-snapper9260.c      |    2 +-
 arch/arm/mach-at91/board-stamp9g20.c        |    2 +-
 arch/arm/mach-at91/board-usb-a9260.c        |    2 +-
 arch/arm/mach-at91/board-usb-a9263.c        |    2 +-
 arch/arm/mach-at91/board-yl-9200.c          |    2 +-
 arch/arm/mach-at91/include/mach/board.h     |   14 ++------------
 arch/avr32/mach-at32ap/include/mach/board.h |    5 +----
 drivers/net/macb.c                          |    4 +---
 include/linux/platform_data/macb.h          |   10 ++++++++++
 43 files changed, 65 insertions(+), 70 deletions(-)
 create mode 100644 include/linux/platform_data/macb.h

diff --git a/arch/arm/mach-at91/at572d940hf_devices.c b/arch/arm/mach-at91/at572d940hf_devices.c
index 0fc20a2..6e1b9a3 100644
--- a/arch/arm/mach-at91/at572d940hf_devices.c
+++ b/arch/arm/mach-at91/at572d940hf_devices.c
@@ -140,7 +140,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
 
 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
 static u64 eth_dmamask = DMA_BIT_MASK(32);
-static struct at91_eth_data eth_data;
+static struct eth_platform_data eth_data;
 
 static struct resource eth_resources[] = {
 	[0] = {
@@ -167,7 +167,7 @@ static struct platform_device at572d940hf_eth_device = {
 	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
-void __init at91_add_device_eth(struct at91_eth_data *data)
+void __init at91_add_device_eth(struct eth_platform_data *data)
 {
 	if (!data)
 		return;
@@ -196,7 +196,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)
 	platform_device_register(&at572d940hf_eth_device);
 }
 #else
-void __init at91_add_device_eth(struct at91_eth_data *data) {}
+void __init at91_add_device_eth(struct eth_platform_data *data) {}
 #endif
 
 
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index d1f775e..e041743 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -198,7 +198,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data) {}
 
 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
 static u64 eth_dmamask = DMA_BIT_MASK(32);
-static struct at91_eth_data eth_data;
+static struct eth_platform_data eth_data;
 
 static struct resource eth_resources[] = {
 	[0] = {
@@ -225,7 +225,7 @@ static struct platform_device at91cap9_eth_device = {
 	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
-void __init at91_add_device_eth(struct at91_eth_data *data)
+void __init at91_add_device_eth(struct eth_platform_data *data)
 {
 	if (!data)
 		return;
@@ -262,7 +262,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)
 	platform_device_register(&at91cap9_eth_device);
 }
 #else
-void __init at91_add_device_eth(struct at91_eth_data *data) {}
+void __init at91_add_device_eth(struct eth_platform_data *data) {}
 #endif
 
 
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 7b53922..5f873d5 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -127,7 +127,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
 
 #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
 static u64 eth_dmamask = DMA_BIT_MASK(32);
-static struct at91_eth_data eth_data;
+static struct eth_platform_data eth_data;
 
 static struct resource eth_resources[] = {
 	[0] = {
@@ -154,7 +154,7 @@ static struct platform_device at91rm9200_eth_device = {
 	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
-void __init at91_add_device_eth(struct at91_eth_data *data)
+void __init at91_add_device_eth(struct eth_platform_data *data)
 {
 	if (!data)
 		return;
@@ -191,7 +191,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)
 	platform_device_register(&at91rm9200_eth_device);
 }
 #else
-void __init at91_add_device_eth(struct at91_eth_data *data) {}
+void __init at91_add_device_eth(struct eth_platform_data *data) {}
 #endif
 
 
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 07eb7b0..e172b46 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -128,7 +128,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
 
 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
 static u64 eth_dmamask = DMA_BIT_MASK(32);
-static struct at91_eth_data eth_data;
+static struct eth_platform_data eth_data;
 
 static struct resource eth_resources[] = {
 	[0] = {
@@ -155,7 +155,7 @@ static struct platform_device at91sam9260_eth_device = {
 	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
-void __init at91_add_device_eth(struct at91_eth_data *data)
+void __init at91_add_device_eth(struct eth_platform_data *data)
 {
 	if (!data)
 		return;
@@ -192,7 +192,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)
 	platform_device_register(&at91sam9260_eth_device);
 }
 #else
-void __init at91_add_device_eth(struct at91_eth_data *data) {}
+void __init at91_add_device_eth(struct eth_platform_data *data) {}
 #endif
 
 
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index fb5c23a..416613c 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -138,7 +138,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
 
 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
 static u64 eth_dmamask = DMA_BIT_MASK(32);
-static struct at91_eth_data eth_data;
+static struct eth_platform_data eth_data;
 
 static struct resource eth_resources[] = {
 	[0] = {
@@ -165,7 +165,7 @@ static struct platform_device at91sam9263_eth_device = {
 	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
-void __init at91_add_device_eth(struct at91_eth_data *data)
+void __init at91_add_device_eth(struct eth_platform_data *data)
 {
 	if (!data)
 		return;
@@ -202,7 +202,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)
 	platform_device_register(&at91sam9263_eth_device);
 }
 #else
-void __init at91_add_device_eth(struct at91_eth_data *data) {}
+void __init at91_add_device_eth(struct eth_platform_data *data) {}
 #endif
 
 
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 1e8f275..0867343 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -283,7 +283,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data) {}
 
 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
 static u64 eth_dmamask = DMA_BIT_MASK(32);
-static struct at91_eth_data eth_data;
+static struct eth_platform_data eth_data;
 
 static struct resource eth_resources[] = {
 	[0] = {
@@ -310,7 +310,7 @@ static struct platform_device at91sam9g45_eth_device = {
 	.num_resources	= ARRAY_SIZE(eth_resources),
 };
 
-void __init at91_add_device_eth(struct at91_eth_data *data)
+void __init at91_add_device_eth(struct eth_platform_data *data)
 {
 	if (!data)
 		return;
@@ -347,7 +347,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)
 	platform_device_register(&at91sam9g45_eth_device);
 }
 #else
-void __init at91_add_device_eth(struct at91_eth_data *data) {}
+void __init at91_add_device_eth(struct eth_platform_data *data) {}
 #endif
 
 
diff --git a/arch/arm/mach-at91/board-1arm.c b/arch/arm/mach-at91/board-1arm.c
index 8a3fc84..1961d1e 100644
--- a/arch/arm/mach-at91/board-1arm.c
+++ b/arch/arm/mach-at91/board-1arm.c
@@ -64,7 +64,7 @@ static void __init onearm_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata onearm_eth_data = {
+static struct eth_platform_data __initdata onearm_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c
index cba7f77..8943ff3 100644
--- a/arch/arm/mach-at91/board-afeb-9260v1.c
+++ b/arch/arm/mach-at91/board-afeb-9260v1.c
@@ -109,7 +109,7 @@ static struct spi_board_info afeb9260_spi_devices[] = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata afeb9260_macb_data = {
+static struct eth_platform_data __initdata afeb9260_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA9,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-at572d940hf_ek.c b/arch/arm/mach-at91/board-at572d940hf_ek.c
index 3929f1c..a17d8e7 100644
--- a/arch/arm/mach-at91/board-at572d940hf_ek.c
+++ b/arch/arm/mach-at91/board-at572d940hf_ek.c
@@ -104,7 +104,7 @@ static struct at91_mmc_data __initdata eb_mmc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata eb_eth_data = {
+static struct eth_platform_data __initdata eb_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PB25,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
index b54e3e6..8cc6bfc 100644
--- a/arch/arm/mach-at91/board-cam60.c
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -121,7 +121,7 @@ static struct spi_board_info cam60_spi_devices[] __initdata = {
 /*
  * MACB Ethernet device
  */
-static struct __initdata at91_eth_data cam60_macb_data = {
+static struct __initdata eth_platform_data cam60_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PB5,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c
index e727444..8f9bc88 100644
--- a/arch/arm/mach-at91/board-cap9adk.c
+++ b/arch/arm/mach-at91/board-cap9adk.c
@@ -158,7 +158,7 @@ static struct at91_mmc_data __initdata cap9adk_mmc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata cap9adk_macb_data = {
+static struct eth_platform_data __initdata cap9adk_macb_data = {
 	.is_rmii	= 1,
 };
 
diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c
index 2e74a19..dbc9061 100644
--- a/arch/arm/mach-at91/board-carmeva.c
+++ b/arch/arm/mach-at91/board-carmeva.c
@@ -62,7 +62,7 @@ static void __init carmeva_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata carmeva_eth_data = {
+static struct eth_platform_data __initdata carmeva_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-cpu9krea.c b/arch/arm/mach-at91/board-cpu9krea.c
index 3838594..a7d0843 100644
--- a/arch/arm/mach-at91/board-cpu9krea.c
+++ b/arch/arm/mach-at91/board-cpu9krea.c
@@ -104,7 +104,7 @@ static struct at91_udc_data __initdata cpu9krea_udc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata cpu9krea_macb_data = {
+static struct eth_platform_data __initdata cpu9krea_macb_data = {
 	.is_rmii	= 1,
 };
 
diff --git a/arch/arm/mach-at91/board-cpuat91.c b/arch/arm/mach-at91/board-cpuat91.c
index 2f4dd8c..52909f0 100644
--- a/arch/arm/mach-at91/board-cpuat91.c
+++ b/arch/arm/mach-at91/board-cpuat91.c
@@ -83,7 +83,7 @@ static void __init cpuat91_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata cpuat91_eth_data = {
+static struct eth_platform_data __initdata cpuat91_eth_data = {
 	.is_rmii	= 1,
 };
 
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index 464839d..7e062fa 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -63,7 +63,7 @@ static void __init csb337_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata csb337_eth_data = {
+static struct eth_platform_data __initdata csb337_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC2,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c
index 431688c..fb8456e 100644
--- a/arch/arm/mach-at91/board-csb637.c
+++ b/arch/arm/mach-at91/board-csb637.c
@@ -57,7 +57,7 @@ static void __init csb637_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata csb637_eth_data = {
+static struct eth_platform_data __initdata csb637_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC0,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-eb9200.c b/arch/arm/mach-at91/board-eb9200.c
index 6cf6566..ac71845 100644
--- a/arch/arm/mach-at91/board-eb9200.c
+++ b/arch/arm/mach-at91/board-eb9200.c
@@ -65,7 +65,7 @@ static void __init eb9200_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata eb9200_eth_data = {
+static struct eth_platform_data __initdata eb9200_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
index de2fd04..aa8fb2a 100644
--- a/arch/arm/mach-at91/board-ecbat91.c
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -65,7 +65,7 @@ static void __init ecb_at91init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata ecb_at91eth_data = {
+static struct eth_platform_data __initdata ecb_at91eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c
index a158a0c..a1e9173 100644
--- a/arch/arm/mach-at91/board-eco920.c
+++ b/arch/arm/mach-at91/board-eco920.c
@@ -47,7 +47,7 @@ static void __init eco920_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata eco920_eth_data = {
+static struct eth_platform_data __initdata eco920_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC2,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-foxg20.c b/arch/arm/mach-at91/board-foxg20.c
index dfc7dfe..b7630b9 100644
--- a/arch/arm/mach-at91/board-foxg20.c
+++ b/arch/arm/mach-at91/board-foxg20.c
@@ -141,7 +141,7 @@ static struct spi_board_info foxg20_spi_devices[] = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata foxg20_macb_data = {
+static struct eth_platform_data __initdata foxg20_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA7,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-gsia18s.c b/arch/arm/mach-at91/board-gsia18s.c
index bc28136..0405b17 100644
--- a/arch/arm/mach-at91/board-gsia18s.c
+++ b/arch/arm/mach-at91/board-gsia18s.c
@@ -98,7 +98,7 @@ static struct at91_udc_data __initdata udc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata macb_data = {
+static struct eth_platform_data __initdata macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA28,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c
index d2e1f4e..f45fc82 100644
--- a/arch/arm/mach-at91/board-kafa.c
+++ b/arch/arm/mach-at91/board-kafa.c
@@ -62,7 +62,7 @@ static void __init kafa_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata kafa_eth_data = {
+static struct eth_platform_data __initdata kafa_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index a13d206..88a40c2 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -71,7 +71,7 @@ static void __init kb9202_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata kb9202_eth_data = {
+static struct eth_platform_data __initdata kb9202_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PB29,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c
index fe5f1d4..97890d8 100644
--- a/arch/arm/mach-at91/board-neocore926.c
+++ b/arch/arm/mach-at91/board-neocore926.c
@@ -161,7 +161,7 @@ static struct at91_mmc_data __initdata neocore926_mmc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata neocore926_macb_data = {
+static struct eth_platform_data __initdata neocore926_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PE31,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-pcontrol-g20.c b/arch/arm/mach-at91/board-pcontrol-g20.c
index feb6578..03e8286 100644
--- a/arch/arm/mach-at91/board-pcontrol-g20.c
+++ b/arch/arm/mach-at91/board-pcontrol-g20.c
@@ -129,7 +129,7 @@ static struct at91_udc_data __initdata pcontrol_g20_udc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata macb_data = {
+static struct eth_platform_data __initdata macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA28,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c
index 55dad3a..3f3cd9c 100644
--- a/arch/arm/mach-at91/board-picotux200.c
+++ b/arch/arm/mach-at91/board-picotux200.c
@@ -65,7 +65,7 @@ static void __init picotux200_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata picotux200_eth_data = {
+static struct eth_platform_data __initdata picotux200_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c
index 69d15a8..165e43e 100644
--- a/arch/arm/mach-at91/board-qil-a9260.c
+++ b/arch/arm/mach-at91/board-qil-a9260.c
@@ -110,7 +110,7 @@ static struct spi_board_info ek_spi_devices[] = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA31,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-rm9200dk.c b/arch/arm/mach-at91/board-rm9200dk.c
index 4c1047c..c31cdda 100644
--- a/arch/arm/mach-at91/board-rm9200dk.c
+++ b/arch/arm/mach-at91/board-rm9200dk.c
@@ -70,7 +70,7 @@ static void __init dk_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata dk_eth_data = {
+static struct eth_platform_data __initdata dk_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-rm9200ek.c b/arch/arm/mach-at91/board-rm9200ek.c
index 9df1be8..0fe93aa 100644
--- a/arch/arm/mach-at91/board-rm9200ek.c
+++ b/arch/arm/mach-at91/board-rm9200ek.c
@@ -70,7 +70,7 @@ static void __init ek_init_irq(void)
 	at91rm9200_init_interrupts(NULL);
 }
 
-static struct at91_eth_data __initdata ek_eth_data = {
+static struct eth_platform_data __initdata ek_eth_data = {
 	.phy_irq_pin	= AT91_PIN_PC4,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index 25a26be..145884d 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -115,7 +115,7 @@ static struct spi_board_info ek_spi_devices[] = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA7,
 	.is_rmii	= 0,
 };
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index de1816e..fcaedf5 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -156,7 +156,7 @@ static struct spi_board_info ek_spi_devices[] = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA7,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index bfe490d..4f799a4 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -163,7 +163,7 @@ static struct at91_mmc_data __initdata ek_mmc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PE31,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index ca8198b..d54b3e6 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -128,7 +128,7 @@ static struct spi_board_info ek_spi_devices[] = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA7,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index 6c999db..7df85eb 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -120,7 +120,7 @@ static struct mci_platform_data __initdata mci1_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PD5,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-snapper9260.c b/arch/arm/mach-at91/board-snapper9260.c
index 17f7d9b..6902e7d 100644
--- a/arch/arm/mach-at91/board-snapper9260.c
+++ b/arch/arm/mach-at91/board-snapper9260.c
@@ -70,7 +70,7 @@ static struct at91_udc_data __initdata snapper9260_udc_data = {
 	.vbus_polled		= 1,
 };
 
-static struct at91_eth_data snapper9260_macb_data = {
+static struct eth_platform_data snapper9260_macb_data = {
 	.is_rmii	= 1,
 };
 
diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c
index f8902b1..9a7c586 100644
--- a/arch/arm/mach-at91/board-stamp9g20.c
+++ b/arch/arm/mach-at91/board-stamp9g20.c
@@ -163,7 +163,7 @@ static struct at91_udc_data __initdata stamp9g20evb_udc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata macb_data = {
+static struct eth_platform_data __initdata macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA28,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-usb-a9260.c b/arch/arm/mach-at91/board-usb-a9260.c
index 07784ba..c756389 100644
--- a/arch/arm/mach-at91/board-usb-a9260.c
+++ b/arch/arm/mach-at91/board-usb-a9260.c
@@ -84,7 +84,7 @@ static struct at91_udc_data __initdata ek_udc_data = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PA31,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-usb-a9263.c b/arch/arm/mach-at91/board-usb-a9263.c
index b614508..e6c260d 100644
--- a/arch/arm/mach-at91/board-usb-a9263.c
+++ b/arch/arm/mach-at91/board-usb-a9263.c
@@ -97,7 +97,7 @@ static struct spi_board_info ek_spi_devices[] = {
 /*
  * MACB Ethernet device
  */
-static struct at91_eth_data __initdata ek_macb_data = {
+static struct eth_platform_data __initdata ek_macb_data = {
 	.phy_irq_pin	= AT91_PIN_PE31,
 	.is_rmii	= 1,
 };
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index e0f0080..102dfc1 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -112,7 +112,7 @@ static struct gpio_led yl9200_leds[] = {
 /*
  * Ethernet
  */
-static struct at91_eth_data __initdata yl9200_eth_data = {
+static struct eth_platform_data __initdata yl9200_eth_data = {
 	.phy_irq_pin		= AT91_PIN_PB28,
 	.is_rmii		= 1,
 };
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 2b499eb..d970420 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -40,6 +40,7 @@
 #include <linux/atmel-mci.h>
 #include <sound/atmel-ac97c.h>
 #include <linux/serial.h>
+#include <linux/platform_data/macb.h>
 
  /* USB Device */
 struct at91_udc_data {
@@ -81,18 +82,7 @@ extern void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
   /* atmel-mci platform config */
 extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data);
 
- /* Ethernet (EMAC & MACB) */
-struct at91_eth_data {
-	u32		phy_mask;
-	u8		phy_irq_pin;	/* PHY IRQ */
-	u8		is_rmii;	/* using RMII interface? */
-};
-extern void __init at91_add_device_eth(struct at91_eth_data *data);
-
-#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9263) || defined(CONFIG_ARCH_AT91SAM9G20) || defined(CONFIG_ARCH_AT91CAP9) \
-	|| defined(CONFIG_ARCH_AT91SAM9G45) || defined(CONFIG_ARCH_AT572D940HF)
-#define eth_platform_data	at91_eth_data
-#endif
+extern void __init at91_add_device_eth(struct eth_platform_data *data);
 
  /* USB Host */
 struct at91_usbh_data {
diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h
index 6174020..3d79356 100644
--- a/arch/avr32/mach-at32ap/include/mach/board.h
+++ b/arch/avr32/mach-at32ap/include/mach/board.h
@@ -6,6 +6,7 @@
 
 #include <linux/types.h>
 #include <linux/serial.h>
+#include <linux/platform_data/macb.h>
 
 #define GPIO_PIN_NONE	(-1)
 
@@ -41,10 +42,6 @@ struct atmel_uart_data {
 void at32_map_usart(unsigned int hw_id, unsigned int line, int flags);
 struct platform_device *at32_add_device_usart(unsigned int id);
 
-struct eth_platform_data {
-	u32	phy_mask;
-	u8	is_rmii;
-};
 struct platform_device *
 at32_add_device_eth(unsigned int id, struct eth_platform_data *data);
 
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 79ccb54..bfd3601 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -18,12 +18,10 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/dma-mapping.h>
+#include <linux/platform_data/macb.h>
 #include <linux/platform_device.h>
 #include <linux/phy.h>
 
-#include <mach/board.h>
-#include <mach/cpu.h>
-
 #include "macb.h"
 
 #define RX_BUFFER_SIZE		128
diff --git a/include/linux/platform_data/macb.h b/include/linux/platform_data/macb.h
new file mode 100644
index 0000000..beddfd3
--- /dev/null
+++ b/include/linux/platform_data/macb.h
@@ -0,0 +1,10 @@
+#ifndef __MACB_PDATA_H__
+#define __MACB_PDATA_H__
+
+struct eth_platform_data {
+	u32		phy_mask;
+	u8		phy_irq_pin;	/* PHY IRQ */
+	u8		is_rmii;	/* using RMII interface? */
+};
+
+#endif /* __MACB_PDATA_H__ */
-- 
1.7.4


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

* [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
  2011-03-10 10:10 ` [PATCH 1/8] macb: unify at91 and avr32 platform data Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-10 10:15   ` Russell King - ARM Linux
  2011-03-11  1:44   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-10 10:10 ` [PATCH 3/8] macb: convert printk to pr_ and friends Jamie Iles
                   ` (5 subsequent siblings)
  7 siblings, 2 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

Rather than detecting whether we need to do a clk_get() and enable on
the "hclk" based on the kernel configuration, add an extra field to the
platform data.  This makes it cleaner to add more supported
architectures without lots of ifdeffery.

This requires that all instantiations of the device have platform data
defined but that is the case currently anyway.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 arch/avr32/mach-at32ap/at32ap700x.c |    2 +
 drivers/net/macb.c                  |   77 ++++++++++++++++++-----------------
 include/linux/platform_data/macb.h  |    1 +
 3 files changed, 43 insertions(+), 37 deletions(-)

diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index 2747cde..2abcafd 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1088,6 +1088,8 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
 	struct platform_device *pdev;
 	u32 pin_mask;
 
+	data->have_hclk = 1;
+
 	switch (id) {
 	case 0:
 		pdev = &macb0_device;
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index bfd3601..ae98fee 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -246,9 +246,7 @@ static int macb_mii_init(struct macb *bp)
 	bp->mii_bus->parent = &bp->dev->dev;
 	pdata = bp->pdev->dev.platform_data;
 
-	if (pdata)
-		bp->mii_bus->phy_mask = pdata->phy_mask;
-
+	bp->mii_bus->phy_mask = pdata->phy_mask;
 	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (!bp->mii_bus->irq) {
 		err = -ENOMEM;
@@ -1103,9 +1101,14 @@ static const struct net_device_ops macb_netdev_ops = {
 #endif
 };
 
+#ifdef CONFIG_ARCH_AT91
+#define PCLK_NAME	"macb_clk"
+#else /* CONFIG_ARCH_AT91 */
+#define PCLK_NAME	"pclk"
+#endif
+
 static int __init macb_probe(struct platform_device *pdev)
 {
-	struct eth_platform_data *pdata;
 	struct resource *regs;
 	struct net_device *dev;
 	struct macb *bp;
@@ -1113,6 +1116,7 @@ static int __init macb_probe(struct platform_device *pdev)
 	unsigned long pclk_hz;
 	u32 config;
 	int err = -ENXIO;
+	struct eth_platform_data *pdata;
 
 	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!regs) {
@@ -1120,6 +1124,13 @@ static int __init macb_probe(struct platform_device *pdev)
 		goto err_out;
 	}
 
+	err = -EINVAL;
+	pdata = dev_get_platdata(&pdev->dev);
+	if (!pdata) {
+		dev_err(&pdev->dev, "no platform data present\n");
+		goto err_out;
+	}
+
 	err = -ENOMEM;
 	dev = alloc_etherdev(sizeof(*bp));
 	if (!dev) {
@@ -1138,28 +1149,22 @@ static int __init macb_probe(struct platform_device *pdev)
 
 	spin_lock_init(&bp->lock);
 
-#if defined(CONFIG_ARCH_AT91)
-	bp->pclk = clk_get(&pdev->dev, "macb_clk");
+	bp->pclk = clk_get(&pdev->dev, PCLK_NAME);
 	if (IS_ERR(bp->pclk)) {
 		dev_err(&pdev->dev, "failed to get macb_clk\n");
 		goto err_out_free_dev;
 	}
 	clk_enable(bp->pclk);
-#else
-	bp->pclk = clk_get(&pdev->dev, "pclk");
-	if (IS_ERR(bp->pclk)) {
-		dev_err(&pdev->dev, "failed to get pclk\n");
-		goto err_out_free_dev;
-	}
-	bp->hclk = clk_get(&pdev->dev, "hclk");
-	if (IS_ERR(bp->hclk)) {
-		dev_err(&pdev->dev, "failed to get hclk\n");
-		goto err_out_put_pclk;
+
+	if (pdata->have_hclk) {
+		bp->hclk = clk_get(&pdev->dev, "hclk");
+		if (IS_ERR(bp->hclk)) {
+			dev_err(&pdev->dev, "failed to get hclk\n");
+			goto err_out_put_pclk;
+		}
+		clk_enable(bp->hclk);
 	}
 
-	clk_enable(bp->pclk);
-	clk_enable(bp->hclk);
-#endif
 
 	bp->regs = ioremap(regs->start, regs->end - regs->start + 1);
 	if (!bp->regs) {
@@ -1197,9 +1202,8 @@ static int __init macb_probe(struct platform_device *pdev)
 	macb_writel(bp, NCFGR, config);
 
 	macb_get_hwaddr(bp);
-	pdata = pdev->dev.platform_data;
 
-	if (pdata && pdata->is_rmii)
+	if (pdata->is_rmii)
 #if defined(CONFIG_ARCH_AT91)
 		macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)) );
 #else
@@ -1243,14 +1247,12 @@ err_out_free_irq:
 err_out_iounmap:
 	iounmap(bp->regs);
 err_out_disable_clocks:
-#ifndef CONFIG_ARCH_AT91
-	clk_disable(bp->hclk);
-	clk_put(bp->hclk);
-#endif
+	if (pdata->have_hclk) {
+		clk_disable(bp->hclk);
+		clk_put(bp->hclk);
+	}
 	clk_disable(bp->pclk);
-#ifndef CONFIG_ARCH_AT91
 err_out_put_pclk:
-#endif
 	clk_put(bp->pclk);
 err_out_free_dev:
 	free_netdev(dev);
@@ -1263,6 +1265,7 @@ static int __exit macb_remove(struct platform_device *pdev)
 {
 	struct net_device *dev;
 	struct macb *bp;
+	struct eth_platform_data *pdata = dev_get_platdata(&pdev->dev);
 
 	dev = platform_get_drvdata(pdev);
 
@@ -1276,10 +1279,10 @@ static int __exit macb_remove(struct platform_device *pdev)
 		unregister_netdev(dev);
 		free_irq(dev->irq, dev);
 		iounmap(bp->regs);
-#ifndef CONFIG_ARCH_AT91
-		clk_disable(bp->hclk);
-		clk_put(bp->hclk);
-#endif
+		if (pdata->have_hclk) {
+			clk_disable(bp->hclk);
+			clk_put(bp->hclk);
+		}
 		clk_disable(bp->pclk);
 		clk_put(bp->pclk);
 		free_netdev(dev);
@@ -1294,12 +1297,12 @@ static int macb_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct net_device *netdev = platform_get_drvdata(pdev);
 	struct macb *bp = netdev_priv(netdev);
+	struct eth_platform_data *pdata = dev_get_platdata(&pdev->dev);
 
 	netif_device_detach(netdev);
 
-#ifndef CONFIG_ARCH_AT91
-	clk_disable(bp->hclk);
-#endif
+	if (pdata->have_hclk)
+		clk_disable(bp->hclk);
 	clk_disable(bp->pclk);
 
 	return 0;
@@ -1309,11 +1312,11 @@ static int macb_resume(struct platform_device *pdev)
 {
 	struct net_device *netdev = platform_get_drvdata(pdev);
 	struct macb *bp = netdev_priv(netdev);
+	struct eth_platform_data *pdata = dev_get_platdata(&pdev->dev);
 
 	clk_enable(bp->pclk);
-#ifndef CONFIG_ARCH_AT91
-	clk_enable(bp->hclk);
-#endif
+	if (pdata->have_hclk)
+		clk_enable(bp->hclk);
 
 	netif_device_attach(netdev);
 
diff --git a/include/linux/platform_data/macb.h b/include/linux/platform_data/macb.h
index beddfd3..ae18579 100644
--- a/include/linux/platform_data/macb.h
+++ b/include/linux/platform_data/macb.h
@@ -5,6 +5,7 @@ struct eth_platform_data {
 	u32		phy_mask;
 	u8		phy_irq_pin;	/* PHY IRQ */
 	u8		is_rmii;	/* using RMII interface? */
+	int		have_hclk;	/* have hclk as well as pclk */
 };
 
 #endif /* __MACB_PDATA_H__ */
-- 
1.7.4


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

* [PATCH 3/8] macb: convert printk to pr_ and friends
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
  2011-03-10 10:10 ` [PATCH 1/8] macb: unify at91 and avr32 platform data Jamie Iles
  2011-03-10 10:10 ` [PATCH 2/8] macb: detect hclk presence from " Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-10 22:48   ` Joe Perches
  2011-03-11 12:53   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-10 10:10 ` [PATCH 4/8] macb: initial support for Cadence GEM Jamie Iles
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

macb is already using the dev_dbg() and friends helpers so use pr_foo()
along with a pr_fmt() definition to make the printing a little cleaner.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/net/macb.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index ae98fee..5d676ad 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#define pr_fmt(fmt) "macb: " fmt
 #include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -175,11 +176,11 @@ static void macb_handle_link_change(struct net_device *dev)
 
 	if (status_change) {
 		if (phydev->link)
-			printk(KERN_INFO "%s: link up (%d/%s)\n",
+			pr_info("%s: link up (%d/%s)\n",
 			       dev->name, phydev->speed,
 			       DUPLEX_FULL == phydev->duplex ? "Full":"Half");
 		else
-			printk(KERN_INFO "%s: link down\n", dev->name);
+			pr_info("%s: link down\n", dev->name);
 	}
 }
 
@@ -193,7 +194,7 @@ static int macb_mii_probe(struct net_device *dev)
 
 	phydev = phy_find_first(bp->mii_bus);
 	if (!phydev) {
-		printk (KERN_ERR "%s: no PHY found\n", dev->name);
+		pr_err("%s: no PHY found\n", dev->name);
 		return -1;
 	}
 
@@ -206,7 +207,7 @@ static int macb_mii_probe(struct net_device *dev)
 				 PHY_INTERFACE_MODE_RMII :
 				 PHY_INTERFACE_MODE_MII);
 	if (ret) {
-		printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
+		pr_err("%s: Could not attach to PHY\n", dev->name);
 		return ret;
 	}
 
@@ -303,7 +304,7 @@ static void macb_tx(struct macb *bp)
 
 	if (status & (MACB_BIT(UND) | MACB_BIT(TSR_RLE))) {
 		int i;
-		printk(KERN_ERR "%s: TX %s, resetting buffers\n",
+		pr_err("%s: TX %s, resetting buffers\n",
 			bp->dev->name, status & MACB_BIT(UND) ?
 			"underrun" : "retry limit exceeded");
 
@@ -574,10 +575,11 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id)
 
 		if (status & MACB_BIT(HRESP)) {
 			/*
-			 * TODO: Reset the hardware, and maybe move the printk
-			 * to a lower-priority context as well (work queue?)
+			 * TODO: Reset the hardware, and maybe move the
+			 * pr_err to a lower-priority context as well (work
+			 * queue?)
 			 */
-			printk(KERN_ERR "%s: DMA bus error: HRESP not OK\n",
+			pr_err("%s: DMA bus error: HRESP not OK\n",
 			       dev->name);
 		}
 
@@ -950,9 +952,8 @@ static int macb_open(struct net_device *dev)
 
 	err = macb_alloc_consistent(bp);
 	if (err) {
-		printk(KERN_ERR
-		       "%s: Unable to allocate DMA memory (error %d)\n",
-		       dev->name, err);
+		pr_err("%s: Unable to allocate DMA memory (error %d)\n",
+			 dev->name, err);
 		return err;
 	}
 
@@ -1177,9 +1178,8 @@ static int __init macb_probe(struct platform_device *pdev)
 	err = request_irq(dev->irq, macb_interrupt, IRQF_SAMPLE_RANDOM,
 			  dev->name, dev);
 	if (err) {
-		printk(KERN_ERR
-		       "%s: Unable to request IRQ %d (error %d)\n",
-		       dev->name, dev->irq, err);
+		pr_err("%s: Unable to request IRQ %d (error %d)\n",
+			 dev->name, dev->irq, err);
 		goto err_out_iounmap;
 	}
 
@@ -1230,11 +1230,11 @@ static int __init macb_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, dev);
 
-	printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d (%pM)\n",
-	       dev->name, dev->base_addr, dev->irq, dev->dev_addr);
+	pr_info("%s: Atmel MACB at 0x%08lx irq %d (%pM)\n",
+		dev->name, dev->base_addr, dev->irq, dev->dev_addr);
 
 	phydev = bp->phy_dev;
-	printk(KERN_INFO "%s: attached PHY driver [%s] "
+	pr_info("%s: attached PHY driver [%s] "
 		"(mii_bus:phy_addr=%s, irq=%d)\n", dev->name,
 		phydev->drv->name, dev_name(&phydev->dev), phydev->irq);
 
-- 
1.7.4


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

* [PATCH 4/8] macb: initial support for Cadence GEM
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
                   ` (2 preceding siblings ...)
  2011-03-10 10:10 ` [PATCH 3/8] macb: convert printk to pr_ and friends Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-11 13:14   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-10 10:10 ` [PATCH 5/8] macb: handle HW address registers for GEM devices Jamie Iles
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

The Cadence GEM is based on the MACB Ethernet controller but has a few
small changes with regards to register and bitfield placement.  This
patch adds a new platform driver for gem which sets allows the driver to
tell at runtime whether it is targetting a GEM device.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/net/Kconfig |    8 ++++--
 drivers/net/macb.c  |   53 ++++++++++++++++++++++++++++++++++++++++++--------
 drivers/net/macb.h  |   18 +++++++++++++++++
 3 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 6bd5caa..6de335a 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -223,12 +223,14 @@ menuconfig NET_ETHERNET
 if NET_ETHERNET
 
 config MACB
-	tristate "Atmel MACB support"
+	tristate "Cadence MACB/GEM support"
 	depends on HAVE_NET_MACB
 	select PHYLIB
 	help
-	  The Atmel MACB ethernet interface is found on many AT32 and AT91
-	  parts. Say Y to include support for the MACB chip.
+	  The Cadence MACB ethernet interface is found on many Atmel AT32 and
+	  AT91 parts.  This driver also supports the Cadence GEM (Gigabit
+	  Ethernet MAC found in some ARM SoC devices).  Note: the Gigabit mode
+	  is not yet supported.  Say Y to include support for the MACB/GEM chip.
 
 	  To compile this driver as a module, choose M here: the module
 	  will be called macb.
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 5d676ad..204afa6 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -1,5 +1,5 @@
 /*
- * Atmel MACB Ethernet Controller driver
+ * Cadence MACB/GEM Ethernet Controller driver
  *
  * Copyright (C) 2004-2006 Atmel Corporation
  *
@@ -7,7 +7,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
 #define pr_fmt(fmt) "macb: " fmt
 #include <linux/clk.h>
 #include <linux/module.h>
@@ -1108,7 +1107,7 @@ static const struct net_device_ops macb_netdev_ops = {
 #define PCLK_NAME	"pclk"
 #endif
 
-static int __init macb_probe(struct platform_device *pdev)
+static int __macb_probe(struct platform_device *pdev, int is_gem)
 {
 	struct resource *regs;
 	struct net_device *dev;
@@ -1147,6 +1146,7 @@ static int __init macb_probe(struct platform_device *pdev)
 	bp = netdev_priv(dev);
 	bp->pdev = pdev;
 	bp->dev = dev;
+	bp->is_gem = is_gem;
 
 	spin_lock_init(&bp->lock);
 
@@ -1230,8 +1230,9 @@ static int __init macb_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, dev);
 
-	pr_info("%s: Atmel MACB at 0x%08lx irq %d (%pM)\n",
-		dev->name, dev->base_addr, dev->irq, dev->dev_addr);
+	pr_info("%s: Cadence %s at 0x%08lx irq %d (%pM)\n",
+		dev->name, bp->is_gem ? "GEM" : "MACB", dev->base_addr,
+		dev->irq, dev->dev_addr);
 
 	phydev = bp->phy_dev;
 	pr_info("%s: attached PHY driver [%s] "
@@ -1261,7 +1262,17 @@ err_out:
 	return err;
 }
 
-static int __exit macb_remove(struct platform_device *pdev)
+static int __devinit macb_probe(struct platform_device *pdev)
+{
+	return __macb_probe(pdev, 0);
+}
+
+static int __devinit gem_probe(struct platform_device *pdev)
+{
+	return __macb_probe(pdev, 1);
+}
+
+static int __devexit macb_remove(struct platform_device *pdev)
 {
 	struct net_device *dev;
 	struct macb *bp;
@@ -1328,7 +1339,8 @@ static int macb_resume(struct platform_device *pdev)
 #endif
 
 static struct platform_driver macb_driver = {
-	.remove		= __exit_p(macb_remove),
+	.probe		= macb_probe,
+	.remove		= __devexit_p(macb_remove),
 	.suspend	= macb_suspend,
 	.resume		= macb_resume,
 	.driver		= {
@@ -1337,20 +1349,43 @@ static struct platform_driver macb_driver = {
 	},
 };
 
+static struct platform_driver gem_driver = {
+	.probe		= gem_probe,
+	.remove		= __devexit_p(macb_remove),
+	.suspend	= macb_suspend,
+	.resume		= macb_resume,
+	.driver		= {
+		.name		= "gem",
+		.owner	= THIS_MODULE,
+	},
+};
+
 static int __init macb_init(void)
 {
-	return platform_driver_probe(&macb_driver, macb_probe);
+	int ret;
+
+	ret = platform_driver_register(&macb_driver);
+	if (ret)
+		return ret;
+
+	ret = platform_driver_register(&gem_driver);
+	if (ret)
+		platform_driver_unregister(&macb_driver);
+
+	return ret;
+
 }
 
 static void __exit macb_exit(void)
 {
 	platform_driver_unregister(&macb_driver);
+	platform_driver_unregister(&gem_driver);
 }
 
 module_init(macb_init);
 module_exit(macb_exit);
 
 MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("Atmel MACB Ethernet driver");
+MODULE_DESCRIPTION("Cadence MACB/GEM Ethernet driver");
 MODULE_AUTHOR("Haavard Skinnemoen <hskinnemoen@atmel.com>");
 MODULE_ALIAS("platform:macb");
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index d3212f6..f838615 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -254,11 +254,28 @@
 		    << MACB_##name##_OFFSET))		\
 	 | MACB_BF(name,value))
 
+#define GEM_BIT(name)					\
+	(1 << GEM_##name##_OFFSET)
+#define GEM_BF(name,value)				\
+	(((value) & ((1 << GEM_##name##_SIZE) - 1))	\
+	 << GEM_##name##_OFFSET)
+#define GEM_BFEXT(name,value)\
+	(((value) >> GEM_##name##_OFFSET)		\
+	 & ((1 << GEM_##name##_SIZE) - 1))
+#define GEM_BFINS(name,value,old)			\
+	(((old) & ~(((1 << GEM_##name##_SIZE) - 1)	\
+		    << GEM_##name##_OFFSET))		\
+	 | GEM_BF(name,value))
+
 /* Register access macros */
 #define macb_readl(port,reg)				\
 	__raw_readl((port)->regs + MACB_##reg)
 #define macb_writel(port,reg,value)			\
 	__raw_writel((value), (port)->regs + MACB_##reg)
+#define gem_readl(port,reg)				\
+	__raw_readl((port)->regs + GEM_##reg)
+#define gem_writel(port,reg,value)			\
+	__raw_writel((value), (port)->regs + GEM_##reg)
 
 struct dma_desc {
 	u32	addr;
@@ -360,6 +377,7 @@ struct macb_stats {
 
 struct macb {
 	void __iomem		*regs;
+	int			is_gem;
 
 	unsigned int		rx_tail;
 	struct dma_desc		*rx_ring;
-- 
1.7.4


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

* [PATCH 5/8] macb: handle HW address registers for GEM devices
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
                   ` (3 preceding siblings ...)
  2011-03-10 10:10 ` [PATCH 4/8] macb: initial support for Cadence GEM Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-10 10:10 ` [PATCH 6/8] macb: support higher rate GEM MDIO clock divisors Jamie Iles
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

GEM has it's hardware address registers in a different location
to MACB so we need to make this conditional on type.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/net/macb.c |   19 +++++++++++++++----
 drivers/net/macb.h |    4 ++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 204afa6..2541e3b 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -57,9 +57,15 @@ static void __macb_set_hwaddr(struct macb *bp)
 	u16 top;
 
 	bottom = cpu_to_le32(*((u32 *)bp->dev->dev_addr));
-	macb_writel(bp, SA1B, bottom);
 	top = cpu_to_le16(*((u16 *)(bp->dev->dev_addr + 4)));
-	macb_writel(bp, SA1T, top);
+
+	if (!bp->is_gem) {
+		macb_writel(bp, SA1B, bottom);
+		macb_writel(bp, SA1T, top);
+	} else {
+		gem_writel(bp, SA1B, bottom);
+		gem_writel(bp, SA1T, top);
+	}
 }
 
 static void __init macb_get_hwaddr(struct macb *bp)
@@ -68,8 +74,13 @@ static void __init macb_get_hwaddr(struct macb *bp)
 	u16 top;
 	u8 addr[6];
 
-	bottom = macb_readl(bp, SA1B);
-	top = macb_readl(bp, SA1T);
+	if (!bp->is_gem) {
+		bottom = macb_readl(bp, SA1B);
+		top = macb_readl(bp, SA1T);
+	} else {
+		bottom = gem_readl(bp, SA1B);
+		top = gem_readl(bp, SA1T);
+	}
 
 	addr[0] = bottom & 0xff;
 	addr[1] = (bottom >> 8) & 0xff;
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index f838615..6248af6 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -60,6 +60,10 @@
 #define MACB_USRIO				0x00c0
 #define MACB_WOL				0x00c4
 
+/* GEM register offsets. */
+#define GEM_SA1B				0x0088
+#define GEM_SA1T				0x008C
+
 /* Bitfields in NCR */
 #define MACB_LB_OFFSET				0
 #define MACB_LB_SIZE				1
-- 
1.7.4


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

* [PATCH 6/8] macb: support higher rate GEM MDIO clock divisors
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
                   ` (4 preceding siblings ...)
  2011-03-10 10:10 ` [PATCH 5/8] macb: handle HW address registers for GEM devices Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-10 10:10 ` [PATCH 7/8] macb: support statistics for GEM devices Jamie Iles
  2011-03-10 10:10 ` [PATCH 8/8] macb: support data bus widths > 32 bits Jamie Iles
  7 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

GEM devices support larger clock divisors and have a different
range of divisors.  Program the MDIO clock divisors based on the
device type.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/net/macb.c |   49 ++++++++++++++++++++++++++++++++++++++++---------
 drivers/net/macb.h |   11 +++++++++++
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 2541e3b..dbc6e7ea 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -801,7 +801,8 @@ static void macb_init_hw(struct macb *bp)
 	macb_reset_hw(bp);
 	__macb_set_hwaddr(bp);
 
-	config = macb_readl(bp, NCFGR) & MACB_BF(CLK, -1L);
+	config = bp->is_gem ? macb_readl(bp, NCFGR) & GEM_BF(CLK, -1L) :
+		macb_readl(bp, NCFGR) & MACB_BF(CLK, -1L);
 	config |= MACB_BIT(PAE);		/* PAuse Enable */
 	config |= MACB_BIT(DRFCS);		/* Discard Rx FCS */
 	config |= MACB_BIT(BIG);		/* Receive oversized frames */
@@ -1118,6 +1119,42 @@ static const struct net_device_ops macb_netdev_ops = {
 #define PCLK_NAME	"pclk"
 #endif
 
+static u32 macb_mdc_clk_div(unsigned long pclk_hz)
+{
+	u32 config;
+
+	if (pclk_hz <= 20000000)
+		config = MACB_BF(CLK, MACB_CLK_DIV8);
+	else if (pclk_hz <= 40000000)
+		config = MACB_BF(CLK, MACB_CLK_DIV16);
+	else if (pclk_hz <= 80000000)
+		config = MACB_BF(CLK, MACB_CLK_DIV32);
+	else
+		config = MACB_BF(CLK, MACB_CLK_DIV64);
+
+	return config;
+}
+
+static u32 gem_mdc_clk_div(unsigned long pclk_hz)
+{
+	u32 config;
+
+	if (pclk_hz <= 20000000)
+		config = GEM_BF(CLK, GEM_CLK_DIV8);
+	else if (pclk_hz <= 40000000)
+		config = GEM_BF(CLK, GEM_CLK_DIV16);
+	else if (pclk_hz <= 80000000)
+		config = GEM_BF(CLK, GEM_CLK_DIV32);
+	else if (pclk_hz <= 120000000)
+		config = GEM_BF(CLK, GEM_CLK_DIV48);
+	else if (pclk_hz <= 160000000)
+		config = GEM_BF(CLK, GEM_CLK_DIV64);
+	else
+		config = GEM_BF(CLK, GEM_CLK_DIV96);
+
+	return config;
+}
+
 static int __macb_probe(struct platform_device *pdev, int is_gem)
 {
 	struct resource *regs;
@@ -1202,14 +1239,8 @@ static int __macb_probe(struct platform_device *pdev, int is_gem)
 
 	/* Set MII management clock divider */
 	pclk_hz = clk_get_rate(bp->pclk);
-	if (pclk_hz <= 20000000)
-		config = MACB_BF(CLK, MACB_CLK_DIV8);
-	else if (pclk_hz <= 40000000)
-		config = MACB_BF(CLK, MACB_CLK_DIV16);
-	else if (pclk_hz <= 80000000)
-		config = MACB_BF(CLK, MACB_CLK_DIV32);
-	else
-		config = MACB_BF(CLK, MACB_CLK_DIV64);
+	config = bp->is_gem ? gem_mdc_clk_div(pclk_hz) :
+		macb_mdc_clk_div(pclk_hz);
 	macb_writel(bp, NCFGR, config);
 
 	macb_get_hwaddr(bp);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 6248af6..4cd1e41 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -130,6 +130,9 @@
 #define MACB_IRXFCS_OFFSET			19
 #define MACB_IRXFCS_SIZE			1
 
+/* GEM specific NCFGR bitfields. */
+#define GEM_CLK_OFFSET				18
+#define GEM_CLK_SIZE				3
 /* Bitfields in NSR */
 #define MACB_NSR_LINK_OFFSET			0
 #define MACB_NSR_LINK_SIZE			1
@@ -238,6 +241,14 @@
 #define MACB_CLK_DIV32				2
 #define MACB_CLK_DIV64				3
 
+/* GEM specific constants for CLK. */
+#define GEM_CLK_DIV8				0
+#define GEM_CLK_DIV16				1
+#define GEM_CLK_DIV32				2
+#define GEM_CLK_DIV48				3
+#define GEM_CLK_DIV64				4
+#define GEM_CLK_DIV96				5
+
 /* Constants for MAN register */
 #define MACB_MAN_SOF				1
 #define MACB_MAN_WRITE				1
-- 
1.7.4


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

* [PATCH 7/8] macb: support statistics for GEM devices
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
                   ` (5 preceding siblings ...)
  2011-03-10 10:10 ` [PATCH 6/8] macb: support higher rate GEM MDIO clock divisors Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-10 10:10 ` [PATCH 8/8] macb: support data bus widths > 32 bits Jamie Iles
  7 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

GEM devices have a different number of statistics registers and they
are at a different offset to MACB devices.  Make the statistics
collection method dependent on device type.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/net/macb.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++--
 drivers/net/macb.h |   54 ++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index dbc6e7ea..2965405 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -291,8 +291,8 @@ err_out:
 static void macb_update_stats(struct macb *bp)
 {
 	u32 __iomem *reg = bp->regs + MACB_PFR;
-	u32 *p = &bp->hw_stats.rx_pause_frames;
-	u32 *end = &bp->hw_stats.tx_pause_frames + 1;
+	u32 *p = &bp->hw_stats.macb.rx_pause_frames;
+	u32 *end = &bp->hw_stats.macb.tx_pause_frames + 1;
 
 	WARN_ON((unsigned long)(end - p - 1) != (MACB_TPF - MACB_PFR) / 4);
 
@@ -1002,11 +1002,62 @@ static int macb_close(struct net_device *dev)
 	return 0;
 }
 
+static void gem_update_stats(struct macb *bp)
+{
+	u32 __iomem *reg = bp->regs + GEM_OTX;
+	u32 *p = &bp->hw_stats.gem.tx_octets_31_0;
+	u32 *end = &bp->hw_stats.gem.rx_udp_checksum_errors + 1;
+
+	for (; p < end; p++, reg++)
+		*p += __raw_readl(reg);
+}
+
+static struct net_device_stats *gem_get_stats(struct macb *bp)
+{
+	struct gem_stats *hwstat = &bp->hw_stats.gem;
+	struct net_device_stats *nstat = &bp->stats;
+
+	gem_update_stats(bp);
+
+	nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors +
+			    hwstat->rx_alignment_errors +
+			    hwstat->rx_resource_errors +
+			    hwstat->rx_overruns +
+			    hwstat->rx_oversize_frames +
+			    hwstat->rx_jabbers +
+			    hwstat->rx_undersized_frames +
+			    hwstat->rx_length_field_frame_errors);
+	nstat->tx_errors = (hwstat->tx_late_collisions +
+			    hwstat->tx_excessive_collisions +
+			    hwstat->tx_underrun +
+			    hwstat->tx_carrier_sense_errors);
+	nstat->multicast = hwstat->rx_multicast_frames;
+	nstat->collisions = (hwstat->tx_single_collision_frames +
+			     hwstat->tx_multiple_collision_frames +
+			     hwstat->tx_excessive_collisions);
+	nstat->rx_length_errors = (hwstat->rx_oversize_frames +
+				   hwstat->rx_jabbers +
+				   hwstat->rx_undersized_frames +
+				   hwstat->rx_length_field_frame_errors);
+	nstat->rx_over_errors = hwstat->rx_resource_errors;
+	nstat->rx_crc_errors = hwstat->rx_frame_check_sequence_errors;
+	nstat->rx_frame_errors = hwstat->rx_alignment_errors;
+	nstat->rx_fifo_errors = hwstat->rx_overruns;
+	nstat->tx_aborted_errors = hwstat->tx_excessive_collisions;
+	nstat->tx_carrier_errors = hwstat->tx_carrier_sense_errors;
+	nstat->tx_fifo_errors = hwstat->tx_underrun;
+
+	return nstat;
+}
+
 static struct net_device_stats *macb_get_stats(struct net_device *dev)
 {
 	struct macb *bp = netdev_priv(dev);
 	struct net_device_stats *nstat = &bp->stats;
-	struct macb_stats *hwstat = &bp->hw_stats;
+	struct macb_stats *hwstat = &bp->hw_stats.macb;
+
+	if (bp->is_gem)
+		return gem_get_stats(bp);
 
 	/* read stats from hardware */
 	macb_update_stats(bp);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index 4cd1e41..bc2e2c0 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -63,6 +63,7 @@
 /* GEM register offsets. */
 #define GEM_SA1B				0x0088
 #define GEM_SA1T				0x008C
+#define GEM_OTX					0x0100
 
 /* Bitfields in NCR */
 #define MACB_LB_OFFSET				0
@@ -390,6 +391,54 @@ struct macb_stats {
 	u32	tx_pause_frames;
 };
 
+struct gem_stats {
+	u32	tx_octets_31_0;
+	u32	tx_octets_47_32;
+	u32	tx_frames;
+	u32	tx_broadcast_frames;
+	u32	tx_multicast_frames;
+	u32	tx_pause_frames;
+	u32	tx_64_byte_frames;
+	u32	tx_65_127_byte_frames;
+	u32	tx_128_255_byte_frames;
+	u32	tx_256_511_byte_frames;
+	u32	tx_512_1023_byte_frames;
+	u32	tx_1024_1518_byte_frames;
+	u32	tx_greater_than_1518_byte_frames;
+	u32	tx_underrun;
+	u32	tx_single_collision_frames;
+	u32	tx_multiple_collision_frames;
+	u32	tx_excessive_collisions;
+	u32	tx_late_collisions;
+	u32	tx_deferred_frames;
+	u32	tx_carrier_sense_errors;
+	u32	rx_octets_31_0;
+	u32	rx_octets_47_32;
+	u32	rx_frames;
+	u32	rx_broadcast_frames;
+	u32	rx_multicast_frames;
+	u32	rx_pause_frames;
+	u32	rx_64_byte_frames;
+	u32	rx_65_127_byte_frames;
+	u32	rx_128_255_byte_frames;
+	u32	rx_256_511_byte_frames;
+	u32	rx_512_1023_byte_frames;
+	u32	rx_1024_1518_byte_frames;
+	u32	rx_greater_than_1518_byte_frames;
+	u32	rx_undersized_frames;
+	u32	rx_oversize_frames;
+	u32	rx_jabbers;
+	u32	rx_frame_check_sequence_errors;
+	u32	rx_length_field_frame_errors;
+	u32	rx_symbol_errors;
+	u32	rx_alignment_errors;
+	u32	rx_resource_errors;
+	u32	rx_overruns;
+	u32	rx_ip_header_checksum_errors;
+	u32	rx_tcp_checksum_errors;
+	u32	rx_udp_checksum_errors;
+};
+
 struct macb {
 	void __iomem		*regs;
 	int			is_gem;
@@ -409,7 +458,10 @@ struct macb {
 	struct net_device	*dev;
 	struct napi_struct	napi;
 	struct net_device_stats	stats;
-	struct macb_stats	hw_stats;
+	union {
+		struct macb_stats	macb;
+		struct gem_stats	gem;
+	}			hw_stats;
 
 	dma_addr_t		rx_ring_dma;
 	dma_addr_t		tx_ring_dma;
-- 
1.7.4


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

* [PATCH 8/8] macb: support data bus widths > 32 bits
  2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
                   ` (6 preceding siblings ...)
  2011-03-10 10:10 ` [PATCH 7/8] macb: support statistics for GEM devices Jamie Iles
@ 2011-03-10 10:10 ` Jamie Iles
  2011-03-11 12:55   ` Jean-Christophe PLAGNIOL-VILLARD
  7 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 10:10 UTC (permalink / raw)
  To: netdev, linux-arm-kernel; +Cc: nicolas.ferre, Jamie Iles

Some GEM implementations may support data bus widths up to 128 bits.
Allow the platform data to specify the data bus width and let the driver
program it up.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/net/macb.c                 |    5 +++++
 drivers/net/macb.h                 |    3 +++
 include/linux/platform_data/macb.h |    6 ++++++
 3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 2965405..6ecbd69 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -797,6 +797,7 @@ static void macb_reset_hw(struct macb *bp)
 static void macb_init_hw(struct macb *bp)
 {
 	u32 config;
+	struct eth_platform_data *pdata = dev_get_platdata(&bp->pdev->dev);
 
 	macb_reset_hw(bp);
 	__macb_set_hwaddr(bp);
@@ -810,6 +811,8 @@ static void macb_init_hw(struct macb *bp)
 		config |= MACB_BIT(CAF);	/* Copy All Frames */
 	if (!(bp->dev->flags & IFF_BROADCAST))
 		config |= MACB_BIT(NBC);	/* No BroadCast */
+	if (bp->is_gem)
+		config |= GEM_BF(DBW, pdata->dbw);	/* Data bus width. */
 	macb_writel(bp, NCFGR, config);
 
 	/* Initialize TX and RX buffers */
@@ -1292,6 +1295,8 @@ static int __macb_probe(struct platform_device *pdev, int is_gem)
 	pclk_hz = clk_get_rate(bp->pclk);
 	config = bp->is_gem ? gem_mdc_clk_div(pclk_hz) :
 		macb_mdc_clk_div(pclk_hz);
+	if (bp->is_gem)
+		config |= GEM_BF(DBW, pdata->dbw);	/* Data bus width. */
 	macb_writel(bp, NCFGR, config);
 
 	macb_get_hwaddr(bp);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index bc2e2c0..cd63c1b 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -134,6 +134,9 @@
 /* GEM specific NCFGR bitfields. */
 #define GEM_CLK_OFFSET				18
 #define GEM_CLK_SIZE				3
+#define GEM_DBW_OFFSET				21
+#define GEM_DBW_SIZE				2
+
 /* Bitfields in NSR */
 #define MACB_NSR_LINK_OFFSET			0
 #define MACB_NSR_LINK_SIZE			1
diff --git a/include/linux/platform_data/macb.h b/include/linux/platform_data/macb.h
index ae18579..d11bfab 100644
--- a/include/linux/platform_data/macb.h
+++ b/include/linux/platform_data/macb.h
@@ -1,11 +1,17 @@
 #ifndef __MACB_PDATA_H__
 #define __MACB_PDATA_H__
 
+/* Constants for data bus width. */
+#define MACB_DBW32				0
+#define MACB_DBW64				1
+#define MACB_DBW128				2
+
 struct eth_platform_data {
 	u32		phy_mask;
 	u8		phy_irq_pin;	/* PHY IRQ */
 	u8		is_rmii;	/* using RMII interface? */
 	int		have_hclk;	/* have hclk as well as pclk */
+	u8		dbw;		/* Data bus width. */
 };
 
 #endif /* __MACB_PDATA_H__ */
-- 
1.7.4


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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-10 10:10 ` [PATCH 2/8] macb: detect hclk presence from " Jamie Iles
@ 2011-03-10 10:15   ` Russell King - ARM Linux
  2011-03-10 11:41     ` Jamie Iles
  2011-03-11  1:44   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 34+ messages in thread
From: Russell King - ARM Linux @ 2011-03-10 10:15 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On Thu, Mar 10, 2011 at 10:10:37AM +0000, Jamie Iles wrote:
> Rather than detecting whether we need to do a clk_get() and enable on
> the "hclk" based on the kernel configuration, add an extra field to the
> platform data.  This makes it cleaner to add more supported
> architectures without lots of ifdeffery.

Why not have the platform provide a dummy hclk if no real hclk exists?

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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-10 10:15   ` Russell King - ARM Linux
@ 2011-03-10 11:41     ` Jamie Iles
  2011-03-10 11:45       ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 11:41 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Jamie Iles, netdev, linux-arm-kernel, nicolas.ferre

On Thu, Mar 10, 2011 at 10:15:54AM +0000, Russell King - ARM Linux wrote:
> On Thu, Mar 10, 2011 at 10:10:37AM +0000, Jamie Iles wrote:
> > Rather than detecting whether we need to do a clk_get() and enable on
> > the "hclk" based on the kernel configuration, add an extra field to the
> > platform data.  This makes it cleaner to add more supported
> > architectures without lots of ifdeffery.
> 
> Why not have the platform provide a dummy hclk if no real hclk exists?

Yes, that would be much better.  In that case, this patch can be 
replaced with the two below.  I'll repost the series with the other 
patches refreshed, but I'd like someone with AT91 knowledge to check 
that at91_clock_associate() is doing what I think it is first.

This also means that the driver doesn't need a conditional on ARCH_AT91 
for the pclk name.

Jamie

>From 11dc6ca059e848295db8c0c534ece196e8f9ff37 Mon Sep 17 00:00:00 2001
From: Jamie Iles <jamie@jamieiles.com>
Date: Thu, 10 Mar 2011 11:11:20 +0000
Subject: [PATCH 1/2] at91: provide pclk and hclk for macb ethernet devices

AT91 has a "macb_pclk" which is used to control the clock to the
Ethernet controller, but this is a different name to the AVR32
devices that use "pclk".  Associate the clock with the names "pclk"
and "hclk" and the macb driver doesn't need to handle the two
architectures differently.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 arch/arm/mach-at91/at572d940hf_devices.c |    3 +++
 arch/arm/mach-at91/at91cap9_devices.c    |    3 +++
 arch/arm/mach-at91/at91rm9200_devices.c  |    3 +++
 arch/arm/mach-at91/at91sam9260_devices.c |    3 +++
 arch/arm/mach-at91/at91sam9263_devices.c |    3 +++
 arch/arm/mach-at91/at91sam9g45_devices.c |    3 +++
 6 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-at91/at572d940hf_devices.c b/arch/arm/mach-at91/at572d940hf_devices.c
index 6e1b9a3..9234b4e 100644
--- a/arch/arm/mach-at91/at572d940hf_devices.c
+++ b/arch/arm/mach-at91/at572d940hf_devices.c
@@ -192,6 +192,9 @@ void __init at91_add_device_eth(struct eth_platform_data *data)
 	at91_set_A_periph(AT91_PIN_PA13, 0);	/* EMDIO */
 	at91_set_A_periph(AT91_PIN_PA14, 0);	/* EMDC */
 
+	at91_clock_associate("macb_clk", &at572d940hf_eth_device.dev, "pclk");
+	at91_clock_associate("macb_clk", &at572d940hf_eth_device.dev, "hclk");
+
 	eth_data = *data;
 	platform_device_register(&at572d940hf_eth_device);
 }
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index e041743..5c57885 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -258,6 +258,9 @@ void __init at91_add_device_eth(struct eth_platform_data *data)
 		at91_set_B_periph(AT91_PIN_PC24, 0);	/* ETXER */
 	}
 
+	at91_clock_associate("macb_clk", &at91cap9_eth_device.dev, "pclk");
+	at91_clock_associate("macb_clk", &at91cap9_eth_device.dev, "hclk");
+
 	eth_data = *data;
 	platform_device_register(&at91cap9_eth_device);
 }
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 5f873d5..e7b8ec3 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -187,6 +187,9 @@ void __init at91_add_device_eth(struct eth_platform_data *data)
 		at91_set_B_periph(AT91_PIN_PB12, 0);	/* ETX2 */
 	}
 
+	at91_clock_associate("macb_clk", &at91rm9200_eth_device.dev, "pclk");
+	at91_clock_associate("macb_clk", &at91rm9200_eth_device.dev, "hclk");
+
 	eth_data = *data;
 	platform_device_register(&at91rm9200_eth_device);
 }
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index e172b46..9ff8592 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -188,6 +188,9 @@ void __init at91_add_device_eth(struct eth_platform_data *data)
 		at91_set_B_periph(AT91_PIN_PA22, 0);	/* ETXER */
 	}
 
+	at91_clock_associate("macb_clk", &at91sam9260_eth_device.dev, "pclk");
+	at91_clock_associate("macb_clk", &at91sam9260_eth_device.dev, "hclk");
+
 	eth_data = *data;
 	platform_device_register(&at91sam9260_eth_device);
 }
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 416613c..46560e9 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -198,6 +198,9 @@ void __init at91_add_device_eth(struct eth_platform_data *data)
 		at91_set_B_periph(AT91_PIN_PC24, 0);	/* ETXER */
 	}
 
+	at91_clock_associate("macb_clk", &at91sam9263_eth_device.dev, "pclk");
+	at91_clock_associate("macb_clk", &at91sam9263_eth_device.dev, "hclk");
+
 	eth_data = *data;
 	platform_device_register(&at91sam9263_eth_device);
 }
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 0867343..ab46ae7 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -343,6 +343,9 @@ void __init at91_add_device_eth(struct eth_platform_data *data)
 		at91_set_B_periph(AT91_PIN_PA27, 0);	/* ETXER */
 	}
 
+	at91_clock_associate("macb_clk", &at91sam9g45_eth_device.dev, "pclk");
+	at91_clock_associate("macb_clk", &at91sam9g45_eth_device.dev, "hclk");
+
 	eth_data = *data;
 	platform_device_register(&at91sam9g45_eth_device);
 }
-- 
1.7.4

>From 7dfd4a15bbb0b5c14be44ebc54c3038423086418 Mon Sep 17 00:00:00 2001
From: Jamie Iles <jamie@jamieiles.com>
Date: Tue, 8 Mar 2011 20:19:23 +0000
Subject: [PATCH 2/2] macb: remove conditional clk handling

AT91 now provides both "pclk" and "hclk" aliases for the the macb
device so we can use the same clk handling paths for both AT91 and
AVR32.

Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
 drivers/net/macb.c |   27 +++------------------------
 1 files changed, 3 insertions(+), 24 deletions(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index bfd3601..8e6d8e3 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -246,9 +246,7 @@ static int macb_mii_init(struct macb *bp)
 	bp->mii_bus->parent = &bp->dev->dev;
 	pdata = bp->pdev->dev.platform_data;
 
-	if (pdata)
-		bp->mii_bus->phy_mask = pdata->phy_mask;
-
+	bp->mii_bus->phy_mask = pdata->phy_mask;
 	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
 	if (!bp->mii_bus->irq) {
 		err = -ENOMEM;
@@ -1138,28 +1136,19 @@ static int __init macb_probe(struct platform_device *pdev)
 
 	spin_lock_init(&bp->lock);
 
-#if defined(CONFIG_ARCH_AT91)
-	bp->pclk = clk_get(&pdev->dev, "macb_clk");
+	bp->pclk = clk_get(&pdev->dev, "pclk");
 	if (IS_ERR(bp->pclk)) {
 		dev_err(&pdev->dev, "failed to get macb_clk\n");
 		goto err_out_free_dev;
 	}
 	clk_enable(bp->pclk);
-#else
-	bp->pclk = clk_get(&pdev->dev, "pclk");
-	if (IS_ERR(bp->pclk)) {
-		dev_err(&pdev->dev, "failed to get pclk\n");
-		goto err_out_free_dev;
-	}
+
 	bp->hclk = clk_get(&pdev->dev, "hclk");
 	if (IS_ERR(bp->hclk)) {
 		dev_err(&pdev->dev, "failed to get hclk\n");
 		goto err_out_put_pclk;
 	}
-
-	clk_enable(bp->pclk);
 	clk_enable(bp->hclk);
-#endif
 
 	bp->regs = ioremap(regs->start, regs->end - regs->start + 1);
 	if (!bp->regs) {
@@ -1243,14 +1232,10 @@ err_out_free_irq:
 err_out_iounmap:
 	iounmap(bp->regs);
 err_out_disable_clocks:
-#ifndef CONFIG_ARCH_AT91
 	clk_disable(bp->hclk);
 	clk_put(bp->hclk);
-#endif
 	clk_disable(bp->pclk);
-#ifndef CONFIG_ARCH_AT91
 err_out_put_pclk:
-#endif
 	clk_put(bp->pclk);
 err_out_free_dev:
 	free_netdev(dev);
@@ -1276,10 +1261,8 @@ static int __exit macb_remove(struct platform_device *pdev)
 		unregister_netdev(dev);
 		free_irq(dev->irq, dev);
 		iounmap(bp->regs);
-#ifndef CONFIG_ARCH_AT91
 		clk_disable(bp->hclk);
 		clk_put(bp->hclk);
-#endif
 		clk_disable(bp->pclk);
 		clk_put(bp->pclk);
 		free_netdev(dev);
@@ -1297,9 +1280,7 @@ static int macb_suspend(struct platform_device *pdev, pm_message_t state)
 
 	netif_device_detach(netdev);
 
-#ifndef CONFIG_ARCH_AT91
 	clk_disable(bp->hclk);
-#endif
 	clk_disable(bp->pclk);
 
 	return 0;
@@ -1311,9 +1292,7 @@ static int macb_resume(struct platform_device *pdev)
 	struct macb *bp = netdev_priv(netdev);
 
 	clk_enable(bp->pclk);
-#ifndef CONFIG_ARCH_AT91
 	clk_enable(bp->hclk);
-#endif
 
 	netif_device_attach(netdev);
 
-- 
1.7.4


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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-10 11:41     ` Jamie Iles
@ 2011-03-10 11:45       ` Jamie Iles
  0 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 11:45 UTC (permalink / raw)
  To: Jamie Iles
  Cc: Russell King - ARM Linux, netdev, linux-arm-kernel, nicolas.ferre

On Thu, Mar 10, 2011 at 11:41:37AM +0000, Jamie Iles wrote:
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index bfd3601..8e6d8e3 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -246,9 +246,7 @@ static int macb_mii_init(struct macb *bp)
>  	bp->mii_bus->parent = &bp->dev->dev;
>  	pdata = bp->pdev->dev.platform_data;
>  
> -	if (pdata)
> -		bp->mii_bus->phy_mask = pdata->phy_mask;
> -
> +	bp->mii_bus->phy_mask = pdata->phy_mask;
>  	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
>  	if (!bp->mii_bus->irq) {
>  		err = -ENOMEM;

Doh, too hasty.  That hunk shouldn't be there now.  I'll fix that up for 
next time.

Jamie

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-10 10:10 ` [PATCH 1/8] macb: unify at91 and avr32 platform data Jamie Iles
@ 2011-03-10 13:06   ` Nicolas Ferre
  2011-03-10 13:17     ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Nicolas Ferre @ 2011-03-10 13:06 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel

On 3/10/2011 11:10 AM, Jamie Iles :
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -18,12 +18,10 @@
>  #include <linux/netdevice.h>
>  #include <linux/etherdevice.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/platform_data/macb.h>
>  #include <linux/platform_device.h>
>  #include <linux/phy.h>
>  
> -#include <mach/board.h>
> -#include <mach/cpu.h>

I did not bouble check but do we need no more cpu_is_ macros?

> -
>  #include "macb.h"
>  
>  #define RX_BUFFER_SIZE		128

-- 
Nicolas Ferre

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-10 13:06   ` Nicolas Ferre
@ 2011-03-10 13:17     ` Jamie Iles
  2011-03-11  1:41       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-10 13:17 UTC (permalink / raw)
  To: Nicolas Ferre; +Cc: Jamie Iles, netdev, linux-arm-kernel

On Thu, Mar 10, 2011 at 02:06:04PM +0100, Nicolas Ferre wrote:
> On 3/10/2011 11:10 AM, Jamie Iles :
> > --- a/drivers/net/macb.c
> > +++ b/drivers/net/macb.c
> > @@ -18,12 +18,10 @@
> >  #include <linux/netdevice.h>
> >  #include <linux/etherdevice.h>
> >  #include <linux/dma-mapping.h>
> > +#include <linux/platform_data/macb.h>
> >  #include <linux/platform_device.h>
> >  #include <linux/phy.h>
> >  
> > -#include <mach/board.h>
> > -#include <mach/cpu.h>
> 
> I did not bouble check but do we need no more cpu_is_ macros?

No, I couldn't see any in there and it builds for all of the AT91 
targets and all of the AVR32 ones that I tried.  I can't see any macros 
in there that are likely to use cpu_is_* internally either.

Jamie

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

* Re: [PATCH 3/8] macb: convert printk to pr_ and friends
  2011-03-10 10:10 ` [PATCH 3/8] macb: convert printk to pr_ and friends Jamie Iles
@ 2011-03-10 22:48   ` Joe Perches
  2011-03-11  0:09     ` Jamie Iles
  2011-03-11 12:53   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 1 reply; 34+ messages in thread
From: Joe Perches @ 2011-03-10 22:48 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On Thu, 2011-03-10 at 10:10 +0000, Jamie Iles wrote:
> macb is already using the dev_dbg() and friends helpers so use pr_foo()
> along with a pr_fmt() definition to make the printing a little cleaner.
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>

Hi Jamie.

Because these conversions use a struct net_device,
they would be better as:

	netdev_<foo>(struct net_device *dev, const char *fmt, ...)

> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> @@ -175,11 +176,11 @@ static void macb_handle_link_change(struct net_device *dev)
>  
>  	if (status_change) {
>  		if (phydev->link)
> -			printk(KERN_INFO "%s: link up (%d/%s)\n",
> +			pr_info("%s: link up (%d/%s)\n",
>  			       dev->name, phydev->speed,
>  			       DUPLEX_FULL == phydev->duplex ? "Full":"Half");

			netdev_info(dev, "link up (%d/%s)\n",
				    phydev->speed,
				    phydev->duplex == DUPLEX_FULL ? "Full" : "Half");
 
>  		else
> -			printk(KERN_INFO "%s: link down\n", dev->name);
> +			pr_info("%s: link down\n", dev->name);

			netdev_info(dev, "link down\n");

> @@ -193,7 +194,7 @@ static int macb_mii_probe(struct net_device *dev)
>  
>  	phydev = phy_find_first(bp->mii_bus);
>  	if (!phydev) {
> -		printk (KERN_ERR "%s: no PHY found\n", dev->name);
> +		pr_err("%s: no PHY found\n", dev->name);

		netdev_err(dev, "no PHY found\n");

> @@ -206,7 +207,7 @@ static int macb_mii_probe(struct net_device *dev)
>  				 PHY_INTERFACE_MODE_RMII :
>  				 PHY_INTERFACE_MODE_MII);
>  	if (ret) {
> -		printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
> +		pr_err("%s: Could not attach to PHY\n", dev->name);

		netdev_err(dev, "could not attach to PHY\n");

etc...



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

* Re: [PATCH 3/8] macb: convert printk to pr_ and friends
  2011-03-10 22:48   ` Joe Perches
@ 2011-03-11  0:09     ` Jamie Iles
  0 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-11  0:09 UTC (permalink / raw)
  To: Joe Perches; +Cc: Jamie Iles, netdev, linux-arm-kernel, nicolas.ferre

On Thu, Mar 10, 2011 at 02:48:04PM -0800, Joe Perches wrote:
> On Thu, 2011-03-10 at 10:10 +0000, Jamie Iles wrote:
> > macb is already using the dev_dbg() and friends helpers so use pr_foo()
> > along with a pr_fmt() definition to make the printing a little cleaner.
> > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> 
> Hi Jamie.
> 
> Because these conversions use a struct net_device,
> they would be better as:
> 
> 	netdev_<foo>(struct net_device *dev, const char *fmt, ...)

Ahh nice, I hadn't come across those before.  I'll update all of the 
pr_* and dev_* statements to use the netdev variants.

Thanks for that!

Jamie

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-10 13:17     ` Jamie Iles
@ 2011-03-11  1:41       ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11  8:56         ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11  1:41 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, Nicolas Ferre, linux-arm-kernel

On 13:17 Thu 10 Mar     , Jamie Iles wrote:
> On Thu, Mar 10, 2011 at 02:06:04PM +0100, Nicolas Ferre wrote:
> > On 3/10/2011 11:10 AM, Jamie Iles :
> > > --- a/drivers/net/macb.c
> > > +++ b/drivers/net/macb.c
> > > @@ -18,12 +18,10 @@
> > >  #include <linux/netdevice.h>
> > >  #include <linux/etherdevice.h>
> > >  #include <linux/dma-mapping.h>
> > > +#include <linux/platform_data/macb.h>
> > >  #include <linux/platform_device.h>
> > >  #include <linux/phy.h>
> > >  
> > > -#include <mach/board.h>
> > > -#include <mach/cpu.h>
> > 
> > I did not bouble check but do we need no more cpu_is_ macros?
> 
> No, I couldn't see any in there and it builds for all of the AT91 
> targets and all of the AVR32 ones that I tried.  I can't see any macros 
> in there that are likely to use cpu_is_* internally either.
keep as we need to remove the #ifdef AT91 to cpu_is

I've patch for this

Best Regards,
J.

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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-10 10:10 ` [PATCH 2/8] macb: detect hclk presence from " Jamie Iles
  2011-03-10 10:15   ` Russell King - ARM Linux
@ 2011-03-11  1:44   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11  8:54     ` Jamie Iles
  1 sibling, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11  1:44 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, nicolas.ferre, linux-arm-kernel

On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> Rather than detecting whether we need to do a clk_get() and enable on
> the "hclk" based on the kernel configuration, add an extra field to the
> platform data.  This makes it cleaner to add more supported
> architectures without lots of ifdeffery.
> 
> This requires that all instantiations of the device have platform data
> defined but that is the case currently anyway.
> 
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> ---
>  arch/avr32/mach-at32ap/at32ap700x.c |    2 +
>  drivers/net/macb.c                  |   77 ++++++++++++++++++-----------------
>  include/linux/platform_data/macb.h  |    1 +
>  3 files changed, 43 insertions(+), 37 deletions(-)
> 
> diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
> index 2747cde..2abcafd 100644
> --- a/arch/avr32/mach-at32ap/at32ap700x.c
> +++ b/arch/avr32/mach-at32ap/at32ap700x.c
> @@ -1088,6 +1088,8 @@ at32_add_device_eth(unsigned int id, struct eth_platform_data *data)
>  	struct platform_device *pdev;
>  	u32 pin_mask;
>  
> +	data->have_hclk = 1;
> +
>  	switch (id) {
>  	case 0:
>  		pdev = &macb0_device;
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index bfd3601..ae98fee 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -246,9 +246,7 @@ static int macb_mii_init(struct macb *bp)
>  	bp->mii_bus->parent = &bp->dev->dev;
>  	pdata = bp->pdev->dev.platform_data;
>  
> -	if (pdata)
> -		bp->mii_bus->phy_mask = pdata->phy_mask;
> -
> +	bp->mii_bus->phy_mask = pdata->phy_mask;
>  	bp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
>  	if (!bp->mii_bus->irq) {
>  		err = -ENOMEM;
> @@ -1103,9 +1101,14 @@ static const struct net_device_ops macb_netdev_ops = {
>  #endif
>  };
>  
> +#ifdef CONFIG_ARCH_AT91
> +#define PCLK_NAME	"macb_clk"
> +#else /* CONFIG_ARCH_AT91 */
> +#define PCLK_NAME	"pclk"
> +#endif

we need change the clock name and avoid the ifdef
so this will be generic

nb I work on the switch to clkdev currently for avr32 and at91

Best Regards,
J.

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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-11  1:44   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11  8:54     ` Jamie Iles
  2011-03-11 12:47       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-11  8:54 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, netdev, linux-arm-kernel, nicolas.ferre

On Fri, Mar 11, 2011 at 02:44:00AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > +#ifdef CONFIG_ARCH_AT91
> > +#define PCLK_NAME	"macb_clk"
> > +#else /* CONFIG_ARCH_AT91 */
> > +#define PCLK_NAME	"pclk"
> > +#endif
> 
> we need change the clock name and avoid the ifdef
> so this will be generic
> 
> nb I work on the switch to clkdev currently for avr32 and at91

This should be gone now.  Russell made the suggestion to have a fake clk 
for hclk on AT91 so I think I've solved that now.  There's an updated 
patch in my reply to Russell's message but essentially I'm using 
at91_clock_associate() to turn "macb_pclk" into "hclk" and "pclk".  Does 
this seem reasonable?

Jamie

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-11  1:41       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11  8:56         ` Jamie Iles
  2011-03-11 12:52           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-11  8:56 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, Nicolas Ferre, netdev, linux-arm-kernel

On Fri, Mar 11, 2011 at 02:41:40AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 13:17 Thu 10 Mar     , Jamie Iles wrote:
> > On Thu, Mar 10, 2011 at 02:06:04PM +0100, Nicolas Ferre wrote:
> > > On 3/10/2011 11:10 AM, Jamie Iles :
> > > > --- a/drivers/net/macb.c
> > > > +++ b/drivers/net/macb.c
> > > > @@ -18,12 +18,10 @@
> > > >  #include <linux/netdevice.h>
> > > >  #include <linux/etherdevice.h>
> > > >  #include <linux/dma-mapping.h>
> > > > +#include <linux/platform_data/macb.h>
> > > >  #include <linux/platform_device.h>
> > > >  #include <linux/phy.h>
> > > >  
> > > > -#include <mach/board.h>
> > > > -#include <mach/cpu.h>
> > > 
> > > I did not bouble check but do we need no more cpu_is_ macros?
> > 
> > No, I couldn't see any in there and it builds for all of the AT91 
> > targets and all of the AVR32 ones that I tried.  I can't see any macros 
> > in there that are likely to use cpu_is_* internally either.
>
> keep as we need to remove the #ifdef AT91 to cpu_is
> 
> I've patch for this

Is this for the user IO register where the value written is conditional 
on both RMII/MII and arch type?

Jamie

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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-11  8:54     ` Jamie Iles
@ 2011-03-11 12:47       ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11 13:08         ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 12:47 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On 08:54 Fri 11 Mar     , Jamie Iles wrote:
> On Fri, Mar 11, 2011 at 02:44:00AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > > +#ifdef CONFIG_ARCH_AT91
> > > +#define PCLK_NAME	"macb_clk"
> > > +#else /* CONFIG_ARCH_AT91 */
> > > +#define PCLK_NAME	"pclk"
> > > +#endif
> > 
> > we need change the clock name and avoid the ifdef
> > so this will be generic
> > 
> > nb I work on the switch to clkdev currently for avr32 and at91
> 
> This should be gone now.  Russell made the suggestion to have a fake clk 
> for hclk on AT91 so I think I've solved that now.  There's an updated 
> patch in my reply to Russell's message but essentially I'm using 
> at91_clock_associate() to turn "macb_pclk" into "hclk" and "pclk".  Does 
> this seem reasonable?
please do not use at91_clock_associate as I'm going to remove it as use static
clock as done on shmobile as example
so if it's a fake clock please as ochi_clk on 9g45

Best Regards,
J.

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-11  8:56         ` Jamie Iles
@ 2011-03-11 12:52           ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11 13:25             ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 12:52 UTC (permalink / raw)
  To: Jamie Iles; +Cc: Nicolas Ferre, netdev, linux-arm-kernel

On 08:56 Fri 11 Mar     , Jamie Iles wrote:
> On Fri, Mar 11, 2011 at 02:41:40AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 13:17 Thu 10 Mar     , Jamie Iles wrote:
> > > On Thu, Mar 10, 2011 at 02:06:04PM +0100, Nicolas Ferre wrote:
> > > > On 3/10/2011 11:10 AM, Jamie Iles :
> > > > > --- a/drivers/net/macb.c
> > > > > +++ b/drivers/net/macb.c
> > > > > @@ -18,12 +18,10 @@
> > > > >  #include <linux/netdevice.h>
> > > > >  #include <linux/etherdevice.h>
> > > > >  #include <linux/dma-mapping.h>
> > > > > +#include <linux/platform_data/macb.h>
> > > > >  #include <linux/platform_device.h>
> > > > >  #include <linux/phy.h>
> > > > >  
> > > > > -#include <mach/board.h>
> > > > > -#include <mach/cpu.h>
> > > > 
> > > > I did not bouble check but do we need no more cpu_is_ macros?
> > > 
> > > No, I couldn't see any in there and it builds for all of the AT91 
> > > targets and all of the AVR32 ones that I tried.  I can't see any macros 
> > > in there that are likely to use cpu_is_* internally either.
> >
> > keep as we need to remove the #ifdef AT91 to cpu_is
> > 
> > I've patch for this
> 
> Is this for the user IO register where the value written is conditional 
> on both RMII/MII and arch type?
yes for 

#if defined(CONFIG_ARCH_AT91)
		macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)));
#else
		macb_writel(bp, USRIO, 0);
#endif
	else
#if defined(CONFIG_ARCH_AT91)
		macb_writel(bp, USRIO, MACB_BIT(CLKEN));
#else
		macb_writel(bp, USRIO, MACB_BIT(MII));
#endif

Best Regards,
J.

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

* Re: [PATCH 3/8] macb: convert printk to pr_ and friends
  2011-03-10 10:10 ` [PATCH 3/8] macb: convert printk to pr_ and friends Jamie Iles
  2011-03-10 22:48   ` Joe Perches
@ 2011-03-11 12:53   ` Jean-Christophe PLAGNIOL-VILLARD
  1 sibling, 0 replies; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 12:53 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> macb is already using the dev_dbg() and friends helpers so use pr_foo()
> along with a pr_fmt() definition to make the printing a little cleaner.
> 
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.

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

* Re: [PATCH 8/8] macb: support data bus widths > 32 bits
  2011-03-10 10:10 ` [PATCH 8/8] macb: support data bus widths > 32 bits Jamie Iles
@ 2011-03-11 12:55   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11 13:15     ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 12:55 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> Some GEM implementations may support data bus widths up to 128 bits.
> Allow the platform data to specify the data bus width and let the driver
> program it up.
> 
can we detect it?

Best Regards,
J.

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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-11 12:47       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11 13:08         ` Jamie Iles
  2011-03-11 13:39           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-11 13:08 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, netdev, linux-arm-kernel, nicolas.ferre

On Fri, Mar 11, 2011 at 01:47:57PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 08:54 Fri 11 Mar     , Jamie Iles wrote:
> > On Fri, Mar 11, 2011 at 02:44:00AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > > > +#ifdef CONFIG_ARCH_AT91
> > > > +#define PCLK_NAME	"macb_clk"
> > > > +#else /* CONFIG_ARCH_AT91 */
> > > > +#define PCLK_NAME	"pclk"
> > > > +#endif
> > > 
> > > we need change the clock name and avoid the ifdef
> > > so this will be generic
> > > 
> > > nb I work on the switch to clkdev currently for avr32 and at91
> > 
> > This should be gone now.  Russell made the suggestion to have a fake clk 
> > for hclk on AT91 so I think I've solved that now.  There's an updated 
> > patch in my reply to Russell's message but essentially I'm using 
> > at91_clock_associate() to turn "macb_pclk" into "hclk" and "pclk".  Does 
> > this seem reasonable?
> please do not use at91_clock_associate as I'm going to remove it as use static
> clock as done on shmobile as example
> so if it's a fake clock please as ochi_clk on 9g45

Ok, that's fine.  How about for the "macb_plk" though, won't that need 
an at91_clock_associate() or is it OK to rename all of the macb_clk 
definitions to have be called "pclk"?

Jamie

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

* Re: [PATCH 4/8] macb: initial support for Cadence GEM
  2011-03-10 10:10 ` [PATCH 4/8] macb: initial support for Cadence GEM Jamie Iles
@ 2011-03-11 13:14   ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11 13:30     ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 13:14 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> The Cadence GEM is based on the MACB Ethernet controller but has a few
> small changes with regards to register and bitfield placement.  This
> patch adds a new platform driver for gem which sets allows the driver to
> tell at runtime whether it is targetting a GEM device.
> 
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>
could we avoid all this if else everywhere?

Best Regards,
J.

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

* Re: [PATCH 8/8] macb: support data bus widths > 32 bits
  2011-03-11 12:55   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11 13:15     ` Jamie Iles
  0 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-11 13:15 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, netdev, linux-arm-kernel, nicolas.ferre

On Fri, Mar 11, 2011 at 01:55:23PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > Some GEM implementations may support data bus widths up to 128 bits.
> > Allow the platform data to specify the data bus width and let the driver
> > program it up.
> > 
> can we detect it?

Well, the first design configuration register will tell you what the 
maximum data bus width is so we could probably always go with that.  I 
can't think of a good reason why you wouldn't want to do that.

Jamie

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-11 12:52           ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11 13:25             ` Jamie Iles
  2011-03-11 13:37               ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-11 13:25 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, Nicolas Ferre, netdev, linux-arm-kernel

On Fri, Mar 11, 2011 at 01:52:46PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 08:56 Fri 11 Mar     , Jamie Iles wrote:
> > On Fri, Mar 11, 2011 at 02:41:40AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > keep as we need to remove the #ifdef AT91 to cpu_is
> > > 
> > > I've patch for this
> > 
> > Is this for the user IO register where the value written is conditional 
> > on both RMII/MII and arch type?
> yes for 
> 
> #if defined(CONFIG_ARCH_AT91)
> 		macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)));
> #else
> 		macb_writel(bp, USRIO, 0);
> #endif
> 	else
> #if defined(CONFIG_ARCH_AT91)
> 		macb_writel(bp, USRIO, MACB_BIT(CLKEN));
> #else
> 		macb_writel(bp, USRIO, MACB_BIT(MII));
> #endif

Ok, but what about non-AT91/AVR32 systems?  They may not have a 
mach/cpu.h and won't have cpu_is_foo() for the platforms the driver is 
interested in.

Could we supply these values in the platform data so the driver doesn't 
need to do any cpu_is_ magic?

Jamie

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

* Re: [PATCH 4/8] macb: initial support for Cadence GEM
  2011-03-11 13:14   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11 13:30     ` Jamie Iles
  2011-03-11 13:34       ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 34+ messages in thread
From: Jamie Iles @ 2011-03-11 13:30 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, netdev, linux-arm-kernel, nicolas.ferre

On Fri, Mar 11, 2011 at 02:14:15PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > The Cadence GEM is based on the MACB Ethernet controller but has a few
> > small changes with regards to register and bitfield placement.  This
> > patch adds a new platform driver for gem which sets allows the driver to
> > tell at runtime whether it is targetting a GEM device.
> > 
> > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> could we avoid all this if else everywhere?

I can't really see any other way to do this, but you're right it isn't 
particularly nice.  Having said that, it is only in the initialization 
code so there shouldn't be any real performance impact.

I'm open to ideas though!

Jamie

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

* Re: [PATCH 4/8] macb: initial support for Cadence GEM
  2011-03-11 13:30     ` Jamie Iles
@ 2011-03-11 13:34       ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11 14:08         ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 13:34 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On 13:30 Fri 11 Mar     , Jamie Iles wrote:
> On Fri, Mar 11, 2011 at 02:14:15PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > > The Cadence GEM is based on the MACB Ethernet controller but has a few
> > > small changes with regards to register and bitfield placement.  This
> > > patch adds a new platform driver for gem which sets allows the driver to
> > > tell at runtime whether it is targetting a GEM device.
> > > 
> > > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> > could we avoid all this if else everywhere?
> 
> I can't really see any other way to do this, but you're right it isn't 
> particularly nice.  Having said that, it is only in the initialization 
> code so there shouldn't be any real performance impact.
> 
> I'm open to ideas though!
use macro or inline at least

Best Regards,
J.

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-11 13:25             ` Jamie Iles
@ 2011-03-11 13:37               ` Jean-Christophe PLAGNIOL-VILLARD
  2011-03-11 13:53                 ` Jamie Iles
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 13:37 UTC (permalink / raw)
  To: Jamie Iles; +Cc: Nicolas Ferre, netdev, linux-arm-kernel

On 13:25 Fri 11 Mar     , Jamie Iles wrote:
> On Fri, Mar 11, 2011 at 01:52:46PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 08:56 Fri 11 Mar     , Jamie Iles wrote:
> > > On Fri, Mar 11, 2011 at 02:41:40AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > keep as we need to remove the #ifdef AT91 to cpu_is
> > > > 
> > > > I've patch for this
> > > 
> > > Is this for the user IO register where the value written is conditional 
> > > on both RMII/MII and arch type?
> > yes for 
> > 
> > #if defined(CONFIG_ARCH_AT91)
> > 		macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)));
> > #else
> > 		macb_writel(bp, USRIO, 0);
> > #endif
> > 	else
> > #if defined(CONFIG_ARCH_AT91)
> > 		macb_writel(bp, USRIO, MACB_BIT(CLKEN));
> > #else
> > 		macb_writel(bp, USRIO, MACB_BIT(MII));
> > #endif
> 
> Ok, but what about non-AT91/AVR32 systems?  They may not have a 
> mach/cpu.h and won't have cpu_is_foo() for the platforms the driver is 
> interested in.
> 
> Could we supply these values in the platform data so the driver doesn't 
> need to do any cpu_is_ magic?
for other arch you can but at91 I prefer to avoid this copy and paste in every
soc

Best Regards,
J.

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

* Re: [PATCH 2/8] macb: detect hclk presence from platform data
  2011-03-11 13:08         ` Jamie Iles
@ 2011-03-11 13:39           ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 34+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2011-03-11 13:39 UTC (permalink / raw)
  To: Jamie Iles; +Cc: netdev, linux-arm-kernel, nicolas.ferre

On 13:08 Fri 11 Mar     , Jamie Iles wrote:
> On Fri, Mar 11, 2011 at 01:47:57PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 08:54 Fri 11 Mar     , Jamie Iles wrote:
> > > On Fri, Mar 11, 2011 at 02:44:00AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > > > > +#ifdef CONFIG_ARCH_AT91
> > > > > +#define PCLK_NAME	"macb_clk"
> > > > > +#else /* CONFIG_ARCH_AT91 */
> > > > > +#define PCLK_NAME	"pclk"
> > > > > +#endif
> > > > 
> > > > we need change the clock name and avoid the ifdef
> > > > so this will be generic
> > > > 
> > > > nb I work on the switch to clkdev currently for avr32 and at91
> > > 
> > > This should be gone now.  Russell made the suggestion to have a fake clk 
> > > for hclk on AT91 so I think I've solved that now.  There's an updated 
> > > patch in my reply to Russell's message but essentially I'm using 
> > > at91_clock_associate() to turn "macb_pclk" into "hclk" and "pclk".  Does 
> > > this seem reasonable?
> > please do not use at91_clock_associate as I'm going to remove it as use static
> > clock as done on shmobile as example
> > so if it's a fake clock please as ochi_clk on 9g45
> 
> Ok, that's fine.  How about for the "macb_plk" though, won't that need 
> an at91_clock_associate() or is it OK to rename all of the macb_clk 
> definitions to have be called "pclk"?

Personnaly I prefer macb_clk but if Nico prefer pclk it's fine

Best Regards,
J.

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

* Re: [PATCH 1/8] macb: unify at91 and avr32 platform data
  2011-03-11 13:37               ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11 13:53                 ` Jamie Iles
  0 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-11 13:53 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, Nicolas Ferre, netdev, linux-arm-kernel

On Fri, Mar 11, 2011 at 02:37:13PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 13:25 Fri 11 Mar     , Jamie Iles wrote:
> > On Fri, Mar 11, 2011 at 01:52:46PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 08:56 Fri 11 Mar     , Jamie Iles wrote:
> > > > On Fri, Mar 11, 2011 at 02:41:40AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > > > keep as we need to remove the #ifdef AT91 to cpu_is
> > > > > 
> > > > > I've patch for this
> > > > 
> > > > Is this for the user IO register where the value written is conditional 
> > > > on both RMII/MII and arch type?
> > > yes for 
> > > 
> > > #if defined(CONFIG_ARCH_AT91)
> > > 		macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)));
> > > #else
> > > 		macb_writel(bp, USRIO, 0);
> > > #endif
> > > 	else
> > > #if defined(CONFIG_ARCH_AT91)
> > > 		macb_writel(bp, USRIO, MACB_BIT(CLKEN));
> > > #else
> > > 		macb_writel(bp, USRIO, MACB_BIT(MII));
> > > #endif
> > 
> > Ok, but what about non-AT91/AVR32 systems?  They may not have a 
> > mach/cpu.h and won't have cpu_is_foo() for the platforms the driver is 
> > interested in.
> > 
> > Could we supply these values in the platform data so the driver doesn't 
> > need to do any cpu_is_ magic?
>
> for other arch you can but at91 I prefer to avoid this copy and paste in every
> soc

Ok, just so I'm clear, you want to be able to set the USRIO register 
based on a cpu_is_foo() test which requires mach/cpu.h to be included.  

For other architectures we may not have mach/cpu.h and the cpu_is_foo() 
macros, so we'd still need to protect all of that with "#ifdef 
CONFIG_ARCH_AT91" tests.  Is that okay?

Jamie

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

* Re: [PATCH 4/8] macb: initial support for Cadence GEM
  2011-03-11 13:34       ` Jean-Christophe PLAGNIOL-VILLARD
@ 2011-03-11 14:08         ` Jamie Iles
  0 siblings, 0 replies; 34+ messages in thread
From: Jamie Iles @ 2011-03-11 14:08 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: Jamie Iles, netdev, linux-arm-kernel, nicolas.ferre

On Fri, Mar 11, 2011 at 02:34:45PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 13:30 Fri 11 Mar     , Jamie Iles wrote:
> > On Fri, Mar 11, 2011 at 02:14:15PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 10:10 Thu 10 Mar     , Jamie Iles wrote:
> > > > The Cadence GEM is based on the MACB Ethernet controller but has a few
> > > > small changes with regards to register and bitfield placement.  This
> > > > patch adds a new platform driver for gem which sets allows the driver to
> > > > tell at runtime whether it is targetting a GEM device.
> > > > 
> > > > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> > > could we avoid all this if else everywhere?
> > 
> > I can't really see any other way to do this, but you're right it isn't 
> > particularly nice.  Having said that, it is only in the initialization 
> > code so there shouldn't be any real performance impact.
> > 
> > I'm open to ideas though!
> use macro or inline at least

Ok, so this works:

#define macb_or_gem_writel(__bp, __reg, __value) \
	({ \
		if ((__bp)->is_gem) \
			gem_writel((__bp), __reg, __value); \
		else \
			macb_writel((__bp), __reg, __value); \
	})

#define macb_or_gem_readl(__bp, __reg) \
	({ \
		u32 __v; \
		if ((__bp)->is_gem) \
			__v = gem_readl((__bp), __reg); \
		else \
			__v = macb_readl((__bp), __reg); \
		__v; \
	})

and then we can use these for things like the hardware addresses where 
the registers are different but I wanted to avoid the conditional in 
every register access if possible.

How is this for you?  We then only have visible conditionals for the 
data bus width (as I don't know if that is something that MACB can do or 
what the numbers are) and for the stats collection, but that seems 
acceptable to me.

Jamie

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

end of thread, other threads:[~2011-03-11 14:08 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-10 10:10 [PATCH 0/8] macb: add support for Cadence GEM Jamie Iles
2011-03-10 10:10 ` [PATCH 1/8] macb: unify at91 and avr32 platform data Jamie Iles
2011-03-10 13:06   ` Nicolas Ferre
2011-03-10 13:17     ` Jamie Iles
2011-03-11  1:41       ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11  8:56         ` Jamie Iles
2011-03-11 12:52           ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11 13:25             ` Jamie Iles
2011-03-11 13:37               ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11 13:53                 ` Jamie Iles
2011-03-10 10:10 ` [PATCH 2/8] macb: detect hclk presence from " Jamie Iles
2011-03-10 10:15   ` Russell King - ARM Linux
2011-03-10 11:41     ` Jamie Iles
2011-03-10 11:45       ` Jamie Iles
2011-03-11  1:44   ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11  8:54     ` Jamie Iles
2011-03-11 12:47       ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11 13:08         ` Jamie Iles
2011-03-11 13:39           ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-10 10:10 ` [PATCH 3/8] macb: convert printk to pr_ and friends Jamie Iles
2011-03-10 22:48   ` Joe Perches
2011-03-11  0:09     ` Jamie Iles
2011-03-11 12:53   ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-10 10:10 ` [PATCH 4/8] macb: initial support for Cadence GEM Jamie Iles
2011-03-11 13:14   ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11 13:30     ` Jamie Iles
2011-03-11 13:34       ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11 14:08         ` Jamie Iles
2011-03-10 10:10 ` [PATCH 5/8] macb: handle HW address registers for GEM devices Jamie Iles
2011-03-10 10:10 ` [PATCH 6/8] macb: support higher rate GEM MDIO clock divisors Jamie Iles
2011-03-10 10:10 ` [PATCH 7/8] macb: support statistics for GEM devices Jamie Iles
2011-03-10 10:10 ` [PATCH 8/8] macb: support data bus widths > 32 bits Jamie Iles
2011-03-11 12:55   ` Jean-Christophe PLAGNIOL-VILLARD
2011-03-11 13:15     ` Jamie Iles

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