rk30_sdk:use new sensors driver
authorlw <lw@rock-chips.com>
Thu, 14 Jun 2012 02:41:04 +0000 (10:41 +0800)
committerlw <lw@rock-chips.com>
Thu, 14 Jun 2012 02:41:04 +0000 (10:41 +0800)
arch/arm/mach-rk30/board-rk30-sdk.c
drivers/input/sensors/sensor-i2c.c

index 6454798c5e2a421cbc12e39d4209a0e39ed5898b..dd136a44ff63da5a35c1a0a58dd74f0dc46ab4ec 100755 (executable)
@@ -43,7 +43,7 @@
 #include <linux/fb.h>
 #include <linux/regulator/machine.h>
 #include <linux/rfkill-rk.h>
-
+#include <linux/sensor-dev.h>
 #if defined(CONFIG_HDMI_RK30)
        #include "../../../drivers/video/rockchip/hdmi/rk_hdmi.h"
 #endif
@@ -689,19 +689,13 @@ static int mma8452_init_platform_hw(void)
 {
        rk30_mux_api_set(GPIO4C0_SMCDATA0_TRACEDATA0_NAME, GPIO4C_GPIO4C0);
 
-       if (gpio_request(MMA8452_INT_PIN, NULL) != 0) {
-               gpio_free(MMA8452_INT_PIN);
-               printk("mma8452_init_platform_hw gpio_request error\n");
-               return -EIO;
-       }
-       gpio_pull_updown(MMA8452_INT_PIN, 1);
        return 0;
 }
 
-static struct gsensor_platform_data mma8452_info = {
-        .model = 8452,
-        .swap_xy = 0,
-        .swap_xyz = 1,
+static struct sensor_platform_data mma8452_info = {
+       .type = SENSOR_TYPE_ACCEL,
+       .irq_enable = 1,
+       .poll_delay_ms = 30,
         .init_platform_hw = mma8452_init_platform_hw,
         .orientation = {-1, 0, 0, 0, 0, 1, 0, -1, 0},
 };
@@ -725,14 +719,17 @@ static struct gsensor_platform_data lis3dh_info = {
 };
 #endif
 #if defined (CONFIG_COMPASS_AK8975)
-static struct akm8975_platform_data akm8975_info =
+static struct sensor_platform_data akm8975_info =
 {
+       .type = SENSOR_TYPE_COMPASS,
+       .irq_enable = 1,
+       .poll_delay_ms = 30,
        .m_layout = 
        {
                {
                        {1, 0, 0},
-                       {0, 0, 1},
                        {0, 1, 0},
+                       {0, 0, 1},
                },
 
                {
@@ -769,9 +766,12 @@ static int l3g4200d_init_platform_hw(void)
        return 0;
 }
 
-static struct l3g4200d_platform_data l3g4200d_info = {
+static struct sensor_platform_data l3g4200d_info = {
+       .type = SENSOR_TYPE_GYROSCOPE,
+       .irq_enable = 1,
+       .poll_delay_ms = 30,
        .orientation = {0, 1, 0, -1, 0, 0, 0, 0, 1},
-       .init = l3g4200d_init_platform_hw,
+       .init_platform_hw = l3g4200d_init_platform_hw,
        .x_min = 40,//x_min,y_min,z_min = (0-100) according to hardware
        .y_min = 40,
        .z_min = 20,
@@ -780,44 +780,12 @@ static struct l3g4200d_platform_data l3g4200d_info = {
 #endif
 
 #ifdef CONFIG_LS_CM3217
-
-#define CM3217_POWER_PIN       INVALID_GPIO
-#define CM3217_IRQ_PIN         INVALID_GPIO
-static int cm3217_init_hw(void)
-{
-#if 0
-       if (gpio_request(CM3217_POWER_PIN, NULL) != 0) {
-               gpio_free(CM3217_POWER_PIN);
-               printk("%s: request cm3217 power pin error\n", __func__);
-               return -EIO;
-       }
-       gpio_pull_updown(CM3217_POWER_PIN, PullDisable);
-
-       if (gpio_request(CM3217_IRQ_PIN, NULL) != 0) {
-               gpio_free(CM3217_IRQ_PIN);
-               printk("%s: request cm3217 int pin error\n", __func__);
-               return -EIO;
-       }
-       gpio_pull_updown(CM3217_IRQ_PIN, PullDisable);
-#endif
-       return 0;
-}
-
-static void cm3217_exit_hw(void)
-{
-#if 0
-       gpio_free(CM3217_POWER_PIN);
-       gpio_free(CM3217_IRQ_PIN);
-#endif
-       return;
-}
-
-static struct cm3217_platform_data cm3217_info = {
-       .irq_pin = CM3217_IRQ_PIN,
-       .power_pin = CM3217_POWER_PIN,
-       .init_platform_hw = cm3217_init_hw,
-       .exit_platform_hw = cm3217_exit_hw,
+static struct sensor_platform_data cm3217_info = {
+       .type = SENSOR_TYPE_LIGHT,
+       .irq_enable = 0,
+       .poll_delay_ms = 500,
 };
+
 #endif
 
 #ifdef CONFIG_FB_ROCKCHIP
@@ -1443,7 +1411,6 @@ static struct i2c_board_info __initdata i2c2_info[] = {
                .type          = "lightsensor",
                .addr          = 0x10,
                .flags         = 0,
-               .irq           = CM3217_IRQ_PIN,
                .platform_data = &cm3217_info,
        },
 #endif
index 29545cbd916e211ddc683442a11255a30d238e7f..92c5c5e8bfaab6b34e74189c58635a48da649932 100755 (executable)
@@ -217,7 +217,7 @@ EXPORT_SYMBOL(sensor_write_reg_normal);
 \r
 int sensor_read_reg_normal(struct i2c_client *client)\r
 {\r
-       char tmp[0];\r
+       char tmp[1] = {0};\r
        int ret = 0;    \r
        struct sensor_private_data* sensor = \r
                (struct sensor_private_data *)i2c_get_clientdata(client);\r
@@ -231,4 +231,3 @@ int sensor_read_reg_normal(struct i2c_client *client)
 \r
 EXPORT_SYMBOL(sensor_read_reg_normal);\r
 \r
-\r