Skip to contentSkip to conversation

Adding OMAP DMIC driver to kernel

PATCH In review David Lambert 5 participants 13 messages Jan 25, 2011 – Feb 14, 2011

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v3 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.

Note: The DMIC codec driver was removed from this series as it was accepted for and merged for the 2.6.38 kernel.

Benoit Cousson (1):
OMAP4: hwmod: add entries for DMIC driver

David Lambert (3):
ASoC: DMIC: Adding the OMAP DMIC driver
OMAP4: DMIC: initializes the 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/omap/Kconfig                     |    3 +
 sound/soc/omap/Makefile                    |    2 +
 sound/soc/omap/omap-dmic.c                 |  534 ++++++++++++++++++++++++++++
 7 files changed, 758 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/dmic.h
 create mode 100644 sound/soc/omap/omap-dmic.c
#1 lore raw

PATCH v3 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                 |    3 +
 sound/soc/omap/Makefile                |    2 +
 sound/soc/omap/omap-dmic.c             |  534 ++++++++++++++++++++++++++++++++
 4 files changed, 621 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 +3 -0
index a088db6..818ead3 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
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 +534 -0

534 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#4 lore raw

PATCH v3 2/4 OMAP4: hwmod: add entries for DMIC driver

In reply to David Lambert

From: Benoit Cousson <[email protected]>

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 ++++++++++++++++++++++++++++
 1 files changed, 91 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,
 
Signature · 1 line
1.7.0.4
#9 lore raw

PATCH v3 3/4 OMAP4: DMIC: initializes the DMIC driver

In reply to David Lambert

This code is used to read the HWMOD database and initialize the DMIC driver.

---
 arch/arm/plat-omap/devices.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
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
#11 lore raw

PATCH v3 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
maintainer
#5 lore raw

Re: [PATCH v3 2/4] OMAP4: hwmod: add entries for DMIC driver

In reply to David Lambert
Quoted 10 lines · David Lambert

From: Benoit Cousson <[email protected]>

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.

This should have Benoit's Signed-off-by: also.

- Paul

#12 lore raw
In reply to David Lambert
Quoted 8 lines · David Lambert

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.

Note: The DMIC codec driver was removed from this series as it was accepted for and merged for the 2.6.38 kernel.

You have not mentioned the baseline for this patch series. I tried to apply first patch of this series on linux omap master branch, patch applies cleanly but the changes are not getting compiled eventhough it is enabled in Makefile if I use omap2plus_defconfig. Am I missing anything?

-Manjunath

Quoted 24 lines

Benoit Cousson (1):
OMAP4: hwmod: add entries for DMIC driver

David Lambert (3):
ASoC: DMIC: Adding the OMAP DMIC driver
OMAP4: DMIC: initializes the 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/omap/Kconfig                     |    3 +
 sound/soc/omap/Makefile                    |    2 +
 sound/soc/omap/omap-dmic.c                 |  534 ++++++++++++++++++++++++++++
 7 files changed, 758 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/dmic.h
 create mode 100644 sound/soc/omap/omap-dmic.c

--
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

#6 lore raw

Re: [PATCH v3 2/4] OMAP4: hwmod: add entries for DMIC driver

In reply to Paul Walmsley
Quoted 12 lines · Paul Walmsley
Quoted 9 lines · David Lambert

From: Benoit Cousson <[email protected]>

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 4 lines
Quoted 1 line

This should have Benoit's Signed-off-by: also.

OK... Benoit has already agreed to it... will it be sufficient if I just have him ACK the
change here on e-mail?

--
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

maintainer
#7 lore raw

Re: [PATCH v3 2/4] OMAP4: hwmod: add entries for DMIC driver

Quoted 13 lines · David
Quoted 12 lines · Paul Walmsley
Quoted 9 lines · David Lambert

From: Benoit Cousson <[email protected]>

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 7 lines
Quoted 4 lines
Quoted 1 line

This should have Benoit's Signed-off-by: also.

OK... Benoit has already agreed to it... will it be sufficient if I just have him ACK the change here on e-mail?

Yes.

- Paul

#2 lore raw

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

In reply to David Lambert
Quoted 25 lines · David Lambert

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                 |    3 + sound/soc/omap/Makefile                |    2 + sound/soc/omap/omap-dmic.c             |  534 ++++++++++++++++++++++++++++++++

 4 files changed, 621 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 +0 -0
new file mode 100644
index 0000000..a72e080

arch/arm/plat-omap/include/plat/dmic.h line 6

Quoted 6 lines
arch/arm/plat-omap/include/plat/dmic.h new file +6 -0
@@ -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]>

Consider adding the copyright info.

arch/arm/plat-omap/include/plat/dmic.h line 19

Quoted 13 lines
arch/arm/plat-omap/include/plat/dmic.h new file +13 -0
+ *
+ * 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

As this driver would use hwmod framework, it would be good to avoid defining this macro in the driver. Anyway it is not used in the driver.

Quoted 9 lines
arch/arm/plat-omap/include/plat/dmic.h new file +9 -0
+#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

arch/arm/plat-omap/include/plat/dmic.h line 38

Quoted 10 lines
arch/arm/plat-omap/include/plat/dmic.h new file +10 -0
+#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
+
+/*

<<snip>>

Quoted 39 lines
sound/soc/omap/omap-dmic.c new file +33 -0
new file mode 100644
index 0000000..06dbb99
@@ -0,0 +1,534 @@
+/*
+ * omap-dmic.c  --  OMAP ASoC DMIC DAI driver
+ *
+ * Copyright (C) 2010 Texas Instruments
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#undef DEBUG
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/wait.h>
+#include <linux/interrupt.h>
+#include <linux/err.h>

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

Quoted 10 lines
sound/soc/omap/omap-dmic.c new file +10 -0
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/pm_runtime.h>
+
+#include <plat/control.h>
+#include <plat/dma.h>
+#include <plat/dmic.h>
+#include <plat/omap_hwmod.h>

The above header file is not required in the driver

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

Quoted 7 lines
sound/soc/omap/omap-dmic.c new file +7 -0
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/initval.h>
+#include <sound/soc.h>
+

<<snip>>

Quoted 5 lines
sound/soc/omap/omap-dmic.c new file +5 -0
+
+static int omap_dmic_dai_trigger(struct snd_pcm_substream *substream,
+                                 int cmd, struct snd_soc_dai *dai)
+{
+       struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);

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

Quoted 10 lines
sound/soc/omap/omap-dmic.c new file +10 -0
+       int dmic_id = dmic->link->channels;
+
+       switch (cmd) {
+       case SNDRV_PCM_TRIGGER_START:
+               omap_dmic_start(dmic, dmic_id);
+               break;
+       case SNDRV_PCM_TRIGGER_STOP:
+               omap_dmic_stop(dmic, dmic_id);
+               break;
+       default:

You may consider adding a "command not supported" warning if it would be meaningful.

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

Quoted 6 lines
sound/soc/omap/omap-dmic.c new file +6 -0
+               break;
+       }
+
+       return 0;
+}
+

<<snip>>

Quoted 29 lines
sound/soc/omap/omap-dmic.c new file +29 -0
+
+static struct snd_soc_dai_driver omap_dmic_dai = {
+
+       .name = "omap-dmic-dai-0",
+       .capture = {
+               .channels_min = 2,
+               .channels_max = 6,
+               .rates = OMAP_DMIC_RATES,
+               .formats = OMAP_DMIC_FORMATS,
+       },
+       .ops = &omap_dmic_dai_ops,
+};
+
+static __devinit int asoc_dmic_probe(struct platform_device *pdev)
+{
+       struct omap_dmic *dmic;
+       struct resource *res;
+       int ret;
+
+       dmic = kzalloc(sizeof(struct omap_dmic), GFP_KERNEL);
+       if (!dmic)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, dmic);
+       dmic->dev = &pdev->dev;
+       dmic->link = &omap_dmic_link;
+       dmic->sysclk = OMAP_DMIC_SYSCLK_SYNC_MUX_CLKS;
+
+       spin_lock_init(&dmic->lock);

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

Quoted 10 lines
sound/soc/omap/omap-dmic.c new file +10 -0
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res) {
+               dev_err(dmic->dev, "invalid memory resource\n");
+               ret = -ENODEV;
+               goto err_res;
+       }
+
+       dmic->io_base = ioremap(res->start, resource_size(res));
+       if (!dmic->io_base) {

Print the error.

Quoted 4 lines
sound/soc/omap/omap-dmic.c new file +4 -0
+               ret = -ENOMEM;
+               goto err_res;
+       }
+

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

Quoted 10 lines
sound/soc/omap/omap-dmic.c new file +10 -0
+       res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
+       if (!res) {
+               dev_err(dmic->dev, "invalid dma resource\n");
+               ret = -ENODEV;
+               goto err_dai;
+       }
+       omap_dmic_dai_dma_params.dma_req = res->start;
+
+       pm_runtime_enable(dmic->dev);
+

Before accessing the below register, you should be doing a pm_runtime_get*()

Quoted 6 lines
sound/soc/omap/omap-dmic.c new file +6 -0
+       /* Disable lines while request is ongoing */
+       omap_dmic_write(dmic, OMAP_DMIC_CTRL, 0x00);
+
+       ret = snd_soc_register_dais(&pdev->dev, &omap_dmic_dai, 1);
+       if (ret)
+               goto err_dai;

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

Quoted 10 lines
sound/soc/omap/omap-dmic.c new file +10 -0
+
+       return 0;
+
+err_dai:
+       iounmap(dmic->io_base);
+err_res:
+       kfree(dmic);
+       return ret;
+}
+

<<snip>>
--
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

#3 lore raw

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

In reply to David Lambert

<<snip>>

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

Quoted 10 lines
sound/soc/omap/omap-dmic.c new file +10 -0
+
+static int omap_dmic_set_dai_sysclk(struct snd_soc_dai *dai,
+                                   int clk_id, unsigned int freq,
+                                   int dir)
+{
+       struct omap_dmic *dmic = snd_soc_dai_get_drvdata(dai);
+       struct clk *dmic_clk, *parent_clk;
+       int ret = 0;
+
+       dmic_clk = clk_get(NULL, "dmic_fck");

It is preferred to use device pointer. instead of NULL. (Applicable elsewhere)

Quoted 50 lines

+       if (IS_ERR(dmic_clk))
+               return -ENODEV;

sound/soc/omap/omap-dmic.c new file +48 -0
+
+       switch (clk_id) {
+       case OMAP_DMIC_SYSCLK_PAD_CLKS:
+               parent_clk = clk_get(NULL, "pad_clks_ck");
+               if (IS_ERR(parent_clk)) {
+                       ret = -ENODEV;
+                       goto err_par;
+               }
+               break;
+       case OMAP_DMIC_SYSCLK_SLIMBLUS_CLKS:
+               parent_clk = clk_get(NULL, "slimbus_clk");
+               if (IS_ERR(parent_clk)) {
+                       ret = -ENODEV;
+                       goto err_par;
+               }
+               break;
+       case OMAP_DMIC_SYSCLK_SYNC_MUX_CLKS:
+               parent_clk = clk_get(NULL, "dmic_sync_mux_ck");
+               if (IS_ERR(parent_clk)) {
+                       ret = -ENODEV;
+                       goto err_par;
+               }
+               break;
+       default:
+               dev_err(dai->dev, "clk_id not supported %d\n", clk_id);
+               ret = -EINVAL;
+               goto err_par;
+       }
+
+       if (dmic->sysclk != clk_id) {
+               /* reparent not allowed if a stream is ongoing */
+               if (dmic->active > 1) {
+                       ret = -EBUSY;
+                       goto err_busy;
+               }
+
+               /* disable clock while reparenting */
+               if (dmic->active == 1)
+                       pm_runtime_put_sync(dmic->dev);
+
+               ret = clk_set_parent(dmic_clk, parent_clk);
+
+               if (dmic->active == 1)
+                       pm_runtime_get_sync(dmic->dev);
+
+               dmic->sysclk = clk_id;
+       }
+

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

Quoted 10 lines
sound/soc/omap/omap-dmic.c new file +10 -0
+       dmic->clk_freq = clk_get_rate(dmic_clk);
+
+err_busy:
+       clk_put(parent_clk);
+err_par:
+       clk_put(dmic_clk);
+
+       return ret;
+}
+

<<snip>>
--
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

#8 lore raw

Re: [PATCH v3 2/4] OMAP4: hwmod: add entries for DMIC driver

In reply to David Lambert

Hi David,

I have few comments about the modification you did to the original code.

Quoted 4 lines · David

From: Benoit Cousson<[email protected]>

Adds HWMOD entries for the OMAP DMIC driver and creates a platform device. The HWMOD entires define the system

The changelog does not really reflect what the patch is doing. You are not creating a platform device in that patch.

Quoted 5 lines

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.

We already discussed that, but my S-O-B is missing.

Quoted 13 lines
---
  arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   91 ++++++++++++++++++++++++++++
  1 files changed, 91 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +0 -0
index 7274db4..f9b2ad3 100644
@@ -383,6 +383,95 @@ static struct omap_hwmod omap44xx_l4_wkup_hwmod = {
  };
 
  /*

arch/arm/mach-omap2/omap_hwmod_44xx_data.c static struct omap_hwmod omap44xx_l4_wkup_hwmod = { · line 395

Quoted 10 lines
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +10 -0
+ * '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),

SIDLE_SMART_WKUP flag is missing.

arch/arm/mach-omap2/omap_hwmod_44xx_data.c static struct omap_hwmod omap44xx_l4_wkup_hwmod = { · line 400

Quoted 5 lines
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +5 -0
+	.sysc_fields	=&omap_hwmod_sysc_type2,
+};
+
+static struct omap_hwmod_class omap44xx_dmic_hwmod_class = {
+	.name = "omap-dmic",

This is not the right name. Please stick to the original one from the HW spec. You can rename it the way you want in the device only.

Quoted 5 lines
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +5 -0
+	.sysc =&omap44xx_dmic_sysc,
+};
+
+/* dmic */
+static struct omap_hwmod omap44xx_dmic_hwmod;

arch/arm/mach-omap2/omap_hwmod_44xx_data.c static struct omap_hwmod omap44xx_l4_wkup_hwmod = { · line 415

Quoted 10 lines
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +10 -0
+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[] = {
+	{

it might not be useful for your driver, but we should use a name to differentiate the dual memory mapping here. It was introduce by Kishon in his McBSP series.

Quoted 63 lines
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +59 -0
+		.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
   */

arch/arm/mach-omap2/omap_hwmod_44xx_data.c static __initdata struct omap_hwmod *omap44xx_hwmods[] = { · line 919

Quoted 5 lines
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +2 -0
@@ -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,

This is not the right place, and a blank line is missing before and after.

Please find the fixed version below. This is based on top of the spinlock + mcspi + mcbsp to avoid conflict and to get the hwmod memory name support.

Regards,
Benoit

---

Quoted 1 line

From 01f72d4f3887d2356455bb4455cd0ba3c7eb4758 Mon Sep 17 00:00:00 2001

From: Benoit Cousson <[email protected]>
Date: Tue, 25 Jan 2011 22:01:00 +0000
Subject: [PATCH] OMAP4: hwmod data: Add entries for DMIC

Adds HWMOD entries for the OMAP DMIC. The HWMOD entires define the system resource requirements for the driver 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.

[[email protected]: Change the wrong hwmod name, add memory name, add missing flag and re-order structures]

---
 arch/arm/mach-omap2/omap_hwmod_44xx_data.c |   96 +++++++++++++++++++++++++++-
 1 files changed, 95 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +95 -1
index 6665922..703f3d4 100644
@@ -519,7 +519,6 @@ static struct omap_hwmod omap44xx_mpu_private_hwmod = {
  *  ctrl_module_pad_wkup
  *  ctrl_module_wkup
  *  debugss
- *  dmic
  *  efuse_ctrl_cust
  *  efuse_ctrl_std
  *  elm
@@ -646,6 +645,98 @@ static struct omap_hwmod omap44xx_dma_system_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 |
+			   SIDLE_SMART_WKUP),
+	.sysc_fields	= &omap_hwmod_sysc_type2,
+};
+
+static struct omap_hwmod_class omap44xx_dmic_hwmod_class = {
+	.name	= "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[] = {
+	{
+		.name		= "mpu",
+		.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[] = {
+	{
+		.name		= "dma",
+		.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		= "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),
+};
+
+/*
  * 'dsp' class
  * dsp sub-system
  */
@@ -3895,6 +3986,9 @@ static __initdata struct omap_hwmod *omap44xx_hwmods[] = {
 	/* dma class */
 	&omap44xx_dma_system_hwmod,
 
+	/* dmic class */
+	&omap44xx_dmic_hwmod,
+
 	/* dsp class */
 	&omap44xx_dsp_hwmod,
 	&omap44xx_dsp_c0_hwmod,
Signature · 1 line
1.7.0.4