18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef __LPASS_LPAIF_REG_H__
78c2ecf20Sopenharmony_ci#define __LPASS_LPAIF_REG_H__
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci/* LPAIF I2S */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_REG_ADDR(v, addr, port) \
128c2ecf20Sopenharmony_ci	(v->i2sctrl_reg_base + (addr) + v->i2sctrl_reg_stride * (port))
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_REG(v, port)	LPAIF_I2SCTL_REG_ADDR(v, 0x0, (port))
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_LOOPBACK_DISABLE	0
178c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_LOOPBACK_ENABLE	1
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_SPKEN_DISABLE	0
208c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_SPKEN_ENABLE	1
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_NONE		0
238c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD0		1
248c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD1		2
258c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD2		3
268c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD3		4
278c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_QUAD01	5
288c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_QUAD23	6
298c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_6CH		7
308c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_8CH		8
318c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_10CH		9
328c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_12CH		10
338c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_14CH		11
348c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_16CH		12
358c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD4		13
368c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD5		14
378c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD6		15
388c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_SD7		16
398c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_QUAD45	17
408c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_QUAD47	18
418c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MODE_8CH_2		19
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_SPKMODE(mode)	mode
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_SPKMONO_STEREO	0
468c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_SPKMONO_MONO	1
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MICEN_DISABLE	0
498c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MICEN_ENABLE	1
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MICMODE(mode)	mode
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MICMONO_STEREO	0
548c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_MICMONO_MONO	1
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_WSSRC_INTERNAL	0
578c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_WSSRC_EXTERNAL	1
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_BITWIDTH_16	0
608c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_BITWIDTH_24	1
618c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_BITWIDTH_32	2
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define LPAIF_I2SCTL_RESET_STATE	0x003C0004
648c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_RESET_STATE	0x00200000
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/* LPAIF IRQ */
688c2ecf20Sopenharmony_ci#define LPAIF_IRQ_REG_ADDR(v, addr, port) \
698c2ecf20Sopenharmony_ci	(v->irq_reg_base + (addr) + v->irq_reg_stride * (port))
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define LPAIF_IRQ_PORT_HOST		0
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci#define LPAIF_IRQEN_REG(v, port)	LPAIF_IRQ_REG_ADDR(v, 0x0, (port))
748c2ecf20Sopenharmony_ci#define LPAIF_IRQSTAT_REG(v, port)	LPAIF_IRQ_REG_ADDR(v, 0x4, (port))
758c2ecf20Sopenharmony_ci#define LPAIF_IRQCLEAR_REG(v, port)	LPAIF_IRQ_REG_ADDR(v, 0xC, (port))
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define LPASS_HDMITX_APP_IRQ_REG_ADDR(v, addr)  \
798c2ecf20Sopenharmony_ci	((v->hdmi_irq_reg_base) + (addr))
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define LPASS_HDMITX_APP_IRQEN_REG(v)			LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0x4)
828c2ecf20Sopenharmony_ci#define LPASS_HDMITX_APP_IRQSTAT_REG(v)			LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0x8)
838c2ecf20Sopenharmony_ci#define LPASS_HDMITX_APP_IRQCLEAR_REG(v)		LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0xC)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define LPAIF_IRQ_BITSTRIDE		3
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define LPAIF_IRQ_PER(chan)		(1 << (LPAIF_IRQ_BITSTRIDE * (chan)))
888c2ecf20Sopenharmony_ci#define LPAIF_IRQ_XRUN(chan)		(2 << (LPAIF_IRQ_BITSTRIDE * (chan)))
898c2ecf20Sopenharmony_ci#define LPAIF_IRQ_ERR(chan)		(4 << (LPAIF_IRQ_BITSTRIDE * (chan)))
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define LPAIF_IRQ_ALL(chan)		(7 << (LPAIF_IRQ_BITSTRIDE * (chan)))
928c2ecf20Sopenharmony_ci#define LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(chan)	(1 << (14 + chan))
938c2ecf20Sopenharmony_ci#define LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(chan)	(1 << (24 + chan))
948c2ecf20Sopenharmony_ci#define LPAIF_IRQ_HDMI_METADONE		BIT(23)
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci/* LPAIF DMA */
978c2ecf20Sopenharmony_ci#define LPAIF_HDMI_RDMA_REG_ADDR(v, addr, chan) \
988c2ecf20Sopenharmony_ci	(v->hdmi_rdma_reg_base + (addr) + v->hdmi_rdma_reg_stride * (chan))
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci#define LPAIF_HDMI_RDMACTL_AUDINTF(id)	(id << LPAIF_RDMACTL_AUDINTF_SHIFT)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define LPAIF_HDMI_RDMACTL_REG(v, chan)		LPAIF_HDMI_RDMA_REG_ADDR(v, 0x00, (chan))
1038c2ecf20Sopenharmony_ci#define LPAIF_HDMI_RDMABASE_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x04, (chan))
1048c2ecf20Sopenharmony_ci#define	LPAIF_HDMI_RDMABUFF_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x08, (chan))
1058c2ecf20Sopenharmony_ci#define LPAIF_HDMI_RDMACURR_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x0C, (chan))
1068c2ecf20Sopenharmony_ci#define	LPAIF_HDMI_RDMAPER_REG(v, chan)		LPAIF_HDMI_RDMA_REG_ADDR(v, 0x10, (chan))
1078c2ecf20Sopenharmony_ci#define	LPAIF_HDMI_RDMAPERCNT_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x14, (chan))
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define LPAIF_RDMA_REG_ADDR(v, addr, chan) \
1108c2ecf20Sopenharmony_ci	(v->rdma_reg_base + (addr) + v->rdma_reg_stride * (chan))
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#define LPAIF_RDMACTL_AUDINTF(id)	(id << LPAIF_RDMACTL_AUDINTF_SHIFT)
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define LPAIF_RDMACTL_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x00, (chan))
1158c2ecf20Sopenharmony_ci#define LPAIF_RDMABASE_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x04, (chan))
1168c2ecf20Sopenharmony_ci#define	LPAIF_RDMABUFF_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x08, (chan))
1178c2ecf20Sopenharmony_ci#define LPAIF_RDMACURR_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x0C, (chan))
1188c2ecf20Sopenharmony_ci#define	LPAIF_RDMAPER_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x10, (chan))
1198c2ecf20Sopenharmony_ci#define	LPAIF_RDMAPERCNT_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x14, (chan))
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci#define LPAIF_WRDMA_REG_ADDR(v, addr, chan) \
1228c2ecf20Sopenharmony_ci	(v->wrdma_reg_base + (addr) + \
1238c2ecf20Sopenharmony_ci	 v->wrdma_reg_stride * (chan - v->wrdma_channel_start))
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci#define LPAIF_WRDMACTL_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x00, (chan))
1268c2ecf20Sopenharmony_ci#define LPAIF_WRDMABASE_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x04, (chan))
1278c2ecf20Sopenharmony_ci#define	LPAIF_WRDMABUFF_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x08, (chan))
1288c2ecf20Sopenharmony_ci#define LPAIF_WRDMACURR_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x0C, (chan))
1298c2ecf20Sopenharmony_ci#define	LPAIF_WRDMAPER_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x10, (chan))
1308c2ecf20Sopenharmony_ci#define	LPAIF_WRDMAPERCNT_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x14, (chan))
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define LPAIF_INTFDMA_REG(v, chan, reg, dai_id)  \
1338c2ecf20Sopenharmony_ci	((dai_id ==  LPASS_DP_RX) ? \
1348c2ecf20Sopenharmony_ci		LPAIF_HDMI_RDMA##reg##_REG(v, chan) : \
1358c2ecf20Sopenharmony_ci		 LPAIF_RDMA##reg##_REG(v, chan))
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci#define __LPAIF_DMA_REG(v, chan, dir, reg, dai_id)  \
1388c2ecf20Sopenharmony_ci	((dir ==  SNDRV_PCM_STREAM_PLAYBACK) ? \
1398c2ecf20Sopenharmony_ci		(LPAIF_INTFDMA_REG(v, chan, reg, dai_id)) : \
1408c2ecf20Sopenharmony_ci		LPAIF_WRDMA##reg##_REG(v, chan))
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, CTL, dai_id)
1438c2ecf20Sopenharmony_ci#define LPAIF_DMABASE_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, BASE, dai_id)
1448c2ecf20Sopenharmony_ci#define	LPAIF_DMABUFF_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, BUFF, dai_id)
1458c2ecf20Sopenharmony_ci#define LPAIF_DMACURR_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, CURR, dai_id)
1468c2ecf20Sopenharmony_ci#define	LPAIF_DMAPER_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, PER, dai_id)
1478c2ecf20Sopenharmony_ci#define	LPAIF_DMAPERCNT_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, PERCNT, dai_id)
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_BURSTEN_SINGLE	0
1508c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_BURSTEN_INCR4	1
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_ONE		0
1538c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_TWO		1
1548c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_THREE	2
1558c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_FOUR	3
1568c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_SIX		5
1578c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_EIGHT	7
1588c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_TEN		9
1598c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_TWELVE	11
1608c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_FOURTEEN	13
1618c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_WPSCNT_SIXTEEN	15
1628c2ecf20Sopenharmony_ci
1638c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_AUDINTF(id)	id
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_1		0
1668c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_2		1
1678c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_3		2
1688c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_4		3
1698c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_5		4
1708c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_6		5
1718c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_7		6
1728c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_8		7
1738c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_9		8
1748c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_10		9
1758c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_11		10
1768c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_12		11
1778c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_13		12
1788c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_14		13
1798c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_15		14
1808c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_16		15
1818c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_17		16
1828c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_18		17
1838c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_19		18
1848c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_20		19
1858c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_21		20
1868c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_22		21
1878c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_23		22
1888c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_24		23
1898c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_25		24
1908c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_26		25
1918c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_27		26
1928c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_28		27
1938c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_29		28
1948c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_30		29
1958c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_31		30
1968c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_FIFOWM_32		31
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_ENABLE_OFF		0
1998c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_ENABLE_ON		1
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_DYNCLK_OFF		0
2028c2ecf20Sopenharmony_ci#define LPAIF_DMACTL_DYNCLK_ON		1
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci#endif /* __LPASS_LPAIF_REG_H__ */
205