Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS Board Setup |
| 4 | * |
Martin Michlmayr | f9afdd3 | 2010-05-22 02:23:10 +0100 | [diff] [blame] | 5 | * Copyright (C) 2009-2010 Martin Michlmayr <tbm@cyrius.com> |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 6 | * 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 Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 17 | #include <linux/i2c.h> |
| 18 | #include <linux/mv643xx_eth.h> |
| 19 | #include <linux/ata_platform.h> |
Martin Michlmayr | f9afdd3 | 2010-05-22 02:23:10 +0100 | [diff] [blame] | 20 | #include <linux/gpio.h> |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 21 | #include <linux/gpio_keys.h> |
| 22 | #include <linux/input.h> |
Thomas Petazzoni | 060f3d1 | 2012-09-11 14:27:19 +0200 | [diff] [blame] | 23 | #include <linux/io.h> |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 24 | #include <asm/mach-types.h> |
| 25 | #include <asm/mach/arch.h> |
| 26 | #include <mach/kirkwood.h> |
| 27 | #include "common.h" |
| 28 | #include "mpp.h" |
Martin Michlmayr | 8d27b2f | 2009-11-05 20:27:46 +0000 | [diff] [blame] | 29 | #include "tsx1x-common.h" |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 30 | |
Nicolas Pitre | 3924996 | 2010-10-21 15:48:33 -0400 | [diff] [blame] | 31 | /* for the PCIe reset workaround */ |
| 32 | #include <plat/pcie.h> |
| 33 | |
| 34 | |
Martin Michlmayr | f9afdd3 | 2010-05-22 02:23:10 +0100 | [diff] [blame] | 35 | #define QNAP_TS41X_JUMPER_JP1 45 |
| 36 | |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 37 | static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = { |
| 38 | I2C_BOARD_INFO("s35390a", 0x30), |
| 39 | }; |
| 40 | |
| 41 | static struct mv643xx_eth_platform_data qnap_ts41x_ge00_data = { |
| 42 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 43 | }; |
| 44 | |
| 45 | static struct mv643xx_eth_platform_data qnap_ts41x_ge01_data = { |
| 46 | .phy_addr = MV643XX_ETH_PHY_ADDR(0), |
| 47 | }; |
| 48 | |
| 49 | static struct mv_sata_platform_data qnap_ts41x_sata_data = { |
| 50 | .n_ports = 2, |
| 51 | }; |
| 52 | |
| 53 | static struct gpio_keys_button qnap_ts41x_buttons[] = { |
| 54 | { |
| 55 | .code = KEY_COPY, |
| 56 | .gpio = 43, |
| 57 | .desc = "USB Copy", |
| 58 | .active_low = 1, |
| 59 | }, |
| 60 | { |
| 61 | .code = KEY_RESTART, |
| 62 | .gpio = 37, |
| 63 | .desc = "Reset", |
| 64 | .active_low = 1, |
| 65 | }, |
| 66 | }; |
| 67 | |
| 68 | static struct gpio_keys_platform_data qnap_ts41x_button_data = { |
| 69 | .buttons = qnap_ts41x_buttons, |
| 70 | .nbuttons = ARRAY_SIZE(qnap_ts41x_buttons), |
| 71 | }; |
| 72 | |
| 73 | static struct platform_device qnap_ts41x_button_device = { |
| 74 | .name = "gpio-keys", |
| 75 | .id = -1, |
| 76 | .num_resources = 0, |
| 77 | .dev = { |
| 78 | .platform_data = &qnap_ts41x_button_data, |
| 79 | } |
| 80 | }; |
| 81 | |
| 82 | static unsigned int qnap_ts41x_mpp_config[] __initdata = { |
| 83 | MPP0_SPI_SCn, |
| 84 | MPP1_SPI_MOSI, |
| 85 | MPP2_SPI_SCK, |
| 86 | MPP3_SPI_MISO, |
| 87 | MPP6_SYSRST_OUTn, |
| 88 | MPP7_PEX_RST_OUTn, |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 89 | MPP8_TW0_SDA, |
| 90 | MPP9_TW0_SCK, |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 91 | MPP10_UART0_TXD, |
| 92 | MPP11_UART0_RXD, |
| 93 | MPP13_UART1_TXD, /* PIC controller */ |
| 94 | MPP14_UART1_RXD, /* PIC controller */ |
| 95 | MPP15_SATA0_ACTn, |
| 96 | MPP16_SATA1_ACTn, |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 97 | MPP20_GE1_TXD0, |
| 98 | MPP21_GE1_TXD1, |
| 99 | MPP22_GE1_TXD2, |
| 100 | MPP23_GE1_TXD3, |
| 101 | MPP24_GE1_RXD0, |
| 102 | MPP25_GE1_RXD1, |
| 103 | MPP26_GE1_RXD2, |
| 104 | MPP27_GE1_RXD3, |
| 105 | MPP30_GE1_RXCTL, |
| 106 | MPP31_GE1_RXCLK, |
| 107 | MPP32_GE1_TCLKOUT, |
| 108 | MPP33_GE1_TXCTL, |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 109 | MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */ |
| 110 | MPP37_GPIO, /* Reset button */ |
| 111 | MPP43_GPIO, /* USB Copy button */ |
| 112 | MPP44_GPIO, /* Board ID: 0: TS-419U, 1: TS-419 */ |
Martin Michlmayr | 9e1d934 | 2010-05-25 18:20:14 +0100 | [diff] [blame] | 113 | MPP45_GPIO, /* JP1: 0: LCD, 1: serial console */ |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 114 | MPP46_GPIO, /* External SATA HDD1 error indicator */ |
| 115 | MPP47_GPIO, /* External SATA HDD2 error indicator */ |
| 116 | MPP48_GPIO, /* External SATA HDD3 error indicator */ |
| 117 | MPP49_GPIO, /* External SATA HDD4 error indicator */ |
| 118 | 0 |
| 119 | }; |
| 120 | |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 121 | static void __init qnap_ts41x_init(void) |
| 122 | { |
Martin Michlmayr | ce56d16 | 2010-12-06 21:53:16 +0000 | [diff] [blame] | 123 | u32 dev, rev; |
| 124 | |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 125 | /* |
| 126 | * Basic setup. Needs to be called early. |
| 127 | */ |
| 128 | kirkwood_init(); |
| 129 | kirkwood_mpp_conf(qnap_ts41x_mpp_config); |
| 130 | |
| 131 | kirkwood_uart0_init(); |
| 132 | kirkwood_uart1_init(); /* A PIC controller is connected here. */ |
Martin Michlmayr | 8d27b2f | 2009-11-05 20:27:46 +0000 | [diff] [blame] | 133 | qnap_tsx1x_register_flash(); |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 134 | kirkwood_i2c_init(); |
| 135 | i2c_register_board_info(0, &qnap_ts41x_i2c_rtc, 1); |
Martin Michlmayr | ce56d16 | 2010-12-06 21:53:16 +0000 | [diff] [blame] | 136 | |
| 137 | kirkwood_pcie_id(&dev, &rev); |
| 138 | if (dev == MV88F6282_DEV_ID) { |
| 139 | qnap_ts41x_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0); |
| 140 | qnap_ts41x_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1); |
| 141 | } |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 142 | kirkwood_ge00_init(&qnap_ts41x_ge00_data); |
| 143 | kirkwood_ge01_init(&qnap_ts41x_ge01_data); |
Martin Michlmayr | ce56d16 | 2010-12-06 21:53:16 +0000 | [diff] [blame] | 144 | |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 145 | kirkwood_sata_init(&qnap_ts41x_sata_data); |
| 146 | kirkwood_ehci_init(); |
| 147 | platform_device_register(&qnap_ts41x_button_device); |
| 148 | |
Martin Michlmayr | 8d27b2f | 2009-11-05 20:27:46 +0000 | [diff] [blame] | 149 | pm_power_off = qnap_tsx1x_power_off; |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 150 | |
Martin Michlmayr | f9afdd3 | 2010-05-22 02:23:10 +0100 | [diff] [blame] | 151 | if (gpio_request(QNAP_TS41X_JUMPER_JP1, "JP1") == 0) |
| 152 | gpio_export(QNAP_TS41X_JUMPER_JP1, 0); |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | static int __init ts41x_pci_init(void) |
| 156 | { |
Nicolas Pitre | 3924996 | 2010-10-21 15:48:33 -0400 | [diff] [blame] | 157 | if (machine_is_ts41x()) { |
Zintis PÄ“tersons | 1ab6962 | 2011-02-14 18:38:13 +0200 | [diff] [blame] | 158 | u32 dev, rev; |
| 159 | |
Nicolas Pitre | 3924996 | 2010-10-21 15:48:33 -0400 | [diff] [blame] | 160 | /* |
| 161 | * Without this explicit reset, the PCIe SATA controller |
| 162 | * (Marvell 88sx7042/sata_mv) is known to stop working |
| 163 | * after a few minutes. |
| 164 | */ |
Thomas Petazzoni | 060f3d1 | 2012-09-11 14:27:19 +0200 | [diff] [blame] | 165 | orion_pcie_reset(PCIE_VIRT_BASE); |
Nicolas Pitre | 3924996 | 2010-10-21 15:48:33 -0400 | [diff] [blame] | 166 | |
Zintis PÄ“tersons | 1ab6962 | 2011-02-14 18:38:13 +0200 | [diff] [blame] | 167 | kirkwood_pcie_id(&dev, &rev); |
| 168 | if (dev == MV88F6282_DEV_ID) |
| 169 | kirkwood_pcie_init(KW_PCIE1 | KW_PCIE0); |
| 170 | else |
| 171 | kirkwood_pcie_init(KW_PCIE0); |
Nicolas Pitre | 3924996 | 2010-10-21 15:48:33 -0400 | [diff] [blame] | 172 | } |
Andrew Lunn | 98adf93 | 2012-10-20 13:23:16 +0200 | [diff] [blame] | 173 | return 0; |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 174 | } |
| 175 | subsys_initcall(ts41x_pci_init); |
| 176 | |
| 177 | MACHINE_START(TS41X, "QNAP TS-41x") |
| 178 | /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ |
Nicolas Pitre | 1b7bd28 | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 179 | .atag_offset = 0x100, |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 180 | .init_machine = qnap_ts41x_init, |
| 181 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 182 | .init_early = kirkwood_init_early, |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 183 | .init_irq = kirkwood_init_irq, |
| 184 | .timer = &kirkwood_timer, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 185 | .restart = kirkwood_restart, |
Martin Michlmayr | f3a131b | 2009-11-05 17:45:32 +0000 | [diff] [blame] | 186 | MACHINE_END |