Path: blob/master/arch/arm/mach-kirkwood/d2net_v2-setup.c
10819 views
/*1* arch/arm/mach-kirkwood/d2net_v2-setup.c2*3* LaCie d2 Network Space v2 Board Setup4*5* Copyright (C) 2010 Simon Guinot <[email protected]>6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or10* (at your option) any later version.11*12* This program is distributed in the hope that it will be useful,13* but WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15* GNU General Public License for more details.16*17* You should have received a copy of the GNU General Public License18* along with this program; if not, write to the Free Software19* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA20*/2122#include <linux/kernel.h>23#include <linux/init.h>24#include <linux/platform_device.h>25#include <linux/ata_platform.h>26#include <linux/mv643xx_eth.h>27#include <linux/input.h>28#include <linux/gpio.h>29#include <linux/gpio_keys.h>30#include <linux/leds.h>31#include <asm/mach-types.h>32#include <asm/mach/arch.h>33#include <mach/kirkwood.h>34#include <mach/leds-ns2.h>35#include "common.h"36#include "mpp.h"37#include "lacie_v2-common.h"3839/*****************************************************************************40* Ethernet41****************************************************************************/4243static struct mv643xx_eth_platform_data d2net_v2_ge00_data = {44.phy_addr = MV643XX_ETH_PHY_ADDR(8),45};4647/*****************************************************************************48* SATA49****************************************************************************/5051static struct mv_sata_platform_data d2net_v2_sata_data = {52.n_ports = 2,53};5455/*****************************************************************************56* GPIO keys57****************************************************************************/5859#define D2NET_V2_GPIO_PUSH_BUTTON 3460#define D2NET_V2_GPIO_POWER_SWITCH_ON 1361#define D2NET_V2_GPIO_POWER_SWITCH_OFF 156263#define D2NET_V2_SWITCH_POWER_ON 0x164#define D2NET_V2_SWITCH_POWER_OFF 0x26566static struct gpio_keys_button d2net_v2_buttons[] = {67[0] = {68.type = EV_SW,69.code = D2NET_V2_SWITCH_POWER_ON,70.gpio = D2NET_V2_GPIO_POWER_SWITCH_ON,71.desc = "Back power switch (on|auto)",72.active_low = 0,73},74[1] = {75.type = EV_SW,76.code = D2NET_V2_SWITCH_POWER_OFF,77.gpio = D2NET_V2_GPIO_POWER_SWITCH_OFF,78.desc = "Back power switch (auto|off)",79.active_low = 0,80},81[2] = {82.code = KEY_POWER,83.gpio = D2NET_V2_GPIO_PUSH_BUTTON,84.desc = "Front Push Button",85.active_low = 1,86},87};8889static struct gpio_keys_platform_data d2net_v2_button_data = {90.buttons = d2net_v2_buttons,91.nbuttons = ARRAY_SIZE(d2net_v2_buttons),92};9394static struct platform_device d2net_v2_gpio_buttons = {95.name = "gpio-keys",96.id = -1,97.dev = {98.platform_data = &d2net_v2_button_data,99},100};101102/*****************************************************************************103* GPIO LEDs104****************************************************************************/105106#define D2NET_V2_GPIO_RED_LED 12107108static struct gpio_led d2net_v2_gpio_led_pins[] = {109{110.name = "d2net_v2:red:fail",111.gpio = D2NET_V2_GPIO_RED_LED,112},113};114115static struct gpio_led_platform_data d2net_v2_gpio_leds_data = {116.num_leds = ARRAY_SIZE(d2net_v2_gpio_led_pins),117.leds = d2net_v2_gpio_led_pins,118};119120static struct platform_device d2net_v2_gpio_leds = {121.name = "leds-gpio",122.id = -1,123.dev = {124.platform_data = &d2net_v2_gpio_leds_data,125},126};127128/*****************************************************************************129* Dual-GPIO CPLD LEDs130****************************************************************************/131132#define D2NET_V2_GPIO_BLUE_LED_SLOW 29133#define D2NET_V2_GPIO_BLUE_LED_CMD 30134135static struct ns2_led d2net_v2_led_pins[] = {136{137.name = "d2net_v2:blue:sata",138.cmd = D2NET_V2_GPIO_BLUE_LED_CMD,139.slow = D2NET_V2_GPIO_BLUE_LED_SLOW,140},141};142143static struct ns2_led_platform_data d2net_v2_leds_data = {144.num_leds = ARRAY_SIZE(d2net_v2_led_pins),145.leds = d2net_v2_led_pins,146};147148static struct platform_device d2net_v2_leds = {149.name = "leds-ns2",150.id = -1,151.dev = {152.platform_data = &d2net_v2_leds_data,153},154};155156/*****************************************************************************157* General Setup158****************************************************************************/159160static unsigned int d2net_v2_mpp_config[] __initdata = {161MPP0_SPI_SCn,162MPP1_SPI_MOSI,163MPP2_SPI_SCK,164MPP3_SPI_MISO,165MPP6_SYSRST_OUTn,166MPP7_GPO, /* Request power-off */167MPP8_TW0_SDA,168MPP9_TW0_SCK,169MPP10_UART0_TXD,170MPP11_UART0_RXD,171MPP12_GPO, /* Red led */172MPP13_GPIO, /* Rear power switch (on|auto) */173MPP14_GPIO, /* USB fuse */174MPP15_GPIO, /* Rear power switch (auto|off) */175MPP16_GPIO, /* SATA 0 power */176MPP21_SATA0_ACTn,177MPP24_GPIO, /* USB mode select */178MPP26_GPIO, /* USB device vbus */179MPP28_GPIO, /* USB enable host vbus */180MPP29_GPIO, /* Blue led (slow register) */181MPP30_GPIO, /* Blue led (command register) */182MPP34_GPIO, /* Power button (1 = Released, 0 = Pushed) */183MPP35_GPIO, /* Inhibit power-off */1840185};186187#define D2NET_V2_GPIO_POWER_OFF 7188189static void d2net_v2_power_off(void)190{191gpio_set_value(D2NET_V2_GPIO_POWER_OFF, 1);192}193194static void __init d2net_v2_init(void)195{196/*197* Basic setup. Needs to be called early.198*/199kirkwood_init();200kirkwood_mpp_conf(d2net_v2_mpp_config);201202lacie_v2_hdd_power_init(1);203204kirkwood_ehci_init();205kirkwood_ge00_init(&d2net_v2_ge00_data);206kirkwood_sata_init(&d2net_v2_sata_data);207kirkwood_uart0_init();208lacie_v2_register_flash();209lacie_v2_register_i2c_devices();210211platform_device_register(&d2net_v2_leds);212platform_device_register(&d2net_v2_gpio_leds);213platform_device_register(&d2net_v2_gpio_buttons);214215if (gpio_request(D2NET_V2_GPIO_POWER_OFF, "power-off") == 0 &&216gpio_direction_output(D2NET_V2_GPIO_POWER_OFF, 0) == 0)217pm_power_off = d2net_v2_power_off;218else219pr_err("d2net_v2: failed to configure power-off GPIO\n");220}221222MACHINE_START(D2NET_V2, "LaCie d2 Network v2")223.boot_params = 0x00000100,224.init_machine = d2net_v2_init,225.map_io = kirkwood_map_io,226.init_early = kirkwood_init_early,227.init_irq = kirkwood_init_irq,228.timer = &kirkwood_timer,229MACHINE_END230231232