Lines Matching +full:led +full:- +full:3
1 // SPDX-License-Identifier: GPL-2.0-only
16 #include <linux/platform_data/leds-lp55xx.h>
18 #include <dt-bindings/leds/leds-lp55xx.h>
20 #include "leds-lp55xx-common.h"
27 * 0x80 engine 3 program (4 pages)
30 * 0xe0 engine 3 muxing info (1 page)
52 #define LP5569_CP_MODE_MASK GENMASK(4, 3)
57 #define LP5569_LED_OPEN_TEST BIT(3)
68 #define LP5569_CLK_OUTPUT BIT(3)
84 #define LP5569_LED_FAULT3 BIT(3)
120 /* Precompiled pattern per ENGINE setting LED MUX start and stop addresses */ in lp5569_init_program_engine()
140 /* Write precompiled pattern for LED MUX address space for each ENGINE */ in lp5569_init_program_engine()
142 chip->engine_idx = i; in lp5569_init_program_engine()
147 pattern[i - 1][j]); in lp5569_init_program_engine()
161 dev_err(&chip->cl->dev, in lp5569_init_program_engine()
162 "could not configure LED engine, status = 0x%.2x\n", in lp5569_init_program_engine()
164 ret = -EINVAL; in lp5569_init_program_engine()
178 val |= FIELD_PREP(LP5569_CP_MODE_MASK, chip->pdata->charge_pump_mode); in lp5569_post_init_device()
183 if (chip->pdata->clock_mode == LP55XX_CLOCK_INT) { in lp5569_post_init_device()
209 static ssize_t lp5569_led_open_test(struct lp55xx_led *led, char *buf) in lp5569_led_open_test() argument
211 struct lp55xx_chip *chip = led->chip; in lp5569_led_open_test()
212 struct lp55xx_platform_data *pdata = chip->pdata; in lp5569_led_open_test()
214 struct lp55xx_led *led_tmp = led; in lp5569_led_open_test()
233 /* Enable LED Open Test */ in lp5569_led_open_test()
247 /* Enable LED and set to 100% brightness */ in lp5569_led_open_test()
248 for (i = 0; i < pdata->num_channels; i++) { in lp5569_led_open_test()
249 ret = lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr, in lp5569_led_open_test()
260 /* Parse status led fault 1 regs */ in lp5569_led_open_test()
268 /* Parse status led fault 2 regs */ in lp5569_led_open_test()
276 /* Report LED fault */ in lp5569_led_open_test()
277 led_tmp = led; in lp5569_led_open_test()
278 for (i = 0; i < pdata->num_channels; i++) { in lp5569_led_open_test()
279 if (leds_fault[led_tmp->chan_nr]) in lp5569_led_open_test()
280 pos += sysfs_emit_at(buf, pos, "LED %d OPEN FAIL\n", in lp5569_led_open_test()
281 led_tmp->chan_nr); in lp5569_led_open_test()
289 /* Disable LED Open Test */ in lp5569_led_open_test()
292 led_tmp = led; in lp5569_led_open_test()
293 for (i = 0; i < pdata->num_channels; i++) { in lp5569_led_open_test()
294 lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr, 0); in lp5569_led_open_test()
302 static ssize_t lp5569_led_short_test(struct lp55xx_led *led, char *buf) in lp5569_led_short_test() argument
304 struct lp55xx_chip *chip = led->chip; in lp5569_led_short_test()
305 struct lp55xx_platform_data *pdata = chip->pdata; in lp5569_led_short_test()
307 struct lp55xx_led *led_tmp = led; in lp5569_led_short_test()
326 /* Enable LED and set to 100% brightness and current to 100% (25.5mA) */ in lp5569_led_short_test()
327 for (i = 0; i < pdata->num_channels; i++) { in lp5569_led_short_test()
328 ret = lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr, in lp5569_led_short_test()
333 ret = lp55xx_write(chip, LP5569_REG_LED_CURRENT_BASE + led_tmp->chan_nr, in lp5569_led_short_test()
349 /* Enable LED Shorted Test */ in lp5569_led_short_test()
358 /* Parse status led fault 1 regs */ in lp5569_led_short_test()
366 /* Parse status led fault 2 regs */ in lp5569_led_short_test()
374 /* Report LED fault */ in lp5569_led_short_test()
375 led_tmp = led; in lp5569_led_short_test()
376 for (i = 0; i < pdata->num_channels; i++) { in lp5569_led_short_test()
377 if (leds_fault[led_tmp->chan_nr]) in lp5569_led_short_test()
378 pos += sysfs_emit_at(buf, pos, "LED %d SHORTED FAIL\n", in lp5569_led_short_test()
379 led_tmp->chan_nr); in lp5569_led_short_test()
387 /* Disable LED Shorted Test */ in lp5569_led_short_test()
390 led_tmp = led; in lp5569_led_short_test()
391 for (i = 0; i < pdata->num_channels; i++) { in lp5569_led_short_test()
392 lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led_tmp->chan_nr, 0); in lp5569_led_short_test()
404 struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); in lp5569_selftest() local
405 struct lp55xx_chip *chip = led->chip; in lp5569_selftest()
408 guard(mutex)(&chip->lock); in lp5569_selftest()
410 /* Test LED Open */ in lp5569_selftest()
411 pos = lp5569_led_open_test(led, buf); in lp5569_selftest()
415 /* Test LED Shorted */ in lp5569_selftest()
416 pos += lp5569_led_short_test(led, buf); in lp5569_selftest()
420 for (i = 0; i < chip->pdata->num_channels; i++) { in lp5569_selftest()
422 lp55xx_write(chip, LP5569_REG_LED_CURRENT_BASE + led->chan_nr, in lp5569_selftest()
423 led->led_current); in lp5569_selftest()
426 lp55xx_write(chip, LP5569_REG_LED_PWM_BASE + led->chan_nr, in lp5569_selftest()
427 led->brightness); in lp5569_selftest()
428 led++; in lp5569_selftest()
436 LP55XX_DEV_ATTR_ENGINE_MODE(3);
439 LP55XX_DEV_ATTR_ENGINE_LEDS(3);
442 LP55XX_DEV_ATTR_ENGINE_LOAD(3);
446 LP55XX_DEV_ATTR_MASTER_FADER(3);
543 MODULE_DESCRIPTION("LP5569 LED engine");