Commit e8a2a176 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'leds_for_4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds

Pull LED updates from Jacek Anaszewski:

 - Move the out-of-LED-tree led-sead3 driver to the LED subsystem.

 - Add 'invert' sysfs attribute to the heartbeat trigger.

 - Add Device Tree support to the leds-netxbig driver and add related DT
   nodes to the kirkwood-netxbig.dtsi and kirkwood-net5big.dts files.
   Remove static LED setup from the related board files.

 - Remove redundant brightness conversion operation from leds-netxbig.

 - Improve leds-bcm6328 driver: improve default-state handling, add more
   init configuration options, print invalid LED instead of warning only
   about maximum LED value.

 - Add a shutdown function for setting gpio-leds into off state when
   shutting down.

 - Fix DT flash timeout property naming in leds-aat1290.txt.

 - Switch to using devm prefixed version of led_classdev_register()
   (leds-cobalt-qube, leds-hp6xx, leds-ot200, leds-ipaq-micro,
   leds-netxbig, leds-locomo, leds-menf21bmc, leds-net48xx, leds-wrap).

 - Add missing of_node_put (leds-powernv, leds-bcm6358, leds-bcm6328,
   leds-88pm860x).

 - Coding style fixes and cleanups: led-class/led-core, leds-ipaq-micro.

* tag 'leds_for_4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds: (27 commits)
  leds: 88pm860x: add missing of_node_put
  leds: bcm6328: add missing of_node_put
  leds: bcm6358: add missing of_node_put
  powerpc/powernv: add missing of_node_put
  leds: leds-wrap.c: Use devm_led_classdev_register
  leds: aat1290: Fix property naming of flash-timeout-us
  leds: leds-net48xx: Use devm_led_classdev_register
  leds: leds-menf21bmc.c: Use devm_led_class_register
  leds: leds-locomo.c: Use devm_led_classdev_register
  leds: leds-gpio: add shutdown function
  Documentation: leds: update DT bindings for leds-bcm6328
  leds-bcm6328: add more init configuration options
  leds-bcm6328: simplify and improve default-state handling
  leds-bcm6328: print invalid LED
  leds: netxbig: set led_classdev max_brightness
  leds: netxbig: convert to use the devm_ functions
  ARM: mvebu: remove static LED setup for netxbig boards
  ARM: Kirkwood: add LED DT entries for netxbig boards
  leds: netxbig: add device tree binding
  leds: triggers: add invert to heartbeat
  ...
parents 5062ecdb ffdc307d
Binding for the GPIO extension bus found on some LaCie/Seagate boards
(Example: 2Big/5Big Network v2, 2Big NAS).
Required properties:
- compatible: "lacie,netxbig-gpio-ext".
- addr-gpios: GPIOs representing the address register (LSB -> MSB).
- data-gpios: GPIOs representing the data register (LSB -> MSB).
- enable-gpio: latches the new configuration (address, data) on raising edge.
Example:
netxbig_gpio_ext: netxbig-gpio-ext {
compatible = "lacie,netxbig-gpio-ext";
addr-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH
&gpio1 16 GPIO_ACTIVE_HIGH
&gpio1 17 GPIO_ACTIVE_HIGH>;
data-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH
&gpio1 13 GPIO_ACTIVE_HIGH
&gpio1 14 GPIO_ACTIVE_HIGH>;
enable-gpio = <&gpio0 29 GPIO_ACTIVE_HIGH>;
};
...@@ -27,7 +27,7 @@ Required properties of the LED child node: ...@@ -27,7 +27,7 @@ Required properties of the LED child node:
- flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt - flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt
Maximum flash LED supply current can be calculated using Maximum flash LED supply current can be calculated using
following formula: I = 1A * 162kohm / Rset. following formula: I = 1A * 162kohm / Rset.
- flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt - flash-max-timeout-us : see Documentation/devicetree/bindings/leds/common.txt
Maximum flash timeout can be calculated using following Maximum flash timeout can be calculated using following
formula: T = 8.82 * 10^9 * Ct. formula: T = 8.82 * 10^9 * Ct.
...@@ -54,7 +54,7 @@ aat1290 { ...@@ -54,7 +54,7 @@ aat1290 {
label = "aat1290-flash"; label = "aat1290-flash";
led-max-microamp = <520833>; led-max-microamp = <520833>;
flash-max-microamp = <1012500>; flash-max-microamp = <1012500>;
flash-timeout-us = <1940000>; flash-max-timeout-us = <1940000>;
}; };
}; };
......
...@@ -29,6 +29,14 @@ Required properties: ...@@ -29,6 +29,14 @@ Required properties:
Optional properties: Optional properties:
- brcm,serial-leds : Boolean, enables Serial LEDs. - brcm,serial-leds : Boolean, enables Serial LEDs.
Default : false Default : false
- brcm,serial-mux : Boolean, enables Serial LEDs multiplexing.
Default : false
- brcm,serial-clk-low : Boolean, makes clock signal active low.
Default : false
- brcm,serial-dat-low : Boolean, makes data signal active low.
Default : false
- brcm,serial-shift-inv : Boolean, inverts Serial LEDs shift direction.
Default : false
Each LED is represented as a sub-node of the brcm,bcm6328-leds device. Each LED is represented as a sub-node of the brcm,bcm6328-leds device.
...@@ -110,6 +118,8 @@ Scenario 2 : BCM63268 with Serial/GPHY0 LEDs ...@@ -110,6 +118,8 @@ Scenario 2 : BCM63268 with Serial/GPHY0 LEDs
#size-cells = <0>; #size-cells = <0>;
reg = <0x10001900 0x24>; reg = <0x10001900 0x24>;
brcm,serial-leds; brcm,serial-leds;
brcm,serial-dat-low;
brcm,serial-shift-inv;
gphy0_spd0@0 { gphy0_spd0@0 {
reg = <0>; reg = <0>;
......
Binding for the CPLD LEDs (GPIO extension bus) found on some LaCie/Seagate
boards (Example: 2Big/5Big Network v2, 2Big NAS).
Required properties:
- compatible: "lacie,netxbig-leds".
- gpio-ext: Phandle for the gpio-ext bus.
Optional properties:
- timers: Timer array. Each timer entry is represented by three integers:
Mode (gpio-ext bus), delay_on and delay_off.
Each LED is represented as a sub-node of the netxbig-leds device.
Required sub-node properties:
- mode-addr: Mode register address on gpio-ext bus.
- mode-val: Mode to value mapping. Each entry is represented by two integers:
A mode and the corresponding value on the gpio-ext bus.
- bright-addr: Brightness register address on gpio-ext bus.
- max-brightness: Maximum brightness value.
Optional sub-node properties:
- label: Name for this LED. If omitted, the label is taken from the node name.
- linux,default-trigger: Trigger assigned to the LED.
Example:
netxbig-leds {
compatible = "lacie,netxbig-leds";
gpio-ext = &gpio_ext;
timers = <NETXBIG_LED_TIMER1 500 500
NETXBIG_LED_TIMER2 500 1000>;
blue-power {
label = "netxbig:blue:power";
mode-addr = <0>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 1
NETXBIG_LED_TIMER1 3
NETXBIG_LED_TIMER2 7>;
bright-addr = <1>;
max-brightness = <7>;
};
red-power {
label = "netxbig:red:power";
mode-addr = <0>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <1>;
max-brightness = <7>;
};
blue-sata0 {
label = "netxbig:blue:sata0";
mode-addr = <3>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 7
NETXBIG_LED_SATA 1
NETXBIG_LED_TIMER1 3>;
bright-addr = <2>;
max-brightness = <7>;
};
red-sata0 {
label = "netxbig:red:sata0";
mode-addr = <3>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <2>;
max-brightness = <7>;
};
blue-sata1 {
label = "netxbig:blue:sata1";
mode-addr = <4>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 7
NETXBIG_LED_SATA 1
NETXBIG_LED_TIMER1 3>;
bright-addr = <2>;
max-brightness = <7>;
};
red-sata1 {
label = "netxbig:red:sata1";
mode-addr = <4>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <2>;
max-brightness = <7>;
};
};
...@@ -86,6 +86,66 @@ g762_clk: g762-oscillator { ...@@ -86,6 +86,66 @@ g762_clk: g762-oscillator {
clock-frequency = <32768>; clock-frequency = <32768>;
}; };
}; };
netxbig-leds {
blue-sata2 {
label = "netxbig:blue:sata2";
mode-addr = <5>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 7
NETXBIG_LED_SATA 1
NETXBIG_LED_TIMER1 3>;
bright-addr = <2>;
max-brightness = <7>;
};
red-sata2 {
label = "netxbig:red:sata2";
mode-addr = <5>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <2>;
max-brightness = <7>;
};
blue-sata3 {
label = "netxbig:blue:sata3";
mode-addr = <6>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 7
NETXBIG_LED_SATA 1
NETXBIG_LED_TIMER1 3>;
bright-addr = <2>;
max-brightness = <7>;
};
red-sata3 {
label = "netxbig:red:sata3";
mode-addr = <6>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <2>;
max-brightness = <7>;
};
blue-sata4 {
label = "netxbig:blue:sata4";
mode-addr = <7>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 7
NETXBIG_LED_SATA 1
NETXBIG_LED_TIMER1 3>;
bright-addr = <2>;
max-brightness = <7>;
};
red-sata4 {
label = "netxbig:red:sata4";
mode-addr = <7>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <2>;
max-brightness = <7>;
};
};
}; };
&mdio { &mdio {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#include <dt-bindings/leds/leds-netxbig.h>
#include "kirkwood.dtsi" #include "kirkwood.dtsi"
#include "kirkwood-6281.dtsi" #include "kirkwood-6281.dtsi"
...@@ -105,6 +106,85 @@ regulator@1 { ...@@ -105,6 +106,85 @@ regulator@1 {
gpio = <&gpio0 16 GPIO_ACTIVE_HIGH>; gpio = <&gpio0 16 GPIO_ACTIVE_HIGH>;
}; };
}; };
netxbig_gpio_ext: netxbig-gpio-ext {
compatible = "lacie,netxbig-gpio-ext";
addr-gpios = <&gpio1 15 GPIO_ACTIVE_HIGH
&gpio1 16 GPIO_ACTIVE_HIGH
&gpio1 17 GPIO_ACTIVE_HIGH>;
data-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH
&gpio1 13 GPIO_ACTIVE_HIGH
&gpio1 14 GPIO_ACTIVE_HIGH>;
enable-gpio = <&gpio0 29 GPIO_ACTIVE_HIGH>;
};
netxbig-leds {
compatible = "lacie,netxbig-leds";
gpio-ext = <&netxbig_gpio_ext>;
timers = <NETXBIG_LED_TIMER1 500 500
NETXBIG_LED_TIMER2 500 1000>;
blue-power {
label = "netxbig:blue:power";
mode-addr = <0>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 1
NETXBIG_LED_TIMER1 3
NETXBIG_LED_TIMER2 7>;
bright-addr = <1>;
max-brightness = <7>;
};
red-power {
label = "netxbig:red:power";
mode-addr = <0>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <1>;
max-brightness = <7>;
};
blue-sata0 {
label = "netxbig:blue:sata0";
mode-addr = <3>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 7
NETXBIG_LED_SATA 1
NETXBIG_LED_TIMER1 3>;
bright-addr = <2>;
max-brightness = <7>;
};
red-sata0 {
label = "netxbig:red:sata0";
mode-addr = <3>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <2>;
max-brightness = <7>;
};
blue-sata1 {
label = "netxbig:blue:sata1";
mode-addr = <4>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 7
NETXBIG_LED_SATA 1
NETXBIG_LED_TIMER1 3>;
bright-addr = <2>;
max-brightness = <7>;
};
red-sata1 {
label = "netxbig:red:sata1";
mode-addr = <4>;
mode-val = <NETXBIG_LED_OFF 0
NETXBIG_LED_ON 2
NETXBIG_LED_TIMER1 4>;
bright-addr = <2>;
max-brightness = <7>;
};
};
}; };
&mdio { &mdio {
......
...@@ -117,11 +117,4 @@ config MACH_KIRKWOOD ...@@ -117,11 +117,4 @@ config MACH_KIRKWOOD
Say 'Y' here if you want your kernel to support boards based Say 'Y' here if you want your kernel to support boards based
on the Marvell Kirkwood device tree. on the Marvell Kirkwood device tree.
config MACH_NETXBIG
bool "LaCie 2Big and 5Big Network v2"
depends on MACH_KIRKWOOD
help
Say 'Y' here if you want your kernel to support the
LaCie 2Big and 5Big Network v2
endif endif
...@@ -13,4 +13,3 @@ endif ...@@ -13,4 +13,3 @@ endif
obj-$(CONFIG_MACH_DOVE) += dove.o obj-$(CONFIG_MACH_DOVE) += dove.o
obj-$(CONFIG_MACH_KIRKWOOD) += kirkwood.o kirkwood-pm.o obj-$(CONFIG_MACH_KIRKWOOD) += kirkwood.o kirkwood-pm.o
obj-$(CONFIG_MACH_NETXBIG) += netxbig.o
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "kirkwood.h" #include "kirkwood.h"
#include "kirkwood-pm.h" #include "kirkwood-pm.h"
#include "common.h" #include "common.h"
#include "board.h"
static struct resource kirkwood_cpufreq_resources[] = { static struct resource kirkwood_cpufreq_resources[] = {
[0] = { [0] = {
...@@ -180,9 +179,6 @@ static void __init kirkwood_dt_init(void) ...@@ -180,9 +179,6 @@ static void __init kirkwood_dt_init(void)
kirkwood_pm_init(); kirkwood_pm_init();
kirkwood_dt_eth_fixup(); kirkwood_dt_eth_fixup();
if (of_machine_is_compatible("lacie,netxbig"))
netxbig_init();
of_platform_populate(NULL, of_default_bus_match_table, auxdata, NULL); of_platform_populate(NULL, of_default_bus_match_table, auxdata, NULL);
} }
......
/*
* arch/arm/mach-mvbu/board-netxbig.c
*
* LaCie 2Big and 5Big Network v2 board setup
*
* Copyright (C) 2010 Simon Guinot <sguinot@lacie.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/platform_data/leds-kirkwood-netxbig.h>
#include "common.h"
/*****************************************************************************
* GPIO extension LEDs
****************************************************************************/
/*
* The LEDs are controlled by a CPLD and can be configured through a GPIO
* extension bus:
*
* - address register : bit [0-2] -> GPIO [47-49]
* - data register : bit [0-2] -> GPIO [44-46]
* - enable register : GPIO 29
*/
static int netxbig_v2_gpio_ext_addr[] = { 47, 48, 49 };
static int netxbig_v2_gpio_ext_data[] = { 44, 45, 46 };
static struct netxbig_gpio_ext netxbig_v2_gpio_ext = {
.addr = netxbig_v2_gpio_ext_addr,
.num_addr = ARRAY_SIZE(netxbig_v2_gpio_ext_addr),
.data = netxbig_v2_gpio_ext_data,
.num_data = ARRAY_SIZE(netxbig_v2_gpio_ext_data),
.enable = 29,
};
/*
* Address register selection:
*
* addr | register
* ----------------------------
* 0 | front LED
* 1 | front LED brightness
* 2 | SATA LED brightness
* 3 | SATA0 LED
* 4 | SATA1 LED
* 5 | SATA2 LED
* 6 | SATA3 LED
* 7 | SATA4 LED
*
* Data register configuration:
*
* data | LED brightness
* -------------------------------------------------
* 0 | min (off)
* - | -
* 7 | max
*
* data | front LED mode
* -------------------------------------------------
* 0 | fix off
* 1 | fix blue on
* 2 | fix red on
* 3 | blink blue on=1 sec and blue off=1 sec
* 4 | blink red on=1 sec and red off=1 sec
* 5 | blink blue on=2.5 sec and red on=0.5 sec
* 6 | blink blue on=1 sec and red on=1 sec
* 7 | blink blue on=0.5 sec and blue off=2.5 sec
*
* data | SATA LED mode
* -------------------------------------------------
* 0 | fix off
* 1 | SATA activity blink
* 2 | fix red on
* 3 | blink blue on=1 sec and blue off=1 sec
* 4 | blink red on=1 sec and red off=1 sec
* 5 | blink blue on=2.5 sec and red on=0.5 sec
* 6 | blink blue on=1 sec and red on=1 sec
* 7 | fix blue on
*/
static int netxbig_v2_red_mled[NETXBIG_LED_MODE_NUM] = {
[NETXBIG_LED_OFF] = 0,
[NETXBIG_LED_ON] = 2,
[NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,
[NETXBIG_LED_TIMER1] = 4,
[NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,
};
static int netxbig_v2_blue_pwr_mled[NETXBIG_LED_MODE_NUM] = {
[NETXBIG_LED_OFF] = 0,
[NETXBIG_LED_ON] = 1,
[NETXBIG_LED_SATA] = NETXBIG_LED_INVALID_MODE,
[NETXBIG_LED_TIMER1] = 3,
[NETXBIG_LED_TIMER2] = 7,
};
static int netxbig_v2_blue_sata_mled[NETXBIG_LED_MODE_NUM] = {
[NETXBIG_LED_OFF] = 0,
[NETXBIG_LED_ON] = 7,
[NETXBIG_LED_SATA] = 1,
[NETXBIG_LED_TIMER1] = 3,
[NETXBIG_LED_TIMER2] = NETXBIG_LED_INVALID_MODE,
};
static struct netxbig_led_timer netxbig_v2_led_timer[] = {
[0] = {
.delay_on = 500,
.delay_off = 500,
.mode = NETXBIG_LED_TIMER1,
},
[1] = {
.delay_on = 500,
.delay_off = 1000,
.mode = NETXBIG_LED_TIMER2,
},
};
#define NETXBIG_LED(_name, maddr, mval, baddr) \
{ .name = _name, \
.mode_addr = maddr, \
.mode_val = mval, \
.bright_addr = baddr }
static struct netxbig_led net2big_v2_leds_ctrl[] = {
NETXBIG_LED("net2big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),
NETXBIG_LED("net2big-v2:red:power", 0, netxbig_v2_red_mled, 1),
NETXBIG_LED("net2big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),
NETXBIG_LED("net2big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),
NETXBIG_LED("net2big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),
NETXBIG_LED("net2big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),
};
static struct netxbig_led_platform_data net2big_v2_leds_data = {
.gpio_ext = &netxbig_v2_gpio_ext,
.timer = netxbig_v2_led_timer,
.num_timer = ARRAY_SIZE(netxbig_v2_led_timer),
.leds = net2big_v2_leds_ctrl,
.num_leds = ARRAY_SIZE(net2big_v2_leds_ctrl),
};
static struct netxbig_led net5big_v2_leds_ctrl[] = {
NETXBIG_LED("net5big-v2:blue:power", 0, netxbig_v2_blue_pwr_mled, 1),
NETXBIG_LED("net5big-v2:red:power", 0, netxbig_v2_red_mled, 1),
NETXBIG_LED("net5big-v2:blue:sata0", 3, netxbig_v2_blue_sata_mled, 2),
NETXBIG_LED("net5big-v2:red:sata0", 3, netxbig_v2_red_mled, 2),
NETXBIG_LED("net5big-v2:blue:sata1", 4, netxbig_v2_blue_sata_mled, 2),
NETXBIG_LED("net5big-v2:red:sata1", 4, netxbig_v2_red_mled, 2),
NETXBIG_LED("net5big-v2:blue:sata2", 5, netxbig_v2_blue_sata_mled, 2),
NETXBIG_LED("net5big-v2:red:sata2", 5, netxbig_v2_red_mled, 2),
NETXBIG_LED("net5big-v2:blue:sata3", 6, netxbig_v2_blue_sata_mled, 2),
NETXBIG_LED("net5big-v2:red:sata3", 6, netxbig_v2_red_mled, 2),
NETXBIG_LED("net5big-v2:blue:sata4", 7, netxbig_v2_blue_sata_mled, 2),
NETXBIG_LED("net5big-v2:red:sata4", 7, netxbig_v2_red_mled, 2),
};
static struct netxbig_led_platform_data net5big_v2_leds_data = {
.gpio_ext = &netxbig_v2_gpio_ext,
.timer = netxbig_v2_led_timer,
.num_timer = ARRAY_SIZE(netxbig_v2_led_timer),
.leds = net5big_v2_leds_ctrl,
.num_leds = ARRAY_SIZE(net5big_v2_leds_ctrl),
};
static struct platform_device netxbig_v2_leds = {
.name = "leds-netxbig",
.id = -1,
.dev = {
.platform_data = &net2big_v2_leds_data,
},
};
void __init netxbig_init(void)
{
if (of_machine_is_compatible("lacie,net5big_v2"))
netxbig_v2_leds.dev.platform_data = &net5big_v2_leds_data;
platform_device_register(&netxbig_v2_leds);
}
...@@ -12,6 +12,4 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \ ...@@ -12,6 +12,4 @@ obj-y := sead3-lcd.o sead3-display.o sead3-init.o \
sead3-int.o sead3-platform.o sead3-reset.o \ sead3-int.o sead3-platform.o sead3-reset.o \
sead3-setup.o sead3-time.o sead3-setup.o sead3-time.o
obj-y += leds-sead3.o
obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o obj-$(CONFIG_EARLY_PRINTK) += sead3-console.o
...@@ -556,6 +556,16 @@ config LEDS_KTD2692 ...@@ -556,6 +556,16 @@ config LEDS_KTD2692
Say Y to enable this driver. Say Y to enable this driver.
config LEDS_SEAD3
tristate "LED support for the MIPS SEAD 3 board"
depends on LEDS_CLASS && MIPS_SEAD3
help
Say Y here to include support for the FLED and PLED LEDs on SEAD3 eval
boards.
This driver can also be built as a module. If so the module
will be called leds-sead3.
comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)"
config LEDS_BLINKM config LEDS_BLINKM
......
...@@ -65,6 +65,7 @@ obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o ...@@ -65,6 +65,7 @@ obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o
obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o
obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o
obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o obj-$(CONFIG_LEDS_POWERNV) += leds-powernv.o
obj-$(CONFIG_LEDS_SEAD3) += leds-sead3.o
# LED SPI Drivers # LED SPI Drivers
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
......
...@@ -102,70 +102,6 @@ static const struct attribute_group *led_groups[] = { ...@@ -102,70 +102,6 @@ static const struct attribute_group *led_groups[] = {
NULL, NULL,
}; };
static void led_timer_function(unsigned long data)
{
struct led_classdev *led_cdev = (void *)data;
unsigned long brightness;
unsigned long delay;
if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) {
led_set_brightness_async(led_cdev, LED_OFF);
return;
}
if (led_cdev->flags & LED_BLINK_ONESHOT_STOP) {
led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP;
return;
}
brightness = led_get_brightness(led_cdev);
if (!brightness) {
/* Time to switch the LED on. */
if (led_cdev->delayed_set_value) {
led_cdev->blink_brightness =
led_cdev->delayed_set_value;
led_cdev->delayed_set_value = 0;
}
brightness = led_cdev->blink_brightness;
delay = led_cdev->blink_delay_on;
} else {
/* Store the current brightness value to be able
* to restore it when the delay_off period is over.
*/
led_cdev->blink_brightness = brightness;
brightness = LED_OFF;
delay = led_cdev->blink_delay_off;
}
led_set_brightness_async(led_cdev, brightness);
/* Return in next iteration if led is in one-shot mode and we are in
* the final blink state so that the led is toggled each delay_on +
* delay_off milliseconds in worst case.
*/
if (led_cdev->flags & LED_BLINK_ONESHOT) {
if (led_cdev->flags & LED_BLINK_INVERT) {
if (brightness)
led_cdev->flags |= LED_BLINK_ONESHOT_STOP;
} else {
if (!brightness)
led_cdev->flags |= LED_BLINK_ONESHOT_STOP;
}
}
mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
}
static void set_brightness_delayed(struct work_struct *ws)
{
struct led_classdev *led_cdev =
container_of(ws, struct led_classdev, set_brightness_work);
led_stop_software_blink(led_cdev);
led_set_brightness_async(led_cdev, led_cdev->delayed_set_value);
}
/** /**
* led_classdev_suspend - suspend an led_classdev. * led_classdev_suspend - suspend an led_classdev.
* @led_cdev: the led_classdev to suspend. * @led_cdev: the led_classdev to suspend.
...@@ -283,10 +219,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) ...@@ -283,10 +219,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
led_update_brightness(led_cdev); led_update_brightness(led_cdev);
INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed); led_init_core(led_cdev);
setup_timer(&led_cdev->blink_timer, led_timer_function,
(unsigned long)led_cdev);
#ifdef CONFIG_LEDS_TRIGGERS #ifdef CONFIG_LEDS_TRIGGERS
led_trigger_set_default(led_cdev); led_trigger_set_default(led_cdev);
......
...@@ -25,6 +25,70 @@ EXPORT_SYMBOL_GPL(leds_list_lock); ...@@ -25,6 +25,70 @@ EXPORT_SYMBOL_GPL(leds_list_lock);
LIST_HEAD(leds_list); LIST_HEAD(leds_list);
EXPORT_SYMBOL_GPL(leds_list); EXPORT_SYMBOL_GPL(leds_list);
static void led_timer_function(unsigned long data)
{
struct led_classdev *led_cdev = (void *)data;
unsigned long brightness;
unsigned long delay;
if (!led_cdev->blink_delay_on || !led_cdev->blink_delay_off) {
led_set_brightness_async(led_cdev, LED_OFF);
return;
}
if (led_cdev->flags & LED_BLINK_ONESHOT_STOP) {
led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP;
return;
}
brightness = led_get_brightness(led_cdev);
if (!brightness) {
/* Time to switch the LED on. */
if (led_cdev->delayed_set_value) {
led_cdev->blink_brightness =
led_cdev->delayed_set_value;
led_cdev->delayed_set_value = 0;
}
brightness = led_cdev->blink_brightness;
delay = led_cdev->blink_delay_on;
} else {
/* Store the current brightness value to be able
* to restore it when the delay_off period is over.
*/
led_cdev->blink_brightness = brightness;
brightness = LED_OFF;
delay = led_cdev->blink_delay_off;
}
led_set_brightness_async(led_cdev, brightness);
/* Return in next iteration if led is in one-shot mode and we are in
* the final blink state so that the led is toggled each delay_on +
* delay_off milliseconds in worst case.
*/
if (led_cdev->flags & LED_BLINK_ONESHOT) {
if (led_cdev->flags & LED_BLINK_INVERT) {
if (brightness)
led_cdev->flags |= LED_BLINK_ONESHOT_STOP;
} else {
if (!brightness)
led_cdev->flags |= LED_BLINK_ONESHOT_STOP;
}
}
mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
}
static void set_brightness_delayed(struct work_struct *ws)
{
struct led_classdev *led_cdev =
container_of(ws, struct led_classdev, set_brightness_work);
led_stop_software_blink(led_cdev);
led_set_brightness_async(led_cdev, led_cdev->delayed_set_value);
}
static void led_set_software_blink(struct led_classdev *led_cdev, static void led_set_software_blink(struct led_classdev *led_cdev,
unsigned long delay_on, unsigned long delay_on,
unsigned long delay_off) unsigned long delay_off)
...@@ -72,6 +136,15 @@ static void led_blink_setup(struct led_classdev *led_cdev, ...@@ -72,6 +136,15 @@ static void led_blink_setup(struct led_classdev *led_cdev,
led_set_software_blink(led_cdev, *delay_on, *delay_off); led_set_software_blink(led_cdev, *delay_on, *delay_off);
} }
void led_init_core(struct led_classdev *led_cdev)
{
INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed);
setup_timer(&led_cdev->blink_timer, led_timer_function,
(unsigned long)led_cdev);
}
EXPORT_SYMBOL_GPL(led_init_core);
void led_blink_set(struct led_classdev *led_cdev, void led_blink_set(struct led_classdev *led_cdev,
unsigned long *delay_on, unsigned long *delay_on,
unsigned long *delay_off) unsigned long *delay_off)
......
...@@ -142,6 +142,7 @@ static int pm860x_led_dt_init(struct platform_device *pdev, ...@@ -142,6 +142,7 @@ static int pm860x_led_dt_init(struct platform_device *pdev,
of_property_read_u32(np, "marvell,88pm860x-iset", of_property_read_u32(np, "marvell,88pm860x-iset",
&iset); &iset);
data->iset = PM8606_LED_CURRENT(iset); data->iset = PM8606_LED_CURRENT(iset);
of_node_put(np);
break; break;
} }
} }
......
...@@ -41,6 +41,11 @@ ...@@ -41,6 +41,11 @@
#define BCM6328_SERIAL_LED_SHIFT_DIR BIT(16) #define BCM6328_SERIAL_LED_SHIFT_DIR BIT(16)
#define BCM6328_LED_SHIFT_TEST BIT(30) #define BCM6328_LED_SHIFT_TEST BIT(30)
#define BCM6328_LED_TEST BIT(31) #define BCM6328_LED_TEST BIT(31)
#define BCM6328_INIT_MASK (BCM6328_SERIAL_LED_EN | \
BCM6328_SERIAL_LED_MUX | \
BCM6328_SERIAL_LED_CLK_NPOL | \
BCM6328_SERIAL_LED_DATA_PPOL | \
BCM6328_SERIAL_LED_SHIFT_DIR)
#define BCM6328_LED_MODE_MASK 3 #define BCM6328_LED_MODE_MASK 3
#define BCM6328_LED_MODE_OFF 0 #define BCM6328_LED_MODE_OFF 0
...@@ -281,11 +286,10 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -281,11 +286,10 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
"linux,default-trigger", "linux,default-trigger",
NULL); NULL);
if (!of_property_read_string(nc, "default-state", &state)) {
spin_lock_irqsave(lock, flags); spin_lock_irqsave(lock, flags);
if (!of_property_read_string(nc, "default-state", &state)) {
if (!strcmp(state, "on")) { if (!strcmp(state, "on")) {
led->cdev.brightness = LED_FULL; led->cdev.brightness = LED_FULL;
bcm6328_led_mode(led, BCM6328_LED_MODE_ON);
} else if (!strcmp(state, "keep")) { } else if (!strcmp(state, "keep")) {
void __iomem *mode; void __iomem *mode;
unsigned long val, shift; unsigned long val, shift;
...@@ -296,20 +300,27 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg, ...@@ -296,20 +300,27 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,
else else
mode = mem + BCM6328_REG_MODE_LO; mode = mem + BCM6328_REG_MODE_LO;
val = bcm6328_led_read(mode) >> (shift % 16); val = bcm6328_led_read(mode) >>
BCM6328_LED_SHIFT(shift % 16);
val &= BCM6328_LED_MODE_MASK; val &= BCM6328_LED_MODE_MASK;
if (val == BCM6328_LED_MODE_ON) if ((led->active_low && val == BCM6328_LED_MODE_ON) ||
(!led->active_low && val == BCM6328_LED_MODE_OFF))
led->cdev.brightness = LED_FULL; led->cdev.brightness = LED_FULL;
else { else
led->cdev.brightness = LED_OFF;
} else {
led->cdev.brightness = LED_OFF; led->cdev.brightness = LED_OFF;
bcm6328_led_mode(led, BCM6328_LED_MODE_OFF);
} }
} else { } else {
led->cdev.brightness = LED_OFF; led->cdev.brightness = LED_OFF;
bcm6328_led_mode(led, BCM6328_LED_MODE_OFF);
} }
if ((led->active_low && led->cdev.brightness == LED_FULL) ||
(!led->active_low && led->cdev.brightness == LED_OFF))
bcm6328_led_mode(led, BCM6328_LED_MODE_ON);
else
bcm6328_led_mode(led, BCM6328_LED_MODE_OFF);
spin_unlock_irqrestore(lock, flags); spin_unlock_irqrestore(lock, flags);
}
led->cdev.brightness_set = bcm6328_led_set; led->cdev.brightness_set = bcm6328_led_set;
led->cdev.blink_set = bcm6328_blink_set; led->cdev.blink_set = bcm6328_blink_set;
...@@ -360,9 +371,17 @@ static int bcm6328_leds_probe(struct platform_device *pdev) ...@@ -360,9 +371,17 @@ static int bcm6328_leds_probe(struct platform_device *pdev)
bcm6328_led_write(mem + BCM6328_REG_LNKACTSEL_LO, 0); bcm6328_led_write(mem + BCM6328_REG_LNKACTSEL_LO, 0);
val = bcm6328_led_read(mem + BCM6328_REG_INIT); val = bcm6328_led_read(mem + BCM6328_REG_INIT);
val &= ~BCM6328_SERIAL_LED_EN; val &= ~(BCM6328_INIT_MASK);
if (of_property_read_bool(np, "brcm,serial-leds")) if (of_property_read_bool(np, "brcm,serial-leds"))
val |= BCM6328_SERIAL_LED_EN; val |= BCM6328_SERIAL_LED_EN;
if (of_property_read_bool(np, "brcm,serial-mux"))
val |= BCM6328_SERIAL_LED_MUX;
if (of_property_read_bool(np, "brcm,serial-clk-low"))
val |= BCM6328_SERIAL_LED_CLK_NPOL;
if (!of_property_read_bool(np, "brcm,serial-dat-low"))
val |= BCM6328_SERIAL_LED_DATA_PPOL;
if (!of_property_read_bool(np, "brcm,serial-shift-inv"))
val |= BCM6328_SERIAL_LED_SHIFT_DIR;
bcm6328_led_write(mem + BCM6328_REG_INIT, val); bcm6328_led_write(mem + BCM6328_REG_INIT, val);
for_each_available_child_of_node(np, child) { for_each_available_child_of_node(np, child) {
...@@ -373,7 +392,7 @@ static int bcm6328_leds_probe(struct platform_device *pdev) ...@@ -373,7 +392,7 @@ static int bcm6328_leds_probe(struct platform_device *pdev)
continue; continue;
if (reg >= BCM6328_LED_MAX_COUNT) { if (reg >= BCM6328_LED_MAX_COUNT) {
dev_err(dev, "invalid LED (>= %d)\n", dev_err(dev, "invalid LED (%u >= %d)\n", reg,
BCM6328_LED_MAX_COUNT); BCM6328_LED_MAX_COUNT);
continue; continue;
} }
...@@ -384,9 +403,11 @@ static int bcm6328_leds_probe(struct platform_device *pdev) ...@@ -384,9 +403,11 @@ static int bcm6328_leds_probe(struct platform_device *pdev)
rc = bcm6328_led(dev, child, reg, mem, lock, rc = bcm6328_led(dev, child, reg, mem, lock,
blink_leds, blink_delay); blink_leds, blink_delay);
if (rc < 0) if (rc < 0) {
of_node_put(child);
return rc; return rc;
} }
}
return 0; return 0;
} }
......
...@@ -215,9 +215,11 @@ static int bcm6358_leds_probe(struct platform_device *pdev) ...@@ -215,9 +215,11 @@ static int bcm6358_leds_probe(struct platform_device *pdev)
} }
rc = bcm6358_led(dev, child, reg, mem, lock); rc = bcm6358_led(dev, child, reg, mem, lock);
if (rc < 0) if (rc < 0) {
of_node_put(child);
return rc; return rc;
} }
}
return 0; return 0;
} }
......
...@@ -36,7 +36,6 @@ static struct led_classdev qube_front_led = { ...@@ -36,7 +36,6 @@ static struct led_classdev qube_front_led = {
static int cobalt_qube_led_probe(struct platform_device *pdev) static int cobalt_qube_led_probe(struct platform_device *pdev)
{ {
struct resource *res; struct resource *res;
int retval;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) if (!res)
...@@ -49,31 +48,11 @@ static int cobalt_qube_led_probe(struct platform_device *pdev) ...@@ -49,31 +48,11 @@ static int cobalt_qube_led_probe(struct platform_device *pdev)
led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT; led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
writeb(led_value, led_port); writeb(led_value, led_port);
retval = led_classdev_register(&pdev->dev, &qube_front_led); return devm_led_classdev_register(&pdev->dev, &qube_front_led);
if (retval)
goto err_null;
return 0;
err_null:
led_port = NULL;
return retval;
}
static int cobalt_qube_led_remove(struct platform_device *pdev)
{
led_classdev_unregister(&qube_front_led);
if (led_port)
led_port = NULL;
return 0;
} }
static struct platform_driver cobalt_qube_led_driver = { static struct platform_driver cobalt_qube_led_driver = {
.probe = cobalt_qube_led_probe, .probe = cobalt_qube_led_probe,
.remove = cobalt_qube_led_remove,
.driver = { .driver = {
.name = "cobalt-qube-leds", .name = "cobalt-qube-leds",
}, },
......
...@@ -291,9 +291,22 @@ static int gpio_led_remove(struct platform_device *pdev) ...@@ -291,9 +291,22 @@ static int gpio_led_remove(struct platform_device *pdev)
return 0; return 0;
} }
static void gpio_led_shutdown(struct platform_device *pdev)
{
struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
int i;
for (i = 0; i < priv->num_leds; i++) {
struct gpio_led_data *led = &priv->leds[i];
gpio_led_set(&led->cdev, LED_OFF);
}
}
static struct platform_driver gpio_led_driver = { static struct platform_driver gpio_led_driver = {
.probe = gpio_led_probe, .probe = gpio_led_probe,
.remove = gpio_led_remove, .remove = gpio_led_remove,
.shutdown = gpio_led_shutdown,
.driver = { .driver = {
.name = "leds-gpio", .name = "leds-gpio",
.of_match_table = of_gpio_leds_match, .of_match_table = of_gpio_leds_match,
......
...@@ -59,28 +59,15 @@ static int hp6xxled_probe(struct platform_device *pdev) ...@@ -59,28 +59,15 @@ static int hp6xxled_probe(struct platform_device *pdev)
{ {
int ret; int ret;
ret = led_classdev_register(&pdev->dev, &hp6xx_red_led); ret = devm_led_classdev_register(&pdev->dev, &hp6xx_red_led);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = led_classdev_register(&pdev->dev, &hp6xx_green_led); return devm_led_classdev_register(&pdev->dev, &hp6xx_green_led);
if (ret < 0)
led_classdev_unregister(&hp6xx_red_led);
return ret;
}
static int hp6xxled_remove(struct platform_device *pdev)
{
led_classdev_unregister(&hp6xx_red_led);
led_classdev_unregister(&hp6xx_green_led);
return 0;
} }
static struct platform_driver hp6xxled_driver = { static struct platform_driver hp6xxled_driver = {
.probe = hp6xxled_probe, .probe = hp6xxled_probe,
.remove = hp6xxled_remove,
.driver = { .driver = {
.name = "hp6xx-led", .name = "hp6xx-led",
}, },
......
...@@ -111,7 +111,7 @@ static int micro_leds_probe(struct platform_device *pdev) ...@@ -111,7 +111,7 @@ static int micro_leds_probe(struct platform_device *pdev)
{ {
int ret; int ret;
ret = led_classdev_register(&pdev->dev, &micro_led); ret = devm_led_classdev_register(&pdev->dev, &micro_led);
if (ret) { if (ret) {
dev_err(&pdev->dev, "registering led failed: %d\n", ret); dev_err(&pdev->dev, "registering led failed: %d\n", ret);
return ret; return ret;
...@@ -121,18 +121,11 @@ static int micro_leds_probe(struct platform_device *pdev) ...@@ -121,18 +121,11 @@ static int micro_leds_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int micro_leds_remove(struct platform_device *pdev)
{
led_classdev_unregister(&micro_led);
return 0;
}
static struct platform_driver micro_leds_device_driver = { static struct platform_driver micro_leds_device_driver = {
.driver = { .driver = {
.name = "ipaq-micro-leds", .name = "ipaq-micro-leds",
}, },
.probe = micro_leds_probe, .probe = micro_leds_probe,
.remove = micro_leds_remove,
}; };
module_platform_driver(micro_leds_device_driver); module_platform_driver(micro_leds_device_driver);
......
...@@ -59,23 +59,13 @@ static int locomoled_probe(struct locomo_dev *ldev) ...@@ -59,23 +59,13 @@ static int locomoled_probe(struct locomo_dev *ldev)
{ {
int ret; int ret;
ret = led_classdev_register(&ldev->dev, &locomo_led0); ret = devm_led_classdev_register(&ldev->dev, &locomo_led0);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = led_classdev_register(&ldev->dev, &locomo_led1); return devm_led_classdev_register(&ldev->dev, &locomo_led1);
if (ret < 0)
led_classdev_unregister(&locomo_led0);
return ret;
} }
static int locomoled_remove(struct locomo_dev *dev)
{
led_classdev_unregister(&locomo_led0);
led_classdev_unregister(&locomo_led1);
return 0;
}
static struct locomo_driver locomoled_driver = { static struct locomo_driver locomoled_driver = {
.drv = { .drv = {
...@@ -83,7 +73,6 @@ static struct locomo_driver locomoled_driver = { ...@@ -83,7 +73,6 @@ static struct locomo_driver locomoled_driver = {
}, },
.devid = LOCOMO_DEVID_LED, .devid = LOCOMO_DEVID_LED,
.probe = locomoled_probe, .probe = locomoled_probe,
.remove = locomoled_remove,
}; };
static int __init locomoled_init(void) static int __init locomoled_init(void)
......
...@@ -87,36 +87,20 @@ static int menf21bmc_led_probe(struct platform_device *pdev) ...@@ -87,36 +87,20 @@ static int menf21bmc_led_probe(struct platform_device *pdev)
leds[i].cdev.name = leds[i].name; leds[i].cdev.name = leds[i].name;
leds[i].cdev.brightness_set = menf21bmc_led_set; leds[i].cdev.brightness_set = menf21bmc_led_set;
leds[i].i2c_client = i2c_client; leds[i].i2c_client = i2c_client;
ret = led_classdev_register(&pdev->dev, &leds[i].cdev); ret = devm_led_classdev_register(&pdev->dev, &leds[i].cdev);
if (ret < 0) if (ret < 0) {
goto err_free_leds; dev_err(&pdev->dev, "failed to register LED device\n");
return ret;
}
} }
dev_info(&pdev->dev, "MEN 140F21P00 BMC LED device enabled\n"); dev_info(&pdev->dev, "MEN 140F21P00 BMC LED device enabled\n");
return 0; return 0;
err_free_leds:
dev_err(&pdev->dev, "failed to register LED device\n");
for (i = i - 1; i >= 0; i--)
led_classdev_unregister(&leds[i].cdev);
return ret;
}
static int menf21bmc_led_remove(struct platform_device *pdev)
{
int i;
for (i = 0; i < ARRAY_SIZE(leds); i++)
led_classdev_unregister(&leds[i].cdev);
return 0;
} }
static struct platform_driver menf21bmc_led = { static struct platform_driver menf21bmc_led = {
.probe = menf21bmc_led_probe, .probe = menf21bmc_led_probe,
.remove = menf21bmc_led_remove,
.driver = { .driver = {
.name = "menf21bmc_led", .name = "menf21bmc_led",
}, },
......
...@@ -39,18 +39,11 @@ static struct led_classdev net48xx_error_led = { ...@@ -39,18 +39,11 @@ static struct led_classdev net48xx_error_led = {
static int net48xx_led_probe(struct platform_device *pdev) static int net48xx_led_probe(struct platform_device *pdev)
{ {
return led_classdev_register(&pdev->dev, &net48xx_error_led); return devm_led_classdev_register(&pdev->dev, &net48xx_error_led);
}
static int net48xx_led_remove(struct platform_device *pdev)
{
led_classdev_unregister(&net48xx_error_led);
return 0;
} }
static struct platform_driver net48xx_led_driver = { static struct platform_driver net48xx_led_driver = {
.probe = net48xx_led_probe, .probe = net48xx_led_probe,
.remove = net48xx_led_remove,
.driver = { .driver = {
.name = DRVNAME, .name = DRVNAME,
}, },
......
This diff is collapsed.
...@@ -124,9 +124,9 @@ static int ot200_led_probe(struct platform_device *pdev) ...@@ -124,9 +124,9 @@ static int ot200_led_probe(struct platform_device *pdev)
leds[i].cdev.name = leds[i].name; leds[i].cdev.name = leds[i].name;
leds[i].cdev.brightness_set = ot200_led_brightness_set; leds[i].cdev.brightness_set = ot200_led_brightness_set;
ret = led_classdev_register(&pdev->dev, &leds[i].cdev); ret = devm_led_classdev_register(&pdev->dev, &leds[i].cdev);
if (ret < 0) if (ret < 0)
goto err; return ret;
} }
leds_front = 0; /* turn off all front leds */ leds_front = 0; /* turn off all front leds */
...@@ -135,27 +135,10 @@ static int ot200_led_probe(struct platform_device *pdev) ...@@ -135,27 +135,10 @@ static int ot200_led_probe(struct platform_device *pdev)
outb(leds_back, 0x5a); outb(leds_back, 0x5a);
return 0; return 0;
err:
for (i = i - 1; i >= 0; i--)
led_classdev_unregister(&leds[i].cdev);
return ret;
}
static int ot200_led_remove(struct platform_device *pdev)
{
int i;
for (i = 0; i < ARRAY_SIZE(leds); i++)
led_classdev_unregister(&leds[i].cdev);
return 0;
} }
static struct platform_driver ot200_led_driver = { static struct platform_driver ot200_led_driver = {
.probe = ot200_led_probe, .probe = ot200_led_probe,
.remove = ot200_led_remove,
.driver = { .driver = {
.name = "leds-ot200", .name = "leds-ot200",
}, },
......
...@@ -262,15 +262,19 @@ static int powernv_led_classdev(struct platform_device *pdev, ...@@ -262,15 +262,19 @@ static int powernv_led_classdev(struct platform_device *pdev,
while ((cur = of_prop_next_string(p, cur)) != NULL) { while ((cur = of_prop_next_string(p, cur)) != NULL) {
powernv_led = devm_kzalloc(dev, sizeof(*powernv_led), powernv_led = devm_kzalloc(dev, sizeof(*powernv_led),
GFP_KERNEL); GFP_KERNEL);
if (!powernv_led) if (!powernv_led) {
of_node_put(np);
return -ENOMEM; return -ENOMEM;
}
powernv_led->common = powernv_led_common; powernv_led->common = powernv_led_common;
powernv_led->loc_code = (char *)np->name; powernv_led->loc_code = (char *)np->name;
rc = powernv_led_create(dev, powernv_led, cur); rc = powernv_led_create(dev, powernv_led, cur);
if (rc) if (rc) {
of_node_put(np);
return rc; return rc;
}
} /* while end */ } /* while end */
} }
......
...@@ -59,6 +59,7 @@ static int sead3_led_remove(struct platform_device *pdev) ...@@ -59,6 +59,7 @@ static int sead3_led_remove(struct platform_device *pdev)
{ {
led_classdev_unregister(&sead3_pled); led_classdev_unregister(&sead3_pled);
led_classdev_unregister(&sead3_fled); led_classdev_unregister(&sead3_fled);
return 0; return 0;
} }
......
...@@ -76,39 +76,19 @@ static int wrap_led_probe(struct platform_device *pdev) ...@@ -76,39 +76,19 @@ static int wrap_led_probe(struct platform_device *pdev)
{ {
int ret; int ret;
ret = led_classdev_register(&pdev->dev, &wrap_power_led); ret = devm_led_classdev_register(&pdev->dev, &wrap_power_led);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = led_classdev_register(&pdev->dev, &wrap_error_led); ret = devm_led_classdev_register(&pdev->dev, &wrap_error_led);
if (ret < 0) if (ret < 0)
goto err1;
ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
if (ret < 0)
goto err2;
return ret;
err2:
led_classdev_unregister(&wrap_error_led);
err1:
led_classdev_unregister(&wrap_power_led);
return ret; return ret;
}
static int wrap_led_remove(struct platform_device *pdev) return devm_led_classdev_register(&pdev->dev, &wrap_extra_led);
{
led_classdev_unregister(&wrap_power_led);
led_classdev_unregister(&wrap_error_led);
led_classdev_unregister(&wrap_extra_led);
return 0;
} }
static struct platform_driver wrap_led_driver = { static struct platform_driver wrap_led_driver = {
.probe = wrap_led_probe, .probe = wrap_led_probe,
.remove = wrap_led_remove,
.driver = { .driver = {
.name = DRVNAME, .name = DRVNAME,
}, },
......
...@@ -44,6 +44,7 @@ static inline int led_get_brightness(struct led_classdev *led_cdev) ...@@ -44,6 +44,7 @@ static inline int led_get_brightness(struct led_classdev *led_cdev)
return led_cdev->brightness; return led_cdev->brightness;
} }
void led_init_core(struct led_classdev *led_cdev);
void led_stop_software_blink(struct led_classdev *led_cdev); void led_stop_software_blink(struct led_classdev *led_cdev);
extern struct rw_semaphore leds_list_lock; extern struct rw_semaphore leds_list_lock;
......
...@@ -27,6 +27,7 @@ struct heartbeat_trig_data { ...@@ -27,6 +27,7 @@ struct heartbeat_trig_data {
unsigned int phase; unsigned int phase;
unsigned int period; unsigned int period;
struct timer_list timer; struct timer_list timer;
unsigned int invert;
}; };
static void led_heartbeat_function(unsigned long data) static void led_heartbeat_function(unsigned long data)
...@@ -56,21 +57,27 @@ static void led_heartbeat_function(unsigned long data) ...@@ -56,21 +57,27 @@ static void led_heartbeat_function(unsigned long data)
msecs_to_jiffies(heartbeat_data->period); msecs_to_jiffies(heartbeat_data->period);
delay = msecs_to_jiffies(70); delay = msecs_to_jiffies(70);
heartbeat_data->phase++; heartbeat_data->phase++;
if (!heartbeat_data->invert)
brightness = led_cdev->max_brightness; brightness = led_cdev->max_brightness;
break; break;
case 1: case 1:
delay = heartbeat_data->period / 4 - msecs_to_jiffies(70); delay = heartbeat_data->period / 4 - msecs_to_jiffies(70);
heartbeat_data->phase++; heartbeat_data->phase++;
if (heartbeat_data->invert)
brightness = led_cdev->max_brightness;
break; break;
case 2: case 2:
delay = msecs_to_jiffies(70); delay = msecs_to_jiffies(70);
heartbeat_data->phase++; heartbeat_data->phase++;
if (!heartbeat_data->invert)
brightness = led_cdev->max_brightness; brightness = led_cdev->max_brightness;
break; break;
default: default:
delay = heartbeat_data->period - heartbeat_data->period / 4 - delay = heartbeat_data->period - heartbeat_data->period / 4 -
msecs_to_jiffies(70); msecs_to_jiffies(70);
heartbeat_data->phase = 0; heartbeat_data->phase = 0;
if (heartbeat_data->invert)
brightness = led_cdev->max_brightness;
break; break;
} }
...@@ -78,15 +85,50 @@ static void led_heartbeat_function(unsigned long data) ...@@ -78,15 +85,50 @@ static void led_heartbeat_function(unsigned long data)
mod_timer(&heartbeat_data->timer, jiffies + delay); mod_timer(&heartbeat_data->timer, jiffies + delay);
} }
static ssize_t led_invert_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data;
return sprintf(buf, "%u\n", heartbeat_data->invert);
}
static ssize_t led_invert_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct heartbeat_trig_data *heartbeat_data = led_cdev->trigger_data;
unsigned long state;
int ret;
ret = kstrtoul(buf, 0, &state);
if (ret)
return ret;
heartbeat_data->invert = !!state;
return size;
}
static DEVICE_ATTR(invert, 0644, led_invert_show, led_invert_store);
static void heartbeat_trig_activate(struct led_classdev *led_cdev) static void heartbeat_trig_activate(struct led_classdev *led_cdev)
{ {
struct heartbeat_trig_data *heartbeat_data; struct heartbeat_trig_data *heartbeat_data;
int rc;
heartbeat_data = kzalloc(sizeof(*heartbeat_data), GFP_KERNEL); heartbeat_data = kzalloc(sizeof(*heartbeat_data), GFP_KERNEL);
if (!heartbeat_data) if (!heartbeat_data)
return; return;
led_cdev->trigger_data = heartbeat_data; led_cdev->trigger_data = heartbeat_data;
rc = device_create_file(led_cdev->dev, &dev_attr_invert);
if (rc) {
kfree(led_cdev->trigger_data);
return;
}
setup_timer(&heartbeat_data->timer, setup_timer(&heartbeat_data->timer,
led_heartbeat_function, (unsigned long) led_cdev); led_heartbeat_function, (unsigned long) led_cdev);
heartbeat_data->phase = 0; heartbeat_data->phase = 0;
...@@ -100,6 +142,7 @@ static void heartbeat_trig_deactivate(struct led_classdev *led_cdev) ...@@ -100,6 +142,7 @@ static void heartbeat_trig_deactivate(struct led_classdev *led_cdev)
if (led_cdev->activated) { if (led_cdev->activated) {
del_timer_sync(&heartbeat_data->timer); del_timer_sync(&heartbeat_data->timer);
device_remove_file(led_cdev->dev, &dev_attr_invert);
kfree(heartbeat_data); kfree(heartbeat_data);
led_cdev->activated = false; led_cdev->activated = false;
} }
......
/* /*
* Board functions for Marvell System On Chip * This header provides constants for netxbig LED bindings.
*
* Copyright (C) 2014
*
* Andrew Lunn <andrew@lunn.ch>
* *
* This file is licensed under the terms of the GNU General Public * This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any * License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied. * warranty of any kind, whether express or implied.
*/ */
#ifndef __ARCH_MVEBU_BOARD_H #ifndef _DT_BINDINGS_LEDS_NETXBIG_H
#define __ARCH_MVEBU_BOARD_H #define _DT_BINDINGS_LEDS_NETXBIG_H
#define NETXBIG_LED_OFF 0
#define NETXBIG_LED_ON 1
#define NETXBIG_LED_SATA 2
#define NETXBIG_LED_TIMER1 3
#define NETXBIG_LED_TIMER2 4
#ifdef CONFIG_MACH_NETXBIG #endif /* _DT_BINDINGS_LEDS_NETXBIG_H */
void netxbig_init(void);
#else
static inline void netxbig_init(void) {};
#endif
#endif
...@@ -40,6 +40,7 @@ struct netxbig_led { ...@@ -40,6 +40,7 @@ struct netxbig_led {
int mode_addr; int mode_addr;
int *mode_val; int *mode_val;
int bright_addr; int bright_addr;
int bright_max;
}; };
struct netxbig_led_platform_data { struct netxbig_led_platform_data {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment