12 #include <linux/module.h>
13 #include <linux/slab.h>
14 #include <linux/i2c.h>
20 #define BRIGHTNESS_CTRL 0x00
21 #define DEVICE_CTRL 0x01
22 #define EEPROM_START 0xA0
23 #define EEPROM_END 0xA7
24 #define EPROM_START 0xA0
25 #define EPROM_END 0xAF
28 #define DEFAULT_BL_NAME "lcd-backlight"
29 #define MAX_BRIGHTNESS 255
49 dev_err(lp->
dev,
"failed to read 0x%.2x\n", reg);
89 return (addr >= start && addr <= end);
92 static int lp855x_init_registers(
struct lp855x *lp)
112 if (!lp855x_is_valid_rom_area(lp, addr))
115 ret = lp855x_write_byte(lp, addr, val);
126 struct lp855x *lp = bl_get_data(bl);
130 bl->
props.brightness = 0;
134 int br = bl->
props.brightness;
135 int max_br = bl->
props.max_brightness;
150 struct lp855x *lp = bl_get_data(bl);
155 int max_br = bl->
props.max_brightness;
167 return bl->
props.brightness;
172 .update_status = lp855x_bl_update_status,
173 .get_brightness = lp855x_bl_get_brightness,
176 static int lp855x_backlight_register(
struct lp855x *lp)
192 &lp855x_bl_ops, &props);
201 static void lp855x_backlight_unregister(
struct lp855x *lp)
219 char *strmode =
NULL;
222 strmode =
"pwm based";
224 strmode =
"register based";
232 static struct attribute *lp855x_attributes[] = {
233 &dev_attr_chip_id.attr,
234 &dev_attr_bl_ctl_mode.attr,
239 .attrs = lp855x_attributes,
250 dev_err(&cl->
dev,
"no platform data supplied\n");
267 i2c_set_clientdata(cl, lp);
271 ret = lp855x_init_registers(lp);
273 dev_err(lp->
dev,
"i2c communication err: %d", ret);
278 ret = lp855x_backlight_register(lp);
281 "failed to register backlight. err: %d\n", ret);
287 dev_err(lp->
dev,
"failed to register sysfs. err: %d\n", ret);
291 backlight_update_status(lp->
bl);
295 lp855x_backlight_unregister(lp);
302 struct lp855x *lp = i2c_get_clientdata(cl);
304 lp->
bl->props.brightness = 0;
305 backlight_update_status(lp->
bl);
307 lp855x_backlight_unregister(lp);
326 .probe = lp855x_probe,
328 .id_table = lp855x_ids,