aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorByron Bradley <byron.bbradley@gmail.com>2007-12-15 15:05:49 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-26 10:04:03 -0500
commit3faf2ee870c26f6a809af3f32368f96c357ed91b (patch)
tree99939dc2e163a3642f7c606b9a55cfed65ea7b57 /arch
parent144aa3db1e8faa34bb33c61131494ac879a6d978 (diff)
[ARM] Orion: add support for QNAP TS-109/TS-209
This patch adds support for the Orion/MV88F5182 based QNAP TS-109/TS-209 NAS device. The driver for the S-35390A RTC chip on this board has been submitted to LKML separately. Signed-off-by: Byron Bradley <byron.bbradley@gmail.com> Tested-by: Oyvind Repvik <repvik@kynisk.com> Tested-by: Tim Ellis <timtimred@foonas.org> Tested-by: Herbert Valerio Riedel <hvr@gnu.org> Acked-by: Tzachi Perelstein <tzachi@marvell.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/configs/orion_defconfig1
-rw-r--r--arch/arm/mach-orion/Kconfig6
-rw-r--r--arch/arm/mach-orion/Makefile1
-rw-r--r--arch/arm/mach-orion/ts209-setup.c305
4 files changed, 313 insertions, 0 deletions
diff --git a/arch/arm/configs/orion_defconfig b/arch/arm/configs/orion_defconfig
index 85b80f6b78e1..17a55def1103 100644
--- a/arch/arm/configs/orion_defconfig
+++ b/arch/arm/configs/orion_defconfig
@@ -147,6 +147,7 @@ CONFIG_MACH_DB88F5281=y
147CONFIG_MACH_RD88F5182=y 147CONFIG_MACH_RD88F5182=y
148CONFIG_MACH_KUROBOX_PRO=y 148CONFIG_MACH_KUROBOX_PRO=y
149CONFIG_MACH_DNS323=y 149CONFIG_MACH_DNS323=y
150CONFIG_MACH_TS209=y
150 151
151# 152#
152# Boot options 153# Boot options
diff --git a/arch/arm/mach-orion/Kconfig b/arch/arm/mach-orion/Kconfig
index bdaed867e450..1dcbb6ac5a30 100644
--- a/arch/arm/mach-orion/Kconfig
+++ b/arch/arm/mach-orion/Kconfig
@@ -30,6 +30,12 @@ config MACH_DNS323
30 Say 'Y' here if you want your kernel to support the 30 Say 'Y' here if you want your kernel to support the
31 D-Link DNS-323 platform. 31 D-Link DNS-323 platform.
32 32
33config MACH_TS209
34 bool "QNAP TS-109/TS-209"
35 help
36 Say 'Y' here if you want your kernel to support the
37 QNAP TS-109/TS-209 platform.
38
33endmenu 39endmenu
34 40
35endif 41endif
diff --git a/arch/arm/mach-orion/Makefile b/arch/arm/mach-orion/Makefile
index 237ce98ad0ef..f91d937a73e8 100644
--- a/arch/arm/mach-orion/Makefile
+++ b/arch/arm/mach-orion/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_MACH_DB88F5281) += db88f5281-setup.o
3obj-$(CONFIG_MACH_RD88F5182) += rd88f5182-setup.o 3obj-$(CONFIG_MACH_RD88F5182) += rd88f5182-setup.o
4obj-$(CONFIG_MACH_KUROBOX_PRO) += kurobox_pro-setup.o 4obj-$(CONFIG_MACH_KUROBOX_PRO) += kurobox_pro-setup.o
5obj-$(CONFIG_MACH_DNS323) += dns323-setup.o 5obj-$(CONFIG_MACH_DNS323) += dns323-setup.o
6obj-$(CONFIG_MACH_TS209) += ts209-setup.o
diff --git a/arch/arm/mach-orion/ts209-setup.c b/arch/arm/mach-orion/ts209-setup.c
new file mode 100644
index 000000000000..34f88ac24ac8
--- /dev/null
+++ b/arch/arm/mach-orion/ts209-setup.c
@@ -0,0 +1,305 @@
1/*
2 * QNAP TS-109/TS-209 Board Setup
3 *
4 * Maintainer: Byron Bradley <byron.bbradley@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/pci.h>
16#include <linux/irq.h>
17#include <linux/mtd/physmap.h>
18#include <linux/mtd/nand.h>
19#include <linux/mv643xx_eth.h>
20#include <linux/gpio_keys.h>
21#include <linux/input.h>
22#include <linux/i2c.h>
23#include <asm/mach-types.h>
24#include <asm/gpio.h>
25#include <asm/mach/arch.h>
26#include <asm/mach/pci.h>
27#include <asm/arch/orion.h>
28#include <asm/arch/platform.h>
29#include "common.h"
30
31#define QNAP_TS209_NOR_BOOT_BASE 0xf4000000
32#define QNAP_TS209_NOR_BOOT_SIZE SZ_8M
33
34/****************************************************************************
35 * 8MiB NOR flash. The struct mtd_partition is not in the same order as the
36 * partitions on the device because we want to keep compatability with
37 * existing QNAP firmware.
38 *
39 * Layout as used by QNAP:
40 * [2] 0x00000000-0x00200000 : "Kernel"
41 * [3] 0x00200000-0x00600000 : "RootFS1"
42 * [4] 0x00600000-0x00700000 : "RootFS2"
43 * [6] 0x00700000-0x00760000 : "NAS Config" (read-only)
44 * [5] 0x00760000-0x00780000 : "U-Boot Config"
45 * [1] 0x00780000-0x00800000 : "U-Boot" (read-only)
46 ***************************************************************************/
47static struct mtd_partition qnap_ts209_partitions[] = {
48 {
49 .name = "U-Boot",
50 .size = 0x00080000,
51 .offset = 0x00780000,
52 .mask_flags = MTD_WRITEABLE,
53 }, {
54 .name = "Kernel",
55 .size = 0x00200000,
56 .offset = 0,
57 }, {
58 .name = "RootFS1",
59 .size = 0x00400000,
60 .offset = 0x00200000,
61 }, {
62 .name = "RootFS2",
63 .size = 0x00100000,
64 .offset = 0x00600000,
65 }, {
66 .name = "U-Boot Config",
67 .size = 0x00020000,
68 .offset = 0x00760000,
69 }, {
70 .name = "NAS Config",
71 .size = 0x00060000,
72 .offset = 0x00700000,
73 .mask_flags = MTD_WRITEABLE,
74 }
75};
76
77static struct physmap_flash_data qnap_ts209_nor_flash_data = {
78 .width = 1,
79 .parts = qnap_ts209_partitions,
80 .nr_parts = ARRAY_SIZE(qnap_ts209_partitions)
81};
82
83static struct resource qnap_ts209_nor_flash_resource = {
84 .flags = IORESOURCE_MEM,
85 .start = QNAP_TS209_NOR_BOOT_BASE,
86 .end = QNAP_TS209_NOR_BOOT_BASE + QNAP_TS209_NOR_BOOT_SIZE - 1,
87};
88
89static struct platform_device qnap_ts209_nor_flash = {
90 .name = "physmap-flash",
91 .id = 0,
92 .dev = { .platform_data = &qnap_ts209_nor_flash_data, },
93 .resource = &qnap_ts209_nor_flash_resource,
94 .num_resources = 1,
95};
96
97/*****************************************************************************
98 * PCI
99 ****************************************************************************/
100
101#define QNAP_TS209_PCI_SLOT0_OFFS 7
102#define QNAP_TS209_PCI_SLOT0_IRQ_PIN 6
103#define QNAP_TS209_PCI_SLOT1_IRQ_PIN 7
104
105void __init qnap_ts209_pci_preinit(void)
106{
107 int pin;
108
109 /*
110 * Configure PCI GPIO IRQ pins
111 */
112 pin = QNAP_TS209_PCI_SLOT0_IRQ_PIN;
113 if (gpio_request(pin, "PCI Int1") == 0) {
114 if (gpio_direction_input(pin) == 0) {
115 set_irq_type(gpio_to_irq(pin), IRQT_LOW);
116 } else {
117 printk(KERN_ERR "qnap_ts209_pci_preinit failed to "
118 "set_irq_type pin %d\n", pin);
119 gpio_free(pin);
120 }
121 } else {
122 printk(KERN_ERR "qnap_ts209_pci_preinit failed to gpio_request "
123 "%d\n", pin);
124 }
125
126 pin = QNAP_TS209_PCI_SLOT1_IRQ_PIN;
127 if (gpio_request(pin, "PCI Int2") == 0) {
128 if (gpio_direction_input(pin) == 0) {
129 set_irq_type(gpio_to_irq(pin), IRQT_LOW);
130 } else {
131 printk(KERN_ERR "qnap_ts209_pci_preinit failed "
132 "to set_irq_type pin %d\n", pin);
133 gpio_free(pin);
134 }
135 } else {
136 printk(KERN_ERR "qnap_ts209_pci_preinit failed to gpio_request "
137 "%d\n", pin);
138 }
139}
140
141static int __init qnap_ts209_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
142{
143 /*
144 * PCIE IRQ is connected internally (not GPIO)
145 */
146 if (dev->bus->number == orion_pcie_local_bus_nr())
147 return IRQ_ORION_PCIE0_INT;
148
149 /*
150 * PCI IRQs are connected via GPIOs
151 */
152 switch (slot - QNAP_TS209_PCI_SLOT0_OFFS) {
153 case 0:
154 return gpio_to_irq(QNAP_TS209_PCI_SLOT0_IRQ_PIN);
155 case 1:
156 return gpio_to_irq(QNAP_TS209_PCI_SLOT1_IRQ_PIN);
157 default:
158 return -1;
159 }
160}
161
162static struct hw_pci qnap_ts209_pci __initdata = {
163 .nr_controllers = 2,
164 .preinit = qnap_ts209_pci_preinit,
165 .swizzle = pci_std_swizzle,
166 .setup = orion_pci_sys_setup,
167 .scan = orion_pci_sys_scan_bus,
168 .map_irq = qnap_ts209_pci_map_irq,
169};
170
171static int __init qnap_ts209_pci_init(void)
172{
173 if (machine_is_ts_x09())
174 pci_common_init(&qnap_ts209_pci);
175
176 return 0;
177}
178
179subsys_initcall(qnap_ts209_pci_init);
180
181/*****************************************************************************
182 * Ethernet
183 ****************************************************************************/
184
185static struct mv643xx_eth_platform_data qnap_ts209_eth_data = {
186 .phy_addr = 8,
187 .force_phy_addr = 1,
188};
189
190/*****************************************************************************
191 * RTC S35390A on I2C bus
192 ****************************************************************************/
193static struct i2c_board_info __initdata qnap_ts209_i2c_rtc = {
194 .driver_name = "rtc-s35390a",
195 .addr = 0x30,
196};
197
198/****************************************************************************
199 * GPIO Attached Keys
200 * Power button is attached to the PIC microcontroller
201 ****************************************************************************/
202
203#define QNAP_TS209_GPIO_KEY_MEDIA 1
204#define QNAP_TS209_GPIO_KEY_RESET 2
205
206static struct gpio_keys_button qnap_ts209_buttons[] = {
207 {
208 .code = KEY_RESTART,
209 .gpio = QNAP_TS209_GPIO_KEY_MEDIA,
210 .desc = "USB Copy Button",
211 .active_low = 1,
212 },
213 {
214 .code = KEY_POWER,
215 .gpio = QNAP_TS209_GPIO_KEY_RESET,
216 .desc = "Reset Button",
217 .active_low = 1,
218 }
219};
220
221static struct gpio_keys_platform_data qnap_ts209_button_data = {
222 .buttons = qnap_ts209_buttons,
223 .nbuttons = ARRAY_SIZE(qnap_ts209_buttons),
224};
225
226static struct platform_device qnap_ts209_button_device = {
227 .name = "gpio-keys",
228 .id = -1,
229 .num_resources = 0,
230 .dev = { .platform_data = &qnap_ts209_button_data, },
231};
232
233/*****************************************************************************
234 * General Setup
235 ****************************************************************************/
236
237static struct platform_device *qnap_ts209_devices[] __initdata = {
238 &qnap_ts209_nor_flash,
239 &qnap_ts209_button_device,
240};
241
242static void __init qnap_ts209_init(void)
243{
244 /*
245 * Setup basic Orion functions. Need to be called early.
246 */
247 orion_init();
248
249 /*
250 * Setup flash mapping
251 */
252 orion_setup_cpu_win(ORION_DEV_BOOT, QNAP_TS209_NOR_BOOT_BASE,
253 QNAP_TS209_NOR_BOOT_SIZE, -1);
254
255 /*
256 * Open a special address decode windows for the PCIE WA.
257 */
258 orion_write(ORION_REGS_BASE | 0x20074, ORION_PCIE_WA_BASE);
259 orion_write(ORION_REGS_BASE | 0x20070, (0x7941 |
260 (((ORION_PCIE_WA_SIZE >> 16) - 1)) << 16));
261
262 /*
263 * Setup Multiplexing Pins --
264 * MPP[0] Reserved
265 * MPP[1] USB copy button (0 active)
266 * MPP[2] Load defaults button (0 active)
267 * MPP[3] GPIO RTC
268 * MPP[4-5] Reserved
269 * MPP[6] PCI Int A
270 * MPP[7] PCI Int B
271 * MPP[8-11] Reserved
272 * MPP[12] SATA 0 presence
273 * MPP[13] SATA 1 presence
274 * MPP[14] SATA 0 active
275 * MPP[15] SATA 1 active
276 * MPP[16] UART1 RXD
277 * MPP[17] UART1 TXD
278 * MPP[18] SW_RST (0 active)
279 * MPP[19] Reserved
280 * MPP[20] PCI clock 0
281 * MPP[21] PCI clock 1
282 * MPP[22] USB 0 over current
283 * MPP[23-25] Reserved
284 */
285 orion_write(MPP_0_7_CTRL, 0x3);
286 orion_write(MPP_8_15_CTRL, 0x55550000);
287 orion_write(MPP_16_19_CTRL, 0x5500);
288 orion_gpio_set_valid_pins(0x3cc0fff);
289
290 platform_add_devices(qnap_ts209_devices,
291 ARRAY_SIZE(qnap_ts209_devices));
292 i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1);
293 orion_eth_init(&qnap_ts209_eth_data);
294}
295
296MACHINE_START(TS209, "QNAP TS-109/TS-209")
297 /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */
298 .phys_io = ORION_REGS_BASE,
299 .io_pg_offst = ((ORION_REGS_BASE) >> 18) & 0xFFFC,
300 .boot_params = 0x00000100,
301 .init_machine = qnap_ts209_init,
302 .map_io = orion_map_io,
303 .init_irq = orion_init_irq,
304 .timer = &orion_timer,
305MACHINE_END