From fe23e10f7c2abb2902432b4ccbb3ec8b65451262 Mon Sep 17 00:00:00 2001 From: Martin Michlmayr Date: Sun, 22 Mar 2009 21:00:19 +0000 Subject: [PATCH] add QNAP TS-219 support svn path=/dists/trunk/linux-2.6/; revision=13198 --- debian/changelog | 2 + .../features/arm/kw-consistency-mpp.patch | 26 ++ .../features/arm/kw-dont-init-rtc.patch | 81 +++++ .../patches/features/arm/kw-hook-up-i2c.patch | 85 ++++++ debian/patches/features/arm/ts219.patch | 279 ++++++++++++++++++ debian/patches/series/1~experimental.1 | 4 + 6 files changed, 477 insertions(+) create mode 100644 debian/patches/features/arm/kw-consistency-mpp.patch create mode 100644 debian/patches/features/arm/kw-dont-init-rtc.patch create mode 100644 debian/patches/features/arm/kw-hook-up-i2c.patch create mode 100644 debian/patches/features/arm/ts219.patch diff --git a/debian/changelog b/debian/changelog index 3b95af569..fcd34c6ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -80,6 +80,8 @@ linux-2.6 (2.6.29~rc8-1~experimental.1) UNRELEASED; urgency=low - Marvell SheevaPlug support - SheevaPlug USB Power Enable setup - SheevaPlug LED support + - Hook up I2C on Kirkwood + - Add support for QNAP TS-119/TS-219 Turbo NAS * [armel/kirkwood] Add an image for Marvell's Kirkwood platform. [ Ben Hutchings ] diff --git a/debian/patches/features/arm/kw-consistency-mpp.patch b/debian/patches/features/arm/kw-consistency-mpp.patch new file mode 100644 index 000000000..a63a52cc9 --- /dev/null +++ b/debian/patches/features/arm/kw-consistency-mpp.patch @@ -0,0 +1,26 @@ +To: nico@cam.org +Cc: linux-arm-kernel@lists.arm.linux.org.uk +Subject: [PATCH] Kirkwood: More consistency regarding MPP naming + +With the exception of UART0, all MPP names are uppercase. + +Signed-off-by: Martin Michlmayr + +--- a/arch/arm/mach-kirkwood/mpp.h ++++ b/arch/arm/mach-kirkwood/mpp.h +@@ -90,13 +90,13 @@ + + #define MPP10_GPO MPP( 10, 0x0, 0, 1, 1, 1, 1, 1 ) + #define MPP10_SPI_SCK MPP( 10, 0x2, 0, 1, 1, 1, 1, 1 ) +-#define MPP10_UArt0_TXD MPP( 10, 0X3, 0, 1, 1, 1, 1, 1 ) ++#define MPP10_UART0_TXD MPP( 10, 0X3, 0, 1, 1, 1, 1, 1 ) + #define MPP10_SATA1_ACTn MPP( 10, 0x5, 0, 1, 0, 0, 1, 1 ) + #define MPP10_PTP_TRIG_GEN MPP( 10, 0xc, 0, 1, 1, 1, 1, 1 ) + + #define MPP11_GPIO MPP( 11, 0x0, 1, 1, 1, 1, 1, 1 ) + #define MPP11_SPI_MISO MPP( 11, 0x2, 1, 0, 1, 1, 1, 1 ) +-#define MPP11_UArt0_RXD MPP( 11, 0x3, 1, 0, 1, 1, 1, 1 ) ++#define MPP11_UART0_RXD MPP( 11, 0x3, 1, 0, 1, 1, 1, 1 ) + #define MPP11_PTP_EVENT_REQ MPP( 11, 0x4, 1, 0, 1, 1, 1, 1 ) + #define MPP11_PTP_TRIG_GEN MPP( 11, 0xc, 0, 1, 1, 1, 1, 1 ) + #define MPP11_PTP_CLK MPP( 11, 0xd, 1, 0, 1, 1, 1, 1 ) diff --git a/debian/patches/features/arm/kw-dont-init-rtc.patch b/debian/patches/features/arm/kw-dont-init-rtc.patch new file mode 100644 index 000000000..51a9fa9b7 --- /dev/null +++ b/debian/patches/features/arm/kw-dont-init-rtc.patch @@ -0,0 +1,81 @@ +To: nico@cam.org +Cc: linux-arm-kernel@lists.arm.linux.org.uk +Subject: [PATCH] Kirkwood: Don't initialize Marvell RTC for all boards + +Even though the Marvell Kirkwood has a built-in RTC, some Kirkwood-based +boards (e.g. QNAP TS-219) use a separate RTC chip. Don't initialize the +Marvell RTC in common code for all boards, otherwise you end up with +two RTC devices on those with their own RTC chip and the default device +is the Marvell RTC which may not work. + +Signed-off-by: Martin Michlmayr + +--- a/arch/arm/mach-kirkwood/common.c 2009-03-22 20:39:53.000000000 +0000 ++++ b/arch/arm/mach-kirkwood/common.c 2009-03-22 20:40:03.000000000 +0000 +@@ -256,7 +256,7 @@ + .flags = IORESOURCE_MEM, + }; + +-static void __init kirkwood_rtc_init(void) ++void __init kirkwood_rtc_init(void) + { + platform_device_register_simple("rtc-mv", -1, &kirkwood_rtc_resource, 1); + } +@@ -795,7 +795,6 @@ + #endif + + /* internal devices that every board has */ +- kirkwood_rtc_init(); + kirkwood_xor0_init(); + kirkwood_xor1_init(); + } +--- a/arch/arm/mach-kirkwood/common.h ++++ b/arch/arm/mach-kirkwood/common.h +@@ -34,6 +34,7 @@ + void kirkwood_ge01_init(struct mv643xx_eth_platform_data *eth_data); + void kirkwood_ge00_switch_init(struct dsa_platform_data *d, int irq); + void kirkwood_pcie_init(void); ++void kirkwood_rtc_init(void); + void kirkwood_sata_init(struct mv_sata_platform_data *sata_data); + void kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data); + void kirkwood_spi_init(void); +--- a/arch/arm/mach-kirkwood/rd88f6281-setup.c 2009-03-22 20:37:57.000000000 +0000 ++++ b/arch/arm/mach-kirkwood/rd88f6281-setup.c 2009-03-22 20:38:08.000000000 +0000 +@@ -124,6 +124,7 @@ + } + kirkwood_ge00_switch_init(&rd88f6281_switch_data, NO_IRQ); + ++ kirkwood_rtc_init(); + kirkwood_sata_init(&rd88f6281_sata_data); + kirkwood_sdio_init(&rd88f6281_mvsdio_data); + kirkwood_uart0_init(); +--- a/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c 2009-03-22 20:37:54.000000000 +0000 ++++ b/arch/arm/mach-kirkwood/rd88f6192-nas-setup.c 2009-03-22 20:38:08.000000000 +0000 +@@ -61,6 +61,7 @@ + + kirkwood_ehci_init(); + kirkwood_ge00_init(&rd88f6192_ge00_data); ++ kirkwood_rtc_init(); + kirkwood_sata_init(&rd88f6192_sata_data); + spi_register_board_info(rd88F6192_spi_slave_info, + ARRAY_SIZE(rd88F6192_spi_slave_info)); +--- a/arch/arm/mach-kirkwood/db88f6281-bp-setup.c 2009-03-22 20:37:50.000000000 +0000 ++++ b/arch/arm/mach-kirkwood/db88f6281-bp-setup.c 2009-03-22 20:38:08.000000000 +0000 +@@ -55,6 +55,7 @@ + + kirkwood_ehci_init(); + kirkwood_ge00_init(&db88f6281_ge00_data); ++ kirkwood_rtc_init(); + kirkwood_sata_init(&db88f6281_sata_data); + kirkwood_uart0_init(); + kirkwood_sdio_init(&db88f6281_mvsdio_data); +--- a/arch/arm/mach-kirkwood/sheevaplug-setup.c ++++ b/arch/arm/mach-kirkwood/sheevaplug-setup.c +@@ -118,6 +118,7 @@ static void __init sheevaplug_init(void) + kirkwood_ehci_init(); + + kirkwood_ge00_init(&sheevaplug_ge00_data); ++ kirkwood_rtc_init(); + kirkwood_sdio_init(&sheevaplug_mvsdio_data); + + platform_device_register(&sheevaplug_nand_flash); diff --git a/debian/patches/features/arm/kw-hook-up-i2c.patch b/debian/patches/features/arm/kw-hook-up-i2c.patch new file mode 100644 index 000000000..0e7921fdf --- /dev/null +++ b/debian/patches/features/arm/kw-hook-up-i2c.patch @@ -0,0 +1,85 @@ +To: nico@cam.org +Cc: linux-arm-kernel@lists.arm.linux.org.uk +Subject: [PATCH] Kirkwood: Hook up I2C + +Hook up I2C on Marvell Kirkwood. Tested on a QNAP TS-219 which has RTC +connected through I2C. + +Signed-off-by: Martin Michlmayr + +--- a/arch/arm/mach-kirkwood/common.c ++++ b/arch/arm/mach-kirkwood/common.c +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -371,6 +372,45 @@ void __init kirkwood_spi_init() + + + /***************************************************************************** ++ * I2C ++ ****************************************************************************/ ++static struct mv64xxx_i2c_pdata kirkwood_i2c_pdata = { ++ .freq_m = 8, /* assumes 166 MHz TCLK */ ++ .freq_n = 3, ++ .timeout = 1000, /* Default timeout of 1 second */ ++}; ++ ++static struct resource kirkwood_i2c_resources[] = { ++ { ++ .name = "i2c base", ++ .start = I2C_PHYS_BASE, ++ .end = I2C_PHYS_BASE + 0x1f, ++ .flags = IORESOURCE_MEM, ++ }, { ++ .name = "i2c irq", ++ .start = IRQ_KIRKWOOD_TWSI, ++ .end = IRQ_KIRKWOOD_TWSI, ++ .flags = IORESOURCE_IRQ, ++ }, ++}; ++ ++static struct platform_device kirkwood_i2c = { ++ .name = MV64XXX_I2C_CTLR_NAME, ++ .id = 0, ++ .num_resources = ARRAY_SIZE(kirkwood_i2c_resources), ++ .resource = kirkwood_i2c_resources, ++ .dev = { ++ .platform_data = &kirkwood_i2c_pdata, ++ }, ++}; ++ ++void __init kirkwood_i2c_init(void) ++{ ++ platform_device_register(&kirkwood_i2c); ++} ++ ++ ++/***************************************************************************** + * UART0 + ****************************************************************************/ + static struct plat_serial8250_port kirkwood_uart0_data[] = { +--- a/arch/arm/mach-kirkwood/common.h ++++ b/arch/arm/mach-kirkwood/common.h +@@ -37,6 +37,7 @@ void kirkwood_pcie_init(void); + void kirkwood_sata_init(struct mv_sata_platform_data *sata_data); + void kirkwood_sdio_init(struct mvsdio_platform_data *mvsdio_data); + void kirkwood_spi_init(void); ++void kirkwood_i2c_init(void); + void kirkwood_uart0_init(void); + void kirkwood_uart1_init(void); + +--- a/arch/arm/mach-kirkwood/include/mach/kirkwood.h ++++ b/arch/arm/mach-kirkwood/include/mach/kirkwood.h +@@ -93,6 +93,7 @@ + #define DEVICE_ID (DEV_BUS_VIRT_BASE | 0x0034) + #define RTC_PHYS_BASE (DEV_BUS_PHYS_BASE | 0x0300) + #define SPI_PHYS_BASE (DEV_BUS_PHYS_BASE | 0x0600) ++#define I2C_PHYS_BASE (DEV_BUS_PHYS_BASE | 0x1000) + #define UART0_PHYS_BASE (DEV_BUS_PHYS_BASE | 0x2000) + #define UART0_VIRT_BASE (DEV_BUS_VIRT_BASE | 0x2000) + #define UART1_PHYS_BASE (DEV_BUS_PHYS_BASE | 0x2100) diff --git a/debian/patches/features/arm/ts219.patch b/debian/patches/features/arm/ts219.patch new file mode 100644 index 000000000..e95842d46 --- /dev/null +++ b/debian/patches/features/arm/ts219.patch @@ -0,0 +1,279 @@ +To: nico@cam.org +Cc: linux-arm-kernel@lists.arm.linux.org.uk +Subject: [PATCH] Kirkwood: Add support for QNAP TS-119/TS-219 Turbo NAS + +Add support for the QNAP TS-119 and TS-219 Turbo NAS devices. + +Signed-off-by: Martin Michlmayr + + +--- a/arch/arm/mach-kirkwood/Kconfig ++++ b/arch/arm/mach-kirkwood/Kconfig +@@ -26,6 +26,12 @@ config MACH_SHEEVAPLUG + Say 'Y' here if you want your kernel to support the + Marvell SheevaPlug Reference Board. + ++config MACH_TS219 ++ bool "QNAP TS-119 and TS-219 Turbo NAS" ++ help ++ Say 'Y' here if you want your kernel to support the ++ QNAP TS-119 and TS-219 Turbo NAS devices. ++ + endmenu + + endif +--- a/arch/arm/mach-kirkwood/Makefile ++++ b/arch/arm/mach-kirkwood/Makefile +@@ -4,3 +4,4 @@ obj-$(CONFIG_MACH_DB88F6281_BP) += db88f6281-bp-setup.o + obj-$(CONFIG_MACH_RD88F6192_NAS) += rd88f6192-nas-setup.o + obj-$(CONFIG_MACH_RD88F6281) += rd88f6281-setup.o + obj-$(CONFIG_MACH_SHEEVAPLUG) += sheevaplug-setup.o ++obj-$(CONFIG_MACH_TS219) += ts219-setup.o +--- a/arch/arm/mach-kirkwood/common.h ++++ b/arch/arm/mach-kirkwood/common.h +@@ -42,6 +42,7 @@ + void kirkwood_uart0_init(void); + void kirkwood_uart1_init(void); + ++extern int kirkwood_tclk; + extern struct sys_timer kirkwood_timer; + + +--- /dev/null ++++ b/arch/arm/mach-kirkwood/ts219-setup.c +@@ -0,0 +1,220 @@ ++/* ++ * ++ * QNAP TS-119/TS-219 Turbo NAS Board Setup ++ * ++ * Copyright (C) 2009 Martin Michlmayr ++ * Copyright (C) 2008 Byron Bradley ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version ++ * 2 of the License, or (at your option) any later version. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include "common.h" ++#include "mpp.h" ++ ++/**************************************************************************** ++ * 16 MiB NOR flash. The struct mtd_partition is not in the same order as the ++ * partitions on the device because we want to keep compatability with ++ * the QNAP firmware. ++ * Layout as used by QNAP: ++ * 0x00000000-0x00080000 : "U-Boot" ++ * 0x00200000-0x00400000 : "Kernel" ++ * 0x00400000-0x00d00000 : "RootFS" ++ * 0x00d00000-0x01000000 : "RootFS2" ++ * 0x00080000-0x000c0000 : "U-Boot Config" ++ * 0x000c0000-0x00200000 : "NAS Config" ++ * ++ * We'll use "RootFS1" instead of "RootFS" to stay compatible with the layout ++ * used by the QNAP TS-109/TS-209. ++ * ++ ***************************************************************************/ ++ ++static struct mtd_partition qnap_ts219_partitions[] = { ++ { ++ .name = "U-Boot", ++ .size = 0x00080000, ++ .offset = 0, ++ .mask_flags = MTD_WRITEABLE, ++ }, { ++ .name = "Kernel", ++ .size = 0x00200000, ++ .offset = 0x00200000, ++ }, { ++ .name = "RootFS1", ++ .size = 0x00900000, ++ .offset = 0x00400000, ++ }, { ++ .name = "RootFS2", ++ .size = 0x00300000, ++ .offset = 0x00d00000, ++ }, { ++ .name = "U-Boot Config", ++ .size = 0x00040000, ++ .offset = 0x00080000, ++ }, { ++ .name = "NAS Config", ++ .size = 0x00140000, ++ .offset = 0x000c0000, ++ }, ++}; ++ ++static const struct flash_platform_data qnap_ts219_flash = { ++ .type = "m25p128", ++ .name = "spi_flash", ++ .parts = qnap_ts219_partitions, ++ .nr_parts = ARRAY_SIZE(qnap_ts219_partitions), ++}; ++ ++static struct spi_board_info __initdata qnap_ts219_spi_slave_info[] = { ++ { ++ .modalias = "m25p80", ++ .platform_data = &qnap_ts219_flash, ++ .irq = -1, ++ .max_speed_hz = 20000000, ++ .bus_num = 0, ++ .chip_select = 0, ++ }, ++}; ++ ++static struct i2c_board_info __initdata qnap_ts219_i2c_rtc = { ++ I2C_BOARD_INFO("s35390a", 0x30), ++}; ++ ++static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = { ++ .phy_addr = MV643XX_ETH_PHY_ADDR(8), ++}; ++ ++static struct mv_sata_platform_data qnap_ts219_sata_data = { ++ .n_ports = 2, ++}; ++ ++static struct gpio_keys_button qnap_ts219_buttons[] = { ++ { ++ .code = KEY_COPY, ++ .gpio = 15, ++ .desc = "USB Copy", ++ .active_low = 1, ++ }, ++ { ++ .code = KEY_RESTART, ++ .gpio = 16, ++ .desc = "Reset", ++ .active_low = 1, ++ }, ++}; ++ ++static struct gpio_keys_platform_data qnap_ts219_button_data = { ++ .buttons = qnap_ts219_buttons, ++ .nbuttons = ARRAY_SIZE(qnap_ts219_buttons), ++}; ++ ++static struct platform_device qnap_ts219_button_device = { ++ .name = "gpio-keys", ++ .id = -1, ++ .num_resources = 0, ++ .dev = { ++ .platform_data = &qnap_ts219_button_data, ++ } ++}; ++ ++static unsigned int qnap_ts219_mpp_config[] __initdata = { ++ MPP0_SPI_SCn, ++ MPP1_SPI_MOSI, ++ MPP2_SPI_SCK, ++ MPP3_SPI_MISO, ++ MPP8_TW_SDA, ++ MPP9_TW_SCK, ++ MPP10_UART0_TXD, ++ MPP11_UART0_RXD, ++ MPP13_UART1_TXD, /* PIC controller */ ++ MPP14_UART1_RXD, /* PIC controller */ ++ MPP15_GPIO, /* USB Copy button */ ++ MPP16_GPIO, /* Reset button */ ++ MPP20_SATA1_ACTn, ++ MPP21_SATA0_ACTn, ++ MPP22_SATA1_PRESENTn, ++ MPP23_SATA0_PRESENTn, ++ 0 ++}; ++ ++ ++/***************************************************************************** ++ * QNAP TS-x19 specific power off method via UART1-attached PIC ++ ****************************************************************************/ ++ ++#define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2)) ++ ++void qnap_ts219_power_off(void) ++{ ++ /* 19200 baud divisor */ ++ const unsigned divisor = ((kirkwood_tclk + (8 * 19200)) / (16 * 19200)); ++ ++ pr_info("%s: triggering power-off...\n", __func__); ++ ++ /* hijack UART1 and reset into sane state (19200,8n1) */ ++ writel(0x83, UART1_REG(LCR)); ++ writel(divisor & 0xff, UART1_REG(DLL)); ++ writel((divisor >> 8) & 0xff, UART1_REG(DLM)); ++ writel(0x03, UART1_REG(LCR)); ++ writel(0x00, UART1_REG(IER)); ++ writel(0x00, UART1_REG(FCR)); ++ writel(0x00, UART1_REG(MCR)); ++ ++ /* send the power-off command 'A' to PIC */ ++ writel('A', UART1_REG(TX)); ++} ++ ++static void __init qnap_ts219_init(void) ++{ ++ /* ++ * Basic setup. Needs to be called early. ++ */ ++ kirkwood_init(); ++ kirkwood_mpp_conf(qnap_ts219_mpp_config); ++ ++ kirkwood_uart0_init(); ++ kirkwood_uart1_init(); /* A PIC controller is connected here. */ ++ spi_register_board_info(qnap_ts219_spi_slave_info, ++ ARRAY_SIZE(qnap_ts219_spi_slave_info)); ++ kirkwood_spi_init(); ++ kirkwood_i2c_init(); ++ i2c_register_board_info(0, &qnap_ts219_i2c_rtc, 1); ++ kirkwood_ge00_init(&qnap_ts219_ge00_data); ++ kirkwood_sata_init(&qnap_ts219_sata_data); ++ kirkwood_ehci_init(); ++ platform_device_register(&qnap_ts219_button_device); ++ ++ pm_power_off = qnap_ts219_power_off; ++ ++} ++ ++MACHINE_START(TS219, "QNAP TS-119/TS-219") ++ /* Maintainer: Martin Michlmayr */ ++ .phys_io = KIRKWOOD_REGS_PHYS_BASE, ++ .io_pg_offst = ((KIRKWOOD_REGS_VIRT_BASE) >> 18) & 0xfffc, ++ .boot_params = 0x00000100, ++ .init_machine = qnap_ts219_init, ++ .map_io = kirkwood_map_io, ++ .init_irq = kirkwood_init_irq, ++ .timer = &kirkwood_timer, ++MACHINE_END +--- a/arch/arm/tools/mach-types 2009-03-22 20:42:58.000000000 +0000 ++++ b/arch/arm/tools/mach-types 2009-03-22 20:43:18.000000000 +0000 +@@ -1995,3 +1995,4 @@ + linkstation_ls_hgl MACH_LINKSTATION_LS_HGL LINKSTATION_LS_HGL 2005 + htcvenus MACH_HTCVENUS HTCVENUS 2006 + sheevaplug MACH_SHEEVAPLUG SHEEVAPLUG 2097 ++ts219 MACH_TS219 TS219 2139 + +#--- a/arch/arm/tools/mach-types +#+++ b/arch/arm/tools/mach-types +#@@ -2124,3 +2124,4 @@ mx27wallace MACH_MX27WALLACE MX27WALLACE 2133 + fmzwebmodul MACH_FMZWEBMODUL FMZWEBMODUL 2134 + rd78x00_masa MACH_RD78X00_MASA RD78X00_MASA 2135 + smallogger MACH_SMALLOGGER SMALLOGGER 2136 ++ts219 MACH_TS219 TS219 2139 diff --git a/debian/patches/series/1~experimental.1 b/debian/patches/series/1~experimental.1 index 0dd61b781..1faf9bf63 100644 --- a/debian/patches/series/1~experimental.1 +++ b/debian/patches/series/1~experimental.1 @@ -35,3 +35,7 @@ + features/arm/kw-sheevaplug.patch + features/arm/kw-sheevaplug-usb-power.patch + features/arm/kw-sheevaplug-led.patch ++ features/arm/kw-hook-up-i2c.patch ++ features/arm/kw-dont-init-rtc.patch ++ features/arm/kw-consistency-mpp.patch ++ features/arm/ts219.patch