18 #include <linux/module.h>
19 #include <linux/kernel.h>
25 #include <linux/slab.h>
35 #define MC13783_REG_LED_CONTROL_0 51
36 #define MC13783_LED_C0_ENABLE_BIT (1 << 0)
37 #define MC13783_LED_C0_TRIODE_MD_BIT (1 << 7)
38 #define MC13783_LED_C0_TRIODE_AD_BIT (1 << 8)
39 #define MC13783_LED_C0_TRIODE_KP_BIT (1 << 9)
40 #define MC13783_LED_C0_BOOST_BIT (1 << 10)
41 #define MC13783_LED_C0_ABMODE_MASK 0x7
42 #define MC13783_LED_C0_ABMODE 11
43 #define MC13783_LED_C0_ABREF_MASK 0x3
44 #define MC13783_LED_C0_ABREF 14
46 #define MC13783_REG_LED_CONTROL_1 52
47 #define MC13783_LED_C1_TC1HALF_BIT (1 << 18)
49 #define MC13783_REG_LED_CONTROL_2 53
50 #define MC13783_LED_C2_BL_P_MASK 0xf
51 #define MC13783_LED_C2_MD_P 9
52 #define MC13783_LED_C2_AD_P 13
53 #define MC13783_LED_C2_KP_P 17
54 #define MC13783_LED_C2_BL_C_MASK 0x7
55 #define MC13783_LED_C2_MD_C 0
56 #define MC13783_LED_C2_AD_C 3
57 #define MC13783_LED_C2_KP_C 6
59 #define MC13783_REG_LED_CONTROL_3 54
60 #define MC13783_LED_C3_TC_P 6
61 #define MC13783_LED_C3_TC_P_MASK 0x1f
63 #define MC13783_REG_LED_CONTROL_4 55
64 #define MC13783_REG_LED_CONTROL_5 56
66 #define MC13783_LED_Cx_PERIOD 21
67 #define MC13783_LED_Cx_PERIOD_MASK 0x3
68 #define MC13783_LED_Cx_SLEWLIM_BIT (1 << 23)
69 #define MC13783_LED_Cx_TRIODE_TC_BIT (1 << 23)
70 #define MC13783_LED_Cx_TC_C_MASK 0x3
121 static void mc13783_led_set(
struct led_classdev *led_cdev,
274 dev_err(&pdev->
dev,
"missing platform data\n");
286 dev_err(&pdev->
dev,
"failed to alloc memory\n");
290 ret = mc13783_leds_prepare(pdev);
292 dev_err(&pdev->
dev,
"unable to init led driver\n");
296 for (i = 0; i < pdata->
num_leds; i++) {
298 led_cur = &pdata->
led[
i];
306 if (init_led & (1 << led_cur->
id)) {
307 dev_err(&pdev->
dev,
"led %d already initialized\n",
313 init_led |= 1 << led_cur->
id;
316 led_dat->
cdev.brightness_set = mc13783_led_set;
318 led_dat->
id = led_cur->
id;
325 dev_err(&pdev->
dev,
"failed to register led %d\n",
330 ret = mc13783_led_setup(led_dat, led_cur->
max_current);
332 dev_err(&pdev->
dev,
"unable to init led %d\n",
339 platform_set_drvdata(pdev, led);
343 for (i = i - 1; i >= 0; i--) {
354 struct mc13783_led *led = platform_get_drvdata(pdev);
358 for (i = 0; i < pdata->
num_leds; i++) {
374 platform_set_drvdata(pdev,
NULL);
380 .name =
"mc13783-led",
383 .probe = mc13783_led_probe,