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