18c2ecf20Sopenharmony_ci#ifndef _VC4_HDMI_REGS_H_
28c2ecf20Sopenharmony_ci#define _VC4_HDMI_REGS_H_
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include "vc4_hdmi.h"
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#define VC4_HDMI_PACKET_STRIDE			0x24
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cienum vc4_hdmi_regs {
98c2ecf20Sopenharmony_ci	VC4_INVALID = 0,
108c2ecf20Sopenharmony_ci	VC4_HDMI,
118c2ecf20Sopenharmony_ci	VC4_HD,
128c2ecf20Sopenharmony_ci	VC5_CEC,
138c2ecf20Sopenharmony_ci	VC5_CSC,
148c2ecf20Sopenharmony_ci	VC5_DVP,
158c2ecf20Sopenharmony_ci	VC5_PHY,
168c2ecf20Sopenharmony_ci	VC5_RAM,
178c2ecf20Sopenharmony_ci	VC5_RM,
188c2ecf20Sopenharmony_ci};
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cienum vc4_hdmi_field {
218c2ecf20Sopenharmony_ci	HDMI_AUDIO_PACKET_CONFIG,
228c2ecf20Sopenharmony_ci	HDMI_CEC_CNTRL_1,
238c2ecf20Sopenharmony_ci	HDMI_CEC_CNTRL_2,
248c2ecf20Sopenharmony_ci	HDMI_CEC_CNTRL_3,
258c2ecf20Sopenharmony_ci	HDMI_CEC_CNTRL_4,
268c2ecf20Sopenharmony_ci	HDMI_CEC_CNTRL_5,
278c2ecf20Sopenharmony_ci	HDMI_CEC_CPU_CLEAR,
288c2ecf20Sopenharmony_ci	HDMI_CEC_CPU_MASK_CLEAR,
298c2ecf20Sopenharmony_ci	HDMI_CEC_CPU_MASK_SET,
308c2ecf20Sopenharmony_ci	HDMI_CEC_CPU_MASK_STATUS,
318c2ecf20Sopenharmony_ci	HDMI_CEC_CPU_STATUS,
328c2ecf20Sopenharmony_ci	HDMI_CEC_CPU_SET,
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	/*
358c2ecf20Sopenharmony_ci	 * Transmit data, first byte is low byte of the 32-bit reg.
368c2ecf20Sopenharmony_ci	 * MSB of each byte transmitted first.
378c2ecf20Sopenharmony_ci	 */
388c2ecf20Sopenharmony_ci	HDMI_CEC_RX_DATA_1,
398c2ecf20Sopenharmony_ci	HDMI_CEC_RX_DATA_2,
408c2ecf20Sopenharmony_ci	HDMI_CEC_RX_DATA_3,
418c2ecf20Sopenharmony_ci	HDMI_CEC_RX_DATA_4,
428c2ecf20Sopenharmony_ci	HDMI_CEC_TX_DATA_1,
438c2ecf20Sopenharmony_ci	HDMI_CEC_TX_DATA_2,
448c2ecf20Sopenharmony_ci	HDMI_CEC_TX_DATA_3,
458c2ecf20Sopenharmony_ci	HDMI_CEC_TX_DATA_4,
468c2ecf20Sopenharmony_ci	HDMI_CLOCK_STOP,
478c2ecf20Sopenharmony_ci	HDMI_CORE_REV,
488c2ecf20Sopenharmony_ci	HDMI_CRP_CFG,
498c2ecf20Sopenharmony_ci	HDMI_CSC_12_11,
508c2ecf20Sopenharmony_ci	HDMI_CSC_14_13,
518c2ecf20Sopenharmony_ci	HDMI_CSC_22_21,
528c2ecf20Sopenharmony_ci	HDMI_CSC_24_23,
538c2ecf20Sopenharmony_ci	HDMI_CSC_32_31,
548c2ecf20Sopenharmony_ci	HDMI_CSC_34_33,
558c2ecf20Sopenharmony_ci	HDMI_CSC_CTL,
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	/*
588c2ecf20Sopenharmony_ci	 * 20-bit fields containing CTS values to be transmitted if
598c2ecf20Sopenharmony_ci	 * !EXTERNAL_CTS_EN
608c2ecf20Sopenharmony_ci	 */
618c2ecf20Sopenharmony_ci	HDMI_CTS_0,
628c2ecf20Sopenharmony_ci	HDMI_CTS_1,
638c2ecf20Sopenharmony_ci	HDMI_DVP_CTL,
648c2ecf20Sopenharmony_ci	HDMI_FIFO_CTL,
658c2ecf20Sopenharmony_ci	HDMI_FRAME_COUNT,
668c2ecf20Sopenharmony_ci	HDMI_HORZA,
678c2ecf20Sopenharmony_ci	HDMI_HORZB,
688c2ecf20Sopenharmony_ci	HDMI_HOTPLUG,
698c2ecf20Sopenharmony_ci	HDMI_HOTPLUG_INT,
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	/*
728c2ecf20Sopenharmony_ci	 * 3 bits per field, where each field maps from that
738c2ecf20Sopenharmony_ci	 * corresponding MAI bus channel to the given HDMI channel.
748c2ecf20Sopenharmony_ci	 */
758c2ecf20Sopenharmony_ci	HDMI_MAI_CHANNEL_MAP,
768c2ecf20Sopenharmony_ci	HDMI_MAI_CONFIG,
778c2ecf20Sopenharmony_ci	HDMI_MAI_CTL,
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	/*
808c2ecf20Sopenharmony_ci	 * Register for DMAing in audio data to be transported over
818c2ecf20Sopenharmony_ci	 * the MAI bus to the Falcon core.
828c2ecf20Sopenharmony_ci	 */
838c2ecf20Sopenharmony_ci	HDMI_MAI_DATA,
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	/* Format header to be placed on the MAI data. Unused. */
868c2ecf20Sopenharmony_ci	HDMI_MAI_FMT,
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	/* Last received format word on the MAI bus. */
898c2ecf20Sopenharmony_ci	HDMI_MAI_FORMAT,
908c2ecf20Sopenharmony_ci	HDMI_MAI_SMP,
918c2ecf20Sopenharmony_ci	HDMI_MAI_THR,
928c2ecf20Sopenharmony_ci	HDMI_M_CTL,
938c2ecf20Sopenharmony_ci	HDMI_RAM_PACKET_CONFIG,
948c2ecf20Sopenharmony_ci	HDMI_RAM_PACKET_START,
958c2ecf20Sopenharmony_ci	HDMI_RAM_PACKET_STATUS,
968c2ecf20Sopenharmony_ci	HDMI_RM_CONTROL,
978c2ecf20Sopenharmony_ci	HDMI_RM_FORMAT,
988c2ecf20Sopenharmony_ci	HDMI_RM_OFFSET,
998c2ecf20Sopenharmony_ci	HDMI_SCHEDULER_CONTROL,
1008c2ecf20Sopenharmony_ci	HDMI_SW_RESET_CONTROL,
1018c2ecf20Sopenharmony_ci	HDMI_TX_PHY_CHANNEL_SWAP,
1028c2ecf20Sopenharmony_ci	HDMI_TX_PHY_CLK_DIV,
1038c2ecf20Sopenharmony_ci	HDMI_TX_PHY_CTL_0,
1048c2ecf20Sopenharmony_ci	HDMI_TX_PHY_CTL_1,
1058c2ecf20Sopenharmony_ci	HDMI_TX_PHY_CTL_2,
1068c2ecf20Sopenharmony_ci	HDMI_TX_PHY_CTL_3,
1078c2ecf20Sopenharmony_ci	HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_1,
1088c2ecf20Sopenharmony_ci	HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_2,
1098c2ecf20Sopenharmony_ci	HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_4,
1108c2ecf20Sopenharmony_ci	HDMI_TX_PHY_PLL_CFG,
1118c2ecf20Sopenharmony_ci	HDMI_TX_PHY_PLL_CTL_0,
1128c2ecf20Sopenharmony_ci	HDMI_TX_PHY_PLL_CTL_1,
1138c2ecf20Sopenharmony_ci	HDMI_TX_PHY_POWERDOWN_CTL,
1148c2ecf20Sopenharmony_ci	HDMI_TX_PHY_RESET_CTL,
1158c2ecf20Sopenharmony_ci	HDMI_TX_PHY_TMDS_CLK_WORD_SEL,
1168c2ecf20Sopenharmony_ci	HDMI_VEC_INTERFACE_XBAR,
1178c2ecf20Sopenharmony_ci	HDMI_VERTA0,
1188c2ecf20Sopenharmony_ci	HDMI_VERTA1,
1198c2ecf20Sopenharmony_ci	HDMI_VERTB0,
1208c2ecf20Sopenharmony_ci	HDMI_VERTB1,
1218c2ecf20Sopenharmony_ci	HDMI_VID_CTL,
1228c2ecf20Sopenharmony_ci};
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_cistruct vc4_hdmi_register {
1258c2ecf20Sopenharmony_ci	char *name;
1268c2ecf20Sopenharmony_ci	enum vc4_hdmi_regs reg;
1278c2ecf20Sopenharmony_ci	unsigned int offset;
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#define _VC4_REG(_base, _reg, _offset)	\
1318c2ecf20Sopenharmony_ci	[_reg] = {				\
1328c2ecf20Sopenharmony_ci		.name = #_reg,			\
1338c2ecf20Sopenharmony_ci		.reg = _base,			\
1348c2ecf20Sopenharmony_ci		.offset = _offset,		\
1358c2ecf20Sopenharmony_ci	}
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci#define VC4_HD_REG(reg, offset)		_VC4_REG(VC4_HD, reg, offset)
1388c2ecf20Sopenharmony_ci#define VC4_HDMI_REG(reg, offset)	_VC4_REG(VC4_HDMI, reg, offset)
1398c2ecf20Sopenharmony_ci#define VC5_CEC_REG(reg, offset)	_VC4_REG(VC5_CEC, reg, offset)
1408c2ecf20Sopenharmony_ci#define VC5_CSC_REG(reg, offset)	_VC4_REG(VC5_CSC, reg, offset)
1418c2ecf20Sopenharmony_ci#define VC5_DVP_REG(reg, offset)	_VC4_REG(VC5_DVP, reg, offset)
1428c2ecf20Sopenharmony_ci#define VC5_PHY_REG(reg, offset)	_VC4_REG(VC5_PHY, reg, offset)
1438c2ecf20Sopenharmony_ci#define VC5_RAM_REG(reg, offset)	_VC4_REG(VC5_RAM, reg, offset)
1448c2ecf20Sopenharmony_ci#define VC5_RM_REG(reg, offset)		_VC4_REG(VC5_RM, reg, offset)
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_cistatic const struct vc4_hdmi_register vc4_hdmi_fields[] = {
1478c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_M_CTL, 0x000c),
1488c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_CTL, 0x0014),
1498c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_THR, 0x0018),
1508c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_FMT, 0x001c),
1518c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_DATA, 0x0020),
1528c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_SMP, 0x002c),
1538c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_VID_CTL, 0x0038),
1548c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_CSC_CTL, 0x0040),
1558c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_CSC_12_11, 0x0044),
1568c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_CSC_14_13, 0x0048),
1578c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_CSC_22_21, 0x004c),
1588c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_CSC_24_23, 0x0050),
1598c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_CSC_32_31, 0x0054),
1608c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_CSC_34_33, 0x0058),
1618c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_FRAME_COUNT, 0x0068),
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CORE_REV, 0x0000),
1648c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_SW_RESET_CONTROL, 0x0004),
1658c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HOTPLUG_INT, 0x0008),
1668c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HOTPLUG, 0x000c),
1678c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_FIFO_CTL, 0x005c),
1688c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_MAI_CHANNEL_MAP, 0x0090),
1698c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_MAI_CONFIG, 0x0094),
1708c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_MAI_FORMAT, 0x0098),
1718c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_AUDIO_PACKET_CONFIG, 0x009c),
1728c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_RAM_PACKET_CONFIG, 0x00a0),
1738c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_RAM_PACKET_STATUS, 0x00a4),
1748c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CRP_CFG, 0x00a8),
1758c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CTS_0, 0x00ac),
1768c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CTS_1, 0x00b0),
1778c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_SCHEDULER_CONTROL, 0x00c0),
1788c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HORZA, 0x00c4),
1798c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HORZB, 0x00c8),
1808c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTA0, 0x00cc),
1818c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTB0, 0x00d0),
1828c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTA1, 0x00d4),
1838c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTB1, 0x00d8),
1848c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CNTRL_1, 0x00e8),
1858c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CNTRL_2, 0x00ec),
1868c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CNTRL_3, 0x00f0),
1878c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CNTRL_4, 0x00f4),
1888c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CNTRL_5, 0x00f8),
1898c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_TX_DATA_1, 0x00fc),
1908c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_TX_DATA_2, 0x0100),
1918c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_TX_DATA_3, 0x0104),
1928c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_TX_DATA_4, 0x0108),
1938c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_RX_DATA_1, 0x010c),
1948c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_RX_DATA_2, 0x0110),
1958c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_RX_DATA_3, 0x0114),
1968c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_RX_DATA_4, 0x0118),
1978c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_TX_PHY_RESET_CTL, 0x02c0),
1988c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_TX_PHY_CTL_0, 0x02c4),
1998c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CPU_STATUS, 0x0340),
2008c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CPU_SET, 0x0344),
2018c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CPU_CLEAR, 0x0348),
2028c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CPU_MASK_STATUS, 0x034c),
2038c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CPU_MASK_SET, 0x0350),
2048c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CEC_CPU_MASK_CLEAR, 0x0354),
2058c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_RAM_PACKET_START, 0x0400),
2068c2ecf20Sopenharmony_ci};
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_cistatic const struct vc4_hdmi_register vc5_hdmi_hdmi0_fields[] = {
2098c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_DVP_CTL, 0x0000),
2108c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_CTL, 0x0010),
2118c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_THR, 0x0014),
2128c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_FMT, 0x0018),
2138c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_DATA, 0x001c),
2148c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_SMP, 0x0020),
2158c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_VID_CTL, 0x0044),
2168c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_FRAME_COUNT, 0x0060),
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_FIFO_CTL, 0x074),
2198c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_AUDIO_PACKET_CONFIG, 0x0b8),
2208c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_RAM_PACKET_CONFIG, 0x0bc),
2218c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_RAM_PACKET_STATUS, 0x0c4),
2228c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CRP_CFG, 0x0c8),
2238c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CTS_0, 0x0cc),
2248c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CTS_1, 0x0d0),
2258c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_SCHEDULER_CONTROL, 0x0e0),
2268c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HORZA, 0x0e4),
2278c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HORZB, 0x0e8),
2288c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTA0, 0x0ec),
2298c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTB0, 0x0f0),
2308c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTA1, 0x0f4),
2318c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTB1, 0x0f8),
2328c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_MAI_CHANNEL_MAP, 0x09c),
2338c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_MAI_CONFIG, 0x0a0),
2348c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HOTPLUG, 0x1a8),
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	VC5_DVP_REG(HDMI_CLOCK_STOP, 0x0bc),
2378c2ecf20Sopenharmony_ci	VC5_DVP_REG(HDMI_VEC_INTERFACE_XBAR, 0x0f0),
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_RESET_CTL, 0x000),
2408c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_POWERDOWN_CTL, 0x004),
2418c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_0, 0x008),
2428c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_1, 0x00c),
2438c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_2, 0x010),
2448c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_3, 0x014),
2458c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_0, 0x01c),
2468c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_1, 0x020),
2478c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CLK_DIV, 0x028),
2488c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CFG, 0x034),
2498c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_TMDS_CLK_WORD_SEL, 0x044),
2508c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CHANNEL_SWAP, 0x04c),
2518c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_1, 0x050),
2528c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_2, 0x054),
2538c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_4, 0x05c),
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci	VC5_RM_REG(HDMI_RM_CONTROL, 0x000),
2568c2ecf20Sopenharmony_ci	VC5_RM_REG(HDMI_RM_OFFSET, 0x018),
2578c2ecf20Sopenharmony_ci	VC5_RM_REG(HDMI_RM_FORMAT, 0x01c),
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	VC5_RAM_REG(HDMI_RAM_PACKET_START, 0x000),
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_1, 0x010),
2628c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_2, 0x014),
2638c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_3, 0x018),
2648c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_4, 0x01c),
2658c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_5, 0x020),
2668c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_1, 0x028),
2678c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_2, 0x02c),
2688c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_3, 0x030),
2698c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_4, 0x034),
2708c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_1, 0x038),
2718c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_2, 0x03c),
2728c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_3, 0x040),
2738c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_4, 0x044),
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_CTL, 0x000),
2768c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_12_11, 0x004),
2778c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_14_13, 0x008),
2788c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_22_21, 0x00c),
2798c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_24_23, 0x010),
2808c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_32_31, 0x014),
2818c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_34_33, 0x018),
2828c2ecf20Sopenharmony_ci};
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_cistatic const struct vc4_hdmi_register vc5_hdmi_hdmi1_fields[] = {
2858c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_DVP_CTL, 0x0000),
2868c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_CTL, 0x0030),
2878c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_THR, 0x0034),
2888c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_FMT, 0x0038),
2898c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_DATA, 0x003c),
2908c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_MAI_SMP, 0x0040),
2918c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_VID_CTL, 0x0048),
2928c2ecf20Sopenharmony_ci	VC4_HD_REG(HDMI_FRAME_COUNT, 0x0064),
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_FIFO_CTL, 0x074),
2958c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_AUDIO_PACKET_CONFIG, 0x0b8),
2968c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_RAM_PACKET_CONFIG, 0x0bc),
2978c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_RAM_PACKET_STATUS, 0x0c4),
2988c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CRP_CFG, 0x0c8),
2998c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CTS_0, 0x0cc),
3008c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_CTS_1, 0x0d0),
3018c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_SCHEDULER_CONTROL, 0x0e0),
3028c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HORZA, 0x0e4),
3038c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HORZB, 0x0e8),
3048c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTA0, 0x0ec),
3058c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTB0, 0x0f0),
3068c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTA1, 0x0f4),
3078c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_VERTB1, 0x0f8),
3088c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_MAI_CHANNEL_MAP, 0x09c),
3098c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_MAI_CONFIG, 0x0a0),
3108c2ecf20Sopenharmony_ci	VC4_HDMI_REG(HDMI_HOTPLUG, 0x1a8),
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci	VC5_DVP_REG(HDMI_CLOCK_STOP, 0x0bc),
3138c2ecf20Sopenharmony_ci	VC5_DVP_REG(HDMI_VEC_INTERFACE_XBAR, 0x0f0),
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_RESET_CTL, 0x000),
3168c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_POWERDOWN_CTL, 0x004),
3178c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_0, 0x008),
3188c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_1, 0x00c),
3198c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_2, 0x010),
3208c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CTL_3, 0x014),
3218c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_0, 0x01c),
3228c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CTL_1, 0x020),
3238c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CLK_DIV, 0x028),
3248c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CFG, 0x034),
3258c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_CHANNEL_SWAP, 0x04c),
3268c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_TMDS_CLK_WORD_SEL, 0x044),
3278c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_1, 0x050),
3288c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_2, 0x054),
3298c2ecf20Sopenharmony_ci	VC5_PHY_REG(HDMI_TX_PHY_PLL_CALIBRATION_CONFIG_4, 0x05c),
3308c2ecf20Sopenharmony_ci
3318c2ecf20Sopenharmony_ci	VC5_RM_REG(HDMI_RM_CONTROL, 0x000),
3328c2ecf20Sopenharmony_ci	VC5_RM_REG(HDMI_RM_OFFSET, 0x018),
3338c2ecf20Sopenharmony_ci	VC5_RM_REG(HDMI_RM_FORMAT, 0x01c),
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci	VC5_RAM_REG(HDMI_RAM_PACKET_START, 0x000),
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_1, 0x010),
3388c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_2, 0x014),
3398c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_3, 0x018),
3408c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_4, 0x01c),
3418c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_CNTRL_5, 0x020),
3428c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_1, 0x028),
3438c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_2, 0x02c),
3448c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_3, 0x030),
3458c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_TX_DATA_4, 0x034),
3468c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_1, 0x038),
3478c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_2, 0x03c),
3488c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_3, 0x040),
3498c2ecf20Sopenharmony_ci	VC5_CEC_REG(HDMI_CEC_RX_DATA_4, 0x044),
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_CTL, 0x000),
3528c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_12_11, 0x004),
3538c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_14_13, 0x008),
3548c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_22_21, 0x00c),
3558c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_24_23, 0x010),
3568c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_32_31, 0x014),
3578c2ecf20Sopenharmony_ci	VC5_CSC_REG(HDMI_CSC_34_33, 0x018),
3588c2ecf20Sopenharmony_ci};
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_cistatic inline
3618c2ecf20Sopenharmony_civoid __iomem *__vc4_hdmi_get_field_base(struct vc4_hdmi *hdmi,
3628c2ecf20Sopenharmony_ci					enum vc4_hdmi_regs reg)
3638c2ecf20Sopenharmony_ci{
3648c2ecf20Sopenharmony_ci	switch (reg) {
3658c2ecf20Sopenharmony_ci	case VC4_HD:
3668c2ecf20Sopenharmony_ci		return hdmi->hd_regs;
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci	case VC4_HDMI:
3698c2ecf20Sopenharmony_ci		return hdmi->hdmicore_regs;
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci	case VC5_CSC:
3728c2ecf20Sopenharmony_ci		return hdmi->csc_regs;
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci	case VC5_CEC:
3758c2ecf20Sopenharmony_ci		return hdmi->cec_regs;
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci	case VC5_DVP:
3788c2ecf20Sopenharmony_ci		return hdmi->dvp_regs;
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci	case VC5_PHY:
3818c2ecf20Sopenharmony_ci		return hdmi->phy_regs;
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci	case VC5_RAM:
3848c2ecf20Sopenharmony_ci		return hdmi->ram_regs;
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci	case VC5_RM:
3878c2ecf20Sopenharmony_ci		return hdmi->rm_regs;
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci	default:
3908c2ecf20Sopenharmony_ci		return NULL;
3918c2ecf20Sopenharmony_ci	}
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci	return NULL;
3948c2ecf20Sopenharmony_ci}
3958c2ecf20Sopenharmony_ci
3968c2ecf20Sopenharmony_cistatic inline u32 vc4_hdmi_read(struct vc4_hdmi *hdmi,
3978c2ecf20Sopenharmony_ci				enum vc4_hdmi_field reg)
3988c2ecf20Sopenharmony_ci{
3998c2ecf20Sopenharmony_ci	const struct vc4_hdmi_register *field;
4008c2ecf20Sopenharmony_ci	const struct vc4_hdmi_variant *variant = hdmi->variant;
4018c2ecf20Sopenharmony_ci	void __iomem *base;
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci	if (reg >= variant->num_registers) {
4048c2ecf20Sopenharmony_ci		dev_warn(&hdmi->pdev->dev,
4058c2ecf20Sopenharmony_ci			 "Invalid register ID %u\n", reg);
4068c2ecf20Sopenharmony_ci		return 0;
4078c2ecf20Sopenharmony_ci	}
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	field = &variant->registers[reg];
4108c2ecf20Sopenharmony_ci	base = __vc4_hdmi_get_field_base(hdmi, field->reg);
4118c2ecf20Sopenharmony_ci	if (!base) {
4128c2ecf20Sopenharmony_ci		dev_warn(&hdmi->pdev->dev,
4138c2ecf20Sopenharmony_ci			 "Unknown register ID %u\n", reg);
4148c2ecf20Sopenharmony_ci		return 0;
4158c2ecf20Sopenharmony_ci	}
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci	return readl(base + field->offset);
4188c2ecf20Sopenharmony_ci}
4198c2ecf20Sopenharmony_ci#define HDMI_READ(reg)		vc4_hdmi_read(vc4_hdmi, reg)
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_cistatic inline void vc4_hdmi_write(struct vc4_hdmi *hdmi,
4228c2ecf20Sopenharmony_ci				  enum vc4_hdmi_field reg,
4238c2ecf20Sopenharmony_ci				  u32 value)
4248c2ecf20Sopenharmony_ci{
4258c2ecf20Sopenharmony_ci	const struct vc4_hdmi_register *field;
4268c2ecf20Sopenharmony_ci	const struct vc4_hdmi_variant *variant = hdmi->variant;
4278c2ecf20Sopenharmony_ci	void __iomem *base;
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci	if (reg >= variant->num_registers) {
4308c2ecf20Sopenharmony_ci		dev_warn(&hdmi->pdev->dev,
4318c2ecf20Sopenharmony_ci			 "Invalid register ID %u\n", reg);
4328c2ecf20Sopenharmony_ci		return;
4338c2ecf20Sopenharmony_ci	}
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	field = &variant->registers[reg];
4368c2ecf20Sopenharmony_ci	base = __vc4_hdmi_get_field_base(hdmi, field->reg);
4378c2ecf20Sopenharmony_ci	if (!base)
4388c2ecf20Sopenharmony_ci		return;
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	writel(value, base + field->offset);
4418c2ecf20Sopenharmony_ci}
4428c2ecf20Sopenharmony_ci#define HDMI_WRITE(reg, val)	vc4_hdmi_write(vc4_hdmi, reg, val)
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_ci#endif /* _VC4_HDMI_REGS_H_ */
445