ASoC: ics43432: Add codec driver for InvenSense ICS-43432
authorRicard Wanderlof <ricard.wanderlof@axis.com>
Thu, 27 Aug 2015 09:35:20 +0000 (11:35 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 27 Aug 2015 16:09:27 +0000 (17:09 +0100)
Add support for the InvenSense ICS-43432 I2S MEMS microphone.

This is a non-software-configurable MEMS microphone with I2S output.

Tested on a setup with a single ICS-43432 (the device itself supports
stereo operation using a hardware pin controlling left vs. right channel
output).

Signed-off-by: Ricard Wanderlof <ricardw@axis.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Documentation/devicetree/bindings/sound/ics43432.txt [new file with mode: 0644]
Documentation/devicetree/bindings/vendor-prefixes.txt
sound/soc/codecs/Kconfig
sound/soc/codecs/Makefile
sound/soc/codecs/ics43432.c [new file with mode: 0644]

diff --git a/Documentation/devicetree/bindings/sound/ics43432.txt b/Documentation/devicetree/bindings/sound/ics43432.txt
new file mode 100644 (file)
index 0000000..b02e3a6
--- /dev/null
@@ -0,0 +1,17 @@
+Invensense ICS-43432 MEMS microphone with I2S output.
+
+There are no software configuration options for this device, indeed, the only
+host connection is the I2S interface. Apart from requirements on clock
+frequency (460 kHz to 3.379 MHz according to the data sheet) there must be
+64 clock cycles in each stereo output frame; 24 of the 32 available bits
+contain audio data. A hardware pin determines if the device outputs data
+on the left or right channel of the I2S frame.
+
+Required properties:
+  - compatible : Must be "invensense,ics43432"
+
+Example:
+
+       ics43432: ics43432 {
+               compatible = "invensense,ics43432";
+       };
index d444757c4d9ec3e56c261e0adf330de187251466..80bf96d4795f228d75289f323aa3311d22616f99 100644 (file)
@@ -110,6 +110,7 @@ ingenic     Ingenic Semiconductor
 innolux        Innolux Corporation
 intel  Intel Corporation
 intercontrol   Inter Control Group
+invensense     InvenSense Inc.
 isee   ISEE 2007 S.L.
 isil   Intersil
 karo   Ka-Ro electronics GmbH
index efaafce8ba387340e073796a9de2c7d9b00aac81..1bb6446dce5357595453ddc9f7c85669279a2c1e 100644 (file)
@@ -62,6 +62,7 @@ config SND_SOC_ALL_CODECS
        select SND_SOC_BT_SCO
        select SND_SOC_ES8328_SPI if SPI_MASTER
        select SND_SOC_ES8328_I2C if I2C
+       select SND_SOC_ICS43432
        select SND_SOC_ISABELLE if I2C
        select SND_SOC_JZ4740_CODEC
        select SND_SOC_LM4857 if I2C
@@ -446,6 +447,9 @@ config SND_SOC_ES8328_SPI
        tristate
        select SND_SOC_ES8328
 
+config SND_SOC_ICS43432
+       tristate
+
 config SND_SOC_ISABELLE
         tristate
 
index cf160d972cb3640b0080634fb9d67f6800252e04..5a19a670a82b65c3cc93523de02409f0b61100ea 100644 (file)
@@ -55,6 +55,7 @@ snd-soc-dmic-objs := dmic.o
 snd-soc-es8328-objs := es8328.o
 snd-soc-es8328-i2c-objs := es8328-i2c.o
 snd-soc-es8328-spi-objs := es8328-spi.o
+snd-soc-ics43432-objs := ics43432.o
 snd-soc-isabelle-objs := isabelle.o
 snd-soc-jz4740-codec-objs := jz4740.o
 snd-soc-l3-objs := l3.o
@@ -242,6 +243,7 @@ obj-$(CONFIG_SND_SOC_DMIC)  += snd-soc-dmic.o
 obj-$(CONFIG_SND_SOC_ES8328)   += snd-soc-es8328.o
 obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
 obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
+obj-$(CONFIG_SND_SOC_ICS43432) += snd-soc-ics43432.o
 obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o
 obj-$(CONFIG_SND_SOC_JZ4740_CODEC)     += snd-soc-jz4740-codec.o
 obj-$(CONFIG_SND_SOC_L3)       += snd-soc-l3.o
diff --git a/sound/soc/codecs/ics43432.c b/sound/soc/codecs/ics43432.c
new file mode 100644 (file)
index 0000000..4f202c1
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * I2S MEMS microphone driver for InvenSense ICS-43432
+ *
+ * - Non configurable.
+ * - I2S interface, 64 BCLs per frame, 32 bits per channel, 24 bit data
+ *
+ * Copyright (c) 2015 Axis Communications AB
+ *
+ * Licensed under GPL2.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/initval.h>
+#include <sound/tlv.h>
+
+#define ICS43432_RATE_MIN 7190 /* Hz, from data sheet */
+#define ICS43432_RATE_MAX 52800  /* Hz, from data sheet */
+
+#define ICS43432_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32)
+
+static struct snd_soc_dai_driver ics43432_dai = {
+       .name = "ics43432-hifi",
+       .capture = {
+               .stream_name = "Capture",
+               .channels_min = 1,
+               .channels_max = 2,
+               .rate_min = ICS43432_RATE_MIN,
+               .rate_max = ICS43432_RATE_MAX,
+               .rates = SNDRV_PCM_RATE_CONTINUOUS,
+               .formats = ICS43432_FORMATS,
+       },
+};
+
+static struct snd_soc_codec_driver ics43432_codec_driver = {
+};
+
+static int ics43432_probe(struct platform_device *pdev)
+{
+       return snd_soc_register_codec(&pdev->dev, &ics43432_codec_driver,
+                       &ics43432_dai, 1);
+}
+
+static int ics43432_remove(struct platform_device *pdev)
+{
+       snd_soc_unregister_codec(&pdev->dev);
+       return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id ics43432_ids[] = {
+       { .compatible = "invensense,ics43432", },
+       { }
+};
+MODULE_DEVICE_TABLE(of, ics43432_dt_ids);
+#endif
+
+static struct platform_driver ics43432_driver = {
+       .driver = {
+               .name = "ics43432",
+               .owner = THIS_MODULE,
+               .of_match_table = of_match_ptr(ics43432_ids),
+       },
+       .probe = ics43432_probe,
+       .remove = ics43432_remove,
+};
+
+module_platform_driver(ics43432_driver);
+
+MODULE_DESCRIPTION("ASoC ICS43432 driver");
+MODULE_AUTHOR("Ricard Wanderlof <ricardw@axis.com>");
+MODULE_LICENSE("GPLv2");