Svyatoslav Ryhel | feddf9f | 2023-03-27 11:11:48 +0300 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * (C) Copyright 2010 |
| 4 | * NVIDIA Corporation <www.nvidia.com> |
| 5 | */ |
| 6 | |
| 7 | #ifndef __ASM_ARCH_TEGRA_DSI_H |
| 8 | #define __ASM_ARCH_TEGRA_DSI_H |
| 9 | |
| 10 | #ifndef __ASSEMBLY__ |
| 11 | #include <linux/bitops.h> |
| 12 | #endif |
| 13 | |
| 14 | /* Register definitions for the Tegra display serial interface */ |
| 15 | |
| 16 | /* DSI syncpoint register 0x000 ~ 0x002 */ |
| 17 | struct dsi_syncpt_reg { |
| 18 | /* Address 0x000 ~ 0x002 */ |
| 19 | uint incr_syncpt; /* _INCR_SYNCPT_0 */ |
| 20 | uint incr_syncpt_ctrl; /* _INCR_SYNCPT_CNTRL_0 */ |
| 21 | uint incr_syncpt_err; /* _INCR_SYNCPT_ERROR_0 */ |
| 22 | }; |
| 23 | |
| 24 | /* DSI misc register 0x008 ~ 0x015 */ |
| 25 | struct dsi_misc_reg { |
| 26 | /* Address 0x008 ~ 0x015 */ |
| 27 | uint ctxsw; /* _CTXSW_0 */ |
| 28 | uint dsi_rd_data; /* _DSI_RD_DATA_0 */ |
| 29 | uint dsi_wr_data; /* _DSI_WR_DATA_0 */ |
| 30 | uint dsi_pwr_ctrl; /* _DSI_POWER_CONTROL_0 */ |
| 31 | uint int_enable; /* _INT_ENABLE_0 */ |
| 32 | uint int_status; /* _INT_STATUS_0 */ |
| 33 | uint int_mask; /* _INT_MASK_0 */ |
| 34 | uint host_dsi_ctrl; /* _HOST_DSI_CONTROL_0 */ |
| 35 | uint dsi_ctrl; /* _DSI_CONTROL_0 */ |
| 36 | uint dsi_sol_delay; /* _DSI_SOL_DELAY_0 */ |
| 37 | uint dsi_max_threshold; /* _DSI_MAX_THRESHOLD_0 */ |
| 38 | uint dsi_trigger; /* _DSI_TRIGGER_0 */ |
| 39 | uint dsi_tx_crc; /* _DSI_TX_CRC_0 */ |
| 40 | uint dsi_status; /* _DSI_STATUS_0 */ |
| 41 | }; |
| 42 | |
| 43 | /* DSI init sequence register 0x01a ~ 0x022 */ |
| 44 | struct dsi_init_seq_reg { |
| 45 | /* Address 0x01a ~ 0x022 */ |
| 46 | uint dsi_init_seq_ctrl; /* _DSI_INIT_SEQ_CONTROL_0 */ |
| 47 | uint dsi_init_seq_data_0; /* _DSI_INIT_SEQ_DATA_0_0 */ |
| 48 | uint dsi_init_seq_data_1; /* _DSI_INIT_SEQ_DATA_1_0 */ |
| 49 | uint dsi_init_seq_data_2; /* _DSI_INIT_SEQ_DATA_2_0 */ |
| 50 | uint dsi_init_seq_data_3; /* _DSI_INIT_SEQ_DATA_3_0 */ |
| 51 | uint dsi_init_seq_data_4; /* _DSI_INIT_SEQ_DATA_4_0 */ |
| 52 | uint dsi_init_seq_data_5; /* _DSI_INIT_SEQ_DATA_5_0 */ |
| 53 | uint dsi_init_seq_data_6; /* _DSI_INIT_SEQ_DATA_6_0 */ |
| 54 | uint dsi_init_seq_data_7; /* _DSI_INIT_SEQ_DATA_7_0 */ |
| 55 | }; |
| 56 | |
| 57 | /* DSI packet sequence register 0x023 ~ 0x02e */ |
| 58 | struct dsi_pkt_seq_reg { |
| 59 | /* Address 0x023 ~ 0x02e */ |
| 60 | uint dsi_pkt_seq_0_lo; /* _DSI_PKT_SEQ_0_LO_0 */ |
| 61 | uint dsi_pkt_seq_0_hi; /* _DSI_PKT_SEQ_0_HI_0 */ |
| 62 | uint dsi_pkt_seq_1_lo; /* _DSI_PKT_SEQ_1_LO_0 */ |
| 63 | uint dsi_pkt_seq_1_hi; /* _DSI_PKT_SEQ_1_HI_0 */ |
| 64 | uint dsi_pkt_seq_2_lo; /* _DSI_PKT_SEQ_2_LO_0 */ |
| 65 | uint dsi_pkt_seq_2_hi; /* _DSI_PKT_SEQ_2_HI_0 */ |
| 66 | uint dsi_pkt_seq_3_lo; /* _DSI_PKT_SEQ_3_LO_0 */ |
| 67 | uint dsi_pkt_seq_3_hi; /* _DSI_PKT_SEQ_3_HI_0 */ |
| 68 | uint dsi_pkt_seq_4_lo; /* _DSI_PKT_SEQ_4_LO_0 */ |
| 69 | uint dsi_pkt_seq_4_hi; /* _DSI_PKT_SEQ_4_HI_0 */ |
| 70 | uint dsi_pkt_seq_5_lo; /* _DSI_PKT_SEQ_5_LO_0 */ |
| 71 | uint dsi_pkt_seq_5_hi; /* _DSI_PKT_SEQ_5_HI_0 */ |
| 72 | }; |
| 73 | |
| 74 | /* DSI packet length register 0x033 ~ 0x037 */ |
| 75 | struct dsi_pkt_len_reg { |
| 76 | /* Address 0x033 ~ 0x037 */ |
| 77 | uint dsi_dcs_cmds; /* _DSI_DCS_CMDS_0 */ |
| 78 | uint dsi_pkt_len_0_1; /* _DSI_PKT_LEN_0_1_0 */ |
| 79 | uint dsi_pkt_len_2_3; /* _DSI_PKT_LEN_2_3_0 */ |
| 80 | uint dsi_pkt_len_4_5; /* _DSI_PKT_LEN_4_5_0 */ |
| 81 | uint dsi_pkt_len_6_7; /* _DSI_PKT_LEN_6_7_0 */ |
| 82 | }; |
| 83 | |
| 84 | /* DSI PHY timing register 0x03c ~ 0x03f */ |
| 85 | struct dsi_timing_reg { |
| 86 | /* Address 0x03c ~ 0x03f */ |
| 87 | uint dsi_phy_timing_0; /* _DSI_PHY_TIMING_0_0 */ |
| 88 | uint dsi_phy_timing_1; /* _DSI_PHY_TIMING_1_0 */ |
| 89 | uint dsi_phy_timing_2; /* _DSI_PHY_TIMING_2_0 */ |
| 90 | uint dsi_bta_timing; /* _DSI_BTA_TIMING_0 */ |
| 91 | }; |
| 92 | |
| 93 | /* DSI timeout register 0x044 ~ 0x046 */ |
| 94 | struct dsi_timeout_reg { |
| 95 | /* Address 0x044 ~ 0x046 */ |
| 96 | uint dsi_timeout_0; /* _DSI_TIMEOUT_0_0 */ |
| 97 | uint dsi_timeout_1; /* _DSI_TIMEOUT_1_0 */ |
| 98 | uint dsi_to_tally; /* _DSI_TO_TALLY_0 */ |
| 99 | }; |
| 100 | |
| 101 | /* DSI PAD control register 0x04b ~ 0x04e */ |
| 102 | struct dsi_pad_ctrl_reg { |
| 103 | /* Address 0x04b ~ 0x04e */ |
| 104 | uint pad_ctrl; /* _PAD_CONTROL_0 */ |
| 105 | uint pad_ctrl_cd; /* _PAD_CONTROL_CD_0 */ |
| 106 | uint pad_cd_status; /* _PAD_CD_STATUS_0 */ |
| 107 | uint dsi_vid_mode_control; /* _DSI_VID_MODE_CONTROL_0 */ |
| 108 | }; |
| 109 | |
| 110 | /* Display Serial Interface (DSI_) regs */ |
| 111 | struct dsi_ctlr { |
| 112 | struct dsi_syncpt_reg syncpt; /* SYNCPT register 0x000 ~ 0x002 */ |
| 113 | uint reserved0[5]; /* reserved_0[5] */ |
| 114 | |
| 115 | struct dsi_misc_reg misc; /* MISC register 0x008 ~ 0x015 */ |
| 116 | uint reserved1[4]; /* reserved_1[4] */ |
| 117 | |
| 118 | struct dsi_init_seq_reg init; /* INIT register 0x01a ~ 0x022 */ |
| 119 | struct dsi_pkt_seq_reg pkt; /* PKT register 0x023 ~ 0x02e */ |
| 120 | uint reserved2[4]; /* reserved_2[4] */ |
| 121 | |
| 122 | struct dsi_pkt_len_reg len; /* LEN registers 0x033 ~ 0x037 */ |
| 123 | uint reserved3[4]; /* reserved_3[4] */ |
| 124 | |
| 125 | struct dsi_timing_reg ptiming; /* TIMING registers 0x03c ~ 0x03f */ |
| 126 | uint reserved4[4]; /* reserved_4[4] */ |
| 127 | |
| 128 | struct dsi_timeout_reg timeout; /* TIMEOUT registers 0x044 ~ 0x046 */ |
| 129 | uint reserved5[4]; /* reserved_5[4] */ |
| 130 | |
| 131 | struct dsi_pad_ctrl_reg pad; /* PAD registers 0x04b ~ 0x04e */ |
| 132 | }; |
| 133 | |
| 134 | #define DSI_POWER_CONTROL_ENABLE BIT(0) |
| 135 | |
| 136 | #define DSI_HOST_CONTROL_FIFO_RESET BIT(21) |
| 137 | #define DSI_HOST_CONTROL_CRC_RESET BIT(20) |
| 138 | #define DSI_HOST_CONTROL_TX_TRIG_SOL (0 << 12) |
| 139 | #define DSI_HOST_CONTROL_TX_TRIG_FIFO (1 << 12) |
| 140 | #define DSI_HOST_CONTROL_TX_TRIG_HOST (2 << 12) |
| 141 | #define DSI_HOST_CONTROL_RAW BIT(6) |
| 142 | #define DSI_HOST_CONTROL_HS BIT(5) |
| 143 | #define DSI_HOST_CONTROL_FIFO_SEL BIT(4) |
| 144 | #define DSI_HOST_CONTROL_IMM_BTA BIT(3) |
| 145 | #define DSI_HOST_CONTROL_PKT_BTA BIT(2) |
| 146 | #define DSI_HOST_CONTROL_CS BIT(1) |
| 147 | #define DSI_HOST_CONTROL_ECC BIT(0) |
| 148 | |
| 149 | #define DSI_CONTROL_HS_CLK_CTRL BIT(20) |
| 150 | #define DSI_CONTROL_CHANNEL(c) (((c) & 0x3) << 16) |
| 151 | #define DSI_CONTROL_FORMAT(f) (((f) & 0x3) << 12) |
| 152 | #define DSI_CONTROL_TX_TRIG(x) (((x) & 0x3) << 8) |
| 153 | #define DSI_CONTROL_LANES(n) (((n) & 0x3) << 4) |
| 154 | #define DSI_CONTROL_DCS_ENABLE BIT(3) |
| 155 | #define DSI_CONTROL_SOURCE(s) (((s) & 0x1) << 2) |
| 156 | #define DSI_CONTROL_VIDEO_ENABLE BIT(1) |
| 157 | #define DSI_CONTROL_HOST_ENABLE BIT(0) |
| 158 | |
| 159 | #define DSI_TRIGGER_HOST BIT(1) |
| 160 | #define DSI_TRIGGER_VIDEO BIT(0) |
| 161 | |
| 162 | #define DSI_STATUS_IDLE BIT(10) |
| 163 | #define DSI_STATUS_UNDERFLOW BIT(9) |
| 164 | #define DSI_STATUS_OVERFLOW BIT(8) |
| 165 | |
| 166 | #define DSI_TIMING_FIELD(value, period, hwinc) \ |
| 167 | ((DIV_ROUND_CLOSEST(value, period) - (hwinc)) & 0xff) |
| 168 | |
| 169 | #define DSI_TIMEOUT_LRX(x) (((x) & 0xffff) << 16) |
| 170 | #define DSI_TIMEOUT_HTX(x) (((x) & 0xffff) << 0) |
| 171 | #define DSI_TIMEOUT_PR(x) (((x) & 0xffff) << 16) |
| 172 | #define DSI_TIMEOUT_TA(x) (((x) & 0xffff) << 0) |
| 173 | |
| 174 | #define DSI_TALLY_TA(x) (((x) & 0xff) << 16) |
| 175 | #define DSI_TALLY_LRX(x) (((x) & 0xff) << 8) |
| 176 | #define DSI_TALLY_HTX(x) (((x) & 0xff) << 0) |
| 177 | |
| 178 | #define DSI_PAD_CONTROL_PAD_PULLDN_ENAB(x) (((x) & 0x1) << 28) |
| 179 | #define DSI_PAD_CONTROL_PAD_SLEWUPADJ(x) (((x) & 0x7) << 24) |
| 180 | #define DSI_PAD_CONTROL_PAD_SLEWDNADJ(x) (((x) & 0x7) << 20) |
| 181 | #define DSI_PAD_CONTROL_PAD_PREEMP_EN(x) (((x) & 0x1) << 19) |
| 182 | #define DSI_PAD_CONTROL_PAD_PDIO_CLK(x) (((x) & 0x1) << 18) |
| 183 | #define DSI_PAD_CONTROL_PAD_PDIO(x) (((x) & 0x3) << 16) |
| 184 | #define DSI_PAD_CONTROL_PAD_LPUPADJ(x) (((x) & 0x3) << 14) |
| 185 | #define DSI_PAD_CONTROL_PAD_LPDNADJ(x) (((x) & 0x3) << 12) |
| 186 | |
| 187 | /* |
| 188 | * pixel format as used in the DSI_CONTROL_FORMAT field |
| 189 | */ |
| 190 | enum tegra_dsi_format { |
| 191 | TEGRA_DSI_FORMAT_16P, |
| 192 | TEGRA_DSI_FORMAT_18NP, |
| 193 | TEGRA_DSI_FORMAT_18P, |
| 194 | TEGRA_DSI_FORMAT_24P, |
| 195 | }; |
| 196 | |
| 197 | /* DSI calibration in VI region */ |
| 198 | #define TEGRA_VI_BASE 0x54080000 |
| 199 | |
| 200 | #define CSI_CILA_MIPI_CAL_CONFIG_0 0x22a |
| 201 | #define MIPI_CAL_TERMOSA(x) (((x) & 0x1f) << 0) |
| 202 | |
| 203 | #define CSI_CILB_MIPI_CAL_CONFIG_0 0x22b |
| 204 | #define MIPI_CAL_TERMOSB(x) (((x) & 0x1f) << 0) |
| 205 | |
| 206 | #define CSI_CIL_PAD_CONFIG 0x229 |
| 207 | #define PAD_CIL_PDVREG(x) (((x) & 0x01) << 1) |
| 208 | |
| 209 | #define CSI_DSI_MIPI_CAL_CONFIG 0x234 |
| 210 | #define MIPI_CAL_HSPDOSD(x) (((x) & 0x1f) << 16) |
| 211 | #define MIPI_CAL_HSPUOSD(x) (((x) & 0x1f) << 8) |
| 212 | |
| 213 | #define CSI_MIPIBIAS_PAD_CONFIG 0x235 |
| 214 | #define PAD_DRIV_DN_REF(x) (((x) & 0x7) << 16) |
| 215 | #define PAD_DRIV_UP_REF(x) (((x) & 0x7) << 8) |
| 216 | |
| 217 | #endif /* __ASM_ARCH_TEGRA_DSI_H */ |