Path: blob/master/arch/arm/mach-kirkwood/netxbig_v2-setup.c
10819 views
/*1* arch/arm/mach-kirkwood/netxbig_v2-setup.c2*3* LaCie 2Big and 5Big Network 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-netxbig.h>35#include "common.h"36#include "mpp.h"37#include "lacie_v2-common.h"3839/*****************************************************************************40* Ethernet41****************************************************************************/4243static struct mv643xx_eth_platform_data netxbig_v2_ge00_data = {44.phy_addr = MV643XX_ETH_PHY_ADDR(8),45};4647static struct mv643xx_eth_platform_data netxbig_v2_ge01_data = {48.phy_addr = MV643XX_ETH_PHY_ADDR(0),49};5051/*****************************************************************************52* SATA53****************************************************************************/5455static struct mv_sata_platform_data netxbig_v2_sata_data = {56.n_ports = 2,57};5859/*****************************************************************************60* GPIO keys61****************************************************************************/6263#define NETXBIG_V2_GPIO_SWITCH_POWER_ON 1364#define NETXBIG_V2_GPIO_SWITCH_POWER_OFF 1565#define NETXBIG_V2_GPIO_FUNC_BUTTON 346667#define NETXBIG_V2_SWITCH_POWER_ON 0x168#define NETXBIG_V2_SWITCH_POWER_OFF 0x26970static struct gpio_keys_button netxbig_v2_buttons[] = {71[0] = {72.type = EV_SW,73.code = NETXBIG_V2_SWITCH_POWER_ON,74.gpio = NETXBIG_V2_GPIO_SWITCH_POWER_ON,75.desc = "Back power switch (on|auto)",76.active_low = 1,77},78[1] = {79.type = EV_SW,80.code = NETXBIG_V2_SWITCH_POWER_OFF,81.gpio = NETXBIG_V2_GPIO_SWITCH_POWER_OFF,82.desc = "Back power switch (auto|off)",83.active_low = 1,84},85[2] = {86.code = KEY_OPTION,87.gpio = NETXBIG_V2_GPIO_FUNC_BUTTON,88.desc = "Function button",89.active_low = 1,90},91};9293static struct gpio_keys_platform_data netxbig_v2_button_data = {94.buttons = netxbig_v2_buttons,95.nbuttons = ARRAY_SIZE(netxbig_v2_buttons),96};9798static struct platform_device netxbig_v2_gpio_buttons = {99.name = "gpio-keys",100.id = -1,101.dev = {102.platform_data = &netxbig_v2_button_data,103},104};105106/*****************************************************************************107* GPIO extension LEDs108****************************************************************************/109110/*111* The LEDs are controlled by a CPLD and can be configured through a GPIO112* extension bus:113*114* - address register : bit [0-2] -> GPIO [47-49]115* - data register : bit [0-2] -> GPIO [44-46]116* - enable register : GPIO 29117*/118119static int netxbig_v2_gpio_ext_addr[] = { 47, 48, 49 };120static int netxbig_v2_gpio_ext_data[] = { 44, 45, 46 };121122static struct netxbig_gpio_ext netxbig_v2_gpio_ext = {123.addr = netxbig_v2_gpio_ext_addr,124.num_addr = ARRAY_SIZE(netxbig_v2_gpio_ext_addr),125.data = netxbig_v2_gpio_ext_data,126.num_data = ARRAY_SIZE(netxbig_v2_gpio_ext_data),127.enable = 29,128};129130/*131* Address register selection:132*133* addr | register134* ----------------------------135* 0 | front LED136* 1 | front LED brightness137* 2 | SATA LED brightness138* 3 | SATA0 LED139* 4 | SATA1 LED140* 5 | SATA2 LED141* 6 | SATA3 LED142* 7 | SATA4 LED143*144* Data register configuration:145*146* data | LED brightness147* -------------------------------------------------148* 0 | min (off)149* - | -150* 7 | max151*152* data | front LED mode153* -------------------------------------------------154* 0 | fix off155* 1 | fix blue on156* 2 | fix red on157* 3 | blink blue on=1 sec and blue off=1 sec158* 4 | blink red on=1 sec and red off=1 sec159* 5 | blink blue on=2.5 sec and red on=0.5 sec160* 6 | blink blue on=1 sec and red on=1 sec161* 7 | blink blue on=0.5 sec and blue off=2.5 sec162*163* data | SATA LED mode164* -------------------------------------------------165* 0 | fix off166* 1 | SATA activity blink167* 2 | fix red on168* 3 | blink blue on=1 sec and blue off=1 sec169* 4 | blink red on=1 sec and red off=1 sec170* 5 | blink blue on=2.5 sec and red on=0.5 sec171* 6 | blink blue on=1 sec and red on=1 sec172* 7 | fix blue on173*/174175static int netxbig_v2_red_mled[NETXBIG_LED_MODE_NUM] = {176[NETXBIG_LED_OFF] = 0,177[NETXBIG_LED_ON] = 2,178[NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,179[NETXBIG_LED_TIMER1] = 4,180[NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,181};182183static int netxbig_v2_blue_pwr_mled[NETXBIG_LED_MODE_NUM] = {184[NETXBIG_LED_OFF] = 0,185[NETXBIG_LED_ON] = 1,186[NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,187[NETXBIG_LED_TIMER1] = 3,188[NETXBIG_LED_TIMER2] = 7,189};190191static int netxbig_v2_blue_sata_mled[NETXBIG_LED_MODE_NUM] = {192[NETXBIG_LED_OFF] = 0,193[NETXBIG_LED_ON] = 7,194[NETXBIG_LED_SATA] = 1,195[NETXBIG_LED_TIMER1] = 3,196[NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,197};198199static struct netxbig_led_timer netxbig_v2_led_timer[] = {200[0] = {201.delay_on = 500,202.delay_off = 500,203.mode = NETXBIG_LED_TIMER1,204},205[1] = {206.delay_on = 500,207.delay_off = 1000,208.mode = NETXBIG_LED_TIMER2,209},210};211212#define NETXBIG_LED(_name, maddr, mval, baddr) \213{ .name = _name, \214.mode_addr = maddr, \215.mode_val = mval, \216.bright_addr = baddr }217218static struct netxbig_led net2big_v2_leds_ctrl[] = {219NETXBIG_LED("net2big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),220NETXBIG_LED("net2big-v2:red:power", 0, netxbig_v2_red_mled, 1),221NETXBIG_LED("net2big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),222NETXBIG_LED("net2big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),223NETXBIG_LED("net2big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),224NETXBIG_LED("net2big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),225};226227static struct netxbig_led_platform_data net2big_v2_leds_data = {228.gpio_ext = &netxbig_v2_gpio_ext,229.timer = netxbig_v2_led_timer,230.num_timer = ARRAY_SIZE(netxbig_v2_led_timer),231.leds = net2big_v2_leds_ctrl,232.num_leds = ARRAY_SIZE(net2big_v2_leds_ctrl),233};234235static struct netxbig_led net5big_v2_leds_ctrl[] = {236NETXBIG_LED("net5big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),237NETXBIG_LED("net5big-v2:red:power", 0, netxbig_v2_red_mled, 1),238NETXBIG_LED("net5big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),239NETXBIG_LED("net5big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),240NETXBIG_LED("net5big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),241NETXBIG_LED("net5big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),242NETXBIG_LED("net5big-v2:blue:sata2", 5, netxbig_v2_blue_sata_mled, 2),243NETXBIG_LED("net5big-v2:red:sata2", 5, netxbig_v2_red_mled, 2),244NETXBIG_LED("net5big-v2:blue:sata3", 6, netxbig_v2_blue_sata_mled, 2),245NETXBIG_LED("net5big-v2:red:sata3", 6, netxbig_v2_red_mled, 2),246NETXBIG_LED("net5big-v2:blue:sata4", 7, netxbig_v2_blue_sata_mled, 2),247NETXBIG_LED("net5big-v2:red:sata5", 7, netxbig_v2_red_mled, 2),248};249250static struct netxbig_led_platform_data net5big_v2_leds_data = {251.gpio_ext = &netxbig_v2_gpio_ext,252.timer = netxbig_v2_led_timer,253.num_timer = ARRAY_SIZE(netxbig_v2_led_timer),254.leds = net5big_v2_leds_ctrl,255.num_leds = ARRAY_SIZE(net5big_v2_leds_ctrl),256};257258static struct platform_device netxbig_v2_leds = {259.name = "leds-netxbig",260.id = -1,261.dev = {262.platform_data = &net2big_v2_leds_data,263},264};265266/*****************************************************************************267* General Setup268****************************************************************************/269270static unsigned int net2big_v2_mpp_config[] __initdata = {271MPP0_SPI_SCn,272MPP1_SPI_MOSI,273MPP2_SPI_SCK,274MPP3_SPI_MISO,275MPP6_SYSRST_OUTn,276MPP7_GPO, /* Request power-off */277MPP8_TW0_SDA,278MPP9_TW0_SCK,279MPP10_UART0_TXD,280MPP11_UART0_RXD,281MPP13_GPIO, /* Rear power switch (on|auto) */282MPP14_GPIO, /* USB fuse alarm */283MPP15_GPIO, /* Rear power switch (auto|off) */284MPP16_GPIO, /* SATA HDD1 power */285MPP17_GPIO, /* SATA HDD2 power */286MPP20_SATA1_ACTn,287MPP21_SATA0_ACTn,288MPP24_GPIO, /* USB mode select */289MPP26_GPIO, /* USB device vbus */290MPP28_GPIO, /* USB enable host vbus */291MPP29_GPIO, /* GPIO extension ALE */292MPP34_GPIO, /* Rear Push button */293MPP35_GPIO, /* Inhibit switch power-off */294MPP36_GPIO, /* SATA HDD1 presence */295MPP37_GPIO, /* SATA HDD2 presence */296MPP40_GPIO, /* eSATA presence */297MPP44_GPIO, /* GPIO extension (data 0) */298MPP45_GPIO, /* GPIO extension (data 1) */299MPP46_GPIO, /* GPIO extension (data 2) */300MPP47_GPIO, /* GPIO extension (addr 0) */301MPP48_GPIO, /* GPIO extension (addr 1) */302MPP49_GPIO, /* GPIO extension (addr 2) */3030304};305306static unsigned int net5big_v2_mpp_config[] __initdata = {307MPP0_SPI_SCn,308MPP1_SPI_MOSI,309MPP2_SPI_SCK,310MPP3_SPI_MISO,311MPP6_SYSRST_OUTn,312MPP7_GPO, /* Request power-off */313MPP8_TW0_SDA,314MPP9_TW0_SCK,315MPP10_UART0_TXD,316MPP11_UART0_RXD,317MPP13_GPIO, /* Rear power switch (on|auto) */318MPP14_GPIO, /* USB fuse alarm */319MPP15_GPIO, /* Rear power switch (auto|off) */320MPP16_GPIO, /* SATA HDD1 power */321MPP17_GPIO, /* SATA HDD2 power */322MPP20_GE1_TXD0,323MPP21_GE1_TXD1,324MPP22_GE1_TXD2,325MPP23_GE1_TXD3,326MPP24_GE1_RXD0,327MPP25_GE1_RXD1,328MPP26_GE1_RXD2,329MPP27_GE1_RXD3,330MPP28_GPIO, /* USB enable host vbus */331MPP29_GPIO, /* GPIO extension ALE */332MPP30_GE1_RXCTL,333MPP31_GE1_RXCLK,334MPP32_GE1_TCLKOUT,335MPP33_GE1_TXCTL,336MPP34_GPIO, /* Rear Push button */337MPP35_GPIO, /* Inhibit switch power-off */338MPP36_GPIO, /* SATA HDD1 presence */339MPP37_GPIO, /* SATA HDD2 presence */340MPP38_GPIO, /* SATA HDD3 presence */341MPP39_GPIO, /* SATA HDD4 presence */342MPP40_GPIO, /* SATA HDD5 presence */343MPP41_GPIO, /* SATA HDD3 power */344MPP42_GPIO, /* SATA HDD4 power */345MPP43_GPIO, /* SATA HDD5 power */346MPP44_GPIO, /* GPIO extension (data 0) */347MPP45_GPIO, /* GPIO extension (data 1) */348MPP46_GPIO, /* GPIO extension (data 2) */349MPP47_GPIO, /* GPIO extension (addr 0) */350MPP48_GPIO, /* GPIO extension (addr 1) */351MPP49_GPIO, /* GPIO extension (addr 2) */3520353};354355#define NETXBIG_V2_GPIO_POWER_OFF 7356357static void netxbig_v2_power_off(void)358{359gpio_set_value(NETXBIG_V2_GPIO_POWER_OFF, 1);360}361362static void __init netxbig_v2_init(void)363{364/*365* Basic setup. Needs to be called early.366*/367kirkwood_init();368if (machine_is_net2big_v2())369kirkwood_mpp_conf(net2big_v2_mpp_config);370else371kirkwood_mpp_conf(net5big_v2_mpp_config);372373if (machine_is_net2big_v2())374lacie_v2_hdd_power_init(2);375else376lacie_v2_hdd_power_init(5);377378kirkwood_ehci_init();379kirkwood_ge00_init(&netxbig_v2_ge00_data);380if (machine_is_net5big_v2())381kirkwood_ge01_init(&netxbig_v2_ge01_data);382kirkwood_sata_init(&netxbig_v2_sata_data);383kirkwood_uart0_init();384lacie_v2_register_flash();385lacie_v2_register_i2c_devices();386387if (machine_is_net5big_v2())388netxbig_v2_leds.dev.platform_data = &net5big_v2_leds_data;389platform_device_register(&netxbig_v2_leds);390platform_device_register(&netxbig_v2_gpio_buttons);391392if (gpio_request(NETXBIG_V2_GPIO_POWER_OFF, "power-off") == 0 &&393gpio_direction_output(NETXBIG_V2_GPIO_POWER_OFF, 0) == 0)394pm_power_off = netxbig_v2_power_off;395else396pr_err("netxbig_v2: failed to configure power-off GPIO\n");397}398399#ifdef CONFIG_MACH_NET2BIG_V2400MACHINE_START(NET2BIG_V2, "LaCie 2Big Network v2")401.boot_params = 0x00000100,402.init_machine = netxbig_v2_init,403.map_io = kirkwood_map_io,404.init_early = kirkwood_init_early,405.init_irq = kirkwood_init_irq,406.timer = &kirkwood_timer,407MACHINE_END408#endif409410#ifdef CONFIG_MACH_NET5BIG_V2411MACHINE_START(NET5BIG_V2, "LaCie 5Big Network v2")412.boot_params = 0x00000100,413.init_machine = netxbig_v2_init,414.map_io = kirkwood_map_io,415.init_early = kirkwood_init_early,416.init_irq = kirkwood_init_irq,417.timer = &kirkwood_timer,418MACHINE_END419#endif420421422