linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support.
@ 2012-07-30 15:15 Ian Molton
  2012-07-30 15:15 ` [PATCH 1/6] Initial csb1724 board support (FDT) Ian Molton
                   ` (5 more replies)
  0 siblings, 6 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

This patch series adds support for the CSB1724 SoM by Cogent.

It also provides mv643xx DT support, and the CSB1724 was my test platform
for this support.

The mv643xx driver needs a LOT more TLC, but this should be a pretty
non-invasive way to get started on it.

The CSB1724 SoM platform support is ready-to-go. Supported so far is
SATA, Ethernet, and Serial.

SATA is built upon Thomas' work.

Ian Molton (6):
  Initial csb1724 board support (FDT)
  mv643xx.c: Remove magic numbers.
  mv643xx.c: Add basic device tree support.
  kirkwood: setup clock only in eth helpers.
  csb1724: Enable device tree based mv643xx ethernet support.
  DT: Convert all kirkwood boards with mv643xx that use DT

 arch/arm/boot/dts/kirkwood-csb1724.dts     |   55 ++++++++++++++
 arch/arm/boot/dts/kirkwood-dnskw.dtsi      |   12 +++
 arch/arm/boot/dts/kirkwood-dreamplug.dts   |   24 ++++++
 arch/arm/boot/dts/kirkwood-goflexnet.dts   |   11 +++
 arch/arm/boot/dts/kirkwood-ib62x0.dts      |   13 ++++
 arch/arm/boot/dts/kirkwood-iconnect.dts    |   13 ++++
 arch/arm/boot/dts/kirkwood-lsxl.dtsi       |   23 ++++++
 arch/arm/boot/dts/kirkwood-ts219-6281.dts  |   11 ++-
 arch/arm/boot/dts/kirkwood-ts219-6282.dts  |   11 ++-
 arch/arm/boot/dts/kirkwood-ts219.dtsi      |    3 +
 arch/arm/boot/dts/kirkwood.dtsi            |   16 ++++
 arch/arm/configs/csb1724_defconfig         |   92 ++++++++++++++++++++++
 arch/arm/mach-kirkwood/Kconfig             |    7 ++
 arch/arm/mach-kirkwood/Makefile            |    1 +
 arch/arm/mach-kirkwood/Makefile.boot       |    1 +
 arch/arm/mach-kirkwood/board-csb1724.c     |   62 +++++++++++++++
 arch/arm/mach-kirkwood/board-dnskw.c       |    7 +-
 arch/arm/mach-kirkwood/board-dreamplug.c   |   13 +---
 arch/arm/mach-kirkwood/board-dt.c          |    4 +
 arch/arm/mach-kirkwood/board-goflexnet.c   |    7 +-
 arch/arm/mach-kirkwood/board-ib62x0.c      |    7 +-
 arch/arm/mach-kirkwood/board-iconnect.c    |    7 +-
 arch/arm/mach-kirkwood/board-lsxl.c        |   13 +---
 arch/arm/mach-kirkwood/board-ts219.c       |   10 +--
 arch/arm/mach-kirkwood/common.c            |    6 +-
 arch/arm/mach-kirkwood/common.h            |    6 ++
 drivers/net/ethernet/marvell/mv643xx_eth.c |  114 ++++++++++++++++++++++++----
 27 files changed, 475 insertions(+), 74 deletions(-)
 create mode 100644 arch/arm/boot/dts/kirkwood-csb1724.dts
 create mode 100644 arch/arm/configs/csb1724_defconfig
 create mode 100644 arch/arm/mach-kirkwood/board-csb1724.c

-- 
1.7.9.5

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

* [PATCH 1/6] Initial csb1724 board support (FDT)
  2012-07-30 15:15 [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support Ian Molton
@ 2012-07-30 15:15 ` Ian Molton
  2012-07-30 15:28   ` Andrew Lunn
  2012-07-30 15:15 ` [PATCH 2/6] mv643xx.c: Remove magic numbers Ian Molton
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 35+ messages in thread
From: Ian Molton @ 2012-07-30 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds support for the csb1724 SoM.

It includes serial and SATA support.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 arch/arm/boot/dts/kirkwood-csb1724.dts |   30 ++++++++++++++++
 arch/arm/configs/csb1724_defconfig     |   47 +++++++++++++++++++++++++
 arch/arm/mach-kirkwood/Kconfig         |    7 ++++
 arch/arm/mach-kirkwood/Makefile        |    1 +
 arch/arm/mach-kirkwood/Makefile.boot   |    1 +
 arch/arm/mach-kirkwood/board-csb1724.c |   59 ++++++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/board-dt.c      |    4 +++
 arch/arm/mach-kirkwood/common.h        |    6 ++++
 8 files changed, 155 insertions(+)
 create mode 100644 arch/arm/boot/dts/kirkwood-csb1724.dts
 create mode 100644 arch/arm/configs/csb1724_defconfig
 create mode 100644 arch/arm/mach-kirkwood/board-csb1724.c

diff --git a/arch/arm/boot/dts/kirkwood-csb1724.dts b/arch/arm/boot/dts/kirkwood-csb1724.dts
new file mode 100644
index 0000000..44dfe9a
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-csb1724.dts
@@ -0,0 +1,30 @@
+/dts-v1/;
+
+/include/ "kirkwood.dtsi"
+
+/ {
+	model = "Cogent CSB1724-88F-628X SoM";
+	compatible = "cogent,csb1724", "marvell,kirkwood-88f6281", "marvell,kirkwood";
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x20000000>;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200n8 earlyprintk";
+	};
+
+	ocp at f1000000 {
+		serial at 12000 {
+			clock-frequency = <200000000>;
+			status = "ok";
+		};
+
+		sata at 80000 {
+			nr-ports = <2>;
+			status = "ok";
+		};
+	};
+
+};
diff --git a/arch/arm/configs/csb1724_defconfig b/arch/arm/configs/csb1724_defconfig
new file mode 100644
index 0000000..927b269
--- /dev/null
+++ b/arch/arm/configs/csb1724_defconfig
@@ -0,0 +1,47 @@
+CONFIG_ARCH_KIRKWOOD=y
+CONFIG_ARCH_KIRKWOOD_DT=y
+CONFIG_MACH_CSB1724_DT=y
+CONFIG_EMBEDDED=y
+CONFIG_EXPERT=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_ARM_APPENDED_DTB=y
+CONFIG_VFP=y
+CONFIG_AEABI=y
+CONFIG_OABI_COMPAT=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_ATA=y
+CONFIG_ATA_SFF=y
+CONFIG_ATA_BMDMA=y
+CONFIG_SATA_MV=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_CODEPAGE_850=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_NLS_ISO8859_2=y
+CONFIG_NLS_UTF8=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_FS=y
+CONFIG_TIMER_STATS=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_USER=y
+CONFIG_DEBUG_LL=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_DTC=y
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_EXT4_FS=y
+CONFIG_SYSVIPC=y
+CONFIG_SYSVIPC_SYSCTL=y
+CONFIG_TICK_ONESHOT=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_PROC_DEVICETREE=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
+CONFIG_DYNAMIC_DEBUG=y
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index ca5c15a..6f59f0d 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -109,6 +109,13 @@ config MACH_LSXL_DT
 	  Buffalo Linkstation LS-XHL & LS-CHLv2 devices, using
 	  Flattened Device Tree.
 
+config MACH_CSB1724_DT
+	bool "Cogent csb1724 SoM (Flattened Device Tree)"
+	select ARCH_KIRKWOOD_DT
+	help
+	  Say 'Y' here if you want your kernel to support the
+	  Cogent csb1724 SoM, using Flattened Device Tree.
+
 config MACH_TS219
 	bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS"
 	help
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index 055c85a..665ed63 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -28,3 +28,4 @@ obj-$(CONFIG_MACH_IB62X0_DT)		+= board-ib62x0.o
 obj-$(CONFIG_MACH_TS219_DT)		+= board-ts219.o tsx1x-common.o
 obj-$(CONFIG_MACH_GOFLEXNET_DT)		+= board-goflexnet.o
 obj-$(CONFIG_MACH_LSXL_DT)		+= board-lsxl.o
+obj-$(CONFIG_MACH_CSB1724_DT)		+= board-csb1724.o
diff --git a/arch/arm/mach-kirkwood/Makefile.boot b/arch/arm/mach-kirkwood/Makefile.boot
index 2a576ab..899bc80 100644
--- a/arch/arm/mach-kirkwood/Makefile.boot
+++ b/arch/arm/mach-kirkwood/Makefile.boot
@@ -2,6 +2,7 @@
 params_phys-y	:= 0x00000100
 initrd_phys-y	:= 0x00800000
 
+dtb-$(CONFIG_MACH_CSB1724_DT) += kirkwood-csb1724.dtb
 dtb-$(CONFIG_MACH_DREAMPLUG_DT) += kirkwood-dreamplug.dtb
 dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns320.dtb
 dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns325.dtb
diff --git a/arch/arm/mach-kirkwood/board-csb1724.c b/arch/arm/mach-kirkwood/board-csb1724.c
new file mode 100644
index 0000000..979112d
--- /dev/null
+++ b/arch/arm/mach-kirkwood/board-csb1724.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012 (C), Ian Molton <ian.molton@codethink.co.uk>
+ *
+ * arch/arm/mach-kirkwood/board-csb1724.c
+ *
+ * Cogent csb1724 Board Init for drivers not converted to
+ * flattened device tree yet.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include "mpp.h"
+
+static unsigned int csb1724_mpp_config[] __initdata = {
+	MPP0_NF_IO2,
+	MPP1_NF_IO3,
+	MPP2_NF_IO4,
+	MPP3_NF_IO5,
+	MPP4_NF_IO6,
+	MPP5_NF_IO7,
+	MPP8_TW0_SDA,
+	MPP9_TW0_SCK,
+	MPP12_SD_CLK,
+	MPP13_SD_CMD,
+	MPP14_SD_D0,
+	MPP15_SD_D1,
+	MPP16_SD_D2,
+	MPP17_SD_D3,
+	MPP18_NF_IO0,
+	MPP19_NF_IO1,
+	MPP20_GE1_TXD0,
+	MPP21_GE1_TXD1,
+	MPP22_GE1_TXD2,
+	MPP23_GE1_TXD3,
+	MPP24_GE1_RXD0,
+	MPP25_GE1_RXD1,
+	MPP26_GE1_RXD2,
+	MPP27_GE1_RXD3,
+	MPP30_GE1_RXCTL,
+	MPP31_GE1_RXCLK,
+	MPP32_GE1_TCLKOUT,
+	MPP33_GE1_TXCTL,
+	MPP34_SATA1_ACTn,
+	MPP35_SATA0_ACTn,
+	MPP36_TW1_SDA,
+	MPP37_TW1_SCK,
+};
+
+void __init csb1724_init(void)
+{
+	/*
+	 * Basic setup. Needs to be called early.
+	 */
+	kirkwood_mpp_conf(csb1724_mpp_config);
+}
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index e4eb450..7679f7f 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -87,6 +87,9 @@ static void __init kirkwood_dt_init(void)
 	if (of_machine_is_compatible("buffalo,lsxl"))
 		lsxl_init();
 
+	if (of_machine_is_compatible("cogent,csb1724"))
+		csb1724_init();
+
 	of_platform_populate(NULL, kirkwood_dt_match_table,
 			     kirkwood_auxdata_lookup, NULL);
 }
@@ -100,6 +103,7 @@ static const char *kirkwood_dt_board_compat[] = {
 	"qnap,ts219",
 	"seagate,goflexnet",
 	"buffalo,lsxl",
+	"cogent,csb1724",
 	NULL
 };
 
diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h
index 304dd1a..8aab1ae 100644
--- a/arch/arm/mach-kirkwood/common.h
+++ b/arch/arm/mach-kirkwood/common.h
@@ -94,6 +94,12 @@ void lsxl_init(void);
 static inline void lsxl_init(void) {};
 #endif
 
+#ifdef CONFIG_MACH_CSB1724_DT
+void csb1724_init(void);
+#else
+static inline void csb1724_init(void) {};
+#endif
+
 /* early init functions not converted to fdt yet */
 char *kirkwood_id(void);
 void kirkwood_l2_init(void);
-- 
1.7.9.5

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

* [PATCH 2/6] mv643xx.c: Remove magic numbers.
  2012-07-30 15:15 [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support Ian Molton
  2012-07-30 15:15 ` [PATCH 1/6] Initial csb1724 board support (FDT) Ian Molton
@ 2012-07-30 15:15 ` Ian Molton
  2012-07-30 15:15 ` [PATCH 3/6] mv643xx.c: Add basic device tree support Ian Molton
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

replace magic number with RX_CSUM_WITH_HEADER.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/net/ethernet/marvell/mv643xx_eth.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 4fbba57..92497eb 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -86,6 +86,7 @@ static char mv643xx_eth_driver_version[] = "1.4";
  * port #0, 0x0800 for port #1, and 0x0c00 for port #2.
  */
 #define PORT_CONFIG			0x0000
+#define  RX_CSUM_WITH_HEADER		0x02000000
 #define  UNICAST_PROMISCUOUS_MODE	0x00000001
 #define PORT_CONFIG_EXT			0x0004
 #define MAC_ADDR_LOW			0x0014
@@ -1607,7 +1608,7 @@ mv643xx_eth_set_features(struct net_device *dev, netdev_features_t features)
 	struct mv643xx_eth_private *mp = netdev_priv(dev);
 	bool rx_csum = features & NETIF_F_RXCSUM;
 
-	wrlp(mp, PORT_CONFIG, rx_csum ? 0x02000000 : 0x00000000);
+	wrlp(mp, PORT_CONFIG, rx_csum ? RX_CSUM_WITH_HEADER : 0x00000000);
 
 	return 0;
 }
-- 
1.7.9.5

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-30 15:15 [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support Ian Molton
  2012-07-30 15:15 ` [PATCH 1/6] Initial csb1724 board support (FDT) Ian Molton
  2012-07-30 15:15 ` [PATCH 2/6] mv643xx.c: Remove magic numbers Ian Molton
@ 2012-07-30 15:15 ` Ian Molton
  2012-07-30 15:39   ` Andrew Lunn
                     ` (2 more replies)
  2012-07-30 15:15 ` [PATCH 4/6] kirkwood: setup clock only in eth helpers Ian Molton
                   ` (2 subsequent siblings)
  5 siblings, 3 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds basic device tree support to the mv643xx ethernet driver.

It should be enough for most current users of the device, and should allow
a fairly painless migration once proper support for clk devices is available
to those platforms.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/net/ethernet/marvell/mv643xx_eth.c |  111 ++++++++++++++++++++++++----
 1 file changed, 97 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 92497eb..579692f 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -48,6 +48,9 @@
 #include <linux/ethtool.h>
 #include <linux/platform_device.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_irq.h>
 #include <linux/kernel.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
@@ -2601,11 +2604,11 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
 static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 {
 	static int mv643xx_eth_version_printed;
-	struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
+	struct mv643xx_eth_shared_platform_data *pd;
 	struct mv643xx_eth_shared_private *msp;
 	const struct mbus_dram_target_info *dram;
 	struct resource *res;
-	int ret;
+	int ret, irq = -1;
 
 	if (!mv643xx_eth_version_printed++)
 		pr_notice("MV-643xx 10/100/1000 ethernet driver version %s\n",
@@ -2625,6 +2628,23 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 	if (msp->base == NULL)
 		goto out_free;
 
+	if (pdev->dev.of_node) {
+		struct device_node *np = NULL;
+
+		/* when all users of this driver use FDT, we can remove this */
+		pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
+		if (!pd) {
+			dev_dbg(&pdev->dev, "Could not allocate platform data\n");
+			goto out_free;
+		}
+
+		np = of_parse_phandle(pdev->dev.of_node, "shared_smi", 0);
+		if (np)
+			pd->shared_smi = of_find_device_by_node(np);
+
+	} else {
+		pd = pdev->dev.platform_data;
+	}
 	/*
 	 * Set up and register SMI bus.
 	 */
@@ -2654,15 +2674,22 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 	/*
 	 * Check whether the error interrupt is hooked up.
 	 */
-	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (res != NULL) {
+	if (pdev->dev.of_node) {
+		irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	} else {
+		res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+		if (res)
+			irq = res->start;
+	}
+
+	if (irq != -1) {
 		int err;
 
-		err = request_irq(res->start, mv643xx_eth_err_irq,
+		err = request_irq(irq, mv643xx_eth_err_irq,
 				  IRQF_SHARED, "mv643xx_eth", msp);
 		if (!err) {
 			writel(ERR_INT_SMI_DONE, msp->base + ERR_INT_MASK);
-			msp->err_interrupt = res->start;
+			msp->err_interrupt = irq;
 		}
 	}
 
@@ -2675,6 +2702,10 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 
 	msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
 					pd->tx_csum_limit : 9 * 1024;
+
+	if (pdev->dev.of_node)
+		kfree(pd);  /* If we created a fake pd, free it now */
+
 	infer_hw_params(msp);
 
 	platform_set_drvdata(pdev, msp);
@@ -2708,12 +2739,21 @@ static int mv643xx_eth_shared_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id mv_mdio_dt_ids[] __devinitdata = {
+	{ .compatible = "marvell,mdio-mv643xx", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, mv_mdio_dt_ids);
+#endif
+
 static struct platform_driver mv643xx_eth_shared_driver = {
 	.probe		= mv643xx_eth_shared_probe,
 	.remove		= mv643xx_eth_shared_remove,
 	.driver = {
 		.name	= MV643XX_ETH_SHARED_NAME,
 		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(mv_mdio_dt_ids),
 	},
 };
 
@@ -2873,7 +2913,31 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 	struct resource *res;
 	int err;
 
-	pd = pdev->dev.platform_data;
+	if (pdev->dev.of_node) {
+		struct device_node *np = NULL;
+
+		/* when all users of this driver use FDT, we can remove this */
+		pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
+		if (!pd) {
+			dev_dbg(&pdev->dev, "Could not allocate platform data\n");
+			return -ENOMEM;
+		}
+
+		of_property_read_u32(pdev->dev.of_node,
+			"port_number", &pd->port_number);
+		of_property_read_u32(pdev->dev.of_node,
+			"phy_addr", &pd->phy_addr);
+		np = of_parse_phandle(pdev->dev.of_node, "mdio", 0);
+		if (np) {
+			pd->shared = of_find_device_by_node(np);
+		} else {
+			kfree(pd);
+			return -ENODEV;
+		}
+	} else {
+		pd = pdev->dev.platform_data;
+	}
+
 	if (pd == NULL) {
 		dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
 		return -ENODEV;
@@ -2881,12 +2945,15 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 
 	if (pd->shared == NULL) {
 		dev_err(&pdev->dev, "no mv643xx_eth_platform_data->shared\n");
-		return -ENODEV;
+		err = -ENODEV;
+		goto out_free_pd;
 	}
 
 	dev = alloc_etherdev_mq(sizeof(struct mv643xx_eth_private), 8);
-	if (!dev)
-		return -ENOMEM;
+	if (!dev) {
+		err = -ENOMEM;
+		goto out_free_pd;
+	}
 
 	mp = netdev_priv(dev);
 	platform_set_drvdata(pdev, mp);
@@ -2923,6 +2990,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 
 	init_pscr(mp, pd->speed, pd->duplex);
 
+	if (pdev->dev.of_node)
+		kfree(pd); /* If we created a fake pd, free it now */
 
 	mib_counters_clear(mp);
 
@@ -2942,10 +3011,13 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 	mp->rx_oom.data = (unsigned long)mp;
 	mp->rx_oom.function = oom_timer_wrapper;
 
-
-	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	BUG_ON(!res);
-	dev->irq = res->start;
+	if (pdev->dev.of_node) {
+		dev->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	} else {
+		res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+		BUG_ON(!res);
+		dev->irq = res->start;
+	}
 
 	dev->netdev_ops = &mv643xx_eth_netdev_ops;
 
@@ -2991,6 +3063,8 @@ out:
 	}
 #endif
 	free_netdev(dev);
+out_free_pd:
+	kfree(pd);
 
 	return err;
 }
@@ -3030,6 +3104,14 @@ static void mv643xx_eth_shutdown(struct platform_device *pdev)
 		port_reset(mp);
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id mv_eth_dt_ids[] __devinitdata = {
+	{ .compatible = "marvell,mv643xx", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, mv_eth_dt_ids);
+#endif
+
 static struct platform_driver mv643xx_eth_driver = {
 	.probe		= mv643xx_eth_probe,
 	.remove		= mv643xx_eth_remove,
@@ -3037,6 +3119,7 @@ static struct platform_driver mv643xx_eth_driver = {
 	.driver = {
 		.name	= MV643XX_ETH_NAME,
 		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(mv_eth_dt_ids),
 	},
 };
 
-- 
1.7.9.5

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-30 15:15 [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support Ian Molton
                   ` (2 preceding siblings ...)
  2012-07-30 15:15 ` [PATCH 3/6] mv643xx.c: Add basic device tree support Ian Molton
@ 2012-07-30 15:15 ` Ian Molton
  2012-07-30 16:12   ` Andrew Lunn
  2012-07-30 16:46   ` Josh Coombs
  2012-07-30 15:15 ` [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support Ian Molton
  2012-07-30 15:15 ` [PATCH 6/6] DT: Convert all kirkwood boards with mv643xx that use DT Ian Molton
  5 siblings, 2 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

This patch modifies the ethernet setup helper functions so that they can be
used /purely/ to set up the clocks.

This is part of ongoing work to enable device tree support in the mv643xx.c
ethernet driver, where as yet the kirkwood platform does not have proper clk
support.

This should allow a gradual migration to device tree and later to proper clk
support, wherupon the helper functions can be removed entirely.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 arch/arm/mach-kirkwood/common.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index c4b64ad..c1776ea 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -299,7 +299,8 @@ void __init kirkwood_ehci_init(void)
  ****************************************************************************/
 void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
 {
-	orion_ge00_init(eth_data,
+	if (eth_data)
+		orion_ge00_init(eth_data,
 			GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
 			IRQ_KIRKWOOD_GE00_ERR);
 	/* The interface forgets the MAC address assigned by u-boot if
@@ -313,7 +314,8 @@ void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
  ****************************************************************************/
 void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
 {
-	orion_ge01_init(eth_data,
+	if (eth_data)
+		orion_ge01_init(eth_data,
 			GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
 			IRQ_KIRKWOOD_GE01_ERR);
 	clk_prepare_enable(ge1);
-- 
1.7.9.5

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

* [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support.
  2012-07-30 15:15 [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support Ian Molton
                   ` (3 preceding siblings ...)
  2012-07-30 15:15 ` [PATCH 4/6] kirkwood: setup clock only in eth helpers Ian Molton
@ 2012-07-30 15:15 ` Ian Molton
  2012-07-30 15:55   ` Andrew Lunn
  2012-07-30 16:17   ` Andrew Lunn
  2012-07-30 15:15 ` [PATCH 6/6] DT: Convert all kirkwood boards with mv643xx that use DT Ian Molton
  5 siblings, 2 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

    This patch enables mv643xx based ethernet built into the SoM on the
    csb1724, via flattened device tree.

    Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 arch/arm/boot/dts/kirkwood-csb1724.dts |   25 ++++++++++++++++++
 arch/arm/boot/dts/kirkwood.dtsi        |   16 ++++++++++++
 arch/arm/configs/csb1724_defconfig     |   45 ++++++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/board-csb1724.c |    3 +++
 4 files changed, 89 insertions(+)

diff --git a/arch/arm/boot/dts/kirkwood-csb1724.dts b/arch/arm/boot/dts/kirkwood-csb1724.dts
index 44dfe9a..f652797 100644
--- a/arch/arm/boot/dts/kirkwood-csb1724.dts
+++ b/arch/arm/boot/dts/kirkwood-csb1724.dts
@@ -25,6 +25,31 @@
 			nr-ports = <2>;
 			status = "ok";
 		};
+
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
+
+		smi1: mdio at 76000 {
+			status = "ok";
+		};
+
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x80>;
+			interrupts = <11>;
+		};
+
+		egiga1 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi1>;
+			port_number = <0>;
+			phy_addr = <0x81>;
+			interrupts = <15>;
+		};
+
 	};
 
 };
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index cef9616..dd10422 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -105,5 +105,21 @@
 			clock-frequency = <100000>;
 			status = "disabled";
 		};
+
+		smi0: mdio at 72000 {
+			compatible = "marvell,mdio-mv643xx";
+			reg = <0x72000 0x4000>;
+			interrupts = <46>;
+			status = "disabled";
+		};
+
+		smi1: mdio at 76000 {
+			compatible = "marvell,mdio-mv643xx";
+			reg = <0x76000 0x4000>;
+			interrupts = <47>;
+			shared_smi = <&smi0>;
+			status = "disabled";
+		};
+
 	};
 };
diff --git a/arch/arm/configs/csb1724_defconfig b/arch/arm/configs/csb1724_defconfig
index 927b269..fbea657 100644
--- a/arch/arm/configs/csb1724_defconfig
+++ b/arch/arm/configs/csb1724_defconfig
@@ -45,3 +45,48 @@ CONFIG_PROC_DEVICETREE=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
 CONFIG_DYNAMIC_DEBUG=y
+CONFIG_NET=y
+CONFIG_INET=y
+CONFIG_NETDEVICES=y
+CONFIG_MV643XX_ETH=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_IPV6=n
+CONFIG_NET_VENDOR_3COM=n
+CONFIG_NET_VENDOR_ADAPTEC=n
+CONFIG_NET_VENDOR_ALTEON=n
+CONFIG_NET_VENDOR_AMD=n
+CONFIG_NET_VENDOR_ATHEROS=n
+CONFIG_NET_VENDOR_BROADCOM=n
+CONFIG_NET_VENDOR_BROCADE=n
+CONFIG_NET_VENDOR_CHELSIO=n
+CONFIG_NET_VENDOR_CIRRUS=n
+CONFIG_NET_VENDOR_CISCO=n
+CONFIG_NET_VENDOR_DEC=n
+CONFIG_NET_VENDOR_HP=n
+CONFIG_NET_VENDOR_DLINK=n
+CONFIG_NET_VENDOR_EMULEX=n
+CONFIG_NET_VENDOR_EXAR=n
+CONFIG_NET_VENDOR_FARADAY=n
+CONFIG_NET_VENDOR_INTEL=n
+CONFIG_NET_VENDOR_MELLANOX=n
+CONFIG_NET_VENDOR_MICREL=n
+CONFIG_NET_VENDOR_MYRI=n
+CONFIG_NET_VENDOR_NATSEMI=n
+CONFIG_NET_VENDOR_NVIDIA=n
+CONFIG_NET_VENDOR_OKI=n
+CONFIG_NET_PACKET_ENGINE=n
+CONFIG_NET_VENDOR_QLOGIC=n
+CONFIG_NET_VENDOR_REALTEK=n
+CONFIG_NET_VENDOR_RDC=n
+CONFIG_NET_VENDOR_SEEQ=n
+CONFIG_NET_VENDOR_SILAN=n
+CONFIG_NET_VENDOR_SIS=n
+CONFIG_NET_VENDOR_SMSC=n
+CONFIG_NET_VENDOR_STMICRO=n
+CONFIG_NET_VENDOR_SUN=n
+CONFIG_NET_VENDOR_TEHUTI=n
+CONFIG_NET_VENDOR_TI=n
+CONFIG_NET_VENDOR_VIA=n
+CONFIG_NET_VENDOR_WIZNET=n
+
diff --git a/arch/arm/mach-kirkwood/board-csb1724.c b/arch/arm/mach-kirkwood/board-csb1724.c
index 979112d..50f0c5b 100644
--- a/arch/arm/mach-kirkwood/board-csb1724.c
+++ b/arch/arm/mach-kirkwood/board-csb1724.c
@@ -13,6 +13,7 @@
 
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include "common.h"
 #include "mpp.h"
 
 static unsigned int csb1724_mpp_config[] __initdata = {
@@ -56,4 +57,6 @@ void __init csb1724_init(void)
 	 * Basic setup. Needs to be called early.
 	 */
 	kirkwood_mpp_conf(csb1724_mpp_config);
+	kirkwood_ge00_init(NULL);
+	kirkwood_ge01_init(NULL);
 }
-- 
1.7.9.5

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

* [PATCH 6/6] DT: Convert all kirkwood boards with mv643xx that use DT
  2012-07-30 15:15 [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support Ian Molton
                   ` (4 preceding siblings ...)
  2012-07-30 15:15 ` [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support Ian Molton
@ 2012-07-30 15:15 ` Ian Molton
  5 siblings, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 15:15 UTC (permalink / raw)
  To: linux-arm-kernel

This patch converts all present DT capable kirkwood board configurations
to use DT to configure the mv643xx ethernet controller.

Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
---
 arch/arm/boot/dts/kirkwood-dnskw.dtsi     |   12 ++++++++++++
 arch/arm/boot/dts/kirkwood-dreamplug.dts  |   24 ++++++++++++++++++++++++
 arch/arm/boot/dts/kirkwood-goflexnet.dts  |   11 +++++++++++
 arch/arm/boot/dts/kirkwood-ib62x0.dts     |   13 +++++++++++++
 arch/arm/boot/dts/kirkwood-iconnect.dts   |   13 +++++++++++++
 arch/arm/boot/dts/kirkwood-lsxl.dtsi      |   23 +++++++++++++++++++++++
 arch/arm/boot/dts/kirkwood-ts219-6281.dts |   11 ++++++++++-
 arch/arm/boot/dts/kirkwood-ts219-6282.dts |   11 ++++++++++-
 arch/arm/boot/dts/kirkwood-ts219.dtsi     |    3 +++
 arch/arm/mach-kirkwood/board-dnskw.c      |    7 +------
 arch/arm/mach-kirkwood/board-dreamplug.c  |   13 ++-----------
 arch/arm/mach-kirkwood/board-goflexnet.c  |    7 +------
 arch/arm/mach-kirkwood/board-ib62x0.c     |    7 +------
 arch/arm/mach-kirkwood/board-iconnect.c   |    7 +------
 arch/arm/mach-kirkwood/board-lsxl.c       |   13 ++-----------
 arch/arm/mach-kirkwood/board-ts219.c      |   10 +---------
 16 files changed, 128 insertions(+), 57 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-dnskw.dtsi b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
index 7408655..466a7c6 100644
--- a/arch/arm/boot/dts/kirkwood-dnskw.dtsi
+++ b/arch/arm/boot/dts/kirkwood-dnskw.dtsi
@@ -65,5 +65,17 @@
 				reg = <0x7b00000 0x500000>;
 			};
 		};
+
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
+
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x88>;
+			interrupts = <11>;
+		};
 	};
 };
diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts b/arch/arm/boot/dts/kirkwood-dreamplug.dts
index 26e281f..83ada56 100644
--- a/arch/arm/boot/dts/kirkwood-dreamplug.dts
+++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
@@ -53,6 +53,30 @@
 			status = "okay";
 			nr-ports = <1>;
 		};
+
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
+
+		smi1: mdio at 76000 {
+			status = "ok";
+		};
+
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x80>;
+			interrupts = <11>;
+		};
+
+		egiga1 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi1>;
+			port_number = <0>;
+			phy_addr = <0x81>;
+			interrupts = <15>;
+		};
 	};
 
 	gpio-leds {
diff --git a/arch/arm/boot/dts/kirkwood-goflexnet.dts b/arch/arm/boot/dts/kirkwood-goflexnet.dts
index 7c8238f..4346303 100644
--- a/arch/arm/boot/dts/kirkwood-goflexnet.dts
+++ b/arch/arm/boot/dts/kirkwood-goflexnet.dts
@@ -50,6 +50,17 @@
 			nr-ports = <2>;
 		};
 
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
+
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x80>;
+			interrupts = <11>;
+		};
 	};
 	gpio-leds {
 		compatible = "gpio-leds";
diff --git a/arch/arm/boot/dts/kirkwood-ib62x0.dts b/arch/arm/boot/dts/kirkwood-ib62x0.dts
index 66794ed..0d0a0e6 100644
--- a/arch/arm/boot/dts/kirkwood-ib62x0.dts
+++ b/arch/arm/boot/dts/kirkwood-ib62x0.dts
@@ -45,6 +45,19 @@
 			};
 
 		};
+
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
+
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x88>;
+			interrupts = <11>;
+		};
+
 	};
 
 	gpio_keys {
diff --git a/arch/arm/boot/dts/kirkwood-iconnect.dts b/arch/arm/boot/dts/kirkwood-iconnect.dts
index 52d9470..aef754d 100644
--- a/arch/arm/boot/dts/kirkwood-iconnect.dts
+++ b/arch/arm/boot/dts/kirkwood-iconnect.dts
@@ -30,6 +30,19 @@
 			clock-frequency = <200000000>;
 			status = "ok";
 		};
+
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
+
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x8b>;
+			interrupts = <11>;
+		};
+
 	};
 	gpio-leds {
 		compatible = "gpio-leds";
diff --git a/arch/arm/boot/dts/kirkwood-lsxl.dtsi b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
index 8ac51c0..ae48bfb 100644
--- a/arch/arm/boot/dts/kirkwood-lsxl.dtsi
+++ b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
@@ -40,6 +40,29 @@
 				};
 			};
 		};
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
+
+		smi1: mdio at 76000 {
+			status = "ok";
+		};
+
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x80>;
+			interrupts = <11>;
+		};
+
+		egiga1 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi1>;
+			port_number = <0>;
+			phy_addr = <0x88>;
+			interrupts = <15>;
+		};
 	};
 
 	gpio_keys {
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6281.dts b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
index ccbf327..6813321 100644
--- a/arch/arm/boot/dts/kirkwood-ts219-6281.dts
+++ b/arch/arm/boot/dts/kirkwood-ts219-6281.dts
@@ -3,6 +3,15 @@
 /include/ "kirkwood-ts219.dtsi"
 
 / {
+	ocp at f1000000 {
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x88>;
+			interrupts = <11>;
+		};
+	};
 	gpio_keys {
 		compatible = "gpio-keys";
 		#address-cells = <1>;
@@ -18,4 +27,4 @@
 			gpios = <&gpio0 16 1>;
 		};
 	};
-};
\ No newline at end of file
+};
diff --git a/arch/arm/boot/dts/kirkwood-ts219-6282.dts b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
index fbe9932..af68a71 100644
--- a/arch/arm/boot/dts/kirkwood-ts219-6282.dts
+++ b/arch/arm/boot/dts/kirkwood-ts219-6282.dts
@@ -3,6 +3,15 @@
 /include/ "kirkwood-ts219.dtsi"
 
 / {
+	ocp at f1000000 {
+		egiga0 {
+			compatible = "marvell,mv643xx";
+			mdio = <&smi0>;
+			port_number = <0>;
+			phy_addr = <0x80>;
+			interrupts = <11>;
+		};
+	};
 	gpio_keys {
 		compatible = "gpio-keys";
 		#address-cells = <1>;
@@ -18,4 +27,4 @@
 			gpios = <&gpio1 5 1>;
 		};
 	};
-};
\ No newline at end of file
+};
diff --git a/arch/arm/boot/dts/kirkwood-ts219.dtsi b/arch/arm/boot/dts/kirkwood-ts219.dtsi
index 64ea27c..06caf41 100644
--- a/arch/arm/boot/dts/kirkwood-ts219.dtsi
+++ b/arch/arm/boot/dts/kirkwood-ts219.dtsi
@@ -74,5 +74,8 @@
 			status = "okay";
 			nr-ports = <2>;
 		};
+		smi0: mdio at 72000 {
+			status = "ok";
+		};
 	};
 };
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index 4ab3506..4d8216b 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -15,7 +15,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/ata_platform.h>
-#include <linux/mv643xx_eth.h>
 #include <linux/of.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
@@ -29,10 +28,6 @@
 #include "common.h"
 #include "mpp.h"
 
-static struct mv643xx_eth_platform_data dnskw_ge00_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
-};
-
 static unsigned int dnskw_mpp_config[] __initdata = {
 	MPP13_UART1_TXD,	/* Custom ... */
 	MPP14_UART1_RXD,	/* ... Controller (DNS-320 only) */
@@ -112,7 +107,7 @@ void __init dnskw_init(void)
 	kirkwood_mpp_conf(dnskw_mpp_config);
 
 	kirkwood_ehci_init();
-	kirkwood_ge00_init(&dnskw_ge00_data);
+	kirkwood_ge00_init(NULL);
 
 	platform_device_register(&dnskw_fan_device);
 
diff --git a/arch/arm/mach-kirkwood/board-dreamplug.c b/arch/arm/mach-kirkwood/board-dreamplug.c
index aeb234d..b97a112 100644
--- a/arch/arm/mach-kirkwood/board-dreamplug.c
+++ b/arch/arm/mach-kirkwood/board-dreamplug.c
@@ -15,7 +15,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/ata_platform.h>
-#include <linux/mv643xx_eth.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_fdt.h>
@@ -34,14 +33,6 @@
 #include "common.h"
 #include "mpp.h"
 
-static struct mv643xx_eth_platform_data dreamplug_ge00_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data dreamplug_ge01_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(1),
-};
-
 static struct mvsdio_platform_data dreamplug_mvsdio_data = {
 	/* unfortunately the CD signal has not been connected */
 };
@@ -65,7 +56,7 @@ void __init dreamplug_init(void)
 	kirkwood_mpp_conf(dreamplug_mpp_config);
 
 	kirkwood_ehci_init();
-	kirkwood_ge00_init(&dreamplug_ge00_data);
-	kirkwood_ge01_init(&dreamplug_ge01_data);
+	kirkwood_ge00_init(NULL);
+	kirkwood_ge01_init(NULL);
 	kirkwood_sdio_init(&dreamplug_mvsdio_data);
 }
diff --git a/arch/arm/mach-kirkwood/board-goflexnet.c b/arch/arm/mach-kirkwood/board-goflexnet.c
index 413e2c8..be7437d 100644
--- a/arch/arm/mach-kirkwood/board-goflexnet.c
+++ b/arch/arm/mach-kirkwood/board-goflexnet.c
@@ -20,7 +20,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/ata_platform.h>
-#include <linux/mv643xx_eth.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_fdt.h>
@@ -36,10 +35,6 @@
 #include "common.h"
 #include "mpp.h"
 
-static struct mv643xx_eth_platform_data goflexnet_ge00_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
-};
-
 static unsigned int goflexnet_mpp_config[] __initdata = {
 	MPP29_GPIO,	/* USB Power Enable */
 	MPP47_GPIO,	/* LED Orange */
@@ -67,5 +62,5 @@ void __init goflexnet_init(void)
 		pr_err("can't setup GPIO 29 (USB Power Enable)\n");
 	kirkwood_ehci_init();
 
-	kirkwood_ge00_init(&goflexnet_ge00_data);
+	kirkwood_ge00_init(NULL);
 }
diff --git a/arch/arm/mach-kirkwood/board-ib62x0.c b/arch/arm/mach-kirkwood/board-ib62x0.c
index cfc47f8..0a29183 100644
--- a/arch/arm/mach-kirkwood/board-ib62x0.c
+++ b/arch/arm/mach-kirkwood/board-ib62x0.c
@@ -16,7 +16,6 @@
 #include <linux/platform_device.h>
 #include <linux/mtd/partitions.h>
 #include <linux/ata_platform.h>
-#include <linux/mv643xx_eth.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <asm/mach-types.h>
@@ -27,10 +26,6 @@
 
 #define IB62X0_GPIO_POWER_OFF	24
 
-static struct mv643xx_eth_platform_data ib62x0_ge00_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
-};
-
 static unsigned int ib62x0_mpp_config[] __initdata = {
 	MPP0_NF_IO2,
 	MPP1_NF_IO3,
@@ -62,7 +57,7 @@ void __init ib62x0_init(void)
 	kirkwood_mpp_conf(ib62x0_mpp_config);
 
 	kirkwood_ehci_init();
-	kirkwood_ge00_init(&ib62x0_ge00_data);
+	kirkwood_ge00_init(NULL);
 	if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 &&
 	    gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0)
 		pm_power_off = ib62x0_power_off;
diff --git a/arch/arm/mach-kirkwood/board-iconnect.c b/arch/arm/mach-kirkwood/board-iconnect.c
index d7a9198..220f0d4 100644
--- a/arch/arm/mach-kirkwood/board-iconnect.c
+++ b/arch/arm/mach-kirkwood/board-iconnect.c
@@ -17,7 +17,6 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/mtd/partitions.h>
-#include <linux/mv643xx_eth.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
@@ -26,10 +25,6 @@
 #include "common.h"
 #include "mpp.h"
 
-static struct mv643xx_eth_platform_data iconnect_ge00_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(11),
-};
-
 static unsigned int iconnect_mpp_config[] __initdata = {
 	MPP12_GPIO,
 	MPP35_GPIO,
@@ -92,7 +87,7 @@ void __init iconnect_init(void)
 	kirkwood_nand_init(ARRAY_AND_SIZE(iconnect_nand_parts), 25);
 
 	kirkwood_ehci_init();
-	kirkwood_ge00_init(&iconnect_ge00_data);
+	kirkwood_ge00_init(NULL);
 
 	platform_device_register(&iconnect_button_device);
 }
diff --git a/arch/arm/mach-kirkwood/board-lsxl.c b/arch/arm/mach-kirkwood/board-lsxl.c
index 83d8975..60331d1 100644
--- a/arch/arm/mach-kirkwood/board-lsxl.c
+++ b/arch/arm/mach-kirkwood/board-lsxl.c
@@ -18,7 +18,6 @@
 #include <linux/ata_platform.h>
 #include <linux/spi/flash.h>
 #include <linux/spi/spi.h>
-#include <linux/mv643xx_eth.h>
 #include <linux/gpio.h>
 #include <linux/gpio-fan.h>
 #include <linux/input.h>
@@ -28,14 +27,6 @@
 #include "common.h"
 #include "mpp.h"
 
-static struct mv643xx_eth_platform_data lsxl_ge00_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
-};
-
-static struct mv643xx_eth_platform_data lsxl_ge01_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
-};
-
 static unsigned int lsxl_mpp_config[] __initdata = {
 	MPP10_GPO,	/* HDD Power Enable */
 	MPP11_GPIO,	/* USB Vbus Enable */
@@ -126,8 +117,8 @@ void __init lsxl_init(void)
 	gpio_set_value(LSXL_GPIO_HDD_POWER, 1);
 
 	kirkwood_ehci_init();
-	kirkwood_ge00_init(&lsxl_ge00_data);
-	kirkwood_ge01_init(&lsxl_ge01_data);
+	kirkwood_ge00_init(NULL);
+	kirkwood_ge01_init(NULL);
 	platform_device_register(&lsxl_fan_device);
 
 	/* register power-off method */
diff --git a/arch/arm/mach-kirkwood/board-ts219.c b/arch/arm/mach-kirkwood/board-ts219.c
index 1750e68..7e7fe6c 100644
--- a/arch/arm/mach-kirkwood/board-ts219.c
+++ b/arch/arm/mach-kirkwood/board-ts219.c
@@ -18,7 +18,6 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/mv643xx_eth.h>
 #include <linux/ata_platform.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
@@ -29,10 +28,6 @@
 #include "mpp.h"
 #include "tsx1x-common.h"
 
-static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = {
-	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
-};
-
 static unsigned int qnap_ts219_mpp_config[] __initdata = {
 	MPP0_SPI_SCn,
 	MPP1_SPI_MOSI,
@@ -62,10 +57,7 @@ void __init qnap_dt_ts219_init(void)
 	kirkwood_mpp_conf(qnap_ts219_mpp_config);
 
 	kirkwood_pcie_id(&dev, &rev);
-	if (dev == MV88F6282_DEV_ID)
-		qnap_ts219_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
-
-	kirkwood_ge00_init(&qnap_ts219_ge00_data);
+	kirkwood_ge00_init(NULL);
 	kirkwood_ehci_init();
 
 	pm_power_off = qnap_tsx1x_power_off;
-- 
1.7.9.5

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

* [PATCH 1/6] Initial csb1724 board support (FDT)
  2012-07-30 15:15 ` [PATCH 1/6] Initial csb1724 board support (FDT) Ian Molton
@ 2012-07-30 15:28   ` Andrew Lunn
  2012-07-30 16:28     ` Ian Molton
  0 siblings, 1 reply; 35+ messages in thread
From: Andrew Lunn @ 2012-07-30 15:28 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ian

> diff --git a/arch/arm/configs/csb1724_defconfig b/arch/arm/configs/csb1724_defconfig
> new file mode 100644
> index 0000000..927b269
> --- /dev/null
> +++ b/arch/arm/configs/csb1724_defconfig
> @@ -0,0 +1,47 @@
> +CONFIG_ARCH_KIRKWOOD=y
> +CONFIG_ARCH_KIRKWOOD_DT=y
> +CONFIG_MACH_CSB1724_DT=y

Do you really need this? Its the only kirkwood board with its on
_defconfig file.  What makes this board special?

   Thanks
	Andrew

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-30 15:15 ` [PATCH 3/6] mv643xx.c: Add basic device tree support Ian Molton
@ 2012-07-30 15:39   ` Andrew Lunn
  2012-07-30 16:49     ` Ian Molton
  2012-07-30 16:19   ` Amar Nath
  2012-07-31  7:14   ` Arnaud Patard (Rtp)
  2 siblings, 1 reply; 35+ messages in thread
From: Andrew Lunn @ 2012-07-30 15:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jul 30, 2012 at 04:15:56PM +0100, Ian Molton wrote:
> This patch adds basic device tree support to the mv643xx ethernet driver.
> 
> It should be enough for most current users of the device, and should allow
> a fairly painless migration once proper support for clk devices is available
> to those platforms.
> 
> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  drivers/net/ethernet/marvell/mv643xx_eth.c |  111 ++++++++++++++++++++++++----
>  1 file changed, 97 insertions(+), 14 deletions(-)

Hi Ian

Please document the DT binding in Documentation/devicetree/binding/....

Also, this should also be CC: to the netdev mailing. I got into
trouble for not doing this and breaking the PPC build :-(

	Andrew

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

* [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support.
  2012-07-30 15:15 ` [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support Ian Molton
@ 2012-07-30 15:55   ` Andrew Lunn
  2012-07-30 16:58     ` Ian Molton
  2012-07-30 16:17   ` Andrew Lunn
  1 sibling, 1 reply; 35+ messages in thread
From: Andrew Lunn @ 2012-07-30 15:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jul 30, 2012 at 04:15:58PM +0100, Ian Molton wrote:
>     This patch enables mv643xx based ethernet built into the SoM on the
>     csb1724, via flattened device tree.
> 
>     Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  arch/arm/boot/dts/kirkwood-csb1724.dts |   25 ++++++++++++++++++
>  arch/arm/boot/dts/kirkwood.dtsi        |   16 ++++++++++++
>  arch/arm/configs/csb1724_defconfig     |   45 ++++++++++++++++++++++++++++++++
>  arch/arm/mach-kirkwood/board-csb1724.c |    3 +++
>  4 files changed, 89 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/kirkwood-csb1724.dts b/arch/arm/boot/dts/kirkwood-csb1724.dts
> index 44dfe9a..f652797 100644
> --- a/arch/arm/boot/dts/kirkwood-csb1724.dts
> +++ b/arch/arm/boot/dts/kirkwood-csb1724.dts
> @@ -25,6 +25,31 @@
>  			nr-ports = <2>;
>  			status = "ok";
>  		};
> +
> +		smi0: mdio at 72000 {
> +			status = "ok";
> +		};
> +
> +		smi1: mdio at 76000 {
> +			status = "ok";
> +		};
> +
> +		egiga0 {
> +			compatible = "marvell,mv643xx";
> +			mdio = <&smi0>;
> +			port_number = <0>;
> +			phy_addr = <0x80>;
> +			interrupts = <11>;
> +		};
> +
> +		egiga1 {
> +			compatible = "marvell,mv643xx";
> +			mdio = <&smi1>;
> +			port_number = <0>;
> +			phy_addr = <0x81>;
> +			interrupts = <15>;
> +		};
> +
>  	};
>  
>  };
> diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
> index cef9616..dd10422 100644
> --- a/arch/arm/boot/dts/kirkwood.dtsi
> +++ b/arch/arm/boot/dts/kirkwood.dtsi
> @@ -105,5 +105,21 @@
>  			clock-frequency = <100000>;
>  			status = "disabled";
>  		};
> +
> +		smi0: mdio at 72000 {
> +			compatible = "marvell,mdio-mv643xx";
> +			reg = <0x72000 0x4000>;
> +			interrupts = <46>;
> +			status = "disabled";
> +		};
> +
> +		smi1: mdio at 76000 {
> +			compatible = "marvell,mdio-mv643xx";
> +			reg = <0x76000 0x4000>;
> +			interrupts = <47>;
> +			shared_smi = <&smi0>;
> +			status = "disabled";
> +		};
> +


Hi Ian

I'm trying to keep this in order. Currently i2c is in the wrong place,
but the rest are incremental. It looks like these should be between
wdt & sata.

What about default entries for egiga0 and egiga1 with status
"disabled"? It looks like the only thing which changes between boards
is phy_addr.

   Andrew

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-30 15:15 ` [PATCH 4/6] kirkwood: setup clock only in eth helpers Ian Molton
@ 2012-07-30 16:12   ` Andrew Lunn
  2012-07-30 16:52     ` Ian Molton
  2012-07-30 16:46   ` Josh Coombs
  1 sibling, 1 reply; 35+ messages in thread
From: Andrew Lunn @ 2012-07-30 16:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jul 30, 2012 at 04:15:57PM +0100, Ian Molton wrote:
> This patch modifies the ethernet setup helper functions so that they can be
> used /purely/ to set up the clocks.

Hi Ian

Set up is a bit ambiguous. I would actually say, start the clock
ticking, if it is not already.

I'm also not sure this is the best way to do it. I'd like to throw in
a counter proposal, and then we can discuss....

Problems start then the ethernet driver is a module, not built in. In
this situation, the clock gets turned off, in a lateinitcall, and then
later turned back on again when the module loads. Unfortunately, by
then its forgotten its own MAC address, as programmed by u-boot. So
this clk_prepare_enable() is here to ensure that the clock does not
get turned off, when we know the module is likely to be loaded
sometime later.

I've not looked at the clk DT bindings yet. Does it provide a
mechanism to prepare & enable a named clock? Maybe it does, but this
seems a bit of an edge case.

What i would instead do is add code to board-dt.c which looks into the
DT and see if it finds nodes egige0/egige1 and if so, calls
clk_prepare_enable(). We then don't need any per board code.

Andrew		      

> 
> This is part of ongoing work to enable device tree support in the mv643xx.c
> ethernet driver, where as yet the kirkwood platform does not have proper clk
> support.
> 
> This should allow a gradual migration to device tree and later to proper clk
> support, wherupon the helper functions can be removed entirely.
> 
> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  arch/arm/mach-kirkwood/common.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
> index c4b64ad..c1776ea 100644
> --- a/arch/arm/mach-kirkwood/common.c
> +++ b/arch/arm/mach-kirkwood/common.c
> @@ -299,7 +299,8 @@ void __init kirkwood_ehci_init(void)
>   ****************************************************************************/
>  void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
>  {
> -	orion_ge00_init(eth_data,
> +	if (eth_data)
> +		orion_ge00_init(eth_data,
>  			GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
>  			IRQ_KIRKWOOD_GE00_ERR);
>  	/* The interface forgets the MAC address assigned by u-boot if
> @@ -313,7 +314,8 @@ void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
>   ****************************************************************************/
>  void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
>  {
> -	orion_ge01_init(eth_data,
> +	if (eth_data)
> +		orion_ge01_init(eth_data,
>  			GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
>  			IRQ_KIRKWOOD_GE01_ERR);
>  	clk_prepare_enable(ge1);
> -- 
> 1.7.9.5
> 

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

* [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support.
  2012-07-30 15:15 ` [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support Ian Molton
  2012-07-30 15:55   ` Andrew Lunn
@ 2012-07-30 16:17   ` Andrew Lunn
  2012-07-30 16:57     ` Ian Molton
  1 sibling, 1 reply; 35+ messages in thread
From: Andrew Lunn @ 2012-07-30 16:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jul 30, 2012 at 04:15:58PM +0100, Ian Molton wrote:
>     This patch enables mv643xx based ethernet built into the SoM on the
>     csb1724, via flattened device tree.
> 
>     Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  arch/arm/boot/dts/kirkwood-csb1724.dts |   25 ++++++++++++++++++
>  arch/arm/boot/dts/kirkwood.dtsi        |   16 ++++++++++++
>  arch/arm/configs/csb1724_defconfig     |   45 ++++++++++++++++++++++++++++++++
>  arch/arm/mach-kirkwood/board-csb1724.c |    3 +++
>  4 files changed, 89 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/kirkwood-csb1724.dts b/arch/arm/boot/dts/kirkwood-csb1724.dts
> index 44dfe9a..f652797 100644
> --- a/arch/arm/boot/dts/kirkwood-csb1724.dts
> +++ b/arch/arm/boot/dts/kirkwood-csb1724.dts
> @@ -25,6 +25,31 @@
>  			nr-ports = <2>;
>  			status = "ok";
>  		};
> +
> +		smi0: mdio at 72000 {
> +			status = "ok";
> +		};
> +
> +		smi1: mdio at 76000 {
> +			status = "ok";
> +		};
> +
> +		egiga0 {
> +			compatible = "marvell,mv643xx";
> +			mdio = <&smi0>;
> +			port_number = <0>;
> +			phy_addr = <0x80>;
> +			interrupts = <11>;
> +		};

Hi Ian

Shouldn't there be two interrupt here?

 292         orion_ge00_init(eth_data,
 293                         GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
 294                         IRQ_KIRKWOOD_GE00_ERR);

Documentation of the binding would help....

     Andrew

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-30 15:15 ` [PATCH 3/6] mv643xx.c: Add basic device tree support Ian Molton
  2012-07-30 15:39   ` Andrew Lunn
@ 2012-07-30 16:19   ` Amar Nath
  2012-07-30 16:32     ` Ian Molton
  2012-07-31  7:14   ` Arnaud Patard (Rtp)
  2 siblings, 1 reply; 35+ messages in thread
From: Amar Nath @ 2012-07-30 16:19 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Ian,

On Mon, Jul 30, 2012 at 8:45 PM, Ian Molton <ian.molton@codethink.co.uk>wrote:

> This patch adds basic device tree support to the mv643xx ethernet driver.
>
> It should be enough for most current users of the device, and should allow
> a fairly painless migration once proper support for clk devices is
> available
> to those platforms.
>
> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  drivers/net/ethernet/marvell/mv643xx_eth.c |  111
> ++++++++++++++++++++++++----
>  1 file changed, 97 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c
> b/drivers/net/ethernet/marvell/mv643xx_eth.c
> index 92497eb..579692f 100644
> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
> @@ -48,6 +48,9 @@
>  #include <linux/ethtool.h>
>  #include <linux/platform_device.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_irq.h>
>  #include <linux/kernel.h>
>  #include <linux/spinlock.h>
>  #include <linux/workqueue.h>
> @@ -2601,11 +2604,11 @@ static void infer_hw_params(struct
> mv643xx_eth_shared_private *msp)
>  static int mv643xx_eth_shared_probe(struct platform_device *pdev)
>  {
>         static int mv643xx_eth_version_printed;
> -       struct mv643xx_eth_shared_platform_data *pd =
> pdev->dev.platform_data;
> +       struct mv643xx_eth_shared_platform_data *pd;
>         struct mv643xx_eth_shared_private *msp;
>         const struct mbus_dram_target_info *dram;
>         struct resource *res;
> -       int ret;
> +       int ret, irq = -1;
>
>         if (!mv643xx_eth_version_printed++)
>                 pr_notice("MV-643xx 10/100/1000 ethernet driver version
> %s\n",
> @@ -2625,6 +2628,23 @@ static int mv643xx_eth_shared_probe(struct
> platform_device *pdev)
>         if (msp->base == NULL)
>                 goto out_free;
>
> +       if (pdev->dev.of_node) {
> +               struct device_node *np = NULL;
> +
> +               /* when all users of this driver use FDT, we can remove
> this */
> +               pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
> +               if (!pd) {
> +                       dev_dbg(&pdev->dev, "Could not allocate platform
> data\n");
> +                       goto out_free;
> +               }
> +
> +               np = of_parse_phandle(pdev->dev.of_node, "shared_smi", 0);
> +               if (np)
> +                       pd->shared_smi = of_find_device_by_node(np);
> +
> +       } else {
> +               pd = pdev->dev.platform_data;
> +       }
>         /*
>          * Set up and register SMI bus.
>          */
> @@ -2654,15 +2674,22 @@ static int mv643xx_eth_shared_probe(struct
> platform_device *pdev)
>         /*
>          * Check whether the error interrupt is hooked up.
>          */
> -       res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> -       if (res != NULL) {
> +       if (pdev->dev.of_node) {
> +               irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
> +       } else {
> +               res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +               if (res)
> +                       irq = res->start;
> +       }
> +
> +       if (irq != -1) {
>                 int err;
>
> -               err = request_irq(res->start, mv643xx_eth_err_irq,
> +               err = request_irq(irq, mv643xx_eth_err_irq,
>                                   IRQF_SHARED, "mv643xx_eth", msp);
>                 if (!err) {
>                         writel(ERR_INT_SMI_DONE, msp->base + ERR_INT_MASK);
> -                       msp->err_interrupt = res->start;
> +                       msp->err_interrupt = irq;
>                 }
>         }
>
> @@ -2675,6 +2702,10 @@ static int mv643xx_eth_shared_probe(struct
> platform_device *pdev)
>
>         msp->tx_csum_limit = (pd != NULL && pd->tx_csum_limit) ?
>                                         pd->tx_csum_limit : 9 * 1024;
> +
> +       if (pdev->dev.of_node)
> +               kfree(pd);  /* If we created a fake pd, free it now */
> +
>         infer_hw_params(msp);
>
>         platform_set_drvdata(pdev, msp);
> @@ -2708,12 +2739,21 @@ static int mv643xx_eth_shared_remove(struct
> platform_device *pdev)
>         return 0;
>  }
>
> +#ifdef CONFIG_OF
> +static struct of_device_id mv_mdio_dt_ids[] __devinitdata = {
> +       { .compatible = "marvell,mdio-mv643xx", },
> +       {},
> +};
> +MODULE_DEVICE_TABLE(of, mv_mdio_dt_ids);
> +#endif
> +
>  static struct platform_driver mv643xx_eth_shared_driver = {
>         .probe          = mv643xx_eth_shared_probe,
>         .remove         = mv643xx_eth_shared_remove,
>         .driver = {
>                 .name   = MV643XX_ETH_SHARED_NAME,
>                 .owner  = THIS_MODULE,
> +               .of_match_table = of_match_ptr(mv_mdio_dt_ids),
>         },
>  };
>
> @@ -2873,7 +2913,31 @@ static int mv643xx_eth_probe(struct platform_device
> *pdev)
>         struct resource *res;
>         int err;
>
> -       pd = pdev->dev.platform_data;
> +       if (pdev->dev.of_node) {
> +               struct device_node *np = NULL;
> +
> +               /* when all users of this driver use FDT, we can remove
> this */
> +               pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
> +               if (!pd) {
> +                       dev_dbg(&pdev->dev, "Could not allocate platform
> data\n");
> +                       return -ENOMEM;
> +               }
> +
> +               of_property_read_u32(pdev->dev.of_node,
> +                       "port_number", &pd->port_number);
> +               of_property_read_u32(pdev->dev.of_node,
> +                       "phy_addr", &pd->phy_addr);
> +               np = of_parse_phandle(pdev->dev.of_node, "mdio", 0);
> +               if (np) {
> +                       pd->shared = of_find_device_by_node(np);
> +               } else {
> +                       kfree(pd);
> +                       return -ENODEV;
> +               }
> +       } else {
> +               pd = pdev->dev.platform_data;
> +       }
> +
>         if (pd == NULL) {
>                 dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
>                 return -ENODEV;
>

Can this check for pd be moved in the else part above as well, as for the
pd allocation with kzalloc,
we have already made a check for memory allocation failure?



> @@ -2881,12 +2945,15 @@ static int mv643xx_eth_probe(struct
> platform_device *pdev)
>
>         if (pd->shared == NULL) {
>                 dev_err(&pdev->dev, "no
> mv643xx_eth_platform_data->shared\n");
> -               return -ENODEV;
> +               err = -ENODEV;
> +               goto out_free_pd;
>         }
>
>         dev = alloc_etherdev_mq(sizeof(struct mv643xx_eth_private), 8);
> -       if (!dev)
> -               return -ENOMEM;
> +       if (!dev) {
> +               err = -ENOMEM;
> +               goto out_free_pd;
> +       }
>
>         mp = netdev_priv(dev);
>         platform_set_drvdata(pdev, mp);
> @@ -2923,6 +2990,8 @@ static int mv643xx_eth_probe(struct platform_device
> *pdev)
>
>         init_pscr(mp, pd->speed, pd->duplex);
>
> +       if (pdev->dev.of_node)
> +               kfree(pd); /* If we created a fake pd, free it now */
>
>         mib_counters_clear(mp);
>
> @@ -2942,10 +3011,13 @@ static int mv643xx_eth_probe(struct
> platform_device *pdev)
>         mp->rx_oom.data = (unsigned long)mp;
>         mp->rx_oom.function = oom_timer_wrapper;
>
> -
> -       res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> -       BUG_ON(!res);
> -       dev->irq = res->start;
> +       if (pdev->dev.of_node) {
> +               dev->irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
> +       } else {
> +               res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +               BUG_ON(!res);
> +               dev->irq = res->start;
> +       }
>
>         dev->netdev_ops = &mv643xx_eth_netdev_ops;
>
> @@ -2991,6 +3063,8 @@ out:
>         }
>  #endif
>         free_netdev(dev);
> +out_free_pd:
> +       kfree(pd);
>
>         return err;
>  }
> @@ -3030,6 +3104,14 @@ static void mv643xx_eth_shutdown(struct
> platform_device *pdev)
>                 port_reset(mp);
>  }
>
> +#ifdef CONFIG_OF
> +static struct of_device_id mv_eth_dt_ids[] __devinitdata = {
> +       { .compatible = "marvell,mv643xx", },
> +       {},
> +};
> +MODULE_DEVICE_TABLE(of, mv_eth_dt_ids);
> +#endif
> +
>  static struct platform_driver mv643xx_eth_driver = {
>         .probe          = mv643xx_eth_probe,
>         .remove         = mv643xx_eth_remove,
> @@ -3037,6 +3119,7 @@ static struct platform_driver mv643xx_eth_driver = {
>         .driver = {
>                 .name   = MV643XX_ETH_NAME,
>                 .owner  = THIS_MODULE,
> +               .of_match_table = of_match_ptr(mv_eth_dt_ids),
>         },
>  };
>
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel



Regards,
-Amar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120730/a2bd46ae/attachment-0001.html>

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

* [PATCH 1/6] Initial csb1724 board support (FDT)
  2012-07-30 15:28   ` Andrew Lunn
@ 2012-07-30 16:28     ` Ian Molton
  2012-07-31 11:27       ` Arnd Bergmann
  0 siblings, 1 reply; 35+ messages in thread
From: Ian Molton @ 2012-07-30 16:28 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 16:28, Andrew Lunn wrote:
> Hi Ian
>
>> diff --git a/arch/arm/configs/csb1724_defconfig
>> b/arch/arm/configs/csb1724_defconfig new file mode 100644 index
>> 0000000..927b269 --- /dev/null +++
>> b/arch/arm/configs/csb1724_defconfig @@ -0,0 +1,47 @@
>> +CONFIG_ARCH_KIRKWOOD=y +CONFIG_ARCH_KIRKWOOD_DT=y
>> +CONFIG_MACH_CSB1724_DT=y
> Do you really need this? Its the only kirkwood board with its on
> _defconfig file. What makes this board special?

Nothing. defconfigs are just there to make configuring your kernel easy.

The kirkwood defconfig doesnt fit the currently supported hardware
set on the csb1724 very well. Why build stuff you dont need?

-Ian

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-30 16:19   ` Amar Nath
@ 2012-07-30 16:32     ` Ian Molton
  2012-07-31 15:12       ` Florian Fainelli
  0 siblings, 1 reply; 35+ messages in thread
From: Ian Molton @ 2012-07-30 16:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 17:19, Amar Nath wrote:
> Hi Ian,
>
> On Mon, Jul 30, 2012 at 8:45 PM, Ian Molton <ian.molton@codethink.co.uk>wrote:
>
>> -       pd = pdev->dev.platform_data;
>> +       if (pdev->dev.of_node) {
>> +               struct device_node *np = NULL;
>> +
>> +               /* when all users of this driver use FDT, we can remove
>> this */
>> +               pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
>> +               if (!pd) {
>> +                       dev_dbg(&pdev->dev, "Could not allocate platform
>> data\n");
>> +                       return -ENOMEM;
>> +               }
>> +
>> +               of_property_read_u32(pdev->dev.of_node,
>> +                       "port_number", &pd->port_number);
>> +               of_property_read_u32(pdev->dev.of_node,
>> +                       "phy_addr", &pd->phy_addr);
>> +               np = of_parse_phandle(pdev->dev.of_node, "mdio", 0);
>> +               if (np) {
>> +                       pd->shared = of_find_device_by_node(np);
>> +               } else {
>> +                       kfree(pd);
>> +                       return -ENODEV;
>> +               }
>> +       } else {
>> +               pd = pdev->dev.platform_data;
>> +       }
>> +
>>         if (pd == NULL) {
>>                 dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
>>                 return -ENODEV;
>>
> Can this check for pd be moved in the else part above as well, as for the
> pd allocation with kzalloc,
> we have already made a check for memory allocation failure?

Yes, Folded in for v2.

-Ian

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-30 15:15 ` [PATCH 4/6] kirkwood: setup clock only in eth helpers Ian Molton
  2012-07-30 16:12   ` Andrew Lunn
@ 2012-07-30 16:46   ` Josh Coombs
  2012-07-31  8:23     ` Ian Molton
  2012-07-31 11:04     ` Ian Molton
  1 sibling, 2 replies; 35+ messages in thread
From: Josh Coombs @ 2012-07-30 16:46 UTC (permalink / raw)
  To: linux-arm-kernel

If I'm reading this correctly, if kirkwood_ge00_init is called without
any data, all that happens is the clock is enabled.  If the right data
is passed in, the ethernet interface is initialized, and then the
clock is enabled.

Patch 6 in your series sets all the existing DT board files to call
kirkwood_ge00_init with no data.

Would it make more sense for readability to separate the clock prep
and other interface initialization so DT board files don't appear to
be calling for a full turn up despite now handling that in the DTS
tree?  IE instead of converting all the board-XXX.c to call
kirkwood_ge00_init(NULL) have them call a new function,
kirkwood_ge00_clk_prep(NULL) instead, assuming the clock can't be
handled directly via DTS.

Josh C

On Mon, Jul 30, 2012 at 11:15 AM, Ian Molton <ian.molton@codethink.co.uk> wrote:
> This patch modifies the ethernet setup helper functions so that they can be
> used /purely/ to set up the clocks.
>
> This is part of ongoing work to enable device tree support in the mv643xx.c
> ethernet driver, where as yet the kirkwood platform does not have proper clk
> support.
>
> This should allow a gradual migration to device tree and later to proper clk
> support, wherupon the helper functions can be removed entirely.
>
> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  arch/arm/mach-kirkwood/common.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
> index c4b64ad..c1776ea 100644
> --- a/arch/arm/mach-kirkwood/common.c
> +++ b/arch/arm/mach-kirkwood/common.c
> @@ -299,7 +299,8 @@ void __init kirkwood_ehci_init(void)
>   ****************************************************************************/
>  void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
>  {
> -       orion_ge00_init(eth_data,
> +       if (eth_data)
> +               orion_ge00_init(eth_data,
>                         GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM,
>                         IRQ_KIRKWOOD_GE00_ERR);
>         /* The interface forgets the MAC address assigned by u-boot if
> @@ -313,7 +314,8 @@ void __init kirkwood_ge00_init(struct mv643xx_eth_platform_data *eth_data)
>   ****************************************************************************/
>  void __init kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data)
>  {
> -       orion_ge01_init(eth_data,
> +       if (eth_data)
> +               orion_ge01_init(eth_data,
>                         GE01_PHYS_BASE, IRQ_KIRKWOOD_GE01_SUM,
>                         IRQ_KIRKWOOD_GE01_ERR);
>         clk_prepare_enable(ge1);
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-30 15:39   ` Andrew Lunn
@ 2012-07-30 16:49     ` Ian Molton
  0 siblings, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 16:49 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 16:39, Andrew Lunn wrote:
> On Mon, Jul 30, 2012 at 04:15:56PM +0100, Ian Molton wrote:
>> This patch adds basic device tree support to the mv643xx ethernet
>> driver.
>>
>> It should be enough for most current users of the device, and
>> should allow a fairly painless migration once proper support for
>> clk devices is available to those platforms.
>>
>> Signed-off-by: Ian Molton <ian.molton@codethink.co.uk> ---
>> drivers/net/ethernet/marvell/mv643xx_eth.c | 111
>> ++++++++++++++++++++++++---- 1 file changed, 97 insertions(+), 14
>> deletions(-)
>
> Hi Ian
>
> Please document the DT binding in
> Documentation/devicetree/binding/....

Done.

> Also, this should also be CC: to the netdev mailing. I got into
> trouble for not doing this and breaking the PPC build :-(

Will do so for v2, thanks.

-Ian

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-30 16:12   ` Andrew Lunn
@ 2012-07-30 16:52     ` Ian Molton
  2012-07-30 19:10       ` Andrew Lunn
  0 siblings, 1 reply; 35+ messages in thread
From: Ian Molton @ 2012-07-30 16:52 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 17:12, Andrew Lunn wrote:
> On Mon, Jul 30, 2012 at 04:15:57PM +0100, Ian Molton wrote:
>> This patch modifies the ethernet setup helper functions so that
>> they can be used /purely/ to set up the clocks.
>
> Hi Ian
>
> Set up is a bit ambiguous. I would actually say, start the clock
> ticking, if it is not already.

Fair.

> I'm also not sure this is the best way to do it. I'd like to throw
> in a counter proposal, and then we can discuss....
>
> Problems start then the ethernet driver is a module, not built in.

I find that even if built in, it fails, not because it forgets its MAC, but
later, it hangs because as yet it does not know how to handle the clk
when it is set up from DT bindings. (Kirkwood doesnt really have this
support yet AFAICT).

> I've not looked at the clk DT bindings yet. Does it provide a
> mechanism to prepare & enable a named clock? Maybe it does, but this
> seems a bit of an edge case.

If it does, I cant see it.

> What i would instead do is add code to board-dt.c which looks into
> the DT and see if it finds nodes egige0/egige1 and if so, calls
> clk_prepare_enable(). We then don't need any per board code.

I agree, this seems like a good compromise for now.

I will implement this for v2.

-Ian

-Ian

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

* [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support.
  2012-07-30 16:17   ` Andrew Lunn
@ 2012-07-30 16:57     ` Ian Molton
  0 siblings, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 16:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 17:17, Andrew Lunn wrote:

> Hi Ian
>
> Shouldn't there be two interrupt here?
>
> 292 orion_ge00_init(eth_data, 293
> GE00_PHYS_BASE, IRQ_KIRKWOOD_GE00_SUM, 294
> IRQ_KIRKWOOD_GE00_ERR);

No. This is thanks to the horrific mess in the mv643xx driver - its got
two drivers in one source file, and they do horrid things like pass
round base addresses.

Im making an effort to try to split them out into seperate mdio and
MAC/PHY drivers.

This is a start. :)

-Ian

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

* [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support.
  2012-07-30 15:55   ` Andrew Lunn
@ 2012-07-30 16:58     ` Ian Molton
  0 siblings, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-30 16:58 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 16:55, Andrew Lunn wrote:
> On Mon, Jul 30, 2012 at 04:15:58PM +0100, Ian Molton wrote:

> Hi Ian
>
> I'm trying to keep this in order. Currently i2c is in the wrong
> place, but the rest are incremental. It looks like these should be
> between wdt & sata.

Will fix.

> What about default entries for egiga0 and egiga1 with status
> "disabled"? It looks like the only thing which changes between
> boards is phy_addr.

Seems sensible. I'll change that for v2.

-Ian

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-30 16:52     ` Ian Molton
@ 2012-07-30 19:10       ` Andrew Lunn
  0 siblings, 0 replies; 35+ messages in thread
From: Andrew Lunn @ 2012-07-30 19:10 UTC (permalink / raw)
  To: linux-arm-kernel

> I find that even if built in, it fails, not because it forgets its MAC, but
> later, it hangs because as yet it does not know how to handle the clk
> when it is set up from DT bindings. (Kirkwood doesnt really have this
> support yet AFAICT).

Ah, of course. You are missing auxdata in board-dt.c!

    Andrew

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-30 15:15 ` [PATCH 3/6] mv643xx.c: Add basic device tree support Ian Molton
  2012-07-30 15:39   ` Andrew Lunn
  2012-07-30 16:19   ` Amar Nath
@ 2012-07-31  7:14   ` Arnaud Patard (Rtp)
  2012-07-31  8:19     ` Ian Molton
  2012-07-31 14:30     ` Ben Dooks
  2 siblings, 2 replies; 35+ messages in thread
From: Arnaud Patard (Rtp) @ 2012-07-31  7:14 UTC (permalink / raw)
  To: linux-arm-kernel

Ian Molton <ian.molton@codethink.co.uk> writes:
Hi,

[...]

> @@ -2873,7 +2913,31 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
>  	struct resource *res;
>  	int err;
>  
> -	pd = pdev->dev.platform_data;
> +	if (pdev->dev.of_node) {
> +		struct device_node *np = NULL;
> +
> +		/* when all users of this driver use FDT, we can remove this */
> +		pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
> +		if (!pd) {
> +			dev_dbg(&pdev->dev, "Could not allocate platform data\n");
> +			return -ENOMEM;
> +		}
> +
> +		of_property_read_u32(pdev->dev.of_node,
> +			"port_number", &pd->port_number);
> +		of_property_read_u32(pdev->dev.of_node,
> +			"phy_addr", &pd->phy_addr);

I guess we need something for tx_csum_limit in the device tree too. It's
important for kirkwood and dove.

Arnaud

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-31  7:14   ` Arnaud Patard (Rtp)
@ 2012-07-31  8:19     ` Ian Molton
  2012-07-31  8:27       ` Andrew Lunn
  2012-07-31 14:30     ` Ben Dooks
  1 sibling, 1 reply; 35+ messages in thread
From: Ian Molton @ 2012-07-31  8:19 UTC (permalink / raw)
  To: linux-arm-kernel

On 31/07/12 08:14, Arnaud Patard (Rtp) wrote:
> Ian Molton <ian.molton@codethink.co.uk> writes:
> Hi,
>
> [...]
>
>> @@ -2873,7 +2913,31 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
>>  	struct resource *res;
>>  	int err;
>>  
>> -	pd = pdev->dev.platform_data;
>> +	if (pdev->dev.of_node) {
>> +		struct device_node *np = NULL;
>> +
>> +		/* when all users of this driver use FDT, we can remove this */
>> +		pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
>> +		if (!pd) {
>> +			dev_dbg(&pdev->dev, "Could not allocate platform data\n");
>> +			return -ENOMEM;
>> +		}
>> +
>> +		of_property_read_u32(pdev->dev.of_node,
>> +			"port_number", &pd->port_number);
>> +		of_property_read_u32(pdev->dev.of_node,
>> +			"phy_addr", &pd->phy_addr);
> I guess we need something for tx_csum_limit in the device tree too. It's
> important for kirkwood and dove.

It was my intention to keep the patch as non-invasive as possible - none
of the platforms using D-T at present require this.

Furthermore, git grep shows nothing in mach-kirkwood or mach-dove using
at all...

Are you sure this is required? It can always be added if anything
actually uses it :)

-Ian

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-30 16:46   ` Josh Coombs
@ 2012-07-31  8:23     ` Ian Molton
  2012-07-31 11:04     ` Ian Molton
  1 sibling, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-31  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 17:46, Josh Coombs wrote:
> If I'm reading this correctly, if kirkwood_ge00_init is called without
> any data, all that happens is the clock is enabled.  If the right data
> is passed in, the ethernet interface is initialized, and then the
> clock is enabled.
>
> Patch 6 in your series sets all the existing DT board files to call
> kirkwood_ge00_init with no data.
>
> Would it make more sense for readability to separate the clock prep
> and other interface initialization so DT board files don't appear to
> be calling for a full turn up despite now handling that in the DTS
> tree?  IE instead of converting all the board-XXX.c to call
> kirkwood_ge00_init(NULL) have them call a new function,
> kirkwood_ge00_clk_prep(NULL) instead, assuming the clock can't be
> handled directly via DTS.

This is certainly possible, but I was trying to avoid yet another
function being added to the sources with a (necessarily) short
lifespan - it will only be needed until such time as the clk stuff
is sorted out, which is on my TODO list.

My preference would be to add a comment explaining the
choice in the code.

If its preferred, however, I have no real objection to splitting
out the functionality.

-Ian

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-31  8:19     ` Ian Molton
@ 2012-07-31  8:27       ` Andrew Lunn
  2012-07-31  8:45         ` Ian Molton
  0 siblings, 1 reply; 35+ messages in thread
From: Andrew Lunn @ 2012-07-31  8:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 31, 2012 at 09:19:52AM +0100, Ian Molton wrote:
> On 31/07/12 08:14, Arnaud Patard (Rtp) wrote:
> > Ian Molton <ian.molton@codethink.co.uk> writes:
> > Hi,
> >
> > [...]
> >
> >> @@ -2873,7 +2913,31 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
> >>  	struct resource *res;
> >>  	int err;
> >>  
> >> -	pd = pdev->dev.platform_data;
> >> +	if (pdev->dev.of_node) {
> >> +		struct device_node *np = NULL;
> >> +
> >> +		/* when all users of this driver use FDT, we can remove this */
> >> +		pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
> >> +		if (!pd) {
> >> +			dev_dbg(&pdev->dev, "Could not allocate platform data\n");
> >> +			return -ENOMEM;
> >> +		}
> >> +
> >> +		of_property_read_u32(pdev->dev.of_node,
> >> +			"port_number", &pd->port_number);
> >> +		of_property_read_u32(pdev->dev.of_node,
> >> +			"phy_addr", &pd->phy_addr);
> > I guess we need something for tx_csum_limit in the device tree too. It's
> > important for kirkwood and dove.
> 
> It was my intention to keep the patch as non-invasive as possible - none
> of the platforms using D-T at present require this.
> 
> Furthermore, git grep shows nothing in mach-kirkwood or mach-dove using
> at all...
> 
> Are you sure this is required? It can always be added if anything
> actually uses it :)

Hi Ian

Try using jumbo packets on kirkwood.

http://comments.gmane.org/gmane.linux.ports.arm.kernel/178785
http://www.spinics.net/lists/arm-kernel/msg186152.html

	Andrew

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-31  8:27       ` Andrew Lunn
@ 2012-07-31  8:45         ` Ian Molton
  2012-07-31  8:58           ` Arnaud Patard (Rtp)
  0 siblings, 1 reply; 35+ messages in thread
From: Ian Molton @ 2012-07-31  8:45 UTC (permalink / raw)
  To: linux-arm-kernel

On 31/07/12 09:27, Andrew Lunn wrote:
> On Tue, Jul 31, 2012 at 09:19:52AM +0100, Ian Molton wrote:
>> Are you sure this is required? It can always be added if anything
>> actually uses it :)
> Hi Ian
>
> Try using jumbo packets on kirkwood.
>
> http://comments.gmane.org/gmane.linux.ports.arm.kernel/178785
> http://www.spinics.net/lists/arm-kernel/msg186152.html

Ah, this postdates the D-T branches on which I am working being forked.

I'll fold this into my patchset.

-Ian

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-31  8:45         ` Ian Molton
@ 2012-07-31  8:58           ` Arnaud Patard (Rtp)
  2012-07-31  9:14             ` Ian Molton
  0 siblings, 1 reply; 35+ messages in thread
From: Arnaud Patard (Rtp) @ 2012-07-31  8:58 UTC (permalink / raw)
  To: linux-arm-kernel

Ian Molton <ian.molton@codethink.co.uk> writes:

> On 31/07/12 09:27, Andrew Lunn wrote:
>> On Tue, Jul 31, 2012 at 09:19:52AM +0100, Ian Molton wrote:
>>> Are you sure this is required? It can always be added if anything
>>> actually uses it :)
>> Hi Ian
>>
>> Try using jumbo packets on kirkwood.
>>
>> http://comments.gmane.org/gmane.linux.ports.arm.kernel/178785
>> http://www.spinics.net/lists/arm-kernel/msg186152.html
>
> Ah, this postdates the D-T branches on which I am working being forked.

the original patch was from years ago but I noticed only recently it was
still not merged and sent this patch. I asked about it on DT because I
don't want it to get lost again, even if it looks like not a lot of
people are using jumbo frames on kirkwood or dove.

>
> I'll fold this into my patchset.

Thanks,
Arnaud

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-31  8:58           ` Arnaud Patard (Rtp)
@ 2012-07-31  9:14             ` Ian Molton
  0 siblings, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-31  9:14 UTC (permalink / raw)
  To: linux-arm-kernel

On 31/07/12 09:58, Arnaud Patard (Rtp) wrote:
>> Ah, this postdates the D-T branches on which I am working being forked.
> the original patch was from years ago but I noticed only recently it was
> still not merged and sent this patch. I asked about it on DT because I
> don't want it to get lost again, even if it looks like not a lot of
> people are using jumbo frames on kirkwood or dove.

No problem :) actually it works really nicely in DT, just drop it in
the toplevel includes!

-Ian

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-30 16:46   ` Josh Coombs
  2012-07-31  8:23     ` Ian Molton
@ 2012-07-31 11:04     ` Ian Molton
  2012-07-31 11:08       ` Andrew Lunn
  1 sibling, 1 reply; 35+ messages in thread
From: Ian Molton @ 2012-07-31 11:04 UTC (permalink / raw)
  To: linux-arm-kernel

On 30/07/12 17:46, Josh Coombs wrote:
> If I'm reading this correctly, if kirkwood_ge00_init is called without
> any data, all that happens is the clock is enabled.  If the right data
> is passed in, the ethernet interface is initialized, and then the
> clock is enabled.
>
> Patch 6 in your series sets all the existing DT board files to call
> kirkwood_ge00_init with no data.

Actually Im thinking of dropping this change altogether - it would
seem that since adding aliases so that the driver can managed
the clocks itself (thanks Andrew), the DT code apparently doesnt
disable the clocks, so the MAC is preserved.

I see no reason to keep the calls now that the driver manages to
hang onto its clocks.

-Ian

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-31 11:04     ` Ian Molton
@ 2012-07-31 11:08       ` Andrew Lunn
  2012-07-31 11:39         ` Ian Molton
  0 siblings, 1 reply; 35+ messages in thread
From: Andrew Lunn @ 2012-07-31 11:08 UTC (permalink / raw)
  To: linux-arm-kernel

> I see no reason to keep the calls now that the driver manages to
> hang onto its clocks.

Hi Ian

Did you test this with it built as a module? That is the real test....

    Andrew

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

* [PATCH 1/6] Initial csb1724 board support (FDT)
  2012-07-30 16:28     ` Ian Molton
@ 2012-07-31 11:27       ` Arnd Bergmann
  0 siblings, 0 replies; 35+ messages in thread
From: Arnd Bergmann @ 2012-07-31 11:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Monday 30 July 2012, Ian Molton wrote:
> On 30/07/12 16:28, Andrew Lunn wrote:
> > Hi Ian
> >
> >> diff --git a/arch/arm/configs/csb1724_defconfig
> >> b/arch/arm/configs/csb1724_defconfig new file mode 100644 index
> >> 0000000..927b269 --- /dev/null +++
> >> b/arch/arm/configs/csb1724_defconfig @@ -0,0 +1,47 @@
> >> +CONFIG_ARCH_KIRKWOOD=y +CONFIG_ARCH_KIRKWOOD_DT=y
> >> +CONFIG_MACH_CSB1724_DT=y
> > Do you really need this? Its the only kirkwood board with its on
> > _defconfig file. What makes this board special?
> 
> Nothing. defconfigs are just there to make configuring your kernel easy.
> 
> The kirkwood defconfig doesnt fit the currently supported hardware
> set on the csb1724 very well. Why build stuff you dont need?

The defconfig files serve a number of purposes. One of them is for
build regression testing, and for that reason we try to enable as
many boards as possible with a small number of defconfig files.

It's very rare that we have a board specific defconfig file, and
I would also ask you to just enable the hardware you need in the
kirkwood defconfig. It should not be hard for you to create
your own configuration by starting with that and disabling everything
you don't need.

	Arnd

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

* [PATCH 4/6] kirkwood: setup clock only in eth helpers.
  2012-07-31 11:08       ` Andrew Lunn
@ 2012-07-31 11:39         ` Ian Molton
  0 siblings, 0 replies; 35+ messages in thread
From: Ian Molton @ 2012-07-31 11:39 UTC (permalink / raw)
  To: linux-arm-kernel

On 31/07/12 12:08, Andrew Lunn wrote:
>> I see no reason to keep the calls now that the driver manages to
>> hang onto its clocks.
> Hi Ian
>
> Did you test this with it built as a module? That is the real test....

Rats. Yes, however it managed to survive. The minute I read this was the
minute it died. sods law :(

Guess it'll still be needed for now.

So, the question is about how to implement it - I like the 'probe the OF
device name' idea - I can implement that quickly enough.

Once thats done, I can push out a v2 patch, all the other issues are now
addressed, AFAICS.

-Ian

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-31  7:14   ` Arnaud Patard (Rtp)
  2012-07-31  8:19     ` Ian Molton
@ 2012-07-31 14:30     ` Ben Dooks
  2012-07-31 15:04       ` Arnaud Patard (Rtp)
  1 sibling, 1 reply; 35+ messages in thread
From: Ben Dooks @ 2012-07-31 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 31/07/12 08:14, Arnaud Patard (Rtp) wrote:
> Ian Molton<ian.molton@codethink.co.uk>  writes:
> Hi,
>
> [...]
>
>> @@ -2873,7 +2913,31 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
>>   	struct resource *res;
>>   	int err;
>>
>> -	pd = pdev->dev.platform_data;
>> +	if (pdev->dev.of_node) {
>> +		struct device_node *np = NULL;
>> +
>> +		/* when all users of this driver use FDT, we can remove this */
>> +		pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
>> +		if (!pd) {
>> +			dev_dbg(&pdev->dev, "Could not allocate platform data\n");
>> +			return -ENOMEM;
>> +		}
>> +
>> +		of_property_read_u32(pdev->dev.of_node,
>> +			"port_number",&pd->port_number);
>> +		of_property_read_u32(pdev->dev.of_node,
>> +			"phy_addr",&pd->phy_addr);
>
> I guess we need something for tx_csum_limit in the device tree too. It's
> important for kirkwood and dove.

Is this something for all kirkwood devices? I think the best way of
doing this is to give the driver a new device-tree name and having
it set this field in the init sequence.

However we could also do with some of these as dt parameters just in
case people want to try and alter them for their own systems.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-31 14:30     ` Ben Dooks
@ 2012-07-31 15:04       ` Arnaud Patard (Rtp)
  0 siblings, 0 replies; 35+ messages in thread
From: Arnaud Patard (Rtp) @ 2012-07-31 15:04 UTC (permalink / raw)
  To: linux-arm-kernel

Ben Dooks <ben.dooks@codethink.co.uk> writes:

> On 31/07/12 08:14, Arnaud Patard (Rtp) wrote:
>> Ian Molton<ian.molton@codethink.co.uk>  writes:
>> Hi,
>>
>> [...]
>>
>>> @@ -2873,7 +2913,31 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
>>>   	struct resource *res;
>>>   	int err;
>>>
>>> -	pd = pdev->dev.platform_data;
>>> +	if (pdev->dev.of_node) {
>>> +		struct device_node *np = NULL;
>>> +
>>> +		/* when all users of this driver use FDT, we can remove this */
>>> +		pd = kzalloc(sizeof(*pd), GFP_ATOMIC);
>>> +		if (!pd) {
>>> +			dev_dbg(&pdev->dev, "Could not allocate platform data\n");
>>> +			return -ENOMEM;
>>> +		}
>>> +
>>> +		of_property_read_u32(pdev->dev.of_node,
>>> +			"port_number",&pd->port_number);
>>> +		of_property_read_u32(pdev->dev.of_node,
>>> +			"phy_addr",&pd->phy_addr);
>>
>> I guess we need something for tx_csum_limit in the device tree too. It's
>> important for kirkwood and dove.
>
> Is this something for all kirkwood devices? I think the best way of
> doing this is to give the driver a new device-tree name and having
> it set this field in the init sequence.
>
> However we could also do with some of these as dt parameters just in
> case people want to try and alter them for their own systems.

It's for _all_ kirkwood and dove devices. The kirkwood and dove fifos
are smaller than the orion/mv78xxx ones (no idea about armada xp/370).

Arnaud

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

* [PATCH 3/6] mv643xx.c: Add basic device tree support.
  2012-07-30 16:32     ` Ian Molton
@ 2012-07-31 15:12       ` Florian Fainelli
  0 siblings, 0 replies; 35+ messages in thread
From: Florian Fainelli @ 2012-07-31 15:12 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Ian,

On Monday 30 July 2012 17:32:39 Ian Molton wrote:
> On 30/07/12 17:19, Amar Nath wrote:
> > Hi Ian,
> >
> > On Mon, Jul 30, 2012 at 8:45 PM, Ian Molton 
<ian.molton@codethink.co.uk>wrote:
> >
> >> -       pd = pdev->dev.platform_data;
> >> +       if (pdev->dev.of_node) {
> >> +               struct device_node *np = NULL;
> >> +
> >> +               /* when all users of this driver use FDT, we can remove
> >> this */
> >> +               pd = kzalloc(sizeof(*pd), GFP_ATOMIC);

Do you really need an allocation in atomic context here? Is not GFP_KERNEL 
sufficient?

There was a second place like this where you used an atomic allocation that 
needs fixing.

> >> +               if (!pd) {
> >> +                       dev_dbg(&pdev->dev, "Could not allocate platform
> >> data\n");
> >> +                       return -ENOMEM;
> >> +               }
> >> +
> >> +               of_property_read_u32(pdev->dev.of_node,
> >> +                       "port_number", &pd->port_number);
> >> +               of_property_read_u32(pdev->dev.of_node,
> >> +                       "phy_addr", &pd->phy_addr);
> >> +               np = of_parse_phandle(pdev->dev.of_node, "mdio", 0);
> >> +               if (np) {
> >> +                       pd->shared = of_find_device_by_node(np);
> >> +               } else {
> >> +                       kfree(pd);
> >> +                       return -ENODEV;
> >> +               }
> >> +       } else {
> >> +               pd = pdev->dev.platform_data;
> >> +       }
> >> +
> >>         if (pd == NULL) {
> >>                 dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
> >>                 return -ENODEV;
> >>
> > Can this check for pd be moved in the else part above as well, as for the
> > pd allocation with kzalloc,
> > we have already made a check for memory allocation failure?
> 
> Yes, Folded in for v2.
> 
> -Ian
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2012-07-31 15:12 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-30 15:15 [PATCH 0/6] mv643xx Ethernet DT support and CSB1724 board support Ian Molton
2012-07-30 15:15 ` [PATCH 1/6] Initial csb1724 board support (FDT) Ian Molton
2012-07-30 15:28   ` Andrew Lunn
2012-07-30 16:28     ` Ian Molton
2012-07-31 11:27       ` Arnd Bergmann
2012-07-30 15:15 ` [PATCH 2/6] mv643xx.c: Remove magic numbers Ian Molton
2012-07-30 15:15 ` [PATCH 3/6] mv643xx.c: Add basic device tree support Ian Molton
2012-07-30 15:39   ` Andrew Lunn
2012-07-30 16:49     ` Ian Molton
2012-07-30 16:19   ` Amar Nath
2012-07-30 16:32     ` Ian Molton
2012-07-31 15:12       ` Florian Fainelli
2012-07-31  7:14   ` Arnaud Patard (Rtp)
2012-07-31  8:19     ` Ian Molton
2012-07-31  8:27       ` Andrew Lunn
2012-07-31  8:45         ` Ian Molton
2012-07-31  8:58           ` Arnaud Patard (Rtp)
2012-07-31  9:14             ` Ian Molton
2012-07-31 14:30     ` Ben Dooks
2012-07-31 15:04       ` Arnaud Patard (Rtp)
2012-07-30 15:15 ` [PATCH 4/6] kirkwood: setup clock only in eth helpers Ian Molton
2012-07-30 16:12   ` Andrew Lunn
2012-07-30 16:52     ` Ian Molton
2012-07-30 19:10       ` Andrew Lunn
2012-07-30 16:46   ` Josh Coombs
2012-07-31  8:23     ` Ian Molton
2012-07-31 11:04     ` Ian Molton
2012-07-31 11:08       ` Andrew Lunn
2012-07-31 11:39         ` Ian Molton
2012-07-30 15:15 ` [PATCH 5/6] csb1724: Enable device tree based mv643xx ethernet support Ian Molton
2012-07-30 15:55   ` Andrew Lunn
2012-07-30 16:58     ` Ian Molton
2012-07-30 16:17   ` Andrew Lunn
2012-07-30 16:57     ` Ian Molton
2012-07-30 15:15 ` [PATCH 6/6] DT: Convert all kirkwood boards with mv643xx that use DT Ian Molton

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