Lines Matching +full:vled +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (C) 2018 Texas Instruments Incorporated - https://www.ti.com/
10 #include <linux/leds-ti-lmu-common.h>
42 * struct lm3697_led -
63 * struct lm3697 -
65 * @regulator: LED supply regulator pointer
118 int ctrl_en_val = (1 << led->control_bank); in lm3697_brightness_set()
119 struct device *dev = led->priv->dev; in lm3697_brightness_set()
122 mutex_lock(&led->priv->lock); in lm3697_brightness_set()
125 ret = regmap_update_bits(led->priv->regmap, LM3697_CTRL_ENABLE, in lm3697_brightness_set()
132 led->enabled = LED_OFF; in lm3697_brightness_set()
134 ret = ti_lmu_common_set_brightness(&led->lmu_data, brt_val); in lm3697_brightness_set()
140 if (!led->enabled) { in lm3697_brightness_set()
141 ret = regmap_update_bits(led->priv->regmap, in lm3697_brightness_set()
149 led->enabled = brt_val; in lm3697_brightness_set()
154 mutex_unlock(&led->priv->lock); in lm3697_brightness_set()
160 struct device *dev = priv->dev; in lm3697_init()
164 if (priv->enable_gpio) { in lm3697_init()
165 gpiod_direction_output(priv->enable_gpio, 1); in lm3697_init()
167 ret = regmap_write(priv->regmap, LM3697_RESET, LM3697_SW_RESET); in lm3697_init()
174 ret = regmap_write(priv->regmap, LM3697_CTRL_ENABLE, 0x0); in lm3697_init()
180 ret = regmap_write(priv->regmap, LM3697_OUTPUT_CONFIG, priv->bank_cfg); in lm3697_init()
184 for (i = 0; i < priv->num_banks; i++) { in lm3697_init()
185 led = &priv->leds[i]; in lm3697_init()
186 ret = ti_lmu_common_set_ramp(&led->lmu_data); in lm3697_init()
197 struct device *dev = priv->dev; in lm3697_probe_dt()
199 int ret = -EINVAL; in lm3697_probe_dt()
204 priv->enable_gpio = devm_gpiod_get_optional(dev, "enable", in lm3697_probe_dt()
206 if (IS_ERR(priv->enable_gpio)) { in lm3697_probe_dt()
207 ret = PTR_ERR(priv->enable_gpio); in lm3697_probe_dt()
212 priv->regulator = devm_regulator_get(dev, "vled"); in lm3697_probe_dt()
213 if (IS_ERR(priv->regulator)) in lm3697_probe_dt()
214 priv->regulator = NULL; in lm3697_probe_dt()
228 ret = -EINVAL; in lm3697_probe_dt()
233 led = &priv->leds[i]; in lm3697_probe_dt()
235 ret = ti_lmu_common_get_brt_res(dev, child, &led->lmu_data); in lm3697_probe_dt()
240 led->control_bank = control_bank; in lm3697_probe_dt()
241 led->lmu_data.regmap = priv->regmap; in lm3697_probe_dt()
242 led->lmu_data.runtime_ramp_reg = LM3697_CTRL_A_RAMP + in lm3697_probe_dt()
244 led->lmu_data.msb_brightness_reg = LM3697_CTRL_A_BRT_MSB + in lm3697_probe_dt()
245 led->control_bank * 2; in lm3697_probe_dt()
246 led->lmu_data.lsb_brightness_reg = LM3697_CTRL_A_BRT_LSB + in lm3697_probe_dt()
247 led->control_bank * 2; in lm3697_probe_dt()
249 led->num_leds = fwnode_property_count_u32(child, "led-sources"); in lm3697_probe_dt()
250 if (led->num_leds > LM3697_MAX_LED_STRINGS) { in lm3697_probe_dt()
255 ret = fwnode_property_read_u32_array(child, "led-sources", in lm3697_probe_dt()
256 led->hvled_strings, in lm3697_probe_dt()
257 led->num_leds); in lm3697_probe_dt()
259 dev_err(dev, "led-sources property missing\n"); in lm3697_probe_dt()
264 for (j = 0; j < led->num_leds; j++) in lm3697_probe_dt()
265 priv->bank_cfg |= in lm3697_probe_dt()
266 (led->control_bank << led->hvled_strings[j]); in lm3697_probe_dt()
268 ret = ti_lmu_common_get_ramp_params(dev, child, &led->lmu_data); in lm3697_probe_dt()
270 dev_warn(dev, "runtime-ramp properties missing\n"); in lm3697_probe_dt()
273 init_data.devicename = priv->client->name; in lm3697_probe_dt()
277 led->priv = priv; in lm3697_probe_dt()
278 led->led_dev.max_brightness = led->lmu_data.max_brightness; in lm3697_probe_dt()
279 led->led_dev.brightness_set_blocking = lm3697_brightness_set; in lm3697_probe_dt()
281 ret = devm_led_classdev_register_ext(dev, &led->led_dev, in lm3697_probe_dt()
299 struct device *dev = &client->dev; in lm3697_probe()
307 return -ENODEV; in lm3697_probe()
312 return -ENOMEM; in lm3697_probe()
314 mutex_init(&led->lock); in lm3697_probe()
317 led->client = client; in lm3697_probe()
318 led->dev = dev; in lm3697_probe()
319 led->num_banks = count; in lm3697_probe()
320 led->regmap = devm_regmap_init_i2c(client, &lm3697_regmap_config); in lm3697_probe()
321 if (IS_ERR(led->regmap)) { in lm3697_probe()
322 ret = PTR_ERR(led->regmap); in lm3697_probe()
337 struct device *dev = &led->client->dev; in lm3697_remove()
340 ret = regmap_update_bits(led->regmap, LM3697_CTRL_ENABLE, in lm3697_remove()
347 if (led->enable_gpio) in lm3697_remove()
348 gpiod_direction_output(led->enable_gpio, 0); in lm3697_remove()
350 if (led->regulator) { in lm3697_remove()
351 ret = regulator_disable(led->regulator); in lm3697_remove()
356 mutex_destroy(&led->lock); in lm3697_remove()