porting sensor-dev to 3.10
authorguoyi <gy@rock-chips.com>
Wed, 5 Mar 2014 07:32:13 +0000 (15:32 +0800)
committerguoyi <gy@rock-chips.com>
Wed, 5 Mar 2014 10:14:22 +0000 (18:14 +0800)
arch/arm/boot/dts/rk3188-tb.dts
arch/arm/boot/dts/rk3188.dtsi
drivers/input/Kconfig
drivers/input/Makefile
drivers/input/sensors/sensor-dev.c
drivers/input/sensors/sensor-i2c.c
include/dt-bindings/sensor-dev.h [new file with mode: 0755]
include/linux/sensor-dev.h

index 74c4d0a29b578afb22803785e4784134a23f0b61..a9fe3696676a3c271e56a138ef89dad524aca067 100755 (executable)
                pa_enable_time = <1000>;
        };
 
+       sensor@1d {
+               compatible = "gs_mma8452";
+               reg = <0x1d>;
+               type = <SENSOR_TYPE_ACCEL>;
+               irq-gpio = <&gpio0 GPIO_B7 IRQ_TYPE_EDGE_FALLING>;              
+               irq_enable = <1>;
+               poll_delay_ms = <30>;
+               layout = <1>;
+       };
 };
 
 &i2c1 {
index 812fa29349ef235b0b69cc37c434f9aa037bf795..08aceec982301cbf4c5182c056ff9a878f0c4b65 100755 (executable)
@@ -4,6 +4,7 @@
 #include <dt-bindings/rkfb/rk_fb.h>
 #include "rk3188_io_vol_domain.dtsi"
 
+#include <dt-bindings/sensor-dev.h>
 
 / {
        compatible = "rockchip,rk3188";
index 9c13b63ef915fbf955e1836e8b4961afaa807238..12eaec2e9a7ed9ed074f4b421a0be2e85ab1beda 100644 (file)
@@ -197,6 +197,7 @@ source "drivers/input/touchscreen/Kconfig"
 
 source "drivers/input/misc/Kconfig"
 
+source "drivers/input/sensors/Kconfig"
 endif
 
 menu "Hardware I/O ports"
index 191ea43d0800f8036aba0b065d5e580de4521fe0..1b7621cae0165e89a1e2d4e124ca7c39ce325634 100644 (file)
@@ -23,6 +23,6 @@ obj-$(CONFIG_INPUT_JOYSTICK)  += joystick/
 obj-$(CONFIG_INPUT_TABLET)     += tablet/
 obj-$(CONFIG_INPUT_TOUCHSCREEN)        += touchscreen/
 obj-$(CONFIG_INPUT_MISC)       += misc/
-
+obj-$(CONFIG_SENSOR_DEVICE) += sensors/
 obj-$(CONFIG_INPUT_APMPOWER)   += apm-power.o
 obj-$(CONFIG_INPUT_KEYRESET)   += keyreset.o
index 81852bde8377e6eb09646c55ed4779671f63488d..37da5c5479ddbe0f723a1074a8eae0879fff4098 100755 (executable)
 #include <linux/workqueue.h>\r
 #include <linux/freezer.h>\r
 #include <linux/proc_fs.h>\r
-#include <mach/gpio.h>\r
-#include <mach/board.h> \r
+#include <linux/gpio.h>\r
+#include <linux/of_gpio.h>\r
+#include <linux/of.h>\r
 #ifdef CONFIG_HAS_EARLYSUSPEND\r
 #include <linux/earlysuspend.h>\r
 #endif\r
 #include <linux/l3g4200d.h>\r
 #include <linux/sensor-dev.h>\r
+#include <linux/module.h>\r
+\r
 \r
 \r
 /*\r
@@ -327,22 +330,22 @@ static int sensor_irq_init(struct i2c_client *client)
            (struct sensor_private_data *) i2c_get_clientdata(client);  \r
        int result = 0;\r
        int irq;\r
-       if((sensor->pdata->irq_enable)&&(sensor->ops->trig != SENSOR_UNKNOW_DATA))\r
+       if((sensor->pdata->irq_enable)&&(sensor->pdata->irq_flags!= SENSOR_UNKNOW_DATA))\r
        {\r
                //INIT_DELAYED_WORK(&sensor->delaywork, sensor_delaywork_func);\r
                if(sensor->pdata->poll_delay_ms < 0)\r
                        sensor->pdata->poll_delay_ms = 30;\r
-               \r
                result = gpio_request(client->irq, sensor->i2c_id->name);\r
                if (result)\r
                {\r
                        printk("%s:fail to request gpio :%d\n",__func__,client->irq);\r
                }\r
-       \r
-               gpio_pull_updown(client->irq, PullEnable);\r
+               \r
+               //gpio_pull_updown(client->irq, PullEnable);\r
                irq = gpio_to_irq(client->irq);\r
                //result = request_irq(irq, sensor_interrupt, sensor->ops->trig, sensor->ops->name, sensor);\r
-               result = request_threaded_irq(irq, NULL, sensor_interrupt, sensor->ops->trig, sensor->ops->name, sensor);\r
+               //result = request_threaded_irq(irq, NULL, sensor_interrupt, sensor->ops->trig, sensor->ops->name, sensor);\r
+               result = devm_request_threaded_irq(&client->dev, irq, NULL, sensor_interrupt, sensor->pdata->irq_flags | IRQF_ONESHOT, sensor->ops->name, sensor);\r
                if (result) {\r
                        printk(KERN_ERR "%s:fail to request irq = %d, ret = 0x%x\n",__func__, irq, result);            \r
                        goto error;            \r
@@ -354,7 +357,7 @@ static int sensor_irq_init(struct i2c_client *client)
                disable_irq_nosync(client->irq);//disable irq   \r
                if(((sensor->pdata->type == SENSOR_TYPE_TEMPERATURE) || (sensor->pdata->type == SENSOR_TYPE_PRESSURE))&& (!(sensor->ops->trig & IRQF_SHARED)))          \r
                disable_irq_nosync(client->irq);//disable irq\r
-               printk("%s:use irq=%d\n",__func__,irq);\r
+               DBG("%s:use irq=%d\n",__func__,irq);\r
        }\r
        else if(!sensor->pdata->irq_enable)\r
        {               \r
@@ -362,7 +365,7 @@ static int sensor_irq_init(struct i2c_client *client)
                if(sensor->pdata->poll_delay_ms < 0)\r
                        sensor->pdata->poll_delay_ms = 30;\r
                \r
-               printk("%s:use polling,delay=%d ms\n",__func__,sensor->pdata->poll_delay_ms);\r
+               DBG("%s:use polling,delay=%d ms\n",__func__,sensor->pdata->poll_delay_ms);\r
        }\r
 \r
 error: \r
@@ -1647,6 +1650,9 @@ int sensor_probe(struct i2c_client *client, const struct i2c_device_id *devid)
        struct sensor_private_data *sensor =\r
            (struct sensor_private_data *) i2c_get_clientdata(client);\r
        struct sensor_platform_data *pdata;\r
+       struct device_node *np = client->dev.of_node;\r
+       enum of_gpio_flags rst_flags, pwr_flags;\r
+       unsigned long irq_flags;\r
        int result = 0;\r
        int type = 0;\r
        \r
@@ -1656,54 +1662,212 @@ int sensor_probe(struct i2c_client *client, const struct i2c_device_id *devid)
                result = -ENODEV;\r
                goto out_no_free;\r
        }\r
-\r
-       pdata = client->dev.platform_data;\r
+       if (!np) {\r
+               dev_err(&client->dev, "no device tree\n");\r
+               return -EINVAL;\r
+       }\r
+    pdata = devm_kzalloc(&client->dev,sizeof(*pdata), GFP_KERNEL);\r
        if (!pdata) {\r
-               dev_err(&client->adapter->dev,\r
-                       "Missing platform data for slave %s\n", devid->name);\r
-               result = -EFAULT;\r
+               result = -ENOMEM;\r
                goto out_no_free;\r
        }\r
-\r
-       sensor = kzalloc(sizeof(*sensor), GFP_KERNEL);\r
+       sensor = devm_kzalloc(&client->dev,sizeof(*sensor), GFP_KERNEL);\r
        if (!sensor) {\r
                result = -ENOMEM;\r
                goto out_no_free;\r
        }\r
+       \r
+       of_property_read_u32(np,"type",&(pdata->type));\r
+\r
+       pdata->irq_pin = of_get_named_gpio_flags(np, "irq-gpio", 0,(enum of_gpio_flags *)&irq_flags);\r
+       pdata->reset_pin = of_get_named_gpio_flags(np, "reset-gpio",0,&rst_flags);\r
+       pdata->power_pin = of_get_named_gpio_flags(np, "power-gpio",0,&pwr_flags);\r
+       \r
+       of_property_read_u32(np,"irq_enable",&(pdata->irq_enable));\r
+       of_property_read_u32(np,"poll_delay_ms",&(pdata->poll_delay_ms));\r
+\r
+       of_property_read_u32(np,"x_min",&(pdata->x_min));\r
+       of_property_read_u32(np,"y_min",&(pdata->y_min));\r
+       of_property_read_u32(np,"z_min",&(pdata->z_min));\r
+       of_property_read_u32(np,"factory",&(pdata->factory));\r
+       of_property_read_u32(np,"layout",&(pdata->layout));\r
+\r
+       of_property_read_u8(np,"address",&(pdata->address));\r
+       pdata->project_name = of_get_property(np, "project_name", NULL);\r
+\r
+\r
+       switch(pdata->layout)\r
+       {\r
+               case 1:\r
+                       pdata->orientation[0] = 1;\r
+                       pdata->orientation[1] = 0;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = 0;\r
+                       pdata->orientation[4] = 1;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = 1;\r
+                       break;\r
+\r
+               case 2:\r
+                       pdata->orientation[0] = 0;\r
+                       pdata->orientation[1] = -1;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = 1;\r
+                       pdata->orientation[4] = 0;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = 1;\r
+                       break;\r
+\r
+               case 3:\r
+                       pdata->orientation[0] = -1;\r
+                       pdata->orientation[1] = 0;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = 0;\r
+                       pdata->orientation[4] = -1;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = 1;\r
+                       break;\r
+\r
+               case 4:\r
+                       pdata->orientation[0] = 0;\r
+                       pdata->orientation[1] = 1;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = -1;\r
+                       pdata->orientation[4] = 0;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = 1;\r
+                       break;\r
+\r
+               case 5:\r
+                       pdata->orientation[0] = 1;\r
+                       pdata->orientation[1] = 0;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = 0;\r
+                       pdata->orientation[4] = -1;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = -1;\r
+                       break;\r
+\r
+               case 6:\r
+                       pdata->orientation[0] = 0;\r
+                       pdata->orientation[1] = -1;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = -1;\r
+                       pdata->orientation[4] = 0;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = -1;\r
+                       break;\r
+\r
+               case 7:\r
+                       pdata->orientation[0] = -1;\r
+                       pdata->orientation[1] = 0;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = 0;\r
+                       pdata->orientation[4] = 1;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = -1;\r
+                       break;\r
+\r
+               case 8:\r
+                       pdata->orientation[0] = 0;\r
+                       pdata->orientation[1] = 1;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = 1;\r
+                       pdata->orientation[4] = 0;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = -1;\r
+                       break;\r
+\r
+               default:\r
+                       pdata->orientation[0] = 1;\r
+                       pdata->orientation[1] = 0;\r
+                       pdata->orientation[2] = 0;\r
+\r
+                       pdata->orientation[3] = 0;\r
+                       pdata->orientation[4] = 1;\r
+                       pdata->orientation[5] = 0;\r
+\r
+                       pdata->orientation[6] = 0;\r
+                       pdata->orientation[7] = 0;\r
+                       pdata->orientation[8] = 1;\r
+                       break;\r
+       }\r
 \r
-       type= pdata->type;      \r
+       client->irq = pdata->irq_pin;\r
+       type = pdata->type;\r
+       pdata->irq_flags = irq_flags;\r
+       printk("irq_flags = %lu  padta->irq_flags = %lu\n",irq_flags, pdata->irq_flags);\r
+       printk("type = %d \n",pdata->type);\r
+       printk("irq = %d \n",pdata->irq);\r
+       printk("irq_pin = %d \n",pdata->irq_pin);\r
+       printk("pwer_pin = %d \n",pdata->power_pin);    \r
+       printk("reset_pin = %d \n",pdata->reset_pin);\r
+       printk("irq_enable = %d \n",pdata->irq_enable);\r
+\r
+       printk("poll_delay_ms = %d \n",pdata->poll_delay_ms);\r
+       printk("x_min = %d \n",pdata->x_min);\r
+       printk("y_min = %d \n",pdata->y_min);\r
+       printk("z_min = %d \n",pdata->z_min);   \r
+       printk("factory = %d \n",pdata->factory);\r
+       printk("layout = %d \n",pdata->layout);\r
+       printk("address = 0x%x \n",pdata->address);\r
+       printk("project_name = [%s] \n",pdata->project_name);\r
+       \r
+       printk(" == %d,%d ,%d \t ,%d ,%d ,%d , \t ,%d, %d, %d ,==%d\n",pdata->orientation[0],pdata->orientation[1],pdata->orientation[2]\r
+                               ,pdata->orientation[3],pdata->orientation[4],pdata->orientation[5]\r
+                               ,pdata->orientation[6],pdata->orientation[7],pdata->orientation[8],ARRAY_SIZE(pdata->orientation));\r
+               \r
        \r
        if((type >= SENSOR_NUM_TYPES) || (type <= SENSOR_TYPE_NULL))\r
        {       \r
-               dev_err(&client->adapter->dev, "sensor type is error %d\n", pdata->type);\r
+               dev_err(&client->adapter->dev, "sensor type is error %d\n", type);\r
                result = -EFAULT;\r
                goto out_no_free;       \r
        }\r
-\r
        if(((int)devid->driver_data >= SENSOR_NUM_ID) || ((int)devid->driver_data <= ID_INVALID))\r
        {       \r
                dev_err(&client->adapter->dev, "sensor id is error %d\n", (int)devid->driver_data);\r
                result = -EFAULT;\r
                goto out_no_free;       \r
        }\r
-       \r
        i2c_set_clientdata(client, sensor);\r
        sensor->client = client;        \r
        sensor->pdata = pdata;  \r
        sensor->type = type;\r
        sensor->i2c_id = (struct i2c_device_id *)devid;\r
 \r
-       if (pdata->init_platform_hw) {\r
-               result = pdata->init_platform_hw();\r
-               if (result < 0)\r
-                       goto out_free_memory;\r
-       }\r
-\r
-       if(pdata->reset_pin)\r
-       gpio_request(pdata->reset_pin,"sensor_reset_pin");\r
-\r
-       if(pdata->power_pin)\r
-       gpio_request(pdata->power_pin,"sensor_power_pin");\r
                \r
        memset(&(sensor->axis), 0, sizeof(struct sensor_axis) );\r
        atomic_set(&(sensor->data_ready), 0);\r
@@ -1718,7 +1882,7 @@ int sensor_probe(struct i2c_client *client, const struct i2c_device_id *devid)
        atomic_set(&sensor->flags.a_flag, 1);\r
        atomic_set(&sensor->flags.mv_flag, 1);                  \r
        atomic_set(&sensor->flags.open_flag, 0);\r
-       atomic_set(&sensor->flags.debug_flag, 0);\r
+       atomic_set(&sensor->flags.debug_flag, 1);\r
        init_waitqueue_head(&sensor->flags.open_wq);\r
        sensor->flags.delay = 100;\r
 \r
@@ -1972,6 +2136,47 @@ static const struct i2c_device_id sensor_id[] = {
        {},\r
 };\r
 \r
+static struct of_device_id sensor_dt_ids[] = {\r
+       /*gsensor*/\r
+       { .compatible = "gs_mma8452" },\r
+       { .compatible = "gs_lis3dh" },\r
+       { .compatible = "gs_lsm303d" },\r
+       { .compatible = "gs_mma7660" },\r
+       \r
+       /*compass*/\r
+       { .compatible = "ak8975" },\r
+       { .compatible = "ak8963" },\r
+       { .compatible = "ak09911" },\r
+       { .compatible = "mmc314x" },\r
+\r
+       /* gyroscop*/\r
+       { .compatible = "l3g4200d_gyro" },\r
+       { .compatible = "l3g20d_gyro" },\r
+       { .compatible = "ewtsa_gyro" },\r
+       { .compatible = "k3g" },\r
+       \r
+       \r
+       /*light sensor*/\r
+       { .compatible = "light_cm3217" },\r
+       { .compatible = "light_cm3232" },\r
+       { .compatible = "light_al3006" },\r
+       { .compatible = "ls_stk3171" },\r
+       { .compatible = "ls_ap321xx" },\r
+\r
+       { .compatible = "ls_photoresistor" },\r
+       { .compatible = "ls_us5152" },\r
+\r
+       /*temperature sensor*/\r
+       { .compatible = "tmp_ms5607" },\r
+       \r
+       /*pressure sensor*/\r
+       { .compatible = "pr_ms5607" },\r
+\r
+       /*hall sensor*/\r
+       { .compatible = "hall_och165t" },\r
+       { }\r
+};\r
+\r
 \r
 static struct i2c_driver sensor_driver = {\r
        .probe = sensor_probe,\r
@@ -1981,7 +2186,8 @@ static struct i2c_driver sensor_driver = {
        .driver = {\r
                   .owner = THIS_MODULE,\r
                   .name = "sensors",\r
-                  },\r
+                  .of_match_table = of_match_ptr(sensor_dt_ids),\r
+       },\r
 };\r
 \r
 static int __init sensor_init(void)\r
index a5326bf8b8f73b098b94ade7c81fe63912026e2d..7a36954cd24dc4249b188f0aea577883d5c7d0b9 100755 (executable)
@@ -25,8 +25,7 @@
 #include <linux/input.h>\r
 #include <linux/workqueue.h>\r
 #include <linux/freezer.h>\r
-#include <mach/gpio.h>\r
-#include <mach/board.h> \r
+#include <linux/of_gpio.h>\r
 #ifdef CONFIG_HAS_EARLYSUSPEND\r
 #include <linux/earlysuspend.h>\r
 #endif\r
@@ -100,8 +99,8 @@ static int senosr_i2c_read(struct i2c_adapter *i2c_adap,
 \r
 int sensor_rx_data(struct i2c_client *client, char *rxData, int length)\r
 {\r
-       struct sensor_private_data* sensor = \r
-               (struct sensor_private_data *)i2c_get_clientdata(client);\r
+       //struct sensor_private_data* sensor = \r
+       //      (struct sensor_private_data *)i2c_get_clientdata(client);\r
        int i = 0;\r
        int ret = 0;\r
        char reg = rxData[0];\r
@@ -117,8 +116,8 @@ EXPORT_SYMBOL(sensor_rx_data);
 \r
 int sensor_tx_data(struct i2c_client *client, char *txData, int length)\r
 {\r
-       struct sensor_private_data* sensor = \r
-               (struct sensor_private_data *)i2c_get_clientdata(client);\r
+       //struct sensor_private_data* sensor = \r
+               //(struct sensor_private_data *)i2c_get_clientdata(client);\r
        int i = 0;\r
        int ret = 0;\r
 \r
@@ -165,6 +164,37 @@ int sensor_read_reg(struct i2c_client *client, int addr)
 \r
 EXPORT_SYMBOL(sensor_read_reg);\r
 \r
+static int i2c_master_normal_recv(const struct i2c_client *client, char *buf, int count, int scl_rate)\r
+ {\r
+     struct i2c_adapter *adap=client->adapter;\r
+     struct i2c_msg msg;\r
+    int ret;\r
\r
+    msg.addr = client->addr;\r
+    msg.flags = client->flags | I2C_M_RD;\r
+       msg.len = count;\r
+       msg.buf = (char *)buf;\r
+       msg.scl_rate = scl_rate;\r
+       ret = i2c_transfer(adap, &msg, 1);\r
+\r
+                return (ret == 1) ? count : ret;\r
+}\r
+\r
+static int i2c_master_normal_send(const struct i2c_client *client, const char *buf, int count, int scl_rate)\r
+{\r
+       int ret;\r
+       struct i2c_adapter *adap=client->adapter;\r
+       struct i2c_msg msg; \r
+\r
+       msg.addr = client->addr;\r
+       msg.flags = client->flags;\r
+       msg.len = count;\r
+       msg.buf = (char *)buf;\r
+       msg.scl_rate = scl_rate;\r
+\r
+       ret = i2c_transfer(adap, &msg, 1);\r
+       return (ret == 1) ? count : ret;\r
+}\r
 \r
 int sensor_tx_data_normal(struct i2c_client *client, char *buf, int num)\r
 {\r
diff --git a/include/dt-bindings/sensor-dev.h b/include/dt-bindings/sensor-dev.h
new file mode 100755 (executable)
index 0000000..1533243
--- /dev/null
@@ -0,0 +1,17 @@
+
+#ifndef __DT_BINDINGS_ROCKCHIP_SENSORDEV_H__
+#define __DT_BINDINGS_ROCKCHIP_SENSORDEV_H__
+
+#define        SENSOR_TYPE_NULL  0     
+#define        SENSOR_TYPE_ANGLE 1
+#define        SENSOR_TYPE_ACCEL 2
+#define        SENSOR_TYPE_COMPASS 3   
+#define        SENSOR_TYPE_GYROSCOPE 4 
+#define        SENSOR_TYPE_LIGHT 5     
+#define        SENSOR_TYPE_PROXIMITY 6
+#define        SENSOR_TYPE_TEMPERATURE 7       
+#define        SENSOR_TYPE_PRESSURE 8
+#define        SENSOR_TYPE_HALL 9
+#define        SENSOR_NUM_TYPES 10
+
+#endif
index 582994c498340bda13a51d54c96fc24999b9cdb0..2a86fd6a72b3dd76cf986647d645709017a2e781 100755 (executable)
 #include <linux/earlysuspend.h>\r
 #endif\r
 \r
+#include <dt-bindings/sensor-dev.h>\r
 \r
 #define SENSOR_ON              1\r
 #define SENSOR_OFF             0\r
 #define SENSOR_UNKNOW_DATA     -1\r
 \r
-enum sensor_type {\r
-       SENSOR_TYPE_NULL,               \r
-       SENSOR_TYPE_ANGLE,\r
-       SENSOR_TYPE_ACCEL,\r
-       SENSOR_TYPE_COMPASS,    \r
-       SENSOR_TYPE_GYROSCOPE,  \r
-       SENSOR_TYPE_LIGHT,      \r
-       SENSOR_TYPE_PROXIMITY,\r
-       SENSOR_TYPE_TEMPERATURE,        \r
-       SENSOR_TYPE_PRESSURE,\r
-       SENSOR_NUM_TYPES\r
-};\r
+#define GPIO_HIGH 1\r
+#define GPIO_LOW 0\r
 \r
 enum sensor_id {\r
        ID_INVALID = 0,\r
@@ -107,6 +98,10 @@ enum sensor_id {
        PRESSURE_ID_ALL,\r
        PRESSURE_ID_BMA085,\r
        PRESSURE_ID_MS5607,\r
+\r
+       HALL_ID_ALL,\r
+       HALL_ID_OCH165T,\r
+       \r
        SENSOR_NUM_ID,\r
 };\r
 \r
@@ -183,6 +178,53 @@ struct sensor_private_data {
 #endif\r
 };\r
 \r
+struct sensor_platform_data {\r
+       int type;\r
+       int irq;\r
+       int irq_pin;\r
+       int power_pin;\r
+       int reset_pin;\r
+       int standby_pin;\r
+       int irq_enable;         //if irq_enable=1 then use irq else use polling  \r
+       int poll_delay_ms;      //polling\r
+       int x_min;              //filter\r
+       int y_min;\r
+       int z_min;\r
+       int factory;\r
+       int layout;\r
+       unsigned char address;\r
+       unsigned long irq_flags;\r
+       signed char orientation[9];\r
+       short m_layout[4][3][3];\r
+       char* project_name;\r
+};\r
+\r
+ struct gsensor_platform_data {\r
+         u16 model;\r
+         u16 swap_xy;\r
+         u16 swap_xyz;\r
+         signed char orientation[9];\r
+         int (*get_pendown_state)(void);\r
+         int (*init_platform_hw)(void);\r
+         int (*gsensor_platform_sleep)(void);\r
+         int (*gsensor_platform_wakeup)(void);\r
+         void (*exit_platform_hw)(void);\r
+ };\r
\r
+ struct akm8975_platform_data {\r
+         short m_layout[4][3][3];\r
+         char project_name[64];\r
+         int gpio_DRDY;\r
+ };\r
\r
+ struct akm_platform_data {\r
+        short m_layout[4][3][3];\r
+        char project_name[64];\r
+        char layout;\r
+        char outbit;\r
+        int gpio_DRDY;\r
+        int gpio_RST;\r
+ };\r
 \r
 extern int sensor_register_slave(int type,struct i2c_client *client,\r
                        struct sensor_platform_data *slave_pdata,\r
@@ -193,7 +235,7 @@ extern int sensor_unregister_slave(int type,struct i2c_client *client,
                        struct sensor_platform_data *slave_pdata,\r
                        struct sensor_operate *(*get_sensor_ops)(void));\r
 \r
-#if 1\r
+#if 0\r
 #define DBG(x...) if((atomic_read(&sensor->flags.debug_flag) == sensor->pdata->type) || (atomic_read(&sensor->flags.debug_flag) == SENSOR_NUM_TYPES))printk(x)\r
 #else\r
 #define DBG(x...)\r