leds-bcm6328: several fixes and improvements
Subsystems (2)
cover leds-bcm6328: several fixes and improvements
These patches improve leds-bcm6328 by adding invalid LED printing (like it's done in leds-bcm6358), simplifying default-state handling (once again like it's done in leds-bcm6358), and adding more init configuration options.
Álvaro Fernández Rojas (4):
leds-bcm6328: print invalid LED
leds-bcm6328: simplify and improve default-state handling
leds-bcm6328: add more init configuration options
Documentation: leds: update DT bindings for leds-bcm6328
.../devicetree/bindings/leds/leds-bcm6328.txt | 10 ++++++ drivers/leds/leds-bcm6328.c | 41 ++++++++++++++++------ 2 files changed, 40 insertions(+), 11 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/4 leds-bcm6328: print invalid LED
Print invalid LED instead of warning only about maximum LED value.
--- drivers/leds/leds-bcm6328.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-bcm6328.c +1 -1
@@ -373,7 +373,7 @@ static int bcm6328_leds_probe(struct platform_device *pdev)continue ;if (reg >=BCM6328_LED_MAX_COUNT ) { -dev_err (dev,"invalid LED (>= %d)\n" , +dev_err (dev,"invalid LED (%u >= %d)\n" , reg,BCM6328_LED_MAX_COUNT );continue ; }
Signature · 1 line
1.9.1
PATCH 2/4 leds-bcm6328: simplify and improve default-state handling
In reply to Álvaro Fernández RojasThis patch simplifies and improves the code related to default-state handling.
It also changes the code to power off the LEDs by default.
--- drivers/leds/leds-bcm6328.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/leds/leds-bcm6328.c +15 -9
@@ -281,11 +281,10 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,"linux,default-trigger" , NULL); +spin_lock_irqsave (lock, flags);if (!of_property_read_string (nc,"default-state" , &state)) { -spin_lock_irqsave (lock, flags);if (!strcmp (state,"on" )) { led->cdev.brightness =LED_FULL ; -bcm6328_led_mode (led,BCM6328_LED_MODE_ON ); }else if (!strcmp (state,"keep" )) {void __iomem *mode;unsigned long val, shift;
@@ -296,21 +295,28 @@ static int bcm6328_led(struct device *dev, struct device_node *nc, u32 reg,else mode = mem +BCM6328_REG_MODE_LO ; - val =bcm6328_led_read (mode) >> (shift %16 ); + val =bcm6328_led_read (mode) >> +BCM6328_LED_SHIFT (shift %16 ); val &=BCM6328_LED_MODE_MASK ; -if (val ==BCM6328_LED_MODE_ON ) +if ((led->active_low && val ==BCM6328_LED_MODE_ON ) || + (!led->active_low && val ==BCM6328_LED_MODE_OFF )) led->cdev.brightness =LED_FULL ; -else { +else led->cdev.brightness =LED_OFF ; -bcm6328_led_mode (led,BCM6328_LED_MODE_OFF ); - } }else { led->cdev.brightness =LED_OFF ; -bcm6328_led_mode (led,BCM6328_LED_MODE_OFF ); } -spin_unlock_irqrestore (lock, flags); + }else { + led->cdev.brightness =LED_OFF ; } +if ((led->active_low && led->cdev.brightness ==LED_FULL ) || + (!led->active_low && led->cdev.brightness ==LED_OFF )) +bcm6328_led_mode (led,BCM6328_LED_MODE_ON ); +else +bcm6328_led_mode (led,BCM6328_LED_MODE_OFF ); +spin_unlock_irqrestore (lock, flags); + led->cdev.brightness_set = bcm6328_led_set; led->cdev.blink_set = bcm6328_blink_set;
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): 1444300555-13988-1-git-send-email-noltari-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 3/4 leds-bcm6328: add more init configuration options
This patch adds more init register configuration options:
- Serial LEDs multiplexing.
- Serial LEDs clock signal low/high polarity.
- Serial LEDs data signal low/high polarity.
- Serial LEDs shift direction inverted/normal.
--- drivers/leds/leds-bcm6328.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/leds/leds-bcm6328.c +14 -1
@@ -41,6 +41,11 @@#define BCM6328_SERIAL_LED_SHIFT_DIR BIT(16)#define BCM6328_LED_SHIFT_TEST BIT(30)#define BCM6328_LED_TEST BIT(31) +#define BCM6328_INIT_MASK (BCM6328_SERIAL_LED_EN | \ + BCM6328_SERIAL_LED_MUX | \ + BCM6328_SERIAL_LED_CLK_NPOL | \ + BCM6328_SERIAL_LED_DATA_PPOL | \ + BCM6328_SERIAL_LED_SHIFT_DIR)#define BCM6328_LED_MODE_MASK 3#define BCM6328_LED_MODE_OFF 0
@@ -366,9 +371,17 @@ static int bcm6328_leds_probe(struct platform_device *pdev)bcm6328_led_write (mem +BCM6328_REG_LNKACTSEL_LO ,0 ); val =bcm6328_led_read (mem +BCM6328_REG_INIT ); - val &= ~BCM6328_SERIAL_LED_EN ; + val &= ~(BCM6328_INIT_MASK );if (of_property_read_bool (np,"brcm,serial-leds" )) val |=BCM6328_SERIAL_LED_EN ; +if (of_property_read_bool (np,"brcm,serial-mux" )) + val |=BCM6328_SERIAL_LED_MUX ; +if (of_property_read_bool (np,"brcm,serial-clk-low" )) + val |=BCM6328_SERIAL_LED_CLK_NPOL ; +if (!of_property_read_bool (np,"brcm,serial-dat-low" )) + val |=BCM6328_SERIAL_LED_DATA_PPOL ; +if (!of_property_read_bool (np,"brcm,serial-shift-inv" )) + val |=BCM6328_SERIAL_LED_SHIFT_DIR ;bcm6328_led_write (mem +BCM6328_REG_INIT , val);for_each_available_child_of_node (np, child) {
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/4 Documentation: leds: update DT bindings for leds-bcm6328
In reply to a message not in the archiveThis patch adds latest DT bindings for leds-bcm6328 init register configuration.
--- Documentation/devicetree/bindings/leds/leds-bcm6328.txt | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/leds/leds-bcm6328.txt +10 -0
@@ -29,6 +29,14 @@ Required properties: Optional properties: - brcm,serial-leds : Boolean, enables Serial LEDs. Default : false + - brcm,serial-mux : Boolean, enables Serial LEDs multiplexing. + Default : false + - brcm,serial-clk-low : Boolean, makes clock signal active low. + Default : false + - brcm,serial-dat-low : Boolean, makes data signal active low. + Default : false + - brcm,serial-shift-inv : Boolean, inverts Serial LEDs shift direction. + Default : false Each LED is represented as a sub-node of the brcm,bcm6328-leds device.
@@ -110,6 +118,8 @@ Scenario 2 : BCM63268 with Serial/GPHY0 LEDs #size-cells = <0>; reg = <0x10001900 0x24>; brcm,serial-leds; + brcm,serial-dat-low; + brcm,serial-shift-inv; gphy0_spd0@0 { reg = <0>;
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Alvaro,
Thanks for the patches, merged.
Best Regards,
Jacek Anaszewski
Quoted 12 lines · Álvaro Fernández Rojas
These patches improve leds-bcm6328 by adding invalid LED printing (like it's done in leds-bcm6358), simplifying default-state handling (once again like it's done in leds-bcm6358), and adding more init configuration options.
Álvaro Fernández Rojas (4):
leds-bcm6328: print invalid LED
leds-bcm6328: simplify and improve default-state handling
leds-bcm6328: add more init configuration options
Documentation: leds: update DT bindings for leds-bcm6328.../devicetree/bindings/leds/leds-bcm6328.txt | 10 ++++++ drivers/leds/leds-bcm6328.c | 41 ++++++++++++++++------ 2 files changed, 40 insertions(+), 11 deletions(-)