LED fixes for 4.14-rc3

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJZzq0FAAoJEL1qUBy3i3wmiP0P/ihe5tcmm5ckT6PMCqgAlZQU
 7JDZCKlBZ/T50/f1luumkQ1rkfBD2KeG7NGjPWo2cmOKynalPkc/k2GJBuFzCrQw
 pkl4kpwxdg0EaufNQOFqIBaW14d5kug5upkImlrZNW442xB5/Xmhom8BVO9Uswz6
 wEOpq2QFbsxmtMGfbYC7PwmgmudutV0Iv4Eco940QjZd2ce3r0rkf0x8Q5CTYjHx
 LyoCDqcS4KA9lc88g8NMpI/NUEZ14hMSsZsMGpmXuvYgA2Mn4rtGNT4SFbOVnDW9
 97x7SsxwOJJoC1G1/XbNaRMgJnovAnDl/E7zT3k+ZqtQfXwbl78Jxp6lxB/E6te5
 PKmsqyNc0HvwWy7F8CPjnzn6Nuza9J1cMVU1wTWzQxLzTfm3MLs3Fx5bSKjFUe0g
 ENYDXzYkxiaD0sgfp8mi8qVLdXiidDkIxSX4LnhY3bKcNW6HfcI407lsb4aOpvBt
 Ho5cJWTuVCul4i/j38c0wU1SuYtdCwBOOpOR4FuTjkaCUbFNulHLAFxiKjEzTMSC
 NzVGFHpSLisB/AUTXD3F0jYK7XXqvj1NpVlbgjNVwhhPolv4TofxjGdAZ2IxLRSk
 p1XoRG4KN5Su1al2DS0m0r7hH4dxdvEsyCP0ylX73B+z3iCsIVedfo7Rihkj9Mi2
 oVgdidWdgkotQOrHefVE
 =swPa
 -----END PGP SIGNATURE-----

Merge tag 'led_fixes-4.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds

Pull LED fixes from Jacek Anaszewski:
 "Four fixes for the as3645a LED flash controller and one update to
  MAINTAINERS"

* tag 'led_fixes-4.14-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds:
  MAINTAINERS: Add entry for MediaTek PMIC LED driver
  as3645a: Unregister indicator LED on device unbind
  as3645a: Use integer numbers for parsing LEDs
  dt: bindings: as3645a: Use LED number to refer to LEDs
  as3645a: Use ams,input-max-microamp as documented in DT bindings
This commit is contained in:
Linus Torvalds 2017-09-29 19:33:32 -07:00
commit 95dcc4dc38
4 changed files with 57 additions and 16 deletions

View File

@ -15,11 +15,14 @@ Required properties
compatible : Must be "ams,as3645a". compatible : Must be "ams,as3645a".
reg : The I2C address of the device. Typically 0x30. 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 flash-timeout-us: Flash timeout in microseconds. The value must be in
the range [100000, 850000] and divisible by 50000. the range [100000, 850000] and divisible by 50000.
flash-max-microamp: Maximum flash current in microamperes. Has to be 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. 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. 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 led-max-microamp: Maximum indicator current. The allowed values are
2500, 5000, 7500 and 10000. 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. label : The label of the indicator LED.
@ -55,16 +59,20 @@ Example
======= =======
as3645a@30 { as3645a@30 {
#address-cells: 1
#size-cells: 0
reg = <0x30>; reg = <0x30>;
compatible = "ams,as3645a"; compatible = "ams,as3645a";
flash { flash@0 {
reg = <0x0>;
flash-timeout-us = <150000>; flash-timeout-us = <150000>;
flash-max-microamp = <320000>; flash-max-microamp = <320000>;
led-max-microamp = <60000>; led-max-microamp = <60000>;
ams,input-max-microamp = <1750000>; ams,input-max-microamp = <1750000>;
label = "as3645a:flash"; label = "as3645a:flash";
}; };
indicator { indicator@1 {
reg = <0x1>;
led-max-microamp = <10000>; led-max-microamp = <10000>;
label = "as3645a:indicator"; label = "as3645a:indicator";
}; };

View File

@ -8597,6 +8597,12 @@ M: Sean Wang <sean.wang@mediatek.com>
S: Maintained S: Maintained
F: drivers/media/rc/mtk-cir.c F: drivers/media/rc/mtk-cir.c
MEDIATEK PMIC LED DRIVER
M: Sean Wang <sean.wang@mediatek.com>
S: Maintained
F: drivers/leds/leds-mt6323.c
F: Documentation/devicetree/bindings/leds/leds-mt6323.txt
MEDIATEK ETHERNET DRIVER MEDIATEK ETHERNET DRIVER
M: Felix Fietkau <nbd@openwrt.org> M: Felix Fietkau <nbd@openwrt.org>
M: John Crispin <john@phrozen.org> M: John Crispin <john@phrozen.org>

View File

@ -267,15 +267,19 @@
clock-frequency = <400000>; clock-frequency = <400000>;
as3645a@30 { as3645a@30 {
#address-cells = <1>;
#size-cells = <0>;
reg = <0x30>; reg = <0x30>;
compatible = "ams,as3645a"; compatible = "ams,as3645a";
flash { flash@0 {
reg = <0x0>;
flash-timeout-us = <150000>; flash-timeout-us = <150000>;
flash-max-microamp = <320000>; flash-max-microamp = <320000>;
led-max-microamp = <60000>; led-max-microamp = <60000>;
peak-current-limit = <1750000>; ams,input-max-microamp = <1750000>;
}; };
indicator { indicator@1 {
reg = <0x1>;
led-max-microamp = <10000>; led-max-microamp = <10000>;
}; };
}; };

View File

@ -112,6 +112,10 @@
#define AS_PEAK_mA_TO_REG(a) \ #define AS_PEAK_mA_TO_REG(a) \
((min_t(u32, AS_PEAK_mA_MAX, a) - 1250) / 250) ((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 { enum as_mode {
AS_MODE_EXT_TORCH = 0 << AS_CONTROL_MODE_SETTING_SHIFT, AS_MODE_EXT_TORCH = 0 << AS_CONTROL_MODE_SETTING_SHIFT,
AS_MODE_INDICATOR = 1 << 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 device_node *node)
{ {
struct as3645a_config *cfg = &flash->cfg; struct as3645a_config *cfg = &flash->cfg;
struct device_node *child;
const char *name; const char *name;
int rval; 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) { if (!flash->flash_node) {
dev_err(&flash->client->dev, "can't find flash node\n"); dev_err(&flash->client->dev, "can't find flash node\n");
return -ENODEV; return -ENODEV;
@ -534,11 +557,10 @@ static int as3645a_parse_node(struct as3645a *flash,
of_property_read_u32(flash->flash_node, "voltage-reference", of_property_read_u32(flash->flash_node, "voltage-reference",
&cfg->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);
cfg->peak = AS_PEAK_mA_TO_REG(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) { if (!flash->indicator_node) {
dev_warn(&flash->client->dev, dev_warn(&flash->client->dev,
"can't find indicator node\n"); "can't find indicator node\n");
@ -721,6 +743,7 @@ static int as3645a_remove(struct i2c_client *client)
as3645a_set_control(flash, AS_MODE_EXT_TORCH, false); as3645a_set_control(flash, AS_MODE_EXT_TORCH, false);
v4l2_flash_release(flash->vf); v4l2_flash_release(flash->vf);
v4l2_flash_release(flash->vfind);
led_classdev_flash_unregister(&flash->fled); led_classdev_flash_unregister(&flash->fled);
led_classdev_unregister(&flash->iled_cdev); led_classdev_unregister(&flash->iled_cdev);