Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 1 | /* |
| 2 | * |
Martin Michlmayr | 287989c | 2009-11-05 18:15:31 +0000 | [diff] [blame] | 3 | * QNAP TS-11x/TS-21x Turbo NAS Board Setup |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2009 Martin Michlmayr <tbm@cyrius.com> |
| 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 | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 17 | #include <linux/i2c.h> |
| 18 | #include <linux/mv643xx_eth.h> |
| 19 | #include <linux/ata_platform.h> |
| 20 | #include <linux/gpio_keys.h> |
| 21 | #include <linux/input.h> |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 22 | #include <asm/mach-types.h> |
| 23 | #include <asm/mach/arch.h> |
| 24 | #include <mach/kirkwood.h> |
| 25 | #include "common.h" |
| 26 | #include "mpp.h" |
Martin Michlmayr | 8d27b2f | 2009-11-05 20:27:46 +0000 | [diff] [blame] | 27 | #include "tsx1x-common.h" |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 28 | |
| 29 | static struct i2c_board_info __initdata qnap_ts219_i2c_rtc = { |
| 30 | I2C_BOARD_INFO("s35390a", 0x30), |
| 31 | }; |
| 32 | |
| 33 | static struct mv643xx_eth_platform_data qnap_ts219_ge00_data = { |
| 34 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 35 | }; |
| 36 | |
| 37 | static struct mv_sata_platform_data qnap_ts219_sata_data = { |
| 38 | .n_ports = 2, |
| 39 | }; |
| 40 | |
| 41 | static struct gpio_keys_button qnap_ts219_buttons[] = { |
| 42 | { |
| 43 | .code = KEY_COPY, |
| 44 | .gpio = 15, |
| 45 | .desc = "USB Copy", |
| 46 | .active_low = 1, |
| 47 | }, |
| 48 | { |
| 49 | .code = KEY_RESTART, |
| 50 | .gpio = 16, |
| 51 | .desc = "Reset", |
| 52 | .active_low = 1, |
| 53 | }, |
| 54 | }; |
| 55 | |
| 56 | static struct gpio_keys_platform_data qnap_ts219_button_data = { |
| 57 | .buttons = qnap_ts219_buttons, |
| 58 | .nbuttons = ARRAY_SIZE(qnap_ts219_buttons), |
| 59 | }; |
| 60 | |
| 61 | static struct platform_device qnap_ts219_button_device = { |
| 62 | .name = "gpio-keys", |
| 63 | .id = -1, |
| 64 | .num_resources = 0, |
| 65 | .dev = { |
| 66 | .platform_data = &qnap_ts219_button_data, |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | static unsigned int qnap_ts219_mpp_config[] __initdata = { |
| 71 | MPP0_SPI_SCn, |
| 72 | MPP1_SPI_MOSI, |
| 73 | MPP2_SPI_SCK, |
| 74 | MPP3_SPI_MISO, |
Thomas Reitmayr | 385aa9e | 2009-05-19 19:35:26 +0200 | [diff] [blame] | 75 | MPP4_SATA1_ACTn, |
| 76 | MPP5_SATA0_ACTn, |
Benjamin Zores | 266a245 | 2010-06-08 10:00:22 +0200 | [diff] [blame] | 77 | MPP8_TW0_SDA, |
| 78 | MPP9_TW0_SCK, |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 79 | MPP10_UART0_TXD, |
| 80 | MPP11_UART0_RXD, |
| 81 | MPP13_UART1_TXD, /* PIC controller */ |
| 82 | MPP14_UART1_RXD, /* PIC controller */ |
Martin Michlmayr | ce56d16 | 2010-12-06 21:53:16 +0000 | [diff] [blame] | 83 | MPP15_GPIO, /* USB Copy button (on devices with 88F6281) */ |
| 84 | MPP16_GPIO, /* Reset button (on devices with 88F6281) */ |
Martin Michlmayr | b421950 | 2009-11-05 18:09:01 +0000 | [diff] [blame] | 85 | MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */ |
Martin Michlmayr | ce56d16 | 2010-12-06 21:53:16 +0000 | [diff] [blame] | 86 | MPP37_GPIO, /* Reset button (on devices with 88F6282) */ |
| 87 | MPP43_GPIO, /* USB Copy button (on devices with 88F6282) */ |
Martin Michlmayr | 128190e | 2010-06-13 19:37:18 +0100 | [diff] [blame] | 88 | MPP44_GPIO, /* Board ID: 0: TS-11x, 1: TS-21x */ |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 89 | 0 |
| 90 | }; |
| 91 | |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 92 | static void __init qnap_ts219_init(void) |
| 93 | { |
Martin Michlmayr | ce56d16 | 2010-12-06 21:53:16 +0000 | [diff] [blame] | 94 | u32 dev, rev; |
| 95 | |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 96 | /* |
| 97 | * Basic setup. Needs to be called early. |
| 98 | */ |
| 99 | kirkwood_init(); |
| 100 | kirkwood_mpp_conf(qnap_ts219_mpp_config); |
| 101 | |
| 102 | kirkwood_uart0_init(); |
| 103 | kirkwood_uart1_init(); /* A PIC controller is connected here. */ |
Martin Michlmayr | 8d27b2f | 2009-11-05 20:27:46 +0000 | [diff] [blame] | 104 | qnap_tsx1x_register_flash(); |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 105 | kirkwood_i2c_init(); |
| 106 | i2c_register_board_info(0, &qnap_ts219_i2c_rtc, 1); |
Martin Michlmayr | ce56d16 | 2010-12-06 21:53:16 +0000 | [diff] [blame] | 107 | |
| 108 | kirkwood_pcie_id(&dev, &rev); |
| 109 | if (dev == MV88F6282_DEV_ID) { |
| 110 | qnap_ts219_buttons[0].gpio = 43; /* USB Copy button */ |
| 111 | qnap_ts219_buttons[1].gpio = 37; /* Reset button */ |
| 112 | qnap_ts219_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0); |
| 113 | } |
| 114 | |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 115 | kirkwood_ge00_init(&qnap_ts219_ge00_data); |
| 116 | kirkwood_sata_init(&qnap_ts219_sata_data); |
| 117 | kirkwood_ehci_init(); |
| 118 | platform_device_register(&qnap_ts219_button_device); |
| 119 | |
Martin Michlmayr | 8d27b2f | 2009-11-05 20:27:46 +0000 | [diff] [blame] | 120 | pm_power_off = qnap_tsx1x_power_off; |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 121 | |
| 122 | } |
| 123 | |
John Holland | c55bf10 | 2009-08-19 13:24:03 -1000 | [diff] [blame] | 124 | static int __init ts219_pci_init(void) |
| 125 | { |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 126 | if (machine_is_ts219()) |
| 127 | kirkwood_pcie_init(KW_PCIE0); |
John Holland | c55bf10 | 2009-08-19 13:24:03 -1000 | [diff] [blame] | 128 | |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 129 | return 0; |
John Holland | c55bf10 | 2009-08-19 13:24:03 -1000 | [diff] [blame] | 130 | } |
| 131 | subsys_initcall(ts219_pci_init); |
| 132 | |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 133 | MACHINE_START(TS219, "QNAP TS-119/TS-219") |
| 134 | /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ |
Nicolas Pitre | 1b7bd28 | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 135 | .atag_offset = 0x100, |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 136 | .init_machine = qnap_ts219_init, |
| 137 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 138 | .init_early = kirkwood_init_early, |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 139 | .init_irq = kirkwood_init_irq, |
| 140 | .timer = &kirkwood_timer, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 141 | .restart = kirkwood_restart, |
Martin Michlmayr | 586dcf2 | 2009-03-22 15:22:11 +0100 | [diff] [blame] | 142 | MACHINE_END |