• Home
  • Raw
  • Download

Lines Matching refs:led

140 static inline bool max77693_fled_used(struct max77693_led_device *led,  in max77693_fled_used()  argument
145 return led->fled_mask & fled_bit; in max77693_fled_used()
148 static int max77693_set_mode_reg(struct max77693_led_device *led, u8 mode) in max77693_set_mode_reg() argument
150 struct regmap *rmap = led->regmap; in max77693_set_mode_reg()
180 static int max77693_add_mode(struct max77693_led_device *led, u8 mode) in max77693_add_mode() argument
185 if (led->iout_joint) in max77693_add_mode()
196 led->mode_flags &= (~MODE_TORCH(i) & ~MODE_FLASH(i)); in max77693_add_mode()
198 new_mode_flags = mode | led->mode_flags; in max77693_add_mode()
199 new_mode_flags &= led->allowed_modes; in max77693_add_mode()
201 if (new_mode_flags ^ led->mode_flags) in max77693_add_mode()
202 led->mode_flags = new_mode_flags; in max77693_add_mode()
206 ret = max77693_set_mode_reg(led, led->mode_flags); in max77693_add_mode()
215 led->mode_flags &= ~mode; in max77693_add_mode()
220 static int max77693_clear_mode(struct max77693_led_device *led, in max77693_clear_mode() argument
223 if (led->iout_joint) in max77693_clear_mode()
227 led->mode_flags &= ~mode; in max77693_clear_mode()
229 return max77693_set_mode_reg(led, led->mode_flags); in max77693_clear_mode()
232 static void max77693_add_allowed_modes(struct max77693_led_device *led, in max77693_add_allowed_modes() argument
236 led->allowed_modes |= (MODE_FLASH(fled_id) | in max77693_add_allowed_modes()
239 led->allowed_modes |= MODE_TORCH(fled_id); in max77693_add_allowed_modes()
242 static void max77693_distribute_currents(struct max77693_led_device *led, in max77693_distribute_currents() argument
246 if (!led->iout_joint) { in max77693_distribute_currents()
248 max77693_add_allowed_modes(led, fled_id, mode); in max77693_distribute_currents()
256 led->allowed_modes &= ~MODE_FLASH_MASK; in max77693_distribute_currents()
258 led->allowed_modes &= ~MODE_TORCH_MASK; in max77693_distribute_currents()
260 max77693_add_allowed_modes(led, FLED1, mode); in max77693_distribute_currents()
263 max77693_add_allowed_modes(led, FLED2, mode); in max77693_distribute_currents()
266 static int max77693_set_torch_current(struct max77693_led_device *led, in max77693_set_torch_current() argument
269 struct regmap *rmap = led->regmap; in max77693_set_torch_current()
273 max77693_distribute_currents(led, fled_id, TORCH, micro_amp, in max77693_set_torch_current()
274 led->iout_torch_max, iout); in max77693_set_torch_current()
276 if (fled_id == FLED1 || led->iout_joint) { in max77693_set_torch_current()
278 led->torch_iout_reg &= TORCH_IOUT_MASK(TORCH_IOUT2_SHIFT); in max77693_set_torch_current()
280 if (fled_id == FLED2 || led->iout_joint) { in max77693_set_torch_current()
282 led->torch_iout_reg &= TORCH_IOUT_MASK(TORCH_IOUT1_SHIFT); in max77693_set_torch_current()
285 led->torch_iout_reg |= ((iout1_reg << TORCH_IOUT1_SHIFT) | in max77693_set_torch_current()
289 led->torch_iout_reg); in max77693_set_torch_current()
292 static int max77693_set_flash_current(struct max77693_led_device *led, in max77693_set_flash_current() argument
296 struct regmap *rmap = led->regmap; in max77693_set_flash_current()
301 max77693_distribute_currents(led, fled_id, FLASH, micro_amp, in max77693_set_flash_current()
302 led->iout_flash_max, iout); in max77693_set_flash_current()
304 if (fled_id == FLED1 || led->iout_joint) { in max77693_set_flash_current()
311 if (fled_id == FLED2 || led->iout_joint) { in max77693_set_flash_current()
320 static int max77693_set_timeout(struct max77693_led_device *led, u32 microsec) in max77693_set_timeout() argument
322 struct regmap *rmap = led->regmap; in max77693_set_timeout()
332 led->current_flash_timeout = microsec; in max77693_set_timeout()
337 static int max77693_get_strobe_status(struct max77693_led_device *led, in max77693_get_strobe_status() argument
340 struct regmap *rmap = led->regmap; in max77693_get_strobe_status()
355 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_get_flash_faults() local
356 struct regmap *rmap = led->regmap; in max77693_get_flash_faults()
363 if (led->iout_joint) { in max77693_get_flash_faults()
390 static int max77693_setup(struct max77693_led_device *led, in max77693_setup() argument
393 struct regmap *rmap = led->regmap; in max77693_setup()
403 if (led->iout_joint) { in max77693_setup()
409 first_led = max77693_fled_used(led, FLED1) ? FLED1 : FLED2; in max77693_setup()
410 last_led = max77693_fled_used(led, FLED2) ? FLED2 : FLED1; in max77693_setup()
416 ret = max77693_set_flash_current(led, i, in max77693_setup()
445 if (max77693_fled_used(led, FLED1) && max77693_fled_used(led, FLED2)) in max77693_setup()
457 return max77693_set_mode_reg(led, MODE_OFF); in max77693_setup()
466 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_brightness_set() local
469 mutex_lock(&led->lock); in max77693_led_brightness_set()
472 ret = max77693_clear_mode(led, MODE_TORCH(fled_id)); in max77693_led_brightness_set()
474 dev_dbg(&led->pdev->dev, in max77693_led_brightness_set()
480 ret = max77693_set_torch_current(led, fled_id, value * TORCH_IOUT_STEP); in max77693_led_brightness_set()
482 dev_dbg(&led->pdev->dev, in max77693_led_brightness_set()
488 ret = max77693_add_mode(led, MODE_TORCH(fled_id)); in max77693_led_brightness_set()
490 dev_dbg(&led->pdev->dev, in max77693_led_brightness_set()
494 mutex_unlock(&led->lock); in max77693_led_brightness_set()
504 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_brightness_set() local
507 mutex_lock(&led->lock); in max77693_led_flash_brightness_set()
508 ret = max77693_set_flash_current(led, sub_led->fled_id, brightness); in max77693_led_flash_brightness_set()
509 mutex_unlock(&led->lock); in max77693_led_flash_brightness_set()
519 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_strobe_set() local
523 mutex_lock(&led->lock); in max77693_led_flash_strobe_set()
526 ret = max77693_clear_mode(led, MODE_FLASH(fled_id)); in max77693_led_flash_strobe_set()
530 if (sub_led->flash_timeout != led->current_flash_timeout) { in max77693_led_flash_strobe_set()
531 ret = max77693_set_timeout(led, sub_led->flash_timeout); in max77693_led_flash_strobe_set()
536 led->strobing_sub_led_id = fled_id; in max77693_led_flash_strobe_set()
538 ret = max77693_add_mode(led, MODE_FLASH(fled_id)); in max77693_led_flash_strobe_set()
545 mutex_unlock(&led->lock); in max77693_led_flash_strobe_set()
565 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_strobe_get() local
571 mutex_lock(&led->lock); in max77693_led_flash_strobe_get()
573 ret = max77693_get_strobe_status(led, state); in max77693_led_flash_strobe_get()
575 *state = !!(*state && (led->strobing_sub_led_id == sub_led->fled_id)); in max77693_led_flash_strobe_get()
577 mutex_unlock(&led->lock); in max77693_led_flash_strobe_get()
587 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_flash_timeout_set() local
589 mutex_lock(&led->lock); in max77693_led_flash_timeout_set()
591 mutex_unlock(&led->lock); in max77693_led_flash_timeout_set()
596 static int max77693_led_parse_dt(struct max77693_led_device *led, in max77693_led_parse_dt() argument
600 struct device *dev = &led->pdev->dev; in max77693_led_parse_dt()
601 struct max77693_sub_led *sub_leds = led->sub_leds; in max77693_led_parse_dt()
631 led->fled_mask = FLED1_IOUT | FLED2_IOUT; in max77693_led_parse_dt()
634 led->fled_mask |= FLED1_IOUT; in max77693_led_parse_dt()
637 led->fled_mask |= FLED2_IOUT; in max77693_led_parse_dt()
683 (max77693_fled_used(led, FLED1) && in max77693_led_parse_dt()
684 max77693_fled_used(led, FLED2))) { in max77693_led_parse_dt()
705 static void max77693_align_iout_current(struct max77693_led_device *led, in max77693_align_iout_current() argument
710 if (led->iout_joint) { in max77693_align_iout_current()
722 if (max77693_fled_used(led, i)) in max77693_align_iout_current()
728 static void max77693_led_validate_configuration(struct max77693_led_device *led, in max77693_led_validate_configuration() argument
736 max77693_fled_used(led, FLED1) && max77693_fled_used(led, FLED2)) in max77693_led_validate_configuration()
737 led->iout_joint = true; in max77693_led_validate_configuration()
743 if ((cfg->boost_mode == MAX77693_LED_BOOST_NONE) && led->iout_joint) in max77693_led_validate_configuration()
746 max77693_align_iout_current(led, cfg->iout_torch_max, in max77693_led_validate_configuration()
749 max77693_align_iout_current(led, cfg->iout_flash_max, in max77693_led_validate_configuration()
764 static int max77693_led_get_configuration(struct max77693_led_device *led, in max77693_led_get_configuration() argument
770 ret = max77693_led_parse_dt(led, cfg, sub_nodes); in max77693_led_get_configuration()
774 max77693_led_validate_configuration(led, cfg); in max77693_led_get_configuration()
776 memcpy(led->iout_torch_max, cfg->iout_torch_max, in max77693_led_get_configuration()
777 sizeof(led->iout_torch_max)); in max77693_led_get_configuration()
778 memcpy(led->iout_flash_max, cfg->iout_flash_max, in max77693_led_get_configuration()
779 sizeof(led->iout_flash_max)); in max77693_led_get_configuration()
796 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_init_flash_settings() local
803 setting->max = led->iout_joint ? in max77693_init_flash_settings()
826 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_led_external_strobe_set() local
830 mutex_lock(&led->lock); in max77693_led_external_strobe_set()
833 ret = max77693_add_mode(led, MODE_FLASH_EXTERNAL(fled_id)); in max77693_led_external_strobe_set()
835 ret = max77693_clear_mode(led, MODE_FLASH_EXTERNAL(fled_id)); in max77693_led_external_strobe_set()
837 mutex_unlock(&led->lock); in max77693_led_external_strobe_set()
846 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_init_v4l2_flash_config() local
847 struct device *dev = &led->pdev->dev; in max77693_init_v4l2_flash_config()
886 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_init_fled_cdev() local
899 led_cdev->max_brightness = (led->iout_joint ? in max77693_init_fled_cdev()
916 struct max77693_led_device *led = sub_led_to_led(sub_led); in max77693_register_led() local
918 struct device *dev = &led->pdev->dev; in max77693_register_led()
949 struct max77693_led_device *led; in max77693_led_probe() local
955 led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); in max77693_led_probe()
956 if (!led) in max77693_led_probe()
959 led->pdev = pdev; in max77693_led_probe()
960 led->regmap = iodev->regmap; in max77693_led_probe()
961 led->allowed_modes = MODE_FLASH_MASK; in max77693_led_probe()
962 sub_leds = led->sub_leds; in max77693_led_probe()
964 platform_set_drvdata(pdev, led); in max77693_led_probe()
965 ret = max77693_led_get_configuration(led, &led_cfg, sub_nodes); in max77693_led_probe()
969 ret = max77693_setup(led, &led_cfg); in max77693_led_probe()
973 mutex_init(&led->lock); in max77693_led_probe()
976 led->iout_joint || max77693_fled_used(led, FLED1); in max77693_led_probe()
978 !led->iout_joint && max77693_fled_used(led, FLED2); in max77693_led_probe()
1014 mutex_destroy(&led->lock); in max77693_led_probe()
1021 struct max77693_led_device *led = platform_get_drvdata(pdev); in max77693_led_remove() local
1022 struct max77693_sub_led *sub_leds = led->sub_leds; in max77693_led_remove()
1024 if (led->iout_joint || max77693_fled_used(led, FLED1)) { in max77693_led_remove()
1029 if (!led->iout_joint && max77693_fled_used(led, FLED2)) { in max77693_led_remove()
1034 mutex_destroy(&led->lock); in max77693_led_remove()