Lines Matching refs:wled

181 struct wled {  struct
207 int (*wled_set_brightness)(struct wled *wled, u16 brightness); argument
210 int (*wled_cabc_config)(struct wled *wled, bool enable); argument
216 int (*wled_sync_toggle)(struct wled *wled); argument
222 int (*wled_ovp_delay)(struct wled *wled); argument
228 bool (*wled_auto_detection_required)(struct wled *wled); argument
231 static int wled3_set_brightness(struct wled *wled, u16 brightness) in wled3_set_brightness() argument
238 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled3_set_brightness()
239 rc = regmap_bulk_write(wled->regmap, wled->ctrl_addr + in wled3_set_brightness()
240 WLED3_SINK_REG_BRIGHT(wled->cfg.enabled_strings[i]), in wled3_set_brightness()
249 static int wled4_set_brightness(struct wled *wled, u16 brightness) in wled4_set_brightness() argument
252 u16 low_limit = wled->max_brightness * 4 / 1000; in wled4_set_brightness()
261 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled4_set_brightness()
262 rc = regmap_bulk_write(wled->regmap, wled->sink_addr + in wled4_set_brightness()
263 WLED4_SINK_REG_BRIGHT(wled->cfg.enabled_strings[i]), in wled4_set_brightness()
272 static int wled5_set_brightness(struct wled *wled, u16 brightness) in wled5_set_brightness() argument
275 u16 low_limit = wled->max_brightness * 1 / 1000; in wled5_set_brightness()
284 offset = (wled->cfg.mod_sel == MOD_A) ? in wled5_set_brightness()
288 rc = regmap_bulk_write(wled->regmap, wled->sink_addr + offset, in wled5_set_brightness()
295 struct wled *wled = container_of(work, in wled_ovp_work() local
296 struct wled, ovp_work.work); in wled_ovp_work()
297 enable_irq(wled->ovp_irq); in wled_ovp_work()
300 static int wled_module_enable(struct wled *wled, int val) in wled_module_enable() argument
304 if (wled->disabled_by_short) in wled_module_enable()
307 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled_module_enable()
314 if (wled->ovp_irq > 0) { in wled_module_enable()
322 schedule_delayed_work(&wled->ovp_work, HZ / 100); in wled_module_enable()
324 if (!cancel_delayed_work_sync(&wled->ovp_work)) in wled_module_enable()
325 disable_irq(wled->ovp_irq); in wled_module_enable()
332 static int wled3_sync_toggle(struct wled *wled) in wled3_sync_toggle() argument
335 unsigned int mask = GENMASK(wled->max_string_count - 1, 0); in wled3_sync_toggle()
337 rc = regmap_update_bits(wled->regmap, in wled3_sync_toggle()
338 wled->sink_addr + WLED3_SINK_REG_SYNC, in wled3_sync_toggle()
343 rc = regmap_update_bits(wled->regmap, in wled3_sync_toggle()
344 wled->sink_addr + WLED3_SINK_REG_SYNC, in wled3_sync_toggle()
350 static int wled5_mod_sync_toggle(struct wled *wled) in wled5_mod_sync_toggle() argument
355 rc = regmap_update_bits(wled->regmap, in wled5_mod_sync_toggle()
356 wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT, in wled5_mod_sync_toggle()
361 val = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_SYNC_MOD_A_BIT : in wled5_mod_sync_toggle()
363 return regmap_update_bits(wled->regmap, in wled5_mod_sync_toggle()
364 wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT, in wled5_mod_sync_toggle()
368 static int wled_ovp_fault_status(struct wled *wled, bool *fault_set) in wled_ovp_fault_status() argument
374 rc = regmap_read(wled->regmap, in wled_ovp_fault_status()
375 wled->ctrl_addr + WLED3_CTRL_REG_INT_RT_STS, in wled_ovp_fault_status()
378 dev_err(wled->dev, "Failed to read INT_RT_STS rc=%d\n", rc); in wled_ovp_fault_status()
382 rc = regmap_read(wled->regmap, in wled_ovp_fault_status()
383 wled->ctrl_addr + WLED3_CTRL_REG_FAULT_STATUS, in wled_ovp_fault_status()
386 dev_err(wled->dev, "Failed to read FAULT_STATUS rc=%d\n", rc); in wled_ovp_fault_status()
393 if (wled->version == 4 && (fault_sts & WLED3_CTRL_REG_OVP_FAULT_BIT)) in wled_ovp_fault_status()
396 if (wled->version == 5 && (fault_sts & (WLED3_CTRL_REG_OVP_FAULT_BIT | in wled_ovp_fault_status()
401 dev_dbg(wled->dev, "WLED OVP fault detected, int_rt_sts=0x%x fault_sts=0x%x\n", in wled_ovp_fault_status()
407 static int wled4_ovp_delay(struct wled *wled) in wled4_ovp_delay() argument
412 static int wled5_ovp_delay(struct wled *wled) in wled5_ovp_delay() argument
419 rc = regmap_read(wled->regmap, wled->ctrl_addr + in wled5_ovp_delay()
427 dev_dbg(wled->dev, "delay_time_us: %d\n", delay_us); in wled5_ovp_delay()
434 struct wled *wled = bl_get_data(bl); in wled_update_status() local
438 mutex_lock(&wled->lock); in wled_update_status()
440 rc = wled->wled_set_brightness(wled, brightness); in wled_update_status()
442 dev_err(wled->dev, "wled failed to set brightness rc:%d\n", in wled_update_status()
447 if (wled->version < 5) { in wled_update_status()
448 rc = wled->wled_sync_toggle(wled); in wled_update_status()
450 dev_err(wled->dev, "wled sync failed rc:%d\n", rc); in wled_update_status()
458 rc = wled5_mod_sync_toggle(wled); in wled_update_status()
460 dev_err(wled->dev, "wled mod sync failed rc:%d\n", in wled_update_status()
467 if (!!brightness != !!wled->brightness) { in wled_update_status()
468 rc = wled_module_enable(wled, !!brightness); in wled_update_status()
470 dev_err(wled->dev, "wled enable failed rc:%d\n", rc); in wled_update_status()
475 wled->brightness = brightness; in wled_update_status()
478 mutex_unlock(&wled->lock); in wled_update_status()
483 static int wled4_cabc_config(struct wled *wled, bool enable) in wled4_cabc_config() argument
488 for (i = 0; i < wled->cfg.num_strings; i++) { in wled4_cabc_config()
489 j = wled->cfg.enabled_strings[i]; in wled4_cabc_config()
492 rc = regmap_update_bits(wled->regmap, wled->sink_addr + in wled4_cabc_config()
502 static int wled5_cabc_config(struct wled *wled, bool enable) in wled5_cabc_config() argument
507 if (wled->cabc_disabled) in wled5_cabc_config()
510 reg = enable ? wled->cfg.cabc_sel : 0; in wled5_cabc_config()
511 offset = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_MOD_A_SRC_SEL : in wled5_cabc_config()
514 rc = regmap_update_bits(wled->regmap, wled->sink_addr + offset, in wled5_cabc_config()
521 if (!wled->cfg.cabc_sel) in wled5_cabc_config()
522 wled->cabc_disabled = true; in wled5_cabc_config()
533 struct wled *wled = _wled; in wled_short_irq_handler() local
537 wled->short_count++; in wled_short_irq_handler()
538 mutex_lock(&wled->lock); in wled_short_irq_handler()
539 rc = wled_module_enable(wled, false); in wled_short_irq_handler()
541 dev_err(wled->dev, "wled disable failed rc:%d\n", rc); in wled_short_irq_handler()
546 wled->last_short_event); in wled_short_irq_handler()
548 wled->short_count = 1; in wled_short_irq_handler()
550 if (wled->short_count > WLED_SHORT_CNT_MAX) { in wled_short_irq_handler()
551 dev_err(wled->dev, "Short triggered %d times, disabling WLED forever!\n", in wled_short_irq_handler()
552 wled->short_count); in wled_short_irq_handler()
553 wled->disabled_by_short = true; in wled_short_irq_handler()
557 wled->last_short_event = ktime_get(); in wled_short_irq_handler()
560 rc = wled_module_enable(wled, true); in wled_short_irq_handler()
562 dev_err(wled->dev, "wled enable failed rc:%d\n", rc); in wled_short_irq_handler()
565 mutex_unlock(&wled->lock); in wled_short_irq_handler()
572 static void wled_auto_string_detection(struct wled *wled) in wled_auto_string_detection() argument
580 rc = regmap_read(wled->regmap, wled->sink_addr + in wled_auto_string_detection()
583 dev_err(wled->dev, "Failed to read SINK configuration rc=%d\n", in wled_auto_string_detection()
589 rc = regmap_update_bits(wled->regmap, in wled_auto_string_detection()
590 wled->ctrl_addr + WLED3_CTRL_REG_MOD_EN, in wled_auto_string_detection()
593 dev_err(wled->dev, "Failed to disable WLED module rc=%d\n", rc); in wled_auto_string_detection()
598 rc = wled4_set_brightness(wled, AUTO_DETECT_BRIGHTNESS); in wled_auto_string_detection()
600 dev_err(wled->dev, "Failed to set brightness for auto detection rc=%d\n", in wled_auto_string_detection()
605 if (wled->cfg.cabc) { in wled_auto_string_detection()
606 rc = wled->wled_cabc_config(wled, false); in wled_auto_string_detection()
612 rc = regmap_write(wled->regmap, in wled_auto_string_detection()
613 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, 0); in wled_auto_string_detection()
615 dev_err(wled->dev, "Failed to disable all sinks rc=%d\n", rc); in wled_auto_string_detection()
620 for (i = 0; i < wled->cfg.num_strings; i++) { in wled_auto_string_detection()
621 j = wled->cfg.enabled_strings[i]; in wled_auto_string_detection()
625 rc = regmap_write(wled->regmap, wled->ctrl_addr + in wled_auto_string_detection()
628 dev_err(wled->dev, "Failed to enable feedback for SINK %d rc = %d\n", in wled_auto_string_detection()
634 rc = regmap_write(wled->regmap, wled->sink_addr + in wled_auto_string_detection()
637 dev_err(wled->dev, "Failed to configure SINK %d rc=%d\n", in wled_auto_string_detection()
643 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled_auto_string_detection()
648 dev_err(wled->dev, "Failed to enable WLED module rc=%d\n", in wled_auto_string_detection()
653 delay_time_us = wled->wled_ovp_delay(wled); in wled_auto_string_detection()
656 rc = wled_ovp_fault_status(wled, &fault_set); in wled_auto_string_detection()
658 dev_err(wled->dev, "Error in getting OVP fault_sts, rc=%d\n", in wled_auto_string_detection()
664 dev_dbg(wled->dev, "WLED OVP fault detected with SINK %d\n", in wled_auto_string_detection()
670 rc = regmap_update_bits(wled->regmap, in wled_auto_string_detection()
671 wled->ctrl_addr + WLED3_CTRL_REG_MOD_EN, in wled_auto_string_detection()
674 dev_err(wled->dev, "Failed to disable WLED module rc=%d\n", in wled_auto_string_detection()
681 dev_err(wled->dev, "No valid WLED sinks found\n"); in wled_auto_string_detection()
682 wled->disabled_by_short = true; in wled_auto_string_detection()
687 dev_warn(wled->dev, "%x is not a valid sink configuration - using %x instead\n", in wled_auto_string_detection()
693 rc = regmap_write(wled->regmap, in wled_auto_string_detection()
694 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, in wled_auto_string_detection()
697 dev_err(wled->dev, "Failed to reconfigure the default sink rc=%d\n", in wled_auto_string_detection()
703 if (wled->version == 4) { in wled_auto_string_detection()
704 for (i = 0; i < wled->cfg.num_strings; i++) { in wled_auto_string_detection()
705 j = wled->cfg.enabled_strings[i]; in wled_auto_string_detection()
713 rc = regmap_write(wled->regmap, wled->sink_addr + in wled_auto_string_detection()
716 dev_err(wled->dev, "Failed to configure MODULATOR_EN rc=%d\n", in wled_auto_string_detection()
724 rc = wled->wled_cabc_config(wled, true); in wled_auto_string_detection()
729 rc = regmap_write(wled->regmap, in wled_auto_string_detection()
730 wled->ctrl_addr + WLED3_CTRL_REG_FEEDBACK_CONTROL, 0); in wled_auto_string_detection()
732 dev_err(wled->dev, "Failed to restore feedback setting rc=%d\n", in wled_auto_string_detection()
738 rc = wled4_set_brightness(wled, wled->brightness); in wled_auto_string_detection()
740 dev_err(wled->dev, "Failed to set brightness after auto detection rc=%d\n", in wled_auto_string_detection()
745 rc = regmap_update_bits(wled->regmap, in wled_auto_string_detection()
746 wled->ctrl_addr + WLED3_CTRL_REG_MOD_EN, in wled_auto_string_detection()
750 dev_err(wled->dev, "Failed to enable WLED module rc=%d\n", rc); in wled_auto_string_detection()
761 static bool wled4_auto_detection_required(struct wled *wled) in wled4_auto_detection_required() argument
765 if (!wled->cfg.auto_detection_enabled) in wled4_auto_detection_required()
773 if (!wled->auto_detection_ovp_count) { in wled4_auto_detection_required()
774 wled->start_ovp_fault_time = ktime_get(); in wled4_auto_detection_required()
775 wled->auto_detection_ovp_count++; in wled4_auto_detection_required()
778 wled->start_ovp_fault_time); in wled4_auto_detection_required()
780 wled->auto_detection_ovp_count = 0; in wled4_auto_detection_required()
782 wled->auto_detection_ovp_count++; in wled4_auto_detection_required()
784 if (wled->auto_detection_ovp_count >= in wled4_auto_detection_required()
786 wled->auto_detection_ovp_count = 0; in wled4_auto_detection_required()
794 static bool wled5_auto_detection_required(struct wled *wled) in wled5_auto_detection_required() argument
796 if (!wled->cfg.auto_detection_enabled) in wled5_auto_detection_required()
811 static int wled_auto_detection_at_init(struct wled *wled) in wled_auto_detection_at_init() argument
816 if (!wled->cfg.auto_detection_enabled) in wled_auto_detection_at_init()
819 rc = wled_ovp_fault_status(wled, &fault_set); in wled_auto_detection_at_init()
821 dev_err(wled->dev, "Error in getting OVP fault_sts, rc=%d\n", in wled_auto_detection_at_init()
827 mutex_lock(&wled->lock); in wled_auto_detection_at_init()
828 wled_auto_string_detection(wled); in wled_auto_detection_at_init()
829 mutex_unlock(&wled->lock); in wled_auto_detection_at_init()
837 struct wled *wled = _wled; in wled_ovp_irq_handler() local
841 rc = regmap_read(wled->regmap, in wled_ovp_irq_handler()
842 wled->ctrl_addr + WLED3_CTRL_REG_INT_RT_STS, &int_sts); in wled_ovp_irq_handler()
844 dev_err(wled->dev, "Error in reading WLED3_INT_RT_STS rc=%d\n", in wled_ovp_irq_handler()
849 rc = regmap_read(wled->regmap, wled->ctrl_addr + in wled_ovp_irq_handler()
852 dev_err(wled->dev, "Error in reading WLED_FAULT_STATUS rc=%d\n", in wled_ovp_irq_handler()
859 dev_dbg(wled->dev, "WLED OVP fault detected, int_sts=%x fault_sts= %x\n", in wled_ovp_irq_handler()
863 if (wled->wled_auto_detection_required(wled)) { in wled_ovp_irq_handler()
864 mutex_lock(&wled->lock); in wled_ovp_irq_handler()
865 wled_auto_string_detection(wled); in wled_ovp_irq_handler()
866 mutex_unlock(&wled->lock); in wled_ovp_irq_handler()
873 static int wled3_setup(struct wled *wled) in wled3_setup() argument
879 rc = regmap_update_bits(wled->regmap, in wled3_setup()
880 wled->ctrl_addr + WLED3_CTRL_REG_OVP, in wled3_setup()
881 WLED3_CTRL_REG_OVP_MASK, wled->cfg.ovp); in wled3_setup()
885 rc = regmap_update_bits(wled->regmap, in wled3_setup()
886 wled->ctrl_addr + WLED3_CTRL_REG_ILIMIT, in wled3_setup()
888 wled->cfg.boost_i_limit); in wled3_setup()
892 rc = regmap_update_bits(wled->regmap, in wled3_setup()
893 wled->ctrl_addr + WLED3_CTRL_REG_FREQ, in wled3_setup()
895 wled->cfg.switch_freq); in wled3_setup()
899 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled3_setup()
900 j = wled->cfg.enabled_strings[i]; in wled3_setup()
901 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_MOD_EN(j); in wled3_setup()
902 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
908 if (wled->cfg.ext_gen) { in wled3_setup()
909 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_MOD_SRC(j); in wled3_setup()
910 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
917 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_FULL_SCALE_CURR(j); in wled3_setup()
918 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
920 wled->cfg.string_i_limit); in wled3_setup()
924 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_CABC(j); in wled3_setup()
925 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
927 wled->cfg.cabc ? in wled3_setup()
935 rc = regmap_update_bits(wled->regmap, in wled3_setup()
936 wled->ctrl_addr + WLED3_SINK_REG_CURR_SINK, in wled3_setup()
956 static int wled4_setup(struct wled *wled) in wled4_setup() argument
963 rc = regmap_update_bits(wled->regmap, in wled4_setup()
964 wled->ctrl_addr + WLED3_CTRL_REG_OVP, in wled4_setup()
965 WLED3_CTRL_REG_OVP_MASK, wled->cfg.ovp); in wled4_setup()
969 rc = regmap_update_bits(wled->regmap, in wled4_setup()
970 wled->ctrl_addr + WLED3_CTRL_REG_ILIMIT, in wled4_setup()
972 wled->cfg.boost_i_limit); in wled4_setup()
976 rc = regmap_update_bits(wled->regmap, in wled4_setup()
977 wled->ctrl_addr + WLED3_CTRL_REG_FREQ, in wled4_setup()
979 wled->cfg.switch_freq); in wled4_setup()
983 if (wled->cfg.external_pfet) { in wled4_setup()
985 rc = regmap_write(wled->regmap, wled->ctrl_addr + in wled4_setup()
991 rc = regmap_write(wled->regmap, in wled4_setup()
992 wled->ctrl_addr + WLED4_CTRL_REG_TEST1, in wled4_setup()
998 rc = regmap_read(wled->regmap, wled->sink_addr + in wled4_setup()
1003 for (i = 0; i < wled->cfg.num_strings; i++) { in wled4_setup()
1004 j = wled->cfg.enabled_strings[i]; in wled4_setup()
1010 rc = wled_auto_detection_at_init(wled); in wled4_setup()
1014 rc = regmap_update_bits(wled->regmap, in wled4_setup()
1015 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, in wled4_setup()
1020 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled4_setup()
1027 for (i = 0; i < wled->cfg.num_strings; i++) { in wled4_setup()
1028 j = wled->cfg.enabled_strings[i]; in wled4_setup()
1030 addr = wled->sink_addr + in wled4_setup()
1032 rc = regmap_update_bits(wled->regmap, addr, in wled4_setup()
1038 addr = wled->sink_addr + in wled4_setup()
1040 rc = regmap_update_bits(wled->regmap, addr, in wled4_setup()
1042 wled->cfg.string_i_limit); in wled4_setup()
1047 rc = wled4_cabc_config(wled, wled->cfg.cabc); in wled4_setup()
1051 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled4_setup()
1058 rc = regmap_update_bits(wled->regmap, in wled4_setup()
1059 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, in wled4_setup()
1064 rc = wled->wled_sync_toggle(wled); in wled4_setup()
1066 dev_err(wled->dev, "Failed to toggle sync reg rc:%d\n", rc); in wled4_setup()
1070 rc = wled_auto_detection_at_init(wled); in wled4_setup()
1087 static int wled5_setup(struct wled *wled) in wled5_setup() argument
1094 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1095 wled->ctrl_addr + WLED3_CTRL_REG_OVP, in wled5_setup()
1096 WLED5_CTRL_REG_OVP_MASK, wled->cfg.ovp); in wled5_setup()
1100 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1101 wled->ctrl_addr + WLED3_CTRL_REG_ILIMIT, in wled5_setup()
1103 wled->cfg.boost_i_limit); in wled5_setup()
1107 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1108 wled->ctrl_addr + WLED3_CTRL_REG_FREQ, in wled5_setup()
1110 wled->cfg.switch_freq); in wled5_setup()
1115 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled5_setup()
1116 j = wled->cfg.enabled_strings[i]; in wled5_setup()
1117 addr = wled->sink_addr + in wled5_setup()
1119 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1121 wled->cfg.string_i_limit); in wled5_setup()
1125 addr = wled->sink_addr + WLED5_SINK_REG_STR_SRC_SEL(j); in wled5_setup()
1126 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1128 wled->cfg.mod_sel == MOD_A ? in wled5_setup()
1136 rc = wled5_cabc_config(wled, wled->cfg.cabc_sel ? true : false); in wled5_setup()
1141 addr = wled->sink_addr + WLED5_SINK_REG_MOD_A_EN; in wled5_setup()
1142 val = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_MOD_EN_MASK : 0; in wled5_setup()
1143 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1148 addr = wled->sink_addr + WLED5_SINK_REG_MOD_B_EN; in wled5_setup()
1149 val = (wled->cfg.mod_sel == MOD_B) ? WLED5_SINK_REG_MOD_EN_MASK : 0; in wled5_setup()
1150 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1155 offset = (wled->cfg.mod_sel == MOD_A) ? in wled5_setup()
1159 addr = wled->sink_addr + offset; in wled5_setup()
1160 val = (wled->max_brightness == WLED5_SINK_REG_BRIGHT_MAX_15B) ? in wled5_setup()
1163 rc = regmap_write(wled->regmap, addr, val); in wled5_setup()
1167 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1168 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, in wled5_setup()
1174 rc = wled->wled_sync_toggle(wled); in wled5_setup()
1180 rc = wled_auto_detection_at_init(wled); in wled5_setup()
1305 static int wled_configure(struct wled *wled) in wled_configure() argument
1307 struct wled_config *cfg = &wled->cfg; in wled_configure()
1308 struct device *dev = wled->dev; in wled_configure()
1403 dev_err(wled->dev, "invalid IO resources\n"); in wled_configure()
1406 wled->ctrl_addr = be32_to_cpu(*prop_addr); in wled_configure()
1408 rc = of_property_read_string(dev->of_node, "label", &wled->name); in wled_configure()
1410 wled->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node); in wled_configure()
1412 switch (wled->version) { in wled_configure()
1417 wled->wled_set_brightness = wled3_set_brightness; in wled_configure()
1418 wled->wled_sync_toggle = wled3_sync_toggle; in wled_configure()
1419 wled->max_string_count = 3; in wled_configure()
1420 wled->sink_addr = wled->ctrl_addr; in wled_configure()
1427 wled->wled_set_brightness = wled4_set_brightness; in wled_configure()
1428 wled->wled_sync_toggle = wled3_sync_toggle; in wled_configure()
1429 wled->wled_cabc_config = wled4_cabc_config; in wled_configure()
1430 wled->wled_ovp_delay = wled4_ovp_delay; in wled_configure()
1431 wled->wled_auto_detection_required = in wled_configure()
1433 wled->max_string_count = 4; in wled_configure()
1437 dev_err(wled->dev, "invalid IO resources\n"); in wled_configure()
1440 wled->sink_addr = be32_to_cpu(*prop_addr); in wled_configure()
1447 wled->wled_set_brightness = wled5_set_brightness; in wled_configure()
1448 wled->wled_sync_toggle = wled3_sync_toggle; in wled_configure()
1449 wled->wled_cabc_config = wled5_cabc_config; in wled_configure()
1450 wled->wled_ovp_delay = wled5_ovp_delay; in wled_configure()
1451 wled->wled_auto_detection_required = in wled_configure()
1453 wled->max_string_count = 4; in wled_configure()
1457 dev_err(wled->dev, "invalid IO resources\n"); in wled_configure()
1460 wled->sink_addr = be32_to_cpu(*prop_addr); in wled_configure()
1464 dev_err(wled->dev, "Invalid WLED version\n"); in wled_configure()
1503 if (string_len > wled->max_string_count) { in wled_configure()
1505 wled->max_string_count); in wled_configure()
1511 wled->cfg.enabled_strings, in wled_configure()
1520 if (wled->cfg.enabled_strings[i] >= wled->max_string_count) { in wled_configure()
1523 wled->cfg.enabled_strings[i], i); in wled_configure()
1533 if (val < 1 || val > wled->max_string_count) { in wled_configure()
1535 wled->max_string_count); in wled_configure()
1554 static int wled_configure_short_irq(struct wled *wled, in wled_configure_short_irq() argument
1559 if (!wled->has_short_detect) in wled_configure_short_irq()
1562 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled_configure_short_irq()
1569 wled->short_irq = platform_get_irq_byname(pdev, "short"); in wled_configure_short_irq()
1570 if (wled->short_irq < 0) { in wled_configure_short_irq()
1575 rc = devm_request_threaded_irq(wled->dev, wled->short_irq, in wled_configure_short_irq()
1578 "wled_short_irq", wled); in wled_configure_short_irq()
1580 dev_err(wled->dev, "Unable to request short_irq (err:%d)\n", in wled_configure_short_irq()
1586 static int wled_configure_ovp_irq(struct wled *wled, in wled_configure_ovp_irq() argument
1592 wled->ovp_irq = platform_get_irq_byname(pdev, "ovp"); in wled_configure_ovp_irq()
1593 if (wled->ovp_irq < 0) { in wled_configure_ovp_irq()
1598 rc = devm_request_threaded_irq(wled->dev, wled->ovp_irq, NULL, in wled_configure_ovp_irq()
1600 "wled_ovp_irq", wled); in wled_configure_ovp_irq()
1602 dev_err(wled->dev, "Unable to request ovp_irq (err:%d)\n", in wled_configure_ovp_irq()
1604 wled->ovp_irq = 0; in wled_configure_ovp_irq()
1608 rc = regmap_read(wled->regmap, wled->ctrl_addr + in wled_configure_ovp_irq()
1615 disable_irq(wled->ovp_irq); in wled_configure_ovp_irq()
1628 struct wled *wled; in wled_probe() local
1639 wled = devm_kzalloc(&pdev->dev, sizeof(*wled), GFP_KERNEL); in wled_probe()
1640 if (!wled) in wled_probe()
1643 wled->regmap = regmap; in wled_probe()
1644 wled->dev = &pdev->dev; in wled_probe()
1646 wled->version = (uintptr_t)of_device_get_match_data(&pdev->dev); in wled_probe()
1647 if (!wled->version) { in wled_probe()
1652 mutex_init(&wled->lock); in wled_probe()
1653 rc = wled_configure(wled); in wled_probe()
1659 wled->max_brightness = val; in wled_probe()
1661 switch (wled->version) { in wled_probe()
1663 wled->cfg.auto_detection_enabled = false; in wled_probe()
1664 rc = wled3_setup(wled); in wled_probe()
1672 wled->has_short_detect = true; in wled_probe()
1673 rc = wled4_setup(wled); in wled_probe()
1681 wled->has_short_detect = true; in wled_probe()
1682 if (wled->cfg.cabc_sel) in wled_probe()
1683 wled->max_brightness = WLED5_SINK_REG_BRIGHT_MAX_12B; in wled_probe()
1685 rc = wled5_setup(wled); in wled_probe()
1693 dev_err(wled->dev, "Invalid WLED version\n"); in wled_probe()
1697 INIT_DELAYED_WORK(&wled->ovp_work, wled_ovp_work); in wled_probe()
1699 rc = wled_configure_short_irq(wled, pdev); in wled_probe()
1703 rc = wled_configure_ovp_irq(wled, pdev); in wled_probe()
1713 props.max_brightness = wled->max_brightness; in wled_probe()
1714 bl = devm_backlight_device_register(&pdev->dev, wled->name, in wled_probe()
1715 &pdev->dev, wled, in wled_probe()
1722 struct wled *wled = platform_get_drvdata(pdev); in wled_remove() local
1724 mutex_destroy(&wled->lock); in wled_remove()
1725 cancel_delayed_work_sync(&wled->ovp_work); in wled_remove()
1726 disable_irq(wled->short_irq); in wled_remove()
1727 disable_irq(wled->ovp_irq); in wled_remove()