Lines Matching +full:enabled +full:- +full:strings
1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (C) 2018 Texas Instruments Incorporated - https://www.ti.com/
15 #include <linux/leds-ti-lmu-common.h>
47 * struct lm3697_led -
48 * @hvled_strings: Array of LED strings associated with a control bank
55 * @enabled: LED brightness level (or LED_OFF)
65 int enabled; member
70 * struct lm3697 -
77 * @leds: Array of LED strings
127 int ctrl_en_val = (1 << led->control_bank); in lm3697_brightness_set()
128 struct device *dev = led->priv->dev; in lm3697_brightness_set()
131 mutex_lock(&led->priv->lock); in lm3697_brightness_set()
134 ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE, in lm3697_brightness_set()
141 led->enabled = LED_OFF; in lm3697_brightness_set()
143 ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val); in lm3697_brightness_set()
149 if (!led->enabled) { in lm3697_brightness_set()
150 ret = regmap_update_bits(led->priv->regmap, in lm3697_brightness_set()
158 led->enabled = brt_val; in lm3697_brightness_set()
163 mutex_unlock(&led->priv->lock); in lm3697_brightness_set()
169 struct device *dev = priv->dev; in lm3697_init()
173 if (priv->enable_gpio) { in lm3697_init()
174 gpiod_direction_output(priv->enable_gpio, 1); in lm3697_init()
176 ret = regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET); in lm3697_init()
183 ret = regmap_write(priv->regmap, LM3697_CTRL_ENABLE, 0x0); in lm3697_init()
189 ret = regmap_write(priv->regmap, LM3697_OUTPUT_CONFIG, priv->bank_cfg); in lm3697_init()
193 for (i = 0; i < priv->num_banks; i++) { in lm3697_init()
194 led = &priv->leds[i]; in lm3697_init()
195 ret = ti_lmu_common_set_ramp(&led->lmu_data); in lm3697_init()
206 struct device *dev = priv->dev; in lm3697_probe_dt()
208 int ret = -EINVAL; in lm3697_probe_dt()
213 priv->enable_gpio = devm_gpiod_get_optional(dev, "enable", in lm3697_probe_dt()
215 if (IS_ERR(priv->enable_gpio)) in lm3697_probe_dt()
216 return dev_err_probe(dev, PTR_ERR(priv->enable_gpio), in lm3697_probe_dt()
219 priv->regulator = devm_regulator_get(dev, "vled"); in lm3697_probe_dt()
220 if (IS_ERR(priv->regulator)) in lm3697_probe_dt()
221 priv->regulator = NULL; in lm3697_probe_dt()
234 ret = -EINVAL; in lm3697_probe_dt()
238 led = &priv->leds[i]; in lm3697_probe_dt()
240 ret = ti_lmu_common_get_brt_res(dev, child, &led->lmu_data); in lm3697_probe_dt()
245 led->control_bank = control_bank; in lm3697_probe_dt()
246 led->lmu_data.regmap = priv->regmap; in lm3697_probe_dt()
247 led->lmu_data.runtime_ramp_reg = LM3697_CTRL_A_RAMP + in lm3697_probe_dt()
249 led->lmu_data.msb_brightness_reg = LM3697_CTRL_A_BRT_MSB + in lm3697_probe_dt()
250 led->control_bank * 2; in lm3697_probe_dt()
251 led->lmu_data.lsb_brightness_reg = LM3697_CTRL_A_BRT_LSB + in lm3697_probe_dt()
252 led->control_bank * 2; in lm3697_probe_dt()
254 led->num_leds = fwnode_property_count_u32(child, "led-sources"); in lm3697_probe_dt()
255 if (led->num_leds > LM3697_MAX_LED_STRINGS) { in lm3697_probe_dt()
256 dev_err(dev, "Too many LED strings defined\n"); in lm3697_probe_dt()
260 ret = fwnode_property_read_u32_array(child, "led-sources", in lm3697_probe_dt()
261 led->hvled_strings, in lm3697_probe_dt()
262 led->num_leds); in lm3697_probe_dt()
264 dev_err(dev, "led-sources property missing\n"); in lm3697_probe_dt()
268 for (j = 0; j < led->num_leds; j++) in lm3697_probe_dt()
269 priv->bank_cfg |= in lm3697_probe_dt()
270 (led->control_bank << led->hvled_strings[j]); in lm3697_probe_dt()
272 ret = ti_lmu_common_get_ramp_params(dev, child, &led->lmu_data); in lm3697_probe_dt()
274 dev_warn(dev, "runtime-ramp properties missing\n"); in lm3697_probe_dt()
277 init_data.devicename = priv->client->name; in lm3697_probe_dt()
281 led->priv = priv; in lm3697_probe_dt()
282 led->led_dev.max_brightness = led->lmu_data.max_brightness; in lm3697_probe_dt()
283 led->led_dev.brightness_set_blocking = lm3697_brightness_set; in lm3697_probe_dt()
285 ret = devm_led_classdev_register_ext(dev, &led->led_dev, in lm3697_probe_dt()
304 struct device *dev = &client->dev; in lm3697_probe()
312 return -ENODEV; in lm3697_probe()
317 return -ENOMEM; in lm3697_probe()
319 mutex_init(&led->lock); in lm3697_probe()
322 led->client = client; in lm3697_probe()
323 led->dev = dev; in lm3697_probe()
324 led->num_banks = count; in lm3697_probe()
325 led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config); in lm3697_probe()
326 if (IS_ERR(led->regmap)) { in lm3697_probe()
327 ret = PTR_ERR(led->regmap); in lm3697_probe()
342 struct device *dev = &led->client->dev; in lm3697_remove()
345 ret = regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE, in lm3697_remove()
350 if (led->enable_gpio) in lm3697_remove()
351 gpiod_direction_output(led->enable_gpio, 0); in lm3697_remove()
353 if (led->regulator) { in lm3697_remove()
354 ret = regulator_disable(led->regulator); in lm3697_remove()
359 mutex_destroy(&led->lock); in lm3697_remove()