a22: add button light driver
authorlyx <lyx@rock-chips.com>
Fri, 3 Jun 2011 03:29:37 +0000 (20:29 -0700)
committerlyx <lyx@rock-chips.com>
Tue, 7 Jun 2011 01:59:07 +0000 (18:59 -0700)
arch/arm/configs/rk29_a22_defconfig [changed mode: 0644->0755]
arch/arm/mach-rk29/board-rk29-a22.c
arch/arm/mach-rk29/include/mach/board.h
drivers/video/backlight/Kconfig
drivers/video/backlight/Makefile
drivers/video/backlight/rk29_buttonlight.c [new file with mode: 0755]

old mode 100644 (file)
new mode 100755 (executable)
index ff32ea6..f255623
@@ -1225,6 +1225,7 @@ CONFIG_BACKLIGHT_CLASS_DEVICE=y
 # CONFIG_BACKLIGHT_RK29_BL is not set
 # CONFIG_FIH_TOUCHKEY_LED is not set
 CONFIG_BACKLIGHT_AW9364=y
+CONFIG_BUTTON_LIGHT=y
 
 #
 # Display device support
index dea8ae984452fa0fac94ff81d64e69865451b58f..ef4c024c3edc66b2382189eddc40de55bdf22e95 100755 (executable)
@@ -1984,6 +1984,20 @@ struct platform_device aw9364_device_backlight = {
 
 #endif
 
+#ifdef CONFIG_BUTTON_LIGHT      
+struct rk29_button_light_info rk29_button_light_info = {
+       .led_on_pin   = RK29_PIN6_PB4,
+       .led_on_level = GPIO_HIGH,
+};
+
+struct platform_device rk29_device_button_light = {
+               .name   = "rk29_button_light",
+               .id     = -1,
+               .dev    = {
+                  .platform_data  = &rk29_button_light_info,
+               }
+};
+#endif
 
 /*****************************************************************************************
 * pwm voltage regulator devices
@@ -2493,6 +2507,9 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_BACKLIGHT_AW9364
        &aw9364_device_backlight,
 #endif
+#ifdef CONFIG_BUTTON_LIGHT       
+       &rk29_device_button_light,
+#endif
 #ifdef CONFIG_RK29_VMAC
        &rk29_device_vmac,
 #endif
index b9e59e90ee59363666cd5ef51756953a75fe44a7..3a0e7c23e0a9b3c8d8a75082bc1db11dda6fe251 100755 (executable)
 #include <linux/timer.h>
 #include <linux/notifier.h>
 
+struct rk29_button_light_info{
+       u32 led_on_pin;
+       u32 led_on_level;
+       int (*io_init)(void);
+       int (*io_deinit)(void);
+};
+
 /*spi*/
 struct spi_cs_gpio {
        const char *name;
index 07f29590de62616037240b176f0dfd555cef1548..8ecc980c7faa42b0917747dc19ce1f43b4cda09a 100644 (file)
@@ -286,4 +286,12 @@ config BACKLIGHT_AW9364
         bool "aw9364 backlight driver"
        depends on BACKLIGHT_CLASS_DEVICE && ARCH_RK29
        help
-         aw9364 backlight support.       
+         aw9364 backlight support.      
+
+config BUTTON_LIGHT
+        bool "rk29 button light driver"
+       depends on BACKLIGHT_CLASS_DEVICE
+       default n
+       help
+         rk29 button light support.      
index d38ca546f89d8d065a23591d3088b34e965ca072..54235006d719081920b3c68da3eae9ab60693b74 100644 (file)
@@ -32,3 +32,5 @@ obj-$(CONFIG_BACKLIGHT_RK2818_BL) += rk2818_backlight.o
 obj-$(CONFIG_BACKLIGHT_RK29_BL) += rk29_backlight.o
 obj-$(CONFIG_BACKLIGHT_AW9364) += aw9364_bl.o
 obj-$(CONFIG_FIH_TOUCHKEY_LED) += fih_touchkey_led.o
+obj-$(CONFIG_BUTTON_LIGHT) += rk29_buttonlight.o
+
diff --git a/drivers/video/backlight/rk29_buttonlight.c b/drivers/video/backlight/rk29_buttonlight.c
new file mode 100755 (executable)
index 0000000..bb72a66
--- /dev/null
@@ -0,0 +1,135 @@
+/* 
+ * Copyright (C) 2009 Rockchip Corporation.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/err.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/debugfs.h>
+#include <linux/backlight.h>
+#include <linux/fb.h>
+#include <linux/cpufreq.h>
+#include <linux/clk.h>
+
+#include <linux/earlysuspend.h>
+#include <asm/io.h>
+#include <mach/iomux.h>
+#include <mach/gpio.h>
+#include <mach/board.h>
+
+
+/*
+ * Debug
+ */
+#if 0 
+#define DBG(x...)      printk(x)
+#else
+#define DBG(x...)
+#endif
+
+static int rk29_button_light_value = 0;
+struct backlight_device * rk29_button_light_device;
+
+static s32 rk29_set_button_light(struct backlight_device *bl)
+{
+    struct rk29_button_light_info *button_light_info = bl->dev.parent->platform_data;
+
+    DBG(">>>>>>> rk29_set_button_light\n");
+    if(bl->props.brightness)
+        {
+       gpio_set_value(button_light_info->led_on_pin, button_light_info->led_on_level);
+       rk29_button_light_value = 255;
+        }
+    else
+        {
+        gpio_set_value(button_light_info->led_on_pin, button_light_info->led_on_level?0:1);
+       rk29_button_light_value = 0;
+        }
+    return 0;
+}
+
+static s32 rk29_get_button_light(struct backlight_device *bl)
+{
+    DBG(">>>>>>> rk29_get_button_light\n");
+    return rk29_button_light_value;
+}
+
+static struct backlight_ops rk29_button_light_ops = {
+       .update_status = rk29_set_button_light,
+       .get_brightness = rk29_get_button_light,
+};
+
+static int rk29_button_light_probe(struct platform_device *pdev)
+{               
+    struct rk29_button_light_info *button_light_info = pdev->dev.platform_data;
+    
+       rk29_button_light_device = backlight_device_register("rk29_button_light", &pdev->dev, NULL, &rk29_button_light_ops);
+       if (!rk29_button_light_device) {
+        DBG("rk29_button_light_probe error\n"); 
+               return -ENODEV;         
+       }
+   
+       rk29_button_light_device->props.power = FB_BLANK_UNBLANK;
+       rk29_button_light_device->props.fb_blank = FB_BLANK_UNBLANK;
+       rk29_button_light_device->props.max_brightness = 255;
+       rk29_button_light_device->props.brightness = 255;
+
+    gpio_request(button_light_info->led_on_pin, NULL);         
+    gpio_direction_output(button_light_info->led_on_pin, button_light_info->led_on_level?0:1);
+    
+    if (button_light_info && button_light_info->io_init)
+        button_light_info->io_init();
+    
+    return 0;
+}
+
+static int rk29_button_light_remove(struct platform_device *pdev)
+{              
+   
+       if (rk29_button_light_device) {
+               backlight_device_unregister(rk29_button_light_device);
+        return 0;
+    } else {
+        DBG("rk29_button_light_remove error\n"); 
+        return -ENODEV;      
+    }
+}
+
+static struct platform_driver rk29_button_light_driver = {
+       .probe  = rk29_button_light_probe,
+       .remove = rk29_button_light_remove,
+       .driver = {
+               .name   = "rk29_button_light",
+               .owner  = THIS_MODULE,
+       },
+};
+
+
+static int __init rk29_button_light_init(void)
+{
+       platform_driver_register(&rk29_button_light_driver);
+       return 0;
+}
+
+static int __init rk29_button_light_exit(void)
+{
+       platform_driver_unregister(&rk29_button_light_driver);
+       return 0;
+}
+
+late_initcall(rk29_button_light_init);
+module_exit(rk29_button_light_exit);
+