Linux Audio

Check our new training course

Loading...
v6.13.7
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * arch/arm/mach-orion5x/board-d2net.c
  4 *
  5 * LaCie d2Network and Big Disk Network NAS setup
  6 *
  7 * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
  8 */
  9
 10#include <linux/kernel.h>
 11#include <linux/init.h>
 12#include <linux/platform_device.h>
 13#include <linux/pci.h>
 14#include <linux/irq.h>
 15#include <linux/leds.h>
 16#include <linux/gpio.h>
 17#include <linux/gpio/machine.h>
 18#include <asm/mach-types.h>
 19#include <asm/mach/arch.h>
 20#include <asm/mach/pci.h>
 21#include <plat/orion-gpio.h>
 22#include "common.h"
 23#include "orion5x.h"
 24
 25/*****************************************************************************
 26 * LaCie d2 Network Info
 27 ****************************************************************************/
 28
 29/*****************************************************************************
 30 * GPIO LED's
 31 ****************************************************************************/
 32
 33/*
 34 * The blue front LED is wired to the CPLD and can blink in relation with the
 35 * SATA activity.
 36 *
 37 * The following array detail the different LED registers and the combination
 38 * of their possible values:
 39 *
 40 * led_off   | blink_ctrl | SATA active | LED state
 41 *           |            |             |
 42 *    1      |     x      |      x      |  off
 43 *    0      |     0      |      0      |  off
 44 *    0      |     1      |      0      |  blink (rate 300ms)
 45 *    0      |     x      |      1      |  on
 46 *
 47 * Notes: The blue and the red front LED's can't be on at the same time.
 48 *        Red LED have priority.
 49 */
 50
 51#define D2NET_GPIO_RED_LED		6
 52#define D2NET_GPIO_BLUE_LED_BLINK_CTRL	16
 53#define D2NET_GPIO_BLUE_LED_OFF		23
 54
 55static struct gpio_led d2net_leds[] = {
 56	{
 57		.name = "d2net:blue:sata",
 58		.default_trigger = "default-on",
 
 
 59	},
 60	{
 61		.name = "d2net:red:fail",
 
 62	},
 63};
 64
 65static struct gpio_led_platform_data d2net_led_data = {
 66	.num_leds = ARRAY_SIZE(d2net_leds),
 67	.leds = d2net_leds,
 68};
 69
 70static struct platform_device d2net_gpio_leds = {
 71	.name           = "leds-gpio",
 72	.id             = -1,
 73	.dev            = {
 74		.platform_data  = &d2net_led_data,
 75	},
 76};
 77
 78static struct gpiod_lookup_table d2net_leds_gpio_table = {
 79	.dev_id = "leds-gpio",
 80	.table = {
 81		GPIO_LOOKUP_IDX("orion_gpio0", D2NET_GPIO_BLUE_LED_OFF, NULL,
 82				0, GPIO_ACTIVE_LOW),
 83		GPIO_LOOKUP_IDX("orion_gpio0", D2NET_GPIO_RED_LED, NULL,
 84				1, GPIO_ACTIVE_HIGH),
 85		{ },
 86	},
 87};
 88
 89static void __init d2net_gpio_leds_init(void)
 90{
 91	int err;
 92
 93	/* Configure register blink_ctrl to allow SATA activity LED blinking. */
 94	err = gpio_request(D2NET_GPIO_BLUE_LED_BLINK_CTRL, "blue LED blink");
 95	if (err == 0) {
 96		err = gpio_direction_output(D2NET_GPIO_BLUE_LED_BLINK_CTRL, 1);
 97		if (err)
 98			gpio_free(D2NET_GPIO_BLUE_LED_BLINK_CTRL);
 99	}
100	if (err)
101		pr_err("d2net: failed to configure blue LED blink GPIO\n");
102
103	gpiod_add_lookup_table(&d2net_leds_gpio_table);
104	platform_device_register(&d2net_gpio_leds);
105}
106
107/*****************************************************************************
108 * General Setup
109 ****************************************************************************/
110
111void __init d2net_init(void)
112{
113	d2net_gpio_leds_init();
114
115	pr_notice("d2net: Flash write are not yet supported.\n");
116}
v6.8
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * arch/arm/mach-orion5x/board-d2net.c
  4 *
  5 * LaCie d2Network and Big Disk Network NAS setup
  6 *
  7 * Copyright (C) 2009 Simon Guinot <sguinot@lacie.com>
  8 */
  9
 10#include <linux/kernel.h>
 11#include <linux/init.h>
 12#include <linux/platform_device.h>
 13#include <linux/pci.h>
 14#include <linux/irq.h>
 15#include <linux/leds.h>
 16#include <linux/gpio.h>
 
 17#include <asm/mach-types.h>
 18#include <asm/mach/arch.h>
 19#include <asm/mach/pci.h>
 20#include <plat/orion-gpio.h>
 21#include "common.h"
 22#include "orion5x.h"
 23
 24/*****************************************************************************
 25 * LaCie d2 Network Info
 26 ****************************************************************************/
 27
 28/*****************************************************************************
 29 * GPIO LED's
 30 ****************************************************************************/
 31
 32/*
 33 * The blue front LED is wired to the CPLD and can blink in relation with the
 34 * SATA activity.
 35 *
 36 * The following array detail the different LED registers and the combination
 37 * of their possible values:
 38 *
 39 * led_off   | blink_ctrl | SATA active | LED state
 40 *           |            |             |
 41 *    1      |     x      |      x      |  off
 42 *    0      |     0      |      0      |  off
 43 *    0      |     1      |      0      |  blink (rate 300ms)
 44 *    0      |     x      |      1      |  on
 45 *
 46 * Notes: The blue and the red front LED's can't be on at the same time.
 47 *        Red LED have priority.
 48 */
 49
 50#define D2NET_GPIO_RED_LED		6
 51#define D2NET_GPIO_BLUE_LED_BLINK_CTRL	16
 52#define D2NET_GPIO_BLUE_LED_OFF		23
 53
 54static struct gpio_led d2net_leds[] = {
 55	{
 56		.name = "d2net:blue:sata",
 57		.default_trigger = "default-on",
 58		.gpio = D2NET_GPIO_BLUE_LED_OFF,
 59		.active_low = 1,
 60	},
 61	{
 62		.name = "d2net:red:fail",
 63		.gpio = D2NET_GPIO_RED_LED,
 64	},
 65};
 66
 67static struct gpio_led_platform_data d2net_led_data = {
 68	.num_leds = ARRAY_SIZE(d2net_leds),
 69	.leds = d2net_leds,
 70};
 71
 72static struct platform_device d2net_gpio_leds = {
 73	.name           = "leds-gpio",
 74	.id             = -1,
 75	.dev            = {
 76		.platform_data  = &d2net_led_data,
 77	},
 78};
 79
 
 
 
 
 
 
 
 
 
 
 
 80static void __init d2net_gpio_leds_init(void)
 81{
 82	int err;
 83
 84	/* Configure register blink_ctrl to allow SATA activity LED blinking. */
 85	err = gpio_request(D2NET_GPIO_BLUE_LED_BLINK_CTRL, "blue LED blink");
 86	if (err == 0) {
 87		err = gpio_direction_output(D2NET_GPIO_BLUE_LED_BLINK_CTRL, 1);
 88		if (err)
 89			gpio_free(D2NET_GPIO_BLUE_LED_BLINK_CTRL);
 90	}
 91	if (err)
 92		pr_err("d2net: failed to configure blue LED blink GPIO\n");
 93
 
 94	platform_device_register(&d2net_gpio_leds);
 95}
 96
 97/*****************************************************************************
 98 * General Setup
 99 ****************************************************************************/
100
101void __init d2net_init(void)
102{
103	d2net_gpio_leds_init();
104
105	pr_notice("d2net: Flash write are not yet supported.\n");
106}