]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/media/video/omap/h4_sensor_power.c
Move i2c_driver out of ov9640_sensor structure and
[linux-2.6-omap-h63xx.git] / drivers / media / video / omap / h4_sensor_power.c
1 /*
2  * drivers/media/video/omap/h4_sensor_power.c
3  *
4  * H4 sensor powerup/down functions.
5  *
6  * Author: Andy Lowe (source@mvista.com)
7  *
8  * Copyright (C) 2004 MontaVista Software, Inc.
9  * Copyright (C) 2004 Texas Instruments.
10  *
11  * This file is licensed under the terms of the GNU General Public License
12  * version 2. This program is licensed "as is" without any warranty of any
13  * kind, whether express or implied.
14  */
15
16 #include <linux/module.h>
17 #include <linux/types.h>
18
19 #include <asm/arch/gpioexpander.h>
20
21 int h4_sensor_powerup(void);
22 int h4_sensor_powerdown(void);
23
24 int
25 h4_sensor_powerup(void)
26 {
27         unsigned char expa;
28         int err;
29
30         /* read current state of GPIO EXPA outputs */
31         if ((err = read_gpio_expa(&expa, 0x20))) {
32                 printk(KERN_ERR "Error reading GPIO EXPA\n");
33                 return err;
34         }
35         /* Set GPIO EXPA P3 (CAMERA_MODULE_EN) to power-up sensor */
36         if ((err = write_gpio_expa(expa | 0x08, 0x20))) {
37                 printk(KERN_ERR "Error writing to GPIO EXPA\n");
38                 return err;
39         }
40
41         /* read current state of GPIO EXPA outputs */
42         if ((err = read_gpio_expa(&expa, 0x22))) {
43                 printk(KERN_ERR "Error reading GPIO EXPA\n");
44                 return err;
45         }
46         /* Clear GPIO EXPA P7 (CAM_RST) */
47         if ((err = write_gpio_expa(expa & ~0x80, 0x22))) {
48                 printk(KERN_ERR "Error writing to GPIO EXPA\n");
49                 return err;
50         }
51
52         return 0;
53 }
54
55 int
56 h4_sensor_powerdown(void)
57 {
58         unsigned char expa;
59         int err;
60
61         /* read current state of GPIO EXPA outputs */
62         if ((err = read_gpio_expa(&expa, 0x20))) {
63                 printk(KERN_ERR "Error reading GPIO EXPA\n");
64                 return err;
65         }
66         /* Clear GPIO EXPA P3 (CAMERA_MODULE_EN) to power-down sensor */
67         if ((err = write_gpio_expa(expa & ~0x08, 0x20))) {
68                 printk(KERN_ERR "Error writing to GPIO EXPA\n");
69                 return err;
70         }
71
72         return 0;
73 }
74
75 EXPORT_SYMBOL(h4_sensor_powerup);
76 EXPORT_SYMBOL(h4_sensor_powerdown);