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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*
* Copyright 2008-2011 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/fb.h>
#include <linux/backlight.h>
#include <linux/pmic_light.h>
#include <linux/pmic_external.h>
/* workaround for atlas hot issue */
#define MXC_MAX_INTENSITY 100
#define MXC_DEFAULT_INTENSITY 0
#define MXC_INTENSITY_OFF 0
struct mxcfl_dev_data {
int intensity;
int suspend;
};
extern int fl_set_percentage(int iFL_Percentage);
extern int FL_suspend(void);
static int mxcfl_set_intensity(struct backlight_device *bd)
{
int brightness = bd->props.brightness;
struct mxcfl_dev_data *devdata = dev_get_drvdata(&bd->dev);
fl_set_percentage (brightness);
devdata->intensity = brightness;
return 0;
}
static int mxcfl_get_intensity(struct backlight_device *bd)
{
struct mxcfl_dev_data *devdata = dev_get_drvdata(&bd->dev);
return devdata->intensity;
}
static int mxcfl_check_fb(struct backlight_device *bldev, struct fb_info *info)
{
return 0;
}
static struct backlight_ops bl_ops;
static int __devinit mxcfl_probe(struct platform_device *pdev)
{
int ret = 0;
struct backlight_device *bd;
struct mxcfl_dev_data *devdata;
struct backlight_properties props;
pmic_version_t pmic_version;
devdata = kzalloc(sizeof(struct mxcfl_dev_data), GFP_KERNEL);
if (!devdata)
return -ENOMEM;
bl_ops.check_fb = mxcfl_check_fb;
bl_ops.get_brightness = mxcfl_get_intensity;
bl_ops.update_status = mxcfl_set_intensity;
memset(&props, 0, sizeof(struct backlight_properties));
props.max_brightness = MXC_MAX_INTENSITY;
props.type = BACKLIGHT_RAW;
bd = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, devdata,
&bl_ops, &props);
if (IS_ERR(bd)) {
ret = PTR_ERR(bd);
goto err0;
}
platform_set_drvdata(pdev, bd);
bd->props.brightness = MXC_DEFAULT_INTENSITY;
backlight_update_status(bd);
pr_debug("MSP430 frontlight probed successfully\n");
return 0;
err0:
kfree(devdata);
return ret;
}
static int mxcfl_remove(struct platform_device *pdev)
{
struct backlight_device *bd = platform_get_drvdata(pdev);
struct mxcfl_dev_data *devdata = dev_get_drvdata(&bd->dev);
kfree(devdata);
backlight_device_unregister(bd);
return 0;
}
static int mxcfl_suspend(struct platform_device *pdev, pm_message_t state)
{
return FL_suspend ();
}
static int mxcfl_resume(struct platform_device *pdev)
{
return 0;
}
static struct platform_driver mxcfl_driver = {
.probe = mxcfl_probe,
.remove = mxcfl_remove,
.suspend = mxcfl_suspend,
.resume = mxcfl_resume,
.driver = {
.name = "mxc_msp430_fl",
},
};
static int __init mxcfl_init(void)
{
return platform_driver_register(&mxcfl_driver);
}
static void __exit mxcfl_exit(void)
{
platform_driver_unregister(&mxcfl_driver);
}
module_init(mxcfl_init);
module_exit(mxcfl_exit);
MODULE_DESCRIPTION("MSP430 Frontlight Driver");
MODULE_AUTHOR("Netronix, Inc.");
MODULE_LICENSE("GPL");
|