Skip to contentSkip to conversation

EXYNOS5: Add Audio support

PATCH Superseded Rajeshwari Shinde 5 participants 19 messages Aug 14, 2012 – Aug 22, 2012

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover EXYNOS5: Add Audio support

This patchset adds the audio support for EXYNOS5.
This patchset plays a predefined beep sound.

Rajeshwari Shinde (9):
SOUND: Add I2S driver
SOUND: Add WM8994 codec
Sound: Add command for audio playback
EXYNOS: Add I2S registers
EXYNOS: Add parameters required by I2S
EXYNOS: Add pinmux for I2S
EXYNOS: Add I2S base address
EXYNOS: Add clock for I2S
EXYNOS5: Enable Sound

 Makefile                                    |    1 +
 arch/arm/cpu/armv7/exynos/clock.c           |  119 ++++
 arch/arm/cpu/armv7/exynos/pinmux.c          |   12 +
 arch/arm/include/asm/arch-exynos/clk.h      |    3 +
 arch/arm/include/asm/arch-exynos/clock.h    |   29 +
 arch/arm/include/asm/arch-exynos/cpu.h      |    3 +
 arch/arm/include/asm/arch-exynos/i2s-regs.h |   66 +++
 arch/arm/include/asm/arch-exynos/periph.h   |    1 +
 arch/arm/include/asm/arch-exynos/sound.h    |   44 ++
 common/Makefile                             |    1 +
 common/cmd_sound.c                          |   90 +++
 drivers/sound/Makefile                      |   48 ++
 drivers/sound/i2s.c                         |  358 ++++++++++++
 drivers/sound/sound.c                       |  220 ++++++++
 drivers/sound/wm8994.c                      |  781 +++++++++++++++++++++++++++
 drivers/sound/wm8994.h                      |   87 +++
 drivers/sound/wm8994_registers.h            |  299 ++++++++++
 include/configs/smdk5250.h                  |    8 +
 include/i2s.h                               |  127 +++++
 include/sound.h                             |   62 +++
 20 files changed, 2359 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-exynos/i2s-regs.h
 create mode 100644 arch/arm/include/asm/arch-exynos/sound.h
 create mode 100644 common/cmd_sound.c
 create mode 100644 drivers/sound/Makefile
 create mode 100644 drivers/sound/i2s.c
 create mode 100644 drivers/sound/sound.c
 create mode 100644 drivers/sound/wm8994.c
 create mode 100644 drivers/sound/wm8994.h
 create mode 100644 drivers/sound/wm8994_registers.h
 create mode 100644 include/i2s.h
 create mode 100644 include/sound.h
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 1/9 SOUND: Add I2S driver

This patch adds driver for I2S interface

---
 Makefile               |    1 +
 drivers/sound/Makefile |   47 +++++++
 drivers/sound/i2s.c    |  358 ++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/sound/sound.c  |  220 +++++++++++++++++++++++++++++
 include/i2s.h          |  127 +++++++++++++++++
 include/sound.h        |   62 +++++++++
 6 files changed, 815 insertions(+), 0 deletions(-)
 create mode 100644 drivers/sound/Makefile
 create mode 100644 drivers/sound/i2s.c
 create mode 100644 drivers/sound/sound.c
 create mode 100644 include/i2s.h
 create mode 100644 include/sound.h
Makefile +1 -0
index 6e8b5a7..b914980 100644
@@ -288,6 +288,7 @@ LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o
 endif
 LIBS += drivers/rtc/librtc.o
 LIBS += drivers/serial/libserial.o
+LIBS += drivers/sound/libsound.o
 ifeq ($(CONFIG_GENERIC_LPC_TPM),y)
 LIBS += drivers/tpm/libtpm.o
 endif
drivers/sound/Makefile new file +47 -0

47 lines not on this page · raw message

drivers/sound/i2s.c new file +358 -0

358 lines not on this page · raw message

drivers/sound/sound.c new file +220 -0

220 lines not on this page · raw message

include/i2s.h new file +127 -0

127 lines not on this page · raw message

include/sound.h new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 1/9 SOUND: Add I2S driver

I don't have any comment on the body of the patch, but calling this an i2s patch is misleading. I2s is a generic standard for moving stereo audio around, and many chips support it.

This patch looks like i2s support for a specific codec chip and the filenames should reflect that.

#3 lore raw

PATCH 1/9 SOUND: Add I2S driver

Hi Andrew,

Thank you for comments.

Quoted 7 lines · Andrew Dyer

I don't have any comment on the body of the patch, but calling this an i2s patch is misleading. I2s is a generic standard for moving stereo audio around, and many chips support it.

This patch looks like i2s support for a specific codec chip and the filenames should reflect that.

In this patch we can support different codecs without doing any changes to i2s files.
The only change would be in sound.c, where you have to check for specific codec required and set values accordingly.
We use I2S1 here, but it is not specific to any particular codec.

Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Rajeshwari Shinde.

#4 lore raw

PATCH 1/9 SOUND: Add I2S driver

The code in the i2s.c file is still full of samsung soc specific stuff, so I think the filename is misleading. Something like samsung-i2s.c would be more appropriate.

Quoted 26 lines · Rajeshwari Birje

Hi Andrew,

Thank you for comments.

Quoted 1 line · Andrew Dyer

I don't have any comment on the body of the patch, but calling this an

i2s

Quoted 6 lines

patch is misleading. I2s is a generic standard for moving stereo audio around, and many chips support it.

This patch looks like i2s support for a specific codec chip and the filenames should reflect that.

In this patch we can support different codecs without doing any changes to i2s files.
The only change would be in sound.c, where you have to check for specific codec required and set values accordingly.
We use I2S1 here, but it is not specific to any particular codec.

Quoted 5 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Rajeshwari Shinde.

#5 lore raw

PATCH 1/9 SOUND: Add I2S driver

Quoted 3 lines · On Friday 17 August 2012 08:48:59 Andrew Dyer wrote:

The code in the i2s.c file is still full of samsung soc specific stuff, so I think the filename is misleading. Something like samsung-i2s.c would be more appropriate.

+1
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/8b1aae2e/attachment.pgp>

#6 lore raw

PATCH 1/9 SOUND: Add I2S driver

Hi,

Quoted 6 lines · Mike Frysinger
Quoted 3 lines · On Friday 17 August 2012 08:48:59 Andrew Dyer wrote:

The code in the i2s.c file is still full of samsung soc specific stuff, so I think the filename is misleading. Something like samsung-i2s.c would be more appropriate.

+1

Ok will do so and resend the patches.

Quoted 1 line

-mike

Regards,
Rajeshwari Shinde.

#7 lore raw

PATCH 2/9 SOUND: Add WM8994 codec

In reply to Rajeshwari Shinde

This pastc adds driver for audio codec WM8994

---
 drivers/sound/Makefile           |    1 +
 drivers/sound/wm8994.c           |  781 ++++++++++++++++++++++++++++++++++++++
 drivers/sound/wm8994.h           |   87 +++++
 drivers/sound/wm8994_registers.h |  299 +++++++++++++++
 4 files changed, 1168 insertions(+), 0 deletions(-)
 create mode 100644 drivers/sound/wm8994.c
 create mode 100644 drivers/sound/wm8994.h
 create mode 100644 drivers/sound/wm8994_registers.h
drivers/sound/Makefile +1 -0
index 60d6af7..51524ee 100644
@@ -27,6 +27,7 @@ LIB	:= $(obj)libsound.o
 
 COBJS-$(CONFIG_SOUND) += sound.o
 COBJS-$(CONFIG_I2S) += i2s.o
+COBJS-$(CONFIG_SOUND_WM8994) += wm8994.o
 
 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
drivers/sound/wm8994.c new file +781 -0

781 lines not on this page · raw message

drivers/sound/wm8994.h new file +87 -0

87 lines not on this page · raw message

drivers/sound/wm8994_registers.h new file +299 -0

299 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#8 lore raw

PATCH 3/9 Sound: Add command for audio playback

In reply to Rajeshwari Shinde

This patch adds command to test audio playback.
sound init - Initialises the audio subsystem (i2s and wm8994 codec) sound play - Plays predefined the audio data.

---
 common/Makefile    |    1 +
 common/cmd_sound.c |   90 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_sound.c
common/Makefile +1 -0
index 483eb4d..a21cac9 100644
@@ -73,6 +73,7 @@ COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
 COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
 COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
 COBJS-$(CONFIG_CMD_DATE) += cmd_date.o
+COBJS-$(CONFIG_CMD_SOUND) += cmd_sound.o
 ifdef CONFIG_4xx
 COBJS-$(CONFIG_CMD_SETGETDCR) += cmd_dcr.o
 endif
common/cmd_sound.c new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#9 lore raw

PATCH 4/9 EXYNOS: Add I2S registers

In reply to Rajeshwari Shinde

This patch add I2S registers

---
 arch/arm/include/asm/arch-exynos/i2s-regs.h |   66 +++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-exynos/i2s-regs.h
arch/arm/include/asm/arch-exynos/i2s-regs.h new file +66 -0
new file mode 100644
index 0000000..2326ca0
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * R. Chandrasekar <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __I2S_REGS_H__
+#define __I2S_REGS_H__
+
+#define CON_TXFIFO_FULL		(1 << 8)
+#define CON_TXCH_PAUSE		(1 << 4)
+#define CON_ACTIVE		(1 << 0)
+
+#define MOD_BLCP_SHIFT		24
+#define MOD_BLCP_16BIT		(0 << MOD_BLCP_SHIFT)
+#define MOD_BLCP_8BIT		(1 << MOD_BLCP_SHIFT)
+#define MOD_BLCP_24BIT		(2 << MOD_BLCP_SHIFT)
+#define MOD_BLCP_MASK		(3 << MOD_BLCP_SHIFT)
+
+#define MOD_BLC_16BIT		(0 << 13)
+#define MOD_BLC_8BIT		(1 << 13)
+#define MOD_BLC_24BIT		(2 << 13)
+#define MOD_BLC_MASK		(3 << 13)
+
+#define MOD_SLAVE		(1 << 11)
+#define MOD_MASK		(3 << 8)
+#define MOD_LR_LLOW		(0 << 7)
+#define MOD_LR_RLOW		(1 << 7)
+#define MOD_SDF_IIS		(0 << 5)
+#define MOD_SDF_MSB		(1 << 5)
+#define MOD_SDF_LSB		(2 << 5)
+#define MOD_SDF_MASK		(3 << 5)
+#define MOD_RCLK_256FS		(0 << 3)
+#define MOD_RCLK_512FS		(1 << 3)
+#define MOD_RCLK_384FS		(2 << 3)
+#define MOD_RCLK_768FS		(3 << 3)
+#define MOD_RCLK_MASK		(3 << 3)
+#define MOD_BCLK_32FS		(0 << 1)
+#define MOD_BCLK_48FS		(1 << 1)
+#define MOD_BCLK_16FS		(2 << 1)
+#define MOD_BCLK_24FS		(3 << 1)
+#define MOD_BCLK_MASK		(3 << 1)
+
+#define MOD_CDCLKCON		(1 << 12)
+
+#define FIC_TXFLUSH		(1 << 15)
+#define FIC_RXFLUSH		(1 << 7)
+
+#endif /* __I2S_REGS_H__ */
Signature · 1 line
1.7.4.4
#10 lore raw

PATCH 5/9 EXYNOS: Add parameters required by I2S

In reply to Rajeshwari Shinde

This patch adds the audio parameters required by the I2S to play the predefined audio data.

---
 arch/arm/include/asm/arch-exynos/sound.h |   44 ++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-exynos/sound.h
arch/arm/include/asm/arch-exynos/sound.h new file +44 -0
new file mode 100644
index 0000000..d25d4f2
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * Rajeshwari Shinde <[email protected]>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * 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., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+
+#ifndef __SOUND_ARCH_H__
+#define __SOUND_ARCH_H__
+
+/* I2S values */
+#define I2S_PLL_CLK		192000000
+#define I2S_SAMPLING_RATE	48000
+#define I2S_BITS_PER_SAMPLE	16
+#define I2S_CHANNELS		2
+#define I2S_RFS			256
+#define I2S_BFS			32
+
+/* I2C values */
+#define AUDIO_I2C_BUS		1
+#define AUDIO_I2C_REG		0x34
+
+/* Audio Codec */
+#define AUDIO_CODEC		"wm8994"
+
+#define AUDIO_COMPAT		1
+#endif
Signature · 1 line
1.7.4.4
#11 lore raw

PATCH 6/9 EXYNOS: Add pinmux for I2S

In reply to Rajeshwari Shinde

This patch adds pinmux support for I2S1

---
 arch/arm/cpu/armv7/exynos/pinmux.c        |   12 ++++++++++++
 arch/arm/include/asm/arch-exynos/periph.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +12 -0
index 13f75e0..ba25f6c 100644
@@ -273,6 +273,15 @@ void exynos5_spi_config(int peripheral)
 	}
 }
 
+void exynos5_i2s_config(int peripheral)
+{
+	int i;
+	struct exynos5_gpio_part1 *gpio1 =
+		(struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1();
+	for (i = 0; i < 5; i++)
+		s5p_gpio_cfg_pin(&gpio1->b0, i, GPIO_FUNC(0x02));
+}
+
 static int exynos5_pinmux_config(int peripheral, int flags)
 {
 	switch (peripheral) {
@@ -307,6 +316,9 @@ static int exynos5_pinmux_config(int peripheral, int flags)
 	case PERIPH_ID_SPI4:
 		exynos5_spi_config(peripheral);
 		break;
+	case PERIPH_ID_I2S1:
+		exynos5_i2s_config(peripheral);
+		break;
 	default:
 		debug("%s: invalid peripheral %d", __func__, peripheral);
 		return -1;
arch/arm/include/asm/arch-exynos/periph.h +1 -0
index dafc3f3..404e5db 100644
@@ -38,6 +38,7 @@ enum periph_id {
 	PERIPH_ID_I2C5,
 	PERIPH_ID_I2C6,
 	PERIPH_ID_I2C7,
+	PERIPH_ID_I2S1,
 	PERIPH_ID_SDMMC0,
 	PERIPH_ID_SDMMC1,
 	PERIPH_ID_SDMMC2,
Signature · 1 line
1.7.4.4
#12 lore raw

PATCH 6/9 EXYNOS: Add pinmux for I2S

hi,

Quoted 13 lines · Rajeshwari Shinde

This patch adds pinmux support for I2S1

---
 arch/arm/cpu/armv7/exynos/pinmux.c        |   12 ++++++++++++
 arch/arm/include/asm/arch-exynos/periph.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +0 -0
index 13f75e0..ba25f6c 100644

arch/arm/cpu/armv7/exynos/pinmux.c void exynos5_spi_config(int peripheral) · line 277

Quoted 5 lines
arch/arm/cpu/armv7/exynos/pinmux.c +1 -0
@@ -273,6 +273,15 @@ void exynos5_spi_config(int peripheral)
        }
 }
 
 
+void exynos5_i2s_config(int peripheral)

make it static.

Quoted 36 lines
arch/arm/cpu/armv7/exynos/pinmux.c +8 -0
+{
+       int i;
+       struct exynos5_gpio_part1 *gpio1 =
+               (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1();
+       for (i = 0; i < 5; i++)
+               s5p_gpio_cfg_pin(&gpio1->b0, i, GPIO_FUNC(0x02));
+}
+
 static int exynos5_pinmux_config(int peripheral, int flags)
 {
        switch (peripheral) {
arch/arm/cpu/armv7/exynos/pinmux.c +3 -0
@@ -307,6 +316,9 @@ static int exynos5_pinmux_config(int peripheral, int flags)
        case PERIPH_ID_SPI4:
                exynos5_spi_config(peripheral);
                break;
+       case PERIPH_ID_I2S1:
+               exynos5_i2s_config(peripheral);
+               break;
        default:
                debug("%s: invalid peripheral %d", __func__, peripheral);
                return -1;
arch/arm/include/asm/arch-exynos/periph.h +1 -1
index dafc3f3..404e5db 100644
@@ -38,6 +38,7 @@ enum periph_id {
        PERIPH_ID_I2C5,
        PERIPH_ID_I2C6,
        PERIPH_ID_I2C7,
+       PERIPH_ID_I2S1,
        PERIPH_ID_SDMMC0,
        PERIPH_ID_SDMMC1,
        PERIPH_ID_SDMMC2,
--

1.7.4.4

Signature · 2 lines
with warm regards,
Chander Kashyap
#13 lore raw

PATCH 6/9 EXYNOS: Add pinmux for I2S

Hi Chander,

Quoted 20 lines · Chander Kashyap

hi,

Quoted 16 lines · Rajeshwari Shinde

This patch adds pinmux support for I2S1

---
 arch/arm/cpu/armv7/exynos/pinmux.c        |   12 ++++++++++++
 arch/arm/include/asm/arch-exynos/periph.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/pinmux.c +0 -0
index 13f75e0..ba25f6c 100644
@@ -273,6 +273,15 @@ void exynos5_spi_config(int peripheral)
        }
 }
 
Quoted 2 lines

arch/arm/cpu/armv7/exynos/pinmux.c void exynos5_spi_config(int peripheral) · line 276

Quoted 1 line
arch/arm/cpu/armv7/exynos/pinmux.c +1 -0
+void exynos5_i2s_config(int peripheral)

make it static.

- Ok

Quoted 39 lines
Quoted 34 lines
arch/arm/cpu/armv7/exynos/pinmux.c +11 -0
+{
+       int i;
+       struct exynos5_gpio_part1 *gpio1 =
+               (struct exynos5_gpio_part1 *) samsung_get_base_gpio_part1();
+       for (i = 0; i < 5; i++)
+               s5p_gpio_cfg_pin(&gpio1->b0, i, GPIO_FUNC(0x02));
+}
+
 static int exynos5_pinmux_config(int peripheral, int flags)
 {
        switch (peripheral) {
@@ -307,6 +316,9 @@ static int exynos5_pinmux_config(int peripheral, int flags)
        case PERIPH_ID_SPI4:
                exynos5_spi_config(peripheral);
                break;
+       case PERIPH_ID_I2S1:
+               exynos5_i2s_config(peripheral);
+               break;
        default:
                debug("%s: invalid peripheral %d", __func__, peripheral);
                return -1;
arch/arm/include/asm/arch-exynos/periph.h +1 -1
index dafc3f3..404e5db 100644
@@ -38,6 +38,7 @@ enum periph_id {
        PERIPH_ID_I2C5,
        PERIPH_ID_I2C6,
        PERIPH_ID_I2C7,
+       PERIPH_ID_I2S1,
        PERIPH_ID_SDMMC0,
        PERIPH_ID_SDMMC1,
        PERIPH_ID_SDMMC2,
--
Quoted 2 lines

1.7.4.4

Quoted 7 lines

--
with warm regards,
Chander Kashyap
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Rajeshwari Shinde.

#14 lore raw

PATCH 7/9 EXYNOS: Add I2S base address

In reply to Rajeshwari Shinde

This patch adds base address for I2S

---
 arch/arm/include/asm/arch-exynos/cpu.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-exynos/cpu.h +3 -0
index 89c2dd3..f7fda7f 100644
@@ -55,6 +55,7 @@
 #define EXYNOS4_PWMTIMER_BASE		0x139D0000
 #define EXYNOS4_MODEM_BASE		0x13A00000
 #define EXYNOS4_USBPHY_CONTROL		0x10020704
+#define EXYNOS4_I2S_BASE		0xE2100000
 
 #define EXYNOS4_GPIO_PART4_BASE		DEVICE_NOT_AVAILABLE
 #define EXYNOS4_SPI_ISP_BASE		DEVICE_NOT_AVAILABLE
@@ -83,6 +84,7 @@
 #define EXYNOS5_UART_BASE		0x12C00000
 #define EXYNOS5_I2C_BASE		0x12C60000
 #define EXYNOS5_SPI_BASE		0x12D20000
+#define EXYNOS5_I2S_BASE		0x12D60000
 #define EXYNOS5_PWMTIMER_BASE		0x12DD0000
 #define EXYNOS5_SPI_ISP_BASE		0x131A0000
 #define EXYNOS5_GPIO_PART2_BASE		0x13400000
@@ -157,6 +159,7 @@ SAMSUNG_BASE(clock, CLOCK_BASE)
 SAMSUNG_BASE(sysreg, SYSREG_BASE)
 SAMSUNG_BASE(fimd, FIMD_BASE)
 SAMSUNG_BASE(i2c, I2C_BASE)
+SAMSUNG_BASE(i2s, I2S_BASE)
 SAMSUNG_BASE(mipi_dsim, MIPI_DSIM_BASE)
 SAMSUNG_BASE(gpio_part1, GPIO_PART1_BASE)
 SAMSUNG_BASE(gpio_part2, GPIO_PART2_BASE)
Signature · 1 line
1.7.4.4
#15 lore raw

PATCH 8/9 EXYNOS: Add clock for I2S

In reply to Rajeshwari Shinde

This patch adds clock support for I2S

---
 arch/arm/cpu/armv7/exynos/clock.c        |  119 ++++++++++++++++++++++++++++++
 arch/arm/include/asm/arch-exynos/clk.h   |    3 +
 arch/arm/include/asm/arch-exynos/clock.h |   29 +++++++
 3 files changed, 151 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/exynos/clock.c +119 -0
index 2aa511e..ad47d22 100644
@@ -26,6 +26,16 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/clk.h>
 
+/* Epll Clock division values to achive different frequency output */
+static struct st_epll_con_val epll_div[] = {
+	{ 192000000, 0, 48, 3, 1, 0 },
+	{ 180000000, 0, 45, 3, 1, 0 },
+	{  73728000, 1, 73, 3, 3, 47710 },
+	{  67737600, 1, 90, 4, 3, 20762 },
+	{  49152000, 0, 49, 3, 3, 9961 },
+	{  45158400, 0, 45, 3, 3, 10381 },
+	{ 180633600, 0, 45, 3, 1, 10381 }
+};
 /* exynos4: return pll clock frequency */
 static unsigned long exynos4_get_pll_clk(int pllreg)
 {
@@ -744,6 +754,92 @@ static int exynos5_spi_set_clock_rate(enum periph_id periph_id,
 	return 0;
 }
 
+int exynos5_clock_epll_set_rate(unsigned long rate)
+{
+	unsigned int epll_con, epll_con_k;
+	unsigned int i;
+	unsigned int lockcnt;
+	unsigned int start;
+	struct exynos5_clock *clk =
+		(struct exynos5_clock *)samsung_get_base_clock();
+
+	epll_con = readl(&clk->epll_con0);
+	epll_con &= ~((EPLL_CON0_LOCK_DET_EN_MASK <<
+			EPLL_CON0_LOCK_DET_EN_SHIFT) |
+		EPLL_CON0_MDIV_MASK << EPLL_CON0_MDIV_SHIFT |
+		EPLL_CON0_PDIV_MASK << EPLL_CON0_PDIV_SHIFT |
+		EPLL_CON0_SDIV_MASK << EPLL_CON0_SDIV_SHIFT);
+
+	for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
+		if (epll_div[i].freq_out == rate)
+			break;
+	}
+
+	if (i == ARRAY_SIZE(epll_div))
+		return -1;
+
+	epll_con_k = epll_div[i].k_dsm << 0;
+	epll_con |= epll_div[i].en_lock_det << EPLL_CON0_LOCK_DET_EN_SHIFT;
+	epll_con |= epll_div[i].m_div << EPLL_CON0_MDIV_SHIFT;
+	epll_con |= epll_div[i].p_div << EPLL_CON0_PDIV_SHIFT;
+	epll_con |= epll_div[i].s_div << EPLL_CON0_SDIV_SHIFT;
+
+	/*
+	 * Required period ( in cycles) to genarate a stable clock output.
+	 * The maximum clock time can be up to 3000 * PDIV cycles of PLLs
+	 * frequency input (as per spec)
+	 */
+	lockcnt = 3000 * epll_div[i].p_div;
+
+	writel(lockcnt, &clk->epll_lock);
+	writel(epll_con, &clk->epll_con0);
+	writel(epll_con_k, &clk->epll_con1);
+
+	start = get_timer(0);
+
+	 while (!(readl(&clk->epll_con0) &
+			(0x1 << EXYNOS5_EPLLCON0_LOCKED_SHIFT))) {
+		if (get_timer(start) > TIMEOUT_EPLL_LOCK) {
+			debug("%s: Timeout waiting for EPLL lock\n", __func__);
+			return -1;
+		}
+	}
+	return 0;
+}
+
+void exynos5_clock_select_i2s_clk_source(void)
+{
+	struct exynos5_clock *clk =
+		(struct exynos5_clock *)samsung_get_base_clock();
+
+	clrsetbits_le32(&clk->src_peric1, AUDIO1_SEL_MASK,
+			(CLK_SRC_SCLK_EPLL));
+}
+
+int exynos5_clock_set_i2s_clk_prescaler(unsigned int src_frq,
+					unsigned int dst_frq)
+{
+	struct exynos5_clock *clk =
+		(struct exynos5_clock *)samsung_get_base_clock();
+	unsigned int div;
+
+	if ((dst_frq == 0) || (src_frq == 0)) {
+		debug("%s: Invalid requency input for prescaler\n", __func__);
+		debug("src frq = %d des frq = %d ", src_frq, dst_frq);
+		return -1;
+	}
+
+	div = (src_frq / dst_frq);
+	if (div > AUDIO_1_RATIO_MASK) {
+		debug("%s: Frequency ratio is out of range\n", __func__);
+		debug("src frq = %d des frq = %d ", src_frq, dst_frq);
+		return -1;
+	}
+	clrsetbits_le32(&clk->div_peric4, AUDIO_1_RATIO_MASK,
+				(div & AUDIO_1_RATIO_MASK));
+	return 0;
+}
+
 unsigned long get_pll_clk(int pllreg)
 {
 	if (cpu_is_exynos5())
@@ -821,3 +917,26 @@ int spi_set_clock_rate(enum periph_id periph_id, unsigned int rate)
 	else
 		return 0;
 }
+
+int clock_set_i2s_clk_prescaler(unsigned int src_frq, unsigned int dst_frq)
+{
+
+	if (cpu_is_exynos5())
+		return exynos5_clock_set_i2s_clk_prescaler(src_frq, dst_frq);
+	else
+		return 0;
+}
+
+void clock_select_i2s_clk_source(void)
+{
+	if (cpu_is_exynos5())
+		exynos5_clock_select_i2s_clk_source();
+}
+
+int clock_epll_set_rate(unsigned long rate)
+{
+	if (cpu_is_exynos5())
+		return exynos5_clock_epll_set_rate(rate);
+	else
+		return 0;
+}
arch/arm/include/asm/arch-exynos/clk.h +3 -0
index 4e51402..f32c634 100644
@@ -41,4 +41,7 @@ unsigned long get_lcd_clk(void);
 void set_lcd_clk(void);
 void set_mipi_clk(void);
 int spi_set_clock_rate(enum periph_id periph_id, unsigned int rate);
+void clock_select_i2s_clk_source(void);
+int clock_set_i2s_clk_prescaler(unsigned int src_frq, unsigned int dst_frq);
+int clock_epll_set_rate(unsigned long rate);
 #endif
arch/arm/include/asm/arch-exynos/clock.h +29 -0
index fce38ef..1df49a9 100644
@@ -595,9 +595,38 @@ struct exynos5_clock {
 	unsigned int	pll_div2_sel;
 	unsigned char	res123[0xf5d8];
 };
+
+/* structure for epll configuration used in audio clock configuration */
+struct st_epll_con_val {
+	unsigned int freq_out;		/* frequency out */
+	unsigned int en_lock_det;	/* enable lock detect */
+	unsigned int m_div;		/* m divider value */
+	unsigned int p_div;		/* p divider value */
+	unsigned int s_div;		/* s divider value */
+	unsigned int k_dsm;		/* k value of delta signal modulator */
+};
 #endif
 
 #define MPLL_FOUT_SEL_SHIFT	4
+#define EXYNOS5_EPLLCON0_LOCKED_SHIFT	29  /* EPLL Locked bit position*/
+#define TIMEOUT_EPLL_LOCK		1000
+
+#define AUDIO_0_RATIO_MASK		0x0f
+#define AUDIO_1_RATIO_MASK		0x0f
+
+#define AUDIO1_SEL_MASK			0xf
+#define CLK_SRC_SCLK_EPLL		0x7
+
+/* CON0 bit-fields */
+#define EPLL_CON0_MDIV_MASK		0x1ff
+#define EPLL_CON0_PDIV_MASK		0x3f
+#define EPLL_CON0_SDIV_MASK		0x7
+#define EPLL_CON0_MDIV_SHIFT		16
+#define EPLL_CON0_PDIV_SHIFT		8
+#define EPLL_CON0_SDIV_SHIFT		0
+#define EPLL_CON0_LOCK_DET_EN_SHIFT	28
+#define EPLL_CON0_LOCK_DET_EN_MASK	1
+
 #define MPLL_FOUT_SEL_MASK	0x1
 #define BPLL_FOUT_SEL_SHIFT	0
 #define BPLL_FOUT_SEL_MASK	0x1
Signature · 1 line
1.7.4.4
#16 lore raw

PATCH 9/9 EXYNOS5: Enable Sound

In reply to Rajeshwari Shinde

This patch enables sound support for EXYNOS5

---
 include/configs/smdk5250.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
include/configs/smdk5250.h +8 -0
index 4b9093c..fae1c0c 100644
@@ -242,6 +242,14 @@
 #define CONFIG_ENV_SPI_MAX_HZ	50000000
 #endif
 
+/* Sound */
+#define CONFIG_CMD_SOUND
+#ifdef CONFIG_CMD_SOUND
+#define CONFIG_SOUND
+#define CONFIG_I2S
+#define CONFIG_SOUND_WM8994
+#endif
+
 /* Enable devicetree support */
 #define CONFIG_OF_LIBFDT
 
Signature · 1 line
1.7.4.4
#17 lore raw

PATCH 9/9 EXYNOS5: Enable Sound

hi Rajeshwari,

Quoted 1 line · Rajeshwari Shinde

This patch enables sound support for EXYNOS5

Enable sound for exynos5 based smdk5250 not exynos5.

Quoted 28 lines
---
 include/configs/smdk5250.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
include/configs/smdk5250.h +8 -1
index 4b9093c..fae1c0c 100644
@@ -242,6 +242,14 @@
 #define CONFIG_ENV_SPI_MAX_HZ  50000000
 #endif
 
+/* Sound */
+#define CONFIG_CMD_SOUND
+#ifdef CONFIG_CMD_SOUND
+#define CONFIG_SOUND
+#define CONFIG_I2S
+#define CONFIG_SOUND_WM8994
+#endif
+
 /* Enable devicetree support */
 #define CONFIG_OF_LIBFDT
 
--

1.7.4.4

Signature · 2 lines
with warm regards,
Chander Kashyap
#18 lore raw

PATCH 9/9 EXYNOS5: Enable Sound

Hi Chander,

Thank you for comments.

Quoted 5 lines · Chander Kashyap

hi Rajeshwari,

Quoted 1 line · Rajeshwari Shinde

This patch enables sound support for EXYNOS5

Enable sound for exynos5 based smdk5250 not exynos5.

- ok

Quoted 25 lines
Quoted 25 lines
---
 include/configs/smdk5250.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
include/configs/smdk5250.h +8 -0
index 4b9093c..fae1c0c 100644
@@ -242,6 +242,14 @@
 #define CONFIG_ENV_SPI_MAX_HZ  50000000
 #endif
 
+/* Sound */
+#define CONFIG_CMD_SOUND
+#ifdef CONFIG_CMD_SOUND
+#define CONFIG_SOUND
+#define CONFIG_I2S
+#define CONFIG_SOUND_WM8994
+#endif
+
 /* Enable devicetree support */
 #define CONFIG_OF_LIBFDT
 
Quoted 13 lines
Quoted 3 lines

--
1.7.4.4

--
with warm regards,
Chander Kashyap
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Rajeshwari Shinde