blob: 9a44029915e2a4fd7fbab3fa8580b7611cbf69ed [file] [log] [blame]
Martin Michlmayrf3a131b2009-11-05 17:45:32 +00001/*
2 *
3 * QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS Board Setup
4 *
Martin Michlmayrf9afdd32010-05-22 02:23:10 +01005 * Copyright (C) 2009-2010 Martin Michlmayr <tbm@cyrius.com>
Martin Michlmayrf3a131b2009-11-05 17:45:32 +00006 * Copyright (C) 2008 Byron Bradley <byron.bbradley@gmail.com>
7 *
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.
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
Martin Michlmayrf3a131b2009-11-05 17:45:32 +000017#include <linux/i2c.h>
18#include <linux/mv643xx_eth.h>
19#include <linux/ata_platform.h>
Martin Michlmayrf9afdd32010-05-22 02:23:10 +010020#include <linux/gpio.h>
Martin Michlmayrf3a131b2009-11-05 17:45:32 +000021#include <linux/gpio_keys.h>
22#include <linux/input.h>
Martin Michlmayrf3a131b2009-11-05 17:45:32 +000023#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25#include <mach/kirkwood.h>
26#include "common.h"
27#include "mpp.h"
Martin Michlmayr8d27b2f2009-11-05 20:27:46 +000028#include "tsx1x-common.h"
Martin Michlmayrf3a131b2009-11-05 17:45:32 +000029
Nicolas Pitre39249962010-10-21 15:48:33 -040030/* for the PCIe reset workaround */
31#include <plat/pcie.h>
32
33
Martin Michlmayrf9afdd32010-05-22 02:23:10 +010034#define QNAP_TS41X_JUMPER_JP1 45
35
Martin Michlmayrf3a131b2009-11-05 17:45:32 +000036static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = {
37 I2C_BOARD_INFO("s35390a", 0x30),
38};
39
40static struct mv643xx_eth_platform_data qnap_ts41x_ge00_data = {
41 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
42};
43
44static struct mv643xx_eth_platform_data qnap_ts41x_ge01_data = {
45 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
46};
47
48static struct mv_sata_platform_data qnap_ts41x_sata_data = {
49 .n_ports = 2,
50};
51
52static struct gpio_keys_button qnap_ts41x_buttons[] = {
53 {
54 .code = KEY_COPY,
55 .gpio = 43,
56 .desc = "USB Copy",
57 .active_low = 1,
58 },
59 {
60 .code = KEY_RESTART,
61 .gpio = 37,
62 .desc = "Reset",
63 .active_low = 1,
64 },
65};
66
67static struct gpio_keys_platform_data qnap_ts41x_button_data = {
68 .buttons = qnap_ts41x_buttons,
69 .nbuttons = ARRAY_SIZE(qnap_ts41x_buttons),
70};
71
72static struct platform_device qnap_ts41x_button_device = {
73 .name = "gpio-keys",
74 .id = -1,
75 .num_resources = 0,
76 .dev = {
77 .platform_data = &qnap_ts41x_button_data,
78 }
79};
80
81static unsigned int qnap_ts41x_mpp_config[] __initdata = {
82 MPP0_SPI_SCn,
83 MPP1_SPI_MOSI,
84 MPP2_SPI_SCK,
85 MPP3_SPI_MISO,
86 MPP6_SYSRST_OUTn,
87 MPP7_PEX_RST_OUTn,
Benjamin Zores266a2452010-06-08 10:00:22 +020088 MPP8_TW0_SDA,
89 MPP9_TW0_SCK,
Martin Michlmayrf3a131b2009-11-05 17:45:32 +000090 MPP10_UART0_TXD,
91 MPP11_UART0_RXD,
92 MPP13_UART1_TXD, /* PIC controller */
93 MPP14_UART1_RXD, /* PIC controller */
94 MPP15_SATA0_ACTn,
95 MPP16_SATA1_ACTn,
Benjamin Zores266a2452010-06-08 10:00:22 +020096 MPP20_GE1_TXD0,
97 MPP21_GE1_TXD1,
98 MPP22_GE1_TXD2,
99 MPP23_GE1_TXD3,
100 MPP24_GE1_RXD0,
101 MPP25_GE1_RXD1,
102 MPP26_GE1_RXD2,
103 MPP27_GE1_RXD3,
104 MPP30_GE1_RXCTL,
105 MPP31_GE1_RXCLK,
106 MPP32_GE1_TCLKOUT,
107 MPP33_GE1_TXCTL,
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000108 MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */
109 MPP37_GPIO, /* Reset button */
110 MPP43_GPIO, /* USB Copy button */
111 MPP44_GPIO, /* Board ID: 0: TS-419U, 1: TS-419 */
Martin Michlmayr9e1d9342010-05-25 18:20:14 +0100112 MPP45_GPIO, /* JP1: 0: LCD, 1: serial console */
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000113 MPP46_GPIO, /* External SATA HDD1 error indicator */
114 MPP47_GPIO, /* External SATA HDD2 error indicator */
115 MPP48_GPIO, /* External SATA HDD3 error indicator */
116 MPP49_GPIO, /* External SATA HDD4 error indicator */
117 0
118};
119
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000120static void __init qnap_ts41x_init(void)
121{
Martin Michlmayrce56d162010-12-06 21:53:16 +0000122 u32 dev, rev;
123
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000124 /*
125 * Basic setup. Needs to be called early.
126 */
127 kirkwood_init();
128 kirkwood_mpp_conf(qnap_ts41x_mpp_config);
129
130 kirkwood_uart0_init();
131 kirkwood_uart1_init(); /* A PIC controller is connected here. */
Martin Michlmayr8d27b2f2009-11-05 20:27:46 +0000132 qnap_tsx1x_register_flash();
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000133 kirkwood_i2c_init();
134 i2c_register_board_info(0, &qnap_ts41x_i2c_rtc, 1);
Martin Michlmayrce56d162010-12-06 21:53:16 +0000135
136 kirkwood_pcie_id(&dev, &rev);
137 if (dev == MV88F6282_DEV_ID) {
138 qnap_ts41x_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);
139 qnap_ts41x_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1);
140 }
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000141 kirkwood_ge00_init(&qnap_ts41x_ge00_data);
142 kirkwood_ge01_init(&qnap_ts41x_ge01_data);
Martin Michlmayrce56d162010-12-06 21:53:16 +0000143
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000144 kirkwood_sata_init(&qnap_ts41x_sata_data);
145 kirkwood_ehci_init();
146 platform_device_register(&qnap_ts41x_button_device);
147
Martin Michlmayr8d27b2f2009-11-05 20:27:46 +0000148 pm_power_off = qnap_tsx1x_power_off;
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000149
Martin Michlmayrf9afdd32010-05-22 02:23:10 +0100150 if (gpio_request(QNAP_TS41X_JUMPER_JP1, "JP1") == 0)
151 gpio_export(QNAP_TS41X_JUMPER_JP1, 0);
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000152}
153
154static int __init ts41x_pci_init(void)
155{
Nicolas Pitre39249962010-10-21 15:48:33 -0400156 if (machine_is_ts41x()) {
157 /*
158 * Without this explicit reset, the PCIe SATA controller
159 * (Marvell 88sx7042/sata_mv) is known to stop working
160 * after a few minutes.
161 */
162 orion_pcie_reset((void __iomem *)PCIE_VIRT_BASE);
163
Saeed Bisharaffd58bd2010-06-08 14:21:34 +0300164 kirkwood_pcie_init(KW_PCIE0);
Nicolas Pitre39249962010-10-21 15:48:33 -0400165 }
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000166
167 return 0;
168}
169subsys_initcall(ts41x_pci_init);
170
171MACHINE_START(TS41X, "QNAP TS-41x")
172 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
Martin Michlmayrf3a131b2009-11-05 17:45:32 +0000173 .boot_params = 0x00000100,
174 .init_machine = qnap_ts41x_init,
175 .map_io = kirkwood_map_io,
176 .init_irq = kirkwood_init_irq,
177 .timer = &kirkwood_timer,
178MACHINE_END