mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 22:42:10 +00:00
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>
This commit is contained in:
parent
2491c5c8c9
commit
f65f0a1a98
3 changed files with 11 additions and 3 deletions
|
@ -17,12 +17,15 @@ Optional properties:
|
||||||
2: D1~6 with VOUT, D7~9 with VDD
|
2: D1~6 with VOUT, D7~9 with VDD
|
||||||
3: D1~9 are connected to VOUT
|
3: D1~9 are connected to VOUT
|
||||||
|
|
||||||
Alternatively, each child can have specific channel name
|
Alternatively, each child can have a specific channel name and trigger:
|
||||||
- chan-name: Name of each channel name
|
- chan-name (optional): name of channel
|
||||||
|
- linux,default-trigger (optional): see
|
||||||
|
Documentation/devicetree/bindings/leds/common.txt
|
||||||
|
|
||||||
example 1) LP5521
|
example 1) LP5521
|
||||||
3 LED channels, external clock used. Channel names are 'lp5521_pri:channel0',
|
3 LED channels, external clock used. Channel names are 'lp5521_pri:channel0',
|
||||||
'lp5521_pri:channel1' and 'lp5521_pri:channel2'
|
'lp5521_pri:channel1' and 'lp5521_pri:channel2', with a heartbeat trigger
|
||||||
|
on channel 0.
|
||||||
|
|
||||||
lp5521@32 {
|
lp5521@32 {
|
||||||
compatible = "national,lp5521";
|
compatible = "national,lp5521";
|
||||||
|
@ -33,6 +36,7 @@ lp5521@32 {
|
||||||
chan0 {
|
chan0 {
|
||||||
led-cur = /bits/ 8 <0x2f>;
|
led-cur = /bits/ 8 <0x2f>;
|
||||||
max-cur = /bits/ 8 <0x5f>;
|
max-cur = /bits/ 8 <0x5f>;
|
||||||
|
linux,default-trigger = "heartbeat";
|
||||||
};
|
};
|
||||||
|
|
||||||
chan1 {
|
chan1 {
|
||||||
|
|
|
@ -165,6 +165,7 @@ static int lp55xx_init_led(struct lp55xx_led *led,
|
||||||
led->led_current = pdata->led_config[chan].led_current;
|
led->led_current = pdata->led_config[chan].led_current;
|
||||||
led->max_current = pdata->led_config[chan].max_current;
|
led->max_current = pdata->led_config[chan].max_current;
|
||||||
led->chan_nr = pdata->led_config[chan].chan_nr;
|
led->chan_nr = pdata->led_config[chan].chan_nr;
|
||||||
|
led->cdev.default_trigger = pdata->led_config[chan].default_trigger;
|
||||||
|
|
||||||
if (led->chan_nr >= max_channel) {
|
if (led->chan_nr >= max_channel) {
|
||||||
dev_err(dev, "Use channel numbers between 0 and %d\n",
|
dev_err(dev, "Use channel numbers between 0 and %d\n",
|
||||||
|
@ -586,6 +587,8 @@ int lp55xx_of_populate_pdata(struct device *dev, struct device_node *np)
|
||||||
of_property_read_string(child, "chan-name", &cfg[i].name);
|
of_property_read_string(child, "chan-name", &cfg[i].name);
|
||||||
of_property_read_u8(child, "led-cur", &cfg[i].led_current);
|
of_property_read_u8(child, "led-cur", &cfg[i].led_current);
|
||||||
of_property_read_u8(child, "max-cur", &cfg[i].max_current);
|
of_property_read_u8(child, "max-cur", &cfg[i].max_current);
|
||||||
|
cfg[i].default_trigger =
|
||||||
|
of_get_property(child, "linux,default-trigger", NULL);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
struct lp55xx_led_config {
|
struct lp55xx_led_config {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
const char *default_trigger;
|
||||||
u8 chan_nr;
|
u8 chan_nr;
|
||||||
u8 led_current; /* mA x10, 0 if led is not connected */
|
u8 led_current; /* mA x10, 0 if led is not connected */
|
||||||
u8 max_current;
|
u8 max_current;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue