194b0bd36SThomas Petazzoni /* 294b0bd36SThomas Petazzoni * arch/arm/mach-orion5x/board-d2net.c 394b0bd36SThomas Petazzoni * 494b0bd36SThomas Petazzoni * LaCie d2Network and Big Disk Network NAS setup 594b0bd36SThomas Petazzoni * 694b0bd36SThomas Petazzoni * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com> 794b0bd36SThomas Petazzoni * 894b0bd36SThomas Petazzoni * This file is licensed under the terms of the GNU General Public 994b0bd36SThomas Petazzoni * License version 2. This program is licensed "as is" without any 1094b0bd36SThomas Petazzoni * warranty of any kind, whether express or implied. 1194b0bd36SThomas Petazzoni */ 1294b0bd36SThomas Petazzoni 1394b0bd36SThomas Petazzoni #include <linux/kernel.h> 1494b0bd36SThomas Petazzoni #include <linux/init.h> 1594b0bd36SThomas Petazzoni #include <linux/platform_device.h> 1694b0bd36SThomas Petazzoni #include <linux/pci.h> 1794b0bd36SThomas Petazzoni #include <linux/irq.h> 1894b0bd36SThomas Petazzoni #include <linux/leds.h> 1994b0bd36SThomas Petazzoni #include <linux/gpio.h> 2094b0bd36SThomas Petazzoni #include <asm/mach-types.h> 2194b0bd36SThomas Petazzoni #include <asm/mach/arch.h> 2294b0bd36SThomas Petazzoni #include <asm/mach/pci.h> 2394b0bd36SThomas Petazzoni #include <plat/orion-gpio.h> 2494b0bd36SThomas Petazzoni #include "common.h" 25c22c2c60SArnd Bergmann #include "orion5x.h" 2694b0bd36SThomas Petazzoni 2794b0bd36SThomas Petazzoni /***************************************************************************** 2894b0bd36SThomas Petazzoni * LaCie d2 Network Info 2994b0bd36SThomas Petazzoni ****************************************************************************/ 3094b0bd36SThomas Petazzoni 3194b0bd36SThomas Petazzoni /***************************************************************************** 3294b0bd36SThomas Petazzoni * GPIO LED's 3394b0bd36SThomas Petazzoni ****************************************************************************/ 3494b0bd36SThomas Petazzoni 3594b0bd36SThomas Petazzoni /* 3694b0bd36SThomas Petazzoni * The blue front LED is wired to the CPLD and can blink in relation with the 3794b0bd36SThomas Petazzoni * SATA activity. 3894b0bd36SThomas Petazzoni * 3994b0bd36SThomas Petazzoni * The following array detail the different LED registers and the combination 4094b0bd36SThomas Petazzoni * of their possible values: 4194b0bd36SThomas Petazzoni * 4294b0bd36SThomas Petazzoni * led_off | blink_ctrl | SATA active | LED state 4394b0bd36SThomas Petazzoni * | | | 4494b0bd36SThomas Petazzoni * 1 | x | x | off 4594b0bd36SThomas Petazzoni * 0 | 0 | 0 | off 4694b0bd36SThomas Petazzoni * 0 | 1 | 0 | blink (rate 300ms) 4794b0bd36SThomas Petazzoni * 0 | x | 1 | on 4894b0bd36SThomas Petazzoni * 4994b0bd36SThomas Petazzoni * Notes: The blue and the red front LED's can't be on at the same time. 5094b0bd36SThomas Petazzoni * Red LED have priority. 5194b0bd36SThomas Petazzoni */ 5294b0bd36SThomas Petazzoni 5394b0bd36SThomas Petazzoni #define D2NET_GPIO_RED_LED 6 5494b0bd36SThomas Petazzoni #define D2NET_GPIO_BLUE_LED_BLINK_CTRL 16 5594b0bd36SThomas Petazzoni #define D2NET_GPIO_BLUE_LED_OFF 23 5694b0bd36SThomas Petazzoni 5794b0bd36SThomas Petazzoni static struct gpio_led d2net_leds[] = { 5894b0bd36SThomas Petazzoni { 5994b0bd36SThomas Petazzoni .name = "d2net:blue:sata", 6094b0bd36SThomas Petazzoni .default_trigger = "default-on", 6194b0bd36SThomas Petazzoni .gpio = D2NET_GPIO_BLUE_LED_OFF, 6294b0bd36SThomas Petazzoni .active_low = 1, 6394b0bd36SThomas Petazzoni }, 6494b0bd36SThomas Petazzoni { 6594b0bd36SThomas Petazzoni .name = "d2net:red:fail", 6694b0bd36SThomas Petazzoni .gpio = D2NET_GPIO_RED_LED, 6794b0bd36SThomas Petazzoni }, 6894b0bd36SThomas Petazzoni }; 6994b0bd36SThomas Petazzoni 7094b0bd36SThomas Petazzoni static struct gpio_led_platform_data d2net_led_data = { 7194b0bd36SThomas Petazzoni .num_leds = ARRAY_SIZE(d2net_leds), 7294b0bd36SThomas Petazzoni .leds = d2net_leds, 7394b0bd36SThomas Petazzoni }; 7494b0bd36SThomas Petazzoni 7594b0bd36SThomas Petazzoni static struct platform_device d2net_gpio_leds = { 7694b0bd36SThomas Petazzoni .name = "leds-gpio", 7794b0bd36SThomas Petazzoni .id = -1, 7894b0bd36SThomas Petazzoni .dev = { 7994b0bd36SThomas Petazzoni .platform_data = &d2net_led_data, 8094b0bd36SThomas Petazzoni }, 8194b0bd36SThomas Petazzoni }; 8294b0bd36SThomas Petazzoni 8394b0bd36SThomas Petazzoni static void __init d2net_gpio_leds_init(void) 8494b0bd36SThomas Petazzoni { 8594b0bd36SThomas Petazzoni int err; 8694b0bd36SThomas Petazzoni 8794b0bd36SThomas Petazzoni /* Configure register blink_ctrl to allow SATA activity LED blinking. */ 8894b0bd36SThomas Petazzoni err = gpio_request(D2NET_GPIO_BLUE_LED_BLINK_CTRL, "blue LED blink"); 8994b0bd36SThomas Petazzoni if (err == 0) { 9094b0bd36SThomas Petazzoni err = gpio_direction_output(D2NET_GPIO_BLUE_LED_BLINK_CTRL, 1); 9194b0bd36SThomas Petazzoni if (err) 9294b0bd36SThomas Petazzoni gpio_free(D2NET_GPIO_BLUE_LED_BLINK_CTRL); 9394b0bd36SThomas Petazzoni } 9494b0bd36SThomas Petazzoni if (err) 9594b0bd36SThomas Petazzoni pr_err("d2net: failed to configure blue LED blink GPIO\n"); 9694b0bd36SThomas Petazzoni 9794b0bd36SThomas Petazzoni platform_device_register(&d2net_gpio_leds); 9894b0bd36SThomas Petazzoni } 9994b0bd36SThomas Petazzoni 10094b0bd36SThomas Petazzoni /***************************************************************************** 10194b0bd36SThomas Petazzoni * General Setup 10294b0bd36SThomas Petazzoni ****************************************************************************/ 10394b0bd36SThomas Petazzoni 10494b0bd36SThomas Petazzoni void __init d2net_init(void) 10594b0bd36SThomas Petazzoni { 10694b0bd36SThomas Petazzoni d2net_gpio_leds_init(); 10794b0bd36SThomas Petazzoni 10894b0bd36SThomas Petazzoni pr_notice("d2net: Flash write are not yet supported.\n"); 10994b0bd36SThomas Petazzoni } 110