1f8a88917SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
23b7ce997SRicard Wanderlof /*
3*43d2c498SAngelo Dureghello * I2S MEMS microphone driver for InvenSense ICS-43432 and similar
4*43d2c498SAngelo Dureghello * MEMS-based microphones.
53b7ce997SRicard Wanderlof *
63b7ce997SRicard Wanderlof * - Non configurable.
73b7ce997SRicard Wanderlof * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
83b7ce997SRicard Wanderlof *
93b7ce997SRicard Wanderlof * Copyright (c) 2015 Axis Communications AB
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
407c8d9059SKuninori Morimoto static const struct snd_soc_component_driver ics43432_component_driver = {
417c8d9059SKuninori Morimoto .idle_bias_on = 1,
427c8d9059SKuninori Morimoto .use_pmdown_time = 1,
437c8d9059SKuninori Morimoto .endianness = 1,
443b7ce997SRicard Wanderlof };
453b7ce997SRicard Wanderlof
ics43432_probe(struct platform_device * pdev)463b7ce997SRicard Wanderlof static int ics43432_probe(struct platform_device *pdev)
473b7ce997SRicard Wanderlof {
487c8d9059SKuninori Morimoto return devm_snd_soc_register_component(&pdev->dev,
497c8d9059SKuninori Morimoto &ics43432_component_driver,
503b7ce997SRicard Wanderlof &ics43432_dai, 1);
513b7ce997SRicard Wanderlof }
523b7ce997SRicard Wanderlof
533b7ce997SRicard Wanderlof #ifdef CONFIG_OF
543b7ce997SRicard Wanderlof static const struct of_device_id ics43432_ids[] = {
553b7ce997SRicard Wanderlof { .compatible = "invensense,ics43432", },
56*43d2c498SAngelo Dureghello { .compatible = "cui,cmm-4030d-261", },
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