Lines Matching refs:chip
119 static int lp5523_init_program_engine(struct lp55xx_chip *chip);
129 lp55xx_write(led->chip, LP5523_REG_LED_CURRENT_BASE + led->chan_nr, in lp5523_set_led_current()
133 static int lp5523_post_init_device(struct lp55xx_chip *chip) in lp5523_post_init_device() argument
137 ret = lp55xx_write(chip, LP5523_REG_ENABLE, LP5523_ENABLE); in lp5523_post_init_device()
144 ret = lp55xx_write(chip, LP5523_REG_CONFIG, in lp5523_post_init_device()
152 ret = lp55xx_write(chip, LP5523_REG_ENABLE_LEDS_MSB, 0x01); in lp5523_post_init_device()
156 ret = lp55xx_write(chip, LP5523_REG_ENABLE_LEDS_LSB, 0xff); in lp5523_post_init_device()
160 return lp5523_init_program_engine(chip); in lp5523_post_init_device()
163 static void lp5523_load_engine(struct lp55xx_chip *chip) in lp5523_load_engine() argument
165 enum lp55xx_engine_index idx = chip->engine_idx; in lp5523_load_engine()
178 lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], val[idx]); in lp5523_load_engine()
183 static void lp5523_load_engine_and_select_page(struct lp55xx_chip *chip) in lp5523_load_engine_and_select_page() argument
185 enum lp55xx_engine_index idx = chip->engine_idx; in lp5523_load_engine_and_select_page()
192 lp5523_load_engine(chip); in lp5523_load_engine_and_select_page()
194 lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, page_sel[idx]); in lp5523_load_engine_and_select_page()
197 static void lp5523_stop_all_engines(struct lp55xx_chip *chip) in lp5523_stop_all_engines() argument
199 lp55xx_write(chip, LP5523_REG_OP_MODE, 0); in lp5523_stop_all_engines()
203 static void lp5523_stop_engine(struct lp55xx_chip *chip) in lp5523_stop_engine() argument
205 enum lp55xx_engine_index idx = chip->engine_idx; in lp5523_stop_engine()
212 lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], 0); in lp5523_stop_engine()
217 static void lp5523_turn_off_channels(struct lp55xx_chip *chip) in lp5523_turn_off_channels() argument
222 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0); in lp5523_turn_off_channels()
225 static void lp5523_run_engine(struct lp55xx_chip *chip, bool start) in lp5523_run_engine() argument
233 lp5523_stop_engine(chip); in lp5523_run_engine()
234 lp5523_turn_off_channels(chip); in lp5523_run_engine()
243 ret = lp55xx_read(chip, LP5523_REG_OP_MODE, &mode); in lp5523_run_engine()
247 ret = lp55xx_read(chip, LP5523_REG_ENABLE, &exec); in lp5523_run_engine()
267 lp55xx_write(chip, LP5523_REG_OP_MODE, mode); in lp5523_run_engine()
270 lp55xx_update_bits(chip, LP5523_REG_ENABLE, LP5523_EXEC_M, exec); in lp5523_run_engine()
273 static int lp5523_init_program_engine(struct lp55xx_chip *chip) in lp5523_init_program_engine() argument
287 ret = lp55xx_write(chip, LP5523_REG_CH1_PROG_START, 0x00); in lp5523_init_program_engine()
291 ret = lp55xx_write(chip, LP5523_REG_CH2_PROG_START, 0x10); in lp5523_init_program_engine()
295 ret = lp55xx_write(chip, LP5523_REG_CH3_PROG_START, 0x20); in lp5523_init_program_engine()
301 chip->engine_idx = i; in lp5523_init_program_engine()
302 lp5523_load_engine_and_select_page(chip); in lp5523_init_program_engine()
305 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + j, in lp5523_init_program_engine()
312 lp5523_run_engine(chip, true); in lp5523_init_program_engine()
316 lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_init_program_engine()
320 dev_err(&chip->cl->dev, in lp5523_init_program_engine()
327 lp5523_stop_all_engines(chip); in lp5523_init_program_engine()
331 static int lp5523_update_program_memory(struct lp55xx_chip *chip, in lp5523_update_program_memory() argument
362 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]); in lp5523_update_program_memory()
370 dev_err(&chip->cl->dev, "wrong pattern format\n"); in lp5523_update_program_memory()
374 static void lp5523_firmware_loaded(struct lp55xx_chip *chip) in lp5523_firmware_loaded() argument
376 const struct firmware *fw = chip->fw; in lp5523_firmware_loaded()
379 dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n", in lp5523_firmware_loaded()
390 lp5523_load_engine_and_select_page(chip); in lp5523_firmware_loaded()
391 lp5523_update_program_memory(chip, fw->data, fw->size); in lp5523_firmware_loaded()
399 struct lp55xx_chip *chip = led->chip; in show_engine_mode() local
400 enum lp55xx_engine_mode mode = chip->engines[nr - 1].mode; in show_engine_mode()
421 struct lp55xx_chip *chip = led->chip; in store_engine_mode() local
422 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in store_engine_mode()
424 mutex_lock(&chip->lock); in store_engine_mode()
426 chip->engine_idx = nr; in store_engine_mode()
429 lp5523_run_engine(chip, true); in store_engine_mode()
432 lp5523_stop_engine(chip); in store_engine_mode()
433 lp5523_load_engine(chip); in store_engine_mode()
436 lp5523_stop_engine(chip); in store_engine_mode()
440 mutex_unlock(&chip->lock); in store_engine_mode()
488 struct lp55xx_chip *chip = led->chip; in show_engine_leds() local
491 lp5523_mux_to_array(chip->engines[nr - 1].led_mux, mux); in show_engine_leds()
499 static int lp5523_load_mux(struct lp55xx_chip *chip, u16 mux, int nr) in lp5523_load_mux() argument
501 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in lp5523_load_mux()
509 lp5523_load_engine(chip); in lp5523_load_mux()
511 ret = lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, mux_page[nr]); in lp5523_load_mux()
515 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM , (u8)(mux >> 8)); in lp5523_load_mux()
519 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + 1, (u8)(mux)); in lp5523_load_mux()
532 struct lp55xx_chip *chip = led->chip; in store_engine_leds() local
533 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in store_engine_leds()
540 mutex_lock(&chip->lock); in store_engine_leds()
542 chip->engine_idx = nr; in store_engine_leds()
548 if (lp5523_load_mux(chip, mux, nr)) in store_engine_leds()
553 mutex_unlock(&chip->lock); in store_engine_leds()
565 struct lp55xx_chip *chip = led->chip; in store_engine_load() local
568 mutex_lock(&chip->lock); in store_engine_load()
570 chip->engine_idx = nr; in store_engine_load()
571 lp5523_load_engine_and_select_page(chip); in store_engine_load()
572 ret = lp5523_update_program_memory(chip, buf, len); in store_engine_load()
574 mutex_unlock(&chip->lock); in store_engine_load()
587 struct lp55xx_chip *chip = led->chip; in lp5523_selftest() local
588 struct lp55xx_platform_data *pdata = chip->pdata; in lp5523_selftest()
592 mutex_lock(&chip->lock); in lp5523_selftest()
594 ret = lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_selftest()
605 lp55xx_write(chip, LP5523_REG_LED_TEST_CTRL, LP5523_EN_LEDTEST | 16); in lp5523_selftest()
607 ret = lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_selftest()
614 ret = lp55xx_read(chip, LP5523_REG_LED_TEST_ADC, &vdd); in lp5523_selftest()
626 lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + i, in lp5523_selftest()
629 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0xff); in lp5523_selftest()
632 lp55xx_write(chip, LP5523_REG_LED_TEST_CTRL, in lp5523_selftest()
636 ret = lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_selftest()
643 ret = lp55xx_read(chip, LP5523_REG_LED_TEST_ADC, &adc); in lp5523_selftest()
650 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0x00); in lp5523_selftest()
653 lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + i, in lp5523_selftest()
664 mutex_unlock(&chip->lock); in lp5523_selftest()
673 struct lp55xx_chip *chip = led->chip; in lp5523_led_brightness_work() local
675 mutex_lock(&chip->lock); in lp5523_led_brightness_work()
676 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr, in lp5523_led_brightness_work()
678 mutex_unlock(&chip->lock); in lp5523_led_brightness_work()
733 struct lp55xx_chip *chip; in lp5523_probe() local
750 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); in lp5523_probe()
751 if (!chip) in lp5523_probe()
759 chip->cl = client; in lp5523_probe()
760 chip->pdata = pdata; in lp5523_probe()
761 chip->cfg = &lp5523_cfg; in lp5523_probe()
763 mutex_init(&chip->lock); in lp5523_probe()
767 ret = lp55xx_init_device(chip); in lp5523_probe()
773 ret = lp55xx_register_leds(led, chip); in lp5523_probe()
777 ret = lp55xx_register_sysfs(chip); in lp5523_probe()
786 lp55xx_unregister_leds(led, chip); in lp5523_probe()
788 lp55xx_deinit_device(chip); in lp5523_probe()
796 struct lp55xx_chip *chip = led->chip; in lp5523_remove() local
798 lp5523_stop_all_engines(chip); in lp5523_remove()
799 lp55xx_unregister_sysfs(chip); in lp5523_remove()
800 lp55xx_unregister_leds(led, chip); in lp5523_remove()
801 lp55xx_deinit_device(chip); in lp5523_remove()