8a4cd0d69cae55fce5530c0ee70922ae2d769193
[GitHub/MotorolaMobilityLLC/kernel-slsi.git] /
1 /*
2 * Samsung Exynos5 SoC series Sensor driver
3 *
4 *
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 #include <linux/i2c.h>
13 #include <linux/slab.h>
14 #include <linux/irq.h>
15 #include <linux/interrupt.h>
16 #include <linux/delay.h>
17 #include <linux/version.h>
18 #include <linux/gpio.h>
19 #include <linux/clk.h>
20 #include <linux/regulator/consumer.h>
21 #include <linux/videodev2.h>
22 #include <linux/videodev2_exynos_camera.h>
23 #include <linux/module.h>
24 #include <linux/moduleparam.h>
25 #include <linux/platform_device.h>
26 #include <linux/of_gpio.h>
27 #include <media/v4l2-ctrls.h>
28 #include <media/v4l2-device.h>
29 #include <media/v4l2-subdev.h>
30
31 #include <exynos-fimc-is-sensor.h>
32 #include "fimc-is-hw.h"
33 #include "fimc-is-core.h"
34 #include "fimc-is-device-sensor.h"
35 #include "fimc-is-device-sensor-peri.h"
36 #include "fimc-is-resourcemgr.h"
37 #include "fimc-is-dt.h"
38
39 #include "fimc-is-device-module-base.h"
40
41 static struct fimc_is_sensor_cfg config_module_gm1sp[] = {
42 /* width, height, fps, settle, mode, lane, speed, interleave, pd_mode */
43 FIMC_IS_SENSOR_CFG(4000, 3000, 30, 0, 0, CSI_DATA_LANES_4, 1152, CSI_MODE_VC_DT, PD_MSPD_TAIL,
44 VC_IN(0, HW_FORMAT_RAW10, 4000, 3000), VC_OUT(HW_FORMAT_RAW10, VC_NOTHING, 4000, 3000),
45 VC_IN(1, HW_FORMAT_RAW10, 496, 736), VC_OUT(HW_FORMAT_USER, VC_PRIVATE, 4032, 1),
46 VC_IN(2, HW_FORMAT_UNKNOWN, 0, 0), VC_OUT(HW_FORMAT_USER, VC_MIPISTAT, 127680, 1),
47 VC_IN(0, HW_FORMAT_USER, 4000, 4), VC_OUT(HW_FORMAT_USER, VC_EMBEDDED, 4000, 4)),
48 FIMC_IS_SENSOR_CFG(2000, 1124, 60, 0, 1, CSI_DATA_LANES_4, 1152, CSI_MODE_VC_DT, PD_NONE,
49 VC_IN(0, HW_FORMAT_RAW10, 2000, 1124), VC_OUT(HW_FORMAT_RAW10, VC_NOTHING, 2000, 1124),
50 VC_IN(1, HW_FORMAT_UNKNOWN, 0, 0), VC_OUT(HW_FORMAT_UNKNOWN, VC_NOTHING, 0, 0),
51 VC_IN(0, HW_FORMAT_USER, 0, 0), VC_OUT(HW_FORMAT_USER, VC_NOTHING, 0, 0),
52 VC_IN(0, HW_FORMAT_EMBEDDED_8BIT, 0, 0), VC_OUT(HW_FORMAT_UNKNOWN, VC_NOTHING, 0, 0)),
53 FIMC_IS_SENSOR_CFG(2000, 1124, 120, 0, 2, CSI_DATA_LANES_4, 1196, CSI_MODE_VC_DT, PD_NONE,
54 VC_IN(0, HW_FORMAT_RAW10, 2000, 1124), VC_OUT(HW_FORMAT_RAW10, VC_NOTHING, 2000, 1124),
55 VC_IN(1, HW_FORMAT_UNKNOWN, 0, 0), VC_OUT(HW_FORMAT_UNKNOWN, VC_NOTHING, 0, 0),
56 VC_IN(0, HW_FORMAT_USER, 0, 0), VC_OUT(HW_FORMAT_USER, VC_NOTHING, 0, 0),
57 VC_IN(0, HW_FORMAT_EMBEDDED_8BIT, 0, 0), VC_OUT(HW_FORMAT_UNKNOWN, VC_NOTHING, 0, 0)),
58 FIMC_IS_SENSOR_CFG(1280, 720, 240, 0, 3, CSI_DATA_LANES_4, 763, CSI_MODE_DT_ONLY, PD_NONE,
59 VC_IN(0, HW_FORMAT_RAW10, 1280, 720), VC_OUT(HW_FORMAT_RAW10, VC_NOTHING, 1280, 720),
60 VC_IN(1, HW_FORMAT_UNKNOWN, 0, 0), VC_OUT(HW_FORMAT_UNKNOWN, VC_NOTHING, 0, 0),
61 VC_IN(0, HW_FORMAT_USER, 0, 0), VC_OUT(HW_FORMAT_UNKNOWN, VC_NOTHING, 0, 0),
62 VC_IN(0, HW_FORMAT_EMBEDDED_8BIT, 0, 0), VC_OUT(HW_FORMAT_EMBEDDED_8BIT, VC_NOTHING, 0, 0)),
63 };
64
65 static const struct v4l2_subdev_core_ops core_ops = {
66 .init = sensor_module_init,
67 .g_ctrl = sensor_module_g_ctrl,
68 .s_ctrl = sensor_module_s_ctrl,
69 .g_ext_ctrls = sensor_module_g_ext_ctrls,
70 .s_ext_ctrls = sensor_module_s_ext_ctrls,
71 .ioctl = sensor_module_ioctl,
72 .log_status = sensor_module_log_status,
73 };
74
75 static const struct v4l2_subdev_video_ops video_ops = {
76 .s_routing = sensor_module_s_routing,
77 .s_stream = sensor_module_s_stream,
78 .s_parm = sensor_module_s_param
79 };
80
81 static const struct v4l2_subdev_pad_ops pad_ops = {
82 .set_fmt = sensor_module_s_format
83 };
84
85 static const struct v4l2_subdev_ops subdev_ops = {
86 .core = &core_ops,
87 .video = &video_ops,
88 .pad = &pad_ops
89 };
90
91 static int sensor_module_gm1sp_power_setpin(struct device *dev,
92 struct exynos_platform_fimc_is_module *pdata)
93 {
94 struct device_node *dnode;
95 int gpio_reset = 0;
96 int gpio_none = 0;
97 int gpio_mclk = 0;
98 int gpio_avdd_en = 0;
99 int gpio_dvdd_en = 0;
100 int gpio_iovdd_en = 0;
101 struct fimc_is_core *core;
102
103 BUG_ON(!dev);
104
105 dnode = dev->of_node;
106
107 core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev);
108 if (!core) {
109 err("core is NULL");
110 return -EINVAL;
111 }
112
113 dev_info(dev, "%s E v4\n", __func__);
114
115 /* TODO */
116 gpio_reset = of_get_named_gpio(dnode, "gpio_reset", 0);
117 if (gpio_is_valid(gpio_reset)) {
118 gpio_request_one(gpio_reset, GPIOF_OUT_INIT_LOW, "CAM_GPIO_OUTPUT_LOW");
119 gpio_free(gpio_reset);
120 } else {
121 dev_err(dev, "failed to get PIN_RESET\n");
122 return -EINVAL;
123 }
124
125 gpio_avdd_en = of_get_named_gpio(dnode, "gpio_avdd_en", 0);
126 if (gpio_is_valid(gpio_avdd_en)) {
127 if (gpio_request_one(gpio_avdd_en, GPIOF_OUT_INIT_LOW, "CAM_AVDD_EN_LOW")) {
128 dev_err(dev, "%s: failed to gpio request avdd_en\n", __func__);
129 return -ENODEV;
130 }
131 gpio_free(gpio_avdd_en);
132 } else {
133 dev_err(dev, "%s: failed to get avdd_en\n", __func__);
134 return -EINVAL;
135 }
136
137 gpio_dvdd_en = of_get_named_gpio(dnode, "gpio_dvdd_en", 0);
138 if (gpio_is_valid(gpio_dvdd_en)) {
139 if (gpio_request_one(gpio_dvdd_en, GPIOF_OUT_INIT_LOW, "CAM_DVDD_EN_LOW")) {
140 dev_err(dev, "%s: failed to gpio request dvdd_en\n", __func__);
141 return -ENODEV;
142 }
143 gpio_free(gpio_dvdd_en);
144 } else {
145 dev_err(dev, "%s: failed to get dvdd_en\n", __func__);
146 return -EINVAL;
147 }
148
149 gpio_iovdd_en = of_get_named_gpio(dnode, "gpio_iovdd_en", 0);
150 if (gpio_is_valid(gpio_iovdd_en)) {
151 if (gpio_request_one(gpio_iovdd_en, GPIOF_OUT_INIT_LOW, "CAM_IOVDD_EN_LOW")) {
152 dev_err(dev, "%s: failed to gpio request iovdd_en\n", __func__);
153 return -ENODEV;
154 }
155 gpio_free(gpio_iovdd_en);
156 } else {
157 dev_err(dev, "%s: failed to get iovdd_en\n", __func__);
158 return -EINVAL;
159 }
160
161 gpio_mclk = of_get_named_gpio(dnode, "gpio_mclk", 0);
162 if (gpio_is_valid(gpio_mclk)) {
163 if (gpio_request_one(gpio_mclk, GPIOF_OUT_INIT_LOW, "CAM_MCLK_OUTPUT_LOW")) {
164 dev_err(dev, "%s: failed to gpio request mclk\n", __func__);
165 return -ENODEV;
166 }
167 gpio_free(gpio_mclk);
168 } else {
169 dev_err(dev, "%s: failed to get mclk\n", __func__);
170 return -EINVAL;
171 }
172
173 SET_PIN_INIT(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON);
174 SET_PIN_INIT(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF);
175 SET_PIN_INIT(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON);
176 SET_PIN_INIT(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF);
177 SET_PIN_INIT(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON);
178 SET_PIN_INIT(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF);
179
180 /* BACK CAEMRA - POWER ON */
181 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst low", PIN_OUTPUT, 0, 0);
182
183 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "VLDO38_PMIC_RCAM_AFVCC_2P8", PIN_REGULATOR, 1, 0);
184 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 1, 0);
185 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_dvdd_en, "dvdd_en", PIN_OUTPUT, 1, 0);
186 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 1, 0);
187 SET_PIN_SHARED(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, SRT_ACQUIRE,
188 &core->shared_rsc_slock[SHARED_PIN0], &core->shared_rsc_count[SHARED_PIN0], 1);
189
190 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0);
191 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000);
192
193 /* BACK CAEMRA - POWER OFF */
194 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_RESET, 0, 10);
195 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst input", PIN_INPUT, 0, 0);
196
197 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "VLDO38_PMIC_RCAM_AFVCC_2P8", PIN_REGULATOR, 0, 0);
198 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 0, 0);
199 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_dvdd_en, "dvdd_en", PIN_OUTPUT, 0, 0);
200 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 0, 0);
201 SET_PIN_SHARED(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, SRT_RELEASE,
202 &core->shared_rsc_slock[SHARED_PIN0], &core->shared_rsc_count[SHARED_PIN0], 0);
203
204 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0);
205 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 1, 0);
206 SET_PIN(pdata, SENSOR_SCENARIO_NORMAL, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0);
207
208 /* REAR VISION CAEMRA - POWER ON */
209 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_reset, "sen_rst low", PIN_OUTPUT, 0, 0);
210
211 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_none, "VLDO38_PMIC_RCAM_AFVCC_2P8", PIN_REGULATOR, 1, 0);
212 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 1, 0);
213 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_dvdd_en, "dvdd_en", PIN_OUTPUT, 1, 0);
214 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 1, 0);
215
216 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0);
217 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000);
218
219
220 /* REAR VISION CAEMRA - POWER OFF */
221 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_RESET, 0, 10);
222 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst input", PIN_INPUT, 0, 0);
223
224 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_none, "VLDO38_PMIC_RCAM_AFVCC_2P8", PIN_REGULATOR, 0, 0);
225 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 0, 0);
226 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_dvdd_en, "dvdd_en", PIN_OUTPUT, 0, 0);
227 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 0, 0);
228
229 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0);
230 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 1, 0);
231 SET_PIN(pdata, SENSOR_SCENARIO_VISION, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0);
232
233 /* SENSOR FACTORY TEST - POWER ON */
234 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst low", PIN_OUTPUT, 0, 0);
235
236 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "VLDO38_PMIC_RCAM_AFVCC_2P8", PIN_REGULATOR, 1, 0);
237 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 1, 0);
238 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_dvdd_en, "dvdd_en", PIN_OUTPUT, 1, 0);
239 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 1, 0);
240
241 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_none, "pin", PIN_FUNCTION, 2, 0);
242 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_ON, gpio_reset, "sen_rst high", PIN_OUTPUT, 1, 2000);
243
244
245 /* REAR VISION CAEMRA - POWER OFF */
246 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst", PIN_RESET, 0, 10);
247 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_reset, "sen_rst input", PIN_INPUT, 0, 0);
248
249 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "VLDO38_PMIC_RCAM_AFVCC_2P8", PIN_REGULATOR, 0, 0);
250 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_avdd_en, "avdd_en", PIN_OUTPUT, 0, 0);
251 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_dvdd_en, "dvdd_en", PIN_OUTPUT, 0, 0);
252 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_iovdd_en, "iovdd_en", PIN_OUTPUT, 0, 0);
253
254 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0);
255 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 1, 0);
256 SET_PIN(pdata, SENSOR_SCENARIO_FACTORY, GPIO_SCENARIO_OFF, gpio_none, "pin", PIN_FUNCTION, 0, 0);
257
258 dev_info(dev, "%s X v4\n", __func__);
259
260 return 0;
261 }
262
263 static int __init sensor_module_gm1sp_probe(struct platform_device *pdev)
264 {
265 int ret = 0;
266 struct fimc_is_core *core;
267 struct v4l2_subdev *subdev_module;
268 struct fimc_is_module_enum *module;
269 struct fimc_is_device_sensor *device;
270 struct sensor_open_extended *ext;
271 struct exynos_platform_fimc_is_module *pdata;
272 struct device *dev;
273 int ch, t;
274 struct pinctrl_state *s;
275
276 BUG_ON(!fimc_is_dev);
277
278 core = (struct fimc_is_core *)dev_get_drvdata(fimc_is_dev);
279 if (!core) {
280 probe_info("core device is not yet probed");
281 return -EPROBE_DEFER;
282 }
283
284 dev = &pdev->dev;
285
286 #ifdef CONFIG_OF
287 fimc_is_module_parse_dt(dev, sensor_module_gm1sp_power_setpin);
288 #endif
289
290 pdata = dev_get_platdata(dev);
291 device = &core->sensor[pdata->id];
292
293 subdev_module = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
294 if (!subdev_module) {
295 err("subdev_module is NULL");
296 ret = -ENOMEM;
297 goto p_err;
298 }
299
300 probe_info("%s pdta->id(%d), module_enum id = %d\n", __func__, pdata->id, atomic_read(&device->module_count));
301 module = &device->module_enum[atomic_read(&device->module_count)];
302 atomic_inc(&device->module_count);
303 clear_bit(FIMC_IS_MODULE_GPIO_ON, &module->state);
304 module->pdata = pdata;
305 module->dev = dev;
306 module->sensor_id = SENSOR_NAME_S5KGM1SP;
307 module->subdev = subdev_module;
308 module->device = pdata->id;
309 module->client = NULL;
310 module->active_width = 4000;
311 module->active_height = 3000;
312 module->margin_left = 0;
313 module->margin_right = 0;
314 module->margin_top = 0;
315 module->margin_bottom = 0;
316 module->pixel_width = module->active_width;
317 module->pixel_height = module->active_height;
318 module->max_framerate = 240;
319 module->position = pdata->position;
320 module->bitwidth = 10;
321 module->sensor_maker = "SLSI";
322 module->sensor_name = "S5KGM1SP";
323 module->setfile_name = "setfile_gm1sp.bin";
324 module->cfgs = ARRAY_SIZE(config_module_gm1sp);
325 module->cfg = config_module_gm1sp;
326 module->ops = NULL;
327
328 for (ch = 1; ch < CSI_VIRTUAL_CH_MAX; ch++)
329 module->vc_buffer_offset[ch] = pdata->vc_buffer_offset[ch];
330
331 for (t = VC_BUF_DATA_TYPE_SENSOR_STAT1; t < VC_BUF_DATA_TYPE_MAX; t++) {
332 module->vc_extra_info[t].stat_type = VC_STAT_TYPE_INVALID;
333 module->vc_extra_info[t].sensor_mode = VC_SENSOR_MODE_INVALID;
334 module->vc_extra_info[t].max_width = 0;
335 module->vc_extra_info[t].max_height = 0;
336 module->vc_extra_info[t].max_element = 0;
337
338 if (IS_ENABLED(CONFIG_CAMERA_PAFSTAT)) {
339 switch (t) {
340 case VC_BUF_DATA_TYPE_GENERAL_STAT1:
341 module->vc_extra_info[t].stat_type
342 = VC_STAT_TYPE_PAFSTAT_FLOATING;
343
344 module->vc_extra_info[t].sensor_mode = VC_SENSOR_MODE_ULTRA_PD_TAIL;
345 module->vc_extra_info[t].max_width = 4032;
346 module->vc_extra_info[t].max_height = 1;
347 module->vc_extra_info[t].max_element = 1;
348 break;
349 case VC_BUF_DATA_TYPE_GENERAL_STAT2:
350 module->vc_extra_info[t].stat_type
351 = VC_STAT_TYPE_PAFSTAT_STATIC;
352
353 module->vc_extra_info[t].sensor_mode = VC_SENSOR_MODE_ULTRA_PD_TAIL;
354 module->vc_extra_info[t].max_width = 127680;
355 module->vc_extra_info[t].max_height = 1;
356 module->vc_extra_info[t].max_element = 1;
357 break;
358 }
359 }
360 }
361
362 /* Sensor peri */
363 module->private_data = kzalloc(sizeof(struct fimc_is_device_sensor_peri), GFP_KERNEL);
364 if (!module->private_data) {
365 err("fimc_is_device_sensor_peri is NULL");
366 ret = -ENOMEM;
367 goto p_err;
368 }
369 fimc_is_sensor_peri_probe((struct fimc_is_device_sensor_peri *)module->private_data);
370 PERI_SET_MODULE(module);
371
372 ext = &module->ext;
373
374 ext->sensor_con.product_name = module->sensor_id;
375 ext->sensor_con.peri_type = SE_I2C;
376 ext->sensor_con.peri_setting.i2c.channel = pdata->sensor_i2c_ch;
377 ext->sensor_con.peri_setting.i2c.slave_address = pdata->sensor_i2c_addr;
378 ext->sensor_con.peri_setting.i2c.speed = 400000;
379
380 ext->actuator_con.product_name = ACTUATOR_NAME_NOTHING;
381 ext->flash_con.product_name = FLADRV_NAME_NOTHING;
382 ext->from_con.product_name = FROMDRV_NAME_NOTHING;
383 ext->preprocessor_con.product_name = PREPROCESSOR_NAME_NOTHING;
384 ext->ois_con.product_name = OIS_NAME_NOTHING;
385
386 if (pdata->af_product_name != ACTUATOR_NAME_NOTHING) {
387 ext->actuator_con.product_name = pdata->af_product_name;
388 ext->actuator_con.peri_type = SE_I2C;
389 ext->actuator_con.peri_setting.i2c.channel = pdata->af_i2c_ch;
390 ext->actuator_con.peri_setting.i2c.slave_address = pdata->af_i2c_addr;
391 ext->actuator_con.peri_setting.i2c.speed = 400000;
392 }
393
394 if (pdata->flash_product_name != FLADRV_NAME_NOTHING) {
395 ext->flash_con.product_name = pdata->flash_product_name;
396 ext->flash_con.peri_type = SE_GPIO;
397 ext->flash_con.peri_setting.gpio.first_gpio_port_no = pdata->flash_first_gpio;
398 ext->flash_con.peri_setting.gpio.second_gpio_port_no = pdata->flash_second_gpio;
399 }
400
401 ext->from_con.product_name = FROMDRV_NAME_NOTHING;
402
403 if (pdata->preprocessor_product_name != PREPROCESSOR_NAME_NOTHING) {
404 ext->preprocessor_con.product_name = pdata->preprocessor_product_name;
405 ext->preprocessor_con.peri_info0.valid = true;
406 ext->preprocessor_con.peri_info0.peri_type = SE_SPI;
407 ext->preprocessor_con.peri_info0.peri_setting.spi.channel = pdata->preprocessor_spi_channel;
408 ext->preprocessor_con.peri_info1.valid = true;
409 ext->preprocessor_con.peri_info1.peri_type = SE_I2C;
410 ext->preprocessor_con.peri_info1.peri_setting.i2c.channel = pdata->preprocessor_i2c_ch;
411 ext->preprocessor_con.peri_info1.peri_setting.i2c.slave_address = pdata->preprocessor_i2c_addr;
412 ext->preprocessor_con.peri_info1.peri_setting.i2c.speed = 400000;
413 ext->preprocessor_con.peri_info2.valid = true;
414 ext->preprocessor_con.peri_info2.peri_type = SE_DMA;
415 if (pdata->preprocessor_dma_channel == DMA_CH_NOT_DEFINED)
416 ext->preprocessor_con.peri_info2.peri_setting.dma.channel = FLITE_ID_D;
417 else
418 ext->preprocessor_con.peri_info2.peri_setting.dma.channel = pdata->preprocessor_dma_channel;
419 }
420
421 if (pdata->ois_product_name != OIS_NAME_NOTHING) {
422 ext->ois_con.product_name = pdata->ois_product_name;
423 ext->ois_con.peri_type = SE_I2C;
424 ext->ois_con.peri_setting.i2c.channel = pdata->ois_i2c_ch;
425 ext->ois_con.peri_setting.i2c.slave_address = pdata->ois_i2c_addr;
426 ext->ois_con.peri_setting.i2c.speed = 400000;
427 } else {
428 ext->ois_con.product_name = pdata->ois_product_name;
429 ext->ois_con.peri_type = SE_NULL;
430 }
431
432 if (pdata->eeprom_product_name != EEPROM_NAME_NOTHING) {
433 ext->eeprom_con.product_name = pdata->eeprom_product_name;
434 ext->eeprom_con.peri_type = SE_I2C;
435 ext->eeprom_con.peri_setting.i2c.channel = pdata->eeprom_i2c_ch;
436 ext->eeprom_con.peri_setting.i2c.slave_address = pdata->eeprom_i2c_addr;
437 ext->eeprom_con.peri_setting.i2c.speed = 400000;
438 } else {
439 ext->eeprom_con.product_name = pdata->eeprom_product_name;
440 ext->eeprom_con.peri_type = SE_NULL;
441 }
442
443 v4l2_subdev_init(subdev_module, &subdev_ops);
444
445 v4l2_set_subdevdata(subdev_module, module);
446 v4l2_set_subdev_hostdata(subdev_module, device);
447 snprintf(subdev_module->name, V4L2_SUBDEV_NAME_SIZE, "sensor-subdev.%d", module->sensor_id);
448
449 s = pinctrl_lookup_state(pdata->pinctrl, "release");
450
451 if (pinctrl_select_state(pdata->pinctrl, s) < 0) {
452 probe_err("pinctrl_select_state is fail\n");
453 goto p_err;
454 }
455
456 probe_info("%s done\n", __func__);
457
458 p_err:
459 return ret;
460 }
461
462 static const struct of_device_id exynos_fimc_is_sensor_module_gm1sp_match[] = {
463 {
464 .compatible = "samsung,sensor-module-gm1sp",
465 },
466 {},
467 };
468 MODULE_DEVICE_TABLE(of, exynos_fimc_is_sensor_module_gm1sp_match);
469
470 static struct platform_driver sensor_module_gm1sp_driver = {
471 .driver = {
472 .name = "FIMC-IS-SENSOR-MODULE-GM1SP",
473 .owner = THIS_MODULE,
474 .of_match_table = exynos_fimc_is_sensor_module_gm1sp_match,
475 }
476 };
477
478 static int __init fimc_is_sensor_module_gm1sp_init(void)
479 {
480 int ret;
481
482 ret = platform_driver_probe(&sensor_module_gm1sp_driver,
483 sensor_module_gm1sp_probe);
484 if (ret)
485 err("failed to probe %s driver: %d\n",
486 sensor_module_gm1sp_driver.driver.name, ret);
487
488 return ret;
489 }
490 late_initcall(fimc_is_sensor_module_gm1sp_init);