xref: /linux/sound/soc/codecs/cs42l42.h (revision 7ec4a058c16f3da9c2c0c66506f45c083198ed30)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
22c394ca7SJames Schulman /*
32c394ca7SJames Schulman  * cs42l42.h -- CS42L42 ALSA SoC audio driver header
42c394ca7SJames Schulman  *
52c394ca7SJames Schulman  * Copyright 2016 Cirrus Logic, Inc.
62c394ca7SJames Schulman  *
72c394ca7SJames Schulman  * Author: James Schulman <james.schulman@cirrus.com>
82c394ca7SJames Schulman  * Author: Brian Austin <brian.austin@cirrus.com>
92c394ca7SJames Schulman  * Author: Michael White <michael.white@cirrus.com>
102c394ca7SJames Schulman  */
112c394ca7SJames Schulman 
122c394ca7SJames Schulman #ifndef __CS42L42_H__
132c394ca7SJames Schulman #define __CS42L42_H__
142c394ca7SJames Schulman 
15c5b8ee08SLucas Tanure #include <sound/jack.h>
16c5b8ee08SLucas Tanure 
172c394ca7SJames Schulman #define CS42L42_PAGE_REGISTER	0x00	/* Page Select Register */
182c394ca7SJames Schulman #define CS42L42_WIN_START	0x00
192c394ca7SJames Schulman #define CS42L42_WIN_LEN		0x100
202c394ca7SJames Schulman #define CS42L42_RANGE_MIN	0x00
212c394ca7SJames Schulman #define CS42L42_RANGE_MAX	0x7F
222c394ca7SJames Schulman 
232c394ca7SJames Schulman #define CS42L42_PAGE_10		0x1000
242c394ca7SJames Schulman #define CS42L42_PAGE_11		0x1100
252c394ca7SJames Schulman #define CS42L42_PAGE_12		0x1200
262c394ca7SJames Schulman #define CS42L42_PAGE_13		0x1300
272c394ca7SJames Schulman #define CS42L42_PAGE_15		0x1500
282c394ca7SJames Schulman #define CS42L42_PAGE_19		0x1900
292c394ca7SJames Schulman #define CS42L42_PAGE_1B		0x1B00
302c394ca7SJames Schulman #define CS42L42_PAGE_1C		0x1C00
312c394ca7SJames Schulman #define CS42L42_PAGE_1D		0x1D00
322c394ca7SJames Schulman #define CS42L42_PAGE_1F		0x1F00
332c394ca7SJames Schulman #define CS42L42_PAGE_20		0x2000
342c394ca7SJames Schulman #define CS42L42_PAGE_21		0x2100
352c394ca7SJames Schulman #define CS42L42_PAGE_23		0x2300
362c394ca7SJames Schulman #define CS42L42_PAGE_24		0x2400
372c394ca7SJames Schulman #define CS42L42_PAGE_25		0x2500
382c394ca7SJames Schulman #define CS42L42_PAGE_26		0x2600
392c394ca7SJames Schulman #define CS42L42_PAGE_28		0x2800
402c394ca7SJames Schulman #define CS42L42_PAGE_29		0x2900
412c394ca7SJames Schulman #define CS42L42_PAGE_2A		0x2A00
422c394ca7SJames Schulman #define CS42L42_PAGE_30		0x3000
432c394ca7SJames Schulman 
442c394ca7SJames Schulman #define CS42L42_CHIP_ID		0x42A42
452c394ca7SJames Schulman 
462c394ca7SJames Schulman /* Page 0x10 Global Registers */
472c394ca7SJames Schulman #define CS42L42_DEVID_AB		(CS42L42_PAGE_10 + 0x01)
482c394ca7SJames Schulman #define CS42L42_DEVID_CD		(CS42L42_PAGE_10 + 0x02)
492c394ca7SJames Schulman #define CS42L42_DEVID_E			(CS42L42_PAGE_10 + 0x03)
502c394ca7SJames Schulman #define CS42L42_FABID			(CS42L42_PAGE_10 + 0x04)
512c394ca7SJames Schulman #define CS42L42_REVID			(CS42L42_PAGE_10 + 0x05)
522c394ca7SJames Schulman #define CS42L42_FRZ_CTL			(CS42L42_PAGE_10 + 0x06)
532c394ca7SJames Schulman 
542c394ca7SJames Schulman #define CS42L42_SRC_CTL			(CS42L42_PAGE_10 + 0x07)
552c394ca7SJames Schulman #define CS42L42_SRC_BYPASS_DAC_SHIFT	1
562c394ca7SJames Schulman #define CS42L42_SRC_BYPASS_DAC_MASK	(1 << CS42L42_SRC_BYPASS_DAC_SHIFT)
572c394ca7SJames Schulman 
582c394ca7SJames Schulman #define CS42L42_MCLK_STATUS		(CS42L42_PAGE_10 + 0x08)
592c394ca7SJames Schulman 
602c394ca7SJames Schulman #define CS42L42_MCLK_CTL		(CS42L42_PAGE_10 + 0x09)
612c394ca7SJames Schulman #define CS42L42_INTERNAL_FS_SHIFT	1
622c394ca7SJames Schulman #define CS42L42_INTERNAL_FS_MASK	(1 << CS42L42_INTERNAL_FS_SHIFT)
632c394ca7SJames Schulman 
642c394ca7SJames Schulman #define CS42L42_SFTRAMP_RATE		(CS42L42_PAGE_10 + 0x0A)
65*7ec4a058SRichard Fitzgerald #define CS42L42_SLOW_START_ENABLE	(CS42L42_PAGE_10 + 0x0B)
66*7ec4a058SRichard Fitzgerald #define CS42L42_SLOW_START_EN_MASK	GENMASK(6, 4)
67*7ec4a058SRichard Fitzgerald #define CS42L42_SLOW_START_EN_SHIFT	4
682c394ca7SJames Schulman #define CS42L42_I2C_DEBOUNCE		(CS42L42_PAGE_10 + 0x0E)
692c394ca7SJames Schulman #define CS42L42_I2C_STRETCH		(CS42L42_PAGE_10 + 0x0F)
702c394ca7SJames Schulman #define CS42L42_I2C_TIMEOUT		(CS42L42_PAGE_10 + 0x10)
712c394ca7SJames Schulman 
722c394ca7SJames Schulman /* Page 0x11 Power and Headset Detect Registers */
732c394ca7SJames Schulman #define CS42L42_PWR_CTL1		(CS42L42_PAGE_11 + 0x01)
742c394ca7SJames Schulman #define CS42L42_ASP_DAO_PDN_SHIFT	7
752c394ca7SJames Schulman #define CS42L42_ASP_DAO_PDN_MASK	(1 << CS42L42_ASP_DAO_PDN_SHIFT)
762c394ca7SJames Schulman #define CS42L42_ASP_DAI_PDN_SHIFT	6
772c394ca7SJames Schulman #define CS42L42_ASP_DAI_PDN_MASK	(1 << CS42L42_ASP_DAI_PDN_SHIFT)
782c394ca7SJames Schulman #define CS42L42_MIXER_PDN_SHIFT		5
792c394ca7SJames Schulman #define CS42L42_MIXER_PDN_MASK		(1 << CS42L42_MIXER_PDN_SHIFT)
802c394ca7SJames Schulman #define CS42L42_EQ_PDN_SHIFT		4
812c394ca7SJames Schulman #define CS42L42_EQ_PDN_MASK		(1 << CS42L42_EQ_PDN_SHIFT)
822c394ca7SJames Schulman #define CS42L42_HP_PDN_SHIFT		3
832c394ca7SJames Schulman #define CS42L42_HP_PDN_MASK		(1 << CS42L42_HP_PDN_SHIFT)
842c394ca7SJames Schulman #define CS42L42_ADC_PDN_SHIFT		2
85fac165f2SRichard Fitzgerald #define CS42L42_ADC_PDN_MASK		(1 << CS42L42_ADC_PDN_SHIFT)
862c394ca7SJames Schulman #define CS42L42_PDN_ALL_SHIFT		0
872c394ca7SJames Schulman #define CS42L42_PDN_ALL_MASK		(1 << CS42L42_PDN_ALL_SHIFT)
882c394ca7SJames Schulman 
892c394ca7SJames Schulman #define CS42L42_PWR_CTL2		(CS42L42_PAGE_11 + 0x02)
902c394ca7SJames Schulman #define CS42L42_ADC_SRC_PDNB_SHIFT	0
912c394ca7SJames Schulman #define CS42L42_ADC_SRC_PDNB_MASK	(1 << CS42L42_ADC_SRC_PDNB_SHIFT)
922c394ca7SJames Schulman #define CS42L42_DAC_SRC_PDNB_SHIFT	1
932c394ca7SJames Schulman #define CS42L42_DAC_SRC_PDNB_MASK	(1 << CS42L42_DAC_SRC_PDNB_SHIFT)
942c394ca7SJames Schulman #define CS42L42_ASP_DAI1_PDN_SHIFT	2
952c394ca7SJames Schulman #define CS42L42_ASP_DAI1_PDN_MASK	(1 << CS42L42_ASP_DAI1_PDN_SHIFT)
962c394ca7SJames Schulman #define CS42L42_SRC_PDN_OVERRIDE_SHIFT	3
972c394ca7SJames Schulman #define CS42L42_SRC_PDN_OVERRIDE_MASK	(1 << CS42L42_SRC_PDN_OVERRIDE_SHIFT)
982c394ca7SJames Schulman #define CS42L42_DISCHARGE_FILT_SHIFT	4
992c394ca7SJames Schulman #define CS42L42_DISCHARGE_FILT_MASK	(1 << CS42L42_DISCHARGE_FILT_SHIFT)
1002c394ca7SJames Schulman 
1012c394ca7SJames Schulman #define CS42L42_PWR_CTL3			(CS42L42_PAGE_11 + 0x03)
1022c394ca7SJames Schulman #define CS42L42_RING_SENSE_PDNB_SHIFT		1
1032c394ca7SJames Schulman #define CS42L42_RING_SENSE_PDNB_MASK		(1 << \
1042c394ca7SJames Schulman 					CS42L42_RING_SENSE_PDNB_SHIFT)
1052c394ca7SJames Schulman #define CS42L42_VPMON_PDNB_SHIFT		2
1062c394ca7SJames Schulman #define CS42L42_VPMON_PDNB_MASK			(1 << \
1072c394ca7SJames Schulman 					CS42L42_VPMON_PDNB_SHIFT)
1082c394ca7SJames Schulman #define CS42L42_SW_CLK_STP_STAT_SEL_SHIFT	5
1092c394ca7SJames Schulman #define CS42L42_SW_CLK_STP_STAT_SEL_MASK	(3 << \
1102c394ca7SJames Schulman 					CS42L42_SW_CLK_STP_STAT_SEL_SHIFT)
1112c394ca7SJames Schulman 
1122c394ca7SJames Schulman #define CS42L42_RSENSE_CTL1			(CS42L42_PAGE_11 + 0x04)
1132c394ca7SJames Schulman #define CS42L42_RS_TRIM_R_SHIFT			0
1142c394ca7SJames Schulman #define CS42L42_RS_TRIM_R_MASK			(1 << \
1152c394ca7SJames Schulman 					CS42L42_RS_TRIM_R_SHIFT)
1162c394ca7SJames Schulman #define CS42L42_RS_TRIM_T_SHIFT			1
1172c394ca7SJames Schulman #define CS42L42_RS_TRIM_T_MASK			(1 << \
1182c394ca7SJames Schulman 					CS42L42_RS_TRIM_T_SHIFT)
1192c394ca7SJames Schulman #define CS42L42_HPREF_RS_SHIFT			2
1202c394ca7SJames Schulman #define CS42L42_HPREF_RS_MASK			(1 << \
1212c394ca7SJames Schulman 					CS42L42_HPREF_RS_SHIFT)
1222c394ca7SJames Schulman #define CS42L42_HSBIAS_FILT_REF_RS_SHIFT	3
1232c394ca7SJames Schulman #define CS42L42_HSBIAS_FILT_REF_RS_MASK		(1 << \
1242c394ca7SJames Schulman 					CS42L42_HSBIAS_FILT_REF_RS_SHIFT)
1252c394ca7SJames Schulman #define CS42L42_RING_SENSE_PU_HIZ_SHIFT		6
1262c394ca7SJames Schulman #define CS42L42_RING_SENSE_PU_HIZ_MASK		(1 << \
1272c394ca7SJames Schulman 					CS42L42_RING_SENSE_PU_HIZ_SHIFT)
1282c394ca7SJames Schulman 
1292c394ca7SJames Schulman #define CS42L42_RSENSE_CTL2		(CS42L42_PAGE_11 + 0x05)
1302c394ca7SJames Schulman #define CS42L42_TS_RS_GATE_SHIFT	7
1312c394ca7SJames Schulman #define CS42L42_TS_RS_GATE_MAS		(1 << CS42L42_TS_RS_GATE_SHIFT)
1322c394ca7SJames Schulman 
1332c394ca7SJames Schulman #define CS42L42_OSC_SWITCH		(CS42L42_PAGE_11 + 0x07)
1342c394ca7SJames Schulman #define CS42L42_SCLK_PRESENT_SHIFT	0
1352c394ca7SJames Schulman #define CS42L42_SCLK_PRESENT_MASK	(1 << CS42L42_SCLK_PRESENT_SHIFT)
1362c394ca7SJames Schulman 
1372c394ca7SJames Schulman #define CS42L42_OSC_SWITCH_STATUS	(CS42L42_PAGE_11 + 0x09)
1382c394ca7SJames Schulman #define CS42L42_OSC_SW_SEL_STAT_SHIFT	0
1392c394ca7SJames Schulman #define CS42L42_OSC_SW_SEL_STAT_MASK	(3 << CS42L42_OSC_SW_SEL_STAT_SHIFT)
1402c394ca7SJames Schulman #define CS42L42_OSC_PDNB_STAT_SHIFT	2
1412c394ca7SJames Schulman #define CS42L42_OSC_PDNB_STAT_MASK	(1 << CS42L42_OSC_SW_SEL_STAT_SHIFT)
1422c394ca7SJames Schulman 
1432c394ca7SJames Schulman #define CS42L42_RSENSE_CTL3			(CS42L42_PAGE_11 + 0x12)
1442c394ca7SJames Schulman #define CS42L42_RS_RISE_DBNCE_TIME_SHIFT	0
1452c394ca7SJames Schulman #define CS42L42_RS_RISE_DBNCE_TIME_MASK		(7 << \
1462c394ca7SJames Schulman 					CS42L42_RS_RISE_DBNCE_TIME_SHIFT)
1472c394ca7SJames Schulman #define CS42L42_RS_FALL_DBNCE_TIME_SHIFT	3
1482c394ca7SJames Schulman #define CS42L42_RS_FALL_DBNCE_TIME_MASK		(7 << \
1492c394ca7SJames Schulman 					CS42L42_RS_FALL_DBNCE_TIME_SHIFT)
1502c394ca7SJames Schulman #define CS42L42_RS_PU_EN_SHIFT			6
1512c394ca7SJames Schulman #define CS42L42_RS_PU_EN_MASK			(1 << \
1522c394ca7SJames Schulman 					CS42L42_RS_PU_EN_SHIFT)
1532c394ca7SJames Schulman #define CS42L42_RS_INV_SHIFT			7
1542c394ca7SJames Schulman #define CS42L42_RS_INV_MASK			(1 << \
1552c394ca7SJames Schulman 					CS42L42_RS_INV_SHIFT)
1562c394ca7SJames Schulman 
1572c394ca7SJames Schulman #define CS42L42_TSENSE_CTL			(CS42L42_PAGE_11 + 0x13)
1582c394ca7SJames Schulman #define CS42L42_TS_RISE_DBNCE_TIME_SHIFT	0
1592c394ca7SJames Schulman #define CS42L42_TS_RISE_DBNCE_TIME_MASK		(7 << \
1602c394ca7SJames Schulman 					CS42L42_TS_RISE_DBNCE_TIME_SHIFT)
1612c394ca7SJames Schulman #define CS42L42_TS_FALL_DBNCE_TIME_SHIFT	3
1622c394ca7SJames Schulman #define CS42L42_TS_FALL_DBNCE_TIME_MASK		(7 << \
1632c394ca7SJames Schulman 					CS42L42_TS_FALL_DBNCE_TIME_SHIFT)
1642c394ca7SJames Schulman #define CS42L42_TS_INV_SHIFT			7
1652c394ca7SJames Schulman #define CS42L42_TS_INV_MASK			(1 << \
1662c394ca7SJames Schulman 					CS42L42_TS_INV_SHIFT)
1672c394ca7SJames Schulman 
1682c394ca7SJames Schulman #define CS42L42_TSRS_INT_DISABLE	(CS42L42_PAGE_11 + 0x14)
1692c394ca7SJames Schulman #define CS42L42_D_RS_PLUG_DBNC_SHIFT	0
1702c394ca7SJames Schulman #define CS42L42_D_RS_PLUG_DBNC_MASK	(1 << CS42L42_D_RS_PLUG_DBNC_SHIFT)
1712c394ca7SJames Schulman #define CS42L42_D_RS_UNPLUG_DBNC_SHIFT	1
1722c394ca7SJames Schulman #define CS42L42_D_RS_UNPLUG_DBNC_MASK	(1 << CS42L42_D_RS_UNPLUG_DBNC_SHIFT)
1732c394ca7SJames Schulman #define CS42L42_D_TS_PLUG_DBNC_SHIFT	2
1742c394ca7SJames Schulman #define CS42L42_D_TS_PLUG_DBNC_MASK	(1 << CS42L42_D_TS_PLUG_DBNC_SHIFT)
1752c394ca7SJames Schulman #define CS42L42_D_TS_UNPLUG_DBNC_SHIFT	3
1762c394ca7SJames Schulman #define CS42L42_D_TS_UNPLUG_DBNC_MASK	(1 << CS42L42_D_TS_UNPLUG_DBNC_SHIFT)
1772c394ca7SJames Schulman 
1782c394ca7SJames Schulman #define CS42L42_TRSENSE_STATUS		(CS42L42_PAGE_11 + 0x15)
1792c394ca7SJames Schulman #define CS42L42_RS_PLUG_DBNC_SHIFT	0
1802c394ca7SJames Schulman #define CS42L42_RS_PLUG_DBNC_MASK	(1 << CS42L42_RS_PLUG_DBNC_SHIFT)
1812c394ca7SJames Schulman #define CS42L42_RS_UNPLUG_DBNC_SHIFT	1
1822c394ca7SJames Schulman #define CS42L42_RS_UNPLUG_DBNC_MASK	(1 << CS42L42_RS_UNPLUG_DBNC_SHIFT)
1832c394ca7SJames Schulman #define CS42L42_TS_PLUG_DBNC_SHIFT	2
1842c394ca7SJames Schulman #define CS42L42_TS_PLUG_DBNC_MASK	(1 << CS42L42_TS_PLUG_DBNC_SHIFT)
1852c394ca7SJames Schulman #define CS42L42_TS_UNPLUG_DBNC_SHIFT	3
1862c394ca7SJames Schulman #define CS42L42_TS_UNPLUG_DBNC_MASK	(1 << CS42L42_TS_UNPLUG_DBNC_SHIFT)
1872c394ca7SJames Schulman 
1882c394ca7SJames Schulman #define CS42L42_HSDET_CTL1		(CS42L42_PAGE_11 + 0x1F)
1892c394ca7SJames Schulman #define CS42L42_HSDET_COMP1_LVL_SHIFT	0
1902c394ca7SJames Schulman #define CS42L42_HSDET_COMP1_LVL_MASK	(15 << CS42L42_HSDET_COMP1_LVL_SHIFT)
1912c394ca7SJames Schulman #define CS42L42_HSDET_COMP2_LVL_SHIFT	4
1922c394ca7SJames Schulman #define CS42L42_HSDET_COMP2_LVL_MASK	(15 << CS42L42_HSDET_COMP2_LVL_SHIFT)
1932c394ca7SJames Schulman 
194edd6dffdSStefan Binding #define CS42L42_HSDET_COMP1_LVL_VAL	12 /* 1.25V Comparator */
195edd6dffdSStefan Binding #define CS42L42_HSDET_COMP2_LVL_VAL	2  /* 1.75V Comparator */
196edd6dffdSStefan Binding #define CS42L42_HSDET_COMP1_LVL_DEFAULT	7  /* 1V Comparator */
197edd6dffdSStefan Binding #define CS42L42_HSDET_COMP2_LVL_DEFAULT	7  /* 2V Comparator */
198edd6dffdSStefan Binding 
1992c394ca7SJames Schulman #define CS42L42_HSDET_CTL2		(CS42L42_PAGE_11 + 0x20)
2002c394ca7SJames Schulman #define CS42L42_HSDET_AUTO_TIME_SHIFT	0
2012c394ca7SJames Schulman #define CS42L42_HSDET_AUTO_TIME_MASK	(3 << CS42L42_HSDET_AUTO_TIME_SHIFT)
2022c394ca7SJames Schulman #define CS42L42_HSBIAS_REF_SHIFT	3
2032c394ca7SJames Schulman #define CS42L42_HSBIAS_REF_MASK		(1 << CS42L42_HSBIAS_REF_SHIFT)
2042c394ca7SJames Schulman #define CS42L42_HSDET_SET_SHIFT		4
2052c394ca7SJames Schulman #define CS42L42_HSDET_SET_MASK		(3 << CS42L42_HSDET_SET_SHIFT)
2062c394ca7SJames Schulman #define CS42L42_HSDET_CTRL_SHIFT	6
2072c394ca7SJames Schulman #define CS42L42_HSDET_CTRL_MASK		(3 << CS42L42_HSDET_CTRL_SHIFT)
2082c394ca7SJames Schulman 
2092c394ca7SJames Schulman #define CS42L42_HS_SWITCH_CTL		(CS42L42_PAGE_11 + 0x21)
2102c394ca7SJames Schulman #define CS42L42_SW_GNDHS_HS4_SHIFT	0
2112c394ca7SJames Schulman #define CS42L42_SW_GNDHS_HS4_MASK	(1 << CS42L42_SW_GNDHS_HS4_SHIFT)
2122c394ca7SJames Schulman #define CS42L42_SW_GNDHS_HS3_SHIFT	1
2132c394ca7SJames Schulman #define CS42L42_SW_GNDHS_HS3_MASK	(1 << CS42L42_SW_GNDHS_HS3_SHIFT)
2142c394ca7SJames Schulman #define CS42L42_SW_HSB_HS4_SHIFT	2
2152c394ca7SJames Schulman #define CS42L42_SW_HSB_HS4_MASK		(1 << CS42L42_SW_HSB_HS4_SHIFT)
2162c394ca7SJames Schulman #define CS42L42_SW_HSB_HS3_SHIFT	3
2172c394ca7SJames Schulman #define CS42L42_SW_HSB_HS3_MASK		(1 << CS42L42_SW_HSB_HS3_SHIFT)
2182c394ca7SJames Schulman #define CS42L42_SW_HSB_FILT_HS4_SHIFT	4
2192c394ca7SJames Schulman #define CS42L42_SW_HSB_FILT_HS4_MASK	(1 << CS42L42_SW_HSB_FILT_HS4_SHIFT)
2202c394ca7SJames Schulman #define CS42L42_SW_HSB_FILT_HS3_SHIFT	5
2212c394ca7SJames Schulman #define CS42L42_SW_HSB_FILT_HS3_MASK	(1 << CS42L42_SW_HSB_FILT_HS3_SHIFT)
2222c394ca7SJames Schulman #define CS42L42_SW_REF_HS4_SHIFT	6
2232c394ca7SJames Schulman #define CS42L42_SW_REF_HS4_MASK		(1 << CS42L42_SW_REF_HS4_SHIFT)
2242c394ca7SJames Schulman #define CS42L42_SW_REF_HS3_SHIFT	7
2252c394ca7SJames Schulman #define CS42L42_SW_REF_HS3_MASK		(1 << CS42L42_SW_REF_HS3_SHIFT)
2262c394ca7SJames Schulman 
2272c394ca7SJames Schulman #define CS42L42_HS_DET_STATUS		(CS42L42_PAGE_11 + 0x24)
2282c394ca7SJames Schulman #define CS42L42_HSDET_TYPE_SHIFT	0
2292c394ca7SJames Schulman #define CS42L42_HSDET_TYPE_MASK		(3 << CS42L42_HSDET_TYPE_SHIFT)
2302c394ca7SJames Schulman #define CS42L42_HSDET_COMP1_OUT_SHIFT	6
2312c394ca7SJames Schulman #define CS42L42_HSDET_COMP1_OUT_MASK	(1 << CS42L42_HSDET_COMP1_OUT_SHIFT)
2322c394ca7SJames Schulman #define CS42L42_HSDET_COMP2_OUT_SHIFT	7
2332c394ca7SJames Schulman #define CS42L42_HSDET_COMP2_OUT_MASK	(1 << CS42L42_HSDET_COMP2_OUT_SHIFT)
2342c394ca7SJames Schulman #define CS42L42_PLUG_CTIA		0
2352c394ca7SJames Schulman #define CS42L42_PLUG_OMTP		1
2362c394ca7SJames Schulman #define CS42L42_PLUG_HEADPHONE		2
2372c394ca7SJames Schulman #define CS42L42_PLUG_INVALID		3
2382c394ca7SJames Schulman 
23912451814SStefan Binding #define CS42L42_HSDET_SW_COMP1		((0 << CS42L42_SW_GNDHS_HS4_SHIFT) | \
24012451814SStefan Binding 					 (1 << CS42L42_SW_GNDHS_HS3_SHIFT) | \
24112451814SStefan Binding 					 (1 << CS42L42_SW_HSB_HS4_SHIFT) | \
24212451814SStefan Binding 					 (0 << CS42L42_SW_HSB_HS3_SHIFT) | \
24312451814SStefan Binding 					 (0 << CS42L42_SW_HSB_FILT_HS4_SHIFT) | \
24412451814SStefan Binding 					 (1 << CS42L42_SW_HSB_FILT_HS3_SHIFT) | \
24512451814SStefan Binding 					 (0 << CS42L42_SW_REF_HS4_SHIFT) | \
24612451814SStefan Binding 					 (1 << CS42L42_SW_REF_HS3_SHIFT))
24712451814SStefan Binding #define CS42L42_HSDET_SW_COMP2		((1 << CS42L42_SW_GNDHS_HS4_SHIFT) | \
24812451814SStefan Binding 					 (0 << CS42L42_SW_GNDHS_HS3_SHIFT) | \
24912451814SStefan Binding 					 (0 << CS42L42_SW_HSB_HS4_SHIFT) | \
25012451814SStefan Binding 					 (1 << CS42L42_SW_HSB_HS3_SHIFT) | \
25112451814SStefan Binding 					 (1 << CS42L42_SW_HSB_FILT_HS4_SHIFT) | \
25212451814SStefan Binding 					 (0 << CS42L42_SW_HSB_FILT_HS3_SHIFT) | \
25312451814SStefan Binding 					 (1 << CS42L42_SW_REF_HS4_SHIFT) | \
25412451814SStefan Binding 					 (0 << CS42L42_SW_REF_HS3_SHIFT))
25512451814SStefan Binding #define CS42L42_HSDET_SW_TYPE1		((0 << CS42L42_SW_GNDHS_HS4_SHIFT) | \
25612451814SStefan Binding 					 (1 << CS42L42_SW_GNDHS_HS3_SHIFT) | \
25712451814SStefan Binding 					 (1 << CS42L42_SW_HSB_HS4_SHIFT) | \
25812451814SStefan Binding 					 (0 << CS42L42_SW_HSB_HS3_SHIFT) | \
25912451814SStefan Binding 					 (0 << CS42L42_SW_HSB_FILT_HS4_SHIFT) | \
26012451814SStefan Binding 					 (1 << CS42L42_SW_HSB_FILT_HS3_SHIFT) | \
26112451814SStefan Binding 					 (0 << CS42L42_SW_REF_HS4_SHIFT) | \
26212451814SStefan Binding 					 (1 << CS42L42_SW_REF_HS3_SHIFT))
26312451814SStefan Binding #define CS42L42_HSDET_SW_TYPE2		((1 << CS42L42_SW_GNDHS_HS4_SHIFT) | \
26412451814SStefan Binding 					 (0 << CS42L42_SW_GNDHS_HS3_SHIFT) | \
26512451814SStefan Binding 					 (0 << CS42L42_SW_HSB_HS4_SHIFT) | \
26612451814SStefan Binding 					 (1 << CS42L42_SW_HSB_HS3_SHIFT) | \
26712451814SStefan Binding 					 (1 << CS42L42_SW_HSB_FILT_HS4_SHIFT) | \
26812451814SStefan Binding 					 (0 << CS42L42_SW_HSB_FILT_HS3_SHIFT) | \
26912451814SStefan Binding 					 (1 << CS42L42_SW_REF_HS4_SHIFT) | \
27012451814SStefan Binding 					 (0 << CS42L42_SW_REF_HS3_SHIFT))
27112451814SStefan Binding #define CS42L42_HSDET_SW_TYPE3		((1 << CS42L42_SW_GNDHS_HS4_SHIFT) | \
27212451814SStefan Binding 					 (1 << CS42L42_SW_GNDHS_HS3_SHIFT) | \
27312451814SStefan Binding 					 (0 << CS42L42_SW_HSB_HS4_SHIFT) | \
27412451814SStefan Binding 					 (0 << CS42L42_SW_HSB_HS3_SHIFT) | \
27512451814SStefan Binding 					 (1 << CS42L42_SW_HSB_FILT_HS4_SHIFT) | \
27612451814SStefan Binding 					 (1 << CS42L42_SW_HSB_FILT_HS3_SHIFT) | \
27712451814SStefan Binding 					 (1 << CS42L42_SW_REF_HS4_SHIFT) | \
27812451814SStefan Binding 					 (1 << CS42L42_SW_REF_HS3_SHIFT))
27912451814SStefan Binding #define CS42L42_HSDET_SW_TYPE4		((0 << CS42L42_SW_GNDHS_HS4_SHIFT) | \
28012451814SStefan Binding 					 (1 << CS42L42_SW_GNDHS_HS3_SHIFT) | \
28112451814SStefan Binding 					 (1 << CS42L42_SW_HSB_HS4_SHIFT) | \
28212451814SStefan Binding 					 (0 << CS42L42_SW_HSB_HS3_SHIFT) | \
28312451814SStefan Binding 					 (0 << CS42L42_SW_HSB_FILT_HS4_SHIFT) | \
28412451814SStefan Binding 					 (1 << CS42L42_SW_HSB_FILT_HS3_SHIFT) | \
28512451814SStefan Binding 					 (0 << CS42L42_SW_REF_HS4_SHIFT) | \
28612451814SStefan Binding 					 (1 << CS42L42_SW_REF_HS3_SHIFT))
28712451814SStefan Binding 
28812451814SStefan Binding #define CS42L42_HSDET_COMP_TYPE1	1
28912451814SStefan Binding #define CS42L42_HSDET_COMP_TYPE2	2
29012451814SStefan Binding #define CS42L42_HSDET_COMP_TYPE3	0
29112451814SStefan Binding #define CS42L42_HSDET_COMP_TYPE4	3
29212451814SStefan Binding 
2932c394ca7SJames Schulman #define CS42L42_HS_CLAMP_DISABLE	(CS42L42_PAGE_11 + 0x29)
2942c394ca7SJames Schulman #define CS42L42_HS_CLAMP_DISABLE_SHIFT	0
2952c394ca7SJames Schulman #define CS42L42_HS_CLAMP_DISABLE_MASK	(1 << CS42L42_HS_CLAMP_DISABLE_SHIFT)
2962c394ca7SJames Schulman 
2972c394ca7SJames Schulman /* Page 0x12 Clocking Registers */
2982c394ca7SJames Schulman #define CS42L42_MCLK_SRC_SEL		(CS42L42_PAGE_12 + 0x01)
2992c394ca7SJames Schulman #define CS42L42_MCLKDIV_SHIFT		1
3002c394ca7SJames Schulman #define CS42L42_MCLKDIV_MASK		(1 << CS42L42_MCLKDIV_SHIFT)
3012c394ca7SJames Schulman #define CS42L42_MCLK_SRC_SEL_SHIFT	0
3022c394ca7SJames Schulman #define CS42L42_MCLK_SRC_SEL_MASK	(1 << CS42L42_MCLK_SRC_SEL_SHIFT)
3032c394ca7SJames Schulman 
3042c394ca7SJames Schulman #define CS42L42_SPDIF_CLK_CFG		(CS42L42_PAGE_12 + 0x02)
3052c394ca7SJames Schulman #define CS42L42_FSYNC_PW_LOWER		(CS42L42_PAGE_12 + 0x03)
3062c394ca7SJames Schulman 
3072c394ca7SJames Schulman #define CS42L42_FSYNC_PW_UPPER			(CS42L42_PAGE_12 + 0x04)
3082c394ca7SJames Schulman #define CS42L42_FSYNC_PULSE_WIDTH_SHIFT		0
3092c394ca7SJames Schulman #define CS42L42_FSYNC_PULSE_WIDTH_MASK		(0xff << \
3102c394ca7SJames Schulman 					CS42L42_FSYNC_PULSE_WIDTH_SHIFT)
3112c394ca7SJames Schulman 
3122c394ca7SJames Schulman #define CS42L42_FSYNC_P_LOWER		(CS42L42_PAGE_12 + 0x05)
3132c394ca7SJames Schulman 
3142c394ca7SJames Schulman #define CS42L42_FSYNC_P_UPPER		(CS42L42_PAGE_12 + 0x06)
3152c394ca7SJames Schulman #define CS42L42_FSYNC_PERIOD_SHIFT	0
3162c394ca7SJames Schulman #define CS42L42_FSYNC_PERIOD_MASK	(0xff << CS42L42_FSYNC_PERIOD_SHIFT)
3172c394ca7SJames Schulman 
3182c394ca7SJames Schulman #define CS42L42_ASP_CLK_CFG		(CS42L42_PAGE_12 + 0x07)
3192c394ca7SJames Schulman #define CS42L42_ASP_SCLK_EN_SHIFT	5
3202c394ca7SJames Schulman #define CS42L42_ASP_SCLK_EN_MASK	(1 << CS42L42_ASP_SCLK_EN_SHIFT)
3212c394ca7SJames Schulman #define CS42L42_ASP_MASTER_MODE		0x01
3222c394ca7SJames Schulman #define CS42L42_ASP_SLAVE_MODE		0x00
3232c394ca7SJames Schulman #define CS42L42_ASP_MODE_SHIFT		4
3242c394ca7SJames Schulman #define CS42L42_ASP_MODE_MASK		(1 << CS42L42_ASP_MODE_SHIFT)
325e793c965SLucas Tanure #define CS42L42_ASP_SCPOL_SHIFT		2
326e793c965SLucas Tanure #define CS42L42_ASP_SCPOL_MASK		(3 << CS42L42_ASP_SCPOL_SHIFT)
327e793c965SLucas Tanure #define CS42L42_ASP_SCPOL_NOR		3
328e793c965SLucas Tanure #define CS42L42_ASP_LCPOL_SHIFT		0
329e793c965SLucas Tanure #define CS42L42_ASP_LCPOL_MASK		(3 << CS42L42_ASP_LCPOL_SHIFT)
330e793c965SLucas Tanure #define CS42L42_ASP_LCPOL_INV		3
3312c394ca7SJames Schulman 
3322c394ca7SJames Schulman #define CS42L42_ASP_FRM_CFG		(CS42L42_PAGE_12 + 0x08)
3332c394ca7SJames Schulman #define CS42L42_ASP_STP_SHIFT		4
3342c394ca7SJames Schulman #define CS42L42_ASP_STP_MASK		(1 << CS42L42_ASP_STP_SHIFT)
3352c394ca7SJames Schulman #define CS42L42_ASP_5050_SHIFT		3
3362c394ca7SJames Schulman #define CS42L42_ASP_5050_MASK		(1 << CS42L42_ASP_5050_SHIFT)
3372c394ca7SJames Schulman #define CS42L42_ASP_FSD_SHIFT		0
3382c394ca7SJames Schulman #define CS42L42_ASP_FSD_MASK		(7 << CS42L42_ASP_FSD_SHIFT)
3392c394ca7SJames Schulman #define CS42L42_ASP_FSD_0_5		1
3402c394ca7SJames Schulman #define CS42L42_ASP_FSD_1_0		2
3412c394ca7SJames Schulman #define CS42L42_ASP_FSD_1_5		3
3422c394ca7SJames Schulman #define CS42L42_ASP_FSD_2_0		4
3432c394ca7SJames Schulman 
3442c394ca7SJames Schulman #define CS42L42_FS_RATE_EN		(CS42L42_PAGE_12 + 0x09)
3452c394ca7SJames Schulman #define CS42L42_FS_EN_SHIFT		0
3462c394ca7SJames Schulman #define CS42L42_FS_EN_MASK		(0xf << CS42L42_FS_EN_SHIFT)
3472c394ca7SJames Schulman #define CS42L42_FS_EN_IASRC_96K		0x1
3482c394ca7SJames Schulman #define CS42L42_FS_EN_OASRC_96K		0x2
3492c394ca7SJames Schulman 
3502c394ca7SJames Schulman #define CS42L42_IN_ASRC_CLK		(CS42L42_PAGE_12 + 0x0A)
3512c394ca7SJames Schulman #define CS42L42_CLK_IASRC_SEL_SHIFT	0
3522c394ca7SJames Schulman #define CS42L42_CLK_IASRC_SEL_MASK	(1 << CS42L42_CLK_IASRC_SEL_SHIFT)
353fdbd2561SRichard Fitzgerald #define CS42L42_CLK_IASRC_SEL_6		0
3542c394ca7SJames Schulman #define CS42L42_CLK_IASRC_SEL_12	1
3552c394ca7SJames Schulman 
3562c394ca7SJames Schulman #define CS42L42_OUT_ASRC_CLK		(CS42L42_PAGE_12 + 0x0B)
3572c394ca7SJames Schulman #define CS42L42_CLK_OASRC_SEL_SHIFT	0
3582c394ca7SJames Schulman #define CS42L42_CLK_OASRC_SEL_MASK	(1 << CS42L42_CLK_OASRC_SEL_SHIFT)
3592c394ca7SJames Schulman #define CS42L42_CLK_OASRC_SEL_12	1
3602c394ca7SJames Schulman 
3612c394ca7SJames Schulman #define CS42L42_PLL_DIV_CFG1		(CS42L42_PAGE_12 + 0x0C)
3622c394ca7SJames Schulman #define CS42L42_SCLK_PREDIV_SHIFT	0
3632c394ca7SJames Schulman #define CS42L42_SCLK_PREDIV_MASK	(3 << CS42L42_SCLK_PREDIV_SHIFT)
3642c394ca7SJames Schulman 
3652c394ca7SJames Schulman /* Page 0x13 Interrupt Registers */
3662c394ca7SJames Schulman /* Interrupts */
3672c394ca7SJames Schulman #define CS42L42_ADC_OVFL_STATUS		(CS42L42_PAGE_13 + 0x01)
3682c394ca7SJames Schulman #define CS42L42_MIXER_STATUS		(CS42L42_PAGE_13 + 0x02)
3692c394ca7SJames Schulman #define CS42L42_SRC_STATUS		(CS42L42_PAGE_13 + 0x03)
3702c394ca7SJames Schulman #define CS42L42_ASP_RX_STATUS		(CS42L42_PAGE_13 + 0x04)
3712c394ca7SJames Schulman #define CS42L42_ASP_TX_STATUS		(CS42L42_PAGE_13 + 0x05)
3722c394ca7SJames Schulman #define CS42L42_CODEC_STATUS		(CS42L42_PAGE_13 + 0x08)
3732c394ca7SJames Schulman #define CS42L42_DET_INT_STATUS1		(CS42L42_PAGE_13 + 0x09)
3742c394ca7SJames Schulman #define CS42L42_DET_INT_STATUS2		(CS42L42_PAGE_13 + 0x0A)
3752c394ca7SJames Schulman #define CS42L42_SRCPL_INT_STATUS	(CS42L42_PAGE_13 + 0x0B)
3762c394ca7SJames Schulman #define CS42L42_VPMON_STATUS		(CS42L42_PAGE_13 + 0x0D)
3772c394ca7SJames Schulman #define CS42L42_PLL_LOCK_STATUS		(CS42L42_PAGE_13 + 0x0E)
3782c394ca7SJames Schulman #define CS42L42_TSRS_PLUG_STATUS	(CS42L42_PAGE_13 + 0x0F)
3792c394ca7SJames Schulman /* Masks */
3802c394ca7SJames Schulman #define CS42L42_ADC_OVFL_INT_MASK	(CS42L42_PAGE_13 + 0x16)
3812c394ca7SJames Schulman #define CS42L42_ADC_OVFL_SHIFT		0
3822c394ca7SJames Schulman #define CS42L42_ADC_OVFL_MASK		(1 << CS42L42_ADC_OVFL_SHIFT)
3832c394ca7SJames Schulman #define CS42L42_ADC_OVFL_VAL_MASK	CS42L42_ADC_OVFL_MASK
3842c394ca7SJames Schulman 
3852c394ca7SJames Schulman #define CS42L42_MIXER_INT_MASK		(CS42L42_PAGE_13 + 0x17)
3862c394ca7SJames Schulman #define CS42L42_MIX_CHB_OVFL_SHIFT	0
3872c394ca7SJames Schulman #define CS42L42_MIX_CHB_OVFL_MASK	(1 << CS42L42_MIX_CHB_OVFL_SHIFT)
3882c394ca7SJames Schulman #define CS42L42_MIX_CHA_OVFL_SHIFT	1
3892c394ca7SJames Schulman #define CS42L42_MIX_CHA_OVFL_MASK	(1 << CS42L42_MIX_CHA_OVFL_SHIFT)
3902c394ca7SJames Schulman #define CS42L42_EQ_OVFL_SHIFT		2
3912c394ca7SJames Schulman #define CS42L42_EQ_OVFL_MASK		(1 << CS42L42_EQ_OVFL_SHIFT)
3922c394ca7SJames Schulman #define CS42L42_EQ_BIQUAD_OVFL_SHIFT	3
3932c394ca7SJames Schulman #define CS42L42_EQ_BIQUAD_OVFL_MASK	(1 << CS42L42_EQ_BIQUAD_OVFL_SHIFT)
3942c394ca7SJames Schulman #define CS42L42_MIXER_VAL_MASK		(CS42L42_MIX_CHB_OVFL_MASK | \
3952c394ca7SJames Schulman 					CS42L42_MIX_CHA_OVFL_MASK | \
3962c394ca7SJames Schulman 					CS42L42_EQ_OVFL_MASK | \
3972c394ca7SJames Schulman 					CS42L42_EQ_BIQUAD_OVFL_MASK)
3982c394ca7SJames Schulman 
3992c394ca7SJames Schulman #define CS42L42_SRC_INT_MASK		(CS42L42_PAGE_13 + 0x18)
4002c394ca7SJames Schulman #define CS42L42_SRC_ILK_SHIFT		0
4012c394ca7SJames Schulman #define CS42L42_SRC_ILK_MASK		(1 << CS42L42_SRC_ILK_SHIFT)
4022c394ca7SJames Schulman #define CS42L42_SRC_OLK_SHIFT		1
4032c394ca7SJames Schulman #define CS42L42_SRC_OLK_MASK		(1 << CS42L42_SRC_OLK_SHIFT)
4042c394ca7SJames Schulman #define CS42L42_SRC_IUNLK_SHIFT		2
4052c394ca7SJames Schulman #define CS42L42_SRC_IUNLK_MASK		(1 << CS42L42_SRC_IUNLK_SHIFT)
4062c394ca7SJames Schulman #define CS42L42_SRC_OUNLK_SHIFT		3
4072c394ca7SJames Schulman #define CS42L42_SRC_OUNLK_MASK		(1 << CS42L42_SRC_OUNLK_SHIFT)
4082c394ca7SJames Schulman #define CS42L42_SRC_VAL_MASK		(CS42L42_SRC_ILK_MASK | \
4092c394ca7SJames Schulman 					CS42L42_SRC_OLK_MASK | \
4102c394ca7SJames Schulman 					CS42L42_SRC_IUNLK_MASK | \
4112c394ca7SJames Schulman 					CS42L42_SRC_OUNLK_MASK)
4122c394ca7SJames Schulman 
4132c394ca7SJames Schulman #define CS42L42_ASP_RX_INT_MASK		(CS42L42_PAGE_13 + 0x19)
4142c394ca7SJames Schulman #define CS42L42_ASPRX_NOLRCK_SHIFT	0
4152c394ca7SJames Schulman #define CS42L42_ASPRX_NOLRCK_MASK	(1 << CS42L42_ASPRX_NOLRCK_SHIFT)
4162c394ca7SJames Schulman #define CS42L42_ASPRX_EARLY_SHIFT	1
4172c394ca7SJames Schulman #define CS42L42_ASPRX_EARLY_MASK	(1 << CS42L42_ASPRX_EARLY_SHIFT)
4182c394ca7SJames Schulman #define CS42L42_ASPRX_LATE_SHIFT	2
4192c394ca7SJames Schulman #define CS42L42_ASPRX_LATE_MASK		(1 << CS42L42_ASPRX_LATE_SHIFT)
4202c394ca7SJames Schulman #define CS42L42_ASPRX_ERROR_SHIFT	3
4212c394ca7SJames Schulman #define CS42L42_ASPRX_ERROR_MASK	(1 << CS42L42_ASPRX_ERROR_SHIFT)
4222c394ca7SJames Schulman #define CS42L42_ASPRX_OVLD_SHIFT	4
4232c394ca7SJames Schulman #define CS42L42_ASPRX_OVLD_MASK		(1 << CS42L42_ASPRX_OVLD_SHIFT)
4242c394ca7SJames Schulman #define CS42L42_ASP_RX_VAL_MASK		(CS42L42_ASPRX_NOLRCK_MASK | \
4252c394ca7SJames Schulman 					CS42L42_ASPRX_EARLY_MASK | \
4262c394ca7SJames Schulman 					CS42L42_ASPRX_LATE_MASK | \
4272c394ca7SJames Schulman 					CS42L42_ASPRX_ERROR_MASK | \
4282c394ca7SJames Schulman 					CS42L42_ASPRX_OVLD_MASK)
4292c394ca7SJames Schulman 
4302c394ca7SJames Schulman #define CS42L42_ASP_TX_INT_MASK		(CS42L42_PAGE_13 + 0x1A)
4312c394ca7SJames Schulman #define CS42L42_ASPTX_NOLRCK_SHIFT	0
4322c394ca7SJames Schulman #define CS42L42_ASPTX_NOLRCK_MASK	(1 << CS42L42_ASPTX_NOLRCK_SHIFT)
4332c394ca7SJames Schulman #define CS42L42_ASPTX_EARLY_SHIFT	1
4342c394ca7SJames Schulman #define CS42L42_ASPTX_EARLY_MASK	(1 << CS42L42_ASPTX_EARLY_SHIFT)
4352c394ca7SJames Schulman #define CS42L42_ASPTX_LATE_SHIFT	2
4362c394ca7SJames Schulman #define CS42L42_ASPTX_LATE_MASK		(1 << CS42L42_ASPTX_LATE_SHIFT)
4372c394ca7SJames Schulman #define CS42L42_ASPTX_SMERROR_SHIFT	3
4382c394ca7SJames Schulman #define CS42L42_ASPTX_SMERROR_MASK	(1 << CS42L42_ASPTX_SMERROR_SHIFT)
4392c394ca7SJames Schulman #define CS42L42_ASP_TX_VAL_MASK		(CS42L42_ASPTX_NOLRCK_MASK | \
4402c394ca7SJames Schulman 					CS42L42_ASPTX_EARLY_MASK | \
4412c394ca7SJames Schulman 					CS42L42_ASPTX_LATE_MASK | \
4422c394ca7SJames Schulman 					CS42L42_ASPTX_SMERROR_MASK)
4432c394ca7SJames Schulman 
4442c394ca7SJames Schulman #define CS42L42_CODEC_INT_MASK		(CS42L42_PAGE_13 + 0x1B)
4452c394ca7SJames Schulman #define CS42L42_PDN_DONE_SHIFT		0
4462c394ca7SJames Schulman #define CS42L42_PDN_DONE_MASK		(1 << CS42L42_PDN_DONE_SHIFT)
4472c394ca7SJames Schulman #define CS42L42_HSDET_AUTO_DONE_SHIFT	1
4482c394ca7SJames Schulman #define CS42L42_HSDET_AUTO_DONE_MASK	(1 << CS42L42_HSDET_AUTO_DONE_SHIFT)
4492c394ca7SJames Schulman #define CS42L42_CODEC_VAL_MASK		(CS42L42_PDN_DONE_MASK | \
4502c394ca7SJames Schulman 					CS42L42_HSDET_AUTO_DONE_MASK)
4512c394ca7SJames Schulman 
4522c394ca7SJames Schulman #define CS42L42_SRCPL_INT_MASK		(CS42L42_PAGE_13 + 0x1C)
4532c394ca7SJames Schulman #define CS42L42_SRCPL_ADC_LK_SHIFT	0
4542c394ca7SJames Schulman #define CS42L42_SRCPL_ADC_LK_MASK	(1 << CS42L42_SRCPL_ADC_LK_SHIFT)
4552c394ca7SJames Schulman #define CS42L42_SRCPL_DAC_LK_SHIFT	2
4562c394ca7SJames Schulman #define CS42L42_SRCPL_DAC_LK_MASK	(1 << CS42L42_SRCPL_DAC_LK_SHIFT)
4572c394ca7SJames Schulman #define CS42L42_SRCPL_ADC_UNLK_SHIFT	5
4582c394ca7SJames Schulman #define CS42L42_SRCPL_ADC_UNLK_MASK	(1 << CS42L42_SRCPL_ADC_UNLK_SHIFT)
4592c394ca7SJames Schulman #define CS42L42_SRCPL_DAC_UNLK_SHIFT	6
4602c394ca7SJames Schulman #define CS42L42_SRCPL_DAC_UNLK_MASK	(1 << CS42L42_SRCPL_DAC_UNLK_SHIFT)
4612c394ca7SJames Schulman #define CS42L42_SRCPL_VAL_MASK		(CS42L42_SRCPL_ADC_LK_MASK | \
4622c394ca7SJames Schulman 					CS42L42_SRCPL_DAC_LK_MASK | \
4632c394ca7SJames Schulman 					CS42L42_SRCPL_ADC_UNLK_MASK | \
4642c394ca7SJames Schulman 					CS42L42_SRCPL_DAC_UNLK_MASK)
4652c394ca7SJames Schulman 
4662c394ca7SJames Schulman #define CS42L42_VPMON_INT_MASK		(CS42L42_PAGE_13 + 0x1E)
4672c394ca7SJames Schulman #define CS42L42_VPMON_SHIFT		0
4682c394ca7SJames Schulman #define CS42L42_VPMON_MASK		(1 << CS42L42_VPMON_SHIFT)
4692c394ca7SJames Schulman #define CS42L42_VPMON_VAL_MASK		CS42L42_VPMON_MASK
4702c394ca7SJames Schulman 
4712c394ca7SJames Schulman #define CS42L42_PLL_LOCK_INT_MASK	(CS42L42_PAGE_13 + 0x1F)
4722c394ca7SJames Schulman #define CS42L42_PLL_LOCK_SHIFT		0
4732c394ca7SJames Schulman #define CS42L42_PLL_LOCK_MASK		(1 << CS42L42_PLL_LOCK_SHIFT)
4742c394ca7SJames Schulman #define CS42L42_PLL_LOCK_VAL_MASK	CS42L42_PLL_LOCK_MASK
4752c394ca7SJames Schulman 
4762c394ca7SJames Schulman #define CS42L42_TSRS_PLUG_INT_MASK	(CS42L42_PAGE_13 + 0x20)
4772c394ca7SJames Schulman #define CS42L42_RS_PLUG_SHIFT		0
4782c394ca7SJames Schulman #define CS42L42_RS_PLUG_MASK		(1 << CS42L42_RS_PLUG_SHIFT)
4792c394ca7SJames Schulman #define CS42L42_RS_UNPLUG_SHIFT		1
4802c394ca7SJames Schulman #define CS42L42_RS_UNPLUG_MASK		(1 << CS42L42_RS_UNPLUG_SHIFT)
4812c394ca7SJames Schulman #define CS42L42_TS_PLUG_SHIFT		2
4822c394ca7SJames Schulman #define CS42L42_TS_PLUG_MASK		(1 << CS42L42_TS_PLUG_SHIFT)
4832c394ca7SJames Schulman #define CS42L42_TS_UNPLUG_SHIFT		3
4842c394ca7SJames Schulman #define CS42L42_TS_UNPLUG_MASK		(1 << CS42L42_TS_UNPLUG_SHIFT)
4852c394ca7SJames Schulman #define CS42L42_TSRS_PLUG_VAL_MASK	(CS42L42_RS_PLUG_MASK | \
4862c394ca7SJames Schulman 					CS42L42_RS_UNPLUG_MASK | \
4872c394ca7SJames Schulman 					CS42L42_TS_PLUG_MASK | \
4882c394ca7SJames Schulman 					CS42L42_TS_UNPLUG_MASK)
4892c394ca7SJames Schulman #define CS42L42_TS_PLUG			3
4902c394ca7SJames Schulman #define CS42L42_TS_UNPLUG		0
4912c394ca7SJames Schulman #define CS42L42_TS_TRANS		1
4922c394ca7SJames Schulman 
4932c394ca7SJames Schulman /* Page 0x15 Fractional-N PLL Registers */
4942c394ca7SJames Schulman #define CS42L42_PLL_CTL1		(CS42L42_PAGE_15 + 0x01)
4952c394ca7SJames Schulman #define CS42L42_PLL_START_SHIFT		0
4962c394ca7SJames Schulman #define CS42L42_PLL_START_MASK		(1 << CS42L42_PLL_START_SHIFT)
4972c394ca7SJames Schulman 
4982c394ca7SJames Schulman #define CS42L42_PLL_DIV_FRAC0		(CS42L42_PAGE_15 + 0x02)
4992c394ca7SJames Schulman #define CS42L42_PLL_DIV_FRAC_SHIFT	0
5002c394ca7SJames Schulman #define CS42L42_PLL_DIV_FRAC_MASK	(0xff << CS42L42_PLL_DIV_FRAC_SHIFT)
5012c394ca7SJames Schulman 
5022c394ca7SJames Schulman #define CS42L42_PLL_DIV_FRAC1		(CS42L42_PAGE_15 + 0x03)
5032c394ca7SJames Schulman #define CS42L42_PLL_DIV_FRAC2		(CS42L42_PAGE_15 + 0x04)
5042c394ca7SJames Schulman 
5052c394ca7SJames Schulman #define CS42L42_PLL_DIV_INT		(CS42L42_PAGE_15 + 0x05)
5062c394ca7SJames Schulman #define CS42L42_PLL_DIV_INT_SHIFT	0
5072c394ca7SJames Schulman #define CS42L42_PLL_DIV_INT_MASK	(0xff << CS42L42_PLL_DIV_INT_SHIFT)
5082c394ca7SJames Schulman 
5092c394ca7SJames Schulman #define CS42L42_PLL_CTL3		(CS42L42_PAGE_15 + 0x08)
5102c394ca7SJames Schulman #define CS42L42_PLL_DIVOUT_SHIFT	0
5112c394ca7SJames Schulman #define CS42L42_PLL_DIVOUT_MASK		(0xff << CS42L42_PLL_DIVOUT_SHIFT)
5122c394ca7SJames Schulman 
5132c394ca7SJames Schulman #define CS42L42_PLL_CAL_RATIO		(CS42L42_PAGE_15 + 0x0A)
5142c394ca7SJames Schulman #define CS42L42_PLL_CAL_RATIO_SHIFT	0
5152c394ca7SJames Schulman #define CS42L42_PLL_CAL_RATIO_MASK	(0xff << CS42L42_PLL_CAL_RATIO_SHIFT)
5162c394ca7SJames Schulman 
5172c394ca7SJames Schulman #define CS42L42_PLL_CTL4		(CS42L42_PAGE_15 + 0x1B)
5182c394ca7SJames Schulman #define CS42L42_PLL_MODE_SHIFT		0
5192c394ca7SJames Schulman #define CS42L42_PLL_MODE_MASK		(3 << CS42L42_PLL_MODE_SHIFT)
5202c394ca7SJames Schulman 
5212c394ca7SJames Schulman /* Page 0x19 HP Load Detect Registers */
5222c394ca7SJames Schulman #define CS42L42_LOAD_DET_RCSTAT		(CS42L42_PAGE_19 + 0x25)
5232c394ca7SJames Schulman #define CS42L42_RLA_STAT_SHIFT		0
5242c394ca7SJames Schulman #define CS42L42_RLA_STAT_MASK		(3 << CS42L42_RLA_STAT_SHIFT)
5252c394ca7SJames Schulman #define CS42L42_RLA_STAT_15_OHM		0
5262c394ca7SJames Schulman 
5272c394ca7SJames Schulman #define CS42L42_LOAD_DET_DONE		(CS42L42_PAGE_19 + 0x26)
5282c394ca7SJames Schulman #define CS42L42_HPLOAD_DET_DONE_SHIFT	0
5292c394ca7SJames Schulman #define CS42L42_HPLOAD_DET_DONE_MASK	(1 << CS42L42_HPLOAD_DET_DONE_SHIFT)
5302c394ca7SJames Schulman 
5312c394ca7SJames Schulman #define CS42L42_LOAD_DET_EN		(CS42L42_PAGE_19 + 0x27)
5322c394ca7SJames Schulman #define CS42L42_HP_LD_EN_SHIFT		0
5332c394ca7SJames Schulman #define CS42L42_HP_LD_EN_MASK		(1 << CS42L42_HP_LD_EN_SHIFT)
5342c394ca7SJames Schulman 
5352c394ca7SJames Schulman /* Page 0x1B Headset Interface Registers */
5362c394ca7SJames Schulman #define CS42L42_HSBIAS_SC_AUTOCTL		(CS42L42_PAGE_1B + 0x70)
5372c394ca7SJames Schulman #define CS42L42_HSBIAS_SENSE_TRIP_SHIFT		0
5382c394ca7SJames Schulman #define CS42L42_HSBIAS_SENSE_TRIP_MASK		(7 << \
5392c394ca7SJames Schulman 					CS42L42_HSBIAS_SENSE_TRIP_SHIFT)
5402c394ca7SJames Schulman #define CS42L42_TIP_SENSE_EN_SHIFT		5
5412c394ca7SJames Schulman #define CS42L42_TIP_SENSE_EN_MASK		(1 << \
5422c394ca7SJames Schulman 					CS42L42_TIP_SENSE_EN_SHIFT)
5432c394ca7SJames Schulman #define CS42L42_AUTO_HSBIAS_HIZ_SHIFT		6
5442c394ca7SJames Schulman #define CS42L42_AUTO_HSBIAS_HIZ_MASK		(1 << \
5452c394ca7SJames Schulman 					CS42L42_AUTO_HSBIAS_HIZ_SHIFT)
5462c394ca7SJames Schulman #define CS42L42_HSBIAS_SENSE_EN_SHIFT		7
5472c394ca7SJames Schulman #define CS42L42_HSBIAS_SENSE_EN_MASK		(1 << \
5482c394ca7SJames Schulman 					CS42L42_HSBIAS_SENSE_EN_SHIFT)
5492c394ca7SJames Schulman 
5502c394ca7SJames Schulman #define CS42L42_WAKE_CTL		(CS42L42_PAGE_1B + 0x71)
5512c394ca7SJames Schulman #define CS42L42_WAKEB_CLEAR_SHIFT	0
5522c394ca7SJames Schulman #define CS42L42_WAKEB_CLEAR_MASK	(1 << CS42L42_WAKEB_CLEAR_SHIFT)
5532c394ca7SJames Schulman #define CS42L42_WAKEB_MODE_SHIFT	5
5542c394ca7SJames Schulman #define CS42L42_WAKEB_MODE_MASK		(1 << CS42L42_WAKEB_MODE_SHIFT)
5552c394ca7SJames Schulman #define CS42L42_M_HP_WAKE_SHIFT		6
5562c394ca7SJames Schulman #define CS42L42_M_HP_WAKE_MASK		(1 << CS42L42_M_HP_WAKE_SHIFT)
5572c394ca7SJames Schulman #define CS42L42_M_MIC_WAKE_SHIFT	7
5582c394ca7SJames Schulman #define CS42L42_M_MIC_WAKE_MASK		(1 << CS42L42_M_MIC_WAKE_SHIFT)
5592c394ca7SJames Schulman 
5602c394ca7SJames Schulman #define CS42L42_ADC_DISABLE_MUTE		(CS42L42_PAGE_1B + 0x72)
5612c394ca7SJames Schulman #define CS42L42_ADC_DISABLE_S0_MUTE_SHIFT	7
5622c394ca7SJames Schulman #define CS42L42_ADC_DISABLE_S0_MUTE_MASK	(1 << \
5632c394ca7SJames Schulman 					CS42L42_ADC_DISABLE_S0_MUTE_SHIFT)
5642c394ca7SJames Schulman 
5652c394ca7SJames Schulman #define CS42L42_TIPSENSE_CTL			(CS42L42_PAGE_1B + 0x73)
5662c394ca7SJames Schulman #define CS42L42_TIP_SENSE_DEBOUNCE_SHIFT	0
5672c394ca7SJames Schulman #define CS42L42_TIP_SENSE_DEBOUNCE_MASK		(3 << \
5682c394ca7SJames Schulman 					CS42L42_TIP_SENSE_DEBOUNCE_SHIFT)
5692c394ca7SJames Schulman #define CS42L42_TIP_SENSE_INV_SHIFT		5
5702c394ca7SJames Schulman #define CS42L42_TIP_SENSE_INV_MASK		(1 << \
5712c394ca7SJames Schulman 					CS42L42_TIP_SENSE_INV_SHIFT)
5722c394ca7SJames Schulman #define CS42L42_TIP_SENSE_CTRL_SHIFT		6
5732c394ca7SJames Schulman #define CS42L42_TIP_SENSE_CTRL_MASK		(3 << \
5742c394ca7SJames Schulman 					CS42L42_TIP_SENSE_CTRL_SHIFT)
5752c394ca7SJames Schulman 
5762c394ca7SJames Schulman #define CS42L42_MISC_DET_CTL		(CS42L42_PAGE_1B + 0x74)
5772c394ca7SJames Schulman #define CS42L42_PDN_MIC_LVL_DET_SHIFT	0
5782c394ca7SJames Schulman #define CS42L42_PDN_MIC_LVL_DET_MASK	(1 << CS42L42_PDN_MIC_LVL_DET_SHIFT)
5792c394ca7SJames Schulman #define CS42L42_HSBIAS_CTL_SHIFT	1
5802c394ca7SJames Schulman #define CS42L42_HSBIAS_CTL_MASK		(3 << CS42L42_HSBIAS_CTL_SHIFT)
5812c394ca7SJames Schulman #define CS42L42_DETECT_MODE_SHIFT	3
5822c394ca7SJames Schulman #define CS42L42_DETECT_MODE_MASK	(3 << CS42L42_DETECT_MODE_SHIFT)
5832c394ca7SJames Schulman 
5842c394ca7SJames Schulman #define CS42L42_MIC_DET_CTL1		(CS42L42_PAGE_1B + 0x75)
5852c394ca7SJames Schulman #define CS42L42_HS_DET_LEVEL_SHIFT	0
5862c394ca7SJames Schulman #define CS42L42_HS_DET_LEVEL_MASK	(0x3F << CS42L42_HS_DET_LEVEL_SHIFT)
5872c394ca7SJames Schulman #define CS42L42_EVENT_STAT_SEL_SHIFT	6
5882c394ca7SJames Schulman #define CS42L42_EVENT_STAT_SEL_MASK	(1 << CS42L42_EVENT_STAT_SEL_SHIFT)
5892c394ca7SJames Schulman #define CS42L42_LATCH_TO_VP_SHIFT	7
5902c394ca7SJames Schulman #define CS42L42_LATCH_TO_VP_MASK	(1 << CS42L42_LATCH_TO_VP_SHIFT)
5912c394ca7SJames Schulman 
5922c394ca7SJames Schulman #define CS42L42_MIC_DET_CTL2		(CS42L42_PAGE_1B + 0x76)
5932c394ca7SJames Schulman #define CS42L42_DEBOUNCE_TIME_SHIFT	5
5942c394ca7SJames Schulman #define CS42L42_DEBOUNCE_TIME_MASK	(0x07 << CS42L42_DEBOUNCE_TIME_SHIFT)
5952c394ca7SJames Schulman 
5962c394ca7SJames Schulman #define CS42L42_DET_STATUS1		(CS42L42_PAGE_1B + 0x77)
5972c394ca7SJames Schulman #define CS42L42_HSBIAS_HIZ_MODE_SHIFT	6
5982c394ca7SJames Schulman #define CS42L42_HSBIAS_HIZ_MODE_MASK	(1 << CS42L42_HSBIAS_HIZ_MODE_SHIFT)
5992c394ca7SJames Schulman #define CS42L42_TIP_SENSE_SHIFT		7
6002c394ca7SJames Schulman #define CS42L42_TIP_SENSE_MASK		(1 << CS42L42_TIP_SENSE_SHIFT)
6012c394ca7SJames Schulman 
6022c394ca7SJames Schulman #define CS42L42_DET_STATUS2		(CS42L42_PAGE_1B + 0x78)
6032c394ca7SJames Schulman #define CS42L42_SHORT_TRUE_SHIFT	0
6042c394ca7SJames Schulman #define CS42L42_SHORT_TRUE_MASK		(1 << CS42L42_SHORT_TRUE_SHIFT)
6052c394ca7SJames Schulman #define CS42L42_HS_TRUE_SHIFT	1
6062c394ca7SJames Schulman #define CS42L42_HS_TRUE_MASK		(1 << CS42L42_HS_TRUE_SHIFT)
6072c394ca7SJames Schulman 
6082c394ca7SJames Schulman #define CS42L42_DET_INT1_MASK		(CS42L42_PAGE_1B + 0x79)
6092c394ca7SJames Schulman #define CS42L42_TIP_SENSE_UNPLUG_SHIFT	5
6102c394ca7SJames Schulman #define CS42L42_TIP_SENSE_UNPLUG_MASK	(1 << CS42L42_TIP_SENSE_UNPLUG_SHIFT)
6112c394ca7SJames Schulman #define CS42L42_TIP_SENSE_PLUG_SHIFT	6
6122c394ca7SJames Schulman #define CS42L42_TIP_SENSE_PLUG_MASK	(1 << CS42L42_TIP_SENSE_PLUG_SHIFT)
6132c394ca7SJames Schulman #define CS42L42_HSBIAS_SENSE_SHIFT	7
6142c394ca7SJames Schulman #define CS42L42_HSBIAS_SENSE_MASK	(1 << CS42L42_HSBIAS_SENSE_SHIFT)
6152c394ca7SJames Schulman #define CS42L42_DET_INT_VAL1_MASK	(CS42L42_TIP_SENSE_UNPLUG_MASK | \
6162c394ca7SJames Schulman 					CS42L42_TIP_SENSE_PLUG_MASK | \
6172c394ca7SJames Schulman 					CS42L42_HSBIAS_SENSE_MASK)
6182c394ca7SJames Schulman 
6192c394ca7SJames Schulman #define CS42L42_DET_INT2_MASK		(CS42L42_PAGE_1B + 0x7A)
6202c394ca7SJames Schulman #define CS42L42_M_SHORT_DET_SHIFT	0
6212c394ca7SJames Schulman #define CS42L42_M_SHORT_DET_MASK	(1 << \
6222c394ca7SJames Schulman 					CS42L42_M_SHORT_DET_SHIFT)
6232c394ca7SJames Schulman #define CS42L42_M_SHORT_RLS_SHIFT	1
6242c394ca7SJames Schulman #define CS42L42_M_SHORT_RLS_MASK	(1 << \
6252c394ca7SJames Schulman 					CS42L42_M_SHORT_RLS_SHIFT)
6262c394ca7SJames Schulman #define CS42L42_M_HSBIAS_HIZ_SHIFT	2
6272c394ca7SJames Schulman #define CS42L42_M_HSBIAS_HIZ_MASK	(1 << \
6282c394ca7SJames Schulman 					CS42L42_M_HSBIAS_HIZ_SHIFT)
6292c394ca7SJames Schulman #define CS42L42_M_DETECT_FT_SHIFT	6
6302c394ca7SJames Schulman #define CS42L42_M_DETECT_FT_MASK	(1 << \
6312c394ca7SJames Schulman 					CS42L42_M_DETECT_FT_SHIFT)
6322c394ca7SJames Schulman #define CS42L42_M_DETECT_TF_SHIFT	7
6332c394ca7SJames Schulman #define CS42L42_M_DETECT_TF_MASK	(1 << \
6342c394ca7SJames Schulman 					CS42L42_M_DETECT_TF_SHIFT)
6352c394ca7SJames Schulman #define CS42L42_DET_INT_VAL2_MASK	(CS42L42_M_SHORT_DET_MASK | \
6362c394ca7SJames Schulman 					CS42L42_M_SHORT_RLS_MASK | \
6372c394ca7SJames Schulman 					CS42L42_M_HSBIAS_HIZ_MASK | \
6382c394ca7SJames Schulman 					CS42L42_M_DETECT_FT_MASK | \
6392c394ca7SJames Schulman 					CS42L42_M_DETECT_TF_MASK)
6402c394ca7SJames Schulman 
6412c394ca7SJames Schulman /* Page 0x1C Headset Bias Registers */
6422c394ca7SJames Schulman #define CS42L42_HS_BIAS_CTL		(CS42L42_PAGE_1C + 0x03)
6432c394ca7SJames Schulman #define CS42L42_HSBIAS_RAMP_SHIFT	0
6442c394ca7SJames Schulman #define CS42L42_HSBIAS_RAMP_MASK	(3 << CS42L42_HSBIAS_RAMP_SHIFT)
6452c394ca7SJames Schulman #define CS42L42_HSBIAS_PD_SHIFT		4
6462c394ca7SJames Schulman #define CS42L42_HSBIAS_PD_MASK		(1 << CS42L42_HSBIAS_PD_SHIFT)
6472c394ca7SJames Schulman #define CS42L42_HSBIAS_CAPLESS_SHIFT	7
6482c394ca7SJames Schulman #define CS42L42_HSBIAS_CAPLESS_MASK	(1 << CS42L42_HSBIAS_CAPLESS_SHIFT)
6492c394ca7SJames Schulman 
6502c394ca7SJames Schulman /* Page 0x1D ADC Registers */
6512c394ca7SJames Schulman #define CS42L42_ADC_CTL			(CS42L42_PAGE_1D + 0x01)
6522c394ca7SJames Schulman #define CS42L42_ADC_NOTCH_DIS_SHIFT		5
6532c394ca7SJames Schulman #define CS42L42_ADC_FORCE_WEAK_VCM_SHIFT	4
6542c394ca7SJames Schulman #define CS42L42_ADC_INV_SHIFT			2
6552c394ca7SJames Schulman #define CS42L42_ADC_DIG_BOOST_SHIFT		0
6562c394ca7SJames Schulman 
6572c394ca7SJames Schulman #define CS42L42_ADC_VOLUME		(CS42L42_PAGE_1D + 0x03)
6582c394ca7SJames Schulman #define CS42L42_ADC_VOL_SHIFT		0
6592c394ca7SJames Schulman 
6602c394ca7SJames Schulman #define CS42L42_ADC_WNF_HPF_CTL		(CS42L42_PAGE_1D + 0x04)
6612c394ca7SJames Schulman #define CS42L42_ADC_WNF_CF_SHIFT	4
6622c394ca7SJames Schulman #define CS42L42_ADC_WNF_EN_SHIFT	3
6632c394ca7SJames Schulman #define CS42L42_ADC_HPF_CF_SHIFT	1
6642c394ca7SJames Schulman #define CS42L42_ADC_HPF_EN_SHIFT	0
6652c394ca7SJames Schulman 
6662c394ca7SJames Schulman /* Page 0x1F DAC Registers */
6672c394ca7SJames Schulman #define CS42L42_DAC_CTL1		(CS42L42_PAGE_1F + 0x01)
6682c394ca7SJames Schulman #define CS42L42_DACB_INV_SHIFT		1
6692c394ca7SJames Schulman #define CS42L42_DACA_INV_SHIFT		0
6702c394ca7SJames Schulman 
6712c394ca7SJames Schulman #define CS42L42_DAC_CTL2		(CS42L42_PAGE_1F + 0x06)
6722c394ca7SJames Schulman #define CS42L42_HPOUT_PULLDOWN_SHIFT	4
6732c394ca7SJames Schulman #define CS42L42_HPOUT_PULLDOWN_MASK	(15 << CS42L42_HPOUT_PULLDOWN_SHIFT)
6742c394ca7SJames Schulman #define CS42L42_HPOUT_LOAD_SHIFT	3
6752c394ca7SJames Schulman #define CS42L42_HPOUT_LOAD_MASK		(1 << CS42L42_HPOUT_LOAD_SHIFT)
6762c394ca7SJames Schulman #define CS42L42_HPOUT_CLAMP_SHIFT	2
6772c394ca7SJames Schulman #define CS42L42_HPOUT_CLAMP_MASK	(1 << CS42L42_HPOUT_CLAMP_SHIFT)
6782c394ca7SJames Schulman #define CS42L42_DAC_HPF_EN_SHIFT	1
6792c394ca7SJames Schulman #define CS42L42_DAC_HPF_EN_MASK		(1 << CS42L42_DAC_HPF_EN_SHIFT)
6802c394ca7SJames Schulman #define CS42L42_DAC_MON_EN_SHIFT	0
6812c394ca7SJames Schulman #define CS42L42_DAC_MON_EN_MASK		(1 << CS42L42_DAC_MON_EN_SHIFT)
6822c394ca7SJames Schulman 
6832c394ca7SJames Schulman /* Page 0x20 HP CTL Registers */
6842c394ca7SJames Schulman #define CS42L42_HP_CTL			(CS42L42_PAGE_20 + 0x01)
6852c394ca7SJames Schulman #define CS42L42_HP_ANA_BMUTE_SHIFT	3
6862c394ca7SJames Schulman #define CS42L42_HP_ANA_BMUTE_MASK	(1 << CS42L42_HP_ANA_BMUTE_SHIFT)
6872c394ca7SJames Schulman #define CS42L42_HP_ANA_AMUTE_SHIFT	2
6882c394ca7SJames Schulman #define CS42L42_HP_ANA_AMUTE_MASK	(1 << CS42L42_HP_ANA_AMUTE_SHIFT)
6892c394ca7SJames Schulman #define CS42L42_HP_FULL_SCALE_VOL_SHIFT	1
6902c394ca7SJames Schulman #define CS42L42_HP_FULL_SCALE_VOL_MASK	(1 << CS42L42_HP_FULL_SCALE_VOL_SHIFT)
6912c394ca7SJames Schulman 
6922c394ca7SJames Schulman /* Page 0x21 Class H Registers */
6932c394ca7SJames Schulman #define CS42L42_CLASSH_CTL		(CS42L42_PAGE_21 + 0x01)
6942c394ca7SJames Schulman 
6952c394ca7SJames Schulman /* Page 0x23 Mixer Volume Registers */
6962c394ca7SJames Schulman #define CS42L42_MIXER_CHA_VOL		(CS42L42_PAGE_23 + 0x01)
6972c394ca7SJames Schulman #define CS42L42_MIXER_ADC_VOL		(CS42L42_PAGE_23 + 0x02)
6982c394ca7SJames Schulman 
6992c394ca7SJames Schulman #define CS42L42_MIXER_CHB_VOL		(CS42L42_PAGE_23 + 0x03)
7002c394ca7SJames Schulman #define CS42L42_MIXER_CH_VOL_SHIFT	0
7012c394ca7SJames Schulman #define CS42L42_MIXER_CH_VOL_MASK	(0x3f << CS42L42_MIXER_CH_VOL_SHIFT)
7022c394ca7SJames Schulman 
7032c394ca7SJames Schulman /* Page 0x24 EQ Registers */
7042c394ca7SJames Schulman #define CS42L42_EQ_COEF_IN0		(CS42L42_PAGE_24 + 0x01)
7052c394ca7SJames Schulman #define CS42L42_EQ_COEF_IN1		(CS42L42_PAGE_24 + 0x02)
7062c394ca7SJames Schulman #define CS42L42_EQ_COEF_IN2		(CS42L42_PAGE_24 + 0x03)
7072c394ca7SJames Schulman #define CS42L42_EQ_COEF_IN3		(CS42L42_PAGE_24 + 0x04)
7082c394ca7SJames Schulman #define CS42L42_EQ_COEF_RW		(CS42L42_PAGE_24 + 0x06)
7092c394ca7SJames Schulman #define CS42L42_EQ_COEF_OUT0		(CS42L42_PAGE_24 + 0x07)
7102c394ca7SJames Schulman #define CS42L42_EQ_COEF_OUT1		(CS42L42_PAGE_24 + 0x08)
7112c394ca7SJames Schulman #define CS42L42_EQ_COEF_OUT2		(CS42L42_PAGE_24 + 0x09)
7122c394ca7SJames Schulman #define CS42L42_EQ_COEF_OUT3		(CS42L42_PAGE_24 + 0x0A)
7132c394ca7SJames Schulman #define CS42L42_EQ_INIT_STAT		(CS42L42_PAGE_24 + 0x0B)
7142c394ca7SJames Schulman #define CS42L42_EQ_START_FILT		(CS42L42_PAGE_24 + 0x0C)
7152c394ca7SJames Schulman #define CS42L42_EQ_MUTE_CTL		(CS42L42_PAGE_24 + 0x0E)
7162c394ca7SJames Schulman 
7172c394ca7SJames Schulman /* Page 0x25 Audio Port Registers */
7182c394ca7SJames Schulman #define CS42L42_SP_RX_CH_SEL		(CS42L42_PAGE_25 + 0x01)
719e5ada3f6SRichard Fitzgerald #define CS42L42_SP_RX_CHB_SEL_SHIFT	2
720e5ada3f6SRichard Fitzgerald #define CS42L42_SP_RX_CHB_SEL_MASK	(3 << CS42L42_SP_RX_CHB_SEL_SHIFT)
7212c394ca7SJames Schulman 
7222c394ca7SJames Schulman #define CS42L42_SP_RX_ISOC_CTL		(CS42L42_PAGE_25 + 0x02)
7232c394ca7SJames Schulman #define CS42L42_SP_RX_RSYNC_SHIFT	6
7242c394ca7SJames Schulman #define CS42L42_SP_RX_RSYNC_MASK	(1 << CS42L42_SP_RX_RSYNC_SHIFT)
7252c394ca7SJames Schulman #define CS42L42_SP_RX_NSB_POS_SHIFT	3
7262c394ca7SJames Schulman #define CS42L42_SP_RX_NSB_POS_MASK	(7 << CS42L42_SP_RX_NSB_POS_SHIFT)
7272c394ca7SJames Schulman #define CS42L42_SP_RX_NFS_NSBB_SHIFT	2
7282c394ca7SJames Schulman #define CS42L42_SP_RX_NFS_NSBB_MASK	(1 << CS42L42_SP_RX_NFS_NSBB_SHIFT)
7292c394ca7SJames Schulman #define CS42L42_SP_RX_ISOC_MODE_SHIFT	0
7302c394ca7SJames Schulman #define CS42L42_SP_RX_ISOC_MODE_MASK	(3 << CS42L42_SP_RX_ISOC_MODE_SHIFT)
7312c394ca7SJames Schulman 
7322c394ca7SJames Schulman #define CS42L42_SP_RX_FS		(CS42L42_PAGE_25 + 0x03)
7332c394ca7SJames Schulman #define CS42l42_SPDIF_CH_SEL		(CS42L42_PAGE_25 + 0x04)
7342c394ca7SJames Schulman #define CS42L42_SP_TX_ISOC_CTL		(CS42L42_PAGE_25 + 0x05)
7352c394ca7SJames Schulman #define CS42L42_SP_TX_FS		(CS42L42_PAGE_25 + 0x06)
7362c394ca7SJames Schulman #define CS42L42_SPDIF_SW_CTL1		(CS42L42_PAGE_25 + 0x07)
7372c394ca7SJames Schulman 
7382c394ca7SJames Schulman /* Page 0x26 SRC Registers */
7392c394ca7SJames Schulman #define CS42L42_SRC_SDIN_FS		(CS42L42_PAGE_26 + 0x01)
7402c394ca7SJames Schulman #define CS42L42_SRC_SDIN_FS_SHIFT	0
7412c394ca7SJames Schulman #define CS42L42_SRC_SDIN_FS_MASK	(0x1f << CS42L42_SRC_SDIN_FS_SHIFT)
7422c394ca7SJames Schulman 
7432c394ca7SJames Schulman #define CS42L42_SRC_SDOUT_FS		(CS42L42_PAGE_26 + 0x09)
7442c394ca7SJames Schulman 
7452c394ca7SJames Schulman /* Page 0x28 S/PDIF Registers */
7462c394ca7SJames Schulman #define CS42L42_SPDIF_CTL1		(CS42L42_PAGE_28 + 0x01)
7472c394ca7SJames Schulman #define CS42L42_SPDIF_CTL2		(CS42L42_PAGE_28 + 0x02)
7482c394ca7SJames Schulman #define CS42L42_SPDIF_CTL3		(CS42L42_PAGE_28 + 0x03)
7492c394ca7SJames Schulman #define CS42L42_SPDIF_CTL4		(CS42L42_PAGE_28 + 0x04)
7502c394ca7SJames Schulman 
7512c394ca7SJames Schulman /* Page 0x29 Serial Port TX Registers */
7522c394ca7SJames Schulman #define CS42L42_ASP_TX_SZ_EN		(CS42L42_PAGE_29 + 0x01)
753585e7079SLucas Tanure #define CS42L42_ASP_TX_EN_SHIFT		0
7542c394ca7SJames Schulman #define CS42L42_ASP_TX_CH_EN		(CS42L42_PAGE_29 + 0x02)
755585e7079SLucas Tanure #define CS42L42_ASP_TX0_CH2_SHIFT	1
756585e7079SLucas Tanure #define CS42L42_ASP_TX0_CH1_SHIFT	0
757585e7079SLucas Tanure 
7582c394ca7SJames Schulman #define CS42L42_ASP_TX_CH_AP_RES	(CS42L42_PAGE_29 + 0x03)
759585e7079SLucas Tanure #define CS42L42_ASP_TX_CH1_AP_SHIFT	7
760585e7079SLucas Tanure #define CS42L42_ASP_TX_CH1_AP_MASK	(1 << CS42L42_ASP_TX_CH1_AP_SHIFT)
761585e7079SLucas Tanure #define CS42L42_ASP_TX_CH2_AP_SHIFT	6
762585e7079SLucas Tanure #define CS42L42_ASP_TX_CH2_AP_MASK	(1 << CS42L42_ASP_TX_CH2_AP_SHIFT)
763585e7079SLucas Tanure #define CS42L42_ASP_TX_CH2_RES_SHIFT	2
764585e7079SLucas Tanure #define CS42L42_ASP_TX_CH2_RES_MASK	(3 << CS42L42_ASP_TX_CH2_RES_SHIFT)
765585e7079SLucas Tanure #define CS42L42_ASP_TX_CH1_RES_SHIFT	0
766585e7079SLucas Tanure #define CS42L42_ASP_TX_CH1_RES_MASK	(3 << CS42L42_ASP_TX_CH1_RES_SHIFT)
7672c394ca7SJames Schulman #define CS42L42_ASP_TX_CH1_BIT_MSB	(CS42L42_PAGE_29 + 0x04)
7682c394ca7SJames Schulman #define CS42L42_ASP_TX_CH1_BIT_LSB	(CS42L42_PAGE_29 + 0x05)
7692c394ca7SJames Schulman #define CS42L42_ASP_TX_HIZ_DLY_CFG	(CS42L42_PAGE_29 + 0x06)
7702c394ca7SJames Schulman #define CS42L42_ASP_TX_CH2_BIT_MSB	(CS42L42_PAGE_29 + 0x0A)
7712c394ca7SJames Schulman #define CS42L42_ASP_TX_CH2_BIT_LSB	(CS42L42_PAGE_29 + 0x0B)
7722c394ca7SJames Schulman 
7732c394ca7SJames Schulman /* Page 0x2A Serial Port RX Registers */
7742c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_EN		(CS42L42_PAGE_2A + 0x01)
7752c394ca7SJames Schulman #define CS42L42_ASP_RX0_CH_EN_SHIFT	2
7762c394ca7SJames Schulman #define CS42L42_ASP_RX0_CH_EN_MASK	(0xf << CS42L42_ASP_RX0_CH_EN_SHIFT)
777621d65f3SLucas Tanure #define CS42L42_ASP_RX0_CH1_SHIFT	2
778621d65f3SLucas Tanure #define CS42L42_ASP_RX0_CH2_SHIFT	3
779621d65f3SLucas Tanure #define CS42L42_ASP_RX0_CH3_SHIFT	4
780621d65f3SLucas Tanure #define CS42L42_ASP_RX0_CH4_SHIFT	5
7812c394ca7SJames Schulman 
7822c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH1_AP_RES	(CS42L42_PAGE_2A + 0x02)
7832c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH1_BIT_MSB	(CS42L42_PAGE_2A + 0x03)
7842c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH1_BIT_LSB	(CS42L42_PAGE_2A + 0x04)
7852c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH2_AP_RES	(CS42L42_PAGE_2A + 0x05)
7862c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH2_BIT_MSB	(CS42L42_PAGE_2A + 0x06)
7872c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH2_BIT_LSB	(CS42L42_PAGE_2A + 0x07)
7882c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH3_AP_RES	(CS42L42_PAGE_2A + 0x08)
7892c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH3_BIT_MSB	(CS42L42_PAGE_2A + 0x09)
7902c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH3_BIT_LSB	(CS42L42_PAGE_2A + 0x0A)
7912c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH4_AP_RES	(CS42L42_PAGE_2A + 0x0B)
7922c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH4_BIT_MSB	(CS42L42_PAGE_2A + 0x0C)
7932c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI0_CH4_BIT_LSB	(CS42L42_PAGE_2A + 0x0D)
7942c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI1_CH1_AP_RES	(CS42L42_PAGE_2A + 0x0E)
7952c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI1_CH1_BIT_MSB	(CS42L42_PAGE_2A + 0x0F)
7962c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI1_CH1_BIT_LSB	(CS42L42_PAGE_2A + 0x10)
7972c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI1_CH2_AP_RES	(CS42L42_PAGE_2A + 0x11)
7982c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI1_CH2_BIT_MSB	(CS42L42_PAGE_2A + 0x12)
7992c394ca7SJames Schulman #define CS42L42_ASP_RX_DAI1_CH2_BIT_LSB	(CS42L42_PAGE_2A + 0x13)
8002c394ca7SJames Schulman 
8012c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_AP_SHIFT	6
8022c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_AP_MASK	(1 << CS42L42_ASP_RX_CH_AP_SHIFT)
8032c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_AP_LOW	0
8042c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_AP_HI		1
8052c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_RES_SHIFT	0
8062c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_RES_MASK	(3 << CS42L42_ASP_RX_CH_RES_SHIFT)
8072c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_RES_32	3
8082c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_RES_16	1
8092c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_BIT_ST_SHIFT	0
8102c394ca7SJames Schulman #define CS42L42_ASP_RX_CH_BIT_ST_MASK	(0xff << CS42L42_ASP_RX_CH_BIT_ST_SHIFT)
8112c394ca7SJames Schulman 
8122c394ca7SJames Schulman /* Page 0x30 ID Registers */
8132c394ca7SJames Schulman #define CS42L42_SUB_REVID		(CS42L42_PAGE_30 + 0x14)
8142c394ca7SJames Schulman #define CS42L42_MAX_REGISTER		(CS42L42_PAGE_30 + 0x14)
8152c394ca7SJames Schulman 
8162c394ca7SJames Schulman /* Defines for fracturing values spread across multiple registers */
8172c394ca7SJames Schulman #define CS42L42_FRAC0_VAL(val)	((val) & 0x0000ff)
8182c394ca7SJames Schulman #define CS42L42_FRAC1_VAL(val)	(((val) & 0x00ff00) >> 8)
8192c394ca7SJames Schulman #define CS42L42_FRAC2_VAL(val)	(((val) & 0xff0000) >> 16)
8202c394ca7SJames Schulman 
8212c394ca7SJames Schulman #define CS42L42_NUM_SUPPLIES	5
82219325cfeSLucas Tanure #define CS42L42_BOOT_TIME_US	3000
8231c52825cSLucas Tanure #define CS42L42_PLL_DIVOUT_TIME_US	800
8240ea23660SRichard Fitzgerald #define CS42L42_CLOCK_SWITCH_DELAY_US 150
825b7d00776SRichard Fitzgerald #define CS42L42_PLL_LOCK_POLL_US	250
826b7d00776SRichard Fitzgerald #define CS42L42_PLL_LOCK_TIMEOUT_US	1250
8274ae1d8f9SRichard Fitzgerald #define CS42L42_HP_ADC_EN_TIME_US	20000
8282c394ca7SJames Schulman 
8292c394ca7SJames Schulman static const char *const cs42l42_supply_names[CS42L42_NUM_SUPPLIES] = {
8302c394ca7SJames Schulman 	"VA",
8312c394ca7SJames Schulman 	"VP",
8322c394ca7SJames Schulman 	"VCP",
8332c394ca7SJames Schulman 	"VD_FILT",
8342c394ca7SJames Schulman 	"VL",
8352c394ca7SJames Schulman };
8362c394ca7SJames Schulman 
8372c394ca7SJames Schulman struct  cs42l42_private {
8382c394ca7SJames Schulman 	struct regmap *regmap;
8392003c44eSRichard Fitzgerald 	struct device *dev;
8402c394ca7SJames Schulman 	struct regulator_bulk_data supplies[CS42L42_NUM_SUPPLIES];
8412c394ca7SJames Schulman 	struct gpio_desc *reset_gpio;
8422c394ca7SJames Schulman 	struct completion pdn_done;
843c26a5289SLucas Tanure 	struct snd_soc_jack *jack;
844f1040e86SRichard Fitzgerald 	int pll_config;
8452cdba9b0SLucas Tanure 	int bclk;
8462c394ca7SJames Schulman 	u32 sclk;
8472c394ca7SJames Schulman 	u32 srate;
8481c52825cSLucas Tanure 	u8 pll_divout;
8492c394ca7SJames Schulman 	u8 plug_state;
8502c394ca7SJames Schulman 	u8 hs_type;
8512c394ca7SJames Schulman 	u8 ts_inv;
8522c394ca7SJames Schulman 	u8 ts_dbnc_rise;
8532c394ca7SJames Schulman 	u8 ts_dbnc_fall;
8542c394ca7SJames Schulman 	u8 btn_det_init_dbnce;
8552c394ca7SJames Schulman 	u8 btn_det_event_dbnce;
8562c394ca7SJames Schulman 	u8 bias_thresholds[CS42L42_NUM_BIASES];
8572c394ca7SJames Schulman 	u8 hs_bias_ramp_rate;
8582c394ca7SJames Schulman 	u8 hs_bias_ramp_time;
859c9f2e3c3SVitaly Rodionov 	u8 hs_bias_sense_en;
86043fc3571SLucas Tanure 	u8 stream_use;
8614ae1d8f9SRichard Fitzgerald 	bool hp_adc_up_pending;
8622c394ca7SJames Schulman };
8632c394ca7SJames Schulman 
8642c394ca7SJames Schulman #endif /* __CS42L42_H__ */
865