This source file includes following definitions.
- rave_sp_backlight_update_status
- rave_sp_backlight_probe
1
2
3
4
5
6
7
8
9
10 #include <linux/backlight.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/mfd/rave-sp.h>
14 #include <linux/platform_device.h>
15
16 #define RAVE_SP_BACKLIGHT_LCD_EN BIT(7)
17
18 static int rave_sp_backlight_update_status(struct backlight_device *bd)
19 {
20 const struct backlight_properties *p = &bd->props;
21 const u8 intensity =
22 (p->power == FB_BLANK_UNBLANK) ? p->brightness : 0;
23 struct rave_sp *sp = dev_get_drvdata(&bd->dev);
24 u8 cmd[] = {
25 [0] = RAVE_SP_CMD_SET_BACKLIGHT,
26 [1] = 0,
27 [2] = intensity ? RAVE_SP_BACKLIGHT_LCD_EN | intensity : 0,
28 [3] = 0,
29 [4] = 0,
30 };
31
32 return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0);
33 }
34
35 static const struct backlight_ops rave_sp_backlight_ops = {
36 .options = BL_CORE_SUSPENDRESUME,
37 .update_status = rave_sp_backlight_update_status,
38 };
39
40 static struct backlight_properties rave_sp_backlight_props = {
41 .type = BACKLIGHT_PLATFORM,
42 .max_brightness = 100,
43 .brightness = 50,
44 };
45
46 static int rave_sp_backlight_probe(struct platform_device *pdev)
47 {
48 struct device *dev = &pdev->dev;
49 struct backlight_device *bd;
50
51 bd = devm_backlight_device_register(dev, pdev->name, dev,
52 dev_get_drvdata(dev->parent),
53 &rave_sp_backlight_ops,
54 &rave_sp_backlight_props);
55 if (IS_ERR(bd))
56 return PTR_ERR(bd);
57
58
59
60
61
62
63 if (!dev->of_node->phandle)
64 backlight_update_status(bd);
65
66 return 0;
67 }
68
69 static const struct of_device_id rave_sp_backlight_of_match[] = {
70 { .compatible = "zii,rave-sp-backlight" },
71 {}
72 };
73
74 static struct platform_driver rave_sp_backlight_driver = {
75 .probe = rave_sp_backlight_probe,
76 .driver = {
77 .name = KBUILD_MODNAME,
78 .of_match_table = rave_sp_backlight_of_match,
79 },
80 };
81 module_platform_driver(rave_sp_backlight_driver);
82
83 MODULE_DEVICE_TABLE(of, rave_sp_backlight_of_match);
84 MODULE_LICENSE("GPL");
85 MODULE_AUTHOR("Andrey Vostrikov <andrey.vostrikov@cogentembedded.com>");
86 MODULE_AUTHOR("Nikita Yushchenko <nikita.yoush@cogentembedded.com>");
87 MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>");
88 MODULE_DESCRIPTION("RAVE SP Backlight driver");