Symbol: tps6131x
drivers/leds/flash/leds-tps6131x.c
124
static struct tps6131x *fled_cdev_to_tps6131x(struct led_classdev_flash *fled_cdev)
drivers/leds/flash/leds-tps6131x.c
126
return container_of(fled_cdev, struct tps6131x, fled_cdev);
drivers/leds/flash/leds-tps6131x.c
229
static int tps6131x_reset_chip(struct tps6131x *tps6131x)
drivers/leds/flash/leds-tps6131x.c
233
if (tps6131x->reset_gpio) {
drivers/leds/flash/leds-tps6131x.c
234
gpiod_set_value_cansleep(tps6131x->reset_gpio, 1);
drivers/leds/flash/leds-tps6131x.c
236
gpiod_set_value_cansleep(tps6131x->reset_gpio, 0);
drivers/leds/flash/leds-tps6131x.c
239
ret = regmap_update_bits(tps6131x->regmap, TPS6131X_REG_0, TPS6131X_REG_0_RESET,
drivers/leds/flash/leds-tps6131x.c
246
ret = regmap_update_bits(tps6131x->regmap, TPS6131X_REG_0, TPS6131X_REG_0_RESET, 0);
drivers/leds/flash/leds-tps6131x.c
254
static int tps6131x_init_chip(struct tps6131x *tps6131x)
drivers/leds/flash/leds-tps6131x.c
259
val = tps6131x->valley_current_limit ? TPS6131X_REG_4_ILIM : 0;
drivers/leds/flash/leds-tps6131x.c
261
ret = regmap_write(tps6131x->regmap, TPS6131X_REG_4, val);
drivers/leds/flash/leds-tps6131x.c
267
if (tps6131x->chan1_en)
drivers/leds/flash/leds-tps6131x.c
270
if (tps6131x->chan2_en)
drivers/leds/flash/leds-tps6131x.c
273
if (tps6131x->chan3_en)
drivers/leds/flash/leds-tps6131x.c
276
ret = regmap_write(tps6131x->regmap, TPS6131X_REG_5, val);
drivers/leds/flash/leds-tps6131x.c
282
ret = regmap_write(tps6131x->regmap, TPS6131X_REG_6, val);
drivers/leds/flash/leds-tps6131x.c
289
static int tps6131x_set_mode(struct tps6131x *tps6131x, enum tps6131x_mode mode, bool force)
drivers/leds/flash/leds-tps6131x.c
293
return regmap_update_bits_base(tps6131x->regmap, TPS6131X_REG_1, TPS6131X_REG_1_MODE, val,
drivers/leds/flash/leds-tps6131x.c
299
struct tps6131x *tps6131x = container_of(work, struct tps6131x, torch_refresh_work.work);
drivers/leds/flash/leds-tps6131x.c
302
guard(mutex)(&tps6131x->lock);
drivers/leds/flash/leds-tps6131x.c
304
ret = tps6131x_set_mode(tps6131x, TPS6131X_MODE_TORCH, true);
drivers/leds/flash/leds-tps6131x.c
306
dev_err(tps6131x->dev, "Failed to refresh torch watchdog timer\n");
drivers/leds/flash/leds-tps6131x.c
310
schedule_delayed_work(&tps6131x->torch_refresh_work,
drivers/leds/flash/leds-tps6131x.c
317
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
drivers/leds/flash/leds-tps6131x.c
322
cancel_delayed_work_sync(&tps6131x->torch_refresh_work);
drivers/leds/flash/leds-tps6131x.c
329
steps_remaining = (brightness * tps6131x->step_torch_current_ma) / TPS6131X_TORCH_STEP_I_MA;
drivers/leds/flash/leds-tps6131x.c
331
num_chans = tps6131x->chan1_en + tps6131x->chan2_en + tps6131x->chan3_en;
drivers/leds/flash/leds-tps6131x.c
341
if (tps6131x->chan1_en)
drivers/leds/flash/leds-tps6131x.c
343
if (tps6131x->chan3_en)
drivers/leds/flash/leds-tps6131x.c
349
guard(mutex)(&tps6131x->lock);
drivers/leds/flash/leds-tps6131x.c
353
ret = regmap_update_bits(tps6131x->regmap, TPS6131X_REG_0,
drivers/leds/flash/leds-tps6131x.c
358
ret = tps6131x_set_mode(tps6131x, brightness ? TPS6131X_MODE_TORCH : TPS6131X_MODE_SHUTDOWN,
drivers/leds/flash/leds-tps6131x.c
370
schedule_delayed_work(&tps6131x->torch_refresh_work,
drivers/leds/flash/leds-tps6131x.c
378
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
drivers/leds/flash/leds-tps6131x.c
381
guard(mutex)(&tps6131x->lock);
drivers/leds/flash/leds-tps6131x.c
383
ret = tps6131x_set_mode(tps6131x, state ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
drivers/leds/flash/leds-tps6131x.c
389
ret = regmap_update_bits_base(tps6131x->regmap, TPS6131X_REG_3, TPS6131X_REG_3_SFT,
drivers/leds/flash/leds-tps6131x.c
395
ret = regmap_update_bits_base(tps6131x->regmap, TPS6131X_REG_3, TPS6131X_REG_3_SFT, 0, NULL,
drivers/leds/flash/leds-tps6131x.c
405
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
drivers/leds/flash/leds-tps6131x.c
412
num_chans = tps6131x->chan1_en + tps6131x->chan2_en + tps6131x->chan3_en;
drivers/leds/flash/leds-tps6131x.c
415
if (tps6131x->chan1_en)
drivers/leds/flash/leds-tps6131x.c
417
if (tps6131x->chan3_en)
drivers/leds/flash/leds-tps6131x.c
422
guard(mutex)(&tps6131x->lock);
drivers/leds/flash/leds-tps6131x.c
424
ret = regmap_update_bits(tps6131x->regmap, TPS6131X_REG_2, TPS6131X_REG_2_FC13,
drivers/leds/flash/leds-tps6131x.c
429
ret = regmap_update_bits(tps6131x->regmap, TPS6131X_REG_1, TPS6131X_REG_1_FC2,
drivers/leds/flash/leds-tps6131x.c
442
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
drivers/leds/flash/leds-tps6131x.c
446
guard(mutex)(&tps6131x->lock);
drivers/leds/flash/leds-tps6131x.c
454
ret = regmap_update_bits(tps6131x->regmap, TPS6131X_REG_3,
drivers/leds/flash/leds-tps6131x.c
466
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
drivers/leds/flash/leds-tps6131x.c
470
ret = regmap_read_bypassed(tps6131x->regmap, TPS6131X_REG_3, &reg3);
drivers/leds/flash/leds-tps6131x.c
481
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
drivers/leds/flash/leds-tps6131x.c
487
ret = regmap_read_bypassed(tps6131x->regmap, TPS6131X_REG_3, &reg3);
drivers/leds/flash/leds-tps6131x.c
491
ret = regmap_read_bypassed(tps6131x->regmap, TPS6131X_REG_4, &reg4);
drivers/leds/flash/leds-tps6131x.c
495
ret = regmap_read_bypassed(tps6131x->regmap, TPS6131X_REG_6, &reg6);
drivers/leds/flash/leds-tps6131x.c
515
ret = regmap_update_bits_base(tps6131x->regmap, TPS6131X_REG_6,
drivers/leds/flash/leds-tps6131x.c
532
static int tps6131x_parse_node(struct tps6131x *tps6131x)
drivers/leds/flash/leds-tps6131x.c
535
struct device *dev = tps6131x->dev;
drivers/leds/flash/leds-tps6131x.c
545
tps6131x->valley_current_limit = device_property_read_bool(dev, "ti,valley-current-limit");
drivers/leds/flash/leds-tps6131x.c
547
tps6131x->led_node = device_get_next_child_node(dev, NULL);
drivers/leds/flash/leds-tps6131x.c
548
if (!tps6131x->led_node) {
drivers/leds/flash/leds-tps6131x.c
553
num_channels = fwnode_property_count_u32(tps6131x->led_node, "led-sources");
drivers/leds/flash/leds-tps6131x.c
565
ret = fwnode_property_read_u32_array(tps6131x->led_node, "led-sources", channels,
drivers/leds/flash/leds-tps6131x.c
577
tps6131x->chan1_en = true;
drivers/leds/flash/leds-tps6131x.c
582
tps6131x->chan2_en = true;
drivers/leds/flash/leds-tps6131x.c
587
tps6131x->chan3_en = true;
drivers/leds/flash/leds-tps6131x.c
602
(tps6131x->chan1_en && tps6131x->chan3_en && !tps6131x->chan2_en) ? 2 : 1;
drivers/leds/flash/leds-tps6131x.c
603
tps6131x->step_flash_current_ma = current_step_multiplier * TPS6131X_FLASH_STEP_I_MA;
drivers/leds/flash/leds-tps6131x.c
604
tps6131x->step_torch_current_ma = current_step_multiplier * TPS6131X_TORCH_STEP_I_MA;
drivers/leds/flash/leds-tps6131x.c
606
ret = fwnode_property_read_u32(tps6131x->led_node, "led-max-microamp", &current_ua);
drivers/leds/flash/leds-tps6131x.c
612
tps6131x->max_torch_current_ma = UA_TO_MA(current_ua);
drivers/leds/flash/leds-tps6131x.c
614
if (!tps6131x->max_torch_current_ma ||
drivers/leds/flash/leds-tps6131x.c
615
tps6131x->max_torch_current_ma > max_current_torch_ma ||
drivers/leds/flash/leds-tps6131x.c
616
(tps6131x->max_torch_current_ma % tps6131x->step_torch_current_ma)) {
drivers/leds/flash/leds-tps6131x.c
618
tps6131x->step_torch_current_ma);
drivers/leds/flash/leds-tps6131x.c
622
ret = fwnode_property_read_u32(tps6131x->led_node, "flash-max-microamp", &current_ua);
drivers/leds/flash/leds-tps6131x.c
628
tps6131x->max_flash_current_ma = UA_TO_MA(current_ua);
drivers/leds/flash/leds-tps6131x.c
630
if (!tps6131x->max_flash_current_ma ||
drivers/leds/flash/leds-tps6131x.c
631
tps6131x->max_flash_current_ma > max_current_flash_ma ||
drivers/leds/flash/leds-tps6131x.c
632
(tps6131x->max_flash_current_ma % tps6131x->step_flash_current_ma)) {
drivers/leds/flash/leds-tps6131x.c
634
tps6131x->step_flash_current_ma);
drivers/leds/flash/leds-tps6131x.c
638
ret = fwnode_property_read_u32(tps6131x->led_node, "flash-max-timeout-us", &timeout_us);
drivers/leds/flash/leds-tps6131x.c
645
tps6131x->max_timeout_us = timer_config->time_us;
drivers/leds/flash/leds-tps6131x.c
647
if (tps6131x->max_timeout_us != timeout_us)
drivers/leds/flash/leds-tps6131x.c
649
tps6131x->max_timeout_us);
drivers/leds/flash/leds-tps6131x.c
654
static int tps6131x_led_class_setup(struct tps6131x *tps6131x)
drivers/leds/flash/leds-tps6131x.c
662
tps6131x->fled_cdev.ops = &flash_ops;
drivers/leds/flash/leds-tps6131x.c
664
setting = &tps6131x->fled_cdev.timeout;
drivers/leds/flash/leds-tps6131x.c
667
setting->max = tps6131x->max_timeout_us;
drivers/leds/flash/leds-tps6131x.c
671
setting = &tps6131x->fled_cdev.brightness;
drivers/leds/flash/leds-tps6131x.c
672
setting->min = tps6131x->step_flash_current_ma;
drivers/leds/flash/leds-tps6131x.c
673
setting->max = tps6131x->max_flash_current_ma;
drivers/leds/flash/leds-tps6131x.c
674
setting->step = tps6131x->step_flash_current_ma;
drivers/leds/flash/leds-tps6131x.c
677
led_cdev = &tps6131x->fled_cdev.led_cdev;
drivers/leds/flash/leds-tps6131x.c
679
led_cdev->max_brightness = tps6131x->max_torch_current_ma;
drivers/leds/flash/leds-tps6131x.c
682
init_data.fwnode = tps6131x->led_node;
drivers/leds/flash/leds-tps6131x.c
687
ret = devm_led_classdev_flash_register_ext(tps6131x->dev, &tps6131x->fled_cdev,
drivers/leds/flash/leds-tps6131x.c
698
struct tps6131x *tps6131x = fled_cdev_to_tps6131x(fled_cdev);
drivers/leds/flash/leds-tps6131x.c
700
guard(mutex)(&tps6131x->lock);
drivers/leds/flash/leds-tps6131x.c
702
return tps6131x_set_mode(tps6131x, enable ? TPS6131X_MODE_FLASH : TPS6131X_MODE_SHUTDOWN,
drivers/leds/flash/leds-tps6131x.c
710
static int tps6131x_v4l2_setup(struct tps6131x *tps6131x)
drivers/leds/flash/leds-tps6131x.c
715
intensity->min = tps6131x->step_torch_current_ma;
drivers/leds/flash/leds-tps6131x.c
716
intensity->max = tps6131x->max_torch_current_ma;
drivers/leds/flash/leds-tps6131x.c
717
intensity->step = tps6131x->step_torch_current_ma;
drivers/leds/flash/leds-tps6131x.c
720
strscpy(v4l2_cfg.dev_name, tps6131x->fled_cdev.led_cdev.dev->kobj.name,
drivers/leds/flash/leds-tps6131x.c
728
tps6131x->v4l2_flash = v4l2_flash_init(tps6131x->dev, tps6131x->led_node,
drivers/leds/flash/leds-tps6131x.c
729
&tps6131x->fled_cdev, &tps6131x_v4l2_flash_ops,
drivers/leds/flash/leds-tps6131x.c
731
if (IS_ERR(tps6131x->v4l2_flash)) {
drivers/leds/flash/leds-tps6131x.c
732
dev_err(tps6131x->dev, "Failed to initialize v4l2 flash LED\n");
drivers/leds/flash/leds-tps6131x.c
733
return PTR_ERR(tps6131x->v4l2_flash);
drivers/leds/flash/leds-tps6131x.c
741
struct tps6131x *tps6131x;
drivers/leds/flash/leds-tps6131x.c
744
tps6131x = devm_kzalloc(&client->dev, sizeof(*tps6131x), GFP_KERNEL);
drivers/leds/flash/leds-tps6131x.c
745
if (!tps6131x)
drivers/leds/flash/leds-tps6131x.c
748
tps6131x->dev = &client->dev;
drivers/leds/flash/leds-tps6131x.c
749
i2c_set_clientdata(client, tps6131x);
drivers/leds/flash/leds-tps6131x.c
750
mutex_init(&tps6131x->lock);
drivers/leds/flash/leds-tps6131x.c
751
INIT_DELAYED_WORK(&tps6131x->torch_refresh_work, tps6131x_torch_refresh_handler);
drivers/leds/flash/leds-tps6131x.c
753
ret = tps6131x_parse_node(tps6131x);
drivers/leds/flash/leds-tps6131x.c
757
tps6131x->regmap = devm_regmap_init_i2c(client, &tps6131x_regmap);
drivers/leds/flash/leds-tps6131x.c
758
if (IS_ERR(tps6131x->regmap)) {
drivers/leds/flash/leds-tps6131x.c
759
ret = PTR_ERR(tps6131x->regmap);
drivers/leds/flash/leds-tps6131x.c
763
tps6131x->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH);
drivers/leds/flash/leds-tps6131x.c
764
if (IS_ERR(tps6131x->reset_gpio)) {
drivers/leds/flash/leds-tps6131x.c
765
ret = PTR_ERR(tps6131x->reset_gpio);
drivers/leds/flash/leds-tps6131x.c
769
ret = tps6131x_reset_chip(tps6131x);
drivers/leds/flash/leds-tps6131x.c
773
ret = tps6131x_init_chip(tps6131x);
drivers/leds/flash/leds-tps6131x.c
777
ret = tps6131x_led_class_setup(tps6131x);
drivers/leds/flash/leds-tps6131x.c
781
ret = tps6131x_v4l2_setup(tps6131x);
drivers/leds/flash/leds-tps6131x.c
790
struct tps6131x *tps6131x = i2c_get_clientdata(client);
drivers/leds/flash/leds-tps6131x.c
792
v4l2_flash_release(tps6131x->v4l2_flash);
drivers/leds/flash/leds-tps6131x.c
794
cancel_delayed_work_sync(&tps6131x->torch_refresh_work);