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 #define LPAIF_BIT_CLK_DISABLE 0 64 #define LPAIF_BIT_CLK_ENABLE 1 65 66 #define LPAIF_I2SCTL_RESET_STATE 0x003C0004 67 #define LPAIF_DMACTL_RESET_STATE 0x00200000 68 69 70 /* LPAIF IRQ */ 71 #define LPAIF_IRQ_REG_ADDR(v, addr, port) \ 72 (v->irq_reg_base + (addr) + v->irq_reg_stride * (port)) 73 74 #define LPAIF_IRQ_PORT_HOST 0 75 76 #define LPAIF_IRQEN_REG(v, port) LPAIF_IRQ_REG_ADDR(v, 0x0, (port)) 77 #define LPAIF_IRQSTAT_REG(v, port) LPAIF_IRQ_REG_ADDR(v, 0x4, (port)) 78 #define LPAIF_IRQCLEAR_REG(v, port) LPAIF_IRQ_REG_ADDR(v, 0xC, (port)) 79 80 81 #define LPASS_HDMITX_APP_IRQ_REG_ADDR(v, addr) \ 82 ((v->hdmi_irq_reg_base) + (addr)) 83 84 #define LPASS_HDMITX_APP_IRQEN_REG(v) LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0x4) 85 #define LPASS_HDMITX_APP_IRQSTAT_REG(v) LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0x8) 86 #define LPASS_HDMITX_APP_IRQCLEAR_REG(v) LPASS_HDMITX_APP_IRQ_REG_ADDR(v, 0xC) 87 88 #define LPAIF_IRQ_BITSTRIDE 3 89 90 #define LPAIF_IRQ_PER(chan) (1 << (LPAIF_IRQ_BITSTRIDE * (chan))) 91 #define LPAIF_IRQ_XRUN(chan) (2 << (LPAIF_IRQ_BITSTRIDE * (chan))) 92 #define LPAIF_IRQ_ERR(chan) (4 << (LPAIF_IRQ_BITSTRIDE * (chan))) 93 94 #define LPAIF_IRQ_ALL(chan) (7 << (LPAIF_IRQ_BITSTRIDE * (chan))) 95 #define LPAIF_IRQ_HDMI_REQ_ON_PRELOAD(chan) (1 << (14 + chan)) 96 #define LPAIF_IRQ_HDMI_SDEEP_AUD_DIS(chan) (1 << (24 + chan)) 97 #define LPAIF_IRQ_HDMI_METADONE BIT(23) 98 99 /* LPAIF DMA */ 100 #define LPAIF_HDMI_RDMA_REG_ADDR(v, addr, chan) \ 101 (v->hdmi_rdma_reg_base + (addr) + v->hdmi_rdma_reg_stride * (chan)) 102 103 #define LPAIF_HDMI_RDMACTL_AUDINTF(id) (id << LPAIF_RDMACTL_AUDINTF_SHIFT) 104 105 #define LPAIF_HDMI_RDMACTL_REG(v, chan) LPAIF_HDMI_RDMA_REG_ADDR(v, 0x00, (chan)) 106 #define LPAIF_HDMI_RDMABASE_REG(v, chan) LPAIF_HDMI_RDMA_REG_ADDR(v, 0x04, (chan)) 107 #define LPAIF_HDMI_RDMABUFF_REG(v, chan) LPAIF_HDMI_RDMA_REG_ADDR(v, 0x08, (chan)) 108 #define LPAIF_HDMI_RDMACURR_REG(v, chan) LPAIF_HDMI_RDMA_REG_ADDR(v, 0x0C, (chan)) 109 #define LPAIF_HDMI_RDMAPER_REG(v, chan) LPAIF_HDMI_RDMA_REG_ADDR(v, 0x10, (chan)) 110 #define LPAIF_HDMI_RDMAPERCNT_REG(v, chan) LPAIF_HDMI_RDMA_REG_ADDR(v, 0x14, (chan)) 111 112 #define LPAIF_RDMA_REG_ADDR(v, addr, chan) \ 113 (v->rdma_reg_base + (addr) + v->rdma_reg_stride * (chan)) 114 115 #define LPAIF_RDMACTL_AUDINTF(id) (id << LPAIF_RDMACTL_AUDINTF_SHIFT) 116 117 #define LPAIF_RDMACTL_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x00, (chan)) 118 #define LPAIF_RDMABASE_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x04, (chan)) 119 #define LPAIF_RDMABUFF_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x08, (chan)) 120 #define LPAIF_RDMACURR_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x0C, (chan)) 121 #define LPAIF_RDMAPER_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x10, (chan)) 122 #define LPAIF_RDMAPERCNT_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x14, (chan)) 123 124 #define LPAIF_WRDMA_REG_ADDR(v, addr, chan) \ 125 (v->wrdma_reg_base + (addr) + \ 126 v->wrdma_reg_stride * (chan - v->wrdma_channel_start)) 127 128 #define LPAIF_WRDMACTL_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x00, (chan)) 129 #define LPAIF_WRDMABASE_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x04, (chan)) 130 #define LPAIF_WRDMABUFF_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x08, (chan)) 131 #define LPAIF_WRDMACURR_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x0C, (chan)) 132 #define LPAIF_WRDMAPER_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x10, (chan)) 133 #define LPAIF_WRDMAPERCNT_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x14, (chan)) 134 135 #define LPAIF_INTFDMA_REG(v, chan, reg, dai_id) \ 136 ((v->dai_driver[dai_id].id == LPASS_DP_RX) ? \ 137 LPAIF_HDMI_RDMA##reg##_REG(v, chan) : \ 138 LPAIF_RDMA##reg##_REG(v, chan)) 139 140 #define __LPAIF_DMA_REG(v, chan, dir, reg, dai_id) \ 141 ((dir == SNDRV_PCM_STREAM_PLAYBACK) ? \ 142 (LPAIF_INTFDMA_REG(v, chan, reg, dai_id)) : \ 143 LPAIF_WRDMA##reg##_REG(v, chan)) 144 145 #define LPAIF_DMACTL_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, CTL, dai_id) 146 #define LPAIF_DMABASE_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, BASE, dai_id) 147 #define LPAIF_DMABUFF_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, BUFF, dai_id) 148 #define LPAIF_DMACURR_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, CURR, dai_id) 149 #define LPAIF_DMAPER_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, PER, dai_id) 150 #define LPAIF_DMAPERCNT_REG(v, chan, dir, dai_id) __LPAIF_DMA_REG(v, chan, dir, PERCNT, dai_id) 151 152 #define LPAIF_DMACTL_BURSTEN_SINGLE 0 153 #define LPAIF_DMACTL_BURSTEN_INCR4 1 154 155 #define LPAIF_DMACTL_WPSCNT_ONE 0 156 #define LPAIF_DMACTL_WPSCNT_TWO 1 157 #define LPAIF_DMACTL_WPSCNT_THREE 2 158 #define LPAIF_DMACTL_WPSCNT_FOUR 3 159 #define LPAIF_DMACTL_WPSCNT_SIX 5 160 #define LPAIF_DMACTL_WPSCNT_EIGHT 7 161 #define LPAIF_DMACTL_WPSCNT_TEN 9 162 #define LPAIF_DMACTL_WPSCNT_TWELVE 11 163 #define LPAIF_DMACTL_WPSCNT_FOURTEEN 13 164 #define LPAIF_DMACTL_WPSCNT_SIXTEEN 15 165 166 #define LPAIF_DMACTL_AUDINTF(id) id 167 168 #define LPAIF_DMACTL_FIFOWM_1 0 169 #define LPAIF_DMACTL_FIFOWM_2 1 170 #define LPAIF_DMACTL_FIFOWM_3 2 171 #define LPAIF_DMACTL_FIFOWM_4 3 172 #define LPAIF_DMACTL_FIFOWM_5 4 173 #define LPAIF_DMACTL_FIFOWM_6 5 174 #define LPAIF_DMACTL_FIFOWM_7 6 175 #define LPAIF_DMACTL_FIFOWM_8 7 176 #define LPAIF_DMACTL_FIFOWM_9 8 177 #define LPAIF_DMACTL_FIFOWM_10 9 178 #define LPAIF_DMACTL_FIFOWM_11 10 179 #define LPAIF_DMACTL_FIFOWM_12 11 180 #define LPAIF_DMACTL_FIFOWM_13 12 181 #define LPAIF_DMACTL_FIFOWM_14 13 182 #define LPAIF_DMACTL_FIFOWM_15 14 183 #define LPAIF_DMACTL_FIFOWM_16 15 184 #define LPAIF_DMACTL_FIFOWM_17 16 185 #define LPAIF_DMACTL_FIFOWM_18 17 186 #define LPAIF_DMACTL_FIFOWM_19 18 187 #define LPAIF_DMACTL_FIFOWM_20 19 188 #define LPAIF_DMACTL_FIFOWM_21 20 189 #define LPAIF_DMACTL_FIFOWM_22 21 190 #define LPAIF_DMACTL_FIFOWM_23 22 191 #define LPAIF_DMACTL_FIFOWM_24 23 192 #define LPAIF_DMACTL_FIFOWM_25 24 193 #define LPAIF_DMACTL_FIFOWM_26 25 194 #define LPAIF_DMACTL_FIFOWM_27 26 195 #define LPAIF_DMACTL_FIFOWM_28 27 196 #define LPAIF_DMACTL_FIFOWM_29 28 197 #define LPAIF_DMACTL_FIFOWM_30 29 198 #define LPAIF_DMACTL_FIFOWM_31 30 199 #define LPAIF_DMACTL_FIFOWM_32 31 200 201 #define LPAIF_DMACTL_ENABLE_OFF 0 202 #define LPAIF_DMACTL_ENABLE_ON 1 203 204 #define LPAIF_DMACTL_DYNCLK_OFF 0 205 #define LPAIF_DMACTL_DYNCLK_ON 1 206 207 #endif /* __LPASS_LPAIF_REG_H__ */ 208