Skip to content

Commit

Permalink
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/cooloney/linux-leds

Pull LED subsystem updates from Bryan Wu:
 "In this cycle, we merged some fix and update for LED Flash class
  driver.  Then the core code of LED Flash class driver is in the kernel
  now.  Moreover, we also got some bug fixes, code cleanup and new
  drivers for LED controllers"

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
  leds: Don't treat the LED name as a format string
  leds: Use log level warn instead of info when telling about a name clash
  leds/led-class: Handle LEDs with the same name
  leds: lp8860: Fix typo in MODULE_DESCRIPTION in leds-lp8860.c
  leds: lp8501: Fix typo in MODULE_DESCRIPTION in leds-lp8501.c
  DT: leds: Add uniqueness requirement for 'label' property.
  dt-binding: leds: Add common LED DT bindings macros
  leds: add Qualcomm PM8941 WLED driver
  leds: add DT binding for Qualcomm PM8941 WLED block
  leds: pca963x: Add missing initialiation of struct led_info.flags
  leds: flash: Fix the size of sysfs_groups array
  Documentation: leds: Add description of LED Flash class extension
  leds: flash: document sysfs interface
  leds: flash: Remove synchronized flash strobe feature
  leds: Introduce devres helper for led_classdev_register
  leds: lp8860: make use of devm_gpiod_get_optional
  leds: Let the binding document example for leds-gpio follow the gpio bindings
  leds: flash: remove stray include directive
  leds: leds-pwm: drop one pwm_get_period() call
  • Loading branch information
Linus Torvalds committed Apr 15, 2015
2 parents d0a3997 + ccdc450 commit e7c8241
Show file tree
Hide file tree
Showing 18 changed files with 735 additions and 120 deletions.
80 changes: 80 additions & 0 deletions Documentation/ABI/testing/sysfs-class-led-flash
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
What: /sys/class/leds/<led>/flash_brightness
Date: March 2015
KernelVersion: 4.0
Contact: Jacek Anaszewski <j.anaszewski@samsung.com>
Description: read/write
Set the brightness of this LED in the flash strobe mode, in
microamperes. The file is created only for the flash LED devices
that support setting flash brightness.

The value is between 0 and
/sys/class/leds/<led>/max_flash_brightness.

What: /sys/class/leds/<led>/max_flash_brightness
Date: March 2015
KernelVersion: 4.0
Contact: Jacek Anaszewski <j.anaszewski@samsung.com>
Description: read only
Maximum brightness level for this LED in the flash strobe mode,
in microamperes.

What: /sys/class/leds/<led>/flash_timeout
Date: March 2015
KernelVersion: 4.0
Contact: Jacek Anaszewski <j.anaszewski@samsung.com>
Description: read/write
Hardware timeout for flash, in microseconds. The flash strobe
is stopped after this period of time has passed from the start
of the strobe. The file is created only for the flash LED
devices that support setting flash timeout.

What: /sys/class/leds/<led>/max_flash_timeout
Date: March 2015
KernelVersion: 4.0
Contact: Jacek Anaszewski <j.anaszewski@samsung.com>
Description: read only
Maximum flash timeout for this LED, in microseconds.

What: /sys/class/leds/<led>/flash_strobe
Date: March 2015
KernelVersion: 4.0
Contact: Jacek Anaszewski <j.anaszewski@samsung.com>
Description: read/write
Flash strobe state. When written with 1 it triggers flash strobe
and when written with 0 it turns the flash off.

On read 1 means that flash is currently strobing and 0 means
that flash is off.

What: /sys/class/leds/<led>/flash_fault
Date: March 2015
KernelVersion: 4.0
Contact: Jacek Anaszewski <j.anaszewski@samsung.com>
Description: read only
Space separated list of flash faults that may have occurred.
Flash faults are re-read after strobing the flash. Possible
flash faults:

* led-over-voltage - flash controller voltage to the flash LED
has exceeded the limit specific to the flash controller
* flash-timeout-exceeded - the flash strobe was still on when
the timeout set by the user has expired; not all flash
controllers may set this in all such conditions
* controller-over-temperature - the flash controller has
overheated
* controller-short-circuit - the short circuit protection
of the flash controller has been triggered
* led-power-supply-over-current - current in the LED power
supply has exceeded the limit specific to the flash
controller
* indicator-led-fault - the flash controller has detected
a short or open circuit condition on the indicator LED
* led-under-voltage - flash controller voltage to the flash
LED has been below the minimum limit specific to
the flash
* controller-under-voltage - the input voltage of the flash
controller is below the limit under which strobing the
flash at full current will not be possible;
the condition persists until this flag is no longer set
* led-over-temperature - the temperature of the LED has exceeded
its allowed upper limit
6 changes: 4 additions & 2 deletions Documentation/devicetree/bindings/leds/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ Optional properties for child nodes:
- led-sources : List of device current outputs the LED is connected to. The
outputs are identified by the numbers that must be defined
in the LED device binding documentation.
- label : The label for this LED. If omitted, the label is
taken from the node name (excluding the unit address).
- label : The label for this LED. If omitted, the label is taken from the node
name (excluding the unit address). It has to uniquely identify
a device, i.e. no other LED class device can be assigned the same
label.

- linux,default-trigger : This parameter, if present, is a
string defining the trigger assigned to the LED. Current triggers are:
Expand Down
12 changes: 7 additions & 5 deletions Documentation/devicetree/bindings/leds/leds-gpio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ LED sub-node properties:

Examples:

#include <dt-bindings/gpio/gpio.h>

leds {
compatible = "gpio-leds";
hdd {
label = "IDE Activity";
gpios = <&mcu_pio 0 1>; /* Active low */
gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>;
linux,default-trigger = "ide-disk";
};

fault {
gpios = <&mcu_pio 1 0>;
gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>;
/* Keep LED on if BIOS detected hardware fault */
default-state = "keep";
};
Expand All @@ -44,11 +46,11 @@ leds {
run-control {
compatible = "gpio-leds";
red {
gpios = <&mpc8572 6 0>;
gpios = <&mpc8572 6 GPIO_ACTIVE_HIGH>;
default-state = "off";
};
green {
gpios = <&mpc8572 7 0>;
gpios = <&mpc8572 7 GPIO_ACTIVE_HIGH>;
default-state = "on";
};
};
Expand All @@ -57,7 +59,7 @@ leds {
compatible = "gpio-leds";

charger-led {
gpios = <&gpio1 2 0>;
gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "max8903-charger-charging";
retain-state-suspended;
};
Expand Down
43 changes: 43 additions & 0 deletions Documentation/devicetree/bindings/leds/leds-pm8941-wled.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Binding for Qualcomm PM8941 WLED driver

Required properties:
- compatible: should be "qcom,pm8941-wled"
- reg: slave address

Optional properties:
- label: The label for this led
See Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger: Default trigger assigned to the LED
See Documentation/devicetree/bindings/leds/common.txt
- qcom,cs-out: bool; enable current sink output
- qcom,cabc: bool; enable content adaptive backlight control
- qcom,ext-gen: bool; use externally generated modulator signal to dim
- qcom,current-limit: mA; per-string current limit; value from 0 to 25
default: 20mA
- qcom,current-boost-limit: mA; boost current limit; one of:
105, 385, 525, 805, 980, 1260, 1400, 1680
default: 805mA
- qcom,switching-freq: kHz; switching frequency; one of:
600, 640, 685, 738, 800, 872, 960, 1066, 1200, 1371,
1600, 1920, 2400, 3200, 4800, 9600,
default: 1600kHz
- qcom,ovp: V; Over-voltage protection limit; one of:
27, 29, 32, 35
default: 29V
- qcom,num-strings: #; number of led strings attached; value from 1 to 3
default: 2

Example:

pm8941-wled@d800 {
compatible = "qcom,pm8941-wled";
reg = <0xd800>;
label = "backlight";

qcom,cs-out;
qcom,current-limit = <20>;
qcom,current-boost-limit = <805>;
qcom,switching-freq = <1600>;
qcom,ovp = <29>;
qcom,num-strings = <2>;
};
4 changes: 4 additions & 0 deletions Documentation/driver-model/devres.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ IRQ
devm_request_irq()
devm_request_threaded_irq()

LED
devm_led_classdev_register()
devm_led_classdev_unregister()

MDIO
devm_mdiobus_alloc()
devm_mdiobus_alloc_size()
Expand Down
22 changes: 22 additions & 0 deletions Documentation/leds/leds-class-flash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Flash LED handling under Linux
==============================

Some LED devices provide two modes - torch and flash. In the LED subsystem
those modes are supported by LED class (see Documentation/leds/leds-class.txt)
and LED Flash class respectively. The torch mode related features are enabled
by default and the flash ones only if a driver declares it by setting
LED_DEV_CAP_FLASH flag.

In order to enable the support for flash LEDs CONFIG_LEDS_CLASS_FLASH symbol
must be defined in the kernel config. A LED Flash class driver must be
registered in the LED subsystem with led_classdev_flash_register function.

Following sysfs attributes are exposed for controlling flash LED devices:
(see Documentation/ABI/testing/sysfs-class-led-flash)
- flash_brightness
- max_flash_brightness
- flash_timeout
- max_flash_timeout
- flash_strobe
- flash_fault
8 changes: 8 additions & 0 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,14 @@ config LEDS_VERSATILE
This option enabled support for the LEDs on the ARM Versatile
and RealView boards. Say Y to enabled these.

config LEDS_PM8941_WLED
tristate "LED support for the Qualcomm PM8941 WLED block"
depends on LEDS_CLASS
select REGMAP
help
This option enables support for the 'White' LED block
on Qualcomm PM8941 PMICs.

comment "LED Triggers"
source "drivers/leds/trigger/Kconfig"

Expand Down
1 change: 1 addition & 0 deletions drivers/leds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o
obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o
obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o
obj-$(CONFIG_LEDS_PM8941_WLED) += leds-pm8941-wled.o

# LED SPI Drivers
obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
Expand Down
82 changes: 0 additions & 82 deletions drivers/leds/led-class-flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,75 +216,6 @@ static ssize_t flash_fault_show(struct device *dev,
}
static DEVICE_ATTR_RO(flash_fault);

static ssize_t available_sync_leds_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
char *pbuf = buf;
int i, buf_len;

buf_len = sprintf(pbuf, "[0: none] ");
pbuf += buf_len;

for (i = 0; i < fled_cdev->num_sync_leds; ++i) {
buf_len = sprintf(pbuf, "[%d: %s] ", i + 1,
fled_cdev->sync_leds[i]->led_cdev.name);
pbuf += buf_len;
}

return sprintf(buf, "%s\n", buf);
}
static DEVICE_ATTR_RO(available_sync_leds);

static ssize_t flash_sync_strobe_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
unsigned long led_id;
ssize_t ret;

mutex_lock(&led_cdev->led_access);

if (led_sysfs_is_disabled(led_cdev)) {
ret = -EBUSY;
goto unlock;
}

ret = kstrtoul(buf, 10, &led_id);
if (ret)
goto unlock;

if (led_id > fled_cdev->num_sync_leds) {
ret = -ERANGE;
goto unlock;
}

fled_cdev->sync_led_id = led_id;

ret = size;
unlock:
mutex_unlock(&led_cdev->led_access);
return ret;
}

static ssize_t flash_sync_strobe_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct led_classdev *led_cdev = dev_get_drvdata(dev);
struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
int sled_id = fled_cdev->sync_led_id;
char *sync_led_name = "none";

if (fled_cdev->sync_led_id > 0)
sync_led_name = (char *)
fled_cdev->sync_leds[sled_id - 1]->led_cdev.name;

return sprintf(buf, "[%d: %s]\n", sled_id, sync_led_name);
}
static DEVICE_ATTR_RW(flash_sync_strobe);

static struct attribute *led_flash_strobe_attrs[] = {
&dev_attr_flash_strobe.attr,
NULL,
Expand All @@ -307,12 +238,6 @@ static struct attribute *led_flash_fault_attrs[] = {
NULL,
};

static struct attribute *led_flash_sync_strobe_attrs[] = {
&dev_attr_available_sync_leds.attr,
&dev_attr_flash_sync_strobe.attr,
NULL,
};

static const struct attribute_group led_flash_strobe_group = {
.attrs = led_flash_strobe_attrs,
};
Expand All @@ -329,10 +254,6 @@ static const struct attribute_group led_flash_fault_group = {
.attrs = led_flash_fault_attrs,
};

static const struct attribute_group led_flash_sync_strobe_group = {
.attrs = led_flash_sync_strobe_attrs,
};

static void led_flash_resume(struct led_classdev *led_cdev)
{
struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
Expand Down Expand Up @@ -361,9 +282,6 @@ static void led_flash_init_sysfs_groups(struct led_classdev_flash *fled_cdev)
if (ops->fault_get)
flash_groups[num_sysfs_groups++] = &led_flash_fault_group;

if (led_cdev->flags & LED_DEV_CAP_SYNC_STROBE)
flash_groups[num_sysfs_groups++] = &led_flash_sync_strobe_group;

led_cdev->groups = flash_groups;
}

Expand Down
Loading

0 comments on commit e7c8241

Please sign in to comment.