Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * arch/arm/mach-orion5x/board-d2net.c
0004  *
0005  * LaCie d2Network and Big Disk Network NAS setup
0006  *
0007  * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
0008  */
0009 
0010 #include <linux/kernel.h>
0011 #include <linux/init.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/pci.h>
0014 #include <linux/irq.h>
0015 #include <linux/leds.h>
0016 #include <linux/gpio.h>
0017 #include <asm/mach-types.h>
0018 #include <asm/mach/arch.h>
0019 #include <asm/mach/pci.h>
0020 #include <plat/orion-gpio.h>
0021 #include "common.h"
0022 #include "orion5x.h"
0023 
0024 /*****************************************************************************
0025  * LaCie d2 Network Info
0026  ****************************************************************************/
0027 
0028 /*****************************************************************************
0029  * GPIO LED's
0030  ****************************************************************************/
0031 
0032 /*
0033  * The blue front LED is wired to the CPLD and can blink in relation with the
0034  * SATA activity.
0035  *
0036  * The following array detail the different LED registers and the combination
0037  * of their possible values:
0038  *
0039  * led_off   | blink_ctrl | SATA active | LED state
0040  *           |            |             |
0041  *    1      |     x      |      x      |  off
0042  *    0      |     0      |      0      |  off
0043  *    0      |     1      |      0      |  blink (rate 300ms)
0044  *    0      |     x      |      1      |  on
0045  *
0046  * Notes: The blue and the red front LED's can't be on at the same time.
0047  *        Red LED have priority.
0048  */
0049 
0050 #define D2NET_GPIO_RED_LED      6
0051 #define D2NET_GPIO_BLUE_LED_BLINK_CTRL  16
0052 #define D2NET_GPIO_BLUE_LED_OFF     23
0053 
0054 static struct gpio_led d2net_leds[] = {
0055     {
0056         .name = "d2net:blue:sata",
0057         .default_trigger = "default-on",
0058         .gpio = D2NET_GPIO_BLUE_LED_OFF,
0059         .active_low = 1,
0060     },
0061     {
0062         .name = "d2net:red:fail",
0063         .gpio = D2NET_GPIO_RED_LED,
0064     },
0065 };
0066 
0067 static struct gpio_led_platform_data d2net_led_data = {
0068     .num_leds = ARRAY_SIZE(d2net_leds),
0069     .leds = d2net_leds,
0070 };
0071 
0072 static struct platform_device d2net_gpio_leds = {
0073     .name           = "leds-gpio",
0074     .id             = -1,
0075     .dev            = {
0076         .platform_data  = &d2net_led_data,
0077     },
0078 };
0079 
0080 static void __init d2net_gpio_leds_init(void)
0081 {
0082     int err;
0083 
0084     /* Configure register blink_ctrl to allow SATA activity LED blinking. */
0085     err = gpio_request(D2NET_GPIO_BLUE_LED_BLINK_CTRL, "blue LED blink");
0086     if (err == 0) {
0087         err = gpio_direction_output(D2NET_GPIO_BLUE_LED_BLINK_CTRL, 1);
0088         if (err)
0089             gpio_free(D2NET_GPIO_BLUE_LED_BLINK_CTRL);
0090     }
0091     if (err)
0092         pr_err("d2net: failed to configure blue LED blink GPIO\n");
0093 
0094     platform_device_register(&d2net_gpio_leds);
0095 }
0096 
0097 /*****************************************************************************
0098  * General Setup
0099  ****************************************************************************/
0100 
0101 void __init d2net_init(void)
0102 {
0103     d2net_gpio_leds_init();
0104 
0105     pr_notice("d2net: Flash write are not yet supported.\n");
0106 }