Skip to contentSkip to conversation

ep93xx i2s audio

RFC PATCH Superseded Ryan Mallon 6 participants 10 messages May 26, 2010 – May 27, 2010

Subsystems (5)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover ep93xx i2s audio

The following patch series adds support for i2s audio on the ep93xx, with the Snapper CL15 used as an example implementation.

I have created psuedo clocks for sclk and lrclk as suggested by Hartley/Mark. This moves the sdiv/lrdiv calculation into ep93xx_i2s_hw_parms. The ep93xx documentation implies that lrclk is gated for unused bits (ie if lrdiv > word length). If this is true for all ep93xx i2s setups then the lrclk/sclk's could be replaced by a single audio rate clock.

I have fixed the enabling/disabling of the i2s peripheral, which corrects the problem I was having with playback sometimes resulting in noise.

I have also made a number of changes suggested from the first round of patches.

Ryan Mallon (3):
ep93xx i2s audio driver
ep93xx i2s core support
ep93xx i2s audio snapper cl15 support

 arch/arm/mach-ep93xx/clock.c                    |   69 ++++-
 arch/arm/mach-ep93xx/core.c                     |   31 ++
 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |   10 +
 arch/arm/mach-ep93xx/include/mach/platform.h    |    1 +
 arch/arm/mach-ep93xx/snappercl15.c              |    1 +
 sound/soc/Kconfig                               |    1 +
 sound/soc/Makefile                              |    1 +
 sound/soc/ep93xx/Kconfig                        |   18 +
 sound/soc/ep93xx/Makefile                       |   11 +
 sound/soc/ep93xx/ep93xx-i2s.c                   |  489 +++++++++++++++++++++++
 sound/soc/ep93xx/ep93xx-i2s.h                   |   25 ++
 sound/soc/ep93xx/ep93xx-pcm.c                   |  323 +++++++++++++++
 sound/soc/ep93xx/ep93xx-pcm.h                   |   22 +
 sound/soc/ep93xx/snappercl15.c                  |  143 +++++++
 14 files changed, 1144 insertions(+), 1 deletions(-)
 create mode 100644 sound/soc/ep93xx/Kconfig
 create mode 100644 sound/soc/ep93xx/Makefile
 create mode 100644 sound/soc/ep93xx/ep93xx-i2s.c
 create mode 100644 sound/soc/ep93xx/ep93xx-i2s.h
 create mode 100644 sound/soc/ep93xx/ep93xx-pcm.c
 create mode 100644 sound/soc/ep93xx/ep93xx-pcm.h
 create mode 100644 sound/soc/ep93xx/snappercl15.c
#1 lore raw

RFC PATCH v2 1/3 ep93xx i2s audio driver

Add ep93xx i2s audio driver

---
 sound/soc/Kconfig             |    1 +
 sound/soc/Makefile            |    1 +
 sound/soc/ep93xx/Kconfig      |    9 +
 sound/soc/ep93xx/Makefile     |    8 +
 sound/soc/ep93xx/ep93xx-i2s.c |  489 +++++++++++++++++++++++++++++++++++++++++
 sound/soc/ep93xx/ep93xx-i2s.h |   25 ++
 sound/soc/ep93xx/ep93xx-pcm.c |  323 +++++++++++++++++++++++++++
 sound/soc/ep93xx/ep93xx-pcm.h |   22 ++
 8 files changed, 878 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/ep93xx/Kconfig
 create mode 100644 sound/soc/ep93xx/Makefile
 create mode 100644 sound/soc/ep93xx/ep93xx-i2s.c
 create mode 100644 sound/soc/ep93xx/ep93xx-i2s.h
 create mode 100644 sound/soc/ep93xx/ep93xx-pcm.c
 create mode 100644 sound/soc/ep93xx/ep93xx-pcm.h
sound/soc/Kconfig +1 -0
index b1749bc..f7cb451 100644
@@ -28,6 +28,7 @@ source "sound/soc/atmel/Kconfig"
 source "sound/soc/au1x/Kconfig"
 source "sound/soc/blackfin/Kconfig"
 source "sound/soc/davinci/Kconfig"
+source "sound/soc/ep93xx/Kconfig"
 source "sound/soc/fsl/Kconfig"
 source "sound/soc/imx/Kconfig"
 source "sound/soc/omap/Kconfig"
sound/soc/Makefile +1 -0
index 1470141..55b711a 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_SND_SOC)	+= atmel/
 obj-$(CONFIG_SND_SOC)	+= au1x/
 obj-$(CONFIG_SND_SOC)	+= blackfin/
 obj-$(CONFIG_SND_SOC)	+= davinci/
+obj-$(CONFIG_SND_SOC)	+= ep93xx/
 obj-$(CONFIG_SND_SOC)	+= fsl/
 obj-$(CONFIG_SND_SOC)   += imx/
 obj-$(CONFIG_SND_SOC)	+= omap/
sound/soc/ep93xx/Kconfig new file +9 -0
new file mode 100644
index 0000000..ba66ac8
@@ -0,0 +1,9 @@
+config SND_EP93XX_SOC
+	tristate "SoC Audio support for the Cirrus Logic EP93xx series"
+	depends on ARCH_EP93XX && SND_SOC
+	help
+	  Say Y or M if you want to add support for codecs attached to
+	  the EP93xx I2S interface.
+
+config SND_EP93XX_SOC_I2S
+	tristate
sound/soc/ep93xx/Makefile new file +8 -0
new file mode 100644
index 0000000..0239da3
@@ -0,0 +1,8 @@
+# EP93xx Platform Support
+snd-soc-ep93xx-objs				:= ep93xx-pcm.o
+snd-soc-ep93xx-i2s-objs	 			:= ep93xx-i2s.o
+
+obj-$(CONFIG_SND_EP93XX_SOC)			+= snd-soc-ep93xx.o
+obj-$(CONFIG_SND_EP93XX_SOC_I2S)		+= snd-soc-ep93xx-i2s.o
+
+# EP93XX Machine Support
sound/soc/ep93xx/ep93xx-i2s.c new file +489 -0

489 lines not on this page · raw message

sound/soc/ep93xx/ep93xx-i2s.h new file +25 -0
new file mode 100644
index 0000000..830c793
@@ -0,0 +1,25 @@
+/*
+ * linux/sound/soc/ep93xx-i2s.h
+ * EP93xx I2S driver
+ *
+ * Copyright (C) 2010 Ryan Mallon <[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 _EP93XX_SND_SOC_I2S_H
+#define _EP93XX_SND_SOC_I2S_H
+
+/*
+ * These are the offsets for the LRDIV and SDIV fields in the syscon i2sclkdiv
+ * register.
+ */
+#define EP93XX_I2S_LRDIV	17
+#define EP93XX_I2S_SDIV		16
+
+extern struct snd_soc_dai ep93xx_i2s_dai;
+
+#endif /* _EP93XX_SND_SOC_I2S_H */
sound/soc/ep93xx/ep93xx-pcm.c new file +323 -0

323 lines not on this page · raw message

sound/soc/ep93xx/ep93xx-pcm.h new file +22 -0
new file mode 100644
index 0000000..4ffdd3f
@@ -0,0 +1,22 @@
+/*
+ * sound/soc/ep93xx/ep93xx-pcm.h - EP93xx ALSA PCM interface
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <[email protected]>
+ * Copyright (C) 2006 Applied Data Systems
+ *
+ * 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 _EP93XX_SND_SOC_PCM_H
+#define _EP93XX_SND_SOC_PCM_H
+
+struct ep93xx_pcm_dma_params {
+	char	*name;
+	int	dma_port;
+};
+
+extern struct snd_soc_platform ep93xx_soc_platform;
+
+#endif /* _EP93XX_SND_SOC_PCM_H */
Signature · 1 line
1.5.5.1
#2 lore raw

Re: [RFC PATCH v2 1/3] ep93xx i2s audio driver

Quoted 20 lines · Ryan Mallon

Add ep93xx i2s audio driver

---
 sound/soc/Kconfig             |    1 +
 sound/soc/Makefile            |    1 +
 sound/soc/ep93xx/Kconfig      |    9 +
 sound/soc/ep93xx/Makefile     |    8 +
 sound/soc/ep93xx/ep93xx-i2s.c |  489 +++++++++++++++++++++++++++++++++++++++++
 sound/soc/ep93xx/ep93xx-i2s.h |   25 ++
 sound/soc/ep93xx/ep93xx-pcm.c |  323 +++++++++++++++++++++++++++
 sound/soc/ep93xx/ep93xx-pcm.h |   22 ++
 8 files changed, 878 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/ep93xx/Kconfig
 create mode 100644 sound/soc/ep93xx/Makefile
 create mode 100644 sound/soc/ep93xx/ep93xx-i2s.c
 create mode 100644 sound/soc/ep93xx/ep93xx-i2s.h
 create mode 100644 sound/soc/ep93xx/ep93xx-pcm.c
 create mode 100644 sound/soc/ep93xx/ep93xx-pcm.h

Overall looks OK, just some comments below.

Quoted 6 lines
sound/soc/ep93xx/ep93xx-i2s.c new file +6 -0
+static void ep93xx_i2s_enable(struct ep93xx_i2s_info *info)
+{
+	int i;
+
+	/* Enable clocks */
+	clk_enable(info->mclk);

sound/soc/ep93xx/ep93xx-i2s.c line 126

Quoted 10 lines
sound/soc/ep93xx/ep93xx-i2s.c new file +10 -0
+	clk_enable(info->sclk);
+	clk_enable(info->lrclk);
+
+	/* Enable i2s */
+	ep93xx_i2s_write_reg(info, EP93XX_I2S_GLCTRL, 1);
+
+	/* Enable fifos */
+	for (i = 0; i < 3; i++) {
+		ep93xx_i2s_write_reg(info, EP93XX_I2S_RX0EN + (i * 4), 1);
+		ep93xx_i2s_write_reg(info, EP93XX_I2S_TX0EN + (i * 4), 1);

Just curious, do we always need to enable both the RX and TX FIFOs ? Is there unnecessary system overhead here when we have playback only or capture only use cases ?

sound/soc/ep93xx/ep93xx-pcm.c line 73

Quoted 4 lines
sound/soc/ep93xx/ep93xx-pcm.c new file +4 -0
+static void ep93xx_pcm_buffer_started(void *cookie,
+				      struct ep93xx_dma_buffer *buf)
+{
+}

Do we need this ?

sound/soc/ep93xx/ep93xx-pcm.c line 172

Quoted 5 lines
sound/soc/ep93xx/ep93xx-pcm.c new file +5 -0
+
+static int ep93xx_pcm_prepare(struct snd_pcm_substream *substream)
+{
+	return 0;
+}

This can be removed

Thanks

Liam

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

Re: [RFC PATCH v2 1/3] ep93xx i2s audio driver

In reply to Ryan Mallon

Hi,

Quoted 1 line · On Wednesday 26 May 2010 08:09:46 ext Ryan Mallon wrote:

Add ep93xx i2s audio driver

..

Quoted 8 lines
sound/soc/ep93xx/ep93xx-i2s.c new file +8 -0
+static void ep93xx_i2s_disable(struct ep93xx_i2s_info *info)
+{
+       int i;
+
+       /* Disable fifos */
+       for (i = 0; i < 3; i++) {
+               ep93xx_i2s_write_reg(info, EP93XX_I2S_RX0EN + (i * 4), 0);
+               ep93xx_i2s_write_reg(info, EP93XX_I2S_TX0EN + (i * 4), 0);

sound/soc/ep93xx/ep93xx-i2s.c line 147

Quoted 10 lines
sound/soc/ep93xx/ep93xx-i2s.c new file +10 -0
+       }
+
+       /* Disable i2s */
+       ep93xx_i2s_write_reg(info, EP93XX_I2S_GLCTRL, 0);
+
+       /* Disable clocks */
+       clk_disable(info->lrclk);
+       clk_disable(info->sclk);
+       clk_disable(info->mclk);
+}

I think this will break the other stream in duplex case, since you stop both FIFOs, and also disable the clocks.
Does the ep93xx supports duplex audio?

Signature · 1 line
P?ter
#4 lore raw

Re: [RFC PATCH v2 1/3] ep93xx i2s audio driver

In reply to Ryan Mallon
Quoted 17 lines · Ryan Mallon
sound/soc/ep93xx/ep93xx-i2s.h new file +11 -0
new file mode 100644
index 0000000..830c793
@@ -0,0 +1,25 @@
+/*
+ * linux/sound/soc/ep93xx-i2s.h
+ * EP93xx I2S driver
+ *
+ * Copyright (C) 2010 Ryan Mallon <[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.
+ *
+ */

sound/soc/ep93xx/ep93xx-i2s.h line 21

Quoted 10 lines
sound/soc/ep93xx/ep93xx-i2s.h new file +10 -0
+
+#ifndef _EP93XX_SND_SOC_I2S_H
+#define _EP93XX_SND_SOC_I2S_H
+
+/*
+ * These are the offsets for the LRDIV and SDIV fields in the syscon i2sclkdiv
+ * register.
+ */
+#define EP93XX_I2S_LRDIV	17
+#define EP93XX_I2S_SDIV		16

Looks like a minor ugly whitespace issue above.

-- Chase

#5 lore raw

Re: [RFC PATCH v2 1/3] ep93xx i2s audio driver

Hi,

Quoted 5 lines

sound/soc/ep93xx/ep93xx-i2s.h line 21

Quoted 2 lines
sound/soc/ep93xx/ep93xx-i2s.h new file +2 -0
+#define EP93XX_I2S_LRDIV	17
+#define EP93XX_I2S_SDIV		16

Looks like a minor ugly whitespace issue above.

Only in the indentation of the patch...
If you look at the code with the leading '+' removed, indentation is OK.

Lothar Waßmann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstraße 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Geschäftsführer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | [email protected]
___________________________________________________________
#6 lore raw

Re: [RFC PATCH v2 1/3] ep93xx i2s audio driver

In reply to Ryan Mallon

sound/soc/ep93xx/ep93xx-i2s.c line 290

Quoted 13 lines · Ryan Mallon
sound/soc/ep93xx/ep93xx-i2s.c new file +13 -0
+	/* 
+	 * Calculate the sdiv (bit clock) and lrdiv (left/right clock) values. 
+	 * If the lrclk is pulse length is larger than the word size, then the
+	 * bit clock will be gated for the unused bits.
+	 */
+	div = (clk_get_rate(info->mclk) / params_rate(params)) * 
+		params_channels(params);
+	for (sdiv = 2; !found && sdiv <= 4; sdiv += 2)
+		for (lrdiv = 32; !found && lrdiv <= 128; lrdiv <<= 1)
+			if (sdiv * lrdiv == div)
+				found = 1;
+	if (!found)
+		return -EINVAL;

This suggests that the device has a single LRCLK for both TX and RX and therefore the DAI should have symmetric_rates set so that applications are told about this restriction and the upper layers prevent them from setting asymmetric rates (which would result in the first direction ending up running at the wrong rate when the second direction starts).

sound/soc/ep93xx/ep93xx-i2s.c line 400

Quoted 10 lines
sound/soc/ep93xx/ep93xx-i2s.c new file +9 -0
+	err = snd_soc_register_dai(&ep93xx_i2s_dai);
+	if (err)
+		goto fail_free_info;
 
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		err = -ENODEV;
+		goto fail_unregister_dai;
+	}
+		

The DAI registration is happening at the wrong place - you're telling ASoC the DAI is ready before you've finished acquiring the resources it needs to run, meaning that there's a race condition where something may try to start audio up while the probe is still running. Generally DAI registration should be the last thing your driver does.

sound/soc/ep93xx/ep93xx-i2s.c line 462

Quoted 13 lines
sound/soc/ep93xx/ep93xx-i2s.c new file +13 -0
+static int __devexit ep93xx_i2s_remove(struct platform_device *pdev)
+{
+	struct ep93xx_i2s_info *info = ep93xx_i2s_dai.private_data;
+	
+	clk_put(info->lrclk);
+	clk_put(info->sclk);
+	clk_put(info->mclk);
+	iounmap(info->regs);
+	release_mem_region(info->mem->start, resource_size(info->mem));
+	snd_soc_unregister_dai(&ep93xx_i2s_dai);
+	kfree(info);
+	return 0;
+}

Here you should free the DAI before anything else for the same reason as above.

sound/soc/ep93xx/ep93xx-i2s.h line 21

Quoted 6 lines
sound/soc/ep93xx/ep93xx-i2s.h new file +6 -0
+/*
+ * These are the offsets for the LRDIV and SDIV fields in the syscon i2sclkdiv
+ * register.
+ */
+#define EP93XX_I2S_LRDIV	17
+#define EP93XX_I2S_SDIV		16

Most of the other defines are in the driver - should these be there (or removed)?

sound/soc/ep93xx/ep93xx-pcm.c line 172

Quoted 4 lines
sound/soc/ep93xx/ep93xx-pcm.c new file +4 -0
+static int ep93xx_pcm_prepare(struct snd_pcm_substream *substream)
+{
+	return 0;
+}

Remove this if no code is needed.

#7 lore raw

RFC PATCH v2 2/3 ep93xx i2s core support

In reply to Ryan Mallon

Add core support for ep93xx i2s driver

---
 arch/arm/mach-ep93xx/clock.c                    |   69 ++++++++++++++++++++++-
 arch/arm/mach-ep93xx/core.c                     |   31 ++++++++++
 arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h |   10 +++
 arch/arm/mach-ep93xx/include/mach/platform.h    |    1 +
 4 files changed, 110 insertions(+), 1 deletions(-)
arch/arm/mach-ep93xx/clock.c +68 -1
index 5f80092..503d430 100644
@@ -43,7 +43,8 @@ static unsigned long get_uart_rate(struct clk *clk);
 
 static int set_keytchclk_rate(struct clk *clk, unsigned long rate);
 static int set_div_rate(struct clk *clk, unsigned long rate);
-
+static int set_i2s_sclk_rate(struct clk *clk, unsigned long rate);
+static int set_i2s_lrclk_rate(struct clk *clk, unsigned long rate);
 
 static struct clk clk_xtali = {
 	.rate		= EP93XX_EXT_CLK_RATE,
@@ -108,6 +109,31 @@ static struct clk clk_video = {
 	.set_rate	= set_div_rate,
 };
 
+static struct clk clk_i2s_mclk = {
+	.sw_locked	= 1,
+	.enable_reg	= EP93XX_SYSCON_I2SCLKDIV,
+	.enable_mask	= (EP93XX_SYSCON_CLKDIV_ENABLE  |
+			   EP93XX_SYSCON_I2SCLKDIV_SPOL |
+			   EP93XX_SYSCON_I2SCLKDIV_ORIDE),
+	.set_rate	= set_div_rate,
+};
+
+static struct clk clk_i2s_sclk = {
+	.sw_locked	= 1,
+	.parent		= &clk_i2s_mclk,
+	.enable_reg	= EP93XX_SYSCON_I2SCLKDIV,
+	.enable_mask	= EP93XX_SYSCON_I2SCLKDIV_SENA,
+	.set_rate	= set_i2s_sclk_rate,
+};
+
+static struct clk clk_i2s_lrclk = {
+	.sw_locked	= 1,
+	.parent		= &clk_i2s_sclk,
+	.enable_reg	= EP93XX_SYSCON_I2SCLKDIV,
+	.enable_mask	= EP93XX_SYSCON_I2SCLKDIV_SENA,
+	.set_rate	= set_i2s_lrclk_rate,
+};
+
 /* DMA Clocks */
 static struct clk clk_m2p0 = {
 	.parent		= &clk_h,
@@ -186,6 +212,9 @@ static struct clk_lookup clocks[] = {
 	INIT_CK("ep93xx-ohci",		NULL,		&clk_usb_host),
 	INIT_CK("ep93xx-keypad",	NULL,		&clk_keypad),
 	INIT_CK("ep93xx-fb",		NULL,		&clk_video),
+	INIT_CK("ep93xx-i2s",		"mclk",		&clk_i2s_mclk),
+	INIT_CK("ep93xx-i2s",		"sclk",		&clk_i2s_sclk),
+	INIT_CK("ep93xx-i2s",		"lrclk",	&clk_i2s_lrclk),
 	INIT_CK(NULL,			"pwm_clk",	&clk_pwm),
 	INIT_CK(NULL,			"m2p0",		&clk_m2p0),
 	INIT_CK(NULL,			"m2p1",		&clk_m2p1),
@@ -396,6 +425,44 @@ static int set_div_rate(struct clk *clk, unsigned long rate)
 	return 0;
 }
 
+static int set_i2s_sclk_rate(struct clk *clk, unsigned long rate)
+{
+	unsigned val = __raw_readl(clk->enable_reg);
+
+	if (rate == clk_i2s_mclk.rate / 2)
+		ep93xx_syscon_swlocked_write(val & ~EP93XX_I2SCLKDIV_SDIV, 
+					     clk->enable_reg);
+	else if (rate == clk_i2s_mclk.rate / 4)
+		ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_SDIV, 
+					     clk->enable_reg);
+	else
+		return -EINVAL;
+
+	clk_i2s_sclk.rate = rate;
+	return 0;
+}
+
+static int set_i2s_lrclk_rate(struct clk *clk, unsigned long rate)
+{
+	unsigned val = __raw_readl(clk->enable_reg) & 
+		~EP93XX_I2SCLKDIV_LRDIV_MASK;
+	
+	if (rate == clk_i2s_sclk.rate / 32)
+		ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_LRDIV32,
+					     clk->enable_reg);
+	else if (rate == clk_i2s_sclk.rate / 64)
+		ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_LRDIV64,
+					     clk->enable_reg);
+	else if (rate == clk_i2s_sclk.rate / 128)
+		ep93xx_syscon_swlocked_write(val | EP93XX_I2SCLKDIV_LRDIV128,
+					     clk->enable_reg);
+	else
+		return -EINVAL;
+
+	clk_i2s_lrclk.rate = rate;
+	return 0;
+}
+
 int clk_set_rate(struct clk *clk, unsigned long rate)
 {
 	if (clk->set_rate)
arch/arm/mach-ep93xx/core.c +31 -0
index 90fb591..c04fd6f 100644
@@ -617,6 +617,37 @@ void ep93xx_keypad_release_gpio(struct platform_device *pdev)
 }
 EXPORT_SYMBOL(ep93xx_keypad_release_gpio);
 
+/*************************************************************************
+ * EP93xx I2S audio peripheral handling
+ *************************************************************************/
+static struct resource ep93xx_i2s_resource[] = {
+	{
+		.start	= EP93XX_I2S_PHYS_BASE,
+		.end	= EP93XX_I2S_PHYS_BASE + 0x100 - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device ep93xx_i2s_device = {
+	.name		= "ep93xx-i2s",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(ep93xx_i2s_resource),
+	.resource	= ep93xx_i2s_resource,
+};
+
+void __init ep93xx_register_i2s(unsigned pins)
+{
+	if (pins != EP93XX_SYSCON_DEVCFG_I2SONSSP &&
+	    pins != EP93XX_SYSCON_DEVCFG_I2SONAC97) {
+		pr_err("Invalid I2S pin configuration - not registering\n");
+		return;
+	}
+
+	ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONSSP |
+				 EP93XX_SYSCON_DEVCFG_I2SONAC97);
+	ep93xx_devcfg_set_bits(pins);
+	platform_device_register(&ep93xx_i2s_device);
+}
 
 extern void ep93xx_gpio_init(void);
 
arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h +10 -0
index 93e2ecc..3fbb095 100644
@@ -93,6 +93,7 @@
 /* APB peripherals */
 #define EP93XX_TIMER_BASE		EP93XX_APB_IOMEM(0x00010000)
 
+#define EP93XX_I2S_PHYS_BASE		EP93XX_APB_PHYS(0x00020000)
 #define EP93XX_I2S_BASE			EP93XX_APB_IOMEM(0x00020000)
 
 #define EP93XX_SECURITY_BASE		EP93XX_APB_IOMEM(0x00030000)
@@ -193,6 +194,15 @@
 #define EP93XX_SYSCON_CLKDIV_ESEL	(1<<14)
 #define EP93XX_SYSCON_CLKDIV_PSEL	(1<<13)
 #define EP93XX_SYSCON_CLKDIV_PDIV_SHIFT	8
+#define EP93XX_SYSCON_I2SCLKDIV		EP93XX_SYSCON_REG(0x8c)
+#define EP93XX_SYSCON_I2SCLKDIV_SENA	(1<<31)
+#define EP93XX_SYSCON_I2SCLKDIV_ORIDE   (1<<29)
+#define EP93XX_SYSCON_I2SCLKDIV_SPOL	(1<<19)
+#define EP93XX_I2SCLKDIV_SDIV		(1 << 16)
+#define EP93XX_I2SCLKDIV_LRDIV32	(0 << 17)
+#define EP93XX_I2SCLKDIV_LRDIV64	(1 << 17)
+#define EP93XX_I2SCLKDIV_LRDIV128 	(2 << 17)
+#define EP93XX_I2SCLKDIV_LRDIV_MASK 	(3 << 17)
 #define EP93XX_SYSCON_KEYTCHCLKDIV	EP93XX_SYSCON_REG(0x90)
 #define EP93XX_SYSCON_KEYTCHCLKDIV_TSEN	(1<<31)
 #define EP93XX_SYSCON_KEYTCHCLKDIV_ADIV	(1<<16)
arch/arm/mach-ep93xx/include/mach/platform.h +1 -0
index c6dc14d..9252adf 100644
@@ -43,6 +43,7 @@ void ep93xx_pwm_release_gpio(struct platform_device *pdev);
 void ep93xx_register_keypad(struct ep93xx_keypad_platform_data *data);
 int ep93xx_keypad_acquire_gpio(struct platform_device *pdev);
 void ep93xx_keypad_release_gpio(struct platform_device *pdev);
+void ep93xx_register_i2s(unsigned pins);
 
 void ep93xx_init_devices(void);
 extern struct sys_timer ep93xx_timer;
Signature · 1 line
1.5.5.1
#8 lore raw

RFC PATCH v2 3/3 ep93xx i2s audio snapper cl15 support

In reply to Ryan Mallon

Add support for i2s audio on Bluewater Systems Snapper CL15 module

---
 arch/arm/mach-ep93xx/snappercl15.c |    1 +
 sound/soc/ep93xx/Kconfig           |    9 ++
 sound/soc/ep93xx/Makefile          |    3 +
 sound/soc/ep93xx/snappercl15.c     |  143 ++++++++++++++++++++++++++++++++++++
 4 files changed, 156 insertions(+), 0 deletions(-)
 create mode 100644 sound/soc/ep93xx/snappercl15.c
arch/arm/mach-ep93xx/snappercl15.c +1 -0
index 51134b0..d4ca5cc 100644
@@ -157,6 +157,7 @@ static void __init snappercl15_init_machine(void)
 	ep93xx_register_i2c(&snappercl15_i2c_gpio_data, snappercl15_i2c_data,
 			    ARRAY_SIZE(snappercl15_i2c_data));
 	ep93xx_register_fb(&snappercl15_fb_info);
+	ep93xx_register_i2s(EP93XX_SYSCON_DEVCFG_I2SONAC97);
 	platform_device_register(&snappercl15_nand_device);
 }
 
sound/soc/ep93xx/Kconfig +9 -0
index ba66ac8..f617f56 100644
@@ -7,3 +7,12 @@ config SND_EP93XX_SOC
 
 config SND_EP93XX_SOC_I2S
 	tristate
+
+config SND_EP93XX_SOC_SNAPPERCL15
+        tristate "SoC Audio support for Bluewater Systems Snapper CL15 module"
+        depends on SND_EP93XX_SOC && MACH_SNAPPER_CL15
+        select SND_EP93XX_SOC_I2S
+        select SND_SOC_TLV320AIC23
+        help
+          Say Y or M here if you want to add support for I2S audio on the
+          Bluewater Systems Snapper CL15 module.
sound/soc/ep93xx/Makefile +3 -0
index 0239da3..272e60f 100644
@@ -6,3 +6,6 @@ obj-$(CONFIG_SND_EP93XX_SOC)			+= snd-soc-ep93xx.o
 obj-$(CONFIG_SND_EP93XX_SOC_I2S)		+= snd-soc-ep93xx-i2s.o
 
 # EP93XX Machine Support
+snd-soc-snappercl15-objs			:= snappercl15.o
+
+obj-$(CONFIG_SND_EP93XX_SOC_SNAPPERCL15)	+= snd-soc-snappercl15.o
sound/soc/ep93xx/snappercl15.c new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
1.5.5.1
#9 lore raw
In reply to Ryan Mallon
Quoted 10 lines · Ryan Mallon

The following patch series adds support for i2s audio on the ep93xx, with the Snapper CL15 used as an example implementation.

I have created psuedo clocks for sclk and lrclk as suggested by Hartley/Mark. This moves the sdiv/lrdiv calculation into ep93xx_i2s_hw_parms. The ep93xx documentation implies that lrclk is gated for unused bits (ie if lrdiv > word length). If this is true for all ep93xx i2s setups then the lrclk/sclk's could be replaced by a single audio rate clock.

Quoted 3 lines

I have fixed the enabling/disabling of the i2s peripheral, which corrects the problem I was having with playback sometimes resulting in noise.

Cool!

As I looked through the patches briefly, I noticed that the first patch depends on the second. I think they should be swapped in order so that it is compilable after each commit. This is important when using tools like git bisect.

-- Chase