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

1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI LP8860 4-Channel LED Driver
88 * struct lp8860_led -
89 * @lock - Lock for reading/writing the device
90 * @client - Pointer to the I2C client
91 * @led_dev - led class device pointer
92 * @regmap - Devices register map
93 * @eeprom_regmap - EEPROM register map
94 * @enable_gpio - VDDIO/EN gpio to enable communication interface
95 * @regulator - LED supply regulator pointer
144 mutex_lock(&led->lock); in lp8860_unlock_eeprom()
147 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
151 dev_err(&led->client->dev, "EEPROM Unlock failed\n"); in lp8860_unlock_eeprom()
155 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
159 dev_err(&led->client->dev, "EEPROM Unlock failed\n"); in lp8860_unlock_eeprom()
162 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
166 dev_err(&led->client->dev, "EEPROM Unlock failed\n"); in lp8860_unlock_eeprom()
170 ret = regmap_write(led->regmap, in lp8860_unlock_eeprom()
176 mutex_unlock(&led->lock); in lp8860_unlock_eeprom()
185 ret = regmap_read(led->regmap, LP8860_LED_FAULT, &read_buf); in lp8860_fault_check()
191 ret = regmap_read(led->regmap, LP8860_FAULT, &read_buf); in lp8860_fault_check()
199 ret = regmap_write(led->regmap, LP8860_FAULT_CLEAR, in lp8860_fault_check()
213 mutex_lock(&led->lock); in lp8860_brightness_set()
217 dev_err(&led->client->dev, "Cannot read/clear faults\n"); in lp8860_brightness_set()
221 ret = regmap_write(led->regmap, LP8860_DISP_CL1_BRT_MSB, in lp8860_brightness_set()
224 dev_err(&led->client->dev, "Cannot write CL1 MSB\n"); in lp8860_brightness_set()
228 ret = regmap_write(led->regmap, LP8860_DISP_CL1_BRT_LSB, in lp8860_brightness_set()
231 dev_err(&led->client->dev, "Cannot write CL1 LSB\n"); in lp8860_brightness_set()
235 mutex_unlock(&led->lock); in lp8860_brightness_set()
244 if (led->regulator) { in lp8860_init()
245 ret = regulator_enable(led->regulator); in lp8860_init()
247 dev_err(&led->client->dev, in lp8860_init()
253 if (led->enable_gpio) in lp8860_init()
254 gpiod_direction_output(led->enable_gpio, 1); in lp8860_init()
260 ret = regmap_read(led->regmap, LP8860_STATUS, &read_buf); in lp8860_init()
266 dev_err(&led->client->dev, "Failed unlocking EEPROM\n"); in lp8860_init()
272 ret = regmap_write(led->eeprom_regmap, in lp8860_init()
276 dev_err(&led->client->dev, "Failed writing EEPROM\n"); in lp8860_init()
285 ret = regmap_write(led->regmap, in lp8860_init()
289 dev_err(&led->client->dev, "Failed programming EEPROM\n"); in lp8860_init()
297 if (led->enable_gpio) in lp8860_init()
298 gpiod_direction_output(led->enable_gpio, 0); in lp8860_init()
300 if (led->regulator) { in lp8860_init()
301 ret = regulator_disable(led->regulator); in lp8860_init()
303 dev_err(&led->client->dev, in lp8860_init()
383 struct device_node *np = dev_of_node(&client->dev); in lp8860_probe()
387 led = devm_kzalloc(&client->dev, sizeof(*led), GFP_KERNEL); in lp8860_probe()
389 return -ENOMEM; in lp8860_probe()
393 return -EINVAL; in lp8860_probe()
395 led->enable_gpio = devm_gpiod_get_optional(&client->dev, in lp8860_probe()
397 if (IS_ERR(led->enable_gpio)) { in lp8860_probe()
398 ret = PTR_ERR(led->enable_gpio); in lp8860_probe()
399 dev_err(&client->dev, "Failed to get enable gpio: %d\n", ret); in lp8860_probe()
403 led->regulator = devm_regulator_get(&client->dev, "vled"); in lp8860_probe()
404 if (IS_ERR(led->regulator)) in lp8860_probe()
405 led->regulator = NULL; in lp8860_probe()
407 led->client = client; in lp8860_probe()
408 led->led_dev.brightness_set_blocking = lp8860_brightness_set; in lp8860_probe()
410 mutex_init(&led->lock); in lp8860_probe()
414 led->regmap = devm_regmap_init_i2c(client, &lp8860_regmap_config); in lp8860_probe()
415 if (IS_ERR(led->regmap)) { in lp8860_probe()
416 ret = PTR_ERR(led->regmap); in lp8860_probe()
417 dev_err(&client->dev, "Failed to allocate register map: %d\n", in lp8860_probe()
422 led->eeprom_regmap = devm_regmap_init_i2c(client, &lp8860_eeprom_regmap_config); in lp8860_probe()
423 if (IS_ERR(led->eeprom_regmap)) { in lp8860_probe()
424 ret = PTR_ERR(led->eeprom_regmap); in lp8860_probe()
425 dev_err(&client->dev, "Failed to allocate register map: %d\n", in lp8860_probe()
438 ret = devm_led_classdev_register_ext(&client->dev, &led->led_dev, in lp8860_probe()
441 dev_err(&client->dev, "led register err: %d\n", ret); in lp8860_probe()
453 if (led->enable_gpio) in lp8860_remove()
454 gpiod_direction_output(led->enable_gpio, 0); in lp8860_remove()
456 if (led->regulator) { in lp8860_remove()
457 ret = regulator_disable(led->regulator); in lp8860_remove()
459 dev_err(&led->client->dev, in lp8860_remove()
463 mutex_destroy(&led->lock); in lp8860_remove()