rk312x : cif : cif driver v0.0x1.5
authorzyc <zyc@rock-chips.com>
Thu, 4 Sep 2014 09:34:39 +0000 (17:34 +0800)
committerzyc <zyc@rock-chips.com>
Thu, 4 Sep 2014 09:34:39 +0000 (17:34 +0800)
arch/arm/boot/dts/rk3126-cif-sensor.dtsi
arch/arm/boot/dts/rk3128-cif-sensor.dtsi
arch/arm/mach-rockchip/rk_camera.c
arch/arm/mach-rockchip/rk_camera_sensor_info.h
drivers/media/video/rk30_camera_oneframe.c

index ce968112d26e9a2b2c50e06b4373f3a4c1ddc880..a817b80980b6944a2555af05fe70691a773c227d 100755 (executable)
                        rockchip,powerdown = <&gpio3 GPIO_B3 GPIO_ACTIVE_HIGH>;
                        pwdn_active = <ov2659_PWRDN_ACTIVE>;
                        #rockchip,power = <>;
-                       #pwr_active = <>;
+                       pwr_active = <PWR_ACTIVE_HIGH>;
                        #rockchip,reset = <>;
                        #rst_active = <>;
+                       #rockchip,flash = <>;
+                       #rockchip,af = <>;
                        mir = <0>;
                        flash_attach = <0>;
                        resolution = <ov2659_FULL_RESOLUTION>;
                        rockchip,powerdown = <&gpio3 GPIO_B3 GPIO_ACTIVE_HIGH>;
                        pwdn_active = <gc0329_PWRDN_ACTIVE>;
                        #rockchip,power = <>;
-                       #pwr_active = <>;
+                       pwr_active = <PWR_ACTIVE_HIGH>;
                        #rockchip,reset = <>;
                        #rst_active = <>;
+                       #rockchip,flash = <>;
+                       #rockchip,af = <>;
                        mir = <0>;
                        flash_attach = <0>;
                        resolution = <gc0329_FULL_RESOLUTION>;
index 209c9b1e050d027f771cb6aecbd8bb5959fd7754..17e81fecec35998ba412b372d95ec5c05b12cf26 100755 (executable)
                        rockchip,powerdown = <&gpio3 GPIO_D7 GPIO_ACTIVE_HIGH>;
                        pwdn_active = <ov2659_PWRDN_ACTIVE>;
                        #rockchip,power = <>;
-                       #pwr_active = <>;
+                       pwr_active = <PWR_ACTIVE_HIGH>;
                        #rockchip,reset = <>;
                        #rst_active = <>;
+                       #rockchip,flash = <>;
+                       #rockchip,af = <>;
                        mir = <0>;
                        flash_attach = <0>;
                        resolution = <ov2659_FULL_RESOLUTION>;
                        rockchip,powerdown = <&gpio3 GPIO_D7 GPIO_ACTIVE_HIGH>;
                        pwdn_active = <gc0329_PWRDN_ACTIVE>;
                        #rockchip,power = <>;
-                       #pwr_active = <>;
+                       pwr_active = <PWR_ACTIVE_HIGH>;
                        #rockchip,reset = <>;
                        #rst_active = <>;
+                       #rockchip,flash = <>;
+                       #rockchip,af = <>;
                        mir = <0>;
                        flash_attach = <0>;
                        resolution = <gc0329_FULL_RESOLUTION>;
index 350d759379f6cb73874bfea6fd02e0fd5843463f..b60c421c186037075fa1c452c12ca758249ab27b 100644 (file)
@@ -163,7 +163,7 @@ static int  rk_dts_sensor_probe(struct platform_device *pdev)
                u32     powerdown = INVALID_GPIO,power = INVALID_GPIO,reset = INVALID_GPIO;\r
                u32 af = INVALID_GPIO,flash = INVALID_GPIO;\r
 \r
-               int pwr_active = INVALID_VALUE, rst_active = INVALID_VALUE, pwdn_active = INVALID_VALUE;\r
+               int pwr_active = 0, rst_active = 0, pwdn_active = 0;\r
                int orientation = 0;\r
                struct rkcamera_platform_data *new_camera; \r
                new_camera = kzalloc(sizeof(struct rkcamera_platform_data),GFP_KERNEL);\r
@@ -211,16 +211,16 @@ static int        rk_dts_sensor_probe(struct platform_device *pdev)
                                dprintk("%s:Get %s pwr_active failed!\n",__func__, cp->name);                           \r
                }\r
                if (of_property_read_u32(cp, "rockchip,reset", &reset)) {\r
-                               printk("%s:Get %s rockchip,reset failed!\n",__func__, cp->name);                                \r
+                               dprintk("%s:Get %s rockchip,reset failed!\n",__func__, cp->name);                               \r
                }\r
                if (of_property_read_u32(cp, "rst_active", &rst_active)) {\r
                                dprintk("%s:Get %s rst_active failed!\n",__func__, cp->name);                           \r
                }\r
                if (of_property_read_u32(cp, "rockchip,af", &af)) {\r
-                               printk("%s:Get %s rockchip,af failed!\n",__func__, cp->name);                           \r
+                               dprintk("%s:Get %s rockchip,af failed!\n",__func__, cp->name);                          \r
                }\r
                if (of_property_read_u32(cp, "rockchip,flash", &flash)) {\r
-                               printk("%s:Get %s rockchip,flash failed!\n",__func__, cp->name);                                \r
+                               dprintk("%s:Get %s rockchip,flash failed!\n",__func__, cp->name);                               \r
                }\r
                if (of_property_read_u32(cp, "i2c_add", &i2c_add)) {\r
                        printk("%s:Get %s rockchip,i2c_add failed!\n",__func__, cp->name);                              \r
@@ -341,13 +341,11 @@ debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE
     if (camera_power != INVALID_GPIO)  {\r
                if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {\r
             if (on) {\r
-               /*gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));*/\r
-                               gpio_direction_output(camera_power,1);\r
+               gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
                                dprintk("%s PowerPin=%d ..PinLevel = %x",res->dev_name, camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
                        msleep(10);\r
                } else {\r
-                       /*gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));*/\r
-                               gpio_direction_output(camera_power,0);\r
+                       gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
                                dprintk("%s PowerPin=%d ..PinLevel = %x",res->dev_name, camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
                }\r
                } else {\r
@@ -551,28 +549,25 @@ static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct devic
                dprintk("%s power pin(%d) init success(0x%x)" ,gpio_res->dev_name,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));\r
 \r
     }\r
-/*\r
+\r
     if (camera_reset != INVALID_GPIO) {\r
+               \r
+               camera_power = of_get_named_gpio_flags(of_node,"rockchip,reset",0,&flags);/*yzm*/\r
+               gpio_res->gpio_reset = camera_reset;/*yzm information back to the IO*/\r
         ret = gpio_request(camera_reset, "camera reset");\r
         if (ret) {\r
             io_requested_in_camera = false;\r
-            for (i=0; i<RK_CAM_NUM; i++) {\r
-                io_res = &rk_camera_platform_data.gpio_res[i];\r
-                if (io_res->gpio_init & RK29_CAM_RESETACTIVE_MASK) {\r
-                    if (io_res->gpio_reset == camera_reset)\r
-                        io_requested_in_camera = true;    \r
-                }\r
-            }\r
 \r
             if (io_requested_in_camera==false) {\r
-                i=0;\r
-                while (strstr(new_camera[i].dev_name,"end")==NULL) {\r
-                    io_res = &new_camera[i].io;\r
+                               \r
+                new_camera = new_camera_head;\r
+                while (new_camera != NULL) {\r
+                    io_res = &new_camera->io;\r
                     if (io_res->gpio_init & RK29_CAM_RESETACTIVE_MASK) {\r
                         if (io_res->gpio_reset == camera_reset)\r
                             io_requested_in_camera = true;    \r
                     }\r
-                    i++;\r
+                    new_camera = new_camera->next_camera;\r
                 }\r
             }\r
             \r
@@ -583,13 +578,7 @@ static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct devic
                 ret =0;\r
             }\r
         }\r
-\r
-        if (rk_camera_platform_data.iomux(camera_reset,dev) < 0) {\r
-            ret = -1;\r
-            eprintk("%s reset pin(%d) iomux init failed", gpio_res->dev_name,camera_reset);\r
-            goto _rk_sensor_io_init_end_;\r
-        }\r
-        \r
+       \r
                gpio_res->gpio_init |= RK29_CAM_RESETACTIVE_MASK;\r
         gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));\r
         gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));\r
@@ -597,7 +586,7 @@ static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct devic
                dprintk("%s reset pin(%d) init success(0x%x)" ,gpio_res->dev_name,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));\r
 \r
     }\r
-*/\r
+\r
        if (camera_powerdown != INVALID_GPIO) {\r
                debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_powerdown  = %x\n", camera_powerdown );\r
 \r
@@ -638,28 +627,25 @@ static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct devic
                dprintk("%s powerdown pin(%d) init success(0x%x)" ,gpio_res->dev_name,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));\r
 \r
     }\r
-/*\r
+\r
        if (camera_flash != INVALID_GPIO) {\r
+\r
+               camera_flash = of_get_named_gpio_flags(of_node,"rockchip,flash",0,&flags);/*yzm*/\r
+               gpio_res->gpio_flash = camera_flash;/*yzm information back to the IO*/\r
         ret = gpio_request(camera_flash, "camera flash");\r
         if (ret) {\r
             io_requested_in_camera = false;\r
-            for (i=0; i<RK_CAM_NUM; i++) {\r
-                io_res = &rk_camera_platform_data.gpio_res[i];\r
-                if (io_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {\r
-                    if (io_res->gpio_powerdown == camera_powerdown)\r
-                        io_requested_in_camera = true;    \r
-                }\r
-            }\r
 \r
             if (io_requested_in_camera==false) {\r
-                i=0;\r
-                while (strstr(new_camera[i].dev_name,"end")==NULL) {\r
-                    io_res = &new_camera[i].io;\r
+\r
+                               new_camera = new_camera_head;\r
+                while (new_camera != NULL) {\r
+                    io_res = &new_camera->io;\r
                     if (io_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {\r
                         if (io_res->gpio_powerdown == camera_powerdown)\r
                             io_requested_in_camera = true;    \r
                     }\r
-                    i++;\r
+                    new_camera = new_camera->next_camera;\r
                 }\r
             }\r
             \r
@@ -671,9 +657,6 @@ static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct devic
         }\r
 \r
 \r
-        if (rk_camera_platform_data.iomux(camera_flash,dev) < 0) {\r
-            printk("%s flash pin(%d) iomux init failed\n",gpio_res->dev_name,camera_flash);                            \r
-        }\r
         \r
                gpio_res->gpio_init |= RK29_CAM_FLASHACTIVE_MASK;\r
         gpio_set_value(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));   //  falsh off \r
@@ -683,28 +666,24 @@ static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct devic
 \r
     }  \r
 \r
-\r
        if (camera_af != INVALID_GPIO) {\r
+               \r
+               camera_af = of_get_named_gpio_flags(of_node,"rockchip,af",0,&flags);/*yzm*/\r
+               gpio_res->gpio_af = camera_af;/*yzm information back to the IO*/\r
                ret = gpio_request(camera_af, "camera af");\r
                if (ret) {\r
                        io_requested_in_camera = false;\r
-                       for (i=0; i<RK_CAM_NUM; i++) {\r
-                               io_res = &rk_camera_platform_data.gpio_res[i];\r
-                               if (io_res->gpio_init & RK29_CAM_AFACTIVE_MASK) {\r
-                                       if (io_res->gpio_af == camera_af)\r
-                                               io_requested_in_camera = true;    \r
-                               }\r
-                       }\r
 \r
                        if (io_requested_in_camera==false) {\r
-                               i=0;\r
-                               while (strstr(new_camera[i].dev_name,"end")==NULL) {\r
-                                       io_res = &new_camera[i].io;\r
+\r
+                               new_camera = new_camera_head;\r
+                               while (new_camera != NULL) {\r
+                                       io_res = &new_camera->io;\r
                                        if (io_res->gpio_init & RK29_CAM_AFACTIVE_MASK) {\r
                                                if (io_res->gpio_af == camera_af)\r
                                                        io_requested_in_camera = true;    \r
                                        }\r
-                                       i++;\r
+                                       new_camera = new_camera->next_camera;\r
                                }\r
                        }\r
                        \r
@@ -716,20 +695,12 @@ static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct devic
             }\r
                        \r
                }\r
-\r
-\r
-               if (rk_camera_platform_data.iomux(camera_af,dev) < 0) {\r
-                        ret = -1;\r
-                       eprintk("%s af pin(%d) iomux init failed\n",gpio_res->dev_name,camera_af);      \r
-            goto _rk_sensor_io_init_end_;                      \r
-               }\r
                \r
                gpio_res->gpio_init |= RK29_CAM_AFACTIVE_MASK;\r
                //gpio_direction_output(camera_af, ((camera_ioflag&RK29_CAM_AFACTIVE_MASK)>>RK29_CAM_AFACTIVE_BITPOS));\r
                dprintk("%s af pin(%d) init success",gpio_res->dev_name, camera_af);\r
 \r
        }\r
-*/\r
 \r
        \r
 _rk_sensor_io_init_end_:\r
index 70f96bd5ddc9ecf6570fb35d6bf5f072f5bd62ee..9fded1de437707b791733f0bc4f922235d64c537 100644 (file)
 #define icatchov2720_I2C_ADDR       0x78  //zyt
 #define end_I2C_ADDR                INVALID_VALUE
 
+//Sensor power  active level define
+#define PWR_ACTIVE_HIGH                  0x01
+#define PWR_ACTIVE_LOW                                  0x0
 
 //Sensor power down active level define
 #define ov7675_PWRDN_ACTIVE             0x01            
index cead1f273367342f5386095b9ad39cd7464e667e..68ba342a17770f3fc1809e15aed57cbc22e41a93 100755 (executable)
@@ -264,8 +264,10 @@ static u32 DISABLE_INVERT_PCLK_CIF1;
                 1. i2c 1 and wifi use the common io in rk3128,so just enable i2c1 in rk3126 dts file
 *v0.1.4:
                 1. When cif was at work, the aclk is closed ,may cause bus abnormal ,so sleep 100ms before close aclk 
+*v0.1.5:       
+           1. Improve the code to support all configuration.reset,af,flash...
 */
-#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 1, 0x4)
+#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 1, 0x5)
 static int version = RK_CAM_VERSION_CODE;
 module_param(version, int, S_IRUGO);