1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * ATC2603C PMIC register definitions
4  *
5  * Copyright (C) 2020 Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
6  */
7 
8 #ifndef __LINUX_MFD_ATC260X_ATC2603C_H
9 #define __LINUX_MFD_ATC260X_ATC2603C_H
10 
11 enum atc2603c_irq_def {
12 	ATC2603C_IRQ_AUDIO = 0,
13 	ATC2603C_IRQ_OV,
14 	ATC2603C_IRQ_OC,
15 	ATC2603C_IRQ_OT,
16 	ATC2603C_IRQ_UV,
17 	ATC2603C_IRQ_ALARM,
18 	ATC2603C_IRQ_ONOFF,
19 	ATC2603C_IRQ_SGPIO,
20 	ATC2603C_IRQ_IR,
21 	ATC2603C_IRQ_REMCON,
22 	ATC2603C_IRQ_POWER_IN,
23 };
24 
25 /* PMU Registers */
26 #define ATC2603C_PMU_SYS_CTL0			0x00
27 #define ATC2603C_PMU_SYS_CTL1			0x01
28 #define ATC2603C_PMU_SYS_CTL2			0x02
29 #define ATC2603C_PMU_SYS_CTL3			0x03
30 #define ATC2603C_PMU_SYS_CTL4			0x04
31 #define ATC2603C_PMU_SYS_CTL5			0x05
32 #define ATC2603C_PMU_SYS_CTL6			0x06
33 #define ATC2603C_PMU_SYS_CTL7			0x07
34 #define ATC2603C_PMU_SYS_CTL8			0x08
35 #define ATC2603C_PMU_SYS_CTL9			0x09
36 #define ATC2603C_PMU_BAT_CTL0			0x0A
37 #define ATC2603C_PMU_BAT_CTL1			0x0B
38 #define ATC2603C_PMU_VBUS_CTL0			0x0C
39 #define ATC2603C_PMU_VBUS_CTL1			0x0D
40 #define ATC2603C_PMU_WALL_CTL0			0x0E
41 #define ATC2603C_PMU_WALL_CTL1			0x0F
42 #define ATC2603C_PMU_SYS_PENDING		0x10
43 #define ATC2603C_PMU_DC1_CTL0			0x11
44 #define ATC2603C_PMU_DC1_CTL1			0x12 // Undocumented
45 #define ATC2603C_PMU_DC1_CTL2			0x13 // Undocumented
46 #define ATC2603C_PMU_DC2_CTL0			0x14
47 #define ATC2603C_PMU_DC2_CTL1			0x15 // Undocumented
48 #define ATC2603C_PMU_DC2_CTL2			0x16 // Undocumented
49 #define ATC2603C_PMU_DC3_CTL0			0x17
50 #define ATC2603C_PMU_DC3_CTL1			0x18 // Undocumented
51 #define ATC2603C_PMU_DC3_CTL2			0x19 // Undocumented
52 #define ATC2603C_PMU_DC4_CTL0			0x1A // Undocumented
53 #define ATC2603C_PMU_DC4_CTL1			0x1B // Undocumented
54 #define ATC2603C_PMU_DC5_CTL0			0x1C // Undocumented
55 #define ATC2603C_PMU_DC5_CTL1			0x1D // Undocumented
56 #define ATC2603C_PMU_LDO1_CTL			0x1E
57 #define ATC2603C_PMU_LDO2_CTL			0x1F
58 #define ATC2603C_PMU_LDO3_CTL			0x20
59 #define ATC2603C_PMU_LDO4_CTL			0x21 // Undocumented
60 #define ATC2603C_PMU_LDO5_CTL			0x22
61 #define ATC2603C_PMU_LDO6_CTL			0x23
62 #define ATC2603C_PMU_LDO7_CTL			0x24
63 #define ATC2603C_PMU_LDO8_CTL			0x25 // Undocumented
64 #define ATC2603C_PMU_LDO9_CTL			0x26 // Undocumented
65 #define ATC2603C_PMU_LDO10_CTL			0x27 // Undocumented
66 #define ATC2603C_PMU_LDO11_CTL			0x28
67 #define ATC2603C_PMU_SWITCH_CTL			0x29
68 #define ATC2603C_PMU_OV_CTL0			0x2A
69 #define ATC2603C_PMU_OV_CTL1			0x2B
70 #define ATC2603C_PMU_OV_STATUS			0x2C
71 #define ATC2603C_PMU_OV_EN			0x2D
72 #define ATC2603C_PMU_OV_INT_EN			0x2E
73 #define ATC2603C_PMU_OC_CTL			0x2F
74 #define ATC2603C_PMU_OC_STATUS			0x30
75 #define ATC2603C_PMU_OC_EN			0x31
76 #define ATC2603C_PMU_OC_INT_EN			0x32
77 #define ATC2603C_PMU_UV_CTL0			0x33
78 #define ATC2603C_PMU_UV_CTL1			0x34
79 #define ATC2603C_PMU_UV_STATUS			0x35
80 #define ATC2603C_PMU_UV_EN			0x36
81 #define ATC2603C_PMU_UV_INT_EN			0x37
82 #define ATC2603C_PMU_OT_CTL			0x38
83 #define ATC2603C_PMU_CHARGER_CTL0		0x39
84 #define ATC2603C_PMU_CHARGER_CTL1		0x3A
85 #define ATC2603C_PMU_CHARGER_CTL2		0x3B
86 #define ATC2603C_PMU_BAKCHARGER_CTL		0x3C // Undocumented
87 #define ATC2603C_PMU_APDS_CTL			0x3D
88 #define ATC2603C_PMU_AUXADC_CTL0		0x3E
89 #define ATC2603C_PMU_AUXADC_CTL1		0x3F
90 #define ATC2603C_PMU_BATVADC			0x40
91 #define ATC2603C_PMU_BATIADC			0x41
92 #define ATC2603C_PMU_WALLVADC			0x42
93 #define ATC2603C_PMU_WALLIADC			0x43
94 #define ATC2603C_PMU_VBUSVADC			0x44
95 #define ATC2603C_PMU_VBUSIADC			0x45
96 #define ATC2603C_PMU_SYSPWRADC			0x46
97 #define ATC2603C_PMU_REMCONADC			0x47
98 #define ATC2603C_PMU_SVCCADC			0x48
99 #define ATC2603C_PMU_CHGIADC			0x49
100 #define ATC2603C_PMU_IREFADC			0x4A
101 #define ATC2603C_PMU_BAKBATADC			0x4B
102 #define ATC2603C_PMU_ICTEMPADC			0x4C
103 #define ATC2603C_PMU_AUXADC0			0x4D
104 #define ATC2603C_PMU_AUXADC1			0x4E
105 #define ATC2603C_PMU_AUXADC2			0x4F
106 #define	ATC2603C_PMU_ICMADC			0x50
107 #define ATC2603C_PMU_BDG_CTL			0x51 // Undocumented
108 #define ATC2603C_RTC_CTL			0x52
109 #define ATC2603C_RTC_MSALM			0x53
110 #define ATC2603C_RTC_HALM			0x54
111 #define ATC2603C_RTC_YMDALM			0x55
112 #define ATC2603C_RTC_MS				0x56
113 #define ATC2603C_RTC_H				0x57
114 #define ATC2603C_RTC_DC				0x58
115 #define ATC2603C_RTC_YMD			0x59
116 #define ATC2603C_EFUSE_DAT			0x5A // Undocumented
117 #define ATC2603C_EFUSECRTL1			0x5B // Undocumented
118 #define ATC2603C_EFUSECRTL2			0x5C // Undocumented
119 #define ATC2603C_PMU_FW_USE0			0x5D // Undocumented
120 #define ATC2603C_PMU_FW_USE1			0x5E // Undocumented
121 #define ATC2603C_PMU_FW_USE2			0x5F // Undocumented
122 #define ATC2603C_PMU_FW_USE3			0x60 // Undocumented
123 #define ATC2603C_PMU_FW_USE4			0x61 // Undocumented
124 #define ATC2603C_PMU_ABNORMAL_STATUS		0x62
125 #define ATC2603C_PMU_WALL_APDS_CTL		0x63
126 #define ATC2603C_PMU_REMCON_CTL0		0x64
127 #define ATC2603C_PMU_REMCON_CTL1		0x65
128 #define ATC2603C_PMU_MUX_CTL0			0x66
129 #define ATC2603C_PMU_SGPIO_CTL0			0x67
130 #define ATC2603C_PMU_SGPIO_CTL1			0x68
131 #define ATC2603C_PMU_SGPIO_CTL2			0x69
132 #define ATC2603C_PMU_SGPIO_CTL3			0x6A
133 #define ATC2603C_PMU_SGPIO_CTL4			0x6B
134 #define ATC2603C_PWMCLK_CTL			0x6C
135 #define ATC2603C_PWM0_CTL			0x6D
136 #define ATC2603C_PWM1_CTL			0x6E
137 #define ATC2603C_PMU_ADC_DBG0			0x70
138 #define ATC2603C_PMU_ADC_DBG1			0x71
139 #define ATC2603C_PMU_ADC_DBG2			0x72
140 #define ATC2603C_PMU_ADC_DBG3			0x73
141 #define ATC2603C_PMU_ADC_DBG4			0x74
142 #define ATC2603C_IRC_CTL			0x80
143 #define ATC2603C_IRC_STAT			0x81
144 #define ATC2603C_IRC_CC				0x82
145 #define ATC2603C_IRC_KDC			0x83
146 #define ATC2603C_IRC_WK				0x84
147 #define ATC2603C_IRC_RCC			0x85
148 #define ATC2603C_IRC_FILTER			0x86
149 
150 /* AUDIO_OUT Registers */
151 #define ATC2603C_AUDIOINOUT_CTL			0xA0
152 #define ATC2603C_AUDIO_DEBUGOUTCTL		0xA1
153 #define ATC2603C_DAC_DIGITALCTL			0xA2
154 #define ATC2603C_DAC_VOLUMECTL0			0xA3
155 #define ATC2603C_DAC_ANALOG0			0xA4
156 #define ATC2603C_DAC_ANALOG1			0xA5
157 #define ATC2603C_DAC_ANALOG2			0xA6
158 #define ATC2603C_DAC_ANALOG3			0xA7
159 
160 /* AUDIO_IN Registers */
161 #define ATC2603C_ADC_DIGITALCTL			0xA8
162 #define ATC2603C_ADC_HPFCTL			0xA9
163 #define ATC2603C_ADC_CTL			0xAA
164 #define ATC2603C_AGC_CTL0			0xAB
165 #define ATC2603C_AGC_CTL1			0xAC // Undocumented
166 #define ATC2603C_AGC_CTL2			0xAD
167 #define ATC2603C_ADC_ANALOG0			0xAE
168 #define ATC2603C_ADC_ANALOG1			0xAF
169 
170 /* PCM_IF Registers */
171 #define ATC2603C_PCM0_CTL			0xB0 // Undocumented
172 #define ATC2603C_PCM1_CTL			0xB1 // Undocumented
173 #define ATC2603C_PCM2_CTL			0xB2 // Undocumented
174 #define ATC2603C_PCMIF_CTL			0xB3 // Undocumented
175 
176 /* CMU_CONTROL Registers */
177 #define ATC2603C_CMU_DEVRST			0xC1 // Undocumented
178 
179 /* INTS Registers */
180 #define ATC2603C_INTS_PD			0xC8
181 #define ATC2603C_INTS_MSK			0xC9
182 
183 /* MFP Registers */
184 #define ATC2603C_MFP_CTL			0xD0
185 #define ATC2603C_PAD_VSEL			0xD1 // Undocumented
186 #define ATC2603C_GPIO_OUTEN			0xD2
187 #define ATC2603C_GPIO_INEN			0xD3
188 #define ATC2603C_GPIO_DAT			0xD4
189 #define ATC2603C_PAD_DRV			0xD5
190 #define ATC2603C_PAD_EN				0xD6
191 #define ATC2603C_DEBUG_SEL			0xD7 // Undocumented
192 #define ATC2603C_DEBUG_IE			0xD8 // Undocumented
193 #define ATC2603C_DEBUG_OE			0xD9 // Undocumented
194 #define ATC2603C_BIST_START			0x0A // Undocumented
195 #define ATC2603C_BIST_RESULT			0x0B // Undocumented
196 #define ATC2603C_CHIP_VER			0xDC
197 
198 /* TWSI Registers */
199 #define ATC2603C_SADDR				0xFF
200 
201 /* PMU_SYS_CTL0 Register Mask Bits */
202 #define ATC2603C_PMU_SYS_CTL0_IR_WK_EN			BIT(5)
203 #define ATC2603C_PMU_SYS_CTL0_RESET_WK_EN		BIT(6)
204 #define ATC2603C_PMU_SYS_CTL0_HDSW_WK_EN		BIT(7)
205 #define ATC2603C_PMU_SYS_CTL0_ALARM_WK_EN		BIT(8)
206 #define ATC2603C_PMU_SYS_CTL0_REM_CON_WK_EN		BIT(9)
207 #define ATC2603C_PMU_SYS_CTL0_RESTART_EN		BIT(10)
208 #define ATC2603C_PMU_SYS_CTL0_SGPIOIRQ_WK_EN		BIT(11)
209 #define ATC2603C_PMU_SYS_CTL0_ONOFF_SHORT_WK_EN		BIT(12)
210 #define ATC2603C_PMU_SYS_CTL0_ONOFF_LONG_WK_EN		BIT(13)
211 #define ATC2603C_PMU_SYS_CTL0_WALL_WK_EN		BIT(14)
212 #define ATC2603C_PMU_SYS_CTL0_USB_WK_EN			BIT(15)
213 #define ATC2603C_PMU_SYS_CTL0_WK_ALL			(GENMASK(15, 5) & (~BIT(10)))
214 
215 /* PMU_SYS_CTL1 Register Mask Bits */
216 #define ATC2603C_PMU_SYS_CTL1_EN_S1			BIT(0)
217 #define ATC2603C_PMU_SYS_CTL1_LB_S4_EN			BIT(2)
218 #define ATC2603C_PMU_SYS_CTL1_LB_S4			GENMASK(4, 3)
219 #define ATC2603C_PMU_SYS_CTL1_LB_S4_3_1V		BIT(4)
220 #define ATC2603C_PMU_SYS_CTL1_IR_WK_FLAG		BIT(5)
221 #define ATC2603C_PMU_SYS_CTL1_RESET_WK_FLAG		BIT(6)
222 #define ATC2603C_PMU_SYS_CTL1_HDSW_WK_FLAG		BIT(7)
223 #define ATC2603C_PMU_SYS_CTL1_ALARM_WK_FLAG		BIT(8)
224 #define ATC2603C_PMU_SYS_CTL1_REM_CON_WK_FLAG		BIT(9)
225 #define ATC2603C_PMU_SYS_CTL1_ONOFF_PRESS_RESET_IRQ_PD	BIT(10)
226 #define ATC2603C_PMU_SYS_CTL1_SGPIOIRQ_WK_FLAG		BIT(11)
227 #define ATC2603C_PMU_SYS_CTL1_ONOFF_SHORT_WK_FLAG	BIT(12)
228 #define ATC2603C_PMU_SYS_CTL1_ONOFF_LONG_WK_FLAG	BIT(13)
229 #define ATC2603C_PMU_SYS_CTL1_WALL_WK_FLAG		BIT(14)
230 #define ATC2603C_PMU_SYS_CTL1_USB_WK_FLAG		BIT(15)
231 
232 /* PMU_SYS_CTL2 Register Mask Bits */
233 #define ATC2603C_PMU_SYS_CTL2_PMU_A_EN			BIT(0)
234 #define ATC2603C_PMU_SYS_CTL2_ONOFF_PRESS_INT_EN	BIT(1)
235 #define ATC2603C_PMU_SYS_CTL2_ONOFF_PRESS_PD		BIT(2)
236 #define ATC2603C_PMU_SYS_CTL2_S2TIMER			GENMASK(5, 3)
237 #define ATC2603C_PMU_SYS_CTL2_S2_TIMER_EN		BIT(6)
238 #define ATC2603C_PMU_SYS_CTL2_ONOFF_RESET_TIME_SEL	GENMASK(8, 7)
239 #define ATC2603C_PMU_SYS_CTL2_ONOFF_PRESS_RESET_EN	BIT(9)
240 #define ATC2603C_PMU_SYS_CTL2_ONOFF_PRESS_TIME		GENMASK(11, 10)
241 #define ATC2603C_PMU_SYS_CTL2_ONOFF_INT_EN		BIT(12)
242 #define ATC2603C_PMU_SYS_CTL2_ONOFF_LONG_PRESS		BIT(13)
243 #define ATC2603C_PMU_SYS_CTL2_ONOFF_SHORT_PRESS		BIT(14)
244 #define ATC2603C_PMU_SYS_CTL2_ONOFF_PRESS		BIT(15)
245 
246 /* PMU_SYS_CTL3 Register Mask Bits */
247 #define ATC2603C_PMU_SYS_CTL3_S2S3TOS1_TIMER		GENMASK(8, 7)
248 #define ATC2603C_PMU_SYS_CTL3_S2S3TOS1_TIMER_EN		BIT(9)
249 #define ATC2603C_PMU_SYS_CTL3_S3_TIMER			GENMASK(12, 10)
250 #define ATC2603C_PMU_SYS_CTL3_S3_TIMER_EN		BIT(13)
251 #define ATC2603C_PMU_SYS_CTL3_EN_S3			BIT(14)
252 #define ATC2603C_PMU_SYS_CTL3_EN_S2			BIT(15)
253 
254 /* PMU_SYS_CTL5 Register Mask Bits */
255 #define ATC2603C_PMU_SYS_CTL5_WALLWKDTEN		BIT(7)
256 #define ATC2603C_PMU_SYS_CTL5_VBUSWKDTEN		BIT(8)
257 #define ATC2603C_PMU_SYS_CTL5_REMCON_DECT_EN		BIT(9)
258 #define ATC2603C_PMU_SYS_CTL5_ONOFF_8S_SEL		BIT(10)
259 
260 /* INTS_MSK Register Mask Bits */
261 #define ATC2603C_INTS_MSK_AUDIO				BIT(0)
262 #define ATC2603C_INTS_MSK_OV				BIT(1)
263 #define ATC2603C_INTS_MSK_OC				BIT(2)
264 #define ATC2603C_INTS_MSK_OT				BIT(3)
265 #define ATC2603C_INTS_MSK_UV				BIT(4)
266 #define ATC2603C_INTS_MSK_ALARM				BIT(5)
267 #define ATC2603C_INTS_MSK_ONOFF				BIT(6)
268 #define ATC2603C_INTS_MSK_SGPIO				BIT(7)
269 #define ATC2603C_INTS_MSK_IR				BIT(8)
270 #define ATC2603C_INTS_MSK_REMCON			BIT(9)
271 #define ATC2603C_INTS_MSK_POWERIN			BIT(10)
272 
273 /* CMU_DEVRST Register Mask Bits */
274 #define ATC2603C_CMU_DEVRST_MFP				BIT(1)
275 #define ATC2603C_CMU_DEVRST_INTS			BIT(2)
276 #define ATC2603C_CMU_DEVRST_AUDIO			BIT(4)
277 
278 /* PAD_EN Register Mask Bits */
279 #define ATC2603C_PAD_EN_EXTIRQ				BIT(0)
280 
281 #endif /* __LINUX_MFD_ATC260X_ATC2603C_H */
282