2 * QNAP TS-409 Board Setup
4 * Maintainer: Sylver Bruneau <sylver.bruneau@gmail.com>
6 * Copyright (C) 2008 Sylver Bruneau <sylver.bruneau@gmail.com>
7 * Copyright (C) 2008 Martin Michlmayr <tbm@cyrius.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
14 #include <linux/gpio.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/pci.h>
19 #include <linux/irq.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/mv643xx_eth.h>
22 #include <linux/leds.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/input.h>
25 #include <linux/i2c.h>
26 #include <linux/serial_reg.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/pci.h>
30 #include <mach/orion5x.h>
33 #include "tsx09-common.h"
35 /*****************************************************************************
37 ****************************************************************************/
40 * QNAP TS-409 hardware :
41 * - Marvell 88F5281-D0
42 * - Marvell 88SX7042 SATA controller (PCIe)
43 * - Marvell 88E1118 Gigabit Ethernet PHY
44 * - RTC S35390A (@0x30) on I2C bus
46 * - 256MB of DDR-2 RAM
50 * 8MB NOR flash Device bus boot chip select
53 #define QNAP_TS409_NOR_BOOT_BASE 0xff800000
54 #define QNAP_TS409_NOR_BOOT_SIZE SZ_8M
56 /****************************************************************************
57 * 8MiB NOR flash. The struct mtd_partition is not in the same order as the
58 * partitions on the device because we want to keep compatibility with
59 * existing QNAP firmware.
61 * Layout as used by QNAP:
62 * [2] 0x00000000-0x00200000 : "Kernel"
63 * [3] 0x00200000-0x00600000 : "RootFS1"
64 * [4] 0x00600000-0x00700000 : "RootFS2"
65 * [6] 0x00700000-0x00760000 : "NAS Config" (read-only)
66 * [5] 0x00760000-0x00780000 : "U-Boot Config"
67 * [1] 0x00780000-0x00800000 : "U-Boot" (read-only)
68 ***************************************************************************/
69 static struct mtd_partition qnap_ts409_partitions
[] = {
74 .mask_flags
= MTD_WRITEABLE
,
88 .name
= "U-Boot Config",
95 .mask_flags
= MTD_WRITEABLE
,
99 static struct physmap_flash_data qnap_ts409_nor_flash_data
= {
101 .parts
= qnap_ts409_partitions
,
102 .nr_parts
= ARRAY_SIZE(qnap_ts409_partitions
)
105 static struct resource qnap_ts409_nor_flash_resource
= {
106 .flags
= IORESOURCE_MEM
,
107 .start
= QNAP_TS409_NOR_BOOT_BASE
,
108 .end
= QNAP_TS409_NOR_BOOT_BASE
+ QNAP_TS409_NOR_BOOT_SIZE
- 1,
111 static struct platform_device qnap_ts409_nor_flash
= {
112 .name
= "physmap-flash",
114 .dev
= { .platform_data
= &qnap_ts409_nor_flash_data
, },
116 .resource
= &qnap_ts409_nor_flash_resource
,
119 /*****************************************************************************
121 ****************************************************************************/
123 static int __init
qnap_ts409_pci_map_irq(const struct pci_dev
*dev
, u8 slot
,
129 * Check for devices with hard-wired IRQs.
131 irq
= orion5x_pci_map_irq(dev
, slot
, pin
);
136 * PCI isn't used on the TS-409
141 static struct hw_pci qnap_ts409_pci __initdata
= {
143 .setup
= orion5x_pci_sys_setup
,
144 .scan
= orion5x_pci_sys_scan_bus
,
145 .map_irq
= qnap_ts409_pci_map_irq
,
148 static int __init
qnap_ts409_pci_init(void)
150 if (machine_is_ts409())
151 pci_common_init(&qnap_ts409_pci
);
156 subsys_initcall(qnap_ts409_pci_init
);
158 /*****************************************************************************
159 * RTC S35390A on I2C bus
160 ****************************************************************************/
162 #define TS409_RTC_GPIO 10
164 static struct i2c_board_info __initdata qnap_ts409_i2c_rtc
= {
165 I2C_BOARD_INFO("s35390a", 0x30),
168 /*****************************************************************************
169 * LEDs attached to GPIO
170 ****************************************************************************/
172 static struct gpio_led ts409_led_pins
[] = {
174 .name
= "ts409:red:sata1",
178 .name
= "ts409:red:sata2",
182 .name
= "ts409:red:sata3",
186 .name
= "ts409:red:sata4",
192 static struct gpio_led_platform_data ts409_led_data
= {
193 .leds
= ts409_led_pins
,
194 .num_leds
= ARRAY_SIZE(ts409_led_pins
),
197 static struct platform_device ts409_leds
= {
201 .platform_data
= &ts409_led_data
,
205 /****************************************************************************
207 * Power button is attached to the PIC microcontroller
208 ****************************************************************************/
210 #define QNAP_TS409_GPIO_KEY_RESET 14
211 #define QNAP_TS409_GPIO_KEY_MEDIA 15
213 static struct gpio_keys_button qnap_ts409_buttons
[] = {
216 .gpio
= QNAP_TS409_GPIO_KEY_RESET
,
217 .desc
= "Reset Button",
221 .gpio
= QNAP_TS409_GPIO_KEY_MEDIA
,
222 .desc
= "USB Copy Button",
227 static struct gpio_keys_platform_data qnap_ts409_button_data
= {
228 .buttons
= qnap_ts409_buttons
,
229 .nbuttons
= ARRAY_SIZE(qnap_ts409_buttons
),
232 static struct platform_device qnap_ts409_button_device
= {
237 .platform_data
= &qnap_ts409_button_data
,
241 /*****************************************************************************
243 ****************************************************************************/
244 static unsigned int ts409_mpp_modes
[] __initdata
= {
249 MPP4_GPIO
, /* HDD 1 status */
250 MPP5_GPIO
, /* HDD 2 status */
251 MPP6_GPIO
, /* HDD 3 status */
252 MPP7_GPIO
, /* HDD 4 status */
255 MPP10_GPIO
, /* RTC int */
259 MPP14_GPIO
, /* SW_RST */
260 MPP15_GPIO
, /* USB copy button */
261 MPP16_UART
, /* UART1 RXD */
262 MPP17_UART
, /* UART1 TXD */
268 static void __init
qnap_ts409_init(void)
271 * Setup basic Orion functions. Need to be called early.
275 orion5x_mpp_conf(ts409_mpp_modes
);
278 * Configure peripherals.
280 mvebu_mbus_add_window("devbus-boot", QNAP_TS409_NOR_BOOT_BASE
,
281 QNAP_TS409_NOR_BOOT_SIZE
);
282 platform_device_register(&qnap_ts409_nor_flash
);
284 orion5x_ehci0_init();
285 qnap_tsx09_find_mac_addr(QNAP_TS409_NOR_BOOT_BASE
+
286 qnap_ts409_partitions
[5].offset
,
287 qnap_ts409_partitions
[5].size
);
288 orion5x_eth_init(&qnap_tsx09_eth_data
);
290 orion5x_uart0_init();
291 orion5x_uart1_init();
293 platform_device_register(&qnap_ts409_button_device
);
295 /* Get RTC IRQ and register the chip */
296 if (gpio_request(TS409_RTC_GPIO
, "rtc") == 0) {
297 if (gpio_direction_input(TS409_RTC_GPIO
) == 0)
298 qnap_ts409_i2c_rtc
.irq
= gpio_to_irq(TS409_RTC_GPIO
);
300 gpio_free(TS409_RTC_GPIO
);
302 if (qnap_ts409_i2c_rtc
.irq
== 0)
303 pr_warning("qnap_ts409_init: failed to get RTC IRQ\n");
304 i2c_register_board_info(0, &qnap_ts409_i2c_rtc
, 1);
305 platform_device_register(&ts409_leds
);
307 /* register tsx09 specific power-off method */
308 pm_power_off
= qnap_tsx09_power_off
;
311 MACHINE_START(TS409
, "QNAP TS-409")
312 /* Maintainer: Sylver Bruneau <sylver.bruneau@gmail.com> */
313 .atag_offset
= 0x100,
314 .init_machine
= qnap_ts409_init
,
315 .map_io
= orion5x_map_io
,
316 .init_early
= orion5x_init_early
,
317 .init_irq
= orion5x_init_irq
,
318 .init_time
= orion5x_timer_init
,
319 .fixup
= tag_fixup_mem32
,
320 .restart
= orion5x_restart
,