leds: leds-mc13783: Prepare driver to support MC13892 LEDs
Subsystems (6)
PATCH v4 1/3 leds: leds-mc13783: Prepare driver to support MC13892 LEDs
This patch rewrite driver code to be ready to add support for MC13892 LEDs and probe from devicetree.
--- arch/arm/mach-imx/mach-mx31moboard.c | 9 +- drivers/leds/leds-mc13783.c | 406 ++++++++++++++--------------------- include/linux/mfd/mc13xxx.h | 93 ++++---- 3 files changed, 204 insertions(+), 304 deletions(-)
arch/arm/mach-imx/mach-mx31moboard.c +5 -4
@@ -268,10 +268,11 @@ static struct mc13xxx_led_platform_data moboard_led[] = {static struct mc13xxx_leds_platform_data moboard_leds = { .num_leds =ARRAY_SIZE (moboard_led), .led = moboard_led, - .flags =MC13783_LED_SLEWLIMTC , - .abmode =MC13783_LED_AB_DISABLED , - .tc1_period =MC13783_LED_PERIOD_10MS , - .tc2_period =MC13783_LED_PERIOD_10MS , + .led_control[0 ] =MC13783_LED_C0_ENABLE |MC13783_LED_C0_ABMODE (0 ), + .led_control[1 ] =MC13783_LED_C1_SLEWLIM , + .led_control[2 ] =MC13783_LED_C2_SLEWLIM , + .led_control[3 ] =MC13783_LED_C3_PERIOD (0 ), + .led_control[4 ] =MC13783_LED_C3_PERIOD (0 ), };static struct mc13xxx_buttons_platform_data moboard_buttons = {
drivers/leds/leds-mc13783.c +156 -250
516 lines not on this page · raw message
include/linux/mfd/mc13xxx.h +43 -50
109 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH v4 2/3 leds: leds-mc13783: Add MC13892 LED support
--- drivers/leds/Kconfig | 6 ++--- drivers/leds/leds-mc13783.c | 60 ++++++++++++++++++++++++++++++++++++++++++++- include/linux/mfd/mc13xxx.h | 7 ++++++ 3 files changed, 69 insertions(+), 4 deletions(-)
drivers/leds/Kconfig +3 -3
@@ -388,12 +388,12 @@ config LEDS_DELL_NETBOOKS notebooks that have an external LED. config LEDS_MC13783 - tristate "LED Support for MC13783 PMIC" + tristate "LED Support for MC13XXX PMIC" depends on LEDS_CLASS - depends on MFD_MC13783 + depends on MFD_MC13XXX help This option enable support for on-chip LED drivers found - on Freescale Semiconductor MC13783 PMIC. + on Freescale Semiconductor MC13783/MC13892 PMIC. config LEDS_NS2 tristate "LED support for Network Space v2 GPIO LEDs"
drivers/leds/leds-mc13783.c +59 -1
84 lines not on this page · raw message
include/linux/mfd/mc13xxx.h +7 -0
@@ -92,6 +92,13 @@ enum {MC13783_LED_R3 ,MC13783_LED_G3 ,MC13783_LED_B3 , +/* MC13892 LED IDs */ +MC13892_LED_MD , +MC13892_LED_AD , +MC13892_LED_KP , +MC13892_LED_R , +MC13892_LED_G , + MC13892_LED_B, }; struct mc13xxx_led_platform_data {
Signature · 1 line
1.8.1.5
PATCH v4 3/3 leds: leds-mc13783: Add devicetree support
In reply to Alexander Shiyan--- Documentation/devicetree/bindings/mfd/mc13xxx.txt | 39 +++++++++++++ drivers/leds/leds-mc13783.c | 69 +++++++++++++++++++---- 2 files changed, 96 insertions(+), 12 deletions(-)
Documentation/devicetree/bindings/mfd/mc13xxx.txt +39 -0
@@ -12,6 +12,13 @@ Optional properties: Sub-nodes: - regulators : Contain the regulator nodes. The regulators are bound using their names as listed below with their registers and bits for enabling. +- leds : Contain the led nodes and initial register values in property + "led_control". Number of register depends of used IC, for MC13783 is 6, + for MC13892 is 4. See datasheet for bits definitions of these register. + Each led node should contain "id", which is described below, and "max_cur" + which selects value current depending on the led (Values should be taken + from IC datasheet). Optional properties "label" and "linux,default-trigger" + is described in Documentation/devicetree/bindings/leds/common.txt MC13783 regulators: sw1a : regulator SW1A (register 24, bit 0)
@@ -72,6 +79,28 @@ MC13892 regulators: The bindings details of individual regulator device can be found in: Documentation/devicetree/bindings/regulator/regulator.txt +MC13783 LED IDs: + 0 : Main display + 1 : AUX display + 2 : Keypad + 3 : Red 1 + 4 : Green 1 + 5 : Blue 1 + 6 : Red 2 + 7 : Green 2 + 8 : Blue 2 + 9 : Red 3 + 10 : Green 3 + 11 : Blue 3 + +MC13892 LED IDs: + 12 : Main display + 13 : AUX display + 14 : Keypad + 15 : Red + 16 : Green + 17 : Blue + Examples: ecspi at 70010000 { /* ECSPI1 */
@@ -89,6 +118,16 @@ ecspi at 70010000 { /* ECSPI1 */ interrupt-parent = <&gpio0>; interrupts = <8>; + leds { + led_control = <0x0 0x0 0x0 0x0>; + led_r { + id = <15>; + label = "system:red:live"; + linux,default-trigger = "heartbeat"; + max-cur = <6>; + }; + }; + regulators { sw1_reg: mc13892__sw1 { regulator-min-microvolt = <600000>;
drivers/leds/leds-mc13783.c +57 -12
118 lines not on this page · raw message
Signature · 1 line
1.8.1.5
PATCH v4 3/3 leds: leds-mc13783: Add devicetree support
Quoted 1 line · Alexander Shiyan
I'm OK for this patchset. But I need some review from DT maintainer, Grant and Rob could you please help to take a look.
Thanks,
-Bryan
Quoted 199 lines
Signed-off-by Alexander Shiyan <[email protected]>--- Documentation/devicetree/bindings/mfd/mc13xxx.txt | 39 +++++++++++++ drivers/leds/leds-mc13783.c | 69 +++++++++++++++++++---- 2 files changed, 96 insertions(+), 12 deletions(-)Documentation/devicetree/bindings/mfd/mc13xxx.txt +39
-0@@ -12,6 +12,13 @@ Optional properties: Sub-nodes: - regulators : Contain the regulator nodes. The regulators are bound using their names as listed below with their registers and bits for enabling. +- leds : Contain the led nodes and initial register values in property + "led_control". Number of register depends of used IC, for MC13783 is 6, + for MC13892 is 4. See datasheet for bits definitions of these register. + Each led node should contain "id", which is described below, and "max_cur" + which selects value current depending on the led (Values should be taken + from IC datasheet). Optional properties "label" and "linux,default-trigger" + is described in Documentation/devicetree/bindings/leds/common.txt MC13783 regulators: sw1a : regulator SW1A (register 24, bit 0)@@ -72,6 +79,28 @@ MC13892 regulators: The bindings details of individual regulator device can be found in: Documentation/devicetree/bindings/regulator/regulator.txt +MC13783 LED IDs: + 0 : Main display + 1 : AUX display + 2 : Keypad + 3 : Red 1 + 4 : Green 1 + 5 : Blue 1 + 6 : Red 2 + 7 : Green 2 + 8 : Blue 2 + 9 : Red 3 + 10 : Green 3 + 11 : Blue 3 + +MC13892 LED IDs: + 12 : Main display + 13 : AUX display + 14 : Keypad + 15 : Red + 16 : Green + 17 : Blue + Examples: ecspi at 70010000 { /* ECSPI1 */@@ -89,6 +118,16 @@ ecspi at 70010000 { /* ECSPI1 */ interrupt-parent = <&gpio0>; interrupts = <8>; + leds { + led_control = <0x0 0x0 0x0 0x0>; + led_r { + id = <15>; + label = "system:red:live"; + linux,default-trigger = "heartbeat"; + max-cur = <6>; + }; + }; + regulators { sw1_reg: mc13892__sw1 { regulator-min-microvolt = <600000>;drivers/leds/leds-mc13783.c +57
-13@@ -20,6 +20,7 @@#include <linux/init.h> #include <linux/platform_device.h> #include <linux/leds.h> +#include <linux/of.h> #include <linux/workqueue.h> #include <linux/mfd/mc13xxx.h> @@ -207,35 +208,55 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)struct mc13xxx *mcdev =dev_get_drvdata (pdev->dev.parent);struct mc13xxx_led_devtype *devtype = (struct mc13xxx_led_devtype *)pdev->id_entry->driver_data; +struct device_node *parent, *child =NULL ;struct mc13xxx_leds *leds; -int i, id, num_leds, ret; -u32 reg, init_led =0 ; +int i, id, num_leds, ret = -EINVAL ; +u32 reg, ctrls[MAX_LED_CONTROL_REGS ], init_led =0 ; -if (!pdata) { +of_node_get (pdev->dev.parent->of_node); + parent =of_find_node_by_name (pdev->dev.parent->of_node,"leds" ); +if (!parent && !pdata) {dev_err (&pdev->dev,"Missing platform data\n" );return -ENODEV ; } - num_leds = pdata->num_leds; +if (parent) + num_leds =of_get_child_count (parent); +else + num_leds = pdata->num_leds;if ((num_leds <1 ) || (num_leds > (devtype->led_max - devtype->led_min +1 ))) {dev_err (&pdev->dev,"Invalid LED count %d\n" , num_leds); -return -EINVAL ; + goto out_node_put; } leds =devm_kzalloc (&pdev->dev, num_leds *sizeof (struct mc13xxx_led ) +sizeof (struct mc13xxx_leds ),GFP_KERNEL ); -if (!leds) -return -ENOMEM ; +if (!leds) { + ret = -ENOMEM ; + goto out_node_put; + } leds->devtype = devtype; leds->num_leds = num_leds;platform_set_drvdata (pdev, leds); +if (parent) { + ret =of_property_read_u32_array (parent,"led_control" , ctrls, + devtype->num_regs); +if (ret) { +dev_err (&pdev->dev,"Missing led_control settings\n" ); + goto out_node_put; + } + } +mc13xxx_lock (mcdev);for (i =0 ; i < devtype->num_regs; i++) { - reg = pdata->led_control[i]; +if (parent) + reg = ctrls[i]; +else + reg = pdata->led_control[i];WARN_ON (reg >= (1 <<24 )); ret =mc13xxx_reg_write (mcdev,MC13XXX_REG_LED_CONTROL (i), reg);if (ret)@@ -250,14 +271,34 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)for (i =0 ; i < num_leds; i++) {const char *name, *trig; +const __be32 *prop;char max_current; ret = -EINVAL ; - id = pdata->led[i].id; - name = pdata->led[i].name; - trig = pdata->led[i].default_trigger; - max_current = pdata->led[i].max_current; +if (parent) { + child =of_get_next_child (parent, child); + prop =of_get_property (child,"id" ,NULL ); +if (!prop) { +dev_err (&pdev->dev,"Missing LED ID\n" ); +break ; + }else + id =be32_to_cpu (*prop); + name =of_get_property (child,"label" ,NULL ); + trig =of_get_property (child,"linux,default-trigger" , +NULL ); + prop =of_get_property (child,"max-cur" ,NULL ); +if (!prop) { +dev_err (&pdev->dev,"Missing LED max-cur\n" ); +break ; + }else + max_current =be32_to_cpu (*prop); + }else { + id = pdata->led[i].id; + name = pdata->led[i].name; + trig = pdata->led[i].default_trigger; + max_current = pdata->led[i].max_current; + }if ((id > devtype->led_max) || (id < devtype->led_min)) {dev_err (&pdev->dev,"Invalid ID %i\n" , id);@@ -299,6 +340,10 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)cancel_work_sync (&leds->led[i].work); } +out_node_put: +if (parent) +of_node_put (parent); +return ret; } --1.8.1.5
PATCH v4 1/3 leds: leds-mc13783: Prepare driver to support MC13892 LEDs
In reply to Alexander ShiyanLe 10/06/2013 18:59, Alexander Shiyan a ?crit :
Quoted 4 lines
This patch rewrite driver code to be ready to add support for MC13892 LEDs and probe from devicetree.
Signed-off-by Alexander Shiyan <[email protected]>
The whole serie:
On mx31moboard with an mc13783.
Thanks !
Philippe
PATCH v4 1/3 leds: leds-mc13783: Prepare driver to support MC13892 LEDs
Quoted 9 lines · Philippe R?tornaz
Le 10/06/2013 18:59, Alexander Shiyan a ?crit :
Quoted 4 lines
This patch rewrite driver code to be ready to add support for MC13892 LEDs and probe from devicetree.
Signed-off-by Alexander Shiyan <[email protected]>
Quoted 6 lines
The whole serie:
Tested-by Philippe Retornaz <[email protected]>On mx31moboard with an mc13783.
Thanks for testing, did you test device tree as well? I failed to see any DTS file adding/change in this patchset.
-Bryan
PATCH v4 1/3 leds: leds-mc13783: Prepare driver to support MC13892 LEDs
Le 11/06/2013 20:29, Bryan Wu a ?crit :
Quoted 13 lines
Quoted 11 lines · Philippe R?tornaz
Le 10/06/2013 18:59, Alexander Shiyan a ?crit :
Quoted 4 lines
This patch rewrite driver code to be ready to add support for MC13892 LEDs and probe from devicetree.
Signed-off-by Alexander Shiyan <[email protected]>The whole serie:
Quoted 8 lines
Quoted 4 lines
Tested-by Philippe Retornaz <[email protected]>On mx31moboard with an mc13783.
Thanks for testing, did you test device tree as well? I failed to see any DTS file adding/change in this patchset.
No, I tested on a mx31moboard: mc13783 with an imx31, so no device tree. But AFAIK this board was the only in-tree user of this driver.
Regards,
Philippe
PATCH v4 1/3 leds: leds-mc13783: Prepare driver to support MC13892 LEDs
Quoted 22 lines · Philippe R?tornaz
Le 11/06/2013 20:29, Bryan Wu a ?crit :
Quoted 20 lines
Quoted 17 lines · Philippe R?tornaz
Le 10/06/2013 18:59, Alexander Shiyan a ?crit :
Quoted 4 lines
This patch rewrite driver code to be ready to add support for MC13892 LEDs and probe from devicetree.
Signed-off-by Alexander Shiyan <[email protected]>The whole serie:
Tested-by Philippe Retornaz <[email protected]>On mx31moboard with an mc13783.
Quoted 7 lines
Quoted 3 lines
Thanks for testing, did you test device tree as well? I failed to see any DTS file adding/change in this patchset.
No, I tested on a mx31moboard: mc13783 with an imx31, so no device tree. But AFAIK this board was the only in-tree user of this driver.
Sure, I merged these 3 patches into my tree.
Thanks,
-Bryan
Quoted 13 lines
Quoted 11 lines · Philippe R?tornaz
Le 10/06/2013 18:59, Alexander Shiyan a ?crit :
Quoted 4 lines
This patch rewrite driver code to be ready to add support for MC13892 LEDs and probe from devicetree.
Signed-off-by Alexander Shiyan <[email protected]>The whole serie:
Quoted 7 lines
Quoted 4 lines
Tested-by Philippe Retornaz <[email protected]>On mx31moboard with an mc13783.
Thanks for testing, did you test device tree as well? I failed to see any DTS file adding/change in this patchset.
DT test passed by me on the PCM-970 board (i.MX27 & MC13783). Non-DT test passed by me on Digi CCWMX51 module (i.MX51 & MC13892). Thanks.
---