1 // SPDX-License-Identifier: GPL-2.0
3 * imx214.c - imx214 sensor driver
5 * Copyright 2018 Qtechnology A/S
7 * Ricardo Ribalda <ribalda@kernel.org>
10 #include <linux/delay.h>
11 #include <linux/gpio/consumer.h>
12 #include <linux/i2c.h>
13 #include <linux/module.h>
14 #include <linux/pm_runtime.h>
15 #include <linux/regmap.h>
16 #include <linux/regulator/consumer.h>
17 #include <media/media-entity.h>
18 #include <media/v4l2-ctrls.h>
19 #include <media/v4l2-fwnode.h>
20 #include <media/v4l2-subdev.h>
22 #define IMX214_REG_MODE_SELECT 0x0100
23 #define IMX214_MODE_STANDBY 0x00
24 #define IMX214_MODE_STREAMING 0x01
26 #define IMX214_DEFAULT_CLK_FREQ 24000000
27 #define IMX214_DEFAULT_LINK_FREQ 480000000
28 #define IMX214_DEFAULT_PIXEL_RATE ((IMX214_DEFAULT_LINK_FREQ * 8LL) / 10)
30 #define IMX214_MBUS_CODE MEDIA_BUS_FMT_SRGGB10_1X10
32 /* Exposure control */
33 #define IMX214_REG_EXPOSURE 0x0202
34 #define IMX214_EXPOSURE_MIN 0
35 #define IMX214_EXPOSURE_MAX 3184
36 #define IMX214_EXPOSURE_STEP 1
37 #define IMX214_EXPOSURE_DEFAULT 3184
39 /* IMX214 native and active pixel array size */
40 #define IMX214_NATIVE_WIDTH 4224U
41 #define IMX214_NATIVE_HEIGHT 3136U
42 #define IMX214_PIXEL_ARRAY_LEFT 8U
43 #define IMX214_PIXEL_ARRAY_TOP 8U
44 #define IMX214_PIXEL_ARRAY_WIDTH 4208U
45 #define IMX214_PIXEL_ARRAY_HEIGHT 3120U
47 static const char * const imx214_supply_name
[] = {
53 #define IMX214_NUM_SUPPLIES ARRAY_SIZE(imx214_supply_name)
58 struct regmap
*regmap
;
60 struct v4l2_subdev sd
;
62 struct v4l2_mbus_framefmt fmt
;
63 struct v4l2_rect crop
;
65 struct v4l2_ctrl_handler ctrls
;
66 struct v4l2_ctrl
*pixel_rate
;
67 struct v4l2_ctrl
*link_freq
;
68 struct v4l2_ctrl
*exposure
;
69 struct v4l2_ctrl
*unit_size
;
71 struct regulator_bulk_data supplies
[IMX214_NUM_SUPPLIES
];
73 struct gpio_desc
*enable_gpio
;
76 * Serialize control access, get/set format, get selection
77 * and start streaming.
88 IMX214_TABLE_WAIT_MS
= 0,
94 /*From imx214_mode_tbls.h*/
95 static const struct reg_8 mode_4096x2304
[] = {
194 {IMX214_TABLE_WAIT_MS
, 10},
196 {IMX214_TABLE_END
, 0x00}
199 static const struct reg_8 mode_1920x1080
[] = {
298 {IMX214_TABLE_WAIT_MS
, 10},
300 {IMX214_TABLE_END
, 0x00}
303 static const struct reg_8 mode_table_common
[] = {
306 /* software standby settings */
312 /* external clock setting */
392 /* CNR parameter setting */
395 /* Moire reduction */
398 /* image enhancement */
420 {IMX214_TABLE_END
, 0x00}
424 * Declare modes in order, from biggest
425 * to smallest height.
427 static const struct imx214_mode
{
430 const struct reg_8
*reg_table
;
435 .reg_table
= mode_4096x2304
,
440 .reg_table
= mode_1920x1080
,
444 static inline struct imx214
*to_imx214(struct v4l2_subdev
*sd
)
446 return container_of(sd
, struct imx214
, sd
);
449 static int __maybe_unused
imx214_power_on(struct device
*dev
)
451 struct i2c_client
*client
= to_i2c_client(dev
);
452 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
453 struct imx214
*imx214
= to_imx214(sd
);
456 ret
= regulator_bulk_enable(IMX214_NUM_SUPPLIES
, imx214
->supplies
);
458 dev_err(imx214
->dev
, "failed to enable regulators: %d\n", ret
);
462 usleep_range(2000, 3000);
464 ret
= clk_prepare_enable(imx214
->xclk
);
466 regulator_bulk_disable(IMX214_NUM_SUPPLIES
, imx214
->supplies
);
467 dev_err(imx214
->dev
, "clk prepare enable failed\n");
471 gpiod_set_value_cansleep(imx214
->enable_gpio
, 1);
472 usleep_range(12000, 15000);
477 static int __maybe_unused
imx214_power_off(struct device
*dev
)
479 struct i2c_client
*client
= to_i2c_client(dev
);
480 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
481 struct imx214
*imx214
= to_imx214(sd
);
483 gpiod_set_value_cansleep(imx214
->enable_gpio
, 0);
485 clk_disable_unprepare(imx214
->xclk
);
487 regulator_bulk_disable(IMX214_NUM_SUPPLIES
, imx214
->supplies
);
488 usleep_range(10, 20);
493 static int imx214_enum_mbus_code(struct v4l2_subdev
*sd
,
494 struct v4l2_subdev_state
*sd_state
,
495 struct v4l2_subdev_mbus_code_enum
*code
)
500 code
->code
= IMX214_MBUS_CODE
;
505 static int imx214_enum_frame_size(struct v4l2_subdev
*subdev
,
506 struct v4l2_subdev_state
*sd_state
,
507 struct v4l2_subdev_frame_size_enum
*fse
)
509 if (fse
->code
!= IMX214_MBUS_CODE
)
512 if (fse
->index
>= ARRAY_SIZE(imx214_modes
))
515 fse
->min_width
= fse
->max_width
= imx214_modes
[fse
->index
].width
;
516 fse
->min_height
= fse
->max_height
= imx214_modes
[fse
->index
].height
;
521 #ifdef CONFIG_VIDEO_ADV_DEBUG
522 static int imx214_s_register(struct v4l2_subdev
*subdev
,
523 const struct v4l2_dbg_register
*reg
)
525 struct imx214
*imx214
= container_of(subdev
, struct imx214
, sd
);
527 return regmap_write(imx214
->regmap
, reg
->reg
, reg
->val
);
530 static int imx214_g_register(struct v4l2_subdev
*subdev
,
531 struct v4l2_dbg_register
*reg
)
533 struct imx214
*imx214
= container_of(subdev
, struct imx214
, sd
);
538 ret
= regmap_read(imx214
->regmap
, reg
->reg
, &aux
);
545 static const struct v4l2_subdev_core_ops imx214_core_ops
= {
546 #ifdef CONFIG_VIDEO_ADV_DEBUG
547 .g_register
= imx214_g_register
,
548 .s_register
= imx214_s_register
,
552 static struct v4l2_mbus_framefmt
*
553 __imx214_get_pad_format(struct imx214
*imx214
,
554 struct v4l2_subdev_state
*sd_state
,
556 enum v4l2_subdev_format_whence which
)
559 case V4L2_SUBDEV_FORMAT_TRY
:
560 return v4l2_subdev_state_get_format(sd_state
, pad
);
561 case V4L2_SUBDEV_FORMAT_ACTIVE
:
568 static int imx214_get_format(struct v4l2_subdev
*sd
,
569 struct v4l2_subdev_state
*sd_state
,
570 struct v4l2_subdev_format
*format
)
572 struct imx214
*imx214
= to_imx214(sd
);
574 mutex_lock(&imx214
->mutex
);
575 format
->format
= *__imx214_get_pad_format(imx214
, sd_state
,
578 mutex_unlock(&imx214
->mutex
);
583 static struct v4l2_rect
*
584 __imx214_get_pad_crop(struct imx214
*imx214
,
585 struct v4l2_subdev_state
*sd_state
,
586 unsigned int pad
, enum v4l2_subdev_format_whence which
)
589 case V4L2_SUBDEV_FORMAT_TRY
:
590 return v4l2_subdev_state_get_crop(sd_state
, pad
);
591 case V4L2_SUBDEV_FORMAT_ACTIVE
:
592 return &imx214
->crop
;
598 static int imx214_set_format(struct v4l2_subdev
*sd
,
599 struct v4l2_subdev_state
*sd_state
,
600 struct v4l2_subdev_format
*format
)
602 struct imx214
*imx214
= to_imx214(sd
);
603 struct v4l2_mbus_framefmt
*__format
;
604 struct v4l2_rect
*__crop
;
605 const struct imx214_mode
*mode
;
607 mutex_lock(&imx214
->mutex
);
609 __crop
= __imx214_get_pad_crop(imx214
, sd_state
, format
->pad
,
612 mode
= v4l2_find_nearest_size(imx214_modes
,
613 ARRAY_SIZE(imx214_modes
), width
, height
,
614 format
->format
.width
,
615 format
->format
.height
);
617 __crop
->width
= mode
->width
;
618 __crop
->height
= mode
->height
;
620 __format
= __imx214_get_pad_format(imx214
, sd_state
, format
->pad
,
622 __format
->width
= __crop
->width
;
623 __format
->height
= __crop
->height
;
624 __format
->code
= IMX214_MBUS_CODE
;
625 __format
->field
= V4L2_FIELD_NONE
;
626 __format
->colorspace
= V4L2_COLORSPACE_SRGB
;
627 __format
->ycbcr_enc
= V4L2_MAP_YCBCR_ENC_DEFAULT(__format
->colorspace
);
628 __format
->quantization
= V4L2_MAP_QUANTIZATION_DEFAULT(true,
629 __format
->colorspace
, __format
->ycbcr_enc
);
630 __format
->xfer_func
= V4L2_MAP_XFER_FUNC_DEFAULT(__format
->colorspace
);
632 format
->format
= *__format
;
634 mutex_unlock(&imx214
->mutex
);
639 static int imx214_get_selection(struct v4l2_subdev
*sd
,
640 struct v4l2_subdev_state
*sd_state
,
641 struct v4l2_subdev_selection
*sel
)
643 struct imx214
*imx214
= to_imx214(sd
);
645 switch (sel
->target
) {
646 case V4L2_SEL_TGT_CROP
:
647 mutex_lock(&imx214
->mutex
);
648 sel
->r
= *__imx214_get_pad_crop(imx214
, sd_state
, sel
->pad
,
650 mutex_unlock(&imx214
->mutex
);
653 case V4L2_SEL_TGT_NATIVE_SIZE
:
656 sel
->r
.width
= IMX214_NATIVE_WIDTH
;
657 sel
->r
.height
= IMX214_NATIVE_HEIGHT
;
660 case V4L2_SEL_TGT_CROP_DEFAULT
:
661 case V4L2_SEL_TGT_CROP_BOUNDS
:
662 sel
->r
.top
= IMX214_PIXEL_ARRAY_TOP
;
663 sel
->r
.left
= IMX214_PIXEL_ARRAY_LEFT
;
664 sel
->r
.width
= IMX214_PIXEL_ARRAY_WIDTH
;
665 sel
->r
.height
= IMX214_PIXEL_ARRAY_HEIGHT
;
672 static int imx214_entity_init_state(struct v4l2_subdev
*subdev
,
673 struct v4l2_subdev_state
*sd_state
)
675 struct v4l2_subdev_format fmt
= { };
677 fmt
.which
= sd_state
? V4L2_SUBDEV_FORMAT_TRY
: V4L2_SUBDEV_FORMAT_ACTIVE
;
678 fmt
.format
.width
= imx214_modes
[0].width
;
679 fmt
.format
.height
= imx214_modes
[0].height
;
681 imx214_set_format(subdev
, sd_state
, &fmt
);
686 static int imx214_set_ctrl(struct v4l2_ctrl
*ctrl
)
688 struct imx214
*imx214
= container_of(ctrl
->handler
,
689 struct imx214
, ctrls
);
694 * Applying V4L2 control value only happens
695 * when power is up for streaming
697 if (!pm_runtime_get_if_in_use(imx214
->dev
))
701 case V4L2_CID_EXPOSURE
:
703 vals
[0] = ctrl
->val
>> 8;
704 ret
= regmap_bulk_write(imx214
->regmap
, IMX214_REG_EXPOSURE
, vals
, 2);
706 dev_err(imx214
->dev
, "Error %d\n", ret
);
714 pm_runtime_put(imx214
->dev
);
719 static const struct v4l2_ctrl_ops imx214_ctrl_ops
= {
720 .s_ctrl
= imx214_set_ctrl
,
723 static int imx214_ctrls_init(struct imx214
*imx214
)
725 static const s64 link_freq
[] = {
726 IMX214_DEFAULT_LINK_FREQ
728 static const struct v4l2_area unit_size
= {
732 struct v4l2_fwnode_device_properties props
;
733 struct v4l2_ctrl_handler
*ctrl_hdlr
;
736 ret
= v4l2_fwnode_device_parse(imx214
->dev
, &props
);
740 ctrl_hdlr
= &imx214
->ctrls
;
741 ret
= v4l2_ctrl_handler_init(&imx214
->ctrls
, 6);
745 imx214
->pixel_rate
= v4l2_ctrl_new_std(ctrl_hdlr
, NULL
,
746 V4L2_CID_PIXEL_RATE
, 0,
747 IMX214_DEFAULT_PIXEL_RATE
, 1,
748 IMX214_DEFAULT_PIXEL_RATE
);
750 imx214
->link_freq
= v4l2_ctrl_new_int_menu(ctrl_hdlr
, NULL
,
752 ARRAY_SIZE(link_freq
) - 1,
754 if (imx214
->link_freq
)
755 imx214
->link_freq
->flags
|= V4L2_CTRL_FLAG_READ_ONLY
;
759 * Values obtained reverse engineering blobs and/or devices.
760 * Ranges and functionality might be wrong.
762 * Sony, please release some register set documentation for the
765 * Yours sincerely, Ricardo.
767 imx214
->exposure
= v4l2_ctrl_new_std(ctrl_hdlr
, &imx214_ctrl_ops
,
771 IMX214_EXPOSURE_STEP
,
772 IMX214_EXPOSURE_DEFAULT
);
774 imx214
->unit_size
= v4l2_ctrl_new_std_compound(ctrl_hdlr
,
776 V4L2_CID_UNIT_CELL_SIZE
,
777 v4l2_ctrl_ptr_create((void *)&unit_size
));
779 v4l2_ctrl_new_fwnode_properties(ctrl_hdlr
, &imx214_ctrl_ops
, &props
);
781 ret
= ctrl_hdlr
->error
;
783 v4l2_ctrl_handler_free(ctrl_hdlr
);
784 dev_err(imx214
->dev
, "failed to add controls: %d\n", ret
);
788 imx214
->sd
.ctrl_handler
= ctrl_hdlr
;
794 static int imx214_write_table(struct imx214
*imx214
,
795 const struct reg_8 table
[])
801 for (; table
->addr
!= IMX214_TABLE_END
; table
++) {
802 if (table
->addr
== IMX214_TABLE_WAIT_MS
) {
803 usleep_range(table
->val
* 1000,
804 table
->val
* 1000 + 500);
808 for (i
= 0; i
< MAX_CMD
; i
++) {
809 if (table
[i
].addr
!= (table
[0].addr
+ i
))
811 vals
[i
] = table
[i
].val
;
814 ret
= regmap_bulk_write(imx214
->regmap
, table
->addr
, vals
, i
);
817 dev_err(imx214
->dev
, "write_table error: %d\n", ret
);
827 static int imx214_start_streaming(struct imx214
*imx214
)
829 const struct imx214_mode
*mode
;
832 mutex_lock(&imx214
->mutex
);
833 ret
= imx214_write_table(imx214
, mode_table_common
);
835 dev_err(imx214
->dev
, "could not sent common table %d\n", ret
);
839 mode
= v4l2_find_nearest_size(imx214_modes
,
840 ARRAY_SIZE(imx214_modes
), width
, height
,
841 imx214
->fmt
.width
, imx214
->fmt
.height
);
842 ret
= imx214_write_table(imx214
, mode
->reg_table
);
844 dev_err(imx214
->dev
, "could not sent mode table %d\n", ret
);
847 ret
= __v4l2_ctrl_handler_setup(&imx214
->ctrls
);
849 dev_err(imx214
->dev
, "could not sync v4l2 controls\n");
852 ret
= regmap_write(imx214
->regmap
, IMX214_REG_MODE_SELECT
, IMX214_MODE_STREAMING
);
854 dev_err(imx214
->dev
, "could not sent start table %d\n", ret
);
858 mutex_unlock(&imx214
->mutex
);
862 mutex_unlock(&imx214
->mutex
);
866 static int imx214_stop_streaming(struct imx214
*imx214
)
870 ret
= regmap_write(imx214
->regmap
, IMX214_REG_MODE_SELECT
, IMX214_MODE_STANDBY
);
872 dev_err(imx214
->dev
, "could not sent stop table %d\n", ret
);
877 static int imx214_s_stream(struct v4l2_subdev
*subdev
, int enable
)
879 struct imx214
*imx214
= to_imx214(subdev
);
883 ret
= pm_runtime_resume_and_get(imx214
->dev
);
887 ret
= imx214_start_streaming(imx214
);
891 ret
= imx214_stop_streaming(imx214
);
894 pm_runtime_put(imx214
->dev
);
900 pm_runtime_put(imx214
->dev
);
904 static int imx214_get_frame_interval(struct v4l2_subdev
*subdev
,
905 struct v4l2_subdev_state
*sd_state
,
906 struct v4l2_subdev_frame_interval
*fival
)
909 * FIXME: Implement support for V4L2_SUBDEV_FORMAT_TRY, using the V4L2
910 * subdev active state API.
912 if (fival
->which
!= V4L2_SUBDEV_FORMAT_ACTIVE
)
915 fival
->interval
.numerator
= 1;
916 fival
->interval
.denominator
= IMX214_FPS
;
921 static int imx214_enum_frame_interval(struct v4l2_subdev
*subdev
,
922 struct v4l2_subdev_state
*sd_state
,
923 struct v4l2_subdev_frame_interval_enum
*fie
)
925 const struct imx214_mode
*mode
;
930 mode
= v4l2_find_nearest_size(imx214_modes
,
931 ARRAY_SIZE(imx214_modes
), width
, height
,
932 fie
->width
, fie
->height
);
934 fie
->code
= IMX214_MBUS_CODE
;
935 fie
->width
= mode
->width
;
936 fie
->height
= mode
->height
;
937 fie
->interval
.numerator
= 1;
938 fie
->interval
.denominator
= IMX214_FPS
;
943 static const struct v4l2_subdev_video_ops imx214_video_ops
= {
944 .s_stream
= imx214_s_stream
,
947 static const struct v4l2_subdev_pad_ops imx214_subdev_pad_ops
= {
948 .enum_mbus_code
= imx214_enum_mbus_code
,
949 .enum_frame_size
= imx214_enum_frame_size
,
950 .enum_frame_interval
= imx214_enum_frame_interval
,
951 .get_fmt
= imx214_get_format
,
952 .set_fmt
= imx214_set_format
,
953 .get_selection
= imx214_get_selection
,
954 .get_frame_interval
= imx214_get_frame_interval
,
955 .set_frame_interval
= imx214_get_frame_interval
,
958 static const struct v4l2_subdev_ops imx214_subdev_ops
= {
959 .core
= &imx214_core_ops
,
960 .video
= &imx214_video_ops
,
961 .pad
= &imx214_subdev_pad_ops
,
964 static const struct v4l2_subdev_internal_ops imx214_internal_ops
= {
965 .init_state
= imx214_entity_init_state
,
968 static const struct regmap_config sensor_regmap_config
= {
971 .cache_type
= REGCACHE_MAPLE
,
974 static int imx214_get_regulators(struct device
*dev
, struct imx214
*imx214
)
978 for (i
= 0; i
< IMX214_NUM_SUPPLIES
; i
++)
979 imx214
->supplies
[i
].supply
= imx214_supply_name
[i
];
981 return devm_regulator_bulk_get(dev
, IMX214_NUM_SUPPLIES
,
985 static int imx214_parse_fwnode(struct device
*dev
)
987 struct fwnode_handle
*endpoint
;
988 struct v4l2_fwnode_endpoint bus_cfg
= {
989 .bus_type
= V4L2_MBUS_CSI2_DPHY
,
994 endpoint
= fwnode_graph_get_next_endpoint(dev_fwnode(dev
), NULL
);
996 dev_err(dev
, "endpoint node not found\n");
1000 ret
= v4l2_fwnode_endpoint_alloc_parse(endpoint
, &bus_cfg
);
1002 dev_err(dev
, "parsing endpoint node failed\n");
1006 for (i
= 0; i
< bus_cfg
.nr_of_link_frequencies
; i
++)
1007 if (bus_cfg
.link_frequencies
[i
] == IMX214_DEFAULT_LINK_FREQ
)
1010 if (i
== bus_cfg
.nr_of_link_frequencies
) {
1011 dev_err(dev
, "link-frequencies %d not supported, Please review your DT\n",
1012 IMX214_DEFAULT_LINK_FREQ
);
1018 v4l2_fwnode_endpoint_free(&bus_cfg
);
1019 fwnode_handle_put(endpoint
);
1023 static int imx214_probe(struct i2c_client
*client
)
1025 struct device
*dev
= &client
->dev
;
1026 struct imx214
*imx214
;
1029 ret
= imx214_parse_fwnode(dev
);
1033 imx214
= devm_kzalloc(dev
, sizeof(*imx214
), GFP_KERNEL
);
1039 imx214
->xclk
= devm_clk_get(dev
, NULL
);
1040 if (IS_ERR(imx214
->xclk
)) {
1041 dev_err(dev
, "could not get xclk");
1042 return PTR_ERR(imx214
->xclk
);
1045 ret
= clk_set_rate(imx214
->xclk
, IMX214_DEFAULT_CLK_FREQ
);
1047 dev_err(dev
, "could not set xclk frequency\n");
1051 ret
= imx214_get_regulators(dev
, imx214
);
1053 dev_err(dev
, "cannot get regulators\n");
1057 imx214
->enable_gpio
= devm_gpiod_get(dev
, "enable", GPIOD_OUT_LOW
);
1058 if (IS_ERR(imx214
->enable_gpio
)) {
1059 dev_err(dev
, "cannot get enable gpio\n");
1060 return PTR_ERR(imx214
->enable_gpio
);
1063 imx214
->regmap
= devm_regmap_init_i2c(client
, &sensor_regmap_config
);
1064 if (IS_ERR(imx214
->regmap
)) {
1065 dev_err(dev
, "regmap init failed\n");
1066 return PTR_ERR(imx214
->regmap
);
1069 v4l2_i2c_subdev_init(&imx214
->sd
, client
, &imx214_subdev_ops
);
1070 imx214
->sd
.internal_ops
= &imx214_internal_ops
;
1073 * Enable power initially, to avoid warnings
1074 * from clk_disable on power_off
1076 imx214_power_on(imx214
->dev
);
1078 pm_runtime_set_active(imx214
->dev
);
1079 pm_runtime_enable(imx214
->dev
);
1080 pm_runtime_idle(imx214
->dev
);
1082 ret
= imx214_ctrls_init(imx214
);
1084 goto error_power_off
;
1086 mutex_init(&imx214
->mutex
);
1087 imx214
->ctrls
.lock
= &imx214
->mutex
;
1089 imx214
->sd
.flags
|= V4L2_SUBDEV_FL_HAS_DEVNODE
;
1090 imx214
->pad
.flags
= MEDIA_PAD_FL_SOURCE
;
1091 imx214
->sd
.dev
= &client
->dev
;
1092 imx214
->sd
.entity
.function
= MEDIA_ENT_F_CAM_SENSOR
;
1094 ret
= media_entity_pads_init(&imx214
->sd
.entity
, 1, &imx214
->pad
);
1096 dev_err(dev
, "could not register media entity\n");
1100 imx214_entity_init_state(&imx214
->sd
, NULL
);
1102 ret
= v4l2_async_register_subdev_sensor(&imx214
->sd
);
1104 dev_err(dev
, "could not register v4l2 device\n");
1111 media_entity_cleanup(&imx214
->sd
.entity
);
1113 mutex_destroy(&imx214
->mutex
);
1114 v4l2_ctrl_handler_free(&imx214
->ctrls
);
1116 pm_runtime_disable(imx214
->dev
);
1117 regulator_bulk_disable(IMX214_NUM_SUPPLIES
, imx214
->supplies
);
1122 static void imx214_remove(struct i2c_client
*client
)
1124 struct v4l2_subdev
*sd
= i2c_get_clientdata(client
);
1125 struct imx214
*imx214
= to_imx214(sd
);
1127 v4l2_async_unregister_subdev(&imx214
->sd
);
1128 media_entity_cleanup(&imx214
->sd
.entity
);
1129 v4l2_ctrl_handler_free(&imx214
->ctrls
);
1131 pm_runtime_disable(&client
->dev
);
1132 pm_runtime_set_suspended(&client
->dev
);
1134 mutex_destroy(&imx214
->mutex
);
1137 static const struct of_device_id imx214_of_match
[] = {
1138 { .compatible
= "sony,imx214" },
1141 MODULE_DEVICE_TABLE(of
, imx214_of_match
);
1143 static const struct dev_pm_ops imx214_pm_ops
= {
1144 SET_RUNTIME_PM_OPS(imx214_power_off
, imx214_power_on
, NULL
)
1147 static struct i2c_driver imx214_i2c_driver
= {
1149 .of_match_table
= imx214_of_match
,
1150 .pm
= &imx214_pm_ops
,
1153 .probe
= imx214_probe
,
1154 .remove
= imx214_remove
,
1157 module_i2c_driver(imx214_i2c_driver
);
1159 MODULE_DESCRIPTION("Sony IMX214 Camera driver");
1160 MODULE_AUTHOR("Ricardo Ribalda <ribalda@kernel.org>");
1161 MODULE_LICENSE("GPL v2");