From 9007d1007317658d5b32bda9f59c797c59ce4d47 Mon Sep 17 00:00:00 2001 From: Jamie Lentin Date: Wed, 18 Apr 2012 11:06:40 +0100 Subject: ARM: kirkwood: Basic support for DNS-320 and DNS-325 Add support for the DNS-320 and DNS-325. Describe as much as currently possible in the devicetree files, create a board-dnskw.c for everything else. Changes since last submission (V3) [Addressing comments by]:- * One MACH_DLINK_KIRKWOOD_DT for all dtb files [Grant Likely, Jason Cooper] * Drop brain-dead select "select CONFIG_MTD_OF_PARTS" [Grant Likely] * Don't add NAND support then throw it away immediately after [Grant Likely] * Describe purpose of MPP 41, 42 & 49 Changes since last submission (V2):- * Use IEEE-compliant "okay", rather than "ok" [Scott Wood] Signed-off-by: Jamie Lentin Signed-off-by: Jason Cooper --- arch/arm/mach-kirkwood/Kconfig | 8 + arch/arm/mach-kirkwood/Makefile | 1 + arch/arm/mach-kirkwood/Makefile.boot | 2 + arch/arm/mach-kirkwood/board-dnskw.c | 275 +++++++++++++++++++++++++++++++++++ arch/arm/mach-kirkwood/board-dt.c | 5 + arch/arm/mach-kirkwood/common.h | 6 + 6 files changed, 297 insertions(+) create mode 100644 arch/arm/mach-kirkwood/board-dnskw.c (limited to 'arch/arm/mach-kirkwood') diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index 90ceab7..636778e 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig @@ -58,6 +58,14 @@ config MACH_DREAMPLUG_DT Say 'Y' here if you want your kernel to support the Marvell DreamPlug (Flattened Device Tree). +config MACH_DLINK_KIRKWOOD_DT + bool "D-Link Kirkwood-based NAS (Flattened Device Tree)" + select ARCH_KIRKWOOD_DT + help + Say 'Y' here if you want your kernel to support the + Kirkwood-based D-Link NASes such as DNS-320 & DNS-325, + using Flattened Device Tree. + config MACH_TS219 bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS" help diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile index e299a95..36781b3 100644 --- a/arch/arm/mach-kirkwood/Makefile +++ b/arch/arm/mach-kirkwood/Makefile @@ -22,3 +22,4 @@ obj-$(CONFIG_MACH_T5325) += t5325-setup.o obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_ARCH_KIRKWOOD_DT) += board-dt.o obj-$(CONFIG_MACH_DREAMPLUG_DT) += board-dreamplug.o +obj-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += board-dnskw.o diff --git a/arch/arm/mach-kirkwood/Makefile.boot b/arch/arm/mach-kirkwood/Makefile.boot index 16f9385..8bbffbe 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_DLINK_KIRKWOOD_DT) += kirkwood-dns320.dtb +dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns325.dtb diff --git a/arch/arm/mach-kirkwood/board-dnskw.c b/arch/arm/mach-kirkwood/board-dnskw.c new file mode 100644 index 0000000..58c2d68 --- /dev/null +++ b/arch/arm/mach-kirkwood/board-dnskw.c @@ -0,0 +1,275 @@ +/* + * Copyright 2012 (C), Jamie Lentin + * + * arch/arm/mach-kirkwood/board-dnskw.c + * + * D-link DNS-320 & DNS-325 NAS Init for drivers not converted to + * flattened device tree yet. + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "mpp.h" + +static struct mv643xx_eth_platform_data dnskw_ge00_data = { + .phy_addr = MV643XX_ETH_PHY_ADDR(8), +}; + +static struct mv_sata_platform_data dnskw_sata_data = { + .n_ports = 2, +}; + +static unsigned int dnskw_mpp_config[] __initdata = { + MPP13_UART1_TXD, /* Custom ... */ + MPP14_UART1_RXD, /* ... Controller (DNS-320 only) */ + MPP20_SATA1_ACTn, /* LED: White Right HDD */ + MPP21_SATA0_ACTn, /* LED: White Left HDD */ + MPP24_GPIO, + MPP25_GPIO, + MPP26_GPIO, /* LED: Power */ + MPP27_GPIO, /* LED: Red Right HDD */ + MPP28_GPIO, /* LED: Red Left HDD */ + MPP29_GPIO, /* LED: Red USB (DNS-325 only) */ + MPP30_GPIO, + MPP31_GPIO, + MPP32_GPIO, + MPP33_GPO, + MPP34_GPIO, /* Button: Front power */ + MPP35_GPIO, /* LED: Red USB (DNS-320 only) */ + MPP36_GPIO, /* Power: Turn off board */ + MPP37_GPIO, /* Power: Turn back on after power failure */ + MPP38_GPIO, + MPP39_GPIO, /* Power: SATA0 */ + MPP40_GPIO, /* Power: SATA1 */ + MPP41_GPIO, /* SATA0 present */ + MPP42_GPIO, /* SATA1 present */ + 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, /* Temp Alarm (DNS-325) Pin of U5 (DNS-320) */ + 0 +}; + +static struct gpio_led dns325_led_pins[] = { + { + .name = "dns325:white:power", + .gpio = 26, + .active_low = 1, + .default_trigger = "default-on", + }, + { + .name = "dns325:white:usb", + .gpio = 43, + .active_low = 1, + }, + { + .name = "dns325:red:l_hdd", + .gpio = 28, + .active_low = 1, + }, + { + .name = "dns325:red:r_hdd", + .gpio = 27, + .active_low = 1, + }, + { + .name = "dns325:red:usb", + .gpio = 29, + .active_low = 1, + }, +}; + +static struct gpio_led_platform_data dns325_led_data = { + .num_leds = ARRAY_SIZE(dns325_led_pins), + .leds = dns325_led_pins, +}; + +static struct platform_device dns325_led_device = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &dns325_led_data, + }, +}; + +static struct gpio_led dns320_led_pins[] = { + { + .name = "dns320:blue:power", + .gpio = 26, + .active_low = 1, + .default_trigger = "default-on", + }, + { + .name = "dns320:blue:usb", + .gpio = 43, + .active_low = 1, + }, + { + .name = "dns320:orange:l_hdd", + .gpio = 28, + .active_low = 1, + }, + { + .name = "dns320:orange:r_hdd", + .gpio = 27, + .active_low = 1, + }, + { + .name = "dns320:orange:usb", + .gpio = 35, + .active_low = 1, + }, +}; + +static struct gpio_led_platform_data dns320_led_data = { + .num_leds = ARRAY_SIZE(dns320_led_pins), + .leds = dns320_led_pins, +}; + +static struct platform_device dns320_led_device = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &dns320_led_data, + }, +}; + +static struct i2c_board_info dns325_i2c_board_info[] __initdata = { + { + I2C_BOARD_INFO("lm75", 0x48), + }, + /* Something at 0x0c also */ +}; + +static struct gpio_keys_button dnskw_button_pins[] = { + { + .code = KEY_POWER, + .gpio = 34, + .desc = "Power button", + .active_low = 1, + }, + { + .code = KEY_EJECTCD, + .gpio = 47, + .desc = "USB unmount button", + .active_low = 1, + }, + { + .code = KEY_RESTART, + .gpio = 48, + .desc = "Reset button", + .active_low = 1, + }, +}; + +static struct gpio_keys_platform_data dnskw_button_data = { + .buttons = dnskw_button_pins, + .nbuttons = ARRAY_SIZE(dnskw_button_pins), +}; + +static struct platform_device dnskw_button_device = { + .name = "gpio-keys", + .id = -1, + .num_resources = 0, + .dev = { + .platform_data = &dnskw_button_data, + } +}; + +/* Fan: ADDA AD045HB-G73 40mm 6000rpm@5v */ +static struct gpio_fan_speed dnskw_fan_speed[] = { + { 0, 0 }, + { 3000, 1 }, + { 6000, 2 }, +}; +static unsigned dnskw_fan_pins[] = {46, 45}; + +static struct gpio_fan_platform_data dnskw_fan_data = { + .num_ctrl = ARRAY_SIZE(dnskw_fan_pins), + .ctrl = dnskw_fan_pins, + .num_speed = ARRAY_SIZE(dnskw_fan_speed), + .speed = dnskw_fan_speed, +}; + +static struct platform_device dnskw_fan_device = { + .name = "gpio-fan", + .id = -1, + .dev = { + .platform_data = &dnskw_fan_data, + }, +}; + +static void dnskw_power_off(void) +{ + gpio_set_value(36, 1); +} + +/* Register any GPIO for output and set the value */ +static void __init dnskw_gpio_register(unsigned gpio, char *name, int def) +{ + if (gpio_request(gpio, name) == 0 && + gpio_direction_output(gpio, 0) == 0) { + gpio_set_value(gpio, def); + if (gpio_export(gpio, 0) != 0) + pr_err("dnskw: Failed to export GPIO %s\n", name); + } else + pr_err("dnskw: Failed to register %s\n", name); +} + +void __init dnskw_init(void) +{ + kirkwood_mpp_conf(dnskw_mpp_config); + + kirkwood_ehci_init(); + kirkwood_ge00_init(&dnskw_ge00_data); + kirkwood_sata_init(&dnskw_sata_data); + kirkwood_i2c_init(); + + platform_device_register(&dnskw_button_device); + platform_device_register(&dnskw_fan_device); + + if (of_machine_is_compatible("dlink,dns-325")) { + i2c_register_board_info(0, dns325_i2c_board_info, + ARRAY_SIZE(dns325_i2c_board_info)); + platform_device_register(&dns325_led_device); + + } else if (of_machine_is_compatible("dlink,dns-320")) + platform_device_register(&dns320_led_device); + + /* Register power-off GPIO. */ + if (gpio_request(36, "dnskw:power:off") == 0 + && gpio_direction_output(36, 0) == 0) + pm_power_off = dnskw_power_off; + else + pr_err("dnskw: failed to configure power-off GPIO\n"); + + /* Ensure power is supplied to both HDDs */ + dnskw_gpio_register(39, "dnskw:power:sata0", 1); + dnskw_gpio_register(40, "dnskw:power:sata1", 1); + + /* Set NAS to turn back on after a power failure */ + dnskw_gpio_register(37, "dnskw:power:recover", 1); +} diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index f7fe1b9..3ade0ec 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c @@ -56,11 +56,16 @@ static void __init kirkwood_dt_init(void) if (of_machine_is_compatible("globalscale,dreamplug")) dreamplug_init(); + if (of_machine_is_compatible("dlink,dns-kirkwood")) + dnskw_init(); + of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL); } static const char *kirkwood_dt_board_compat[] = { "globalscale,dreamplug", + "dlink,dns-320", + "dlink,dns-325", NULL }; diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h index fa8e768..6195a37 100644 --- a/arch/arm/mach-kirkwood/common.h +++ b/arch/arm/mach-kirkwood/common.h @@ -58,6 +58,12 @@ void dreamplug_init(void); static inline void dreamplug_init(void) {}; #endif +#ifdef CONFIG_MACH_DLINK_KIRKWOOD_DT +void dnskw_init(void); +#else +static inline void dnskw_init(void) {}; +#endif + /* early init functions not converted to fdt yet */ char *kirkwood_id(void); void kirkwood_l2_init(void); -- cgit v1.1 From 858156bd6c24f12c3fca94bceacb05fa9a2daef4 Mon Sep 17 00:00:00 2001 From: Jamie Lentin Date: Wed, 18 Apr 2012 11:06:42 +0100 Subject: kirkwood: Allow nand to be configured via. devicetree Add default configuration for NAND, to be enabled in your board config. Ensure clock gating is set appropriately when the NAND is enabled. Acked-by: Jason Cooper Signed-off-by: Jamie Lentin Signed-off-by: Jason Cooper --- arch/arm/mach-kirkwood/common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'arch/arm/mach-kirkwood') diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c index a02cae8..3ad0373 100644 --- a/arch/arm/mach-kirkwood/common.c +++ b/arch/arm/mach-kirkwood/common.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -482,6 +483,9 @@ static int __init kirkwood_clock_gate(void) unsigned int curr = readl(CLOCK_GATING_CTRL); u32 dev, rev; +#ifdef CONFIG_OF + struct device_node *np; +#endif kirkwood_pcie_id(&dev, &rev); printk(KERN_DEBUG "Gating clock of unused units\n"); printk(KERN_DEBUG "before: 0x%08x\n", curr); @@ -489,6 +493,14 @@ static int __init kirkwood_clock_gate(void) /* Make sure those units are accessible */ writel(curr | CGC_SATA0 | CGC_SATA1 | CGC_PEX0 | CGC_PEX1, CLOCK_GATING_CTRL); +#ifdef CONFIG_OF + np = of_find_compatible_node(NULL, NULL, "mrvl,orion-nand"); + if (np && of_device_is_available(np)) { + kirkwood_clk_ctrl |= CGC_RUNIT; + of_node_put(np); + } +#endif + /* For SATA: first shutdown the phy */ if (!(kirkwood_clk_ctrl & CGC_SATA0)) { /* Disable PLL and IVREF */ -- cgit v1.1 From c06cd9bfcad4960023bac1f052da748824e24961 Mon Sep 17 00:00:00 2001 From: "Arnaud Patard (Rtp)" Date: Wed, 18 Apr 2012 23:16:41 +0200 Subject: kirkwood: Add iconnect support Add support for Iomega Iconnect system. Signed-off-by: Arnaud Patard Tested-By: Adam Baker Signed-off-by: Jason Cooper --- arch/arm/mach-kirkwood/Kconfig | 6 ++ arch/arm/mach-kirkwood/Makefile | 1 + arch/arm/mach-kirkwood/Makefile.boot | 1 + arch/arm/mach-kirkwood/board-dt.c | 4 + arch/arm/mach-kirkwood/board-iconnect.c | 165 ++++++++++++++++++++++++++++++++ arch/arm/mach-kirkwood/common.h | 6 ++ 6 files changed, 183 insertions(+) create mode 100644 arch/arm/mach-kirkwood/board-iconnect.c (limited to 'arch/arm/mach-kirkwood') diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index 636778e..bbea3f6f 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig @@ -58,6 +58,12 @@ config MACH_DREAMPLUG_DT Say 'Y' here if you want your kernel to support the Marvell DreamPlug (Flattened Device Tree). +config MACH_ICONNECT_DT + bool "Iomega Iconnect (Flattened Device Tree)" + select ARCH_KIRKWOOD_DT + help + Say 'Y' here to enable Iomega Iconnect support. + config MACH_DLINK_KIRKWOOD_DT bool "D-Link Kirkwood-based NAS (Flattened Device Tree)" select ARCH_KIRKWOOD_DT diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile index 36781b3..82a3d13 100644 --- a/arch/arm/mach-kirkwood/Makefile +++ b/arch/arm/mach-kirkwood/Makefile @@ -22,4 +22,5 @@ obj-$(CONFIG_MACH_T5325) += t5325-setup.o obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_ARCH_KIRKWOOD_DT) += board-dt.o obj-$(CONFIG_MACH_DREAMPLUG_DT) += board-dreamplug.o +obj-$(CONFIG_MACH_ICONNECT_DT) += board-iconnect.o obj-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += board-dnskw.o diff --git a/arch/arm/mach-kirkwood/Makefile.boot b/arch/arm/mach-kirkwood/Makefile.boot index 8bbffbe..a827ca1 100644 --- a/arch/arm/mach-kirkwood/Makefile.boot +++ b/arch/arm/mach-kirkwood/Makefile.boot @@ -5,3 +5,4 @@ initrd_phys-y := 0x00800000 dtb-$(CONFIG_MACH_DREAMPLUG_DT) += kirkwood-dreamplug.dtb dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns320.dtb dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns325.dtb +dtb-$(CONFIG_MACH_ICONNECT_DT) += kirkwood-iconnect.dtb diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index 3ade0ec..7e82a8e 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c @@ -59,6 +59,9 @@ static void __init kirkwood_dt_init(void) if (of_machine_is_compatible("dlink,dns-kirkwood")) dnskw_init(); + if (of_machine_is_compatible("iom,iconnect")) + iconnect_init(); + of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL); } @@ -66,6 +69,7 @@ static const char *kirkwood_dt_board_compat[] = { "globalscale,dreamplug", "dlink,dns-320", "dlink,dns-325", + "iom,iconnect", NULL }; diff --git a/arch/arm/mach-kirkwood/board-iconnect.c b/arch/arm/mach-kirkwood/board-iconnect.c new file mode 100644 index 0000000..2222c57 --- /dev/null +++ b/arch/arm/mach-kirkwood/board-iconnect.c @@ -0,0 +1,165 @@ +/* + * arch/arm/mach-kirkwood/board-iconnect.c + * + * Iomega i-connect Board Setup + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "mpp.h" + +static struct mv643xx_eth_platform_data iconnect_ge00_data = { + .phy_addr = MV643XX_ETH_PHY_ADDR(11), +}; + +static struct gpio_led iconnect_led_pins[] = { + { + .name = "led_level", + .gpio = 41, + .default_trigger = "default-on", + }, { + .name = "power:blue", + .gpio = 42, + .default_trigger = "timer", + }, { + .name = "power:red", + .gpio = 43, + }, { + .name = "usb1:blue", + .gpio = 44, + }, { + .name = "usb2:blue", + .gpio = 45, + }, { + .name = "usb3:blue", + .gpio = 46, + }, { + .name = "usb4:blue", + .gpio = 47, + }, { + .name = "otb:blue", + .gpio = 48, + }, +}; + +static struct gpio_led_platform_data iconnect_led_data = { + .leds = iconnect_led_pins, + .num_leds = ARRAY_SIZE(iconnect_led_pins), + .gpio_blink_set = orion_gpio_led_blink_set, +}; + +static struct platform_device iconnect_leds = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &iconnect_led_data, + } +}; + +static unsigned int iconnect_mpp_config[] __initdata = { + MPP12_GPIO, + MPP35_GPIO, + MPP41_GPIO, + MPP42_GPIO, + MPP43_GPIO, + MPP44_GPIO, + MPP45_GPIO, + MPP46_GPIO, + MPP47_GPIO, + MPP48_GPIO, + 0 +}; + +static struct i2c_board_info __initdata iconnect_board_info[] = { + { + I2C_BOARD_INFO("lm63", 0x4c), + }, +}; + +static struct mtd_partition iconnect_nand_parts[] = { + { + .name = "flash", + .offset = 0, + .size = MTDPART_SIZ_FULL, + }, +}; + +/* yikes... theses are the original input buttons */ +/* but I'm not convinced by the sw event choices */ +static struct gpio_keys_button iconnect_buttons[] = { + { + .type = EV_SW, + .code = SW_LID, + .gpio = 12, + .desc = "Reset Button", + .active_low = 1, + .debounce_interval = 100, + }, { + .type = EV_SW, + .code = SW_TABLET_MODE, + .gpio = 35, + .desc = "OTB Button", + .active_low = 1, + .debounce_interval = 100, + }, +}; + +static struct gpio_keys_platform_data iconnect_button_data = { + .buttons = iconnect_buttons, + .nbuttons = ARRAY_SIZE(iconnect_buttons), +}; + +static struct platform_device iconnect_button_device = { + .name = "gpio-keys", + .id = -1, + .num_resources = 0, + .dev = { + .platform_data = &iconnect_button_data, + }, +}; + +void __init iconnect_init(void) +{ + kirkwood_mpp_conf(iconnect_mpp_config); + kirkwood_nand_init(ARRAY_AND_SIZE(iconnect_nand_parts), 25); + kirkwood_i2c_init(); + i2c_register_board_info(0, iconnect_board_info, + ARRAY_SIZE(iconnect_board_info)); + + kirkwood_ehci_init(); + kirkwood_ge00_init(&iconnect_ge00_data); + + platform_device_register(&iconnect_button_device); + platform_device_register(&iconnect_leds); +} + +static int __init iconnect_pci_init(void) +{ + if (of_machine_is_compatible("iom,iconnect")) + kirkwood_pcie_init(KW_PCIE0); + return 0; +} +subsys_initcall(iconnect_pci_init); diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h index 6195a37..5f0365c 100644 --- a/arch/arm/mach-kirkwood/common.h +++ b/arch/arm/mach-kirkwood/common.h @@ -64,6 +64,12 @@ void dnskw_init(void); static inline void dnskw_init(void) {}; #endif +#ifdef CONFIG_MACH_ICONNECT_DT +void iconnect_init(void); +#else +static inline void iconnect_init(void) {}; +#endif + /* early init functions not converted to fdt yet */ char *kirkwood_id(void); void kirkwood_l2_init(void); -- cgit v1.1 From f5520363532690f56e12126029864d9383d5203f Mon Sep 17 00:00:00 2001 From: Simon Baatz Date: Mon, 30 Apr 2012 23:55:17 +0200 Subject: ARM: kirkwood: Add support for RaidSonic IB-NAS6210/6220 using devicetree Add support for the IB-NAS6210 and IB-NAS 6220. Describe as much as currently possible in the devicetree files, including the NAND partitions. Use the partition scheme of the original firmware by default. Create a board-ib62x0.c for everything else. Signed-off-by: Simon Baatz Signed-off-by: Jason Cooper --- arch/arm/mach-kirkwood/Kconfig | 8 ++ arch/arm/mach-kirkwood/Makefile | 1 + arch/arm/mach-kirkwood/Makefile.boot | 1 + arch/arm/mach-kirkwood/board-dt.c | 4 + arch/arm/mach-kirkwood/board-ib62x0.c | 143 ++++++++++++++++++++++++++++++++++ arch/arm/mach-kirkwood/common.h | 6 ++ 6 files changed, 163 insertions(+) create mode 100644 arch/arm/mach-kirkwood/board-ib62x0.c (limited to 'arch/arm/mach-kirkwood') diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig index bbea3f6f..199764f 100644 --- a/arch/arm/mach-kirkwood/Kconfig +++ b/arch/arm/mach-kirkwood/Kconfig @@ -72,6 +72,14 @@ config MACH_DLINK_KIRKWOOD_DT Kirkwood-based D-Link NASes such as DNS-320 & DNS-325, using Flattened Device Tree. +config MACH_IB62X0_DT + bool "RaidSonic IB-NAS6210, IB-NAS6220 (Flattened Device Tree)" + select ARCH_KIRKWOOD_DT + help + Say 'Y' here if you want your kernel to support the + RaidSonic IB-NAS6210 & IB-NAS6220 devices, using + Flattened Device Tree. + config MACH_TS219 bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS" help diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile index 82a3d13..d2b0590 100644 --- a/arch/arm/mach-kirkwood/Makefile +++ b/arch/arm/mach-kirkwood/Makefile @@ -24,3 +24,4 @@ obj-$(CONFIG_ARCH_KIRKWOOD_DT) += board-dt.o obj-$(CONFIG_MACH_DREAMPLUG_DT) += board-dreamplug.o obj-$(CONFIG_MACH_ICONNECT_DT) += board-iconnect.o obj-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += board-dnskw.o +obj-$(CONFIG_MACH_IB62X0_DT) += board-ib62x0.o diff --git a/arch/arm/mach-kirkwood/Makefile.boot b/arch/arm/mach-kirkwood/Makefile.boot index a827ca1..02edbdf 100644 --- a/arch/arm/mach-kirkwood/Makefile.boot +++ b/arch/arm/mach-kirkwood/Makefile.boot @@ -6,3 +6,4 @@ dtb-$(CONFIG_MACH_DREAMPLUG_DT) += kirkwood-dreamplug.dtb dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns320.dtb dtb-$(CONFIG_MACH_DLINK_KIRKWOOD_DT) += kirkwood-dns325.dtb dtb-$(CONFIG_MACH_ICONNECT_DT) += kirkwood-iconnect.dtb +dtb-$(CONFIG_MACH_IB62X0_DT) += kirkwood-ib62x0.dtb diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c index 7e82a8e..10d1969 100644 --- a/arch/arm/mach-kirkwood/board-dt.c +++ b/arch/arm/mach-kirkwood/board-dt.c @@ -62,6 +62,9 @@ static void __init kirkwood_dt_init(void) if (of_machine_is_compatible("iom,iconnect")) iconnect_init(); + if (of_machine_is_compatible("raidsonic,ib-nas62x0")) + ib62x0_init(); + of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL); } @@ -70,6 +73,7 @@ static const char *kirkwood_dt_board_compat[] = { "dlink,dns-320", "dlink,dns-325", "iom,iconnect", + "raidsonic,ib-nas62x0", NULL }; diff --git a/arch/arm/mach-kirkwood/board-ib62x0.c b/arch/arm/mach-kirkwood/board-ib62x0.c new file mode 100644 index 0000000..eddf1df --- /dev/null +++ b/arch/arm/mach-kirkwood/board-ib62x0.c @@ -0,0 +1,143 @@ +/* + * Copyright 2012 (C), Simon Baatz + * + * arch/arm/mach-kirkwood/board-ib62x0.c + * + * RaidSonic ICY BOX IB-NAS6210 & IB-NAS6220 init for drivers not + * converted to flattened device tree yet. + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "mpp.h" + +#define IB62X0_GPIO_POWER_OFF 24 + +static struct mv643xx_eth_platform_data ib62x0_ge00_data = { + .phy_addr = MV643XX_ETH_PHY_ADDR(8), +}; + +static struct mv_sata_platform_data ib62x0_sata_data = { + .n_ports = 2, +}; + +static unsigned int ib62x0_mpp_config[] __initdata = { + MPP0_NF_IO2, + MPP1_NF_IO3, + MPP2_NF_IO4, + MPP3_NF_IO5, + MPP4_NF_IO6, + MPP5_NF_IO7, + MPP18_NF_IO0, + MPP19_NF_IO1, + MPP22_GPIO, /* OS LED red */ + MPP24_GPIO, /* Power off device */ + MPP25_GPIO, /* OS LED green */ + MPP27_GPIO, /* USB transfer LED */ + MPP28_GPIO, /* Reset button */ + MPP29_GPIO, /* USB Copy button */ + 0 +}; + +static struct gpio_led ib62x0_led_pins[] = { + { + .name = "ib62x0:green:os", + .default_trigger = "default-on", + .gpio = 25, + .active_low = 0, + }, + { + .name = "ib62x0:red:os", + .default_trigger = "none", + .gpio = 22, + .active_low = 0, + }, + { + .name = "ib62x0:red:usb_copy", + .default_trigger = "none", + .gpio = 27, + .active_low = 0, + }, +}; + +static struct gpio_led_platform_data ib62x0_led_data = { + .leds = ib62x0_led_pins, + .num_leds = ARRAY_SIZE(ib62x0_led_pins), +}; + +static struct platform_device ib62x0_led_device = { + .name = "leds-gpio", + .id = -1, + .dev = { + .platform_data = &ib62x0_led_data, + } +}; + +static struct gpio_keys_button ib62x0_button_pins[] = { + { + .code = KEY_COPY, + .gpio = 29, + .desc = "USB Copy", + .active_low = 1, + }, + { + .code = KEY_RESTART, + .gpio = 28, + .desc = "Reset", + .active_low = 1, + }, +}; + +static struct gpio_keys_platform_data ib62x0_button_data = { + .buttons = ib62x0_button_pins, + .nbuttons = ARRAY_SIZE(ib62x0_button_pins), +}; + +static struct platform_device ib62x0_button_device = { + .name = "gpio-keys", + .id = -1, + .num_resources = 0, + .dev = { + .platform_data = &ib62x0_button_data, + } +}; + +static void ib62x0_power_off(void) +{ + gpio_set_value(IB62X0_GPIO_POWER_OFF, 1); +} + +void __init ib62x0_init(void) +{ + /* + * Basic setup. Needs to be called early. + */ + kirkwood_mpp_conf(ib62x0_mpp_config); + + kirkwood_ehci_init(); + kirkwood_ge00_init(&ib62x0_ge00_data); + kirkwood_sata_init(&ib62x0_sata_data); + platform_device_register(&ib62x0_led_device); + platform_device_register(&ib62x0_button_device); + if (gpio_request(IB62X0_GPIO_POWER_OFF, "ib62x0:power:off") == 0 && + gpio_direction_output(IB62X0_GPIO_POWER_OFF, 0) == 0) + pm_power_off = ib62x0_power_off; + else + pr_err("board-ib62x0: failed to configure power-off GPIO\n"); +} diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h index 5f0365c..a34c41a 100644 --- a/arch/arm/mach-kirkwood/common.h +++ b/arch/arm/mach-kirkwood/common.h @@ -70,6 +70,12 @@ void iconnect_init(void); static inline void iconnect_init(void) {}; #endif +#ifdef CONFIG_MACH_IB62X0_DT +void ib62x0_init(void); +#else +static inline void ib62x0_init(void) {}; +#endif + /* early init functions not converted to fdt yet */ char *kirkwood_id(void); void kirkwood_l2_init(void); -- cgit v1.1