14 #include <linux/module.h>
19 #include <linux/slab.h>
24 #define LM3533_HVCTRLBANK_COUNT 2
25 #define LM3533_BL_MAX_BRIGHTNESS 255
27 #define LM3533_REG_CTRLBANK_AB_BCONF 0x1a
38 static inline int lm3533_bl_get_ctrlbank_id(
struct lm3533_bl *
bl)
70 .get_brightness = lm3533_bl_get_brightness,
71 .update_status = lm3533_bl_update_status,
86 unsigned channel = lm3533_bl_get_ctrlbank_id(bl);
95 int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
105 mask = 1 << (2 * ctrlbank);
113 const char *buf,
size_t len)
116 int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
125 mask = 1 << (2 * ctrlbank);
153 mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
165 const char *buf,
size_t len)
173 if (kstrtoul(buf, 0, &linear))
176 mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
208 const char *buf,
size_t len)
230 static struct attribute *lm3533_bl_attributes[] = {
231 &dev_attr_als_channel.attr,
232 &dev_attr_als_en.attr,
234 &dev_attr_linear.attr,
246 if (attr == &dev_attr_als_channel.attr ||
247 attr == &dev_attr_als_en.attr) {
248 if (!bl->
lm3533->have_als)
256 .is_visible = lm3533_bl_attr_is_visible,
257 .attrs = lm3533_bl_attributes
287 pdata = pdev->
dev.platform_data;
294 dev_err(&pdev->
dev,
"illegal backlight id %d\n", pdev->
id);
301 "failed to allocate memory for backlight\n");
308 bl->
cb.lm3533 = lm3533;
309 bl->
cb.id = lm3533_bl_get_ctrlbank_id(bl);
312 memset(&props, 0,
sizeof(props));
317 &lm3533_bl_ops, &props);
319 dev_err(&pdev->
dev,
"failed to register backlight device\n");
324 bl->
cb.dev = &bl->
bd->dev;
326 platform_set_drvdata(pdev, bl);
330 dev_err(&pdev->
dev,
"failed to create sysfs attributes\n");
334 backlight_update_status(bd);
336 ret = lm3533_bl_setup(bl, pdata);
338 goto err_sysfs_remove;
342 goto err_sysfs_remove;
356 struct lm3533_bl *bl = platform_get_drvdata(pdev);
362 bd->
props.brightness = 0;
374 struct lm3533_bl *bl = platform_get_drvdata(pdev);
383 struct lm3533_bl *bl = platform_get_drvdata(pdev);
390 #define lm3533_bl_suspend NULL
391 #define lm3533_bl_resume NULL
396 struct lm3533_bl *bl = platform_get_drvdata(pdev);
405 .name =
"lm3533-backlight",
408 .probe = lm3533_bl_probe,
410 .shutdown = lm3533_bl_shutdown,