162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * NWL MIPI DSI host driver 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (C) 2017 NXP 662306a36Sopenharmony_ci * Copyright (C) 2019 Purism SPC 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci#ifndef __NWL_DSI_H__ 962306a36Sopenharmony_ci#define __NWL_DSI_H__ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* DSI HOST registers */ 1262306a36Sopenharmony_ci#define NWL_DSI_CFG_NUM_LANES 0x0 1362306a36Sopenharmony_ci#define NWL_DSI_CFG_NONCONTINUOUS_CLK 0x4 1462306a36Sopenharmony_ci#define NWL_DSI_CFG_T_PRE 0x8 1562306a36Sopenharmony_ci#define NWL_DSI_CFG_T_POST 0xc 1662306a36Sopenharmony_ci#define NWL_DSI_CFG_TX_GAP 0x10 1762306a36Sopenharmony_ci#define NWL_DSI_CFG_AUTOINSERT_EOTP 0x14 1862306a36Sopenharmony_ci#define NWL_DSI_CFG_EXTRA_CMDS_AFTER_EOTP 0x18 1962306a36Sopenharmony_ci#define NWL_DSI_CFG_HTX_TO_COUNT 0x1c 2062306a36Sopenharmony_ci#define NWL_DSI_CFG_LRX_H_TO_COUNT 0x20 2162306a36Sopenharmony_ci#define NWL_DSI_CFG_BTA_H_TO_COUNT 0x24 2262306a36Sopenharmony_ci#define NWL_DSI_CFG_TWAKEUP 0x28 2362306a36Sopenharmony_ci#define NWL_DSI_CFG_STATUS_OUT 0x2c 2462306a36Sopenharmony_ci#define NWL_DSI_RX_ERROR_STATUS 0x30 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* DSI DPI registers */ 2762306a36Sopenharmony_ci#define NWL_DSI_PIXEL_PAYLOAD_SIZE 0x200 2862306a36Sopenharmony_ci#define NWL_DSI_PIXEL_FIFO_SEND_LEVEL 0x204 2962306a36Sopenharmony_ci#define NWL_DSI_INTERFACE_COLOR_CODING 0x208 3062306a36Sopenharmony_ci#define NWL_DSI_PIXEL_FORMAT 0x20c 3162306a36Sopenharmony_ci#define NWL_DSI_VSYNC_POLARITY 0x210 3262306a36Sopenharmony_ci#define NWL_DSI_VSYNC_POLARITY_ACTIVE_LOW 0 3362306a36Sopenharmony_ci#define NWL_DSI_VSYNC_POLARITY_ACTIVE_HIGH BIT(1) 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define NWL_DSI_HSYNC_POLARITY 0x214 3662306a36Sopenharmony_ci#define NWL_DSI_HSYNC_POLARITY_ACTIVE_LOW 0 3762306a36Sopenharmony_ci#define NWL_DSI_HSYNC_POLARITY_ACTIVE_HIGH BIT(1) 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define NWL_DSI_VIDEO_MODE 0x218 4062306a36Sopenharmony_ci#define NWL_DSI_HFP 0x21c 4162306a36Sopenharmony_ci#define NWL_DSI_HBP 0x220 4262306a36Sopenharmony_ci#define NWL_DSI_HSA 0x224 4362306a36Sopenharmony_ci#define NWL_DSI_ENABLE_MULT_PKTS 0x228 4462306a36Sopenharmony_ci#define NWL_DSI_VBP 0x22c 4562306a36Sopenharmony_ci#define NWL_DSI_VFP 0x230 4662306a36Sopenharmony_ci#define NWL_DSI_BLLP_MODE 0x234 4762306a36Sopenharmony_ci#define NWL_DSI_USE_NULL_PKT_BLLP 0x238 4862306a36Sopenharmony_ci#define NWL_DSI_VACTIVE 0x23c 4962306a36Sopenharmony_ci#define NWL_DSI_VC 0x240 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci/* DSI APB PKT control */ 5262306a36Sopenharmony_ci#define NWL_DSI_TX_PAYLOAD 0x280 5362306a36Sopenharmony_ci#define NWL_DSI_PKT_CONTROL 0x284 5462306a36Sopenharmony_ci#define NWL_DSI_SEND_PACKET 0x288 5562306a36Sopenharmony_ci#define NWL_DSI_PKT_STATUS 0x28c 5662306a36Sopenharmony_ci#define NWL_DSI_PKT_FIFO_WR_LEVEL 0x290 5762306a36Sopenharmony_ci#define NWL_DSI_PKT_FIFO_RD_LEVEL 0x294 5862306a36Sopenharmony_ci#define NWL_DSI_RX_PAYLOAD 0x298 5962306a36Sopenharmony_ci#define NWL_DSI_RX_PKT_HEADER 0x29c 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* DSI IRQ handling */ 6262306a36Sopenharmony_ci#define NWL_DSI_IRQ_STATUS 0x2a0 6362306a36Sopenharmony_ci#define NWL_DSI_SM_NOT_IDLE BIT(0) 6462306a36Sopenharmony_ci#define NWL_DSI_TX_PKT_DONE BIT(1) 6562306a36Sopenharmony_ci#define NWL_DSI_DPHY_DIRECTION BIT(2) 6662306a36Sopenharmony_ci#define NWL_DSI_TX_FIFO_OVFLW BIT(3) 6762306a36Sopenharmony_ci#define NWL_DSI_TX_FIFO_UDFLW BIT(4) 6862306a36Sopenharmony_ci#define NWL_DSI_RX_FIFO_OVFLW BIT(5) 6962306a36Sopenharmony_ci#define NWL_DSI_RX_FIFO_UDFLW BIT(6) 7062306a36Sopenharmony_ci#define NWL_DSI_RX_PKT_HDR_RCVD BIT(7) 7162306a36Sopenharmony_ci#define NWL_DSI_RX_PKT_PAYLOAD_DATA_RCVD BIT(8) 7262306a36Sopenharmony_ci#define NWL_DSI_BTA_TIMEOUT BIT(29) 7362306a36Sopenharmony_ci#define NWL_DSI_LP_RX_TIMEOUT BIT(30) 7462306a36Sopenharmony_ci#define NWL_DSI_HS_TX_TIMEOUT BIT(31) 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define NWL_DSI_IRQ_STATUS2 0x2a4 7762306a36Sopenharmony_ci#define NWL_DSI_SINGLE_BIT_ECC_ERR BIT(0) 7862306a36Sopenharmony_ci#define NWL_DSI_MULTI_BIT_ECC_ERR BIT(1) 7962306a36Sopenharmony_ci#define NWL_DSI_CRC_ERR BIT(2) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define NWL_DSI_IRQ_MASK 0x2a8 8262306a36Sopenharmony_ci#define NWL_DSI_SM_NOT_IDLE_MASK BIT(0) 8362306a36Sopenharmony_ci#define NWL_DSI_TX_PKT_DONE_MASK BIT(1) 8462306a36Sopenharmony_ci#define NWL_DSI_DPHY_DIRECTION_MASK BIT(2) 8562306a36Sopenharmony_ci#define NWL_DSI_TX_FIFO_OVFLW_MASK BIT(3) 8662306a36Sopenharmony_ci#define NWL_DSI_TX_FIFO_UDFLW_MASK BIT(4) 8762306a36Sopenharmony_ci#define NWL_DSI_RX_FIFO_OVFLW_MASK BIT(5) 8862306a36Sopenharmony_ci#define NWL_DSI_RX_FIFO_UDFLW_MASK BIT(6) 8962306a36Sopenharmony_ci#define NWL_DSI_RX_PKT_HDR_RCVD_MASK BIT(7) 9062306a36Sopenharmony_ci#define NWL_DSI_RX_PKT_PAYLOAD_DATA_RCVD_MASK BIT(8) 9162306a36Sopenharmony_ci#define NWL_DSI_BTA_TIMEOUT_MASK BIT(29) 9262306a36Sopenharmony_ci#define NWL_DSI_LP_RX_TIMEOUT_MASK BIT(30) 9362306a36Sopenharmony_ci#define NWL_DSI_HS_TX_TIMEOUT_MASK BIT(31) 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define NWL_DSI_IRQ_MASK2 0x2ac 9662306a36Sopenharmony_ci#define NWL_DSI_SINGLE_BIT_ECC_ERR_MASK BIT(0) 9762306a36Sopenharmony_ci#define NWL_DSI_MULTI_BIT_ECC_ERR_MASK BIT(1) 9862306a36Sopenharmony_ci#define NWL_DSI_CRC_ERR_MASK BIT(2) 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci/* 10162306a36Sopenharmony_ci * PKT_CONTROL format: 10262306a36Sopenharmony_ci * [15: 0] - word count 10362306a36Sopenharmony_ci * [17:16] - virtual channel 10462306a36Sopenharmony_ci * [23:18] - data type 10562306a36Sopenharmony_ci * [24] - LP or HS select (0 - LP, 1 - HS) 10662306a36Sopenharmony_ci * [25] - perform BTA after packet is sent 10762306a36Sopenharmony_ci * [26] - perform BTA only, no packet tx 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_ci#define NWL_DSI_WC(x) FIELD_PREP(GENMASK(15, 0), (x)) 11062306a36Sopenharmony_ci#define NWL_DSI_TX_VC(x) FIELD_PREP(GENMASK(17, 16), (x)) 11162306a36Sopenharmony_ci#define NWL_DSI_TX_DT(x) FIELD_PREP(GENMASK(23, 18), (x)) 11262306a36Sopenharmony_ci#define NWL_DSI_HS_SEL(x) FIELD_PREP(GENMASK(24, 24), (x)) 11362306a36Sopenharmony_ci#define NWL_DSI_BTA_TX(x) FIELD_PREP(GENMASK(25, 25), (x)) 11462306a36Sopenharmony_ci#define NWL_DSI_BTA_NO_TX(x) FIELD_PREP(GENMASK(26, 26), (x)) 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* 11762306a36Sopenharmony_ci * RX_PKT_HEADER format: 11862306a36Sopenharmony_ci * [15: 0] - word count 11962306a36Sopenharmony_ci * [21:16] - data type 12062306a36Sopenharmony_ci * [23:22] - virtual channel 12162306a36Sopenharmony_ci */ 12262306a36Sopenharmony_ci#define NWL_DSI_RX_DT(x) FIELD_GET(GENMASK(21, 16), (x)) 12362306a36Sopenharmony_ci#define NWL_DSI_RX_VC(x) FIELD_GET(GENMASK(23, 22), (x)) 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* DSI Video mode */ 12662306a36Sopenharmony_ci#define NWL_DSI_VM_BURST_MODE_WITH_SYNC_PULSES 0 12762306a36Sopenharmony_ci#define NWL_DSI_VM_NON_BURST_MODE_WITH_SYNC_EVENTS BIT(0) 12862306a36Sopenharmony_ci#define NWL_DSI_VM_BURST_MODE BIT(1) 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci/* * DPI color coding */ 13162306a36Sopenharmony_ci#define NWL_DSI_DPI_16_BIT_565_PACKED 0 13262306a36Sopenharmony_ci#define NWL_DSI_DPI_16_BIT_565_ALIGNED 1 13362306a36Sopenharmony_ci#define NWL_DSI_DPI_16_BIT_565_SHIFTED 2 13462306a36Sopenharmony_ci#define NWL_DSI_DPI_18_BIT_PACKED 3 13562306a36Sopenharmony_ci#define NWL_DSI_DPI_18_BIT_ALIGNED 4 13662306a36Sopenharmony_ci#define NWL_DSI_DPI_24_BIT 5 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci/* * DPI Pixel format */ 13962306a36Sopenharmony_ci#define NWL_DSI_PIXEL_FORMAT_16 0 14062306a36Sopenharmony_ci#define NWL_DSI_PIXEL_FORMAT_18 BIT(0) 14162306a36Sopenharmony_ci#define NWL_DSI_PIXEL_FORMAT_18L BIT(1) 14262306a36Sopenharmony_ci#define NWL_DSI_PIXEL_FORMAT_24 (BIT(0) | BIT(1)) 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci#endif /* __NWL_DSI_H__ */ 145