Lines Matching +full:dphy +full:- +full:ref

1 // SPDX-License-Identifier: GPL-2.0+
5 * Guochun Huang <hero.huang@rock-chips.com>
19 #include <media/v4l2-ctrls.h>
20 #include <media/v4l2-fwnode.h>
21 #include <media/v4l2-subdev.h>
22 #include <media/v4l2-device.h>
23 #include "phy-rockchip-csi2-dphy-common.h"
24 #include "phy-rockchip-samsung-dcphy.h"
1278 csi_dphy->dphy_param.lp_vol_ref != 3 && in samsung_mipi_dcphy_bias_block_enable()
1279 csi_dphy->dphy_param.lp_vol_ref < 0x7) { in samsung_mipi_dcphy_bias_block_enable()
1281 bias_con2 |= csi_dphy->dphy_param.lp_vol_ref; in samsung_mipi_dcphy_bias_block_enable()
1282 dev_info(samsung->dev, in samsung_mipi_dcphy_bias_block_enable()
1284 csi_dphy->dphy_param.lp_vol_ref); in samsung_mipi_dcphy_bias_block_enable()
1286 regmap_write(samsung->regmap, BIAS_CON0, 0x0010); in samsung_mipi_dcphy_bias_block_enable()
1287 regmap_write(samsung->regmap, BIAS_CON1, 0x0110); in samsung_mipi_dcphy_bias_block_enable()
1288 regmap_write(samsung->regmap, BIAS_CON2, bias_con2); in samsung_mipi_dcphy_bias_block_enable()
1291 * dphy: 400mv in samsung_mipi_dcphy_bias_block_enable()
1294 if (samsung->c_option) in samsung_mipi_dcphy_bias_block_enable()
1295 regmap_update_bits(samsung->regmap, BIAS_CON4, in samsung_mipi_dcphy_bias_block_enable()
1305 regmap_write(samsung->regmap, DPHY_MC_GNR_CON1, T_PHY_READY(0x2000)); in samsung_mipi_dphy_lane_enable()
1306 regmap_update_bits(samsung->regmap, DPHY_MC_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1309 switch (samsung->lanes) { in samsung_mipi_dphy_lane_enable()
1311 regmap_write(samsung->regmap, DPHY_MD3_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1313 regmap_update_bits(samsung->regmap, DPHY_MD3_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1317 regmap_write(samsung->regmap, COMBO_MD2_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1319 regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1323 regmap_write(samsung->regmap, COMBO_MD1_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1325 regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1330 regmap_write(samsung->regmap, COMBO_MD0_GNR_CON1, in samsung_mipi_dphy_lane_enable()
1332 regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, in samsung_mipi_dphy_lane_enable()
1340 regmap_write(samsung->regmap, COMBO_MD0_GNR_CON1, T_PHY_READY(0x2000)); in samsung_mipi_cphy_lane_enable()
1341 regmap_write(samsung->regmap, COMBO_MD1_GNR_CON1, T_PHY_READY(0x2000)); in samsung_mipi_cphy_lane_enable()
1342 regmap_write(samsung->regmap, COMBO_MD2_GNR_CON1, T_PHY_READY(0x2000)); in samsung_mipi_cphy_lane_enable()
1344 regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, in samsung_mipi_cphy_lane_enable()
1346 regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, in samsung_mipi_cphy_lane_enable()
1348 regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, in samsung_mipi_cphy_lane_enable()
1354 regmap_update_bits(samsung->regmap, DPHY_MC_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_dphy_lane_disable()
1355 regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_dphy_lane_disable()
1356 regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_dphy_lane_disable()
1357 regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_dphy_lane_disable()
1358 regmap_update_bits(samsung->regmap, DPHY_MD3_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_dphy_lane_disable()
1363 regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_cphy_lane_disable()
1364 regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_cphy_lane_disable()
1365 regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, PHY_ENABLE, 0); in samsung_mipi_cphy_lane_disable()
1370 regmap_update_bits(samsung->regmap, PLL_CON0, S_MASK | P_MASK, in samsung_mipi_dcphy_pll_configure()
1371 S(samsung->pll.scaler) | P(samsung->pll.prediv)); in samsung_mipi_dcphy_pll_configure()
1373 if (samsung->pll.dsm < 0) { in samsung_mipi_dcphy_pll_configure()
1377 dsm_tmp = abs(samsung->pll.dsm); in samsung_mipi_dcphy_pll_configure()
1378 dsm_tmp = dsm_tmp - 1; in samsung_mipi_dcphy_pll_configure()
1380 regmap_write(samsung->regmap, PLL_CON1, dsm_tmp); in samsung_mipi_dcphy_pll_configure()
1382 regmap_write(samsung->regmap, PLL_CON1, samsung->pll.dsm); in samsung_mipi_dcphy_pll_configure()
1385 regmap_update_bits(samsung->regmap, PLL_CON2, in samsung_mipi_dcphy_pll_configure()
1386 M_MASK, M(samsung->pll.fbdiv)); in samsung_mipi_dcphy_pll_configure()
1388 if (samsung->pll.ssc_en) { in samsung_mipi_dcphy_pll_configure()
1389 regmap_write(samsung->regmap, PLL_CON3, in samsung_mipi_dcphy_pll_configure()
1390 MRR(samsung->pll.mrr) | MFR(samsung->pll.mfr)); in samsung_mipi_dcphy_pll_configure()
1391 regmap_update_bits(samsung->regmap, PLL_CON4, SSCG_EN, SSCG_EN); in samsung_mipi_dcphy_pll_configure()
1394 regmap_write(samsung->regmap, PLL_CON5, RESET_N_SEL | PLL_ENABLE_SEL); in samsung_mipi_dcphy_pll_configure()
1395 regmap_write(samsung->regmap, PLL_CON7, PLL_LOCK_CNT(0xf000)); in samsung_mipi_dcphy_pll_configure()
1396 regmap_write(samsung->regmap, PLL_CON8, PLL_STB_CNT(0xf000)); in samsung_mipi_dcphy_pll_configure()
1404 regmap_update_bits(samsung->regmap, PLL_CON0, PLL_EN, PLL_EN); in samsung_mipi_dcphy_pll_enable()
1406 ret = regmap_read_poll_timeout(samsung->regmap, PLL_STAT0, in samsung_mipi_dcphy_pll_enable()
1409 dev_err(samsung->dev, "DC-PHY pll is not locked\n"); in samsung_mipi_dcphy_pll_enable()
1414 regmap_update_bits(samsung->regmap, PLL_CON0, PLL_EN, 0); in samsung_mipi_dcphy_pll_disable()
1422 unsigned int lane_mbps = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_dphy_get_timing()
1428 for (i = num_timings; i > 0; i--) in samsung_mipi_dphy_get_timing()
1429 if (lane_mbps <= timings[i - 1].max_lane_mbps) in samsung_mipi_dphy_get_timing()
1435 return &timings[i - 1]; in samsung_mipi_dphy_get_timing()
1443 unsigned int lane_msps = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_cphy_get_timing()
1449 for (i = num_timings; i > 0; i--) in samsung_mipi_cphy_get_timing()
1450 if (lane_msps <= timings[i - 1].max_lane_msps) in samsung_mipi_cphy_get_timing()
1456 return &timings[i - 1]; in samsung_mipi_cphy_get_timing()
1462 unsigned int lane_hs_rate = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_cphy_timing_init()
1468 * Divide-by-2 Clock from Serial Clock. Use this when data rate is under in samsung_mipi_cphy_timing_init()
1469 * 500Msps, otherwise divide-by-16 Clock from Serial Clock in samsung_mipi_cphy_timing_init()
1474 val |= T_LPX(timing->lpx); in samsung_mipi_cphy_timing_init()
1476 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON0, val); in samsung_mipi_cphy_timing_init()
1477 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON0, val); in samsung_mipi_cphy_timing_init()
1478 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON0, val); in samsung_mipi_cphy_timing_init()
1480 val = T_HS_ZERO(timing->prebegin_3) | T_HS_PREPARE(timing->prepare_3); in samsung_mipi_cphy_timing_init()
1481 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON1, val); in samsung_mipi_cphy_timing_init()
1482 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON1, val); in samsung_mipi_cphy_timing_init()
1483 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON1, val); in samsung_mipi_cphy_timing_init()
1485 val = T_HS_EXIT(timing->hs_exit) | T_HS_TRAIL(timing->post_3); in samsung_mipi_cphy_timing_init()
1486 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON2, val); in samsung_mipi_cphy_timing_init()
1487 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON2, val); in samsung_mipi_cphy_timing_init()
1488 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON2, val); in samsung_mipi_cphy_timing_init()
1490 /* TTA-GET/TTA-GO Timing Counter register use default value */ in samsung_mipi_cphy_timing_init()
1492 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON3, val); in samsung_mipi_cphy_timing_init()
1493 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON3, val); in samsung_mipi_cphy_timing_init()
1494 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON3, val); in samsung_mipi_cphy_timing_init()
1497 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON4, 0x1f4); in samsung_mipi_cphy_timing_init()
1498 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON4, 0x1f4); in samsung_mipi_cphy_timing_init()
1499 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON4, 0x1f4); in samsung_mipi_cphy_timing_init()
1509 u64 max_fout = samsung->c_option ? MAX_CPHY_BW : MAX_DPHY_BW; in samsung_mipi_dcphy_pll_round_rate()
1554 /* -32767 ≤ K[15:0] ≤ 32767 */ in samsung_mipi_dcphy_pll_round_rate()
1555 _dsm = ((_prediv * fvco) - (2 * _fbdiv * fin)); in samsung_mipi_dcphy_pll_round_rate()
1563 delta = abs(fvco * MSEC_PER_SEC - tmp); in samsung_mipi_dcphy_pll_round_rate()
1582 dev_dbg(samsung->dev, "p: %d, m: %d, dsm:%ld, scaler: %d\n", in samsung_mipi_dcphy_pll_round_rate()
1592 unsigned int lane_hs_rate = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_dphy_clk_lane_timing_init()
1596 regmap_write(samsung->regmap, DPHY_MC_GNR_CON0, 0xf000); in samsung_mipi_dphy_clk_lane_timing_init()
1597 regmap_write(samsung->regmap, DPHY_MC_ANA_CON0, 0x7133); in samsung_mipi_dphy_clk_lane_timing_init()
1600 regmap_write(samsung->regmap, DPHY_MC_ANA_CON1, 0x0001); in samsung_mipi_dphy_clk_lane_timing_init()
1603 * Divide-by-2 Clock from Serial Clock. Use this when data rate is under in samsung_mipi_dphy_clk_lane_timing_init()
1604 * 1500Mbps, otherwise divide-by-16 Clock from Serial Clock in samsung_mipi_dphy_clk_lane_timing_init()
1609 val |= T_LPX(timing->lpx); in samsung_mipi_dphy_clk_lane_timing_init()
1611 regmap_write(samsung->regmap, DPHY_MC_TIME_CON0, val); in samsung_mipi_dphy_clk_lane_timing_init()
1613 val = T_CLK_ZERO(timing->clk_zero) | T_CLK_PREPARE(timing->clk_prepare); in samsung_mipi_dphy_clk_lane_timing_init()
1614 regmap_write(samsung->regmap, DPHY_MC_TIME_CON1, val); in samsung_mipi_dphy_clk_lane_timing_init()
1616 val = T_HS_EXIT(timing->hs_exit) | T_CLK_TRAIL(timing->clk_trail_eot); in samsung_mipi_dphy_clk_lane_timing_init()
1617 regmap_write(samsung->regmap, DPHY_MC_TIME_CON2, val); in samsung_mipi_dphy_clk_lane_timing_init()
1619 val = T_CLK_POST(timing->clk_post); in samsung_mipi_dphy_clk_lane_timing_init()
1620 regmap_write(samsung->regmap, DPHY_MC_TIME_CON3, val); in samsung_mipi_dphy_clk_lane_timing_init()
1623 regmap_write(samsung->regmap, DPHY_MC_TIME_CON4, 0x1f4); in samsung_mipi_dphy_clk_lane_timing_init()
1630 regmap_write(samsung->regmap, DPHY_MC_DESKEW_CON0, 0x9cb1); in samsung_mipi_dphy_clk_lane_timing_init()
1637 unsigned int lane_hs_rate = div64_ul(samsung->pll.rate, USEC_PER_SEC); in samsung_mipi_dphy_data_lane_timing_init()
1642 regmap_write(samsung->regmap, COMBO_MD0_ANA_CON0, 0x7133); in samsung_mipi_dphy_data_lane_timing_init()
1643 regmap_write(samsung->regmap, COMBO_MD1_ANA_CON0, 0x7133); in samsung_mipi_dphy_data_lane_timing_init()
1644 regmap_write(samsung->regmap, COMBO_MD2_ANA_CON0, 0x7133); in samsung_mipi_dphy_data_lane_timing_init()
1645 regmap_write(samsung->regmap, DPHY_MD3_ANA_CON0, 0x7133); in samsung_mipi_dphy_data_lane_timing_init()
1648 regmap_write(samsung->regmap, COMBO_MD0_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1649 regmap_write(samsung->regmap, COMBO_MD1_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1650 regmap_write(samsung->regmap, COMBO_MD2_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1651 regmap_write(samsung->regmap, DPHY_MD3_ANA_CON1, 0x0001); in samsung_mipi_dphy_data_lane_timing_init()
1655 * Divide-by-2 Clock from Serial Clock. Use this when data rate is under in samsung_mipi_dphy_data_lane_timing_init()
1656 * 1500Mbps, otherwise divide-by-16 Clock from Serial Clock in samsung_mipi_dphy_data_lane_timing_init()
1661 val |= T_LPX(timing->lpx); in samsung_mipi_dphy_data_lane_timing_init()
1663 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1664 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1665 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1666 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON0, val); in samsung_mipi_dphy_data_lane_timing_init()
1668 val = T_HS_ZERO(timing->hs_zero) | T_HS_PREPARE(timing->hs_prepare); in samsung_mipi_dphy_data_lane_timing_init()
1669 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1670 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1671 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1672 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON1, val); in samsung_mipi_dphy_data_lane_timing_init()
1674 val = T_HS_EXIT(timing->hs_exit) | T_HS_TRAIL(timing->hs_trail_eot); in samsung_mipi_dphy_data_lane_timing_init()
1675 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1676 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1677 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1678 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON2, val); in samsung_mipi_dphy_data_lane_timing_init()
1680 /* TTA-GET/TTA-GO Timing Counter register use default value */ in samsung_mipi_dphy_data_lane_timing_init()
1682 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1683 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1684 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1685 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON3, val); in samsung_mipi_dphy_data_lane_timing_init()
1688 regmap_write(samsung->regmap, COMBO_MD0_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1689 regmap_write(samsung->regmap, COMBO_MD1_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1690 regmap_write(samsung->regmap, COMBO_MD2_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1691 regmap_write(samsung->regmap, DPHY_MD3_TIME_CON4, 0x1f4); in samsung_mipi_dphy_data_lane_timing_init()
1697 regmap_write(samsung->regmap, DPHY_MC_ANA_CON2, HS_VREG_AMP_ICON(2)); in samsung_mipi_dcphy_hs_vreg_amp_configure()
1702 reset_control_assert(samsung->m_phy_rst); in samsung_mipi_dphy_power_on()
1711 reset_control_deassert(samsung->m_phy_rst); in samsung_mipi_dphy_power_on()
1721 regmap_write(samsung->grf_regmap, MIPI_DCPHY_GRF_CON0, M_CPHY_MODE); in samsung_mipi_cphy_power_on()
1722 reset_control_assert(samsung->m_phy_rst); in samsung_mipi_cphy_power_on()
1731 reset_control_deassert(samsung->m_phy_rst); in samsung_mipi_cphy_power_on()
1743 pm_runtime_get_sync(samsung->dev); in samsung_mipi_dcphy_power_on()
1744 reset_control_assert(samsung->apb_rst); in samsung_mipi_dcphy_power_on()
1746 reset_control_deassert(samsung->apb_rst); in samsung_mipi_dcphy_power_on()
1747 if (atomic_read(&samsung->stream_cnt)) { in samsung_mipi_dcphy_power_on()
1748 sensor_sd = get_remote_sensor(&samsung->dphy_dev[0]->sd); in samsung_mipi_dcphy_power_on()
1749 samsung->stream_off(samsung->dphy_dev[0], &samsung->dphy_dev[0]->sd); in samsung_mipi_dcphy_power_on()
1753 samsung->stream_on(samsung->dphy_dev[0], &samsung->dphy_dev[0]->sd); in samsung_mipi_dcphy_power_on()
1787 pm_runtime_put(samsung->dev); in samsung_mipi_dcphy_power_off()
1802 unsigned long fin = div64_ul(clk_get_rate(samsung->ref_clk), MSEC_PER_SEC); in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1803 u16 prediv = samsung->pll.prediv; in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1804 u16 fbdiv = samsung->pll.fbdiv; in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1836 dev_err(samsung->dev, "failed to calc ssc parameter mfr and mrr\n"); in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1837 return -EINVAL; in samsung_mipi_dcphy_pll_ssc_modulation_calc()
1847 unsigned long prate = clk_get_rate(samsung->ref_clk); in samsung_mipi_dcphy_pll_calc_rate()
1859 dev_dbg(samsung->dev, "%s: fin=%lu, req_rate=%llu\n", in samsung_mipi_dcphy_pll_calc_rate()
1861 dev_dbg(samsung->dev, "%s: fout=%lu, prediv=%u, fbdiv=%u\n", in samsung_mipi_dcphy_pll_calc_rate()
1864 samsung->pll.prediv = prediv; in samsung_mipi_dcphy_pll_calc_rate()
1865 samsung->pll.fbdiv = fbdiv; in samsung_mipi_dcphy_pll_calc_rate()
1866 samsung->pll.dsm = dsm; in samsung_mipi_dcphy_pll_calc_rate()
1867 samsung->pll.scaler = scaler; in samsung_mipi_dcphy_pll_calc_rate()
1868 samsung->pll.rate = fout; in samsung_mipi_dcphy_pll_calc_rate()
1871 * All DPHY 2.0 compliant Transmitters shall support SSC operating above in samsung_mipi_dcphy_pll_calc_rate()
1878 samsung->pll.ssc_en = true; in samsung_mipi_dcphy_pll_calc_rate()
1879 samsung->pll.mfr = mfr; in samsung_mipi_dcphy_pll_calc_rate()
1880 samsung->pll.mrr = mrr; in samsung_mipi_dcphy_pll_calc_rate()
1889 unsigned long long target_rate = opts->mipi_dphy.hs_clk_rate; in samsung_mipi_dcphy_configure()
1892 samsung->c_option = (mode == PHY_MODE_MIPI_DPHY) ? false : true; in samsung_mipi_dcphy_configure()
1894 samsung->lanes = opts->mipi_dphy.lanes > 4 ? 4 : opts->mipi_dphy.lanes; in samsung_mipi_dcphy_configure()
1897 opts->mipi_dphy.hs_clk_rate = samsung->pll.rate; in samsung_mipi_dcphy_configure()
1907 local = &sd->entity.pads[CSI2_DPHY_RX_PAD_SINK]; in get_remote_sensor()
1910 v4l2_warn(sd, "No link between dphy and sensor\n"); in get_remote_sensor()
1914 sensor_me = media_entity_remote_pad(local)->entity; in get_remote_sensor()
1918 static struct csi2_sensor *sd_to_sensor(struct csi2_dphy *dphy, in sd_to_sensor() argument
1923 for (i = 0; i < dphy->num_sensors; ++i) in sd_to_sensor()
1924 if (dphy->sensors[i].sd == sd) in sd_to_sensor()
1925 return &dphy->sensors[i]; in sd_to_sensor()
1930 static void samsung_dcphy_rx_config_settle(struct csi2_dphy *dphy, in samsung_dcphy_rx_config_settle() argument
1933 struct samsung_mipi_dcphy *samsung = dphy->samsung_phy; in samsung_dcphy_rx_config_settle()
1939 if (sensor->mbus.type == V4L2_MBUS_CSI2_DPHY) { in samsung_dcphy_rx_config_settle()
1943 } else if (sensor->mbus.type == V4L2_MBUS_CSI2_CPHY) { in samsung_dcphy_rx_config_settle()
1948 dev_err(dphy->dev, "mbus type %d is not support", in samsung_dcphy_rx_config_settle()
1949 sensor->mbus.type); in samsung_dcphy_rx_config_settle()
1954 if (hsfreq_ranges[i].range_h >= dphy->data_rate_mbps) { in samsung_dcphy_rx_config_settle()
1961 i = num_hsfreq_ranges - 1; in samsung_dcphy_rx_config_settle()
1962 dev_warn(dphy->dev, "data rate: %lld mbps, max support %d mbps", in samsung_dcphy_rx_config_settle()
1963 dphy->data_rate_mbps, hsfreq_ranges[i].range_h + 1); in samsung_dcphy_rx_config_settle()
1967 if (sensor->mbus.type == V4L2_MBUS_CSI2_DPHY) in samsung_dcphy_rx_config_settle()
1968 regmap_write(samsung->regmap, RX_CLK_THS_SETTLE, 0x301); in samsung_dcphy_rx_config_settle()
1970 if (sensor->lanes > 0x00) { in samsung_dcphy_rx_config_settle()
1971 regmap_update_bits(samsung->regmap, RX_LANE0_THS_SETTLE, 0x1ff, hsfreq); in samsung_dcphy_rx_config_settle()
1972 regmap_update_bits(samsung->regmap, RX_LANE0_ERR_SOT_SYNC, 0xff, sot_sync); in samsung_dcphy_rx_config_settle()
1974 if (sensor->lanes > 0x01) { in samsung_dcphy_rx_config_settle()
1975 regmap_update_bits(samsung->regmap, RX_LANE1_THS_SETTLE, 0x1ff, hsfreq); in samsung_dcphy_rx_config_settle()
1976 regmap_update_bits(samsung->regmap, RX_LANE1_ERR_SOT_SYNC, 0xff, sot_sync); in samsung_dcphy_rx_config_settle()
1978 if (sensor->lanes > 0x02) { in samsung_dcphy_rx_config_settle()
1979 regmap_update_bits(samsung->regmap, RX_LANE2_THS_SETTLE, 0x1ff, hsfreq); in samsung_dcphy_rx_config_settle()
1980 regmap_update_bits(samsung->regmap, RX_LANE2_ERR_SOT_SYNC, 0xff, sot_sync); in samsung_dcphy_rx_config_settle()
1982 if (sensor->lanes > 0x03) { in samsung_dcphy_rx_config_settle()
1983 regmap_update_bits(samsung->regmap, RX_LANE3_THS_SETTLE, 0x1ff, hsfreq); in samsung_dcphy_rx_config_settle()
1984 regmap_update_bits(samsung->regmap, RX_LANE3_ERR_SOT_SYNC, 0xff, sot_sync); in samsung_dcphy_rx_config_settle()
1988 static int samsung_dcphy_rx_config_common(struct csi2_dphy *dphy, in samsung_dcphy_rx_config_common() argument
1991 struct samsung_mipi_dcphy *samsung = dphy->samsung_phy; in samsung_dcphy_rx_config_common()
1995 if (sensor->mbus.type == V4L2_MBUS_CSI2_DPHY) { in samsung_dcphy_rx_config_common()
1996 if (dphy->data_rate_mbps < 1500) in samsung_dcphy_rx_config_common()
1998 else if (dphy->data_rate_mbps < 2000) in samsung_dcphy_rx_config_common()
2000 else if (dphy->data_rate_mbps < 3000) in samsung_dcphy_rx_config_common()
2002 else if (dphy->data_rate_mbps < 4000) in samsung_dcphy_rx_config_common()
2004 else if (dphy->data_rate_mbps < 6500) in samsung_dcphy_rx_config_common()
2006 if (dphy->dphy_param.clk_hs_term_sel > 0x7) { in samsung_dcphy_rx_config_common()
2007 dev_err(dphy->dev, "clk_hs_term_sel error param %d\n", in samsung_dcphy_rx_config_common()
2008 dphy->dphy_param.clk_hs_term_sel); in samsung_dcphy_rx_config_common()
2009 return -EINVAL; in samsung_dcphy_rx_config_common()
2011 for (i = 0; i < sensor->lanes; i++) { in samsung_dcphy_rx_config_common()
2012 if (dphy->dphy_param.data_hs_term_sel[i] > 0x7) { in samsung_dcphy_rx_config_common()
2013 dev_err(dphy->dev, "data_hs_term_sel[%d] error param %d\n", in samsung_dcphy_rx_config_common()
2015 dphy->dphy_param.data_hs_term_sel[i]); in samsung_dcphy_rx_config_common()
2016 return -EINVAL; in samsung_dcphy_rx_config_common()
2018 if (dphy->dphy_param.lp_hys_sw[i] > 0x3) { in samsung_dcphy_rx_config_common()
2019 dev_err(dphy->dev, "lp_hys_sw[%d] error param %d\n", in samsung_dcphy_rx_config_common()
2021 dphy->dphy_param.lp_hys_sw[i]); in samsung_dcphy_rx_config_common()
2022 return -EINVAL; in samsung_dcphy_rx_config_common()
2024 if (dphy->dphy_param.lp_escclk_pol_sel[i] > 0x1) { in samsung_dcphy_rx_config_common()
2025 dev_err(dphy->dev, "lp_escclk_pol_sel[%d] error param %d\n", in samsung_dcphy_rx_config_common()
2027 dphy->dphy_param.lp_escclk_pol_sel[i]); in samsung_dcphy_rx_config_common()
2028 return -EINVAL; in samsung_dcphy_rx_config_common()
2030 if (dphy->dphy_param.skew_data_cal_clk[i] > 0x1f) { in samsung_dcphy_rx_config_common()
2031 dev_err(dphy->dev, "skew_data_cal_clk[%d] error param %d\n", in samsung_dcphy_rx_config_common()
2033 dphy->dphy_param.skew_data_cal_clk[i]); in samsung_dcphy_rx_config_common()
2034 return -EINVAL; in samsung_dcphy_rx_config_common()
2037 regmap_write(samsung->regmap, RX_S0C_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2038 regmap_write(samsung->regmap, RX_S0C_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2039 regmap_write(samsung->regmap, RX_S0C_ANA_CON2, dphy->dphy_param.clk_hs_term_sel); in samsung_dcphy_rx_config_common()
2040 regmap_write(samsung->regmap, RX_S0C_ANA_CON3, 0x0600); in samsung_dcphy_rx_config_common()
2041 if (sensor->lanes > 0x00) { in samsung_dcphy_rx_config_common()
2042 regmap_write(samsung->regmap, RX_COMBO_S0D0_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2043 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2044 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON2, dlysel | in samsung_dcphy_rx_config_common()
2045 dphy->dphy_param.data_hs_term_sel[0]); in samsung_dcphy_rx_config_common()
2046 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON3, 0x0600 | in samsung_dcphy_rx_config_common()
2047 (dphy->dphy_param.lp_hys_sw[0] << 4) | in samsung_dcphy_rx_config_common()
2048 (dphy->dphy_param.lp_escclk_pol_sel[0] << 11)); in samsung_dcphy_rx_config_common()
2049 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON7, 0x40); in samsung_dcphy_rx_config_common()
2050 regmap_write(samsung->regmap, RX_COMBO_S0D0_DESKEW_CON2, in samsung_dcphy_rx_config_common()
2051 dphy->dphy_param.skew_data_cal_clk[0]); in samsung_dcphy_rx_config_common()
2053 if (sensor->lanes > 0x01) { in samsung_dcphy_rx_config_common()
2054 regmap_write(samsung->regmap, RX_COMBO_S0D1_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2055 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2056 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON2, dlysel | in samsung_dcphy_rx_config_common()
2057 dphy->dphy_param.data_hs_term_sel[1]); in samsung_dcphy_rx_config_common()
2058 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON3, 0x0600 | in samsung_dcphy_rx_config_common()
2059 (dphy->dphy_param.lp_hys_sw[1] << 4) | in samsung_dcphy_rx_config_common()
2060 (dphy->dphy_param.lp_escclk_pol_sel[1] << 11)); in samsung_dcphy_rx_config_common()
2061 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON7, 0x40); in samsung_dcphy_rx_config_common()
2062 regmap_write(samsung->regmap, RX_COMBO_S0D1_DESKEW_CON2, in samsung_dcphy_rx_config_common()
2063 dphy->dphy_param.skew_data_cal_clk[1]); in samsung_dcphy_rx_config_common()
2065 if (sensor->lanes > 0x02) { in samsung_dcphy_rx_config_common()
2066 regmap_write(samsung->regmap, RX_COMBO_S0D2_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2067 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2068 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON2, dlysel | in samsung_dcphy_rx_config_common()
2069 dphy->dphy_param.data_hs_term_sel[2]); in samsung_dcphy_rx_config_common()
2070 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON3, 0x0600 | in samsung_dcphy_rx_config_common()
2071 (dphy->dphy_param.lp_hys_sw[2] << 4) | in samsung_dcphy_rx_config_common()
2072 (dphy->dphy_param.lp_escclk_pol_sel[2] << 11)); in samsung_dcphy_rx_config_common()
2073 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON7, 0x40); in samsung_dcphy_rx_config_common()
2074 regmap_write(samsung->regmap, RX_COMBO_S0D2_DESKEW_CON2, in samsung_dcphy_rx_config_common()
2075 dphy->dphy_param.skew_data_cal_clk[2]); in samsung_dcphy_rx_config_common()
2077 if (sensor->lanes > 0x03) { in samsung_dcphy_rx_config_common()
2078 regmap_write(samsung->regmap, RX_S0D3_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2079 regmap_write(samsung->regmap, RX_S0D3_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2080 regmap_write(samsung->regmap, RX_S0D3_ANA_CON2, dlysel | in samsung_dcphy_rx_config_common()
2081 dphy->dphy_param.data_hs_term_sel[3]); in samsung_dcphy_rx_config_common()
2082 regmap_write(samsung->regmap, RX_S0D3_ANA_CON3, 0x0600 | in samsung_dcphy_rx_config_common()
2083 (dphy->dphy_param.lp_hys_sw[3] << 4) | in samsung_dcphy_rx_config_common()
2084 (dphy->dphy_param.lp_escclk_pol_sel[3] << 11)); in samsung_dcphy_rx_config_common()
2085 regmap_write(samsung->regmap, RX_S0D3_DESKEW_CON2, in samsung_dcphy_rx_config_common()
2086 dphy->dphy_param.skew_data_cal_clk[3]); in samsung_dcphy_rx_config_common()
2089 if (sensor->lanes > 0x00) { in samsung_dcphy_rx_config_common()
2090 regmap_write(samsung->regmap, RX_COMBO_S0D0_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2091 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2092 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON2, 0x5); in samsung_dcphy_rx_config_common()
2093 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON3, 0x600); in samsung_dcphy_rx_config_common()
2094 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON6, 0x608); in samsung_dcphy_rx_config_common()
2095 regmap_write(samsung->regmap, RX_COMBO_S0D0_ANA_CON7, 0x40); in samsung_dcphy_rx_config_common()
2096 regmap_write(samsung->regmap, RX_COMBO_S0D0_CRC_CON1, 0x1500); in samsung_dcphy_rx_config_common()
2097 regmap_write(samsung->regmap, RX_COMBO_S0D0_CRC_CON2, 0x30); in samsung_dcphy_rx_config_common()
2099 if (sensor->lanes > 0x01) { in samsung_dcphy_rx_config_common()
2100 regmap_write(samsung->regmap, RX_COMBO_S0D1_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2101 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2102 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON2, 0x5); in samsung_dcphy_rx_config_common()
2103 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON3, 0x600); in samsung_dcphy_rx_config_common()
2104 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON6, 0x608); in samsung_dcphy_rx_config_common()
2105 regmap_write(samsung->regmap, RX_COMBO_S0D1_ANA_CON7, 0x40); in samsung_dcphy_rx_config_common()
2106 regmap_write(samsung->regmap, RX_COMBO_S0D1_CRC_CON1, 0x1500); in samsung_dcphy_rx_config_common()
2107 regmap_write(samsung->regmap, RX_COMBO_S0D1_CRC_CON2, 0x30); in samsung_dcphy_rx_config_common()
2109 if (sensor->lanes > 0x02) { in samsung_dcphy_rx_config_common()
2110 regmap_write(samsung->regmap, RX_COMBO_S0D2_GNR_CON1, 0x1450); in samsung_dcphy_rx_config_common()
2111 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON1, 0x8000); in samsung_dcphy_rx_config_common()
2112 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON2, 0x5); in samsung_dcphy_rx_config_common()
2113 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON3, 0x600); in samsung_dcphy_rx_config_common()
2114 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON6, 0x608); in samsung_dcphy_rx_config_common()
2115 regmap_write(samsung->regmap, RX_COMBO_S0D2_ANA_CON7, 0x40); in samsung_dcphy_rx_config_common()
2116 regmap_write(samsung->regmap, RX_COMBO_S0D2_CRC_CON1, 0x1500); in samsung_dcphy_rx_config_common()
2117 regmap_write(samsung->regmap, RX_COMBO_S0D2_CRC_CON2, 0x30); in samsung_dcphy_rx_config_common()
2123 static int samsung_dcphy_rx_lane_enable(struct csi2_dphy *dphy, in samsung_dcphy_rx_lane_enable() argument
2126 struct samsung_mipi_dcphy *samsung = dphy->samsung_phy; in samsung_dcphy_rx_lane_enable()
2130 if (sensor->mbus.type == V4L2_MBUS_CSI2_DPHY) in samsung_dcphy_rx_lane_enable()
2131 regmap_update_bits(samsung->regmap, RX_CLK_LANE_ENABLE, PHY_ENABLE, PHY_ENABLE); in samsung_dcphy_rx_lane_enable()
2133 if (sensor->lanes > 0x00) in samsung_dcphy_rx_lane_enable()
2134 regmap_update_bits(samsung->regmap, RX_DATA_LANE0_ENABLE, PHY_ENABLE, PHY_ENABLE); in samsung_dcphy_rx_lane_enable()
2135 if (sensor->lanes > 0x01) in samsung_dcphy_rx_lane_enable()
2136 regmap_update_bits(samsung->regmap, RX_DATA_LANE1_ENABLE, PHY_ENABLE, PHY_ENABLE); in samsung_dcphy_rx_lane_enable()
2137 if (sensor->lanes > 0x02) in samsung_dcphy_rx_lane_enable()
2138 regmap_update_bits(samsung->regmap, RX_DATA_LANE2_ENABLE, PHY_ENABLE, PHY_ENABLE); in samsung_dcphy_rx_lane_enable()
2139 if (sensor->lanes > 0x03) in samsung_dcphy_rx_lane_enable()
2140 regmap_update_bits(samsung->regmap, RX_DATA_LANE3_ENABLE, PHY_ENABLE, PHY_ENABLE); in samsung_dcphy_rx_lane_enable()
2143 if (sensor->mbus.type == V4L2_MBUS_CSI2_DPHY) { in samsung_dcphy_rx_lane_enable()
2144 ret = regmap_read_poll_timeout(samsung->regmap, RX_CLK_LANE_ENABLE, in samsung_dcphy_rx_lane_enable()
2147 dev_err(samsung->dev, "phy rx clk lane is not locked\n"); in samsung_dcphy_rx_lane_enable()
2148 return -EINVAL; in samsung_dcphy_rx_lane_enable()
2153 if (sensor->lanes > 0x00) { in samsung_dcphy_rx_lane_enable()
2154 ret = regmap_read_poll_timeout(samsung->regmap, RX_DATA_LANE0_ENABLE, in samsung_dcphy_rx_lane_enable()
2157 dev_err(samsung->dev, "phy rx data lane 0 is not locked\n"); in samsung_dcphy_rx_lane_enable()
2158 return -EINVAL; in samsung_dcphy_rx_lane_enable()
2161 if (sensor->lanes > 0x01) { in samsung_dcphy_rx_lane_enable()
2162 ret = regmap_read_poll_timeout(samsung->regmap, RX_DATA_LANE1_ENABLE, in samsung_dcphy_rx_lane_enable()
2165 dev_err(samsung->dev, "phy rx data lane 1 is not locked\n"); in samsung_dcphy_rx_lane_enable()
2166 return -EINVAL; in samsung_dcphy_rx_lane_enable()
2169 if (sensor->lanes > 0x02) { in samsung_dcphy_rx_lane_enable()
2170 ret = regmap_read_poll_timeout(samsung->regmap, RX_DATA_LANE2_ENABLE, in samsung_dcphy_rx_lane_enable()
2173 dev_err(samsung->dev, "phy rx data lane 2 is not locked\n"); in samsung_dcphy_rx_lane_enable()
2174 return -EINVAL; in samsung_dcphy_rx_lane_enable()
2178 if (sensor->lanes > 0x03) { in samsung_dcphy_rx_lane_enable()
2179 ret = regmap_read_poll_timeout(samsung->regmap, RX_DATA_LANE3_ENABLE, in samsung_dcphy_rx_lane_enable()
2182 dev_err(samsung->dev, "phy rx data lane 3 is not locked\n"); in samsung_dcphy_rx_lane_enable()
2183 return -EINVAL; in samsung_dcphy_rx_lane_enable()
2189 static int samsung_dcphy_rx_stream_on(struct csi2_dphy *dphy, in samsung_dcphy_rx_stream_on() argument
2194 struct samsung_mipi_dcphy *samsung = dphy->samsung_phy; in samsung_dcphy_rx_stream_on()
2198 return -ENODEV; in samsung_dcphy_rx_stream_on()
2199 sensor = sd_to_sensor(dphy, sensor_sd); in samsung_dcphy_rx_stream_on()
2201 return -ENODEV; in samsung_dcphy_rx_stream_on()
2203 mutex_lock(&samsung->mutex); in samsung_dcphy_rx_stream_on()
2204 if (sensor->mbus.type == V4L2_MBUS_CSI2_CPHY) in samsung_dcphy_rx_stream_on()
2205 regmap_write(samsung->grf_regmap, MIPI_DCPHY_GRF_CON0, S_CPHY_MODE); in samsung_dcphy_rx_stream_on()
2207 if (samsung->s_phy_rst) in samsung_dcphy_rx_stream_on()
2208 reset_control_assert(samsung->s_phy_rst); in samsung_dcphy_rx_stream_on()
2210 samsung_mipi_dcphy_bias_block_enable(samsung, dphy); in samsung_dcphy_rx_stream_on()
2211 ret = samsung_dcphy_rx_config_common(dphy, sensor); in samsung_dcphy_rx_stream_on()
2214 samsung_dcphy_rx_config_settle(dphy, sensor); in samsung_dcphy_rx_stream_on()
2216 ret = samsung_dcphy_rx_lane_enable(dphy, sensor); in samsung_dcphy_rx_stream_on()
2220 if (samsung->s_phy_rst) in samsung_dcphy_rx_stream_on()
2221 reset_control_deassert(samsung->s_phy_rst); in samsung_dcphy_rx_stream_on()
2223 atomic_inc(&samsung->stream_cnt); in samsung_dcphy_rx_stream_on()
2224 mutex_unlock(&samsung->mutex); in samsung_dcphy_rx_stream_on()
2228 if (samsung->s_phy_rst) in samsung_dcphy_rx_stream_on()
2229 reset_control_deassert(samsung->s_phy_rst); in samsung_dcphy_rx_stream_on()
2230 mutex_unlock(&samsung->mutex); in samsung_dcphy_rx_stream_on()
2231 dev_err(dphy->dev, "stream on error\n"); in samsung_dcphy_rx_stream_on()
2232 return -EINVAL; in samsung_dcphy_rx_stream_on()
2236 static int samsung_dcphy_rx_stream_off(struct csi2_dphy *dphy, in samsung_dcphy_rx_stream_off() argument
2239 struct samsung_mipi_dcphy *samsung = dphy->samsung_phy; in samsung_dcphy_rx_stream_off()
2244 return -ENODEV; in samsung_dcphy_rx_stream_off()
2245 sensor = sd_to_sensor(dphy, sensor_sd); in samsung_dcphy_rx_stream_off()
2247 return -ENODEV; in samsung_dcphy_rx_stream_off()
2249 if (atomic_dec_return(&samsung->stream_cnt)) in samsung_dcphy_rx_stream_off()
2252 mutex_lock(&samsung->mutex); in samsung_dcphy_rx_stream_off()
2253 if (samsung->s_phy_rst) in samsung_dcphy_rx_stream_off()
2254 reset_control_assert(samsung->s_phy_rst); in samsung_dcphy_rx_stream_off()
2256 if (sensor->mbus.type == V4L2_MBUS_CSI2_DPHY) in samsung_dcphy_rx_stream_off()
2257 regmap_update_bits(samsung->regmap, RX_CLK_LANE_ENABLE, PHY_ENABLE, 0); in samsung_dcphy_rx_stream_off()
2259 if (sensor->lanes > 0x00) in samsung_dcphy_rx_stream_off()
2260 regmap_update_bits(samsung->regmap, RX_DATA_LANE0_ENABLE, PHY_ENABLE, 0); in samsung_dcphy_rx_stream_off()
2261 if (sensor->lanes > 0x01) in samsung_dcphy_rx_stream_off()
2262 regmap_update_bits(samsung->regmap, RX_DATA_LANE1_ENABLE, PHY_ENABLE, 0); in samsung_dcphy_rx_stream_off()
2263 if (sensor->lanes > 0x02) in samsung_dcphy_rx_stream_off()
2264 regmap_update_bits(samsung->regmap, RX_DATA_LANE2_ENABLE, PHY_ENABLE, 0); in samsung_dcphy_rx_stream_off()
2265 if (sensor->lanes > 0x03) in samsung_dcphy_rx_stream_off()
2266 regmap_update_bits(samsung->regmap, RX_DATA_LANE3_ENABLE, PHY_ENABLE, 0); in samsung_dcphy_rx_stream_off()
2268 if (samsung->s_phy_rst) in samsung_dcphy_rx_stream_off()
2269 reset_control_deassert(samsung->s_phy_rst); in samsung_dcphy_rx_stream_off()
2272 mutex_unlock(&samsung->mutex); in samsung_dcphy_rx_stream_off()
2281 pm_runtime_get_sync(samsung->dev); in samsung_mipi_dcphy_init()
2290 pm_runtime_put(samsung->dev); in samsung_mipi_dcphy_exit()
2314 struct device *dev = &pdev->dev; in samsung_mipi_dcphy_probe()
2315 struct device_node *np = dev->of_node; in samsung_mipi_dcphy_probe()
2325 return -ENOMEM; in samsung_mipi_dcphy_probe()
2327 samsung->dev = dev; in samsung_mipi_dcphy_probe()
2335 samsung->regmap = devm_regmap_init_mmio(dev, regs, in samsung_mipi_dcphy_probe()
2337 if (IS_ERR(samsung->regmap)) { in samsung_mipi_dcphy_probe()
2338 ret = PTR_ERR(samsung->regmap); in samsung_mipi_dcphy_probe()
2343 samsung->grf_regmap = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); in samsung_mipi_dcphy_probe()
2344 if (IS_ERR(samsung->grf_regmap)) { in samsung_mipi_dcphy_probe()
2346 return PTR_ERR(samsung->grf_regmap); in samsung_mipi_dcphy_probe()
2349 samsung->ref_clk = devm_clk_get(dev, "ref"); in samsung_mipi_dcphy_probe()
2350 if (IS_ERR(samsung->ref_clk)) { in samsung_mipi_dcphy_probe()
2352 return PTR_ERR(samsung->ref_clk); in samsung_mipi_dcphy_probe()
2355 samsung->pclk = devm_clk_get(dev, "pclk"); in samsung_mipi_dcphy_probe()
2356 if (IS_ERR(samsung->pclk)) { in samsung_mipi_dcphy_probe()
2358 return PTR_ERR(samsung->pclk); in samsung_mipi_dcphy_probe()
2361 samsung->m_phy_rst = devm_reset_control_get(dev, "m_phy"); in samsung_mipi_dcphy_probe()
2362 if (IS_ERR(samsung->m_phy_rst)) { in samsung_mipi_dcphy_probe()
2364 return PTR_ERR(samsung->m_phy_rst); in samsung_mipi_dcphy_probe()
2367 samsung->s_phy_rst = devm_reset_control_get(dev, "s_phy"); in samsung_mipi_dcphy_probe()
2368 if (IS_ERR(samsung->s_phy_rst)) { in samsung_mipi_dcphy_probe()
2370 return PTR_ERR(samsung->s_phy_rst); in samsung_mipi_dcphy_probe()
2373 samsung->apb_rst = devm_reset_control_get(dev, "apb"); in samsung_mipi_dcphy_probe()
2374 if (IS_ERR(samsung->apb_rst)) { in samsung_mipi_dcphy_probe()
2376 return PTR_ERR(samsung->apb_rst); in samsung_mipi_dcphy_probe()
2379 samsung->grf_apb_rst = devm_reset_control_get(dev, "grf"); in samsung_mipi_dcphy_probe()
2380 if (IS_ERR(samsung->grf_apb_rst)) { in samsung_mipi_dcphy_probe()
2382 return PTR_ERR(samsung->grf_apb_rst); in samsung_mipi_dcphy_probe()
2387 dev_err(dev, "failed to create MIPI Dc-PHY\n"); in samsung_mipi_dcphy_probe()
2399 samsung->stream_on = samsung_dcphy_rx_stream_on; in samsung_mipi_dcphy_probe()
2400 samsung->stream_off = samsung_dcphy_rx_stream_off; in samsung_mipi_dcphy_probe()
2401 mutex_init(&samsung->mutex); in samsung_mipi_dcphy_probe()
2411 pm_runtime_disable(samsung->dev); in samsung_mipi_dcphy_remove()
2412 mutex_destroy(&samsung->mutex); in samsung_mipi_dcphy_remove()
2421 clk_disable_unprepare(samsung->pclk); in samsung_mipi_dcphy_runtime_suspend()
2422 clk_disable_unprepare(samsung->ref_clk); in samsung_mipi_dcphy_runtime_suspend()
2431 clk_prepare_enable(samsung->pclk); in samsung_mipi_dcphy_runtime_resume()
2432 clk_prepare_enable(samsung->ref_clk); in samsung_mipi_dcphy_runtime_resume()
2444 .compatible = "rockchip,rk3588-mipi-dcphy",
2452 .name = "samsung-mipi-dcphy",
2461 MODULE_AUTHOR("Guochun Huang<hero.huang@rock-chips.com>");