xref: /linux/sound/soc/codecs/twl6040.h (revision a2d2362edf9f068bdee7d0411e0603b322f8415d)
18ecbabd9SMisael Lopez Cruz /*
28ecbabd9SMisael Lopez Cruz  * ALSA SoC TWL6040 codec driver
38ecbabd9SMisael Lopez Cruz  *
48ecbabd9SMisael Lopez Cruz  * Author:	Misael Lopez Cruz <x0052729@ti.com>
58ecbabd9SMisael Lopez Cruz  *
68ecbabd9SMisael Lopez Cruz  * This program is free software; you can redistribute it and/or
78ecbabd9SMisael Lopez Cruz  * modify it under the terms of the GNU General Public License
88ecbabd9SMisael Lopez Cruz  * version 2 as published by the Free Software Foundation.
98ecbabd9SMisael Lopez Cruz  *
108ecbabd9SMisael Lopez Cruz  * This program is distributed in the hope that it will be useful, but
118ecbabd9SMisael Lopez Cruz  * WITHOUT ANY WARRANTY; without even the implied warranty of
128ecbabd9SMisael Lopez Cruz  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
138ecbabd9SMisael Lopez Cruz  * General Public License for more details.
148ecbabd9SMisael Lopez Cruz  *
158ecbabd9SMisael Lopez Cruz  * You should have received a copy of the GNU General Public License
168ecbabd9SMisael Lopez Cruz  * along with this program; if not, write to the Free Software
178ecbabd9SMisael Lopez Cruz  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
188ecbabd9SMisael Lopez Cruz  * 02110-1301 USA
198ecbabd9SMisael Lopez Cruz  *
208ecbabd9SMisael Lopez Cruz  */
218ecbabd9SMisael Lopez Cruz 
228ecbabd9SMisael Lopez Cruz #ifndef __TWL6040_H__
238ecbabd9SMisael Lopez Cruz #define __TWL6040_H__
248ecbabd9SMisael Lopez Cruz 
258ecbabd9SMisael Lopez Cruz #define TWL6040_REG_ASICID		0x01
268ecbabd9SMisael Lopez Cruz #define TWL6040_REG_ASICREV		0x02
278ecbabd9SMisael Lopez Cruz #define TWL6040_REG_INTID		0x03
288ecbabd9SMisael Lopez Cruz #define TWL6040_REG_INTMR		0x04
298ecbabd9SMisael Lopez Cruz #define TWL6040_REG_NCPCTL		0x05
308ecbabd9SMisael Lopez Cruz #define TWL6040_REG_LDOCTL		0x06
318ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HPPLLCTL		0x07
328ecbabd9SMisael Lopez Cruz #define TWL6040_REG_LPPLLCTL		0x08
338ecbabd9SMisael Lopez Cruz #define TWL6040_REG_LPPLLDIV		0x09
348ecbabd9SMisael Lopez Cruz #define TWL6040_REG_AMICBCTL		0x0A
358ecbabd9SMisael Lopez Cruz #define TWL6040_REG_DMICBCTL		0x0B
368ecbabd9SMisael Lopez Cruz #define TWL6040_REG_MICLCTL		0x0C
378ecbabd9SMisael Lopez Cruz #define TWL6040_REG_MICRCTL		0x0D
388ecbabd9SMisael Lopez Cruz #define TWL6040_REG_MICGAIN		0x0E
398ecbabd9SMisael Lopez Cruz #define TWL6040_REG_LINEGAIN		0x0F
408ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HSLCTL		0x10
418ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HSRCTL		0x11
428ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HSGAIN		0x12
438ecbabd9SMisael Lopez Cruz #define TWL6040_REG_EARCTL		0x13
448ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HFLCTL		0x14
458ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HFLGAIN		0x15
468ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HFRCTL		0x16
478ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HFRGAIN		0x17
488ecbabd9SMisael Lopez Cruz #define TWL6040_REG_VIBCTLL		0x18
498ecbabd9SMisael Lopez Cruz #define TWL6040_REG_VIBDATL		0x19
508ecbabd9SMisael Lopez Cruz #define TWL6040_REG_VIBCTLR		0x1A
518ecbabd9SMisael Lopez Cruz #define TWL6040_REG_VIBDATR		0x1B
528ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HKCTL1		0x1C
538ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HKCTL2		0x1D
548ecbabd9SMisael Lopez Cruz #define TWL6040_REG_GPOCTL		0x1E
558ecbabd9SMisael Lopez Cruz #define TWL6040_REG_ALB			0x1F
568ecbabd9SMisael Lopez Cruz #define TWL6040_REG_DLB			0x20
578ecbabd9SMisael Lopez Cruz #define TWL6040_REG_TRIM1		0x28
588ecbabd9SMisael Lopez Cruz #define TWL6040_REG_TRIM2		0x29
598ecbabd9SMisael Lopez Cruz #define TWL6040_REG_TRIM3		0x2A
608ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HSOTRIM		0x2B
618ecbabd9SMisael Lopez Cruz #define TWL6040_REG_HFOTRIM		0x2C
628ecbabd9SMisael Lopez Cruz #define TWL6040_REG_ACCCTL		0x2D
638ecbabd9SMisael Lopez Cruz #define TWL6040_REG_STATUS		0x2E
648ecbabd9SMisael Lopez Cruz 
658ecbabd9SMisael Lopez Cruz #define TWL6040_CACHEREGNUM		(TWL6040_REG_STATUS + 1)
668ecbabd9SMisael Lopez Cruz 
678ecbabd9SMisael Lopez Cruz #define TWL6040_VIOREGNUM		18
688ecbabd9SMisael Lopez Cruz #define TWL6040_VDDREGNUM		21
698ecbabd9SMisael Lopez Cruz 
708ecbabd9SMisael Lopez Cruz /* INTID (0x03) fields */
718ecbabd9SMisael Lopez Cruz 
728ecbabd9SMisael Lopez Cruz #define TWL6040_THINT			0x01
738ecbabd9SMisael Lopez Cruz #define TWL6040_PLUGINT			0x02
748ecbabd9SMisael Lopez Cruz #define TWL6040_UNPLUGINT		0x04
758ecbabd9SMisael Lopez Cruz #define TWL6040_HOOKINT			0x08
768ecbabd9SMisael Lopez Cruz #define TWL6040_HFINT			0x10
778ecbabd9SMisael Lopez Cruz #define TWL6040_VIBINT			0x20
788ecbabd9SMisael Lopez Cruz #define TWL6040_READYINT		0x40
798ecbabd9SMisael Lopez Cruz 
808ecbabd9SMisael Lopez Cruz /* INTMR (0x04) fields */
818ecbabd9SMisael Lopez Cruz 
828ecbabd9SMisael Lopez Cruz #define TWL6040_READYMSK		0x40
838ecbabd9SMisael Lopez Cruz #define TWL6040_ALLINT_MSK		0x7B
848ecbabd9SMisael Lopez Cruz 
858ecbabd9SMisael Lopez Cruz /* NCPCTL (0x05) fields */
868ecbabd9SMisael Lopez Cruz 
878ecbabd9SMisael Lopez Cruz #define TWL6040_NCPENA			0x01
888ecbabd9SMisael Lopez Cruz #define TWL6040_NCPOPEN			0x40
898ecbabd9SMisael Lopez Cruz 
908ecbabd9SMisael Lopez Cruz /* LDOCTL (0x06) fields */
918ecbabd9SMisael Lopez Cruz 
928ecbabd9SMisael Lopez Cruz #define TWL6040_LSLDOENA		0x01
938ecbabd9SMisael Lopez Cruz #define TWL6040_HSLDOENA		0x04
948ecbabd9SMisael Lopez Cruz #define TWL6040_REFENA			0x40
958ecbabd9SMisael Lopez Cruz #define TWL6040_OSCENA			0x80
968ecbabd9SMisael Lopez Cruz 
978ecbabd9SMisael Lopez Cruz /* HPPLLCTL (0x07) fields */
988ecbabd9SMisael Lopez Cruz 
998ecbabd9SMisael Lopez Cruz #define TWL6040_HPLLENA			0x01
1008ecbabd9SMisael Lopez Cruz #define TWL6040_HPLLRST			0x02
1018ecbabd9SMisael Lopez Cruz #define TWL6040_HPLLBP			0x04
1028ecbabd9SMisael Lopez Cruz #define TWL6040_HPLLSQRENA		0x08
1038ecbabd9SMisael Lopez Cruz #define TWL6040_HPLLSQRBP		0x10
1048ecbabd9SMisael Lopez Cruz #define TWL6040_MCLK_12000KHZ		(0 << 5)
1058ecbabd9SMisael Lopez Cruz #define TWL6040_MCLK_19200KHZ		(1 << 5)
1068ecbabd9SMisael Lopez Cruz #define TWL6040_MCLK_26000KHZ		(2 << 5)
1078ecbabd9SMisael Lopez Cruz #define TWL6040_MCLK_38400KHZ		(3 << 5)
1088ecbabd9SMisael Lopez Cruz #define TWL6040_MCLK_MSK		0x60
1098ecbabd9SMisael Lopez Cruz 
1108ecbabd9SMisael Lopez Cruz /* LPPLLCTL (0x08) fields */
1118ecbabd9SMisael Lopez Cruz 
1128ecbabd9SMisael Lopez Cruz #define TWL6040_LPLLENA			0x01
1138ecbabd9SMisael Lopez Cruz #define TWL6040_LPLLRST			0x02
1148ecbabd9SMisael Lopez Cruz #define TWL6040_LPLLSEL			0x04
1158ecbabd9SMisael Lopez Cruz #define TWL6040_LPLLFIN			0x08
1168ecbabd9SMisael Lopez Cruz #define TWL6040_HPLLSEL			0x10
1178ecbabd9SMisael Lopez Cruz 
1188ecbabd9SMisael Lopez Cruz /* HSLCTL (0x10) fields */
1198ecbabd9SMisael Lopez Cruz 
1208ecbabd9SMisael Lopez Cruz #define TWL6040_HSDACMODEL		0x02
1218ecbabd9SMisael Lopez Cruz #define TWL6040_HSDRVMODEL		0x08
1228ecbabd9SMisael Lopez Cruz 
1238ecbabd9SMisael Lopez Cruz /* HSRCTL (0x11) fields */
1248ecbabd9SMisael Lopez Cruz 
1258ecbabd9SMisael Lopez Cruz #define TWL6040_HSDACMODER		0x02
1268ecbabd9SMisael Lopez Cruz #define TWL6040_HSDRVMODER		0x08
1278ecbabd9SMisael Lopez Cruz 
1288ecbabd9SMisael Lopez Cruz /* ACCCTL (0x2D) fields */
1298ecbabd9SMisael Lopez Cruz 
1308ecbabd9SMisael Lopez Cruz #define TWL6040_RESETSPLIT		0x04
1318ecbabd9SMisael Lopez Cruz 
1328ecbabd9SMisael Lopez Cruz #define TWL6040_SYSCLK_SEL_LPPLL	1
1338ecbabd9SMisael Lopez Cruz #define TWL6040_SYSCLK_SEL_HPPLL	2
1348ecbabd9SMisael Lopez Cruz 
1358ecbabd9SMisael Lopez Cruz #define TWL6040_HPPLL_ID		1
1368ecbabd9SMisael Lopez Cruz #define TWL6040_LPPLL_ID		2
1378ecbabd9SMisael Lopez Cruz 
138*a2d2362eSJorge Eduardo Candelaria /* STATUS (0x2E) fields */
139*a2d2362eSJorge Eduardo Candelaria 
140*a2d2362eSJorge Eduardo Candelaria #define TWL6040_PLUGCOMP		0x02
141*a2d2362eSJorge Eduardo Candelaria 
142*a2d2362eSJorge Eduardo Candelaria void twl6040_hs_jack_detect(struct snd_soc_codec *codec,
143*a2d2362eSJorge Eduardo Candelaria 			    struct snd_soc_jack *jack, int report);
144*a2d2362eSJorge Eduardo Candelaria 
1458ecbabd9SMisael Lopez Cruz #endif /* End of __TWL6040_H__ */
146