Path: blob/master/arch/arm/mach-kirkwood/ts41x-setup.c
10817 views
/*1*2* QNAP TS-410, TS-410U, TS-419P and TS-419U Turbo NAS Board Setup3*4* Copyright (C) 2009-2010 Martin Michlmayr <[email protected]>5* Copyright (C) 2008 Byron Bradley <[email protected]>6*7* This program is free software; you can redistribute it and/or8* modify it under the terms of the GNU General Public License9* as published by the Free Software Foundation; either version10* 2 of the License, or (at your option) any later version.11*/1213#include <linux/kernel.h>14#include <linux/init.h>15#include <linux/platform_device.h>16#include <linux/i2c.h>17#include <linux/mv643xx_eth.h>18#include <linux/ata_platform.h>19#include <linux/gpio.h>20#include <linux/gpio_keys.h>21#include <linux/input.h>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"27#include "tsx1x-common.h"2829/* for the PCIe reset workaround */30#include <plat/pcie.h>313233#define QNAP_TS41X_JUMPER_JP1 453435static struct i2c_board_info __initdata qnap_ts41x_i2c_rtc = {36I2C_BOARD_INFO("s35390a", 0x30),37};3839static struct mv643xx_eth_platform_data qnap_ts41x_ge00_data = {40.phy_addr = MV643XX_ETH_PHY_ADDR(8),41};4243static struct mv643xx_eth_platform_data qnap_ts41x_ge01_data = {44.phy_addr = MV643XX_ETH_PHY_ADDR(0),45};4647static struct mv_sata_platform_data qnap_ts41x_sata_data = {48.n_ports = 2,49};5051static struct gpio_keys_button qnap_ts41x_buttons[] = {52{53.code = KEY_COPY,54.gpio = 43,55.desc = "USB Copy",56.active_low = 1,57},58{59.code = KEY_RESTART,60.gpio = 37,61.desc = "Reset",62.active_low = 1,63},64};6566static struct gpio_keys_platform_data qnap_ts41x_button_data = {67.buttons = qnap_ts41x_buttons,68.nbuttons = ARRAY_SIZE(qnap_ts41x_buttons),69};7071static struct platform_device qnap_ts41x_button_device = {72.name = "gpio-keys",73.id = -1,74.num_resources = 0,75.dev = {76.platform_data = &qnap_ts41x_button_data,77}78};7980static unsigned int qnap_ts41x_mpp_config[] __initdata = {81MPP0_SPI_SCn,82MPP1_SPI_MOSI,83MPP2_SPI_SCK,84MPP3_SPI_MISO,85MPP6_SYSRST_OUTn,86MPP7_PEX_RST_OUTn,87MPP8_TW0_SDA,88MPP9_TW0_SCK,89MPP10_UART0_TXD,90MPP11_UART0_RXD,91MPP13_UART1_TXD, /* PIC controller */92MPP14_UART1_RXD, /* PIC controller */93MPP15_SATA0_ACTn,94MPP16_SATA1_ACTn,95MPP20_GE1_TXD0,96MPP21_GE1_TXD1,97MPP22_GE1_TXD2,98MPP23_GE1_TXD3,99MPP24_GE1_RXD0,100MPP25_GE1_RXD1,101MPP26_GE1_RXD2,102MPP27_GE1_RXD3,103MPP30_GE1_RXCTL,104MPP31_GE1_RXCLK,105MPP32_GE1_TCLKOUT,106MPP33_GE1_TXCTL,107MPP36_GPIO, /* RAM: 0: 256 MB, 1: 512 MB */108MPP37_GPIO, /* Reset button */109MPP43_GPIO, /* USB Copy button */110MPP44_GPIO, /* Board ID: 0: TS-419U, 1: TS-419 */111MPP45_GPIO, /* JP1: 0: LCD, 1: serial console */112MPP46_GPIO, /* External SATA HDD1 error indicator */113MPP47_GPIO, /* External SATA HDD2 error indicator */114MPP48_GPIO, /* External SATA HDD3 error indicator */115MPP49_GPIO, /* External SATA HDD4 error indicator */1160117};118119static void __init qnap_ts41x_init(void)120{121u32 dev, rev;122123/*124* Basic setup. Needs to be called early.125*/126kirkwood_init();127kirkwood_mpp_conf(qnap_ts41x_mpp_config);128129kirkwood_uart0_init();130kirkwood_uart1_init(); /* A PIC controller is connected here. */131qnap_tsx1x_register_flash();132kirkwood_i2c_init();133i2c_register_board_info(0, &qnap_ts41x_i2c_rtc, 1);134135kirkwood_pcie_id(&dev, &rev);136if (dev == MV88F6282_DEV_ID) {137qnap_ts41x_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0);138qnap_ts41x_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1);139}140kirkwood_ge00_init(&qnap_ts41x_ge00_data);141kirkwood_ge01_init(&qnap_ts41x_ge01_data);142143kirkwood_sata_init(&qnap_ts41x_sata_data);144kirkwood_ehci_init();145platform_device_register(&qnap_ts41x_button_device);146147pm_power_off = qnap_tsx1x_power_off;148149if (gpio_request(QNAP_TS41X_JUMPER_JP1, "JP1") == 0)150gpio_export(QNAP_TS41X_JUMPER_JP1, 0);151}152153static int __init ts41x_pci_init(void)154{155if (machine_is_ts41x()) {156u32 dev, rev;157158/*159* Without this explicit reset, the PCIe SATA controller160* (Marvell 88sx7042/sata_mv) is known to stop working161* after a few minutes.162*/163orion_pcie_reset((void __iomem *)PCIE_VIRT_BASE);164165kirkwood_pcie_id(&dev, &rev);166if (dev == MV88F6282_DEV_ID)167kirkwood_pcie_init(KW_PCIE1 | KW_PCIE0);168else169kirkwood_pcie_init(KW_PCIE0);170}171172return 0;173}174subsys_initcall(ts41x_pci_init);175176MACHINE_START(TS41X, "QNAP TS-41x")177/* Maintainer: Martin Michlmayr <[email protected]> */178.boot_params = 0x00000100,179.init_machine = qnap_ts41x_init,180.map_io = kirkwood_map_io,181.init_early = kirkwood_init_early,182.init_irq = kirkwood_init_irq,183.timer = &kirkwood_timer,184MACHINE_END185186187