blob: 96064f8d3d4c07143e7242c5ef9fa071c059c5e5 [file] [log] [blame]
xjb04a4022021-11-25 15:01:52 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2019 MediaTek Inc.
4 */
5
6#include <linux/init.h>
7#include <linux/module.h>
8#include <linux/kernel.h>
9#include <linux/regmap.h>
10#include <linux/platform_device.h>
11#include <linux/interrupt.h>
12#include <linux/of.h>
13#include <linux/led-class-flash.h>
14#include <media/v4l2-flash-led-class.h>
15
16#include <linux/mfd/mt6360-private.h>
17
18enum {
19 MT6360_LED_ISINK1 = 0,
20 MT6360_LED_ISINK2,
21 MT6360_LED_ISINK3,
22 MT6360_LED_ISINK4,
23 MT6360_LED_MAX,
24};
25
26enum {
27 MT6360_LEDMODE_PWM = 0,
28 MT6360_LEDMODE_BREATH,
29 MT6360_LEDMODE_CC,
30 MT6360_LEDMODE_MAX,
31};
32
33enum {
34 MT6360_FLED_CH1 = 0,
35 MT6360_FLED_CH2,
36 MT6360_FLED_MAX,
37};
38
39/* ILED setting/reg */
40#define MT6360_SINKCUR_MAX1 (0x0d)
41#define MT6360_SINKCUR_MAX2 (0x0d)
42#define MT6360_SINKCUR_MAX3 (0x0d)
43#define MT6360_SINKCUR_MAX4 (0x1f)
44#define MT6360_CURRSEL_REG1 (MT6360_PMU_RGB1_ISNK)
45#define MT6360_CURRSEL_REG2 (MT6360_PMU_RGB2_ISNK)
46#define MT6360_CURRSEL_REG3 (MT6360_PMU_RGB3_ISNK)
47#define MT6360_CURRSEL_REG4 (MT6360_PMU_RGB_ML_ISNK)
48#define MT6360_CURRSEL_MASK1 (0x0f)
49#define MT6360_CURRSEL_MASK2 (0x0f)
50#define MT6360_CURRSEL_MASK3 (0x0f)
51#define MT6360_CURRSEL_MASK4 (0x1f)
52#define MT6360_LEDMODE_REG1 (MT6360_PMU_RGB1_ISNK)
53#define MT6360_LEDMODE_REG2 (MT6360_PMU_RGB2_ISNK)
54#define MT6360_LEDMODE_REG3 (MT6360_PMU_RGB3_ISNK)
55#define MT6360_LEDMODE_REG4 (0)
56#define MT6360_LEDMODE_MASK1 (0xc0)
57#define MT6360_LEDMODE_MASK2 (0xc0)
58#define MT6360_LEDMODE_MASK3 (0xc0)
59#define MT6360_LEDMODE_MASK4 (0)
60#define MT6360_PWMDUTY_REG1 (MT6360_PMU_RGB1_DIM)
61#define MT6360_PWMDUTY_REG2 (MT6360_PMU_RGB2_DIM)
62#define MT6360_PWMDUTY_REG3 (MT6360_PMU_RGB3_DIM)
63#define MT6360_PWMDUTY_REG4 (0)
64#define MT6360_PWMDUTY_MASK1 (0xff)
65#define MT6360_PWMDUTY_MASK2 (0xff)
66#define MT6360_PWMDUTY_MASK3 (0xff)
67#define MT6360_PWMDUTY_MASK4 (0)
68#define MT6360_PWMFREQ_REG1 (MT6360_PMU_RGB12_Freq)
69#define MT6360_PWMFREQ_REG2 (MT6360_PMU_RGB12_Freq)
70#define MT6360_PWMFREQ_REG3 (MT6360_PMU_RGB34_Freq)
71#define MT6360_PWMFREQ_REG4 (0)
72#define MT6360_PWMFREQ_MASK1 (0xe0)
73#define MT6360_PWMFREQ_MASK2 (0x1c)
74#define MT6360_PWMFREQ_MASK3 (0xe0)
75#define MT6360_PWMFREQ_MASK4 (0)
76#define MT6360_BREATH_REGBASE1 (MT6360_PMU_RGB1_Tr)
77#define MT6360_BREATH_REGBASE2 (MT6360_PMU_RGB2_Tr)
78#define MT6360_BREATH_REGBASE3 (MT6360_PMU_RGB3_Tr)
79#define MT6360_BREATH_REGBASE4 (0)
80#define MT6360_LEDEN_MASK1 (0x80)
81#define MT6360_LEDEN_MASK2 (0x40)
82#define MT6360_LEDEN_MASK3 (0x20)
83#define MT6360_LEDEN_MASK4 (0x10)
84#define MT6360_LEDEN_REG (MT6360_PMU_RGB_EN)
85#define MT6360_LEDALLEN_MASK (0xf0)
86
87#define MT6360_CHRIND_MASK (0x08)
88
89/* pattern order -> toff, tr1, tr2, ton, tf1, tf2 */
90#define MT6360_BRPATTERN_NUM (6)
91#define MT6360_BREATHREG_NUM (3)
92
93/* FLED setting */
94#define MT6360_CSENABLE_REG1 (MT6360_PMU_FLED_EN)
95#define MT6360_CSENABLE_MASK1 (0x02)
96#define MT6360_CSENABLE_REG2 (MT6360_PMU_FLED_EN)
97#define MT6360_CSENABLE_MASK2 (0x01)
98#define MT6360_TORBRIGHT_MAX1 (0x1f)
99#define MT6360_TORBRIGHT_MAX2 (0x1f)
100#define MT6360_TORBRIGHT_REG1 (MT6360_PMU_FLED1_TOR_CTRL)
101#define MT6360_TORBRIGHT_MASK1 (0x1f)
102#define MT6360_STRBRIGHT_REG1 (MT6360_PMU_FLED1_STRB_CTRL2)
103#define MT6360_STRBRIGHT_MASK1 (0x7f)
104#define MT6360_TORBRIGHT_REG2 (MT6360_PMU_FLED2_TOR_CTRL)
105#define MT6360_TORBRIGHT_MASK2 (0x1f)
106#define MT6360_STRBRIGHT_REG2 (MT6360_PMU_FLED2_STRB_CTRL2)
107#define MT6360_STRBRIGHT_MASK2 (0x7f)
108#define MT6360_TORENABLE_REG1 (MT6360_PMU_FLED_EN)
109#define MT6360_TORENABLE_MASK1 (0x08)
110#define MT6360_TORENABLE_REG2 (MT6360_PMU_FLED_EN)
111#define MT6360_TORENABLE_MASK2 (0x08)
112#define MT6360_STRBENABLE_REG1 (MT6360_PMU_FLED_EN)
113#define MT6360_STRBENABLE_MASK1 (0x06)
114#define MT6360_STRBENABLE_REG2 (MT6360_PMU_FLED_EN)
115#define MT6360_STRBENABLE_MASK2 (0x04)
116#define MT6360_STRBTIMEOUT_REG (MT6360_PMU_FLED_STRB_CTRL)
117#define MT6360_STRBTIMEOUT_MASK (0x7f)
118#define MT6360_TORCHCUR_MIN (25000)
119#define MT6360_TORCHCUR_STEP (12500)
120#define MT6360_TORCHCUR_MAX (400000)
121#define MT6360_STROBECUR_MIN (50000)
122#define MT6360_STROBECUR_STEP (12500)
123#define MT6360_STROBECUR_MAX (1500000)
124#define MT6360_STRBTIMEOUT_MIN (64000)
125#define MT6360_STRBTIMEOUT_STEP (32000)
126#define MT6360_STRBTIMEOUT_MAX (2432000)
127
128#define MT6360_FLEDSUPPORT_FAULTS (LED_FAULT_UNDER_VOLTAGE |\
129 LED_FAULT_SHORT_CIRCUIT |\
130 LED_FAULT_INPUT_VOLTAGE |\
131 LED_FAULT_TIMEOUT)
132
133struct mt6360_led_platform_data {
134 u32 rgbon_sync;
135 u32 fled1_ultraistrb;
136 u32 fled2_ultraistrb;
137};
138
139struct breath_element_cfg {
140 /* base, step in ms */
141 unsigned int base;
142 unsigned int step;
143 unsigned int maxval;
144 unsigned int reg_offset;
145 unsigned int reg_mask;
146};
147
148struct mt6360_led_classdev {
149 struct led_classdev cdev;
150 int index;
151 struct device_node *np;
152 unsigned int currsel_reg;
153 unsigned int currsel_mask;
154 unsigned int enable_mask;
155 unsigned int mode_reg;
156 unsigned int mode_mask;
157 unsigned int pwmduty_reg;
158 unsigned int pwmduty_mask;
159 unsigned int pwmfreq_reg;
160 unsigned int pwmfreq_mask;
161 unsigned int breath_regbase;
162};
163
164struct mt6360_fled_classdev {
165 struct led_classdev_flash fl_cdev;
166 int index;
167 struct v4l2_flash *v4l2_flash;
168 struct device_node *np;
169 unsigned int cs_enable_reg;
170 unsigned int cs_enable_mask;
171 unsigned int torch_bright_reg;
172 unsigned int torch_bright_mask;
173 unsigned int torch_enable_reg;
174 unsigned int torch_enable_mask;
175 unsigned int strobe_bright_reg;
176 unsigned int strobe_bright_mask;
177 unsigned int strobe_enable_reg;
178 unsigned int strobe_enable_mask;
179 unsigned int strobe_external_reg;
180 unsigned int strobe_external_mask;
181 u32 faults;
182};
183
184struct mt6360_led_info {
185 struct device *dev;
186 struct mt6360_led_platform_data *pdata;
187 struct regmap *regmap;
188 struct mt6360_led_classdev mtled_cdev[MT6360_LED_MAX];
189 struct mt6360_fled_classdev mtfled_cdev[MT6360_FLED_MAX];
190 unsigned long fl_torch_flags;
191 unsigned long fl_strobe_flags;
192};
193
194static const struct mt6360_led_platform_data def_platform_data = {
195 .rgbon_sync = 0,
196 .fled1_ultraistrb = 1,
197 .fled2_ultraistrb = 1,
198};
199
200static int mt6360_led_brightness_set(struct led_classdev *cdev,
201 enum led_brightness brightness)
202{
203 struct mt6360_led_classdev *mtled_cdev =
204 (struct mt6360_led_classdev *)cdev;
205 struct mt6360_led_info *mli = dev_get_drvdata(cdev->dev->parent);
206 int shift, sync_regval = 0, ret;
207
208 dev_dbg(cdev->dev, "%s, bright %d\n", __func__, brightness);
209 /* if isink1 user control, set chrind function to sw mode */
210 if (mtled_cdev->index == MT6360_LED_ISINK1) {
211 ret = regmap_update_bits(mli->regmap,
212 MT6360_PMU_RGB_EN, MT6360_CHRIND_MASK, 0xff);
213 if (ret < 0)
214 dev_err(cdev->dev, "disable chrind func fail\n");
215 }
216 if (brightness == LED_OFF) {
217 ret = regmap_update_bits(mli->regmap,
218 MT6360_LEDEN_REG, mtled_cdev->enable_mask, 0);
219 if (ret < 0)
220 return ret;
221 if (mtled_cdev->mode_reg == 0)
222 goto out_bright_set;
223 /* if off, force config to cc_mode */
224 shift = ffs(mtled_cdev->mode_mask) - 1;
225 ret = regmap_update_bits(mli->regmap, mtled_cdev->mode_reg,
226 mtled_cdev->mode_mask, MT6360_LEDMODE_CC << shift);
227 if (ret < 0)
228 dev_err(cdev->dev, "config cc mode fail\n");
229 goto out_bright_set;
230 }
231 shift = ffs(mtled_cdev->currsel_mask) - 1;
232 brightness -= 1;
233 ret = regmap_update_bits(mli->regmap, mtled_cdev->currsel_reg,
234 mtled_cdev->currsel_mask, brightness << shift);
235 if (ret < 0)
236 return ret;
237 if (mli->pdata->rgbon_sync) {
238 ret = regmap_read(mli->regmap, MT6360_LEDEN_REG, &sync_regval);
239 if (ret < 0)
240 goto out_bright_set;
241 ret = regmap_update_bits(mli->regmap,
242 MT6360_LEDEN_REG, MT6360_LEDALLEN_MASK, 0);
243 if (ret < 0)
244 goto out_bright_set;
245 sync_regval |= mtled_cdev->enable_mask;
246 ret = regmap_update_bits(mli->regmap, MT6360_LEDEN_REG,
247 MT6360_LEDALLEN_MASK, sync_regval);
248 } else {
249 ret = regmap_update_bits(mli->regmap, MT6360_LEDEN_REG,
250 mtled_cdev->enable_mask, 0xff);
251 }
252out_bright_set:
253 return ret;
254}
255
256static enum led_brightness mt6360_led_brightness_get(struct led_classdev *cdev)
257{
258 struct mt6360_led_classdev *mtled_cdev =
259 (struct mt6360_led_classdev *)cdev;
260 struct mt6360_led_info *mli = dev_get_drvdata(cdev->dev->parent);
261 unsigned int regval = 0;
262 int shift = ffs(mtled_cdev->currsel_mask) - 1, ret;
263
264 ret = regmap_read(mli->regmap, MT6360_LEDEN_REG, &regval);
265 if (ret < 0) {
266 dev_err(cdev->dev, "%s: get enable fail\n", __func__);
267 return LED_OFF;
268 }
269 if (!(regval & mtled_cdev->enable_mask))
270 return LED_OFF;
271 ret = regmap_read(mli->regmap, mtled_cdev->currsel_reg, &regval);
272 if (ret < 0) {
273 dev_err(cdev->dev, "%s: get isink fail\n", __func__);
274 return LED_OFF;
275 }
276 regval &= mtled_cdev->currsel_mask;
277 regval >>= shift;
278 return (regval + 1);
279}
280
281static const unsigned int dim_freqs[] = {
282 4, 8, 250, 500, 1000, 2000, 4000, 8000,
283};
284
285static int mt6360_led_blink_set(struct led_classdev *cdev,
286 unsigned long *delay_on, unsigned long *delay_off)
287{
288 struct mt6360_led_classdev *mtled_cdev =
289 (struct mt6360_led_classdev *)cdev;
290 struct mt6360_led_info *mli = dev_get_drvdata(cdev->dev->parent);
291 int freq, duty, shift, sum, ret;
292
293 if (mtled_cdev->mode_reg == 0)
294 return -ENOTSUPP;
295 if (*delay_on == 0 && *delay_off == 0)
296 *delay_on = *delay_off = 500;
297 sum = *delay_on + *delay_off;
298 for (freq = 0; freq < ARRAY_SIZE(dim_freqs); freq++) {
299 if (sum <= dim_freqs[freq])
300 break;
301 }
302 if (freq == ARRAY_SIZE(dim_freqs)) {
303 dev_err(cdev->dev, "exceed pwm frequency max\n");
304 return -EINVAL;
305 }
306 /* invert */
307 freq = ARRAY_SIZE(dim_freqs) - 1 - freq;
308 dev_dbg(cdev->dev, "freq sel [%d]\n", freq);
309 shift = ffs(mtled_cdev->pwmfreq_mask) - 1;
310 ret = regmap_update_bits(mli->regmap, mtled_cdev->pwmfreq_reg,
311 mtled_cdev->pwmfreq_mask, freq << shift);
312 if (ret < 0) {
313 dev_err(cdev->dev, "Failed to set pwmfreq\n");
314 return ret;
315 }
316 duty = 255 * (*delay_on) / sum;
317 shift = ffs(mtled_cdev->pwmduty_mask) - 1;
318 ret = regmap_update_bits(mli->regmap, mtled_cdev->pwmduty_reg,
319 mtled_cdev->pwmduty_mask, duty << shift);
320 if (ret < 0) {
321 dev_err(cdev->dev, "Failed to set pwmduty\n");
322 return ret;
323 }
324 dev_dbg(cdev->dev, "final duty [%d]\n", duty);
325 shift = ffs(mtled_cdev->mode_mask) - 1;
326 ret = regmap_update_bits(mli->regmap, mtled_cdev->mode_reg,
327 mtled_cdev->mode_mask, MT6360_LEDMODE_PWM << shift);
328 return ret;
329}
330
331#define MT6360_LED_DESC(_id) { \
332 .cdev = { \
333 .name = "mt6360_isink" #_id, \
334 .max_brightness = MT6360_SINKCUR_MAX##_id, \
335 .brightness_set_blocking = mt6360_led_brightness_set, \
336 .brightness_get = mt6360_led_brightness_get, \
337 .blink_set = mt6360_led_blink_set, \
338 }, \
339 .index = MT6360_LED_ISINK##_id, \
340 .currsel_reg = MT6360_CURRSEL_REG##_id, \
341 .currsel_mask = MT6360_CURRSEL_MASK##_id, \
342 .enable_mask = MT6360_LEDEN_MASK##_id, \
343 .mode_reg = MT6360_LEDMODE_REG##_id, \
344 .mode_mask = MT6360_LEDMODE_MASK##_id, \
345 .pwmduty_reg = MT6360_PWMDUTY_REG##_id, \
346 .pwmduty_mask = MT6360_PWMDUTY_MASK##_id, \
347 .pwmfreq_reg = MT6360_PWMFREQ_REG##_id, \
348 .pwmfreq_mask = MT6360_PWMFREQ_MASK##_id, \
349 .breath_regbase = MT6360_BREATH_REGBASE##_id, \
350}
351
352/* ISINK 1/2/3 for RGBLED, ISINK4 for MoonLight */
353static const struct mt6360_led_classdev def_led_classdev[MT6360_LED_MAX] = {
354 MT6360_LED_DESC(1),
355 MT6360_LED_DESC(2),
356 MT6360_LED_DESC(3),
357 MT6360_LED_DESC(4),
358};
359
360static inline bool mt6360_fled_check_flags_if_any(unsigned long *flags)
361{
362 return (*flags) ? true : false;
363}
364
365static int mt6360_fled_strobe_brightness_set(
366 struct led_classdev_flash *fled_cdev, u32 brightness)
367{
368 struct led_classdev *led_cdev = &fled_cdev->led_cdev;
369 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
370 struct led_flash_setting *fs = &fled_cdev->brightness;
371 struct mt6360_fled_classdev *mtfled_cdev = (void *)fled_cdev;
372 int id = mtfled_cdev->index, shift;
373 u32 val;
374
375 dev_dbg(led_cdev->dev,
376 "%s: id[%d], brightness %u\n", __func__, id, brightness);
377 val = brightness;
378 val = (val - fs->min) / fs->step;
379 shift = ffs(mtfled_cdev->strobe_bright_mask) - 1;
380 return regmap_update_bits(mli->regmap, mtfled_cdev->strobe_bright_reg,
381 mtfled_cdev->strobe_bright_mask, val << shift);
382}
383
384static int mt6360_fled_strobe_brightness_get(
385 struct led_classdev_flash *fled_cdev, u32 *brightness)
386{
387 struct led_classdev *led_cdev = &fled_cdev->led_cdev;
388 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
389 struct led_flash_setting *fs = &fled_cdev->brightness;
390 struct mt6360_fled_classdev *mtfled_cdev = (void *)fled_cdev;
391 int id = mtfled_cdev->index, shift, ret;
392 u32 regval = 0;
393
394 dev_dbg(led_cdev->dev, "%s: id[%d]\n", __func__, id);
395 ret = regmap_read(mli->regmap, mtfled_cdev->strobe_bright_reg, &regval);
396 if (ret < 0)
397 return ret;
398 regval &= mtfled_cdev->strobe_bright_mask;
399 shift = ffs(mtfled_cdev->strobe_bright_mask) - 1;
400 regval >>= shift;
401 /* convert to microamp value */
402 *brightness = regval * fs->step + fs->min;
403 return 0;
404}
405
406static int mt6360_fled_strobe_set(
407 struct led_classdev_flash *fled_cdev, bool state)
408{
409 struct led_classdev *led_cdev = &fled_cdev->led_cdev;
410 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
411 struct mt6360_fled_classdev *mtfled_cdev = (void *)fled_cdev;
412 int id = mtfled_cdev->index, ret;
413
414 dev_dbg(led_cdev->dev, "%s: id[%d], state %d\n", __func__, id, state);
415 if (!(state ^ test_bit(id, &mli->fl_strobe_flags))) {
416 dev_dbg(led_cdev->dev,
417 "no change for strobe [%lu]\n", mli->fl_strobe_flags);
418 return 0;
419 }
420 if (mt6360_fled_check_flags_if_any(&mli->fl_torch_flags)) {
421 dev_err(led_cdev->dev,
422 "Disable all leds torch [%lu]\n", mli->fl_torch_flags);
423 return -EINVAL;
424 }
425 ret = regmap_update_bits(mli->regmap, mtfled_cdev->cs_enable_reg,
426 mtfled_cdev->cs_enable_mask, state ? 0xff : 0);
427 if (ret < 0) {
428 dev_err(led_cdev->dev, "Fail to set cs enable [%d]\n", state);
429 goto out_strobe_set;
430 }
431 ret = regmap_update_bits(mli->regmap, mtfled_cdev->strobe_enable_reg,
432 mtfled_cdev->strobe_enable_mask, state ? 0xff : 0);
433 if (ret < 0) {
434 dev_err(led_cdev->dev, "Fail to set strb enable [%d]\n", state);
435 goto out_strobe_set;
436 }
437 if (state) {
438 if (!mt6360_fled_check_flags_if_any(&mli->fl_strobe_flags))
439 usleep_range(5000, 6000);
440 set_bit(id, &mli->fl_strobe_flags);
441 mtfled_cdev->faults = 0;
442 } else {
443 clear_bit(id, &mli->fl_strobe_flags);
444 if (!mt6360_fled_check_flags_if_any(&mli->fl_strobe_flags))
445 usleep_range(400, 500);
446 }
447out_strobe_set:
448 return ret;
449}
450
451static int mt6360_fled_strobe_get(
452 struct led_classdev_flash *fled_cdev, bool *state)
453{
454 struct led_classdev *led_cdev = &fled_cdev->led_cdev;
455 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
456 struct mt6360_fled_classdev *mtfled_cdev = (void *)fled_cdev;
457 int id = mtfled_cdev->index;
458
459 dev_dbg(led_cdev->dev, "%s: id[%d]\n", __func__, id);
460 *state = test_bit(id, &mli->fl_strobe_flags) ? true : false;
461 return 0;
462}
463
464static int mt6360_fled_strobe_timeout_set(
465 struct led_classdev_flash *fled_cdev, u32 timeout)
466{
467 struct led_classdev *led_cdev = &fled_cdev->led_cdev;
468 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
469 struct led_flash_setting *ts = &fled_cdev->timeout;
470 struct mt6360_fled_classdev *mtfled_cdev = (void *)fled_cdev;
471 int id = mtfled_cdev->index, shift, ret;
472 u32 regval;
473
474 dev_dbg(led_cdev->dev,
475 "%s: id[%d], timeout %u\n", __func__, id, timeout);
476 regval = (timeout - ts->min) / ts->step;
477 shift = ffs(MT6360_STRBTIMEOUT_MASK) - 1;
478 ret = regmap_update_bits(mli->regmap, MT6360_STRBTIMEOUT_REG,
479 MT6360_STRBTIMEOUT_MASK, regval << shift);
480 return ret;
481}
482
483static int mt6360_fled_strobe_fault_get(
484 struct led_classdev_flash *fled_cdev, u32 *fault)
485{
486 struct led_classdev *led_cdev = &fled_cdev->led_cdev;
487 struct mt6360_fled_classdev *mtfled_cdev = (void *)fled_cdev;
488 int id = mtfled_cdev->index;
489
490 dev_dbg(led_cdev->dev, "%s: id[%d]\n", __func__, id);
491 *fault = mtfled_cdev->faults;
492 return 0;
493}
494
495static const struct led_flash_ops mt6360_fled_ops = {
496 .flash_brightness_set = mt6360_fled_strobe_brightness_set,
497 .flash_brightness_get = mt6360_fled_strobe_brightness_get,
498 .strobe_set = mt6360_fled_strobe_set,
499 .strobe_get = mt6360_fled_strobe_get,
500 .timeout_set = mt6360_fled_strobe_timeout_set,
501 .fault_get = mt6360_fled_strobe_fault_get,
502};
503
504static int mt6360_fled_brightness_set(struct led_classdev *led_cdev,
505 enum led_brightness brightness)
506{
507 struct led_classdev_flash *lcf = lcdev_to_flcdev(led_cdev);
508 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
509 struct mt6360_fled_classdev *mtfled_cdev = (void *)lcf;
510 int id = mtfled_cdev->index, shift, keep, ret;
511
512 dev_dbg(led_cdev->dev,
513 "%s: id [%d], brightness %d\n", __func__, id, brightness);
514 if (mt6360_fled_check_flags_if_any(&mli->fl_strobe_flags)) {
515 dev_err(led_cdev->dev,
516 "Disable all leds strobe [%lu]\n", mli->fl_strobe_flags);
517 return -EINVAL;
518 }
519 if (brightness == LED_OFF) {
520 clear_bit(id, &mli->fl_torch_flags);
521 keep = mt6360_fled_check_flags_if_any(&mli->fl_torch_flags);
522 ret = regmap_update_bits(mli->regmap,
523 mtfled_cdev->torch_enable_reg,
524 mtfled_cdev->torch_enable_mask,
525 keep ? 0xff : 0);
526 if (ret < 0) {
527 dev_err(led_cdev->dev, "Fail to set torch disable\n");
528 goto out_bright_set;
529 }
530 ret = regmap_update_bits(mli->regmap,
531 mtfled_cdev->cs_enable_reg,
532 mtfled_cdev->cs_enable_mask, 0);
533 if (ret < 0)
534 dev_err(led_cdev->dev, "Fail to set torch disable\n");
535 goto out_bright_set;
536 }
537 shift = ffs(mtfled_cdev->torch_bright_mask) - 1;
538 brightness -= 1;
539 ret = regmap_update_bits(mli->regmap, mtfled_cdev->torch_bright_reg,
540 mtfled_cdev->torch_bright_mask, brightness << shift);
541 if (ret < 0) {
542 dev_err(led_cdev->dev,
543 "Fail to set torch bright [%d]\n", brightness);
544 goto out_bright_set;
545 }
546 ret = regmap_update_bits(mli->regmap, mtfled_cdev->cs_enable_reg,
547 mtfled_cdev->cs_enable_mask, 0xff);
548 if (ret < 0) {
549 dev_err(led_cdev->dev, "Fail to set cs enable\n");
550 goto out_bright_set;
551 }
552 ret = regmap_update_bits(mli->regmap, mtfled_cdev->torch_enable_reg,
553 mtfled_cdev->torch_enable_mask, 0xff);
554 set_bit(id, &mli->fl_torch_flags);
555out_bright_set:
556 return ret;
557}
558
559static enum led_brightness mt6360_fled_brightness_get(
560 struct led_classdev *led_cdev)
561{
562 struct led_classdev_flash *lcf = lcdev_to_flcdev(led_cdev);
563 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
564 struct mt6360_fled_classdev *mtfled_cdev = (void *)lcf;
565 int id = mtfled_cdev->index, shift, ret;
566 u32 regval = 0;
567
568 dev_dbg(led_cdev->dev, "%s: id [%d]\n", __func__, id);
569 if (!test_bit(id, &mli->fl_torch_flags))
570 return LED_OFF;
571 ret = regmap_read(mli->regmap, mtfled_cdev->torch_bright_reg, &regval);
572 if (ret < 0) {
573 dev_err(led_cdev->dev, "%s: Fail to get torb reg\n", __func__);
574 return LED_OFF;
575 }
576 shift = ffs(mtfled_cdev->torch_bright_mask) - 1;
577 regval &= mtfled_cdev->torch_bright_mask;
578 regval >>= shift;
579 return (regval + 1);
580}
581
582#define MT6360_FLED_DESC(_id) { \
583 .fl_cdev = { \
584 .led_cdev = { \
585 .name = "mt6360_fled_ch" #_id, \
586 .max_brightness = MT6360_TORBRIGHT_MAX##_id, \
587 .brightness_set_blocking = mt6360_fled_brightness_set, \
588 .brightness_get = mt6360_fled_brightness_get, \
589 .flags = LED_DEV_CAP_FLASH, \
590 }, \
591 .brightness = { \
592 .min = MT6360_STROBECUR_MIN, \
593 .step = MT6360_STROBECUR_STEP, \
594 .max = MT6360_STROBECUR_MAX, \
595 .val = MT6360_STROBECUR_MIN, \
596 }, \
597 .timeout = { \
598 .min = MT6360_STRBTIMEOUT_MIN, \
599 .step = MT6360_STRBTIMEOUT_STEP, \
600 .max = MT6360_STRBTIMEOUT_MAX, \
601 .val = MT6360_STRBTIMEOUT_MIN, \
602 }, \
603 .ops = &mt6360_fled_ops, \
604 }, \
605 .index = MT6360_FLED_CH##_id, \
606 .cs_enable_reg = MT6360_CSENABLE_REG##_id, \
607 .cs_enable_mask = MT6360_CSENABLE_MASK##_id, \
608 .torch_bright_reg = MT6360_TORBRIGHT_REG##_id, \
609 .torch_bright_mask = MT6360_TORBRIGHT_MASK##_id, \
610 .torch_enable_reg = MT6360_TORENABLE_REG##_id, \
611 .torch_enable_mask = MT6360_TORENABLE_MASK##_id, \
612 .strobe_bright_reg = MT6360_STRBRIGHT_REG##_id, \
613 .strobe_bright_mask = MT6360_STRBRIGHT_MASK##_id, \
614 .strobe_enable_reg = MT6360_STRBENABLE_REG##_id, \
615 .strobe_enable_mask = MT6360_STRBENABLE_MASK##_id, \
616}
617
618static const struct mt6360_fled_classdev def_fled_classdev[MT6360_FLED_MAX] = {
619 MT6360_FLED_DESC(1),
620 MT6360_FLED_DESC(2),
621};
622
623#if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS)
624static int mt6360_fled_external_strobe_set(
625 struct v4l2_flash *v4l2_flash, bool enable)
626{
627 struct led_classdev_flash *lcf = v4l2_flash->fled_cdev;
628 struct led_classdev *led_cdev = &lcf->led_cdev;
629 struct mt6360_led_info *mli = dev_get_drvdata(led_cdev->dev->parent);
630 struct mt6360_fled_classdev *mtfled_cdev = (void *)lcf;
631 int id = mtfled_cdev->index, ret;
632
633 dev_dbg(led_cdev->dev, "%s: id[%d], %d\n", __func__, id, enable);
634 if (!(enable ^ test_bit(id, &mli->fl_strobe_flags))) {
635 dev_dbg(led_cdev->dev,
636 "no change for strobe [%lu]\n", mli->fl_strobe_flags);
637 return 0;
638 }
639 if (mt6360_fled_check_flags_if_any(&mli->fl_torch_flags)) {
640 dev_err(led_cdev->dev,
641 "Disable all leds torch [%lu]\n", mli->fl_torch_flags);
642 return -EINVAL;
643 }
644 ret = regmap_update_bits(mli->regmap, mtfled_cdev->cs_enable_reg,
645 mtfled_cdev->cs_enable_mask, enable ? 0xff : 0);
646 if (enable) {
647 set_bit(id, &mli->fl_strobe_flags);
648 mtfled_cdev->faults = 0;
649 } else
650 clear_bit(id, &mli->fl_strobe_flags);
651 return ret;
652}
653
654static const struct v4l2_flash_ops v4l2_flash_ops = {
655 .external_strobe_set = mt6360_fled_external_strobe_set,
656};
657
658static void mt6360_init_v4l2_flash_config(
659 struct mt6360_fled_classdev *mtfled_cdev,
660 struct v4l2_flash_config *config)
661{
662 struct led_flash_setting *torch_intensity = &config->intensity;
663 struct led_classdev *led_cdev = &(mtfled_cdev->fl_cdev.led_cdev);
664 s32 val;
665
666 snprintf(config->dev_name, sizeof(config->dev_name),
667 "%s", mtfled_cdev->fl_cdev.led_cdev.name);
668 torch_intensity->min = MT6360_TORCHCUR_MIN;
669 torch_intensity->step = MT6360_TORCHCUR_STEP;
670 val = MT6360_TORCHCUR_MIN;
671 val += ((led_cdev->max_brightness - 1) * MT6360_TORCHCUR_STEP);
672 torch_intensity->val = torch_intensity->max = val;
673 config->flash_faults |= MT6360_FLEDSUPPORT_FAULTS;
674 config->has_external_strobe = 1;
675}
676#else
677static const struct v4l2_flash_ops v4l2_flash_ops;
678
679static void mt6360_init_v4l2_flash_config(
680 struct mt6360_fled_classdev *mtfled_cdev,
681 struct v4l2_flash_config *config)
682{
683}
684#endif /* IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS) */
685
686static irqreturn_t mt6360_pmu_fled_lvf_evt_handler(int irq, void *data)
687{
688 struct mt6360_led_info *mli = data;
689
690 dev_err(mli->dev, "%s\n", __func__);
691 mli->mtfled_cdev[MT6360_FLED_CH1].faults |= LED_FAULT_UNDER_VOLTAGE;
692 mli->mtfled_cdev[MT6360_FLED_CH2].faults |= LED_FAULT_UNDER_VOLTAGE;
693 return IRQ_HANDLED;
694}
695
696static irqreturn_t mt6360_pmu_fled2_short_evt_handler(int irq, void *data)
697{
698 struct mt6360_led_info *mli = data;
699
700 dev_err(mli->dev, "%s\n", __func__);
701 mli->mtfled_cdev[MT6360_FLED_CH2].faults |= LED_FAULT_SHORT_CIRCUIT;
702 return IRQ_HANDLED;
703}
704
705static irqreturn_t mt6360_pmu_fled1_short_evt_handler(int irq, void *data)
706{
707 struct mt6360_led_info *mli = data;
708
709 dev_err(mli->dev, "%s\n", __func__);
710 mli->mtfled_cdev[MT6360_FLED_CH1].faults |= LED_FAULT_SHORT_CIRCUIT;
711 return IRQ_HANDLED;
712}
713
714static irqreturn_t mt6360_pmu_fled2_strb_to_evt_handler(int irq, void *data)
715{
716 struct mt6360_led_info *mli = data;
717
718 dev_dbg(mli->dev, "%s\n", __func__);
719 mli->mtfled_cdev[MT6360_FLED_CH2].faults |= LED_FAULT_TIMEOUT;
720 return IRQ_HANDLED;
721}
722
723static irqreturn_t mt6360_pmu_fled1_strb_to_evt_handler(int irq, void *data)
724{
725 struct mt6360_led_info *mli = data;
726
727 dev_dbg(mli->dev, "%s\n", __func__);
728 mli->mtfled_cdev[MT6360_FLED_CH1].faults |= LED_FAULT_TIMEOUT;
729 return IRQ_HANDLED;
730}
731
732static irqreturn_t mt6360_pmu_fled_chg_vinovp_evt_handler(int irq, void *data)
733{
734 struct mt6360_led_info *mli = data;
735
736 dev_warn(mli->dev, "%s\n", __func__);
737 mli->mtfled_cdev[MT6360_FLED_CH1].faults |= LED_FAULT_INPUT_VOLTAGE;
738 mli->mtfled_cdev[MT6360_FLED_CH2].faults |= LED_FAULT_INPUT_VOLTAGE;
739 return IRQ_HANDLED;
740}
741
742static struct mt6360_pmu_irq_desc mt6360_pmu_fled_irq_desc[] = {
743 { "fled_chg_vinovp_evt", mt6360_pmu_fled_chg_vinovp_evt_handler },
744 { "fled_lvf_evt", mt6360_pmu_fled_lvf_evt_handler },
745 { "fled2_short_evt", mt6360_pmu_fled2_short_evt_handler },
746 { "fled1_short_evt", mt6360_pmu_fled1_short_evt_handler },
747 { "fled2_strb_to_evt", mt6360_pmu_fled2_strb_to_evt_handler },
748 { "fled1_strb_to_evt", mt6360_pmu_fled1_strb_to_evt_handler },
749};
750
751static int mt6360_fled_irq_register(struct platform_device *pdev)
752{
753 struct mt6360_pmu_irq_desc *irq_desc;
754 int i, irq, ret;
755
756 for (i = 0; i < ARRAY_SIZE(mt6360_pmu_fled_irq_desc); i++) {
757 irq_desc = mt6360_pmu_fled_irq_desc + i;
758 if (unlikely(!irq_desc->name))
759 continue;
760 irq = platform_get_irq_byname(pdev, irq_desc->name);
761 if (irq < 0)
762 continue;
763 ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
764 irq_desc->irq_handler,
765 IRQF_TRIGGER_FALLING,
766 irq_desc->name,
767 platform_get_drvdata(pdev));
768 if (ret < 0) {
769 dev_err(&pdev->dev,
770 "request %s irq fail\n", irq_desc->name);
771 return ret;
772 }
773 }
774 return 0;
775}
776
777static int mt6360_iled_parse_dt(struct device *dev,
778 struct mt6360_led_info *mli)
779{
780 struct device_node *iled_np, *child;
781 struct mt6360_led_classdev *mtled_cdev;
782 u32 val;
783 int ret;
784
785 if (!dev->of_node)
786 return 0;
787 iled_np = of_find_node_by_name(dev->of_node, "iled");
788 if (!iled_np)
789 return 0;
790 for_each_available_child_of_node(iled_np, child) {
791 ret = of_property_read_u32(child, "reg", &val);
792 if (ret) {
793 dev_err(dev, "Fail to read reg property\n");
794 continue;
795 }
796 if (val >= MT6360_LED_MAX) {
797 dev_err(dev, "Invalid iled reg [%u]\n", val);
798 ret = -EINVAL;
799 goto out_iled_dt;
800 }
801 mtled_cdev = mli->mtled_cdev + val;
802
803 of_property_read_string(child,
804 "label", &(mtled_cdev->cdev.name));
805 of_property_read_string(child, "linux,default-trigger",
806 &(mtled_cdev->cdev.default_trigger));
807 mtled_cdev->np = child;
808 }
809 return 0;
810out_iled_dt:
811 of_node_put(child);
812 return ret;
813}
814
815static int mt6360_fled_parse_dt(struct device *dev,
816 struct mt6360_led_info *mli)
817{
818 struct device_node *fled_np, *child;
819 struct mt6360_fled_classdev *mtfled_cdev;
820 struct led_classdev *led_cdev;
821 struct led_flash_setting *fs;
822 u32 val;
823 int ret;
824
825 if (!dev->of_node)
826 return 0;
827 fled_np = of_find_node_by_name(dev->of_node, "fled");
828 if (!fled_np)
829 return 0;
830 for_each_available_child_of_node(fled_np, child) {
831 ret = of_property_read_u32(child, "reg", &val);
832 if (ret) {
833 dev_err(dev, "Fail to read reg property\n");
834 continue;
835 }
836 if (val >= MT6360_FLED_MAX) {
837 dev_err(dev, "Invalid fled reg [%u]\n", val);
838 ret = -EINVAL;
839 goto out_fled_dt;
840 }
841 mtfled_cdev = mli->mtfled_cdev + val;
842
843 of_property_read_string(child, "label",
844 &(mtfled_cdev->fl_cdev.led_cdev.name));
845 ret = of_property_read_u32(child, "led-max-microamp", &val);
846 if (ret) {
847 dev_warn(dev, "led-max-microamp property missing\n");
848 val = MT6360_TORCHCUR_MIN;
849 }
850 if (val < MT6360_TORCHCUR_MIN)
851 val = MT6360_TORCHCUR_MIN;
852 val = (val - MT6360_TORCHCUR_MIN) / MT6360_TORCHCUR_STEP + 1;
853 led_cdev = &(mtfled_cdev->fl_cdev.led_cdev);
854 led_cdev->max_brightness = min(led_cdev->max_brightness, val);
855 ret = of_property_read_u32(child, "flash-max-microamp", &val);
856 if (ret) {
857 dev_warn(dev, "flash-max-microamp property missing\n");
858 val = MT6360_STROBECUR_MIN;
859 }
860 if (val < MT6360_STROBECUR_MIN)
861 val = MT6360_STROBECUR_MIN;
862 fs = &(mtfled_cdev->fl_cdev.brightness);
863 fs->val = fs->max = min(fs->max, val);
864 ret = of_property_read_u32(child, "flash-max-timeout", &val);
865 if (ret) {
866 dev_warn(dev, "flash-max-timeout property missing\n");
867 val = MT6360_STRBTIMEOUT_MIN;
868 }
869 if (val < MT6360_STRBTIMEOUT_MIN)
870 val = MT6360_STRBTIMEOUT_MIN;
871 fs = &(mtfled_cdev->fl_cdev.timeout);
872 fs->val = fs->max = min(fs->max, val);
873 mtfled_cdev->np = child;
874 }
875 return 0;
876out_fled_dt:
877 of_node_put(child);
878 return ret;
879}
880
881static const struct mt6360_pdata_prop mt6360_pdata_props[] = {
882 MT6360_PDATA_VALPROP(fled1_ultraistrb, struct mt6360_led_platform_data,
883 MT6360_PMU_FLED1_STRB_CTRL2, 7, 0x80, NULL, 0),
884 MT6360_PDATA_VALPROP(fled2_ultraistrb, struct mt6360_led_platform_data,
885 MT6360_PMU_FLED2_STRB_CTRL2, 7, 0x80, NULL, 0),
886};
887
888static int mt6360_led_apply_pdata(struct mt6360_led_info *mli,
889 struct mt6360_led_platform_data *pdata)
890{
891 int ret;
892
893 dev_dbg(mli->dev, "%s ++\n", __func__);
894 ret = mt6360_pdata_apply_helper(mli->regmap, pdata, mt6360_pdata_props,
895 ARRAY_SIZE(mt6360_pdata_props));
896 if (ret < 0)
897 return ret;
898 dev_dbg(mli->dev, "%s --\n", __func__);
899 return 0;
900}
901
902static const struct mt6360_val_prop mt6360_val_props[] = {
903 MT6360_DT_VALPROP(rgbon_sync, struct mt6360_led_platform_data),
904};
905
906static int mt6360_led_parse_dt_data(struct device *dev,
907 struct mt6360_led_platform_data *pdata)
908{
909 struct device_node *np = dev->of_node;
910
911 dev_dbg(dev, "%s ++\n", __func__);
912 memcpy(pdata, &def_platform_data, sizeof(*pdata));
913 mt6360_dt_parser_helper(np, (void *)pdata,
914 mt6360_val_props, ARRAY_SIZE(mt6360_val_props));
915 dev_dbg(dev, "%s --\n", __func__);
916 return 0;
917}
918
919static int mt6360_led_probe(struct platform_device *pdev)
920{
921 struct mt6360_led_platform_data *pdata = dev_get_platdata(&pdev->dev);
922 struct mt6360_led_info *mli;
923 struct mt6360_led_classdev *mtled_cdev;
924 struct mt6360_fled_classdev *mtfled_cdev;
925 struct v4l2_flash_config v4l2_config;
926 int i, ret;
927
928 dev_dbg(&pdev->dev, "%s\n", __func__);
929 mli = devm_kzalloc(&pdev->dev, sizeof(*mli), GFP_KERNEL);
930 if (!mli)
931 return -ENOMEM;
932 if (pdev->dev.of_node) {
933 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
934 if (!pdata)
935 return -ENOMEM;
936 ret = mt6360_led_parse_dt_data(&pdev->dev, pdata);
937 if (ret < 0) {
938 dev_err(&pdev->dev, "parse dt fail\n");
939 return ret;
940 }
941 }
942 if (!pdata) {
943 dev_err(&pdev->dev, "no platform data specified\n");
944 return -EINVAL;
945 }
946 mli->dev = &pdev->dev;
947 mli->pdata = pdata;
948 platform_set_drvdata(pdev, mli);
949
950 /* get parent regmap */
951 mli->regmap = dev_get_regmap(pdev->dev.parent, NULL);
952 if (!mli->regmap) {
953 dev_err(&pdev->dev, "Failed to get parent regmap\n");
954 return -ENODEV;
955 }
956 /* apply platform data */
957 ret = mt6360_led_apply_pdata(mli, pdata);
958 if (ret < 0) {
959 dev_err(&pdev->dev, "apply pdata fail\n");
960 return ret;
961 }
962 /* iled register */
963 memcpy(mli->mtled_cdev, def_led_classdev, sizeof(def_led_classdev));
964 ret = mt6360_iled_parse_dt(&pdev->dev, mli);
965 if (ret < 0) {
966 dev_err(&pdev->dev, "Fail to parse iled dt\n");
967 return ret;
968 }
969 for (i = 0; i < MT6360_LED_MAX; i++) {
970 mtled_cdev = mli->mtled_cdev + i;
971 ret = devm_led_classdev_register(&pdev->dev,
972 &(mtled_cdev->cdev));
973 if (ret < 0) {
974 dev_err(&pdev->dev, "Failed to register led[%d]\n", i);
975 return ret;
976 }
977 mtled_cdev->cdev.dev->of_node = mtled_cdev->np;
978 }
979 /* fled register */
980 memcpy(mli->mtfled_cdev, def_fled_classdev, sizeof(def_fled_classdev));
981 ret = mt6360_fled_parse_dt(&pdev->dev, mli);
982 if (ret < 0) {
983 dev_err(&pdev->dev, "Fail to parse fled dt\n");
984 return ret;
985 }
986 for (i = 0; i < MT6360_FLED_MAX; i++) {
987 mtfled_cdev = mli->mtfled_cdev + i;
988 ret = led_classdev_flash_register(&pdev->dev,
989 &mtfled_cdev->fl_cdev);
990 if (ret < 0) {
991 dev_err(&pdev->dev, "Failed to register fled[%d]\n", i);
992 goto out_fled_cdev;
993 }
994 }
995 for (i = 0; i < MT6360_FLED_MAX; i++) {
996 mtfled_cdev = mli->mtfled_cdev + i;
997 memset(&v4l2_config, 0, sizeof(v4l2_config));
998 mt6360_init_v4l2_flash_config(mtfled_cdev, &v4l2_config);
999 mtfled_cdev->v4l2_flash = v4l2_flash_init(&pdev->dev,
1000 of_fwnode_handle(mtfled_cdev->np),
1001 &mtfled_cdev->fl_cdev,
1002 &v4l2_flash_ops, &v4l2_config);
1003 if (IS_ERR(mtfled_cdev->v4l2_flash)) {
1004 dev_err(&pdev->dev, "Failed to register v4l2_sd\n");
1005 ret = PTR_ERR(mtfled_cdev->v4l2_flash);
1006 goto out_v4l2_sd;
1007 }
1008 }
1009 ret = mt6360_fled_irq_register(pdev);
1010 if (ret < 0) {
1011 dev_err(&pdev->dev, "Failed to register irqs\n");
1012 goto out_v4l2_sd;
1013 }
1014 dev_info(&pdev->dev, "Successfully probed\n");
1015 return 0;
1016out_v4l2_sd:
1017 while (--i >= 0) {
1018 mtfled_cdev = mli->mtfled_cdev + i;
1019 v4l2_flash_release(mtfled_cdev->v4l2_flash);
1020 }
1021 i = MT6360_FLED_MAX;
1022out_fled_cdev:
1023 while (--i >= 0) {
1024 mtfled_cdev = mli->mtfled_cdev + i;
1025 led_classdev_flash_unregister(&mtfled_cdev->fl_cdev);
1026 }
1027 return ret;
1028}
1029
1030static int mt6360_led_remove(struct platform_device *pdev)
1031{
1032 struct mt6360_led_info *mli = platform_get_drvdata(pdev);
1033 struct mt6360_fled_classdev *mtfled_cdev;
1034 int i;
1035
1036 for (i = 0; i < MT6360_FLED_MAX; i++) {
1037 mtfled_cdev = mli->mtfled_cdev + i;
1038 v4l2_flash_release(mtfled_cdev->v4l2_flash);
1039 led_classdev_flash_unregister(&mtfled_cdev->fl_cdev);
1040 }
1041 return 0;
1042}
1043
1044static const struct of_device_id __maybe_unused mt6360_led_of_id[] = {
1045 { .compatible = "mediatek,mt6360_led", },
1046 {},
1047};
1048MODULE_DEVICE_TABLE(of, mt6360_led_of_id);
1049
1050static const struct platform_device_id mt6360_led_id[] = {
1051 { "mt6360_led", 0 },
1052 {},
1053};
1054MODULE_DEVICE_TABLE(platform, mt6360_led_id);
1055
1056static struct platform_driver mt6360_led_driver = {
1057 .driver = {
1058 .name = "mt6360_led",
1059 .owner = THIS_MODULE,
1060 .of_match_table = of_match_ptr(mt6360_led_of_id),
1061 },
1062 .probe = mt6360_led_probe,
1063 .remove = mt6360_led_remove,
1064 .id_table = mt6360_led_id,
1065};
1066module_platform_driver(mt6360_led_driver);
1067
1068MODULE_AUTHOR("CY_Huang <cy_huang@richtek.com>");
1069MODULE_DESCRIPTION("MT6360 Led Driver");
1070MODULE_LICENSE("GPL");
1071MODULE_VERSION("1.0.0");