xref: /linux/sound/soc/codecs/cs35l33.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
23333cb71SPaul Handrigan /*
33333cb71SPaul Handrigan  * cs35l33.h -- CS35L33 ALSA SoC audio driver
43333cb71SPaul Handrigan  *
53333cb71SPaul Handrigan  * Copyright 2016 Cirrus Logic, Inc.
63333cb71SPaul Handrigan  *
73333cb71SPaul Handrigan  * Author: Paul Handrigan <paul.handrigan@cirrus.com>
83333cb71SPaul Handrigan  */
93333cb71SPaul Handrigan 
103333cb71SPaul Handrigan #ifndef __CS35L33_H__
113333cb71SPaul Handrigan #define __CS35L33_H__
123333cb71SPaul Handrigan 
133333cb71SPaul Handrigan #define CS35L33_CHIP_ID		0x00035A33
143333cb71SPaul Handrigan #define CS35L33_DEVID_AB	0x01	/* Device ID A & B [RO] */
153333cb71SPaul Handrigan #define CS35L33_DEVID_CD	0x02	/* Device ID C & D [RO] */
163333cb71SPaul Handrigan #define CS35L33_DEVID_E		0x03	/* Device ID E [RO] */
173333cb71SPaul Handrigan #define CS35L33_FAB_ID		0x04	/* Fab ID [RO] */
183333cb71SPaul Handrigan #define CS35L33_REV_ID		0x05	/* Revision ID [RO] */
193333cb71SPaul Handrigan #define CS35L33_PWRCTL1		0x06	/* Power Ctl 1 */
203333cb71SPaul Handrigan #define CS35L33_PWRCTL2		0x07	/* Power Ctl 2 */
213333cb71SPaul Handrigan #define CS35L33_CLK_CTL		0x08	/* Clock Ctl */
223333cb71SPaul Handrigan #define CS35L33_BST_PEAK_CTL	0x09	/* Max Current for Boost */
233333cb71SPaul Handrigan #define CS35L33_PROTECT_CTL	0x0A	/* Amp Protection Parameters */
243333cb71SPaul Handrigan #define CS35L33_BST_CTL1	0x0B	/* Boost Converter CTL1 */
253333cb71SPaul Handrigan #define CS35L33_BST_CTL2	0x0C	/* Boost Converter CTL2 */
263333cb71SPaul Handrigan #define CS35L33_ADSP_CTL	0x0D	/* Serial Port Control */
273333cb71SPaul Handrigan #define CS35L33_ADC_CTL		0x0E	/* ADC Control */
283333cb71SPaul Handrigan #define CS35L33_DAC_CTL		0x0F	/* DAC Control */
293333cb71SPaul Handrigan #define CS35L33_DIG_VOL_CTL	0x10	/* Digital Volume CTL */
303333cb71SPaul Handrigan #define CS35L33_CLASSD_CTL	0x11	/* Class D Amp CTL */
313333cb71SPaul Handrigan #define CS35L33_AMP_CTL		0x12	/* Amp Gain/Protecton Release CTL */
323333cb71SPaul Handrigan #define CS35L33_INT_MASK_1	0x13	/* Interrupt Mask 1 */
333333cb71SPaul Handrigan #define CS35L33_INT_MASK_2	0x14	/* Interrupt Mask 2 */
343333cb71SPaul Handrigan #define CS35L33_INT_STATUS_1	0x15	/* Interrupt Status 1 [RO] */
353333cb71SPaul Handrigan #define CS35L33_INT_STATUS_2	0x16	/* Interrupt Status 2 [RO] */
363333cb71SPaul Handrigan #define CS35L33_DIAG_LOCK	0x17	/* Diagnostic Mode Register Lock */
373333cb71SPaul Handrigan #define CS35L33_DIAG_CTRL_1	0x18	/* Diagnostic Mode Register Control */
383333cb71SPaul Handrigan #define CS35L33_DIAG_CTRL_2	0x19	/* Diagnostic Mode Register Control 2 */
393333cb71SPaul Handrigan #define CS35L33_HG_MEMLDO_CTL	0x23	/* H/G Memory/LDO CTL */
403333cb71SPaul Handrigan #define CS35L33_HG_REL_RATE	0x24	/* H/G Release Rate */
413333cb71SPaul Handrigan #define CS35L33_LDO_DEL		0x25	/* LDO Entry Delay/VPhg Control 1 */
423333cb71SPaul Handrigan #define CS35L33_HG_HEAD		0x29	/* H/G Headroom */
433333cb71SPaul Handrigan #define CS35L33_HG_EN		0x2A	/* H/G Enable/VPhg CNT2 */
443333cb71SPaul Handrigan #define CS35L33_TX_VMON		0x2D	/* TDM TX Control 1 (VMON) */
453333cb71SPaul Handrigan #define CS35L33_TX_IMON		0x2E	/* TDM TX Control 2 (IMON) */
463333cb71SPaul Handrigan #define CS35L33_TX_VPMON	0x2F	/* TDM TX Control 3 (VPMON) */
473333cb71SPaul Handrigan #define CS35L33_TX_VBSTMON	0x30	/* TDM TX Control 4 (VBSTMON) */
483333cb71SPaul Handrigan #define CS35L33_TX_FLAG		0x31	/* TDM TX Control 5 (FLAG) */
493333cb71SPaul Handrigan #define CS35L33_TX_EN1		0x32	/* TDM TX Enable 1 */
503333cb71SPaul Handrigan #define CS35L33_TX_EN2		0x33	/* TDM TX Enable 2 */
513333cb71SPaul Handrigan #define CS35L33_TX_EN3		0x34	/* TDM TX Enable 3 */
523333cb71SPaul Handrigan #define CS35L33_TX_EN4		0x35	/* TDM TX Enable 4 */
533333cb71SPaul Handrigan #define CS35L33_RX_AUD		0x36	/* TDM RX Control 1 */
543333cb71SPaul Handrigan #define CS35L33_RX_SPLY		0x37	/* TDM RX Control 2 */
553333cb71SPaul Handrigan #define CS35L33_RX_ALIVE	0x38	/* TDM RX Control 3 */
563333cb71SPaul Handrigan #define CS35L33_BST_CTL4	0x39	/* Boost Converter Control 4 */
573333cb71SPaul Handrigan #define CS35L33_HG_STATUS	0x3F	/* H/G Status */
583333cb71SPaul Handrigan #define CS35L33_MAX_REGISTER	0x59
593333cb71SPaul Handrigan 
603333cb71SPaul Handrigan #define CS35L33_MCLK_5644	5644800
613333cb71SPaul Handrigan #define CS35L33_MCLK_6144	6144000
623333cb71SPaul Handrigan #define CS35L33_MCLK_6		6000000
633333cb71SPaul Handrigan #define CS35L33_MCLK_11289	11289600
643333cb71SPaul Handrigan #define CS35L33_MCLK_12		12000000
653333cb71SPaul Handrigan #define CS35L33_MCLK_12288	12288000
663333cb71SPaul Handrigan 
673333cb71SPaul Handrigan /* CS35L33_PWRCTL1 */
683333cb71SPaul Handrigan #define CS35L33_PDN_AMP			(1 << 7)
693333cb71SPaul Handrigan #define CS35L33_PDN_BST			(1 << 2)
703333cb71SPaul Handrigan #define CS35L33_PDN_ALL			1
713333cb71SPaul Handrigan 
723333cb71SPaul Handrigan /* CS35L33_PWRCTL2 */
733333cb71SPaul Handrigan #define CS35L33_PDN_VMON_SHIFT		7
743333cb71SPaul Handrigan #define CS35L33_PDN_VMON		(1 << CS35L33_PDN_VMON_SHIFT)
753333cb71SPaul Handrigan #define CS35L33_PDN_IMON_SHIFT		6
763333cb71SPaul Handrigan #define CS35L33_PDN_IMON		(1 << CS35L33_PDN_IMON_SHIFT)
773333cb71SPaul Handrigan #define CS35L33_PDN_VPMON_SHIFT		5
783333cb71SPaul Handrigan #define CS35L33_PDN_VPMON		(1 << CS35L33_PDN_VPMON_SHIFT)
793333cb71SPaul Handrigan #define CS35L33_PDN_VBSTMON_SHIFT	4
803333cb71SPaul Handrigan #define CS35L33_PDN_VBSTMON		(1 << CS35L33_PDN_VBSTMON_SHIFT)
813333cb71SPaul Handrigan #define CS35L33_SDOUT_3ST_I2S_SHIFT	3
823333cb71SPaul Handrigan #define CS35L33_SDOUT_3ST_I2S		(1 << CS35L33_SDOUT_3ST_I2S_SHIFT)
833333cb71SPaul Handrigan #define CS35L33_PDN_SDIN_SHIFT		2
843333cb71SPaul Handrigan #define CS35L33_PDN_SDIN		(1 << CS35L33_PDN_SDIN_SHIFT)
853333cb71SPaul Handrigan #define CS35L33_PDN_TDM_SHIFT		1
863333cb71SPaul Handrigan #define CS35L33_PDN_TDM			(1 << CS35L33_PDN_TDM_SHIFT)
873333cb71SPaul Handrigan 
883333cb71SPaul Handrigan /* CS35L33_CLK_CTL */
893333cb71SPaul Handrigan #define CS35L33_MCLKDIS			(1 << 7)
903333cb71SPaul Handrigan #define CS35L33_MCLKDIV2		(1 << 6)
913333cb71SPaul Handrigan #define CS35L33_SDOUT_3ST_TDM		(1 << 5)
923333cb71SPaul Handrigan #define CS35L33_INT_FS_RATE		(1 << 4)
933333cb71SPaul Handrigan #define CS35L33_ADSP_FS			0xF
943333cb71SPaul Handrigan 
953333cb71SPaul Handrigan /* CS35L33_PROTECT_CTL */
963333cb71SPaul Handrigan #define CS35L33_ALIVE_WD_DIS		(3 << 2)
973333cb71SPaul Handrigan 
983333cb71SPaul Handrigan /* CS35L33_BST_CTL1 */
993333cb71SPaul Handrigan #define CS35L33_BST_CTL_SRC		(1 << 6)
1003333cb71SPaul Handrigan #define CS35L33_BST_CTL_SHIFT		(1 << 5)
1013333cb71SPaul Handrigan #define CS35L33_BST_CTL_MASK		0x3F
1023333cb71SPaul Handrigan 
1033333cb71SPaul Handrigan /* CS35L33_BST_CTL2 */
1043333cb71SPaul Handrigan #define CS35L33_TDM_WD_SEL		(1 << 4)
1053333cb71SPaul Handrigan #define CS35L33_ALIVE_WD_DIS2		(1 << 3)
1063333cb71SPaul Handrigan #define CS35L33_VBST_SR_STEP		0x3
1073333cb71SPaul Handrigan 
1083333cb71SPaul Handrigan /* CS35L33_ADSP_CTL */
1093333cb71SPaul Handrigan #define CS35L33_ADSP_DRIVE		(1 << 7)
1103333cb71SPaul Handrigan #define CS35L33_MS_MASK			(1 << 6)
1113333cb71SPaul Handrigan #define CS35L33_SDIN_LOC		(3 << 4)
1123333cb71SPaul Handrigan #define CS35L33_ALIVE_RATE		0x3
1133333cb71SPaul Handrigan 
1143333cb71SPaul Handrigan /* CS35L33_ADC_CTL */
1153333cb71SPaul Handrigan #define CS35L33_INV_VMON		(1 << 7)
1163333cb71SPaul Handrigan #define CS35L33_INV_IMON		(1 << 6)
1173333cb71SPaul Handrigan #define CS35L33_ADC_NOTCH_DIS		(1 << 5)
1183333cb71SPaul Handrigan #define CS35L33_IMON_SCALE		0xF
1193333cb71SPaul Handrigan 
1203333cb71SPaul Handrigan /* CS35L33_DAC_CTL */
1213333cb71SPaul Handrigan #define CS35L33_INV_DAC			(1 << 7)
1223333cb71SPaul Handrigan #define CS35L33_DAC_NOTCH_DIS		(1 << 5)
1233333cb71SPaul Handrigan #define CS35L33_DIGSFT			(1 << 4)
1243333cb71SPaul Handrigan #define CS35L33_DSR_RATE		0xF
1253333cb71SPaul Handrigan 
1263333cb71SPaul Handrigan /* CS35L33_CLASSD_CTL */
1273333cb71SPaul Handrigan #define CS35L33_AMP_SD			(1 << 6)
1283333cb71SPaul Handrigan #define CS35L33_AMP_DRV_SEL_SRC		(1 << 5)
1293333cb71SPaul Handrigan #define CS35L33_AMP_DRV_SEL_MASK	0x10
1303333cb71SPaul Handrigan #define CS35L33_AMP_DRV_SEL_SHIFT	4
1313333cb71SPaul Handrigan #define CS35L33_AMP_CAL			(1 << 3)
1323333cb71SPaul Handrigan #define CS35L33_GAIN_CHG_ZC_MASK	0x04
1333333cb71SPaul Handrigan #define CS35L33_GAIN_CHG_ZC_SHIFT	2
1343333cb71SPaul Handrigan #define CS35L33_CLASS_D_CTL_MASK	0x3F
1353333cb71SPaul Handrigan 
1363333cb71SPaul Handrigan /* CS35L33_AMP_CTL */
1373333cb71SPaul Handrigan #define CS35L33_AMP_GAIN		0xF0
1383333cb71SPaul Handrigan #define CS35L33_CAL_ERR_RLS		(1 << 3)
1393333cb71SPaul Handrigan #define CS35L33_AMP_SHORT_RLS		(1 << 2)
1403333cb71SPaul Handrigan #define CS35L33_OTW_RLS			(1 << 1)
1413333cb71SPaul Handrigan #define CS35L33_OTE_RLS			1
1423333cb71SPaul Handrigan 
1433333cb71SPaul Handrigan /* CS35L33_INT_MASK_1 */
1443333cb71SPaul Handrigan #define CS35L33_M_CAL_ERR_SHIFT		6
1453333cb71SPaul Handrigan #define CS35L33_M_CAL_ERR		(1 << CS35L33_M_CAL_ERR_SHIFT)
1463333cb71SPaul Handrigan #define CS35L33_M_ALIVE_ERR_SHIFT	5
1473333cb71SPaul Handrigan #define CS35L33_M_ALIVE_ERR		(1 << CS35L33_M_ALIVE_ERR_SHIFT)
1483333cb71SPaul Handrigan #define CS35L33_M_AMP_SHORT_SHIFT	2
1493333cb71SPaul Handrigan #define CS35L33_M_AMP_SHORT		(1 << CS35L33_M_AMP_SHORT_SHIFT)
1503333cb71SPaul Handrigan #define CS35L33_M_OTW_SHIFT		1
1513333cb71SPaul Handrigan #define CS35L33_M_OTW			(1 << CS35L33_M_OTW_SHIFT)
1523333cb71SPaul Handrigan #define CS35L33_M_OTE_SHIFT		0
1533333cb71SPaul Handrigan #define CS35L33_M_OTE			(1 << CS35L33_M_OTE_SHIFT)
1543333cb71SPaul Handrigan 
1553333cb71SPaul Handrigan /* CS35L33_INT_STATUS_1 */
1563333cb71SPaul Handrigan #define CS35L33_CAL_ERR			(1 << 6)
1573333cb71SPaul Handrigan #define CS35L33_ALIVE_ERR		(1 << 5)
1583333cb71SPaul Handrigan #define CS35L33_ADSPCLK_ERR		(1 << 4)
1593333cb71SPaul Handrigan #define CS35L33_MCLK_ERR		(1 << 3)
1603333cb71SPaul Handrigan #define CS35L33_AMP_SHORT		(1 << 2)
1613333cb71SPaul Handrigan #define CS35L33_OTW			(1 << 1)
1623333cb71SPaul Handrigan #define CS35L33_OTE			(1 << 0)
1633333cb71SPaul Handrigan 
1643333cb71SPaul Handrigan /* CS35L33_INT_STATUS_2 */
1653333cb71SPaul Handrigan #define CS35L33_VMON_OVFL		(1 << 7)
1663333cb71SPaul Handrigan #define CS35L33_IMON_OVFL		(1 << 6)
1673333cb71SPaul Handrigan #define CS35L33_VPMON_OVFL		(1 << 5)
1683333cb71SPaul Handrigan #define CS35L33_VBSTMON_OVFL		(1 << 4)
1693333cb71SPaul Handrigan #define CS35L33_PDN_DONE		1
1703333cb71SPaul Handrigan 
1713333cb71SPaul Handrigan /* CS35L33_BST_CTL4 */
1723333cb71SPaul Handrigan #define CS35L33_BST_RGS			0x70
1733333cb71SPaul Handrigan #define CS35L33_BST_COEFF3		0xF
1743333cb71SPaul Handrigan 
1753333cb71SPaul Handrigan /* CS35L33_HG_MEMLDO_CTL */
1763333cb71SPaul Handrigan #define CS35L33_MEM_DEPTH_SHIFT		5
1773333cb71SPaul Handrigan #define CS35L33_MEM_DEPTH_MASK		(0x3 << CS35L33_MEM_DEPTH_SHIFT)
1783333cb71SPaul Handrigan #define CS35L33_LDO_THLD_SHIFT		1
1793333cb71SPaul Handrigan #define CS35L33_LDO_THLD_MASK		(0xF << CS35L33_LDO_THLD_SHIFT)
1803333cb71SPaul Handrigan #define CS35L33_LDO_DISABLE_SHIFT	0
1813333cb71SPaul Handrigan #define CS35L33_LDO_DISABLE_MASK	(0x1 << CS35L33_LDO_DISABLE_SHIFT)
1823333cb71SPaul Handrigan 
1833333cb71SPaul Handrigan /* CS35L33_LDO_DEL */
1843333cb71SPaul Handrigan #define CS35L33_VP_HG_VA_SHIFT		5
1853333cb71SPaul Handrigan #define CS35L33_VP_HG_VA_MASK		(0x7 << CS35L33_VP_HG_VA_SHIFT)
1863333cb71SPaul Handrigan #define CS35L33_LDO_ENTRY_DELAY_SHIFT	2
1873333cb71SPaul Handrigan #define CS35L33_LDO_ENTRY_DELAY_MASK	(0x7 << CS35L33_LDO_ENTRY_DELAY_SHIFT)
1883333cb71SPaul Handrigan #define CS35L33_VP_HG_RATE_SHIFT	0
1893333cb71SPaul Handrigan #define CS35L33_VP_HG_RATE_MASK		(0x3 << CS35L33_VP_HG_RATE_SHIFT)
1903333cb71SPaul Handrigan 
1913333cb71SPaul Handrigan /* CS35L33_HG_HEAD */
1923333cb71SPaul Handrigan #define CS35L33_HD_RM_SHIFT		0
1933333cb71SPaul Handrigan #define CS35L33_HD_RM_MASK		(0x7F << CS35L33_HD_RM_SHIFT)
1943333cb71SPaul Handrigan 
1953333cb71SPaul Handrigan /* CS35L33_HG_EN */
1963333cb71SPaul Handrigan #define CS35L33_CLASS_HG_ENA_SHIFT	7
1973333cb71SPaul Handrigan #define CS35L33_CLASS_HG_EN_MASK	(0x1 << CS35L33_CLASS_HG_ENA_SHIFT)
1983333cb71SPaul Handrigan #define CS35L33_VP_HG_AUTO_SHIFT	6
1993333cb71SPaul Handrigan #define CS35L33_VP_HG_AUTO_MASK		(0x1 << 6)
2003333cb71SPaul Handrigan #define CS35L33_VP_HG_SHIFT		0
2013333cb71SPaul Handrigan #define CS35L33_VP_HG_MASK		(0x1F << CS35L33_VP_HG_SHIFT)
2023333cb71SPaul Handrigan 
2033333cb71SPaul Handrigan #define CS35L33_RATES (SNDRV_PCM_RATE_8000_48000)
2043333cb71SPaul Handrigan #define CS35L33_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
2053333cb71SPaul Handrigan 			SNDRV_PCM_FMTBIT_S24_LE)
2063333cb71SPaul Handrigan 
2073333cb71SPaul Handrigan /* CS35L33_{RX,TX}_X */
2083333cb71SPaul Handrigan #define CS35L33_X_STATE_SHIFT		7
2093333cb71SPaul Handrigan #define CS35L33_X_STATE			(1 << CS35L33_X_STATE_SHIFT)
2103333cb71SPaul Handrigan #define CS35L33_X_LOC_SHIFT		0
2113333cb71SPaul Handrigan #define CS35L33_X_LOC			(0x1F << CS35L33_X_LOC_SHIFT)
2123333cb71SPaul Handrigan 
2133333cb71SPaul Handrigan /* CS35L33_RX_AUD */
2143333cb71SPaul Handrigan #define CS35L33_AUDIN_RX_DEPTH_SHIFT	5
2153333cb71SPaul Handrigan #define CS35L33_AUDIN_RX_DEPTH		(0x7 << CS35L33_AUDIN_RX_DEPTH_SHIFT)
2163333cb71SPaul Handrigan 
2173333cb71SPaul Handrigan #endif
218