xref: /openbmc/linux/sound/soc/qcom/lpass-lpaif-reg.h (revision abcda807)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef __LPASS_LPAIF_REG_H__
7 #define __LPASS_LPAIF_REG_H__
8 
9 /* LPAIF I2S */
10 
11 #define LPAIF_I2SCTL_REG_ADDR(v, addr, port) \
12 	(v->i2sctrl_reg_base + (addr) + v->i2sctrl_reg_stride * (port))
13 
14 #define LPAIF_I2SCTL_REG(v, port)	LPAIF_I2SCTL_REG_ADDR(v, 0x0, (port))
15 
16 #define LPAIF_I2SCTL_LOOPBACK_DISABLE	0
17 #define LPAIF_I2SCTL_LOOPBACK_ENABLE	1
18 
19 #define LPAIF_I2SCTL_SPKEN_DISABLE	0
20 #define LPAIF_I2SCTL_SPKEN_ENABLE	1
21 
22 #define LPAIF_I2SCTL_MODE_NONE		0
23 #define LPAIF_I2SCTL_MODE_SD0		1
24 #define LPAIF_I2SCTL_MODE_SD1		2
25 #define LPAIF_I2SCTL_MODE_SD2		3
26 #define LPAIF_I2SCTL_MODE_SD3		4
27 #define LPAIF_I2SCTL_MODE_QUAD01	5
28 #define LPAIF_I2SCTL_MODE_QUAD23	6
29 #define LPAIF_I2SCTL_MODE_6CH		7
30 #define LPAIF_I2SCTL_MODE_8CH		8
31 #define LPAIF_I2SCTL_MODE_10CH		9
32 #define LPAIF_I2SCTL_MODE_12CH		10
33 #define LPAIF_I2SCTL_MODE_14CH		11
34 #define LPAIF_I2SCTL_MODE_16CH		12
35 #define LPAIF_I2SCTL_MODE_SD4		13
36 #define LPAIF_I2SCTL_MODE_SD5		14
37 #define LPAIF_I2SCTL_MODE_SD6		15
38 #define LPAIF_I2SCTL_MODE_SD7		16
39 #define LPAIF_I2SCTL_MODE_QUAD45	17
40 #define LPAIF_I2SCTL_MODE_QUAD47	18
41 #define LPAIF_I2SCTL_MODE_8CH_2		19
42 
43 #define LPAIF_I2SCTL_SPKMODE(mode)	mode
44 
45 #define LPAIF_I2SCTL_SPKMONO_STEREO	0
46 #define LPAIF_I2SCTL_SPKMONO_MONO	1
47 
48 #define LPAIF_I2SCTL_MICEN_DISABLE	0
49 #define LPAIF_I2SCTL_MICEN_ENABLE	1
50 
51 #define LPAIF_I2SCTL_MICMODE(mode)	mode
52 
53 #define LPAIF_I2SCTL_MICMONO_STEREO	0
54 #define LPAIF_I2SCTL_MICMONO_MONO	1
55 
56 #define LPAIF_I2SCTL_WSSRC_INTERNAL	0
57 #define LPAIF_I2SCTL_WSSRC_EXTERNAL	1
58 
59 #define LPAIF_I2SCTL_BITWIDTH_16	0
60 #define LPAIF_I2SCTL_BITWIDTH_24	1
61 #define LPAIF_I2SCTL_BITWIDTH_32	2
62 
63 /* LPAIF IRQ */
64 #define LPAIF_IRQ_REG_ADDR(v, addr, port) \
65 	(v->irq_reg_base + (addr) + v->irq_reg_stride * (port))
66 
67 #define LPAIF_IRQ_PORT_HOST		0
68 
69 #define LPAIF_IRQEN_REG(v, port)	LPAIF_IRQ_REG_ADDR(v, 0x0, (port))
70 #define LPAIF_IRQSTAT_REG(v, port)	LPAIF_IRQ_REG_ADDR(v, 0x4, (port))
71 #define LPAIF_IRQCLEAR_REG(v, port)	LPAIF_IRQ_REG_ADDR(v, 0xC, (port))
72 
73 
74 #define LPASS_HDMITX_APP_IRQ_REG_ADDR(v, addr)  \
75 	((v->hdmi_irq_reg_base) + (addr))
76 
77 #define LPASS_HDMITX_APP_IRQEN_REG(v)			LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0x4)
78 #define LPASS_HDMITX_APP_IRQSTAT_REG(v)			LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0x8)
79 #define LPASS_HDMITX_APP_IRQCLEAR_REG(v)		LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0xC)
80 
81 #define LPAIF_IRQ_BITSTRIDE		3
82 
83 #define LPAIF_IRQ_PER(chan)		(1 << (LPAIF_IRQ_BITSTRIDE * (chan)))
84 #define LPAIF_IRQ_XRUN(chan)		(2 << (LPAIF_IRQ_BITSTRIDE * (chan)))
85 #define LPAIF_IRQ_ERR(chan)		(4 << (LPAIF_IRQ_BITSTRIDE * (chan)))
86 
87 #define LPAIF_IRQ_ALL(chan)		(7 << (LPAIF_IRQ_BITSTRIDE * (chan)))
88 #define LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(chan)	(1 << (14 + chan))
89 #define LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(chan)	(1 << (24 + chan))
90 #define LPAIF_IRQ_HDMI_METADONE		BIT(23)
91 
92 /* LPAIF DMA */
93 #define LPAIF_HDMI_RDMA_REG_ADDR(v, addr, chan) \
94 	(v->hdmi_rdma_reg_base + (addr) + v->hdmi_rdma_reg_stride * (chan))
95 
96 #define LPAIF_HDMI_RDMACTL_AUDINTF(id)	(id << LPAIF_RDMACTL_AUDINTF_SHIFT)
97 
98 #define LPAIF_HDMI_RDMACTL_REG(v, chan)		LPAIF_HDMI_RDMA_REG_ADDR(v, 0x00, (chan))
99 #define LPAIF_HDMI_RDMABASE_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x04, (chan))
100 #define	LPAIF_HDMI_RDMABUFF_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x08, (chan))
101 #define LPAIF_HDMI_RDMACURR_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x0C, (chan))
102 #define	LPAIF_HDMI_RDMAPER_REG(v, chan)		LPAIF_HDMI_RDMA_REG_ADDR(v, 0x10, (chan))
103 #define	LPAIF_HDMI_RDMAPERCNT_REG(v, chan)	LPAIF_HDMI_RDMA_REG_ADDR(v, 0x14, (chan))
104 
105 #define LPAIF_RDMA_REG_ADDR(v, addr, chan) \
106 	(v->rdma_reg_base + (addr) + v->rdma_reg_stride * (chan))
107 
108 #define LPAIF_RDMACTL_AUDINTF(id)	(id << LPAIF_RDMACTL_AUDINTF_SHIFT)
109 
110 #define LPAIF_RDMACTL_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x00, (chan))
111 #define LPAIF_RDMABASE_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x04, (chan))
112 #define	LPAIF_RDMABUFF_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x08, (chan))
113 #define LPAIF_RDMACURR_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x0C, (chan))
114 #define	LPAIF_RDMAPER_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x10, (chan))
115 #define	LPAIF_RDMAPERCNT_REG(v, chan)	LPAIF_RDMA_REG_ADDR(v, 0x14, (chan))
116 
117 #define LPAIF_WRDMA_REG_ADDR(v, addr, chan) \
118 	(v->wrdma_reg_base + (addr) + \
119 	 v->wrdma_reg_stride * (chan - v->wrdma_channel_start))
120 
121 #define LPAIF_WRDMACTL_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x00, (chan))
122 #define LPAIF_WRDMABASE_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x04, (chan))
123 #define	LPAIF_WRDMABUFF_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x08, (chan))
124 #define LPAIF_WRDMACURR_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x0C, (chan))
125 #define	LPAIF_WRDMAPER_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x10, (chan))
126 #define	LPAIF_WRDMAPERCNT_REG(v, chan)	LPAIF_WRDMA_REG_ADDR(v, 0x14, (chan))
127 
128 #define LPAIF_INTFDMA_REG(v, chan, reg, dai_id)  \
129 		((v->dai_driver[dai_id].id ==  LPASS_DP_RX) ? \
130 		LPAIF_HDMI_RDMA##reg##_REG(v, chan) : \
131 		 LPAIF_RDMA##reg##_REG(v, chan))
132 
133 #define __LPAIF_DMA_REG(v, chan, dir, reg, dai_id)  \
134 	((dir ==  SNDRV_PCM_STREAM_PLAYBACK) ? \
135 		(LPAIF_INTFDMA_REG(v, chan, reg, dai_id)) : \
136 		LPAIF_WRDMA##reg##_REG(v, chan))
137 
138 #define LPAIF_DMACTL_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, CTL, dai_id)
139 #define LPAIF_DMABASE_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, BASE, dai_id)
140 #define	LPAIF_DMABUFF_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, BUFF, dai_id)
141 #define LPAIF_DMACURR_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, CURR, dai_id)
142 #define	LPAIF_DMAPER_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, PER, dai_id)
143 #define	LPAIF_DMAPERCNT_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, PERCNT, dai_id)
144 
145 #define LPAIF_DMACTL_BURSTEN_SINGLE	0
146 #define LPAIF_DMACTL_BURSTEN_INCR4	1
147 
148 #define LPAIF_DMACTL_WPSCNT_ONE		0
149 #define LPAIF_DMACTL_WPSCNT_TWO		1
150 #define LPAIF_DMACTL_WPSCNT_THREE	2
151 #define LPAIF_DMACTL_WPSCNT_FOUR	3
152 #define LPAIF_DMACTL_WPSCNT_SIX		5
153 #define LPAIF_DMACTL_WPSCNT_EIGHT	7
154 #define LPAIF_DMACTL_WPSCNT_TEN		9
155 #define LPAIF_DMACTL_WPSCNT_TWELVE	11
156 #define LPAIF_DMACTL_WPSCNT_FOURTEEN	13
157 #define LPAIF_DMACTL_WPSCNT_SIXTEEN	15
158 
159 #define LPAIF_DMACTL_AUDINTF(id)	id
160 
161 #define LPAIF_DMACTL_FIFOWM_1		0
162 #define LPAIF_DMACTL_FIFOWM_2		1
163 #define LPAIF_DMACTL_FIFOWM_3		2
164 #define LPAIF_DMACTL_FIFOWM_4		3
165 #define LPAIF_DMACTL_FIFOWM_5		4
166 #define LPAIF_DMACTL_FIFOWM_6		5
167 #define LPAIF_DMACTL_FIFOWM_7		6
168 #define LPAIF_DMACTL_FIFOWM_8		7
169 #define LPAIF_DMACTL_FIFOWM_9		8
170 #define LPAIF_DMACTL_FIFOWM_10		9
171 #define LPAIF_DMACTL_FIFOWM_11		10
172 #define LPAIF_DMACTL_FIFOWM_12		11
173 #define LPAIF_DMACTL_FIFOWM_13		12
174 #define LPAIF_DMACTL_FIFOWM_14		13
175 #define LPAIF_DMACTL_FIFOWM_15		14
176 #define LPAIF_DMACTL_FIFOWM_16		15
177 #define LPAIF_DMACTL_FIFOWM_17		16
178 #define LPAIF_DMACTL_FIFOWM_18		17
179 #define LPAIF_DMACTL_FIFOWM_19		18
180 #define LPAIF_DMACTL_FIFOWM_20		19
181 #define LPAIF_DMACTL_FIFOWM_21		20
182 #define LPAIF_DMACTL_FIFOWM_22		21
183 #define LPAIF_DMACTL_FIFOWM_23		22
184 #define LPAIF_DMACTL_FIFOWM_24		23
185 #define LPAIF_DMACTL_FIFOWM_25		24
186 #define LPAIF_DMACTL_FIFOWM_26		25
187 #define LPAIF_DMACTL_FIFOWM_27		26
188 #define LPAIF_DMACTL_FIFOWM_28		27
189 #define LPAIF_DMACTL_FIFOWM_29		28
190 #define LPAIF_DMACTL_FIFOWM_30		29
191 #define LPAIF_DMACTL_FIFOWM_31		30
192 #define LPAIF_DMACTL_FIFOWM_32		31
193 
194 #define LPAIF_DMACTL_ENABLE_OFF		0
195 #define LPAIF_DMACTL_ENABLE_ON		1
196 
197 #define LPAIF_DMACTL_DYNCLK_OFF		0
198 #define LPAIF_DMACTL_DYNCLK_ON		1
199 
200 #endif /* __LPASS_LPAIF_REG_H__ */
201