2010-11-12 06:05:23 +08:00
|
|
|
Kernel driver for lp5521
|
|
|
|
========================
|
|
|
|
|
|
|
|
* National Semiconductor LP5521 led driver chip
|
|
|
|
* Datasheet: http://www.national.com/pf/LP/LP5521.html
|
|
|
|
|
|
|
|
Authors: Mathias Nyman, Yuri Zaporozhets, Samu Onkalo
|
|
|
|
Contact: Samu Onkalo (samu.p.onkalo-at-nokia.com)
|
|
|
|
|
|
|
|
Description
|
|
|
|
-----------
|
|
|
|
|
|
|
|
LP5521 can drive up to 3 channels. Leds can be controlled directly via
|
|
|
|
the led class control interface. Channels have generic names:
|
|
|
|
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.
|
|
|
|
|
2013-02-05 19:22:48 +08:00
|
|
|
LP5521 has the internal program memory for running various LED patterns.
|
|
|
|
For the details, please refer to 'firmware' section in leds-lp55xx.txt
|
2010-11-12 06:05:23 +08:00
|
|
|
|
|
|
|
sysfs contains a selftest entry.
|
|
|
|
The test communicates with the chip and checks that
|
|
|
|
the clock mode is automatically set to the requested one.
|
|
|
|
|
|
|
|
Each channel has its own led current settings.
|
|
|
|
/sys/class/leds/lp5521:channel0/led_current - RW
|
|
|
|
/sys/class/leds/lp5521:channel0/max_current - RO
|
|
|
|
Format: 10x mA i.e 10 means 1.0 mA
|
|
|
|
|
|
|
|
example platform data:
|
|
|
|
|
|
|
|
Note: chan_nr can have values between 0 and 2.
|
2012-03-24 06:02:08 +08:00
|
|
|
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)
|
2010-11-12 06:05:23 +08:00
|
|
|
|
2013-02-05 19:22:48 +08:00
|
|
|
static struct lp55xx_led_config lp5521_led_config[] = {
|
2010-11-12 06:05:23 +08:00
|
|
|
{
|
2012-03-24 06:02:08 +08:00
|
|
|
.name = "red",
|
2010-11-12 06:05:23 +08:00
|
|
|
.chan_nr = 0,
|
|
|
|
.led_current = 50,
|
|
|
|
.max_current = 130,
|
|
|
|
}, {
|
2012-03-24 06:02:08 +08:00
|
|
|
.name = "green",
|
2010-11-12 06:05:23 +08:00
|
|
|
.chan_nr = 1,
|
|
|
|
.led_current = 0,
|
|
|
|
.max_current = 130,
|
|
|
|
}, {
|
2012-03-24 06:02:08 +08:00
|
|
|
.name = "blue",
|
2010-11-12 06:05:23 +08:00
|
|
|
.chan_nr = 2,
|
|
|
|
.led_current = 0,
|
|
|
|
.max_current = 130,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static int lp5521_setup(void)
|
|
|
|
{
|
|
|
|
/* setup HW resources */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lp5521_release(void)
|
|
|
|
{
|
|
|
|
/* Release HW resources */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void lp5521_enable(bool state)
|
|
|
|
{
|
|
|
|
/* Control of chip enable signal */
|
|
|
|
}
|
|
|
|
|
2013-02-05 19:22:48 +08:00
|
|
|
static struct lp55xx_platform_data lp5521_platform_data = {
|
2010-11-12 06:05:23 +08:00
|
|
|
.led_config = lp5521_led_config,
|
|
|
|
.num_channels = ARRAY_SIZE(lp5521_led_config),
|
2013-02-05 19:22:48 +08:00
|
|
|
.clock_mode = LP55XX_CLOCK_EXT,
|
2010-11-12 06:05:23 +08:00
|
|
|
.setup_resources = lp5521_setup,
|
|
|
|
.release_resources = lp5521_release,
|
|
|
|
.enable = lp5521_enable,
|
|
|
|
};
|
|
|
|
|
|
|
|
If the current is set to 0 in the platform data, that channel is
|
|
|
|
disabled and it is not visible in the sysfs.
|