1*44cfc623SGuido Günther /* SPDX-License-Identifier: GPL-2.0+ */ 2*44cfc623SGuido Günther /* 3*44cfc623SGuido Günther * NWL MIPI DSI host driver 4*44cfc623SGuido Günther * 5*44cfc623SGuido Günther * Copyright (C) 2017 NXP 6*44cfc623SGuido Günther * Copyright (C) 2019 Purism SPC 7*44cfc623SGuido Günther */ 8*44cfc623SGuido Günther #ifndef __NWL_DSI_H__ 9*44cfc623SGuido Günther #define __NWL_DSI_H__ 10*44cfc623SGuido Günther 11*44cfc623SGuido Günther /* DSI HOST registers */ 12*44cfc623SGuido Günther #define NWL_DSI_CFG_NUM_LANES 0x0 13*44cfc623SGuido Günther #define NWL_DSI_CFG_NONCONTINUOUS_CLK 0x4 14*44cfc623SGuido Günther #define NWL_DSI_CFG_T_PRE 0x8 15*44cfc623SGuido Günther #define NWL_DSI_CFG_T_POST 0xc 16*44cfc623SGuido Günther #define NWL_DSI_CFG_TX_GAP 0x10 17*44cfc623SGuido Günther #define NWL_DSI_CFG_AUTOINSERT_EOTP 0x14 18*44cfc623SGuido Günther #define NWL_DSI_CFG_EXTRA_CMDS_AFTER_EOTP 0x18 19*44cfc623SGuido Günther #define NWL_DSI_CFG_HTX_TO_COUNT 0x1c 20*44cfc623SGuido Günther #define NWL_DSI_CFG_LRX_H_TO_COUNT 0x20 21*44cfc623SGuido Günther #define NWL_DSI_CFG_BTA_H_TO_COUNT 0x24 22*44cfc623SGuido Günther #define NWL_DSI_CFG_TWAKEUP 0x28 23*44cfc623SGuido Günther #define NWL_DSI_CFG_STATUS_OUT 0x2c 24*44cfc623SGuido Günther #define NWL_DSI_RX_ERROR_STATUS 0x30 25*44cfc623SGuido Günther 26*44cfc623SGuido Günther /* DSI DPI registers */ 27*44cfc623SGuido Günther #define NWL_DSI_PIXEL_PAYLOAD_SIZE 0x200 28*44cfc623SGuido Günther #define NWL_DSI_PIXEL_FIFO_SEND_LEVEL 0x204 29*44cfc623SGuido Günther #define NWL_DSI_INTERFACE_COLOR_CODING 0x208 30*44cfc623SGuido Günther #define NWL_DSI_PIXEL_FORMAT 0x20c 31*44cfc623SGuido Günther #define NWL_DSI_VSYNC_POLARITY 0x210 32*44cfc623SGuido Günther #define NWL_DSI_VSYNC_POLARITY_ACTIVE_LOW 0 33*44cfc623SGuido Günther #define NWL_DSI_VSYNC_POLARITY_ACTIVE_HIGH BIT(1) 34*44cfc623SGuido Günther 35*44cfc623SGuido Günther #define NWL_DSI_HSYNC_POLARITY 0x214 36*44cfc623SGuido Günther #define NWL_DSI_HSYNC_POLARITY_ACTIVE_LOW 0 37*44cfc623SGuido Günther #define NWL_DSI_HSYNC_POLARITY_ACTIVE_HIGH BIT(1) 38*44cfc623SGuido Günther 39*44cfc623SGuido Günther #define NWL_DSI_VIDEO_MODE 0x218 40*44cfc623SGuido Günther #define NWL_DSI_HFP 0x21c 41*44cfc623SGuido Günther #define NWL_DSI_HBP 0x220 42*44cfc623SGuido Günther #define NWL_DSI_HSA 0x224 43*44cfc623SGuido Günther #define NWL_DSI_ENABLE_MULT_PKTS 0x228 44*44cfc623SGuido Günther #define NWL_DSI_VBP 0x22c 45*44cfc623SGuido Günther #define NWL_DSI_VFP 0x230 46*44cfc623SGuido Günther #define NWL_DSI_BLLP_MODE 0x234 47*44cfc623SGuido Günther #define NWL_DSI_USE_NULL_PKT_BLLP 0x238 48*44cfc623SGuido Günther #define NWL_DSI_VACTIVE 0x23c 49*44cfc623SGuido Günther #define NWL_DSI_VC 0x240 50*44cfc623SGuido Günther 51*44cfc623SGuido Günther /* DSI APB PKT control */ 52*44cfc623SGuido Günther #define NWL_DSI_TX_PAYLOAD 0x280 53*44cfc623SGuido Günther #define NWL_DSI_PKT_CONTROL 0x284 54*44cfc623SGuido Günther #define NWL_DSI_SEND_PACKET 0x288 55*44cfc623SGuido Günther #define NWL_DSI_PKT_STATUS 0x28c 56*44cfc623SGuido Günther #define NWL_DSI_PKT_FIFO_WR_LEVEL 0x290 57*44cfc623SGuido Günther #define NWL_DSI_PKT_FIFO_RD_LEVEL 0x294 58*44cfc623SGuido Günther #define NWL_DSI_RX_PAYLOAD 0x298 59*44cfc623SGuido Günther #define NWL_DSI_RX_PKT_HEADER 0x29c 60*44cfc623SGuido Günther 61*44cfc623SGuido Günther /* DSI IRQ handling */ 62*44cfc623SGuido Günther #define NWL_DSI_IRQ_STATUS 0x2a0 63*44cfc623SGuido Günther #define NWL_DSI_SM_NOT_IDLE BIT(0) 64*44cfc623SGuido Günther #define NWL_DSI_TX_PKT_DONE BIT(1) 65*44cfc623SGuido Günther #define NWL_DSI_DPHY_DIRECTION BIT(2) 66*44cfc623SGuido Günther #define NWL_DSI_TX_FIFO_OVFLW BIT(3) 67*44cfc623SGuido Günther #define NWL_DSI_TX_FIFO_UDFLW BIT(4) 68*44cfc623SGuido Günther #define NWL_DSI_RX_FIFO_OVFLW BIT(5) 69*44cfc623SGuido Günther #define NWL_DSI_RX_FIFO_UDFLW BIT(6) 70*44cfc623SGuido Günther #define NWL_DSI_RX_PKT_HDR_RCVD BIT(7) 71*44cfc623SGuido Günther #define NWL_DSI_RX_PKT_PAYLOAD_DATA_RCVD BIT(8) 72*44cfc623SGuido Günther #define NWL_DSI_BTA_TIMEOUT BIT(29) 73*44cfc623SGuido Günther #define NWL_DSI_LP_RX_TIMEOUT BIT(30) 74*44cfc623SGuido Günther #define NWL_DSI_HS_TX_TIMEOUT BIT(31) 75*44cfc623SGuido Günther 76*44cfc623SGuido Günther #define NWL_DSI_IRQ_STATUS2 0x2a4 77*44cfc623SGuido Günther #define NWL_DSI_SINGLE_BIT_ECC_ERR BIT(0) 78*44cfc623SGuido Günther #define NWL_DSI_MULTI_BIT_ECC_ERR BIT(1) 79*44cfc623SGuido Günther #define NWL_DSI_CRC_ERR BIT(2) 80*44cfc623SGuido Günther 81*44cfc623SGuido Günther #define NWL_DSI_IRQ_MASK 0x2a8 82*44cfc623SGuido Günther #define NWL_DSI_SM_NOT_IDLE_MASK BIT(0) 83*44cfc623SGuido Günther #define NWL_DSI_TX_PKT_DONE_MASK BIT(1) 84*44cfc623SGuido Günther #define NWL_DSI_DPHY_DIRECTION_MASK BIT(2) 85*44cfc623SGuido Günther #define NWL_DSI_TX_FIFO_OVFLW_MASK BIT(3) 86*44cfc623SGuido Günther #define NWL_DSI_TX_FIFO_UDFLW_MASK BIT(4) 87*44cfc623SGuido Günther #define NWL_DSI_RX_FIFO_OVFLW_MASK BIT(5) 88*44cfc623SGuido Günther #define NWL_DSI_RX_FIFO_UDFLW_MASK BIT(6) 89*44cfc623SGuido Günther #define NWL_DSI_RX_PKT_HDR_RCVD_MASK BIT(7) 90*44cfc623SGuido Günther #define NWL_DSI_RX_PKT_PAYLOAD_DATA_RCVD_MASK BIT(8) 91*44cfc623SGuido Günther #define NWL_DSI_BTA_TIMEOUT_MASK BIT(29) 92*44cfc623SGuido Günther #define NWL_DSI_LP_RX_TIMEOUT_MASK BIT(30) 93*44cfc623SGuido Günther #define NWL_DSI_HS_TX_TIMEOUT_MASK BIT(31) 94*44cfc623SGuido Günther 95*44cfc623SGuido Günther #define NWL_DSI_IRQ_MASK2 0x2ac 96*44cfc623SGuido Günther #define NWL_DSI_SINGLE_BIT_ECC_ERR_MASK BIT(0) 97*44cfc623SGuido Günther #define NWL_DSI_MULTI_BIT_ECC_ERR_MASK BIT(1) 98*44cfc623SGuido Günther #define NWL_DSI_CRC_ERR_MASK BIT(2) 99*44cfc623SGuido Günther 100*44cfc623SGuido Günther /* 101*44cfc623SGuido Günther * PKT_CONTROL format: 102*44cfc623SGuido Günther * [15: 0] - word count 103*44cfc623SGuido Günther * [17:16] - virtual channel 104*44cfc623SGuido Günther * [23:18] - data type 105*44cfc623SGuido Günther * [24] - LP or HS select (0 - LP, 1 - HS) 106*44cfc623SGuido Günther * [25] - perform BTA after packet is sent 107*44cfc623SGuido Günther * [26] - perform BTA only, no packet tx 108*44cfc623SGuido Günther */ 109*44cfc623SGuido Günther #define NWL_DSI_WC(x) FIELD_PREP(GENMASK(15, 0), (x)) 110*44cfc623SGuido Günther #define NWL_DSI_TX_VC(x) FIELD_PREP(GENMASK(17, 16), (x)) 111*44cfc623SGuido Günther #define NWL_DSI_TX_DT(x) FIELD_PREP(GENMASK(23, 18), (x)) 112*44cfc623SGuido Günther #define NWL_DSI_HS_SEL(x) FIELD_PREP(GENMASK(24, 24), (x)) 113*44cfc623SGuido Günther #define NWL_DSI_BTA_TX(x) FIELD_PREP(GENMASK(25, 25), (x)) 114*44cfc623SGuido Günther #define NWL_DSI_BTA_NO_TX(x) FIELD_PREP(GENMASK(26, 26), (x)) 115*44cfc623SGuido Günther 116*44cfc623SGuido Günther /* 117*44cfc623SGuido Günther * RX_PKT_HEADER format: 118*44cfc623SGuido Günther * [15: 0] - word count 119*44cfc623SGuido Günther * [21:16] - data type 120*44cfc623SGuido Günther * [23:22] - virtual channel 121*44cfc623SGuido Günther */ 122*44cfc623SGuido Günther #define NWL_DSI_RX_DT(x) FIELD_GET(GENMASK(21, 16), (x)) 123*44cfc623SGuido Günther #define NWL_DSI_RX_VC(x) FIELD_GET(GENMASK(23, 22), (x)) 124*44cfc623SGuido Günther 125*44cfc623SGuido Günther /* DSI Video mode */ 126*44cfc623SGuido Günther #define NWL_DSI_VM_BURST_MODE_WITH_SYNC_PULSES 0 127*44cfc623SGuido Günther #define NWL_DSI_VM_NON_BURST_MODE_WITH_SYNC_EVENTS BIT(0) 128*44cfc623SGuido Günther #define NWL_DSI_VM_BURST_MODE BIT(1) 129*44cfc623SGuido Günther 130*44cfc623SGuido Günther /* * DPI color coding */ 131*44cfc623SGuido Günther #define NWL_DSI_DPI_16_BIT_565_PACKED 0 132*44cfc623SGuido Günther #define NWL_DSI_DPI_16_BIT_565_ALIGNED 1 133*44cfc623SGuido Günther #define NWL_DSI_DPI_16_BIT_565_SHIFTED 2 134*44cfc623SGuido Günther #define NWL_DSI_DPI_18_BIT_PACKED 3 135*44cfc623SGuido Günther #define NWL_DSI_DPI_18_BIT_ALIGNED 4 136*44cfc623SGuido Günther #define NWL_DSI_DPI_24_BIT 5 137*44cfc623SGuido Günther 138*44cfc623SGuido Günther /* * DPI Pixel format */ 139*44cfc623SGuido Günther #define NWL_DSI_PIXEL_FORMAT_16 0 140*44cfc623SGuido Günther #define NWL_DSI_PIXEL_FORMAT_18 BIT(0) 141*44cfc623SGuido Günther #define NWL_DSI_PIXEL_FORMAT_18L BIT(1) 142*44cfc623SGuido Günther #define NWL_DSI_PIXEL_FORMAT_24 (BIT(0) | BIT(1)) 143*44cfc623SGuido Günther 144*44cfc623SGuido Günther #endif /* __NWL_DSI_H__ */ 145