Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/i2c.h> |
| 14 | #include <linux/i2c/sx150x.h> |
| 15 | #include <linux/gpio.h> |
| 16 | #include <linux/regulator/consumer.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/platform_device.h> |
| 19 | #include <asm/mach-types.h> |
| 20 | #include <mach/msm_iomap.h> |
| 21 | #include <mach/board.h> |
| 22 | #include <mach/irqs-7xxx.h> |
| 23 | #include "devices-msm7x2xa.h" |
| 24 | #include "board-msm7627a.h" |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 25 | #include <mach/vreg.h> |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 26 | |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 27 | #define GPIO_SKU1_CAM_VGA_SHDN 18 |
| 28 | #define GPIO_SKU1_CAM_VGA_RESET_N 29 |
| 29 | #define GPIO_SKU3_CAM_5MP_SHDN_N 5 /* PWDN */ |
| 30 | #define GPIO_SKU3_CAM_5MP_CAMIF_RESET 6 /* (board_is(EVT))?123:121 RESET */ |
| 31 | #define GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN 30 |
| 32 | |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 33 | #ifdef CONFIG_MSM_CAMERA_V4L2 |
| 34 | static uint32_t camera_off_gpio_table[] = { |
| 35 | GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 36 | }; |
| 37 | |
| 38 | static uint32_t camera_on_gpio_table[] = { |
| 39 | GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 40 | }; |
| 41 | |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 42 | static struct gpio s5k4e1_cam_req_gpio[] = { |
| 43 | {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_DIR_OUT, "CAM_RESET"}, |
| 44 | }; |
| 45 | |
| 46 | static struct msm_gpio_set_tbl s5k4e1_cam_gpio_set_tbl[] = { |
| 47 | {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_LOW, 1000}, |
| 48 | {GPIO_CAM_GP_CAMIF_RESET_N, GPIOF_OUT_INIT_HIGH, 4000}, |
| 49 | }; |
| 50 | |
| 51 | static struct msm_camera_gpio_conf gpio_conf_s5k4e1 = { |
| 52 | .camera_off_table = camera_off_gpio_table, |
| 53 | .camera_off_table_size = ARRAY_SIZE(camera_off_gpio_table), |
| 54 | .camera_on_table = camera_on_gpio_table, |
| 55 | .camera_on_table_size = ARRAY_SIZE(camera_on_gpio_table), |
| 56 | .cam_gpio_req_tbl = s5k4e1_cam_req_gpio, |
| 57 | .cam_gpio_req_tbl_size = ARRAY_SIZE(s5k4e1_cam_req_gpio), |
| 58 | .cam_gpio_set_tbl = s5k4e1_cam_gpio_set_tbl, |
| 59 | .cam_gpio_set_tbl_size = ARRAY_SIZE(s5k4e1_cam_gpio_set_tbl), |
| 60 | .gpio_no_mux = 1, |
| 61 | }; |
| 62 | |
| 63 | static struct msm_camera_gpio_conf gpio_conf_mt9e013 = { |
| 64 | .camera_off_table = camera_off_gpio_table, |
| 65 | .camera_on_table = camera_on_gpio_table, |
| 66 | .gpio_no_mux = 1, |
| 67 | }; |
| 68 | |
| 69 | static struct msm_camera_gpio_conf gpio_conf_ov9726 = { |
| 70 | .camera_off_table = camera_off_gpio_table, |
| 71 | .camera_on_table = camera_on_gpio_table, |
| 72 | .gpio_no_mux = 1, |
| 73 | }; |
| 74 | |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 75 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 76 | static struct msm_camera_gpio_conf gpio_conf_ov7692 = { |
| 77 | .camera_off_table = camera_off_gpio_table, |
| 78 | .camera_on_table = camera_on_gpio_table, |
| 79 | .gpio_no_mux = 1, |
| 80 | }; |
| 81 | #endif |
| 82 | |
| 83 | #ifdef CONFIG_OV5647 |
| 84 | static struct msm_camera_gpio_conf gpio_conf_ov5647 = { |
| 85 | .camera_off_table = camera_off_gpio_table, |
| 86 | .camera_on_table = camera_on_gpio_table, |
| 87 | .gpio_no_mux = 1, |
| 88 | }; |
| 89 | #endif |
| 90 | |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 91 | #ifdef CONFIG_MSM_CAMERA_FLASH |
| 92 | static struct msm_camera_sensor_flash_src msm_flash_src = { |
| 93 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT, |
| 94 | ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1, |
| 95 | ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2, |
| 96 | }; |
| 97 | #endif |
| 98 | |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 99 | static struct camera_vreg_t msm_cam_vreg[] = { |
| 100 | {"msme1", REG_LDO, 1800000, 1800000, 0}, |
| 101 | {"gp2", REG_LDO, 2850000, 2850000, 0}, |
| 102 | {"usb2", REG_LDO, 1800000, 1800000, 0}, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 103 | }; |
| 104 | |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 105 | static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data; |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 106 | |
| 107 | struct msm_camera_device_platform_data msm_camera_device_data_csi1 = { |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 108 | .csid_core = 1, |
| 109 | .is_csic = 1, |
| 110 | }; |
| 111 | |
| 112 | struct msm_camera_device_platform_data msm_camera_device_data_csi0 = { |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 113 | .csid_core = 0, |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 114 | .is_csic = 1, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 115 | }; |
| 116 | |
| 117 | #ifdef CONFIG_DW9712_ACT |
| 118 | static struct i2c_board_info s5k4e1_actuator_i2c_info = { |
| 119 | I2C_BOARD_INFO("dw9712_act", 0x8C >> 1), |
| 120 | }; |
| 121 | |
| 122 | static struct msm_actuator_info s5k4e1_actuator_info = { |
| 123 | .board_info = &s5k4e1_actuator_i2c_info, |
| 124 | .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID, |
| 125 | .vcm_pwd = GPIO_CAM_GP_CAM_PWDN, |
| 126 | .vcm_enable = 1, |
| 127 | }; |
| 128 | #endif |
| 129 | |
| 130 | #ifdef CONFIG_S5K4E1 |
| 131 | static struct msm_camera_sensor_flash_data flash_s5k4e1 = { |
| 132 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 133 | .flash_src = &msm_flash_src |
| 134 | }; |
| 135 | |
| 136 | static struct msm_camera_sensor_platform_info sensor_board_info_s5k4e1 = { |
| 137 | .mount_angle = 90, |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 138 | .cam_vreg = msm_cam_vreg, |
| 139 | .num_vreg = ARRAY_SIZE(msm_cam_vreg), |
| 140 | .gpio_conf = &gpio_conf_s5k4e1, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = { |
| 144 | .sensor_name = "s5k4e1", |
| 145 | .sensor_reset_enable = 1, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 146 | .pmic_gpio_enable = 0, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 147 | .pdata = &msm_camera_device_data_csi1, |
| 148 | .flash_data = &flash_s5k4e1, |
| 149 | .sensor_platform_info = &sensor_board_info_s5k4e1, |
| 150 | .csi_if = 1, |
| 151 | .camera_type = BACK_CAMERA_2D, |
| 152 | #ifdef CONFIG_DW9712_ACT |
| 153 | .actuator_info = &s5k4e1_actuator_info |
| 154 | #endif |
| 155 | }; |
| 156 | #endif |
| 157 | |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 158 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 159 | static struct msm_camera_sensor_platform_info sensor_board_info_ov7692 = { |
| 160 | .mount_angle = 90, |
| 161 | .cam_vreg = msm_cam_vreg, |
| 162 | .num_vreg = ARRAY_SIZE(msm_cam_vreg), |
| 163 | .gpio_conf = &gpio_conf_ov7692, |
| 164 | }; |
| 165 | |
| 166 | static struct msm_camera_sensor_flash_data flash_ov7692 = { |
| 167 | .flash_type = MSM_CAMERA_FLASH_NONE, |
| 168 | }; |
| 169 | |
| 170 | static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = { |
| 171 | .sensor_name = "ov7692", |
| 172 | .sensor_reset_enable = 0, |
| 173 | .pmic_gpio_enable = 1, |
| 174 | .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N, |
| 175 | .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN, |
| 176 | .pdata = &msm_camera_device_data_csi0, |
| 177 | .flash_data = &flash_ov7692, |
| 178 | .sensor_platform_info = &sensor_board_info_ov7692, |
| 179 | .csi_if = 1, |
| 180 | .camera_type = FRONT_CAMERA_2D, |
| 181 | }; |
| 182 | #endif |
| 183 | |
| 184 | #ifdef CONFIG_OV5647 |
| 185 | |
| 186 | #ifdef CONFIG_AD5046_ACT |
| 187 | static struct i2c_board_info ad5046_actuator_i2c_info = { |
| 188 | I2C_BOARD_INFO("ad5046_act", 0x18 >> 1), |
| 189 | }; |
| 190 | |
| 191 | static struct msm_actuator_info ad5046_actuator_info = { |
| 192 | .board_info = &ad5046_actuator_i2c_info, |
| 193 | .bus_id = MSM_GSBI0_QUP_I2C_BUS_ID, |
| 194 | .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN, |
| 195 | .vcm_enable = 1, |
| 196 | }; |
| 197 | #endif |
| 198 | |
| 199 | static struct msm_camera_sensor_platform_info sensor_board_info_ov5647 = { |
| 200 | .mount_angle = 90, |
| 201 | .cam_vreg = msm_cam_vreg, |
| 202 | .num_vreg = ARRAY_SIZE(msm_cam_vreg), |
| 203 | .gpio_conf = &gpio_conf_ov5647, |
| 204 | }; |
| 205 | |
| 206 | static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = { |
| 207 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED, |
| 208 | ._fsrc.led_src.led_name = "flashlight", |
| 209 | ._fsrc.led_src.led_name_len = 10, |
| 210 | }; |
| 211 | |
| 212 | static struct msm_camera_sensor_flash_data flash_ov5647 = { |
| 213 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 214 | .flash_src = &msm_flash_src_ov5647, |
| 215 | }; |
| 216 | |
| 217 | static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = { |
| 218 | .sensor_name = "ov5647", |
| 219 | .sensor_reset_enable = 1, |
| 220 | .pmic_gpio_enable = 1, |
| 221 | .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET, |
| 222 | .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N, |
| 223 | .pdata = &msm_camera_device_data_csi1, |
| 224 | .flash_data = &flash_ov5647, |
| 225 | .sensor_platform_info = &sensor_board_info_ov5647, |
| 226 | .csi_if = 1, |
| 227 | .camera_type = BACK_CAMERA_2D, |
| 228 | |
| 229 | #ifdef CONFIG_AD5046_ACT |
| 230 | .actuator_info = &ad5046_actuator_info |
| 231 | #endif |
| 232 | }; |
| 233 | |
| 234 | #endif |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 235 | #ifdef CONFIG_MT9E013 |
| 236 | static struct msm_camera_sensor_flash_data flash_mt9e013 = { |
| 237 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 238 | .flash_src = &msm_flash_src |
| 239 | }; |
| 240 | |
| 241 | static struct msm_camera_sensor_platform_info sensor_board_info_mt9e013 = { |
| 242 | .mount_angle = 90, |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 243 | .cam_vreg = msm_cam_vreg, |
| 244 | .num_vreg = ARRAY_SIZE(msm_cam_vreg), |
| 245 | .gpio_conf = &gpio_conf_mt9e013, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = { |
| 249 | .sensor_name = "mt9e013", |
| 250 | .sensor_reset_enable = 1, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 251 | .pmic_gpio_enable = 0, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 252 | .pdata = &msm_camera_device_data_csi1, |
| 253 | .flash_data = &flash_mt9e013, |
| 254 | .sensor_platform_info = &sensor_board_info_mt9e013, |
| 255 | .csi_if = 1, |
| 256 | .camera_type = BACK_CAMERA_2D, |
| 257 | }; |
| 258 | #endif |
| 259 | |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 260 | #ifdef CONFIG_WEBCAM_OV9726 |
| 261 | static struct msm_camera_sensor_flash_data flash_ov9726 = { |
| 262 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 263 | .flash_src = &msm_flash_src |
| 264 | }; |
| 265 | |
| 266 | static struct msm_camera_sensor_platform_info sensor_board_info_ov9726 = { |
| 267 | .mount_angle = 90, |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 268 | .cam_vreg = msm_cam_vreg, |
| 269 | .num_vreg = ARRAY_SIZE(msm_cam_vreg), |
| 270 | .gpio_conf = &gpio_conf_ov9726, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = { |
| 274 | .sensor_name = "ov9726", |
| 275 | .sensor_reset_enable = 0, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 276 | .pmic_gpio_enable = 0, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 277 | .pdata = &msm_camera_device_data_csi0, |
| 278 | .flash_data = &flash_ov9726, |
| 279 | .sensor_platform_info = &sensor_board_info_ov9726, |
| 280 | .csi_if = 1, |
| 281 | .camera_type = FRONT_CAMERA_2D, |
| 282 | }; |
| 283 | #endif |
| 284 | |
| 285 | static void __init msm7x27a_init_cam(void) |
| 286 | { |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 287 | if (!(machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() |
| 288 | || machine_is_msm7627a_qrd1())) { |
| 289 | sensor_board_info_s5k4e1.cam_vreg = NULL; |
| 290 | sensor_board_info_s5k4e1.num_vreg = 0; |
| 291 | sensor_board_info_mt9e013.cam_vreg = NULL; |
| 292 | sensor_board_info_mt9e013.num_vreg = 0; |
| 293 | sensor_board_info_ov9726.cam_vreg = NULL; |
| 294 | sensor_board_info_ov9726.num_vreg = 0; |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 295 | sensor_board_info_ov7692.cam_vreg = NULL; |
| 296 | sensor_board_info_ov7692.num_vreg = 0; |
| 297 | sensor_board_info_ov5647.cam_vreg = NULL; |
| 298 | sensor_board_info_ov5647.num_vreg = 0; |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 299 | } |
Raju P.L.S.S.S.N | 2b34501 | 2012-03-15 10:18:30 +0530 | [diff] [blame^] | 300 | if (machine_is_msm8625_surf() || machine_is_msm8625_evb()) { |
| 301 | platform_device_register(&msm8625_device_csic0); |
| 302 | platform_device_register(&msm8625_device_csic1); |
| 303 | } else { |
| 304 | platform_device_register(&msm7x27a_device_csic0); |
| 305 | platform_device_register(&msm7x27a_device_csic1); |
| 306 | } |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 307 | platform_device_register(&msm7x27a_device_clkctl); |
| 308 | platform_device_register(&msm7x27a_device_vfe); |
| 309 | } |
| 310 | |
| 311 | static struct i2c_board_info i2c_camera_devices[] = { |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 312 | { |
| 313 | I2C_BOARD_INFO("s5k4e1", 0x36), |
| 314 | .platform_data = &msm_camera_sensor_s5k4e1_data, |
| 315 | }, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 316 | { |
| 317 | I2C_BOARD_INFO("ov9726", 0x10), |
| 318 | .platform_data = &msm_camera_sensor_ov9726_data, |
| 319 | }, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 320 | { |
| 321 | I2C_BOARD_INFO("mt9e013", 0x6C >> 2), |
| 322 | .platform_data = &msm_camera_sensor_mt9e013_data, |
| 323 | }, |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 324 | { |
| 325 | I2C_BOARD_INFO("ov7692", 0x78), |
| 326 | .platform_data = &msm_camera_sensor_ov7692_data, |
| 327 | }, |
| 328 | { |
| 329 | I2C_BOARD_INFO("ov5647", 0x36 << 1), |
| 330 | .platform_data = &msm_camera_sensor_ov5647_data, |
| 331 | }, |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 332 | { |
| 333 | I2C_BOARD_INFO("sc628a", 0x6E), |
| 334 | }, |
| 335 | }; |
| 336 | #else |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 337 | static uint32_t camera_off_gpio_table[] = { |
| 338 | GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 339 | }; |
| 340 | |
| 341 | static uint32_t camera_on_gpio_table[] = { |
| 342 | GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 343 | }; |
| 344 | |
| 345 | #ifdef CONFIG_MSM_CAMERA_FLASH |
| 346 | static struct msm_camera_sensor_flash_src msm_flash_src = { |
| 347 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT, |
| 348 | ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1, |
| 349 | ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2, |
| 350 | }; |
| 351 | #endif |
| 352 | |
| 353 | static struct regulator_bulk_data regs_camera[] = { |
| 354 | { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 }, |
| 355 | { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 356 | { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 }, |
| 357 | }; |
| 358 | |
| 359 | static void qrd1_camera_gpio_cfg(void) |
| 360 | { |
| 361 | |
| 362 | int rc = 0; |
| 363 | |
| 364 | rc = gpio_request(QRD_GPIO_CAM_5MP_SHDN_EN, "ov5640"); |
| 365 | if (rc < 0) |
| 366 | pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!", |
| 367 | __func__); |
| 368 | |
| 369 | |
| 370 | rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_SHDN_EN, 0, |
| 371 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 372 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 373 | if (rc < 0) { |
| 374 | pr_err("%s: unable to enable Power Down gpio for main" |
| 375 | "camera!\n", __func__); |
| 376 | gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN); |
| 377 | } |
| 378 | |
| 379 | |
| 380 | rc = gpio_request(QRD_GPIO_CAM_5MP_RESET, "ov5640"); |
| 381 | if (rc < 0) { |
| 382 | pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!", |
| 383 | __func__); |
| 384 | gpio_free(QRD_GPIO_CAM_5MP_SHDN_EN); |
| 385 | } |
| 386 | |
| 387 | |
| 388 | rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_5MP_RESET, 0, |
| 389 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 390 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 391 | if (rc < 0) { |
| 392 | pr_err("%s: unable to enable reset gpio for main camera!\n", |
| 393 | __func__); |
| 394 | gpio_free(QRD_GPIO_CAM_5MP_RESET); |
| 395 | } |
| 396 | |
| 397 | rc = gpio_request(QRD_GPIO_CAM_3MP_PWDN, "ov7692"); |
| 398 | if (rc < 0) |
| 399 | pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!", |
| 400 | __func__); |
| 401 | |
| 402 | rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_CAM_3MP_PWDN, 0, |
| 403 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 404 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 405 | if (rc < 0) { |
| 406 | pr_err("%s: unable to enable Power Down gpio for front" |
| 407 | "camera!\n", __func__); |
| 408 | gpio_free(QRD_GPIO_CAM_3MP_PWDN); |
| 409 | } |
| 410 | |
| 411 | gpio_direction_output(QRD_GPIO_CAM_5MP_SHDN_EN, 1); |
| 412 | gpio_direction_output(QRD_GPIO_CAM_5MP_RESET, 1); |
| 413 | gpio_direction_output(QRD_GPIO_CAM_3MP_PWDN, 1); |
| 414 | } |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 415 | #endif |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 416 | |
| 417 | static void evb_camera_gpio_cfg(void) |
| 418 | { |
| 419 | int rc = 0; |
| 420 | |
| 421 | rc = gpio_request(GPIO_SKU3_CAM_5MP_SHDN_N, "ov5647"); |
| 422 | if (rc < 0) |
| 423 | pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_SHDN_N failed!", |
| 424 | __func__); |
| 425 | |
| 426 | pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_SHDN_N); |
| 427 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_SHDN_N, 0, |
| 428 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, |
| 429 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 430 | if (rc < 0) { |
| 431 | pr_err("%s:unable to enable Powr Dwn gpio for main camera!\n", |
| 432 | __func__); |
| 433 | gpio_free(GPIO_SKU3_CAM_5MP_SHDN_N); |
| 434 | } |
| 435 | |
| 436 | gpio_direction_output(GPIO_SKU3_CAM_5MP_SHDN_N, 1); |
| 437 | |
| 438 | rc = gpio_request(GPIO_SKU3_CAM_5MP_CAMIF_RESET, "ov5647"); |
| 439 | if (rc < 0) |
| 440 | pr_err("%s: gpio_request GPIO_SKU3_CAM_5MP_CAMIF_RESET failed!", |
| 441 | __func__); |
| 442 | |
| 443 | pr_debug("gpio_tlmm_config %d\r\n", GPIO_SKU3_CAM_5MP_CAMIF_RESET); |
| 444 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 0, |
| 445 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, |
| 446 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 447 | if (rc < 0) { |
| 448 | pr_err("%s: unable to enable reset gpio for main camera!\n", |
| 449 | __func__); |
| 450 | gpio_free(GPIO_SKU3_CAM_5MP_CAMIF_RESET); |
| 451 | } |
| 452 | |
| 453 | gpio_direction_output(GPIO_SKU3_CAM_5MP_CAMIF_RESET, 1); |
| 454 | |
| 455 | rc = gpio_request(GPIO_SKU1_CAM_VGA_SHDN, "ov7692"); |
| 456 | if (rc < 0) |
| 457 | pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_SHDN failed!", |
| 458 | __func__); |
| 459 | |
| 460 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_SHDN, 0, |
| 461 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 462 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 463 | if (rc < 0) { |
| 464 | pr_err("%s:unable to enable Powr Dwn gpio for frnt camera!\n", |
| 465 | __func__); |
| 466 | gpio_free(GPIO_SKU1_CAM_VGA_SHDN); |
| 467 | } |
| 468 | |
| 469 | gpio_direction_output(GPIO_SKU1_CAM_VGA_SHDN, 1); |
| 470 | |
| 471 | rc = gpio_request(GPIO_SKU1_CAM_VGA_RESET_N, "ov7692"); |
| 472 | if (rc < 0) |
| 473 | pr_err("%s: gpio_request---GPIO_SKU1_CAM_VGA_RESET_N failed!", |
| 474 | __func__); |
| 475 | |
| 476 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_SKU1_CAM_VGA_RESET_N, 0, |
| 477 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 478 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 479 | |
| 480 | if (rc < 0) { |
| 481 | pr_err("%s: unable to enable reset gpio for front camera!\n", |
| 482 | __func__); |
| 483 | gpio_free(GPIO_SKU1_CAM_VGA_RESET_N); |
| 484 | } |
| 485 | gpio_direction_output(GPIO_SKU1_CAM_VGA_RESET_N, 1); |
| 486 | |
| 487 | } |
| 488 | |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 489 | #ifndef CONFIG_MSM_CAMERA_V4L2 |
| 490 | |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 491 | static void msm_camera_vreg_config(int vreg_en) |
| 492 | { |
| 493 | int rc = vreg_en ? |
| 494 | regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) : |
| 495 | regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera); |
| 496 | |
| 497 | if (rc) |
| 498 | pr_err("%s: could not %sable regulators: %d\n", |
| 499 | __func__, vreg_en ? "en" : "dis", rc); |
| 500 | } |
| 501 | |
| 502 | static int config_gpio_table(uint32_t *table, int len) |
| 503 | { |
| 504 | int rc = 0, i = 0; |
| 505 | |
| 506 | for (i = 0; i < len; i++) { |
| 507 | rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE); |
| 508 | if (rc) { |
| 509 | pr_err("%s not able to get gpio\n", __func__); |
| 510 | for (i--; i >= 0; i--) |
| 511 | gpio_tlmm_config(camera_off_gpio_table[i], |
| 512 | GPIO_CFG_ENABLE); |
| 513 | break; |
| 514 | } |
| 515 | } |
| 516 | return rc; |
| 517 | } |
| 518 | |
| 519 | static int config_camera_on_gpios_rear(void) |
| 520 | { |
| 521 | int rc = 0; |
| 522 | |
| 523 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() |
| 524 | || machine_is_msm7627a_qrd1()) |
| 525 | msm_camera_vreg_config(1); |
| 526 | |
| 527 | rc = config_gpio_table(camera_on_gpio_table, |
| 528 | ARRAY_SIZE(camera_on_gpio_table)); |
| 529 | if (rc < 0) { |
| 530 | pr_err("%s: CAMSENSOR gpio table request" |
| 531 | "failed\n", __func__); |
| 532 | return rc; |
| 533 | } |
| 534 | |
| 535 | return rc; |
| 536 | } |
| 537 | |
| 538 | static void config_camera_off_gpios_rear(void) |
| 539 | { |
| 540 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() |
| 541 | || machine_is_msm7627a_qrd1()) |
| 542 | msm_camera_vreg_config(0); |
| 543 | |
| 544 | config_gpio_table(camera_off_gpio_table, |
| 545 | ARRAY_SIZE(camera_off_gpio_table)); |
| 546 | } |
| 547 | |
| 548 | static int config_camera_on_gpios_front(void) |
| 549 | { |
| 550 | int rc = 0; |
| 551 | |
| 552 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() |
| 553 | || machine_is_msm7627a_qrd1()) |
| 554 | msm_camera_vreg_config(1); |
| 555 | |
| 556 | rc = config_gpio_table(camera_on_gpio_table, |
| 557 | ARRAY_SIZE(camera_on_gpio_table)); |
| 558 | if (rc < 0) { |
| 559 | pr_err("%s: CAMSENSOR gpio table request" |
| 560 | "failed\n", __func__); |
| 561 | return rc; |
| 562 | } |
| 563 | |
| 564 | return rc; |
| 565 | } |
| 566 | |
| 567 | static void config_camera_off_gpios_front(void) |
| 568 | { |
| 569 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() |
| 570 | || machine_is_msm7627a_qrd1()) |
| 571 | msm_camera_vreg_config(0); |
| 572 | |
| 573 | config_gpio_table(camera_off_gpio_table, |
| 574 | ARRAY_SIZE(camera_off_gpio_table)); |
| 575 | } |
| 576 | |
| 577 | struct msm_camera_device_platform_data msm_camera_device_data_rear = { |
| 578 | .camera_gpio_on = config_camera_on_gpios_rear, |
| 579 | .camera_gpio_off = config_camera_off_gpios_rear, |
| 580 | .ioext.csiphy = 0xA1000000, |
| 581 | .ioext.csisz = 0x00100000, |
| 582 | .ioext.csiirq = INT_CSI_IRQ_1, |
| 583 | .ioclk.mclk_clk_rate = 24000000, |
| 584 | .ioclk.vfe_clk_rate = 192000000, |
Taniya Das | 13b811a | 2011-12-09 18:33:45 +0530 | [diff] [blame] | 585 | .ioext.appphy = MSM7XXX_CLK_CTL_PHYS, |
| 586 | .ioext.appsz = MSM7XXX_CLK_CTL_SIZE, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 587 | }; |
| 588 | |
| 589 | struct msm_camera_device_platform_data msm_camera_device_data_front = { |
| 590 | .camera_gpio_on = config_camera_on_gpios_front, |
| 591 | .camera_gpio_off = config_camera_off_gpios_front, |
| 592 | .ioext.csiphy = 0xA0F00000, |
| 593 | .ioext.csisz = 0x00100000, |
| 594 | .ioext.csiirq = INT_CSI_IRQ_0, |
| 595 | .ioclk.mclk_clk_rate = 24000000, |
| 596 | .ioclk.vfe_clk_rate = 192000000, |
Taniya Das | 13b811a | 2011-12-09 18:33:45 +0530 | [diff] [blame] | 597 | .ioext.appphy = MSM7XXX_CLK_CTL_PHYS, |
| 598 | .ioext.appsz = MSM7XXX_CLK_CTL_SIZE, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 599 | }; |
| 600 | |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 601 | #ifdef CONFIG_OV5647 |
| 602 | |
| 603 | static struct msm_camera_sensor_platform_info ov5647_sensor_7627a_info = { |
| 604 | .mount_angle = 90 |
| 605 | }; |
| 606 | |
| 607 | static struct msm_camera_sensor_flash_src msm_flash_src_ov5647 = { |
| 608 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED, |
| 609 | ._fsrc.led_src.led_name = "flashlight", |
| 610 | ._fsrc.led_src.led_name_len = 10, |
| 611 | }; |
| 612 | |
| 613 | static struct msm_camera_sensor_flash_data flash_ov5647 = { |
| 614 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 615 | .flash_src = &msm_flash_src_ov5647, |
| 616 | }; |
| 617 | |
| 618 | static struct msm_camera_sensor_info msm_camera_sensor_ov5647_data = { |
| 619 | .sensor_name = "ov5647", |
| 620 | .sensor_reset_enable = 1, |
| 621 | .sensor_reset = GPIO_SKU3_CAM_5MP_CAMIF_RESET, |
| 622 | .pmic_gpio_enable = 1, |
| 623 | .sensor_pwd = GPIO_SKU3_CAM_5MP_SHDN_N, |
| 624 | .vcm_pwd = GPIO_SKU3_CAM_5MP_CAM_DRIVER_PWDN, |
Lokesh Kumar Aakulu | fe9c3ec | 2012-02-22 19:26:29 +0530 | [diff] [blame] | 625 | .vcm_enable = 1, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 626 | .pdata = &msm_camera_device_data_rear, |
| 627 | .flash_data = &flash_ov5647, |
| 628 | .sensor_platform_info = &ov5647_sensor_7627a_info, |
| 629 | .csi_if = 1 |
| 630 | }; |
| 631 | |
| 632 | static struct platform_device msm_camera_sensor_ov5647 = { |
| 633 | .name = "msm_camera_ov5647", |
| 634 | .dev = { |
| 635 | .platform_data = &msm_camera_sensor_ov5647_data, |
| 636 | }, |
| 637 | }; |
| 638 | #endif |
| 639 | |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 640 | #ifdef CONFIG_S5K4E1 |
| 641 | static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = { |
| 642 | .mount_angle = 90 |
| 643 | }; |
| 644 | |
| 645 | static struct msm_camera_sensor_flash_data flash_s5k4e1 = { |
| 646 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 647 | .flash_src = &msm_flash_src |
| 648 | }; |
| 649 | |
| 650 | static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = { |
| 651 | .sensor_name = "s5k4e1", |
| 652 | .sensor_reset_enable = 1, |
| 653 | .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 654 | .pmic_gpio_enable = 0, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 655 | .sensor_pwd = 85, |
| 656 | .vcm_pwd = GPIO_CAM_GP_CAM_PWDN, |
| 657 | .vcm_enable = 1, |
| 658 | .pdata = &msm_camera_device_data_rear, |
| 659 | .flash_data = &flash_s5k4e1, |
| 660 | .sensor_platform_info = &s5k4e1_sensor_7627a_info, |
| 661 | .csi_if = 1 |
| 662 | }; |
| 663 | |
| 664 | static struct platform_device msm_camera_sensor_s5k4e1 = { |
| 665 | .name = "msm_camera_s5k4e1", |
| 666 | .dev = { |
| 667 | .platform_data = &msm_camera_sensor_s5k4e1_data, |
| 668 | }, |
| 669 | }; |
| 670 | #endif |
| 671 | |
| 672 | #ifdef CONFIG_IMX072 |
| 673 | static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = { |
| 674 | .mount_angle = 90 |
| 675 | }; |
| 676 | |
| 677 | static struct msm_camera_sensor_flash_data flash_imx072 = { |
| 678 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 679 | .flash_src = &msm_flash_src |
| 680 | }; |
| 681 | |
| 682 | static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = { |
| 683 | .sensor_name = "imx072", |
| 684 | .sensor_reset_enable = 1, |
| 685 | .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/ |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 686 | .pmic_gpio_enable = 0, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 687 | .sensor_pwd = 85, |
| 688 | .vcm_pwd = GPIO_CAM_GP_CAM_PWDN, |
| 689 | .vcm_enable = 1, |
| 690 | .pdata = &msm_camera_device_data_rear, |
| 691 | .flash_data = &flash_imx072, |
| 692 | .sensor_platform_info = &imx072_sensor_7627a_info, |
| 693 | .csi_if = 1 |
| 694 | }; |
| 695 | |
| 696 | static struct platform_device msm_camera_sensor_imx072 = { |
| 697 | .name = "msm_camera_imx072", |
| 698 | .dev = { |
| 699 | .platform_data = &msm_camera_sensor_imx072_data, |
| 700 | }, |
| 701 | }; |
| 702 | #endif |
| 703 | |
| 704 | static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data; |
| 705 | #ifdef CONFIG_WEBCAM_OV9726 |
| 706 | static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = { |
| 707 | .mount_angle = 90 |
| 708 | }; |
| 709 | |
| 710 | static struct msm_camera_sensor_flash_data flash_ov9726 = { |
| 711 | .flash_type = MSM_CAMERA_FLASH_NONE, |
| 712 | .flash_src = &msm_flash_src |
| 713 | }; |
| 714 | |
| 715 | static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = { |
| 716 | .sensor_name = "ov9726", |
| 717 | .sensor_reset_enable = 0, |
| 718 | .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 719 | .pmic_gpio_enable = 0, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 720 | .sensor_pwd = 85, |
| 721 | .vcm_pwd = 1, |
| 722 | .vcm_enable = 0, |
| 723 | .pdata = &msm_camera_device_data_front, |
| 724 | .flash_data = &flash_ov9726, |
| 725 | .sensor_platform_info = &ov9726_sensor_7627a_info, |
| 726 | .csi_if = 1 |
| 727 | }; |
| 728 | |
| 729 | static struct platform_device msm_camera_sensor_ov9726 = { |
| 730 | .name = "msm_camera_ov9726", |
| 731 | .dev = { |
| 732 | .platform_data = &msm_camera_sensor_ov9726_data, |
| 733 | }, |
| 734 | }; |
| 735 | #else |
| 736 | static inline void msm_camera_vreg_init(void) { } |
| 737 | #endif |
| 738 | |
| 739 | #ifdef CONFIG_MT9E013 |
| 740 | static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = { |
| 741 | .mount_angle = 90 |
| 742 | }; |
| 743 | |
| 744 | static struct msm_camera_sensor_flash_data flash_mt9e013 = { |
| 745 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 746 | .flash_src = &msm_flash_src |
| 747 | }; |
| 748 | |
| 749 | static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = { |
| 750 | .sensor_name = "mt9e013", |
| 751 | .sensor_reset = 0, |
| 752 | .sensor_reset_enable = 1, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 753 | .pmic_gpio_enable = 0, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 754 | .sensor_pwd = 85, |
| 755 | .vcm_pwd = 1, |
| 756 | .vcm_enable = 0, |
| 757 | .pdata = &msm_camera_device_data_rear, |
| 758 | .flash_data = &flash_mt9e013, |
| 759 | .sensor_platform_info = &mt9e013_sensor_7627a_info, |
| 760 | .csi_if = 1 |
| 761 | }; |
| 762 | |
| 763 | static struct platform_device msm_camera_sensor_mt9e013 = { |
| 764 | .name = "msm_camera_mt9e013", |
| 765 | .dev = { |
| 766 | .platform_data = &msm_camera_sensor_mt9e013_data, |
| 767 | }, |
| 768 | }; |
| 769 | #endif |
| 770 | |
| 771 | #ifdef CONFIG_OV5640 |
| 772 | static struct msm_camera_sensor_platform_info ov5640_sensor_info = { |
| 773 | .mount_angle = 90 |
| 774 | }; |
| 775 | |
| 776 | static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = { |
| 777 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED, |
| 778 | ._fsrc.led_src.led_name = "flashlight", |
| 779 | ._fsrc.led_src.led_name_len = 10, |
| 780 | }; |
| 781 | |
| 782 | static struct msm_camera_sensor_flash_data flash_ov5640 = { |
| 783 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 784 | .flash_src = &msm_flash_src_ov5640, |
| 785 | }; |
| 786 | |
| 787 | static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = { |
| 788 | .sensor_name = "ov5640", |
| 789 | .sensor_reset_enable = 1, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 790 | .pmic_gpio_enable = 0, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 791 | .sensor_reset = QRD_GPIO_CAM_5MP_RESET, |
| 792 | .sensor_pwd = QRD_GPIO_CAM_5MP_SHDN_EN, |
| 793 | .vcm_pwd = 0, |
| 794 | .vcm_enable = 0, |
| 795 | .pdata = &msm_camera_device_data_rear, |
| 796 | .flash_data = &flash_ov5640, |
| 797 | .sensor_platform_info = &ov5640_sensor_info, |
| 798 | .csi_if = 1, |
| 799 | }; |
| 800 | |
| 801 | static struct platform_device msm_camera_sensor_ov5640 = { |
| 802 | .name = "msm_camera_ov5640", |
| 803 | .dev = { |
| 804 | .platform_data = &msm_camera_sensor_ov5640_data, |
| 805 | }, |
| 806 | }; |
| 807 | #endif |
| 808 | |
| 809 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 810 | static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = { |
| 811 | .mount_angle = 90 |
| 812 | }; |
| 813 | |
| 814 | static struct msm_camera_sensor_flash_data flash_ov7692 = { |
| 815 | .flash_type = MSM_CAMERA_FLASH_NONE, |
| 816 | }; |
| 817 | |
| 818 | static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = { |
| 819 | .sensor_name = "ov7692", |
| 820 | .sensor_reset_enable = 0, |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 821 | .pmic_gpio_enable = 1, |
| 822 | .sensor_reset = GPIO_SKU1_CAM_VGA_RESET_N, |
| 823 | .sensor_pwd = GPIO_SKU1_CAM_VGA_SHDN, |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 824 | .vcm_pwd = 0, |
| 825 | .vcm_enable = 0, |
| 826 | .pdata = &msm_camera_device_data_front, |
| 827 | .flash_data = &flash_ov7692, |
| 828 | .sensor_platform_info = &ov7692_sensor_7627a_info, |
| 829 | .csi_if = 1, |
| 830 | }; |
| 831 | |
| 832 | static struct platform_device msm_camera_sensor_ov7692 = { |
| 833 | .name = "msm_camera_ov7692", |
| 834 | .dev = { |
| 835 | .platform_data = &msm_camera_sensor_ov7692_data, |
| 836 | }, |
| 837 | }; |
| 838 | #endif |
| 839 | |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 840 | static struct i2c_board_info i2c_camera_devices[] = { |
| 841 | #ifdef CONFIG_S5K4E1 |
| 842 | { |
| 843 | I2C_BOARD_INFO("s5k4e1", 0x36), |
| 844 | }, |
| 845 | { |
| 846 | I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1), |
| 847 | }, |
| 848 | #endif |
| 849 | #ifdef CONFIG_WEBCAM_OV9726 |
| 850 | { |
| 851 | I2C_BOARD_INFO("ov9726", 0x10), |
| 852 | }, |
| 853 | #endif |
| 854 | #ifdef CONFIG_IMX072 |
| 855 | { |
| 856 | I2C_BOARD_INFO("imx072", 0x34), |
| 857 | }, |
| 858 | #endif |
| 859 | #ifdef CONFIG_MT9E013 |
| 860 | { |
| 861 | I2C_BOARD_INFO("mt9e013", 0x6C >> 2), |
| 862 | }, |
| 863 | #endif |
| 864 | { |
| 865 | I2C_BOARD_INFO("sc628a", 0x6E), |
| 866 | }, |
| 867 | }; |
| 868 | |
| 869 | static struct i2c_board_info i2c_camera_devices_qrd[] = { |
| 870 | #ifdef CONFIG_OV5640 |
| 871 | { |
| 872 | I2C_BOARD_INFO("ov5640", 0x78 >> 1), |
| 873 | }, |
| 874 | #endif |
| 875 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 876 | { |
| 877 | I2C_BOARD_INFO("ov7692", 0x78), |
| 878 | }, |
| 879 | #endif |
| 880 | }; |
| 881 | |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 882 | static struct i2c_board_info i2c_camera_devices_evb[] = { |
| 883 | #ifdef CONFIG_OV5647 |
| 884 | { |
| 885 | I2C_BOARD_INFO("ov5647", 0x36 << 1), |
| 886 | }, |
| 887 | { |
| 888 | I2C_BOARD_INFO("ov5647_af", 0x18 >> 1), |
| 889 | }, |
| 890 | #endif |
| 891 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 892 | { |
| 893 | I2C_BOARD_INFO("ov7692", 0x78), |
| 894 | }, |
| 895 | #endif |
| 896 | }; |
| 897 | |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 898 | static struct platform_device *camera_devices_msm[] __initdata = { |
| 899 | #ifdef CONFIG_S5K4E1 |
| 900 | &msm_camera_sensor_s5k4e1, |
| 901 | #endif |
| 902 | #ifdef CONFIG_IMX072 |
| 903 | &msm_camera_sensor_imx072, |
| 904 | #endif |
| 905 | #ifdef CONFIG_WEBCAM_OV9726 |
| 906 | &msm_camera_sensor_ov9726, |
| 907 | #endif |
| 908 | #ifdef CONFIG_MT9E013 |
| 909 | &msm_camera_sensor_mt9e013, |
| 910 | #endif |
| 911 | }; |
| 912 | |
| 913 | static struct platform_device *camera_devices_qrd[] __initdata = { |
| 914 | #ifdef CONFIG_OV5640 |
| 915 | &msm_camera_sensor_ov5640, |
| 916 | #endif |
| 917 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 918 | &msm_camera_sensor_ov7692, |
| 919 | #endif |
| 920 | }; |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 921 | |
| 922 | static struct platform_device *camera_devices_evb[] __initdata = { |
| 923 | #ifdef CONFIG_OV5647 |
| 924 | &msm_camera_sensor_ov5647, |
| 925 | #endif |
| 926 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 927 | &msm_camera_sensor_ov7692, |
| 928 | #endif |
| 929 | }; |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 930 | #endif |
| 931 | |
| 932 | enum { |
| 933 | SX150X_CAM, |
| 934 | }; |
| 935 | |
| 936 | static struct sx150x_platform_data sx150x_data[] __initdata = { |
| 937 | [SX150X_CAM] = { |
| 938 | .gpio_base = GPIO_CAM_EXPANDER_BASE, |
| 939 | .oscio_is_gpo = false, |
| 940 | .io_pullup_ena = 0, |
| 941 | .io_pulldn_ena = 0, |
| 942 | .io_open_drain_ena = 0x23, |
| 943 | .irq_summary = -1, |
| 944 | }, |
| 945 | }; |
| 946 | |
| 947 | static struct i2c_board_info cam_exp_i2c_info[] __initdata = { |
| 948 | { |
| 949 | I2C_BOARD_INFO("sx1508q", 0x22), |
| 950 | .platform_data = &sx150x_data[SX150X_CAM], |
| 951 | }, |
| 952 | }; |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 953 | |
| 954 | static void __init register_i2c_devices(void) |
| 955 | { |
| 956 | i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, |
| 957 | cam_exp_i2c_info, |
| 958 | ARRAY_SIZE(cam_exp_i2c_info)); |
| 959 | } |
| 960 | |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 961 | #define LCD_CAMERA_LDO_2V8 35 /* SKU1&SKU3 2.8V LDO */ |
| 962 | #define SKU3_LCD_CAMERA_LDO_1V8 40 /* SKU3 1.8V LDO */ |
| 963 | |
| 964 | static int lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; |
| 965 | |
| 966 | static void lcd_camera_power_init(void) |
| 967 | { |
| 968 | int rc = 0; |
| 969 | |
| 970 | pr_debug("lcd_camera_power_init\n"); |
| 971 | |
| 972 | lcd_camera_ldo_1v8 = SKU3_LCD_CAMERA_LDO_1V8; /* SKU3 PVT */ |
| 973 | |
| 974 | /* LDO_EXT2V8 */ |
| 975 | if (gpio_request(LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) { |
| 976 | pr_err("failed to request gpio lcd_camera_ldo_2v8\n"); |
| 977 | return; |
| 978 | } |
| 979 | |
| 980 | rc = gpio_tlmm_config(GPIO_CFG(LCD_CAMERA_LDO_2V8, 0, |
| 981 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, |
| 982 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 983 | if (rc < 0) { |
| 984 | pr_err("%s: unable to enable lcd_camera_ldo_2v8!\n", __func__); |
| 985 | goto fail_gpio2; |
| 986 | } |
| 987 | |
| 988 | /* LDO_EVT1V8 */ |
| 989 | if (gpio_request(lcd_camera_ldo_1v8, "lcd_camera_ldo_1v8")) { |
| 990 | pr_err("failed to request gpio lcd_camera_ldo_1v8\n"); |
| 991 | goto fail_gpio2; |
| 992 | } |
| 993 | |
| 994 | rc = gpio_tlmm_config(GPIO_CFG(lcd_camera_ldo_1v8, 0, |
| 995 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, |
| 996 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 997 | if (rc < 0) { |
| 998 | pr_err("%s: unable to enable lcd_camera_ldo_1v8!\n", __func__); |
| 999 | goto fail_gpio1; |
| 1000 | } |
| 1001 | |
| 1002 | return; |
| 1003 | |
| 1004 | fail_gpio1: |
| 1005 | gpio_free(lcd_camera_ldo_1v8); |
| 1006 | fail_gpio2: |
| 1007 | gpio_free(LCD_CAMERA_LDO_2V8); |
| 1008 | |
| 1009 | return; |
| 1010 | } |
| 1011 | |
| 1012 | static int lcd_camera_power_on_sku3(void) |
| 1013 | { |
| 1014 | int rc = 0; |
| 1015 | |
| 1016 | pr_debug("turn on sku3 lcd_camera_ldo_1v8\n"); |
| 1017 | gpio_set_value_cansleep(lcd_camera_ldo_1v8, 1); |
| 1018 | |
| 1019 | pr_debug("turn on sku3 lcd_camera_ldo\n"); |
| 1020 | gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 1); |
| 1021 | |
| 1022 | return rc; |
| 1023 | } |
| 1024 | |
| 1025 | static int lcd_camera_power_off_sku3(void) |
| 1026 | { |
| 1027 | int rc = 0; |
| 1028 | |
| 1029 | pr_debug("turn off sku3 lcd_camera_ldo_1v8\n"); |
| 1030 | gpio_set_value_cansleep(lcd_camera_ldo_1v8, 0); |
| 1031 | |
| 1032 | pr_debug("turn off sku3 lcd_camera_ldo\n"); |
| 1033 | gpio_set_value_cansleep(LCD_CAMERA_LDO_2V8, 0); |
| 1034 | |
| 1035 | gpio_free(lcd_camera_ldo_1v8); |
| 1036 | gpio_free(LCD_CAMERA_LDO_2V8); |
| 1037 | |
| 1038 | return rc; |
| 1039 | } |
| 1040 | |
| 1041 | int lcd_camera_power_onoff(int on) |
| 1042 | { |
| 1043 | int rc = 0; |
| 1044 | |
| 1045 | pr_debug("lcd_camera_power_onoff on = %d,\n", on); |
| 1046 | |
| 1047 | if (on) |
| 1048 | rc = lcd_camera_power_on_sku3(); |
| 1049 | else |
| 1050 | rc = lcd_camera_power_off_sku3(); |
| 1051 | |
| 1052 | return rc; |
| 1053 | } |
| 1054 | EXPORT_SYMBOL(lcd_camera_power_onoff); |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 1055 | |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1056 | void __init msm7627a_camera_init(void) |
| 1057 | { |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 1058 | |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 1059 | #ifndef CONFIG_MSM_CAMERA_V4L2 |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1060 | int rc; |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 1061 | #endif |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1062 | |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 1063 | pr_debug("msm7627a_camera_init Entered\n"); |
| 1064 | /* LCD and camera power (VREG & LDO) init */ |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 1065 | if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) { |
| 1066 | evb_camera_gpio_cfg(); |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 1067 | lcd_camera_power_init(); |
| 1068 | |
Raju P.L.S.S.S.N | cc40097 | 2012-03-13 10:09:59 +0530 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | #ifndef CONFIG_MSM_CAMERA_V4L2 |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1072 | if (machine_is_msm7627a_qrd1()) { |
| 1073 | qrd1_camera_gpio_cfg(); |
| 1074 | platform_add_devices(camera_devices_qrd, |
| 1075 | ARRAY_SIZE(camera_devices_qrd)); |
Chintan Pandya | f4ad400 | 2012-02-28 19:49:03 +0530 | [diff] [blame] | 1076 | } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) { |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 1077 | platform_add_devices(camera_devices_evb, |
| 1078 | ARRAY_SIZE(camera_devices_evb)); |
| 1079 | } else if (machine_is_msm7627a_qrd3()) |
Chintan Pandya | b1bad0e | 2012-02-06 19:04:51 +0530 | [diff] [blame] | 1080 | return; |
Taniya Das | c868a2e | 2012-01-03 10:18:47 +0530 | [diff] [blame] | 1081 | else |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1082 | platform_add_devices(camera_devices_msm, |
| 1083 | ARRAY_SIZE(camera_devices_msm)); |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 1084 | #endif |
Chintan Pandya | f4ad400 | 2012-02-28 19:49:03 +0530 | [diff] [blame] | 1085 | if (!machine_is_msm7627a_qrd1() || !machine_is_msm7627a_evb() |
| 1086 | || !machine_is_msm8625_evb()) |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1087 | register_i2c_devices(); |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 1088 | #ifndef CONFIG_MSM_CAMERA_V4L2 |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1089 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera); |
| 1090 | |
| 1091 | if (rc) { |
| 1092 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 1093 | return; |
| 1094 | } |
| 1095 | |
| 1096 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera); |
| 1097 | |
| 1098 | if (rc) { |
| 1099 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 1100 | return; |
| 1101 | } |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 1102 | #endif |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1103 | |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 1104 | #if defined(CONFIG_MSM_CAMERA_V4L2) |
| 1105 | msm7x27a_init_cam(); |
| 1106 | #endif |
| 1107 | #ifndef CONFIG_MSM_CAMERA_V4L2 |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 1108 | if (machine_is_msm7627a_qrd1()) { |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1109 | i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, |
| 1110 | i2c_camera_devices_qrd, |
| 1111 | ARRAY_SIZE(i2c_camera_devices_qrd)); |
Chintan Pandya | f4ad400 | 2012-02-28 19:49:03 +0530 | [diff] [blame] | 1112 | } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) { |
Su Liu | aca0470 | 2012-02-14 02:27:32 +0530 | [diff] [blame] | 1113 | pr_debug("machine_is_msm7627a_evb i2c_register_board_info\n"); |
| 1114 | i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, |
| 1115 | i2c_camera_devices_evb, |
| 1116 | ARRAY_SIZE(i2c_camera_devices_evb)); |
| 1117 | } else |
Suresh Vankadara | 87e195b | 2012-01-18 00:42:58 +0530 | [diff] [blame] | 1118 | #endif |
Sandeep Kodimela | c6f7867 | 2012-03-07 10:44:04 +0530 | [diff] [blame] | 1119 | pr_debug("i2c_register_board_info\n"); |
Chintan Pandya | 4076270 | 2011-12-06 13:47:06 +0530 | [diff] [blame] | 1120 | i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, |
| 1121 | i2c_camera_devices, |
| 1122 | ARRAY_SIZE(i2c_camera_devices)); |
| 1123 | } |