Lines Matching +full:led +full:- +full:pattern
1 // SPDX-License-Identifier: GPL-2.0-only
3 * LP5562 LED driver
17 #include <linux/platform_data/leds-lp55xx.h>
20 #include "leds-lp55xx-common.h"
114 static void lp5562_set_led_current(struct lp55xx_led *led, u8 led_current) in lp5562_set_led_current() argument
123 led->led_current = led_current; in lp5562_set_led_current()
124 lp55xx_write(led->chip, addr[led->chan_nr], led_current); in lp5562_set_led_current()
129 enum lp55xx_engine_index idx = chip->engine_idx; in lp5562_load_engine()
209 enum lp55xx_engine_index idx = chip->engine_idx; in lp5562_update_firmware()
210 u8 pattern[LP5562_PROGRAM_LENGTH] = {0}; in lp5562_update_firmware() local
229 while ((offset < size - 1) && (i < LP5562_PROGRAM_LENGTH)) { in lp5562_update_firmware()
239 pattern[i] = (u8)cmd; in lp5562_update_firmware()
250 lp55xx_write(chip, addr[idx] + i, pattern[i]); in lp5562_update_firmware()
255 dev_err(&chip->cl->dev, "wrong pattern format\n"); in lp5562_update_firmware()
256 return -EINVAL; in lp5562_update_firmware()
261 const struct firmware *fw = chip->fw; in lp5562_firmware_loaded()
267 if (fw->size > (LP5562_PROGRAM_LENGTH * 2)) { in lp5562_firmware_loaded()
268 dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n", in lp5562_firmware_loaded()
269 fw->size); in lp5562_firmware_loaded()
280 lp5562_update_firmware(chip, fw->data, fw->size); in lp5562_firmware_loaded()
303 /* Initialize all channels PWM to zero -> leds off */ in lp5562_post_init_device()
309 /* Set LED map as register PWM by default */ in lp5562_post_init_device()
315 static int lp5562_led_brightness(struct lp55xx_led *led) in lp5562_led_brightness() argument
317 struct lp55xx_chip *chip = led->chip; in lp5562_led_brightness()
326 mutex_lock(&chip->lock); in lp5562_led_brightness()
327 ret = lp55xx_write(chip, addr[led->chan_nr], led->brightness); in lp5562_led_brightness()
328 mutex_unlock(&chip->lock); in lp5562_led_brightness()
351 return ptn->size_r >= LP5562_PROGRAM_LENGTH || in _is_pc_overflow()
352 ptn->size_g >= LP5562_PROGRAM_LENGTH || in _is_pc_overflow()
353 ptn->size_b >= LP5562_PROGRAM_LENGTH; in _is_pc_overflow()
366 ptn = chip->pdata->patterns + (mode - 1); in lp5562_run_predef_led_pattern()
368 dev_err(&chip->cl->dev, "invalid pattern data\n"); in lp5562_run_predef_led_pattern()
369 return -EINVAL; in lp5562_run_predef_led_pattern()
374 /* Set LED map as RGB */ in lp5562_run_predef_led_pattern()
379 chip->engine_idx = i; in lp5562_run_predef_led_pattern()
393 ptn->r, ptn->size_r); in lp5562_run_predef_led_pattern()
395 ptn->g, ptn->size_g); in lp5562_run_predef_led_pattern()
397 ptn->b, ptn->size_b); in lp5562_run_predef_led_pattern()
409 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); in lp5562_store_pattern() local
410 struct lp55xx_chip *chip = led->chip; in lp5562_store_pattern()
411 struct lp55xx_predef_pattern *ptn = chip->pdata->patterns; in lp5562_store_pattern()
412 int num_patterns = chip->pdata->num_patterns; in lp5562_store_pattern()
421 return -EINVAL; in lp5562_store_pattern()
423 mutex_lock(&chip->lock); in lp5562_store_pattern()
425 mutex_unlock(&chip->lock); in lp5562_store_pattern()
437 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); in lp5562_store_engine_mux() local
438 struct lp55xx_chip *chip = led->chip; in lp5562_store_engine_mux()
442 /* LED map in lp5562_store_engine_mux()
453 enum lp55xx_engine_index idx = chip->engine_idx; in lp5562_store_engine_mux()
467 return -EINVAL; in lp5562_store_engine_mux()
472 return -EINVAL; in lp5562_store_engine_mux()
475 mutex_lock(&chip->lock); in lp5562_store_engine_mux()
477 mutex_unlock(&chip->lock); in lp5562_store_engine_mux()
519 struct lp55xx_led *led; in lp5562_probe() local
520 struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev); in lp5562_probe()
521 struct device_node *np = dev_of_node(&client->dev); in lp5562_probe()
523 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); in lp5562_probe()
525 return -ENOMEM; in lp5562_probe()
527 chip->cfg = &lp5562_cfg; in lp5562_probe()
531 pdata = lp55xx_of_populate_pdata(&client->dev, np, in lp5562_probe()
536 dev_err(&client->dev, "no platform data\n"); in lp5562_probe()
537 return -EINVAL; in lp5562_probe()
542 led = devm_kcalloc(&client->dev, in lp5562_probe()
543 pdata->num_channels, sizeof(*led), GFP_KERNEL); in lp5562_probe()
544 if (!led) in lp5562_probe()
545 return -ENOMEM; in lp5562_probe()
547 chip->cl = client; in lp5562_probe()
548 chip->pdata = pdata; in lp5562_probe()
550 mutex_init(&chip->lock); in lp5562_probe()
552 i2c_set_clientdata(client, led); in lp5562_probe()
558 ret = lp55xx_register_leds(led, chip); in lp5562_probe()
564 dev_err(&client->dev, "registering sysfs failed\n"); in lp5562_probe()
578 struct lp55xx_led *led = i2c_get_clientdata(client); in lp5562_remove() local
579 struct lp55xx_chip *chip = led->chip; in lp5562_remove()
614 MODULE_DESCRIPTION("Texas Instruments LP5562 LED Driver");