media: tegra: ov7695: apply 070213 tuning values
[linux-2.6.git] / drivers / media / video / tegra / ov7695.c
1 /*
2  * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/delay.h>
19 #include <linux/fs.h>
20 #include <linux/i2c.h>
21 #include <linux/miscdevice.h>
22 #include <linux/slab.h>
23 #include <linux/uaccess.h>
24 #include <linux/gpio.h>
25 #include <linux/debugfs.h>
26 #include <linux/seq_file.h>
27 #include <linux/atomic.h>
28 #include <linux/regulator/consumer.h>
29 #include <linux/export.h>
30 #include <linux/module.h>
31
32 #include <media/ov7695.h>
33
34 #define SIZEOF_I2C_TRANSBUF 128
35
36 #define OV7695_TABLE_START      0x01
37 #define OV7695_TABLE_END        0x02
38 #define OV7695_WAIT_MS          0xFFFF
39
40 struct ov7695_reg {
41         u16 addr;
42         u16 val;
43 };
44
45 static struct ov7695_reg mode_640x480_30fps[] = {
46         {OV7695_TABLE_START, 0x01},
47         {0x0100, 0x00},
48         {OV7695_WAIT_MS, 0x0a},
49         {0x0103, 0x01},
50         {0x3620, 0x2f},
51         {0x3623, 0x12},
52         {0x3718, 0x88},
53         {0x3703, 0x80},
54         {0x3712, 0x40},
55         {0x3706, 0x40},
56         {0x3631, 0x44},
57         {0x3632, 0x05},
58         {0x3013, 0xd0},
59         {0x3705, 0x1d},
60         {0x3713, 0x0e},
61         {0x3012, 0x0a},
62         {0x3717, 0x18},
63         {0x3621, 0x47},
64         {0x0309, 0x24},
65         {0x4803, 0x08},
66         {0x0101, 0x02},
67         {0x3002, 0x09},
68         {0x3024, 0x00},
69         {0x3630, 0x69},
70         {0x5090, 0x00},
71         {0x3820, 0x90},
72         {0x4500, 0x24},
73         {0x4008, 0x02},
74         {0x4009, 0x09},
75         {0x3811, 0x07},
76         {0x3813, 0x06},
77         /* YUV order 0x4300
78          * 3F : YUYV(default)
79          * 33 : YVYU
80          * 31 : VYUY
81          * 30 : UYVY
82          */
83         {0x4300, 0x30},
84         {0x5000, 0xff},
85         {0x5001, 0x3f},
86         {0x5002, 0x48},
87         {0x5910, 0x00},
88         {0x3a0f, 0x40},
89         {0x3a10, 0x38},
90         {0x3a1b, 0x42},
91         {0x3a1e, 0x36},
92         {0x3a11, 0x88},
93         {0x3a1f, 0x10},
94         {0x3a18, 0x00},
95         {0x3a19, 0xf8},
96         {0x3503, 0x00},
97         {0x3a00, 0x7c},
98         {0x382a, 0x08},
99         {0x3a02, 0x03},
100         {0x3a03, 0x24},
101         {0x3a14, 0x03},
102         {0x3a15, 0x20},
103         {0x3a0d, 0x06},
104         {0x3a0e, 0x05},
105         {0x3a17, 0x03},
106         {0x5100, 0x01},
107         {0x5101, 0xbf},
108         {0x5102, 0x00},
109         {0x5103, 0xaa},
110         {0x5104, 0x3f},
111         {0x5105, 0x05},
112         {0x5106, 0xff},
113         {0x5107, 0x0f},
114         {0x5108, 0x01},
115         {0x5109, 0xff},
116         {0x510a, 0x00},
117         {0x510b, 0x72},
118         {0x510c, 0x45},
119         {0x510d, 0x06},
120         {0x510e, 0xff},
121         {0x510f, 0x0f},
122         {0x5110, 0x01},
123         {0x5111, 0xfe},
124         {0x5112, 0x00},
125         {0x5113, 0x70},
126         {0x5114, 0x21},
127         {0x5115, 0x05},
128         {0x5116, 0xff},
129         {0x5117, 0x0f},
130         {0x5201, 0xd0},
131         {0x520a, 0xf4},
132         {0x520b, 0xf4},
133         {0x520c, 0xf4},
134         {0x5301, 0x05},
135         {0x5302, 0x0c},
136         {0x5303, 0x1c},
137         {0x5304, 0x2a},
138         {0x5305, 0x39},
139         {0x5306, 0x45},
140         {0x5307, 0x53},
141         {0x5308, 0x5d},
142         {0x5309, 0x68},
143         {0x530a, 0x7f},
144         {0x530b, 0x91},
145         {0x530c, 0xa5},
146         {0x530d, 0xc6},
147         {0x530e, 0xde},
148         {0x530f, 0xef},
149         {0x5310, 0x16},
150         {0x5003, 0x80},
151         {0x5500, 0x08},
152         {0x5501, 0x48},
153         {0x5502, 0x18},
154         {0x5503, 0x04},
155         {0x5504, 0x08},
156         {0x5505, 0x48},
157         {0x5506, 0x03},
158         {0x5507, 0x18},
159         {0x5508, 0x2d},
160         {0x5509, 0x08},
161         {0x550a, 0x48},
162         {0x550b, 0x06},
163         {0x550c, 0x04},
164         {0x550d, 0x01},
165         {0x5600, 0x00},
166         {0x5601, 0x31},
167         {0x5602, 0x3A},
168         {0x5603, 0x16},
169         {0x5604, 0x0A},
170         {0x5605, 0x61},
171         {0x5606, 0x6B},
172         {0x5607, 0x65},
173         {0x5608, 0x4F},
174         {0x5609, 0x16},
175         {0x560a, 0x01},
176         {0x560b, 0x98},
177         {0x5800, 0x02},
178         {0x5803, 0x40},
179         {0x5804, 0x34},
180         {0x5200, 0x20},         /* Manual White Balance */
181         {0x5204, 0x05},         /* R-gain */
182         {0x5208, 0x07},         /* B-gain */
183         {0x0100, 0x01},
184         {OV7695_WAIT_MS, 0x64}, /* delay 3 frame (100msec) */
185         {0x5200, 0x00},         /* Auto White Balance */
186         {OV7695_TABLE_END, 0x01},
187 };
188
189 struct ov7695_info {
190         struct miscdevice               miscdev_info;
191         struct ov7695_power_rail        power;
192         struct ov7695_sensordata        sensor_data;
193         struct i2c_client               *i2c_client;
194         struct ov7695_platform_data     *pdata;
195         atomic_t                        in_use;
196         const struct ov7695_reg         *mode;
197 #ifdef CONFIG_DEBUG_FS
198         struct dentry                   *debugfs_root;
199         u32                             debug_i2c_offset;
200 #endif
201         u8                              i2c_trans_buf[SIZEOF_I2C_TRANSBUF];
202 };
203
204 struct ov7695_mode_desc {
205         u16                     xres;
206         u16                     yres;
207         const struct ov7695_reg *mode_tbl;
208         struct ov7695_modeinfo  mode_info;
209 };
210
211 static struct ov7695_mode_desc mode_table[] = {
212         {
213                 .xres = 640,
214                 .yres = 480,
215                 .mode_tbl = mode_640x480_30fps,
216         },
217         { },
218 };
219
220 static long ov7695_ioctl(struct file *file,
221                         unsigned int cmd, unsigned long arg);
222
223 static inline void ov7695_msleep(u32 t)
224 {
225         usleep_range(t*1000, t*1000 + 500);
226 }
227
228 static int ov7695_read_reg(struct i2c_client *client, u16 addr, u8 *val)
229 {
230         int err;
231         struct i2c_msg msg[2];
232         unsigned char data[3];
233
234         if (!client->adapter)
235                 return -ENODEV;
236
237         msg[0].addr = client->addr;
238         msg[0].flags = 0;
239         msg[0].len = 2;
240         msg[0].buf = data;
241
242         data[0] = (u8) (addr >> 8);
243         data[1] = (u8) (addr & 0xff);
244
245         msg[1].addr = client->addr;
246         msg[1].flags = I2C_M_RD;
247         msg[1].len = 1;
248         msg[1].buf = data + 2;
249
250         err = i2c_transfer(client->adapter, msg, 2);
251
252         if (err != 2)
253                 return -EINVAL;
254
255         *val = data[2];
256
257         return 0;
258 }
259
260 static int ov7695_write_bulk_reg(struct i2c_client *client, u8 *data, int len)
261 {
262         int err;
263         struct i2c_msg msg;
264
265         if (!client->adapter)
266                 return -ENODEV;
267
268         msg.addr = client->addr;
269         msg.flags = 0;
270         msg.len = len;
271         msg.buf = data;
272
273         dev_dbg(&client->dev,
274                 "%s {0x%04x,", __func__, (int)data[0] << 8 | data[1]);
275         for (err = 2; err < len; err++)
276                 dev_dbg(&client->dev, " 0x%02x", data[err]);
277         dev_dbg(&client->dev, "},\n");
278
279         err = i2c_transfer(client->adapter, &msg, 1);
280         if (err == 1)
281                 return 0;
282
283         dev_err(&client->dev, "ov7695: i2c bulk transfer failed at %x\n",
284                 (int)data[0] << 8 | data[1]);
285
286         return err;
287 }
288
289 static int ov7695_write_reg8(struct i2c_client *client, u16 addr, u8 val)
290 {
291         unsigned char data[3];
292
293         if (!client->adapter)
294                 return -ENODEV;
295
296         data[0] = (u8) (addr >> 8);
297         data[1] = (u8) (addr & 0xff);
298         data[2] = (u8) (val & 0xff);
299
300         dev_dbg(&client->dev, "0x%x = 0x%x\n", addr, val);
301         return ov7695_write_bulk_reg(client, data, sizeof(data));
302 }
303
304 static int ov7695_write_reg16(struct i2c_client *client, u16 addr, u16 val)
305 {
306         unsigned char data[4];
307
308         if (!client->adapter)
309                 return -ENODEV;
310
311         data[0] = (u8) (addr >> 8);
312         data[1] = (u8) (addr & 0xff);
313         data[2] = (u8) (val >> 8);
314         data[3] = (u8) (val & 0xff);
315
316         dev_dbg(&client->dev, "0x%x = 0x%x\n", addr, val);
317         return ov7695_write_bulk_reg(client, data, sizeof(data));
318 }
319
320 static int ov7695_write_table(
321         struct ov7695_info *info,
322         const struct ov7695_reg table[])
323 {
324         int err;
325         const struct ov7695_reg *next;
326         u16 val;
327
328         for (next = table; next->addr != OV7695_TABLE_END; next++) {
329                 if (next->addr == OV7695_WAIT_MS) {
330                         msleep(next->val);
331                         continue;
332                 }
333
334                 val = next->val;
335
336                 err = ov7695_write_reg8(info->i2c_client, next->addr, val);
337                 if (err)
338                         return err;
339         }
340         return 0;
341 }
342
343 static int ov7695_open(struct inode *inode, struct file *file)
344 {
345         struct miscdevice       *miscdev = file->private_data;
346         struct ov7695_info *info = dev_get_drvdata(miscdev->parent);
347
348         dev_dbg(&info->i2c_client->dev, "ov7695: open.\n");
349         info = container_of(miscdev, struct ov7695_info, miscdev_info);
350         /* check if the device is in use */
351         if (atomic_xchg(&info->in_use, 1)) {
352                 dev_err(&info->i2c_client->dev, "%s:BUSY!\n", __func__);
353                 return -EBUSY;
354         }
355
356         file->private_data = info;
357
358         if (info->pdata && info->pdata->power_on)
359                 info->pdata->power_on(&info->power);
360         else {
361                 dev_err(&info->i2c_client->dev,
362                         "%s:no valid power_on function.\n", __func__);
363                 return -EFAULT;
364         }
365         return 0;
366 }
367
368 int ov7695_release(struct inode *inode, struct file *file)
369 {
370         struct ov7695_info *info = file->private_data;
371
372         if (info->pdata && info->pdata->power_off)
373                 info->pdata->power_off(&info->power);
374         file->private_data = NULL;
375
376         /* warn if device is already released */
377         WARN_ON(!atomic_xchg(&info->in_use, 0));
378         return 0;
379 }
380
381 static int ov7695_regulator_get(struct ov7695_info *info,
382         struct regulator **vreg, char vreg_name[])
383 {
384         struct regulator *reg = NULL;
385         int err = 0;
386
387         reg = devm_regulator_get(&info->i2c_client->dev, vreg_name);
388         if (unlikely(IS_ERR(reg))) {
389                 dev_err(&info->i2c_client->dev, "%s %s ERR: %d\n",
390                         __func__, vreg_name, (int)reg);
391                 err = PTR_ERR(reg);
392                 reg = NULL;
393         } else {
394                 dev_dbg(&info->i2c_client->dev, "%s: %s\n",
395                         __func__, vreg_name);
396         }
397
398         *vreg = reg;
399         return err;
400 }
401
402 static int ov7695_power_get(struct ov7695_info *info)
403 {
404         struct ov7695_power_rail *pw = &info->power;
405         int err;
406
407         /* note: ov7695 uses i2c address 0x42,
408          *
409          * This needs us to define a new vif2 as 2-0021
410          * for platform board file that uses ov7695
411          * otherwise below could not get the regulator
412          *
413          * This rails of "vif2" and "vana" can be modified as needed
414          * for a new platform.
415          *
416          * ov7695: need to get 1.8v first
417          */
418         /* interface 1.8v */
419         err = ov7695_regulator_get(info, &pw->iovdd, "vif2");
420         if (unlikely(IS_ERR(ERR_PTR(err))))
421                 return err;
422
423         /* ananlog 2.7v */
424         err = ov7695_regulator_get(info, &pw->avdd, "vana");
425         if (unlikely(IS_ERR(ERR_PTR(err))))
426                 return err;
427
428         return 0;
429 }
430
431 static const struct file_operations ov7695_fileops = {
432         .owner = THIS_MODULE,
433         .open = ov7695_open,
434         .unlocked_ioctl = ov7695_ioctl,
435         .release = ov7695_release,
436 };
437
438 static struct miscdevice ov7695_device = {
439         .minor = MISC_DYNAMIC_MINOR,
440         .name = "ov7695",
441         .fops = &ov7695_fileops,
442 };
443
444 #ifdef CONFIG_DEBUG_FS
445 static int ov7695_stats_show(struct seq_file *s, void *data)
446 {
447         static struct ov7695_info *info;
448
449         seq_printf(s, "%-20s : %-20s\n", "Name", "ov7695-debugfs-testing");
450         seq_printf(s, "%-20s : 0x%X\n", "Current i2c-offset Addr",
451                         info->debug_i2c_offset);
452         return 0;
453 }
454
455 static int ov7695_stats_open(struct inode *inode, struct file *file)
456 {
457         return single_open(file, ov7695_stats_show, inode->i_private);
458 }
459
460 static const struct file_operations ov7695_stats_fops = {
461         .open       = ov7695_stats_open,
462         .read       = seq_read,
463         .llseek     = seq_lseek,
464         .release    = single_release,
465 };
466
467 static int debug_i2c_offset_w(void *data, u64 val)
468 {
469         struct ov7695_info *info = (struct ov7695_info *)(data);
470         dev_info(&info->i2c_client->dev,
471                         "ov7695:%s setting i2c offset to 0x%X\n",
472                         __func__, (u32)val);
473         info->debug_i2c_offset = (u32)val;
474         dev_info(&info->i2c_client->dev,
475                         "ov7695:%s new i2c offset is 0x%X\n", __func__,
476                         info->debug_i2c_offset);
477         return 0;
478 }
479
480 static int debug_i2c_offset_r(void *data, u64 *val)
481 {
482         struct ov7695_info *info = (struct ov7695_info *)(data);
483         *val = (u64)info->debug_i2c_offset;
484         dev_info(&info->i2c_client->dev,
485                         "ov7695:%s reading i2c offset is 0x%X\n", __func__,
486                         info->debug_i2c_offset);
487         return 0;
488 }
489
490 static int debug_i2c_read(void *data, u64 *val)
491 {
492         struct ov7695_info *info = (struct ov7695_info *)(data);
493         u8 temp1 = 0;
494         u8 temp2 = 0;
495         dev_info(&info->i2c_client->dev,
496                         "ov7695:%s reading offset 0x%X\n", __func__,
497                         info->debug_i2c_offset);
498         if (ov7695_read_reg(info->i2c_client,
499                                 info->debug_i2c_offset, &temp1)
500                 || ov7695_read_reg(info->i2c_client,
501                         info->debug_i2c_offset+1, &temp2)) {
502                 dev_err(&info->i2c_client->dev,
503                                 "ov7695:%s failed\n", __func__);
504                 return -EIO;
505         }
506         dev_info(&info->i2c_client->dev,
507                         "ov7695:%s read value is 0x%X\n", __func__,
508                         temp1<<8 | temp2);
509         *val = (u64)(temp1<<8 | temp2);
510         return 0;
511 }
512
513 static int debug_i2c_write(void *data, u64 val)
514 {
515         struct ov7695_info *info = (struct ov7695_info *)(data);
516         dev_info(&info->i2c_client->dev,
517                         "ov7695:%s writing 0x%X to offset 0x%X\n", __func__,
518                         (u16)val, info->debug_i2c_offset);
519         if (ov7695_write_reg16(info->i2c_client,
520                                 info->debug_i2c_offset, (u16)val)) {
521                 dev_err(&info->i2c_client->dev,
522                         "ov7695:%s failed\n", __func__);
523                 return -EIO;
524         }
525         return 0;
526 }
527
528 DEFINE_SIMPLE_ATTRIBUTE(i2c_offset_fops, debug_i2c_offset_r,
529                 debug_i2c_offset_w, "0x%llx\n");
530 DEFINE_SIMPLE_ATTRIBUTE(i2c_read_fops, debug_i2c_read,
531                 /*debug_i2c_dummy_w*/ NULL, "0x%llx\n");
532 DEFINE_SIMPLE_ATTRIBUTE(i2c_write_fops, /*debug_i2c_dummy_r*/NULL,
533                 debug_i2c_write, "0x%llx\n");
534
535 static int ov7695_debug_init(struct ov7695_info *info)
536 {
537         dev_dbg(&info->i2c_client->dev, "%s", __func__);
538
539         info->debugfs_root = debugfs_create_dir(ov7695_device.name, NULL);
540
541         if (!info->debugfs_root)
542                 goto err_out;
543
544         if (!debugfs_create_file("stats", S_IRUGO,
545                         info->debugfs_root, info, &ov7695_stats_fops))
546                 goto err_out;
547
548         if (!debugfs_create_file("i2c_offset", S_IRUGO | S_IWUSR,
549                         info->debugfs_root, info, &i2c_offset_fops))
550                 goto err_out;
551
552         if (!debugfs_create_file("i2c_read", S_IRUGO,
553                         info->debugfs_root, info, &i2c_read_fops))
554                 goto err_out;
555
556         if (!debugfs_create_file("i2c_write", S_IWUSR,
557                         info->debugfs_root, info, &i2c_write_fops))
558                 goto err_out;
559
560         return 0;
561
562 err_out:
563         dev_err(&info->i2c_client->dev, "ERROR:%s failed", __func__);
564         if (info->debugfs_root)
565                 debugfs_remove_recursive(info->debugfs_root);
566         return -ENOMEM;
567 }
568 #endif  /* CONFIG_DEBUG_FS */
569
570 static struct ov7695_modeinfo def_modeinfo = {
571         .xres = 640,
572         .yres = 480,
573 };
574
575 static struct ov7695_mode_desc *ov7695_get_mode(
576         struct ov7695_info *info, struct ov7695_mode *mode)
577 {
578         struct ov7695_mode_desc *mt = mode_table;
579
580         while (mt->xres) {
581                 if ((mt->xres == mode->xres) &&
582                         (mt->yres == mode->yres))
583                                 break;
584                 mt++;
585         }
586
587         if (!mt->xres)
588                 mt = NULL;
589         return mt;
590 }
591
592 static int ov7695_mode_info_init(struct ov7695_info *info)
593 {
594         struct ov7695_mode_desc *md = mode_table;
595         const struct ov7695_reg *mt;
596         struct ov7695_modeinfo *mi;
597
598         dev_dbg(&info->i2c_client->dev, "%s", __func__);
599         while (md->xres) {
600                 mi = &md->mode_info;
601                 mt = md->mode_tbl;
602                 memcpy(mi, &def_modeinfo, sizeof(*mi));
603                 dev_dbg(&info->i2c_client->dev, "mode %d x %d ",
604                         md->xres, md->yres);
605                 mi->xres = md->xres;
606                 mi->yres = md->yres;
607                 md++;
608         }
609         return 0;
610 }
611
612 static int ov7695_set_mode(struct ov7695_info *info,
613         struct ov7695_mode *mode)
614 {
615         struct ov7695_mode_desc *sensor_mode;
616         int err;
617
618         dev_info(&info->i2c_client->dev,
619                 "%s: xres %u yres %u\n", __func__, mode->xres, mode->yres);
620
621         sensor_mode = ov7695_get_mode(info, mode);
622         if (sensor_mode == NULL) {
623                 dev_err(&info->i2c_client->dev,
624                         "%s: invalid params supplied to set mode %d %d\n",
625                                 __func__, mode->xres, mode->yres);
626                 return -EINVAL;
627         }
628
629         err = ov7695_write_table(
630                 info, sensor_mode->mode_tbl);
631         if (err)
632                 return err;
633
634         info->mode = sensor_mode->mode_tbl;
635
636         return 0;
637 }
638
639 static long ov7695_ioctl(struct file *file,
640                          unsigned int cmd, unsigned long arg)
641 {
642         int err = 0;
643         struct ov7695_info *info = file->private_data;
644
645         switch (cmd) {
646         case OV7695_SENSOR_IOCTL_SET_MODE:
647         {
648                 struct ov7695_mode mode;
649
650                 dev_dbg(&info->i2c_client->dev, "OV7695_IOCTL_SET_MODE\n");
651                 if (copy_from_user(&mode, (const void __user *)arg,
652                         sizeof(struct ov7695_mode))) {
653                         err = -EFAULT;
654                         break;
655                 }
656                 err = ov7695_set_mode(info, &mode);
657                 break;
658         }
659
660         default:
661                 dev_dbg(&info->i2c_client->dev, "INVALID IOCTL\n");
662                 err = -EINVAL;
663         }
664
665         if (err)
666                 dev_err(&info->i2c_client->dev,
667                         "%s - %x: ERR = %d\n", __func__, cmd, err);
668         return err;
669 }
670
671 static int ov7695_probe(struct i2c_client *client,
672                         const struct i2c_device_id *id)
673 {
674         int err;
675         struct ov7695_info *info;
676         dev_dbg(&client->dev, "ov7695: probing sensor.\n");
677
678         info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
679         if (info == NULL) {
680                 dev_err(&client->dev, "%s: kzalloc error\n", __func__);
681                 return -ENOMEM;
682         }
683
684         info->pdata = client->dev.platform_data;
685         info->i2c_client = client;
686         atomic_set(&info->in_use, 0);
687         info->mode = NULL;
688
689         i2c_set_clientdata(client, info);
690
691         err = ov7695_power_get(info);
692         if (err) {
693                 dev_err(&info->i2c_client->dev,
694                         "ov7695: Unable to get regulators\n");
695                 return err;
696         }
697         ov7695_mode_info_init(info);
698
699         memcpy(&info->miscdev_info,
700                 &ov7695_device,
701                 sizeof(struct miscdevice));
702
703         err = misc_register(&info->miscdev_info);
704         if (err) {
705                 dev_err(&info->i2c_client->dev,
706                         "ov7695: Unable to register misc device!\n");
707                 return err;
708         }
709 #ifdef CONFIG_DEBUG_FS
710         ov7695_debug_init(info);
711 #endif
712
713         return 0;
714 }
715
716 static int ov7695_remove(struct i2c_client *client)
717 {
718         struct ov7695_info *info;
719         info = i2c_get_clientdata(client);
720         misc_deregister(&ov7695_device);
721         kfree(info);
722
723 #ifdef CONFIG_DEBUG_FS
724         if (info->debugfs_root)
725                 debugfs_remove_recursive(info->debugfs_root);
726 #endif
727
728         return 0;
729 }
730
731 static const struct i2c_device_id ov7695_id[] = {
732         { "ov7695", 0 },
733         { },
734 };
735
736 MODULE_DEVICE_TABLE(i2c, ov7695_id);
737
738 static struct i2c_driver ov7695_i2c_driver = {
739         .driver = {
740                 .name = "ov7695",
741                 .owner = THIS_MODULE,
742         },
743         .probe = ov7695_probe,
744         .remove = ov7695_remove,
745         .id_table = ov7695_id,
746 };
747
748 static int __init ov7695_init(void)
749 {
750         pr_info("ov7695 sensor driver loading\n");
751         return i2c_add_driver(&ov7695_i2c_driver);
752 }
753
754 static void __exit ov7695_exit(void)
755 {
756         i2c_del_driver(&ov7695_i2c_driver);
757 }
758
759 module_init(ov7695_init);
760 module_exit(ov7695_exit);
761 MODULE_LICENSE("GPL v2");