blob: 3d74ae123e9db8209417553149220e21ceda9b31 [file] [log] [blame]
Thomas Gleixner97fb5e82019-05-29 07:17:58 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Kenneth Westfieldcd59f132015-03-03 16:21:53 -08002/*
3 * Copyright (c) 2010-2011,2013-2015 The Linux Foundation. All rights reserved.
Kenneth Westfieldcd59f132015-03-03 16:21:53 -08004 */
5
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +01006#ifndef __LPASS_LPAIF_REG_H__
7#define __LPASS_LPAIF_REG_H__
Kenneth Westfieldcd59f132015-03-03 16:21:53 -08008
9/* LPAIF I2S */
10
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010011#define LPAIF_I2SCTL_REG_ADDR(v, addr, port) \
12 (v->i2sctrl_reg_base + (addr) + v->i2sctrl_reg_stride * (port))
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080013
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010014#define LPAIF_I2SCTL_REG(v, port) LPAIF_I2SCTL_REG_ADDR(v, 0x0, (port))
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080015#define LPAIF_I2SCTL_LOOPBACK_MASK 0x8000
16#define LPAIF_I2SCTL_LOOPBACK_SHIFT 15
17#define LPAIF_I2SCTL_LOOPBACK_DISABLE (0 << LPAIF_I2SCTL_LOOPBACK_SHIFT)
18#define LPAIF_I2SCTL_LOOPBACK_ENABLE (1 << LPAIF_I2SCTL_LOOPBACK_SHIFT)
19
20#define LPAIF_I2SCTL_SPKEN_MASK 0x4000
21#define LPAIF_I2SCTL_SPKEN_SHIFT 14
22#define LPAIF_I2SCTL_SPKEN_DISABLE (0 << LPAIF_I2SCTL_SPKEN_SHIFT)
23#define LPAIF_I2SCTL_SPKEN_ENABLE (1 << LPAIF_I2SCTL_SPKEN_SHIFT)
24
25#define LPAIF_I2SCTL_SPKMODE_MASK 0x3C00
26#define LPAIF_I2SCTL_SPKMODE_SHIFT 10
27#define LPAIF_I2SCTL_SPKMODE_NONE (0 << LPAIF_I2SCTL_SPKMODE_SHIFT)
28#define LPAIF_I2SCTL_SPKMODE_SD0 (1 << LPAIF_I2SCTL_SPKMODE_SHIFT)
29#define LPAIF_I2SCTL_SPKMODE_SD1 (2 << LPAIF_I2SCTL_SPKMODE_SHIFT)
30#define LPAIF_I2SCTL_SPKMODE_SD2 (3 << LPAIF_I2SCTL_SPKMODE_SHIFT)
31#define LPAIF_I2SCTL_SPKMODE_SD3 (4 << LPAIF_I2SCTL_SPKMODE_SHIFT)
32#define LPAIF_I2SCTL_SPKMODE_QUAD01 (5 << LPAIF_I2SCTL_SPKMODE_SHIFT)
33#define LPAIF_I2SCTL_SPKMODE_QUAD23 (6 << LPAIF_I2SCTL_SPKMODE_SHIFT)
34#define LPAIF_I2SCTL_SPKMODE_6CH (7 << LPAIF_I2SCTL_SPKMODE_SHIFT)
35#define LPAIF_I2SCTL_SPKMODE_8CH (8 << LPAIF_I2SCTL_SPKMODE_SHIFT)
36
37#define LPAIF_I2SCTL_SPKMONO_MASK 0x0200
38#define LPAIF_I2SCTL_SPKMONO_SHIFT 9
39#define LPAIF_I2SCTL_SPKMONO_STEREO (0 << LPAIF_I2SCTL_SPKMONO_SHIFT)
40#define LPAIF_I2SCTL_SPKMONO_MONO (1 << LPAIF_I2SCTL_SPKMONO_SHIFT)
41
Srinivas Kandagatla39ad0ec2016-02-11 12:18:06 +000042#define LPAIF_I2SCTL_MICEN_MASK GENMASK(8, 8)
43#define LPAIF_I2SCTL_MICEN_SHIFT 8
44#define LPAIF_I2SCTL_MICEN_DISABLE (0 << LPAIF_I2SCTL_MICEN_SHIFT)
45#define LPAIF_I2SCTL_MICEN_ENABLE (1 << LPAIF_I2SCTL_MICEN_SHIFT)
46
47#define LPAIF_I2SCTL_MICMODE_MASK GENMASK(7, 4)
48#define LPAIF_I2SCTL_MICMODE_SHIFT 4
49#define LPAIF_I2SCTL_MICMODE_NONE (0 << LPAIF_I2SCTL_MICMODE_SHIFT)
50#define LPAIF_I2SCTL_MICMODE_SD0 (1 << LPAIF_I2SCTL_MICMODE_SHIFT)
51#define LPAIF_I2SCTL_MICMODE_SD1 (2 << LPAIF_I2SCTL_MICMODE_SHIFT)
52#define LPAIF_I2SCTL_MICMODE_SD2 (3 << LPAIF_I2SCTL_MICMODE_SHIFT)
53#define LPAIF_I2SCTL_MICMODE_SD3 (4 << LPAIF_I2SCTL_MICMODE_SHIFT)
54#define LPAIF_I2SCTL_MICMODE_QUAD01 (5 << LPAIF_I2SCTL_MICMODE_SHIFT)
55#define LPAIF_I2SCTL_MICMODE_QUAD23 (6 << LPAIF_I2SCTL_MICMODE_SHIFT)
56#define LPAIF_I2SCTL_MICMODE_6CH (7 << LPAIF_I2SCTL_MICMODE_SHIFT)
57#define LPAIF_I2SCTL_MICMODE_8CH (8 << LPAIF_I2SCTL_MICMODE_SHIFT)
58
59#define LPAIF_I2SCTL_MIMONO_MASK GENMASK(3, 3)
60#define LPAIF_I2SCTL_MICMONO_SHIFT 3
61#define LPAIF_I2SCTL_MICMONO_STEREO (0 << LPAIF_I2SCTL_MICMONO_SHIFT)
62#define LPAIF_I2SCTL_MICMONO_MONO (1 << LPAIF_I2SCTL_MICMONO_SHIFT)
63
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080064#define LPAIF_I2SCTL_WSSRC_MASK 0x0004
65#define LPAIF_I2SCTL_WSSRC_SHIFT 2
66#define LPAIF_I2SCTL_WSSRC_INTERNAL (0 << LPAIF_I2SCTL_WSSRC_SHIFT)
67#define LPAIF_I2SCTL_WSSRC_EXTERNAL (1 << LPAIF_I2SCTL_WSSRC_SHIFT)
68
69#define LPAIF_I2SCTL_BITWIDTH_MASK 0x0003
70#define LPAIF_I2SCTL_BITWIDTH_SHIFT 0
71#define LPAIF_I2SCTL_BITWIDTH_16 (0 << LPAIF_I2SCTL_BITWIDTH_SHIFT)
72#define LPAIF_I2SCTL_BITWIDTH_24 (1 << LPAIF_I2SCTL_BITWIDTH_SHIFT)
73#define LPAIF_I2SCTL_BITWIDTH_32 (2 << LPAIF_I2SCTL_BITWIDTH_SHIFT)
74
75/* LPAIF IRQ */
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010076#define LPAIF_IRQ_REG_ADDR(v, addr, port) \
77 (v->irq_reg_base + (addr) + v->irq_reg_stride * (port))
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080078
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010079#define LPAIF_IRQ_PORT_HOST 0
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080080
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010081#define LPAIF_IRQEN_REG(v, port) LPAIF_IRQ_REG_ADDR(v, 0x0, (port))
82#define LPAIF_IRQSTAT_REG(v, port) LPAIF_IRQ_REG_ADDR(v, 0x4, (port))
83#define LPAIF_IRQCLEAR_REG(v, port) LPAIF_IRQ_REG_ADDR(v, 0xC, (port))
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080084
85#define LPAIF_IRQ_BITSTRIDE 3
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010086
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080087#define LPAIF_IRQ_PER(chan) (1 << (LPAIF_IRQ_BITSTRIDE * (chan)))
88#define LPAIF_IRQ_XRUN(chan) (2 << (LPAIF_IRQ_BITSTRIDE * (chan)))
89#define LPAIF_IRQ_ERR(chan) (4 << (LPAIF_IRQ_BITSTRIDE * (chan)))
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010090
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080091#define LPAIF_IRQ_ALL(chan) (7 << (LPAIF_IRQ_BITSTRIDE * (chan)))
92
93/* LPAIF DMA */
94
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010095#define LPAIF_RDMA_REG_ADDR(v, addr, chan) \
96 (v->rdma_reg_base + (addr) + v->rdma_reg_stride * (chan))
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080097
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +010098#define LPAIF_RDMACTL_AUDINTF(id) (id << LPAIF_RDMACTL_AUDINTF_SHIFT)
Kenneth Westfieldcd59f132015-03-03 16:21:53 -080099
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +0100100#define LPAIF_RDMACTL_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x00, (chan))
101#define LPAIF_RDMABASE_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x04, (chan))
102#define LPAIF_RDMABUFF_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x08, (chan))
103#define LPAIF_RDMACURR_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x0C, (chan))
104#define LPAIF_RDMAPER_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x10, (chan))
105#define LPAIF_RDMAPERCNT_REG(v, chan) LPAIF_RDMA_REG_ADDR(v, 0x14, (chan))
Kenneth Westfieldcd59f132015-03-03 16:21:53 -0800106
Srinivas Kandagatla71aaa602016-02-11 12:18:14 +0000107#define LPAIF_WRDMA_REG_ADDR(v, addr, chan) \
108 (v->wrdma_reg_base + (addr) + \
109 v->wrdma_reg_stride * (chan - v->wrdma_channel_start))
110
111#define LPAIF_WRDMACTL_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x00, (chan))
112#define LPAIF_WRDMABASE_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x04, (chan))
113#define LPAIF_WRDMABUFF_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x08, (chan))
114#define LPAIF_WRDMACURR_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x0C, (chan))
115#define LPAIF_WRDMAPER_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x10, (chan))
116#define LPAIF_WRDMAPERCNT_REG(v, chan) LPAIF_WRDMA_REG_ADDR(v, 0x14, (chan))
117
Srinivas Kandagatlaec9e0ec2016-02-11 12:18:20 +0000118#define __LPAIF_DMA_REG(v, chan, dir, reg) \
119 (dir == SNDRV_PCM_STREAM_PLAYBACK) ? \
120 LPAIF_RDMA##reg##_REG(v, chan) : \
121 LPAIF_WRDMA##reg##_REG(v, chan)
122
123#define LPAIF_DMACTL_REG(v, chan, dir) __LPAIF_DMA_REG(v, chan, dir, CTL)
124#define LPAIF_DMABASE_REG(v, chan, dir) __LPAIF_DMA_REG(v, chan, dir, BASE)
125#define LPAIF_DMABUFF_REG(v, chan, dir) __LPAIF_DMA_REG(v, chan, dir, BUFF)
126#define LPAIF_DMACURR_REG(v, chan, dir) __LPAIF_DMA_REG(v, chan, dir, CURR)
127#define LPAIF_DMAPER_REG(v, chan, dir) __LPAIF_DMA_REG(v, chan, dir, PER)
128#define LPAIF_DMAPERCNT_REG(v, chan, dir) __LPAIF_DMA_REG(v, chan, dir, PERCNT)
129
130#define LPAIF_DMACTL_BURSTEN_MASK 0x800
131#define LPAIF_DMACTL_BURSTEN_SHIFT 11
132#define LPAIF_DMACTL_BURSTEN_SINGLE (0 << LPAIF_DMACTL_BURSTEN_SHIFT)
133#define LPAIF_DMACTL_BURSTEN_INCR4 (1 << LPAIF_DMACTL_BURSTEN_SHIFT)
134
135#define LPAIF_DMACTL_WPSCNT_MASK 0x700
136#define LPAIF_DMACTL_WPSCNT_SHIFT 8
137#define LPAIF_DMACTL_WPSCNT_ONE (0 << LPAIF_DMACTL_WPSCNT_SHIFT)
138#define LPAIF_DMACTL_WPSCNT_TWO (1 << LPAIF_DMACTL_WPSCNT_SHIFT)
139#define LPAIF_DMACTL_WPSCNT_THREE (2 << LPAIF_DMACTL_WPSCNT_SHIFT)
140#define LPAIF_DMACTL_WPSCNT_FOUR (3 << LPAIF_DMACTL_WPSCNT_SHIFT)
141#define LPAIF_DMACTL_WPSCNT_SIX (5 << LPAIF_DMACTL_WPSCNT_SHIFT)
142#define LPAIF_DMACTL_WPSCNT_EIGHT (7 << LPAIF_DMACTL_WPSCNT_SHIFT)
143
144#define LPAIF_DMACTL_AUDINTF_MASK 0x0F0
145#define LPAIF_DMACTL_AUDINTF_SHIFT 4
146#define LPAIF_DMACTL_AUDINTF(id) (id << LPAIF_DMACTL_AUDINTF_SHIFT)
147
148#define LPAIF_DMACTL_FIFOWM_MASK 0x00E
149#define LPAIF_DMACTL_FIFOWM_SHIFT 1
150#define LPAIF_DMACTL_FIFOWM_1 (0 << LPAIF_DMACTL_FIFOWM_SHIFT)
151#define LPAIF_DMACTL_FIFOWM_2 (1 << LPAIF_DMACTL_FIFOWM_SHIFT)
152#define LPAIF_DMACTL_FIFOWM_3 (2 << LPAIF_DMACTL_FIFOWM_SHIFT)
153#define LPAIF_DMACTL_FIFOWM_4 (3 << LPAIF_DMACTL_FIFOWM_SHIFT)
154#define LPAIF_DMACTL_FIFOWM_5 (4 << LPAIF_DMACTL_FIFOWM_SHIFT)
155#define LPAIF_DMACTL_FIFOWM_6 (5 << LPAIF_DMACTL_FIFOWM_SHIFT)
156#define LPAIF_DMACTL_FIFOWM_7 (6 << LPAIF_DMACTL_FIFOWM_SHIFT)
157#define LPAIF_DMACTL_FIFOWM_8 (7 << LPAIF_DMACTL_FIFOWM_SHIFT)
158
159#define LPAIF_DMACTL_ENABLE_MASK 0x1
160#define LPAIF_DMACTL_ENABLE_SHIFT 0
161#define LPAIF_DMACTL_ENABLE_OFF (0 << LPAIF_DMACTL_ENABLE_SHIFT)
162#define LPAIF_DMACTL_ENABLE_ON (1 << LPAIF_DMACTL_ENABLE_SHIFT)
163
164#define LPAIF_DMACTL_DYNCLK_MASK BIT(12)
165#define LPAIF_DMACTL_DYNCLK_SHIFT 12
166#define LPAIF_DMACTL_DYNCLK_OFF (0 << LPAIF_DMACTL_DYNCLK_SHIFT)
167#define LPAIF_DMACTL_DYNCLK_ON (1 << LPAIF_DMACTL_DYNCLK_SHIFT)
Srinivas Kandagatla9bae4882015-05-16 13:32:17 +0100168#endif /* __LPASS_LPAIF_REG_H__ */