leds: leds-mc13783: Add MC34708 LED support
Subsystems (2)
PATCH v2 1/5 leds: leds-mc13783: Add MC34708 LED support
This patch adds support for two LEDs on MC34708 PMIC.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/leds/Kconfig | 2 +- drivers/leds/leds-mc13783.c | 98 ++++++++++++++++++++++----------------------- include/linux/mfd/mc13xxx.h | 6 +++ 3 files changed, 55 insertions(+), 51 deletions(-)
drivers/leds/Kconfig +1 -1
@@ -413,7 +413,7 @@ config LEDS_MC13783 depends on MFD_MC13XXX help This option enable support for on-chip LED drivers found - on Freescale Semiconductor MC13783/MC13892 PMIC. + on Freescale Semiconductor MC13783/MC13892/MC34708 PMIC. config LEDS_NS2 tristate "LED support for Network Space v2 GPIO LEDs"
drivers/leds/leds-mc13783.c +48 -50
242 lines not on this page · raw message
include/linux/mfd/mc13xxx.h +6 -0
@@ -104,6 +104,9 @@ enum {MC13892_LED_R ,MC13892_LED_G ,MC13892_LED_B , +/* MC34708 LED IDs */ +MC34708_LED_R , + MC34708_LED_G, }; struct mc13xxx_led_platform_data {
@@ -163,6 +166,9 @@ struct mc13xxx_leds_platform_data {#define MC13892_LED_C2_CURRENT_G (x) (((x) & 0x7) << 21)/* MC13892 LED Control 3 */ #define MC13892_LED_C3_CURRENT_B (x) (((x) & 0x7) << 9) +/* MC34708 LED Control 0 */ +#define MC34708_LED_C0_CURRENT_R (x) (((x) & 0x3) << 9) +#define MC34708_LED_C0_CURRENT_G (x) (((x) & 0x3) << 21)u32 led_control[MAX_LED_CONTROL_REGS ]; };
Signature · 1 line
1.8.3.2
PATCH v2 2/5 leds: leds-mc13783: Use LED core PM functions
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/leds/leds-mc13783.c | 1 + 1 file changed, 1 insertion(+)
drivers/leds/leds-mc13783.c +1 -0
@@ -184,6 +184,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) leds->led[i].leds = leds; leds->led[i].cdev.name = name; leds->led[i].cdev.default_trigger = trig; + leds->led[i].cdev.flags =LED_CORE_SUSPENDRESUME ; leds->led[i].cdev.brightness_set = mc13xxx_led_set; leds->led[i].cdev.brightness =LED_OFF ;
Signature · 1 line
1.8.3.2
PATCH v2 3/5 leds: leds-mc13783: Use proper "max_brightness" value for LEDs
In reply to Alexander ShiyanInstead of using maximum value of 255 and shift it to appropriate LED duty cycle, this patch introduce a helper to use proper maximum value for each LED.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/leds/leds-mc13783.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/leds/leds-mc13783.c +14 -13
@@ -45,11 +45,21 @@ struct mc13xxx_leds {struct mc13xxx_led led[0 ]; }; +static unsigned int mc13xxx_max_brightness (int id) +{ +if (id >=MC13783_LED_MD && id <=MC13783_LED_KP ) +return 0x0f ; +else if (id >=MC13783_LED_R1 && id <=MC13783_LED_B3 ) +return 0x1f ; + +return 0x3f ; +} +static void mc13xxx_led_work (struct work_struct *work) { struct mc13xxx_led *led = container_of(work, struct mc13xxx_led, work);struct mc13xxx_leds *leds = led->leds; -unsigned int reg, mask, value, bank, off, shift; +unsigned int reg, bank, off, shift;switch (led->id) {case MC13783_LED_MD :
@@ -57,8 +67,6 @@ static void mc13xxx_led_work(struct work_struct *work)case MC13783_LED_KP : reg =2 ; shift =9 + (led->id -MC13783_LED_MD ) *4 ; - mask =0x0f ; - value = led->new_brightness >>4 ;break ;case MC13783_LED_R1 :case MC13783_LED_G1 :
@@ -73,16 +81,12 @@ static void mc13xxx_led_work(struct work_struct *work) bank = off /3 ; reg =3 + bank; shift = (off - bank *3 ) *5 +6 ; - value = led->new_brightness >>3 ; - mask =0x1f ;break ;case MC13892_LED_MD :case MC13892_LED_AD :case MC13892_LED_KP : reg = (led->id -MC13892_LED_MD ) /2 ; shift =3 + (led->id -MC13892_LED_MD ) *12 ; - mask =0x3f ; - value = led->new_brightness >>2 ;break ;case MC13892_LED_R :case MC13892_LED_G :
@@ -91,22 +95,19 @@ static void mc13xxx_led_work(struct work_struct *work) bank = off /2 ; reg =2 + bank; shift = (off - bank *2 ) *12 +3 ; - value = led->new_brightness >>2 ; - mask =0x3f ;break ;case MC34708_LED_R :case MC34708_LED_G : reg =0 ; shift =3 + (led->id -MC34708_LED_R ) *12 ; - value = led->new_brightness >>2 ; - mask =0x3f ;break ;default :BUG (); }mc13xxx_reg_rmw (leds->master, leds->devtype->ledctrl_base + reg, - mask << shift, value << shift); +mc13xxx_max_brightness (led->id) << shift, + led->new_brightness << shift); } static void mc13xxx_led_set(struct led_classdev *led_cdev,
@@ -186,7 +187,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) leds->led[i].cdev.default_trigger = trig; leds->led[i].cdev.flags =LED_CORE_SUSPENDRESUME ; leds->led[i].cdev.brightness_set = mc13xxx_led_set; - leds->led[i].cdev.brightness =LED_OFF ; + leds->led[i].cdev.max_brightness =mc13xxx_max_brightness (id);INIT_WORK (&leds->led[i].work, mc13xxx_led_work);
Signature · 1 line
1.8.3.2
PATCH v2 4/5 leds: leds-mc13783: Remove unnecessary cleaning of registers on exit
In reply to Alexander ShiyanLED core switches each LED to OFF-state on exit, so there is no need for resetting registers.
Signed-off-by Alexander Shiyan <[email protected]>
--- drivers/leds/leds-mc13783.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/leds/leds-mc13783.c +0 -4
@@ -210,7 +210,6 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)static int mc13xxx_led_remove (struct platform_device *pdev) {struct mc13xxx_leds *leds =platform_get_drvdata (pdev); -struct mc13xxx *mcdev = leds->master;int i;for (i =0 ; i < leds->num_leds; i++) {
@@ -218,9 +217,6 @@ static int mc13xxx_led_remove(struct platform_device *pdev)cancel_work_sync (&leds->led[i].work); } -for (i =0 ; i < leds->devtype->num_regs; i++) -mc13xxx_reg_write (mcdev, leds->devtype->ledctrl_base + i,0 ); -return 0 ; }
Signature · 1 line
1.8.3.2