Linux Audio

Check our new training course

Loading...
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * I2S MEMS microphone driver for InvenSense ICS-43432 and similar
 4 * MEMS-based microphones.
 5 *
 6 * - Non configurable.
 7 * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
 8 *
 9 * Copyright (c) 2015 Axis Communications AB
10 */
11
12#include <linux/module.h>
13#include <linux/init.h>
14#include <linux/slab.h>
15#include <sound/core.h>
16#include <sound/pcm.h>
17#include <sound/pcm_params.h>
18#include <sound/soc.h>
19#include <sound/initval.h>
20#include <sound/tlv.h>
21
22#define ICS43432_RATE_MIN 7190 /* Hz, from data sheet */
23#define ICS43432_RATE_MAX 52800  /* Hz, from data sheet */
24
25#define ICS43432_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32)
26
27static struct snd_soc_dai_driver ics43432_dai = {
28	.name = "ics43432-hifi",
29	.capture = {
30		.stream_name = "Capture",
31		.channels_min = 1,
32		.channels_max = 2,
33		.rate_min = ICS43432_RATE_MIN,
34		.rate_max = ICS43432_RATE_MAX,
35		.rates = SNDRV_PCM_RATE_CONTINUOUS,
36		.formats = ICS43432_FORMATS,
37	},
38};
39
40static const struct snd_soc_component_driver ics43432_component_driver = {
41	.idle_bias_on		= 1,
42	.use_pmdown_time	= 1,
43	.endianness		= 1,
 
44};
45
46static int ics43432_probe(struct platform_device *pdev)
47{
48	return devm_snd_soc_register_component(&pdev->dev,
49			&ics43432_component_driver,
50			&ics43432_dai, 1);
51}
52
53#ifdef CONFIG_OF
54static const struct of_device_id ics43432_ids[] = {
55	{ .compatible = "invensense,ics43432", },
56	{ .compatible = "cui,cmm-4030d-261", },
57	{ }
58};
59MODULE_DEVICE_TABLE(of, ics43432_ids);
60#endif
61
62static struct platform_driver ics43432_driver = {
63	.driver = {
64		.name = "ics43432",
65		.of_match_table = of_match_ptr(ics43432_ids),
66	},
67	.probe = ics43432_probe,
68};
69
70module_platform_driver(ics43432_driver);
71
72MODULE_DESCRIPTION("ASoC ICS43432 driver");
73MODULE_AUTHOR("Ricard Wanderlof <ricardw@axis.com>");
74MODULE_LICENSE("GPL v2");
v5.4
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * I2S MEMS microphone driver for InvenSense ICS-43432
 
 4 *
 5 * - Non configurable.
 6 * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
 7 *
 8 * Copyright (c) 2015 Axis Communications AB
 9 */
10
11#include <linux/module.h>
12#include <linux/init.h>
13#include <linux/slab.h>
14#include <sound/core.h>
15#include <sound/pcm.h>
16#include <sound/pcm_params.h>
17#include <sound/soc.h>
18#include <sound/initval.h>
19#include <sound/tlv.h>
20
21#define ICS43432_RATE_MIN 7190 /* Hz, from data sheet */
22#define ICS43432_RATE_MAX 52800  /* Hz, from data sheet */
23
24#define ICS43432_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32)
25
26static struct snd_soc_dai_driver ics43432_dai = {
27	.name = "ics43432-hifi",
28	.capture = {
29		.stream_name = "Capture",
30		.channels_min = 1,
31		.channels_max = 2,
32		.rate_min = ICS43432_RATE_MIN,
33		.rate_max = ICS43432_RATE_MAX,
34		.rates = SNDRV_PCM_RATE_CONTINUOUS,
35		.formats = ICS43432_FORMATS,
36	},
37};
38
39static const struct snd_soc_component_driver ics43432_component_driver = {
40	.idle_bias_on		= 1,
41	.use_pmdown_time	= 1,
42	.endianness		= 1,
43	.non_legacy_dai_naming	= 1,
44};
45
46static int ics43432_probe(struct platform_device *pdev)
47{
48	return devm_snd_soc_register_component(&pdev->dev,
49			&ics43432_component_driver,
50			&ics43432_dai, 1);
51}
52
53#ifdef CONFIG_OF
54static const struct of_device_id ics43432_ids[] = {
55	{ .compatible = "invensense,ics43432", },
 
56	{ }
57};
58MODULE_DEVICE_TABLE(of, ics43432_ids);
59#endif
60
61static struct platform_driver ics43432_driver = {
62	.driver = {
63		.name = "ics43432",
64		.of_match_table = of_match_ptr(ics43432_ids),
65	},
66	.probe = ics43432_probe,
67};
68
69module_platform_driver(ics43432_driver);
70
71MODULE_DESCRIPTION("ASoC ICS43432 driver");
72MODULE_AUTHOR("Ricard Wanderlof <ricardw@axis.com>");
73MODULE_LICENSE("GPL v2");