• Home
  • Raw
  • Download

Lines Matching +full:led +full:- +full:0

2  * LED Flash class driver for the flash cell of max77693 mfd.
14 #include <linux/led-class-flash.h>
16 #include <linux/mfd/max77693-common.h>
17 #include <linux/mfd/max77693-private.h>
23 #include <media/v4l2-flash-led-class.h>
25 #define MODE_OFF 0
35 #define FLED1_IOUT (1 << 0)
62 /* corresponding LED Flash class device */
83 /* sub led data */
99 /* bitmask of FLED outputs use state (bit 0. - FLED1, bit 1. - FLED2) */
112 return (ua - FLASH_IOUT_MIN) / FLASH_IOUT_STEP; in max77693_led_iout_to_reg()
117 return (us - FLASH_TIMEOUT_MIN) / FLASH_TIMEOUT_STEP; in max77693_flash_timeout_to_reg()
130 sub_leds[sub_led->fled_id]); in sub_led_to_led()
135 return ((mv - MAX_FLASH1_VSYS_MIN) / MAX_FLASH1_VSYS_STEP) << 2; in max77693_led_vsys_to_reg()
140 return (mv - FLASH_VOUT_MIN) / FLASH_VOUT_STEP + FLASH_VOUT_RMIN; in max77693_led_vout_to_reg()
143 static inline bool max77693_fled_used(struct max77693_led_device *led, in max77693_fled_used() argument
148 return led->fled_mask & fled_bit; in max77693_fled_used()
151 static int max77693_set_mode_reg(struct max77693_led_device *led, u8 mode) in max77693_set_mode_reg() argument
153 struct regmap *rmap = led->regmap; in max77693_set_mode_reg()
154 int ret, v = 0, i; in max77693_set_mode_reg()
166 * camera sensors use torch led to fathom ambient light in max77693_set_mode_reg()
175 ret = regmap_write(rmap, MAX77693_LED_REG_FLASH_EN, 0); in max77693_set_mode_reg()
176 if (ret < 0) in max77693_set_mode_reg()
183 static int max77693_add_mode(struct max77693_led_device *led, u8 mode) in max77693_add_mode() argument
188 if (led->iout_joint) in max77693_add_mode()
199 led->mode_flags &= (~MODE_TORCH(i) & ~MODE_FLASH(i)); in max77693_add_mode()
201 new_mode_flags = mode | led->mode_flags; in max77693_add_mode()
202 new_mode_flags &= led->allowed_modes; in max77693_add_mode()
204 if (new_mode_flags ^ led->mode_flags) in max77693_add_mode()
205 led->mode_flags = new_mode_flags; in max77693_add_mode()
207 return 0; in max77693_add_mode()
209 ret = max77693_set_mode_reg(led, led->mode_flags); in max77693_add_mode()
210 if (ret < 0) in max77693_add_mode()
218 led->mode_flags &= ~mode; in max77693_add_mode()
223 static int max77693_clear_mode(struct max77693_led_device *led, in max77693_clear_mode() argument
226 if (led->iout_joint) in max77693_clear_mode()
230 led->mode_flags &= ~mode; in max77693_clear_mode()
232 return max77693_set_mode_reg(led, led->mode_flags); in max77693_clear_mode()
235 static void max77693_add_allowed_modes(struct max77693_led_device *led, in max77693_add_allowed_modes() argument
239 led->allowed_modes |= (MODE_FLASH(fled_id) | in max77693_add_allowed_modes()
242 led->allowed_modes |= MODE_TORCH(fled_id); in max77693_add_allowed_modes()
245 static void max77693_distribute_currents(struct max77693_led_device *led, in max77693_distribute_currents() argument
249 if (!led->iout_joint) { in max77693_distribute_currents()
251 max77693_add_allowed_modes(led, fled_id, mode); in max77693_distribute_currents()
256 iout[FLED2] = micro_amp - iout[FLED1]; in max77693_distribute_currents()
259 led->allowed_modes &= ~MODE_FLASH_MASK; in max77693_distribute_currents()
261 led->allowed_modes &= ~MODE_TORCH_MASK; in max77693_distribute_currents()
263 max77693_add_allowed_modes(led, FLED1, mode); in max77693_distribute_currents()
266 max77693_add_allowed_modes(led, FLED2, mode); in max77693_distribute_currents()
269 static int max77693_set_torch_current(struct max77693_led_device *led, in max77693_set_torch_current() argument
272 struct regmap *rmap = led->regmap; in max77693_set_torch_current()
273 u8 iout1_reg = 0, iout2_reg = 0; in max77693_set_torch_current()
276 max77693_distribute_currents(led, fled_id, TORCH, micro_amp, in max77693_set_torch_current()
277 led->iout_torch_max, iout); in max77693_set_torch_current()
279 if (fled_id == FLED1 || led->iout_joint) { in max77693_set_torch_current()
281 led->torch_iout_reg &= TORCH_IOUT_MASK(TORCH_IOUT2_SHIFT); in max77693_set_torch_current()
283 if (fled_id == FLED2 || led->iout_joint) { in max77693_set_torch_current()
285 led->torch_iout_reg &= TORCH_IOUT_MASK(TORCH_IOUT1_SHIFT); in max77693_set_torch_current()
288 led->torch_iout_reg |= ((iout1_reg << TORCH_IOUT1_SHIFT) | in max77693_set_torch_current()
292 led->torch_iout_reg); in max77693_set_torch_current()
295 static int max77693_set_flash_current(struct max77693_led_device *led, in max77693_set_flash_current() argument
299 struct regmap *rmap = led->regmap; in max77693_set_flash_current()
302 int ret = -EINVAL; in max77693_set_flash_current()
304 max77693_distribute_currents(led, fled_id, FLASH, micro_amp, in max77693_set_flash_current()
305 led->iout_flash_max, iout); in max77693_set_flash_current()
307 if (fled_id == FLED1 || led->iout_joint) { in max77693_set_flash_current()
311 if (ret < 0) in max77693_set_flash_current()
314 if (fled_id == FLED2 || led->iout_joint) { in max77693_set_flash_current()
323 static int max77693_set_timeout(struct max77693_led_device *led, u32 microsec) in max77693_set_timeout() argument
325 struct regmap *rmap = led->regmap; in max77693_set_timeout()
332 if (ret < 0) in max77693_set_timeout()
335 led->current_flash_timeout = microsec; in max77693_set_timeout()
337 return 0; in max77693_set_timeout()
340 static int max77693_get_strobe_status(struct max77693_led_device *led, in max77693_get_strobe_status() argument
343 struct regmap *rmap = led->regmap; in max77693_get_strobe_status()
348 if (ret < 0) in max77693_get_strobe_status()
358 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_get_flash_faults() local
359 struct regmap *rmap = led->regmap; in max77693_get_flash_faults()
364 sub_led->flash_faults = 0; in max77693_get_flash_faults()
366 if (led->iout_joint) { in max77693_get_flash_faults()
371 fault_open_mask = (sub_led->fled_id == FLED1) ? in max77693_get_flash_faults()
374 fault_short_mask = (sub_led->fled_id == FLED1) ? in max77693_get_flash_faults()
380 if (ret < 0) in max77693_get_flash_faults()
384 sub_led->flash_faults |= LED_FAULT_OVER_VOLTAGE; in max77693_get_flash_faults()
386 sub_led->flash_faults |= LED_FAULT_SHORT_CIRCUIT; in max77693_get_flash_faults()
388 sub_led->flash_faults |= LED_FAULT_OVER_CURRENT; in max77693_get_flash_faults()
390 return 0; in max77693_get_flash_faults()
393 static int max77693_setup(struct max77693_led_device *led, in max77693_setup() argument
396 struct regmap *rmap = led->regmap; in max77693_setup()
406 if (led->iout_joint) { in max77693_setup()
409 max_flash_curr[FLED1] = led_cfg->iout_flash_max[FLED1] + in max77693_setup()
410 led_cfg->iout_flash_max[FLED2]; in max77693_setup()
412 first_led = max77693_fled_used(led, FLED1) ? FLED1 : FLED2; in max77693_setup()
413 last_led = max77693_fled_used(led, FLED2) ? FLED2 : FLED1; in max77693_setup()
414 max_flash_curr[FLED1] = led_cfg->iout_flash_max[FLED1]; in max77693_setup()
415 max_flash_curr[FLED2] = led_cfg->iout_flash_max[FLED2]; in max77693_setup()
419 ret = max77693_set_flash_current(led, i, in max77693_setup()
421 if (ret < 0) in max77693_setup()
427 if (ret < 0) in max77693_setup()
430 if (led_cfg->low_vsys > 0) in max77693_setup()
431 v = max77693_led_vsys_to_reg(led_cfg->low_vsys) | in max77693_setup()
434 v = 0; in max77693_setup()
437 if (ret < 0) in max77693_setup()
439 ret = regmap_write(rmap, MAX77693_LED_REG_MAX_FLASH2, 0); in max77693_setup()
440 if (ret < 0) in max77693_setup()
443 if (led_cfg->boost_mode == MAX77693_LED_BOOST_FIXED) in max77693_setup()
446 v = led_cfg->boost_mode | led_cfg->boost_mode << 1; in max77693_setup()
448 if (max77693_fled_used(led, FLED1) && max77693_fled_used(led, FLED2)) in max77693_setup()
452 if (ret < 0) in max77693_setup()
455 v = max77693_led_vout_to_reg(led_cfg->boost_vout); in max77693_setup()
457 if (ret < 0) in max77693_setup()
460 return max77693_set_mode_reg(led, MODE_OFF); in max77693_setup()
463 /* LED subsystem callbacks */
469 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_brightness_set() local
470 int fled_id = sub_led->fled_id, ret; in max77693_led_brightness_set()
472 mutex_lock(&led->lock); in max77693_led_brightness_set()
474 if (value == 0) { in max77693_led_brightness_set()
475 ret = max77693_clear_mode(led, MODE_TORCH(fled_id)); in max77693_led_brightness_set()
476 if (ret < 0) in max77693_led_brightness_set()
477 dev_dbg(&led->pdev->dev, in max77693_led_brightness_set()
483 ret = max77693_set_torch_current(led, fled_id, value * TORCH_IOUT_STEP); in max77693_led_brightness_set()
484 if (ret < 0) { in max77693_led_brightness_set()
485 dev_dbg(&led->pdev->dev, in max77693_led_brightness_set()
491 ret = max77693_add_mode(led, MODE_TORCH(fled_id)); in max77693_led_brightness_set()
492 if (ret < 0) in max77693_led_brightness_set()
493 dev_dbg(&led->pdev->dev, in max77693_led_brightness_set()
497 mutex_unlock(&led->lock); in max77693_led_brightness_set()
507 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_brightness_set() local
510 mutex_lock(&led->lock); in max77693_led_flash_brightness_set()
511 ret = max77693_set_flash_current(led, sub_led->fled_id, brightness); in max77693_led_flash_brightness_set()
512 mutex_unlock(&led->lock); in max77693_led_flash_brightness_set()
522 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_strobe_set() local
523 int fled_id = sub_led->fled_id; in max77693_led_flash_strobe_set()
526 mutex_lock(&led->lock); in max77693_led_flash_strobe_set()
529 ret = max77693_clear_mode(led, MODE_FLASH(fled_id)); in max77693_led_flash_strobe_set()
533 if (sub_led->flash_timeout != led->current_flash_timeout) { in max77693_led_flash_strobe_set()
534 ret = max77693_set_timeout(led, sub_led->flash_timeout); in max77693_led_flash_strobe_set()
535 if (ret < 0) in max77693_led_flash_strobe_set()
539 led->strobing_sub_led_id = fled_id; in max77693_led_flash_strobe_set()
541 ret = max77693_add_mode(led, MODE_FLASH(fled_id)); in max77693_led_flash_strobe_set()
542 if (ret < 0) in max77693_led_flash_strobe_set()
548 mutex_unlock(&led->lock); in max77693_led_flash_strobe_set()
558 *fault = sub_led->flash_faults; in max77693_led_flash_fault_get()
560 return 0; in max77693_led_flash_fault_get()
568 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_strobe_get() local
572 return -EINVAL; in max77693_led_flash_strobe_get()
574 mutex_lock(&led->lock); in max77693_led_flash_strobe_get()
576 ret = max77693_get_strobe_status(led, state); in max77693_led_flash_strobe_get()
578 *state = !!(*state && (led->strobing_sub_led_id == sub_led->fled_id)); in max77693_led_flash_strobe_get()
580 mutex_unlock(&led->lock); in max77693_led_flash_strobe_get()
590 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_timeout_set() local
592 mutex_lock(&led->lock); in max77693_led_flash_timeout_set()
593 sub_led->flash_timeout = timeout; in max77693_led_flash_timeout_set()
594 mutex_unlock(&led->lock); in max77693_led_flash_timeout_set()
596 return 0; in max77693_led_flash_timeout_set()
599 static int max77693_led_parse_dt(struct max77693_led_device *led, in max77693_led_parse_dt() argument
603 struct device *dev = &led->pdev->dev; in max77693_led_parse_dt()
604 struct max77693_sub_led *sub_leds = led->sub_leds; in max77693_led_parse_dt()
605 struct device_node *node = dev->of_node, *child_node; in max77693_led_parse_dt()
610 of_property_read_u32(node, "maxim,boost-mode", &cfg->boost_mode); in max77693_led_parse_dt()
611 of_property_read_u32(node, "maxim,boost-mvout", &cfg->boost_vout); in max77693_led_parse_dt()
612 of_property_read_u32(node, "maxim,mvsys-min", &cfg->low_vsys); in max77693_led_parse_dt()
615 prop = of_find_property(child_node, "led-sources", NULL); in max77693_led_parse_dt()
619 for (i = 0; i < ARRAY_SIZE(led_sources); ++i) { in max77693_led_parse_dt()
627 "led-sources DT property missing\n"); in max77693_led_parse_dt()
629 return -EINVAL; in max77693_led_parse_dt()
634 led->fled_mask = FLED1_IOUT | FLED2_IOUT; in max77693_led_parse_dt()
635 } else if (led_sources[0] == FLED1) { in max77693_led_parse_dt()
637 led->fled_mask |= FLED1_IOUT; in max77693_led_parse_dt()
638 } else if (led_sources[0] == FLED2) { in max77693_led_parse_dt()
640 led->fled_mask |= FLED2_IOUT; in max77693_led_parse_dt()
643 "Wrong led-sources DT property value.\n"); in max77693_led_parse_dt()
645 return -EINVAL; in max77693_led_parse_dt()
650 "Conflicting \"led-sources\" DT properties\n"); in max77693_led_parse_dt()
652 return -EINVAL; in max77693_led_parse_dt()
658 cfg->label[fled_id] = in max77693_led_parse_dt()
660 child_node->name; in max77693_led_parse_dt()
662 ret = of_property_read_u32(child_node, "led-max-microamp", in max77693_led_parse_dt()
663 &cfg->iout_torch_max[fled_id]); in max77693_led_parse_dt()
664 if (ret < 0) { in max77693_led_parse_dt()
665 cfg->iout_torch_max[fled_id] = TORCH_IOUT_MIN; in max77693_led_parse_dt()
666 dev_warn(dev, "led-max-microamp DT property missing\n"); in max77693_led_parse_dt()
669 ret = of_property_read_u32(child_node, "flash-max-microamp", in max77693_led_parse_dt()
670 &cfg->iout_flash_max[fled_id]); in max77693_led_parse_dt()
671 if (ret < 0) { in max77693_led_parse_dt()
672 cfg->iout_flash_max[fled_id] = FLASH_IOUT_MIN; in max77693_led_parse_dt()
674 "flash-max-microamp DT property missing\n"); in max77693_led_parse_dt()
677 ret = of_property_read_u32(child_node, "flash-max-timeout-us", in max77693_led_parse_dt()
678 &cfg->flash_timeout_max[fled_id]); in max77693_led_parse_dt()
679 if (ret < 0) { in max77693_led_parse_dt()
680 cfg->flash_timeout_max[fled_id] = FLASH_TIMEOUT_MIN; in max77693_led_parse_dt()
682 "flash-max-timeout-us DT property missing\n"); in max77693_led_parse_dt()
685 if (++cfg->num_leds == 2 || in max77693_led_parse_dt()
686 (max77693_fled_used(led, FLED1) && in max77693_led_parse_dt()
687 max77693_fled_used(led, FLED2))) { in max77693_led_parse_dt()
693 if (cfg->num_leds == 0) { in max77693_led_parse_dt()
694 dev_err(dev, "No DT child node found for connected LED(s).\n"); in max77693_led_parse_dt()
695 return -EINVAL; in max77693_led_parse_dt()
698 return 0; in max77693_led_parse_dt()
705 *v = (*v - min) / step * step + min; in clamp_align()
708 static void max77693_align_iout_current(struct max77693_led_device *led, in max77693_align_iout_current() argument
713 if (led->iout_joint) { in max77693_align_iout_current()
719 iout[FLED2] = 0; in max77693_align_iout_current()
725 if (max77693_fled_used(led, i)) in max77693_align_iout_current()
728 iout[i] = 0; in max77693_align_iout_current()
731 static void max77693_led_validate_configuration(struct max77693_led_device *led, in max77693_led_validate_configuration() argument
734 u32 flash_iout_max = cfg->boost_mode ? FLASH_IOUT_MAX_2LEDS : in max77693_led_validate_configuration()
738 if (cfg->num_leds == 1 && in max77693_led_validate_configuration()
739 max77693_fled_used(led, FLED1) && max77693_fled_used(led, FLED2)) in max77693_led_validate_configuration()
740 led->iout_joint = true; in max77693_led_validate_configuration()
742 cfg->boost_mode = clamp_val(cfg->boost_mode, MAX77693_LED_BOOST_NONE, in max77693_led_validate_configuration()
746 if ((cfg->boost_mode == MAX77693_LED_BOOST_NONE) && led->iout_joint) in max77693_led_validate_configuration()
747 cfg->boost_mode = MAX77693_LED_BOOST_FIXED; in max77693_led_validate_configuration()
749 max77693_align_iout_current(led, cfg->iout_torch_max, in max77693_led_validate_configuration()
752 max77693_align_iout_current(led, cfg->iout_flash_max, in max77693_led_validate_configuration()
755 for (i = 0; i < ARRAY_SIZE(cfg->flash_timeout_max); ++i) in max77693_led_validate_configuration()
756 clamp_align(&cfg->flash_timeout_max[i], FLASH_TIMEOUT_MIN, in max77693_led_validate_configuration()
759 clamp_align(&cfg->boost_vout, FLASH_VOUT_MIN, FLASH_VOUT_MAX, in max77693_led_validate_configuration()
762 if (cfg->low_vsys) in max77693_led_validate_configuration()
763 clamp_align(&cfg->low_vsys, MAX_FLASH1_VSYS_MIN, in max77693_led_validate_configuration()
767 static int max77693_led_get_configuration(struct max77693_led_device *led, in max77693_led_get_configuration() argument
773 ret = max77693_led_parse_dt(led, cfg, sub_nodes); in max77693_led_get_configuration()
774 if (ret < 0) in max77693_led_get_configuration()
777 max77693_led_validate_configuration(led, cfg); in max77693_led_get_configuration()
779 memcpy(led->iout_torch_max, cfg->iout_torch_max, in max77693_led_get_configuration()
780 sizeof(led->iout_torch_max)); in max77693_led_get_configuration()
781 memcpy(led->iout_flash_max, cfg->iout_flash_max, in max77693_led_get_configuration()
782 sizeof(led->iout_flash_max)); in max77693_led_get_configuration()
784 return 0; in max77693_led_get_configuration()
798 struct led_classdev_flash *fled_cdev = &sub_led->fled_cdev; in max77693_init_flash_settings()
799 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_init_flash_settings() local
800 int fled_id = sub_led->fled_id; in max77693_init_flash_settings()
804 setting = &fled_cdev->brightness; in max77693_init_flash_settings()
805 setting->min = FLASH_IOUT_MIN; in max77693_init_flash_settings()
806 setting->max = led->iout_joint ? in max77693_init_flash_settings()
807 led_cfg->iout_flash_max[FLED1] + in max77693_init_flash_settings()
808 led_cfg->iout_flash_max[FLED2] : in max77693_init_flash_settings()
809 led_cfg->iout_flash_max[fled_id]; in max77693_init_flash_settings()
810 setting->step = FLASH_IOUT_STEP; in max77693_init_flash_settings()
811 setting->val = setting->max; in max77693_init_flash_settings()
814 setting = &fled_cdev->timeout; in max77693_init_flash_settings()
815 setting->min = FLASH_TIMEOUT_MIN; in max77693_init_flash_settings()
816 setting->max = led_cfg->flash_timeout_max[fled_id]; in max77693_init_flash_settings()
817 setting->step = FLASH_TIMEOUT_STEP; in max77693_init_flash_settings()
818 setting->val = setting->max; in max77693_init_flash_settings()
828 flcdev_to_sub_led(v4l2_flash->fled_cdev); in max77693_led_external_strobe_set()
829 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_external_strobe_set() local
830 int fled_id = sub_led->fled_id; in max77693_led_external_strobe_set()
833 mutex_lock(&led->lock); in max77693_led_external_strobe_set()
836 ret = max77693_add_mode(led, MODE_FLASH_EXTERNAL(fled_id)); in max77693_led_external_strobe_set()
838 ret = max77693_clear_mode(led, MODE_FLASH_EXTERNAL(fled_id)); in max77693_led_external_strobe_set()
840 mutex_unlock(&led->lock); in max77693_led_external_strobe_set()
849 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_init_v4l2_flash_config() local
850 struct device *dev = &led->pdev->dev; in max77693_init_v4l2_flash_config()
851 struct max77693_dev *iodev = dev_get_drvdata(dev->parent); in max77693_init_v4l2_flash_config()
852 struct i2c_client *i2c = iodev->i2c; in max77693_init_v4l2_flash_config()
855 snprintf(v4l2_sd_cfg->dev_name, sizeof(v4l2_sd_cfg->dev_name), in max77693_init_v4l2_flash_config()
856 "%s %d-%04x", sub_led->fled_cdev.led_cdev.name, in max77693_init_v4l2_flash_config()
857 i2c_adapter_id(i2c->adapter), i2c->addr); in max77693_init_v4l2_flash_config()
859 s = &v4l2_sd_cfg->intensity; in max77693_init_v4l2_flash_config()
860 s->min = TORCH_IOUT_MIN; in max77693_init_v4l2_flash_config()
861 s->max = sub_led->fled_cdev.led_cdev.max_brightness * TORCH_IOUT_STEP; in max77693_init_v4l2_flash_config()
862 s->step = TORCH_IOUT_STEP; in max77693_init_v4l2_flash_config()
863 s->val = s->max; in max77693_init_v4l2_flash_config()
866 v4l2_sd_cfg->flash_faults = LED_FAULT_OVER_VOLTAGE | in max77693_init_v4l2_flash_config()
870 v4l2_sd_cfg->has_external_strobe = true; in max77693_init_v4l2_flash_config()
889 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_init_fled_cdev() local
890 int fled_id = sub_led->fled_id; in max77693_init_fled_cdev()
894 /* Initialize LED Flash class device */ in max77693_init_fled_cdev()
895 fled_cdev = &sub_led->fled_cdev; in max77693_init_fled_cdev()
896 fled_cdev->ops = &flash_ops; in max77693_init_fled_cdev()
897 led_cdev = &fled_cdev->led_cdev; in max77693_init_fled_cdev()
899 led_cdev->name = led_cfg->label[fled_id]; in max77693_init_fled_cdev()
901 led_cdev->brightness_set_blocking = max77693_led_brightness_set; in max77693_init_fled_cdev()
902 led_cdev->max_brightness = (led->iout_joint ? in max77693_init_fled_cdev()
903 led_cfg->iout_torch_max[FLED1] + in max77693_init_fled_cdev()
904 led_cfg->iout_torch_max[FLED2] : in max77693_init_fled_cdev()
905 led_cfg->iout_torch_max[fled_id]) / in max77693_init_fled_cdev()
907 led_cdev->flags |= LED_DEV_CAP_FLASH; in max77693_init_fled_cdev()
912 sub_led->flash_timeout = fled_cdev->timeout.val; in max77693_init_fled_cdev()
919 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_register_led() local
920 struct led_classdev_flash *fled_cdev = &sub_led->fled_cdev; in max77693_register_led()
921 struct device *dev = &led->pdev->dev; in max77693_register_led()
925 /* Register in the LED subsystem */ in max77693_register_led()
927 if (ret < 0) in max77693_register_led()
933 sub_led->v4l2_flash = v4l2_flash_init(dev, of_fwnode_handle(sub_node), in max77693_register_led()
936 if (IS_ERR(sub_led->v4l2_flash)) { in max77693_register_led()
937 ret = PTR_ERR(sub_led->v4l2_flash); in max77693_register_led()
941 return 0; in max77693_register_led()
950 struct device *dev = &pdev->dev; in max77693_led_probe()
951 struct max77693_dev *iodev = dev_get_drvdata(dev->parent); in max77693_led_probe()
952 struct max77693_led_device *led; in max77693_led_probe() local
958 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); in max77693_led_probe()
959 if (!led) in max77693_led_probe()
960 return -ENOMEM; in max77693_led_probe()
962 led->pdev = pdev; in max77693_led_probe()
963 led->regmap = iodev->regmap; in max77693_led_probe()
964 led->allowed_modes = MODE_FLASH_MASK; in max77693_led_probe()
965 sub_leds = led->sub_leds; in max77693_led_probe()
967 platform_set_drvdata(pdev, led); in max77693_led_probe()
968 ret = max77693_led_get_configuration(led, &led_cfg, sub_nodes); in max77693_led_probe()
969 if (ret < 0) in max77693_led_probe()
972 ret = max77693_setup(led, &led_cfg); in max77693_led_probe()
973 if (ret < 0) in max77693_led_probe()
976 mutex_init(&led->lock); in max77693_led_probe()
979 led->iout_joint || max77693_fled_used(led, FLED1); in max77693_led_probe()
981 !led->iout_joint && max77693_fled_used(led, FLED2); in max77693_led_probe()
987 /* Initialize LED Flash class device */ in max77693_led_probe()
991 * Register LED Flash class device and corresponding in max77693_led_probe()
996 if (ret < 0) { in max77693_led_probe()
1008 return 0; in max77693_led_probe()
1017 mutex_destroy(&led->lock); in max77693_led_probe()
1024 struct max77693_led_device *led = platform_get_drvdata(pdev); in max77693_led_remove() local
1025 struct max77693_sub_led *sub_leds = led->sub_leds; in max77693_led_remove()
1027 if (led->iout_joint || max77693_fled_used(led, FLED1)) { in max77693_led_remove()
1032 if (!led->iout_joint && max77693_fled_used(led, FLED2)) { in max77693_led_remove()
1037 mutex_destroy(&led->lock); in max77693_led_remove()
1039 return 0; in max77693_led_remove()
1043 { .compatible = "maxim,max77693-led" },
1052 .name = "max77693-led",
1061 MODULE_DESCRIPTION("Maxim MAX77693 led flash driver");