Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(923)

Side by Side Diff: arch/arm/mach-tegra/board-aebl-sensors.c

Issue 6627032: CHROMIUM: Board file changes for Tegra camera (Closed)
Patch Set: Work in progress on aebl sensor. Fixed C99 comments, and file comment headers. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 NVIDIA Corporation.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15 #include <linux/delay.h>
16 #include <linux/i2c.h>
17 #include <linux/clk.h>
18 #include <linux/regulator/consumer.h>
19 #include <linux/platform_device.h>
20 #include <linux/dma-mapping.h>
21
22 #include <media/soc_camera.h>
23 #include <media/tegra_v4l2_camera.h>
24
25 #include <mach/gpio.h>
26 #include <mach/iomap.h>
27 #include <mach/nvhost.h>
28
29 #include "gpio-names.h"
30 #include "devices.h"
31
32 /* I2C adapter ID for the camera board. */
33 #define TEGRA_CAMERA_I2C_ADAPTER_ID 3
34
35 /* GPIOs relevant to camera module. */
36 #define TEGRA_CAMERA_GPIO_CAM_PWR_EN TEGRA_GPIO_PV4
37 #define TEGRA_CAMERA_GPIO_CAM_RST TEGRA_GPIO_PU2
38 #define TEGRA_CAMERA_GPIO_CAM_PWDN TEGRA_GPIO_PU3
39
40 static struct regulator *regulator;
41 static struct clk *clk_vi;
42 static struct clk *clk_vi_sensor;
43 static struct clk *clk_csi;
44 static struct clk *clk_isp;
45 static struct clk *clk_csus;
46
47 static int tegra_camera_enable(struct nvhost_device *ndev)
48 {
49 int err;
50
51 /* Turn on relevant clocks. */
52 clk_enable(clk_vi);
53 clk_enable(clk_vi_sensor);
54 clk_enable(clk_csi);
55 clk_enable(clk_isp);
56 clk_enable(clk_csus);
57
58 /* Turn on power to the camera board. */
59 regulator = regulator_get(&ndev->dev, "vddio_vi");
60 if (IS_ERR(regulator)) {
61 dev_info(&ndev->dev, "regulator_get() returned error %ld\n",
62 PTR_ERR(regulator));
63 err = PTR_ERR(regulator);
64 goto exit;
65 }
66
67 err = regulator_enable(regulator);
68 if (err != 0)
69 goto exit_regulator_put;
70
71 /* Set up GPIOs. */
72 gpio_set_value(TEGRA_CAMERA_GPIO_CAM_PWR_EN, 1);
73 gpio_set_value(TEGRA_CAMERA_GPIO_CAM_RST, 1);
74 gpio_set_value(TEGRA_CAMERA_GPIO_CAM_PWDN, 0);
75
76 /* Give the sensor time to come out of reset. The OV9740 needs
77 8192 clock cycles (from vi_sensor clock) before the first I2C
78 transaction. */
79 udelay(1000);
80
81 return 0;
82
83 /*exit_regulator_disable:*/
84 /* regulator_disable(regulator);*/
Olof Johansson 2011/03/28 22:41:44 Shouldn't this just be removed?
85 exit_regulator_put:
86 regulator_put(regulator);
87 exit:
88 return err;
89 }
90
91 static void tegra_camera_disable(struct nvhost_device *ndev)
92 {
93 gpio_set_value(TEGRA_CAMERA_GPIO_CAM_PWDN, 1);
94 gpio_set_value(TEGRA_CAMERA_GPIO_CAM_RST, 0);
95 gpio_set_value(TEGRA_CAMERA_GPIO_CAM_PWR_EN, 0);
96
97 BUG_ON(!regulator);
98 regulator_disable(regulator);
99 regulator_put(regulator);
100 regulator = NULL;
101
102 /* Turn off relevant clocks. */
103 clk_disable(clk_vi);
104 clk_disable(clk_vi_sensor);
105 clk_disable(clk_csi);
106 clk_disable(clk_isp);
107 clk_disable(clk_csus);
108 }
109
110 static struct i2c_board_info aebl_i2c_bus3_sensor_info = {
111 I2C_BOARD_INFO("mt9m114", 0x48),
112 };
113
114 static struct soc_camera_link mt9m114_iclink = {
115 .bus_id = 0,
116 .i2c_adapter_id = TEGRA_CAMERA_I2C_ADAPTER_ID,
117 .board_info = &aebl_i2c_bus3_sensor_info,
118 .module_name = "mt9m114",
119 };
120
121 static struct platform_device soc_camera = {
122 .name = "soc-camera-pdrv",
123 .id = 0,
124 .dev = {
125 .platform_data = &mt9m114_iclink,
126 },
127 };
128
129 static struct tegra_camera_platform_data tegra_camera_platform_data = {
130 .enable_camera = tegra_camera_enable,
131 .disable_camera = tegra_camera_disable,
132 .flip_v = 0,
133 .flip_h = 0,
134 };
135
136 int __init aebl_sensors_init(void)
137 {
138 int err;
139
140 tegra_camera_device.dev.platform_data = &tegra_camera_platform_data;
141
142 tegra_gpio_enable(TEGRA_CAMERA_GPIO_CAM_PWR_EN);
143 err = gpio_request(TEGRA_CAMERA_GPIO_CAM_PWR_EN, "cam_pwr_en");
144 if (err != 0)
145 goto exit;
146 err = gpio_direction_output(TEGRA_CAMERA_GPIO_CAM_PWR_EN, 0);
147 if (err != 0)
148 goto exit_free_gpio_cam_pwr_en;
149
150 tegra_gpio_enable(TEGRA_CAMERA_GPIO_CAM_RST);
151 err = gpio_request(TEGRA_CAMERA_GPIO_CAM_RST, "cam_rst");
152 if (err != 0)
153 goto exit_free_gpio_cam_pwr_en;
154 err = gpio_direction_output(TEGRA_CAMERA_GPIO_CAM_RST, 0);
155 if (err != 0)
156 goto exit_free_gpio_cam_rst;
157
158 tegra_gpio_enable(TEGRA_CAMERA_GPIO_CAM_PWDN);
159 err = gpio_request(TEGRA_CAMERA_GPIO_CAM_PWDN, "cam_pwdn");
160 if (err != 0)
161 goto exit_free_gpio_cam_rst;
162 err = gpio_direction_output(TEGRA_CAMERA_GPIO_CAM_PWDN, 0);
163 if (err != 0)
164 goto exit_free_gpio_cam_pwdn;
165
166 clk_vi = clk_get_sys("tegra_camera", "vi");
167 clk_vi_sensor = clk_get_sys("tegra_camera", "vi_sensor");
168 clk_csi = clk_get_sys("tegra_camera", "csi");
169 clk_isp = clk_get_sys("tegra_camera", "isp");
170 clk_csus = clk_get_sys("tegra_camera", "csus");
171
172 clk_set_rate(clk_vi_sensor, 24000000);
173
174 nvhost_device_register(&tegra_camera_device);
175
176 platform_device_register(&soc_camera);
177
178 return 0;
179
180 exit_free_gpio_cam_pwdn:
181 gpio_free(TEGRA_CAMERA_GPIO_CAM_PWDN);
182 exit_free_gpio_cam_rst:
183 gpio_free(TEGRA_CAMERA_GPIO_CAM_RST);
184 exit_free_gpio_cam_pwr_en:
185 gpio_free(TEGRA_CAMERA_GPIO_CAM_PWR_EN);
186 exit:
187 BUG_ON(1);
188 return err;
189 }
190
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698