1 // SPDX-License-Identifier: GPL-2.0
5 * Qualcomm MSM Camera Subsystem - CSIPHY Module
7 * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
8 * Copyright (C) 2016-2018 Linaro Ltd.
10 #include <linux/clk.h>
11 #include <linux/delay.h>
12 #include <linux/interrupt.h>
14 #include <linux/kernel.h>
16 #include <linux/platform_device.h>
17 #include <linux/pm_runtime.h>
18 #include <media/media-entity.h>
19 #include <media/v4l2-device.h>
20 #include <media/v4l2-subdev.h>
22 #include "camss-csiphy.h"
25 #define MSM_CSIPHY_NAME "msm_csiphy"
27 struct csiphy_format {
32 static const struct csiphy_format csiphy_formats_8x16[] = {
33 { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
34 { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
35 { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
36 { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
37 { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
38 { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
39 { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
40 { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
41 { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
42 { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
43 { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
44 { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
45 { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
46 { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
47 { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
48 { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
49 { MEDIA_BUS_FMT_Y10_1X10, 10 },
52 static const struct csiphy_format csiphy_formats_8x96[] = {
53 { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
54 { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
55 { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
56 { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
57 { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
58 { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
59 { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
60 { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
61 { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
62 { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
63 { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
64 { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
65 { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
66 { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
67 { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
68 { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
69 { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
70 { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
71 { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
72 { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
73 { MEDIA_BUS_FMT_Y10_1X10, 10 },
76 static const struct csiphy_format csiphy_formats_sdm845[] = {
77 { MEDIA_BUS_FMT_UYVY8_1X16, 8 },
78 { MEDIA_BUS_FMT_VYUY8_1X16, 8 },
79 { MEDIA_BUS_FMT_YUYV8_1X16, 8 },
80 { MEDIA_BUS_FMT_YVYU8_1X16, 8 },
81 { MEDIA_BUS_FMT_SBGGR8_1X8, 8 },
82 { MEDIA_BUS_FMT_SGBRG8_1X8, 8 },
83 { MEDIA_BUS_FMT_SGRBG8_1X8, 8 },
84 { MEDIA_BUS_FMT_SRGGB8_1X8, 8 },
85 { MEDIA_BUS_FMT_SBGGR10_1X10, 10 },
86 { MEDIA_BUS_FMT_SGBRG10_1X10, 10 },
87 { MEDIA_BUS_FMT_SGRBG10_1X10, 10 },
88 { MEDIA_BUS_FMT_SRGGB10_1X10, 10 },
89 { MEDIA_BUS_FMT_SBGGR12_1X12, 12 },
90 { MEDIA_BUS_FMT_SGBRG12_1X12, 12 },
91 { MEDIA_BUS_FMT_SGRBG12_1X12, 12 },
92 { MEDIA_BUS_FMT_SRGGB12_1X12, 12 },
93 { MEDIA_BUS_FMT_SBGGR14_1X14, 14 },
94 { MEDIA_BUS_FMT_SGBRG14_1X14, 14 },
95 { MEDIA_BUS_FMT_SGRBG14_1X14, 14 },
96 { MEDIA_BUS_FMT_SRGGB14_1X14, 14 },
97 { MEDIA_BUS_FMT_Y8_1X8, 8 },
98 { MEDIA_BUS_FMT_Y10_1X10, 10 },
102 * csiphy_get_bpp - map media bus format to bits per pixel
103 * @formats: supported media bus formats array
104 * @nformats: size of @formats array
105 * @code: media bus format code
107 * Return number of bits per pixel
109 static u8 csiphy_get_bpp(const struct csiphy_format *formats,
110 unsigned int nformats, u32 code)
114 for (i = 0; i < nformats; i++)
115 if (code == formats[i].code)
116 return formats[i].bpp;
118 WARN(1, "Unknown format\n");
120 return formats[0].bpp;
124 * csiphy_set_clock_rates - Calculate and set clock rates on CSIPHY module
125 * @csiphy: CSIPHY device
127 static int csiphy_set_clock_rates(struct csiphy_device *csiphy)
129 struct device *dev = csiphy->camss->dev;
134 u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats,
135 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
136 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
138 link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes);
142 for (i = 0; i < csiphy->nclocks; i++) {
143 struct camss_clock *clock = &csiphy->clock[i];
145 if (csiphy->rate_set[i]) {
146 u64 min_rate = link_freq / 4;
149 camss_add_clock_margin(&min_rate);
151 for (j = 0; j < clock->nfreqs; j++)
152 if (min_rate < clock->freq[j])
155 if (j == clock->nfreqs) {
157 "Pixel clock is too high for CSIPHY\n");
161 /* if sensor pixel clock is not available */
162 /* set highest possible CSIPHY clock rate */
164 j = clock->nfreqs - 1;
166 round_rate = clk_round_rate(clock->clk, clock->freq[j]);
167 if (round_rate < 0) {
168 dev_err(dev, "clk round rate failed: %ld\n",
173 csiphy->timer_clk_rate = round_rate;
175 ret = clk_set_rate(clock->clk, csiphy->timer_clk_rate);
177 dev_err(dev, "clk set rate failed: %d\n", ret);
187 * csiphy_set_power - Power on/off CSIPHY module
188 * @sd: CSIPHY V4L2 subdevice
189 * @on: Requested power state
191 * Return 0 on success or a negative error code otherwise
193 static int csiphy_set_power(struct v4l2_subdev *sd, int on)
195 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
196 struct device *dev = csiphy->camss->dev;
201 ret = pm_runtime_resume_and_get(dev);
205 ret = csiphy_set_clock_rates(csiphy);
207 pm_runtime_put_sync(dev);
211 ret = camss_enable_clocks(csiphy->nclocks, csiphy->clock, dev);
213 pm_runtime_put_sync(dev);
217 enable_irq(csiphy->irq);
219 csiphy->ops->reset(csiphy);
221 csiphy->ops->hw_version_read(csiphy, dev);
223 disable_irq(csiphy->irq);
225 camss_disable_clocks(csiphy->nclocks, csiphy->clock);
227 pm_runtime_put_sync(dev);
234 * csiphy_stream_on - Enable streaming on CSIPHY module
235 * @csiphy: CSIPHY device
237 * Helper function to enable streaming on CSIPHY module.
238 * Main configuration of CSIPHY module is also done here.
240 * Return 0 on success or a negative error code otherwise
242 static int csiphy_stream_on(struct csiphy_device *csiphy)
244 struct csiphy_config *cfg = &csiphy->cfg;
246 u8 lane_mask = csiphy->ops->get_lane_mask(&cfg->csi2->lane_cfg);
247 u8 bpp = csiphy_get_bpp(csiphy->formats, csiphy->nformats,
248 csiphy->fmt[MSM_CSIPHY_PAD_SINK].code);
249 u8 num_lanes = csiphy->cfg.csi2->lane_cfg.num_data;
252 link_freq = camss_get_link_freq(&csiphy->subdev.entity, bpp, num_lanes);
255 dev_err(csiphy->camss->dev,
256 "Cannot get CSI2 transmitter's link frequency\n");
260 if (csiphy->base_clk_mux) {
261 val = readl_relaxed(csiphy->base_clk_mux);
262 if (cfg->combo_mode && (lane_mask & 0x18) == 0x18) {
264 val |= cfg->csid_id << 4;
269 writel_relaxed(val, csiphy->base_clk_mux);
271 /* Enforce reg write ordering between clk mux & lane enabling */
275 csiphy->ops->lanes_enable(csiphy, cfg, link_freq, lane_mask);
281 * csiphy_stream_off - Disable streaming on CSIPHY module
282 * @csiphy: CSIPHY device
284 * Helper function to disable streaming on CSIPHY module
286 static void csiphy_stream_off(struct csiphy_device *csiphy)
288 csiphy->ops->lanes_disable(csiphy, &csiphy->cfg);
293 * csiphy_set_stream - Enable/disable streaming on CSIPHY module
294 * @sd: CSIPHY V4L2 subdevice
295 * @enable: Requested streaming state
297 * Return 0 on success or a negative error code otherwise
299 static int csiphy_set_stream(struct v4l2_subdev *sd, int enable)
301 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
305 ret = csiphy_stream_on(csiphy);
307 csiphy_stream_off(csiphy);
313 * __csiphy_get_format - Get pointer to format structure
314 * @csiphy: CSIPHY device
315 * @cfg: V4L2 subdev pad configuration
316 * @pad: pad from which format is requested
317 * @which: TRY or ACTIVE format
319 * Return pointer to TRY or ACTIVE format structure
321 static struct v4l2_mbus_framefmt *
322 __csiphy_get_format(struct csiphy_device *csiphy,
323 struct v4l2_subdev_state *sd_state,
325 enum v4l2_subdev_format_whence which)
327 if (which == V4L2_SUBDEV_FORMAT_TRY)
328 return v4l2_subdev_get_try_format(&csiphy->subdev, sd_state,
331 return &csiphy->fmt[pad];
335 * csiphy_try_format - Handle try format by pad subdev method
336 * @csiphy: CSIPHY device
337 * @cfg: V4L2 subdev pad configuration
338 * @pad: pad on which format is requested
339 * @fmt: pointer to v4l2 format structure
340 * @which: wanted subdev format
342 static void csiphy_try_format(struct csiphy_device *csiphy,
343 struct v4l2_subdev_state *sd_state,
345 struct v4l2_mbus_framefmt *fmt,
346 enum v4l2_subdev_format_whence which)
351 case MSM_CSIPHY_PAD_SINK:
352 /* Set format on sink pad */
354 for (i = 0; i < csiphy->nformats; i++)
355 if (fmt->code == csiphy->formats[i].code)
358 /* If not found, use UYVY as default */
359 if (i >= csiphy->nformats)
360 fmt->code = MEDIA_BUS_FMT_UYVY8_1X16;
362 fmt->width = clamp_t(u32, fmt->width, 1, 8191);
363 fmt->height = clamp_t(u32, fmt->height, 1, 8191);
365 fmt->field = V4L2_FIELD_NONE;
366 fmt->colorspace = V4L2_COLORSPACE_SRGB;
370 case MSM_CSIPHY_PAD_SRC:
371 /* Set and return a format same as sink pad */
373 *fmt = *__csiphy_get_format(csiphy, sd_state,
382 * csiphy_enum_mbus_code - Handle pixel format enumeration
383 * @sd: CSIPHY V4L2 subdevice
384 * @cfg: V4L2 subdev pad configuration
385 * @code: pointer to v4l2_subdev_mbus_code_enum structure
386 * return -EINVAL or zero on success
388 static int csiphy_enum_mbus_code(struct v4l2_subdev *sd,
389 struct v4l2_subdev_state *sd_state,
390 struct v4l2_subdev_mbus_code_enum *code)
392 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
393 struct v4l2_mbus_framefmt *format;
395 if (code->pad == MSM_CSIPHY_PAD_SINK) {
396 if (code->index >= csiphy->nformats)
399 code->code = csiphy->formats[code->index].code;
404 format = __csiphy_get_format(csiphy, sd_state,
408 code->code = format->code;
415 * csiphy_enum_frame_size - Handle frame size enumeration
416 * @sd: CSIPHY V4L2 subdevice
417 * @cfg: V4L2 subdev pad configuration
418 * @fse: pointer to v4l2_subdev_frame_size_enum structure
419 * return -EINVAL or zero on success
421 static int csiphy_enum_frame_size(struct v4l2_subdev *sd,
422 struct v4l2_subdev_state *sd_state,
423 struct v4l2_subdev_frame_size_enum *fse)
425 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
426 struct v4l2_mbus_framefmt format;
431 format.code = fse->code;
434 csiphy_try_format(csiphy, sd_state, fse->pad, &format, fse->which);
435 fse->min_width = format.width;
436 fse->min_height = format.height;
438 if (format.code != fse->code)
441 format.code = fse->code;
444 csiphy_try_format(csiphy, sd_state, fse->pad, &format, fse->which);
445 fse->max_width = format.width;
446 fse->max_height = format.height;
452 * csiphy_get_format - Handle get format by pads subdev method
453 * @sd: CSIPHY V4L2 subdevice
454 * @cfg: V4L2 subdev pad configuration
455 * @fmt: pointer to v4l2 subdev format structure
457 * Return -EINVAL or zero on success
459 static int csiphy_get_format(struct v4l2_subdev *sd,
460 struct v4l2_subdev_state *sd_state,
461 struct v4l2_subdev_format *fmt)
463 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
464 struct v4l2_mbus_framefmt *format;
466 format = __csiphy_get_format(csiphy, sd_state, fmt->pad, fmt->which);
470 fmt->format = *format;
476 * csiphy_set_format - Handle set format by pads subdev method
477 * @sd: CSIPHY V4L2 subdevice
478 * @cfg: V4L2 subdev pad configuration
479 * @fmt: pointer to v4l2 subdev format structure
481 * Return -EINVAL or zero on success
483 static int csiphy_set_format(struct v4l2_subdev *sd,
484 struct v4l2_subdev_state *sd_state,
485 struct v4l2_subdev_format *fmt)
487 struct csiphy_device *csiphy = v4l2_get_subdevdata(sd);
488 struct v4l2_mbus_framefmt *format;
490 format = __csiphy_get_format(csiphy, sd_state, fmt->pad, fmt->which);
494 csiphy_try_format(csiphy, sd_state, fmt->pad, &fmt->format,
496 *format = fmt->format;
498 /* Propagate the format from sink to source */
499 if (fmt->pad == MSM_CSIPHY_PAD_SINK) {
500 format = __csiphy_get_format(csiphy, sd_state,
504 *format = fmt->format;
505 csiphy_try_format(csiphy, sd_state, MSM_CSIPHY_PAD_SRC,
514 * csiphy_init_formats - Initialize formats on all pads
515 * @sd: CSIPHY V4L2 subdevice
516 * @fh: V4L2 subdev file handle
518 * Initialize all pad formats with default values.
520 * Return 0 on success or a negative error code otherwise
522 static int csiphy_init_formats(struct v4l2_subdev *sd,
523 struct v4l2_subdev_fh *fh)
525 struct v4l2_subdev_format format = {
526 .pad = MSM_CSIPHY_PAD_SINK,
527 .which = fh ? V4L2_SUBDEV_FORMAT_TRY :
528 V4L2_SUBDEV_FORMAT_ACTIVE,
530 .code = MEDIA_BUS_FMT_UYVY8_1X16,
536 return csiphy_set_format(sd, fh ? fh->state : NULL, &format);
539 static bool csiphy_match_clock_name(const char *clock_name, const char *format,
542 char name[16]; /* csiphyXXX_timer\0 */
544 snprintf(name, sizeof(name), format, index);
545 return !strcmp(clock_name, name);
549 * msm_csiphy_subdev_init - Initialize CSIPHY device structure and resources
550 * @csiphy: CSIPHY device
551 * @res: CSIPHY module resources table
552 * @id: CSIPHY module id
554 * Return 0 on success or a negative error code otherwise
556 int msm_csiphy_subdev_init(struct camss *camss,
557 struct csiphy_device *csiphy,
558 const struct camss_subdev_resources *res, u8 id)
560 struct device *dev = camss->dev;
561 struct platform_device *pdev = to_platform_device(dev);
565 csiphy->camss = camss;
567 csiphy->cfg.combo_mode = 0;
568 csiphy->ops = res->ops;
570 switch (camss->res->version) {
572 csiphy->formats = csiphy_formats_8x16;
573 csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x16);
577 csiphy->formats = csiphy_formats_8x96;
578 csiphy->nformats = ARRAY_SIZE(csiphy_formats_8x96);
582 csiphy->formats = csiphy_formats_sdm845;
583 csiphy->nformats = ARRAY_SIZE(csiphy_formats_sdm845);
589 csiphy->base = devm_platform_ioremap_resource_byname(pdev, res->reg[0]);
590 if (IS_ERR(csiphy->base))
591 return PTR_ERR(csiphy->base);
593 if (camss->res->version == CAMSS_8x16 ||
594 camss->res->version == CAMSS_8x96) {
595 csiphy->base_clk_mux =
596 devm_platform_ioremap_resource_byname(pdev, res->reg[1]);
597 if (IS_ERR(csiphy->base_clk_mux))
598 return PTR_ERR(csiphy->base_clk_mux);
600 csiphy->base_clk_mux = NULL;
605 ret = platform_get_irq_byname(pdev, res->interrupt[0]);
610 snprintf(csiphy->irq_name, sizeof(csiphy->irq_name), "%s_%s%d",
611 dev_name(dev), MSM_CSIPHY_NAME, csiphy->id);
613 ret = devm_request_irq(dev, csiphy->irq, csiphy->ops->isr,
614 IRQF_TRIGGER_RISING | IRQF_NO_AUTOEN,
615 csiphy->irq_name, csiphy);
617 dev_err(dev, "request_irq failed: %d\n", ret);
624 while (res->clock[csiphy->nclocks])
627 csiphy->clock = devm_kcalloc(dev,
628 csiphy->nclocks, sizeof(*csiphy->clock),
633 csiphy->rate_set = devm_kcalloc(dev,
635 sizeof(*csiphy->rate_set),
637 if (!csiphy->rate_set)
640 for (i = 0; i < csiphy->nclocks; i++) {
641 struct camss_clock *clock = &csiphy->clock[i];
643 clock->clk = devm_clk_get(dev, res->clock[i]);
644 if (IS_ERR(clock->clk))
645 return PTR_ERR(clock->clk);
647 clock->name = res->clock[i];
650 while (res->clock_rate[i][clock->nfreqs])
653 if (!clock->nfreqs) {
658 clock->freq = devm_kcalloc(dev,
660 sizeof(*clock->freq),
665 for (j = 0; j < clock->nfreqs; j++)
666 clock->freq[j] = res->clock_rate[i][j];
668 for (k = 0; k < camss->res->csiphy_num; k++) {
669 csiphy->rate_set[i] = csiphy_match_clock_name(clock->name,
670 "csiphy%d_timer", k);
671 if (csiphy->rate_set[i])
674 if (camss->res->version == CAMSS_660) {
675 csiphy->rate_set[i] = csiphy_match_clock_name(clock->name,
677 if (csiphy->rate_set[i])
681 csiphy->rate_set[i] = csiphy_match_clock_name(clock->name, "csiphy%d", k);
682 if (csiphy->rate_set[i])
691 * csiphy_link_setup - Setup CSIPHY connections
692 * @entity: Pointer to media entity structure
693 * @local: Pointer to local pad
694 * @remote: Pointer to remote pad
697 * Rreturn 0 on success
699 static int csiphy_link_setup(struct media_entity *entity,
700 const struct media_pad *local,
701 const struct media_pad *remote, u32 flags)
703 if ((local->flags & MEDIA_PAD_FL_SOURCE) &&
704 (flags & MEDIA_LNK_FL_ENABLED)) {
705 struct v4l2_subdev *sd;
706 struct csiphy_device *csiphy;
707 struct csid_device *csid;
709 if (media_pad_remote_pad_first(local))
712 sd = media_entity_to_v4l2_subdev(entity);
713 csiphy = v4l2_get_subdevdata(sd);
715 sd = media_entity_to_v4l2_subdev(remote->entity);
716 csid = v4l2_get_subdevdata(sd);
718 csiphy->cfg.csid_id = csid->id;
724 static const struct v4l2_subdev_core_ops csiphy_core_ops = {
725 .s_power = csiphy_set_power,
728 static const struct v4l2_subdev_video_ops csiphy_video_ops = {
729 .s_stream = csiphy_set_stream,
732 static const struct v4l2_subdev_pad_ops csiphy_pad_ops = {
733 .enum_mbus_code = csiphy_enum_mbus_code,
734 .enum_frame_size = csiphy_enum_frame_size,
735 .get_fmt = csiphy_get_format,
736 .set_fmt = csiphy_set_format,
739 static const struct v4l2_subdev_ops csiphy_v4l2_ops = {
740 .core = &csiphy_core_ops,
741 .video = &csiphy_video_ops,
742 .pad = &csiphy_pad_ops,
745 static const struct v4l2_subdev_internal_ops csiphy_v4l2_internal_ops = {
746 .open = csiphy_init_formats,
749 static const struct media_entity_operations csiphy_media_ops = {
750 .link_setup = csiphy_link_setup,
751 .link_validate = v4l2_subdev_link_validate,
755 * msm_csiphy_register_entity - Register subdev node for CSIPHY module
756 * @csiphy: CSIPHY device
757 * @v4l2_dev: V4L2 device
759 * Return 0 on success or a negative error code otherwise
761 int msm_csiphy_register_entity(struct csiphy_device *csiphy,
762 struct v4l2_device *v4l2_dev)
764 struct v4l2_subdev *sd = &csiphy->subdev;
765 struct media_pad *pads = csiphy->pads;
766 struct device *dev = csiphy->camss->dev;
769 v4l2_subdev_init(sd, &csiphy_v4l2_ops);
770 sd->internal_ops = &csiphy_v4l2_internal_ops;
771 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
772 snprintf(sd->name, ARRAY_SIZE(sd->name), "%s%d",
773 MSM_CSIPHY_NAME, csiphy->id);
774 v4l2_set_subdevdata(sd, csiphy);
776 ret = csiphy_init_formats(sd, NULL);
778 dev_err(dev, "Failed to init format: %d\n", ret);
782 pads[MSM_CSIPHY_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
783 pads[MSM_CSIPHY_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE;
785 sd->entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER;
786 sd->entity.ops = &csiphy_media_ops;
787 ret = media_entity_pads_init(&sd->entity, MSM_CSIPHY_PADS_NUM, pads);
789 dev_err(dev, "Failed to init media entity: %d\n", ret);
793 ret = v4l2_device_register_subdev(v4l2_dev, sd);
795 dev_err(dev, "Failed to register subdev: %d\n", ret);
796 media_entity_cleanup(&sd->entity);
803 * msm_csiphy_unregister_entity - Unregister CSIPHY module subdev node
804 * @csiphy: CSIPHY device
806 void msm_csiphy_unregister_entity(struct csiphy_device *csiphy)
808 v4l2_device_unregister_subdev(&csiphy->subdev);
809 media_entity_cleanup(&csiphy->subdev.entity);