AS3645A fixes
Subsystems (2)
v2 cover AS3645A fixes
Hi folks,
Here are a few fixes for the as3645a DTS as well as changes in bindings. The driver is not in a release yet. I'd like to get these in as through the media tree fixes branch.
since v1:
- Add LED colour to the name of the LED, this adds two patches to the set.
- Add a patch to unregister the indicator LED in driver remove function.
- No changes to v1 patches.
Sakari Ailus (6):
as3645a: Use ams,input-max-microamp as documented in DT bindings
dt: bindings: as3645a: Use LED number to refer to LEDs
as3645a: Use integer numbers for parsing LEDs
dt: bindings: as3645a: Improve label documentation, DT example
as3645a: Add colour to LED name
as3645a: Unregister indicator LED on device unbind
.../devicetree/bindings/leds/ams,as3645a.txt | 40 ++++++++++++++-------- arch/arm/boot/dts/omap3-n950-n9.dtsi | 10 ++++-- drivers/leds/leds-as3645a.c | 33 +++++++++++++++--- 3 files changed, 61 insertions(+), 22 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 1/6 as3645a: Use ams,input-max-microamp as documented in DT bindings
DT bindings document the property "ams,input-max-microamp" that limits the chip's maximum input current. The driver and the DTS however used "peak-current-limit" property. Fix this by using the property documented in DT binding documentation.
--- arch/arm/boot/dts/omap3-n950-n9.dtsi | 2 +- drivers/leds/leds-as3645a.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/omap3-n950-n9.dtsi +1 -1
@@ -273,7 +273,7 @@ flash-timeout-us = <150000>; flash-max-microamp = <320000>; led-max-microamp = <60000>; - peak-current-limit = <1750000>; + ams,input-max-microamp = <1750000>; }; indicator { led-max-microamp = <10000>;
drivers/leds/leds-as3645a.c +1 -1
@@ -534,7 +534,7 @@ static int as3645a_parse_node(struct as3645a *flash,of_property_read_u32 (flash->flash_node,"voltage-reference" , &cfg->voltage_reference); -of_property_read_u32 (flash->flash_node,"peak-current-limit" , +of_property_read_u32 (flash->flash_node,"ams,input-max-microamp" , &cfg->peak); cfg->peak =AS_PEAK_mA_TO_REG (cfg->peak);
Signature · 1 line
2.11.0
PATCH v2 2/6 dt: bindings: as3645a: Use LED number to refer to LEDs
In reply to Sakari AilusUse integers (reg property) to tell the number of the LED to the driver instead of the node name. While both of these approaches are currently used by the LED bindings, using integers will require less driver changes for ACPI support. Additionally, it will make possible LED naming using chip and LED node names, effectively making the label property most useful for human-readable names only.
--- .../devicetree/bindings/leds/ams,as3645a.txt | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/leds/ams,as3645a.txt +18 -10
@@ -15,11 +15,14 @@ Required properties compatible : Must be "ams,as3645a". reg : The I2C address of the device. Typically 0x30. +#address-cells : 1 +#size-cells : 0 -Required properties of the "flash" child node -============================================= +Required properties of the flash child node (0) +=============================================== +reg: 0 flash-timeout-us: Flash timeout in microseconds. The value must be in the range [100000, 850000] and divisible by 50000. flash-max-microamp: Maximum flash current in microamperes. Has to be
@@ -33,20 +36,21 @@ ams,input-max-microamp: Maximum flash controller input current. The and divisible by 50000. -Optional properties of the "flash" child node -============================================= +Optional properties of the flash child node +=========================================== label : The label of the flash LED. -Required properties of the "indicator" child node -================================================= +Required properties of the indicator child node (1) +=================================================== +reg: 1 led-max-microamp: Maximum indicator current. The allowed values are 2500, 5000, 7500 and 10000. -Optional properties of the "indicator" child node -================================================= +Optional properties of the indicator child node +=============================================== label : The label of the indicator LED.
@@ -55,16 +59,20 @@ Example ======= as3645a@30 { + #address-cells: 1 + #size-cells: 0 reg = <0x30>; compatible = "ams,as3645a"; - flash { + flash@0 { + reg = <0x0>; flash-timeout-us = <150000>; flash-max-microamp = <320000>; led-max-microamp = <60000>; ams,input-max-microamp = <1750000>; label = "as3645a:flash"; }; - indicator { + indicator@1 { + reg = <0x1>; led-max-microamp = <10000>; label = "as3645a:indicator"; };
Signature · 1 line
2.11.0
PATCH v2 3/6 as3645a: Use integer numbers for parsing LEDs
In reply to Sakari AilusUse integer numbers for LEDs, 0 is the flash and 1 is the indicator.
--- arch/arm/boot/dts/omap3-n950-n9.dtsi | 8 ++++++-- drivers/leds/leds-as3645a.c | 26 ++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-)
arch/arm/boot/dts/omap3-n950-n9.dtsi +6 -2
@@ -267,15 +267,19 @@ clock-frequency = <400000>; as3645a@30 { + #address-cells = <1>; + #size-cells = <0>; reg = <0x30>; compatible = "ams,as3645a"; - flash { + flash@0 { + reg = <0x0>; flash-timeout-us = <150000>; flash-max-microamp = <320000>; led-max-microamp = <60000>; ams,input-max-microamp = <1750000>; }; - indicator { + indicator@1 { + reg = <0x1>; led-max-microamp = <10000>; }; };
drivers/leds/leds-as3645a.c +24 -2
@@ -112,6 +112,10 @@#define AS_PEAK_mA_TO_REG (a) \ ((min_t(u32, AS_PEAK_mA_MAX, a) - 1250) / 250) +/* LED numbers for Devicetree */ +#define AS_LED_FLASH 0 +#define AS_LED_INDICATOR 1 +enum as_mode {AS_MODE_EXT_TORCH =0 <<AS_CONTROL_MODE_SETTING_SHIFT ,AS_MODE_INDICATOR =1 <<AS_CONTROL_MODE_SETTING_SHIFT ,
@@ -491,10 +495,29 @@ static int as3645a_parse_node(struct as3645a *flash, struct device_node *node) {struct as3645a_config *cfg = &flash->cfg; +struct device_node *child;const char *name;int rval; - flash->flash_node =of_get_child_by_name (node,"flash" ); +for_each_child_of_node (node, child) { +u32 id =0 ; + +of_property_read_u32 (child,"reg" , &id); + +switch (id) { +case AS_LED_FLASH : + flash->flash_node =of_node_get (child); +break ; +case AS_LED_INDICATOR : + flash->indicator_node =of_node_get (child); +break ; +default : +dev_warn (&flash->client->dev, +"unknown LED %u encountered, ignoring\n" , id); +break ; + } + } +if (!flash->flash_node) {dev_err (&flash->client->dev,"can't find flash node\n" );return -ENODEV ;
@@ -538,7 +561,6 @@ static int as3645a_parse_node(struct as3645a *flash, &cfg->peak); cfg->peak =AS_PEAK_mA_TO_REG (cfg->peak); - flash->indicator_node =of_get_child_by_name (node,"indicator" );if (!flash->indicator_node) {dev_warn (&flash->client->dev,"can't find indicator node\n" );
Signature · 1 line
2.11.0
PATCH v2 4/6 dt: bindings: as3645a: Improve label documentation, DT example
In reply to Sakari AilusSpecify the exact label used if the label property is omitted in DT, as well as use label in the example that conforms to LED device naming.
--- Documentation/devicetree/bindings/leds/ams,as3645a.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/leds/ams,as3645a.txt +8 -4
@@ -39,7 +39,9 @@ ams,input-max-microamp: Maximum flash controller input current. The Optional properties of the flash child node =========================================== -label : The label of the flash LED. +label : The label of the flash LED. The label is otherwise assumed to + be the device node name concatenated with ":white:" and the + name of the flash LED node is assumed if omitted. Required properties of the indicator child node (1)
@@ -52,7 +54,9 @@ led-max-microamp: Maximum indicator current. The allowed values are Optional properties of the indicator child node =============================================== -label : The label of the indicator LED. +label : The label of the indicator LED. The label is otherwise assumed + to be the device node name concatenated with ":red:" and the + name of the indicator LED node is assumed if omitted. Example
@@ -69,11 +73,11 @@ Example flash-max-microamp = <320000>; led-max-microamp = <60000>; ams,input-max-microamp = <1750000>; - label = "as3645a:flash"; + label = "as3645a:white:flash"; }; indicator@1 { reg = <0x1>; led-max-microamp = <10000>; - label = "as3645a:indicator"; + label = "as3645a:red:indicator"; }; };
Signature · 1 line
2.11.0
A message that is not in the archive (sent off-list or not yet received): 20170918101756.8562-1-sakari.ailus-VuQAYsv1563Yd54FQh9/[email protected]
PATCH v2 5/6 as3645a: Add colour to LED name
Add the colour of the LED to the LED name, as specified in Documentation/leds/leds-class.txt.
--- drivers/leds/leds-as3645a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-as3645a.c +2 -2
@@ -528,7 +528,7 @@ static int as3645a_parse_node(struct as3645a *flash,strlcpy (names->flash, name,sizeof (names->flash)); else snprintf(names->flash, sizeof(names->flash), - "%s:flash", node->name); + "%s:white:flash", node->name); rval =of_property_read_u32 (flash->flash_node,"flash-timeout-us" , &cfg->flash_timeout_us);
@@ -572,7 +572,7 @@ static int as3645a_parse_node(struct as3645a *flash,strlcpy (names->indicator, name,sizeof (names->indicator)); else snprintf(names->indicator, sizeof(names->indicator), - "%s:indicator", node->name); + "%s:red:indicator", node->name); rval =of_property_read_u32 (flash->indicator_node,"led-max-microamp" , &cfg->indicator_max_ua);
Signature · 6 lines
2.11.0 -- 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 v2 6/6 as3645a: Unregister indicator LED on device unbind
In reply to Sakari AilusThe indicator LED was registered in probe but was not removed in driver remove callback. Fix this.
--- drivers/leds/leds-as3645a.c | 1 + 1 file changed, 1 insertion(+)
drivers/leds/leds-as3645a.c +1 -0
@@ -743,6 +743,7 @@ static int as3645a_remove(struct i2c_client *client)as3645a_set_control (flash,AS_MODE_EXT_TORCH , false);v4l2_flash_release (flash->vf); +v4l2_flash_release (flash->vfind);led_classdev_flash_unregister (&flash->fled);led_classdev_unregister (&flash->iled_cdev);
Signature · 1 line
2.11.0