xref: /linux/sound/soc/codecs/es8326.h (revision 4b660dbd9ee2059850fd30e0df420ca7a38a1856)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * es8326.h -- es8326 ALSA SoC audio driver
4  * Copyright Everest Semiconductor Co.,Ltd
5  *
6  * Authors: David Yang <yangxiaohua@everest-semi.com>
7  */
8 
9 #ifndef _ES8326_H
10 #define _ES8326_H
11 
12 /* ES8326 register space */
13 #define ES8326_RESET		0x00
14 #define ES8326_CLK_CTL		0x01
15 #define ES8326_CLK_INV		0x02
16 #define ES8326_CLK_RESAMPLE	0x03
17 #define ES8326_CLK_DIV1		0x04
18 #define ES8326_CLK_DIV2		0x05
19 #define ES8326_CLK_DLL		0x06
20 #define ES8326_CLK_MUX		0x07
21 #define ES8326_CLK_ADC_SEL	0x08
22 #define ES8326_CLK_DAC_SEL	0x09
23 #define ES8326_CLK_ADC_OSR	0x0a
24 #define ES8326_CLK_DAC_OSR	0x0b
25 #define ES8326_CLK_DIV_CPC	0x0c
26 #define ES8326_CLK_DIV_BCLK	0x0d
27 #define ES8326_CLK_TRI		0x0e
28 #define ES8326_CLK_DIV_LRCK	0x0f
29 #define ES8326_CLK_VMIDS1	0x10
30 #define ES8326_CLK_VMIDS2	0x11
31 #define ES8326_CLK_CAL_TIME	0x12
32 #define ES8326_FMT		0x13
33 
34 #define ES8326_DAC_MUTE		0x14
35 #define ES8326_ADC_MUTE		0x15
36 #define ES8326_ANA_PDN		0x16
37 #define ES8326_PGA_PDN		0x17
38 #define ES8326_VMIDSEL		0x18
39 #define ES8326_ANA_LP		0x19
40 #define ES8326_ANA_DMS		0x1a
41 #define ES8326_ANA_MICBIAS	0x1b
42 #define ES8326_ANA_VSEL		0x1c
43 #define ES8326_SYS_BIAS		0x1d
44 #define ES8326_BIAS_SW1		0x1e
45 #define ES8326_BIAS_SW2		0x1f
46 #define ES8326_BIAS_SW3		0x20
47 #define ES8326_BIAS_SW4		0x21
48 #define ES8326_VMIDLOW		0x22
49 #define ES8326_PGAGAIN		0x23
50 #define ES8326_HP_DRIVER	0x24
51 #define ES8326_DAC2HPMIX	0x25
52 #define ES8326_HP_VOL		0x26
53 #define ES8326_HP_CAL		0x27
54 #define ES8326_HP_DRIVER_REF	0x28
55 #define ES8326_ADC_SCALE	0x29
56 #define ES8326_ADC1_SRC		0x2a
57 #define ES8326_ADC2_SRC		0x2b
58 #define ES8326_ADC1_VOL		0x2c
59 #define ES8326_ADC2_VOL		0x2d
60 #define ES8326_ADC_RAMPRATE	0x2e
61 #define ES8326_ALC_RECOVERY	0x32
62 #define ES8326_ALC_LEVEL	0x33
63 #define ES8326_ADC_HPFS1	0x34
64 #define ES8326_ADC_HPFS2	0x35
65 #define ES8326_ADC_EQ		0x36
66 #define ES8326_HP_OFFSET_CAL	0x4A
67 #define ES8326_HPL_OFFSET_INI	0x4B
68 #define ES8326_HPR_OFFSET_INI	0x4C
69 #define ES8326_DAC_DSM		0x4D
70 #define ES8326_DAC_RAMPRATE	0x4E
71 #define ES8326_DAC_VPPSCALE	0x4F
72 #define ES8326_DACL_VOL	        0x50
73 #define ES8326_DRC_RECOVERY	0x53
74 #define ES8326_DRC_WINSIZE	0x54
75 #define ES8326_DAC_CROSSTALK	0x55
76 #define ES8326_HPJACK_TIMER	0x56
77 #define ES8326_HPDET_TYPE	0x57
78 #define ES8326_INT_SOURCE	0x58
79 #define ES8326_INTOUT_IO	0x59
80 #define ES8326_SDINOUT1_IO	0x5A
81 #define ES8326_SDINOUT23_IO	0x5B
82 #define ES8326_JACK_PULSE	0x5C
83 
84 #define ES8326_DACR_VOL		0xF4
85 #define ES8326_SPKL_VOL		0xF5
86 #define ES8326_SPKR_VOL		0xF6
87 #define ES8326_HP_MISC		0xF7
88 #define ES8326_CTIA_OMTP_STA	0xF8
89 #define ES8326_PULLUP_CTL	0xF9
90 #define ES8326_CSM_I2C_STA	0xFA
91 #define ES8326_HPDET_STA	0xFB
92 #define ES8326_CSM_MUTE_STA	0xFC
93 #define ES8326_CHIP_ID1		0xFD
94 #define ES8326_CHIP_ID2		0xFE
95 #define ES8326_CHIP_VERSION	0xFF
96 
97 /* ES8326_RESET */
98 #define ES8326_CSM_ON (1 << 7)
99 #define ES8326_MASTER_MODE_EN	(1 << 6)
100 #define	ES8326_PWRUP_SEQ_EN	(1 << 5)
101 #define ES8326_CODEC_RESET (0x0f << 0)
102 #define ES8326_CSM_OFF (0 << 7)
103 #define ES8326_MUTE_MASK (3 << 0)
104 #define ES8326_MUTE (3 << 0)
105 
106 /* ES8326_CLK_CTL */
107 #define ES8326_CLK_ON (0x7e << 0)
108 #define ES8326_CLK_OFF (0 << 0)
109 
110 /* ES8326_CLK_INV */
111 #define ES8326_BCLK_AS_MCLK (1 << 3)
112 
113 /* ES8326_FMT */
114 #define ES8326_S24_LE	(0 << 2)
115 #define ES8326_S20_3_LE	(1 << 2)
116 #define ES8326_S18_LE	(2 << 2)
117 #define ES8326_S16_LE	(3 << 2)
118 #define ES8326_S32_LE	(4 << 2)
119 #define ES8326_DATA_LEN_MASK	(7 << 2)
120 
121 #define ES8326_DAIFMT_MASK	((1 << 5) | (3 << 0))
122 #define ES8326_DAIFMT_I2S	0
123 #define ES8326_DAIFMT_LEFT_J	(1 << 0)
124 #define ES8326_DAIFMT_DSP_A	(3 << 0)
125 #define ES8326_DAIFMT_DSP_B	((1 << 5) | (3 << 0))
126 
127 /* ES8326_PGAGAIN */
128 #define ES8326_MIC_SEL_MASK (3 << 4)
129 #define ES8326_MIC1_SEL	(1 << 4)
130 #define ES8326_MIC2_SEL (1 << 5)
131 
132 /* ES8326_HP_CAL */
133 #define ES8326_HP_OFF 0
134 #define ES8326_HP_FORCE_CAL ((1 << 7) | (1 << 3))
135 #define ES8326_HP_ON ((7 << 4) | (7 << 0))
136 
137 /* ES8326_ADC1_SRC */
138 #define ES8326_ADC1_SHIFT 0
139 #define ES8326_ADC2_SHIFT 4
140 #define ES8326_ADC_SRC_ANA 0
141 #define ES8326_ADC_SRC_ANA_INV_SW0 1
142 #define ES8326_ADC_SRC_ANA_INV_SW1 2
143 #define ES8326_ADC_SRC_DMIC_MCLK 3
144 #define ES8326_ADC_SRC_DMIC_SDIN2 4
145 #define ES8326_ADC_SRC_DMIC_SDIN2_INV 5
146 #define ES8326_ADC_SRC_DMIC_SDIN3 6
147 #define ES8326_ADC_SRC_DMIC_SDIN3_INV 7
148 
149 #define ES8326_ADC_AMIC	((ES8326_ADC_SRC_ANA_INV_SW1 << ES8326_ADC2_SHIFT) \
150 		| (ES8326_ADC_SRC_ANA_INV_SW1 << ES8326_ADC1_SHIFT))
151 #define ES8326_ADC_DMIC	((ES8326_ADC_SRC_DMIC_SDIN2 << ES8326_ADC2_SHIFT) \
152 		| (ES8326_ADC_SRC_DMIC_SDIN2 << ES8326_ADC1_SHIFT))
153 /* ES8326_ADC2_SRC */
154 #define ES8326_ADC3_SHIFT 0
155 #define ES8326_ADC4_SHIFT 3
156 
157 /* ES8326_HPDET_TYPE */
158 #define ES8326_HP_DET_SRC_PIN27 (1 << 5)
159 #define ES8326_HP_DET_SRC_PIN9 (1 << 4)
160 #define ES8326_HP_DET_JACK_POL (1 << 3)
161 #define ES8326_HP_DET_BUTTON_POL (1 << 2)
162 #define ES8326_HP_TYPE_OMTP	(3 << 0)
163 #define ES8326_HP_TYPE_CTIA	(2 << 0)
164 #define ES8326_HP_TYPE_AUTO	(1 << 0)
165 #define ES8326_HP_TYPE_AUTO_INV	(0 << 0)
166 
167 /* ES8326_INT_SOURCE */
168 #define ES8326_INT_SRC_DAC_MOZ (1 << 0)
169 #define ES8326_INT_SRC_ADC_MOZ (1 << 1)
170 #define ES8326_INT_SRC_BUTTON (1 << 2)
171 #define ES8326_INT_SRC_PIN9 (1 << 3)
172 #define ES8326_INT_SRC_PIN27 (1 << 4)
173 
174 /* ES8326_SDINOUT1_IO */
175 #define ES8326_IO_INPUT	(0 << 0)
176 #define ES8326_IO_SDIN_SLOT0 (1 << 0)
177 #define ES8326_IO_SDIN_SLOT1 (2 << 0)
178 #define ES8326_IO_SDIN_SLOT2 (3 << 0)
179 #define ES8326_IO_SDIN_SLOT7 (8 << 0)
180 #define ES8326_IO_DMIC_CLK (9 << 0)
181 #define ES8326_IO_DMIC_CLK_INV (0x0a << 0)
182 #define ES8326_IO_SDOUT2 (0x0b << 0)
183 #define ES8326_IO_LOW (0x0e << 0)
184 #define ES8326_IO_HIGH (0x0f << 0)
185 #define ES8326_ADC2DAC (1 << 3)
186 #define ES8326_SDINOUT1_SHIFT 4
187 
188 /* ES8326_SDINOUT23_IO */
189 #define ES8326_SDINOUT2_SHIFT 4
190 #define ES8326_SDINOUT3_SHIFT 0
191 
192 /* ES8326_HPDET_STA */
193 #define ES8326_HPINSERT_FLAG (1 << 1)
194 #define ES8326_HPBUTTON_FLAG (1 << 0)
195 
196 /* ES8326_CHIP_VERSION 0xFF */
197 #define ES8326_VERSION (1 << 0)
198 #define ES8326_VERSION_B (3 << 0)
199 
200 #endif
201