Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0512c04a authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull LED subsystem update from Bryan Wu.

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds: (61 commits)
  leds: leds-sunfire: use dev_err()/pr_err() instead of printk()
  leds: 88pm860x: Add missing of_node_put()
  leds: tca6507: Use of_get_child_count()
  leds: leds-pwm: make it depend on PWM and not HAVE_PWM
  Documentation: leds: update LP55xx family devices
  leds-lp55xx: fix problem on removing LED attributes
  leds-lp5521/5523: add author and copyright description
  leds-lp5521/5523: use new lp55xx common header
  leds-lp55xx: clean up headers
  leds-lp55xx: clean up definitions
  leds-lp55xx: clean up unused data and functions
  leds-lp55xx: clean up _remove()
  leds-lp55xx: add new function for removing device attribtues
  leds-lp55xx: code refactoring on selftest function
  leds-lp55xx: use common device attribute driver function
  leds-lp55xx: support device specific attributes
  leds-lp5523: use generic firmware interface
  leds-lp5521: use generic firmware interface
  leds-lp55xx: support firmware interface
  leds-lp55xx: add new lp55xx_register_sysfs() for the firmware interface
  ...
parents 5115f3c1 4b07c5d5
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
LED connected to PWM

Required properties:
- compatible : should be "pwm-leds".

Each LED is represented as a sub-node of the pwm-leds device.  Each
node's name represents the name of the corresponding LED.

LED sub-node properties:
- pwms : PWM property to point to the PWM device (phandle)/port (id) and to
  specify the period time to be used: <&phandle id period_ns>;
- pwm-names : (optional) Name to be used by the PWM subsystem for the PWM device
  For the pwms and pwm-names property please refer to:
  Documentation/devicetree/bindings/pwm/pwm.txt
- max-brightness : Maximum brightness possible for the LED
- label :  (optional)
  see Documentation/devicetree/bindings/leds/common.txt
- linux,default-trigger :  (optional)
  see Documentation/devicetree/bindings/leds/common.txt

Example:

twl_pwm: pwm {
	/* provides two PWMs (id 0, 1 for PWM1 and PWM2) */
	compatible = "ti,twl6030-pwm";
	#pwm-cells = <2>;
};

twl_pwmled: pwmled {
	/* provides one PWM (id 0 for Charing indicator LED) */
	compatible = "ti,twl6030-pwmled";
	#pwm-cells = <2>;
};

pwmleds {
	compatible = "pwm-leds";
	kpad {
		label = "omap4::keypad";
		pwms = <&twl_pwm 0 7812500>;
		max-brightness = <127>;
	};

	charging {
		label = "omap4:green:chrg";
		pwms = <&twl_pwmled 0 7812500>;
		max-brightness = <255>;
	};
};
+33 −0
Original line number Diff line number Diff line
LEDs conected to tca6507

Required properties:
- compatible : should be : "ti,tca6507".

Each led is represented as a sub-node of the ti,tca6507 device.

LED sub-node properties:
- label : (optional) see Documentation/devicetree/bindings/leds/common.txt
- reg : number of LED line (could be from 0 to 6)
- linux,default-trigger : (optional)
   see Documentation/devicetree/bindings/leds/common.txt

Examples:

tca6507@45 {
	compatible = "ti,tca6507";
	#address-cells = <1>;
	#size-cells = <0>;
	reg = <0x45>;

	led0: red-aux@0 {
		label = "red:aux";
		reg = <0x0>;
	};

	led1: green-aux@1 {
		label = "green:aux";
		reg = <0x5>;
		linux,default-trigger = "default-on";
	};
};
+2 −0
Original line number Diff line number Diff line
@@ -6,5 +6,7 @@ leds-lp5521.txt
	- notes on how to use the leds-lp5521 driver.
leds-lp5523.txt
	- notes on how to use the leds-lp5523 driver.
leds-lp55xx.txt
	- description about lp55xx common driver.
leds-lm3556.txt
	- notes on how to use the leds-lm3556 driver.
+7 −56
Original line number Diff line number Diff line
@@ -17,19 +17,8 @@ lp5521:channelx, where x is 0 .. 2
All three channels can be also controlled using the engine micro programs.
More details of the instructions can be found from the public data sheet.

Control interface for the engines:
x is 1 .. 3
enginex_mode : disabled, load, run
enginex_load : store program (visible only in engine load mode)

Example (start to blink the channel 2 led):
cd   /sys/class/leds/lp5521:channel2/device
echo "load" > engine3_mode
echo "037f4d0003ff6000" > engine3_load
echo "run" > engine3_mode

stop the engine:
echo "disabled" > engine3_mode
LP5521 has the internal program memory for running various LED patterns.
For the details, please refer to 'firmware' section in leds-lp55xx.txt

sysfs contains a selftest entry.
The test communicates with the chip and checks that
@@ -47,7 +36,7 @@ The name of each channel can be configurable.
If the name field is not defined, the default name will be set to 'xxxx:channelN'
(XXXX : pdata->label or i2c client name, N : channel number)

static struct lp5521_led_config lp5521_led_config[] = {
static struct lp55xx_led_config lp5521_led_config[] = {
        {
		.name = "red",
                .chan_nr        = 0,
@@ -81,10 +70,10 @@ static void lp5521_enable(bool state)
	/* Control of chip enable signal */
}

static struct lp5521_platform_data lp5521_platform_data = {
static struct lp55xx_platform_data lp5521_platform_data = {
        .led_config     = lp5521_led_config,
        .num_channels   = ARRAY_SIZE(lp5521_led_config),
        .clock_mode     = LP5521_CLOCK_EXT,
        .clock_mode     = LP55XX_CLOCK_EXT,
        .setup_resources   = lp5521_setup,
        .release_resources = lp5521_release,
        .enable            = lp5521_enable,
@@ -105,47 +94,9 @@ example of update_config :
			LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT | \
			LP5521_CLK_INT)

static struct lp5521_platform_data lp5521_pdata = {
static struct lp55xx_platform_data lp5521_pdata = {
	.led_config = lp5521_led_config,
	.num_channels = ARRAY_SIZE(lp5521_led_config),
	.clock_mode = LP5521_CLOCK_INT,
	.clock_mode = LP55XX_CLOCK_INT,
	.update_config = LP5521_CONFIGS,
};

LED patterns : LP5521 has autonomous operation without external control.
Pattern data can be defined in the platform data.

example of led pattern data :

/* RGB(50,5,0) 500ms on, 500ms off, infinite loop */
static u8 pattern_red[] = {
		0x40, 0x32, 0x60, 0x00,	0x40, 0x00, 0x60, 0x00,
		};

static u8 pattern_green[] = {
		0x40, 0x05, 0x60, 0x00, 0x40, 0x00, 0x60, 0x00,
		};

static struct lp5521_led_pattern board_led_patterns[] = {
	{
		.r = pattern_red,
		.g = pattern_green,
		.size_r = ARRAY_SIZE(pattern_red),
		.size_g = ARRAY_SIZE(pattern_green),
	},
};

static struct lp5521_platform_data lp5521_platform_data = {
        .led_config     = lp5521_led_config,
        .num_channels   = ARRAY_SIZE(lp5521_led_config),
        .clock_mode     = LP5521_CLOCK_EXT,
	.patterns = board_led_patterns,
	.num_patterns = ARRAY_SIZE(board_led_patterns),
};

Then predefined led pattern(s) can be executed via the sysfs.
To start the pattern #1,
# echo 1 > /sys/bus/i2c/devices/xxxx/led_pattern
(xxxx : i2c bus & slave address)
To end the pattern,
# echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern
+5 −22
Original line number Diff line number Diff line
@@ -27,25 +27,8 @@ c) Default
If both fields are NULL, 'lp5523' is used by default.
/sys/class/leds/lp5523:channelN  (N: 0 ~ 8)

The chip provides 3 engines. Each engine can control channels without
interaction from the main CPU. Details of the micro engine code can be found
from the public data sheet. Leds can be muxed to different channels.

Control interface for the engines:
x is 1 .. 3
enginex_mode : disabled, load, run
enginex_load : microcode load (visible only in load mode)
enginex_leds : led mux control (visible only in load mode)

cd /sys/class/leds/lp5523:channel2/device
echo "load" > engine3_mode
echo "9d80400004ff05ff437f0000" > engine3_load
echo "111111111" > engine3_leds
echo "run" > engine3_mode

sysfs contains a selftest entry. It measures each channel
voltage level and checks if it looks reasonable. If the level is too high,
the led is missing; if the level is too low, there is a short circuit.
LP5523 has the internal program memory for running various LED patterns.
For the details, please refer to 'firmware' section in leds-lp55xx.txt

Selftest uses always the current from the platform data.

@@ -58,7 +41,7 @@ Example platform data:

Note - chan_nr can have values between 0 and 8.

static struct lp5523_led_config lp5523_led_config[] = {
static struct lp55xx_led_config lp5523_led_config[] = {
        {
		.name		= "D1",
                .chan_nr        = 0,
@@ -88,10 +71,10 @@ static void lp5523_enable(bool state)
	/* Control chip enable signal */
}

static struct lp5523_platform_data lp5523_platform_data = {
static struct lp55xx_platform_data lp5523_platform_data = {
        .led_config     = lp5523_led_config,
        .num_channels   = ARRAY_SIZE(lp5523_led_config),
        .clock_mode     = LP5523_CLOCK_EXT,
        .clock_mode     = LP55XX_CLOCK_EXT,
        .setup_resources   = lp5523_setup,
        .release_resources = lp5523_release,
        .enable            = lp5523_enable,
Loading