leds: Add LM3633 driver
Subsystems (2)
PATCH 8/10 leds: Add LM3633 driver
LM3633 LED driver supports generic LED functions and pattern generation. Pattern is generated by using LMU effect driver APIs.
Sysfs documentation is added.
Cc Bryan Wu <[email protected]>
Signed-off-by Milo Kim <[email protected]>
--- Documentation/leds/leds-lm3633.txt | 38 +++ drivers/leds/Kconfig | 10 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3633.c | 661 ++++++++++++++++++++++++++++++++++++ 4 files changed, 710 insertions(+) create mode 100644 Documentation/leds/leds-lm3633.txt create mode 100644 drivers/leds/leds-lm3633.c
Documentation/leds/leds-lm3633.txt new file +38 -0
@@ -0,0 +1,38 @@ +LM3633 LED Driver +================= + +LM3633 LED driver supports not only LED functions but also programmable pattern. +A pattern is generated via the sysfs. + +LED Pattern Generator + + (3) + (a) ---------------> ___________ + / \ + (2) / \ (4) + (b) ----> _________/ \_________ ... + (1) (5) + + |<----- period -----> | + + Time dimension + (1) delay : 0 ~ 10 sec + (2) rise : 0 ~ 16 sec + (3) high : 0 ~ 10 sec + (4) fall : 0 ~ 16 sec + (5) low : 0 ~ 16 sec + + Level dimension - channel current + (a) low : 0 ~ 255 + (b) high : 0 ~ 255 + +Example) +Time : No delay, rise 500ms, high 1000ms, fall 400ms, low 2000ms +Level : Brightness 0 and 255 + +echo 0 500 1000 400 2000 > /sys/class/leds/<LED NAME>/pattern_times +echo 0 255 > /sys/class/leds/<LED NAME>/pattern_levels +echo 1 > /sys/class/leds/<LED NAME>/run_pattern + +To stop running pattern, +echo 0 > /sys/class/leds/<LED NAME>/run_pattern
drivers/leds/Kconfig +10 -0
@@ -63,6 +63,16 @@ config LEDS_LM3533 hardware-accelerated blinking with maximum on and off periods of 9.8 and 77 seconds respectively. +config LEDS_LM3633 + tristate "LED support for the TI LM3633 LMU" + depends on LEDS_CLASS + depends on MFD_TI_LMU + help + This option enables support for the LEDs on the LM3633. + LM3633 has 6 low voltage indicator LEDs. + All low voltage current sinks can have a programmable pattern + modulated onto LED output strings. + config LEDS_LM3642 tristate "LED support for LM3642 Chip" depends on LEDS_CLASS && I2C
drivers/leds/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o obj-$(CONFIG_LEDS_LM3533) += leds-lm3533.o +obj-$(CONFIG_LEDS_LM3633) += leds-lm3633.o obj-$(CONFIG_LEDS_LM3642) += leds-lm3642.o obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
drivers/leds/leds-lm3633.c new file +661 -0
661 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 14 lines · Milo Kim
LM3633 LED driver supports generic LED functions and pattern generation. Pattern is generated by using LMU effect driver APIs.
Sysfs documentation is added.Cc Bryan Wu <[email protected]>Signed-off-by Milo Kim <[email protected]>--- Documentation/leds/leds-lm3633.txt | 38 +++ drivers/leds/Kconfig | 10 + drivers/leds/Makefile | 1 + drivers/leds/leds-lm3633.c | 661 ++++++++++++++++++++++++++++++++++++ 4 files changed, 710 insertions(+) create mode 100644 Documentation/leds/leds-lm3633.txt create mode 100644 drivers/leds/leds-lm3633.c
[...]
Quoted 16 lines
drivers/leds/leds-lm3633.c new file +16
-0+static int lm3633_led_parse_dt (struct device *dev,struct ti_lmu *lmu) +{ +struct ti_lmu_led_platform_data *pdata; +struct device_node *node = dev->of_node; +struct device_node *child; +int num_leds; +int i =0 ; +u8 imax_mA; + +if (!node) { +dev_err (dev,"No device node exists\n" ); +return -ENODEV ; + } + + num_leds =of_get_child_count (node); +if (num_leds ==0 ) {
drivers/leds/leds-lm3633.c line 533
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+dev_err (dev,"No LED channels\n" ); +return -EINVAL ; + } + + pdata =devm_kzalloc (dev,sizeof (*pdata) * num_leds,GFP_KERNEL ); +if (!pdata) +return -ENOMEM ; + +for_each_child_of_node (node, child) { +of_property_read_string (child,"chan-name" , &pdata[i].name);
What if this is missing from a node.?
Quoted 5 lines
drivers/leds/leds-lm3633.c new file +5
-0+ +/* Make LED strings */ + pdata[i].led_string =0 ; +if (of_find_property (child,"lvled1-used" ,NULL )) + pdata[i].led_string |=LMU_LVLED1 ;
drivers/leds/leds-lm3633.c line 548
Quoted 10 lines
drivers/leds/leds-lm3633.c new file +10
-0+if (of_find_property (child,"lvled2-used" ,NULL )) + pdata[i].led_string |=LMU_LVLED2 ; +if (of_find_property (child,"lvled3-used" ,NULL )) + pdata[i].led_string |=LMU_LVLED3 ; +if (of_find_property (child,"lvled4-used" ,NULL )) + pdata[i].led_string |=LMU_LVLED4 ; +if (of_find_property (child,"lvled5-used" ,NULL )) + pdata[i].led_string |=LMU_LVLED5 ; +if (of_find_property (child,"lvled6-used" ,NULL )) + pdata[i].led_string |=LMU_LVLED6 ;
You can use of_property_read_bool for these.
drivers/leds/leds-lm3633.c line 551
Quoted 3 lines
drivers/leds/leds-lm3633.c new file +3
-0+ +of_property_read_u8 (child,"max-current-milliamp" , &imax_mA); + pdata[i].imax =ti_lmu_get_current_code (imax_mA);
What happens if this is missing from a node?
Cheers,
Mark.