From 16c5c023aac86228e3e94c4bf6d19708ea861a05 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 3 May 2012 12:26:36 +0200 Subject: mfd: Add LM3533 lighting-power core driver Add support for National Semiconductor / TI LM3533 lighting power chips. This is the core driver which provides register access over I2C and registers the ambient-light-sensor, LED and backlight sub-drivers. Signed-off-by: Johan Hovold Reviewed-by: Mark Brown Signed-off-by: Samuel Ortiz --- include/linux/mfd/lm3533.h | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 include/linux/mfd/lm3533.h (limited to 'include/linux/mfd/lm3533.h') diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h new file mode 100644 index 000000000000..75f85f3fbd90 --- /dev/null +++ b/include/linux/mfd/lm3533.h @@ -0,0 +1,89 @@ +/* + * lm3533.h -- LM3533 interface + * + * Copyright (C) 2011-2012 Texas Instruments + * + * Author: Johan Hovold + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __LINUX_MFD_LM3533_H +#define __LINUX_MFD_LM3533_H + +#define LM3533_ATTR_RO(_name) \ + DEVICE_ATTR(_name, S_IRUGO, show_##_name, NULL) +#define LM3533_ATTR_RW(_name) \ + DEVICE_ATTR(_name, S_IRUGO | S_IWUSR , show_##_name, store_##_name) + +struct device; +struct regmap; + +struct lm3533 { + struct device *dev; + + struct regmap *regmap; + + int gpio_hwen; + int irq; + + unsigned have_als:1; + unsigned have_backlights:1; + unsigned have_leds:1; +}; + +struct lm3533_ctrlbank { + struct lm3533 *lm3533; + struct device *dev; + int id; +}; + +struct lm3533_als_platform_data { + unsigned pwm_mode:1; /* PWM input mode (default analog) */ +}; + +struct lm3533_bl_platform_data { + char *name; + u8 default_brightness; /* 0 - 255 */ + u8 max_current; /* 0 - 31 */ + u8 pwm; /* 0 - 0x3f */ +}; + +struct lm3533_led_platform_data { + char *name; + const char *default_trigger; + u8 max_current; /* 0 - 31 */ + u8 pwm; /* 0 - 0x3f */ +}; + +struct lm3533_platform_data { + int gpio_hwen; + + struct lm3533_als_platform_data *als; + + struct lm3533_bl_platform_data *backlights; + int num_backlights; + + struct lm3533_led_platform_data *leds; + int num_leds; +}; + +extern int lm3533_ctrlbank_enable(struct lm3533_ctrlbank *cb); +extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb); + +extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val); +extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val); +extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, u8 val); +extern int lm3533_ctrlbank_get_max_current(struct lm3533_ctrlbank *cb, + u8 *val); +extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val); +extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val); + +extern int lm3533_read(struct lm3533 *lm3533, u8 reg, u8 *val); +extern int lm3533_write(struct lm3533 *lm3533, u8 reg, u8 val); +extern int lm3533_update(struct lm3533 *lm3533, u8 reg, u8 val, u8 mask); + +#endif /* __LINUX_MFD_LM3533_H */ -- cgit v1.2.1 From d9055dc501da6734e3cfea1ef236173bd8b645b1 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 10 May 2012 14:11:28 +0200 Subject: mfd: Add boost frequency and ovp to lm3533 platform data Add boost-frequency and over-voltage-protection settings to platform data. Signed-off-by: Johan Hovold Signed-off-by: Samuel Ortiz --- include/linux/mfd/lm3533.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/linux/mfd/lm3533.h') diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h index 75f85f3fbd90..336113759fd1 100644 --- a/include/linux/mfd/lm3533.h +++ b/include/linux/mfd/lm3533.h @@ -59,9 +59,24 @@ struct lm3533_led_platform_data { u8 pwm; /* 0 - 0x3f */ }; +enum lm3533_boost_freq { + LM3533_BOOST_FREQ_500KHZ, + LM3533_BOOST_FREQ_1000KHZ, +}; + +enum lm3533_boost_ovp { + LM3533_BOOST_OVP_16V, + LM3533_BOOST_OVP_24V, + LM3533_BOOST_OVP_32V, + LM3533_BOOST_OVP_40V, +}; + struct lm3533_platform_data { int gpio_hwen; + enum lm3533_boost_ovp boost_ovp; + enum lm3533_boost_freq boost_freq; + struct lm3533_als_platform_data *als; struct lm3533_bl_platform_data *backlights; -- cgit v1.2.1 From 7af5e87dc5e6b6f413ba95b06e06ebf810687858 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 10 May 2012 19:18:28 +0200 Subject: mfd: Remove unused max-current lm3533 function The max-current attributes of the subdrivers have been dropped so remove the no longer used lm3533_ctrlbank_get_max_current function. Signed-off-by: Johan Hovold Signed-off-by: Samuel Ortiz --- include/linux/mfd/lm3533.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/linux/mfd/lm3533.h') diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h index 336113759fd1..7cfef9e4f41b 100644 --- a/include/linux/mfd/lm3533.h +++ b/include/linux/mfd/lm3533.h @@ -92,8 +92,6 @@ extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb); extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val); extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val); extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, u8 val); -extern int lm3533_ctrlbank_get_max_current(struct lm3533_ctrlbank *cb, - u8 *val); extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val); extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val); -- cgit v1.2.1 From 6fa4b9d802610116adf4b89c2f9bd155829aafd3 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 10 May 2012 19:18:29 +0200 Subject: mfd: Use SI-units for the lm3533 max-current interface Use SI-units (uA) for max-current interface (5000 - 29800 uA). Signed-off-by: Johan Hovold Signed-off-by: Samuel Ortiz --- include/linux/mfd/lm3533.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/linux/mfd/lm3533.h') diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h index 7cfef9e4f41b..9660febe93c2 100644 --- a/include/linux/mfd/lm3533.h +++ b/include/linux/mfd/lm3533.h @@ -47,15 +47,15 @@ struct lm3533_als_platform_data { struct lm3533_bl_platform_data { char *name; + u16 max_current; /* 5000 - 29800 uA (800 uA step) */ u8 default_brightness; /* 0 - 255 */ - u8 max_current; /* 0 - 31 */ u8 pwm; /* 0 - 0x3f */ }; struct lm3533_led_platform_data { char *name; const char *default_trigger; - u8 max_current; /* 0 - 31 */ + u16 max_current; /* 5000 - 29800 uA (800 uA step) */ u8 pwm; /* 0 - 0x3f */ }; @@ -91,7 +91,8 @@ extern int lm3533_ctrlbank_disable(struct lm3533_ctrlbank *cb); extern int lm3533_ctrlbank_set_brightness(struct lm3533_ctrlbank *cb, u8 val); extern int lm3533_ctrlbank_get_brightness(struct lm3533_ctrlbank *cb, u8 *val); -extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, u8 val); +extern int lm3533_ctrlbank_set_max_current(struct lm3533_ctrlbank *cb, + u16 imax); extern int lm3533_ctrlbank_set_pwm(struct lm3533_ctrlbank *cb, u8 val); extern int lm3533_ctrlbank_get_pwm(struct lm3533_ctrlbank *cb, u8 *val); -- cgit v1.2.1 From 730a3d01b1e1e3ba102a5a4d3d5dcfecd55326b6 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Fri, 18 May 2012 20:22:45 +0200 Subject: mfd: Add r_select to lm3533 platform data Add resistor-select parameter to the platform data. Signed-off-by: Johan Hovold Signed-off-by: Samuel Ortiz --- include/linux/mfd/lm3533.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include/linux/mfd/lm3533.h') diff --git a/include/linux/mfd/lm3533.h b/include/linux/mfd/lm3533.h index 9660febe93c2..594bc591f256 100644 --- a/include/linux/mfd/lm3533.h +++ b/include/linux/mfd/lm3533.h @@ -43,6 +43,7 @@ struct lm3533_ctrlbank { struct lm3533_als_platform_data { unsigned pwm_mode:1; /* PWM input mode (default analog) */ + u8 r_select; /* 1 - 127 (ignored in PWM-mode) */ }; struct lm3533_bl_platform_data { -- cgit v1.2.1