Lines Matching refs:chip

124 static int lp5523_init_program_engine(struct lp55xx_chip *chip);
134 lp55xx_write(led->chip, LP5523_REG_LED_CURRENT_BASE + led->chan_nr, in lp5523_set_led_current()
138 static int lp5523_post_init_device(struct lp55xx_chip *chip) in lp5523_post_init_device() argument
142 ret = lp55xx_write(chip, LP5523_REG_ENABLE, LP5523_ENABLE); in lp5523_post_init_device()
149 ret = lp55xx_write(chip, LP5523_REG_CONFIG, in lp5523_post_init_device()
157 ret = lp55xx_write(chip, LP5523_REG_ENABLE_LEDS_MSB, 0x01); in lp5523_post_init_device()
161 ret = lp55xx_write(chip, LP5523_REG_ENABLE_LEDS_LSB, 0xff); in lp5523_post_init_device()
165 return lp5523_init_program_engine(chip); in lp5523_post_init_device()
168 static void lp5523_load_engine(struct lp55xx_chip *chip) in lp5523_load_engine() argument
170 enum lp55xx_engine_index idx = chip->engine_idx; in lp5523_load_engine()
183 lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], val[idx]); in lp5523_load_engine()
188 static void lp5523_load_engine_and_select_page(struct lp55xx_chip *chip) in lp5523_load_engine_and_select_page() argument
190 enum lp55xx_engine_index idx = chip->engine_idx; in lp5523_load_engine_and_select_page()
197 lp5523_load_engine(chip); in lp5523_load_engine_and_select_page()
199 lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, page_sel[idx]); in lp5523_load_engine_and_select_page()
202 static void lp5523_stop_all_engines(struct lp55xx_chip *chip) in lp5523_stop_all_engines() argument
204 lp55xx_write(chip, LP5523_REG_OP_MODE, 0); in lp5523_stop_all_engines()
208 static void lp5523_stop_engine(struct lp55xx_chip *chip) in lp5523_stop_engine() argument
210 enum lp55xx_engine_index idx = chip->engine_idx; in lp5523_stop_engine()
217 lp55xx_update_bits(chip, LP5523_REG_OP_MODE, mask[idx], 0); in lp5523_stop_engine()
222 static void lp5523_turn_off_channels(struct lp55xx_chip *chip) in lp5523_turn_off_channels() argument
227 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0); in lp5523_turn_off_channels()
230 static void lp5523_run_engine(struct lp55xx_chip *chip, bool start) in lp5523_run_engine() argument
238 lp5523_stop_engine(chip); in lp5523_run_engine()
239 lp5523_turn_off_channels(chip); in lp5523_run_engine()
248 ret = lp55xx_read(chip, LP5523_REG_OP_MODE, &mode); in lp5523_run_engine()
252 ret = lp55xx_read(chip, LP5523_REG_ENABLE, &exec); in lp5523_run_engine()
272 lp55xx_write(chip, LP5523_REG_OP_MODE, mode); in lp5523_run_engine()
275 lp55xx_update_bits(chip, LP5523_REG_ENABLE, LP5523_EXEC_M, exec); in lp5523_run_engine()
278 static int lp5523_init_program_engine(struct lp55xx_chip *chip) in lp5523_init_program_engine() argument
292 ret = lp55xx_write(chip, LP5523_REG_CH1_PROG_START, 0x00); in lp5523_init_program_engine()
296 ret = lp55xx_write(chip, LP5523_REG_CH2_PROG_START, 0x10); in lp5523_init_program_engine()
300 ret = lp55xx_write(chip, LP5523_REG_CH3_PROG_START, 0x20); in lp5523_init_program_engine()
306 chip->engine_idx = i; in lp5523_init_program_engine()
307 lp5523_load_engine_and_select_page(chip); in lp5523_init_program_engine()
310 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + j, in lp5523_init_program_engine()
317 lp5523_run_engine(chip, true); in lp5523_init_program_engine()
321 lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_init_program_engine()
325 dev_err(&chip->cl->dev, in lp5523_init_program_engine()
332 lp5523_stop_all_engines(chip); in lp5523_init_program_engine()
336 static int lp5523_update_program_memory(struct lp55xx_chip *chip, in lp5523_update_program_memory() argument
367 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]); in lp5523_update_program_memory()
375 dev_err(&chip->cl->dev, "wrong pattern format\n"); in lp5523_update_program_memory()
379 static void lp5523_firmware_loaded(struct lp55xx_chip *chip) in lp5523_firmware_loaded() argument
381 const struct firmware *fw = chip->fw; in lp5523_firmware_loaded()
384 dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n", in lp5523_firmware_loaded()
395 lp5523_load_engine_and_select_page(chip); in lp5523_firmware_loaded()
396 lp5523_update_program_memory(chip, fw->data, fw->size); in lp5523_firmware_loaded()
404 struct lp55xx_chip *chip = led->chip; in show_engine_mode() local
405 enum lp55xx_engine_mode mode = chip->engines[nr - 1].mode; in show_engine_mode()
426 struct lp55xx_chip *chip = led->chip; in store_engine_mode() local
427 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in store_engine_mode()
429 mutex_lock(&chip->lock); in store_engine_mode()
431 chip->engine_idx = nr; in store_engine_mode()
434 lp5523_run_engine(chip, true); in store_engine_mode()
437 lp5523_stop_engine(chip); in store_engine_mode()
438 lp5523_load_engine(chip); in store_engine_mode()
441 lp5523_stop_engine(chip); in store_engine_mode()
445 mutex_unlock(&chip->lock); in store_engine_mode()
493 struct lp55xx_chip *chip = led->chip; in show_engine_leds() local
496 lp5523_mux_to_array(chip->engines[nr - 1].led_mux, mux); in show_engine_leds()
504 static int lp5523_load_mux(struct lp55xx_chip *chip, u16 mux, int nr) in lp5523_load_mux() argument
506 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in lp5523_load_mux()
514 lp5523_load_engine(chip); in lp5523_load_mux()
516 ret = lp55xx_write(chip, LP5523_REG_PROG_PAGE_SEL, mux_page[nr]); in lp5523_load_mux()
520 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM , (u8)(mux >> 8)); in lp5523_load_mux()
524 ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + 1, (u8)(mux)); in lp5523_load_mux()
537 struct lp55xx_chip *chip = led->chip; in store_engine_leds() local
538 struct lp55xx_engine *engine = &chip->engines[nr - 1]; in store_engine_leds()
545 mutex_lock(&chip->lock); in store_engine_leds()
547 chip->engine_idx = nr; in store_engine_leds()
553 if (lp5523_load_mux(chip, mux, nr)) in store_engine_leds()
558 mutex_unlock(&chip->lock); in store_engine_leds()
570 struct lp55xx_chip *chip = led->chip; in store_engine_load() local
573 mutex_lock(&chip->lock); in store_engine_load()
575 chip->engine_idx = nr; in store_engine_load()
576 lp5523_load_engine_and_select_page(chip); in store_engine_load()
577 ret = lp5523_update_program_memory(chip, buf, len); in store_engine_load()
579 mutex_unlock(&chip->lock); in store_engine_load()
592 struct lp55xx_chip *chip = led->chip; in lp5523_selftest() local
593 struct lp55xx_platform_data *pdata = chip->pdata; in lp5523_selftest()
597 mutex_lock(&chip->lock); in lp5523_selftest()
599 ret = lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_selftest()
610 lp55xx_write(chip, LP5523_REG_LED_TEST_CTRL, LP5523_EN_LEDTEST | 16); in lp5523_selftest()
612 ret = lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_selftest()
619 ret = lp55xx_read(chip, LP5523_REG_LED_TEST_ADC, &vdd); in lp5523_selftest()
631 lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + i, in lp5523_selftest()
634 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0xff); in lp5523_selftest()
637 lp55xx_write(chip, LP5523_REG_LED_TEST_CTRL, in lp5523_selftest()
641 ret = lp55xx_read(chip, LP5523_REG_STATUS, &status); in lp5523_selftest()
648 ret = lp55xx_read(chip, LP5523_REG_LED_TEST_ADC, &adc); in lp5523_selftest()
655 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + i, 0x00); in lp5523_selftest()
658 lp55xx_write(chip, LP5523_REG_LED_CURRENT_BASE + i, in lp5523_selftest()
669 mutex_unlock(&chip->lock); in lp5523_selftest()
695 struct lp55xx_chip *chip = led->chip; in show_master_fader() local
699 mutex_lock(&chip->lock); in show_master_fader()
700 ret = lp55xx_read(chip, LP5523_REG_MASTER_FADER_BASE + nr - 1, &val); in show_master_fader()
701 mutex_unlock(&chip->lock); in show_master_fader()
717 struct lp55xx_chip *chip = led->chip; in store_master_fader() local
727 mutex_lock(&chip->lock); in store_master_fader()
728 ret = lp55xx_write(chip, LP5523_REG_MASTER_FADER_BASE + nr - 1, in store_master_fader()
730 mutex_unlock(&chip->lock); in store_master_fader()
746 struct lp55xx_chip *chip = led->chip; in show_master_fader_leds() local
750 mutex_lock(&chip->lock); in show_master_fader_leds()
753 ret = lp55xx_read(chip, LP5523_REG_LED_CTRL_BASE + i, &val); in show_master_fader_leds()
768 mutex_unlock(&chip->lock); in show_master_fader_leds()
777 struct lp55xx_chip *chip = led->chip; in store_master_fader_leds() local
783 mutex_lock(&chip->lock); in store_master_fader_leds()
788 ret = lp55xx_update_bits(chip, in store_master_fader_leds()
801 mutex_unlock(&chip->lock); in store_master_fader_leds()
809 struct lp55xx_chip *chip = led->chip; in lp5523_led_brightness_work() local
811 mutex_lock(&chip->lock); in lp5523_led_brightness_work()
812 lp55xx_write(chip, LP5523_REG_LED_PWM_BASE + led->chan_nr, in lp5523_led_brightness_work()
814 mutex_unlock(&chip->lock); in lp5523_led_brightness_work()
881 struct lp55xx_chip *chip; in lp5523_probe() local
897 chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); in lp5523_probe()
898 if (!chip) in lp5523_probe()
906 chip->cl = client; in lp5523_probe()
907 chip->pdata = pdata; in lp5523_probe()
908 chip->cfg = &lp5523_cfg; in lp5523_probe()
910 mutex_init(&chip->lock); in lp5523_probe()
914 ret = lp55xx_init_device(chip); in lp5523_probe()
920 ret = lp55xx_register_leds(led, chip); in lp5523_probe()
924 ret = lp55xx_register_sysfs(chip); in lp5523_probe()
933 lp55xx_unregister_leds(led, chip); in lp5523_probe()
935 lp55xx_deinit_device(chip); in lp5523_probe()
943 struct lp55xx_chip *chip = led->chip; in lp5523_remove() local
945 lp5523_stop_all_engines(chip); in lp5523_remove()
946 lp55xx_unregister_sysfs(chip); in lp5523_remove()
947 lp55xx_unregister_leds(led, chip); in lp5523_remove()
948 lp55xx_deinit_device(chip); in lp5523_remove()