Lines Matching +full:charge +full:- +full:led
1 // SPDX-License-Identifier: GPL-2.0-only
3 * LP5521 LED chip driver.
18 #include <linux/platform_data/leds-lp55xx.h>
22 #include "leds-lp55xx-common.h"
44 /* Base register to set LED current */
61 #define LP5521_CP_MODE_OFF 0 /* Charge pump (CP) off */
114 static void lp5521_set_led_current(struct lp55xx_led *led, u8 led_current) in lp5521_set_led_current() argument
116 led->led_current = led_current; in lp5521_set_led_current()
117 lp55xx_write(led->chip, LP5521_REG_LED_CURRENT_BASE + led->chan_nr, in lp5521_set_led_current()
123 enum lp55xx_engine_index idx = chip->engine_idx; in lp5521_load_engine()
149 enum lp55xx_engine_index idx = chip->engine_idx; in lp5521_stop_engine()
214 enum lp55xx_engine_index idx = chip->engine_idx; in lp5521_update_program_memory()
228 while ((offset < size - 1) && (i < LP5521_PROGRAM_LENGTH)) { in lp5521_update_program_memory()
250 return -EINVAL; in lp5521_update_program_memory()
256 dev_err(&chip->cl->dev, "wrong pattern format\n"); in lp5521_update_program_memory()
257 return -EINVAL; in lp5521_update_program_memory()
262 const struct firmware *fw = chip->fw; in lp5521_firmware_loaded()
264 if (fw->size > LP5521_PROGRAM_LENGTH) { in lp5521_firmware_loaded()
265 dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n", in lp5521_firmware_loaded()
266 fw->size); in lp5521_firmware_loaded()
277 lp5521_update_program_memory(chip, fw->data, fw->size); in lp5521_firmware_loaded()
287 * current reg. This is dummy read is required on some platforms - in lp5521_post_init_device()
289 * LP5521_REG_ENABLE register will not have any effect - strange! in lp5521_post_init_device()
293 dev_err(&chip->cl->dev, "error in resetting chip\n"); in lp5521_post_init_device()
297 dev_err(&chip->cl->dev, in lp5521_post_init_device()
300 ret = -EINVAL; in lp5521_post_init_device()
317 /* Initialize all channels PWM to zero -> leds off */ in lp5521_post_init_device()
334 struct lp55xx_platform_data *pdata = chip->pdata; in lp5521_run_selftest()
342 if (pdata->clock_mode != LP55XX_CLOCK_EXT) in lp5521_run_selftest()
347 return -EIO; in lp5521_run_selftest()
352 static int lp5521_multicolor_brightness(struct lp55xx_led *led) in lp5521_multicolor_brightness() argument
354 struct lp55xx_chip *chip = led->chip; in lp5521_multicolor_brightness()
358 mutex_lock(&chip->lock); in lp5521_multicolor_brightness()
359 for (i = 0; i < led->mc_cdev.num_colors; i++) { in lp5521_multicolor_brightness()
362 led->mc_cdev.subled_info[i].channel, in lp5521_multicolor_brightness()
363 led->mc_cdev.subled_info[i].brightness); in lp5521_multicolor_brightness()
367 mutex_unlock(&chip->lock); in lp5521_multicolor_brightness()
371 static int lp5521_led_brightness(struct lp55xx_led *led) in lp5521_led_brightness() argument
373 struct lp55xx_chip *chip = led->chip; in lp5521_led_brightness()
376 mutex_lock(&chip->lock); in lp5521_led_brightness()
377 ret = lp55xx_write(chip, LP5521_REG_LED_PWM_BASE + led->chan_nr, in lp5521_led_brightness()
378 led->brightness); in lp5521_led_brightness()
379 mutex_unlock(&chip->lock); in lp5521_led_brightness()
388 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); in show_engine_mode() local
389 struct lp55xx_chip *chip = led->chip; in show_engine_mode()
390 enum lp55xx_engine_mode mode = chip->engines[nr - 1].mode; in show_engine_mode()
410 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); in store_engine_mode() local
411 struct lp55xx_chip *chip = led->chip; in store_engine_mode()
412 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in store_engine_mode()
414 mutex_lock(&chip->lock); in store_engine_mode()
416 chip->engine_idx = nr; in store_engine_mode()
420 engine->mode = LP55XX_ENGINE_RUN; in store_engine_mode()
424 engine->mode = LP55XX_ENGINE_LOAD; in store_engine_mode()
427 engine->mode = LP55XX_ENGINE_DISABLED; in store_engine_mode()
430 mutex_unlock(&chip->lock); in store_engine_mode()
442 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); in store_engine_load() local
443 struct lp55xx_chip *chip = led->chip; in store_engine_load()
446 mutex_lock(&chip->lock); in store_engine_load()
448 chip->engine_idx = nr; in store_engine_load()
452 mutex_unlock(&chip->lock); in store_engine_load()
464 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); in lp5521_selftest() local
465 struct lp55xx_chip *chip = led->chip; in lp5521_selftest()
468 mutex_lock(&chip->lock); in lp5521_selftest()
470 mutex_unlock(&chip->lock); in lp5521_selftest()
524 struct lp55xx_led *led; in lp5521_probe() local
525 struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); in lp5521_probe()
526 struct device_node *np = dev_of_node(&client->dev); in lp5521_probe()
528 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); in lp5521_probe()
530 return -ENOMEM; in lp5521_probe()
532 chip->cfg = &lp5521_cfg; in lp5521_probe()
536 pdata = lp55xx_of_populate_pdata(&client->dev, np, in lp5521_probe()
541 dev_err(&client->dev, "no platform data\n"); in lp5521_probe()
542 return -EINVAL; in lp5521_probe()
546 led = devm_kcalloc(&client->dev, in lp5521_probe()
547 pdata->num_channels, sizeof(*led), GFP_KERNEL); in lp5521_probe()
548 if (!led) in lp5521_probe()
549 return -ENOMEM; in lp5521_probe()
551 chip->cl = client; in lp5521_probe()
552 chip->pdata = pdata; in lp5521_probe()
554 mutex_init(&chip->lock); in lp5521_probe()
556 i2c_set_clientdata(client, led); in lp5521_probe()
562 dev_info(&client->dev, "%s programmable led chip found\n", id->name); in lp5521_probe()
564 ret = lp55xx_register_leds(led, chip); in lp5521_probe()
570 dev_err(&client->dev, "registering sysfs failed\n"); in lp5521_probe()
584 struct lp55xx_led *led = i2c_get_clientdata(client); in lp5521_remove() local
585 struct lp55xx_chip *chip = led->chip; in lp5521_remove()
622 MODULE_DESCRIPTION("LP5521 LED engine");