iio: health: max30100: add config for LED current
Subsystems (2)
PATCH 1/1 iio: health: max30100: add config for LED current
Allow the current for both RED and IR LEDs to be set via an device tree property setting.
This is an optional setting that is useful for applications that have a known glass attenuation factor.
--- .../devicetree/bindings/iio/health/max30100.txt | 7 +++++++ drivers/iio/health/max30100.c | 21 +++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/iio/health/max30100.txt +7 -0
@@ -11,11 +11,18 @@ Required properties: Refer to interrupt-controller/interrupts.txt for generic interrupt client node bindings. +Optional properties: + - max30100,led-current: configuration for LED current (in mA) while the engine + is running. Upper nibble is for the RED LED, and lower nibble the IR LED. + + Refer to the datasheet for the current mapping values. + Example: max30100@057 { compatible = "maxim,max30100"; reg = <57>; + max30100,led-current = <0x7f>; interrupt-parent = <&gpio1>; interrupts = <16 2>; };
drivers/iio/health/max30100.c +15 -6
@@ -13,7 +13,7 @@* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * -* TODO: allow LED current and pulse length controls via device tree properties +* TODO: enable pulse length controls via device tree properties */ #include <linux/module.h>
@@ -24,6 +24,7 @@#include <linux/irq.h> #include <linux/i2c.h> #include <linux/mutex.h> +#include <linux/of.h> #include <linux/regmap.h> #include <linux/iio/iio.h> #include <linux/iio/buffer.h>
@@ -245,13 +246,21 @@ static irqreturn_t max30100_interrupt_handler(int irq, void *private)static int max30100_chip_init (struct max30100_data *data) { +struct device *dev = &data->client->dev; +struct device_node *np = dev->of_node;int ret; +u32 val; -/* RED IR LED = 24mA, IR LED = 50mA */ - ret =regmap_write (data->regmap,MAX30100_REG_LED_CONFIG , - (MAX30100_REG_LED_CONFIG_24MA << -MAX30100_REG_LED_CONFIG_RED_LED_SHIFT ) | -MAX30100_REG_LED_CONFIG_50MA ); + ret =of_property_read_u32 (np,"max30100,led-current" , &val); +if (ret) { +/* Default to 24 mA RED LED, 50 mA IR LED */ + val = (MAX30100_REG_LED_CONFIG_24MA << +MAX30100_REG_LED_CONFIG_RED_LED_SHIFT ) | +MAX30100_REG_LED_CONFIG_50MA ; +dev_warn (dev,"no led-current set, defaulting to %d" , val); + } + + ret =regmap_write (data->regmap,MAX30100_REG_LED_CONFIG , val &0xFF );if (ret)return ret;
Signature · 1 line
2.6.4
A message that is not in the archive (sent off-list or not yet received): 1451191104-1281-1-git-send-email-mranostay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 17 lines · Matt Ranostay
Allow the current for both RED and IR LEDs to be set via an device tree property setting.
This is an optional setting that is useful for applications that have a known glass attenuation factor.
Signed-off-by Matt Ranostay <[email protected]>--- .../devicetree/bindings/iio/health/max30100.txt | 7 +++++++ drivers/iio/health/max30100.c | 21 +++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/iio/health/max30100.txt +0
-0
Documentation/devicetree/bindings/iio/health/max30100.txt Required properties: · line 16
Quoted 6 lines
Documentation/devicetree/bindings/iio/health/max30100.txt +3
-0@@ -11,11 +11,18 @@ Required properties: Refer to interrupt-controller/interrupts.txt for generic interrupt client node bindings. +Optional properties: + - max30100,led-current: configuration for LED current (in mA) while the engine + is running. Upper nibble is for the RED LED, and lower nibble the IR LED.
Can you use the common LED binding and led-max-microamp instead?
Otherwise, please add "-microamp" suffix and just split to 2 cells for RED and IR LEDs. Also, "max30100" is not a vendor prefix. Use maxim.
Documentation/devicetree/bindings/iio/health/max30100.txt Required properties: · line 26
Quoted 10 lines
Documentation/devicetree/bindings/iio/health/max30100.txt +10
-0+ ret = of_property_read_u32(np, "max30100,led-current", &val); + if (ret) { + /* Default to 24 mA RED LED, 50 mA IR LED */ + val = (MAX30100_REG_LED_CONFIG_24MA << + MAX30100_REG_LED_CONFIG_RED_LED_SHIFT) | + MAX30100_REG_LED_CONFIG_50MA; + dev_warn(dev, "no led-current set, defaulting to %d", val); + } + + ret = regmap_write(data->regmap, MAX30100_REG_LED_CONFIG, val & 0xFF);
Huh? You say the units are milliamps, but then you use the DT value directly?
Rob
Quoted 21 lines · Rob Herring
Quoted 20 lines · Matt Ranostay
Allow the current for both RED and IR LEDs to be set via an device tree property setting.
This is an optional setting that is useful for applications that have a known glass attenuation factor.
Signed-off-by Matt Ranostay <[email protected]>--- .../devicetree/bindings/iio/health/max30100.txt | 7 +++++++ drivers/iio/health/max30100.c | 21 +++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-)Documentation/devicetree/bindings/iio/health/max30100.txt +0
-0@@ -11,11 +11,18 @@ Required properties: Refer to interrupt-controller/interrupts.txt for generic interrupt client node bindings.
Quoted 8 lines
Documentation/devicetree/bindings/iio/health/max30100.txt Required properties: · line 16
Quoted 3 lines
Documentation/devicetree/bindings/iio/health/max30100.txt +3
-0+Optional properties: + - max30100,led-current: configuration for LED current (in mA) while the engine + is running. Upper nibble is for the RED LED, and lower nibble the IR LED.Can you use the common LED binding and led-max-microamp instead?
Otherwise, please add "-microamp" suffix and just split to 2 cells for RED and IR LEDs. Also, "max30100" is not a vendor prefix. Use maxim.
Ok.
Quoted 13 lines
Documentation/devicetree/bindings/iio/health/max30100.txt Required properties: · line 26
Quoted 12 lines
Documentation/devicetree/bindings/iio/health/max30100.txt +10
-0+ ret = of_property_read_u32(np, "max30100,led-current", &val); + if (ret) { + /* Default to 24 mA RED LED, 50 mA IR LED */ + val = (MAX30100_REG_LED_CONFIG_24MA << + MAX30100_REG_LED_CONFIG_RED_LED_SHIFT) | + MAX30100_REG_LED_CONFIG_50MA; + dev_warn(dev, "no led-current set, defaulting to %d", val); + } + + ret = regmap_write(data->regmap, MAX30100_REG_LED_CONFIG, val & 0xFF);
Quoted 2 lines
Huh? You say the units are milliamps, but then you use the DT value directly?
Yeah they are direct index values in the register. Probably should make the documentation more clear.
Quoted 2 lines
Rob
--
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