xxm FIH:1.update board-rk29-fih.c 2.update cm3202.c 3.update rk29_FIH_defconfig
authorroot <root@rockchip-MID.(none)>
Sat, 7 May 2011 03:04:58 +0000 (11:04 +0800)
committerroot <root@rockchip-MID.(none)>
Sat, 7 May 2011 03:04:58 +0000 (11:04 +0800)
arch/arm/configs/rk29_FIH_defconfig
arch/arm/mach-rk29/board-rk29-fih.c
arch/arm/mach-rk29/include/mach/board.h
drivers/input/lightsensor/Makefile
drivers/input/lightsensor/cm3202.c [new file with mode: 0644]

index 7c9ff01faf68b45be4092e678634fdb598033ef9..7cfeb6e78680695acb0ec26345140e0d0e4c0710 100644 (file)
@@ -1,7 +1,7 @@
 #
 # Automatically generated make config: don't edit
 # Linux kernel version: 2.6.32.27
-# Thu Apr 28 11:04:44 2011
+# Sat May  7 10:51:04 2011
 #
 CONFIG_ARM=y
 CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -204,7 +204,32 @@ CONFIG_MACH_RK29FIH=y
 # CONFIG_MACH_RK29_MALATA is not set
 # CONFIG_MACH_RK29_PHONESDK is not set
 # CONFIG_MACH_RK29_A22 is not set
+# CONFIG_DDR_TYPE_DDRII is not set
+# CONFIG_DDR_TYPE_LPDDR is not set
+# CONFIG_DDR_TYPE_DDR3_800D is not set
+# CONFIG_DDR_TYPE_DDR3_800E is not set
+# CONFIG_DDR_TYPE_DDR3_1066E is not set
+# CONFIG_DDR_TYPE_DDR3_1066F is not set
+# CONFIG_DDR_TYPE_DDR3_1066G is not set
+# CONFIG_DDR_TYPE_DDR3_1333F is not set
+# CONFIG_DDR_TYPE_DDR3_1333G is not set
+# CONFIG_DDR_TYPE_DDR3_1333H is not set
+# CONFIG_DDR_TYPE_DDR3_1333J is not set
+# CONFIG_DDR_TYPE_DDR3_1600G is not set
+# CONFIG_DDR_TYPE_DDR3_1600H is not set
+# CONFIG_DDR_TYPE_DDR3_1600J is not set
+# CONFIG_DDR_TYPE_DDR3_1600K is not set
+# CONFIG_DDR_TYPE_DDR3_1866J is not set
+# CONFIG_DDR_TYPE_DDR3_1866K is not set
+# CONFIG_DDR_TYPE_DDR3_1866L is not set
+# CONFIG_DDR_TYPE_DDR3_1866M is not set
+# CONFIG_DDR_TYPE_DDR3_2133K is not set
+# CONFIG_DDR_TYPE_DDR3_2133L is not set
+# CONFIG_DDR_TYPE_DDR3_2133M is not set
+# CONFIG_DDR_TYPE_DDR3_2133N is not set
+CONFIG_DDR_TYPE_DDR3_DEFAULT=y
 CONFIG_RK29_MEM_SIZE_M=512
+CONFIG_DDR_SDRAM_FREQ=400
 
 #
 # RK29 VPU (Video Processing Unit) support
@@ -1119,6 +1144,7 @@ CONFIG_SOC_CAMERA_MT9P111=y
 # CONFIG_SOC_CAMERA_OV2655 is not set
 # CONFIG_SOC_CAMERA_OV2659 is not set
 # CONFIG_SOC_CAMERA_OV9650 is not set
+# CONFIG_SOC_CAMERA_OV2640 is not set
 # CONFIG_SOC_CAMERA_OV3640 is not set
 # CONFIG_SOC_CAMERA_OV5642 is not set
 # CONFIG_SOC_CAMERA_OV5640 is not set
@@ -1244,6 +1270,7 @@ CONFIG_BACKLIGHT_CLASS_DEVICE=y
 # CONFIG_BACKLIGHT_GENERIC is not set
 CONFIG_BACKLIGHT_RK29_BL=y
 CONFIG_FIH_TOUCHKEY_LED=y
+# CONFIG_BACKLIGHT_AW9364 is not set
 
 #
 # Display device support
@@ -1274,11 +1301,13 @@ CONFIG_DISPLAY_SUPPORT=y
 CONFIG_LCD_AT070TNA2=y
 
 #
-# HDMI support
+# HDMI
 #
 CONFIG_HDMI=y
-CONFIG_ANX7150=y
-# CONFIG_ANX9030 is not set
+# CONFIG_HDMI_OLD is not set
+CONFIG_HDMI_NEW=y
+CONFIG_ANX7150_NEW=y
+# CONFIG_ANX9030_NEW is not set
 # CONFIG_HDMI_DEBUG is not set
 
 #
index 2d3e98c0653c146ae1c3be34d833768598c1ae70..5e65d3ace8fe4ab74b1d65088be4de35b6f88b02 100755 (executable)
@@ -1071,7 +1071,7 @@ static struct i2c_board_info __initdata board_i2c1_devices[] = {
                .flags                  = 0,
        },
 #endif
-#if defined (CONFIG_ANX7150)
+#if defined (CONFIG_ANX7150) || defined (CONFIG_ANX7150_NEW)
     {
                .type           = "anx7150",
         .addr           = 0x39,             //0x39, 0x3d
@@ -1651,6 +1651,43 @@ struct rk29_bl_info rk29_bl_info = {
 };
 #endif
 
+#ifdef CONFIG_CM3202 
+/**********************************
+ * cm3202 lightsensor *
+**********************************/
+#define CM3202_SD      RK29_PIN5_PA2
+static int cm3202_init_hw(void)
+{
+       int ret;
+       ret = gpio_request(CM3202_SD, "cm3202_sd");
+       if (ret) {
+               printk( "failed to request cm3202 SD GPIO%d\n",CM3202_SD);
+       }
+       gpio_pull_updown(CM3202_SD,GPIOPullDown);
+       return ret;
+}
+
+static void cm3202_exit_hw(void)
+{
+       gpio_free(CM3202_SD);
+}
+
+struct cm3202_platform_data cm3202_info = {
+       .CM3202_SD_IOPIN = CM3202_SD,
+       .DATA_ADC_CHN = 2,
+       .init_platform_hw = cm3202_init_hw,
+       .exit_platform_hw = cm3202_exit_hw,
+};
+
+struct platform_device cm3202_device = {
+       .name = "lightsensor",
+       .id = -1,
+       .dev = {
+               .platform_data = &cm3202_info,
+       }
+};
+#endif
+
 #ifdef CONFIG_FIH_TOUCHKEY_LED
 #define FIH_TOUCHKEY_LED_PWM_ID 1
 #define FIH_TOUCHKEY_LED_PWM_MUX_NAME          GPIO5D2_PWM1_UART1SIRIN_NAME 
@@ -2115,17 +2152,6 @@ struct platform_device rk29_device_vibrator ={
                },
 
 };
-#endif
-/*****************************************************************************************
- * mc3202 light sensor
- * author: sevenxuemin@sina.com
- *****************************************************************************************/
-#ifdef CONFIG_CM3202
-static struct platform_device rk29_device_lsr = {
-       .name           = "rk29-lsr",
-       .id                     = -1,
-};
-
 #endif
 static void __init rk29_board_iomux_init(void)
 {
@@ -2192,6 +2218,10 @@ static struct platform_device *devices[] __initdata = {
        &rk29_device_sdmmc1,
 #endif
 
+#ifdef CONFIG_CM3202
+       &cm3202_device,
+#endif
+
 #ifdef CONFIG_MTD_NAND_RK29XX
        &rk29xx_device_nand,
 #endif
@@ -2252,9 +2282,6 @@ static struct platform_device *devices[] __initdata = {
 #ifdef CONFIG_VIDEO_RK29XX_VOUT
        &rk29_v4l2_output_devce,
 #endif
-#ifdef CONFIG_CM3202
-       &rk29_device_lsr,
-#endif
 #ifdef CONFIG_ANDROID_TIMED_GPIO
        &rk29_device_vibrator,
 #endif
index 01c62dc0eb53964a7c42aa6ade669c259f49d683..7d3654e176ddff418236fa23569938be72d1d29c 100755 (executable)
@@ -190,6 +190,14 @@ struct mma8452_platform_data {
     int     (*mma8452_platform_wakeup)(void);
     void    (*exit_platform_hw)(void);
 };
+
+struct cm3202_platform_data {
+       int CM3202_SD_IOPIN;
+       int DATA_ADC_CHN;
+       int     (*init_platform_hw)(void);
+       void    (*exit_platform_hw)(void);
+};
+
 /*it7260 touch */
 struct it7260_platform_data {
     int     (*get_pendown_state)(void);
index 9439d0275b908ebba0c78d108e770068a6efe9ce..c00691dd14fdc8c41353dee39715d1cf0d4ad6ea 100644 (file)
@@ -1,3 +1,3 @@
 # gsensor drivers
 
-obj-$(CONFIG_CM3202)   += rk29_lightsensor.o
+obj-$(CONFIG_CM3202)   += cm3202.o
diff --git a/drivers/input/lightsensor/cm3202.c b/drivers/input/lightsensor/cm3202.c
new file mode 100644 (file)
index 0000000..a1bc3ee
--- /dev/null
@@ -0,0 +1,293 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/adc.h>
+#include <linux/delay.h>
+#include <linux/fs.h>
+#include <linux/sched.h>
+#include <linux/pm.h>
+#include <linux/sysctl.h>
+#include <linux/miscdevice.h>
+#include <linux/slab.h>
+#include <asm/gpio.h>
+#include <asm/uaccess.h>
+#include <linux/timer.h>
+#include <linux/input.h>
+#include <linux/ioctl.h>
+//#include <mach/rk29_sdk_io.h>
+#include <mach/board.h> 
+#include <linux/platform_device.h>
+#ifdef CONFIG_HAS_EARLYSUSPEND
+#include <linux/earlysuspend.h>
+#endif
+
+#define DEBUG  0
+
+#if DEBUG
+#define DBG(X...)      printk(KERN_NOTICE X)
+#else
+#define DBG(X...)
+#endif
+
+//#define CM3202_SD_IOPIN              LIGHT_INT_IOPIN//light sensor int Pin  <level=Low "ON"> <level=Hight "OFF">
+//#define DATA_ADC_CHN 2       //SARADC_AIN[3]
+#define SENSOR_ON      1
+#define SENSOR_OFF     0
+#define LIGHTSENSOR_IOCTL_MAGIC 'l'
+#define LIGHTSENSOR_IOCTL_GET_ENABLED   _IOR(LIGHTSENSOR_IOCTL_MAGIC, 1, int *) 
+#define LIGHTSENSOR_IOCTL_ENABLE        _IOW(LIGHTSENSOR_IOCTL_MAGIC, 2, int *) 
+#define LIGHTSENSOR_IOCTL_DISABLE        _IOW(LIGHTSENSOR_IOCTL_MAGIC, 3, int *)
+
+struct cm3202_data {
+       struct adc_client       *client;
+       struct timer_list       timer;
+       struct work_struct      timer_work;
+       struct input_dev        *input;
+       int CM3202_SD;
+       int statue;
+};
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static struct early_suspend cm3202_early_suspend;
+#endif
+static struct cm3202_data *light;
+
+static int cm3202_start(struct cm3202_data *data)
+{
+       struct cm3202_data *cm3202 = data;
+       if(cm3202->statue)
+               return 0;
+       gpio_direction_output(cm3202->CM3202_SD,0);//level = 0 Sensor ON
+       cm3202->statue = SENSOR_ON;
+       cm3202->timer.expires  = jiffies + 1*HZ;
+       add_timer(&cm3202->timer);
+       printk("========== cm3202 light sensor start ==========\n");
+       return 0;
+}
+
+static int cm3202_stop(struct cm3202_data *data)
+{
+       struct cm3202_data *cm3202 = data;
+       if(cm3202->statue == 0)
+               return 0;
+       gpio_direction_output(cm3202->CM3202_SD,1);//level = 1 Sensor OFF
+       cm3202->statue = SENSOR_OFF;
+       del_timer(&cm3202->timer);
+       printk("========== cm3202 light sensor stop ==========\n");
+       return 0;
+}
+
+#ifdef CONFIG_HAS_EARLYSUSPEND
+static void cm3202_suspend(struct early_suspend *h)
+{
+       struct cm3202_data *cm3202 = light;
+       cm3202_stop(cm3202);
+       printk("Light Sensor cm3202 enter suspend cm3202->status %d\n",cm3202->statue);
+}
+
+static void cm3202_resume(struct early_suspend *h)
+{
+       struct cm3202_data *cm3202 = light;
+       cm3202_start(cm3202);
+       printk("Light Sensor cm3202 enter resume cm3202->status %d\n",cm3202->statue);
+}
+#endif
+static int cm3202_open(struct inode *indoe, struct file *file)
+{
+       return 0;
+}
+
+static int cm3202_release(struct inode *inode, struct file *file)
+{
+       return 0;
+}
+
+static int cm3202_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+       unsigned long *argp = (unsigned char *)arg;
+       switch(cmd){
+               case LIGHTSENSOR_IOCTL_GET_ENABLED:
+                       *argp = light->statue;
+                       break;
+               case LIGHTSENSOR_IOCTL_ENABLE:
+                       if(*argp)
+                               cm3202_start(light);
+                       else
+                               cm3202_stop(light);
+                       break;
+               default:break;
+       }
+       return 0;
+}
+
+static void cm3202_value_report(struct input_dev *input, int data)
+{
+       unsigned char index = 0;
+       if(data <= 10){
+               index = 0;goto report;
+       }
+       else if(data <= 160){
+               index = 1;goto report;
+       }
+       else if(data <= 225){
+               index = 2;goto report;
+       }
+       else if(data <= 320){
+               index = 3;goto report;
+       }
+       else if(data <= 640){
+               index = 4;goto report;
+       }
+       else if(data <= 1280){
+               index = 5;goto report;
+       }
+       else if(data <= 2600){
+               index = 6;goto report;
+       }
+       else{
+               index = 7;goto report;
+       }
+report:
+       DBG("cm3202 report index = %d\n",index);
+       input_report_abs(input, ABS_MISC, index);
+       input_sync(input);
+       return;
+}
+static void callback(struct adc_client *client, void *param, int result)
+{
+       DBG("[chn%d] cm3202 report value: %d\n", client->chn, result);
+       return;
+}
+static void adc_timer(unsigned long data)
+{
+       struct cm3202_data *cm3202=(struct cm3202_data *)data;
+       schedule_work(&cm3202->timer_work);
+}
+static void adc_timer_work(struct work_struct *work)
+{
+       int sync_read = 0;
+       struct cm3202_data *cm3202 = container_of(work, struct cm3202_data,timer_work);
+       adc_async_read(cm3202->client);
+       sync_read = adc_sync_read(cm3202->client);
+       cm3202_value_report(cm3202->input, sync_read);
+       if(cm3202->statue){
+               cm3202->timer.expires  = jiffies + 3*HZ;
+               add_timer(&cm3202->timer);
+       }
+}
+
+static struct file_operations cm3202_fops = {
+       .owner = THIS_MODULE,
+       .ioctl = cm3202_ioctl,
+       .open = cm3202_open,
+       .release = cm3202_release,
+};
+
+static struct miscdevice cm3202_device = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "lightsensor",
+       .fops = &cm3202_fops,
+};
+
+static int cm3202_probe(struct platform_device *pdev)
+{
+       struct cm3202_data *cm3202;
+       struct cm3202_platform_data *pdata = pdata = pdev->dev.platform_data;
+       int err;
+       DBG("============= cm3202 probe enter ==============\n");
+       cm3202 = kmalloc(sizeof(struct cm3202_data), GFP_KERNEL);
+       if(!cm3202){
+               printk("cm3202 alloc memory err !!!\n");
+               err = -ENOMEM;
+               goto alloc_memory_fail;
+       }
+       cm3202->CM3202_SD = pdata->CM3202_SD_IOPIN;
+       DBG("===============================cm3202==========================\ncm3202_ADC_CHN = %d",pdata->DATA_ADC_CHN);
+       light = cm3202;
+       cm3202->client = adc_register(pdata->DATA_ADC_CHN, callback, NULL);
+       cm3202->statue = SENSOR_OFF;
+       cm3202->input = input_allocate_device();
+       if (!cm3202->input) {
+               err = -ENOMEM;
+               printk(KERN_ERR"cm3202: Failed to allocate input device\n");
+               goto exit_input_allocate_device_failed;
+       }
+       set_bit(EV_ABS, cm3202->input->evbit);
+       /* light sensor data */
+       input_set_abs_params(cm3202->input, ABS_MISC, 0, 0x3ff, 0, 0);
+       cm3202->input->name = "lightsensor";
+
+       err = input_register_device(cm3202->input);
+       if (err < 0) {
+               printk(KERN_ERR"cm3202: Unable to register input device: %s\n",cm3202->input->name);                                            
+               goto exit_input_register_device_failed;
+       }
+       /*
+       ret = gpio_request(CM3202_SD_IOPIN, "cm3202_sd");
+       if (ret) {
+               printk( "failed to request cm3202 SD GPIO%d\n",CM3202_SD_IOPIN);
+               goto exit_gpio_request_fail;
+       }
+       DBG("cm3202 request INT inpin ok !!!");
+       gpio_pull_updown(CM3202_SD_IOPIN,GPIOPullDown); */
+       INIT_WORK(&cm3202->timer_work, adc_timer_work);
+       setup_timer(&cm3202->timer, adc_timer, (unsigned long)cm3202);
+       err = misc_register(&cm3202_device);
+       if (err < 0) {
+               printk(KERN_ERR"cm3202_probe: lightsensor_device register failed\n");
+               goto exit_misc_register_fail;
+       }
+       printk("lightsensor cm3202 driver created !\n");
+       //cm3202_start(light);
+#ifdef CONFIG_HAS_EARLYSUSPEND
+       cm3202_early_suspend.suspend = cm3202_suspend;
+       cm3202_early_suspend.resume = cm3202_resume;
+       cm3202_early_suspend.level = 0x2;
+       register_early_suspend(&cm3202_early_suspend);
+#endif
+       return 0;
+exit_misc_register_fail:
+       gpio_free(pdata->CM3202_SD_IOPIN);
+       input_unregister_device(cm3202->input);
+exit_input_register_device_failed:
+       input_free_device(cm3202->input);
+exit_input_allocate_device_failed:
+       kfree(cm3202);
+alloc_memory_fail:
+       printk("%s error\n",__FUNCTION__);
+       return err;
+}
+
+static int cm3202_remove(struct platform_device *pdev)
+{
+       struct cm3202_data *cm3202 = light;
+       kfree(cm3202);
+       input_free_device(cm3202->input);
+       input_unregister_device(cm3202->input);
+       misc_deregister(&cm3202_device);
+       return 0;
+}
+
+static struct platform_driver cm3202_driver = {
+       .probe = cm3202_probe,
+       .remove = cm3202_remove,
+       .driver = {
+               .owner = THIS_MODULE,
+               .name = "lightsensor",
+       }
+};
+
+static int __init cm3202_init(void)
+{
+       return platform_driver_register(&cm3202_driver);
+}
+
+static void __exit cm3202_exit(void)
+{
+       platform_driver_unregister(&cm3202_driver);
+}
+
+module_init(cm3202_init);
+module_exit(cm3202_exit);