2 #include "rk30_camera.h"
3 #include <linux/gpio.h>
4 #include <linux/delay.h>
5 #include <linux/version.h>
6 #include <linux/moduleparam.h>
7 #include <linux/of_gpio.h>
9 #include <linux/of_irq.h>
10 #include <linux/kernel.h>
11 #include <linux/of_address.h>
12 #include <linux/of_platform.h>
13 #include <linux/of_fdt.h>
14 #include <linux/module.h>
15 #include <linux/regulator/consumer.h>
18 static int camio_version = KERNEL_VERSION(0,1,9);
19 module_param(camio_version, int, S_IRUGO);
21 static int camera_debug = 0;
22 module_param(camera_debug, int, S_IRUGO|S_IWUSR);
25 #define CAMMODULE_NAME "rk_cam_io"
27 #define ddprintk(level, fmt, arg...) do { \
28 if (camera_debug >= level) \
29 printk(KERN_WARNING"%s(%d):" fmt"\n", CAMMODULE_NAME,__LINE__,## arg); } while (0)
31 #define dprintk(format, ...) ddprintk(1, format, ## __VA_ARGS__)
32 #define eprintk(format, ...) printk(KERN_ERR "%s(%d):" format"\n",CAMMODULE_NAME,__LINE__,## __VA_ARGS__)
33 #define debug_printk(format, ...) ddprintk(3, format, ## __VA_ARGS__)
35 static int rk_sensor_io_init(void);
36 static int rk_sensor_io_deinit(int sensor);
37 static int rk_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on);
38 static int rk_sensor_power(struct device *dev, int on);
39 static int rk_sensor_register(void);
40 /*static int rk_sensor_reset(struct device *dev);*/
42 static int rk_dts_sensor_probe(struct platform_device *pdev);
43 static int rk_dts_sensor_remove(struct platform_device *pdev);
44 static int rk_dts_cif_probe(struct platform_device *pdev);
45 static int rk_dts_cif_remove(struct platform_device *pdev);
47 static int rk_sensor_powerdown(struct device *dev, int on);
49 static struct rkcamera_platform_data *new_camera_head;
51 static struct rk29camera_platform_data rk_camera_platform_data = {
52 .io_init = rk_sensor_io_init,
53 .io_deinit = rk_sensor_io_deinit,
54 .sensor_ioctrl = rk_sensor_ioctrl,
55 .sensor_register = rk_sensor_register,
59 struct rk29camera_platform_ioctl_cb sensor_ioctl_cb = {
60 .sensor_power_cb = NULL,
61 .sensor_reset_cb = NULL,
62 .sensor_powerdown_cb = NULL,
63 .sensor_flash_cb = NULL,
68 static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
70 static struct resource rk_camera_resource_host_0[2] = {};
73 static struct resource rk_camera_resource_host_1[2] = {};
77 struct platform_device rk_device_camera_host_0 = {
78 .name = RK29_CAM_DRV_NAME,
79 .id = RK_CAM_PLATFORM_DEV_ID_0, /* This is used to put cameras on this interface*/
81 .resource = rk_camera_resource_host_0,
83 .dma_mask = &rockchip_device_camera_dmamask,
84 .coherent_dma_mask = 0xffffffffUL,
85 .platform_data = &rk_camera_platform_data,
91 struct platform_device rk_device_camera_host_1 = {
92 .name = RK29_CAM_DRV_NAME,
93 .id = RK_CAM_PLATFORM_DEV_ID_1, /* This is used to put cameras on this interface */
94 .num_resources = ARRAY_SIZE(rk_camera_resource_host_1),
95 .resource = rk_camera_resource_host_1,
97 .dma_mask = &rockchip_device_camera_dmamask,
98 .coherent_dma_mask = 0xffffffffUL,
99 .platform_data = &rk_camera_platform_data,
106 static const struct of_device_id of_match_cif[] = {
107 { .compatible = "rockchip,cif" },
111 MODULE_DEVICE_TABLE(of,of_match_cif);
112 static struct platform_driver rk_cif_driver =
116 .owner = THIS_MODULE,
117 .of_match_table = of_match_ptr(of_match_cif),
119 .probe = rk_dts_cif_probe,
120 .remove = rk_dts_cif_remove,
123 static const struct of_device_id of_match_sensor[] = {
124 { .compatible = "rockchip,sensor" },
126 MODULE_DEVICE_TABLE(of,of_match_sensor);
127 static struct platform_driver rk_sensor_driver =
130 .name = RK_SENSOR_NAME,
131 .owner = THIS_MODULE,
132 .of_match_table = of_match_ptr(of_match_sensor),
134 .probe = rk_dts_sensor_probe,
135 .remove = rk_dts_sensor_remove,
138 unsigned long rk_cif_grf_base;
139 unsigned long rk_cif_cru_base;
141 static int rk_dts_sensor_remove(struct platform_device *pdev)
145 static int rk_dts_sensor_probe(struct platform_device *pdev)
147 struct device_node *np, *cp;
148 int sensor_num = 0,err;
149 struct device *dev = &pdev->dev;
150 struct rkcamera_platform_data *new_camera_list;
152 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
157 for_each_child_of_node(np, cp) {
158 u32 flash_attach = 0,mir = 0,i2c_rata = 0,i2c_chl = 0,i2c_add = 0;
159 u32 cif_chl = 0, mclk_rate = 0, is_front = 0;
160 u32 resolution = 0, powerup_sequence = 0;
162 u32 powerdown = INVALID_GPIO,power = INVALID_GPIO,reset = INVALID_GPIO;
163 u32 af = INVALID_GPIO,flash = INVALID_GPIO;
165 int pwr_active = 0, rst_active = 0, pwdn_active = 0,flash_active = 0;
167 struct rkcamera_platform_data *new_camera;
169 char sensor_name[20] = {0};
172 strcpy(sensor_name,cp->name);
174 if(strstr(sensor_name,"_") != NULL){
175 name = strsep(&name,"_");
178 new_camera = kzalloc(sizeof(struct rkcamera_platform_data),GFP_KERNEL);
181 new_camera_head = new_camera;
182 rk_camera_platform_data.register_dev_new = new_camera_head;
183 new_camera_list = new_camera;
186 new_camera_list->next_camera = new_camera;
187 new_camera_list = new_camera;
189 if (of_property_read_u32(cp, "flash_attach", &flash_attach)) {
190 dprintk("%s:Get %s rockchip,flash_attach failed!\n",__func__, cp->name);
192 if (of_property_read_u32(cp, "mir", &mir)) {
193 dprintk("%s:Get %s rockchip,mir failed!\n",__func__, cp->name);
195 if (of_property_read_u32(cp, "i2c_rata", &i2c_rata)) {
196 dprintk("%s:Get %s rockchip,i2c_rata failed!\n",__func__, cp->name);
198 if (of_property_read_u32(cp, "i2c_chl", &i2c_chl)) {
199 dprintk("%s:Get %s rockchip,i2c_chl failed!\n",__func__, cp->name);
201 if (of_property_read_u32(cp, "cif_chl", &cif_chl)) {
202 dprintk("%s:Get %s rockchip,cif_chl failed!\n",__func__, cp->name);
204 if (of_property_read_u32(cp, "mclk_rate", &mclk_rate)) {
205 dprintk("%s:Get %s rockchip,mclk_rate failed!\n",__func__, cp->name);
207 if (of_property_read_u32(cp, "is_front", &is_front)) {
208 dprintk("%s:Get %s rockchip,is_front failed!\n",__func__, cp->name);
210 if (of_property_read_u32(cp, "rockchip,powerdown", &powerdown)) {
211 printk("%s:Get %s rockchip,powerdown failed!\n",__func__, cp->name);
213 if (of_property_read_u32(cp, "pwdn_active", &pwdn_active)) {
214 dprintk("%s:Get %s pwdn_active failed!\n",__func__, cp->name);
216 if (of_property_read_u32(cp, "rockchip,power", &power)) {
217 printk("%s:Get %s rockchip,power failed!\n",__func__, cp->name);
219 if (of_property_read_u32(cp, "pwr_active", &pwr_active)) {
220 dprintk("%s:Get %s pwr_active failed!\n",__func__, cp->name);
222 if (of_property_read_u32(cp, "rockchip,reset", &reset)) {
223 dprintk("%s:Get %s rockchip,reset failed!\n",__func__, cp->name);
225 if (of_property_read_u32(cp, "rst_active", &rst_active)) {
226 dprintk("%s:Get %s rst_active failed!\n",__func__, cp->name);
228 if (of_property_read_u32(cp, "rockchip,af", &af)) {
229 dprintk("%s:Get %s rockchip,af failed!\n",__func__, cp->name);
231 if (of_property_read_u32(cp, "rockchip,flash", &flash)) {
232 dprintk("%s:Get %s rockchip,flash failed!\n",__func__, cp->name);
234 if (of_property_read_u32(cp, "flash_active", &flash_active)) {
235 dprintk("%s:Get %s flash_active failed!\n",__func__, cp->name);
237 if (of_property_read_u32(cp, "i2c_add", &i2c_add)) {
238 printk("%s:Get %s rockchip,i2c_add failed!\n",__func__, cp->name);
240 if (of_property_read_u32(cp, "resolution", &resolution)) {
241 printk("%s:Get %s rockchip,resolution failed!\n",__func__, cp->name);
243 if (of_property_read_u32(cp, "powerup_sequence", &powerup_sequence)) {
244 printk("%s:Get %s rockchip,powerup_sequence failed!\n",__func__, cp->name);
246 if (of_property_read_u32(cp, "orientation", &orientation)) {
247 printk("%s:Get %s rockchip,orientation failed!\n",__func__, cp->name);
250 strcpy(new_camera->dev.i2c_cam_info.type, name);
251 new_camera->dev.i2c_cam_info.addr = i2c_add>>1;
252 new_camera->dev.desc_info.host_desc.bus_id = RK29_CAM_PLATFORM_DEV_ID+cif_chl;
253 new_camera->dev.desc_info.host_desc.i2c_adapter_id = i2c_chl;
254 new_camera->dev.desc_info.host_desc.module_name = name;
255 new_camera->dev.device_info.name = "soc-camera-pdrv";
257 sprintf(new_camera->dev_name,"%s_%s",name,"front");
259 sprintf(new_camera->dev_name,"%s_%s",name,"back");
260 new_camera->dev.device_info.dev.init_name =(const char*)&new_camera->dev_name[0];
261 new_camera->io.gpio_reset = reset;
262 new_camera->io.gpio_powerdown = powerdown;
263 new_camera->io.gpio_power = power;
264 new_camera->io.gpio_af = af;
265 new_camera->io.gpio_flash = flash;
266 new_camera->io.gpio_flag = ((pwr_active&0x01)<<RK29_CAM_POWERACTIVE_BITPOS)
267 |((rst_active&0x01)<<RK29_CAM_RESETACTIVE_BITPOS)
268 |((pwdn_active&0x01)<<RK29_CAM_POWERDNACTIVE_BITPOS)
269 |((flash_active&0x01)<<RK29_CAM_FLASHACTIVE_BITPOS);
270 new_camera->orientation = orientation;
271 new_camera->resolution = resolution;
272 new_camera->mirror = mir;
273 new_camera->i2c_rate = i2c_rata;
274 new_camera->flash = flash_attach;
275 new_camera->pwdn_info = ((pwdn_active&0x10)|0x01);
276 new_camera->powerup_sequence = powerup_sequence;
277 new_camera->mclk_rate = mclk_rate;
278 new_camera->of_node = cp;
280 new_camera->powerdown_pmu_name = NULL;
281 new_camera->power_pmu_name1 = NULL;
282 new_camera->power_pmu_name2 = NULL;
283 new_camera->powerdown_pmu_voltage = 0;
284 new_camera->power_pmu_name1 = 0;
285 new_camera->power_pmu_name2 = 0;
286 err = of_property_read_string(cp,"rockchip,powerdown_pmu",&(new_camera->powerdown_pmu_name));
288 dprintk("Get rockchip,powerdown_pmu failed\n");
290 err = of_property_read_string(cp,"rockchip,power_pmu_name1",&(new_camera->power_pmu_name1));
292 dprintk("Get rockchip,power_pmu_name1 failed\n");
294 err = of_property_read_string(cp,"rockchip,power_pmu_name2",&(new_camera->power_pmu_name2));
296 dprintk("rockchip,power_pmu_name2 failed\n");
299 if (of_property_read_u32(cp, "rockchip,powerdown_pmu_voltage", &(new_camera->powerdown_pmu_voltage))) {
300 dprintk("%s:Get %s rockchip,resolution failed!\n",__func__, cp->name);
302 if (of_property_read_u32(cp, "rockchip,power_pmu_voltage1", &(new_camera->power_pmu_voltage1))) {
303 dprintk("%s:Get %s rockchip,resolution failed!\n",__func__, cp->name);
305 if (of_property_read_u32(cp, "rockchip,power_pmu_voltage2", &(new_camera->power_pmu_voltage2))) {
306 dprintk("%s:Get %s rockchip,resolution failed!\n",__func__, cp->name);
308 debug_printk( "******************* /n power = %x\n", power);
309 debug_printk( "******************* /n powerdown = %x\n", powerdown);
310 debug_printk( "******************* /n i2c_add = %x\n", new_camera->dev.i2c_cam_info.addr << 1);
311 debug_printk( "******************* /n i2c_chl = %d\n", new_camera->dev.desc_info.host_desc.i2c_adapter_id);
312 debug_printk( "******************* /n init_name = %s\n", new_camera->dev.device_info.dev.init_name);
313 debug_printk( "******************* /n dev_name = %s\n", new_camera->dev_name);
314 debug_printk( "******************* /n module_name = %s\n", new_camera->dev.desc_info.host_desc.module_name);
316 new_camera_list->next_camera = NULL;
320 static int rk_dts_cif_remove(struct platform_device *pdev)
325 static int rk_dts_cif_probe(struct platform_device *pdev)
328 struct device *dev = &pdev->dev;
329 const char *compatible = NULL;
330 struct device_node * vpu_node =NULL;
331 int vpu_iommu_enabled = 0;
333 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
335 rk_camera_platform_data.cif_dev = &pdev->dev;
337 err = of_address_to_resource(dev->of_node, 0, &rk_camera_resource_host_0[0]);
339 printk(KERN_EMERG "Get register resource from %s platform device failed!",pdev->name);
342 rk_camera_resource_host_0[0].flags = IORESOURCE_MEM;
344 irq = irq_of_parse_and_map(dev->of_node, 0);
346 printk(KERN_EMERG "Get irq resource from %s platform device failed!",pdev->name);
349 err = of_property_read_string(dev->of_node->parent,"compatible",&compatible);
350 rk_camera_platform_data.rockchip_name = compatible;
352 vpu_node = of_find_node_by_name(NULL, "vpu_service");
354 err = of_property_read_u32(vpu_node, "iommu_enabled", &vpu_iommu_enabled);
355 rk_camera_platform_data.iommu_enabled = vpu_iommu_enabled;
356 of_node_put(vpu_node);
358 printk("get vpu_node failed,vpu_iommu_enabled == 0 !!!!!!\n");
361 if(strstr(rk_camera_platform_data.rockchip_name,"3368")){
363 vpu_node = of_parse_phandle(dev->of_node, "rockchip,cru", 0);
364 rk_cif_cru_base = (unsigned long)of_iomap(vpu_node, 0);
365 debug_printk(">>>>>>>rk_cif_cru_base=0x%lx",rk_cif_cru_base);
368 vpu_node = of_parse_phandle(dev->of_node, "rockchip,grf", 0);
369 rk_cif_grf_base = (unsigned long)of_iomap(vpu_node, 0);
370 debug_printk(">>>>>>>rk_cif_grf_base=0x%lx",rk_cif_grf_base);
374 printk(KERN_EMERG "Get rockchip compatible failed!!!!!!");
378 //printk(KERN_ERR "***************%s*************\n", rk_camera_platform_data.rockchip_name);
379 rk_camera_resource_host_0[1].start = irq;
380 rk_camera_resource_host_0[1].end = irq;
381 rk_camera_resource_host_0[1].flags = IORESOURCE_IRQ;
385 static int rk_cif_sensor_init(void)
388 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
389 platform_driver_register(&rk_cif_driver);
391 platform_driver_register(&rk_sensor_driver);
396 static int sensor_power_default_cb (struct rk29camera_gpio_res *res, int on)
398 int camera_power = res->gpio_power;
399 int camera_ioflag = res->gpio_flag;
400 int camera_io_init = res->gpio_init;
403 struct regulator *ldo_18,*ldo_28;
404 struct rkcamera_platform_data *dev = container_of(res,struct rkcamera_platform_data,io);
406 int power_pmu_voltage1 = dev->power_pmu_voltage1;
407 int power_pmu_voltage2 = dev->power_pmu_voltage2;
408 const char *camera_power_pmu_name1 = dev->power_pmu_name1;
409 const char *camera_power_pmu_name2 = dev->power_pmu_name2;;
411 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
413 if(camera_power_pmu_name1 != NULL) {
414 ldo_28 = regulator_get(NULL, camera_power_pmu_name1); // vcc28_cif
416 regulator_set_voltage(ldo_28, power_pmu_voltage1, power_pmu_voltage1);
417 ret = regulator_enable(ldo_28);
418 //printk("%s set ldo7 vcc28_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_28));
419 regulator_put(ldo_28);
423 while(regulator_is_enabled(ldo_28)>0)
424 regulator_disable(ldo_28);
425 regulator_put(ldo_28);
429 if(camera_power_pmu_name2 != NULL) {
430 ldo_18 = regulator_get(NULL, camera_power_pmu_name2); // vcc18_cif
432 regulator_set_voltage(ldo_18, power_pmu_voltage2, power_pmu_voltage2);
433 //regulator_set_suspend_voltage(ldo, 1800000);
434 ret = regulator_enable(ldo_18);
435 //printk("%s set ldo1 vcc18_cif=%dmV end\n", __func__, regulator_get_voltage(ldo_18));
436 regulator_put(ldo_18);
440 while(regulator_is_enabled(ldo_18)>0)
441 regulator_disable(ldo_18);
442 regulator_put(ldo_18);
446 if (camera_power != INVALID_GPIO) {
447 if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
449 gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
450 dprintk("%s PowerPin=%d ..PinLevel = %x",res->dev_name, camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
453 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
454 dprintk("%s PowerPin=%d ..PinLevel = %x",res->dev_name, camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
457 ret = RK29_CAM_EIO_REQUESTFAIL;
458 eprintk("%s PowerPin=%d request failed!", res->dev_name,camera_power);
462 ret = RK29_CAM_EIO_INVALID;
468 static int sensor_reset_default_cb (struct rk29camera_gpio_res *res, int on)
470 int camera_reset = res->gpio_reset;
471 int camera_ioflag = res->gpio_flag;
472 int camera_io_init = res->gpio_init;
475 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
478 if (camera_reset != INVALID_GPIO) {
479 if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
481 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
482 dprintk("%s ResetPin=%d ..PinLevel = %x",res->dev_name,camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
484 gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
485 dprintk("%s ResetPin= %d..PinLevel = %x",res->dev_name, camera_reset, (((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
488 ret = RK29_CAM_EIO_REQUESTFAIL;
489 eprintk("%s ResetPin=%d request failed!", res->dev_name,camera_reset);
492 ret = RK29_CAM_EIO_INVALID;
498 static int sensor_powerdown_default_cb (struct rk29camera_gpio_res *res, int on)
500 int camera_powerdown = res->gpio_powerdown;
501 int camera_ioflag = res->gpio_flag;
502 int camera_io_init = res->gpio_init;
505 struct regulator *powerdown_pmu;
506 struct rkcamera_platform_data *dev = container_of(res,struct rkcamera_platform_data,io);
507 int powerdown_pmu_voltage = dev->powerdown_pmu_voltage;
508 const char *powerdown_pmu_name = dev->powerdown_pmu_name;
510 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
512 if(powerdown_pmu_name != NULL) {
513 powerdown_pmu = regulator_get(NULL, powerdown_pmu_name);
515 regulator_set_voltage(powerdown_pmu, powerdown_pmu_voltage, powerdown_pmu_voltage);
516 ret = regulator_enable(powerdown_pmu);
517 regulator_put(powerdown_pmu);
519 while(regulator_is_enabled(powerdown_pmu)>0)
520 regulator_disable(powerdown_pmu);
521 regulator_put(powerdown_pmu);
525 if (camera_powerdown != INVALID_GPIO) {
526 if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
528 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
529 dprintk("%s PowerDownPin=%d ..PinLevel = %x" ,res->dev_name,camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
531 gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
532 dprintk("%s PowerDownPin= %d..PinLevel = %x" ,res->dev_name, camera_powerdown, (((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
535 ret = RK29_CAM_EIO_REQUESTFAIL;
536 dprintk("%s PowerDownPin=%d request failed!", res->dev_name,camera_powerdown);
539 ret = RK29_CAM_EIO_INVALID;
545 static int sensor_flash_default_cb (struct rk29camera_gpio_res *res, int on)
547 int camera_flash = res->gpio_flash;
548 int camera_ioflag = res->gpio_flag;
549 int camera_io_init = res->gpio_init;
552 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
554 if (camera_flash != INVALID_GPIO) {
555 if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
560 gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
561 dprintk("%s FlashPin= %d..PinLevel = %x", res->dev_name, camera_flash, (((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
567 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
568 dprintk("%s FlashPin=%d ..PinLevel = %x", res->dev_name,camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
574 gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
575 dprintk("%s FlashPin=%d ..PinLevel = %x", res->dev_name,camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
581 eprintk("%s Flash command(%d) is invalidate", res->dev_name,on);
586 ret = RK29_CAM_EIO_REQUESTFAIL;
587 eprintk("%s FlashPin=%d request failed!", res->dev_name,camera_flash);
590 ret = RK29_CAM_EIO_INVALID;
595 static int sensor_afpower_default_cb (struct rk29camera_gpio_res *res, int on)
598 int camera_af = res->gpio_af;
600 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
603 if (camera_af != INVALID_GPIO) {
604 gpio_set_value(camera_af, on);
610 static int _rk_sensor_io_init_(struct rk29camera_gpio_res *gpio_res,struct device_node *of_node)
613 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
614 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
615 unsigned int camera_af = INVALID_GPIO,camera_ioflag;
616 struct rk29camera_gpio_res *io_res;
617 bool io_requested_in_camera;
618 enum of_gpio_flags flags;
620 struct rkcamera_platform_data *new_camera;
621 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
624 camera_reset = gpio_res->gpio_reset;
625 camera_power = gpio_res->gpio_power;
626 camera_powerdown = gpio_res->gpio_powerdown;
627 camera_flash = gpio_res->gpio_flash;
628 camera_af = gpio_res->gpio_af;
629 camera_ioflag = gpio_res->gpio_flag;
630 gpio_res->gpio_init = 0;
632 if (camera_power != INVALID_GPIO) {
633 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_power = %x\n", camera_power );
635 camera_power = of_get_named_gpio_flags(of_node,"rockchip,power",0,&flags);
636 gpio_res->gpio_power = camera_power;/* information back to the IO*/
638 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_power = %x\n", camera_power );
640 ret = gpio_request(camera_power, "camera power");
643 io_requested_in_camera = false;
645 if (io_requested_in_camera==false) {
647 new_camera = new_camera_head;
648 while (new_camera != NULL) {
649 io_res = &new_camera->io;
650 if (io_res->gpio_init & RK29_CAM_POWERACTIVE_MASK) {
651 if (io_res->gpio_power == camera_power)
652 io_requested_in_camera = true;
654 new_camera = new_camera->next_camera;
659 if (io_requested_in_camera==false) {
660 printk( "%s power pin(%d) init failed\n", gpio_res->dev_name,camera_power);
661 goto _rk_sensor_io_init_end_;
667 gpio_res->gpio_init |= RK29_CAM_POWERACTIVE_MASK;
668 gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
669 gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
671 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));
675 if (camera_reset != INVALID_GPIO) {
677 camera_power = of_get_named_gpio_flags(of_node,"rockchip,reset",0,&flags);
678 gpio_res->gpio_reset = camera_reset;/* information back to the IO*/
679 ret = gpio_request(camera_reset, "camera reset");
681 io_requested_in_camera = false;
683 if (io_requested_in_camera==false) {
685 new_camera = new_camera_head;
686 while (new_camera != NULL) {
687 io_res = &new_camera->io;
688 if (io_res->gpio_init & RK29_CAM_RESETACTIVE_MASK) {
689 if (io_res->gpio_reset == camera_reset)
690 io_requested_in_camera = true;
692 new_camera = new_camera->next_camera;
696 if (io_requested_in_camera==false) {
697 eprintk("%s reset pin(%d) init failed" ,gpio_res->dev_name,camera_reset);
698 goto _rk_sensor_io_init_end_;
704 gpio_res->gpio_init |= RK29_CAM_RESETACTIVE_MASK;
705 gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
706 gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
708 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));
712 if (camera_powerdown != INVALID_GPIO) {
713 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_powerdown = %x\n", camera_powerdown );
715 camera_powerdown = of_get_named_gpio_flags(of_node,"rockchip,powerdown",0,&flags);
716 gpio_res->gpio_powerdown = camera_powerdown;/*information back to the IO*/
718 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$/ camera_powerdown = %x\n", camera_powerdown );
719 ret = gpio_request(camera_powerdown, "camera powerdown");
721 io_requested_in_camera = false;
723 if (io_requested_in_camera==false) {
725 new_camera = new_camera_head;
726 while (new_camera != NULL) {
727 io_res = &new_camera->io;
728 if (io_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
729 if (io_res->gpio_powerdown == camera_powerdown)
730 io_requested_in_camera = true;
732 new_camera = new_camera->next_camera;
736 if (io_requested_in_camera==false) {
737 eprintk("%s powerdown pin(%d) init failed",gpio_res->dev_name,camera_powerdown);
738 goto _rk_sensor_io_init_end_;
743 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s(),iomux is ok\n", __FILE__, __LINE__,__FUNCTION__);
745 gpio_res->gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
746 gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
747 gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
749 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));
753 if (camera_flash != INVALID_GPIO) {
755 camera_flash = of_get_named_gpio_flags(of_node,"rockchip,flash",0,&flags);
756 gpio_res->gpio_flash = camera_flash;/* information back to the IO*/
757 ret = gpio_request(camera_flash, "camera flash");
759 io_requested_in_camera = false;
761 if (io_requested_in_camera==false) {
763 new_camera = new_camera_head;
764 while (new_camera != NULL) {
765 io_res = &new_camera->io;
766 if (io_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
767 if (io_res->gpio_powerdown == camera_powerdown)
768 io_requested_in_camera = true;
770 new_camera = new_camera->next_camera;
774 ret = 0; //ddl@rock-chips.com : flash is only a function, sensor is also run;
775 if (io_requested_in_camera==false) {
776 eprintk("%s flash pin(%d) init failed",gpio_res->dev_name,camera_flash);
777 goto _rk_sensor_io_init_end_;
783 gpio_res->gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
784 gpio_set_value(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS)); // falsh off
785 gpio_direction_output(camera_flash, ((~camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
787 dprintk("%s flash pin(%d) init success(0x%x)",gpio_res->dev_name, camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
791 if (camera_af != INVALID_GPIO) {
793 camera_af = of_get_named_gpio_flags(of_node,"rockchip,af",0,&flags);
794 gpio_res->gpio_af = camera_af;/* information back to the IO*/
795 ret = gpio_request(camera_af, "camera af");
797 io_requested_in_camera = false;
799 if (io_requested_in_camera==false) {
801 new_camera = new_camera_head;
802 while (new_camera != NULL) {
803 io_res = &new_camera->io;
804 if (io_res->gpio_init & RK29_CAM_AFACTIVE_MASK) {
805 if (io_res->gpio_af == camera_af)
806 io_requested_in_camera = true;
808 new_camera = new_camera->next_camera;
812 if (io_requested_in_camera==false) {
813 eprintk("%s af pin(%d) init failed",gpio_res->dev_name,camera_af);
814 goto _rk_sensor_io_init_end_;
821 gpio_res->gpio_init |= RK29_CAM_AFACTIVE_MASK;
822 //gpio_direction_output(camera_af, ((camera_ioflag&RK29_CAM_AFACTIVE_MASK)>>RK29_CAM_AFACTIVE_BITPOS));
823 dprintk("%s af pin(%d) init success",gpio_res->dev_name, camera_af);
828 _rk_sensor_io_init_end_:
833 static int _rk_sensor_io_deinit_(struct rk29camera_gpio_res *gpio_res)
835 unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
836 unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO,camera_af = INVALID_GPIO;
838 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
841 camera_reset = gpio_res->gpio_reset;
842 camera_power = gpio_res->gpio_power;
843 camera_powerdown = gpio_res->gpio_powerdown;
844 camera_flash = gpio_res->gpio_flash;
845 camera_af = gpio_res->gpio_af;
847 if (gpio_res->gpio_init & RK29_CAM_POWERACTIVE_MASK) {
848 if (camera_power != INVALID_GPIO) {
849 gpio_direction_input(camera_power);
850 gpio_free(camera_power);
854 if (gpio_res->gpio_init & RK29_CAM_RESETACTIVE_MASK) {
855 if (camera_reset != INVALID_GPIO) {
856 gpio_direction_input(camera_reset);
857 gpio_free(camera_reset);
861 if (gpio_res->gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
862 if (camera_powerdown != INVALID_GPIO) {
863 gpio_direction_input(camera_powerdown);
864 gpio_free(camera_powerdown);
868 if (gpio_res->gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
869 if (camera_flash != INVALID_GPIO) {
870 gpio_direction_input(camera_flash);
871 gpio_free(camera_flash);
874 if (gpio_res->gpio_init & RK29_CAM_AFACTIVE_MASK) {
875 if (camera_af != INVALID_GPIO) {
876 /* gpio_direction_input(camera_af);*/
877 gpio_free(camera_af);
880 gpio_res->gpio_init = 0;
885 static int rk_sensor_io_init(void)
887 static bool is_init = false;
889 struct rkcamera_platform_data *new_camera;
890 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
898 if (sensor_ioctl_cb.sensor_power_cb == NULL)
899 sensor_ioctl_cb.sensor_power_cb = sensor_power_default_cb;
900 if (sensor_ioctl_cb.sensor_reset_cb == NULL)
901 sensor_ioctl_cb.sensor_reset_cb = sensor_reset_default_cb;
902 if (sensor_ioctl_cb.sensor_powerdown_cb == NULL)
903 sensor_ioctl_cb.sensor_powerdown_cb = sensor_powerdown_default_cb;
904 if (sensor_ioctl_cb.sensor_flash_cb == NULL)
905 sensor_ioctl_cb.sensor_flash_cb = sensor_flash_default_cb;
906 if (sensor_ioctl_cb.sensor_af_cb == NULL)
907 sensor_ioctl_cb.sensor_af_cb = sensor_afpower_default_cb;
909 new_camera = new_camera_head;
910 while(new_camera != NULL)
912 if (_rk_sensor_io_init_(&new_camera->io,new_camera->of_node)<0)
913 _rk_sensor_io_deinit_(&new_camera->io);
914 new_camera = new_camera->next_camera;
919 static int rk_sensor_io_deinit(int sensor)
921 struct rkcamera_platform_data *new_camera;
923 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
925 new_camera = new_camera_head;
926 while(new_camera != NULL)
928 _rk_sensor_io_deinit_(&new_camera->io);
929 new_camera = new_camera->next_camera;
934 static int rk_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
936 struct rk29camera_gpio_res *res = NULL;
937 struct rkcamera_platform_data *new_cam_dev = NULL;
938 struct rk29camera_platform_data* plat_data = &rk_camera_platform_data;
939 int ret = RK29_CAM_IO_SUCCESS,i = 0;
940 struct soc_camera_desc *dev_icl = NULL;
941 struct rkcamera_platform_data *new_camera;
942 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
945 new_camera = new_camera_head;
946 while(new_camera != NULL)
948 if (strcmp(new_camera->dev_name, dev_name(dev)) == 0) {
949 res = (struct rk29camera_gpio_res *)&new_camera->io;
950 new_cam_dev = &new_camera[i];
951 dev_icl = &new_camera->dev.desc_info;
954 new_camera = new_camera->next_camera;;
959 eprintk("%s is not regisiterd in rk29_camera_platform_data!!",dev_name(dev));
960 ret = RK29_CAM_EIO_INVALID;
961 goto rk_sensor_ioctrl_end;
968 if (sensor_ioctl_cb.sensor_power_cb) {
969 ret = sensor_ioctl_cb.sensor_power_cb(res, on);
970 ret = (ret != RK29_CAM_EIO_INVALID)?ret:0; /* ddl@rock-chips.com: v0.1.1 */
972 eprintk("sensor_ioctl_cb.sensor_power_cb is NULL");
976 printk("ret: %d\n",ret);
981 if (sensor_ioctl_cb.sensor_reset_cb) {
982 ret = sensor_ioctl_cb.sensor_reset_cb(res, on);
984 ret = (ret != RK29_CAM_EIO_INVALID)?ret:0;
986 eprintk( "sensor_ioctl_cb.sensor_reset_cb is NULL");
994 if (sensor_ioctl_cb.sensor_powerdown_cb) {
995 ret = sensor_ioctl_cb.sensor_powerdown_cb(res, on);
997 eprintk( "sensor_ioctl_cb.sensor_powerdown_cb is NULL");
1005 if (sensor_ioctl_cb.sensor_flash_cb) {
1006 ret = sensor_ioctl_cb.sensor_flash_cb(res, on);
1008 eprintk( "sensor_ioctl_cb.sensor_flash_cb is NULL!");
1016 if (sensor_ioctl_cb.sensor_af_cb) {
1017 ret = sensor_ioctl_cb.sensor_af_cb(res, on);
1019 eprintk( "sensor_ioctl_cb.sensor_af_cb is NULL!");
1027 if (plat_data->sensor_mclk && dev_icl) {
1028 plat_data->sensor_mclk(dev_icl->host_desc.bus_id,(on!=0)?1:0,on);
1030 eprintk( "%s(%d): sensor_mclk(%p) or dev_icl(%p) is NULL",
1031 __FUNCTION__,__LINE__,plat_data->sensor_mclk,dev_icl);
1038 eprintk("%s cmd(0x%x) is unknown!",__FUNCTION__, cmd);
1042 rk_sensor_ioctrl_end:
1046 static int rk_sensor_pwrseq(struct device *dev,int powerup_sequence, int on, int mclk_rate)
1051 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
1054 for (i=0; i<8; i++) {
1057 powerup_type = SENSOR_PWRSEQ_GET(powerup_sequence,i);
1059 powerup_type = SENSOR_PWRSEQ_GET(powerup_sequence,(7-i));
1061 switch (powerup_type)
1063 case SENSOR_PWRSEQ_AVDD:
1064 case SENSOR_PWRSEQ_DOVDD:
1065 case SENSOR_PWRSEQ_DVDD:
1066 case SENSOR_PWRSEQ_PWR:
1068 ret = rk_sensor_ioctrl(dev,Cam_Power, on);
1070 eprintk("SENSOR_PWRSEQ_PWR failed");
1073 dprintk("SensorPwrSeq-power: %d",on);
1078 case SENSOR_PWRSEQ_HWRST:
1081 rk_sensor_ioctrl(dev,Cam_Reset, 1);
1083 ret = rk_sensor_ioctrl(dev,Cam_Reset, 1);
1085 ret |= rk_sensor_ioctrl(dev,Cam_Reset, 0);
1088 eprintk("SENSOR_PWRSEQ_HWRST failed");
1090 dprintk("SensorPwrSeq-reset: %d",on);
1095 case SENSOR_PWRSEQ_PWRDN:
1097 ret = rk_sensor_ioctrl(dev,Cam_PowerDown, !on);
1099 eprintk("SENSOR_PWRSEQ_PWRDN failed");
1101 dprintk("SensorPwrSeq-power down: %d",!on);
1106 case SENSOR_PWRSEQ_CLKIN:
1108 ret = rk_sensor_ioctrl(dev,Cam_Mclk, (on?mclk_rate:on));
1110 eprintk("SENSOR_PWRSEQ_CLKIN failed");
1112 dprintk("SensorPwrSeq-clock: %d",on);
1126 static int rk_sensor_power(struct device *dev, int on)
1128 int powerup_sequence,mclk_rate;
1130 struct rk29camera_platform_data* plat_data = &rk_camera_platform_data;
1131 struct rk29camera_gpio_res *dev_io = NULL;
1132 struct rkcamera_platform_data *new_camera=NULL, *new_device=NULL;
1133 bool real_pwroff = true;
1136 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
1138 new_camera = plat_data->register_dev_new;
1140 while (new_camera != NULL) {
1142 if (new_camera->io.gpio_powerdown != INVALID_GPIO) {
1143 gpio_direction_output(new_camera->io.gpio_powerdown,
1144 ((new_camera->io.gpio_flag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
1147 debug_printk( "new_camera->dev_name= %s \n", new_camera->dev_name);
1148 debug_printk( "dev_name(dev)= %s \n", dev_name(dev));
1150 if (strcmp(new_camera->dev_name,dev_name(dev))) {
1151 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);
1152 if (sensor_ioctl_cb.sensor_powerdown_cb && on)
1154 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);
1155 sensor_ioctl_cb.sensor_powerdown_cb(&new_camera->io,1);
1158 new_device = new_camera;
1159 dev_io = &new_camera->io;
1160 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);
1161 if (!Sensor_Support_DirectResume(new_camera->pwdn_info))
1164 real_pwroff = false;
1166 new_camera = new_camera->next_camera;
1169 if (new_device != NULL) {
1170 powerup_sequence = new_device->powerup_sequence;
1171 if ((new_device->mclk_rate == 24) || (new_device->mclk_rate == 48))
1172 mclk_rate = new_device->mclk_rate*1000000;
1174 mclk_rate = 24000000;
1176 powerup_sequence = sensor_PWRSEQ_DEFAULT;
1177 mclk_rate = 24000000;
1181 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i\n", __FILE__, __LINE__);
1182 rk_sensor_pwrseq(dev, powerup_sequence, on,mclk_rate);
1185 if (rk_sensor_pwrseq(dev, powerup_sequence, on,mclk_rate)<0) /* ddl@rock-chips.com: v0.1.5 */
1188 /*ddl@rock-chips.com: all power down switch to Hi-Z after power off*/
1189 new_camera = plat_data->register_dev_new;
1190 while (new_camera != NULL) {
1191 if (new_camera->io.gpio_powerdown != INVALID_GPIO) {
1192 gpio_direction_input(new_camera->io.gpio_powerdown);
1194 new_camera->pwdn_info |= 0x01;
1195 new_camera = new_camera->next_camera;
1199 rk_sensor_ioctrl(dev,Cam_PowerDown, !on);
1201 rk_sensor_ioctrl(dev,Cam_Mclk, 0);
1204 mdelay(10);/* ddl@rock-chips.com: v0.1.3 */
1209 static int rk_sensor_reset(struct device *dev)
1212 rk_sensor_ioctrl(dev,Cam_Reset,1);
1214 rk_sensor_ioctrl(dev,Cam_Reset,0);
1217 *ddl@rock-chips.com : the rest function invalidate, because this operate is put together in rk_sensor_power;
1223 static int rk_sensor_powerdown(struct device *dev, int on)
1226 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()/n", __FILE__, __LINE__,__FUNCTION__);
1228 return rk_sensor_ioctrl(dev,Cam_PowerDown,on);
1231 int rk_sensor_register(void)
1234 struct rkcamera_platform_data *new_camera;
1237 debug_printk( "/$$$$$$$$$$$$$$$$$$$$$$//n Here I am: %s:%i-------%s()\n", __FILE__, __LINE__,__FUNCTION__);
1239 new_camera = new_camera_head;
1241 while (new_camera != NULL) {
1242 if (new_camera->dev.i2c_cam_info.addr == INVALID_VALUE) {
1244 KERN_ERR "%s(%d): new_camera[%d] i2c addr is invalidate!",
1245 __FUNCTION__,__LINE__,i);
1248 sprintf(new_camera->dev_name,"%s_%d",new_camera->dev.device_info.dev.init_name,i+3);
1249 new_camera->dev.device_info.dev.init_name =(const char*)&new_camera->dev_name[0];
1250 new_camera->io.dev_name =(const char*)&new_camera->dev_name[0];
1251 if (new_camera->orientation == INVALID_VALUE) {
1252 if (strstr(new_camera->dev_name,"back")) {
1253 new_camera->orientation = 90;
1255 new_camera->orientation = 270;
1258 /* ddl@rock-chips.com: v0.1.3 */
1259 if ((new_camera->fov_h <= 0) || (new_camera->fov_h>360))
1260 new_camera->fov_h = 100;
1262 if ((new_camera->fov_v <= 0) || (new_camera->fov_v>360))
1263 new_camera->fov_v = 100;
1265 new_camera->dev.desc_info.subdev_desc.power = rk_sensor_power;
1266 new_camera->dev.desc_info.subdev_desc.powerdown = rk_sensor_powerdown;
1267 new_camera->dev.desc_info.host_desc.board_info =&new_camera->dev.i2c_cam_info;
1269 new_camera->dev.device_info.id = i+6;
1270 new_camera->dev.device_info.dev.platform_data = &new_camera->dev.desc_info;
1271 new_camera->dev.desc_info.subdev_desc.drv_priv = &rk_camera_platform_data;
1273 platform_device_register(&(new_camera->dev.device_info));
1275 new_camera = new_camera->next_camera;
1280 #include "../../../drivers/media/video/rk30_camera.c"