xref: /linux/sound/soc/codecs/ics43432.c (revision 7c8d90592165601fc7f133e72f06d7348d476579)
13b7ce997SRicard Wanderlof /*
23b7ce997SRicard Wanderlof  * I2S MEMS microphone driver for InvenSense ICS-43432
33b7ce997SRicard Wanderlof  *
43b7ce997SRicard Wanderlof  * - Non configurable.
53b7ce997SRicard Wanderlof  * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
63b7ce997SRicard Wanderlof  *
73b7ce997SRicard Wanderlof  * Copyright (c) 2015 Axis Communications AB
83b7ce997SRicard Wanderlof  *
92f38bc88SAxel Lin  * Licensed under GPL v2.
103b7ce997SRicard Wanderlof  */
113b7ce997SRicard Wanderlof 
123b7ce997SRicard Wanderlof #include <linux/module.h>
133b7ce997SRicard Wanderlof #include <linux/init.h>
143b7ce997SRicard Wanderlof #include <linux/slab.h>
153b7ce997SRicard Wanderlof #include <sound/core.h>
163b7ce997SRicard Wanderlof #include <sound/pcm.h>
173b7ce997SRicard Wanderlof #include <sound/pcm_params.h>
183b7ce997SRicard Wanderlof #include <sound/soc.h>
193b7ce997SRicard Wanderlof #include <sound/initval.h>
203b7ce997SRicard Wanderlof #include <sound/tlv.h>
213b7ce997SRicard Wanderlof 
223b7ce997SRicard Wanderlof #define ICS43432_RATE_MIN 7190 /* Hz, from data sheet */
233b7ce997SRicard Wanderlof #define ICS43432_RATE_MAX 52800  /* Hz, from data sheet */
243b7ce997SRicard Wanderlof 
253b7ce997SRicard Wanderlof #define ICS43432_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32)
263b7ce997SRicard Wanderlof 
273b7ce997SRicard Wanderlof static struct snd_soc_dai_driver ics43432_dai = {
283b7ce997SRicard Wanderlof 	.name = "ics43432-hifi",
293b7ce997SRicard Wanderlof 	.capture = {
303b7ce997SRicard Wanderlof 		.stream_name = "Capture",
313b7ce997SRicard Wanderlof 		.channels_min = 1,
323b7ce997SRicard Wanderlof 		.channels_max = 2,
333b7ce997SRicard Wanderlof 		.rate_min = ICS43432_RATE_MIN,
343b7ce997SRicard Wanderlof 		.rate_max = ICS43432_RATE_MAX,
353b7ce997SRicard Wanderlof 		.rates = SNDRV_PCM_RATE_CONTINUOUS,
363b7ce997SRicard Wanderlof 		.formats = ICS43432_FORMATS,
373b7ce997SRicard Wanderlof 	},
383b7ce997SRicard Wanderlof };
393b7ce997SRicard Wanderlof 
40*7c8d9059SKuninori Morimoto static const struct snd_soc_component_driver ics43432_component_driver = {
41*7c8d9059SKuninori Morimoto 	.idle_bias_on		= 1,
42*7c8d9059SKuninori Morimoto 	.use_pmdown_time	= 1,
43*7c8d9059SKuninori Morimoto 	.endianness		= 1,
44*7c8d9059SKuninori Morimoto 	.non_legacy_dai_naming	= 1,
453b7ce997SRicard Wanderlof };
463b7ce997SRicard Wanderlof 
473b7ce997SRicard Wanderlof static int ics43432_probe(struct platform_device *pdev)
483b7ce997SRicard Wanderlof {
49*7c8d9059SKuninori Morimoto 	return devm_snd_soc_register_component(&pdev->dev,
50*7c8d9059SKuninori Morimoto 			&ics43432_component_driver,
513b7ce997SRicard Wanderlof 			&ics43432_dai, 1);
523b7ce997SRicard Wanderlof }
533b7ce997SRicard Wanderlof 
543b7ce997SRicard Wanderlof #ifdef CONFIG_OF
553b7ce997SRicard Wanderlof static const struct of_device_id ics43432_ids[] = {
563b7ce997SRicard Wanderlof 	{ .compatible = "invensense,ics43432", },
573b7ce997SRicard Wanderlof 	{ }
583b7ce997SRicard Wanderlof };
59b37bfdaaSRicard Wanderlof MODULE_DEVICE_TABLE(of, ics43432_ids);
603b7ce997SRicard Wanderlof #endif
613b7ce997SRicard Wanderlof 
623b7ce997SRicard Wanderlof static struct platform_driver ics43432_driver = {
633b7ce997SRicard Wanderlof 	.driver = {
643b7ce997SRicard Wanderlof 		.name = "ics43432",
653b7ce997SRicard Wanderlof 		.of_match_table = of_match_ptr(ics43432_ids),
663b7ce997SRicard Wanderlof 	},
673b7ce997SRicard Wanderlof 	.probe = ics43432_probe,
683b7ce997SRicard Wanderlof };
693b7ce997SRicard Wanderlof 
703b7ce997SRicard Wanderlof module_platform_driver(ics43432_driver);
713b7ce997SRicard Wanderlof 
723b7ce997SRicard Wanderlof MODULE_DESCRIPTION("ASoC ICS43432 driver");
733b7ce997SRicard Wanderlof MODULE_AUTHOR("Ricard Wanderlof <ricardw@axis.com>");
743b7ce997SRicard Wanderlof MODULE_LICENSE("GPL v2");
75