1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/mmio.h>
10 void mtk_dsi_configure_mipi_tx(u32 data_rate
, u32 lanes
)
12 unsigned int txdiv0
, txdiv1
;
15 if (data_rate
>= 2000 * MHz
) {
18 } else if (data_rate
>= 1000 * MHz
) {
21 } else if (data_rate
>= 500 * MHz
) {
24 } else if (data_rate
> 250 * MHz
) {
25 /* (data_rate == 250MHz) is a special case that should go to the
26 else-block below (txdiv0 = 4) */
31 assert(data_rate
>= MTK_DSI_DATA_RATE_MIN_MHZ
* MHz
);
36 clrbits32(&mipi_tx
->pll_con4
, BIT(11) | BIT(10));
37 setbits32(&mipi_tx
->pll_pwr
, AD_DSI_PLL_SDM_PWR_ON
);
39 clrbits32(&mipi_tx
->pll_pwr
, AD_DSI_PLL_SDM_ISO_EN
);
41 pcw
= (u64
)data_rate
* (1 << txdiv0
) * (1 << txdiv1
);
45 write32(&mipi_tx
->pll_con0
, pcw
);
46 clrsetbits32(&mipi_tx
->pll_con1
, RG_DSI_PLL_POSDIV
, txdiv0
<< 8);
48 setbits32(&mipi_tx
->pll_con1
, RG_DSI_PLL_EN
);
50 /* BG_LPF_EN / BG_CORE_EN */
51 write32(&mipi_tx
->lane_con
, 0x3fff0180);
53 write32(&mipi_tx
->lane_con
, 0x3fff00c0);
55 /* Switch OFF each Lane */
56 clrbits32(&mipi_tx
->d0_sw_ctl_en
, DSI_SW_CTL_EN
);
57 clrbits32(&mipi_tx
->d1_sw_ctl_en
, DSI_SW_CTL_EN
);
58 clrbits32(&mipi_tx
->d2_sw_ctl_en
, DSI_SW_CTL_EN
);
59 clrbits32(&mipi_tx
->d3_sw_ctl_en
, DSI_SW_CTL_EN
);
60 clrbits32(&mipi_tx
->ck_sw_ctl_en
, DSI_SW_CTL_EN
);
62 setbits32(&mipi_tx
->ck_ckmode_en
, DSI_CK_CKMODE_EN
);
65 void mtk_dsi_reset(void)
67 write32(&dsi0
->dsi_force_commit
,
68 DSI_FORCE_COMMIT_USE_MMSYS
| DSI_FORCE_COMMIT_ALWAYS
);
69 write32(&dsi0
->dsi_con_ctrl
, 1);
70 write32(&dsi0
->dsi_con_ctrl
, 0);