1 #include <linux/module.h>
6 #include <linux/acpi.h>
8 #include <linux/delay.h>
9 #include <media/v4l2-subdev.h>
10 #include <linux/mfd/intel_soc_pmic.h>
11 #include <linux/regulator/consumer.h>
12 #include <linux/gpio/consumer.h>
13 #include <linux/gpio.h>
14 #include <linux/platform_device.h>
15 #include "../../include/linux/atomisp_platform.h"
16 #include "../../include/linux/atomisp_gmin_platform.h"
20 #define VLV2_CLK_PLL_19P2MHZ 1 /* XTAL on CHT */
21 #define ELDO1_SEL_REG 0x19
22 #define ELDO1_1P8V 0x16
23 #define ELDO1_CTRL_SHIFT 0x00
24 #define ELDO2_SEL_REG 0x1a
25 #define ELDO2_1P8V 0x16
26 #define ELDO2_CTRL_SHIFT 0x01
29 struct v4l2_subdev
*subdev
;
34 struct gpio_desc
*gpio0
;
35 struct gpio_desc
*gpio1
;
36 struct regulator
*v1p8_reg
;
37 struct regulator
*v2p8_reg
;
38 struct regulator
*v1p2_reg
;
39 struct regulator
*v2p8_vcm_reg
;
40 enum atomisp_camera_port csi_port
;
41 unsigned int csi_lanes
;
42 enum atomisp_input_format csi_fmt
;
43 enum atomisp_bayer_order csi_bayer
;
50 static struct gmin_subdev gmin_subdevs
[MAX_SUBDEVS
];
52 static enum { PMIC_UNSET
= 0, PMIC_REGULATOR
, PMIC_AXP
, PMIC_TI
,
53 PMIC_CRYSTALCOVE
} pmic_id
;
55 /* The atomisp uses type==0 for the end-of-list marker, so leave space. */
56 static struct intel_v4l2_subdev_table pdata_subdevs
[MAX_SUBDEVS
+ 1];
58 static const struct atomisp_platform_data pdata
= {
59 .subdevs
= pdata_subdevs
,
63 * Something of a hack. The ECS E7 board drives camera 2.8v from an
64 * external regulator instead of the PMIC. There's a gmin_CamV2P8
65 * config variable that specifies the GPIO to handle this particular
66 * case, but this needs a broader architecture for handling camera
69 enum { V2P8_GPIO_UNSET
= -2, V2P8_GPIO_NONE
= -1 };
70 static int v2p8_gpio
= V2P8_GPIO_UNSET
;
73 * Something of a hack. The CHT RVP board drives camera 1.8v from an
74 * external regulator instead of the PMIC just like ECS E7 board, see the
77 enum { V1P8_GPIO_UNSET
= -2, V1P8_GPIO_NONE
= -1 };
78 static int v1p8_gpio
= V1P8_GPIO_UNSET
;
80 static LIST_HEAD(vcm_devices
);
81 static DEFINE_MUTEX(vcm_lock
);
83 static struct gmin_subdev
*find_gmin_subdev(struct v4l2_subdev
*subdev
);
86 * Legacy/stub behavior copied from upstream platform_camera.c. The
87 * atomisp driver relies on these values being non-NULL in a few
88 * places, even though they are hard-coded in all current
91 const struct atomisp_camera_caps
*atomisp_get_default_camera_caps(void)
93 static const struct atomisp_camera_caps caps
= {
101 EXPORT_SYMBOL_GPL(atomisp_get_default_camera_caps
);
103 const struct atomisp_platform_data
*atomisp_get_platform_data(void)
107 EXPORT_SYMBOL_GPL(atomisp_get_platform_data
);
109 static int af_power_ctrl(struct v4l2_subdev
*subdev
, int flag
)
111 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
113 if (gs
&& gs
->v2p8_vcm_on
== flag
)
115 gs
->v2p8_vcm_on
= flag
;
118 * The power here is used for dw9817,
119 * regulator is from rear sensor
121 if (gs
->v2p8_vcm_reg
) {
123 return regulator_enable(gs
->v2p8_vcm_reg
);
125 return regulator_disable(gs
->v2p8_vcm_reg
);
131 * Used in a handful of modules. Focus motor control, I think. Note
132 * that there is no configurability in the API, so this needs to be
133 * fixed where it is used.
135 * struct camera_af_platform_data {
136 * int (*power_ctrl)(struct v4l2_subdev *subdev, int flag);
139 * Note that the implementation in MCG platform_camera.c is stubbed
140 * out anyway (i.e. returns zero from the callback) on BYT. So
141 * neither needed on gmin platforms or supported upstream.
143 const struct camera_af_platform_data
*camera_get_af_platform_data(void)
145 static struct camera_af_platform_data afpd
= {
146 .power_ctrl
= af_power_ctrl
,
150 EXPORT_SYMBOL_GPL(camera_get_af_platform_data
);
152 int atomisp_register_i2c_module(struct v4l2_subdev
*subdev
,
153 struct camera_sensor_platform_data
*plat_data
,
154 enum intel_v4l2_subdev_type type
)
157 struct i2c_board_info
*bi
;
158 struct gmin_subdev
*gs
;
159 struct i2c_client
*client
= v4l2_get_subdevdata(subdev
);
160 struct acpi_device
*adev
;
162 dev_info(&client
->dev
, "register atomisp i2c module type %d\n", type
);
164 /* The windows driver model (and thus most BIOSes by default)
165 * uses ACPI runtime power management for camera devices, but
166 * we don't. Disable it, or else the rails will be needlessly
167 * tickled during suspend/resume. This has caused power and
168 * performance issues on multiple devices.
170 adev
= ACPI_COMPANION(&client
->dev
);
172 adev
->power
.flags
.power_resources
= 0;
174 for (i
= 0; i
< MAX_SUBDEVS
; i
++)
175 if (!pdata
.subdevs
[i
].type
)
178 if (pdata
.subdevs
[i
].type
)
181 /* Note subtlety of initialization order: at the point where
182 * this registration API gets called, the platform data
183 * callbacks have probably already been invoked, so the
184 * gmin_subdev struct is already initialized for us.
186 gs
= find_gmin_subdev(subdev
);
188 pdata
.subdevs
[i
].type
= type
;
189 pdata
.subdevs
[i
].port
= gs
->csi_port
;
190 pdata
.subdevs
[i
].subdev
= subdev
;
191 pdata
.subdevs
[i
].v4l2_subdev
.i2c_adapter_id
= client
->adapter
->nr
;
193 /* Convert i2c_client to i2c_board_info */
194 bi
= &pdata
.subdevs
[i
].v4l2_subdev
.board_info
;
195 memcpy(bi
->type
, client
->name
, I2C_NAME_SIZE
);
196 bi
->flags
= client
->flags
;
197 bi
->addr
= client
->addr
;
198 bi
->irq
= client
->irq
;
199 bi
->platform_data
= plat_data
;
203 EXPORT_SYMBOL_GPL(atomisp_register_i2c_module
);
205 struct v4l2_subdev
*atomisp_gmin_find_subdev(struct i2c_adapter
*adapter
,
206 struct i2c_board_info
*board_info
)
210 for (i
= 0; i
< MAX_SUBDEVS
&& pdata
.subdevs
[i
].type
; i
++) {
211 struct intel_v4l2_subdev_table
*sd
= &pdata
.subdevs
[i
];
213 if (sd
->v4l2_subdev
.i2c_adapter_id
== adapter
->nr
&&
214 sd
->v4l2_subdev
.board_info
.addr
== board_info
->addr
)
219 EXPORT_SYMBOL_GPL(atomisp_gmin_find_subdev
);
221 int atomisp_gmin_remove_subdev(struct v4l2_subdev
*sd
)
228 for (i
= 0; i
< MAX_SUBDEVS
; i
++) {
229 if (pdata
.subdevs
[i
].subdev
== sd
) {
230 for (j
= i
+ 1; j
<= MAX_SUBDEVS
; j
++)
231 pdata
.subdevs
[j
- 1] = pdata
.subdevs
[j
];
233 if (gmin_subdevs
[i
].subdev
== sd
) {
234 if (gmin_subdevs
[i
].gpio0
)
235 gpiod_put(gmin_subdevs
[i
].gpio0
);
236 gmin_subdevs
[i
].gpio0
= NULL
;
237 if (gmin_subdevs
[i
].gpio1
)
238 gpiod_put(gmin_subdevs
[i
].gpio1
);
239 gmin_subdevs
[i
].gpio1
= NULL
;
240 if (pmic_id
== PMIC_REGULATOR
) {
241 regulator_put(gmin_subdevs
[i
].v1p8_reg
);
242 regulator_put(gmin_subdevs
[i
].v2p8_reg
);
243 regulator_put(gmin_subdevs
[i
].v1p2_reg
);
244 regulator_put(gmin_subdevs
[i
].v2p8_vcm_reg
);
246 gmin_subdevs
[i
].subdev
= NULL
;
251 EXPORT_SYMBOL_GPL(atomisp_gmin_remove_subdev
);
253 struct gmin_cfg_var
{
254 const char *name
, *val
;
257 static const struct gmin_cfg_var ffrd8_vars
[] = {
258 { "INTCF1B:00_ImxId", "0x134" },
259 { "INTCF1B:00_CsiPort", "1" },
260 { "INTCF1B:00_CsiLanes", "4" },
261 { "INTCF1B:00_CamClk", "0" },
265 /* Cribbed from MCG defaults in the mt9m114 driver, not actually verified
268 static const struct gmin_cfg_var t100_vars
[] = {
269 { "INT33F0:00_CsiPort", "0" },
270 { "INT33F0:00_CsiLanes", "1" },
271 { "INT33F0:00_CamClk", "1" },
275 static const struct gmin_cfg_var mrd7_vars
[] = {
276 {"INT33F8:00_CamType", "1"},
277 {"INT33F8:00_CsiPort", "1"},
278 {"INT33F8:00_CsiLanes", "2"},
279 {"INT33F8:00_CsiFmt", "13"},
280 {"INT33F8:00_CsiBayer", "0"},
281 {"INT33F8:00_CamClk", "0"},
282 {"INT33F9:00_CamType", "1"},
283 {"INT33F9:00_CsiPort", "0"},
284 {"INT33F9:00_CsiLanes", "1"},
285 {"INT33F9:00_CsiFmt", "13"},
286 {"INT33F9:00_CsiBayer", "0"},
287 {"INT33F9:00_CamClk", "1"},
291 static const struct gmin_cfg_var ecs7_vars
[] = {
292 {"INT33BE:00_CsiPort", "1"},
293 {"INT33BE:00_CsiLanes", "2"},
294 {"INT33BE:00_CsiFmt", "13"},
295 {"INT33BE:00_CsiBayer", "2"},
296 {"INT33BE:00_CamClk", "0"},
297 {"INT33F0:00_CsiPort", "0"},
298 {"INT33F0:00_CsiLanes", "1"},
299 {"INT33F0:00_CsiFmt", "13"},
300 {"INT33F0:00_CsiBayer", "0"},
301 {"INT33F0:00_CamClk", "1"},
302 {"gmin_V2P8GPIO", "402"},
307 static const struct gmin_cfg_var i8880_vars
[] = {
308 {"XXOV2680:00_CsiPort", "1"},
309 {"XXOV2680:00_CsiLanes", "1"},
310 {"XXOV2680:00_CamClk", "0"},
311 {"XXGC0310:00_CsiPort", "0"},
312 {"XXGC0310:00_CsiLanes", "1"},
313 {"XXGC0310:00_CamClk", "1"},
317 static const struct {
318 const char *dmi_board_name
;
319 const struct gmin_cfg_var
*vars
;
321 { "BYT-T FFD8", ffrd8_vars
},
322 { "T100TA", t100_vars
},
323 { "MRD7", mrd7_vars
},
324 { "ST70408", ecs7_vars
},
325 { "VTA0803", i8880_vars
},
329 #define GMIN_CFG_VAR_EFI_GUID EFI_GUID(0xecb54cd9, 0xe5ae, 0x4fdc, \
330 0xa9, 0x71, 0xe8, 0x77, \
331 0x75, 0x60, 0x68, 0xf7)
333 #define CFG_VAR_NAME_MAX 64
335 static int gmin_platform_init(struct i2c_client
*client
)
340 static int gmin_platform_deinit(void)
345 #define GMIN_PMC_CLK_NAME 14 /* "pmc_plt_clk_[0..5]" */
346 static char gmin_pmc_clk_name
[GMIN_PMC_CLK_NAME
];
348 static struct gmin_subdev
*gmin_subdev_add(struct v4l2_subdev
*subdev
)
352 struct i2c_client
*client
= v4l2_get_subdevdata(subdev
);
355 pmic_id
= PMIC_REGULATOR
;
362 for (i
= 0; i
< MAX_SUBDEVS
&& gmin_subdevs
[i
].subdev
; i
++)
364 if (i
>= MAX_SUBDEVS
)
368 "gmin: initializing atomisp module subdev data.PMIC ID %d\n",
371 gmin_subdevs
[i
].subdev
= subdev
;
372 gmin_subdevs
[i
].clock_num
= gmin_get_var_int(dev
, "CamClk", 0);
373 /*WA:CHT requires XTAL clock as PLL is not stable.*/
374 gmin_subdevs
[i
].clock_src
= gmin_get_var_int(dev
, "ClkSrc",
375 VLV2_CLK_PLL_19P2MHZ
);
376 gmin_subdevs
[i
].csi_port
= gmin_get_var_int(dev
, "CsiPort", 0);
377 gmin_subdevs
[i
].csi_lanes
= gmin_get_var_int(dev
, "CsiLanes", 1);
378 gmin_subdevs
[i
].gpio0
= gpiod_get_index(dev
, NULL
, 0, GPIOD_OUT_LOW
);
379 gmin_subdevs
[i
].gpio1
= gpiod_get_index(dev
, NULL
, 1, GPIOD_OUT_LOW
);
381 /* get PMC clock with clock framework */
382 snprintf(gmin_pmc_clk_name
,
383 sizeof(gmin_pmc_clk_name
),
384 "%s_%d", "pmc_plt_clk", gmin_subdevs
[i
].clock_num
);
386 gmin_subdevs
[i
].pmc_clk
= devm_clk_get(dev
, gmin_pmc_clk_name
);
387 if (IS_ERR(gmin_subdevs
[i
].pmc_clk
)) {
388 ret
= PTR_ERR(gmin_subdevs
[i
].pmc_clk
);
391 "Failed to get clk from %s : %d\n",
399 * The firmware might enable the clock at
400 * boot (this information may or may not
401 * be reflected in the enable clock register).
402 * To change the rate we must disable the clock
403 * first to cover these cases. Due to common
404 * clock framework restrictions that do not allow
405 * to disable a clock that has not been enabled,
406 * we need to enable the clock first.
408 ret
= clk_prepare_enable(gmin_subdevs
[i
].pmc_clk
);
410 clk_disable_unprepare(gmin_subdevs
[i
].pmc_clk
);
412 if (IS_ERR(gmin_subdevs
[i
].gpio0
))
413 gmin_subdevs
[i
].gpio0
= NULL
;
415 if (IS_ERR(gmin_subdevs
[i
].gpio1
))
416 gmin_subdevs
[i
].gpio1
= NULL
;
418 if (pmic_id
== PMIC_REGULATOR
) {
419 gmin_subdevs
[i
].v1p8_reg
= regulator_get(dev
, "V1P8SX");
420 gmin_subdevs
[i
].v2p8_reg
= regulator_get(dev
, "V2P8SX");
421 gmin_subdevs
[i
].v1p2_reg
= regulator_get(dev
, "V1P2A");
422 gmin_subdevs
[i
].v2p8_vcm_reg
= regulator_get(dev
, "VPROG4B");
424 /* Note: ideally we would initialize v[12]p8_on to the
425 * output of regulator_is_enabled(), but sadly that
426 * API is broken with the current drivers, returning
427 * "1" for a regulator that will then emit a
428 * "unbalanced disable" WARNing if we try to disable
433 return &gmin_subdevs
[i
];
436 static struct gmin_subdev
*find_gmin_subdev(struct v4l2_subdev
*subdev
)
440 for (i
= 0; i
< MAX_SUBDEVS
; i
++)
441 if (gmin_subdevs
[i
].subdev
== subdev
)
442 return &gmin_subdevs
[i
];
443 return gmin_subdev_add(subdev
);
446 static int gmin_gpio0_ctrl(struct v4l2_subdev
*subdev
, int on
)
448 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
450 if (gs
&& gs
->gpio0
) {
451 gpiod_set_value(gs
->gpio0
, on
);
457 static int gmin_gpio1_ctrl(struct v4l2_subdev
*subdev
, int on
)
459 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
461 if (gs
&& gs
->gpio1
) {
462 gpiod_set_value(gs
->gpio1
, on
);
468 static int gmin_v1p2_ctrl(struct v4l2_subdev
*subdev
, int on
)
470 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
472 if (gs
&& gs
->v1p2_on
== on
)
478 return regulator_enable(gs
->v1p2_reg
);
480 return regulator_disable(gs
->v1p2_reg
);
483 /*TODO:v1p2 needs to extend to other PMICs*/
488 static int gmin_v1p8_ctrl(struct v4l2_subdev
*subdev
, int on
)
490 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
493 if (v1p8_gpio
== V1P8_GPIO_UNSET
) {
494 v1p8_gpio
= gmin_get_var_int(NULL
, "V1P8GPIO", V1P8_GPIO_NONE
);
495 if (v1p8_gpio
!= V1P8_GPIO_NONE
) {
496 pr_info("atomisp_gmin_platform: 1.8v power on GPIO %d\n",
498 ret
= gpio_request(v1p8_gpio
, "camera_v1p8_en");
500 ret
= gpio_direction_output(v1p8_gpio
, 0);
502 pr_err("V1P8 GPIO initialization failed\n");
506 if (gs
&& gs
->v1p8_on
== on
)
511 gpio_set_value(v1p8_gpio
, on
);
514 regulator_set_voltage(gs
->v1p8_reg
, 1800000, 1800000);
516 return regulator_enable(gs
->v1p8_reg
);
518 return regulator_disable(gs
->v1p8_reg
);
524 static int gmin_v2p8_ctrl(struct v4l2_subdev
*subdev
, int on
)
526 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
529 if (v2p8_gpio
== V2P8_GPIO_UNSET
) {
530 v2p8_gpio
= gmin_get_var_int(NULL
, "V2P8GPIO", V2P8_GPIO_NONE
);
531 if (v2p8_gpio
!= V2P8_GPIO_NONE
) {
532 pr_info("atomisp_gmin_platform: 2.8v power on GPIO %d\n",
534 ret
= gpio_request(v2p8_gpio
, "camera_v2p8");
536 ret
= gpio_direction_output(v2p8_gpio
, 0);
538 pr_err("V2P8 GPIO initialization failed\n");
542 if (gs
&& gs
->v2p8_on
== on
)
547 gpio_set_value(v2p8_gpio
, on
);
550 regulator_set_voltage(gs
->v2p8_reg
, 2900000, 2900000);
552 return regulator_enable(gs
->v2p8_reg
);
554 return regulator_disable(gs
->v2p8_reg
);
560 static int gmin_flisclk_ctrl(struct v4l2_subdev
*subdev
, int on
)
563 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
564 struct i2c_client
*client
= v4l2_get_subdevdata(subdev
);
566 if (gs
->clock_on
== !!on
)
570 ret
= clk_set_rate(gs
->pmc_clk
, gs
->clock_src
);
573 dev_err(&client
->dev
, "unable to set PMC rate %d\n",
576 ret
= clk_prepare_enable(gs
->pmc_clk
);
580 clk_disable_unprepare(gs
->pmc_clk
);
581 gs
->clock_on
= false;
587 static int gmin_csi_cfg(struct v4l2_subdev
*sd
, int flag
)
589 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
590 struct gmin_subdev
*gs
= find_gmin_subdev(sd
);
595 return camera_sensor_csi(sd
, gs
->csi_port
, gs
->csi_lanes
,
596 gs
->csi_fmt
, gs
->csi_bayer
, flag
);
599 static struct camera_vcm_control
*gmin_get_vcm_ctrl(struct v4l2_subdev
*subdev
,
602 struct i2c_client
*client
= v4l2_get_subdevdata(subdev
);
603 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
604 struct camera_vcm_control
*vcm
;
606 if (client
== NULL
|| gs
== NULL
)
612 mutex_lock(&vcm_lock
);
613 list_for_each_entry(vcm
, &vcm_devices
, list
) {
614 if (!strcmp(camera_module
, vcm
->camera_module
)) {
615 mutex_unlock(&vcm_lock
);
620 mutex_unlock(&vcm_lock
);
624 static struct camera_sensor_platform_data gmin_plat
= {
625 .gpio0_ctrl
= gmin_gpio0_ctrl
,
626 .gpio1_ctrl
= gmin_gpio1_ctrl
,
627 .v1p8_ctrl
= gmin_v1p8_ctrl
,
628 .v2p8_ctrl
= gmin_v2p8_ctrl
,
629 .v1p2_ctrl
= gmin_v1p2_ctrl
,
630 .flisclk_ctrl
= gmin_flisclk_ctrl
,
631 .platform_init
= gmin_platform_init
,
632 .platform_deinit
= gmin_platform_deinit
,
633 .csi_cfg
= gmin_csi_cfg
,
634 .get_vcm_ctrl
= gmin_get_vcm_ctrl
,
637 struct camera_sensor_platform_data
*gmin_camera_platform_data(
638 struct v4l2_subdev
*subdev
,
639 enum atomisp_input_format csi_format
,
640 enum atomisp_bayer_order csi_bayer
)
642 struct gmin_subdev
*gs
= find_gmin_subdev(subdev
);
644 gs
->csi_fmt
= csi_format
;
645 gs
->csi_bayer
= csi_bayer
;
649 EXPORT_SYMBOL_GPL(gmin_camera_platform_data
);
651 int atomisp_gmin_register_vcm_control(struct camera_vcm_control
*vcmCtrl
)
656 mutex_lock(&vcm_lock
);
657 list_add_tail(&vcmCtrl
->list
, &vcm_devices
);
658 mutex_unlock(&vcm_lock
);
662 EXPORT_SYMBOL_GPL(atomisp_gmin_register_vcm_control
);
664 /* Retrieves a device-specific configuration variable. The dev
665 * argument should be a device with an ACPI companion, as all
666 * configuration is based on firmware ID.
668 int gmin_get_config_var(struct device
*dev
, const char *var
, char *out
,
671 char var8
[CFG_VAR_NAME_MAX
];
672 efi_char16_t var16
[CFG_VAR_NAME_MAX
];
673 struct efivar_entry
*ev
;
676 if (dev
&& ACPI_COMPANION(dev
))
677 dev
= &ACPI_COMPANION(dev
)->dev
;
680 ret
= snprintf(var8
, sizeof(var8
), "%s_%s", dev_name(dev
), var
);
682 ret
= snprintf(var8
, sizeof(var8
), "gmin_%s", var
);
684 if (ret
< 0 || ret
>= sizeof(var8
) - 1)
687 /* First check a hard-coded list of board-specific variables.
688 * Some device firmwares lack the ability to set EFI variables at
691 for (i
= 0; i
< ARRAY_SIZE(hard_vars
); i
++) {
692 if (dmi_match(DMI_BOARD_NAME
, hard_vars
[i
].dmi_board_name
)) {
693 for (j
= 0; hard_vars
[i
].vars
[j
].name
; j
++) {
695 const struct gmin_cfg_var
*gv
;
697 gv
= &hard_vars
[i
].vars
[j
];
698 vl
= strlen(gv
->val
);
700 if (strcmp(var8
, gv
->name
))
702 if (vl
> *out_len
- 1)
705 memcpy(out
, gv
->val
, min(*out_len
, vl
+1));
714 /* Our variable names are ASCII by construction, but EFI names
715 * are wide chars. Convert and zero-pad.
717 memset(var16
, 0, sizeof(var16
));
718 for (i
= 0; i
< sizeof(var8
) && var8
[i
]; i
++)
721 /* To avoid owerflows when calling the efivar API */
722 if (*out_len
> ULONG_MAX
)
725 /* Not sure this API usage is kosher; efivar_entry_get()'s
726 * implementation simply uses VariableName and VendorGuid from
727 * the struct and ignores the rest, but it seems like there
728 * ought to be an "official" efivar_entry registered
731 ev
= kzalloc(sizeof(*ev
), GFP_KERNEL
);
734 memcpy(&ev
->var
.VariableName
, var16
, sizeof(var16
));
735 ev
->var
.VendorGuid
= GMIN_CFG_VAR_EFI_GUID
;
736 ev
->var
.DataSize
= *out_len
;
738 ret
= efivar_entry_get(ev
, &ev
->var
.Attributes
,
739 &ev
->var
.DataSize
, ev
->var
.Data
);
741 memcpy(out
, ev
->var
.Data
, ev
->var
.DataSize
);
742 *out_len
= ev
->var
.DataSize
;
744 dev_warn(dev
, "Failed to find gmin variable %s\n", var8
);
751 EXPORT_SYMBOL_GPL(gmin_get_config_var
);
753 int gmin_get_var_int(struct device
*dev
, const char *var
, int def
)
755 char val
[CFG_VAR_NAME_MAX
];
756 size_t len
= sizeof(val
);
760 ret
= gmin_get_config_var(dev
, var
, val
, &len
);
763 ret
= kstrtol(val
, 0, &result
);
766 return ret
? def
: result
;
768 EXPORT_SYMBOL_GPL(gmin_get_var_int
);
770 int camera_sensor_csi(struct v4l2_subdev
*sd
, u32 port
,
771 u32 lanes
, u32 format
, u32 bayer_order
, int flag
)
773 struct i2c_client
*client
= v4l2_get_subdevdata(sd
);
774 struct camera_mipi_info
*csi
= NULL
;
777 csi
= kzalloc(sizeof(*csi
), GFP_KERNEL
);
781 csi
->num_lanes
= lanes
;
782 csi
->input_format
= format
;
783 csi
->raw_bayer_order
= bayer_order
;
784 v4l2_set_subdev_hostdata(sd
, (void *)csi
);
785 csi
->metadata_format
= ATOMISP_INPUT_FORMAT_EMBEDDED
;
786 csi
->metadata_effective_width
= NULL
;
787 dev_info(&client
->dev
,
788 "camera pdata: port: %d lanes: %d order: %8.8x\n",
789 port
, lanes
, bayer_order
);
791 csi
= v4l2_get_subdev_hostdata(sd
);
797 EXPORT_SYMBOL_GPL(camera_sensor_csi
);
799 /* PCI quirk: The BYT ISP advertises PCI runtime PM but it doesn't
800 * work. Disable so the kernel framework doesn't hang the device
801 * trying. The driver itself does direct calls to the PUNIT to manage
804 static void isp_pm_cap_fixup(struct pci_dev
*dev
)
806 dev_info(&dev
->dev
, "Disabling PCI power management on camera ISP\n");
809 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL
, 0x0f38, isp_pm_cap_fixup
);