1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* LCD Backlight driver for RAVE SP
*
* Copyright (C) 2018 Zodiac Inflight Innovations
*/
#include <common.h>
#include <malloc.h>
#include <init.h>
#include <video/backlight.h>
#include <linux/mfd/rave-sp.h>
#define RAVE_SP_BACKLIGHT_LCD_EN BIT(7)
static int rave_sp_backlight_set(struct backlight_device *bd, int brightness)
{
struct rave_sp *sp = bd->dev.priv;
u8 cmd[] = {
[0] = RAVE_SP_CMD_SET_BACKLIGHT,
[1] = 0,
[2] = brightness ? RAVE_SP_BACKLIGHT_LCD_EN | brightness : 0,
[3] = 0,
[4] = 0,
};
return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0);
}
static int rave_sp_backlight_probe(struct device *dev)
{
struct backlight_device *bd;
int ret;
bd = xzalloc(sizeof(*bd));
bd->dev.priv = dev->parent->priv;
bd->dev.parent = dev;
bd->brightness = bd->brightness_cur = bd->brightness_default = 50;
bd->brightness_max = 100;
bd->brightness_set = rave_sp_backlight_set;
ret = backlight_register(bd);
if (ret) {
free(bd);
return ret;
}
return 0;
}
static const struct of_device_id rave_sp_backlight_of_match[] = {
{ .compatible = "zii,rave-sp-backlight" },
{}
};
static struct driver_d rave_sp_backlight_driver = {
.name = "rave-sp-backlight",
.probe = rave_sp_backlight_probe,
.of_compatible = DRV_OF_COMPAT(rave_sp_backlight_of_match),
};
device_platform_driver(rave_sp_backlight_driver);
|