Commit 517ea49a authored by Dan Murphy's avatar Dan Murphy Committed by Jacek Anaszewski

leds: lm3532: Add full scale current configuration

Allow the full scale current to be configured at init.
Valid rangles are 5mA->29.8mA.
Signed-off-by: default avatarDan Murphy <dmurphy@ti.com>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
parent aa01d255
...@@ -89,6 +89,10 @@ ...@@ -89,6 +89,10 @@
#define LM3532_NUM_AVG_VALS 8 #define LM3532_NUM_AVG_VALS 8
#define LM3532_NUM_IMP_VALS 32 #define LM3532_NUM_IMP_VALS 32
#define LM3532_FS_CURR_MIN 5000
#define LM3532_FS_CURR_MAX 29800
#define LM3532_FS_CURR_STEP 800
/* /*
* struct lm3532_als_data * struct lm3532_als_data
* @config - value of ALS configuration register * @config - value of ALS configuration register
...@@ -121,6 +125,7 @@ struct lm3532_als_data { ...@@ -121,6 +125,7 @@ struct lm3532_als_data {
* @mode - Mode of the LED string * @mode - Mode of the LED string
* @ctrl_brt_pointer - Zone target register that controls the sink * @ctrl_brt_pointer - Zone target register that controls the sink
* @num_leds - Number of LED strings are supported in this array * @num_leds - Number of LED strings are supported in this array
* @full_scale_current - The full-scale current setting for the current sink.
* @led_strings - The LED strings supported in this array * @led_strings - The LED strings supported in this array
* @label - LED label * @label - LED label
*/ */
...@@ -132,6 +137,7 @@ struct lm3532_led { ...@@ -132,6 +137,7 @@ struct lm3532_led {
int mode; int mode;
int ctrl_brt_pointer; int ctrl_brt_pointer;
int num_leds; int num_leds;
int full_scale_current;
u32 led_strings[LM3532_MAX_CONTROL_BANKS]; u32 led_strings[LM3532_MAX_CONTROL_BANKS];
char label[LED_MAX_NAME_SIZE]; char label[LED_MAX_NAME_SIZE];
}; };
...@@ -363,6 +369,8 @@ static int lm3532_init_registers(struct lm3532_led *led) ...@@ -363,6 +369,8 @@ static int lm3532_init_registers(struct lm3532_led *led)
unsigned int output_cfg_mask = 0; unsigned int output_cfg_mask = 0;
unsigned int brightness_config_reg; unsigned int brightness_config_reg;
unsigned int brightness_config_val; unsigned int brightness_config_val;
int fs_current_reg;
int fs_current_val;
int ret, i; int ret, i;
if (drvdata->enable_gpio) if (drvdata->enable_gpio)
...@@ -385,6 +393,17 @@ static int lm3532_init_registers(struct lm3532_led *led) ...@@ -385,6 +393,17 @@ static int lm3532_init_registers(struct lm3532_led *led)
if (ret) if (ret)
return ret; return ret;
if (led->full_scale_current) {
fs_current_reg = LM3532_REG_CTRL_A_FS_CURR + led->control_bank * 2;
fs_current_val = (led->full_scale_current - LM3532_FS_CURR_MIN) /
LM3532_FS_CURR_STEP;
ret = regmap_write(drvdata->regmap, fs_current_reg,
fs_current_val);
if (ret)
return ret;
}
for (i = 0; i < led->num_leds; i++) { for (i = 0; i < led->num_leds; i++) {
output_cfg_shift = led->led_strings[i] * 2; output_cfg_shift = led->led_strings[i] * 2;
output_cfg_val |= (led->control_bank << output_cfg_shift); output_cfg_val |= (led->control_bank << output_cfg_shift);
...@@ -560,6 +579,12 @@ static int lm3532_parse_node(struct lm3532_data *priv) ...@@ -560,6 +579,12 @@ static int lm3532_parse_node(struct lm3532_data *priv)
goto child_out; goto child_out;
} }
ret = fwnode_property_read_u32(child, "led-max-microamp",
&led->full_scale_current);
if (led->full_scale_current > LM3532_FS_CURR_MAX)
led->full_scale_current = LM3532_FS_CURR_MAX;
if (led->mode == LM3532_BL_MODE_ALS) { if (led->mode == LM3532_BL_MODE_ALS) {
led->mode = LM3532_ALS_CTRL; led->mode = LM3532_ALS_CTRL;
ret = lm3532_parse_als(priv); ret = lm3532_parse_als(priv);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment