Skip to contentSkip to conversation

Panasonic AN30259A support

PATCH Applied Simon Shields 2 participants 4 messages Sep 9, 2018 – Sep 10, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v5 cover Panasonic AN30259A support

Hi,

This patch series adds DT bindings (patch #1) and the corresponding driver (patch #2) for the Panasonic AN30259A 3-channel LED driver. AN30259A uses an internal clock for controlling brightness/on-off cycles, but also supports using an external PWM/clock input. This patch series only implements support for the former.

The AN30259A is connected using I2C, and the datasheet is freely available[0].

Changes since v4 (mistakenly sent as v3):
* Rebased on v4.19-rc2
* Namespace all macros with AN30259A_ prefix
* Fix trivial compiler/checkpatch --strict warnings

Changes since v3:
* Rebased on v4.18-rc3.
* Drop unnecessary DUTYMAX/MID calculations when blinking:
previously I'd thought that the PWM duty values were expressed as a percentage of the maximum current output, but in reality they're a percentage of the current set in the LEDxCC registers.
This simplifies the code quite a bit.
* Corrected MODULE_LICENSE declaration.
* Return -EINVAL from set_blink if the blink rate is unsupported in hardware.
* Fix more checkpatch --strict issues.

Changes since v2:
* Drop "an30259a:" prefix from bindings and add it in the device driver instead.
* Use led-controller instead of leds for sample DT binding.
* Use ":indicator" instead of ":notification" in sample DT binding.
* Merge an30259a_led_set and an30259a_brightness to an30259a_brightness_set (and same for blink functions).
* Explain the range limitations of the AN30259A's sloping mode in the code - the AN30259A only has a 7-bit PWM range in slope mode, and the bottom 3 bits are always set.

Changes since v1:
* Documentation formatting/grammar fixes.
* Use reg property instead of led-sources for leds.
* Add default-state support.
* Fix auto-probing when built as a module.
* Simplified DT parsing code.
* Use devm version of led_class_register().
* Fix LED naming scheme.
* Fixed checkpatch --strict issues.

Cheers,
Simon

[0]: https://www.alliedelec.com/m/d/a9d2b3ee87c2d1a535a41dd747b1c247.pdf

Simon Shields (2):
dt-bindings: leds: document Panasonic AN30259A bindings
leds: add Panasonic AN30259A support

 .../bindings/leds/leds-an30259a.txt           |  43 ++
 drivers/leds/Kconfig                          |  10 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-an30259a.c                  | 368 ++++++++++++++++++
 4 files changed, 422 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-an30259a.txt
 create mode 100644 drivers/leds/leds-an30259a.c
Signature · 1 line
2.18.0
#1 lore raw

PATCH v5 1/2 dt-bindings: leds: document Panasonic AN30259A bindings

---
 .../bindings/leds/leds-an30259a.txt           | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-an30259a.txt
Documentation/devicetree/bindings/leds/leds-an30259a.txt new file +43 -0
new file mode 100644
index 000000000000..6ffb861083c0
@@ -0,0 +1,43 @@
+* Panasonic AN30259A 3-channel LED driver
+
+The AN30259A is a LED controller capable of driving three LEDs independently. It supports
+constant current output and sloping current output modes. The chip is connected over I2C.
+
+Required properties:
+	- compatible: Must be "panasonic,an30259a".
+	- reg: I2C slave address.
+	- #address-cells: Must be 1.
+	- #size-cells: Must be 0.
+
+Each LED is represented as a sub-node of the panasonic,an30259a node.
+
+Required sub-node properties:
+	- reg: Pin that the LED is connected to. Must be 1, 2, or 3.
+
+Optional sub-node properties:
+	- label: see Documentation/devicetree/bindings/leds/common.txt
+	- linux,default-trigger: see Documentation/devicetree/bindings/leds/common.txt
+
+Example:
+led-controller@30 {
+	compatible = "panasonic,an30259a";
+	reg = <0x30>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	led@1 {
+		reg = <1>;
+		linux,default-trigger = "heartbeat";
+		label = "red:indicator";
+	};
+
+	led@2 {
+		reg = <2>;
+		label = "green:indicator";
+	};
+
+	led@3 {
+		reg = <3>;
+		label = "blue:indicator";
+	};
+};
Signature · 1 line
2.18.0
#2 lore raw

PATCH v5 2/2 leds: add Panasonic AN30259A support

In reply to Simon Shields

AN30259A is a 3-channel LED driver which uses I2C. It supports timed operation via an internal PWM clock, and variable brightness. This driver offers support for basic hardware-based blinking and brightness control.

The datasheet is freely available:
https://www.alliedelec.com/m/d/a9d2b3ee87c2d1a535a41dd747b1c247.pdf

---
 drivers/leds/Kconfig         |  10 +
 drivers/leds/Makefile        |   1 +
 drivers/leds/leds-an30259a.c | 368 +++++++++++++++++++++++++++++++++++
 3 files changed, 379 insertions(+)
 create mode 100644 drivers/leds/leds-an30259a.c
drivers/leds/Kconfig +10 -0
index 44097a3e0fcc..a72f97fca57b 100644
@@ -58,6 +58,16 @@ config LEDS_AAT1290
 	help
 	 This option enables support for the LEDs on the AAT1290.
 
+config LEDS_AN30259A
+	tristate "LED support for Panasonic AN30259A"
+	depends on LEDS_CLASS && I2C && OF
+	help
+	  This option enables support for the AN30259A 3-channel
+	  LED driver.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called leds-an30259a.
+
 config LEDS_APU
 	tristate "Front panel LED support for PC Engines APU/APU2/APU3 boards"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index 420b5d2cfa62..4c1b0054f379 100644
@@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
 obj-$(CONFIG_LEDS_AAT1290)		+= leds-aat1290.o
 obj-$(CONFIG_LEDS_APU)			+= leds-apu.o
 obj-$(CONFIG_LEDS_AS3645A)		+= leds-as3645a.o
+obj-$(CONFIG_LEDS_AN30259A)		+= leds-an30259a.o
 obj-$(CONFIG_LEDS_BCM6328)		+= leds-bcm6328.o
 obj-$(CONFIG_LEDS_BCM6358)		+= leds-bcm6358.o
 obj-$(CONFIG_LEDS_BD2802)		+= leds-bd2802.o
drivers/leds/leds-an30259a.c new file +368 -0

368 lines not on this page · raw message

Signature · 1 line
2.18.0
#3 lore raw
In reply to Simon Shields

Hi Simon,

Thank you for the updated set.

Quoted 58 lines · Simon Shields

Hi,

This patch series adds DT bindings (patch #1) and the corresponding driver (patch #2) for the Panasonic AN30259A 3-channel LED driver. AN30259A uses an internal clock for controlling brightness/on-off cycles, but also supports using an external PWM/clock input. This patch series only implements support for the former.

The AN30259A is connected using I2C, and the datasheet is freely available[0].

Changes since v4 (mistakenly sent as v3):
* Rebased on v4.19-rc2
* Namespace all macros with AN30259A_ prefix
* Fix trivial compiler/checkpatch --strict warnings

Changes since v3:
* Rebased on v4.18-rc3.
* Drop unnecessary DUTYMAX/MID calculations when blinking:
previously I'd thought that the PWM duty values were expressed as a percentage of the maximum current output, but in reality they're a percentage of the current set in the LEDxCC registers.
This simplifies the code quite a bit.
* Corrected MODULE_LICENSE declaration.
* Return -EINVAL from set_blink if the blink rate is unsupported in hardware.
* Fix more checkpatch --strict issues.

Changes since v2:
* Drop "an30259a:" prefix from bindings and add it in the device driver instead.
* Use led-controller instead of leds for sample DT binding.
* Use ":indicator" instead of ":notification" in sample DT binding.
* Merge an30259a_led_set and an30259a_brightness to an30259a_brightness_set (and same for blink functions).
* Explain the range limitations of the AN30259A's sloping mode in the code - the AN30259A only has a 7-bit PWM range in slope mode, and the bottom 3 bits are always set.

Changes since v1:
* Documentation formatting/grammar fixes.
* Use reg property instead of led-sources for leds.
* Add default-state support.
* Fix auto-probing when built as a module.
* Simplified DT parsing code.
* Use devm version of led_class_register().
* Fix LED naming scheme.
* Fixed checkpatch --strict issues.

Cheers,
Simon

[0]: https://www.alliedelec.com/m/d/a9d2b3ee87c2d1a535a41dd747b1c247.pdf

Simon Shields (2):
dt-bindings: leds: document Panasonic AN30259A bindings
leds: add Panasonic AN30259A support

Quoted 8 lines
 .../bindings/leds/leds-an30259a.txt           |  43 ++
 drivers/leds/Kconfig                          |  10 +
 drivers/leds/Makefile                         |   1 +
 drivers/leds/leds-an30259a.c                  | 368 ++++++++++++++++++
 4 files changed, 422 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/leds-an30259a.txt
 create mode 100644 drivers/leds/leds-an30259a.c

Applied to the for-next branch of linux-leds.git.

Signature · 2 lines
Best regards,
Jacek Anaszewski