blob: 0b92cc5c05d400717bcb9926aaa11d049aac35bb [file] [log] [blame]
Laxman Dewangan353d5432010-12-22 15:32:30 +05301/*
2 * arch/arm/mach-tegra/board-cardhu-sensors.c
3 *
Maria Gutowski5e3afb12011-05-26 18:44:51 -07004 * Copyright (c) 2010-2011, NVIDIA CORPORATION, All rights reserved.
Laxman Dewangan353d5432010-12-22 15:32:30 +05305 *
Maria Gutowski5e3afb12011-05-26 18:44:51 -07006 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
Laxman Dewangan353d5432010-12-22 15:32:30 +05309 *
Maria Gutowski5e3afb12011-05-26 18:44:51 -070010 * Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
Laxman Dewangan353d5432010-12-22 15:32:30 +053012 *
Maria Gutowski5e3afb12011-05-26 18:44:51 -070013 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
Laxman Dewangan353d5432010-12-22 15:32:30 +053016 *
Maria Gutowski5e3afb12011-05-26 18:44:51 -070017 * Neither the name of NVIDIA CORPORATION nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Laxman Dewangan353d5432010-12-22 15:32:30 +053032 */
33
34#include <linux/i2c.h>
Prayas Mohanty309cf662011-02-11 00:05:42 +053035#include <linux/delay.h>
36#include <linux/regulator/consumer.h>
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +053037#include <linux/i2c/pca954x.h>
Laxman Dewangan39b4ede2011-02-05 17:02:09 +053038#include <linux/i2c/pca953x.h>
Bitan Biswas5730ac42011-02-09 18:01:59 +053039#include <linux/nct1008.h>
Prayas Mohanty309cf662011-02-11 00:05:42 +053040#include <mach/fb.h>
41#include <mach/gpio.h>
42#include <media/ov5650.h>
kdivvela1e757fd2011-09-30 18:34:14 +053043#include <media/ov14810.h>
Prayas Mohantye3171a62011-02-25 04:30:01 +053044#include <media/ov2710.h>
Danielle Sun4a56b6e2011-05-26 16:52:24 -070045#include <media/tps61050.h>
Prayas Mohanty309cf662011-02-11 00:05:42 +053046#include <generated/mach-types.h>
47#include "gpio-names.h"
Laxman Dewangan39b4ede2011-02-05 17:02:09 +053048#include "board.h"
Robert Collins31d11952011-02-01 10:37:48 -080049#include <linux/mpu.h>
Laxman Dewangan25203652011-05-03 14:24:58 +053050#include <media/sh532u.h>
Pritesh Raithathac19b8f12011-06-04 19:03:16 +053051#include <linux/bq27x00.h>
Robert Collins31d11952011-02-01 10:37:48 -080052#include <mach/gpio.h>
Varun Wadekar3c7b5422011-05-12 14:25:01 +053053#include <mach/edp.h>
Joshua Primero0a892e22011-10-13 17:49:20 -070054#include <mach/thermal.h>
Robert Collins31d11952011-02-01 10:37:48 -080055
56#include "gpio-names.h"
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +053057#include "board-cardhu.h"
Robert Morell2c3d7092011-05-19 09:31:45 -070058#include "cpu-tegra.h"
Prayas Mohanty309cf662011-02-11 00:05:42 +053059
60static struct regulator *cardhu_1v8_cam1 = NULL;
Prayas Mohanty98a127e2011-04-13 12:30:56 +053061static struct regulator *cardhu_1v8_cam2 = NULL;
Prayas Mohantydc4ae782011-03-15 19:44:54 +053062static struct regulator *cardhu_1v8_cam3 = NULL;
Abhiruchi6e455812011-02-15 20:06:43 -080063static struct regulator *cardhu_vdd_2v8_cam1 = NULL;
Prayas Mohanty98a127e2011-04-13 12:30:56 +053064static struct regulator *cardhu_vdd_2v8_cam2 = NULL;
Prayas Mohantydc4ae782011-03-15 19:44:54 +053065static struct regulator *cardhu_vdd_cam3 = NULL;
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +053066
Prayas Mohanty98a127e2011-04-13 12:30:56 +053067static struct board_info board_info;
68
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +053069static struct pca954x_platform_mode cardhu_pca954x_modes[] = {
Laxman Dewangand5965af2011-05-02 14:58:16 +053070 { .adap_id = PCA954x_I2C_BUS0, .deselect_on_exit = true, },
71 { .adap_id = PCA954x_I2C_BUS1, .deselect_on_exit = true, },
72 { .adap_id = PCA954x_I2C_BUS2, .deselect_on_exit = true, },
73 { .adap_id = PCA954x_I2C_BUS3, .deselect_on_exit = true, },
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +053074};
75
76static struct pca954x_platform_data cardhu_pca954x_data = {
77 .modes = cardhu_pca954x_modes,
78 .num_modes = ARRAY_SIZE(cardhu_pca954x_modes),
79};
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +053080
Prayas Mohanty309cf662011-02-11 00:05:42 +053081static int cardhu_camera_init(void)
82{
83 int ret;
Prayas Mohanty309cf662011-02-11 00:05:42 +053084
Prayas Mohanty309cf662011-02-11 00:05:42 +053085 /* Boards E1198 and E1291 are of Cardhu personality
86 * and donot have TCA6416 exp for camera */
87 if ((board_info.board_id == BOARD_E1198) ||
88 (board_info.board_id == BOARD_E1291)) {
Abhiruchi6e455812011-02-15 20:06:43 -080089 tegra_gpio_enable(CAM1_POWER_DWN_GPIO);
90 ret = gpio_request(CAM1_POWER_DWN_GPIO, "camera_power_en");
Prayas Mohanty309cf662011-02-11 00:05:42 +053091 if (ret < 0)
92 pr_err("%s: gpio_request failed for gpio %s\n",
Abhiruchi6e455812011-02-15 20:06:43 -080093 __func__, "CAM1_POWER_DWN_GPIO");
Prayas Mohanty98a127e2011-04-13 12:30:56 +053094 tegra_gpio_enable(CAM3_POWER_DWN_GPIO);
Prayas Mohantydc4ae782011-03-15 19:44:54 +053095 ret = gpio_request(CAM3_POWER_DWN_GPIO, "cam3_power_en");
96 if (ret < 0)
97 pr_err("%s: gpio_request failed for gpio %s\n",
98 __func__, "CAM3_POWER_DWN_GPIO");
99
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530100 tegra_gpio_enable(CAM2_POWER_DWN_GPIO);
101 ret = gpio_request(CAM2_POWER_DWN_GPIO, "camera2_power_en");
102 if (ret < 0)
103 pr_err("%s: gpio_request failed for gpio %s\n",
104 __func__, "CAM2_POWER_DWN_GPIO");
105
Abhiruchi6e455812011-02-15 20:06:43 -0800106 tegra_gpio_enable(OV5650_RESETN_GPIO);
107 ret = gpio_request(OV5650_RESETN_GPIO, "camera_reset");
108 if (ret < 0)
109 pr_err("%s: gpio_request failed for gpio %s\n",
110 __func__, "OV5650_RESETN_GPIO");
Prayas Mohantydc4ae782011-03-15 19:44:54 +0530111
112 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
Abhiruchi6e455812011-02-15 20:06:43 -0800113 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530114 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
Abhiruchi6e455812011-02-15 20:06:43 -0800115 mdelay(10);
116
117 gpio_direction_output(OV5650_RESETN_GPIO, 1);
118 mdelay(5);
119 gpio_direction_output(OV5650_RESETN_GPIO, 0);
120 mdelay(5);
121 gpio_direction_output(OV5650_RESETN_GPIO, 1);
122 mdelay(5);
Prayas Mohanty309cf662011-02-11 00:05:42 +0530123 }
124
125 /* To select the CSIB MUX either for cam2 or cam3 */
126 tegra_gpio_enable(CAMERA_CSI_MUX_SEL_GPIO);
127 ret = gpio_request(CAMERA_CSI_MUX_SEL_GPIO, "camera_csi_sel");
128 if (ret < 0)
129 pr_err("%s: gpio_request failed for gpio %s\n",
130 __func__, "CAMERA_CSI_MUX_SEL_GPIO");
131 gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
132 gpio_export(CAMERA_CSI_MUX_SEL_GPIO, false);
133
134 return 0;
135}
136
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530137static int cardhu_left_ov5650_power_on(void)
Prayas Mohanty309cf662011-02-11 00:05:42 +0530138{
Prayas Mohanty309cf662011-02-11 00:05:42 +0530139 /* Boards E1198 and E1291 are of Cardhu personality
140 * and donot have TCA6416 exp for camera */
141 if ((board_info.board_id == BOARD_E1198) ||
142 (board_info.board_id == BOARD_E1291)) {
Abhiruchi6e455812011-02-15 20:06:43 -0800143
Abhiruchi6e455812011-02-15 20:06:43 -0800144 if (cardhu_vdd_2v8_cam1 == NULL) {
145 cardhu_vdd_2v8_cam1 = regulator_get(NULL, "vdd_2v8_cam1");
146 if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam1))) {
147 pr_err("%s: couldn't get regulator vdd_2v8_cam1: %ld\n",
148 __func__, PTR_ERR(cardhu_vdd_2v8_cam1));
149 goto reg_alloc_fail;
150 }
151 }
Abhiruchi6e455812011-02-15 20:06:43 -0800152 regulator_enable(cardhu_vdd_2v8_cam1);
Prayas Mohanty309cf662011-02-11 00:05:42 +0530153 mdelay(5);
154 }
Prayas Mohantydc4ae782011-03-15 19:44:54 +0530155
Abhiruchi6e455812011-02-15 20:06:43 -0800156 /* Enable VDD_1V8_Cam1 */
157 if (cardhu_1v8_cam1 == NULL) {
158 cardhu_1v8_cam1 = regulator_get(NULL, "vdd_1v8_cam1");
159 if (WARN_ON(IS_ERR(cardhu_1v8_cam1))) {
160 pr_err("%s: couldn't get regulator vdd_1v8_cam1: %ld\n",
161 __func__, PTR_ERR(cardhu_1v8_cam1));
162 goto reg_alloc_fail;
Prayas Mohanty309cf662011-02-11 00:05:42 +0530163 }
Abhiruchi6e455812011-02-15 20:06:43 -0800164 }
165 regulator_enable(cardhu_1v8_cam1);
Laxman Dewangan576b2522011-02-14 18:51:14 +0530166
Abhiruchi6e455812011-02-15 20:06:43 -0800167 mdelay(5);
Laxman Dewangan25203652011-05-03 14:24:58 +0530168 if ((board_info.board_id == BOARD_E1198) ||
169 (board_info.board_id == BOARD_E1291)) {
170 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
171 mdelay(20);
172 gpio_direction_output(OV5650_RESETN_GPIO, 0);
173 mdelay(100);
174 gpio_direction_output(OV5650_RESETN_GPIO, 1);
175 }
Frank Chenf237f2f2011-08-24 18:04:52 -0700176
177 if (board_info.board_id == BOARD_PM269) {
178 gpio_direction_output(CAM1_RST_L_GPIO, 0);
179 mdelay(100);
180 gpio_direction_output(CAM1_RST_L_GPIO, 1);
181 }
182
Abhiruchi6e455812011-02-15 20:06:43 -0800183 return 0;
Laxman Dewangan576b2522011-02-14 18:51:14 +0530184
185reg_alloc_fail:
Abhiruchi6e455812011-02-15 20:06:43 -0800186 if (cardhu_1v8_cam1) {
187 regulator_put(cardhu_1v8_cam1);
188 cardhu_1v8_cam1 = NULL;
Prayas Mohanty309cf662011-02-11 00:05:42 +0530189 }
Abhiruchi6e455812011-02-15 20:06:43 -0800190 if (cardhu_vdd_2v8_cam1) {
191 regulator_put(cardhu_vdd_2v8_cam1);
192 cardhu_vdd_2v8_cam1 = NULL;
193 }
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530194
Abhiruchi6e455812011-02-15 20:06:43 -0800195 return -ENODEV;
Prayas Mohanty309cf662011-02-11 00:05:42 +0530196
Prayas Mohanty309cf662011-02-11 00:05:42 +0530197}
198
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530199static int cardhu_left_ov5650_power_off(void)
Prayas Mohanty309cf662011-02-11 00:05:42 +0530200{
Prayas Mohanty309cf662011-02-11 00:05:42 +0530201 /* Boards E1198 and E1291 are of Cardhu personality
202 * and donot have TCA6416 exp for camera */
203 if ((board_info.board_id == BOARD_E1198) ||
204 (board_info.board_id == BOARD_E1291)) {
205 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
Jin Qian1ecfe332011-05-10 11:16:18 -0700206 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
207 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
Prayas Mohanty309cf662011-02-11 00:05:42 +0530208 }
Abhiruchi6e455812011-02-15 20:06:43 -0800209 if (cardhu_1v8_cam1)
210 regulator_disable(cardhu_1v8_cam1);
Abhiruchi6e455812011-02-15 20:06:43 -0800211 if (cardhu_vdd_2v8_cam1)
212 regulator_disable(cardhu_vdd_2v8_cam1);
Prayas Mohanty309cf662011-02-11 00:05:42 +0530213
214 return 0;
215}
216
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530217struct ov5650_platform_data cardhu_left_ov5650_data = {
218 .power_on = cardhu_left_ov5650_power_on,
219 .power_off = cardhu_left_ov5650_power_off,
220};
221
kdivvela1e757fd2011-09-30 18:34:14 +0530222#ifdef CONFIG_VIDEO_OV14810
223static int cardhu_ov14810_power_on(void)
224{
225 if (board_info.board_id == BOARD_E1198) {
226 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
227 mdelay(20);
228 gpio_direction_output(OV14810_RESETN_GPIO, 0);
229 mdelay(100);
230 gpio_direction_output(OV14810_RESETN_GPIO, 1);
231 }
232
233 return 0;
234}
235
236static int cardhu_ov14810_power_off(void)
237{
238 if (board_info.board_id == BOARD_E1198) {
239 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
240 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
241 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
242 }
243
244 return 0;
245}
246
247struct ov14810_platform_data cardhu_ov14810_data = {
248 .power_on = cardhu_ov14810_power_on,
249 .power_off = cardhu_ov14810_power_off,
250};
251
252struct ov14810_platform_data cardhu_ov14810uC_data = {
253 .power_on = NULL,
254 .power_off = NULL,
255};
256
257struct ov14810_platform_data cardhu_ov14810SlaveDev_data = {
258 .power_on = NULL,
259 .power_off = NULL,
260};
261
262static struct i2c_board_info cardhu_i2c_board_info_e1214[] = {
263 {
264 I2C_BOARD_INFO("ov14810", 0x36),
265 .platform_data = &cardhu_ov14810_data,
266 },
267 {
268 I2C_BOARD_INFO("ov14810uC", 0x67),
269 .platform_data = &cardhu_ov14810uC_data,
270 },
271 {
272 I2C_BOARD_INFO("ov14810SlaveDev", 0x69),
273 .platform_data = &cardhu_ov14810SlaveDev_data,
274 }
275};
276#endif
277
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530278static int cardhu_right_ov5650_power_on(void)
279{
Anton Kondratenkoe3794ce2011-12-12 19:06:17 -0800280 /* CSI-B and front sensor are muxed on cardhu */
281 gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
282
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530283 /* Boards E1198 and E1291 are of Cardhu personality
284 * and donot have TCA6416 exp for camera */
285 if ((board_info.board_id == BOARD_E1198) ||
286 (board_info.board_id == BOARD_E1291)) {
287
Jin Qian1ecfe332011-05-10 11:16:18 -0700288 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
289 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
290 mdelay(10);
291
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530292 if (cardhu_vdd_2v8_cam2 == NULL) {
293 cardhu_vdd_2v8_cam2 = regulator_get(NULL, "vdd_2v8_cam2");
294 if (WARN_ON(IS_ERR(cardhu_vdd_2v8_cam2))) {
295 pr_err("%s: couldn't get regulator vdd_2v8_cam2: %ld\n",
296 __func__, PTR_ERR(cardhu_vdd_2v8_cam2));
297 goto reg_alloc_fail;
298 }
299 }
300 regulator_enable(cardhu_vdd_2v8_cam2);
301 mdelay(5);
302 }
303
304 /* Enable VDD_1V8_Cam2 */
305 if (cardhu_1v8_cam2 == NULL) {
306 cardhu_1v8_cam2 = regulator_get(NULL, "vdd_1v8_cam2");
307 if (WARN_ON(IS_ERR(cardhu_1v8_cam2))) {
308 pr_err("%s: couldn't get regulator vdd_1v8_cam2: %ld\n",
309 __func__, PTR_ERR(cardhu_1v8_cam2));
310 goto reg_alloc_fail;
311 }
312 }
313 regulator_enable(cardhu_1v8_cam2);
314
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530315 mdelay(5);
Frank Chenf237f2f2011-08-24 18:04:52 -0700316
317 if (board_info.board_id == BOARD_PM269) {
318 gpio_direction_output(CAM2_RST_L_GPIO, 0);
319 mdelay(100);
320 gpio_direction_output(CAM2_RST_L_GPIO, 1);
321 }
322
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530323 return 0;
324
325reg_alloc_fail:
326 if (cardhu_1v8_cam2) {
327 regulator_put(cardhu_1v8_cam2);
328 cardhu_1v8_cam2 = NULL;
329 }
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530330 if (cardhu_vdd_2v8_cam2) {
331 regulator_put(cardhu_vdd_2v8_cam2);
332 cardhu_vdd_2v8_cam2 = NULL;
333 }
334
335 return -ENODEV;
336
337}
338
339static int cardhu_right_ov5650_power_off(void)
340{
Anton Kondratenkoe3794ce2011-12-12 19:06:17 -0800341 /* CSI-B and front sensor are muxed on cardhu */
342 gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 0);
343
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530344 /* Boards E1198 and E1291 are of Cardhu personality
345 * and donot have TCA6416 exp for camera */
Jin Qian1ecfe332011-05-10 11:16:18 -0700346 if ((board_info.board_id == BOARD_E1198) ||
347 (board_info.board_id == BOARD_E1291)) {
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530348 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
349 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
garyz353a6102011-06-01 18:41:35 -0700350 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
Jin Qian1ecfe332011-05-10 11:16:18 -0700351 }
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530352
353 if (cardhu_1v8_cam2)
354 regulator_disable(cardhu_1v8_cam2);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530355 if (cardhu_vdd_2v8_cam2)
356 regulator_disable(cardhu_vdd_2v8_cam2);
357
358 return 0;
359}
360
Prayas Mohanty56c62f42011-05-18 17:52:29 +0530361static void cardhu_ov5650_synchronize_sensors(void)
362{
363 if (board_info.board_id == BOARD_E1198) {
364 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
365 mdelay(50);
366 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
367 mdelay(50);
368 }
369 else if (board_info.board_id == BOARD_E1291) {
370 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
371 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
372 mdelay(50);
373 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
374 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
375 mdelay(50);
376 }
377 else
378 pr_err("%s: UnSupported BoardId\n", __func__);
379}
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530380
381struct ov5650_platform_data cardhu_right_ov5650_data = {
382 .power_on = cardhu_right_ov5650_power_on,
383 .power_off = cardhu_right_ov5650_power_off,
Prayas Mohanty56c62f42011-05-18 17:52:29 +0530384 .synchronize_sensors = cardhu_ov5650_synchronize_sensors,
Prayas Mohanty309cf662011-02-11 00:05:42 +0530385};
386
Prayas Mohantye3171a62011-02-25 04:30:01 +0530387static int cardhu_ov2710_power_on(void)
388{
Anton Kondratenkoe3794ce2011-12-12 19:06:17 -0800389 /* CSI-B and front sensor are muxed on cardhu */
Prayas Mohantye3171a62011-02-25 04:30:01 +0530390 gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530391
392 /* Boards E1198 and E1291 are of Cardhu personality
393 * and donot have TCA6416 exp for camera */
394 if ((board_info.board_id == BOARD_E1198) ||
395 (board_info.board_id == BOARD_E1291)) {
Jin Qian1ecfe332011-05-10 11:16:18 -0700396
397 gpio_direction_output(CAM1_POWER_DWN_GPIO, 0);
398 gpio_direction_output(CAM2_POWER_DWN_GPIO, 0);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530399 gpio_direction_output(CAM3_POWER_DWN_GPIO, 0);
400 mdelay(10);
401
402 if (cardhu_vdd_cam3 == NULL) {
403 cardhu_vdd_cam3 = regulator_get(NULL, "vdd_cam3");
404 if (WARN_ON(IS_ERR(cardhu_vdd_cam3))) {
405 pr_err("%s: couldn't get regulator vdd_cam3: %ld\n",
406 __func__, PTR_ERR(cardhu_vdd_cam3));
407 goto reg_alloc_fail;
408 }
409 }
410 regulator_enable(cardhu_vdd_cam3);
411 }
412
413 /* Enable VDD_1V8_Cam3 */
414 if (cardhu_1v8_cam3 == NULL) {
415 cardhu_1v8_cam3 = regulator_get(NULL, "vdd_1v8_cam3");
416 if (WARN_ON(IS_ERR(cardhu_1v8_cam3))) {
417 pr_err("%s: couldn't get regulator vdd_1v8_cam3: %ld\n",
418 __func__, PTR_ERR(cardhu_1v8_cam3));
419 goto reg_alloc_fail;
420 }
421 }
422 regulator_enable(cardhu_1v8_cam3);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530423 mdelay(5);
424
Prayas Mohantye3171a62011-02-25 04:30:01 +0530425 return 0;
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530426
427reg_alloc_fail:
428 if (cardhu_1v8_cam3) {
429 regulator_put(cardhu_1v8_cam3);
430 cardhu_1v8_cam3 = NULL;
431 }
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530432 if (cardhu_vdd_cam3) {
433 regulator_put(cardhu_vdd_cam3);
434 cardhu_vdd_cam3 = NULL;
435 }
436
437 return -ENODEV;
Prayas Mohantye3171a62011-02-25 04:30:01 +0530438}
439
440static int cardhu_ov2710_power_off(void)
441{
Anton Kondratenkoe3794ce2011-12-12 19:06:17 -0800442 /* CSI-B and front sensor are muxed on cardhu */
Jin Qian1ecfe332011-05-10 11:16:18 -0700443 gpio_direction_output(CAMERA_CSI_MUX_SEL_GPIO, 1);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530444
445 /* Boards E1198 and E1291 are of Cardhu personality
446 * and donot have TCA6416 exp for camera */
447 if ((board_info.board_id == BOARD_E1198) ||
Jin Qian1ecfe332011-05-10 11:16:18 -0700448 (board_info.board_id == BOARD_E1291)) {
449 gpio_direction_output(CAM1_POWER_DWN_GPIO, 1);
450 gpio_direction_output(CAM2_POWER_DWN_GPIO, 1);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530451 gpio_direction_output(CAM3_POWER_DWN_GPIO, 1);
Jin Qian1ecfe332011-05-10 11:16:18 -0700452 }
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530453
454 if (cardhu_1v8_cam3)
455 regulator_disable(cardhu_1v8_cam3);
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530456 if (cardhu_vdd_cam3)
457 regulator_disable(cardhu_vdd_cam3);
458
Prayas Mohantye3171a62011-02-25 04:30:01 +0530459 return 0;
460}
461
462struct ov2710_platform_data cardhu_ov2710_data = {
463 .power_on = cardhu_ov2710_power_on,
464 .power_off = cardhu_ov2710_power_off,
465};
466
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +0530467static const struct i2c_board_info cardhu_i2c3_board_info[] = {
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +0530468 {
469 I2C_BOARD_INFO("pca9546", 0x70),
470 .platform_data = &cardhu_pca954x_data,
471 },
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +0530472};
Laxman Dewangan25203652011-05-03 14:24:58 +0530473
Erik Lilliebjergf07b43f2011-11-22 04:06:03 -0700474static struct sh532u_platform_data sh532u_left_pdata = {
475 .num = 1,
476 .sync = 2,
477 .dev_name = "focuser",
478 .gpio_reset = TEGRA_GPIO_PBB0,
Laxman Dewangan25203652011-05-03 14:24:58 +0530479};
Danielle Sun4a56b6e2011-05-26 16:52:24 -0700480
Erik Lilliebjergf07b43f2011-11-22 04:06:03 -0700481static struct sh532u_platform_data sh532u_right_pdata = {
482 .num = 2,
483 .sync = 1,
484 .dev_name = "focuser",
485 .gpio_reset = TEGRA_GPIO_PBB0,
garyz353a6102011-06-01 18:41:35 -0700486};
Danielle Sun4a56b6e2011-05-26 16:52:24 -0700487
Erik Lilliebjerg6759a2f2012-01-06 19:59:50 -0700488static struct sh532u_platform_data pm269_sh532u_left_pdata = {
489 .num = 1,
490 .sync = 2,
491 .dev_name = "focuser",
492 .gpio_reset = CAM1_RST_L_GPIO,
493};
494
495static struct sh532u_platform_data pm269_sh532u_right_pdata = {
496 .num = 2,
497 .sync = 1,
498 .dev_name = "focuser",
499 .gpio_reset = CAM2_RST_L_GPIO,
500};
501
Erik Lilliebjergfb24a742011-12-01 05:44:07 -0700502static struct nvc_torch_pin_state cardhu_tps61050_pinstate = {
Danielle Sun4a56b6e2011-05-26 16:52:24 -0700503 .mask = 0x0008, /*VGP3*/
504 .values = 0x0008,
505};
506
Erik Lilliebjergfb24a742011-12-01 05:44:07 -0700507static struct tps61050_platform_data cardhu_tps61050_pdata = {
508 .dev_name = "torch",
Danielle Sun4a56b6e2011-05-26 16:52:24 -0700509 .pinstate = &cardhu_tps61050_pinstate,
Danielle Sun4a56b6e2011-05-26 16:52:24 -0700510};
511
512static const struct i2c_board_info cardhu_i2c_board_info_tps61050[] = {
513 {
514 I2C_BOARD_INFO("tps61050", 0x33),
Erik Lilliebjergfb24a742011-12-01 05:44:07 -0700515 .platform_data = &cardhu_tps61050_pdata,
Danielle Sun4a56b6e2011-05-26 16:52:24 -0700516 },
517};
518
Prayas Mohanty309cf662011-02-11 00:05:42 +0530519static struct i2c_board_info cardhu_i2c6_board_info[] = {
520 {
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530521 I2C_BOARD_INFO("ov5650L", 0x36),
522 .platform_data = &cardhu_left_ov5650_data,
Prayas Mohanty309cf662011-02-11 00:05:42 +0530523 },
Abhiruchi Birajdarb17f8502011-03-18 14:39:50 +0530524 {
Erik Lilliebjergf07b43f2011-11-22 04:06:03 -0700525 I2C_BOARD_INFO("sh532u", 0x72),
garyz353a6102011-06-01 18:41:35 -0700526 .platform_data = &sh532u_left_pdata,
Abhiruchi Birajdarb17f8502011-03-18 14:39:50 +0530527 },
Prayas Mohanty309cf662011-02-11 00:05:42 +0530528};
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +0530529
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530530static struct i2c_board_info cardhu_i2c7_board_info[] = {
531 {
532 I2C_BOARD_INFO("ov5650R", 0x36),
533 .platform_data = &cardhu_right_ov5650_data,
534 },
garyz353a6102011-06-01 18:41:35 -0700535 {
Erik Lilliebjergf07b43f2011-11-22 04:06:03 -0700536 I2C_BOARD_INFO("sh532u", 0x72),
garyz353a6102011-06-01 18:41:35 -0700537 .platform_data = &sh532u_right_pdata,
538 },
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530539};
540
Erik Lilliebjerg6759a2f2012-01-06 19:59:50 -0700541static struct i2c_board_info pm269_i2c6_board_info[] = {
542 {
543 I2C_BOARD_INFO("ov5650L", 0x36),
544 .platform_data = &cardhu_left_ov5650_data,
545 },
546 {
547 I2C_BOARD_INFO("sh532u", 0x72),
548 .platform_data = &pm269_sh532u_left_pdata,
549 },
550};
551
552static struct i2c_board_info pm269_i2c7_board_info[] = {
553 {
554 I2C_BOARD_INFO("ov5650R", 0x36),
555 .platform_data = &cardhu_right_ov5650_data,
556 },
557 {
558 I2C_BOARD_INFO("sh532u", 0x72),
559 .platform_data = &pm269_sh532u_right_pdata,
560 },
561};
562
Prayas Mohantye3171a62011-02-25 04:30:01 +0530563static struct i2c_board_info cardhu_i2c8_board_info[] = {
564 {
565 I2C_BOARD_INFO("ov2710", 0x36),
566 .platform_data = &cardhu_ov2710_data,
567 },
568};
569
Joshua Primero0a892e22011-10-13 17:49:20 -0700570static int nct_get_temp(void *_data, long *temp)
571{
572 struct nct1008_data *data = _data;
573 return nct1008_thermal_get_temp(data, temp);
574}
575
Joshua Primero32ff2dc2011-12-18 15:44:25 -0800576static int nct_get_temp_low(void *_data, long *temp)
577{
578 struct nct1008_data *data = _data;
579 return nct1008_thermal_get_temp_low(data, temp);
580}
581
Joshua Primero0a892e22011-10-13 17:49:20 -0700582static int nct_set_limits(void *_data,
583 long lo_limit_milli,
584 long hi_limit_milli)
585{
586 struct nct1008_data *data = _data;
587 return nct1008_thermal_set_limits(data,
588 lo_limit_milli,
589 hi_limit_milli);
590}
591
592static int nct_set_alert(void *_data,
593 void (*alert_func)(void *),
594 void *alert_data)
595{
596 struct nct1008_data *data = _data;
597 return nct1008_thermal_set_alert(data, alert_func, alert_data);
598}
599
600static int nct_set_shutdown_temp(void *_data, long shutdown_temp)
601{
602 struct nct1008_data *data = _data;
603 return nct1008_thermal_set_shutdown_temp(data, shutdown_temp);
604}
Joshua Primero32ff2dc2011-12-18 15:44:25 -0800605
Joshua Primero0a892e22011-10-13 17:49:20 -0700606static void nct1008_probe_callback(struct nct1008_data *data)
607{
608 struct tegra_thermal_device *thermal_device;
609
610 thermal_device = kzalloc(sizeof(struct tegra_thermal_device),
611 GFP_KERNEL);
612 if (!thermal_device) {
613 pr_err("unable to allocate thermal device\n");
614 return;
615 }
616
Joshua Primerob0874e72011-12-16 11:09:50 -0800617 thermal_device->name = "nct1008";
Joshua Primero0a892e22011-10-13 17:49:20 -0700618 thermal_device->data = data;
619 thermal_device->offset = TDIODE_OFFSET;
620 thermal_device->get_temp = nct_get_temp;
Joshua Primero32ff2dc2011-12-18 15:44:25 -0800621 thermal_device->get_temp_low = nct_get_temp_low;
Joshua Primero0a892e22011-10-13 17:49:20 -0700622 thermal_device->set_limits = nct_set_limits;
623 thermal_device->set_alert = nct_set_alert;
624 thermal_device->set_shutdown_temp = nct_set_shutdown_temp;
625
626 tegra_thermal_set_device(thermal_device);
627}
Joshua Primero0a892e22011-10-13 17:49:20 -0700628
Bitan Biswas5730ac42011-02-09 18:01:59 +0530629static struct nct1008_platform_data cardhu_nct1008_pdata = {
630 .supported_hwrev = true,
Bitan Biswas0513cd62011-07-12 13:00:19 +0530631 .ext_range = true,
Bitan Biswas5730ac42011-02-09 18:01:59 +0530632 .conv_rate = 0x08,
Diwakar Tundlam609ccce2011-09-08 10:59:56 -0700633 .offset = 8, /* 4 * 2C. Bug 844025 - 1C for device accuracies */
Joshua Primero0a892e22011-10-13 17:49:20 -0700634 .probe_callback = nct1008_probe_callback,
Bitan Biswas5730ac42011-02-09 18:01:59 +0530635};
636
Laxman Dewangan12bf37c2011-03-25 14:50:15 +0530637static struct i2c_board_info cardhu_i2c4_bq27510_board_info[] = {
Bitan Biswas5730ac42011-02-09 18:01:59 +0530638 {
syed rafiuddine451d762011-03-21 15:08:26 +0530639 I2C_BOARD_INFO("bq27510", 0x55),
640 },
Laxman Dewangan12bf37c2011-03-25 14:50:15 +0530641};
642
Varun Wadekar3c7b5422011-05-12 14:25:01 +0530643static struct i2c_board_info cardhu_i2c4_nct1008_board_info[] = {
syed rafiuddine451d762011-03-21 15:08:26 +0530644 {
Bitan Biswas5730ac42011-02-09 18:01:59 +0530645 I2C_BOARD_INFO("nct1008", 0x4C),
646 .platform_data = &cardhu_nct1008_pdata,
647 .irq = -1,
648 }
649};
650
651static int cardhu_nct1008_init(void)
652{
653 int nct1008_port = -1;
Colin Patrick McCabe6f3051d2012-01-18 12:08:27 -0800654 int ret = 0;
Bitan Biswas5730ac42011-02-09 18:01:59 +0530655
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530656 if ((board_info.board_id == BOARD_E1198) ||
Laxman Dewangan9fc88222011-08-17 15:59:34 +0530657 (board_info.board_id == BOARD_E1291) ||
Laxman Dewanganabc4aac2011-09-09 11:08:01 +0530658 (board_info.board_id == BOARD_E1257) ||
Laxman Dewangan2de5dd82011-08-30 15:11:20 +0530659 (board_info.board_id == BOARD_PM269) ||
Laxman Dewangan6b57c93f2011-08-31 11:46:43 +0530660 (board_info.board_id == BOARD_PM305) ||
661 (board_info.board_id == BOARD_PM311)) {
Bitan Biswas5730ac42011-02-09 18:01:59 +0530662 nct1008_port = TEGRA_GPIO_PCC2;
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530663 } else if ((board_info.board_id == BOARD_E1186) ||
Laxman Dewangan3187bb12011-07-11 18:22:39 +0530664 (board_info.board_id == BOARD_E1187) ||
665 (board_info.board_id == BOARD_E1256)) {
Bitan Biswas5730ac42011-02-09 18:01:59 +0530666 /* FIXME: seems to be conflicting with usb3 vbus on E1186 */
667 /* nct1008_port = TEGRA_GPIO_PH7; */
668 }
669
670 if (nct1008_port >= 0) {
671 /* FIXME: enable irq when throttling is supported */
Varun Wadekar3c7b5422011-05-12 14:25:01 +0530672 cardhu_i2c4_nct1008_board_info[0].irq = TEGRA_GPIO_TO_IRQ(nct1008_port);
Bitan Biswas5730ac42011-02-09 18:01:59 +0530673
674 ret = gpio_request(nct1008_port, "temp_alert");
675 if (ret < 0)
676 return ret;
677
678 ret = gpio_direction_input(nct1008_port);
679 if (ret < 0)
680 gpio_free(nct1008_port);
681 else
682 tegra_gpio_enable(nct1008_port);
Bitan Biswas5730ac42011-02-09 18:01:59 +0530683 }
Varun Wadekar3c7b5422011-05-12 14:25:01 +0530684
Bitan Biswas5730ac42011-02-09 18:01:59 +0530685 return ret;
686}
687
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530688#if defined(CONFIG_GPIO_PCA953X)
689static struct pca953x_platform_data cardhu_pmu_tca6416_data = {
690 .gpio_base = PMU_TCA6416_GPIO_BASE,
691};
692
693static const struct i2c_board_info cardhu_i2c4_board_info_tca6416[] = {
694 {
695 I2C_BOARD_INFO("tca6416", 0x20),
696 .platform_data = &cardhu_pmu_tca6416_data,
697 },
698};
699
Prayas Mohanty309cf662011-02-11 00:05:42 +0530700static struct pca953x_platform_data cardhu_cam_tca6416_data = {
701 .gpio_base = CAM_TCA6416_GPIO_BASE,
702};
703
704static const struct i2c_board_info cardhu_i2c2_board_info_tca6416[] = {
705 {
706 I2C_BOARD_INFO("tca6416", 0x20),
707 .platform_data = &cardhu_cam_tca6416_data,
708 },
709};
710
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530711static int __init pmu_tca6416_init(void)
712{
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530713 if ((board_info.board_id == BOARD_E1198) ||
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530714 (board_info.board_id == BOARD_E1291))
715 return 0;
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530716
717 pr_info("Registering pmu pca6416\n");
718 i2c_register_board_info(4, cardhu_i2c4_board_info_tca6416,
719 ARRAY_SIZE(cardhu_i2c4_board_info_tca6416));
720 return 0;
721}
Prayas Mohanty309cf662011-02-11 00:05:42 +0530722
723static int __init cam_tca6416_init(void)
724{
Prayas Mohanty309cf662011-02-11 00:05:42 +0530725 /* Boards E1198 and E1291 are of Cardhu personality
726 * and donot have TCA6416 exp for camera */
727 if ((board_info.board_id == BOARD_E1198) ||
728 (board_info.board_id == BOARD_E1291))
729 return 0;
730
731 pr_info("Registering cam pca6416\n");
732 i2c_register_board_info(2, cardhu_i2c2_board_info_tca6416,
733 ARRAY_SIZE(cardhu_i2c2_board_info_tca6416));
734 return 0;
735}
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530736#else
737static int __init pmu_tca6416_init(void)
738{
739 return 0;
740}
Prayas Mohanty309cf662011-02-11 00:05:42 +0530741
742static int __init cam_tca6416_init(void)
743{
744 return 0;
745}
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530746#endif
747
Robert Collinsafe3f592011-12-01 16:19:20 -0800748/* MPU board file definition */
749#if (MPU_GYRO_TYPE == MPU_TYPE_MPU3050)
750#define MPU_GYRO_NAME "mpu3050"
Ge Gao74f15aa2012-05-25 13:38:55 -0700751static struct mpu_platform_data mpu_gyro_data = {
752 .int_config = 0x10,
753 .level_shifter = 0,
754 .orientation = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h */
755 .sec_slave_type = SECONDARY_SLAVE_TYPE_ACCEL,
756 .sec_slave_id = ACCEL_ID_BMA250,
757 .secondary_i2c_addr = MPU_ACCEL_ADDR,
758 .secondary_orientation = MPU_ACCEL_ORIENTATION, /* Located in board_[platformname].h */
759 .key = {221, 22, 205, 7, 217, 186, 151, 55,
760 206, 254, 35, 144, 225, 102, 47, 50},
761};
Robert Collinsafe3f592011-12-01 16:19:20 -0800762#endif
763#if (MPU_GYRO_TYPE == MPU_TYPE_MPU6050)
764#define MPU_GYRO_NAME "mpu6050"
Robert Collinsafe3f592011-12-01 16:19:20 -0800765static struct mpu_platform_data mpu_gyro_data = {
Ge Gao74f15aa2012-05-25 13:38:55 -0700766 .int_config = 0x10,
767 .level_shifter = 0,
768 .orientation = MPU_GYRO_ORIENTATION, /* Located in board_[platformname].h */
769 .sec_slave_type = SECONDARY_SLAVE_TYPE_NONE,
770 .key = {221, 22, 205, 7, 217, 186, 151, 55,
771 206, 254, 35, 144, 225, 102, 47, 50},
Robert Collins5d901d92011-11-09 13:59:33 -0800772};
Robert Collinsafe3f592011-12-01 16:19:20 -0800773#endif
Ge Gao74f15aa2012-05-25 13:38:55 -0700774static struct mpu_platform_data mpu_compass_data = {
775 .orientation = MPU_COMPASS_ORIENTATION, /* Located in board_[platformname].h */
Robert Collins5d901d92011-11-09 13:59:33 -0800776};
777
778static struct i2c_board_info __initdata inv_mpu_i2c2_board_info[] = {
Ge Gao74f15aa2012-05-25 13:38:55 -0700779 {
780 I2C_BOARD_INFO(MPU_GYRO_NAME, MPU_GYRO_ADDR),
781 .irq = TEGRA_GPIO_TO_IRQ(MPU_GYRO_IRQ_GPIO),
782 .platform_data = &mpu_gyro_data,
783 },
784 {
785 I2C_BOARD_INFO(MPU_COMPASS_NAME, MPU_COMPASS_ADDR),
786 .platform_data = &mpu_compass_data,
787 },
Robert Collins31d11952011-02-01 10:37:48 -0800788};
789
Robert Collins5d901d92011-11-09 13:59:33 -0800790static void mpuirq_init(void)
Robert Collins31d11952011-02-01 10:37:48 -0800791{
Robert Collins5d901d92011-11-09 13:59:33 -0800792 int ret = 0;
Laxman Dewangan67e36c22011-04-13 14:08:48 +0530793
Robert Collins5d901d92011-11-09 13:59:33 -0800794 pr_info("*** MPU START *** mpuirq_init...\n");
795
Robert Collins5d901d92011-11-09 13:59:33 -0800796 /* MPU-IRQ assignment */
797 tegra_gpio_enable(MPU_GYRO_IRQ_GPIO);
798 ret = gpio_request(MPU_GYRO_IRQ_GPIO, MPU_GYRO_NAME);
799 if (ret < 0) {
800 pr_err("%s: gpio_request failed %d\n", __func__, ret);
801 return;
802 }
803
804 ret = gpio_direction_input(MPU_GYRO_IRQ_GPIO);
805 if (ret < 0) {
806 pr_err("%s: gpio_direction_input failed %d\n", __func__, ret);
807 gpio_free(MPU_GYRO_IRQ_GPIO);
808 return;
809 }
810 pr_info("*** MPU END *** mpuirq_init...\n");
811
812 i2c_register_board_info(MPU_GYRO_BUS_NUM, inv_mpu_i2c2_board_info,
813 ARRAY_SIZE(inv_mpu_i2c2_board_info));
Robert Collins31d11952011-02-01 10:37:48 -0800814}
Robert Collins31d11952011-02-01 10:37:48 -0800815
Laxman Dewangan8e85dfa2011-03-22 18:40:06 +0530816static struct i2c_board_info cardhu_i2c2_isl_board_info[] = {
817 {
818 I2C_BOARD_INFO("isl29028", 0x44),
819 }
820};
Sachin Nikam9d550b02012-03-07 12:29:55 +0530821
Sachin Nikam9d550b02012-03-07 12:29:55 +0530822static struct i2c_board_info cardhu_i2c2_ltr_board_info[] = {
823 {
824 I2C_BOARD_INFO("LTR_558ALS", 0x23),
825 }
826};
Laxman Dewangan8e85dfa2011-03-22 18:40:06 +0530827
Laxman Dewangan353d5432010-12-22 15:32:30 +0530828int __init cardhu_sensors_init(void)
829{
Bitan Biswas5730ac42011-02-09 18:01:59 +0530830 int err;
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530831
Laxman Dewangan12bf37c2011-03-25 14:50:15 +0530832 tegra_get_board_info(&board_info);
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530833
Prayas Mohanty309cf662011-02-11 00:05:42 +0530834 cardhu_camera_init();
835 cam_tca6416_init();
836
837 i2c_register_board_info(2, cardhu_i2c3_board_info,
838 ARRAY_SIZE(cardhu_i2c3_board_info));
839
Danielle Sun4a56b6e2011-05-26 16:52:24 -0700840 i2c_register_board_info(2, cardhu_i2c_board_info_tps61050,
841 ARRAY_SIZE(cardhu_i2c_board_info_tps61050));
842
kdivvela1e757fd2011-09-30 18:34:14 +0530843#ifdef CONFIG_VIDEO_OV14810
844 /* This is disabled by default; To enable this change Kconfig;
845 * there should be some way to detect dynamically which board
846 * is connected (E1211/E1214), till that time sensor selection
847 * logic is static;
848 * e1214 corresponds to ov14810 sensor */
849 i2c_register_board_info(2, cardhu_i2c_board_info_e1214,
850 ARRAY_SIZE(cardhu_i2c_board_info_e1214));
851#else
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530852 /* Left camera is on PCA954x's I2C BUS0, Right camera is on BUS1 &
853 * Front camera is on BUS2 */
Erik Lilliebjerg6759a2f2012-01-06 19:59:50 -0700854 if (board_info.board_id != BOARD_PM269) {
855 i2c_register_board_info(PCA954x_I2C_BUS0,
856 cardhu_i2c6_board_info,
857 ARRAY_SIZE(cardhu_i2c6_board_info));
Laxman Dewangan8e01bcc2011-01-18 19:37:19 +0530858
Erik Lilliebjerg6759a2f2012-01-06 19:59:50 -0700859 i2c_register_board_info(PCA954x_I2C_BUS1,
860 cardhu_i2c7_board_info,
861 ARRAY_SIZE(cardhu_i2c7_board_info));
862 } else {
863 i2c_register_board_info(PCA954x_I2C_BUS0,
864 pm269_i2c6_board_info,
865 ARRAY_SIZE(pm269_i2c6_board_info));
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530866
Erik Lilliebjerg6759a2f2012-01-06 19:59:50 -0700867 i2c_register_board_info(PCA954x_I2C_BUS1,
868 pm269_i2c7_board_info,
869 ARRAY_SIZE(pm269_i2c7_board_info));
870 }
Prayas Mohantye3171a62011-02-25 04:30:01 +0530871 i2c_register_board_info(PCA954x_I2C_BUS2, cardhu_i2c8_board_info,
872 ARRAY_SIZE(cardhu_i2c8_board_info));
873
kdivvela1e757fd2011-09-30 18:34:14 +0530874#endif
Laxman Dewangan39b4ede2011-02-05 17:02:09 +0530875 pmu_tca6416_init();
Bitan Biswas5730ac42011-02-09 18:01:59 +0530876
Laxman Dewangan12bf37c2011-03-25 14:50:15 +0530877 if (board_info.board_id == BOARD_E1291)
878 i2c_register_board_info(4, cardhu_i2c4_bq27510_board_info,
879 ARRAY_SIZE(cardhu_i2c4_bq27510_board_info));
880
Sachin Nikamf2d6f912012-03-14 12:59:00 +0530881 if (board_info.sku == BOARD_SKU_B11)
882 i2c_register_board_info(2, cardhu_i2c2_ltr_board_info,
883 ARRAY_SIZE(cardhu_i2c2_ltr_board_info));
884 else
885 i2c_register_board_info(2, cardhu_i2c2_isl_board_info,
886 ARRAY_SIZE(cardhu_i2c2_isl_board_info));
Laxman Dewangan8e85dfa2011-03-22 18:40:06 +0530887
Bitan Biswas5730ac42011-02-09 18:01:59 +0530888 err = cardhu_nct1008_init();
889 if (err)
890 return err;
891
Varun Wadekar3c7b5422011-05-12 14:25:01 +0530892 i2c_register_board_info(4, cardhu_i2c4_nct1008_board_info,
893 ARRAY_SIZE(cardhu_i2c4_nct1008_board_info));
894
Robert Collins5d901d92011-11-09 13:59:33 -0800895 mpuirq_init();
Laxman Dewangan353d5432010-12-22 15:32:30 +0530896 return 0;
897}
Prayas Mohanty309cf662011-02-11 00:05:42 +0530898
899#if defined(CONFIG_GPIO_PCA953X)
900struct ov5650_gpios {
901 const char *name;
902 int gpio;
903 int enabled;
904};
905
906#define OV5650_GPIO(_name, _gpio, _enabled) \
907 { \
908 .name = _name, \
909 .gpio = _gpio, \
910 .enabled = _enabled, \
911 }
912
913static struct ov5650_gpios ov5650_gpio_keys[] = {
914 [0] = OV5650_GPIO("cam1_pwdn", CAM1_PWR_DN_GPIO, 0),
915 [1] = OV5650_GPIO("cam1_rst_lo", CAM1_RST_L_GPIO, 1),
Prayas Mohantybd027672011-06-22 16:35:43 +0530916 [2] = OV5650_GPIO("cam1_af_pwdn_lo", CAM1_AF_PWR_DN_L_GPIO, 0),
Prayas Mohanty309cf662011-02-11 00:05:42 +0530917 [3] = OV5650_GPIO("cam1_ldo_shdn_lo", CAM1_LDO_SHUTDN_L_GPIO, 1),
918 [4] = OV5650_GPIO("cam2_pwdn", CAM2_PWR_DN_GPIO, 0),
919 [5] = OV5650_GPIO("cam2_rst_lo", CAM2_RST_L_GPIO, 1),
Prayas Mohantybd027672011-06-22 16:35:43 +0530920 [6] = OV5650_GPIO("cam2_af_pwdn_lo", CAM2_AF_PWR_DN_L_GPIO, 0),
Prayas Mohanty309cf662011-02-11 00:05:42 +0530921 [7] = OV5650_GPIO("cam2_ldo_shdn_lo", CAM2_LDO_SHUTDN_L_GPIO, 1),
922 [8] = OV5650_GPIO("cam3_pwdn", CAM_FRONT_PWR_DN_GPIO, 0),
923 [9] = OV5650_GPIO("cam3_rst_lo", CAM_FRONT_RST_L_GPIO, 1),
Prayas Mohantybd027672011-06-22 16:35:43 +0530924 [10] = OV5650_GPIO("cam3_af_pwdn_lo", CAM_FRONT_AF_PWR_DN_L_GPIO, 0),
Prayas Mohanty309cf662011-02-11 00:05:42 +0530925 [11] = OV5650_GPIO("cam3_ldo_shdn_lo", CAM_FRONT_LDO_SHUTDN_L_GPIO, 1),
926 [12] = OV5650_GPIO("cam_led_exp", CAM_FRONT_LED_EXP, 1),
927 [13] = OV5650_GPIO("cam_led_rear_exp", CAM_SNN_LED_REAR_EXP, 1),
928 [14] = OV5650_GPIO("cam_i2c_mux_rst", CAM_I2C_MUX_RST_EXP, 1),
929};
930
931int __init cardhu_ov5650_late_init(void)
932{
933 int ret;
934 int i;
935
Dan Willemsena4f6c552011-10-24 14:32:09 -0700936 if (!machine_is_cardhu())
937 return 0;
938
Abhiruchi Birajdarbb5f1a92011-06-08 19:36:37 +0530939 if ((board_info.board_id == BOARD_E1198) ||
940 (board_info.board_id == BOARD_E1291))
941 return 0;
942
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530943 printk("%s: \n", __func__);
Prayas Mohanty309cf662011-02-11 00:05:42 +0530944 for (i = 0; i < ARRAY_SIZE(ov5650_gpio_keys); i++) {
945 ret = gpio_request(ov5650_gpio_keys[i].gpio,
946 ov5650_gpio_keys[i].name);
947 if (ret < 0) {
948 printk("%s: gpio_request failed for gpio #%d\n",
949 __func__, i);
950 goto fail;
951 }
Prayas Mohanty98a127e2011-04-13 12:30:56 +0530952 printk("%s: enable - %d\n", __func__, i);
Prayas Mohanty309cf662011-02-11 00:05:42 +0530953 gpio_direction_output(ov5650_gpio_keys[i].gpio,
954 ov5650_gpio_keys[i].enabled);
955 gpio_export(ov5650_gpio_keys[i].gpio, false);
956 }
957
958 return 0;
959
960fail:
961 while (i--)
962 gpio_free(ov5650_gpio_keys[i].gpio);
963 return ret;
964}
965
966late_initcall(cardhu_ov5650_late_init);
967#endif