2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <soc/addressmap.h>
16 #include <soc/clock.h>
17 #include <device/device.h>
18 #include <soc/nvidia/tegra/types.h>
19 #include <soc/display.h>
20 #include <soc/mipi_dsi.h>
21 #include <soc/mipi_display.h>
22 #include <soc/tegra_dsi.h>
23 #include <soc/mipi-phy.h>
26 int mipi_dphy_set_timing(struct tegra_dsi
*dsi
)
29 u32 freq
= (dsi
->clk_rate
* 2) / 1000000;
31 u32 thsdexit
= (DSI_PHY_TIMING_DIV(120, (freq
)));
32 u32 thstrial
= (((3) + (DSI_PHY_TIMING_DIV((DSI_THSTRAIL_VAL(freq
)),
34 u32 tdatzero
= DSI_PHY_TIMING_DIV(((145) + (5 * (DSI_TBIT(freq
)))),
36 u32 thsprepare
= DSI_PHY_TIMING_DIV((65 + (5*(DSI_TBIT(freq
)))), freq
);
37 u32 tclktrial
= (DSI_PHY_TIMING_DIV(80, freq
));
38 u32 tclkpost
= ((DSI_PHY_TIMING_DIV(((70) + ((52) * (DSI_TBIT(freq
)))),
40 u32 tclkzero
= (DSI_PHY_TIMING_DIV(260, freq
));
41 u32 ttlpx
= (DSI_PHY_TIMING_DIV(60, freq
)) ;
42 u32 tclkprepare
= (DSI_PHY_TIMING_DIV(60, freq
));
43 u32 tclkpre
= 1; //min = 8*UI per mipi spec, tclk_pre=0 should be ok, but using 1 value
44 u32 twakeup
= 0x7F; //min = 1ms
61 value
= (thsdexit
<< 24) |
65 tegra_dsi_writel(dsi
, value
, DSI_PHY_TIMING_0
);
67 value
= (tclktrial
<< 24) |
71 tegra_dsi_writel(dsi
, value
, DSI_PHY_TIMING_1
);
73 value
= (tclkprepare
<< 16) |
76 tegra_dsi_writel(dsi
, value
, DSI_PHY_TIMING_2
);
78 value
= (ttaget
<< 16) |
81 tegra_dsi_writel(dsi
, value
, DSI_BTA_TIMING
);