Path: blob/master/arch/arm/mach-kirkwood/netspace_v2-setup.c
10817 views
/*1* arch/arm/mach-kirkwood/netspace_v2-setup.c2*3* LaCie Network Space v2 board setup4*5* Copyright (C) 2009 Simon Guinot <[email protected]>6* Copyright (C) 2009 Benoît Canet <[email protected]>7*8* This program is free software; you can redistribute it and/or modify9* it under the terms of the GNU General Public License as published by10* the Free Software Foundation; either version 2 of the License, or11* (at your option) any later version.12*13* This program is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16* GNU General Public License for more details.17*18* You should have received a copy of the GNU General Public License19* along with this program; if not, write to the Free Software20* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA21*/2223#include <linux/kernel.h>24#include <linux/init.h>25#include <linux/platform_device.h>26#include <linux/ata_platform.h>27#include <linux/mv643xx_eth.h>28#include <linux/input.h>29#include <linux/gpio.h>30#include <linux/gpio_keys.h>31#include <linux/leds.h>32#include <linux/gpio-fan.h>33#include <asm/mach-types.h>34#include <asm/mach/arch.h>35#include <mach/kirkwood.h>36#include <mach/leds-ns2.h>37#include "common.h"38#include "mpp.h"39#include "lacie_v2-common.h"4041/*****************************************************************************42* Ethernet43****************************************************************************/4445static struct mv643xx_eth_platform_data netspace_v2_ge00_data = {46.phy_addr = MV643XX_ETH_PHY_ADDR(8),47};4849/*****************************************************************************50* SATA51****************************************************************************/5253static struct mv_sata_platform_data netspace_v2_sata_data = {54.n_ports = 2,55};5657/*****************************************************************************58* GPIO keys59****************************************************************************/6061#define NETSPACE_V2_PUSH_BUTTON 326263static struct gpio_keys_button netspace_v2_buttons[] = {64[0] = {65.code = KEY_POWER,66.gpio = NETSPACE_V2_PUSH_BUTTON,67.desc = "Power push button",68.active_low = 0,69},70};7172static struct gpio_keys_platform_data netspace_v2_button_data = {73.buttons = netspace_v2_buttons,74.nbuttons = ARRAY_SIZE(netspace_v2_buttons),75};7677static struct platform_device netspace_v2_gpio_buttons = {78.name = "gpio-keys",79.id = -1,80.dev = {81.platform_data = &netspace_v2_button_data,82},83};8485/*****************************************************************************86* GPIO LEDs87****************************************************************************/8889#define NETSPACE_V2_GPIO_RED_LED 129091static struct gpio_led netspace_v2_gpio_led_pins[] = {92{93.name = "ns_v2:red:fail",94.gpio = NETSPACE_V2_GPIO_RED_LED,95},96};9798static struct gpio_led_platform_data netspace_v2_gpio_leds_data = {99.num_leds = ARRAY_SIZE(netspace_v2_gpio_led_pins),100.leds = netspace_v2_gpio_led_pins,101};102103static struct platform_device netspace_v2_gpio_leds = {104.name = "leds-gpio",105.id = -1,106.dev = {107.platform_data = &netspace_v2_gpio_leds_data,108},109};110111/*****************************************************************************112* Dual-GPIO CPLD LEDs113****************************************************************************/114115#define NETSPACE_V2_GPIO_BLUE_LED_SLOW 29116#define NETSPACE_V2_GPIO_BLUE_LED_CMD 30117118static struct ns2_led netspace_v2_led_pins[] = {119{120.name = "ns_v2:blue:sata",121.cmd = NETSPACE_V2_GPIO_BLUE_LED_CMD,122.slow = NETSPACE_V2_GPIO_BLUE_LED_SLOW,123},124};125126static struct ns2_led_platform_data netspace_v2_leds_data = {127.num_leds = ARRAY_SIZE(netspace_v2_led_pins),128.leds = netspace_v2_led_pins,129};130131static struct platform_device netspace_v2_leds = {132.name = "leds-ns2",133.id = -1,134.dev = {135.platform_data = &netspace_v2_leds_data,136},137};138139/*****************************************************************************140* GPIO fan141****************************************************************************/142143/* Designed for fan 40x40x16: ADDA AD0412LB-D50 6000rpm@12v */144static struct gpio_fan_speed netspace_max_v2_fan_speed[] = {145{ 0, 0 },146{ 1500, 15 },147{ 1700, 14 },148{ 1800, 13 },149{ 2100, 12 },150{ 3100, 11 },151{ 3300, 10 },152{ 4300, 9 },153{ 5500, 8 },154};155156static unsigned netspace_max_v2_fan_ctrl[] = { 22, 7, 33, 23 };157158static struct gpio_fan_alarm netspace_max_v2_fan_alarm = {159.gpio = 25,160.active_low = 1,161};162163static struct gpio_fan_platform_data netspace_max_v2_fan_data = {164.num_ctrl = ARRAY_SIZE(netspace_max_v2_fan_ctrl),165.ctrl = netspace_max_v2_fan_ctrl,166.alarm = &netspace_max_v2_fan_alarm,167.num_speed = ARRAY_SIZE(netspace_max_v2_fan_speed),168.speed = netspace_max_v2_fan_speed,169};170171static struct platform_device netspace_max_v2_gpio_fan = {172.name = "gpio-fan",173.id = -1,174.dev = {175.platform_data = &netspace_max_v2_fan_data,176},177};178179/*****************************************************************************180* General Setup181****************************************************************************/182183static unsigned int netspace_v2_mpp_config[] __initdata = {184MPP0_SPI_SCn,185MPP1_SPI_MOSI,186MPP2_SPI_SCK,187MPP3_SPI_MISO,188MPP4_NF_IO6,189MPP5_NF_IO7,190MPP6_SYSRST_OUTn,191MPP7_GPO, /* Fan speed (bit 1) */192MPP8_TW0_SDA,193MPP9_TW0_SCK,194MPP10_UART0_TXD,195MPP11_UART0_RXD,196MPP12_GPO, /* Red led */197MPP14_GPIO, /* USB fuse */198MPP16_GPIO, /* SATA 0 power */199MPP17_GPIO, /* SATA 1 power */200MPP18_NF_IO0,201MPP19_NF_IO1,202MPP20_SATA1_ACTn,203MPP21_SATA0_ACTn,204MPP22_GPIO, /* Fan speed (bit 0) */205MPP23_GPIO, /* Fan power */206MPP24_GPIO, /* USB mode select */207MPP25_GPIO, /* Fan rotation fail */208MPP26_GPIO, /* USB device vbus */209MPP28_GPIO, /* USB enable host vbus */210MPP29_GPIO, /* Blue led (slow register) */211MPP30_GPIO, /* Blue led (command register) */212MPP31_GPIO, /* Board power off */213MPP32_GPIO, /* Power button (0 = Released, 1 = Pushed) */214MPP33_GPO, /* Fan speed (bit 2) */2150216};217218#define NETSPACE_V2_GPIO_POWER_OFF 31219220static void netspace_v2_power_off(void)221{222gpio_set_value(NETSPACE_V2_GPIO_POWER_OFF, 1);223}224225static void __init netspace_v2_init(void)226{227/*228* Basic setup. Needs to be called early.229*/230kirkwood_init();231kirkwood_mpp_conf(netspace_v2_mpp_config);232233if (machine_is_netspace_max_v2())234lacie_v2_hdd_power_init(2);235else236lacie_v2_hdd_power_init(1);237238kirkwood_ehci_init();239kirkwood_ge00_init(&netspace_v2_ge00_data);240kirkwood_sata_init(&netspace_v2_sata_data);241kirkwood_uart0_init();242lacie_v2_register_flash();243lacie_v2_register_i2c_devices();244245platform_device_register(&netspace_v2_leds);246platform_device_register(&netspace_v2_gpio_leds);247platform_device_register(&netspace_v2_gpio_buttons);248if (machine_is_netspace_max_v2())249platform_device_register(&netspace_max_v2_gpio_fan);250251if (gpio_request(NETSPACE_V2_GPIO_POWER_OFF, "power-off") == 0 &&252gpio_direction_output(NETSPACE_V2_GPIO_POWER_OFF, 0) == 0)253pm_power_off = netspace_v2_power_off;254else255pr_err("netspace_v2: failed to configure power-off GPIO\n");256}257258#ifdef CONFIG_MACH_NETSPACE_V2259MACHINE_START(NETSPACE_V2, "LaCie Network Space v2")260.boot_params = 0x00000100,261.init_machine = netspace_v2_init,262.map_io = kirkwood_map_io,263.init_early = kirkwood_init_early,264.init_irq = kirkwood_init_irq,265.timer = &kirkwood_timer,266MACHINE_END267#endif268269#ifdef CONFIG_MACH_INETSPACE_V2270MACHINE_START(INETSPACE_V2, "LaCie Internet Space v2")271.boot_params = 0x00000100,272.init_machine = netspace_v2_init,273.map_io = kirkwood_map_io,274.init_early = kirkwood_init_early,275.init_irq = kirkwood_init_irq,276.timer = &kirkwood_timer,277MACHINE_END278#endif279280#ifdef CONFIG_MACH_NETSPACE_MAX_V2281MACHINE_START(NETSPACE_MAX_V2, "LaCie Network Space Max v2")282.boot_params = 0x00000100,283.init_machine = netspace_v2_init,284.map_io = kirkwood_map_io,285.init_early = kirkwood_init_early,286.init_irq = kirkwood_init_irq,287.timer = &kirkwood_timer,288MACHINE_END289#endif290291292