2 * Copyright (C) 2009 Rockchip Corporation.
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.
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.
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>
24 #include <linux/cpufreq.h>
25 #include <linux/clk.h>
27 #include <linux/earlysuspend.h>
29 #include <mach/iomux.h>
30 #include <mach/gpio.h>
31 #include <mach/board.h>
38 #define DBG(x...) printk(x)
43 static int rk29_button_light_value = 0;
44 struct backlight_device * rk29_button_light_device;
46 static s32 rk29_set_button_light(struct backlight_device *bl)
48 struct rk29_button_light_info *button_light_info = bl->dev.parent->platform_data;
50 DBG(">>>>>>> rk29_set_button_light\n");
51 if(bl->props.brightness)
53 gpio_set_value(button_light_info->led_on_pin, button_light_info->led_on_level);
54 rk29_button_light_value = 255;
58 gpio_set_value(button_light_info->led_on_pin, button_light_info->led_on_level?0:1);
59 rk29_button_light_value = 0;
64 static s32 rk29_get_button_light(struct backlight_device *bl)
66 DBG(">>>>>>> rk29_get_button_light\n");
67 return rk29_button_light_value;
70 static struct backlight_ops rk29_button_light_ops = {
71 .update_status = rk29_set_button_light,
72 .get_brightness = rk29_get_button_light,
75 static int rk29_button_light_probe(struct platform_device *pdev)
77 struct rk29_button_light_info *button_light_info = pdev->dev.platform_data;
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");
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;
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);
93 if (button_light_info && button_light_info->io_init)
94 button_light_info->io_init();
99 static int rk29_button_light_remove(struct platform_device *pdev)
102 if (rk29_button_light_device) {
103 backlight_device_unregister(rk29_button_light_device);
106 DBG("rk29_button_light_remove error\n");
111 static struct platform_driver rk29_button_light_driver = {
112 .probe = rk29_button_light_probe,
113 .remove = rk29_button_light_remove,
115 .name = "rk29_button_light",
116 .owner = THIS_MODULE,
121 static int __init rk29_button_light_init(void)
123 platform_driver_register(&rk29_button_light_driver);
127 static int __init rk29_button_light_exit(void)
129 platform_driver_unregister(&rk29_button_light_driver);
133 late_initcall(rk29_button_light_init);
134 module_exit(rk29_button_light_exit);