Path: blob/master/arch/arm/mach-orion5x/ts409-setup.c
10817 views
/*1* QNAP TS-409 Board Setup2*3* Maintainer: Sylver Bruneau <[email protected]>4*5* Copyright (C) 2008 Sylver Bruneau <[email protected]>6* Copyright (C) 2008 Martin Michlmayr <[email protected]>7*8* This program is free software; you can redistribute it and/or9* modify it under the terms of the GNU General Public License10* as published by the Free Software Foundation; either version11* 2 of the License, or (at your option) any later version.12*/1314#include <linux/kernel.h>15#include <linux/init.h>16#include <linux/platform_device.h>17#include <linux/pci.h>18#include <linux/irq.h>19#include <linux/mtd/physmap.h>20#include <linux/mv643xx_eth.h>21#include <linux/leds.h>22#include <linux/gpio_keys.h>23#include <linux/input.h>24#include <linux/i2c.h>25#include <linux/serial_reg.h>26#include <asm/mach-types.h>27#include <asm/gpio.h>28#include <asm/mach/arch.h>29#include <asm/mach/pci.h>30#include <mach/orion5x.h>31#include "common.h"32#include "mpp.h"33#include "tsx09-common.h"3435/*****************************************************************************36* QNAP TS-409 Info37****************************************************************************/3839/*40* QNAP TS-409 hardware :41* - Marvell 88F5281-D042* - Marvell 88SX7042 SATA controller (PCIe)43* - Marvell 88E1118 Gigabit Ethernet PHY44* - RTC S35390A (@0x30) on I2C bus45* - 8MB NOR flash46* - 256MB of DDR-2 RAM47*/4849/*50* 8MB NOR flash Device bus boot chip select51*/5253#define QNAP_TS409_NOR_BOOT_BASE 0xff80000054#define QNAP_TS409_NOR_BOOT_SIZE SZ_8M5556/****************************************************************************57* 8MiB NOR flash. The struct mtd_partition is not in the same order as the58* partitions on the device because we want to keep compatibility with59* existing QNAP firmware.60*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***************************************************************************/69static struct mtd_partition qnap_ts409_partitions[] = {70{71.name = "U-Boot",72.size = 0x00080000,73.offset = 0x00780000,74.mask_flags = MTD_WRITEABLE,75}, {76.name = "Kernel",77.size = 0x00200000,78.offset = 0,79}, {80.name = "RootFS1",81.size = 0x00400000,82.offset = 0x00200000,83}, {84.name = "RootFS2",85.size = 0x00100000,86.offset = 0x00600000,87}, {88.name = "U-Boot Config",89.size = 0x00020000,90.offset = 0x00760000,91}, {92.name = "NAS Config",93.size = 0x00060000,94.offset = 0x00700000,95.mask_flags = MTD_WRITEABLE,96},97};9899static struct physmap_flash_data qnap_ts409_nor_flash_data = {100.width = 1,101.parts = qnap_ts409_partitions,102.nr_parts = ARRAY_SIZE(qnap_ts409_partitions)103};104105static 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,109};110111static struct platform_device qnap_ts409_nor_flash = {112.name = "physmap-flash",113.id = 0,114.dev = { .platform_data = &qnap_ts409_nor_flash_data, },115.num_resources = 1,116.resource = &qnap_ts409_nor_flash_resource,117};118119/*****************************************************************************120* PCI121****************************************************************************/122123static int __init qnap_ts409_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)124{125int irq;126127/*128* Check for devices with hard-wired IRQs.129*/130irq = orion5x_pci_map_irq(dev, slot, pin);131if (irq != -1)132return irq;133134/*135* PCI isn't used on the TS-409136*/137return -1;138}139140static struct hw_pci qnap_ts409_pci __initdata = {141.nr_controllers = 2,142.swizzle = pci_std_swizzle,143.setup = orion5x_pci_sys_setup,144.scan = orion5x_pci_sys_scan_bus,145.map_irq = qnap_ts409_pci_map_irq,146};147148static int __init qnap_ts409_pci_init(void)149{150if (machine_is_ts409())151pci_common_init(&qnap_ts409_pci);152153return 0;154}155156subsys_initcall(qnap_ts409_pci_init);157158/*****************************************************************************159* RTC S35390A on I2C bus160****************************************************************************/161162#define TS409_RTC_GPIO 10163164static struct i2c_board_info __initdata qnap_ts409_i2c_rtc = {165I2C_BOARD_INFO("s35390a", 0x30),166};167168/*****************************************************************************169* LEDs attached to GPIO170****************************************************************************/171172static struct gpio_led ts409_led_pins[] = {173{174.name = "ts409:red:sata1",175.gpio = 4,176.active_low = 1,177}, {178.name = "ts409:red:sata2",179.gpio = 5,180.active_low = 1,181}, {182.name = "ts409:red:sata3",183.gpio = 6,184.active_low = 1,185}, {186.name = "ts409:red:sata4",187.gpio = 7,188.active_low = 1,189},190};191192static struct gpio_led_platform_data ts409_led_data = {193.leds = ts409_led_pins,194.num_leds = ARRAY_SIZE(ts409_led_pins),195};196197static struct platform_device ts409_leds = {198.name = "leds-gpio",199.id = -1,200.dev = {201.platform_data = &ts409_led_data,202},203};204205/****************************************************************************206* GPIO Attached Keys207* Power button is attached to the PIC microcontroller208****************************************************************************/209210#define QNAP_TS409_GPIO_KEY_RESET 14211#define QNAP_TS409_GPIO_KEY_MEDIA 15212213static struct gpio_keys_button qnap_ts409_buttons[] = {214{215.code = KEY_RESTART,216.gpio = QNAP_TS409_GPIO_KEY_RESET,217.desc = "Reset Button",218.active_low = 1,219}, {220.code = KEY_COPY,221.gpio = QNAP_TS409_GPIO_KEY_MEDIA,222.desc = "USB Copy Button",223.active_low = 1,224},225};226227static struct gpio_keys_platform_data qnap_ts409_button_data = {228.buttons = qnap_ts409_buttons,229.nbuttons = ARRAY_SIZE(qnap_ts409_buttons),230};231232static struct platform_device qnap_ts409_button_device = {233.name = "gpio-keys",234.id = -1,235.num_resources = 0,236.dev = {237.platform_data = &qnap_ts409_button_data,238},239};240241/*****************************************************************************242* General Setup243****************************************************************************/244static unsigned int ts409_mpp_modes[] __initdata = {245MPP0_UNUSED,246MPP1_UNUSED,247MPP2_UNUSED,248MPP3_UNUSED,249MPP4_GPIO, /* HDD 1 status */250MPP5_GPIO, /* HDD 2 status */251MPP6_GPIO, /* HDD 3 status */252MPP7_GPIO, /* HDD 4 status */253MPP8_UNUSED,254MPP9_UNUSED,255MPP10_GPIO, /* RTC int */256MPP11_UNUSED,257MPP12_UNUSED,258MPP13_UNUSED,259MPP14_GPIO, /* SW_RST */260MPP15_GPIO, /* USB copy button */261MPP16_UART, /* UART1 RXD */262MPP17_UART, /* UART1 TXD */263MPP18_UNUSED,264MPP19_UNUSED,2650,266};267268static void __init qnap_ts409_init(void)269{270/*271* Setup basic Orion functions. Need to be called early.272*/273orion5x_init();274275orion5x_mpp_conf(ts409_mpp_modes);276277/*278* Configure peripherals.279*/280orion5x_setup_dev_boot_win(QNAP_TS409_NOR_BOOT_BASE,281QNAP_TS409_NOR_BOOT_SIZE);282platform_device_register(&qnap_ts409_nor_flash);283284orion5x_ehci0_init();285qnap_tsx09_find_mac_addr(QNAP_TS409_NOR_BOOT_BASE +286qnap_ts409_partitions[5].offset,287qnap_ts409_partitions[5].size);288orion5x_eth_init(&qnap_tsx09_eth_data);289orion5x_i2c_init();290orion5x_uart0_init();291orion5x_uart1_init();292293platform_device_register(&qnap_ts409_button_device);294295/* Get RTC IRQ and register the chip */296if (gpio_request(TS409_RTC_GPIO, "rtc") == 0) {297if (gpio_direction_input(TS409_RTC_GPIO) == 0)298qnap_ts409_i2c_rtc.irq = gpio_to_irq(TS409_RTC_GPIO);299else300gpio_free(TS409_RTC_GPIO);301}302if (qnap_ts409_i2c_rtc.irq == 0)303pr_warning("qnap_ts409_init: failed to get RTC IRQ\n");304i2c_register_board_info(0, &qnap_ts409_i2c_rtc, 1);305platform_device_register(&ts409_leds);306307/* register tsx09 specific power-off method */308pm_power_off = qnap_tsx09_power_off;309}310311MACHINE_START(TS409, "QNAP TS-409")312/* Maintainer: Sylver Bruneau <[email protected]> */313.boot_params = 0x00000100,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.timer = &orion5x_timer,319.fixup = tag_fixup_mem32,320MACHINE_END321322323