Angel Pons | a2ee761 | 2020-04-04 18:51:15 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Elyes HAOUAS | e9a0130 | 2018-10-26 15:06:33 +0200 | [diff] [blame] | 2 | |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 3 | #include <soc/addressmap.h> |
| 4 | #include <soc/clock.h> |
| 5 | #include <device/device.h> |
| 6 | #include <soc/nvidia/tegra/types.h> |
| 7 | #include <soc/display.h> |
| 8 | #include <soc/mipi_dsi.h> |
| 9 | #include <soc/mipi_display.h> |
| 10 | #include <soc/tegra_dsi.h> |
| 11 | #include <soc/mipi-phy.h> |
Elyes HAOUAS | 27d02d8 | 2019-05-15 21:11:39 +0200 | [diff] [blame] | 12 | #include <types.h> |
Patrick Georgi | 40a3e32 | 2015-06-22 19:41:29 +0200 | [diff] [blame] | 13 | |
| 14 | int mipi_dphy_set_timing(struct tegra_dsi *dsi) |
| 15 | { |
| 16 | |
| 17 | u32 freq = (dsi->clk_rate * 2) / 1000000; |
| 18 | |
| 19 | u32 thsdexit = (DSI_PHY_TIMING_DIV(120, (freq))); |
| 20 | u32 thstrial = (((3) + (DSI_PHY_TIMING_DIV((DSI_THSTRAIL_VAL(freq)), |
| 21 | freq)))); |
| 22 | u32 tdatzero = DSI_PHY_TIMING_DIV(((145) + (5 * (DSI_TBIT(freq)))), |
| 23 | (freq)); |
| 24 | u32 thsprepare = DSI_PHY_TIMING_DIV((65 + (5*(DSI_TBIT(freq)))), freq); |
| 25 | u32 tclktrial = (DSI_PHY_TIMING_DIV(80, freq)); |
| 26 | u32 tclkpost = ((DSI_PHY_TIMING_DIV(((70) + ((52) * (DSI_TBIT(freq)))), |
| 27 | freq))); |
| 28 | u32 tclkzero = (DSI_PHY_TIMING_DIV(260, freq)); |
| 29 | u32 ttlpx = (DSI_PHY_TIMING_DIV(60, freq)) ; |
| 30 | u32 tclkprepare = (DSI_PHY_TIMING_DIV(60, freq)); |
| 31 | u32 tclkpre = 1; //min = 8*UI per mipi spec, tclk_pre=0 should be ok, but using 1 value |
| 32 | u32 twakeup = 0x7F; //min = 1ms |
| 33 | |
| 34 | u32 ttaget; |
| 35 | u32 ttassure; |
| 36 | u32 ttago; |
| 37 | u32 value; |
| 38 | |
| 39 | if (!ttlpx) { |
| 40 | ttaget = 5; |
| 41 | ttassure = 2; |
| 42 | ttago = 4; |
| 43 | } else { |
| 44 | ttaget = 5 * ttlpx; |
| 45 | ttassure = 2 * ttlpx; |
| 46 | ttago = 4 * ttlpx; |
| 47 | } |
| 48 | |
| 49 | value = (thsdexit << 24) | |
| 50 | (thstrial << 16) | |
| 51 | (tdatzero << 8) | |
| 52 | (thsprepare << 0); |
| 53 | tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_0); |
| 54 | |
| 55 | value = (tclktrial << 24) | |
| 56 | (tclkpost << 16) | |
| 57 | (tclkzero << 8) | |
| 58 | (ttlpx << 0); |
| 59 | tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_1); |
| 60 | |
| 61 | value = (tclkprepare << 16) | |
| 62 | (tclkpre << 8) | |
| 63 | (twakeup << 0); |
| 64 | tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_2); |
| 65 | |
| 66 | value = (ttaget << 16) | |
| 67 | (ttassure << 8) | |
| 68 | (ttago << 0), |
| 69 | tegra_dsi_writel(dsi, value, DSI_BTA_TIMING); |
| 70 | return 0; |
| 71 | } |