10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/i2c.h>
22 #define REG_CONFIG 0x01
23 #define REG_BRT_A 0x03
24 #define REG_BRT_B 0x04
25 #define REG_INT_STATUS 0x09
26 #define REG_INT_EN 0x0A
27 #define REG_FAULT 0x0B
28 #define REG_PWM_OUTLOW 0x12
29 #define REG_PWM_OUTHIGH 0x13
32 #define INT_DEBOUNCE_MSEC 10
40 static const char *bled_name[] = {
98 dev_err(pchip->
dev,
"i2c failed to access register\n");
114 "i2c failed to access REG_INT_STATUS Register\n");
118 dev_info(pchip->
dev,
"REG_INT_STATUS Register is 0x%x\n", reg_val);
135 dev_err(pchip->
dev,
"i2c failed to access register\n");
144 dev_err(pchip->
dev,
"create irq thread fail...\n");
148 (pchip->
irq,
NULL, lm3630_isr_func,
150 dev_err(pchip->
dev,
"request threaded irq fail..\n");
159 if (!pchip->
pdata->pwm_set_intensity)
161 pchip->
pdata->pwm_set_intensity(bl->
props.brightness - 1,
162 pchip->
pdata->pwm_period);
174 if (!bl->
props.brightness) {
178 return bl->
props.brightness;
183 if (!set_intensity(bl, pchip))
184 dev_err(pchip->
dev,
"No pwm control func. in plat-data\n");
197 return bl->
props.brightness;
199 dev_err(pchip->
dev,
"i2c failed to access REG_CTRL\n");
200 return bl->
props.brightness;
214 brightness = reg_val & 0x01;
218 brightness = ((brightness << 8) | reg_val) + 1;
227 brightness = reg_val + 1;
230 return bl->
props.brightness;
232 dev_err(pchip->
dev,
"i2c failed to access register\n");
238 .update_status = lm3630_bank_a_update_status,
239 .get_brightness = lm3630_bank_a_get_brightness,
249 if (!set_intensity(bl, pchip))
251 "no pwm control func. in plat-data\n");
260 return bl->
props.brightness;
262 dev_err(pchip->
dev,
"i2c failed to access register\n");
263 return bl->
props.brightness;
277 brightness = reg_val & 0x01;
281 brightness = ((brightness << 8) | reg_val) + 1;
290 brightness = reg_val + 1;
294 return bl->
props.brightness;
296 dev_err(pchip->
dev,
"i2c failed to access register\n");
297 return bl->
props.brightness;
302 .update_status = lm3630_bank_b_update_status,
303 .get_brightness = lm3630_bank_b_get_brightness,
309 const char *
name = bled_name[ledno];
321 &lm3630_bank_a_ops, &props);
322 if (IS_ERR(pchip->
bled1))
330 &lm3630_bank_b_ops, &props);
331 if (IS_ERR(pchip->
bled2))
346 static const struct regmap_config lm3630_regmap = {
360 dev_err(&client->
dev,
"fail : i2c functionality check...\n");
365 dev_err(&client->
dev,
"fail : no platform data.\n");
374 pchip->
dev = &client->
dev;
377 if (IS_ERR(pchip->
regmap)) {
378 ret = PTR_ERR(pchip->
regmap);
379 dev_err(&client->
dev,
"fail : allocate register map: %d\n",
383 i2c_set_clientdata(client, pchip);
386 ret = lm3630_chip_init(pchip);
394 ret = lm3630_backlight_register(pchip,
BLED_ALL);
398 ret = lm3630_backlight_register(pchip,
BLED_1);
401 ret = lm3630_backlight_register(pchip,
BLED_2);
412 ret = lm3630_backlight_register(pchip,
BLED_2);
420 lm3630_intr_config(pchip);
422 dev_info(&client->
dev,
"LM3630 backlight register OK.\n");
426 dev_err(&client->
dev,
"fail : backlight register.\n");
427 lm3630_backlight_unregister(pchip);
439 dev_err(pchip->
dev,
"i2c failed to access register\n");
443 dev_err(pchip->
dev,
"i2c failed to access register\n");
445 lm3630_backlight_unregister(pchip);
461 static struct i2c_driver lm3630_i2c_driver = {
465 .probe = lm3630_probe,
467 .id_table = lm3630_id,