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

Commit 2b69703f authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull LED subsystem updates from Bryan Wu:
 - move LED trigger drivers into a new directory
 - lp55xx common driver updates
 - other led drivers updates and bug fixing

* 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
  leds: leds-asic3: switch to using SIMPLE_DEV_PM_OPS
  leds: leds-bd2802: add CONFIG_PM_SLEEP to suspend/resume functions
  leds: lp55xx: configure the clock detection
  leds: lp55xx: use common clock framework when external clock is used
  leds: leds-ns2: fix oops at module removal
  leds: leds-pwm: Defer led_pwm_set() if PWM can sleep
  leds: lp55xx: fix the sysfs read operation
  leds: lm355x, lm3642: support camera LED triggers for flash and torch
  leds: add camera LED triggers
  leds: trigger: use inline functions instead of macros
  leds: tca6507: Use of_match_ptr() macro
  leds: wm8350: Complain if we fail to reenable DCDC
  leds: renesas: set gpio_request_one() flags param correctly
  leds: leds-ns2: set devm_gpio_request_one() flags param correctly
  leds: leds-lt3593: set devm_gpio_request_one() flags param correctly
  leds: leds-bd2802: remove erroneous __exit annotation
  leds: atmel-pwm: remove erroneous __exit annotation
  leds: move LED trigger drivers into new subdirectory
  leds: add new LP5562 LED driver
parents 30c67e93 df92d5ff
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ 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-lp5562.txt
	- notes on how to use the leds-lp5562 driver.
leds-lp55xx.txt
	- description about lp55xx common driver.
leds-lm3556.txt
+0 −19
Original line number Diff line number Diff line
@@ -81,22 +81,3 @@ static struct lp55xx_platform_data lp5521_platform_data = {

If the current is set to 0 in the platform data, that channel is
disabled and it is not visible in the sysfs.

The 'update_config' : CONFIG register (ADDR 08h)
This value is platform-specific data.
If update_config is not defined, the CONFIG register is set with
'LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT'.
(Enable auto-powersave, set charge pump to auto, red to battery)

example of update_config :

#define LP5521_CONFIGS	(LP5521_PWM_HF | LP5521_PWRSAVE_EN | \
			LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT | \
			LP5521_CLK_INT)

static struct lp55xx_platform_data lp5521_pdata = {
	.led_config = lp5521_led_config,
	.num_channels = ARRAY_SIZE(lp5521_led_config),
	.clock_mode = LP55XX_CLOCK_INT,
	.update_config = LP5521_CONFIGS,
};
+120 −0
Original line number Diff line number Diff line
Kernel driver for LP5562
========================

* TI LP5562 LED Driver

Author: Milo(Woogyom) Kim <milo.kim@ti.com>

Description

  LP5562 can drive up to 4 channels. R/G/B and White.
  LEDs can be controlled directly via the led class control interface.

  All four channels can be also controlled using the engine micro programs.
  LP5562 has the internal program memory for running various LED patterns.
  For the details, please refer to 'firmware' section in leds-lp55xx.txt

Device attribute: engine_mux

  3 Engines are allocated in LP5562, but the number of channel is 4.
  Therefore each channel should be mapped to the engine number.
  Value : RGB or W

  This attribute is used for programming LED data with the firmware interface.
  Unlike the LP5521/LP5523/55231, LP5562 has unique feature for the engine mux,
  so additional sysfs is required.

  LED Map
  Red   ... Engine 1 (fixed)
  Green ... Engine 2 (fixed)
  Blue  ... Engine 3 (fixed)
  White ... Engine 1 or 2 or 3 (selective)

How to load the program data using engine_mux

  Before loading the LP5562 program data, engine_mux should be written between
  the engine selection and loading the firmware.
  Engine mux has two different mode, RGB and W.
  RGB is used for loading RGB program data, W is used for W program data.

  For example, run blinking green channel pattern,
  echo 2 > /sys/bus/i2c/devices/xxxx/select_engine     # 2 is for green channel
  echo "RGB" > /sys/bus/i2c/devices/xxxx/engine_mux    # engine mux for RGB
  echo 1 > /sys/class/firmware/lp5562/loading
  echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
  echo 0 > /sys/class/firmware/lp5562/loading
  echo 1 > /sys/bus/i2c/devices/xxxx/run_engine

  To run a blinking white pattern,
  echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
  echo "W" > /sys/bus/i2c/devices/xxxx/engine_mux
  echo 1 > /sys/class/firmware/lp5562/loading
  echo "4000600040FF6000" > /sys/class/firmware/lp5562/data
  echo 0 > /sys/class/firmware/lp5562/loading
  echo 1 > /sys/bus/i2c/devices/xxxx/run_engine

How to load the predefined patterns

  Please refer to 'leds-lp55xx.txt"

Setting Current of Each Channel

  Like LP5521 and LP5523/55231, LP5562 provides LED current settings.
  The 'led_current' and 'max_current' are used.

(Example of Platform data)

To configure the platform specific data, lp55xx_platform_data structure is used.

static struct lp55xx_led_config lp5562_led_config[] = {
	{
		.name 		= "R",
		.chan_nr	= 0,
		.led_current	= 20,
		.max_current	= 40,
	},
	{
		.name 		= "G",
		.chan_nr	= 1,
		.led_current	= 20,
		.max_current	= 40,
	},
	{
		.name 		= "B",
		.chan_nr	= 2,
		.led_current	= 20,
		.max_current	= 40,
	},
	{
		.name 		= "W",
		.chan_nr	= 3,
		.led_current	= 20,
		.max_current	= 40,
	},
};

static int lp5562_setup(void)
{
	/* setup HW resources */
}

static void lp5562_release(void)
{
	/* Release HW resources */
}

static void lp5562_enable(bool state)
{
	/* Control of chip enable signal */
}

static struct lp55xx_platform_data lp5562_platform_data = {
        .led_config     = lp5562_led_config,
        .num_channels   = ARRAY_SIZE(lp5562_led_config),
        .setup_resources   = lp5562_setup,
        .release_resources = lp5562_release,
        .enable            = lp5562_enable,
};

If the current is set to 0 in the platform data, that channel is
disabled and it is not visible in the sysfs.
+45 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ Authors: Milo(Woogyom) Kim <milo.kim@ti.com>

Description
-----------
LP5521, LP5523/55231 have common features as below.
LP5521, LP5523/55231 and LP5562 have common features as below.

  Register access via the I2C
  Device initialization/deinitialization
@@ -116,3 +116,47 @@ To support this, 'run_engine' and 'firmware_cb' are configurable in each driver.
run_engine  : Control the selected engine
firmware_cb : The callback function after loading the firmware is done.
              Chip specific commands for loading and updating program memory.

( Predefined pattern data )

Without the firmware interface, LP55xx driver provides another method for
loading a LED pattern. That is 'predefined' pattern.
A predefined pattern is defined in the platform data and load it(or them)
via the sysfs if needed.
To use the predefined pattern concept, 'patterns' and 'num_patterns' should be
configured.

  Example of predefined pattern data:

  /* mode_1: blinking data */
  static const u8 mode_1[] = {
		0x40, 0x00, 0x60, 0x00, 0x40, 0xFF, 0x60, 0x00,
		};

  /* mode_2: always on */
  static const u8 mode_2[] = { 0x40, 0xFF, };

  struct lp55xx_predef_pattern board_led_patterns[] = {
	{
		.r = mode_1,
		.size_r = ARRAY_SIZE(mode_1),
	},
	{
		.b = mode_2,
		.size_b = ARRAY_SIZE(mode_2),
	},
  }

  struct lp55xx_platform_data lp5562_pdata = {
  ...
	.patterns      = board_led_patterns,
	.num_patterns  = ARRAY_SIZE(board_led_patterns),
  };

Then, mode_1 and mode_2 can be run via through the sysfs.

  echo 1 > /sys/bus/i2c/devices/xxxx/led_pattern    # red blinking LED pattern
  echo 2 > /sys/bus/i2c/devices/xxxx/led_pattern    # blue LED always on

To stop running pattern,
  echo 0 > /sys/bus/i2c/devices/xxxx/led_pattern
+13 −102
Original line number Diff line number Diff line
@@ -194,8 +194,8 @@ config LEDS_LP3944
	  module will be called leds-lp3944.

config LEDS_LP55XX_COMMON
	tristate "Common Driver for TI/National LP5521 and LP5523/55231"
	depends on LEDS_LP5521 || LEDS_LP5523
	tristate "Common Driver for TI/National LP5521, LP5523/55231 and LP5562"
	depends on LEDS_LP5521 || LEDS_LP5523 || LEDS_LP5562
	select FW_LOADER
	help
	  This option supports common operations for LP5521 and LP5523/55231
@@ -222,6 +222,16 @@ config LEDS_LP5523
	  Driver provides direct control via LED class and interface for
	  programming the engines.

config LEDS_LP5562
	tristate "LED Support for TI LP5562 LED driver chip"
	depends on LEDS_CLASS && I2C
	select LEDS_LP55XX_COMMON
	help
	  If you say yes here you get support for TI LP5562 LED driver.
	  It is 4 channels chip with programmable engines.
	  Driver provides direct control via LED class and interface for
	  programming the engines.

config LEDS_LP8788
	tristate "LED support for the TI LP8788 PMIC"
	depends on LEDS_CLASS
@@ -469,106 +479,7 @@ config LEDS_BLINKM
	  This option enables support for the BlinkM RGB LED connected
	  through I2C. Say Y to enable support for the BlinkM LED.

config LEDS_TRIGGERS
	bool "LED Trigger support"
	depends on LEDS_CLASS
	help
	  This option enables trigger support for the leds class.
	  These triggers allow kernel events to drive the LEDs and can
	  be configured via sysfs. If unsure, say Y.

comment "LED Triggers"

config LEDS_TRIGGER_TIMER
	tristate "LED Timer Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be controlled by a programmable timer
	  via sysfs. Some LED hardware can be programmed to start
	  blinking the LED without any further software interaction.
	  For more details read Documentation/leds/leds-class.txt.

	  If unsure, say Y.

config LEDS_TRIGGER_ONESHOT
	tristate "LED One-shot Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to blink in one-shot pulses with parameters
	  controlled via sysfs.  It's useful to notify the user on
	  sporadic events, when there are no clear begin and end trap points,
	  or on dense events, where this blinks the LED at constant rate if
	  rearmed continuously.

	  It also shows how to use the led_blink_set_oneshot() function.

	  If unsure, say Y.

config LEDS_TRIGGER_IDE_DISK
	bool "LED IDE Disk Trigger"
	depends on IDE_GD_ATA
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be controlled by IDE disk activity.
	  If unsure, say Y.

config LEDS_TRIGGER_HEARTBEAT
	tristate "LED Heartbeat Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be controlled by a CPU load average.
	  The flash frequency is a hyperbolic function of the 1-minute
	  load average.
	  If unsure, say Y.

config LEDS_TRIGGER_BACKLIGHT
	tristate "LED backlight Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be controlled as a backlight device: they
	  turn off and on when the display is blanked and unblanked.

	  If unsure, say N.

config LEDS_TRIGGER_CPU
	bool "LED CPU Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be controlled by active CPUs. This shows
	  the active CPUs across an array of LEDs so you can see which
	  CPUs are active on the system at any given moment.

	  If unsure, say N.

config LEDS_TRIGGER_GPIO
	tristate "LED GPIO Trigger"
	depends on LEDS_TRIGGERS
	depends on GPIOLIB
	help
	  This allows LEDs to be controlled by gpio events. It's good
	  when using gpios as switches and triggering the needed LEDs
	  from there. One use case is n810's keypad LEDs that could
	  be triggered by this trigger when user slides up to show
	  keypad.

	  If unsure, say N.

config LEDS_TRIGGER_DEFAULT_ON
	tristate "LED Default ON Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows LEDs to be initialised in the ON state.
	  If unsure, say Y.

comment "iptables trigger is under Netfilter config (LED target)"
	depends on LEDS_TRIGGERS

config LEDS_TRIGGER_TRANSIENT
	tristate "LED Transient Trigger"
	depends on LEDS_TRIGGERS
	help
	  This allows one time activation of a transient state on
	  GPIO/PWM based hardware.
	  If unsure, say Y.
source "drivers/leds/trigger/Kconfig"

endif # NEW_LEDS
Loading