Skip to contentSkip to conversation

Adding OMAP DMIC driver to kernel

PATCH Applied David Lambert 4 participants 12 messages Jan 6, 2011 – Jan 12, 2011

Subsystems (6)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Adding OMAP DMIC driver to kernel

This is a patch series to add the OMAP Digital Microphone driver for OMAP4.

It includes the driver, a generic DMIC codec, platform devices, as well as HWMOD entries for OMAP44xx chipsets.

David Lambert (4):
ASoC: DMIC: Adding the OMAP DMIC driver
ASoC: DMIC codec: Adding a generic DMIC codec
OMAP4: hwmod: add entries for DMIC driver
OMAP4: DMIC: Add DMIC codec platform devices

 arch/arm/mach-omap2/board-4430sdp.c        |   11 +
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   91 +++++
 arch/arm/plat-omap/devices.c               |   35 ++
 arch/arm/plat-omap/include/plat/dmic.h     |   82 ++++
 sound/soc/codecs/Kconfig                   |    3 +
 sound/soc/codecs/Makefile                  |    2 +
 sound/soc/codecs/dmic.c                    |   81 ++++
 sound/soc/omap/Kconfig                     |    4 +
 sound/soc/omap/Makefile                    |    2 +
 sound/soc/omap/omap-dmic.c                 |  553 ++++++++++++++++++++++++++++
 10 files changed, 864 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/dmic.h
 create mode 100644 sound/soc/codecs/dmic.c
 create mode 100644 sound/soc/omap/omap-dmic.c
#1 lore raw

PATCH v2 1/4 ASoC: DMIC: Adding the OMAP DMIC driver

This patch adds support for the OMAP4 digital microphone DAI.

This DAI can support support recording in 2, 4, or 6 channels

When provided with a 19.2Mhz functional clock, can encode at 96Khz or 192Khz (all channels must have the same sample rate).

Details of the hardware interface can be found in the OMAP4 TRM in Section 23.7

---
 arch/arm/plat-omap/include/plat/dmic.h |   82 +++++
 sound/soc/omap/Kconfig                 |    4 +
 sound/soc/omap/Makefile                |    2 +
 sound/soc/omap/omap-dmic.c             |  553 ++++++++++++++++++++++++++++++++
 4 files changed, 641 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/dmic.h
 create mode 100644 sound/soc/omap/omap-dmic.c
arch/arm/plat-omap/include/plat/dmic.h new file +82 -0
new file mode 100644
index 0000000..a72e080
@@ -0,0 +1,82 @@
+/*
+ * omap-dmic.h  --  OMAP Digital Microphone Controller
+ *
+ * Author: Liam Girdwood <[email protected]>
+ *	   David Lambert <[email protected]>
+ *	   Misael Lopez Cruz <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ASM_ARCH_OMAP_DMIC_H
+#define __ASM_ARCH_OMAP_DMIC_H
+
+#define OMAP44XX_DMIC_L3_BASE	0x4902e000
+
+#define OMAP_DMIC_REVISION		0x00
+#define OMAP_DMIC_SYSCONFIG		0x10
+#define OMAP_DMIC_IRQSTATUS_RAW		0x24
+#define OMAP_DMIC_IRQSTATUS		0x28
+#define OMAP_DMIC_IRQENABLE_SET		0x2C
+#define OMAP_DMIC_IRQENABLE_CLR		0x30
+#define OMAP_DMIC_IRQWAKE_EN		0x34
+#define OMAP_DMIC_DMAENABLE_SET		0x38
+#define OMAP_DMIC_DMAENABLE_CLR		0x3C
+#define OMAP_DMIC_DMAWAKEEN		0x40
+#define OMAP_DMIC_CTRL			0x44
+#define OMAP_DMIC_DATA			0x48
+#define OMAP_DMIC_FIFO_CTRL		0x4C
+#define OMAP_DMIC_FIFO_DMIC1R_DATA	0x50
+#define OMAP_DMIC_FIFO_DMIC1L_DATA	0x54
+#define OMAP_DMIC_FIFO_DMIC2R_DATA	0x58
+#define OMAP_DMIC_FIFO_DMIC2L_DATA	0x5C
+#define OMAP_DMIC_FIFO_DMIC3R_DATA	0x60
+#define OMAP_DMIC_FIFO_DMIC3L_DATA	0x64
+
+/*
+ * DMIC_IRQ bit fields
+ * IRQSTATUS_RAW, IRQSTATUS, IRQENABLE_SET, IRQENABLE_CLR
+ */
+
+#define OMAP_DMIC_IRQ			(1 << 0)
+#define OMAP_DMIC_IRQ_FULL		(1 << 1)
+#define OMAP_DMIC_IRQ_ALMST_EMPTY	(1 << 2)
+#define OMAP_DMIC_IRQ_EMPTY		(1 << 3)
+#define OMAP_DMIC_IRQ_MASK		0x07
+
+/*
+ * DMIC_DMAENABLE bit fields
+ */
+
+#define OMAP_DMIC_DMA_ENABLE		0x1
+
+/*
+ * DMIC_CTRL bit fields
+ */
+
+#define OMAP_DMIC_UP1_ENABLE		0x0001
+#define OMAP_DMIC_UP2_ENABLE		0x0002
+#define OMAP_DMIC_UP3_ENABLE		0x0004
+#define OMAP_DMIC_FORMAT		0x0008
+#define OMAP_DMIC_POLAR1		0x0010
+#define OMAP_DMIC_POLAR2		0x0020
+#define OMAP_DMIC_POLAR3		0x0040
+#define OMAP_DMIC_POLAR_MASK		0x0070
+#define OMAP_DMIC_CLK_DIV_SHIFT		7
+#define OMAP_DMIC_CLK_DIV_MASK		0x0380
+#define	OMAP_DMIC_RESET			0x0400
+
+#define OMAP_DMIC_ENABLE_MASK		0x007
+
+#define OMAP_DMICOUTFORMAT_LJUST	(0 << 3)
+#define OMAP_DMICOUTFORMAT_RJUST	(1 << 3)
+
+/*
+ * DMIC_FIFO_CTRL bit fields
+ */
+
+#define OMAP_DMIC_THRES_MAX		0xF
+
+#endif
sound/soc/omap/Kconfig +4 -0
index a088db6..fe40488 100644
@@ -9,6 +9,9 @@ config SND_OMAP_SOC_MCBSP
 config SND_OMAP_SOC_MCPDM
 	tristate
 
+config SND_OMAP_SOC_DMIC
+	tristate
+
 config SND_OMAP_SOC_N810
 	tristate "SoC Audio support for Nokia N810"
 	depends on SND_OMAP_SOC && MACH_NOKIA_N810 && I2C
@@ -103,6 +106,7 @@ config SND_OMAP_SOC_SDP4430
 	depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP
 	select SND_OMAP_SOC_MCPDM
 	select SND_SOC_TWL6040
+	select SND_SOC_DMIC
 	help
 	  Say Y if you want to add support for SoC audio on Texas Instruments
 	  SDP4430.
sound/soc/omap/Makefile +2 -0
index ba9fc65..6ff27f5 100644
@@ -1,9 +1,11 @@
 # OMAP Platform Support
 snd-soc-omap-objs := omap-pcm.o
+snd-soc-omap-dmic-objs := omap-dmic.o
 snd-soc-omap-mcbsp-objs := omap-mcbsp.o
 snd-soc-omap-mcpdm-objs := omap-mcpdm.o mcpdm.o
 
 obj-$(CONFIG_SND_OMAP_SOC) += snd-soc-omap.o
+obj-$(CONFIG_SND_OMAP_SOC_DMIC) += snd-soc-omap-dmic.o
 obj-$(CONFIG_SND_OMAP_SOC_MCBSP) += snd-soc-omap-mcbsp.o
 obj-$(CONFIG_SND_OMAP_SOC_MCPDM) += snd-soc-omap-mcpdm.o
 
sound/soc/omap/omap-dmic.c new file +553 -0

553 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#2 lore raw

Re: [PATCH v2 1/4] ASoC: DMIC: Adding the OMAP DMIC driver

sound/soc/omap/Kconfig config SND_OMAP_SOC_SDP4430 · line 112

Quoted 8 lines · David Lambert
sound/soc/omap/Kconfig +1 -0
@@ -103,6 +106,7 @@ config SND_OMAP_SOC_SDP4430
 	depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP
 	select SND_OMAP_SOC_MCPDM
 	select SND_SOC_TWL6040
+	select SND_SOC_DMIC
 	help
 	  Say Y if you want to add support for SoC audio on Texas Instruments
 	  SDP4430.

Any tweaks to specific machines should be done separately to adding the new drivers.

sound/soc/omap/omap-dmic.c line 150

Quoted 12 lines
sound/soc/omap/omap-dmic.c new file +12 -0
+	struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
+	int ctrl, div_sel = -EINVAL;
+
+	if (div_id != OMAP_DMIC_CLKDIV)
+		return -ENODEV;
+
+	switch (dmic->clk_freq) {
+	case 19200000:
+		if (div == 5)
+			div_sel = 0x1;
+		else if (div == 8)
+			div_sel = 0x0;

I suggested switch statements previously; you didn't comment on my reply.

sound/soc/omap/omap-dmic.c line 235

Quoted 3 lines
sound/soc/omap/omap-dmic.c new file +3 -0
+static irqreturn_t omap_dmic_irq_handler(int irq, void *dev_id)
+{
+	struct omap_dmic *dmic = dev_id;

My comments on this function appear to have been mostly ignored also.

sound/soc/omap/omap-dmic.c line 303

Quoted 6 lines
sound/soc/omap/omap-dmic.c new file +6 -0
+	switch (rate) {
+	case 192000:
+		div = 5;
+		break;
+	default:
+		div = 8;

Shouldn't the default case be a case 96000?

sound/soc/omap/omap-dmic.c line 345

Quoted 4 lines
sound/soc/omap/omap-dmic.c new file +4 -0
+	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+		break;
+	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+		break;

Remove the empty cases, they're handled by the default.

sound/soc/omap/omap-dmic.c line 553

Quoted 4 lines
sound/soc/omap/omap-dmic.c new file +4 -0
+
+MODULE_AUTHOR("David Lambert <[email protected]>");
+MODULE_DESCRIPTION("OMAP DMIC SoC Interface");
+MODULE_LICENSE("GPL");

As also previously noted you should have a MODULE_ALIAS.

#3 lore raw

Re: [PATCH v2 1/4] ASoC: DMIC: Adding the OMAP DMIC driver

Quoted 13 lines · Mark Brown
Quoted 8 lines · David Lambert
(quoted diff) +0 -0
@@ -103,6 +106,7 @@ config SND_OMAP_SOC_SDP4430

      depends on TWL4030_CORE && SND_OMAP_SOC && MACH_OMAP_4430SDP select SND_OMAP_SOC_MCPDM
      select SND_SOC_TWL6040
+     select SND_SOC_DMIC
      help
        Say Y if you want to add support for SoC audio on Texas Instruments SDP4430.

Any tweaks to specific machines should be done separately to adding the new drivers.

OK... I'll put that in to a separate patch.

Quoted 17 lines

sound/soc/omap/omap-dmic.c line 150

Quoted 13 lines

+     struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
+     int ctrl, div_sel = -EINVAL;

sound/soc/omap/omap-dmic.c new file +10 -0
+
+     if (div_id != OMAP_DMIC_CLKDIV)
+             return -ENODEV;
+
+     switch (dmic->clk_freq) {
+     case 19200000:
+             if (div == 5)
+                     div_sel = 0x1;
+             else if (div == 8)
+                     div_sel = 0x0;

I suggested switch statements previously; you didn't comment on my reply.

Sorry... my personal standard on when to go with a switch statement is

Quoted 1 line

2 choices,

I'll change it over to a switch...

Quoted 6 lines

sound/soc/omap/omap-dmic.c line 235

Quoted 3 lines
sound/soc/omap/omap-dmic.c new file +3 -0
+static irqreturn_t omap_dmic_irq_handler(int irq, void *dev_id)
+{
+     struct omap_dmic *dmic = dev_id;

My comments on this function appear to have been mostly ignored also.

Being as with this hardware, the IRQ handler really does nothing, I think it best
if I just take it out for now. It is useful in debugging cases to ensure you're moving data. I'll just remove it.

Quoted 8 lines
Quoted 6 lines

+     switch (rate) {
+     case 192000:
+             div = 5;
+             break;
+     default:
+             div = 8;

Shouldn't the default case be a case 96000?

The default case IS 96000 (only options for rate here are 96000 and 192000), isn't it?

Quoted 8 lines
Quoted 5 lines

+     case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+             break;
+     case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+             break;

Remove the empty cases, they're handled by the default.

OK

Quoted 6 lines

sound/soc/omap/omap-dmic.c line 553

Quoted 4 lines
sound/soc/omap/omap-dmic.c new file +4 -0
+
+MODULE_AUTHOR("David Lambert <[email protected]>");
+MODULE_DESCRIPTION("OMAP DMIC SoC Interface");
+MODULE_LICENSE("GPL");

As also previously noted you should have a MODULE_ALIAS.

The MODULE_ALIAS is in there... just following example of the other drivers I looked at, it was placed above the platform_driver declaration.

+MODULE_ALIAS("platform:omap-dmic-dai");
+
+static struct platform_driver asoc_dmic_driver = {
+ .driver = {
+ .name = "omap-dmic-dai",
+ .owner = THIS_MODULE,

+       },
+       .probe = asoc_dmic_probe,
+       .remove = __devexit_p(asoc_dmic_remove),

+};

Quoted 1 line

--
David Lambert
OMAP™ Multimedia
214-567-5692
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH v2 1/4] ASoC: DMIC: Adding the OMAP DMIC driver

Quoted 8 lines · David

On Thu, Jan 6, 2011 at 4:20 PM, Mark Brown

Quoted 2 lines

I suggested switch statements previously; you didn't comment on my reply.

Sorry... my personal standard on when to go with a switch statement is

Quoted 1 line

2 choices,

I'll change it over to a switch...

Think about the impression you're creating here: if someone had a review comment on one version of a patch and you neither reply nor address it in the patch they're very likely to have the same comment again.

Quoted 11 lines
Quoted 8 lines
Quoted 6 lines

+     switch (rate) {
+     case 192000:
+             div = 5;
+             break;
+     default:
+             div = 8;

Shouldn't the default case be a case 96000?

The default case IS 96000 (only options for rate here are 96000 and 192000), isn't it?

Think about this from a robustness, legibility and maintainability point of view - the above code doesn't clearly do the right thing, and if any other sample rates are added it'll be buggy.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

PATCH v2 2/4 ASoC: DMIC codec: Adding a generic DMIC codec

In reply to David Lambert

This codec is to be used by the DMIC driver to control the DMIC codec. This driver will be used on future implementations of the DMIC driver to support codec specific features.

At this time, the codec driver just registers the codec DAI.

---
 sound/soc/codecs/Kconfig  |    3 ++
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/dmic.c   |   81 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/dmic.c
sound/soc/codecs/Kconfig +3 -0
index 0f33db2..f6c6d31 100644
@@ -166,6 +166,9 @@ config SND_SOC_L3
 config SND_SOC_DA7210
         tristate
 
+config SND_SOC_DMIC
+	tristate
+
 config SND_SOC_MAX98088
        tristate
 
sound/soc/codecs/Makefile +2 -0
index 10e5e09..9139cf9 100644
@@ -14,6 +14,7 @@ snd-soc-cs42l51-objs := cs42l51.o
 snd-soc-cs4270-objs := cs4270.o
 snd-soc-cx20442-objs := cx20442.o
 snd-soc-da7210-objs := da7210.o
+snd-soc-dmic-objs := dmic.o
 snd-soc-l3-objs := l3.o
 snd-soc-max98088-objs := max98088.o
 snd-soc-pcm3008-objs := pcm3008.o
@@ -91,6 +92,7 @@ obj-$(CONFIG_SND_SOC_CS42L51)	+= snd-soc-cs42l51.o
 obj-$(CONFIG_SND_SOC_CS4270)	+= snd-soc-cs4270.o
 obj-$(CONFIG_SND_SOC_CX20442)	+= snd-soc-cx20442.o
 obj-$(CONFIG_SND_SOC_DA7210)	+= snd-soc-da7210.o
+obj-$(CONFIG_SND_SOC_DMIC)	+= snd-soc-dmic.o
 obj-$(CONFIG_SND_SOC_L3)	+= snd-soc-l3.o
 obj-$(CONFIG_SND_SOC_JZ4740_CODEC)	+= snd-soc-jz4740-codec.o
 obj-$(CONFIG_SND_SOC_MAX98088)	+= snd-soc-max98088.o
sound/soc/codecs/dmic.c new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#6 lore raw

Re: [alsa-devel] [PATCH v2 2/4] ASoC: DMIC codec: Adding a generic DMIC codec

Quoted 7 lines · David Lambert

This codec is to be used by the DMIC driver to control the DMIC codec. This driver will be used on future implementations of the DMIC driver to support codec specific features.

At this time, the codec driver just registers the codec DAI.

Quoted 8 lines
---
 sound/soc/codecs/Kconfig  |    3 ++
 sound/soc/codecs/Makefile |    2 +
 sound/soc/codecs/dmic.c   |   81 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/codecs/dmic.c

Applied.

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#7 lore raw

PATCH v2 3/4 OMAP4: hwmod: add entries for DMIC driver

In reply to David Lambert

Adds HWMOD entries for the OMAP DMIC driver and creates
a platform device. The HWMOD entires define the system resource requirements for the drvier such as DMA addresses, channels, and IRQ's. Placing this information in the HWMOD database allows for more generic drivers to be written and having the specific implementation details defined in HWMOD.

---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   91 ++++++++++++++++++++++++++++
 arch/arm/plat-omap/devices.c               |   35 +++++++++++
 2 files changed, 126 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +91 -0
index 7274db4..f9b2ad3 100644
@@ -383,6 +383,95 @@ static struct omap_hwmod omap44xx_l4_wkup_hwmod = {
 };
 
 /*
+ * 'dmic' class
+ * digital microphone controller
+ */
+
+static struct omap_hwmod_class_sysconfig omap44xx_dmic_sysc = {
+	.rev_offs	= 0x0000,
+	.sysc_offs	= 0x0010,
+	.sysc_flags	= (SYSC_HAS_EMUFREE | SYSC_HAS_RESET_STATUS |
+			   SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET),
+	.idlemodes	= (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
+	.sysc_fields	= &omap_hwmod_sysc_type2,
+};
+
+static struct omap_hwmod_class omap44xx_dmic_hwmod_class = {
+	.name = "omap-dmic",
+	.sysc = &omap44xx_dmic_sysc,
+};
+
+/* dmic */
+static struct omap_hwmod omap44xx_dmic_hwmod;
+static struct omap_hwmod_irq_info omap44xx_dmic_irqs[] = {
+	{ .irq = 114 + OMAP44XX_IRQ_GIC_START },
+};
+
+static struct omap_hwmod_dma_info omap44xx_dmic_sdma_reqs[] = {
+	{ .dma_req = 66 + OMAP44XX_DMA_REQ_START },
+};
+
+static struct omap_hwmod_addr_space omap44xx_dmic_addrs[] = {
+	{
+		.pa_start	= 0x4012e000,
+		.pa_end		= 0x4012e07f,
+		.flags		= ADDR_TYPE_RT
+	},
+};
+
+/* l4_abe -> dmic */
+static struct omap_hwmod_ocp_if omap44xx_l4_abe__dmic = {
+	.master		= &omap44xx_l4_abe_hwmod,
+	.slave		= &omap44xx_dmic_hwmod,
+	.clk		= "ocp_abe_iclk",
+	.addr		= omap44xx_dmic_addrs,
+	.addr_cnt	= ARRAY_SIZE(omap44xx_dmic_addrs),
+	.user		= OCP_USER_MPU,
+};
+
+static struct omap_hwmod_addr_space omap44xx_dmic_dma_addrs[] = {
+	{
+		.pa_start	= 0x4902e000,
+		.pa_end		= 0x4902e07f,
+		.flags		= ADDR_TYPE_RT
+	},
+};
+
+/* l4_abe -> dmic (dma) */
+static struct omap_hwmod_ocp_if omap44xx_l4_abe__dmic_dma = {
+	.master		= &omap44xx_l4_abe_hwmod,
+	.slave		= &omap44xx_dmic_hwmod,
+	.clk		= "ocp_abe_iclk",
+	.addr		= omap44xx_dmic_dma_addrs,
+	.addr_cnt	= ARRAY_SIZE(omap44xx_dmic_dma_addrs),
+	.user		= OCP_USER_SDMA,
+};
+
+/* dmic slave ports */
+static struct omap_hwmod_ocp_if *omap44xx_dmic_slaves[] = {
+	&omap44xx_l4_abe__dmic,
+	&omap44xx_l4_abe__dmic_dma,
+};
+
+static struct omap_hwmod omap44xx_dmic_hwmod = {
+	.name		= "omap-dmic",
+	.class		= &omap44xx_dmic_hwmod_class,
+	.mpu_irqs	= omap44xx_dmic_irqs,
+	.mpu_irqs_cnt	= ARRAY_SIZE(omap44xx_dmic_irqs),
+	.sdma_reqs	= omap44xx_dmic_sdma_reqs,
+	.sdma_reqs_cnt	= ARRAY_SIZE(omap44xx_dmic_sdma_reqs),
+	.main_clk	= "dmic_fck",
+	.prcm = {
+		.omap4 = {
+			.clkctrl_reg = OMAP4430_CM1_ABE_DMIC_CLKCTRL,
+		},
+	},
+	.slaves		= omap44xx_dmic_slaves,
+	.slaves_cnt	= ARRAY_SIZE(omap44xx_dmic_slaves),
+	.omap_chip	= OMAP_CHIP_INIT(CHIP_IS_OMAP4430),
+};
+
+/*
  * 'mpu_bus' class
  * instance(s): mpu_private
  */
@@ -826,6 +915,8 @@ static __initdata struct omap_hwmod *omap44xx_hwmods[] = {
 	&omap44xx_l4_cfg_hwmod,
 	&omap44xx_l4_per_hwmod,
 	&omap44xx_l4_wkup_hwmod,
+	/* dmic class */
+	&omap44xx_dmic_hwmod,
 	/* mpu_bus class */
 	&omap44xx_mpu_private_hwmod,
 
arch/arm/plat-omap/devices.c +35 -0
index fc81912..b347f75 100644
@@ -72,6 +72,40 @@ void omap_mcbsp_register_board_cfg(struct omap_mcbsp_platform_data *config,
 
 /*-------------------------------------------------------------------------*/
 
+#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
+	defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
+
+static struct omap_device_pm_latency omap_dmic_latency[] = {
+	{
+		.deactivate_func = omap_device_idle_hwmods,
+		.activate_func = omap_device_enable_hwmods,
+		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
+	},
+};
+
+static void omap_init_dmic(void)
+{
+	struct omap_hwmod *oh;
+	struct omap_device *od;
+
+	oh = omap_hwmod_lookup("omap-dmic");
+	if (!oh) {
+		printk(KERN_ERR "Could not look up dmic hw_mod\n");
+		return;
+	}
+
+	od = omap_device_build("omap-dmic-dai", -1, oh, NULL, 0,
+				omap_dmic_latency,
+				ARRAY_SIZE(omap_dmic_latency), 0);
+	if (IS_ERR(od))
+		printk(KERN_ERR "Could not build omap_device for omap-dmic-dai\n");
+}
+#else
+static inline void omap_init_dmic(void) {}
+#endif
+
+/*-------------------------------------------------------------------------*/
+
 #if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
 		defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
 
@@ -328,6 +362,7 @@ static int __init omap_init_devices(void)
 	/* please keep these calls, and their implementations above,
 	 * in alphabetical order so they're easier to sort through.
 	 */
+	omap_init_dmic();
 	omap_init_rng();
 	omap_init_mcpdm();
 	omap_init_uwire();
Signature · 1 line
1.7.0.4
Acked-by on v2 3/4
#8 lore raw

Re: [PATCH v2 3/4] OMAP4: hwmod: add entries for DMIC driver

Quoted 8 lines · David Lambert

Adds HWMOD entries for the OMAP DMIC driver and creates
a platform device. The HWMOD entires define the system resource requirements for the drvier such as DMA addresses, channels, and IRQ's. Placing this information in the HWMOD database allows for more generic drivers to be written and having the specific implementation details defined in HWMOD.

#9 lore raw

Re: [PATCH v2 3/4] OMAP4: hwmod: add entries for DMIC driver

In reply to David Lambert
Quoted 7 lines · David Lambert

Adds HWMOD entries for the OMAP DMIC driver and creates
a platform device. The HWMOD entires define the system resource requirements for the drvier such as DMA addresses, channels, and IRQ's. Placing this information in the HWMOD database allows for more generic drivers to be written and having the specific implementation details defined in HWMOD.

Quoted 6 lines
---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   91 ++++++++++++++++++++++++++++
 arch/arm/plat-omap/devices.c               |   35 +++++++++++
 2 files changed, 126 insertions(+), 0 deletions(-)

Please split this into two patches: one for just the hwmod data, and the other for initializing the device.

Also, I'm assuming the hwmod data came from the auto-generated data from Benoit, correct? If so authorship and signoff of the hwmod data patch should reflect that.

Thanks,

Kevin

#10 lore raw

PATCH v2 4/4 OMAP4: DMIC: Add DMIC codec platform devices

In reply to David Lambert

This creates the DMIC codec platform devices.

The platform devices create an instance of the driver during boot up.

---
 arch/arm/mach-omap2/board-4430sdp.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/board-4430sdp.c +11 -0
index df5a425..e7745cf 100644
@@ -505,6 +505,16 @@ static void __init omap_sfh7741prox_init(void)
 	}
 }
 
+static struct platform_device codec_dmic0 = {
+	.name   = "dmic-codec",
+	.id     = -1,
+};
+
+static inline void omap_dmic_init(void)
+{
+	platform_device_register(&codec_dmic0);
+}
+
 static void __init omap_4430sdp_init(void)
 {
 	int status;
@@ -528,6 +538,7 @@ static void __init omap_4430sdp_init(void)
 		spi_register_board_info(sdp4430_spi_board_info,
 				ARRAY_SIZE(sdp4430_spi_board_info));
 	}
+	omap_dmic_init();
 }
 
 static void __init omap_4430sdp_map_io(void)
Signature · 1 line
1.7.0.4
Acked-by on v2 4/4
#11 lore raw

Re: [PATCH v2 4/4] OMAP4: DMIC: Add DMIC codec platform devices

Quoted 5 lines · David Lambert

This creates the DMIC codec platform devices.

The platform devices create an instance of the driver during boot up.

though:

arch/arm/mach-omap2/board-4430sdp.c static void __init omap_sfh7741prox_init(void) · line 516

Quoted 9 lines
arch/arm/mach-omap2/board-4430sdp.c +8 -0
+static struct platform_device codec_dmic0 = {
+	.name   = "dmic-codec",
+	.id     = -1,
+};
 
+static inline void omap_dmic_init(void)
+{
+	platform_device_register(&codec_dmic0);
+}

This feels like bad namespacing as the name is OMAP-generic but it's actually board specific.

It might also be more sensible to just have an array of platform devices with one entry and register that rather than bouncing through this function as it doesn't add anything and it'll get more and more verbose as more platform devices are added.

It may be that these things are idiomatic, though - I've not looked at the surrounding code.