3 * QNAP TS-119/TS-219 Turbo NAS Board Setup
5 * Copyright (C) 2009 Martin Michlmayr <tbm@cyrius.com>
6 * Copyright (C) 2008 Byron Bradley <byron.bbradley@gmail.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17 #include <linux/mtd/physmap.h>
18 #include <linux/spi/flash.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/orion_spi.h>
21 #include <linux/i2c.h>
22 #include <linux/mv643xx_eth.h>
23 #include <linux/ata_platform.h>
24 #include <linux/gpio_keys.h>
25 #include <linux/input.h>
26 #include <linux/timex.h>
27 #include <linux/serial_reg.h>
28 #include <linux/pci.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <mach/kirkwood.h>
35 /****************************************************************************
36 * 16 MiB NOR flash. The struct mtd_partition is not in the same order as the
37 * partitions on the device because we want to keep compatability with
39 * Layout as used by QNAP:
40 * 0x00000000-0x00080000 : "U-Boot"
41 * 0x00200000-0x00400000 : "Kernel"
42 * 0x00400000-0x00d00000 : "RootFS"
43 * 0x00d00000-0x01000000 : "RootFS2"
44 * 0x00080000-0x000c0000 : "U-Boot Config"
45 * 0x000c0000-0x00200000 : "NAS Config"
47 * We'll use "RootFS1" instead of "RootFS" to stay compatible with the layout
48 * used by the QNAP TS-109/TS-209.
50 ***************************************************************************/
52 static struct mtd_partition qnap_ts219_partitions
[] = {
57 .mask_flags
= MTD_WRITEABLE
,
71 .name
= "U-Boot Config",
81 static const struct flash_platform_data qnap_ts219_flash
= {
84 .parts
= qnap_ts219_partitions
,
85 .nr_parts
= ARRAY_SIZE(qnap_ts219_partitions
),
88 static struct spi_board_info __initdata qnap_ts219_spi_slave_info
[] = {
91 .platform_data
= &qnap_ts219_flash
,
93 .max_speed_hz
= 20000000,
99 static struct i2c_board_info __initdata qnap_ts219_i2c_rtc
= {
100 I2C_BOARD_INFO("s35390a", 0x30),
103 static struct mv643xx_eth_platform_data qnap_ts219_ge00_data
= {
104 .phy_addr
= MV643XX_ETH_PHY_ADDR(8),
107 static struct mv_sata_platform_data qnap_ts219_sata_data
= {
111 static struct gpio_keys_button qnap_ts219_buttons
[] = {
126 static struct gpio_keys_platform_data qnap_ts219_button_data
= {
127 .buttons
= qnap_ts219_buttons
,
128 .nbuttons
= ARRAY_SIZE(qnap_ts219_buttons
),
131 static struct platform_device qnap_ts219_button_device
= {
136 .platform_data
= &qnap_ts219_button_data
,
140 static unsigned int qnap_ts219_mpp_config
[] __initdata
= {
149 MPP13_UART1_TXD
, /* PIC controller */
150 MPP14_UART1_RXD
, /* PIC controller */
151 MPP15_GPIO
, /* USB Copy button */
152 MPP16_GPIO
, /* Reset button */
155 MPP22_SATA1_PRESENTn
,
156 MPP23_SATA0_PRESENTn
,
161 /*****************************************************************************
162 * QNAP TS-x19 specific power off method via UART1-attached PIC
163 ****************************************************************************/
165 #define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
167 void qnap_ts219_power_off(void)
169 /* 19200 baud divisor */
170 const unsigned divisor
= ((kirkwood_tclk
+ (8 * 19200)) / (16 * 19200));
172 pr_info("%s: triggering power-off...\n", __func__
);
174 /* hijack UART1 and reset into sane state (19200,8n1) */
175 writel(0x83, UART1_REG(LCR
));
176 writel(divisor
& 0xff, UART1_REG(DLL
));
177 writel((divisor
>> 8) & 0xff, UART1_REG(DLM
));
178 writel(0x03, UART1_REG(LCR
));
179 writel(0x00, UART1_REG(IER
));
180 writel(0x00, UART1_REG(FCR
));
181 writel(0x00, UART1_REG(MCR
));
183 /* send the power-off command 'A' to PIC */
184 writel('A', UART1_REG(TX
));
187 static void __init
qnap_ts219_init(void)
190 * Basic setup. Needs to be called early.
193 kirkwood_mpp_conf(qnap_ts219_mpp_config
);
195 kirkwood_uart0_init();
196 kirkwood_uart1_init(); /* A PIC controller is connected here. */
197 spi_register_board_info(qnap_ts219_spi_slave_info
,
198 ARRAY_SIZE(qnap_ts219_spi_slave_info
));
201 i2c_register_board_info(0, &qnap_ts219_i2c_rtc
, 1);
202 kirkwood_ge00_init(&qnap_ts219_ge00_data
);
203 kirkwood_sata_init(&qnap_ts219_sata_data
);
204 kirkwood_ehci_init();
205 platform_device_register(&qnap_ts219_button_device
);
207 pm_power_off
= qnap_ts219_power_off
;
211 MACHINE_START(TS219
, "QNAP TS-119/TS-219")
212 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
213 .phys_io
= KIRKWOOD_REGS_PHYS_BASE
,
214 .io_pg_offst
= ((KIRKWOOD_REGS_VIRT_BASE
) >> 18) & 0xfffc,
215 .boot_params
= 0x00000100,
216 .init_machine
= qnap_ts219_init
,
217 .map_io
= kirkwood_map_io
,
218 .init_irq
= kirkwood_init_irq
,
219 .timer
= &kirkwood_timer
,