1 // SPDX-License-Identifier: GPL-2.0-only
3 * drivers/leds/leds-as3645a.c - AS3645A and LM3555 flash controllers driver
5 * Copyright (C) 2008-2011 Nokia Corporation
6 * Copyright (c) 2011, 2017 Intel Corporation.
8 * Based on drivers/media/i2c/as3645a.c.
10 * Contact: Sakari Ailus <sakari.ailus@iki.fi>
13 #include <linux/delay.h>
14 #include <linux/gpio/consumer.h>
15 #include <linux/i2c.h>
16 #include <linux/led-class-flash.h>
17 #include <linux/leds.h>
18 #include <linux/module.h>
19 #include <linux/mutex.h>
20 #include <linux/property.h>
21 #include <linux/slab.h>
23 #include <media/v4l2-flash-led-class.h>
25 #define AS_TIMER_US_TO_CODE(t) (((t) / 1000 - 100) / 50)
26 #define AS_TIMER_CODE_TO_US(c) ((50 * (c) + 100) * 1000)
28 /* Register definitions */
30 /* Read-only Design info register: Reset state: xxxx 0001 */
31 #define AS_DESIGN_INFO_REG 0x00
32 #define AS_DESIGN_INFO_FACTORY(x) (((x) >> 4))
33 #define AS_DESIGN_INFO_MODEL(x) ((x) & 0x0f)
35 /* Read-only Version control register: Reset state: 0000 0000
36 * for first engineering samples
38 #define AS_VERSION_CONTROL_REG 0x01
39 #define AS_VERSION_CONTROL_RFU(x) (((x) >> 4))
40 #define AS_VERSION_CONTROL_VERSION(x) ((x) & 0x0f)
42 /* Read / Write (Indicator and timer register): Reset state: 0000 1111 */
43 #define AS_INDICATOR_AND_TIMER_REG 0x02
44 #define AS_INDICATOR_AND_TIMER_TIMEOUT_SHIFT 0
45 #define AS_INDICATOR_AND_TIMER_VREF_SHIFT 4
46 #define AS_INDICATOR_AND_TIMER_INDICATOR_SHIFT 6
48 /* Read / Write (Current set register): Reset state: 0110 1001 */
49 #define AS_CURRENT_SET_REG 0x03
50 #define AS_CURRENT_ASSIST_LIGHT_SHIFT 0
51 #define AS_CURRENT_LED_DET_ON (1 << 3)
52 #define AS_CURRENT_FLASH_CURRENT_SHIFT 4
54 /* Read / Write (Control register): Reset state: 1011 0100 */
55 #define AS_CONTROL_REG 0x04
56 #define AS_CONTROL_MODE_SETTING_SHIFT 0
57 #define AS_CONTROL_STROBE_ON (1 << 2)
58 #define AS_CONTROL_OUT_ON (1 << 3)
59 #define AS_CONTROL_EXT_TORCH_ON (1 << 4)
60 #define AS_CONTROL_STROBE_TYPE_EDGE (0 << 5)
61 #define AS_CONTROL_STROBE_TYPE_LEVEL (1 << 5)
62 #define AS_CONTROL_COIL_PEAK_SHIFT 6
64 /* Read only (D3 is read / write) (Fault and info): Reset state: 0000 x000 */
65 #define AS_FAULT_INFO_REG 0x05
66 #define AS_FAULT_INFO_INDUCTOR_PEAK_LIMIT (1 << 1)
67 #define AS_FAULT_INFO_INDICATOR_LED (1 << 2)
68 #define AS_FAULT_INFO_LED_AMOUNT (1 << 3)
69 #define AS_FAULT_INFO_TIMEOUT (1 << 4)
70 #define AS_FAULT_INFO_OVER_TEMPERATURE (1 << 5)
71 #define AS_FAULT_INFO_SHORT_CIRCUIT (1 << 6)
72 #define AS_FAULT_INFO_OVER_VOLTAGE (1 << 7)
75 #define AS_BOOST_REG 0x0d
76 #define AS_BOOST_CURRENT_DISABLE (0 << 0)
77 #define AS_BOOST_CURRENT_ENABLE (1 << 0)
79 /* Password register is used to unlock boost register writing */
80 #define AS_PASSWORD_REG 0x0f
81 #define AS_PASSWORD_UNLOCK_VALUE 0x55
83 #define AS_NAME "as3645a"
84 #define AS_I2C_ADDR (0x60 >> 1) /* W:0x60, R:0x61 */
86 #define AS_FLASH_TIMEOUT_MIN 100000 /* us */
87 #define AS_FLASH_TIMEOUT_MAX 850000
88 #define AS_FLASH_TIMEOUT_STEP 50000
90 #define AS_FLASH_INTENSITY_MIN 200000 /* uA */
91 #define AS_FLASH_INTENSITY_MAX_1LED 500000
92 #define AS_FLASH_INTENSITY_MAX_2LEDS 400000
93 #define AS_FLASH_INTENSITY_STEP 20000
95 #define AS_TORCH_INTENSITY_MIN 20000 /* uA */
96 #define AS_TORCH_INTENSITY_MAX 160000
97 #define AS_TORCH_INTENSITY_STEP 20000
99 #define AS_INDICATOR_INTENSITY_MIN 0 /* uA */
100 #define AS_INDICATOR_INTENSITY_MAX 10000
101 #define AS_INDICATOR_INTENSITY_STEP 2500
103 #define AS_PEAK_mA_MAX 2000
104 #define AS_PEAK_mA_TO_REG(a) \
105 ((min_t(u32, AS_PEAK_mA_MAX, a) - 1250) / 250)
107 /* LED numbers for Devicetree */
108 #define AS_LED_FLASH 0
109 #define AS_LED_INDICATOR 1
112 AS_MODE_EXT_TORCH
= 0 << AS_CONTROL_MODE_SETTING_SHIFT
,
113 AS_MODE_INDICATOR
= 1 << AS_CONTROL_MODE_SETTING_SHIFT
,
114 AS_MODE_ASSIST
= 2 << AS_CONTROL_MODE_SETTING_SHIFT
,
115 AS_MODE_FLASH
= 3 << AS_CONTROL_MODE_SETTING_SHIFT
,
118 struct as3645a_config
{
119 u32 flash_timeout_us
;
122 u32 indicator_max_ua
;
123 u32 voltage_reference
;
127 struct as3645a_names
{
133 struct i2c_client
*client
;
137 struct led_classdev_flash fled
;
138 struct led_classdev iled_cdev
;
140 struct v4l2_flash
*vf
;
141 struct v4l2_flash
*vfind
;
143 struct fwnode_handle
*flash_node
;
144 struct fwnode_handle
*indicator_node
;
146 struct as3645a_config cfg
;
149 unsigned int timeout
;
150 unsigned int flash_current
;
151 unsigned int assist_current
;
152 unsigned int indicator_current
;
153 enum v4l2_flash_strobe_source strobe_source
;
156 #define fled_to_as3645a(__fled) container_of(__fled, struct as3645a, fled)
157 #define iled_cdev_to_as3645a(__iled_cdev) \
158 container_of(__iled_cdev, struct as3645a, iled_cdev)
160 /* Return negative errno else zero on success */
161 static int as3645a_write(struct as3645a
*flash
, u8 addr
, u8 val
)
163 struct i2c_client
*client
= flash
->client
;
166 rval
= i2c_smbus_write_byte_data(client
, addr
, val
);
168 dev_dbg(&client
->dev
, "Write Addr:%02X Val:%02X %s\n", addr
, val
,
169 rval
< 0 ? "fail" : "ok");
174 /* Return negative errno else a data byte received from the device. */
175 static int as3645a_read(struct as3645a
*flash
, u8 addr
)
177 struct i2c_client
*client
= flash
->client
;
180 rval
= i2c_smbus_read_byte_data(client
, addr
);
182 dev_dbg(&client
->dev
, "Read Addr:%02X Val:%02X %s\n", addr
, rval
,
183 rval
< 0 ? "fail" : "ok");
188 /* -----------------------------------------------------------------------------
189 * Hardware configuration and trigger
193 * as3645a_set_config - Set flash configuration registers
196 * Configure the hardware with flash, assist and indicator currents, as well as
199 * Return 0 on success, or a negative error code if an I2C communication error
202 static int as3645a_set_current(struct as3645a
*flash
)
206 val
= (flash
->flash_current
<< AS_CURRENT_FLASH_CURRENT_SHIFT
)
207 | (flash
->assist_current
<< AS_CURRENT_ASSIST_LIGHT_SHIFT
)
208 | AS_CURRENT_LED_DET_ON
;
210 return as3645a_write(flash
, AS_CURRENT_SET_REG
, val
);
213 static int as3645a_set_timeout(struct as3645a
*flash
)
217 val
= flash
->timeout
<< AS_INDICATOR_AND_TIMER_TIMEOUT_SHIFT
;
219 val
|= (flash
->cfg
.voltage_reference
220 << AS_INDICATOR_AND_TIMER_VREF_SHIFT
)
221 | ((flash
->indicator_current
? flash
->indicator_current
- 1 : 0)
222 << AS_INDICATOR_AND_TIMER_INDICATOR_SHIFT
);
224 return as3645a_write(flash
, AS_INDICATOR_AND_TIMER_REG
, val
);
228 * as3645a_set_control - Set flash control register
230 * @mode: Desired output mode
231 * @on: Desired output state
233 * Configure the hardware with output mode and state.
235 * Return 0 on success, or a negative error code if an I2C communication error
239 as3645a_set_control(struct as3645a
*flash
, enum as_mode mode
, bool on
)
243 /* Configure output parameters and operation mode. */
244 reg
= (flash
->cfg
.peak
<< AS_CONTROL_COIL_PEAK_SHIFT
)
245 | (on
? AS_CONTROL_OUT_ON
: 0)
248 if (mode
== AS_MODE_FLASH
&&
249 flash
->strobe_source
== V4L2_FLASH_STROBE_SOURCE_EXTERNAL
)
250 reg
|= AS_CONTROL_STROBE_TYPE_LEVEL
251 | AS_CONTROL_STROBE_ON
;
253 return as3645a_write(flash
, AS_CONTROL_REG
, reg
);
256 static int as3645a_get_fault(struct led_classdev_flash
*fled
, u32
*fault
)
258 struct as3645a
*flash
= fled_to_as3645a(fled
);
261 /* NOTE: reading register clears fault status */
262 rval
= as3645a_read(flash
, AS_FAULT_INFO_REG
);
266 if (rval
& AS_FAULT_INFO_INDUCTOR_PEAK_LIMIT
)
267 *fault
|= LED_FAULT_OVER_CURRENT
;
269 if (rval
& AS_FAULT_INFO_INDICATOR_LED
)
270 *fault
|= LED_FAULT_INDICATOR
;
272 dev_dbg(&flash
->client
->dev
, "%u connected LEDs\n",
273 rval
& AS_FAULT_INFO_LED_AMOUNT
? 2 : 1);
275 if (rval
& AS_FAULT_INFO_TIMEOUT
)
276 *fault
|= LED_FAULT_TIMEOUT
;
278 if (rval
& AS_FAULT_INFO_OVER_TEMPERATURE
)
279 *fault
|= LED_FAULT_OVER_TEMPERATURE
;
281 if (rval
& AS_FAULT_INFO_SHORT_CIRCUIT
)
282 *fault
|= LED_FAULT_OVER_CURRENT
;
284 if (rval
& AS_FAULT_INFO_OVER_VOLTAGE
)
285 *fault
|= LED_FAULT_INPUT_VOLTAGE
;
290 static unsigned int __as3645a_current_to_reg(unsigned int min
, unsigned int max
,
300 return (val
- min
) / step
;
303 static unsigned int as3645a_current_to_reg(struct as3645a
*flash
, bool is_flash
,
307 return __as3645a_current_to_reg(AS_TORCH_INTENSITY_MIN
,
308 flash
->cfg
.assist_max_ua
,
309 AS_TORCH_INTENSITY_STEP
, ua
);
311 return __as3645a_current_to_reg(AS_FLASH_INTENSITY_MIN
,
312 flash
->cfg
.flash_max_ua
,
313 AS_FLASH_INTENSITY_STEP
, ua
);
316 static int as3645a_set_indicator_brightness(struct led_classdev
*iled_cdev
,
317 enum led_brightness brightness
)
319 struct as3645a
*flash
= iled_cdev_to_as3645a(iled_cdev
);
322 flash
->indicator_current
= brightness
;
324 rval
= as3645a_set_timeout(flash
);
328 return as3645a_set_control(flash
, AS_MODE_INDICATOR
, brightness
);
331 static int as3645a_set_assist_brightness(struct led_classdev
*fled_cdev
,
332 enum led_brightness brightness
)
334 struct led_classdev_flash
*fled
= lcdev_to_flcdev(fled_cdev
);
335 struct as3645a
*flash
= fled_to_as3645a(fled
);
339 /* Register value 0 is 20 mA. */
340 flash
->assist_current
= brightness
- 1;
342 rval
= as3645a_set_current(flash
);
347 return as3645a_set_control(flash
, AS_MODE_ASSIST
, brightness
);
350 static int as3645a_set_flash_brightness(struct led_classdev_flash
*fled
,
353 struct as3645a
*flash
= fled_to_as3645a(fled
);
355 flash
->flash_current
= as3645a_current_to_reg(flash
, true,
358 return as3645a_set_current(flash
);
361 static int as3645a_set_flash_timeout(struct led_classdev_flash
*fled
,
364 struct as3645a
*flash
= fled_to_as3645a(fled
);
366 flash
->timeout
= AS_TIMER_US_TO_CODE(timeout_us
);
368 return as3645a_set_timeout(flash
);
371 static int as3645a_set_strobe(struct led_classdev_flash
*fled
, bool state
)
373 struct as3645a
*flash
= fled_to_as3645a(fled
);
375 return as3645a_set_control(flash
, AS_MODE_FLASH
, state
);
378 static const struct led_flash_ops as3645a_led_flash_ops
= {
379 .flash_brightness_set
= as3645a_set_flash_brightness
,
380 .timeout_set
= as3645a_set_flash_timeout
,
381 .strobe_set
= as3645a_set_strobe
,
382 .fault_get
= as3645a_get_fault
,
385 static int as3645a_setup(struct as3645a
*flash
)
387 struct device
*dev
= &flash
->client
->dev
;
392 rval
= as3645a_read(flash
, AS_FAULT_INFO_REG
);
396 dev_dbg(dev
, "Fault info: %02x\n", rval
);
398 rval
= as3645a_set_current(flash
);
402 rval
= as3645a_set_timeout(flash
);
406 rval
= as3645a_set_control(flash
, AS_MODE_INDICATOR
, false);
411 rval
= as3645a_get_fault(&flash
->fled
, &fault
);
415 dev_dbg(dev
, "AS_INDICATOR_AND_TIMER_REG: %02x\n",
416 as3645a_read(flash
, AS_INDICATOR_AND_TIMER_REG
));
417 dev_dbg(dev
, "AS_CURRENT_SET_REG: %02x\n",
418 as3645a_read(flash
, AS_CURRENT_SET_REG
));
419 dev_dbg(dev
, "AS_CONTROL_REG: %02x\n",
420 as3645a_read(flash
, AS_CONTROL_REG
));
422 return rval
& ~AS_FAULT_INFO_LED_AMOUNT
? -EIO
: 0;
425 static int as3645a_detect(struct as3645a
*flash
)
427 struct device
*dev
= &flash
->client
->dev
;
428 int rval
, man
, model
, rfu
, version
;
431 rval
= as3645a_read(flash
, AS_DESIGN_INFO_REG
);
433 dev_err(dev
, "can't read design info reg\n");
437 man
= AS_DESIGN_INFO_FACTORY(rval
);
438 model
= AS_DESIGN_INFO_MODEL(rval
);
440 rval
= as3645a_read(flash
, AS_VERSION_CONTROL_REG
);
442 dev_err(dev
, "can't read version control reg\n");
446 rfu
= AS_VERSION_CONTROL_RFU(rval
);
447 version
= AS_VERSION_CONTROL_VERSION(rval
);
449 /* Verify the chip model and version. */
450 if (model
!= 0x01 || rfu
!= 0x00) {
451 dev_err(dev
, "AS3645A not detected (model %d rfu %d)\n",
458 vendor
= "AMS, Austria Micro Systems";
461 vendor
= "ADI, Analog Devices Inc.";
464 vendor
= "NSC, National Semiconductor";
470 vendor
= "TI, Texas Instrument";
476 dev_info(dev
, "Chip vendor: %s (%d) Version: %d\n", vendor
,
479 rval
= as3645a_write(flash
, AS_PASSWORD_REG
, AS_PASSWORD_UNLOCK_VALUE
);
483 return as3645a_write(flash
, AS_BOOST_REG
, AS_BOOST_CURRENT_DISABLE
);
486 static int as3645a_parse_node(struct as3645a
*flash
,
487 struct as3645a_names
*names
,
488 struct fwnode_handle
*fwnode
)
490 struct as3645a_config
*cfg
= &flash
->cfg
;
491 struct fwnode_handle
*child
;
495 fwnode_for_each_child_node(fwnode
, child
) {
498 fwnode_property_read_u32(child
, "reg", &id
);
502 flash
->flash_node
= child
;
504 case AS_LED_INDICATOR
:
505 flash
->indicator_node
= child
;
508 dev_warn(&flash
->client
->dev
,
509 "unknown LED %u encountered, ignoring\n", id
);
512 fwnode_handle_get(child
);
515 if (!flash
->flash_node
) {
516 dev_err(&flash
->client
->dev
, "can't find flash node\n");
520 rval
= fwnode_property_read_string(flash
->flash_node
, "label", &name
);
522 strlcpy(names
->flash
, name
, sizeof(names
->flash
));
523 } else if (is_of_node(fwnode
)) {
524 snprintf(names
->flash
, sizeof(names
->flash
),
525 "%pOFn:flash", to_of_node(fwnode
));
527 dev_err(&flash
->client
->dev
, "flash node has no label!\n");
531 rval
= fwnode_property_read_u32(flash
->flash_node
, "flash-timeout-us",
532 &cfg
->flash_timeout_us
);
534 dev_err(&flash
->client
->dev
,
535 "can't read flash-timeout-us property for flash\n");
539 rval
= fwnode_property_read_u32(flash
->flash_node
, "flash-max-microamp",
542 dev_err(&flash
->client
->dev
,
543 "can't read flash-max-microamp property for flash\n");
547 rval
= fwnode_property_read_u32(flash
->flash_node
, "led-max-microamp",
548 &cfg
->assist_max_ua
);
550 dev_err(&flash
->client
->dev
,
551 "can't read led-max-microamp property for flash\n");
555 fwnode_property_read_u32(flash
->flash_node
, "voltage-reference",
556 &cfg
->voltage_reference
);
558 fwnode_property_read_u32(flash
->flash_node
, "ams,input-max-microamp",
560 cfg
->peak
= AS_PEAK_mA_TO_REG(cfg
->peak
);
562 if (!flash
->indicator_node
) {
563 dev_warn(&flash
->client
->dev
,
564 "can't find indicator node\n");
568 rval
= fwnode_property_read_string(flash
->indicator_node
, "label",
571 strlcpy(names
->indicator
, name
, sizeof(names
->indicator
));
572 } else if (is_of_node(fwnode
)) {
573 snprintf(names
->indicator
, sizeof(names
->indicator
),
574 "%pOFn:indicator", to_of_node(fwnode
));
576 dev_err(&flash
->client
->dev
, "indicator node has no label!\n");
580 rval
= fwnode_property_read_u32(flash
->indicator_node
,
582 &cfg
->indicator_max_ua
);
584 dev_err(&flash
->client
->dev
,
585 "can't read led-max-microamp property for indicator\n");
592 fwnode_handle_put(flash
->flash_node
);
593 fwnode_handle_put(flash
->indicator_node
);
598 static int as3645a_led_class_setup(struct as3645a
*flash
,
599 struct as3645a_names
*names
)
601 struct led_classdev
*fled_cdev
= &flash
->fled
.led_cdev
;
602 struct led_classdev
*iled_cdev
= &flash
->iled_cdev
;
603 struct led_flash_setting
*cfg
;
606 iled_cdev
->name
= names
->indicator
;
607 iled_cdev
->brightness_set_blocking
= as3645a_set_indicator_brightness
;
608 iled_cdev
->max_brightness
=
609 flash
->cfg
.indicator_max_ua
/ AS_INDICATOR_INTENSITY_STEP
;
610 iled_cdev
->flags
= LED_CORE_SUSPENDRESUME
;
612 rval
= led_classdev_register(&flash
->client
->dev
, iled_cdev
);
616 cfg
= &flash
->fled
.brightness
;
617 cfg
->min
= AS_FLASH_INTENSITY_MIN
;
618 cfg
->max
= flash
->cfg
.flash_max_ua
;
619 cfg
->step
= AS_FLASH_INTENSITY_STEP
;
620 cfg
->val
= flash
->cfg
.flash_max_ua
;
622 cfg
= &flash
->fled
.timeout
;
623 cfg
->min
= AS_FLASH_TIMEOUT_MIN
;
624 cfg
->max
= flash
->cfg
.flash_timeout_us
;
625 cfg
->step
= AS_FLASH_TIMEOUT_STEP
;
626 cfg
->val
= flash
->cfg
.flash_timeout_us
;
628 flash
->fled
.ops
= &as3645a_led_flash_ops
;
630 fled_cdev
->name
= names
->flash
;
631 fled_cdev
->brightness_set_blocking
= as3645a_set_assist_brightness
;
632 /* Value 0 is off in LED class. */
633 fled_cdev
->max_brightness
=
634 as3645a_current_to_reg(flash
, false,
635 flash
->cfg
.assist_max_ua
) + 1;
636 fled_cdev
->flags
= LED_DEV_CAP_FLASH
| LED_CORE_SUSPENDRESUME
;
638 rval
= led_classdev_flash_register(&flash
->client
->dev
, &flash
->fled
);
640 led_classdev_unregister(iled_cdev
);
641 dev_err(&flash
->client
->dev
,
642 "led_classdev_flash_register() failed, error %d\n",
649 static int as3645a_v4l2_setup(struct as3645a
*flash
)
651 struct led_classdev_flash
*fled
= &flash
->fled
;
652 struct led_classdev
*led
= &fled
->led_cdev
;
653 struct v4l2_flash_config cfg
= {
655 .min
= AS_TORCH_INTENSITY_MIN
,
656 .max
= flash
->cfg
.assist_max_ua
,
657 .step
= AS_TORCH_INTENSITY_STEP
,
658 .val
= flash
->cfg
.assist_max_ua
,
661 struct v4l2_flash_config cfgind
= {
663 .min
= AS_INDICATOR_INTENSITY_MIN
,
664 .max
= flash
->cfg
.indicator_max_ua
,
665 .step
= AS_INDICATOR_INTENSITY_STEP
,
666 .val
= flash
->cfg
.indicator_max_ua
,
670 strlcpy(cfg
.dev_name
, led
->name
, sizeof(cfg
.dev_name
));
671 strlcpy(cfgind
.dev_name
, flash
->iled_cdev
.name
, sizeof(cfg
.dev_name
));
673 flash
->vf
= v4l2_flash_init(
674 &flash
->client
->dev
, flash
->flash_node
, &flash
->fled
, NULL
,
676 if (IS_ERR(flash
->vf
))
677 return PTR_ERR(flash
->vf
);
679 flash
->vfind
= v4l2_flash_indicator_init(
680 &flash
->client
->dev
, flash
->indicator_node
, &flash
->iled_cdev
,
682 if (IS_ERR(flash
->vfind
)) {
683 v4l2_flash_release(flash
->vf
);
684 return PTR_ERR(flash
->vfind
);
690 static int as3645a_probe(struct i2c_client
*client
)
692 struct as3645a_names names
;
693 struct as3645a
*flash
;
696 if (!dev_fwnode(&client
->dev
))
699 flash
= devm_kzalloc(&client
->dev
, sizeof(*flash
), GFP_KERNEL
);
703 flash
->client
= client
;
705 rval
= as3645a_parse_node(flash
, &names
, dev_fwnode(&client
->dev
));
709 rval
= as3645a_detect(flash
);
713 mutex_init(&flash
->mutex
);
714 i2c_set_clientdata(client
, flash
);
716 rval
= as3645a_setup(flash
);
718 goto out_mutex_destroy
;
720 rval
= as3645a_led_class_setup(flash
, &names
);
722 goto out_mutex_destroy
;
724 rval
= as3645a_v4l2_setup(flash
);
726 goto out_led_classdev_flash_unregister
;
730 out_led_classdev_flash_unregister
:
731 led_classdev_flash_unregister(&flash
->fled
);
734 mutex_destroy(&flash
->mutex
);
737 fwnode_handle_put(flash
->flash_node
);
738 fwnode_handle_put(flash
->indicator_node
);
743 static int as3645a_remove(struct i2c_client
*client
)
745 struct as3645a
*flash
= i2c_get_clientdata(client
);
747 as3645a_set_control(flash
, AS_MODE_EXT_TORCH
, false);
749 v4l2_flash_release(flash
->vf
);
750 v4l2_flash_release(flash
->vfind
);
752 led_classdev_flash_unregister(&flash
->fled
);
753 led_classdev_unregister(&flash
->iled_cdev
);
755 mutex_destroy(&flash
->mutex
);
757 fwnode_handle_put(flash
->flash_node
);
758 fwnode_handle_put(flash
->indicator_node
);
763 static const struct i2c_device_id as3645a_id_table
[] = {
767 MODULE_DEVICE_TABLE(i2c
, as3645a_id_table
);
769 static const struct of_device_id as3645a_of_table
[] = {
770 { .compatible
= "ams,as3645a" },
773 MODULE_DEVICE_TABLE(of
, as3645a_of_table
);
775 static struct i2c_driver as3645a_i2c_driver
= {
777 .of_match_table
= as3645a_of_table
,
780 .probe_new
= as3645a_probe
,
781 .remove
= as3645a_remove
,
782 .id_table
= as3645a_id_table
,
785 module_i2c_driver(as3645a_i2c_driver
);
787 MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
788 MODULE_AUTHOR("Sakari Ailus <sakari.ailus@iki.fi>");
789 MODULE_DESCRIPTION("LED flash driver for AS3645A, LM3555 and their clones");
790 MODULE_LICENSE("GPL v2");