Lines Matching +full:r8a7796 +full:- +full:csi2
1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for Renesas R-Car MIPI CSI-2 Receiver
19 #include <media/mipi-csi2.h>
20 #include <media/v4l2-ctrls.h>
21 #include <media/v4l2-device.h>
22 #include <media/v4l2-fwnode.h>
23 #include <media/v4l2-mc.h>
24 #include <media/v4l2-subdev.h>
55 * VCDT[0-15]: Channel 0 VCDT[16-31]: Channel 1
56 * VCDT2[0-15]: Channel 2 VCDT2[16-31]: Channel 3
154 #define V4H_PPI_STARTUP_RW_COMMON_DPHY_REG(n) (0x21800 + ((n) * 2)) /* n = 0 - 9 */
168 #define V4H_CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_REG(n) (0x22040 + ((n) * 2)) /* n = 0 - 15 */
169 #define V4H_CORE_DIG_IOCTRL_RW_AFE_LANE1_CTRL_2_REG(n) (0x22440 + ((n) * 2)) /* n = 0 - 15 */
170 #define V4H_CORE_DIG_IOCTRL_RW_AFE_LANE2_CTRL_2_REG(n) (0x22840 + ((n) * 2)) /* n = 0 - 15 */
171 #define V4H_CORE_DIG_IOCTRL_RW_AFE_LANE3_CTRL_2_REG(n) (0x22c40 + ((n) * 2)) /* n = 0 - 15 */
172 #define V4H_CORE_DIG_IOCTRL_RW_AFE_LANE4_CTRL_2_REG(n) (0x23040 + ((n) * 2)) /* n = 0 - 15 */
173 #define V4H_CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_REG(n) (0x23840 + ((n) * 2)) /* n = 0 - 11 */
174 #define V4H_CORE_DIG_RW_COMMON_REG(n) (0x23880 + ((n) * 2)) /* n = 0 - 15 */
175 #define V4H_CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_REG(n) (0x239e0 + ((n) * 2)) /* n = 0 - 3 */
179 /* V4H C-PHY */
180 #define V4H_CORE_DIG_RW_TRIO0_REG(n) (0x22100 + ((n) * 2)) /* n = 0 - 3 */
181 #define V4H_CORE_DIG_RW_TRIO1_REG(n) (0x22500 + ((n) * 2)) /* n = 0 - 3 */
182 #define V4H_CORE_DIG_RW_TRIO2_REG(n) (0x22900 + ((n) * 2)) /* n = 0 - 3 */
184 #define V4H_CORE_DIG_CLANE_0_RW_HS_RX_REG(n) (0x2a100 + ((n) * 2)) /* n = 0 - 6 */
186 #define V4H_CORE_DIG_CLANE_1_RW_HS_RX_REG(n) (0x2a500 + ((n) * 2)) /* n = 0 - 6 */
188 #define V4H_CORE_DIG_CLANE_2_RW_HS_RX_REG(n) (0x2a900 + ((n) * 2)) /* n = 0 - 6 */
636 /* Used together with R-Car ISP: one sink and one source pad. */ in rcsi2_num_pads()
637 if (priv->info->use_isp) in rcsi2_num_pads()
640 /* Used together with R-Car VIN: one sink and four source pads. */ in rcsi2_num_pads()
646 return ioread32(priv->base + reg); in rcsi2_read()
651 iowrite32(data, priv->base + reg); in rcsi2_write()
656 iowrite16(data, priv->base + reg); in rcsi2_write16()
667 if (priv->info->enter_standby) in rcsi2_enter_standby()
668 priv->info->enter_standby(priv); in rcsi2_enter_standby()
670 reset_control_assert(priv->rstc); in rcsi2_enter_standby()
672 pm_runtime_put(priv->dev); in rcsi2_enter_standby()
679 ret = pm_runtime_resume_and_get(priv->dev); in rcsi2_exit_standby()
683 reset_control_deassert(priv->rstc); in rcsi2_exit_standby()
693 /* Wait for the clock and data lanes to enter LP-11 state. */ in rcsi2_wait_phy_start()
695 const u32 lane_mask = (1 << lanes) - 1; in rcsi2_wait_phy_start()
704 dev_err(priv->dev, "Timeout waiting for LP-11 state\n"); in rcsi2_wait_phy_start()
706 return -ETIMEDOUT; in rcsi2_wait_phy_start()
714 if (mbps < priv->info->hsfreqrange->mbps) in rcsi2_set_phypll()
715 dev_warn(priv->dev, "%u Mbps less than min PHY speed %u Mbps", in rcsi2_set_phypll()
716 mbps, priv->info->hsfreqrange->mbps); in rcsi2_set_phypll()
718 for (hsfreq = priv->info->hsfreqrange; hsfreq->mbps != 0; hsfreq++) { in rcsi2_set_phypll()
719 if (hsfreq->mbps >= mbps) in rcsi2_set_phypll()
724 if (!hsfreq->mbps) { in rcsi2_set_phypll()
725 dev_err(priv->dev, "Unsupported PHY speed (%u Mbps)", mbps); in rcsi2_set_phypll()
726 return -ERANGE; in rcsi2_set_phypll()
730 ((mbps - hsfreq_prev->mbps) <= (hsfreq->mbps - mbps))) in rcsi2_set_phypll()
733 rcsi2_write(priv, PHYPLL_REG, PHYPLL_HSFREQRANGE(hsfreq->reg)); in rcsi2_set_phypll()
745 if (!priv->remote) in rcsi2_calc_mbps()
746 return -ENODEV; in rcsi2_calc_mbps()
748 source = priv->remote; in rcsi2_calc_mbps()
751 ctrl = v4l2_ctrl_find(source->ctrl_handler, V4L2_CID_PIXEL_RATE); in rcsi2_calc_mbps()
753 dev_err(priv->dev, "no pixel rate control in subdev %s\n", in rcsi2_calc_mbps()
754 source->name); in rcsi2_calc_mbps()
755 return -EINVAL; in rcsi2_calc_mbps()
766 /* Adjust for C-PHY, divide by 2.8. */ in rcsi2_calc_mbps()
767 if (priv->cphy) in rcsi2_calc_mbps()
779 *lanes = priv->lanes; in rcsi2_get_active_lanes()
781 ret = v4l2_subdev_call(priv->remote, pad, get_mbus_config, in rcsi2_get_active_lanes()
782 priv->remote_pad, &mbus_config); in rcsi2_get_active_lanes()
783 if (ret == -ENOIOCTLCMD) { in rcsi2_get_active_lanes()
784 dev_dbg(priv->dev, "No remote mbus configuration available\n"); in rcsi2_get_active_lanes()
789 dev_err(priv->dev, "Failed to get remote mbus configuration\n"); in rcsi2_get_active_lanes()
795 if (!priv->cphy) in rcsi2_get_active_lanes()
796 return -EINVAL; in rcsi2_get_active_lanes()
799 if (priv->cphy) in rcsi2_get_active_lanes()
800 return -EINVAL; in rcsi2_get_active_lanes()
803 dev_err(priv->dev, "Unsupported media bus type %u\n", in rcsi2_get_active_lanes()
805 return -EINVAL; in rcsi2_get_active_lanes()
808 if (mbus_config.bus.mipi_csi2.num_data_lanes > priv->lanes) { in rcsi2_get_active_lanes()
809 dev_err(priv->dev, in rcsi2_get_active_lanes()
812 return -EINVAL; in rcsi2_get_active_lanes()
833 dev_dbg(priv->dev, "Input size (%ux%u%c)\n", in rcsi2_start_receiver_gen3()
834 fmt->width, fmt->height, in rcsi2_start_receiver_gen3()
835 fmt->field == V4L2_FIELD_NONE ? 'p' : 'i'); in rcsi2_start_receiver_gen3()
838 format = rcsi2_code_to_fmt(fmt->code); in rcsi2_start_receiver_gen3()
840 return -EINVAL; in rcsi2_start_receiver_gen3()
843 * Enable all supported CSI-2 channels with virtual channel and in rcsi2_start_receiver_gen3()
850 for (i = 0; i < priv->info->num_channels; i++) { in rcsi2_start_receiver_gen3()
853 if (priv->channel_vc[i] < 0) in rcsi2_start_receiver_gen3()
856 vcdt_part = VCDT_SEL_VC(priv->channel_vc[i]) | VCDT_VCDTN_EN | in rcsi2_start_receiver_gen3()
857 VCDT_SEL_DTN_ON | VCDT_SEL_DT(format->datatype); in rcsi2_start_receiver_gen3()
866 if (fmt->field == V4L2_FIELD_ALTERNATE) { in rcsi2_start_receiver_gen3()
870 if (fmt->height == 240) in rcsi2_start_receiver_gen3()
885 phycnt |= (1 << lanes) - 1; in rcsi2_start_receiver_gen3()
887 mbps = rcsi2_calc_mbps(priv, format->bpp, lanes); in rcsi2_start_receiver_gen3()
900 if (!priv->info->use_isp) { in rcsi2_start_receiver_gen3()
908 LSWAP_L0SEL(priv->lane_swap[0] - 1) | in rcsi2_start_receiver_gen3()
909 LSWAP_L1SEL(priv->lane_swap[1] - 1) | in rcsi2_start_receiver_gen3()
910 LSWAP_L2SEL(priv->lane_swap[2] - 1) | in rcsi2_start_receiver_gen3()
911 LSWAP_L3SEL(priv->lane_swap[3] - 1)); in rcsi2_start_receiver_gen3()
914 if (priv->info->init_phtw) { in rcsi2_start_receiver_gen3()
915 ret = priv->info->init_phtw(priv, mbps); in rcsi2_start_receiver_gen3()
920 if (priv->info->hsfreqrange) { in rcsi2_start_receiver_gen3()
926 if (priv->info->csi0clkfreqrange) in rcsi2_start_receiver_gen3()
928 CSI0CLKFREQRANGE(priv->info->csi0clkfreqrange)); in rcsi2_start_receiver_gen3()
930 if (priv->info->use_isp) in rcsi2_start_receiver_gen3()
946 if (priv->info->use_isp) in rcsi2_start_receiver_gen3()
950 if (priv->info->phy_post_init) { in rcsi2_start_receiver_gen3()
951 ret = priv->info->phy_post_init(priv); in rcsi2_start_receiver_gen3()
957 if (priv->info->clear_ulps) in rcsi2_start_receiver_gen3()
977 return -ETIMEDOUT; in rcsi2_wait_phy_start_v4h()
984 for (conf = cphy_setting_table_r8a779g0; conf->msps != 0; conf++) { in rcsi2_c_phy_setting_v4h()
985 if (conf->msps > msps) in rcsi2_c_phy_setting_v4h()
989 if (!conf->msps) { in rcsi2_c_phy_setting_v4h()
990 dev_err(priv->dev, "Unsupported PHY speed for msps setting (%u Msps)", msps); in rcsi2_c_phy_setting_v4h()
991 return -ERANGE; in rcsi2_c_phy_setting_v4h()
994 /* C-PHY specific */ in rcsi2_c_phy_setting_v4h()
1019 rcsi2_write16(priv, V4H_CORE_DIG_CLANE_0_RW_HS_RX_REG(2), conf->rx2); in rcsi2_c_phy_setting_v4h()
1020 rcsi2_write16(priv, V4H_CORE_DIG_CLANE_1_RW_HS_RX_REG(2), conf->rx2); in rcsi2_c_phy_setting_v4h()
1021 rcsi2_write16(priv, V4H_CORE_DIG_CLANE_2_RW_HS_RX_REG(2), conf->rx2); in rcsi2_c_phy_setting_v4h()
1029 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO0_REG(0), conf->trio0); in rcsi2_c_phy_setting_v4h()
1030 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO1_REG(0), conf->trio0); in rcsi2_c_phy_setting_v4h()
1031 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO2_REG(0), conf->trio0); in rcsi2_c_phy_setting_v4h()
1033 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO0_REG(2), conf->trio2); in rcsi2_c_phy_setting_v4h()
1034 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO1_REG(2), conf->trio2); in rcsi2_c_phy_setting_v4h()
1035 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO2_REG(2), conf->trio2); in rcsi2_c_phy_setting_v4h()
1037 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO0_REG(1), conf->trio1); in rcsi2_c_phy_setting_v4h()
1038 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO1_REG(1), conf->trio1); in rcsi2_c_phy_setting_v4h()
1039 rcsi2_write16(priv, V4H_CORE_DIG_RW_TRIO2_REG(1), conf->trio1); in rcsi2_c_phy_setting_v4h()
1042 * Configure pin-swap. in rcsi2_c_phy_setting_v4h()
1044 * on the 'clock-lanes' and 'data-lanes' devicetree properties. in rcsi2_c_phy_setting_v4h()
1055 dev_err(priv->dev, "PHY calibration failed\n"); in rcsi2_c_phy_setting_v4h()
1056 return -ETIMEDOUT; in rcsi2_c_phy_setting_v4h()
1059 /* C-PHY setting - analog programing*/ in rcsi2_c_phy_setting_v4h()
1060 rcsi2_write16(priv, V4H_CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_REG(9), conf->lane29); in rcsi2_c_phy_setting_v4h()
1061 rcsi2_write16(priv, V4H_CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_REG(7), conf->lane27); in rcsi2_c_phy_setting_v4h()
1077 format = rcsi2_code_to_fmt(fmt->code); in rcsi2_start_receiver_v4h()
1079 return -EINVAL; in rcsi2_start_receiver_v4h()
1085 msps = rcsi2_calc_mbps(priv, format->bpp, lanes); in rcsi2_start_receiver_v4h()
1100 rcsi2_write(priv, V4H_N_LANES_REG, lanes - 1); in rcsi2_start_receiver_v4h()
1102 /* Reset CSI2 */ in rcsi2_start_receiver_v4h()
1122 /* C-PHY settings */ in rcsi2_start_receiver_v4h()
1142 ret = priv->info->start_receiver(priv, state); in rcsi2_start()
1148 ret = v4l2_subdev_call(priv->remote, video, s_stream, 1); in rcsi2_start()
1160 v4l2_subdev_call(priv->remote, video, s_stream, 0); in rcsi2_stop()
1169 if (!priv->remote) in rcsi2_s_stream()
1170 return -ENODEV; in rcsi2_s_stream()
1172 state = v4l2_subdev_lock_and_get_active_state(&priv->subdev); in rcsi2_s_stream()
1174 if (enable && priv->stream_count == 0) { in rcsi2_s_stream()
1178 } else if (!enable && priv->stream_count == 1) { in rcsi2_s_stream()
1182 priv->stream_count += enable ? 1 : -1; in rcsi2_s_stream()
1196 if (format->pad > RCAR_CSI2_SINK) in rcsi2_set_pad_format()
1199 if (!rcsi2_code_to_fmt(format->format.code)) in rcsi2_set_pad_format()
1200 format->format.code = rcar_csi2_formats[0].code; in rcsi2_set_pad_format()
1202 *v4l2_subdev_state_get_format(state, format->pad) = format->format; in rcsi2_set_pad_format()
1206 *v4l2_subdev_state_get_format(state, i) = format->format; in rcsi2_set_pad_format()
1270 dev_info(priv->dev, "Transfer error, restarting CSI-2 receiver\n"); in rcsi2_irq()
1280 state = v4l2_subdev_lock_and_get_active_state(&priv->subdev); in rcsi2_irq_thread()
1285 dev_warn(priv->dev, "Failed to restart CSI-2 receiver\n"); in rcsi2_irq_thread()
1292 /* -----------------------------------------------------------------------------
1303 pad = media_entity_get_fwnode_pad(&subdev->entity, asc->match.fwnode, in rcsi2_notify_bound()
1306 dev_err(priv->dev, "Failed to find pad for %s\n", subdev->name); in rcsi2_notify_bound()
1310 priv->remote = subdev; in rcsi2_notify_bound()
1311 priv->remote_pad = pad; in rcsi2_notify_bound()
1313 dev_dbg(priv->dev, "Bound %s pad: %d\n", subdev->name, pad); in rcsi2_notify_bound()
1315 return media_create_pad_link(&subdev->entity, pad, in rcsi2_notify_bound()
1316 &priv->subdev.entity, 0, in rcsi2_notify_bound()
1327 priv->remote = NULL; in rcsi2_notify_unbind()
1329 dev_dbg(priv->dev, "Unbind %s\n", subdev->name); in rcsi2_notify_unbind()
1343 if (vep->base.port || vep->base.id) in rcsi2_parse_v4l2()
1344 return -ENOTCONN; in rcsi2_parse_v4l2()
1346 priv->lanes = vep->bus.mipi_csi2.num_data_lanes; in rcsi2_parse_v4l2()
1348 switch (vep->bus_type) { in rcsi2_parse_v4l2()
1350 if (!priv->info->support_dphy) { in rcsi2_parse_v4l2()
1351 dev_err(priv->dev, "D-PHY not supported\n"); in rcsi2_parse_v4l2()
1352 return -EINVAL; in rcsi2_parse_v4l2()
1355 if (priv->lanes != 1 && priv->lanes != 2 && priv->lanes != 4) { in rcsi2_parse_v4l2()
1356 dev_err(priv->dev, in rcsi2_parse_v4l2()
1357 "Unsupported number of data-lanes for D-PHY: %u\n", in rcsi2_parse_v4l2()
1358 priv->lanes); in rcsi2_parse_v4l2()
1359 return -EINVAL; in rcsi2_parse_v4l2()
1362 priv->cphy = false; in rcsi2_parse_v4l2()
1365 if (!priv->info->support_cphy) { in rcsi2_parse_v4l2()
1366 dev_err(priv->dev, "C-PHY not supported\n"); in rcsi2_parse_v4l2()
1367 return -EINVAL; in rcsi2_parse_v4l2()
1370 if (priv->lanes != 3) { in rcsi2_parse_v4l2()
1371 dev_err(priv->dev, in rcsi2_parse_v4l2()
1372 "Unsupported number of data-lanes for C-PHY: %u\n", in rcsi2_parse_v4l2()
1373 priv->lanes); in rcsi2_parse_v4l2()
1374 return -EINVAL; in rcsi2_parse_v4l2()
1377 priv->cphy = true; in rcsi2_parse_v4l2()
1380 dev_err(priv->dev, "Unsupported bus: %u\n", vep->bus_type); in rcsi2_parse_v4l2()
1381 return -EINVAL; in rcsi2_parse_v4l2()
1384 for (i = 0; i < ARRAY_SIZE(priv->lane_swap); i++) { in rcsi2_parse_v4l2()
1385 priv->lane_swap[i] = i < priv->lanes ? in rcsi2_parse_v4l2()
1386 vep->bus.mipi_csi2.data_lanes[i] : i; in rcsi2_parse_v4l2()
1389 if (priv->lane_swap[i] < 1 || priv->lane_swap[i] > 4) { in rcsi2_parse_v4l2()
1390 dev_err(priv->dev, "data-lanes must be in 1-4 range\n"); in rcsi2_parse_v4l2()
1391 return -EINVAL; in rcsi2_parse_v4l2()
1408 ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(priv->dev), 0, 0, 0); in rcsi2_parse_dt()
1410 dev_err(priv->dev, "Not connected to subdevice\n"); in rcsi2_parse_dt()
1411 return -EINVAL; in rcsi2_parse_dt()
1416 dev_err(priv->dev, "Could not parse v4l2 endpoint\n"); in rcsi2_parse_dt()
1418 return -EINVAL; in rcsi2_parse_dt()
1430 dev_dbg(priv->dev, "Found '%pOF'\n", to_of_node(fwnode)); in rcsi2_parse_dt()
1432 v4l2_async_subdev_nf_init(&priv->notifier, &priv->subdev); in rcsi2_parse_dt()
1433 priv->notifier.ops = &rcar_csi2_notify_ops; in rcsi2_parse_dt()
1435 asc = v4l2_async_nf_add_fwnode(&priv->notifier, fwnode, in rcsi2_parse_dt()
1441 ret = v4l2_async_nf_register(&priv->notifier); in rcsi2_parse_dt()
1443 v4l2_async_nf_cleanup(&priv->notifier); in rcsi2_parse_dt()
1448 /* -----------------------------------------------------------------------------
1470 dev_err(priv->dev, "Timeout waiting for PHTW_DWEN and/or PHTW_CWEN\n"); in rcsi2_phtw_write()
1472 return -ETIMEDOUT; in rcsi2_phtw_write()
1481 for (value = values; value->data || value->code; value++) { in rcsi2_phtw_write_array()
1482 ret = rcsi2_phtw_write(priv, value->data, value->code); in rcsi2_phtw_write_array()
1496 for (value = values; value->mbps; value++) { in rcsi2_phtw_write_mbps()
1497 if (value->mbps >= mbps) in rcsi2_phtw_write_mbps()
1503 ((mbps - prev_value->mbps) <= (value->mbps - mbps))) in rcsi2_phtw_write_mbps()
1506 if (!value->mbps) { in rcsi2_phtw_write_mbps()
1507 dev_err(priv->dev, "Unsupported PHY speed (%u Mbps)", mbps); in rcsi2_phtw_write_mbps()
1508 return -ERANGE; in rcsi2_phtw_write_mbps()
1511 return rcsi2_phtw_write(priv, value->reg, code); in rcsi2_phtw_write_mbps()
1640 /* -----------------------------------------------------------------------------
1654 if (!is_media_entity_v4l2_video_device(remote->entity)) { in rcsi2_link_setup()
1655 dev_err(priv->dev, "Remote is not a video device\n"); in rcsi2_link_setup()
1656 return -EINVAL; in rcsi2_link_setup()
1659 vdev = media_entity_to_video_device(remote->entity); in rcsi2_link_setup()
1661 if (of_property_read_u32(vdev->dev_parent->of_node, "renesas,id", &id)) { in rcsi2_link_setup()
1662 dev_err(priv->dev, "No renesas,id, can't configure routing\n"); in rcsi2_link_setup()
1663 return -EINVAL; in rcsi2_link_setup()
1670 dev_dbg(priv->dev, in rcsi2_link_setup()
1672 return -EINVAL; in rcsi2_link_setup()
1675 vc = local->index - 1; in rcsi2_link_setup()
1677 dev_dbg(priv->dev, "Route VC%d to VIN%u on output channel %d\n", in rcsi2_link_setup()
1680 vc = -1; in rcsi2_link_setup()
1683 priv->channel_vc[channel] = vc; in rcsi2_link_setup()
1698 priv->base = devm_platform_ioremap_resource(pdev, 0); in rcsi2_probe_resources()
1699 if (IS_ERR(priv->base)) in rcsi2_probe_resources()
1700 return PTR_ERR(priv->base); in rcsi2_probe_resources()
1706 ret = devm_request_threaded_irq(&pdev->dev, irq, rcsi2_irq, in rcsi2_probe_resources()
1712 priv->rstc = devm_reset_control_get(&pdev->dev, NULL); in rcsi2_probe_resources()
1714 return PTR_ERR_OR_ZERO(priv->rstc); in rcsi2_probe_resources()
1813 .compatible = "renesas,r8a774a1-csi2",
1817 .compatible = "renesas,r8a774b1-csi2",
1821 .compatible = "renesas,r8a774c0-csi2",
1825 .compatible = "renesas,r8a774e1-csi2",
1829 .compatible = "renesas,r8a7795-csi2",
1833 .compatible = "renesas,r8a7796-csi2",
1837 .compatible = "renesas,r8a77961-csi2",
1841 .compatible = "renesas,r8a77965-csi2",
1845 .compatible = "renesas,r8a77970-csi2",
1849 .compatible = "renesas,r8a77980-csi2",
1853 .compatible = "renesas,r8a77990-csi2",
1857 .compatible = "renesas,r8a779a0-csi2",
1861 .compatible = "renesas,r8a779g0-csi2",
1883 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in rcsi2_probe()
1885 return -ENOMEM; in rcsi2_probe()
1887 priv->info = of_device_get_match_data(&pdev->dev); in rcsi2_probe()
1895 priv->info = attr->data; in rcsi2_probe()
1897 priv->dev = &pdev->dev; in rcsi2_probe()
1899 priv->stream_count = 0; in rcsi2_probe()
1903 dev_err(priv->dev, "Failed to get resources\n"); in rcsi2_probe()
1913 priv->subdev.owner = THIS_MODULE; in rcsi2_probe()
1914 priv->subdev.dev = &pdev->dev; in rcsi2_probe()
1915 priv->subdev.internal_ops = &rcar_csi2_internal_ops; in rcsi2_probe()
1916 v4l2_subdev_init(&priv->subdev, &rcar_csi2_subdev_ops); in rcsi2_probe()
1917 v4l2_set_subdevdata(&priv->subdev, &pdev->dev); in rcsi2_probe()
1918 snprintf(priv->subdev.name, sizeof(priv->subdev.name), "%s %s", in rcsi2_probe()
1919 KBUILD_MODNAME, dev_name(&pdev->dev)); in rcsi2_probe()
1920 priv->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; in rcsi2_probe()
1922 priv->subdev.entity.function = MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER; in rcsi2_probe()
1923 priv->subdev.entity.ops = &rcar_csi2_entity_ops; in rcsi2_probe()
1927 priv->pads[RCAR_CSI2_SINK].flags = MEDIA_PAD_FL_SINK; in rcsi2_probe()
1929 priv->pads[i].flags = MEDIA_PAD_FL_SOURCE; in rcsi2_probe()
1931 ret = media_entity_pads_init(&priv->subdev.entity, num_pads, in rcsi2_probe()
1932 priv->pads); in rcsi2_probe()
1936 for (i = 0; i < ARRAY_SIZE(priv->channel_vc); i++) in rcsi2_probe()
1937 priv->channel_vc[i] = -1; in rcsi2_probe()
1939 pm_runtime_enable(&pdev->dev); in rcsi2_probe()
1941 ret = v4l2_subdev_init_finalize(&priv->subdev); in rcsi2_probe()
1945 ret = v4l2_async_register_subdev(&priv->subdev); in rcsi2_probe()
1949 dev_info(priv->dev, "%d lanes found\n", priv->lanes); in rcsi2_probe()
1954 v4l2_subdev_cleanup(&priv->subdev); in rcsi2_probe()
1956 pm_runtime_disable(&pdev->dev); in rcsi2_probe()
1958 v4l2_async_nf_unregister(&priv->notifier); in rcsi2_probe()
1959 v4l2_async_nf_cleanup(&priv->notifier); in rcsi2_probe()
1968 v4l2_async_nf_unregister(&priv->notifier); in rcsi2_remove()
1969 v4l2_async_nf_cleanup(&priv->notifier); in rcsi2_remove()
1970 v4l2_async_unregister_subdev(&priv->subdev); in rcsi2_remove()
1971 v4l2_subdev_cleanup(&priv->subdev); in rcsi2_remove()
1973 pm_runtime_disable(&pdev->dev); in rcsi2_remove()
1980 .name = "rcar-csi2",
1989 MODULE_DESCRIPTION("Renesas R-Car MIPI CSI-2 receiver driver");