rkfbsys:mask printk int set_dsp_lut
[firefly-linux-kernel-4.4.55.git] / drivers / video / backlight / rk29_buttonlight.c
1 /* 
2  * Copyright (C) 2009 Rockchip Corporation.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  */
14
15 #include <linux/init.h>
16 #include <linux/module.h>
17 #include <linux/kernel.h>
18 #include <linux/err.h>
19 #include <linux/delay.h>
20 #include <linux/platform_device.h>
21 #include <linux/debugfs.h>
22 #include <linux/backlight.h>
23 #include <linux/fb.h>
24 #include <linux/cpufreq.h>
25 #include <linux/clk.h>
26
27 #include <linux/earlysuspend.h>
28 #include <asm/io.h>
29 #include <mach/iomux.h>
30 #include <mach/gpio.h>
31 #include <mach/board.h>
32
33
34 /*
35  * Debug
36  */
37 #if 0 
38 #define DBG(x...)       printk(x)
39 #else
40 #define DBG(x...)
41 #endif
42
43 static int rk29_button_light_value = 0;
44 struct backlight_device * rk29_button_light_device;
45
46 static s32 rk29_set_button_light(struct backlight_device *bl)
47 {
48     struct rk29_button_light_info *button_light_info = bl->dev.parent->platform_data;
49
50     DBG(">>>>>>> rk29_set_button_light\n");
51     if(bl->props.brightness)
52         {
53         gpio_set_value(button_light_info->led_on_pin, button_light_info->led_on_level);
54         rk29_button_light_value = 255;
55         }
56     else
57         {
58         gpio_set_value(button_light_info->led_on_pin, button_light_info->led_on_level?0:1);
59         rk29_button_light_value = 0;
60         }
61     return 0;
62 }
63
64 static s32 rk29_get_button_light(struct backlight_device *bl)
65 {
66     DBG(">>>>>>> rk29_get_button_light\n");
67     return rk29_button_light_value;
68 }
69
70 static struct backlight_ops rk29_button_light_ops = {
71         .update_status = rk29_set_button_light,
72         .get_brightness = rk29_get_button_light,
73 };
74
75 static int rk29_button_light_probe(struct platform_device *pdev)
76 {                
77     struct rk29_button_light_info *button_light_info = pdev->dev.platform_data;
78     
79         rk29_button_light_device = backlight_device_register("rk28_button_light", &pdev->dev, NULL, &rk29_button_light_ops,NULL);
80         if (!rk29_button_light_device) {
81         DBG("rk29_button_light_probe error\n"); 
82                 return -ENODEV;         
83         }
84    
85         rk29_button_light_device->props.power = FB_BLANK_UNBLANK;
86         rk29_button_light_device->props.fb_blank = FB_BLANK_UNBLANK;
87         rk29_button_light_device->props.max_brightness = 255;
88         rk29_button_light_device->props.brightness = 255;
89
90     gpio_request(button_light_info->led_on_pin, NULL);  
91     gpio_direction_output(button_light_info->led_on_pin, button_light_info->led_on_level?0:1);
92     
93     if (button_light_info && button_light_info->io_init)
94         button_light_info->io_init();
95     
96     return 0;
97 }
98
99 static int rk29_button_light_remove(struct platform_device *pdev)
100 {               
101    
102         if (rk29_button_light_device) {
103                 backlight_device_unregister(rk29_button_light_device);
104         return 0;
105     } else {
106         DBG("rk29_button_light_remove error\n"); 
107         return -ENODEV;      
108     }
109 }
110
111 static struct platform_driver rk29_button_light_driver = {
112         .probe  = rk29_button_light_probe,
113         .remove = rk29_button_light_remove,
114         .driver = {
115                 .name   = "rk29_button_light",
116                 .owner  = THIS_MODULE,
117         },
118 };
119
120
121 static int __init rk29_button_light_init(void)
122 {
123         platform_driver_register(&rk29_button_light_driver);
124         return 0;
125 }
126
127 static int __init rk29_button_light_exit(void)
128 {
129         platform_driver_unregister(&rk29_button_light_driver);
130         return 0;
131 }
132
133 late_initcall(rk29_button_light_init);
134 module_exit(rk29_button_light_exit);
135