Lines Matching full: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
219 * Time to wait before checking the OVP status after wled module enable.
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
239 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled3_set_brightness()
240 rc = regmap_bulk_write(wled->regmap, wled->ctrl_addr + 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()
262 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled4_set_brightness()
263 rc = regmap_bulk_write(wled->regmap, wled->sink_addr + 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()
285 offset = (wled->cfg.mod_sel == MOD_A) ? in wled5_set_brightness()
289 rc = regmap_bulk_write(wled->regmap, wled->sink_addr + offset, in wled5_set_brightness()
296 struct wled *wled = container_of(work, in wled_ovp_work() local
297 struct wled, ovp_work.work); in wled_ovp_work()
298 enable_irq(wled->ovp_irq); in wled_ovp_work()
301 static int wled_module_enable(struct wled *wled, int val) in wled_module_enable() argument
305 if (wled->disabled_by_short) in wled_module_enable()
308 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled_module_enable()
315 if (wled->ovp_irq > 0) { in wled_module_enable()
323 schedule_delayed_work(&wled->ovp_work, HZ / 100); in wled_module_enable()
325 if (!cancel_delayed_work_sync(&wled->ovp_work)) in wled_module_enable()
326 disable_irq(wled->ovp_irq); in wled_module_enable()
333 static int wled3_sync_toggle(struct wled *wled) in wled3_sync_toggle() argument
336 unsigned int mask = GENMASK(wled->max_string_count - 1, 0); in wled3_sync_toggle()
338 rc = regmap_update_bits(wled->regmap, in wled3_sync_toggle()
339 wled->sink_addr + WLED3_SINK_REG_SYNC, in wled3_sync_toggle()
344 rc = regmap_update_bits(wled->regmap, in wled3_sync_toggle()
345 wled->sink_addr + WLED3_SINK_REG_SYNC, in wled3_sync_toggle()
351 static int wled5_mod_sync_toggle(struct wled *wled) in wled5_mod_sync_toggle() argument
356 rc = regmap_update_bits(wled->regmap, in wled5_mod_sync_toggle()
357 wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT, in wled5_mod_sync_toggle()
362 val = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_SYNC_MOD_A_BIT : in wled5_mod_sync_toggle()
364 return regmap_update_bits(wled->regmap, in wled5_mod_sync_toggle()
365 wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT, in wled5_mod_sync_toggle()
369 static int wled_ovp_fault_status(struct wled *wled, bool *fault_set) in wled_ovp_fault_status() argument
375 rc = regmap_read(wled->regmap, in wled_ovp_fault_status()
376 wled->ctrl_addr + WLED3_CTRL_REG_INT_RT_STS, in wled_ovp_fault_status()
379 dev_err(wled->dev, "Failed to read INT_RT_STS rc=%d\n", rc); in wled_ovp_fault_status()
383 rc = regmap_read(wled->regmap, in wled_ovp_fault_status()
384 wled->ctrl_addr + WLED3_CTRL_REG_FAULT_STATUS, in wled_ovp_fault_status()
387 dev_err(wled->dev, "Failed to read FAULT_STATUS rc=%d\n", rc); in wled_ovp_fault_status()
394 if (wled->version == 4 && (fault_sts & WLED3_CTRL_REG_OVP_FAULT_BIT)) in wled_ovp_fault_status()
397 if (wled->version == 5 && (fault_sts & (WLED3_CTRL_REG_OVP_FAULT_BIT | in wled_ovp_fault_status()
402 dev_dbg(wled->dev, "WLED OVP fault detected, int_rt_sts=0x%x fault_sts=0x%x\n", in wled_ovp_fault_status()
408 static int wled4_ovp_delay(struct wled *wled) in wled4_ovp_delay() argument
413 static int wled5_ovp_delay(struct wled *wled) in wled5_ovp_delay() argument
420 rc = regmap_read(wled->regmap, wled->ctrl_addr + in wled5_ovp_delay()
428 dev_dbg(wled->dev, "delay_time_us: %d\n", delay_us); in wled5_ovp_delay()
435 struct wled *wled = bl_get_data(bl); in wled_update_status() local
439 mutex_lock(&wled->lock); in wled_update_status()
441 rc = wled->wled_set_brightness(wled, brightness); in wled_update_status()
443 dev_err(wled->dev, "wled failed to set brightness rc:%d\n", in wled_update_status()
448 if (wled->version < 5) { in wled_update_status()
449 rc = wled->wled_sync_toggle(wled); in wled_update_status()
451 dev_err(wled->dev, "wled sync failed rc:%d\n", rc); in wled_update_status()
459 rc = wled5_mod_sync_toggle(wled); in wled_update_status()
461 dev_err(wled->dev, "wled mod sync failed rc:%d\n", in wled_update_status()
468 if (!!brightness != !!wled->brightness) { in wled_update_status()
469 rc = wled_module_enable(wled, !!brightness); in wled_update_status()
471 dev_err(wled->dev, "wled enable failed rc:%d\n", rc); in wled_update_status()
476 wled->brightness = brightness; in wled_update_status()
479 mutex_unlock(&wled->lock); in wled_update_status()
484 static int wled4_cabc_config(struct wled *wled, bool enable) in wled4_cabc_config() argument
489 for (i = 0; i < wled->cfg.num_strings; i++) { in wled4_cabc_config()
490 j = wled->cfg.enabled_strings[i]; in wled4_cabc_config()
493 rc = regmap_update_bits(wled->regmap, wled->sink_addr + in wled4_cabc_config()
503 static int wled5_cabc_config(struct wled *wled, bool enable) in wled5_cabc_config() argument
508 if (wled->cabc_disabled) in wled5_cabc_config()
511 reg = enable ? wled->cfg.cabc_sel : 0; in wled5_cabc_config()
512 offset = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_MOD_A_SRC_SEL : in wled5_cabc_config()
515 rc = regmap_update_bits(wled->regmap, wled->sink_addr + offset, in wled5_cabc_config()
522 if (!wled->cfg.cabc_sel) in wled5_cabc_config()
523 wled->cabc_disabled = true; in wled5_cabc_config()
534 struct wled *wled = _wled; in wled_short_irq_handler() local
538 wled->short_count++; in wled_short_irq_handler()
539 mutex_lock(&wled->lock); in wled_short_irq_handler()
540 rc = wled_module_enable(wled, false); in wled_short_irq_handler()
542 dev_err(wled->dev, "wled disable failed rc:%d\n", rc); in wled_short_irq_handler()
547 wled->last_short_event); in wled_short_irq_handler()
549 wled->short_count = 1; in wled_short_irq_handler()
551 if (wled->short_count > WLED_SHORT_CNT_MAX) { in wled_short_irq_handler()
552 dev_err(wled->dev, "Short triggered %d times, disabling WLED forever!\n", in wled_short_irq_handler()
553 wled->short_count); in wled_short_irq_handler()
554 wled->disabled_by_short = true; in wled_short_irq_handler()
558 wled->last_short_event = ktime_get(); in wled_short_irq_handler()
561 rc = wled_module_enable(wled, true); in wled_short_irq_handler()
563 dev_err(wled->dev, "wled enable failed rc:%d\n", rc); in wled_short_irq_handler()
566 mutex_unlock(&wled->lock); in wled_short_irq_handler()
573 static void wled_auto_string_detection(struct wled *wled) in wled_auto_string_detection() argument
581 rc = regmap_read(wled->regmap, wled->sink_addr + in wled_auto_string_detection()
584 dev_err(wled->dev, "Failed to read SINK configuration rc=%d\n", in wled_auto_string_detection()
590 rc = regmap_update_bits(wled->regmap, in wled_auto_string_detection()
591 wled->ctrl_addr + WLED3_CTRL_REG_MOD_EN, in wled_auto_string_detection()
594 dev_err(wled->dev, "Failed to disable WLED module rc=%d\n", rc); in wled_auto_string_detection()
599 rc = wled4_set_brightness(wled, AUTO_DETECT_BRIGHTNESS); in wled_auto_string_detection()
601 dev_err(wled->dev, "Failed to set brightness for auto detection rc=%d\n", in wled_auto_string_detection()
606 if (wled->cfg.cabc) { in wled_auto_string_detection()
607 rc = wled->wled_cabc_config(wled, false); in wled_auto_string_detection()
613 rc = regmap_write(wled->regmap, in wled_auto_string_detection()
614 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, 0); in wled_auto_string_detection()
616 dev_err(wled->dev, "Failed to disable all sinks rc=%d\n", rc); in wled_auto_string_detection()
621 for (i = 0; i < wled->cfg.num_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()
712 rc = regmap_write(wled->regmap, wled->sink_addr + in wled_auto_string_detection()
715 dev_err(wled->dev, "Failed to configure MODULATOR_EN rc=%d\n", in wled_auto_string_detection()
723 rc = wled->wled_cabc_config(wled, true); in wled_auto_string_detection()
728 rc = regmap_write(wled->regmap, in wled_auto_string_detection()
729 wled->ctrl_addr + WLED3_CTRL_REG_FEEDBACK_CONTROL, 0); in wled_auto_string_detection()
731 dev_err(wled->dev, "Failed to restore feedback setting rc=%d\n", in wled_auto_string_detection()
737 rc = wled4_set_brightness(wled, wled->brightness); in wled_auto_string_detection()
739 dev_err(wled->dev, "Failed to set brightness after auto detection rc=%d\n", in wled_auto_string_detection()
744 rc = regmap_update_bits(wled->regmap, in wled_auto_string_detection()
745 wled->ctrl_addr + WLED3_CTRL_REG_MOD_EN, in wled_auto_string_detection()
749 dev_err(wled->dev, "Failed to enable WLED module rc=%d\n", rc); in wled_auto_string_detection()
760 static bool wled4_auto_detection_required(struct wled *wled) in wled4_auto_detection_required() argument
764 if (!wled->cfg.auto_detection_enabled) in wled4_auto_detection_required()
772 if (!wled->auto_detection_ovp_count) { in wled4_auto_detection_required()
773 wled->start_ovp_fault_time = ktime_get(); in wled4_auto_detection_required()
774 wled->auto_detection_ovp_count++; in wled4_auto_detection_required()
777 wled->start_ovp_fault_time); in wled4_auto_detection_required()
779 wled->auto_detection_ovp_count = 0; in wled4_auto_detection_required()
781 wled->auto_detection_ovp_count++; in wled4_auto_detection_required()
783 if (wled->auto_detection_ovp_count >= in wled4_auto_detection_required()
785 wled->auto_detection_ovp_count = 0; in wled4_auto_detection_required()
793 static bool wled5_auto_detection_required(struct wled *wled) in wled5_auto_detection_required() argument
795 if (!wled->cfg.auto_detection_enabled) in wled5_auto_detection_required()
810 static int wled_auto_detection_at_init(struct wled *wled) in wled_auto_detection_at_init() argument
815 if (!wled->cfg.auto_detection_enabled) in wled_auto_detection_at_init()
818 rc = wled_ovp_fault_status(wled, &fault_set); in wled_auto_detection_at_init()
820 dev_err(wled->dev, "Error in getting OVP fault_sts, rc=%d\n", in wled_auto_detection_at_init()
826 mutex_lock(&wled->lock); in wled_auto_detection_at_init()
827 wled_auto_string_detection(wled); in wled_auto_detection_at_init()
828 mutex_unlock(&wled->lock); in wled_auto_detection_at_init()
836 struct wled *wled = _wled; in wled_ovp_irq_handler() local
840 rc = regmap_read(wled->regmap, in wled_ovp_irq_handler()
841 wled->ctrl_addr + WLED3_CTRL_REG_INT_RT_STS, &int_sts); in wled_ovp_irq_handler()
843 dev_err(wled->dev, "Error in reading WLED3_INT_RT_STS rc=%d\n", in wled_ovp_irq_handler()
848 rc = regmap_read(wled->regmap, wled->ctrl_addr + in wled_ovp_irq_handler()
851 dev_err(wled->dev, "Error in reading WLED_FAULT_STATUS rc=%d\n", in wled_ovp_irq_handler()
858 dev_dbg(wled->dev, "WLED OVP fault detected, int_sts=%x fault_sts= %x\n", in wled_ovp_irq_handler()
862 if (wled->wled_auto_detection_required(wled)) { in wled_ovp_irq_handler()
863 mutex_lock(&wled->lock); in wled_ovp_irq_handler()
864 wled_auto_string_detection(wled); in wled_ovp_irq_handler()
865 mutex_unlock(&wled->lock); in wled_ovp_irq_handler()
872 static int wled3_setup(struct wled *wled) in wled3_setup() argument
878 rc = regmap_update_bits(wled->regmap, in wled3_setup()
879 wled->ctrl_addr + WLED3_CTRL_REG_OVP, in wled3_setup()
880 WLED3_CTRL_REG_OVP_MASK, wled->cfg.ovp); in wled3_setup()
884 rc = regmap_update_bits(wled->regmap, in wled3_setup()
885 wled->ctrl_addr + WLED3_CTRL_REG_ILIMIT, in wled3_setup()
887 wled->cfg.boost_i_limit); in wled3_setup()
891 rc = regmap_update_bits(wled->regmap, in wled3_setup()
892 wled->ctrl_addr + WLED3_CTRL_REG_FREQ, in wled3_setup()
894 wled->cfg.switch_freq); in wled3_setup()
898 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled3_setup()
899 j = wled->cfg.enabled_strings[i]; in wled3_setup()
900 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_MOD_EN(j); in wled3_setup()
901 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
907 if (wled->cfg.ext_gen) { in wled3_setup()
908 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_MOD_SRC(j); in wled3_setup()
909 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
916 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_FULL_SCALE_CURR(j); in wled3_setup()
917 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
919 wled->cfg.string_i_limit); in wled3_setup()
923 addr = wled->ctrl_addr + WLED3_SINK_REG_STR_CABC(j); in wled3_setup()
924 rc = regmap_update_bits(wled->regmap, addr, in wled3_setup()
926 wled->cfg.cabc ? in wled3_setup()
934 rc = regmap_update_bits(wled->regmap, in wled3_setup()
935 wled->ctrl_addr + WLED3_SINK_REG_CURR_SINK, in wled3_setup()
955 static int wled4_setup(struct wled *wled) in wled4_setup() argument
962 rc = regmap_update_bits(wled->regmap, in wled4_setup()
963 wled->ctrl_addr + WLED3_CTRL_REG_OVP, in wled4_setup()
964 WLED3_CTRL_REG_OVP_MASK, wled->cfg.ovp); in wled4_setup()
968 rc = regmap_update_bits(wled->regmap, in wled4_setup()
969 wled->ctrl_addr + WLED3_CTRL_REG_ILIMIT, in wled4_setup()
971 wled->cfg.boost_i_limit); in wled4_setup()
975 rc = regmap_update_bits(wled->regmap, in wled4_setup()
976 wled->ctrl_addr + WLED3_CTRL_REG_FREQ, in wled4_setup()
978 wled->cfg.switch_freq); in wled4_setup()
982 if (wled->cfg.external_pfet) { in wled4_setup()
984 rc = regmap_write(wled->regmap, wled->ctrl_addr + in wled4_setup()
990 rc = regmap_write(wled->regmap, in wled4_setup()
991 wled->ctrl_addr + WLED4_CTRL_REG_TEST1, in wled4_setup()
997 rc = regmap_read(wled->regmap, wled->sink_addr + in wled4_setup()
1002 for (i = 0; i < wled->cfg.num_strings; i++) { in wled4_setup()
1003 j = wled->cfg.enabled_strings[i]; in wled4_setup()
1009 rc = wled_auto_detection_at_init(wled); in wled4_setup()
1013 rc = regmap_update_bits(wled->regmap, in wled4_setup()
1014 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, in wled4_setup()
1019 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled4_setup()
1026 for (i = 0; i < wled->cfg.num_strings; i++) { in wled4_setup()
1027 j = wled->cfg.enabled_strings[i]; in wled4_setup()
1029 addr = wled->sink_addr + in wled4_setup()
1031 rc = regmap_update_bits(wled->regmap, addr, in wled4_setup()
1037 addr = wled->sink_addr + in wled4_setup()
1039 rc = regmap_update_bits(wled->regmap, addr, in wled4_setup()
1041 wled->cfg.string_i_limit); in wled4_setup()
1046 rc = wled4_cabc_config(wled, wled->cfg.cabc); in wled4_setup()
1050 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled4_setup()
1057 rc = regmap_update_bits(wled->regmap, in wled4_setup()
1058 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, in wled4_setup()
1063 rc = wled->wled_sync_toggle(wled); in wled4_setup()
1065 dev_err(wled->dev, "Failed to toggle sync reg rc:%d\n", rc); in wled4_setup()
1069 rc = wled_auto_detection_at_init(wled); in wled4_setup()
1085 static int wled5_setup(struct wled *wled) in wled5_setup() argument
1092 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1093 wled->ctrl_addr + WLED3_CTRL_REG_OVP, in wled5_setup()
1094 WLED5_CTRL_REG_OVP_MASK, wled->cfg.ovp); in wled5_setup()
1098 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1099 wled->ctrl_addr + WLED3_CTRL_REG_ILIMIT, in wled5_setup()
1101 wled->cfg.boost_i_limit); in wled5_setup()
1105 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1106 wled->ctrl_addr + WLED3_CTRL_REG_FREQ, in wled5_setup()
1108 wled->cfg.switch_freq); in wled5_setup()
1113 for (i = 0; i < wled->cfg.num_strings; ++i) { in wled5_setup()
1114 j = wled->cfg.enabled_strings[i]; in wled5_setup()
1115 addr = wled->sink_addr + in wled5_setup()
1117 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1119 wled->cfg.string_i_limit); in wled5_setup()
1123 addr = wled->sink_addr + WLED5_SINK_REG_STR_SRC_SEL(j); in wled5_setup()
1124 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1126 wled->cfg.mod_sel == MOD_A ? in wled5_setup()
1134 rc = wled5_cabc_config(wled, wled->cfg.cabc_sel ? true : false); in wled5_setup()
1139 addr = wled->sink_addr + WLED5_SINK_REG_MOD_A_EN; in wled5_setup()
1140 val = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_MOD_EN_MASK : 0; in wled5_setup()
1141 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1146 addr = wled->sink_addr + WLED5_SINK_REG_MOD_B_EN; in wled5_setup()
1147 val = (wled->cfg.mod_sel == MOD_B) ? WLED5_SINK_REG_MOD_EN_MASK : 0; in wled5_setup()
1148 rc = regmap_update_bits(wled->regmap, addr, in wled5_setup()
1153 offset = (wled->cfg.mod_sel == MOD_A) ? in wled5_setup()
1157 addr = wled->sink_addr + offset; in wled5_setup()
1158 val = (wled->max_brightness == WLED5_SINK_REG_BRIGHT_MAX_15B) ? in wled5_setup()
1161 rc = regmap_write(wled->regmap, addr, val); in wled5_setup()
1165 rc = regmap_update_bits(wled->regmap, in wled5_setup()
1166 wled->sink_addr + WLED4_SINK_REG_CURR_SINK, in wled5_setup()
1172 rc = wled->wled_sync_toggle(wled); in wled5_setup()
1178 rc = wled_auto_detection_at_init(wled); in wled5_setup()
1317 static int wled_configure(struct wled *wled) in wled_configure() argument
1319 struct wled_config *cfg = &wled->cfg; in wled_configure()
1320 struct device *dev = wled->dev; in wled_configure()
1430 dev_err(wled->dev, "invalid IO resources\n"); in wled_configure()
1433 wled->ctrl_addr = be32_to_cpu(*prop_addr); in wled_configure()
1435 rc = of_property_read_string(dev->of_node, "label", &wled->name); in wled_configure()
1437 wled->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node); in wled_configure()
1439 switch (wled->version) { in wled_configure()
1444 wled->wled_set_brightness = wled3_set_brightness; in wled_configure()
1445 wled->wled_sync_toggle = wled3_sync_toggle; in wled_configure()
1446 wled->max_string_count = 3; in wled_configure()
1447 wled->sink_addr = wled->ctrl_addr; in wled_configure()
1454 wled->wled_set_brightness = wled4_set_brightness; in wled_configure()
1455 wled->wled_sync_toggle = wled3_sync_toggle; in wled_configure()
1456 wled->wled_cabc_config = wled4_cabc_config; in wled_configure()
1457 wled->wled_ovp_delay = wled4_ovp_delay; in wled_configure()
1458 wled->wled_auto_detection_required = in wled_configure()
1460 wled->max_string_count = 4; in wled_configure()
1464 dev_err(wled->dev, "invalid IO resources\n"); in wled_configure()
1467 wled->sink_addr = be32_to_cpu(*prop_addr); in wled_configure()
1474 wled->wled_set_brightness = wled5_set_brightness; in wled_configure()
1475 wled->wled_sync_toggle = wled3_sync_toggle; in wled_configure()
1476 wled->wled_cabc_config = wled5_cabc_config; in wled_configure()
1477 wled->wled_ovp_delay = wled5_ovp_delay; in wled_configure()
1478 wled->wled_auto_detection_required = in wled_configure()
1480 wled->max_string_count = 4; in wled_configure()
1484 dev_err(wled->dev, "invalid IO resources\n"); in wled_configure()
1487 wled->sink_addr = be32_to_cpu(*prop_addr); in wled_configure()
1491 dev_err(wled->dev, "Invalid WLED version\n"); in wled_configure()
1534 wled->cfg.enabled_strings, in wled_configure()
1540 static int wled_configure_short_irq(struct wled *wled, in wled_configure_short_irq() argument
1545 if (!wled->has_short_detect) in wled_configure_short_irq()
1548 rc = regmap_update_bits(wled->regmap, wled->ctrl_addr + in wled_configure_short_irq()
1555 wled->short_irq = platform_get_irq_byname(pdev, "short"); in wled_configure_short_irq()
1556 if (wled->short_irq < 0) { in wled_configure_short_irq()
1561 rc = devm_request_threaded_irq(wled->dev, wled->short_irq, in wled_configure_short_irq()
1564 "wled_short_irq", wled); in wled_configure_short_irq()
1566 dev_err(wled->dev, "Unable to request short_irq (err:%d)\n", in wled_configure_short_irq()
1572 static int wled_configure_ovp_irq(struct wled *wled, in wled_configure_ovp_irq() argument
1578 wled->ovp_irq = platform_get_irq_byname(pdev, "ovp"); in wled_configure_ovp_irq()
1579 if (wled->ovp_irq < 0) { in wled_configure_ovp_irq()
1584 rc = devm_request_threaded_irq(wled->dev, wled->ovp_irq, NULL, in wled_configure_ovp_irq()
1586 "wled_ovp_irq", wled); in wled_configure_ovp_irq()
1588 dev_err(wled->dev, "Unable to request ovp_irq (err:%d)\n", in wled_configure_ovp_irq()
1590 wled->ovp_irq = 0; in wled_configure_ovp_irq()
1594 rc = regmap_read(wled->regmap, wled->ctrl_addr + in wled_configure_ovp_irq()
1601 disable_irq(wled->ovp_irq); in wled_configure_ovp_irq()
1614 struct wled *wled; in wled_probe() local
1625 wled = devm_kzalloc(&pdev->dev, sizeof(*wled), GFP_KERNEL); in wled_probe()
1626 if (!wled) in wled_probe()
1629 wled->regmap = regmap; in wled_probe()
1630 wled->dev = &pdev->dev; in wled_probe()
1632 wled->version = (uintptr_t)of_device_get_match_data(&pdev->dev); in wled_probe()
1633 if (!wled->version) { in wled_probe()
1638 mutex_init(&wled->lock); in wled_probe()
1639 rc = wled_configure(wled); in wled_probe()
1645 wled->max_brightness = val; in wled_probe()
1647 switch (wled->version) { in wled_probe()
1649 wled->cfg.auto_detection_enabled = false; in wled_probe()
1650 rc = wled3_setup(wled); in wled_probe()
1658 wled->has_short_detect = true; in wled_probe()
1659 rc = wled4_setup(wled); in wled_probe()
1667 wled->has_short_detect = true; in wled_probe()
1668 if (wled->cfg.cabc_sel) in wled_probe()
1669 wled->max_brightness = WLED5_SINK_REG_BRIGHT_MAX_12B; in wled_probe()
1671 rc = wled5_setup(wled); in wled_probe()
1679 dev_err(wled->dev, "Invalid WLED version\n"); in wled_probe()
1683 INIT_DELAYED_WORK(&wled->ovp_work, wled_ovp_work); in wled_probe()
1685 rc = wled_configure_short_irq(wled, pdev); in wled_probe()
1689 rc = wled_configure_ovp_irq(wled, pdev); in wled_probe()
1699 props.max_brightness = wled->max_brightness; in wled_probe()
1700 bl = devm_backlight_device_register(&pdev->dev, wled->name, in wled_probe()
1701 &pdev->dev, wled, in wled_probe()
1708 struct wled *wled = platform_get_drvdata(pdev); in wled_remove() local
1710 mutex_destroy(&wled->lock); in wled_remove()
1711 cancel_delayed_work_sync(&wled->ovp_work); in wled_remove()
1712 disable_irq(wled->short_irq); in wled_remove()
1713 disable_irq(wled->ovp_irq); in wled_remove()
1719 { .compatible = "qcom,pm8941-wled", .data = (void *)3 },
1720 { .compatible = "qcom,pmi8994-wled", .data = (void *)4 },
1721 { .compatible = "qcom,pmi8998-wled", .data = (void *)4 },
1722 { .compatible = "qcom,pm660l-wled", .data = (void *)4 },
1723 { .compatible = "qcom,pm8150l-wled", .data = (void *)5 },
1732 .name = "qcom,wled",
1739 MODULE_DESCRIPTION("Qualcomm WLED driver");