Re: [U-Boot] [PATCH 2/9 V3] SOUND: Add WM8994 codec

2012-10-25 Thread Simon Glass
Hi,

On Mon, Oct 22, 2012 at 11:57 PM, Rajeshwari Shinde
rajeshwar...@samsung.com wrote:
 This patch adds driver for audio codec WM8994

 Signed-off-by: R. Chandrasekar rcse...@samsung.com
 Signed-off-by: Rajeshwari Shinde rajeshwar...@samsung.com

Acked-by: Simon Glass s...@chromium.org

 ---
 Changes in V2:
 - None
 Changes in V3:
 - Incorporated comments from Simon Glass.

Sometimes it is better to list the actual changes made.

  drivers/sound/Makefile   |1 +
  drivers/sound/wm8994.c   |  792 
 ++
  drivers/sound/wm8994.h   |   87 +
  drivers/sound/wm8994_registers.h |  299 ++
  4 files changed, 1179 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

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


Re: [U-Boot] [PATCH 2/9 V3] SOUND: Add WM8994 codec

2012-10-25 Thread Rajeshwari Birje
Hi Simon Glass,

Thank you for the comments.

On Thu, Oct 25, 2012 at 10:37 PM, Simon Glass s...@chromium.org wrote:

 Hi,

 On Mon, Oct 22, 2012 at 11:57 PM, Rajeshwari Shinde
 rajeshwar...@samsung.com wrote:
  This patch adds driver for audio codec WM8994
 
  Signed-off-by: R. Chandrasekar rcse...@samsung.com
  Signed-off-by: Rajeshwari Shinde rajeshwar...@samsung.com

 Acked-by: Simon Glass s...@chromium.org

  ---
  Changes in V2:
  - None
  Changes in V3:
  - Incorporated comments from Simon Glass.

 Sometimes it is better to list the actual changes made.
Will take care of the same in future.

   drivers/sound/Makefile   |1 +
   drivers/sound/wm8994.c   |  792 
  ++
   drivers/sound/wm8994.h   |   87 +
   drivers/sound/wm8994_registers.h |  299 ++
   4 files changed, 1179 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
 
 ___
 U-Boot mailing list
 U-Boot@lists.denx.de
 http://lists.denx.de/mailman/listinfo/u-boot

Regards,
Rajeshwari Shinde.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/9 V3] SOUND: Add WM8994 codec

2012-10-23 Thread Rajeshwari Shinde
This patch adds driver for audio codec WM8994

Signed-off-by: R. Chandrasekar rcse...@samsung.com
Signed-off-by: Rajeshwari Shinde rajeshwar...@samsung.com
---
Changes in V2:
- None
Changes in V3:
- Incorporated comments from Simon Glass.
 drivers/sound/Makefile   |1 +
 drivers/sound/wm8994.c   |  792 ++
 drivers/sound/wm8994.h   |   87 +
 drivers/sound/wm8994_registers.h |  299 ++
 4 files changed, 1179 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

diff --git a/drivers/sound/Makefile b/drivers/sound/Makefile
index 18ad2c9..8fdffb1 100644
--- a/drivers/sound/Makefile
+++ b/drivers/sound/Makefile
@@ -27,6 +27,7 @@ LIB   := $(obj)libsound.o
 
 COBJS-$(CONFIG_SOUND)  += sound.o
 COBJS-$(CONFIG_I2S)+= samsung-i2s.o
+COBJS-$(CONFIG_SOUND_WM8994)   += wm8994.o
 
 COBJS  := $(COBJS-y)
 SRCS   := $(COBJS:.o=.c)
diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c
new file mode 100644
index 000..293903a
--- /dev/null
+++ b/drivers/sound/wm8994.c
@@ -0,0 +1,792 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics
+ * R. Chandrasekar rcse...@samsung.com
+ *
+ * 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
+ */
+#include asm/arch/clk.h
+#include asm/arch/cpu.h
+#include asm/gpio.h
+#include asm/io.h
+#include common.h
+#include div64.h
+#include i2c.h
+#include i2s.h
+#include sound.h
+#include wm8994.h
+#include wm8994_registers.h
+
+/* defines for wm8994 system clock selection */
+#define SEL_MCLK1  0x00
+#define SEL_MCLK2  0x08
+#define SEL_FLL1   0x10
+#define SEL_FLL2   0x18
+
+/* fll config to configure fll */
+struct wm8994_fll_config {
+   int src;/* Source */
+   int in; /* Input frequency in Hz */
+   int out;/* output frequency in Hz */
+};
+
+/* codec private data */
+struct wm8994_priv {
+   enum wm8994_type type;  /* codec type of wolfson */
+   int revision;   /* Revision */
+   int sysclk[WM8994_MAX_AIF]; /* System clock frequency in Hz  */
+   int mclk[WM8994_MAX_AIF];   /* master clock frequency in Hz */
+   int aifclk[WM8994_MAX_AIF]; /* audio interface clock in Hz   */
+   struct wm8994_fll_config fll[2]; /* fll config to configure fll */
+};
+
+/* wm 8994 supported sampling rate values */
+static unsigned int src_rate[] = {
+8000, 11025, 12000, 16000, 22050, 24000,
+32000, 44100, 48000, 88200, 96000
+};
+
+/* op clock divisions */
+static int opclk_divs[] = { 10, 20, 30, 40, 55, 60, 80, 120, 160 };
+
+/* lr clock frame size ratio */
+static int fs_ratios[] = {
+   64, 128, 192, 256, 348, 512, 768, 1024, 1408, 1536
+};
+
+/* bit clock divisors */
+static int bclk_divs[] = {
+   10, 15, 20, 30, 40, 50, 60, 80, 110, 120, 160, 220, 240, 320, 440, 480,
+   640, 880, 960, 1280, 1760, 1920
+};
+
+static struct wm8994_priv g_wm8994_info;
+static unsigned char g_wm8994_i2c_dev_addr;
+
+/*
+ * Initialise I2C for wm 8994
+ *
+ * @param bus no   i2c bus number in which wm8994 is connected
+ */
+static void wm8994_i2c_init(int bus_no)
+{
+   i2c_set_bus_num(bus_no);
+}
+
+/*
+ * Writes value to a device register through i2c
+ *
+ * @param reg  reg number to be write
+ * @param data data to be writen to the above registor
+ *
+ * @return int value 1 for change, 0 for no change or negative error code.
+ */
+static int wm8994_i2c_write(unsigned int reg, unsigned short data)
+{
+   unsigned char val[2];
+
+   val[0] = (unsigned char)((data  8)  0xff);
+   val[1] = (unsigned char)(data  0xff);
+   debug(Write Addr : 0x%04X, Data :  0x%04X\n, reg, data);
+
+   return i2c_write(g_wm8994_i2c_dev_addr, reg, 2, val, 2);
+}
+
+/*
+ * Read a value from a device register through i2c
+ *
+ * @param reg  reg number to be read
+ * @param data address of read data to be stored
+ *
+ * @return int value 0 for success, -1 in case of error.
+ */
+static unsigned int  wm8994_i2c_read(unsigned int reg , unsigned short *data)
+{
+   unsigned char val[2];
+   int