devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/3] Add support for DNS-320 and DNS-325 using devicetree
@ 2012-03-24 13:14 Jamie Lentin
       [not found] ` <1332594876-8673-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Jamie Lentin @ 2012-03-24 13:14 UTC (permalink / raw)
  To: Arnd Bergmann, Jason
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jamie Lentin,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Thankyou to Arnd and Jason for taking the time to review, sorry it's taken a
while to get back to you both with an updated version.

Changes since v1:
* Rebase against kirkwood_dt_for_3.4, removing premature devicetree ports.
* Move additions into a separate board-dnskw.c. It could be separated further
  into a board-dns320.c and board-dns325.c but it probably isn't worth it.
* s/marvell,/mrvl,/g
* Include an example dtb partition in documentation
* Copy structure of serial nodes to allow common options for NAND to be set
  in kirkwood.dtsi
* Simplifications in orion-nand.c
    
I looked into adding a dtb partition into the d-link partition scheme. However
D-Link supplied userland references all partitions by number and there isn't
any obvious space that would be safe to use. Regardless, if you still have
D-Link userland around, you probably still have D-Link u-boot, which won't load
the dtb for you anyway.

Jamie Lentin (3):
  ARM: kirkwood: Basic support for DNS-320 and DNS-325
  ARM: kirkwood: Convert orion-nand to fdt
  ARM: kirkwood: Define NAND partitions in dts

 .../devicetree/bindings/mtd/orion-nand.txt         |   46 ++++
 arch/arm/boot/dts/kirkwood-dns320.dts              |   64 +++++
 arch/arm/boot/dts/kirkwood-dns325.dts              |   59 +++++
 arch/arm/boot/dts/kirkwood.dtsi                    |   15 +-
 arch/arm/mach-kirkwood/Kconfig                     |   23 ++
 arch/arm/mach-kirkwood/Makefile                    |    1 +
 arch/arm/mach-kirkwood/Makefile.boot               |    2 +
 arch/arm/mach-kirkwood/board-dnskw.c               |  275 ++++++++++++++++++++
 arch/arm/mach-kirkwood/board-dt.c                  |    5 +
 arch/arm/mach-kirkwood/common.c                    |   12 +
 arch/arm/mach-kirkwood/common.h                    |    6 +
 drivers/mtd/nand/orion_nand.c                      |   34 +++-
 12 files changed, 539 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/orion-nand.txt
 create mode 100644 arch/arm/boot/dts/kirkwood-dns320.dts
 create mode 100644 arch/arm/boot/dts/kirkwood-dns325.dts
 create mode 100644 arch/arm/mach-kirkwood/board-dnskw.c

-- 
1.7.9.1

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

* [PATCH V2 1/3] ARM: kirkwood: Basic support for DNS-320 and DNS-325
       [not found] ` <1332594876-8673-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-24 13:14   ` Jamie Lentin
       [not found]     ` <1332594876-8673-2-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Jamie Lentin @ 2012-03-24 13:14 UTC (permalink / raw)
  To: Arnd Bergmann, Jason
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jamie Lentin,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Add support for the DNS-320 and DNS-325. Describe as much as currently possible
in the devicetree files, create a board-dnskw.c for everything else.

Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
---
 arch/arm/boot/dts/kirkwood-dns320.dts |   29 +++
 arch/arm/boot/dts/kirkwood-dns325.dts |   24 +++
 arch/arm/mach-kirkwood/Kconfig        |   23 +++
 arch/arm/mach-kirkwood/Makefile       |    1 +
 arch/arm/mach-kirkwood/Makefile.boot  |    2 +
 arch/arm/mach-kirkwood/board-dnskw.c  |  306 +++++++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/board-dt.c     |    5 +
 arch/arm/mach-kirkwood/common.h       |    6 +
 8 files changed, 396 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/kirkwood-dns320.dts
 create mode 100644 arch/arm/boot/dts/kirkwood-dns325.dts
 create mode 100644 arch/arm/mach-kirkwood/board-dnskw.c

diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
new file mode 100644
index 0000000..58de7f2
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-dns320.dts
@@ -0,0 +1,29 @@
+/dts-v1/;
+
+/include/ "kirkwood.dtsi"
+
+/ {
+	model = "D-Link DNS-320 NAS (Rev A1)";
+	compatible = "dlink,dns-320-a1", "dlink,dns-320", "dlink,dns-kirkwood", "mrvl,kirkwood-88f6281", "mrvl,kirkwood";
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x8000000>;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200n8 earlyprintk";
+	};
+
+	ocp@f1000000 {
+		serial@12000 {
+			clock-frequency = <166666667>;
+			status = "ok";
+		};
+
+		serial@12100 {
+			clock-frequency = <166666667>;
+			status = "ok";
+		};
+	};
+};
diff --git a/arch/arm/boot/dts/kirkwood-dns325.dts b/arch/arm/boot/dts/kirkwood-dns325.dts
new file mode 100644
index 0000000..79b1133
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-dns325.dts
@@ -0,0 +1,24 @@
+/dts-v1/;
+
+/include/ "kirkwood.dtsi"
+
+/ {
+	model = "D-Link DNS-325 NAS (Rev A1)";
+	compatible = "dlink,dns-325-a1", "dlink,dns-325", "dlink,dns-kirkwood", "mrvl,kirkwood-88f6281", "mrvl,kirkwood";
+
+	memory {
+		device_type = "memory";
+		reg = <0x00000000 0x10000000>;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200n8 earlyprintk";
+	};
+
+	ocp@f1000000 {
+		serial@12000 {
+			clock-frequency = <200000000>;
+			status = "ok";
+		};
+	};
+};
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 90ceab7..d594b6e 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -58,6 +58,29 @@ config MACH_DREAMPLUG_DT
 	  Say 'Y' here if you want your kernel to support the
 	  Marvell DreamPlug (Flattened Device Tree).
 
+config MACH_DNSKW_DT
+        bool
+
+config MACH_DNS320_DT
+	bool "D-Link DNS-320 (Flattened Device Tree)"
+	select ARCH_KIRKWOOD_DT
+	select MACH_DNSKW_DT
+	select CONFIG_MTD_OF_PARTS
+	select CONFIG_SERIAL_OF_PLATFORM
+	help
+	  Say 'Y' here if you want your kernel to support the
+	  D-Link DNS-320 NAS, using Flattened Device Tree.
+
+config MACH_DNS325_DT
+	bool "D-Link DNS-325 (Flattened Device Tree)"
+	select ARCH_KIRKWOOD_DT
+	select MACH_DNSKW_DT
+	select CONFIG_MTD_OF_PARTS
+	select CONFIG_SERIAL_OF_PLATFORM
+	help
+	  Say 'Y' here if you want your kernel to support the
+	  D-Link DNS-325 NAS, 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 e299a95..b092af5 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -22,3 +22,4 @@ obj-$(CONFIG_MACH_T5325)		+= t5325-setup.o
 obj-$(CONFIG_CPU_IDLE)			+= cpuidle.o
 obj-$(CONFIG_ARCH_KIRKWOOD_DT)		+= board-dt.o
 obj-$(CONFIG_MACH_DREAMPLUG_DT)		+= board-dreamplug.o
+obj-$(CONFIG_MACH_DNSKW_DT)		+= board-dnskw.o
diff --git a/arch/arm/mach-kirkwood/Makefile.boot b/arch/arm/mach-kirkwood/Makefile.boot
index 16f9385..9c5e45f 100644
--- a/arch/arm/mach-kirkwood/Makefile.boot
+++ b/arch/arm/mach-kirkwood/Makefile.boot
@@ -3,3 +3,5 @@ params_phys-y	:= 0x00000100
 initrd_phys-y	:= 0x00800000
 
 dtb-$(CONFIG_MACH_DREAMPLUG_DT) += kirkwood-dreamplug.dtb
+dtb-$(CONFIG_MACH_DNS320_DT) += kirkwood-dns320.dtb
+dtb-$(CONFIG_MACH_DNS325_DT) += kirkwood-dns325.dtb
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
new file mode 100644
index 0000000..7cb7f6a
--- /dev/null
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -0,0 +1,306 @@
+/*
+ * Copyright 2012 (C), Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
+ *
+ * arch/arm/mach-kirkwood/board-dnskw.c
+ *
+ * D-link DNS-320 & DNS-325 NAS 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 <linux/platform_device.h>
+#include <linux/i2c.h>
+#include <linux/ata_platform.h>
+#include <linux/mv643xx_eth.h>
+#include <linux/of.h>
+#include <linux/gpio.h>
+#include <linux/input.h>
+#include <linux/gpio_keys.h>
+#include <linux/gpio-fan.h>
+#include <linux/leds.h>
+#include <linux/mtd/physmap.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <mach/kirkwood.h>
+#include <mach/bridge-regs.h>
+#include "common.h"
+#include "mpp.h"
+
+static struct mtd_partition dnskw_nand_parts[] = {
+	{
+		.name		= "u-boot",
+		.offset		= 0,
+		.size		= SZ_1M,
+		.mask_flags	= MTD_WRITEABLE
+	}, {
+		.name		= "uImage",
+		.offset		= MTDPART_OFS_NXTBLK,
+		.size		= 5 * SZ_1M
+	}, {
+		.name		= "ramdisk",
+		.offset		= MTDPART_OFS_NXTBLK,
+		.size		= 5 * SZ_1M
+	}, {
+		.name		= "image",
+		.offset		= MTDPART_OFS_NXTBLK,
+		.size		= 102 * SZ_1M
+	}, {
+		.name		= "mini firmware",
+		.offset		= MTDPART_OFS_NXTBLK,
+		.size		= 10 * SZ_1M
+	}, {
+		.name		= "config",
+		.offset		= MTDPART_OFS_NXTBLK,
+		.size		= 5 * SZ_1M
+	},
+};
+
+static struct mv643xx_eth_platform_data dnskw_ge00_data = {
+	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
+};
+
+static struct mv_sata_platform_data dnskw_sata_data = {
+	.n_ports	= 2,
+};
+
+static unsigned int dnskw_mpp_config[] __initdata = {
+	MPP13_UART1_TXD,	/* Custom ... */
+	MPP14_UART1_RXD,	/* ... Controller (DNS-320 only) */
+	MPP20_SATA1_ACTn,	/* LED: White Right HDD */
+	MPP21_SATA0_ACTn,	/* LED: White Left HDD */
+	MPP24_GPIO,
+	MPP25_GPIO,
+	MPP26_GPIO,	/* LED: Power */
+	MPP27_GPIO,	/* LED: Red Right HDD */
+	MPP28_GPIO,	/* LED: Red Left HDD */
+	MPP29_GPIO,	/* LED: Red USB (DNS-325 only) */
+	MPP30_GPIO,
+	MPP31_GPIO,
+	MPP32_GPIO,
+	MPP33_GPO,
+	MPP34_GPIO,	/* Button: Front power */
+	MPP35_GPIO,	/* LED: Red USB (DNS-320 only) */
+	MPP36_GPIO,	/* Power: Turn off board */
+	MPP37_GPIO,	/* Power: Turn back on after power failure */
+	MPP38_GPIO,
+	MPP39_GPIO,	/* Power: SATA0 */
+	MPP40_GPIO,	/* Power: SATA1 */
+	MPP41_GPIO,
+	MPP42_GPIO,
+	MPP43_GPIO,	/* LED: White USB */
+	MPP44_GPIO,	/* Fan: Tachometer Pin */
+	MPP45_GPIO,	/* Fan: high speed */
+	MPP46_GPIO,	/* Fan: low speed */
+	MPP47_GPIO,	/* Button: Back unmount */
+	MPP48_GPIO,	/* Button: Back reset */
+	MPP49_GPIO,	/* Pin of unused U5 (DNS-320 only) */
+	0
+};
+
+static struct gpio_led dns325_led_pins[] = {
+	{
+		.name	= "dns325:white:power",
+		.gpio	= 26,
+		.active_low = 1,
+		.default_trigger = "default-on",
+	},
+	{
+		.name	= "dns325:white:usb",
+		.gpio	= 43,
+		.active_low = 1,
+	},
+	{
+		.name	= "dns325:red:l_hdd",
+		.gpio	= 28,
+		.active_low = 1,
+	},
+	{
+		.name	= "dns325:red:r_hdd",
+		.gpio	= 27,
+		.active_low = 1,
+	},
+	{
+		.name	= "dns325:red:usb",
+		.gpio	= 29,
+		.active_low = 1,
+	},
+};
+
+static struct gpio_led_platform_data dns325_led_data = {
+	.num_leds	= ARRAY_SIZE(dns325_led_pins),
+	.leds		= dns325_led_pins,
+};
+
+static struct platform_device dns325_led_device = {
+	.name		= "leds-gpio",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &dns325_led_data,
+	},
+};
+
+static struct gpio_led dns320_led_pins[] = {
+	{
+		.name	= "dns320:blue:power",
+		.gpio	= 26,
+		.active_low = 1,
+		.default_trigger = "default-on",
+	},
+	{
+		.name	= "dns320:blue:usb",
+		.gpio	= 43,
+		.active_low = 1,
+	},
+	{
+		.name	= "dns320:orange:l_hdd",
+		.gpio	= 28,
+		.active_low = 1,
+	},
+	{
+		.name	= "dns320:orange:r_hdd",
+		.gpio	= 27,
+		.active_low = 1,
+	},
+	{
+		.name	= "dns320:orange:usb",
+		.gpio	= 35,
+		.active_low = 1,
+	},
+};
+
+static struct gpio_led_platform_data dns320_led_data = {
+	.num_leds	= ARRAY_SIZE(dns320_led_pins),
+	.leds		= dns320_led_pins,
+};
+
+static struct platform_device dns320_led_device = {
+	.name		= "leds-gpio",
+	.id		= -1,
+	.dev		= {
+		.platform_data	= &dns320_led_data,
+	},
+};
+
+static struct i2c_board_info dns325_i2c_board_info[] __initdata = {
+	{
+		I2C_BOARD_INFO("lm75", 0x48),
+	},
+	/* Something at 0x0c also */
+};
+
+static struct gpio_keys_button dnskw_button_pins[] = {
+	{
+		.code		= KEY_POWER,
+		.gpio		= 34,
+		.desc		= "Power button",
+		.active_low	= 1,
+	},
+	{
+		.code		= KEY_EJECTCD,
+		.gpio		= 47,
+		.desc		= "USB unmount button",
+		.active_low	= 1,
+	},
+	{
+		.code		= KEY_RESTART,
+		.gpio		= 48,
+		.desc		= "Reset button",
+		.active_low	= 1,
+	},
+};
+
+static struct gpio_keys_platform_data dnskw_button_data = {
+	.buttons	= dnskw_button_pins,
+	.nbuttons	= ARRAY_SIZE(dnskw_button_pins),
+};
+
+static struct platform_device dnskw_button_device = {
+	.name		= "gpio-keys",
+	.id		= -1,
+	.num_resources	= 0,
+	.dev		= {
+		.platform_data	= &dnskw_button_data,
+	}
+};
+
+/* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */
+static struct gpio_fan_speed dnskw_fan_speed[] = {
+	{    0,  0 },
+	{ 3000,	 1 },
+	{ 6000,	 2 },
+};
+static unsigned dnskw_fan_pins[] = {46, 45};
+
+static struct gpio_fan_platform_data dnskw_fan_data = {
+	.num_ctrl	= ARRAY_SIZE(dnskw_fan_pins),
+	.ctrl		= dnskw_fan_pins,
+	.num_speed	= ARRAY_SIZE(dnskw_fan_speed),
+	.speed		= dnskw_fan_speed,
+};
+
+static struct platform_device dnskw_fan_device = {
+	.name	= "gpio-fan",
+	.id	= -1,
+	.dev	= {
+		.platform_data	= &dnskw_fan_data,
+	},
+};
+
+static void dnskw_power_off(void)
+{
+	gpio_set_value(36, 1);
+}
+
+/* Register any GPIO for output and set the value */
+static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
+{
+	if (gpio_request(gpio, name) == 0 &&
+	    gpio_direction_output(gpio, 0) == 0) {
+		gpio_set_value(gpio, def);
+		if (gpio_export(gpio, 0) != 0)
+			pr_err("dnskw: Failed to export GPIO %s\n", name);
+	} else
+		pr_err("dnskw: Failed to register %s\n", name);
+}
+
+void __init dnskw_init(void)
+{
+	kirkwood_mpp_conf(dnskw_mpp_config);
+	kirkwood_nand_init(ARRAY_AND_SIZE(dnskw_nand_parts), 25);
+
+	kirkwood_ehci_init();
+	kirkwood_ge00_init(&dnskw_ge00_data);
+	kirkwood_sata_init(&dnskw_sata_data);
+	kirkwood_i2c_init();
+
+	platform_device_register(&dnskw_button_device);
+	platform_device_register(&dnskw_fan_device);
+
+	if (of_machine_is_compatible("dlink,dns-325")) {
+		i2c_register_board_info(0, dns325_i2c_board_info,
+					ARRAY_SIZE(dns325_i2c_board_info));
+		platform_device_register(&dns325_led_device);
+
+	} else if (of_machine_is_compatible("dlink,dns-320"))
+		platform_device_register(&dns320_led_device);
+
+	/* Register power-off GPIO. */
+	if (gpio_request(36, "dnskw:power:off") == 0
+	    && gpio_direction_output(36, 0) == 0)
+		pm_power_off = dnskw_power_off;
+	else
+		pr_err("dnskw: failed to configure power-off GPIO\n");
+
+	/* Ensure power is supplied to both HDDs */
+	dnskw_gpio_register(39, "dnskw:power:sata0", 1);
+	dnskw_gpio_register(40, "dnskw:power:sata1", 1);
+
+	/* Set NAS to turn back on after a power failure */
+	dnskw_gpio_register(37, "dnskw:power:recover", 1);
+}
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 1c672d9..eadc4d7 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -55,11 +55,16 @@ static void __init kirkwood_dt_init(void)
 	if (of_machine_is_compatible("globalscale,dreamplug"))
 		dreamplug_init();
 
+	if (of_machine_is_compatible("dlink,dns-kirkwood"))
+		dnskw_init();
+
 	of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
 }
 
 static const char *kirkwood_dt_board_compat[] = {
 	"globalscale,dreamplug",
+	"dlink,dns-320",
+	"dlink,dns-325",
 	NULL
 };
 
diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h
index fa8e768..8c8c733 100644
--- a/arch/arm/mach-kirkwood/common.h
+++ b/arch/arm/mach-kirkwood/common.h
@@ -58,6 +58,12 @@ void dreamplug_init(void);
 static inline void dreamplug_init(void) {};
 #endif
 
+#ifdef CONFIG_MACH_DNSKW_DT
+void dnskw_init(void);
+#else
+static inline void dnskw_init(void) {};
+#endif
+
 /* early init functions not converted to fdt yet */
 char *kirkwood_id(void);
 void kirkwood_l2_init(void);
-- 
1.7.9.1

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

* [PATCH V2 2/3] ARM: kirkwood: Convert orion-nand to fdt
  2012-03-24 13:14 [PATCH V2 0/3] Add support for DNS-320 and DNS-325 using devicetree Jamie Lentin
       [not found] ` <1332594876-8673-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-24 13:14 ` Jamie Lentin
       [not found]   ` <1332594876-8673-3-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
  2012-03-24 13:14 ` [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts Jamie Lentin
  2 siblings, 1 reply; 17+ messages in thread
From: Jamie Lentin @ 2012-03-24 13:14 UTC (permalink / raw)
  To: Arnd Bergmann, Jason; +Cc: devicetree-discuss, Jamie Lentin, linux-arm-kernel

Convert orion-nand to use fdt and add common setup to kirkwood.dtsi, including
a default value for chip-delay (all current boards seem to use 25 anyway).

Add placeholder documentation for the bindings, for someone more knowledgable
than me to fill in the details of the properties.

Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
---
 .../devicetree/bindings/mtd/orion-nand.txt         |   46 ++++++++++++++++++++
 arch/arm/boot/dts/kirkwood.dtsi                    |   15 ++++++-
 arch/arm/mach-kirkwood/common.c                    |   12 +++++
 drivers/mtd/nand/orion_nand.c                      |   34 ++++++++++++++-
 4 files changed, 104 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mtd/orion-nand.txt

diff --git a/Documentation/devicetree/bindings/mtd/orion-nand.txt b/Documentation/devicetree/bindings/mtd/orion-nand.txt
new file mode 100644
index 0000000..d347999
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/orion-nand.txt
@@ -0,0 +1,46 @@
+NAND support for Marvell Orion SoC platforms
+
+Required properties:
+- compatible : "mrvl,orion-nand".
+- reg : Base physical address of the NAND and length of memory mapped
+	region
+
+Optional properties:
+- cle :
+- ale :
+- width :
+- chip-delay :
+
+Examples:
+
+nand@f4000000 {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	cle = <0>;
+	ale = <1>;
+	width = <8>;
+	chip-delay = <25>;
+	compatible = "mrvl,orion-nand";
+	reg = <0xf4000000 0x400>;
+
+	partition@0 {
+		label = "u-boot";
+		reg = <0x0000000 0x100000>;
+		read-only;
+	};
+
+	partition@100000 {
+		label = "uImage";
+		reg = <0x0100000 0x200000>;
+	};
+
+	partition@300000 {
+		label = "dtb";
+		reg = <0x0300000 0x100000>;
+	};
+
+	partition@400000 {
+		label = "root";
+		reg = <0x0400000 0x7d00000>;
+	};
+};
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index 3474ef8..82ffc3e 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -5,7 +5,7 @@
 
 	ocp@f1000000 {
 		compatible = "simple-bus";
-		ranges = <0 0xf1000000 0x1000000>;
+		ranges = <0 0xf1000000 0x4000000>;
 		#address-cells = <1>;
 		#size-cells = <1>;
 
@@ -32,5 +32,18 @@
 			reg = <0x10300 0x20>;
 			interrupts = <53>;
 		};
+
+		nand@3000000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			cle = <0>;
+			ale = <1>;
+			width = <8>;
+			compatible = "mrvl,orion-nand";
+			reg = <0x3000000 0x400>;
+			chip-delay = <25>;
+			/* set partition map and/or chip-delay in board dts */
+			status = "disabled";
+		};
 	};
 };
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index a02cae8..3ad0373 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -15,6 +15,7 @@
 #include <linux/ata_platform.h>
 #include <linux/mtd/nand.h>
 #include <linux/dma-mapping.h>
+#include <linux/of.h>
 #include <net/dsa.h>
 #include <asm/page.h>
 #include <asm/timex.h>
@@ -482,6 +483,9 @@ static int __init kirkwood_clock_gate(void)
 	unsigned int curr = readl(CLOCK_GATING_CTRL);
 	u32 dev, rev;
 
+#ifdef CONFIG_OF
+	struct device_node *np;
+#endif
 	kirkwood_pcie_id(&dev, &rev);
 	printk(KERN_DEBUG "Gating clock of unused units\n");
 	printk(KERN_DEBUG "before: 0x%08x\n", curr);
@@ -489,6 +493,14 @@ static int __init kirkwood_clock_gate(void)
 	/* Make sure those units are accessible */
 	writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL);
 
+#ifdef CONFIG_OF
+	np = of_find_compatible_node(NULL, NULL, "mrvl,orion-nand");
+	if (np && of_device_is_available(np)) {
+		kirkwood_clk_ctrl |= CGC_RUNIT;
+		of_node_put(np);
+	}
+#endif
+
 	/* For SATA: first shutdown the phy */
 	if (!(kirkwood_clk_ctrl & CGC_SATA0)) {
 		/* Disable PLL and IVREF */
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 29f505a..4cb0244 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -13,6 +13,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/of.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
 #include <linux/mtd/partitions.h>
@@ -74,11 +75,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
 static int __init orion_nand_probe(struct platform_device *pdev)
 {
 	struct mtd_info *mtd;
+	struct mtd_part_parser_data ppdata = {};
 	struct nand_chip *nc;
 	struct orion_nand_data *board;
 	struct resource *res;
 	void __iomem *io_base;
 	int ret = 0;
+	u32 val = 0;
 
 	nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
 	if (!nc) {
@@ -101,7 +104,25 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 		goto no_res;
 	}
 
-	board = pdev->dev.platform_data;
+	if (pdev->dev.of_node) {
+		board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
+					GFP_KERNEL);
+		if (!board) {
+			printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
+			ret = -ENOMEM;
+			goto no_res;
+		}
+		if (!of_property_read_u32(pdev->dev.of_node, "cle", &val))
+			board->cle = (u8)val;
+		if (!of_property_read_u32(pdev->dev.of_node, "ale", &val))
+			board->ale = (u8)val;
+		if (!of_property_read_u32(pdev->dev.of_node, "width", &val))
+			board->width = (u8)val;
+		if (!of_property_read_u32(pdev->dev.of_node,
+						"chip-delay", &val))
+			board->chip_delay = (u8)val;
+	} else
+		board = pdev->dev.platform_data;
 
 	mtd->priv = nc;
 	mtd->owner = THIS_MODULE;
@@ -129,7 +150,8 @@ static int __init orion_nand_probe(struct platform_device *pdev)
 	}
 
 	mtd->name = "orion_nand";
-	ret = mtd_device_parse_register(mtd, NULL, 0,
+	ppdata.of_node = pdev->dev.of_node;
+	ret = mtd_device_parse_register(mtd, NULL, &ppdata,
 			board->parts, board->nr_parts);
 	if (ret) {
 		nand_release(mtd);
@@ -161,11 +183,19 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id orion_nand_of_match_table[] = {
+	{ .compatible = "mrvl,orion-nand", },
+	{},
+};
+#endif
+
 static struct platform_driver orion_nand_driver = {
 	.remove		= __devexit_p(orion_nand_remove),
 	.driver		= {
 		.name	= "orion_nand",
 		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(orion_nand_of_match_table),
 	},
 };
 
-- 
1.7.9.1

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

* [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts
  2012-03-24 13:14 [PATCH V2 0/3] Add support for DNS-320 and DNS-325 using devicetree Jamie Lentin
       [not found] ` <1332594876-8673-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
  2012-03-24 13:14 ` [PATCH V2 2/3] ARM: kirkwood: Convert orion-nand to fdt Jamie Lentin
@ 2012-03-24 13:14 ` Jamie Lentin
       [not found]   ` <1332594876-8673-4-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
  2 siblings, 1 reply; 17+ messages in thread
From: Jamie Lentin @ 2012-03-24 13:14 UTC (permalink / raw)
  To: Arnd Bergmann, Jason; +Cc: devicetree-discuss, Jamie Lentin, linux-arm-kernel

Use devicetree to define NAND partitions. Use D-link partition scheme by
default, to be vaguely compatible with their userland.

Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
---
 arch/arm/boot/dts/kirkwood-dns320.dts |   35 +++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/kirkwood-dns325.dts |   35 +++++++++++++++++++++++++++++++++
 arch/arm/mach-kirkwood/board-dnskw.c  |   31 -----------------------------
 3 files changed, 70 insertions(+), 31 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
index 58de7f2..fbf55ff 100644
--- a/arch/arm/boot/dts/kirkwood-dns320.dts
+++ b/arch/arm/boot/dts/kirkwood-dns320.dts
@@ -25,5 +25,40 @@
 			clock-frequency = <166666667>;
 			status = "ok";
 		};
+
+		nand@3000000 {
+			status = "ok";
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0000000 0x100000>;
+				read-only;
+			};
+
+			partition@100000 {
+				label = "uImage";
+				reg = <0x0100000 0x500000>;
+			};
+
+			partition@600000 {
+				label = "ramdisk";
+				reg = <0x0600000 0x500000>;
+			};
+
+			partition@b00000 {
+				label = "image";
+				reg = <0x0b00000 0x6600000>;
+			};
+
+			partition@7100000 {
+				label = "mini firmware";
+				reg = <0x7100000 0xa00000>;
+			};
+
+			partition@7b00000 {
+				label = "config";
+				reg = <0x7b00000 0x500000>;
+			};
+		};
 	};
 };
diff --git a/arch/arm/boot/dts/kirkwood-dns325.dts b/arch/arm/boot/dts/kirkwood-dns325.dts
index 79b1133..b6238db 100644
--- a/arch/arm/boot/dts/kirkwood-dns325.dts
+++ b/arch/arm/boot/dts/kirkwood-dns325.dts
@@ -20,5 +20,40 @@
 			clock-frequency = <200000000>;
 			status = "ok";
 		};
+
+		nand@3000000 {
+			status = "ok";
+
+			partition@0 {
+				label = "u-boot";
+				reg = <0x0000000 0x100000>;
+				read-only;
+			};
+
+			partition@100000 {
+				label = "uImage";
+				reg = <0x0100000 0x500000>;
+			};
+
+			partition@600000 {
+				label = "ramdisk";
+				reg = <0x0600000 0x500000>;
+			};
+
+			partition@b00000 {
+				label = "image";
+				reg = <0x0b00000 0x6600000>;
+			};
+
+			partition@7100000 {
+				label = "mini firmware";
+				reg = <0x7100000 0xa00000>;
+			};
+
+			partition@7b00000 {
+				label = "config";
+				reg = <0x7b00000 0x500000>;
+			};
+		};
 	};
 };
diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c
index 7cb7f6a..dc4e80a 100644
--- a/arch/arm/mach-kirkwood/board-dnskw.c
+++ b/arch/arm/mach-kirkwood/board-dnskw.c
@@ -23,7 +23,6 @@
 #include <linux/gpio_keys.h>
 #include <linux/gpio-fan.h>
 #include <linux/leds.h>
-#include <linux/mtd/physmap.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -32,35 +31,6 @@
 #include "common.h"
 #include "mpp.h"
 
-static struct mtd_partition dnskw_nand_parts[] = {
-	{
-		.name		= "u-boot",
-		.offset		= 0,
-		.size		= SZ_1M,
-		.mask_flags	= MTD_WRITEABLE
-	}, {
-		.name		= "uImage",
-		.offset		= MTDPART_OFS_NXTBLK,
-		.size		= 5 * SZ_1M
-	}, {
-		.name		= "ramdisk",
-		.offset		= MTDPART_OFS_NXTBLK,
-		.size		= 5 * SZ_1M
-	}, {
-		.name		= "image",
-		.offset		= MTDPART_OFS_NXTBLK,
-		.size		= 102 * SZ_1M
-	}, {
-		.name		= "mini firmware",
-		.offset		= MTDPART_OFS_NXTBLK,
-		.size		= 10 * SZ_1M
-	}, {
-		.name		= "config",
-		.offset		= MTDPART_OFS_NXTBLK,
-		.size		= 5 * SZ_1M
-	},
-};
-
 static struct mv643xx_eth_platform_data dnskw_ge00_data = {
 	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
 };
@@ -272,7 +242,6 @@ static void __init dnskw_gpio_register(unsigned gpio, char *name, int def)
 void __init dnskw_init(void)
 {
 	kirkwood_mpp_conf(dnskw_mpp_config);
-	kirkwood_nand_init(ARRAY_AND_SIZE(dnskw_nand_parts), 25);
 
 	kirkwood_ehci_init();
 	kirkwood_ge00_init(&dnskw_ge00_data);
-- 
1.7.9.1

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

* Re: [PATCH V2 2/3] ARM: kirkwood: Convert orion-nand to fdt
       [not found]   ` <1332594876-8673-3-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-24 19:01     ` Arnd Bergmann
       [not found]       ` <201203241901.00405.arnd-r2nGTMty4D4@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Arnd Bergmann @ 2012-03-24 19:01 UTC (permalink / raw)
  To: Jamie Lentin
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Saturday 24 March 2012, Jamie Lentin wrote:
> Convert orion-nand to use fdt and add common setup to kirkwood.dtsi, including
> a default value for chip-delay (all current boards seem to use 25 anyway).
> 
> Add placeholder documentation for the bindings, for someone more knowledgable
> than me to fill in the details of the properties.

Looks very good. Two small comments:

> diff --git a/Documentation/devicetree/bindings/mtd/orion-nand.txt b/Documentation/devicetree/bindings/mtd/orion-nand.txt
> new file mode 100644
> index 0000000..d347999
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/orion-nand.txt
> @@ -0,0 +1,46 @@
> +NAND support for Marvell Orion SoC platforms
> +
> +Required properties:
> +- compatible : "mrvl,orion-nand".
> +- reg : Base physical address of the NAND and length of memory mapped
> +	region
> +
> +Optional properties:
> +- cle :
> +- ale :
> +- width :
> +- chip-delay :

I think the "width" property should be called "bank-width" to match the other
bindings.

> +Examples:
> +
> +nand@f4000000 {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +	cle = <0>;
> +	ale = <1>;
> +	width = <8>;
> +	chip-delay = <25>;
> +	compatible = "mrvl,orion-nand";
> +	reg = <0xf4000000 0x400>;
> +
> +	partition@0 {
> +		label = "u-boot";
> +		reg = <0x0000000 0x100000>;
> +		read-only;
> +	};

You don't describe the partitions in the binding. Others have the same omission,
but I think it's worth mentioning. Either point to the mtd-physmap.txt file,
or make your patch move the partition support into a new file that everything
else can refer to.

	Arnd

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

* Re: [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts
       [not found]   ` <1332594876-8673-4-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-24 19:01     ` Arnd Bergmann
  2012-03-26 15:53     ` Scott Wood
  1 sibling, 0 replies; 17+ messages in thread
From: Arnd Bergmann @ 2012-03-24 19:01 UTC (permalink / raw)
  To: Jamie Lentin
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Saturday 24 March 2012, Jamie Lentin wrote:
> Use devicetree to define NAND partitions. Use D-link partition scheme by
> default, to be vaguely compatible with their userland.
> 
> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>

Acked-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>

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

* Re: [PATCH V2 1/3] ARM: kirkwood: Basic support for DNS-320 and DNS-325
       [not found]     ` <1332594876-8673-2-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-24 19:26       ` Arnd Bergmann
       [not found]         ` <201203241926.00597.arnd-r2nGTMty4D4@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Arnd Bergmann @ 2012-03-24 19:26 UTC (permalink / raw)
  To: Jamie Lentin
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Saturday 24 March 2012, Jamie Lentin wrote:
> 
> Add support for the DNS-320 and DNS-325. Describe as much as currently possible
> in the devicetree files, create a board-dnskw.c for everything else.
> 
> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>

Looks good to me. 

Jason, do you want to add these to your tree? You are already have some
the patches for dreamplug, and I think it makes sense to update these two
together when you have more patches.

Since the dnskw board file contains mostly gpio setup, I think it would
be good if one of you could take that part on next: once the gpio controller
uses DT probing, you can move all the gpio leds and buttons into the
device tree, which drastically shrinks the dnskw file.

Acked-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>

	Arnd

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

* Re: [PATCH V3 2/3] ARM: kirkwood: Convert orion-nand to fdt
       [not found]       ` <201203241901.00405.arnd-r2nGTMty4D4@public.gmane.org>
@ 2012-03-25  0:17         ` Jamie Lentin
  2012-03-25  7:52           ` Arnd Bergmann
  2012-03-25 14:57           ` Jason Cooper
  0 siblings, 2 replies; 17+ messages in thread
From: Jamie Lentin @ 2012-03-25  0:17 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Convert orion-nand to use fdt and add common setup to kirkwood.dtsi, including
a default value for chip-delay (all current boards seem to use 25 anyway).

Add placeholder documentation for the bindings, for someone more knowledgable
than me to fill in the details of the properties.

Move common partition table documentation into a separate file and reference
this.

Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
---
Re-arranged documentation as you suggest, however it's tempting to have 
this as a separate patch and add references to partition.txt for the other 
binding documentation files. Let me know if you want me to do this.

Cheers for your help!

  .../devicetree/bindings/mtd/mtd-physmap.txt        |   24 +--------
  .../devicetree/bindings/mtd/orion-nand.txt         |   50 ++++++++++++++++++++
  .../devicetree/bindings/mtd/partition.txt          |   38 +++++++++++++++
  arch/arm/boot/dts/kirkwood.dtsi                    |   15 ++++++-
  arch/arm/mach-kirkwood/common.c                    |   12 +++++
  drivers/mtd/nand/orion_nand.c                      |   34 +++++++++++++-
  6 files changed, 149 insertions(+), 24 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/mtd/orion-nand.txt
  create mode 100644 Documentation/devicetree/bindings/mtd/partition.txt

diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
index 80152cb..9b873d4 100644
--- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
+++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
@@ -23,27 +23,9 @@ are defined:
   - vendor-id : Contains the flash chip's vendor id (1 byte).
   - device-id : Contains the flash chip's device id (1 byte).

-In addition to the information on the mtd bank itself, the
-device tree may optionally contain additional information
-describing partitions of the address space.  This can be
-used on platforms which have strong conventions about which
-portions of a flash are used for what purposes, but which don't
-use an on-flash partition table such as RedBoot.
-
-Each partition is represented as a sub-node of the mtd device.
-Each node's name represents the name of the corresponding
-partition of the mtd device.
-
-Flash partitions
- - reg : The partition's offset and size within the mtd bank.
- - label : (optional) The label / name for this partition.
-   If omitted, the label is taken from the node name (excluding
-   the unit address).
- - read-only : (optional) This parameter, if present, is a hint to
-   Linux that this partition should only be mounted
-   read-only.  This is usually used for flash partitions
-   containing early-boot firmware images or data which should not
-   be clobbered.
+In addition to the information on the mtd bank itself, the device tree may
+optionally contain additional sub-nodes describing partitions of the address
+space. See partition.txt for more detail.

  Example:

diff --git a/Documentation/devicetree/bindings/mtd/orion-nand.txt b/Documentation/devicetree/bindings/mtd/orion-nand.txt
new file mode 100644
index 0000000..e9acbd2
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/orion-nand.txt
@@ -0,0 +1,50 @@
+NAND support for Marvell Orion SoC platforms
+
+Required properties:
+- compatible : "mrvl,orion-nand".
+- reg : Base physical address of the NAND and length of memory mapped
+	region
+
+Optional properties:
+- cle :
+- ale :
+- bank-width :
+- chip-delay :
+
+In addition to the information on the mtd bank itself, the device tree may
+optionally contain additional sub-nodes describing partitions of the address
+space. See partition.txt for more detail.
+
+Examples:
+
+nand@f4000000 {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	cle = <0>;
+	ale = <1>;
+	bank-width = <8>;
+	chip-delay = <25>;
+	compatible = "mrvl,orion-nand";
+	reg = <0xf4000000 0x400>;
+
+	partition@0 {
+		label = "u-boot";
+		reg = <0x0000000 0x100000>;
+		read-only;
+	};
+
+	partition@100000 {
+		label = "uImage";
+		reg = <0x0100000 0x200000>;
+	};
+
+	partition@300000 {
+		label = "dtb";
+		reg = <0x0300000 0x100000>;
+	};
+
+	partition@400000 {
+		label = "root";
+		reg = <0x0400000 0x7d00000>;
+	};
+};
diff --git a/Documentation/devicetree/bindings/mtd/partition.txt b/Documentation/devicetree/bindings/mtd/partition.txt
new file mode 100644
index 0000000..f114ce1
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partition.txt
@@ -0,0 +1,38 @@
+Representing flash partitions in devicetree
+
+Partitions can be represented by sub-nodes of an mtd device. This can be used
+on platforms which have strong conventions about which portions of a flash are
+used for what purposes, but which don't use an on-flash partition table such
+as RedBoot.
+
+#address-cells & #size-cells must both be present in the mtd device and be
+equal to 1.
+
+Required properties:
+- reg : The partition's offset and size within the mtd bank.
+
+Optional properties:
+- label : The label / name for this partition.  If omitted, the label is taken
+  from the node name (excluding the unit address).
+- read-only : This parameter, if present, is a hint to Linux that this
+  partition should only be mounted read-only. This is usually used for flash
+  partitions containing early-boot firmware images or data which should not be
+  clobbered.
+
+Examples:
+
+
+flash@0 {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	partition@0 {
+		label = "u-boot";
+		reg = <0x0000000 0x100000>;
+		read-only;
+	};
+
+	uimage@100000 {
+		reg = <0x0100000 0x200000>;
+	};
+];
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
index 3474ef8..6b80374 100644
--- a/arch/arm/boot/dts/kirkwood.dtsi
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -5,7 +5,7 @@

  	ocp@f1000000 {
  		compatible = "simple-bus";
-		ranges = <0 0xf1000000 0x1000000>;
+		ranges = <0 0xf1000000 0x4000000>;
  		#address-cells = <1>;
  		#size-cells = <1>;

@@ -32,5 +32,18 @@
  			reg = <0x10300 0x20>;
  			interrupts = <53>;
  		};
+
+		nand@3000000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			cle = <0>;
+			ale = <1>;
+			bank-width = <8>;
+			compatible = "mrvl,orion-nand";
+			reg = <0x3000000 0x400>;
+			chip-delay = <25>;
+			/* set partition map and/or chip-delay in board dts */
+			status = "disabled";
+		};
  	};
  };
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index a02cae8..3ad0373 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -15,6 +15,7 @@
  #include <linux/ata_platform.h>
  #include <linux/mtd/nand.h>
  #include <linux/dma-mapping.h>
+#include <linux/of.h>
  #include <net/dsa.h>
  #include <asm/page.h>
  #include <asm/timex.h>
@@ -482,6 +483,9 @@ static int __init kirkwood_clock_gate(void)
  	unsigned int curr = readl(CLOCK_GATING_CTRL);
  	u32 dev, rev;

+#ifdef CONFIG_OF
+	struct device_node *np;
+#endif
  	kirkwood_pcie_id(&dev, &rev);
  	printk(KERN_DEBUG "Gating clock of unused units\n");
  	printk(KERN_DEBUG "before: 0x%08x\n", curr);
@@ -489,6 +493,14 @@ static int __init kirkwood_clock_gate(void)
  	/* Make sure those units are accessible */
  	writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL);

+#ifdef CONFIG_OF
+	np = of_find_compatible_node(NULL, NULL, "mrvl,orion-nand");
+	if (np && of_device_is_available(np)) {
+		kirkwood_clk_ctrl |= CGC_RUNIT;
+		of_node_put(np);
+	}
+#endif
+
  	/* For SATA: first shutdown the phy */
  	if (!(kirkwood_clk_ctrl & CGC_SATA0)) {
  		/* Disable PLL and IVREF */
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 29f505a..6a5f47b 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -13,6 +13,7 @@
  #include <linux/slab.h>
  #include <linux/module.h>
  #include <linux/platform_device.h>
+#include <linux/of.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/nand.h>
  #include <linux/mtd/partitions.h>
@@ -74,11 +75,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
  static int __init orion_nand_probe(struct platform_device *pdev)
  {
  	struct mtd_info *mtd;
+	struct mtd_part_parser_data ppdata = {};
  	struct nand_chip *nc;
  	struct orion_nand_data *board;
  	struct resource *res;
  	void __iomem *io_base;
  	int ret = 0;
+	u32 val = 0;

  	nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
  	if (!nc) {
@@ -101,7 +104,25 @@ static int __init orion_nand_probe(struct platform_device *pdev)
  		goto no_res;
  	}

-	board = pdev->dev.platform_data;
+	if (pdev->dev.of_node) {
+		board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
+					GFP_KERNEL);
+		if (!board) {
+			printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
+			ret = -ENOMEM;
+			goto no_res;
+		}
+		if (!of_property_read_u32(pdev->dev.of_node, "cle", &val))
+			board->cle = (u8)val;
+		if (!of_property_read_u32(pdev->dev.of_node, "ale", &val))
+			board->ale = (u8)val;
+		if (!of_property_read_u32(pdev->dev.of_node, "bank-width", &val))
+			board->width = (u8)val;
+		if (!of_property_read_u32(pdev->dev.of_node,
+						"chip-delay", &val))
+			board->chip_delay = (u8)val;
+	} else
+		board = pdev->dev.platform_data;

  	mtd->priv = nc;
  	mtd->owner = THIS_MODULE;
@@ -129,7 +150,8 @@ static int __init orion_nand_probe(struct platform_device *pdev)
  	}

  	mtd->name = "orion_nand";
-	ret = mtd_device_parse_register(mtd, NULL, 0,
+	ppdata.of_node = pdev->dev.of_node;
+	ret = mtd_device_parse_register(mtd, NULL, &ppdata,
  			board->parts, board->nr_parts);
  	if (ret) {
  		nand_release(mtd);
@@ -161,11 +183,19 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
  	return 0;
  }

+#ifdef CONFIG_OF
+static struct of_device_id orion_nand_of_match_table[] = {
+	{ .compatible = "mrvl,orion-nand", },
+	{},
+};
+#endif
+
  static struct platform_driver orion_nand_driver = {
  	.remove		= __devexit_p(orion_nand_remove),
  	.driver		= {
  		.name	= "orion_nand",
  		.owner	= THIS_MODULE,
+		.of_match_table = of_match_ptr(orion_nand_of_match_table),
  	},
  };

-- 
1.7.9.1

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

* Re: [PATCH V3 2/3] ARM: kirkwood: Convert orion-nand to fdt
  2012-03-25  0:17         ` [PATCH V3 " Jamie Lentin
@ 2012-03-25  7:52           ` Arnd Bergmann
  2012-03-25 14:57           ` Jason Cooper
  1 sibling, 0 replies; 17+ messages in thread
From: Arnd Bergmann @ 2012-03-25  7:52 UTC (permalink / raw)
  To: Jamie Lentin
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Sunday 25 March 2012, Jamie Lentin wrote:
> Re-arranged documentation as you suggest, however it's tempting to have 
> this as a separate patch and add references to partition.txt for the other 
> binding documentation files. Let me know if you want me to do this.
> 

Sounds lika a good idea, yes. This version is also fine with me though,

Acked-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>

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

* Re: [PATCH V3 2/3] ARM: kirkwood: Convert orion-nand to fdt
  2012-03-25  0:17         ` [PATCH V3 " Jamie Lentin
  2012-03-25  7:52           ` Arnd Bergmann
@ 2012-03-25 14:57           ` Jason Cooper
  1 sibling, 0 replies; 17+ messages in thread
From: Jason Cooper @ 2012-03-25 14:57 UTC (permalink / raw)
  To: Jamie Lentin
  Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Sun, Mar 25, 2012 at 12:17:24AM +0000, Jamie Lentin wrote:
> Convert orion-nand to use fdt and add common setup to kirkwood.dtsi, including
> a default value for chip-delay (all current boards seem to use 25 anyway).
> 
> Add placeholder documentation for the bindings, for someone more knowledgable
> than me to fill in the details of the properties.
> 
> Move common partition table documentation into a separate file and reference
> this.

Jamie,

This looks great!  In addition to Arnd's comments, could you split this
into two?  The orion_nand dt bindings work, and kirkwood making use of
it?  It's not earth-shattering, but it helps folks on orion5x/dove/etc
pull it in and try it without worrying about kirkwood.

> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> ---
> Re-arranged documentation as you suggest, however it's tempting to
> have this as a separate patch and add references to partition.txt
> for the other binding documentation files. Let me know if you want
> me to do this.

If it's not too much trouble, this would be appreciated.

thx,

Jason.

> Cheers for your help!
> 
>  .../devicetree/bindings/mtd/mtd-physmap.txt        |   24 +--------
>  .../devicetree/bindings/mtd/orion-nand.txt         |   50 ++++++++++++++++++++
>  .../devicetree/bindings/mtd/partition.txt          |   38 +++++++++++++++
>  arch/arm/boot/dts/kirkwood.dtsi                    |   15 ++++++-
>  arch/arm/mach-kirkwood/common.c                    |   12 +++++
>  drivers/mtd/nand/orion_nand.c                      |   34 +++++++++++++-
>  6 files changed, 149 insertions(+), 24 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/mtd/orion-nand.txt
>  create mode 100644 Documentation/devicetree/bindings/mtd/partition.txt
> 
> diff --git a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
> index 80152cb..9b873d4 100644
> --- a/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
> +++ b/Documentation/devicetree/bindings/mtd/mtd-physmap.txt
> @@ -23,27 +23,9 @@ are defined:
>   - vendor-id : Contains the flash chip's vendor id (1 byte).
>   - device-id : Contains the flash chip's device id (1 byte).
> 
> -In addition to the information on the mtd bank itself, the
> -device tree may optionally contain additional information
> -describing partitions of the address space.  This can be
> -used on platforms which have strong conventions about which
> -portions of a flash are used for what purposes, but which don't
> -use an on-flash partition table such as RedBoot.
> -
> -Each partition is represented as a sub-node of the mtd device.
> -Each node's name represents the name of the corresponding
> -partition of the mtd device.
> -
> -Flash partitions
> - - reg : The partition's offset and size within the mtd bank.
> - - label : (optional) The label / name for this partition.
> -   If omitted, the label is taken from the node name (excluding
> -   the unit address).
> - - read-only : (optional) This parameter, if present, is a hint to
> -   Linux that this partition should only be mounted
> -   read-only.  This is usually used for flash partitions
> -   containing early-boot firmware images or data which should not
> -   be clobbered.
> +In addition to the information on the mtd bank itself, the device tree may
> +optionally contain additional sub-nodes describing partitions of the address
> +space. See partition.txt for more detail.
> 
>  Example:
> 
> diff --git a/Documentation/devicetree/bindings/mtd/orion-nand.txt b/Documentation/devicetree/bindings/mtd/orion-nand.txt
> new file mode 100644
> index 0000000..e9acbd2
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/orion-nand.txt
> @@ -0,0 +1,50 @@
> +NAND support for Marvell Orion SoC platforms
> +
> +Required properties:
> +- compatible : "mrvl,orion-nand".
> +- reg : Base physical address of the NAND and length of memory mapped
> +	region
> +
> +Optional properties:
> +- cle :
> +- ale :
> +- bank-width :
> +- chip-delay :
> +
> +In addition to the information on the mtd bank itself, the device tree may
> +optionally contain additional sub-nodes describing partitions of the address
> +space. See partition.txt for more detail.
> +
> +Examples:
> +
> +nand@f4000000 {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +	cle = <0>;
> +	ale = <1>;
> +	bank-width = <8>;
> +	chip-delay = <25>;
> +	compatible = "mrvl,orion-nand";
> +	reg = <0xf4000000 0x400>;
> +
> +	partition@0 {
> +		label = "u-boot";
> +		reg = <0x0000000 0x100000>;
> +		read-only;
> +	};
> +
> +	partition@100000 {
> +		label = "uImage";
> +		reg = <0x0100000 0x200000>;
> +	};
> +
> +	partition@300000 {
> +		label = "dtb";
> +		reg = <0x0300000 0x100000>;
> +	};
> +
> +	partition@400000 {
> +		label = "root";
> +		reg = <0x0400000 0x7d00000>;
> +	};
> +};
> diff --git a/Documentation/devicetree/bindings/mtd/partition.txt b/Documentation/devicetree/bindings/mtd/partition.txt
> new file mode 100644
> index 0000000..f114ce1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/partition.txt
> @@ -0,0 +1,38 @@
> +Representing flash partitions in devicetree
> +
> +Partitions can be represented by sub-nodes of an mtd device. This can be used
> +on platforms which have strong conventions about which portions of a flash are
> +used for what purposes, but which don't use an on-flash partition table such
> +as RedBoot.
> +
> +#address-cells & #size-cells must both be present in the mtd device and be
> +equal to 1.
> +
> +Required properties:
> +- reg : The partition's offset and size within the mtd bank.
> +
> +Optional properties:
> +- label : The label / name for this partition.  If omitted, the label is taken
> +  from the node name (excluding the unit address).
> +- read-only : This parameter, if present, is a hint to Linux that this
> +  partition should only be mounted read-only. This is usually used for flash
> +  partitions containing early-boot firmware images or data which should not be
> +  clobbered.
> +
> +Examples:
> +
> +
> +flash@0 {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +
> +	partition@0 {
> +		label = "u-boot";
> +		reg = <0x0000000 0x100000>;
> +		read-only;
> +	};
> +
> +	uimage@100000 {
> +		reg = <0x0100000 0x200000>;
> +	};
> +];
> diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
> index 3474ef8..6b80374 100644
> --- a/arch/arm/boot/dts/kirkwood.dtsi
> +++ b/arch/arm/boot/dts/kirkwood.dtsi
> @@ -5,7 +5,7 @@
> 
>  	ocp@f1000000 {
>  		compatible = "simple-bus";
> -		ranges = <0 0xf1000000 0x1000000>;
> +		ranges = <0 0xf1000000 0x4000000>;
>  		#address-cells = <1>;
>  		#size-cells = <1>;
> 
> @@ -32,5 +32,18 @@
>  			reg = <0x10300 0x20>;
>  			interrupts = <53>;
>  		};
> +
> +		nand@3000000 {
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +			cle = <0>;
> +			ale = <1>;
> +			bank-width = <8>;
> +			compatible = "mrvl,orion-nand";
> +			reg = <0x3000000 0x400>;
> +			chip-delay = <25>;
> +			/* set partition map and/or chip-delay in board dts */
> +			status = "disabled";
> +		};
>  	};
>  };
> diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
> index a02cae8..3ad0373 100644
> --- a/arch/arm/mach-kirkwood/common.c
> +++ b/arch/arm/mach-kirkwood/common.c
> @@ -15,6 +15,7 @@
>  #include <linux/ata_platform.h>
>  #include <linux/mtd/nand.h>
>  #include <linux/dma-mapping.h>
> +#include <linux/of.h>
>  #include <net/dsa.h>
>  #include <asm/page.h>
>  #include <asm/timex.h>
> @@ -482,6 +483,9 @@ static int __init kirkwood_clock_gate(void)
>  	unsigned int curr = readl(CLOCK_GATING_CTRL);
>  	u32 dev, rev;
> 
> +#ifdef CONFIG_OF
> +	struct device_node *np;
> +#endif
>  	kirkwood_pcie_id(&dev, &rev);
>  	printk(KERN_DEBUG "Gating clock of unused units\n");
>  	printk(KERN_DEBUG "before: 0x%08x\n", curr);
> @@ -489,6 +493,14 @@ static int __init kirkwood_clock_gate(void)
>  	/* Make sure those units are accessible */
>  	writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL);
> 
> +#ifdef CONFIG_OF
> +	np = of_find_compatible_node(NULL, NULL, "mrvl,orion-nand");
> +	if (np && of_device_is_available(np)) {
> +		kirkwood_clk_ctrl |= CGC_RUNIT;
> +		of_node_put(np);
> +	}
> +#endif
> +
>  	/* For SATA: first shutdown the phy */
>  	if (!(kirkwood_clk_ctrl & CGC_SATA0)) {
>  		/* Disable PLL and IVREF */
> diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
> index 29f505a..6a5f47b 100644
> --- a/drivers/mtd/nand/orion_nand.c
> +++ b/drivers/mtd/nand/orion_nand.c
> @@ -13,6 +13,7 @@
>  #include <linux/slab.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/of.h>
>  #include <linux/mtd/mtd.h>
>  #include <linux/mtd/nand.h>
>  #include <linux/mtd/partitions.h>
> @@ -74,11 +75,13 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
>  static int __init orion_nand_probe(struct platform_device *pdev)
>  {
>  	struct mtd_info *mtd;
> +	struct mtd_part_parser_data ppdata = {};
>  	struct nand_chip *nc;
>  	struct orion_nand_data *board;
>  	struct resource *res;
>  	void __iomem *io_base;
>  	int ret = 0;
> +	u32 val = 0;
> 
>  	nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
>  	if (!nc) {
> @@ -101,7 +104,25 @@ static int __init orion_nand_probe(struct platform_device *pdev)
>  		goto no_res;
>  	}
> 
> -	board = pdev->dev.platform_data;
> +	if (pdev->dev.of_node) {
> +		board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
> +					GFP_KERNEL);
> +		if (!board) {
> +			printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
> +			ret = -ENOMEM;
> +			goto no_res;
> +		}
> +		if (!of_property_read_u32(pdev->dev.of_node, "cle", &val))
> +			board->cle = (u8)val;
> +		if (!of_property_read_u32(pdev->dev.of_node, "ale", &val))
> +			board->ale = (u8)val;
> +		if (!of_property_read_u32(pdev->dev.of_node, "bank-width", &val))
> +			board->width = (u8)val;
> +		if (!of_property_read_u32(pdev->dev.of_node,
> +						"chip-delay", &val))
> +			board->chip_delay = (u8)val;
> +	} else
> +		board = pdev->dev.platform_data;
> 
>  	mtd->priv = nc;
>  	mtd->owner = THIS_MODULE;
> @@ -129,7 +150,8 @@ static int __init orion_nand_probe(struct platform_device *pdev)
>  	}
> 
>  	mtd->name = "orion_nand";
> -	ret = mtd_device_parse_register(mtd, NULL, 0,
> +	ppdata.of_node = pdev->dev.of_node;
> +	ret = mtd_device_parse_register(mtd, NULL, &ppdata,
>  			board->parts, board->nr_parts);
>  	if (ret) {
>  		nand_release(mtd);
> @@ -161,11 +183,19 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
>  	return 0;
>  }
> 
> +#ifdef CONFIG_OF
> +static struct of_device_id orion_nand_of_match_table[] = {
> +	{ .compatible = "mrvl,orion-nand", },
> +	{},
> +};
> +#endif
> +
>  static struct platform_driver orion_nand_driver = {
>  	.remove		= __devexit_p(orion_nand_remove),
>  	.driver		= {
>  		.name	= "orion_nand",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = of_match_ptr(orion_nand_of_match_table),
>  	},
>  };
> 
> -- 
> 1.7.9.1

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

* Re: [PATCH V2 1/3] ARM: kirkwood: Basic support for DNS-320 and DNS-325
       [not found]         ` <201203241926.00597.arnd-r2nGTMty4D4@public.gmane.org>
@ 2012-03-25 15:05           ` Jason Cooper
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Cooper @ 2012-03-25 15:05 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jamie Lentin, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Sat, Mar 24, 2012 at 07:26:00PM +0000, Arnd Bergmann wrote:
> On Saturday 24 March 2012, Jamie Lentin wrote:
> > 
> > Add support for the DNS-320 and DNS-325. Describe as much as currently possible
> > in the devicetree files, create a board-dnskw.c for everything else.
> > 
> > Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> 
> Looks good to me. 

Me as well.  Jamie, if you could just incorporate the
orion_nand/kirkwood split and then resubmit (don't forget the acks),
I'll pull them in.

> Jason, do you want to add these to your tree? You are already have some
> the patches for dreamplug, and I think it makes sense to update these two
> together when you have more patches.

Will do.

> Since the dnskw board file contains mostly gpio setup, I think it would
> be good if one of you could take that part on next: once the gpio controller
> uses DT probing, you can move all the gpio leds and buttons into the
> device tree, which drastically shrinks the dnskw file.

Agreed.  Jamie, would you mind working on that while I work on the irq
controller?

Other than my one comment about the patch split, please consider this
series:

Acked-by: Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>

thx,

Jason.

> 
> Acked-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
> 
> 	Arnd

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

* Re: [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts
       [not found]   ` <1332594876-8673-4-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
  2012-03-24 19:01     ` Arnd Bergmann
@ 2012-03-26 15:53     ` Scott Wood
       [not found]       ` <4F7090F9.5000603-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
  1 sibling, 1 reply; 17+ messages in thread
From: Scott Wood @ 2012-03-26 15:53 UTC (permalink / raw)
  To: Jamie Lentin
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason

On 03/24/2012 08:14 AM, Jamie Lentin wrote:
> Use devicetree to define NAND partitions. Use D-link partition scheme by
> default, to be vaguely compatible with their userland.
> 
> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> ---
>  arch/arm/boot/dts/kirkwood-dns320.dts |   35 +++++++++++++++++++++++++++++++++
>  arch/arm/boot/dts/kirkwood-dns325.dts |   35 +++++++++++++++++++++++++++++++++
>  arch/arm/mach-kirkwood/board-dnskw.c  |   31 -----------------------------
>  3 files changed, 70 insertions(+), 31 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
> index 58de7f2..fbf55ff 100644
> --- a/arch/arm/boot/dts/kirkwood-dns320.dts
> +++ b/arch/arm/boot/dts/kirkwood-dns320.dts
> @@ -25,5 +25,40 @@
>  			clock-frequency = <166666667>;
>  			status = "ok";
>  		};
> +
> +		nand@3000000 {
> +			status = "ok";
> +

This should be "okay", not "ok" -- see IEEE1275.  Or just leave it out.

-Scott

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

* Re: [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts
       [not found]       ` <4F7090F9.5000603-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2012-03-26 16:20         ` Jason Cooper
       [not found]           ` <20120326162050.GT2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Cooper @ 2012-03-26 16:20 UTC (permalink / raw)
  To: Scott Wood
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jamie Lentin,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

On Mon, Mar 26, 2012 at 10:53:29AM -0500, Scott Wood wrote:
> On 03/24/2012 08:14 AM, Jamie Lentin wrote:
> > Use devicetree to define NAND partitions. Use D-link partition scheme by
> > default, to be vaguely compatible with their userland.
> > 
> > Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> > ---
> >  arch/arm/boot/dts/kirkwood-dns320.dts |   35 +++++++++++++++++++++++++++++++++
> >  arch/arm/boot/dts/kirkwood-dns325.dts |   35 +++++++++++++++++++++++++++++++++
> >  arch/arm/mach-kirkwood/board-dnskw.c  |   31 -----------------------------
> >  3 files changed, 70 insertions(+), 31 deletions(-)
> > 
> > diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
> > index 58de7f2..fbf55ff 100644
> > --- a/arch/arm/boot/dts/kirkwood-dns320.dts
> > +++ b/arch/arm/boot/dts/kirkwood-dns320.dts
> > @@ -25,5 +25,40 @@
> >  			clock-frequency = <166666667>;
> >  			status = "ok";
> >  		};
> > +
> > +		nand@3000000 {
> > +			status = "ok";
> > +
> 
> This should be "okay", not "ok" -- see IEEE1275.  Or just leave it out.

Ack, but it needs to be there.  Most, but not all, kirkwood boards have
nand, so we define it in kirkwood.dtsi and set it as disabled.
Individual boards can then enable it as needed.

As for 'okay', looks like we may need to patch of_device_is_available()
in drivers/of/base.c (~284) if we want to be consistent with IEEE1275.

The following boards would need to be updated:

arch/arm/boot/dts/kirkwood-dreamplug.dts
arch/powerpc/boot/dts/currituck.dts
arch/powerpc/boot/dts/iss4xx-mpic.dts

Grant, any thoughts on this?

thx,

Jason.

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

* Re: [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts
       [not found]           ` <20120326162050.GT2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
@ 2012-03-26 16:28             ` Scott Wood
       [not found]               ` <4F70991E.1000204-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Scott Wood @ 2012-03-26 16:28 UTC (permalink / raw)
  To: Jason Cooper
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r, Jamie Lentin,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

On 03/26/2012 11:20 AM, Jason Cooper wrote:
> On Mon, Mar 26, 2012 at 10:53:29AM -0500, Scott Wood wrote:
>> On 03/24/2012 08:14 AM, Jamie Lentin wrote:
>>> Use devicetree to define NAND partitions. Use D-link partition scheme by
>>> default, to be vaguely compatible with their userland.
>>>
>>> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
>>> ---
>>>  arch/arm/boot/dts/kirkwood-dns320.dts |   35 +++++++++++++++++++++++++++++++++
>>>  arch/arm/boot/dts/kirkwood-dns325.dts |   35 +++++++++++++++++++++++++++++++++
>>>  arch/arm/mach-kirkwood/board-dnskw.c  |   31 -----------------------------
>>>  3 files changed, 70 insertions(+), 31 deletions(-)
>>>
>>> diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
>>> index 58de7f2..fbf55ff 100644
>>> --- a/arch/arm/boot/dts/kirkwood-dns320.dts
>>> +++ b/arch/arm/boot/dts/kirkwood-dns320.dts
>>> @@ -25,5 +25,40 @@
>>>  			clock-frequency = <166666667>;
>>>  			status = "ok";
>>>  		};
>>> +
>>> +		nand@3000000 {
>>> +			status = "ok";
>>> +
>>
>> This should be "okay", not "ok" -- see IEEE1275.  Or just leave it out.
> 
> Ack, but it needs to be there.  Most, but not all, kirkwood boards have
> nand, so we define it in kirkwood.dtsi and set it as disabled.
> Individual boards can then enable it as needed.
> 
> As for 'okay', looks like we may need to patch of_device_is_available()
> in drivers/of/base.c (~284) if we want to be consistent with IEEE1275.

No need to change of_device_is_available() -- it handles the
standards-compliant "okay" as well as "ok" which is non-compliant but
probably exists in some broken real OF trees (and even if not, it's bad
to break compatibility with older device trees without a good reason).

Maybe add a comment indicating which should be used.

-Scott

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

* Re: [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts
       [not found]               ` <4F70991E.1000204-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2012-03-26 16:36                 ` Jamie Lentin
       [not found]                   ` <alpine.DEB.2.00.1203261730590.23719-5X291BYdrx55rAo4AelP/Ydd74u8MsAO@public.gmane.org>
  2012-03-26 16:52                 ` [PATCH] ARM: kirkwood: fdt: use IEEE1275 status = "okay" Jason Cooper
  1 sibling, 1 reply; 17+ messages in thread
From: Jamie Lentin @ 2012-03-26 16:36 UTC (permalink / raw)
  To: Scott Wood
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason Cooper

On Mon, 26 Mar 2012, Scott Wood wrote:

> On 03/26/2012 11:20 AM, Jason Cooper wrote:
>> On Mon, Mar 26, 2012 at 10:53:29AM -0500, Scott Wood wrote:
>>> On 03/24/2012 08:14 AM, Jamie Lentin wrote:
>>>> Use devicetree to define NAND partitions. Use D-link partition scheme by
>>>> default, to be vaguely compatible with their userland.
>>>>
>>>> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
>>>> ---
>>>>  arch/arm/boot/dts/kirkwood-dns320.dts |   35 +++++++++++++++++++++++++++++++++
>>>>  arch/arm/boot/dts/kirkwood-dns325.dts |   35 +++++++++++++++++++++++++++++++++
>>>>  arch/arm/mach-kirkwood/board-dnskw.c  |   31 -----------------------------
>>>>  3 files changed, 70 insertions(+), 31 deletions(-)
>>>>
>>>> diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
>>>> index 58de7f2..fbf55ff 100644
>>>> --- a/arch/arm/boot/dts/kirkwood-dns320.dts
>>>> +++ b/arch/arm/boot/dts/kirkwood-dns320.dts
>>>> @@ -25,5 +25,40 @@
>>>>  			clock-frequency = <166666667>;
>>>>  			status = "ok";
>>>>  		};
>>>> +
>>>> +		nand@3000000 {
>>>> +			status = "ok";
>>>> +
>>>
>>> This should be "okay", not "ok" -- see IEEE1275.  Or just leave it out.
>>
>> Ack, but it needs to be there.  Most, but not all, kirkwood boards have
>> nand, so we define it in kirkwood.dtsi and set it as disabled.
>> Individual boards can then enable it as needed.
>>
>> As for 'okay', looks like we may need to patch of_device_is_available()
>> in drivers/of/base.c (~284) if we want to be consistent with IEEE1275.
>
> No need to change of_device_is_available() -- it handles the
> standards-compliant "okay" as well as "ok" which is non-compliant but
> probably exists in some broken real OF trees (and even if not, it's bad
> to break compatibility with older device trees without a good reason).
>
> Maybe add a comment indicating which should be used.

I need to re-jig this part anyway, so will update to "okay" too---looks 
like a fairly harmless change.

Would it make sense to change drivers/of/base.c to emit a warning if "ok" 
is used? Or are there already too many devicetrees in the wild that use 
"ok"?

>
> -Scott
>
>

-- 
Jamie Lentin

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

* Re: [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts
       [not found]                   ` <alpine.DEB.2.00.1203261730590.23719-5X291BYdrx55rAo4AelP/Ydd74u8MsAO@public.gmane.org>
@ 2012-03-26 16:43                     ` Jason Cooper
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Cooper @ 2012-03-26 16:43 UTC (permalink / raw)
  To: Jamie Lentin
  Cc: Scott Wood, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On Mon, Mar 26, 2012 at 05:36:10PM +0100, Jamie Lentin wrote:
> On Mon, 26 Mar 2012, Scott Wood wrote:
> 
> >On 03/26/2012 11:20 AM, Jason Cooper wrote:
> >>On Mon, Mar 26, 2012 at 10:53:29AM -0500, Scott Wood wrote:
> >>>On 03/24/2012 08:14 AM, Jamie Lentin wrote:
> >>>>Use devicetree to define NAND partitions. Use D-link partition scheme by
> >>>>default, to be vaguely compatible with their userland.
> >>>>
> >>>>Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> >>>>---
> >>>> arch/arm/boot/dts/kirkwood-dns320.dts |   35 +++++++++++++++++++++++++++++++++
> >>>> arch/arm/boot/dts/kirkwood-dns325.dts |   35 +++++++++++++++++++++++++++++++++
> >>>> arch/arm/mach-kirkwood/board-dnskw.c  |   31 -----------------------------
> >>>> 3 files changed, 70 insertions(+), 31 deletions(-)
> >>>>
> >>>>diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
> >>>>index 58de7f2..fbf55ff 100644
> >>>>--- a/arch/arm/boot/dts/kirkwood-dns320.dts
> >>>>+++ b/arch/arm/boot/dts/kirkwood-dns320.dts
> >>>>@@ -25,5 +25,40 @@
> >>>> 			clock-frequency = <166666667>;
> >>>> 			status = "ok";
> >>>> 		};
> >>>>+
> >>>>+		nand@3000000 {
> >>>>+			status = "ok";
> >>>>+
> >>>
> >>>This should be "okay", not "ok" -- see IEEE1275.  Or just leave it out.
> >>
> >>Ack, but it needs to be there.  Most, but not all, kirkwood boards have
> >>nand, so we define it in kirkwood.dtsi and set it as disabled.
> >>Individual boards can then enable it as needed.
> >>
> >>As for 'okay', looks like we may need to patch of_device_is_available()
> >>in drivers/of/base.c (~284) if we want to be consistent with IEEE1275.
> >
> >No need to change of_device_is_available() -- it handles the
> >standards-compliant "okay" as well as "ok" which is non-compliant but
> >probably exists in some broken real OF trees (and even if not, it's bad
> >to break compatibility with older device trees without a good reason).
> >
> >Maybe add a comment indicating which should be used.
> 
> I need to re-jig this part anyway, so will update to "okay"
> too---looks like a fairly harmless change.
> 
> Would it make sense to change drivers/of/base.c to emit a warning if
> "ok" is used? Or are there already too many devicetrees in the wild
> that use "ok"?

There's only two powerpc boards using this.  I have a patch I'm about
to submit that just adds a comment above the test.  Since that's where I
pulled "ok" from, that should prevent others in the future from repeating
my mistake.

thx,

Jason.

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

* [PATCH] ARM: kirkwood: fdt: use IEEE1275 status = "okay".
       [not found]               ` <4F70991E.1000204-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
  2012-03-26 16:36                 ` Jamie Lentin
@ 2012-03-26 16:52                 ` Jason Cooper
  1 sibling, 0 replies; 17+ messages in thread
From: Jason Cooper @ 2012-03-26 16:52 UTC (permalink / raw)
  To: arnd-r2nGTMty4D4, olof-nZhT3qVonbNeoWH0uzbU5w
  Cc: nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A, andrew-g2DYL2Zd6BY,
	Jason Cooper, jm-Pj/HzkgeCk7QXOPxS62xeg, michael-QKn5cuLxLXY,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Signed-off-by: Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>
---
 - This should prevent others from making the same mistake I did when searching
   the code.

 arch/arm/boot/dts/kirkwood-dreamplug.dts |    2 +-
 drivers/of/base.c                        |    1 +
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts b/arch/arm/boot/dts/kirkwood-dreamplug.dts
index a5376b8..7b2b961 100644
--- a/arch/arm/boot/dts/kirkwood-dreamplug.dts
+++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
@@ -18,7 +18,7 @@
 	ocp@f1000000 {
 		serial@12000 {
 			clock-frequency = <200000000>;
-			status = "ok";
+			status = "okay";
 		};
 	};
 };
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 133908a..31eac15 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -285,6 +285,7 @@ int of_device_is_available(const struct device_node *device)
 		return 1;
 
 	if (statlen > 0) {
+		/* new boards should use "okay" according to IEEE1275 */
 		if (!strcmp(status, "okay") || !strcmp(status, "ok"))
 			return 1;
 	}
-- 
1.7.3.4

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

end of thread, other threads:[~2012-03-26 16:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-24 13:14 [PATCH V2 0/3] Add support for DNS-320 and DNS-325 using devicetree Jamie Lentin
     [not found] ` <1332594876-8673-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-24 13:14   ` [PATCH V2 1/3] ARM: kirkwood: Basic support for DNS-320 and DNS-325 Jamie Lentin
     [not found]     ` <1332594876-8673-2-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-24 19:26       ` Arnd Bergmann
     [not found]         ` <201203241926.00597.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-25 15:05           ` Jason Cooper
2012-03-24 13:14 ` [PATCH V2 2/3] ARM: kirkwood: Convert orion-nand to fdt Jamie Lentin
     [not found]   ` <1332594876-8673-3-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-24 19:01     ` Arnd Bergmann
     [not found]       ` <201203241901.00405.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-25  0:17         ` [PATCH V3 " Jamie Lentin
2012-03-25  7:52           ` Arnd Bergmann
2012-03-25 14:57           ` Jason Cooper
2012-03-24 13:14 ` [PATCH V2 3/3] ARM: kirkwood: Define NAND partitions in dts Jamie Lentin
     [not found]   ` <1332594876-8673-4-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-24 19:01     ` Arnd Bergmann
2012-03-26 15:53     ` Scott Wood
     [not found]       ` <4F7090F9.5000603-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-03-26 16:20         ` Jason Cooper
     [not found]           ` <20120326162050.GT2484-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-26 16:28             ` Scott Wood
     [not found]               ` <4F70991E.1000204-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2012-03-26 16:36                 ` Jamie Lentin
     [not found]                   ` <alpine.DEB.2.00.1203261730590.23719-5X291BYdrx55rAo4AelP/Ydd74u8MsAO@public.gmane.org>
2012-03-26 16:43                     ` Jason Cooper
2012-03-26 16:52                 ` [PATCH] ARM: kirkwood: fdt: use IEEE1275 status = "okay" Jason Cooper

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