History log of /drivers/leds/leds-lp55xx-common.c
Revision Date Author Comments
44a1255b03aeedb56cbe7cf27461458bd4513049 25-Jun-2014 Johan Hovold <johan@kernel.org> leds: lp55xx-common: fix attribute-creation race

Use the attribute groups of the led-class to create the LED attributes
during probe in order to avoid racing with userspace.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
660216bf82e0cd65603c0935193c1f7c4aca04fb 25-Jun-2014 Johan Hovold <johan@kernel.org> leds: lp55xx-common: fix sysfs entry leak

Make sure the sysfs group is removed when the LEDs are unregistered.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
93ad8a1d59a35ef7b489a83552daee6506f47815 21-Nov-2013 Milo Kim <milo.kim@ti.com> leds: lp5523: Support LED MUX configuration on running a pattern

There are two ways to run a pattern in LP5523.
One is using legacy sysfs files such as 'enginex_mode','enginex_load' and
'enginex_leds'. ('x' is from 1 to 3).
Among them, 'enginex_leds' are used for selecting specific LED channel MUX.
(MUX means which LEDs are used for running a pattern from LED 1 to 9.)

The other way is using the firmware interface.
In this mode, the default LED MUX strings are used.
In other words, LED MUX is not configurable on the fly.

This patch enables dynamic LED MUX configuration when the firmware is loaded.
By accessing the sysfs file 'enginex_leds', the LED channels can be configured.
To synchronize the operation mode, each engine mode should be set to 'LOAD'.

The documentation is updated as well.

Cc: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
30dae2f98612d7c8cd855861b9de205ebd9ef4fa 22-Oct-2013 Sebastian Reichel <sre@debian.org> leds: lp55xx: handle enable pin in driver

This patch moves the handling of the chip's enable pin from the board
code into the driver. It also updates all board-code files using the
driver to incorporate this change.

This is needed for device tree support of the enable pin.

Signed-off-by: Sebastian Reichel <sre@debian.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
f65f0a1a9836abbfbe5c9b8fa0452e4d8eb7bf00 15-Sep-2013 Linus Walleij <linus.walleij@linaro.org> leds: lp55xx: enable setting default trigger

This enables setting a default trigger on an LP55xx channel,
either from platform data or device tree. This mechanism is
identical to the mechanism for GPIO LEDs and references the
common LEDs device tree bindings.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Milo Kim <milo.kim@ti.com>
Acked-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
33b3a561f417ec3e1013999ce8bdb6c055abb1ce 09-Jul-2013 Kim, Milo <Milo.Kim@ti.com> leds: support new LP8501 device - another LP55xx common

LP8501 can drive up to 9 channels like LP5523.
LEDs can be controlled directly via the I2C and programmable engines are
supported.

LP55xx common driver
LP8501 is one of LP55xx family device, so LP55xx common code are used.
Chip specific data is defined in the structure, 'lp55xx_device_config'.

Differences between LP8501 and LP5523
Different register layout for LED output control and others.
LP8501 specific feature for separate output power selection.
LP8501 doesn't support external clock detection.
Different programming engine data.

LP8501 specific feature - output power selection
Output channels are selected by power selection - Vout or Vdd.
Separate power for VDD1-6 and VDD7-9 are available.
It is configurable in the platform data.
To support this feature, LP55xx DT structure and header are changed.
Device tree binding is updated as well.

LED pattern data
Example pattern data is updated in the driver documentation.

Signed-off-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
2dac912809490ea3a6e5c16b83b54a08f36fc3d9 07-May-2013 Kim, Milo <Milo.Kim@ti.com> leds: lp55xx: support dynamic channel settings in the device tree structure

Currently, the LP55xx DT structure supports max 3 channels.
However, LP5523 has max 9 channels and LP5562 has 4 channels.
To enhance this constraint, the DT structure has been changed.

(a) Use the child node for various channel settings instead of fixed array
(b) Remove 'num_channel' property.
This value can be retrieved by counting the children node.
(c) 'chan-name' property supported
(d) Documentation updates for LP5521 and LP5523

(cooloney@gmail.com: fix a coding style issue in leds-lp55xx.txt)

Cc: Gabriel Fernandez <gabriel.fernandez@stericsson.com>
Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
7542a04b1515f0f878b267beb233c4ef067243fb 23-Apr-2013 Linus Walleij <linus.walleij@linaro.org> leds: lp55xx: add support for Device Tree bindings

This patch allows the lp5521 driver to be successfully probed and
initialised when Device Tree support is enabled.

Based on a patch by Gabriel Fernandez, rewritten in accordance
with review feedback.

Cc: Gabriel Fernandez <gabriel.fernandez@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Milo Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
53b4192266436e75dea96c8ef495eadd6f3df981 21-Mar-2013 Kim, Milo <Milo.Kim@ti.com> leds: lp55xx: use common clock framework when external clock is used

Program execution is timed with 32768Hz clock in the LP55xx family devices.
To run LED functionalities, LP55xx devices provide two options.
One is using internal clock. The other is using external clock.
This patch enables external clock detection automatically.
If external clock is not detected, then the internal clock will be used in the
LP55xx driver.

Valid clock rate is 32768Hz in LP55xx devices.

This new API is used in each LP55xx driver like LP5521 and LP5562.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
24d321284745cbc593fba8115585329d48703704 15-Mar-2013 Kim, Milo <Milo.Kim@ti.com> leds: lp55xx: fix the sysfs read operation

According to a sysfs documentation(Documentation/filesystem/sysfs.txt),
scnprintf() should be used in a read operation method.
It guarantees safe buffer size(PAGE_SIZE) which is allocated by the sysfs.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
ff45262a85dbf1bc74463c5dcea1d71a406d4d8e 19-Feb-2013 Kim, Milo <Milo.Kim@ti.com> leds: add new LP5562 LED driver

LP5562 can drive up to 4 channels, RGB and White.
LEDs can be controlled directly via the led class control interface.

LP55xx common driver
LP5562 is one of LP55xx family device, so LP55xx common code are used.
On the other hand, chip specific configuration is defined in the structure
'lp55xx_device_config'

LED pattern data
LP5562 has also internal program memory which is used for running various LED
patterns. LP5562 driver supports the firmware interface and the predefined
pattern data as well.

LP5562 device attributes: 'led_pattern' and 'engine_mux'
A 'led_pattern' is an index code which runs the predefined pattern data.
And 'engine_mux' is updated with the firmware interface is activated.
Detailed description has been updated in the documentation files,
'leds-lp55xx.txt' and 'leds-lp5562.txt'.

Changes on the header file
LP5562 configurable definitions are added.
Pattern RGB data is fixed as constant value.
(No side effect on other devices, LP5521 or LP5523.)

(cooloney@gmail.com: remove redundant mutex_unlock(). Reported by Dan
Carpenter <dan.carpenter@oracle.com>)

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
109b833071b44a4a6f5dc56385025543ed15a500 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: fix problem on removing LED attributes

LP55XX common device attributes, 'led_current' and 'max_current' are created
while loading the driver.
Those are LED device attributes which are removed automatically on releasing
led class devices - led_classdev_unregister().
Therefore, this duplicate code should be removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
ba6fa84651ff9a609e0ceb8265e3335ab6ed656d 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: add new function for removing device attribtues

lp55xx_unregister_sysfs() is used for removing lp55xx device attributes.
Chip specific and engine attributes are removed on unloading the driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
240085e255cd2818aff2ccde3066b7db1f29076a 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: support device specific attributes

To support device specific attributes, new common driver function is added.
Eventually those are created on registering the sysfs with common dev attrs.
Furthermore, this patch makes adding device attributes simple in each driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
10c06d178df11b0b2b746321a80ea14241997127 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: support firmware interface

This patch provides additional device attributes which enable
loading the firmware. ('select_engine' and 'run_engine')
To run a LED pattern, two parts of driver should be enabled.

Common features : lp55xx-common
===============================
Firmware interface for loading LED patterns

Chip specific features : leds-lp5521, leds-lp5523
=================================================
Register addresses for loading firmware data
Register addresses for running selected engine

Pattern programming sequence
============================
LP55xx chips have three program engines.
To load and run a LED pattern, the programming sequence is as follows.
(1) Select an engine number (1/2/3)
(2) Set engine mode to load
(3) Write pattern data into selected area
(4) Set engine mode to run

This sequence is almost same as the firmware interface.
(1) Select an engine number : 'select_engine' dev attribute
(2) Mode change to load : 'loading' of firmware class
(3) Write pattern data into selected area : 'data' of firmware class
(4) Mode change to run : 'run_engine' dev attribute

(1) and (4) are device specific features which provide callback functions
(2) and (3) are common features.

For example,
echo 1 or 2 or 3 > /sys/bus/i2c/devices/xxxx/select_engine
echo 1 > /sys/class/firmware/lp5521/loading
echo "4000600040FF6000" > /sys/class/firmware/lp5521/data
echo 0 > /sys/class/firmware/lp5521/loading
echo 1 > /sys/bus/i2c/devices/xxxx/run_engine

As soon as 'loading' is set to 0, registered callback is called.
Inside the callback, the selected engine is loaded and memory is updated.
To run programmed pattern, 'run_engine' attribute should be enabled.

Device specific data structure
==============================
o Firmware callback
load selected engine and update program memory
o Run engine
change the engine mode
o 'engine_idx' and firmware data, 'fw'
Those are used in the driver internally with callback functions

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
b3b6f8119d752c969c6394314dc7ab80e6611111 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: add new lp55xx_register_sysfs() for the firmware interface

LP55xx family chips have internal program memory which run various patterns.
Using this memory, LEDs continue on blinking/dimming without continuous I2C
commands. That means the I2C HOST can be entered into sleep once the memory
is updated.

An application can get hex data from a file and write them into
the program memory through the I2C. This is general firwmare interface.

This patch is the initial step for adding the firmware interface.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
d9067d28461cb2e817cacb84c727959cbd57d247 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: fix error condition in lp55xx_register_leds()

Use lp55xx_unregister_leds() rather than duplicate code.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
c3a68ebfcd22abc186f2328149732c801449b297 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx_unregister_leds()

To unregister led class devices and sysfs attributes,
LP5521 and LP5523 have each driver function.
This patch makes both drivers simple using common driver function,
lp55xx_unregister_leds().

And some unused variables are removed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
a96bfa135ddc8045166fc6311ce4d21bfcb8d13d 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: provide common LED current setting

LED current is configurable via the sysfs.
Max current is a read-only attribute.
These attributes code can be shared in lp55xx common driver.

Device attributes: 'led_current' and 'max_current'
move to lp55xx common driver

Replaced functions:
show_max_current() => lp55xx_show_max_current()
show_current() => lp55xx_show_current()
store_current() => lp55xx_store_current()

LED setting function: set_led_current()
Current registers are device specific, so configurable function is added
in each driver.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
a6e4679a09a0a2bcfa63074272fc9fb2a40f11ad 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx_set_brightness()

lp5521_set_brightness() and lp5523_set_brightness() are replaced with
common function, lp55xx_set_brightness().
This function is invoked when the brightness of each LED channel is updated.
LP5521 and LP5523 have different register address for the brightness control,
so this work is done by chip specific brightness_work_fn().

lp5521/5523_led_brightness_work():
use lp55xx_led and lp55xx_chip data structure.
use lp55xx write function.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
0e2023463a3c9412728cb2c36c79aca0bb731cc8 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx_init_led() common function

lp5521_init_led() and lp5523_init_led() are replaced with one common function,
lp55xx_init_led().
Max channels is configurable, so it's used in lp55xx_init_led().

'LP5523_LEDS' are changed to 'LP5523_MAX_LEDS'.

lp55xx_set_brightness, lp55xx_led_attributes: skeleton
Will be filled in next patches.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
9e9b3db1b2f725bacaf1b7e8708a0c78265bde97 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx common led registration function

LED class devices are registered in lp5521_register_leds() and
lp5523_register_leds().
Two separate functions are merged into consolidated lp55xx function,
lp55xx_register_leds().

Error handling fix:
Unregistering LEDS are handled in lp55xx_register_leds() when LED registration
failure occurs. So each driver error handler is changed to 'err_register_leds'

Chip dependency: 'brightness_work_fn' and 'set_led_current'
To make the structure abstract, both functions are configured in each driver.
Those functions should be done by each driver because register control is
chip-dependant work.

lp55xx_init_led: skeleton
Will be filled in next patch

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
6ce6176263393dd80b9a537c1e1462b8529f240b 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx common deinit function

Two separate de-init functions are merged into one common function.
And it is used in err_post_init of lp55xx_init_device().

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
22ebeb488b3dbbb64b81146b366551107ae34af8 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: clean up init function

lp5521/5523_init_device() are replaced with lp55xx common function,
lp55xx_init_device().

Error handler in init_device:
deinit function are matched with 'err_post_init' section in
lp55xx_init_device().

Remove LP5523 engine intialization code:
Engine functionality is not mandatory but optional.
Moreover engine initialization is done internally with device reset command.
Therefore, this code is unnecessary.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
ffbdccdbbaee814963a09d25b1cc598cfe131366 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx common init function - post int

LP5521/5523 chip configuration is replaced with lp55xx common function,
lp55xx_post_init_device().

Name change:
lp5521/5523_configure() to lp5521/5523_post_init_device()
These are called in init function.

Register access function
Argument type is changed from 'i2c_client' to 'lp55xx_chip'.
Use exported R/W functions of lp55xx common driver.

Temporary variables in lp5521/5523_init_device()
These functions will be removed but temporary variables are needed for
blocking build warnings - incompatible pointer.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
e3a700d8aae190e09fb06abe0ddd2e172a682508 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx common init function - detect

LP5521/5523 chip detection functions are replaced with lp55xx common function,
lp55xx_detect_device().
Chip dependent address and values are configurable in each driver.
In init function, chip detection is executed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
48068d5de16c23c256c085b2cd3ff03bec393900 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx common init function - reset

LP5521/5523 reset device functions are moved to lp55xx common driver.
Value of register address and value are chip dependent.
Those are configured in each driver.
In init function, reset command is executed.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
a85908dd7799e4fa242812ce27a8f774c721d1fb 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: use lp55xx common init function - platform data

LP5521/5523 platform data functions are moved to lp55xx common driver.
New init function, lp55xx_init_device() is created.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
c93d08fa75020835741c7b1d0523ff854e8acde1 05-Feb-2013 Milo(Woogyom) Kim <milo.kim@ti.com> leds-lp55xx: add new common driver for lp5521/5523

This patch supports basic common driver code for LP5521, LP5523/55231 devices.

( Driver Structure Data )

lp55xx_led and lp55xx_chip
In lp55xx common driver, two different data structure is used.
o lp55xx_led
control multi output LED channels such as led current, channel index.
o lp55xx_chip
general chip control such like the I2C and platform data.

For example, LP5521 has maximum 3 LED channels.
LP5523/55231 has 9 output channels.

lp55xx_chip for LP5521 ... lp55xx_led #1
lp55xx_led #2
lp55xx_led #3

lp55xx_chip for LP5523 ... lp55xx_led #1
lp55xx_led #2
.
.
lp55xx_led #9

( Platform Data )

LP5521 and LP5523/55231 have own specific platform data.
However, this data can be handled with just one platform data structure.
The lp55xx platform data is declared in the header.
This structure is derived from leds-lp5521.h and leds-lp5523.h

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>