13 #include <linux/module.h>
15 #include <linux/slab.h>
22 #define MAX8997_LED_FLASH_SHIFT 3
23 #define MAX8997_LED_FLASH_CUR_MASK 0xf8
24 #define MAX8997_LED_MOVIE_SHIFT 4
25 #define MAX8997_LED_MOVIE_CUR_MASK 0xf0
27 #define MAX8997_LED_FLASH_MAX_BRIGHTNESS 0x1f
28 #define MAX8997_LED_MOVIE_MAX_BRIGHTNESS 0xf
29 #define MAX8997_LED_NONE_MAX_BRIGHTNESS 0
31 #define MAX8997_LED0_FLASH_MASK 0x1
32 #define MAX8997_LED0_FLASH_PIN_MASK 0x5
33 #define MAX8997_LED0_MOVIE_MASK 0x8
34 #define MAX8997_LED0_MOVIE_PIN_MASK 0x28
36 #define MAX8997_LED1_FLASH_MASK 0x2
37 #define MAX8997_LED1_FLASH_PIN_MASK 0x6
38 #define MAX8997_LED1_MOVIE_MASK 0x10
39 #define MAX8997_LED1_MOVIE_PIN_MASK 0x30
41 #define MAX8997_LED_BOOST_ENABLE_MASK (1 << 6)
96 "failed to update register(%d)\n", ret);
116 "failed to update register(%d)\n", ret);
121 static void max8997_led_set_current(
struct max8997_led *led,
126 u8 val = 0, mask = 0,
reg = 0;
149 "failed to update register(%d)\n", ret);
153 static void max8997_led_brightness_set(
struct led_classdev *led_cdev,
160 max8997_led_set_current(led, value);
161 max8997_led_enable(led,
true);
163 max8997_led_set_current(led, value);
164 max8997_led_enable(led,
false);
180 ret +=
sprintf(buf,
"FLASH\n");
183 ret +=
sprintf(buf,
"MOVIE\n");
186 ret +=
sprintf(buf,
"FLASH_PIN_CONTROL\n");
189 ret +=
sprintf(buf,
"MOVIE_PIN_CONTROL\n");
203 const char *buf,
size_t size)
212 if (!
strncmp(buf,
"FLASH_PIN_CONTROL", 17))
214 else if (!
strncmp(buf,
"MOVIE_PIN_CONTROL", 17))
216 else if (!
strncmp(buf,
"FLASH", 5))
218 else if (!
strncmp(buf,
"MOVIE", 5))
223 max8997_led_set_mode(led, mode);
230 static DEVICE_ATTR(mode, 0644, max8997_led_show_mode, max8997_led_store_mode);
250 snprintf(name,
sizeof(name),
"max8997-led%d", pdev->
id);
253 led->
cdev.brightness_set = max8997_led_brightness_set;
255 led->
cdev.brightness = 0;
265 max8997_led_set_mode(led, pdata->
led_pdata->mode[led->
id]);
273 max8997_led_set_current(led, 0);
278 platform_set_drvdata(pdev, led);
287 "failed to create file: %d\n", ret);
297 struct max8997_led *led = platform_get_drvdata(pdev);
307 .name =
"max8997-led",
310 .probe = max8997_led_probe,