* [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree
@ 2012-03-11 14:33 Jamie Lentin
[not found] ` <1331476406-9844-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
0 siblings, 1 reply; 18+ messages in thread
From: Jamie Lentin @ 2012-03-11 14:33 UTC (permalink / raw)
To: Arnd Bergmann, Jason
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jamie Lentin,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
As agreed with Arnd Bergmann and Jason Cooper, include any board setup that
cannot be done in devicetree in board-dt.c, then replace with devicetree
entries.
The NAND driver is converted to devicetree as part of this patch series,
although I don't feel qualified to explain the parameters actually mean so
have left documentation fields blank.
The patches should apply cleanly to staging/kirkwood/dt, although
kirkwood-dns320.dts attempts to override the orion-wdt definition with a
lower TCLK, even though the orion-wdt work isn't merged yet. If this would
be better to remove I shall.
Cheers,
Jamie Lentin (2):
ARM: kirkwood: Basic support for DNS-320 and DNS-325
ARM: kirkwood: Convert orion-nand to fdt
.../devicetree/bindings/mtd/orion-nand.txt | 41 +++
arch/arm/boot/dts/kirkwood-dns320.dts | 96 +++++++
arch/arm/boot/dts/kirkwood-dns325.dts | 82 ++++++
arch/arm/mach-kirkwood/Kconfig | 18 ++
arch/arm/mach-kirkwood/Makefile.boot | 2 +
arch/arm/mach-kirkwood/board-dt.c | 264 ++++++++++++++++++++
arch/arm/mach-kirkwood/common.c | 6 +
drivers/mtd/nand/orion_nand.c | 39 +++-
8 files changed, 546 insertions(+), 2 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
--
1.7.9.1
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <1331476406-9844-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-11 14:33 ` Jamie Lentin
[not found] ` <1331476406-9844-2-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 14:33 ` [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt Jamie Lentin
2012-03-12 2:36 ` [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree Jason Cooper
2 siblings, 1 reply; 18+ messages in thread
From: Jamie Lentin @ 2012-03-11 14:33 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, leave everything else in board-dt.c to be patched
later.
Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
---
arch/arm/boot/dts/kirkwood-dns320.dts | 54 ++++++
arch/arm/boot/dts/kirkwood-dns325.dts | 40 +++++
arch/arm/mach-kirkwood/Kconfig | 18 ++
arch/arm/mach-kirkwood/Makefile.boot | 2 +
arch/arm/mach-kirkwood/board-dt.c | 294 +++++++++++++++++++++++++++++++++
5 files changed, 408 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/boot/dts/kirkwood-dns320.dts
create mode 100644 arch/arm/boot/dts/kirkwood-dns325.dts
diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
new file mode 100644
index 0000000..c039041
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-dns320.dts
@@ -0,0 +1,54 @@
+/dts-v1/;
+
+/include/ "kirkwood.dtsi"
+
+/ {
+ model = "D-Link DNS-320 NAS (Rev A1)";
+ compatible = "dlink,dns-320-a1", "dlink,dns-320", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
+
+ memory {
+ device_type = "memory";
+ reg = <0x00000000 0x8000000>;
+ };
+
+ chosen {
+ bootargs = "console=ttyS0,115200n8 earlyprintk";
+ };
+
+ wdt@fed20300 {
+ compatible = "mrvl,orion-wdt";
+ reg = <0xfed20300 0x28>;
+ clock-frequency = <166666667>;
+ };
+
+ serial@f1012000 {
+ compatible = "ns16550a";
+ reg = <0xf1012000 0xff>;
+ reg-shift = <2>;
+ interrupts = <33>;
+ clock-frequency = <166666667>;
+ };
+
+ serial@f1012100 {
+ compatible = "ns16550a";
+ reg = <0xf1012100 0xff>;
+ reg-shift = <2>;
+ interrupts = <34>;
+ clock-frequency = <166666667>;
+ };
+
+ sata@f1080000 {
+ compatible = "mrvl,orion-sata";
+ reg = <0xf1080000 0x5000>;
+ interrupts = <21>;
+ nr-ports = <2>;
+ };
+
+ ehci@f1050000 {
+ compatible = "mrvl,orion-ehci";
+ reg = <0xf1050000 0x1000>;
+ interrupts = <19>;
+ dma-mask = <0xffffffff>;
+ phy-version = "";
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dns325.dts b/arch/arm/boot/dts/kirkwood-dns325.dts
new file mode 100644
index 0000000..a7c2c26
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-dns325.dts
@@ -0,0 +1,40 @@
+/dts-v1/;
+
+/include/ "kirkwood.dtsi"
+
+/ {
+ model = "D-Link DNS-325 NAS (Rev A1)";
+ compatible = "dlink,dns-325-a1", "dlink,dns-325", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
+
+ memory {
+ device_type = "memory";
+ reg = <0x00000000 0x10000000>;
+ };
+
+ chosen {
+ bootargs = "console=ttyS0,115200n8 earlyprintk";
+ };
+
+ serial@f1012000 {
+ compatible = "ns16550a";
+ reg = <0xf1012000 0xff>;
+ reg-shift = <2>;
+ interrupts = <33>;
+ clock-frequency = <200000000>;
+ };
+
+ sata@f1080000 {
+ compatible = "mrvl,orion-sata";
+ reg = <0xf1080000 0x5000>;
+ interrupts = <21>;
+ nr-ports = <2>;
+ };
+
+ ehci@f1050000 {
+ compatible = "mrvl,orion-ehci";
+ reg = <0xf1050000 0x1000>;
+ interrupts = <19>;
+ dma-mask = <0xffffffff>;
+ phy-version = "";
+ };
+};
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 90ceab7..6c76e18 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -58,6 +58,24 @@ config MACH_DREAMPLUG_DT
Say 'Y' here if you want your kernel to support the
Marvell DreamPlug (Flattened Device Tree).
+config MACH_DNS320_DT
+ bool "D-Link DNS-320 (Flattened Device Tree)"
+ select ARCH_KIRKWOOD_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 (Flattened Device Tree).
+
+config MACH_DNS325_DT
+ bool "D-Link DNS-325 (Flattened Device Tree)"
+ select ARCH_KIRKWOOD_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 (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.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-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 12dec38..0885713 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -15,6 +15,7 @@
#include <linux/platform_device.h>
#include <linux/irqdomain.h>
#include <linux/mtd/partitions.h>
+#include <linux/i2c.h>
#include <linux/ata_platform.h>
#include <linux/mv643xx_eth.h>
#include <linux/of.h>
@@ -23,6 +24,9 @@
#include <linux/of_irq.h>
#include <linux/of_platform.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 <linux/spi/flash.h>
@@ -150,6 +154,291 @@ static void __init dreamplug_init(void)
platform_device_register(&dreamplug_leds);
}
+/*****************************************************************************
+ * DNS-320 & DNS-325 specifics
+ ****************************************************************************/
+
+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 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: MV88F6281_DEV_ID Board */
+ MPP37_GPIO, /* Power: Boot when power applied */
+ 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 __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);
+}
+
+static void dnskw_power_off(void)
+{
+ gpio_set_value(36, 1);
+}
+
+static void __init dnskw_init(void)
+{
+ u32 dev, rev;
+
+ kirkwood_mpp_conf(dnskw_mpp_config);
+ kirkwood_nand_init(ARRAY_AND_SIZE(dnskw_nand_parts), 25);
+
+ kirkwood_ge00_init(&dnskw_ge00_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 routine */
+ kirkwood_pcie_id(&dev, &rev);
+ if (dev == MV88F6281_DEV_ID) {
+ pr_info("PCI-E Device ID: MV88F6281, configuring power-off");
+ 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");
+ } else {
+ /*
+ * Dlink code also defines 0x6192, and sets LOW_BASE +
+ * 0x01000000 high. Either cargo-culted code or another model.
+ */
+ pr_err("Unknown PCI-E Device ID %x, no power-off", dev);
+ }
+
+ /*
+ * Supply power to HDDs. Bootloader should have turned on sata0 already
+ */
+ 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);
+}
+
static void __init kirkwood_dt_init(void)
{
struct device_node *node;
@@ -186,11 +475,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
};
--
1.7.9.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt
[not found] ` <1331476406-9844-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 14:33 ` [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325 Jamie Lentin
@ 2012-03-11 14:33 ` Jamie Lentin
[not found] ` <1331476406-9844-3-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-12 2:36 ` [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree Jason Cooper
2 siblings, 1 reply; 18+ messages in thread
From: Jamie Lentin @ 2012-03-11 14:33 UTC (permalink / raw)
To: Arnd Bergmann, Jason
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jamie Lentin,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
The DNS-320 and 325 have a NAND partitioned to store uboot, uimage and root
filesystem. Store this information in devicetree.
Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
---
.../devicetree/bindings/mtd/orion-nand.txt | 41 +++++++++++++++++++
arch/arm/boot/dts/kirkwood-dns320.dts | 42 ++++++++++++++++++++
arch/arm/boot/dts/kirkwood-dns325.dts | 42 ++++++++++++++++++++
arch/arm/mach-kirkwood/board-dt.c | 30 --------------
arch/arm/mach-kirkwood/common.c | 6 +++
drivers/mtd/nand/orion_nand.c | 39 +++++++++++++++++-
6 files changed, 168 insertions(+), 32 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..53fd469
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/orion-nand.txt
@@ -0,0 +1,41 @@
+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 = "root";
+ reg = <0x0300000 0x7d00000>;
+ };
+};
diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
index c039041..6772f9d 100644
--- a/arch/arm/boot/dts/kirkwood-dns320.dts
+++ b/arch/arm/boot/dts/kirkwood-dns320.dts
@@ -51,4 +51,46 @@
dma-mask = <0xffffffff>;
phy-version = "";
};
+
+ 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 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 a7c2c26..34740ad 100644
--- a/arch/arm/boot/dts/kirkwood-dns325.dts
+++ b/arch/arm/boot/dts/kirkwood-dns325.dts
@@ -37,4 +37,46 @@
dma-mask = <0xffffffff>;
phy-version = "";
};
+
+ 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 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-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 0885713..d5bc60a 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -158,35 +158,6 @@ static void __init dreamplug_init(void)
* DNS-320 & DNS-325 specifics
****************************************************************************/
-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),
};
@@ -395,7 +366,6 @@ static void __init dnskw_init(void)
u32 dev, rev;
kirkwood_mpp_conf(dnskw_mpp_config);
- kirkwood_nand_init(ARRAY_AND_SIZE(dnskw_nand_parts), 25);
kirkwood_ge00_init(&dnskw_ge00_data);
kirkwood_i2c_init();
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index 70ee7ac..f135854 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -505,6 +505,12 @@ static int __init kirkwood_clock_gate(void)
of_node_put(np);
}
+ 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);
+ }
+
np = of_find_compatible_node(NULL, NULL, "mrvl,orion-sata");
if (np && of_device_is_available(np)) {
int nr_ports;
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 29f505a..5ae0030 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,24 @@ static int __init orion_nand_probe(struct platform_device *pdev)
goto no_res;
}
- board = pdev->dev.platform_data;
+ if (pdev->dev.of_node) {
+ board = kzalloc(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 +149,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);
@@ -141,6 +162,8 @@ static int __init orion_nand_probe(struct platform_device *pdev)
no_dev:
platform_set_drvdata(pdev, NULL);
iounmap(io_base);
+ if (pdev->dev.of_node)
+ kfree(board);
no_res:
kfree(nc);
@@ -156,16 +179,28 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
iounmap(nc->IO_ADDR_W);
+ if (pdev->dev.of_node)
+ kfree(nc->priv);
kfree(nc);
return 0;
}
+#ifdef CONFIG_OF
+static struct of_device_id orion_nand_of_match_table[] = {
+ { .compatible = "mrvl,orion-nand", },
+ {},
+};
+#else
+#define orion_nand_of_match_table NULL
+#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] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <1331476406-9844-2-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-11 17:46 ` Arnd Bergmann
[not found] ` <201203111746.09757.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-12 3:02 ` Jason Cooper
1 sibling, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2012-03-11 17:46 UTC (permalink / raw)
To: Jamie Lentin
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Sunday 11 March 2012, Jamie Lentin wrote:
> Add support for the DNS-320 and DNS-325. Describe as much as currently possible
> in the devicetree files, leave everything else in board-dt.c to be patched
> later.
>
> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
Great work!
> +
> +/ {
> + model = "D-Link DNS-320 NAS (Rev A1)";
> + compatible = "dlink,dns-320-a1", "dlink,dns-320", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
> +
> + memory {
> + device_type = "memory";
> + reg = <0x00000000 0x8000000>;
> + };
> +
> + chosen {
> + bootargs = "console=ttyS0,115200n8 earlyprintk";
> + };
> +
> + wdt@fed20300 {
> + compatible = "mrvl,orion-wdt";
> + reg = <0xfed20300 0x28>;
> + clock-frequency = <166666667>;
> + };
> +
> + serial@f1012000 {
> + compatible = "ns16550a";
> + reg = <0xf1012000 0xff>;
> + reg-shift = <2>;
> + interrupts = <33>;
> + clock-frequency = <166666667>;
> + };
> +
> + serial@f1012100 {
> + compatible = "ns16550a";
> + reg = <0xf1012100 0xff>;
> + reg-shift = <2>;
> + interrupts = <34>;
> + clock-frequency = <166666667>;
> + };
I think the generic kirkwood device nodes should all be part of
the kirkwood.dtsi file, except for any properties you want to
override.
You can add a status="disabled" property in device nodes
that may not be connected in individual boards, and then
just override it by listing status="enabled" in the board.dts
file, without having to duplicate all the other properties.
I would also suggest to change the kirkwood.dtsi layout to
put all the on-chip peripherals from the 0xf1 section into
one bus in the device tree, like
ocp@f1000000 {
compatible = "simple-bus";
ranges = <0xf1000000 0xf1000000 0x1000000>;
#address-cells = 1;
#size-cells = 1;
serial@f1012000 {
...
};
...
};
Or even use the ranges property to remap everything into
a simpler address range:
ocp@f1000000 {
compatible = "simple-bus";
ranges = <0 0xf1000000 0x1000000>;
#address-cells = 1;
#size-cells = 1;
serial@12000 {
reg = <0x12000 0x100>;
...
};
...
};
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt
[not found] ` <1331476406-9844-3-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
@ 2012-03-11 17:52 ` Arnd Bergmann
2012-03-12 3:23 ` Jason Cooper
1 sibling, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2012-03-11 17:52 UTC (permalink / raw)
To: Jamie Lentin
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Jason,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Sunday 11 March 2012, Jamie Lentin wrote:
> The DNS-320 and 325 have a NAND partitioned to store uboot, uimage and root
> filesystem. Store this information in devicetree.
All the important parts look good to me, just two small details:
> - board = pdev->dev.platform_data;
> + if (pdev->dev.of_node) {
> + board = kzalloc(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;
If you use devm_kzalloc, the memory will get freed automatically during cleanup.
> +#ifdef CONFIG_OF
> +static struct of_device_id orion_nand_of_match_table[] = {
> + { .compatible = "mrvl,orion-nand", },
> + {},
> +};
> +#else
> +#define orion_nand_of_match_table NULL
> +#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),
> },
> };
When you use of_match_ptr(), you can leave out the "#else\n#define orion_nand_of_match_table NULL".
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree
[not found] ` <1331476406-9844-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 14:33 ` [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325 Jamie Lentin
2012-03-11 14:33 ` [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt Jamie Lentin
@ 2012-03-12 2:36 ` Jason Cooper
2 siblings, 0 replies; 18+ messages in thread
From: Jason Cooper @ 2012-03-12 2:36 UTC (permalink / raw)
To: Jamie Lentin
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Sun, Mar 11, 2012 at 02:33:24PM +0000, Jamie Lentin wrote:
> As agreed with Arnd Bergmann and Jason Cooper, include any board setup that
> cannot be done in devicetree in board-dt.c, then replace with devicetree
> entries.
>
> The NAND driver is converted to devicetree as part of this patch series,
> although I don't feel qualified to explain the parameters actually mean so
> have left documentation fields blank.
Thanks!
> The patches should apply cleanly to staging/kirkwood/dt, although
> kirkwood-dns320.dts attempts to override the orion-wdt definition with a
> lower TCLK, even though the orion-wdt work isn't merged yet. If this would
> be better to remove I shall.
It would be better if you base off of my stable branch. You won't have
the clock issues (wdt isn't merged there yet). Also, my staging branch
has been in flux and will soon be renamed/removed.
> Cheers,
>
> Jamie Lentin (2):
> ARM: kirkwood: Basic support for DNS-320 and DNS-325
> ARM: kirkwood: Convert orion-nand to fdt
>
> .../devicetree/bindings/mtd/orion-nand.txt | 41 +++
> arch/arm/boot/dts/kirkwood-dns320.dts | 96 +++++++
> arch/arm/boot/dts/kirkwood-dns325.dts | 82 ++++++
> arch/arm/mach-kirkwood/Kconfig | 18 ++
> arch/arm/mach-kirkwood/Makefile.boot | 2 +
> arch/arm/mach-kirkwood/board-dt.c | 264 ++++++++++++++++++++
> arch/arm/mach-kirkwood/common.c | 6 +
> drivers/mtd/nand/orion_nand.c | 39 +++-
> 8 files changed, 546 insertions(+), 2 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
>
> --
> 1.7.9.1
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <1331476406-9844-2-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 17:46 ` Arnd Bergmann
@ 2012-03-12 3:02 ` Jason Cooper
[not found] ` <20120312030232.GX5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
1 sibling, 1 reply; 18+ messages in thread
From: Jason Cooper @ 2012-03-12 3:02 UTC (permalink / raw)
To: Jamie Lentin
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Sun, Mar 11, 2012 at 02:33:25PM +0000, Jamie Lentin wrote:
> Add support for the DNS-320 and DNS-325. Describe as much as currently possible
> in the devicetree files, leave everything else in board-dt.c to be patched
> later.
>
> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
Great work! comments, below.
> ---
> arch/arm/boot/dts/kirkwood-dns320.dts | 54 ++++++
> arch/arm/boot/dts/kirkwood-dns325.dts | 40 +++++
> arch/arm/mach-kirkwood/Kconfig | 18 ++
> arch/arm/mach-kirkwood/Makefile.boot | 2 +
> arch/arm/mach-kirkwood/board-dt.c | 294 +++++++++++++++++++++++++++++++++
> 5 files changed, 408 insertions(+), 0 deletions(-)
> create mode 100644 arch/arm/boot/dts/kirkwood-dns320.dts
> create mode 100644 arch/arm/boot/dts/kirkwood-dns325.dts
>
> diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
> new file mode 100644
> index 0000000..c039041
> --- /dev/null
> +++ b/arch/arm/boot/dts/kirkwood-dns320.dts
> @@ -0,0 +1,54 @@
> +/dts-v1/;
> +
> +/include/ "kirkwood.dtsi"
> +
> +/ {
> + model = "D-Link DNS-320 NAS (Rev A1)";
> + compatible = "dlink,dns-320-a1", "dlink,dns-320", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
s/marvell/mrvl/g for compatible properties.
> + memory {
> + device_type = "memory";
> + reg = <0x00000000 0x8000000>;
> + };
> +
> + chosen {
> + bootargs = "console=ttyS0,115200n8 earlyprintk";
> + };
> +
> + wdt@fed20300 {
> + compatible = "mrvl,orion-wdt";
> + reg = <0xfed20300 0x28>;
> + clock-frequency = <166666667>;
> + };
This hasn't made it into my stable branch yet, waiting on common clock
to land (may be 3.5). Please use kirkwood_wdt_init() in the mean time.
> + serial@f1012000 {
> + compatible = "ns16550a";
> + reg = <0xf1012000 0xff>;
> + reg-shift = <2>;
> + interrupts = <33>;
> + clock-frequency = <166666667>;
> + };
> +
> + serial@f1012100 {
> + compatible = "ns16550a";
> + reg = <0xf1012100 0xff>;
> + reg-shift = <2>;
> + interrupts = <34>;
> + clock-frequency = <166666667>;
> + };
> +
> + sata@f1080000 {
> + compatible = "mrvl,orion-sata";
> + reg = <0xf1080000 0x5000>;
> + interrupts = <21>;
> + nr-ports = <2>;
> + };
> +
> + ehci@f1050000 {
> + compatible = "mrvl,orion-ehci";
> + reg = <0xf1050000 0x1000>;
> + interrupts = <19>;
> + dma-mask = <0xffffffff>;
> + phy-version = "";
> + };
sata and ehci both require working dma and interrupt controller. I
should have the interrupt controller done soon. mv_cesa will then work.
dma will be after that.
Basically, anything in mach-kirkwood/common.c that passes kirkwood_tclk
is on hold for devicetree.
> +};
> diff --git a/arch/arm/boot/dts/kirkwood-dns325.dts b/arch/arm/boot/dts/kirkwood-dns325.dts
> new file mode 100644
> index 0000000..a7c2c26
> --- /dev/null
> +++ b/arch/arm/boot/dts/kirkwood-dns325.dts
> @@ -0,0 +1,40 @@
> +/dts-v1/;
> +
> +/include/ "kirkwood.dtsi"
> +
> +/ {
> + model = "D-Link DNS-325 NAS (Rev A1)";
> + compatible = "dlink,dns-325-a1", "dlink,dns-325", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
same as above, mrvl.
> +
> + memory {
> + device_type = "memory";
> + reg = <0x00000000 0x10000000>;
> + };
> +
> + chosen {
> + bootargs = "console=ttyS0,115200n8 earlyprintk";
> + };
make sure to test serial with earlyprintk disabled. That bit me once.
> +
> + serial@f1012000 {
> + compatible = "ns16550a";
> + reg = <0xf1012000 0xff>;
> + reg-shift = <2>;
> + interrupts = <33>;
> + clock-frequency = <200000000>;
> + };
> +
> + sata@f1080000 {
> + compatible = "mrvl,orion-sata";
> + reg = <0xf1080000 0x5000>;
> + interrupts = <21>;
> + nr-ports = <2>;
> + };
> +
> + ehci@f1050000 {
> + compatible = "mrvl,orion-ehci";
> + reg = <0xf1050000 0x1000>;
> + interrupts = <19>;
> + dma-mask = <0xffffffff>;
> + phy-version = "";
> + };
> +};
> diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
> index 90ceab7..6c76e18 100644
> --- a/arch/arm/mach-kirkwood/Kconfig
> +++ b/arch/arm/mach-kirkwood/Kconfig
> @@ -58,6 +58,24 @@ config MACH_DREAMPLUG_DT
> Say 'Y' here if you want your kernel to support the
> Marvell DreamPlug (Flattened Device Tree).
>
> +config MACH_DNS320_DT
> + bool "D-Link DNS-320 (Flattened Device Tree)"
> + select ARCH_KIRKWOOD_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 (Flattened Device Tree).
> +
> +config MACH_DNS325_DT
> + bool "D-Link DNS-325 (Flattened Device Tree)"
> + select ARCH_KIRKWOOD_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 (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.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-dt.c b/arch/arm/mach-kirkwood/board-dt.c
> index 12dec38..0885713 100644
> --- a/arch/arm/mach-kirkwood/board-dt.c
> +++ b/arch/arm/mach-kirkwood/board-dt.c
> @@ -15,6 +15,7 @@
> #include <linux/platform_device.h>
> #include <linux/irqdomain.h>
> #include <linux/mtd/partitions.h>
> +#include <linux/i2c.h>
> #include <linux/ata_platform.h>
> #include <linux/mv643xx_eth.h>
> #include <linux/of.h>
> @@ -23,6 +24,9 @@
> #include <linux/of_irq.h>
> #include <linux/of_platform.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 <linux/spi/flash.h>
> @@ -150,6 +154,291 @@ static void __init dreamplug_init(void)
> platform_device_register(&dreamplug_leds);
> }
>
> +/*****************************************************************************
> + * DNS-320 & DNS-325 specifics
> + ****************************************************************************/
> +
> +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
> + },
> +};
You should probably squeeze in a partition for the dtb. ;-)
Is the config partition the u-boot environment? That usually is much
smaller than what you have alotted. So, you might be able to split that
to make room for the dtb.
> +
> +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) */
> + 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: MV88F6281_DEV_ID Board */
> + MPP37_GPIO, /* Power: Boot when power applied */
> + 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 __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);
> +}
> +
> +static void dnskw_power_off(void)
> +{
> + gpio_set_value(36, 1);
> +}
> +
> +static void __init dnskw_init(void)
> +{
> + u32 dev, rev;
> +
> + kirkwood_mpp_conf(dnskw_mpp_config);
> + kirkwood_nand_init(ARRAY_AND_SIZE(dnskw_nand_parts), 25);
> +
> + kirkwood_ge00_init(&dnskw_ge00_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);
> + }
braces not needed.
> +
> + /* Register power off routine */
> + kirkwood_pcie_id(&dev, &rev);
> + if (dev == MV88F6281_DEV_ID) {
> + pr_info("PCI-E Device ID: MV88F6281, configuring power-off");
> + 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");
> + } else {
> + /*
> + * Dlink code also defines 0x6192, and sets LOW_BASE +
> + * 0x01000000 high. Either cargo-culted code or another model.
> + */
I'm just curious, what is cargo-culted?
> + pr_err("Unknown PCI-E Device ID %x, no power-off", dev);
> + }
> +
> + /*
> + * Supply power to HDDs. Bootloader should have turned on sata0 already
> + */
Don't assume the bootloader does or doesn't do anything. Put the
peripheral into a known state and work from there.
> + 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);
> +}
> +
I doubt this board is the only one that wants to be added while the
conversion to devicetree is progressing. It makes more sense to me to
break the above out to a separate file, eg board-dnskw.c. I'll follow
and break out the dreamplug code to board-dreamplug.c. Otherwise, I see
board-dt.c becoming a long mess.
Arnd, sound okay to you?
> static void __init kirkwood_dt_init(void)
> {
> struct device_node *node;
> @@ -186,11 +475,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
> };
>
> --
> 1.7.9.1
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <201203111746.09757.arnd-r2nGTMty4D4@public.gmane.org>
@ 2012-03-12 3:17 ` Jason Cooper
[not found] ` <20120312031751.GY5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
0 siblings, 1 reply; 18+ messages in thread
From: Jason Cooper @ 2012-03-12 3:17 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jamie Lentin, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Sun, Mar 11, 2012 at 05:46:09PM +0000, Arnd Bergmann wrote:
> On Sunday 11 March 2012, Jamie Lentin wrote:
> > Add support for the DNS-320 and DNS-325. Describe as much as currently possible
> > in the devicetree files, leave everything else in board-dt.c to be patched
> > later.
> >
> > Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
>
> Great work!
>
> > +
> > +/ {
> > + model = "D-Link DNS-320 NAS (Rev A1)";
> > + compatible = "dlink,dns-320-a1", "dlink,dns-320", "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
> > +
> > + memory {
> > + device_type = "memory";
> > + reg = <0x00000000 0x8000000>;
> > + };
> > +
> > + chosen {
> > + bootargs = "console=ttyS0,115200n8 earlyprintk";
> > + };
> > +
> > + wdt@fed20300 {
> > + compatible = "mrvl,orion-wdt";
> > + reg = <0xfed20300 0x28>;
> > + clock-frequency = <166666667>;
> > + };
> > +
> > + serial@f1012000 {
> > + compatible = "ns16550a";
> > + reg = <0xf1012000 0xff>;
> > + reg-shift = <2>;
> > + interrupts = <33>;
> > + clock-frequency = <166666667>;
> > + };
> > +
> > + serial@f1012100 {
> > + compatible = "ns16550a";
> > + reg = <0xf1012100 0xff>;
oops, I missed this earlier (and, I just corrected in my own code).
Arnd says Linux uses inclusive sizes, so the above should be 0x100.
Please correct for all register sizes.
> > + reg-shift = <2>;
> > + interrupts = <34>;
> > + clock-frequency = <166666667>;
> > + };
>
> I think the generic kirkwood device nodes should all be part of
> the kirkwood.dtsi file, except for any properties you want to
> override.
>
> You can add a status="disabled" property in device nodes
> that may not be connected in individual boards, and then
> just override it by listing status="enabled" in the board.dts
> file, without having to duplicate all the other properties.
The clock-frequency property complicates that, since it is different
from board to board. of_serial appears to print an error message if
clock-frequency isn't set, so would this work:
### blah.dtsi ###
...
serial@f1012100 {
compatible = "ns16550a";
reg = <0xf1012100 0xff>;
reg-shift = <2>;
interrupts = <34>;
/* no clock set */
status = "disabled";
}
#################
then,
### blah-foo.dts ###
...
serial@f1012100 {
status = "ok";
clock-frequency = <166666667>;
}
####################
> I would also suggest to change the kirkwood.dtsi layout to
> put all the on-chip peripherals from the 0xf1 section into
> one bus in the device tree, like
>
> ocp@f1000000 {
> compatible = "simple-bus";
> ranges = <0xf1000000 0xf1000000 0x1000000>;
> #address-cells = 1;
> #size-cells = 1;
>
> serial@f1012000 {
> ...
> };
>
> ...
> };
>
> Or even use the ranges property to remap everything into
> a simpler address range:
>
> ocp@f1000000 {
> compatible = "simple-bus";
> ranges = <0 0xf1000000 0x1000000>;
> #address-cells = 1;
> #size-cells = 1;
>
> serial@12000 {
> reg = <0x12000 0x100>;
> ...
> };
>
> ...
> };
Okay, that's pretty slick. The wdt and intc are at 0xfed00000, is that
another ocp bus? Or, am I missing something?
thx,
Jason.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt
[not found] ` <1331476406-9844-3-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 17:52 ` Arnd Bergmann
@ 2012-03-12 3:23 ` Jason Cooper
1 sibling, 0 replies; 18+ messages in thread
From: Jason Cooper @ 2012-03-12 3:23 UTC (permalink / raw)
To: Jamie Lentin
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Sun, Mar 11, 2012 at 02:33:26PM +0000, Jamie Lentin wrote:
> The DNS-320 and 325 have a NAND partitioned to store uboot, uimage and root
> filesystem. Store this information in devicetree.
>
> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> ---
> .../devicetree/bindings/mtd/orion-nand.txt | 41 +++++++++++++++++++
> arch/arm/boot/dts/kirkwood-dns320.dts | 42 ++++++++++++++++++++
> arch/arm/boot/dts/kirkwood-dns325.dts | 42 ++++++++++++++++++++
> arch/arm/mach-kirkwood/board-dt.c | 30 --------------
> arch/arm/mach-kirkwood/common.c | 6 +++
> drivers/mtd/nand/orion_nand.c | 39 +++++++++++++++++-
> 6 files changed, 168 insertions(+), 32 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..53fd469
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mtd/orion-nand.txt
> @@ -0,0 +1,41 @@
> +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 = "root";
> + reg = <0x0300000 0x7d00000>;
> + };
You may want the example to include a partition for the dtb.
I'll let more experienced folks comment on the guts of the nand
bindings.
thx,
Jason.
> +};
> diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts b/arch/arm/boot/dts/kirkwood-dns320.dts
> index c039041..6772f9d 100644
> --- a/arch/arm/boot/dts/kirkwood-dns320.dts
> +++ b/arch/arm/boot/dts/kirkwood-dns320.dts
> @@ -51,4 +51,46 @@
> dma-mask = <0xffffffff>;
> phy-version = "";
> };
> +
> + 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 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 a7c2c26..34740ad 100644
> --- a/arch/arm/boot/dts/kirkwood-dns325.dts
> +++ b/arch/arm/boot/dts/kirkwood-dns325.dts
> @@ -37,4 +37,46 @@
> dma-mask = <0xffffffff>;
> phy-version = "";
> };
> +
> + 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 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-dt.c b/arch/arm/mach-kirkwood/board-dt.c
> index 0885713..d5bc60a 100644
> --- a/arch/arm/mach-kirkwood/board-dt.c
> +++ b/arch/arm/mach-kirkwood/board-dt.c
> @@ -158,35 +158,6 @@ static void __init dreamplug_init(void)
> * DNS-320 & DNS-325 specifics
> ****************************************************************************/
>
> -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),
> };
> @@ -395,7 +366,6 @@ static void __init dnskw_init(void)
> u32 dev, rev;
>
> kirkwood_mpp_conf(dnskw_mpp_config);
> - kirkwood_nand_init(ARRAY_AND_SIZE(dnskw_nand_parts), 25);
>
> kirkwood_ge00_init(&dnskw_ge00_data);
> kirkwood_i2c_init();
> diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
> index 70ee7ac..f135854 100644
> --- a/arch/arm/mach-kirkwood/common.c
> +++ b/arch/arm/mach-kirkwood/common.c
> @@ -505,6 +505,12 @@ static int __init kirkwood_clock_gate(void)
> of_node_put(np);
> }
>
> + 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);
> + }
> +
> np = of_find_compatible_node(NULL, NULL, "mrvl,orion-sata");
> if (np && of_device_is_available(np)) {
> int nr_ports;
> diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
> index 29f505a..5ae0030 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,24 @@ static int __init orion_nand_probe(struct platform_device *pdev)
> goto no_res;
> }
>
> - board = pdev->dev.platform_data;
> + if (pdev->dev.of_node) {
> + board = kzalloc(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 +149,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);
> @@ -141,6 +162,8 @@ static int __init orion_nand_probe(struct platform_device *pdev)
> no_dev:
> platform_set_drvdata(pdev, NULL);
> iounmap(io_base);
> + if (pdev->dev.of_node)
> + kfree(board);
> no_res:
> kfree(nc);
>
> @@ -156,16 +179,28 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
>
> iounmap(nc->IO_ADDR_W);
>
> + if (pdev->dev.of_node)
> + kfree(nc->priv);
> kfree(nc);
>
> return 0;
> }
>
> +#ifdef CONFIG_OF
> +static struct of_device_id orion_nand_of_match_table[] = {
> + { .compatible = "mrvl,orion-nand", },
> + {},
> +};
> +#else
> +#define orion_nand_of_match_table NULL
> +#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] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <20120312031751.GY5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
@ 2012-03-12 8:11 ` Arnd Bergmann
[not found] ` <201203120811.23137.arnd-r2nGTMty4D4@public.gmane.org>
0 siblings, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2012-03-12 8:11 UTC (permalink / raw)
To: Jason Cooper
Cc: Jamie Lentin, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Monday 12 March 2012, Jason Cooper wrote:
> > Or even use the ranges property to remap everything into
> > a simpler address range:
> >
> > ocp@f1000000 {
> > compatible = "simple-bus";
> > ranges = <0 0xf1000000 0x1000000>;
> > #address-cells = 1;
> > #size-cells = 1;
> >
> > serial@12000 {
> > reg = <0x12000 0x100>;
> > ...
> > };
> >
> > ...
> > };
>
> Okay, that's pretty slick. The wdt and intc are at 0xfed00000, is that
> another ocp bus? Or, am I missing something?
If they are on those addresses, yes. If you have a data sheet, you should
look at what the buses are named there, "ocp" was just an example and I
took that name from the <mach/kirkwood.h> file.
It does seem though that the 0xfed00000 address is where Linux maps
the same 0xf1000000 range in its own virtual address space, so it's
not something that should appear in the device tree.
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <20120312030232.GX5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
@ 2012-03-12 8:17 ` Arnd Bergmann
[not found] ` <201203120817.19777.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-12 17:59 ` Jamie Lentin
1 sibling, 1 reply; 18+ messages in thread
From: Arnd Bergmann @ 2012-03-12 8:17 UTC (permalink / raw)
To: Jason Cooper
Cc: Jamie Lentin, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Monday 12 March 2012, Jason Cooper wrote:
> > + 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);
> > +}
> > +
>
> I doubt this board is the only one that wants to be added while the
> conversion to devicetree is progressing. It makes more sense to me to
> break the above out to a separate file, eg board-dnskw.c. I'll follow
> and break out the dreamplug code to board-dreamplug.c. Otherwise, I see
> board-dt.c becoming a long mess.
>
> Arnd, sound okay to you?
Either way is fine with me. I personally wouldn't expect many more boards
to come in before the DT conversion has mostly completed, but I guess you
have a better feeling for what other hardware is out there that people
are interested in.
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <201203120817.19777.arnd-r2nGTMty4D4@public.gmane.org>
@ 2012-03-12 14:22 ` Jamie Lentin
[not found] ` <op.wa197mq94cuzmg-x9DHNcFvAEtNwP/n92qj9LVCufUGDwFn@public.gmane.org>
0 siblings, 1 reply; 18+ messages in thread
From: Jamie Lentin @ 2012-03-12 14:22 UTC (permalink / raw)
To: Jason Cooper, Arnd Bergmann
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Mon, 12 Mar 2012 08:17:19 -0000, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
> On Monday 12 March 2012, Jason Cooper wrote:
>> > + 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);
>> > +}
>> > +
>>
>> I doubt this board is the only one that wants to be added while the
>> conversion to devicetree is progressing. It makes more sense to me to
>> break the above out to a separate file, eg board-dnskw.c. I'll follow
>> and break out the dreamplug code to board-dreamplug.c. Otherwise, I see
>> board-dt.c becoming a long mess.
>>
>> Arnd, sound okay to you?
>
> Either way is fine with me. I personally wouldn't expect many more boards
> to come in before the DT conversion has mostly completed, but I guess you
> have a better feeling for what other hardware is out there that people
> are interested in.
>
It probably depends on how easy it is to add the gpiochips into
devicetree. Being able to put the LED, buttons and fans in devicetree
would make board-dt.c much more manageable. I started to look into it and
wasn't immediately obvious, but will have a closer look.
Happy to resubmit, breaking it out into a board-dnskw.c though.
--
Jamie Lentin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <op.wa197mq94cuzmg-x9DHNcFvAEtNwP/n92qj9LVCufUGDwFn@public.gmane.org>
@ 2012-03-12 14:27 ` Jason Cooper
[not found] ` <20120312142716.GA5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
0 siblings, 1 reply; 18+ messages in thread
From: Jason Cooper @ 2012-03-12 14:27 UTC (permalink / raw)
To: Jamie Lentin
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Mon, Mar 12, 2012 at 02:22:24PM -0000, Jamie Lentin wrote:
> On Mon, 12 Mar 2012 08:17:19 -0000, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
>
> >On Monday 12 March 2012, Jason Cooper wrote:
> >>> + 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);
> >>> +}
> >>> +
> >>
> >>I doubt this board is the only one that wants to be added while the
> >>conversion to devicetree is progressing. It makes more sense to me to
> >>break the above out to a separate file, eg board-dnskw.c. I'll follow
> >>and break out the dreamplug code to board-dreamplug.c. Otherwise, I see
> >>board-dt.c becoming a long mess.
> >>
> >>Arnd, sound okay to you?
> >
> >Either way is fine with me. I personally wouldn't expect many more boards
> >to come in before the DT conversion has mostly completed, but I guess you
> >have a better feeling for what other hardware is out there that people
> >are interested in.
> >
>
> It probably depends on how easy it is to add the gpiochips into
> devicetree. Being able to put the LED, buttons and fans in
> devicetree would make board-dt.c much more manageable. I started to
> look into it and wasn't immediately obvious, but will have a closer
> look.
>
> Happy to resubmit, breaking it out into a board-dnskw.c though.
Yeah, let's go ahead and do that. pinmux and the above are going to take
a while to sort out. In the mean time, there's:
sheevaplug
guruplug
guruplug-serverplus
Lacie-*
Seagate-*
rd-boards-*
just to name a few. Plus it'll give me something to do while we wait
for pinmux/common clock to land.
thx,
Jason.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <20120312142716.GA5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
@ 2012-03-12 14:58 ` Arnd Bergmann
0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2012-03-12 14:58 UTC (permalink / raw)
To: Jason Cooper
Cc: Jamie Lentin, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Monday 12 March 2012, Jason Cooper wrote:
> >
> > It probably depends on how easy it is to add the gpiochips into
> > devicetree. Being able to put the LED, buttons and fans in
> > devicetree would make board-dt.c much more manageable. I started to
> > look into it and wasn't immediately obvious, but will have a closer
> > look.
I would think that gpio should not be too hard, since it has very
little dependencies on other things. GPIO on kirkwood seems to be
tightly coupled with the irq stuff, so I guess these should be done
together. We can discuss how to do these on #linaro-kernel on
irc.freenode.net if you like.
Once interrupts and GPIO are done, that will enable a lot of
the things that already have bindings like gpio-led and gpio-key.
AFAICT, those won't even need any code changes, only a correct
specification of the device node according to the bindings in
Documentation/devicetree/bindings/gpio/*.
> > Happy to resubmit, breaking it out into a board-dnskw.c though.
>
> Yeah, let's go ahead and do that. pinmux and the above are going to take
> a while to sort out. In the mean time, there's:
>
> sheevaplug
> guruplug
> guruplug-serverplus
> Lacie-*
> Seagate-*
> rd-boards-*
>
> just to name a few. Plus it'll give me something to do while we wait
> for pinmux/common clock to land.
Ok, fair enough. We might also see some interest in having some of the
existing board files moved over to DT based probing in order to slim
them down, which fits in nicely with this approach.
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <201203120811.23137.arnd-r2nGTMty4D4@public.gmane.org>
@ 2012-03-12 16:10 ` Jason Cooper
[not found] ` <20120312161004.GB5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
0 siblings, 1 reply; 18+ messages in thread
From: Jason Cooper @ 2012-03-12 16:10 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jamie Lentin, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Mon, Mar 12, 2012 at 08:11:22AM +0000, Arnd Bergmann wrote:
> On Monday 12 March 2012, Jason Cooper wrote:
> > > Or even use the ranges property to remap everything into
> > > a simpler address range:
> > >
> > > ocp@f1000000 {
> > > compatible = "simple-bus";
> > > ranges = <0 0xf1000000 0x1000000>;
> > > #address-cells = 1;
> > > #size-cells = 1;
> > >
> > > serial@12000 {
> > > reg = <0x12000 0x100>;
> > > ...
> > > };
> > >
> > > ...
> > > };
> >
> > Okay, that's pretty slick. The wdt and intc are at 0xfed00000, is that
> > another ocp bus? Or, am I missing something?
>
> If they are on those addresses, yes. If you have a data sheet, you should
> look at what the buses are named there, "ocp" was just an example and I
> took that name from the <mach/kirkwood.h> file.
>
> It does seem though that the 0xfed00000 address is where Linux maps
> the same 0xf1000000 range in its own virtual address space, so it's
> not something that should appear in the device tree.
Okay, that's what smelled funny. wdt and intc both only have registers
in virtual address space defined. Can I assume they map like everything
else to corresponding physical addresses?
eg wdt@fed20300 -> wdt@f1020300 ?
thx,
Jason.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <20120312161004.GB5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
@ 2012-03-12 16:43 ` Arnd Bergmann
0 siblings, 0 replies; 18+ messages in thread
From: Arnd Bergmann @ 2012-03-12 16:43 UTC (permalink / raw)
To: Jason Cooper
Cc: Jamie Lentin, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Monday 12 March 2012, Jason Cooper wrote:
> Okay, that's what smelled funny. wdt and intc both only have registers
> in virtual address space defined. Can I assume they map like everything
> else to corresponding physical addresses?
>
> eg wdt@fed20300 -> wdt@f1020300 ?
Yes, correct. Or just uses 20300 as the address if you remap everything
using the ranges property.
Arnd
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <20120312030232.GX5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-12 8:17 ` Arnd Bergmann
@ 2012-03-12 17:59 ` Jamie Lentin
[not found] ` <op.wa2j90zu4cuzmg-x9DHNcFvAEtNwP/n92qj9LVCufUGDwFn@public.gmane.org>
1 sibling, 1 reply; 18+ messages in thread
From: Jamie Lentin @ 2012-03-12 17:59 UTC (permalink / raw)
To: Jason Cooper
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Mon, 12 Mar 2012 03:02:32 -0000, Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>
wrote:
> On Sun, Mar 11, 2012 at 02:33:25PM +0000, Jamie Lentin wrote:
>> Add support for the DNS-320 and DNS-325. Describe as much as currently
>> possible
>> in the devicetree files, leave everything else in board-dt.c to be
>> patched
>> later.
>>
>> Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
>
> Great work! comments, below.
>> ---
>> arch/arm/boot/dts/kirkwood-dns320.dts | 54 ++++++
>> arch/arm/boot/dts/kirkwood-dns325.dts | 40 +++++
>> arch/arm/mach-kirkwood/Kconfig | 18 ++
>> arch/arm/mach-kirkwood/Makefile.boot | 2 +
>> arch/arm/mach-kirkwood/board-dt.c | 294
>> +++++++++++++++++++++++++++++++++
>> 5 files changed, 408 insertions(+), 0 deletions(-)
>> create mode 100644 arch/arm/boot/dts/kirkwood-dns320.dts
>> create mode 100644 arch/arm/boot/dts/kirkwood-dns325.dts
>>
>> diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts
>> b/arch/arm/boot/dts/kirkwood-dns320.dts
>> new file mode 100644
>> index 0000000..c039041
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/kirkwood-dns320.dts
>> @@ -0,0 +1,54 @@
>> +/dts-v1/;
>> +
>> +/include/ "kirkwood.dtsi"
>> +
>> +/ {
>> + model = "D-Link DNS-320 NAS (Rev A1)";
>> + compatible = "dlink,dns-320-a1", "dlink,dns-320",
>> "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
>
> s/marvell/mrvl/g for compatible properties.
>
Okay.
>> + memory {
>> + device_type = "memory";
>> + reg = <0x00000000 0x8000000>;
>> + };
>> +
>> + chosen {
>> + bootargs = "console=ttyS0,115200n8 earlyprintk";
>> + };
>> +
>> + wdt@fed20300 {
>> + compatible = "mrvl,orion-wdt";
>> + reg = <0xfed20300 0x28>;
>> + clock-frequency = <166666667>;
>> + };
>
> This hasn't made it into my stable branch yet, waiting on common clock
> to land (may be 3.5). Please use kirkwood_wdt_init() in the mean time.
>
So just to be clear kirkwood_dt_stable on git.infradead.org, as opposed to
any branches on arm-soc?
>> + serial@f1012000 {
>> + compatible = "ns16550a";
>> + reg = <0xf1012000 0xff>;
>> + reg-shift = <2>;
>> + interrupts = <33>;
>> + clock-frequency = <166666667>;
>> + };
>> +
>> + serial@f1012100 {
>> + compatible = "ns16550a";
>> + reg = <0xf1012100 0xff>;
>> + reg-shift = <2>;
>> + interrupts = <34>;
>> + clock-frequency = <166666667>;
>> + };
>> +
>> + sata@f1080000 {
>> + compatible = "mrvl,orion-sata";
>> + reg = <0xf1080000 0x5000>;
>> + interrupts = <21>;
>> + nr-ports = <2>;
>> + };
>> +
>> + ehci@f1050000 {
>> + compatible = "mrvl,orion-ehci";
>> + reg = <0xf1050000 0x1000>;
>> + interrupts = <19>;
>> + dma-mask = <0xffffffff>;
>> + phy-version = "";
>> + };
>
> sata and ehci both require working dma and interrupt controller. I
> should have the interrupt controller done soon. mv_cesa will then work.
> dma will be after that.
I found this out the hard way, but saw that dma-mask was supported in
staging/kirkwood/dt on arm-soc and managed to get working USB using it.
I'll switch back for now.
> Basically, anything in mach-kirkwood/common.c that passes kirkwood_tclk
> is on hold for devicetree.
Including serial ports?
>> +};
>> diff --git a/arch/arm/boot/dts/kirkwood-dns325.dts
>> b/arch/arm/boot/dts/kirkwood-dns325.dts
>> new file mode 100644
>> index 0000000..a7c2c26
>> --- /dev/null
>> +++ b/arch/arm/boot/dts/kirkwood-dns325.dts
>> @@ -0,0 +1,40 @@
>> +/dts-v1/;
>> +
>> +/include/ "kirkwood.dtsi"
>> +
>> +/ {
>> + model = "D-Link DNS-325 NAS (Rev A1)";
>> + compatible = "dlink,dns-325-a1", "dlink,dns-325",
>> "dlink,dns-kirkwood", "marvell,kirkwood-88f6281", "marvell,kirkwood";
>
> same as above, mrvl.
>
>> +
>> + memory {
>> + device_type = "memory";
>> + reg = <0x00000000 0x10000000>;
>> + };
>> +
>> + chosen {
>> + bootargs = "console=ttyS0,115200n8 earlyprintk";
>> + };
>
> make sure to test serial with earlyprintk disabled. That bit me once.
>
Thanks. I didn't think to try that!
>> +
>> + serial@f1012000 {
>> + compatible = "ns16550a";
>> + reg = <0xf1012000 0xff>;
>> + reg-shift = <2>;
>> + interrupts = <33>;
>> + clock-frequency = <200000000>;
>> + };
>> +
>> + sata@f1080000 {
>> + compatible = "mrvl,orion-sata";
>> + reg = <0xf1080000 0x5000>;
>> + interrupts = <21>;
>> + nr-ports = <2>;
>> + };
>> +
>> + ehci@f1050000 {
>> + compatible = "mrvl,orion-ehci";
>> + reg = <0xf1050000 0x1000>;
>> + interrupts = <19>;
>> + dma-mask = <0xffffffff>;
>> + phy-version = "";
>> + };
>> +};
>> diff --git a/arch/arm/mach-kirkwood/Kconfig
>> b/arch/arm/mach-kirkwood/Kconfig
>> index 90ceab7..6c76e18 100644
>> --- a/arch/arm/mach-kirkwood/Kconfig
>> +++ b/arch/arm/mach-kirkwood/Kconfig
>> @@ -58,6 +58,24 @@ config MACH_DREAMPLUG_DT
>> Say 'Y' here if you want your kernel to support the
>> Marvell DreamPlug (Flattened Device Tree).
>>
>> +config MACH_DNS320_DT
>> + bool "D-Link DNS-320 (Flattened Device Tree)"
>> + select ARCH_KIRKWOOD_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 (Flattened Device Tree).
>> +
>> +config MACH_DNS325_DT
>> + bool "D-Link DNS-325 (Flattened Device Tree)"
>> + select ARCH_KIRKWOOD_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 (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.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-dt.c
>> b/arch/arm/mach-kirkwood/board-dt.c
>> index 12dec38..0885713 100644
>> --- a/arch/arm/mach-kirkwood/board-dt.c
>> +++ b/arch/arm/mach-kirkwood/board-dt.c
>> @@ -15,6 +15,7 @@
>> #include <linux/platform_device.h>
>> #include <linux/irqdomain.h>
>> #include <linux/mtd/partitions.h>
>> +#include <linux/i2c.h>
>> #include <linux/ata_platform.h>
>> #include <linux/mv643xx_eth.h>
>> #include <linux/of.h>
>> @@ -23,6 +24,9 @@
>> #include <linux/of_irq.h>
>> #include <linux/of_platform.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 <linux/spi/flash.h>
>> @@ -150,6 +154,291 @@ static void __init dreamplug_init(void)
>> platform_device_register(&dreamplug_leds);
>> }
>>
>> +/*****************************************************************************
>> + * DNS-320 & DNS-325 specifics
>> +
>> ****************************************************************************/
>> +
>> +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
>> + },
>> +};
>
> You should probably squeeze in a partition for the dtb. ;-)
>
> Is the config partition the u-boot environment? That usually is much
> smaller than what you have alotted. So, you might be able to split that
> to make room for the dtb.
>
The partition scheme is the same as D-Link's kernel. The config area is a
jffs2 filesystem that contains their config files. It seemed to me that
copying the partition table was the right thing to do to allow the NAND to
be read, even though in practice it's not that useful---I'm not sure even
D-Link pay much attention to it, there's all sorts of odd offsets in their
code.
The other option would be to ignore the nonsense and replace it with
something useful. This would be more convenient for me because it'd mean I
don't have to replace it with my partition scheme :). Any opinions?
>> +
>> +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) */
>> + 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: MV88F6281_DEV_ID Board */
>> + MPP37_GPIO, /* Power: Boot when power applied */
>> + 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 __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);
>> +}
>> +
>> +static void dnskw_power_off(void)
>> +{
>> + gpio_set_value(36, 1);
>> +}
>> +
>> +static void __init dnskw_init(void)
>> +{
>> + u32 dev, rev;
>> +
>> + kirkwood_mpp_conf(dnskw_mpp_config);
>> + kirkwood_nand_init(ARRAY_AND_SIZE(dnskw_nand_parts), 25);
>> +
>> + kirkwood_ge00_init(&dnskw_ge00_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);
>> + }
>
> braces not needed.
>
>> +
>> + /* Register power off routine */
>> + kirkwood_pcie_id(&dev, &rev);
>> + if (dev == MV88F6281_DEV_ID) {
>> + pr_info("PCI-E Device ID: MV88F6281, configuring power-off");
>> + 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");
>> + } else {
>> + /*
>> + * Dlink code also defines 0x6192, and sets LOW_BASE +
>> + * 0x01000000 high. Either cargo-culted code or another model.
>> + */
>
> I'm just curious, what is cargo-culted?
>
http://en.wikipedia.org/wiki/Cargo_cult_programming
In this case, I originally thought that the line was relevant to
supporting the DNS-320 (I assumed it had a MV88F6192 based on it's lower
TCLK), but it seems it uses the MV88F6281 too. So either D-link have been
blindly including this logic or there is a model somewhere that uses the
different SoC.
On reflection, it's probably best to remove this entirely. Testing the
pcie_id isn't achieving anything and is likely to confuse when it comes to
porting the power-off to devicetree.
>> + pr_err("Unknown PCI-E Device ID %x, no power-off", dev);
>> + }
>> +
>> + /*
>> + * Supply power to HDDs. Bootloader should have turned on sata0
>> already
>> + */
>
> Don't assume the bootloader does or doesn't do anything. Put the
> peripheral into a known state and work from there.
>
It doesn't, it turns both HDDs on. I'll clarify the comment though.
>> + 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);
>> +}
>> +
>
> I doubt this board is the only one that wants to be added while the
> conversion to devicetree is progressing. It makes more sense to me to
> break the above out to a separate file, eg board-dnskw.c. I'll follow
> and break out the dreamplug code to board-dreamplug.c. Otherwise, I see
> board-dt.c becoming a long mess.
>
> Arnd, sound okay to you?
>
>> static void __init kirkwood_dt_init(void)
>> {
>> struct device_node *node;
>> @@ -186,11 +475,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
>> };
>>
>> --
>> 1.7.9.1
>>
--
Jamie Lentin
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325
[not found] ` <op.wa2j90zu4cuzmg-x9DHNcFvAEtNwP/n92qj9LVCufUGDwFn@public.gmane.org>
@ 2012-03-12 18:56 ` Jason Cooper
0 siblings, 0 replies; 18+ messages in thread
From: Jason Cooper @ 2012-03-12 18:56 UTC (permalink / raw)
To: Jamie Lentin
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On Mon, Mar 12, 2012 at 05:59:50PM -0000, Jamie Lentin wrote:
> On Mon, 12 Mar 2012 03:02:32 -0000, Jason Cooper
> <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org> wrote:
>
> >On Sun, Mar 11, 2012 at 02:33:25PM +0000, Jamie Lentin wrote:
> >>Add support for the DNS-320 and DNS-325. Describe as much as
> >>currently possible
> >>in the devicetree files, leave everything else in board-dt.c to
> >>be patched
> >>later.
> >>
> >>Signed-off-by: Jamie Lentin <jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
> >
> >Great work! comments, below.
> >>---
> >> arch/arm/boot/dts/kirkwood-dns320.dts | 54 ++++++
> >> arch/arm/boot/dts/kirkwood-dns325.dts | 40 +++++
> >> arch/arm/mach-kirkwood/Kconfig | 18 ++
> >> arch/arm/mach-kirkwood/Makefile.boot | 2 +
> >> arch/arm/mach-kirkwood/board-dt.c | 294
> >>+++++++++++++++++++++++++++++++++
> >> 5 files changed, 408 insertions(+), 0 deletions(-)
> >> create mode 100644 arch/arm/boot/dts/kirkwood-dns320.dts
> >> create mode 100644 arch/arm/boot/dts/kirkwood-dns325.dts
> >>
> >>diff --git a/arch/arm/boot/dts/kirkwood-dns320.dts
> >>b/arch/arm/boot/dts/kirkwood-dns320.dts
> >>new file mode 100644
> >>index 0000000..c039041
> >>--- /dev/null
> >>+++ b/arch/arm/boot/dts/kirkwood-dns320.dts
> >>@@ -0,0 +1,54 @@
> >>+/dts-v1/;
> >>+
> >>+/include/ "kirkwood.dtsi"
> >>+
> >>+/ {
> >>+ model = "D-Link DNS-320 NAS (Rev A1)";
> >>+ compatible = "dlink,dns-320-a1", "dlink,dns-320",
> >>"dlink,dns-kirkwood", "marvell,kirkwood-88f6281",
> >>"marvell,kirkwood";
> >
> >s/marvell/mrvl/g for compatible properties.
> >
>
> Okay.
>
> >>+ memory {
> >>+ device_type = "memory";
> >>+ reg = <0x00000000 0x8000000>;
> >>+ };
> >>+
> >>+ chosen {
> >>+ bootargs = "console=ttyS0,115200n8 earlyprintk";
> >>+ };
> >>+
> >>+ wdt@fed20300 {
> >>+ compatible = "mrvl,orion-wdt";
> >>+ reg = <0xfed20300 0x28>;
> >>+ clock-frequency = <166666667>;
> >>+ };
> >
> >This hasn't made it into my stable branch yet, waiting on common clock
> >to land (may be 3.5). Please use kirkwood_wdt_init() in the mean time.
> >
>
> So just to be clear kirkwood_dt_stable on git.infradead.org, as
> opposed to any branches on arm-soc?
For now. I'm still learning the git integration/upstream piece. Give
me a few more hours and I should have a new version up for review. It's
a reshuffle and edit of the whole series.
It also redoes serial@ based on Arnd's comments to your patches.
> >>+ serial@f1012000 {
> >>+ compatible = "ns16550a";
> >>+ reg = <0xf1012000 0xff>;
> >>+ reg-shift = <2>;
> >>+ interrupts = <33>;
> >>+ clock-frequency = <166666667>;
> >>+ };
> >>+
> >>+ serial@f1012100 {
> >>+ compatible = "ns16550a";
> >>+ reg = <0xf1012100 0xff>;
> >>+ reg-shift = <2>;
> >>+ interrupts = <34>;
> >>+ clock-frequency = <166666667>;
> >>+ };
> >>+
> >>+ sata@f1080000 {
> >>+ compatible = "mrvl,orion-sata";
> >>+ reg = <0xf1080000 0x5000>;
> >>+ interrupts = <21>;
> >>+ nr-ports = <2>;
> >>+ };
> >>+
> >>+ ehci@f1050000 {
> >>+ compatible = "mrvl,orion-ehci";
> >>+ reg = <0xf1050000 0x1000>;
> >>+ interrupts = <19>;
> >>+ dma-mask = <0xffffffff>;
> >>+ phy-version = "";
> >>+ };
> >
> >sata and ehci both require working dma and interrupt controller. I
> >should have the interrupt controller done soon. mv_cesa will then work.
> >dma will be after that.
>
> I found this out the hard way, but saw that dma-mask was supported
> in staging/kirkwood/dt on arm-soc and managed to get working USB
> using it. I'll switch back for now.
Yes, that "support" was a mistake on my part. It does not appear to be
the correct answer.
> >Basically, anything in mach-kirkwood/common.c that passes kirkwood_tclk
> >is on hold for devicetree.
>
> Including serial ports?
serial is different because it's not a kirkwood/orion-specific driver.
It's clock-frequency is not (as my understanding goes) tied to the
system clock, it just happens to be so in this case.
The other drivers want tclk because they want to know the system clock.
...
> >>diff --git a/arch/arm/mach-kirkwood/board-dt.c
> >>b/arch/arm/mach-kirkwood/board-dt.c
> >>index 12dec38..0885713 100644
> >>--- a/arch/arm/mach-kirkwood/board-dt.c
> >>+++ b/arch/arm/mach-kirkwood/board-dt.c
> >>@@ -15,6 +15,7 @@
> >> #include <linux/platform_device.h>
> >> #include <linux/irqdomain.h>
> >> #include <linux/mtd/partitions.h>
> >>+#include <linux/i2c.h>
> >> #include <linux/ata_platform.h>
> >> #include <linux/mv643xx_eth.h>
> >> #include <linux/of.h>
> >>@@ -23,6 +24,9 @@
> >> #include <linux/of_irq.h>
> >> #include <linux/of_platform.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 <linux/spi/flash.h>
> >>@@ -150,6 +154,291 @@ static void __init dreamplug_init(void)
> >> platform_device_register(&dreamplug_leds);
> >> }
> >>
> >>+/*****************************************************************************
> >>+ * DNS-320 & DNS-325 specifics
> >>+ ****************************************************************************/
> >>+
> >>+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
> >>+ },
> >>+};
> >
> >You should probably squeeze in a partition for the dtb. ;-)
> >
> >Is the config partition the u-boot environment? That usually is much
> >smaller than what you have alotted. So, you might be able to split that
> >to make room for the dtb.
> >
>
> The partition scheme is the same as D-Link's kernel. The config area
> is a jffs2 filesystem that contains their config files. It seemed to
> me that copying the partition table was the right thing to do to
> allow the NAND to be read, even though in practice it's not that
> useful---I'm not sure even D-Link pay much attention to it, there's
> all sorts of odd offsets in their code.
>
> The other option would be to ignore the nonsense and replace it with
> something useful. This would be more convenient for me because it'd
> mean I don't have to replace it with my partition scheme :). Any
> opinions?
No, reverse-compatible is a good thing if we can swing it. How about
giving uImage 4MB and then 1MB for the dtb? Most of my dtbs haven't
even reached 2k...
Although, that'll change device numbering, eg ramdisk = /dev/mtdblock3
where it was /dev/mtdblock2 before.
Is there any unallocated space at the end of the flash?
...
> >>+
> >>+ /* Register power off routine */
> >>+ kirkwood_pcie_id(&dev, &rev);
> >>+ if (dev == MV88F6281_DEV_ID) {
> >>+ pr_info("PCI-E Device ID: MV88F6281, configuring power-off");
> >>+ 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");
> >>+ } else {
> >>+ /*
> >>+ * Dlink code also defines 0x6192, and sets LOW_BASE +
> >>+ * 0x01000000 high. Either cargo-culted code or another model.
> >>+ */
> >
> >I'm just curious, what is cargo-culted?
> >
>
> http://en.wikipedia.org/wiki/Cargo_cult_programming
It's okay, feel free to link me to lmgtfy. ;-)
> In this case, I originally thought that the line was relevant to
> supporting the DNS-320 (I assumed it had a MV88F6192 based on it's
> lower TCLK), but it seems it uses the MV88F6281 too. So either
> D-link have been blindly including this logic or there is a model
> somewhere that uses the different SoC.
>
> On reflection, it's probably best to remove this entirely. Testing
> the pcie_id isn't achieving anything and is likely to confuse when
> it comes to porting the power-off to devicetree.
>
> >>+ pr_err("Unknown PCI-E Device ID %x, no power-off", dev);
> >>+ }
> >>+
> >>+ /*
> >>+ * Supply power to HDDs. Bootloader should have turned on
> >>sata0 already
> >>+ */
> >
> >Don't assume the bootloader does or doesn't do anything. Put the
> >peripheral into a known state and work from there.
> >
>
> It doesn't, it turns both HDDs on. I'll clarify the comment though.
^^ bootloader or kernel?
Users (especially me) may roll their own u-boot, or swapout for redboot,
whatever.
> >>+ 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);
> >>+}
> >>+
> >
> >I doubt this board is the only one that wants to be added while the
> >conversion to devicetree is progressing. It makes more sense to me to
> >break the above out to a separate file, eg board-dnskw.c. I'll follow
> >and break out the dreamplug code to board-dreamplug.c. Otherwise, I see
> >board-dt.c becoming a long mess.
> >
> >Arnd, sound okay to you?
> >
> >> static void __init kirkwood_dt_init(void)
> >> {
> >> struct device_node *node;
> >>@@ -186,11 +475,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
> >> };
> >>
> >>--
> >>1.7.9.1
> >>
>
>
> --
> Jamie Lentin
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2012-03-12 18:56 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-11 14:33 [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree Jamie Lentin
[not found] ` <1331476406-9844-1-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 14:33 ` [PATCH 1/2] ARM: kirkwood: Basic support for DNS-320 and DNS-325 Jamie Lentin
[not found] ` <1331476406-9844-2-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 17:46 ` Arnd Bergmann
[not found] ` <201203111746.09757.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-12 3:17 ` Jason Cooper
[not found] ` <20120312031751.GY5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-12 8:11 ` Arnd Bergmann
[not found] ` <201203120811.23137.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-12 16:10 ` Jason Cooper
[not found] ` <20120312161004.GB5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-12 16:43 ` Arnd Bergmann
2012-03-12 3:02 ` Jason Cooper
[not found] ` <20120312030232.GX5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-12 8:17 ` Arnd Bergmann
[not found] ` <201203120817.19777.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-12 14:22 ` Jamie Lentin
[not found] ` <op.wa197mq94cuzmg-x9DHNcFvAEtNwP/n92qj9LVCufUGDwFn@public.gmane.org>
2012-03-12 14:27 ` Jason Cooper
[not found] ` <20120312142716.GA5050-u4khhh1J0LxI1Ri9qeTfzeTW4wlIGRCZ@public.gmane.org>
2012-03-12 14:58 ` Arnd Bergmann
2012-03-12 17:59 ` Jamie Lentin
[not found] ` <op.wa2j90zu4cuzmg-x9DHNcFvAEtNwP/n92qj9LVCufUGDwFn@public.gmane.org>
2012-03-12 18:56 ` Jason Cooper
2012-03-11 14:33 ` [PATCH 2/2] ARM: kirkwood: Convert orion-nand to fdt Jamie Lentin
[not found] ` <1331476406-9844-3-git-send-email-jm-Pj/HzkgeCk7QXOPxS62xeg@public.gmane.org>
2012-03-11 17:52 ` Arnd Bergmann
2012-03-12 3:23 ` Jason Cooper
2012-03-12 2:36 ` [PATCH 0/2] Add support for DNS-320 and DNS-325 using devicetree 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).