All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] mmc: zboot helpers
@ 2011-03-24  6:54 ` Simon Horman
  0 siblings, 0 replies; 31+ messages in thread
From: Simon Horman @ 2011-03-24  6:54 UTC (permalink / raw)
  To: vger.kernel.org, linux-mmc, linux-arm-kernel
  Cc: Guennadi Liakhovetski, Chris Ball, Kuninori Morimoto, Paul Mundt

Hi Paul,

please consider merging the following two patches.
They are both pre-requisites for
"mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM"
which I plan to submit to Russell King.

These patches were originally submitted in a for patch series
however they do not depend on any of the other patches in the series
so I am posting them independently.

These patches apply against Linus's current tree
and I am not aware of any particular prerequisites for them
other than that the 2nd patch depends on the 1st one.


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 0/2] mmc: zboot helpers
@ 2011-03-24  6:54 ` Simon Horman
  0 siblings, 0 replies; 31+ messages in thread
From: Simon Horman @ 2011-03-24  6:54 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Paul,

please consider merging the following two patches.
They are both pre-requisites for
"mmc, ARM: Add zboot from eSD support for SuperH Mobile ARM"
which I plan to submit to Russell King.

These patches were originally submitted in a for patch series
however they do not depend on any of the other patches in the series
so I am posting them independently.

These patches apply against Linus's current tree
and I am not aware of any particular prerequisites for them
other than that the 2nd patch depends on the 1st one.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers
  2011-03-24  6:54 ` Simon Horman
@ 2011-03-24  6:54   ` Simon Horman
  -1 siblings, 0 replies; 31+ messages in thread
From: Simon Horman @ 2011-03-24  6:54 UTC (permalink / raw)
  To: vger.kernel.org, linux-mmc, linux-arm-kernel
  Cc: Guennadi Liakhovetski, Chris Ball, Kuninori Morimoto, Paul Mundt,
	Simon Horman

These headers and helpers will also be used for SDHI boot
so the mmcif name will start to make a lot less sense.

Signed-off-by: Simon Horman <horms@verge.net.au>
---
 arch/arm/boot/compressed/mmcif-sh7372.c            |   12 +++---
 arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h    |   29 +++++++++++++++
 arch/arm/mach-shmobile/include/mach/mmc-mackerel.h |   38 +++++++++++++++++++
 arch/arm/mach-shmobile/include/mach/mmc.h          |   18 +++++++++
 arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h  |   29 ---------------
 .../mach-shmobile/include/mach/mmcif-mackerel.h    |   39 --------------------
 arch/arm/mach-shmobile/include/mach/mmcif.h        |   18 ---------
 7 files changed, 91 insertions(+), 92 deletions(-)
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmc-mackerel.h
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmc.h
 delete mode 100644 arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h
 delete mode 100644 arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h
 delete mode 100644 arch/arm/mach-shmobile/include/mach/mmcif.h

diff --git a/arch/arm/boot/compressed/mmcif-sh7372.c b/arch/arm/boot/compressed/mmcif-sh7372.c
index e6180af..28bcf3c 100644
--- a/arch/arm/boot/compressed/mmcif-sh7372.c
+++ b/arch/arm/boot/compressed/mmcif-sh7372.c
@@ -10,7 +10,7 @@
  */
 
 #include <linux/mmc/sh_mmcif.h>
-#include <mach/mmcif.h>
+#include <mach/mmc.h>
 
 #define MMCIF_BASE      (void __iomem *)0xe6bd0000
 
@@ -41,8 +41,8 @@
  */
 asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 {
-	mmcif_init_progress();
-	mmcif_update_progress(MMCIF_PROGRESS_ENTER);
+	mmc_init_progress();
+	mmc_update_progress(MMCIF_PROGRESS_ENTER);
 
 	/* Initialise MMC
 	 * registers: PORT84CR-PORT92CR
@@ -68,12 +68,12 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Enable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 12), SMSTPCR3);
 
-	mmcif_update_progress(MMCIF_PROGRESS_INIT);
+	mmc_update_progress(MMCIF_PROGRESS_INIT);
 
 	/* setup MMCIF hardware */
 	sh_mmcif_boot_init(MMCIF_BASE);
 
-	mmcif_update_progress(MMCIF_PROGRESS_LOAD);
+	mmc_update_progress(MMCIF_PROGRESS_LOAD);
 
 	/* load kernel via MMCIF interface */
 	sh_mmcif_boot_do_read(MMCIF_BASE, 2, /* Kernel is at block 2 */
@@ -83,5 +83,5 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Disable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & (1 << 12), SMSTPCR3);
 
-	mmcif_update_progress(MMCIF_PROGRESS_DONE);
+	mmc_update_progress(MMCIF_PROGRESS_DONE);
 }
diff --git a/arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h b/arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h
new file mode 100644
index 0000000..db59fdb
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h
@@ -0,0 +1,29 @@
+#ifndef MMC_AP4EB_H
+#define MMC_AP4EB_H
+
+#define PORT185CR      (void __iomem *)0xe60520b9
+#define PORT186CR      (void __iomem *)0xe60520ba
+#define PORT187CR      (void __iomem *)0xe60520bb
+#define PORT188CR      (void __iomem *)0xe60520bc
+
+#define PORTR191_160DR (void __iomem *)0xe6056014
+
+static inline void mmc_init_progress(void)
+{
+       /* Initialise LEDS1-4
+        * registers: PORT185CR-PORT188CR (LED1-LED4 Control)
+        * value:     0x10 - enable output
+        */
+       __raw_writeb(0x10, PORT185CR);
+       __raw_writeb(0x10, PORT186CR);
+       __raw_writeb(0x10, PORT187CR);
+       __raw_writeb(0x10, PORT188CR);
+}
+
+static inline void mmc_update_progress(int n)
+{
+	__raw_writel((__raw_readl(PORTR191_160DR) & ~(0xf << 25)) |
+		     (1 << (25 + n)), PORTR191_160DR);
+}
+
+#endif /* MMC_AP4EB_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmc-mackerel.h b/arch/arm/mach-shmobile/include/mach/mmc-mackerel.h
new file mode 100644
index 0000000..15d3a9e
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/mmc-mackerel.h
@@ -0,0 +1,38 @@
+#ifndef MMC_MACKEREL_H
+#define MMC_MACKEREL_H
+
+#define PORT0CR      (void __iomem *)0xe6051000
+#define PORT1CR      (void __iomem *)0xe6051001
+#define PORT2CR      (void __iomem *)0xe6051002
+#define PORT159CR    (void __iomem *)0xe605009f
+
+#define PORTR031_000DR (void __iomem *)0xe6055000
+#define PORTL159_128DR (void __iomem *)0xe6054010
+
+static inline void mmc_init_progress(void)
+{
+       /* Initialise LEDS0-3
+        * registers: PORT0CR-PORT2CR,PORT159CR (LED0-LED3 Control)
+        * value:     0x10 - enable output
+        */
+       __raw_writeb(0x10, PORT0CR);
+       __raw_writeb(0x10, PORT1CR);
+       __raw_writeb(0x10, PORT2CR);
+       __raw_writeb(0x10, PORT159CR);
+}
+
+static inline void mmc_update_progress(int n)
+{
+	unsigned a = 0, b = 0;
+
+	if (n < 3)
+		a = 1 << n;
+	else
+		b = 1 << 31;
+
+	__raw_writel((__raw_readl(PORTR031_000DR) & ~0x7) | a,
+		     PORTR031_000DR);
+	__raw_writel((__raw_readl(PORTL159_128DR) & ~(1 << 31)) | b,
+		     PORTL159_128DR);
+}
+#endif /* MMC_MACKEREL_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmc.h b/arch/arm/mach-shmobile/include/mach/mmc.h
new file mode 100644
index 0000000..e11560a
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/mmc.h
@@ -0,0 +1,18 @@
+#ifndef MMC_H
+#define MMC_H
+
+/**************************************************
+ *
+ *		board specific settings
+ *
+ **************************************************/
+
+#ifdef CONFIG_MACH_AP4EVB
+#include "mach/mmc-ap4eb.h"
+#elif CONFIG_MACH_MACKEREL
+#include "mach/mmc-mackerel.h"
+#else
+#error "unsupported board."
+#endif
+
+#endif /* MMC_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h b/arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h
deleted file mode 100644
index a8d02be..0000000
--- a/arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef MMCIF_AP4EB_H
-#define MMCIF_AP4EB_H
-
-#define PORT185CR      (void __iomem *)0xe60520b9
-#define PORT186CR      (void __iomem *)0xe60520ba
-#define PORT187CR      (void __iomem *)0xe60520bb
-#define PORT188CR      (void __iomem *)0xe60520bc
-
-#define PORTR191_160DR (void __iomem *)0xe6056014
-
-static inline void mmcif_init_progress(void)
-{
-       /* Initialise LEDS1-4
-        * registers: PORT185CR-PORT188CR (LED1-LED4 Control)
-        * value:     0x10 - enable output
-        */
-       __raw_writeb(0x10, PORT185CR);
-       __raw_writeb(0x10, PORT186CR);
-       __raw_writeb(0x10, PORT187CR);
-       __raw_writeb(0x10, PORT188CR);
-}
-
-static inline void mmcif_update_progress(int n)
-{
-	__raw_writel((__raw_readl(PORTR191_160DR) & ~(0xf << 25)) |
-		     (1 << (25 + n)), PORTR191_160DR);
-}
-
-#endif /* MMCIF_AP4EB_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h b/arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h
deleted file mode 100644
index 4b4f694..0000000
--- a/arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef MMCIF_MACKEREL_H
-#define MMCIF_MACKEREL_H
-
-#define PORT0CR      (void __iomem *)0xe6051000
-#define PORT1CR      (void __iomem *)0xe6051001
-#define PORT2CR      (void __iomem *)0xe6051002
-#define PORT159CR    (void __iomem *)0xe605009f
-
-#define PORTR031_000DR (void __iomem *)0xe6055000
-#define PORTL159_128DR (void __iomem *)0xe6054010
-
-static inline void mmcif_init_progress(void)
-{
-       /* Initialise LEDS0-3
-        * registers: PORT0CR-PORT2CR,PORT159CR (LED0-LED3 Control)
-        * value:     0x10 - enable output
-        */
-       __raw_writeb(0x10, PORT0CR);
-       __raw_writeb(0x10, PORT1CR);
-       __raw_writeb(0x10, PORT2CR);
-       __raw_writeb(0x10, PORT159CR);
-}
-
-static inline void mmcif_update_progress(int n)
-{
-	unsigned a = 0, b = 0;
-
-	if (n < 3)
-		a = 1 << n;
-	else
-		b = 1 << 31;
-
-	__raw_writel((__raw_readl(PORTR031_000DR) & ~0x7) | a,
-		     PORTR031_000DR);
-	__raw_writel((__raw_readl(PORTL159_128DR) & ~(1 << 31)) | b,
-		     PORTL159_128DR);
-}
-
-#endif /* MMCIF_MACKEREL_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmcif.h b/arch/arm/mach-shmobile/include/mach/mmcif.h
deleted file mode 100644
index f4dc327..0000000
--- a/arch/arm/mach-shmobile/include/mach/mmcif.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef MMCIF_H
-#define MMCIF_H
-
-/**************************************************
- *
- *		board specific settings
- *
- **************************************************/
-
-#ifdef CONFIG_MACH_AP4EVB
-#include "mach/mmcif-ap4eb.h"
-#elif CONFIG_MACH_MACKEREL
-#include "mach/mmcif-mackerel.h"
-#else
-#error "unsupported board."
-#endif
-
-#endif /* MMCIF_H */
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers
@ 2011-03-24  6:54   ` Simon Horman
  0 siblings, 0 replies; 31+ messages in thread
From: Simon Horman @ 2011-03-24  6:54 UTC (permalink / raw)
  To: linux-arm-kernel

These headers and helpers will also be used for SDHI boot
so the mmcif name will start to make a lot less sense.

Signed-off-by: Simon Horman <horms@verge.net.au>
---
 arch/arm/boot/compressed/mmcif-sh7372.c            |   12 +++---
 arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h    |   29 +++++++++++++++
 arch/arm/mach-shmobile/include/mach/mmc-mackerel.h |   38 +++++++++++++++++++
 arch/arm/mach-shmobile/include/mach/mmc.h          |   18 +++++++++
 arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h  |   29 ---------------
 .../mach-shmobile/include/mach/mmcif-mackerel.h    |   39 --------------------
 arch/arm/mach-shmobile/include/mach/mmcif.h        |   18 ---------
 7 files changed, 91 insertions(+), 92 deletions(-)
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmc-mackerel.h
 create mode 100644 arch/arm/mach-shmobile/include/mach/mmc.h
 delete mode 100644 arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h
 delete mode 100644 arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h
 delete mode 100644 arch/arm/mach-shmobile/include/mach/mmcif.h

diff --git a/arch/arm/boot/compressed/mmcif-sh7372.c b/arch/arm/boot/compressed/mmcif-sh7372.c
index e6180af..28bcf3c 100644
--- a/arch/arm/boot/compressed/mmcif-sh7372.c
+++ b/arch/arm/boot/compressed/mmcif-sh7372.c
@@ -10,7 +10,7 @@
  */
 
 #include <linux/mmc/sh_mmcif.h>
-#include <mach/mmcif.h>
+#include <mach/mmc.h>
 
 #define MMCIF_BASE      (void __iomem *)0xe6bd0000
 
@@ -41,8 +41,8 @@
  */
 asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 {
-	mmcif_init_progress();
-	mmcif_update_progress(MMCIF_PROGRESS_ENTER);
+	mmc_init_progress();
+	mmc_update_progress(MMCIF_PROGRESS_ENTER);
 
 	/* Initialise MMC
 	 * registers: PORT84CR-PORT92CR
@@ -68,12 +68,12 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Enable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 12), SMSTPCR3);
 
-	mmcif_update_progress(MMCIF_PROGRESS_INIT);
+	mmc_update_progress(MMCIF_PROGRESS_INIT);
 
 	/* setup MMCIF hardware */
 	sh_mmcif_boot_init(MMCIF_BASE);
 
-	mmcif_update_progress(MMCIF_PROGRESS_LOAD);
+	mmc_update_progress(MMCIF_PROGRESS_LOAD);
 
 	/* load kernel via MMCIF interface */
 	sh_mmcif_boot_do_read(MMCIF_BASE, 2, /* Kernel is@block 2 */
@@ -83,5 +83,5 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Disable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & (1 << 12), SMSTPCR3);
 
-	mmcif_update_progress(MMCIF_PROGRESS_DONE);
+	mmc_update_progress(MMCIF_PROGRESS_DONE);
 }
diff --git a/arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h b/arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h
new file mode 100644
index 0000000..db59fdb
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/mmc-ap4eb.h
@@ -0,0 +1,29 @@
+#ifndef MMC_AP4EB_H
+#define MMC_AP4EB_H
+
+#define PORT185CR      (void __iomem *)0xe60520b9
+#define PORT186CR      (void __iomem *)0xe60520ba
+#define PORT187CR      (void __iomem *)0xe60520bb
+#define PORT188CR      (void __iomem *)0xe60520bc
+
+#define PORTR191_160DR (void __iomem *)0xe6056014
+
+static inline void mmc_init_progress(void)
+{
+       /* Initialise LEDS1-4
+        * registers: PORT185CR-PORT188CR (LED1-LED4 Control)
+        * value:     0x10 - enable output
+        */
+       __raw_writeb(0x10, PORT185CR);
+       __raw_writeb(0x10, PORT186CR);
+       __raw_writeb(0x10, PORT187CR);
+       __raw_writeb(0x10, PORT188CR);
+}
+
+static inline void mmc_update_progress(int n)
+{
+	__raw_writel((__raw_readl(PORTR191_160DR) & ~(0xf << 25)) |
+		     (1 << (25 + n)), PORTR191_160DR);
+}
+
+#endif /* MMC_AP4EB_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmc-mackerel.h b/arch/arm/mach-shmobile/include/mach/mmc-mackerel.h
new file mode 100644
index 0000000..15d3a9e
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/mmc-mackerel.h
@@ -0,0 +1,38 @@
+#ifndef MMC_MACKEREL_H
+#define MMC_MACKEREL_H
+
+#define PORT0CR      (void __iomem *)0xe6051000
+#define PORT1CR      (void __iomem *)0xe6051001
+#define PORT2CR      (void __iomem *)0xe6051002
+#define PORT159CR    (void __iomem *)0xe605009f
+
+#define PORTR031_000DR (void __iomem *)0xe6055000
+#define PORTL159_128DR (void __iomem *)0xe6054010
+
+static inline void mmc_init_progress(void)
+{
+       /* Initialise LEDS0-3
+        * registers: PORT0CR-PORT2CR,PORT159CR (LED0-LED3 Control)
+        * value:     0x10 - enable output
+        */
+       __raw_writeb(0x10, PORT0CR);
+       __raw_writeb(0x10, PORT1CR);
+       __raw_writeb(0x10, PORT2CR);
+       __raw_writeb(0x10, PORT159CR);
+}
+
+static inline void mmc_update_progress(int n)
+{
+	unsigned a = 0, b = 0;
+
+	if (n < 3)
+		a = 1 << n;
+	else
+		b = 1 << 31;
+
+	__raw_writel((__raw_readl(PORTR031_000DR) & ~0x7) | a,
+		     PORTR031_000DR);
+	__raw_writel((__raw_readl(PORTL159_128DR) & ~(1 << 31)) | b,
+		     PORTL159_128DR);
+}
+#endif /* MMC_MACKEREL_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmc.h b/arch/arm/mach-shmobile/include/mach/mmc.h
new file mode 100644
index 0000000..e11560a
--- /dev/null
+++ b/arch/arm/mach-shmobile/include/mach/mmc.h
@@ -0,0 +1,18 @@
+#ifndef MMC_H
+#define MMC_H
+
+/**************************************************
+ *
+ *		board specific settings
+ *
+ **************************************************/
+
+#ifdef CONFIG_MACH_AP4EVB
+#include "mach/mmc-ap4eb.h"
+#elif CONFIG_MACH_MACKEREL
+#include "mach/mmc-mackerel.h"
+#else
+#error "unsupported board."
+#endif
+
+#endif /* MMC_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h b/arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h
deleted file mode 100644
index a8d02be..0000000
--- a/arch/arm/mach-shmobile/include/mach/mmcif-ap4eb.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef MMCIF_AP4EB_H
-#define MMCIF_AP4EB_H
-
-#define PORT185CR      (void __iomem *)0xe60520b9
-#define PORT186CR      (void __iomem *)0xe60520ba
-#define PORT187CR      (void __iomem *)0xe60520bb
-#define PORT188CR      (void __iomem *)0xe60520bc
-
-#define PORTR191_160DR (void __iomem *)0xe6056014
-
-static inline void mmcif_init_progress(void)
-{
-       /* Initialise LEDS1-4
-        * registers: PORT185CR-PORT188CR (LED1-LED4 Control)
-        * value:     0x10 - enable output
-        */
-       __raw_writeb(0x10, PORT185CR);
-       __raw_writeb(0x10, PORT186CR);
-       __raw_writeb(0x10, PORT187CR);
-       __raw_writeb(0x10, PORT188CR);
-}
-
-static inline void mmcif_update_progress(int n)
-{
-	__raw_writel((__raw_readl(PORTR191_160DR) & ~(0xf << 25)) |
-		     (1 << (25 + n)), PORTR191_160DR);
-}
-
-#endif /* MMCIF_AP4EB_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h b/arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h
deleted file mode 100644
index 4b4f694..0000000
--- a/arch/arm/mach-shmobile/include/mach/mmcif-mackerel.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef MMCIF_MACKEREL_H
-#define MMCIF_MACKEREL_H
-
-#define PORT0CR      (void __iomem *)0xe6051000
-#define PORT1CR      (void __iomem *)0xe6051001
-#define PORT2CR      (void __iomem *)0xe6051002
-#define PORT159CR    (void __iomem *)0xe605009f
-
-#define PORTR031_000DR (void __iomem *)0xe6055000
-#define PORTL159_128DR (void __iomem *)0xe6054010
-
-static inline void mmcif_init_progress(void)
-{
-       /* Initialise LEDS0-3
-        * registers: PORT0CR-PORT2CR,PORT159CR (LED0-LED3 Control)
-        * value:     0x10 - enable output
-        */
-       __raw_writeb(0x10, PORT0CR);
-       __raw_writeb(0x10, PORT1CR);
-       __raw_writeb(0x10, PORT2CR);
-       __raw_writeb(0x10, PORT159CR);
-}
-
-static inline void mmcif_update_progress(int n)
-{
-	unsigned a = 0, b = 0;
-
-	if (n < 3)
-		a = 1 << n;
-	else
-		b = 1 << 31;
-
-	__raw_writel((__raw_readl(PORTR031_000DR) & ~0x7) | a,
-		     PORTR031_000DR);
-	__raw_writel((__raw_readl(PORTL159_128DR) & ~(1 << 31)) | b,
-		     PORTL159_128DR);
-}
-
-#endif /* MMCIF_MACKEREL_H */
diff --git a/arch/arm/mach-shmobile/include/mach/mmcif.h b/arch/arm/mach-shmobile/include/mach/mmcif.h
deleted file mode 100644
index f4dc327..0000000
--- a/arch/arm/mach-shmobile/include/mach/mmcif.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef MMCIF_H
-#define MMCIF_H
-
-/**************************************************
- *
- *		board specific settings
- *
- **************************************************/
-
-#ifdef CONFIG_MACH_AP4EVB
-#include "mach/mmcif-ap4eb.h"
-#elif CONFIG_MACH_MACKEREL
-#include "mach/mmcif-mackerel.h"
-#else
-#error "unsupported board."
-#endif
-
-#endif /* MMCIF_H */
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 2/2] mmc: Add MMC_PROGRESS_*
  2011-03-24  6:54 ` Simon Horman
@ 2011-03-24  6:54   ` Simon Horman
  -1 siblings, 0 replies; 31+ messages in thread
From: Simon Horman @ 2011-03-24  6:54 UTC (permalink / raw)
  To: vger.kernel.org, linux-mmc, linux-arm-kernel
  Cc: Guennadi Liakhovetski, Chris Ball, Kuninori Morimoto, Paul Mundt,
	Simon Horman

This is my second attempt to make this enum generally available.
The first attempt added MMCIF_PROGRESS_* to include/linux/mmc/sh_mmcif.h.
However this is not sufficiently generic as the enum will be
used by SDHI boot code.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

This patch depends on
mmc, ARM: Rename SuperH Mobile ARM zboot helpers

v2
* Include linux/mmc/boot.h in arch/sh/boot/romimage/mmcif-sh7724.c and
  arch/arm/boot/compressed/mmcif-sh7372.c to avoid introducing a build failure
---
 arch/arm/boot/compressed/mmcif-sh7372.c |    9 +++++----
 arch/sh/boot/romimage/mmcif-sh7724.c    |    9 +++++----
 include/linux/mmc/boot.h                |    7 +++++++
 include/linux/mmc/sh_mmcif.h            |    3 ---
 4 files changed, 17 insertions(+), 11 deletions(-)
 create mode 100644 include/linux/mmc/boot.h

diff --git a/arch/arm/boot/compressed/mmcif-sh7372.c b/arch/arm/boot/compressed/mmcif-sh7372.c
index 28bcf3c..7453c83 100644
--- a/arch/arm/boot/compressed/mmcif-sh7372.c
+++ b/arch/arm/boot/compressed/mmcif-sh7372.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/mmc/sh_mmcif.h>
+#include <linux/mmc/boot.h>
 #include <mach/mmc.h>
 
 #define MMCIF_BASE      (void __iomem *)0xe6bd0000
@@ -42,7 +43,7 @@
 asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 {
 	mmc_init_progress();
-	mmc_update_progress(MMCIF_PROGRESS_ENTER);
+	mmc_update_progress(MMC_PROGRESS_ENTER);
 
 	/* Initialise MMC
 	 * registers: PORT84CR-PORT92CR
@@ -68,12 +69,12 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Enable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 12), SMSTPCR3);
 
-	mmc_update_progress(MMCIF_PROGRESS_INIT);
+	mmc_update_progress(MMC_PROGRESS_INIT);
 
 	/* setup MMCIF hardware */
 	sh_mmcif_boot_init(MMCIF_BASE);
 
-	mmc_update_progress(MMCIF_PROGRESS_LOAD);
+	mmc_update_progress(MMC_PROGRESS_LOAD);
 
 	/* load kernel via MMCIF interface */
 	sh_mmcif_boot_do_read(MMCIF_BASE, 2, /* Kernel is at block 2 */
@@ -83,5 +84,5 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Disable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & (1 << 12), SMSTPCR3);
 
-	mmc_update_progress(MMCIF_PROGRESS_DONE);
+	mmc_update_progress(MMC_PROGRESS_DONE);
 }
diff --git a/arch/sh/boot/romimage/mmcif-sh7724.c b/arch/sh/boot/romimage/mmcif-sh7724.c
index c84e783..16b1225 100644
--- a/arch/sh/boot/romimage/mmcif-sh7724.c
+++ b/arch/sh/boot/romimage/mmcif-sh7724.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/mmc/sh_mmcif.h>
+#include <linux/mmc/boot.h>
 #include <mach/romimage.h>
 
 #define MMCIF_BASE      (void __iomem *)0xa4ca0000
@@ -29,7 +30,7 @@
  */
 asmlinkage void mmcif_loader(unsigned char *buf, unsigned long no_bytes)
 {
-	mmcif_update_progress(MMCIF_PROGRESS_ENTER);
+	mmcif_update_progress(MMC_PROGRESS_ENTER);
 
 	/* enable clock to the MMCIF hardware block */
 	__raw_writel(__raw_readl(MSTPCR2) & ~0x20000000, MSTPCR2);
@@ -52,12 +53,12 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long no_bytes)
 	/* high drive capability for MMC pins */
 	__raw_writew(__raw_readw(DRVCRA) | 0x3000, DRVCRA);
 
-	mmcif_update_progress(MMCIF_PROGRESS_INIT);
+	mmcif_update_progress(MMC_PROGRESS_INIT);
 
 	/* setup MMCIF hardware */
 	sh_mmcif_boot_init(MMCIF_BASE);
 
-	mmcif_update_progress(MMCIF_PROGRESS_LOAD);
+	mmcif_update_progress(MMC_PROGRESS_LOAD);
 
 	/* load kernel via MMCIF interface */
 	sh_mmcif_boot_do_read(MMCIF_BASE, 512,
@@ -67,5 +68,5 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long no_bytes)
 	/* disable clock to the MMCIF hardware block */
 	__raw_writel(__raw_readl(MSTPCR2) | 0x20000000, MSTPCR2);
 
-	mmcif_update_progress(MMCIF_PROGRESS_DONE);
+	mmcif_update_progress(MMC_PROGRESS_DONE);
 }
diff --git a/include/linux/mmc/boot.h b/include/linux/mmc/boot.h
new file mode 100644
index 0000000..39d787c
--- /dev/null
+++ b/include/linux/mmc/boot.h
@@ -0,0 +1,7 @@
+#ifndef MMC_BOOT_H
+#define MMC_BOOT_H
+
+enum { MMC_PROGRESS_ENTER, MMC_PROGRESS_INIT,
+       MMC_PROGRESS_LOAD, MMC_PROGRESS_DONE };
+
+#endif
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index 38d3930..9eb9b4b 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -104,9 +104,6 @@ static inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val)
 
 #define SH_MMCIF_BBS 512 /* boot block size */
 
-enum { MMCIF_PROGRESS_ENTER, MMCIF_PROGRESS_INIT,
-       MMCIF_PROGRESS_LOAD, MMCIF_PROGRESS_DONE };
-
 static inline void sh_mmcif_boot_cmd_send(void __iomem *base,
 					  unsigned long cmd, unsigned long arg)
 {
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 2/2] mmc: Add MMC_PROGRESS_*
@ 2011-03-24  6:54   ` Simon Horman
  0 siblings, 0 replies; 31+ messages in thread
From: Simon Horman @ 2011-03-24  6:54 UTC (permalink / raw)
  To: linux-arm-kernel

This is my second attempt to make this enum generally available.
The first attempt added MMCIF_PROGRESS_* to include/linux/mmc/sh_mmcif.h.
However this is not sufficiently generic as the enum will be
used by SDHI boot code.

Signed-off-by: Simon Horman <horms@verge.net.au>

---

This patch depends on
mmc, ARM: Rename SuperH Mobile ARM zboot helpers

v2
* Include linux/mmc/boot.h in arch/sh/boot/romimage/mmcif-sh7724.c and
  arch/arm/boot/compressed/mmcif-sh7372.c to avoid introducing a build failure
---
 arch/arm/boot/compressed/mmcif-sh7372.c |    9 +++++----
 arch/sh/boot/romimage/mmcif-sh7724.c    |    9 +++++----
 include/linux/mmc/boot.h                |    7 +++++++
 include/linux/mmc/sh_mmcif.h            |    3 ---
 4 files changed, 17 insertions(+), 11 deletions(-)
 create mode 100644 include/linux/mmc/boot.h

diff --git a/arch/arm/boot/compressed/mmcif-sh7372.c b/arch/arm/boot/compressed/mmcif-sh7372.c
index 28bcf3c..7453c83 100644
--- a/arch/arm/boot/compressed/mmcif-sh7372.c
+++ b/arch/arm/boot/compressed/mmcif-sh7372.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/mmc/sh_mmcif.h>
+#include <linux/mmc/boot.h>
 #include <mach/mmc.h>
 
 #define MMCIF_BASE      (void __iomem *)0xe6bd0000
@@ -42,7 +43,7 @@
 asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 {
 	mmc_init_progress();
-	mmc_update_progress(MMCIF_PROGRESS_ENTER);
+	mmc_update_progress(MMC_PROGRESS_ENTER);
 
 	/* Initialise MMC
 	 * registers: PORT84CR-PORT92CR
@@ -68,12 +69,12 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Enable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & ~(1 << 12), SMSTPCR3);
 
-	mmc_update_progress(MMCIF_PROGRESS_INIT);
+	mmc_update_progress(MMC_PROGRESS_INIT);
 
 	/* setup MMCIF hardware */
 	sh_mmcif_boot_init(MMCIF_BASE);
 
-	mmc_update_progress(MMCIF_PROGRESS_LOAD);
+	mmc_update_progress(MMC_PROGRESS_LOAD);
 
 	/* load kernel via MMCIF interface */
 	sh_mmcif_boot_do_read(MMCIF_BASE, 2, /* Kernel is@block 2 */
@@ -83,5 +84,5 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long len)
 	/* Disable clock to MMC hardware block */
 	__raw_writel(__raw_readl(SMSTPCR3) & (1 << 12), SMSTPCR3);
 
-	mmc_update_progress(MMCIF_PROGRESS_DONE);
+	mmc_update_progress(MMC_PROGRESS_DONE);
 }
diff --git a/arch/sh/boot/romimage/mmcif-sh7724.c b/arch/sh/boot/romimage/mmcif-sh7724.c
index c84e783..16b1225 100644
--- a/arch/sh/boot/romimage/mmcif-sh7724.c
+++ b/arch/sh/boot/romimage/mmcif-sh7724.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/mmc/sh_mmcif.h>
+#include <linux/mmc/boot.h>
 #include <mach/romimage.h>
 
 #define MMCIF_BASE      (void __iomem *)0xa4ca0000
@@ -29,7 +30,7 @@
  */
 asmlinkage void mmcif_loader(unsigned char *buf, unsigned long no_bytes)
 {
-	mmcif_update_progress(MMCIF_PROGRESS_ENTER);
+	mmcif_update_progress(MMC_PROGRESS_ENTER);
 
 	/* enable clock to the MMCIF hardware block */
 	__raw_writel(__raw_readl(MSTPCR2) & ~0x20000000, MSTPCR2);
@@ -52,12 +53,12 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long no_bytes)
 	/* high drive capability for MMC pins */
 	__raw_writew(__raw_readw(DRVCRA) | 0x3000, DRVCRA);
 
-	mmcif_update_progress(MMCIF_PROGRESS_INIT);
+	mmcif_update_progress(MMC_PROGRESS_INIT);
 
 	/* setup MMCIF hardware */
 	sh_mmcif_boot_init(MMCIF_BASE);
 
-	mmcif_update_progress(MMCIF_PROGRESS_LOAD);
+	mmcif_update_progress(MMC_PROGRESS_LOAD);
 
 	/* load kernel via MMCIF interface */
 	sh_mmcif_boot_do_read(MMCIF_BASE, 512,
@@ -67,5 +68,5 @@ asmlinkage void mmcif_loader(unsigned char *buf, unsigned long no_bytes)
 	/* disable clock to the MMCIF hardware block */
 	__raw_writel(__raw_readl(MSTPCR2) | 0x20000000, MSTPCR2);
 
-	mmcif_update_progress(MMCIF_PROGRESS_DONE);
+	mmcif_update_progress(MMC_PROGRESS_DONE);
 }
diff --git a/include/linux/mmc/boot.h b/include/linux/mmc/boot.h
new file mode 100644
index 0000000..39d787c
--- /dev/null
+++ b/include/linux/mmc/boot.h
@@ -0,0 +1,7 @@
+#ifndef MMC_BOOT_H
+#define MMC_BOOT_H
+
+enum { MMC_PROGRESS_ENTER, MMC_PROGRESS_INIT,
+       MMC_PROGRESS_LOAD, MMC_PROGRESS_DONE };
+
+#endif
diff --git a/include/linux/mmc/sh_mmcif.h b/include/linux/mmc/sh_mmcif.h
index 38d3930..9eb9b4b 100644
--- a/include/linux/mmc/sh_mmcif.h
+++ b/include/linux/mmc/sh_mmcif.h
@@ -104,9 +104,6 @@ static inline void sh_mmcif_writel(void __iomem *addr, int reg, u32 val)
 
 #define SH_MMCIF_BBS 512 /* boot block size */
 
-enum { MMCIF_PROGRESS_ENTER, MMCIF_PROGRESS_INIT,
-       MMCIF_PROGRESS_LOAD, MMCIF_PROGRESS_DONE };
-
 static inline void sh_mmcif_boot_cmd_send(void __iomem *base,
 					  unsigned long cmd, unsigned long arg)
 {
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH] mmc, AT91: fix init fequency problem
  2011-03-24  6:54   ` Simon Horman
@ 2011-03-24  9:10     ` Prchal Jiří
  -1 siblings, 0 replies; 31+ messages in thread
From: Prchal Jiří @ 2011-03-24  9:10 UTC (permalink / raw)
  To: linux-mmc, nicolas.ferre, linux-arm-kernel; +Cc: linux-kernel

Hi,
this patch fixes problem with some SD cards during initialization. Not all SD(HC) card can run at even 375kHz. Sets
minimal frequency to 200kHz.
And in function "at91_mci_set_ios" is limit to maximum division, it's only 8 bit value.

Kernel version: 2.6.38
Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
---

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/drivers/mmc/host/at91_mci.c
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/drivers/mmc/host/at91_mci.c
--- linux-2.6.38-vanilla/drivers/mmc/host/at91_mci.c	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/drivers/mmc/host/at91_mci.c	2011-03-24 09:20:22.869370179 +0100
@@ -724,6 +724,10 @@ static void at91_mci_set_ios(struct mmc_
 		else
 			clkdiv = (at91_master_clock / ios->clock) / 2;

+		/* set maximum divider */
+		if (clkdiv > 255)
+			clkdiv = 255;
+
 		pr_debug("clkdiv = %d. mcck = %ld\n", clkdiv,
 			at91_master_clock / (2 * (clkdiv + 1)));
 	}
@@ -944,7 +948,7 @@ static int __init at91_mci_probe(struct
 	}

 	mmc->ops = &at91_mci_ops;
-	mmc->f_min = 375000;
+	mmc->f_min = 200000; /* not all cards can run at 375kHz */
 	mmc->f_max = 25000000;
 	mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
 	mmc->caps = 0;

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] mmc, AT91: fix init fequency problem
@ 2011-03-24  9:10     ` Prchal Jiří
  0 siblings, 0 replies; 31+ messages in thread
From: Prchal Jiří @ 2011-03-24  9:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,
this patch fixes problem with some SD cards during initialization. Not all SD(HC) card can run at even 375kHz. Sets
minimal frequency to 200kHz.
And in function "at91_mci_set_ios" is limit to maximum division, it's only 8 bit value.

Kernel version: 2.6.38
Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
---

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/drivers/mmc/host/at91_mci.c
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/drivers/mmc/host/at91_mci.c
--- linux-2.6.38-vanilla/drivers/mmc/host/at91_mci.c	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/drivers/mmc/host/at91_mci.c	2011-03-24 09:20:22.869370179 +0100
@@ -724,6 +724,10 @@ static void at91_mci_set_ios(struct mmc_
 		else
 			clkdiv = (at91_master_clock / ios->clock) / 2;

+		/* set maximum divider */
+		if (clkdiv > 255)
+			clkdiv = 255;
+
 		pr_debug("clkdiv = %d. mcck = %ld\n", clkdiv,
 			at91_master_clock / (2 * (clkdiv + 1)));
 	}
@@ -944,7 +948,7 @@ static int __init at91_mci_probe(struct
 	}

 	mmc->ops = &at91_mci_ops;
-	mmc->f_min = 375000;
+	mmc->f_min = 200000; /* not all cards can run at 375kHz */
 	mmc->f_max = 25000000;
 	mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
 	mmc->caps = 0;

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
  2011-03-24  6:54   ` Simon Horman
  (?)
  (?)
@ 2011-03-24 10:20   ` Prchal Jiří
  2011-04-02  8:26       ` [alsa-devel] " Mark Brown
  -1 siblings, 1 reply; 31+ messages in thread
From: Prchal Jiří @ 2011-03-24 10:20 UTC (permalink / raw)
  To: alsa-devel, alsa-devel, vbarinov; +Cc: linux-kernel

Hi,
this patch ads SPI communication for codecs TLV320AIC3X and clock input on GPIO2 or BCLK.
Tested on TLV320AIC3106 and AT91SAM9260.
TODO: Set the model in SPI probe the right way. I don't know how.
This codec communicates on SPI in 1st byte: 7 MSB is register address, 1 LSB is read/write, 2nd byte data. For this
reason there is new functions in soc-cache.c snd_soc_7_8_*.

Kernel version: 2.6.38
Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
---

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/codecs/Kconfig
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/codecs/Kconfig
--- linux-2.6.38-vanilla/sound/soc/codecs/Kconfig	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/codecs/Kconfig	2011-03-17 08:37:14.997500191 +0100
@@ -37,7 +37,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
 	select SND_SOC_TLV320AIC23 if I2C
 	select SND_SOC_TLV320AIC26 if SPI_MASTER
-	select SND_SOC_TLV320AIC3X if I2C
+	select SND_SOC_TLV320AIC3X if SND_SOC_I2C_AND_SPI
 	select SND_SOC_TPA6130A2 if I2C
 	select SND_SOC_TLV320DAC33 if I2C
 	select SND_SOC_TWL4030 if TWL4030_CORE
@@ -118,7 +118,7 @@ config SND_SOC_AD1980

 config SND_SOC_AD73311
 	tristate
-
+
 config SND_SOC_ADS117X
 	tristate

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.c
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/codecs/tlv320aic3x.c
--- linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.c	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/codecs/tlv320aic3x.c	2011-03-24 09:34:58.769370117 +0100
@@ -2,7 +2,9 @@
  * ALSA SoC TLV320AIC3X codec driver
  *
  * Author:      Vladimir Barinov, <vbarinov@embeddedalley.com>
+ *              Jiri Prchal, <jiri.prchal@aksignal.cz
  * Copyright:   (C) 2007 MontaVista Software, Inc., <source@mvista.com>
+ *              (C) 2011 AK signal Brno
  *
  * Based on sound/soc/codecs/wm8753.c by Liam Girdwood
  *
@@ -42,6 +44,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/spi/spi.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -984,6 +987,13 @@ static int aic3x_set_dai_sysclk(struct s
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
 	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
+	u8 data;
+
+	/* set external clock on GPIO2 or BCLK */
+	data = snd_soc_read(codec, AIC3X_CLKGEN_CTRL_REG);
+	data &= 0x0f;
+	data |= ((clk_id << PLLCLK_IN_SHIFT) | (clk_id << CLKDIV_IN_SHIFT));
+	snd_soc_write(codec, AIC3X_CLKGEN_CTRL_REG, data);

 	aic3x->sysclk = freq;
 	return 0;
@@ -1371,9 +1381,12 @@ static int aic3x_probe(struct snd_soc_co
 	aic3x->codec = codec;
 	codec->dapm.idle_bias_off = 1;

-	ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type);
+	if (aic3x->control_type == SND_SOC_I2C)
+		ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type);
+	else
+		ret = snd_soc_codec_set_cache_io(codec, 7, 8, aic3x->control_type);
 	if (ret != 0) {
-		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
+		dev_err(codec->dev, "failed to set cache I/O: %d\n", ret);
 		return ret;
 	}

@@ -1472,6 +1485,54 @@ static struct snd_soc_codec_driver soc_c
 	.resume = aic3x_resume,
 };

+#if defined(CONFIG_SPI_MASTER)
+static int aic3x_spi_probe(struct spi_device *spi)
+{
+	struct aic3x_pdata *pdata = spi->dev.platform_data;
+	struct aic3x_priv *aic3x;
+	int ret;
+
+	aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL);
+	if (aic3x == NULL) {
+		dev_err(&spi->dev, "failed to create private data\n");
+		return -ENOMEM;
+	}
+
+	aic3x->control_type = SND_SOC_SPI;
+	spi_set_drvdata(spi, aic3x);
+
+	if (pdata) {
+		aic3x->gpio_reset = pdata->gpio_reset;
+		aic3x->setup = pdata->setup;
+	} else {
+		aic3x->gpio_reset = -1;
+	}
+
+	aic3x->model = AIC3X_MODEL_3X;
+
+	ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_aic3x, &aic3x_dai, 1);
+	if (ret < 0)
+		kfree(aic3x);
+	return ret;
+}
+
+static int __devexit aic3x_spi_remove(struct spi_device *spi)
+{
+	snd_soc_unregister_codec(&spi->dev);
+	kfree(spi_get_drvdata(spi));
+	return 0;
+}
+
+static struct spi_driver aic3x_spi_driver = {
+	.driver = {
+		.name	= "tlv320aic3x-codec",
+		.owner	= THIS_MODULE,
+	},
+	.probe		= aic3x_spi_probe,
+	.remove		= __devexit_p(aic3x_spi_remove),
+};
+#endif /* CONFIG_SPI_MASTER */
+
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 /*
  * AIC3X 2 wire address can be up to 4 devices with device addresses
@@ -1557,6 +1618,13 @@ static int __init aic3x_modinit(void)
 		       ret);
 	}
 #endif
+#if defined(CONFIG_SPI_MASTER)
+	ret = spi_register_driver(&aic3x_spi_driver);
+	if (ret != 0) {
+		printk(KERN_ERR "Failed to register AIC3X SPI driver: %d\n",
+		       ret);
+	}
+#endif
 	return ret;
 }
 module_init(aic3x_modinit);
@@ -1566,6 +1634,9 @@ static void __exit aic3x_exit(void)
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	i2c_del_driver(&aic3x_i2c_driver);
 #endif
+#if defined(CONFIG_SPI_MASTER)
+	spi_unregister_driver(&aic3x_spi_driver);
+#endif
 }
 module_exit(aic3x_exit);

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.h
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/codecs/tlv320aic3x.h
--- linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.h	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/codecs/tlv320aic3x.h	2011-03-22 13:37:54.751566089 +0100
@@ -178,6 +178,13 @@
 #define PLL_CLKIN_SHIFT		4
 #define MCLK_SOURCE		0x0
 #define PLL_CLKDIV_SHIFT	0
+#define PLLCLK_IN_SHIFT		4
+#define CLKDIV_IN_SHIFT		6
+/* clock in source */
+#define CLKIN_MCLK		0
+#define CLKIN_GPIO2		1
+#define CLKIN_BCLK		2
+

 /* Software reset register bits */
 #define SOFT_RESET		0x80
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/soc-cache.c
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/soc-cache.c
--- linux-2.6.38-vanilla/sound/soc/soc-cache.c	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/soc-cache.c	2011-03-24 09:23:00.984373772 +0100
@@ -99,6 +99,58 @@ static int snd_soc_4_12_spi_write(void *
 #define snd_soc_4_12_spi_write NULL
 #endif

+/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
+static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
+				     unsigned int reg)
+{
+	int ret;
+	unsigned int val;
+
+	if (reg >= codec->driver->reg_cache_size ||
+		snd_soc_codec_volatile_register(codec, reg)) {
+			if (codec->cache_only)
+				return -1;
+
+			BUG_ON(!codec->hw_read);
+			return codec->hw_read(codec, ((reg << 1) | 1));
+	}
+
+	ret = snd_soc_cache_read(codec, reg, &val);
+	if (ret < 0)
+		return -1;
+	return val;
+}
+
+static int snd_soc_7_8_write(struct snd_soc_codec *codec, unsigned int reg,
+			     unsigned int value)
+{
+	u8 data[2];
+	int ret;
+
+	data[0] = (reg << 1);
+	data[1] = value;
+
+	if (!snd_soc_codec_volatile_register(codec, reg) &&
+		reg < codec->driver->reg_cache_size) {
+		ret = snd_soc_cache_write(codec, reg, value);
+		if (ret < 0)
+			return -1;
+	}
+
+	if (codec->cache_only) {
+		codec->cache_sync = 1;
+		return 0;
+	}
+
+	ret = codec->hw_write(codec->control_data, data, 2);
+	if (ret == 2)
+		return 0;
+	if (ret < 0)
+		return ret;
+	else
+		return -EIO;
+}
+
 static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
 				     unsigned int reg)
 {
@@ -661,6 +713,11 @@ static struct {
 		.spi_write = snd_soc_4_12_spi_write,
 	},
 	{
+		.addr_bits = 7, .data_bits = 8,
+		.write = snd_soc_7_8_write, .read = snd_soc_7_8_read,
+		.spi_write = snd_soc_8_8_spi_write,
+	},
+	{
 		.addr_bits = 7, .data_bits = 9,
 		.write = snd_soc_7_9_write, .read = snd_soc_7_9_read,
 		.spi_write = snd_soc_7_9_spi_write,

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
  2011-03-24  6:54   ` Simon Horman
                     ` (2 preceding siblings ...)
  (?)
@ 2011-03-24 10:43   ` Prchal Jiří
  2011-03-24 20:07       ` Ryan Mallon
  -1 siblings, 1 reply; 31+ messages in thread
From: Prchal Jiří @ 2011-03-24 10:43 UTC (permalink / raw)
  To: alsa-devel, alsa-devel, vbarinov; +Cc: linux-kernel

Hi,
this patch is for example how to put together AT91SAM9260 and TLV320AIC3106 controlled via SPI.
It tooks me a lot of time to make it working, so I think it could be helpfull for other people.

In original source "snd-soc-afeb9260.c" which I use as example is BIG ERROR:
In function "afeb9260_soc_init" is missing call of "atmel_ssc_set_audio(0);". It cause bug "PROBLEM: Asoc driver in
2.6.37.3 for AT91SAM9260 / TLV320AIC3X is broken" which I post some time ago.

Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
Kernel version: 2.6.38
Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
---

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c
--- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c	2011-03-24 09:15:23.852370981 +0100
@@ -0,0 +1,345 @@
+/*
+ * linux/arch/arm/mach-at91/board-cdu.c
+ *
+ *  Copyright (C) 2005 SAN People
+ *  Copyright (C) 2006 Atmel
+ *  Copyright (C) 2011 AKsignal Brno
+ *                     jiri.prchal@aksignal.cz
+ *
+ * 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 <linux/types.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/clk.h>
+#include <linux/spi/mcp23s08.h>
+#include <linux/dma-mapping.h>
+
+#include <mach/hardware.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/irq.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/at91sam9_smc.h>
+
+#include "sam9_smc.h"
+#include "generic.h"
+
+static void __init cdu_map_io(void)
+{
+	/* Initialize processor: 6 MHz crystal */
+	at91sam9260_initialize(6000000);
+
+	/* DBGU on ttyS0. (Rx & Tx only) */
+	at91_register_uart(0, 0, 0);
+
+	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
+	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
+			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
+			   | ATMEL_UART_RI);
+
+	/* USART1 on ttyS2. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
+
+	/* USART2 on ttyS3. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
+
+	/* USART3 on ttyS4. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
+
+	/* USART4 on ttyS5. (Tx) */
+	/* EBUS - transmit audio, no rx */
+	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
+
+	/* set serial console to ttyS0 (ie, DBGU) */
+	at91_set_serial_console(0);
+}
+
+static void __init cdu_init_irq(void)
+{
+	at91sam9260_init_interrupts(NULL);
+}
+
+/*
+ * USB Host port
+ */
+static struct at91_usbh_data __initdata cdu_usbh_data = {
+	.ports		= 2,
+};
+
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata cdu_udc_data = {
+	.vbus_pin	= AT91_PIN_PC15,
+	.pullup_pin	= 0,		/* pull-up driven by UDC */
+};
+
+/*
+ * SPI devices.
+ */
+#define MCP23S08_GPIO_BASE	128
+
+static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
+	.chip[0].is_present	= true,
+	.chip[0].pullups	= 0,
+	.base			= MCP23S08_GPIO_BASE,
+};
+
+static struct spi_board_info cdu_spi_devices[] = {
+	{ /* ADC LTC2488 */
+		.modalias	= "spidev",
+		.chip_select	= 0,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 1,
+	},
+	{ /* GPIO expander MCP23S08 */
+		.modalias	= "mcp23s08",
+		.chip_select	= 1,
+		.max_speed_hz	= 1000000,
+		.bus_num	= 1,
+		.platform_data	= &mcp23s08_gpio_info,
+		.mode		= SPI_MODE_3,
+	},
+	{ /* non volatile memory (F-RAM) FM25VN10 */
+		.modalias	= "spidev",
+		.chip_select	= 2,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 1,
+	},
+	{ /* audiocodec TLV320AIC3106 */
+		.modalias	= "tlv320aic3x-codec",
+		.chip_select	= 3,
+		.max_speed_hz	= 1000000,
+		.bus_num	= 1,
+		.mode		= SPI_MODE_1,
+	},
+};
+
+/*
+ * MACB Ethernet device
+ */
+static struct at91_eth_data __initdata cdu_macb_data = {
+	.phy_irq_pin	= 0, //nc,
+	.is_rmii	= 1,
+};
+
+/*
+ * NAND flash
+ */
+static struct mtd_partition __initdata cdu_nand_partition[] = {
+	{
+		.name   = "bootstrap",
+		.offset = 0,
+	  .size   = 0x40000,
+	},
+	{
+		.name   = "uboot",
+		.offset = 0x40000,
+		.size   = (0xc0000 - 0x40000),
+	},
+	{
+		.name   = "ubootenv",
+		.offset = 0xc0000,
+		.size   = (0x100000 - 0xc0000),
+	},
+	{
+		.name   = "kernel",
+		.offset = 0x100000,
+		.size   = (0x400000 - 0x100000),
+	},
+	{
+		.name   = "rootfs",
+		.offset = 0x400000,
+		.size   = (0x8000000 - 0x400000),
+	},
+};
+
+static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
+{
+	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
+	return cdu_nand_partition;
+}
+
+static struct atmel_nand_data __initdata cdu_nand_data = {
+	.ale		= 21,
+	.cle		= 22,
+//	.det_pin	= ... not connected
+	.rdy_pin	= AT91_PIN_PC13,
+	.enable_pin	= AT91_PIN_PC14,
+	.partition_info	= nand_partitions,
+	.bus_width_16	= 0,
+};
+
+static struct sam9_smc_config __initdata cdu_nand_smc_config = {
+	.ncs_read_setup		= 0,
+	.nrd_setup		= 1,
+	.ncs_write_setup	= 0,
+	.nwe_setup		= 1,
+
+	.ncs_read_pulse		= 3,
+	.nrd_pulse		= 3,
+	.ncs_write_pulse	= 3,
+	.nwe_pulse		= 3,
+
+	.read_cycle		= 5,
+	.write_cycle		= 5,
+
+	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
+	.tdf_cycles		= 2,
+};
+
+static void __init cdu_add_device_nand(void)
+{
+	/* setup bus-width (8 or 16) */
+	if (cdu_nand_data.bus_width_16)
+		cdu_nand_smc_config.mode |= AT91_SMC_DBW_16;
+	else
+		cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;
+
+	/* configure chip-select 3 (NAND) */
+	sam9_smc_configure(3, &cdu_nand_smc_config);
+
+	at91_add_device_nand(&cdu_nand_data);
+}
+
+/*
+* MCI (SD/MMC)
+*/
+static struct at91_mmc_data __initdata ek_mmc_data = {
+  .slot_b		= 0,
+  .wire4		= 1,
+  //	.det_pin	= ... not connected
+  //	.wp_pin		= ... not connected
+  //	.vcc_pin	= ... not connected
+};
+
+/*
+ * LEDs
+ */
+static struct gpio_led cdu_leds[] = {
+	{
+		.name			= "red",
+		.gpio			= AT91_PIN_PC10,
+		.default_trigger	= "timer",
+	},
+	{
+		.name			= "green",
+		.gpio			= AT91_PIN_PA5,
+		.default_trigger	= "heartbeat",
+	},
+	{
+		.name			= "yellow",
+		.gpio			= AT91_PIN_PB20,
+		.active_low		= 1,
+		.default_trigger	= "mmc0",
+	},
+	{
+		.name			= "blue",
+		.gpio			= AT91_PIN_PB21,
+		.active_low		= 1,
+		.default_trigger	= "nand-disk",
+	},
+};
+
+/*
+ * GPIOs
+ */
+static struct gpio gpios[] = {
+	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
+	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
+	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
+	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
+	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
+	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
+
+	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
+	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
+	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
+	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
+	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
+	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
+
+	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
+	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
+	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
+	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
+	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
+	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
+
+	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
+	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
+	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
+	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
+	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
+	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
+	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
+};
+
+static void __init cdu_add_gpio (void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE (gpios); i++) {
+		gpio_request_one (gpios[i].gpio, gpios[i].flags, gpios[i].label);
+	}
+}
+
+/*
+ * init
+ */
+static void __init cdu_board_init(void)
+{
+	/* Serial */
+	at91_add_device_serial();
+	/* USB Host */
+	at91_add_device_usbh(&cdu_usbh_data);
+	/* USB Device */
+	at91_add_device_udc(&cdu_udc_data);
+	/* SPI */
+	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
+	/* NAND */
+	cdu_add_device_nand();
+	/* Ethernet */
+	at91_add_device_eth(&cdu_macb_data);
+	/* MMC */
+	at91_add_device_mmc(0, &ek_mmc_data);
+	/* SSC */
+	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
+	/* LEDs */
+	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
+	// GPIO
+	cdu_add_gpio ();
+}
+
+MACHINE_START(AT91SAM9260EK, "CDU")
+	/* Maintainer: Atmel */
+	.boot_params	= AT91_SDRAM_BASE + 0x100,
+	.timer		= &at91sam926x_timer,
+	.map_io		= cdu_map_io,
+	.init_irq	= cdu_init_irq,
+	.init_machine	= cdu_board_init,
+MACHINE_END
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig
--- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
@@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
 	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
 	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>

+config MACH_CDU
+	bool "CDU AKsignal board"
+	help
+	  Select this if you are using AKsignal CDU board
+	  <http://www.aksignal.cz>
+
 config MACH_CAM60
 	bool "KwikByte KB9260 (CAM60) board"
 	help
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile
--- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
@@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92

 # AT91SAM9260 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
+obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
 obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
 obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
 obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Kconfig
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig
--- linux-2.6.38-vanilla/sound/soc/atmel/Kconfig	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig	2011-03-22 09:46:46.751566158 +0100
@@ -50,3 +50,11 @@ config SND_AT91_SOC_AFEB9260
 	select SND_SOC_TLV320AIC23
 	help
 	  Say Y here to support sound on AFEB9260 board.
+
+config SND_AT91_SOC_CDU
+	tristate "SoC Audio support for CDU board"
+	depends on ARCH_AT91 && MACH_CDU && SND_ATMEL_SOC
+	select SND_ATMEL_SOC_SSC
+	select SND_SOC_TLV320AIC3X
+	help
+	  Say Y here to support sound on CDU board.
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Makefile
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile
--- linux-2.6.38-vanilla/sound/soc/atmel/Makefile	2011-03-15 02:20:32.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile	2011-03-16 09:26:17.000000000 +0100
@@ -14,3 +14,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o
 obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
 obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
 obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
+obj-$(CONFIG_SND_AT91_SOC_CDU) += snd-soc-cdu.o
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c
/home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c
--- linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c	1970-01-01 01:00:00.000000000 +0100
+++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c	2011-03-24 09:27:55.404367652 +0100
@@ -0,0 +1,264 @@
+/*
+ * snd-soc-cdu  --  SoC audio for AT91SAM9260-based
+ * 			AKsignal CDU board.
+ *
+ *  Copyright (C) 2005 SAN People
+ *  Copyright (C) 2008 Atmel
+ *  Copyright (C) 2011 AK signal Brno
+ *
+ * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
+ *          Jiri Prchal <jiri.prchal@aksignal.cz>
+ *
+ * Based on ati_b1_wm8731.c by:
+ * Frank Mandarino <fmandarino@endrelia.com>
+ * Copyright 2006 Endrelia Technologies Inc.
+ * Based on corgi.c by:
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * 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 <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
+
+#include <linux/atmel-ssc.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
+#include <asm/mach-types.h>
+#include <mach/hardware.h>
+#include <mach/gpio.h>
+
+#include "../codecs/tlv320aic3x.h"
+#include "atmel-pcm.h"
+#include "atmel_ssc_dai.h"
+
+struct {
+	unsigned int channels;
+	snd_pcm_format_t format;
+	unsigned int rate;
+	unsigned int codecclk;
+	unsigned int cmrdiv;
+	unsigned int period;
+} cdu_audio[] = {
+	/* 16 bit stereo modes */
+	{2, SNDRV_PCM_FORMAT_S16_LE, 8000, 2096000, 25, 130,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 16000, 2496000, 21, 77,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 32000, 2496000, 21, 38,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 48000, 2016000, 26, 20,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 96000, 4032000, 13, 20,},
+
+	{2, SNDRV_PCM_FORMAT_S16_LE, 11025, 2381400, 22, 107,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 22050, 2381400, 22, 53,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 44100, 2381400, 22, 26,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 88200, 4762800, 11, 26,},
+
+	{2, SNDRV_PCM_FORMAT_S16_LE, 11520, 2626560, 20, 113,},
+	{2, SNDRV_PCM_FORMAT_S16_LE, 23040, 2626560, 20, 56,},
+
+};
+
+static int cdu_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	int ret;
+	int i, found = 0;
+	snd_pcm_format_t format = params_format(params);
+	unsigned int rate = params_rate(params);
+	unsigned int channels = params_channels(params);
+
+	/* set codec DAI configuration */
+	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+	if (ret < 0)
+		return ret;
+
+	/* set cpu DAI configuration */
+	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
+	if (ret < 0)
+		return ret;
+
+	/* find the correct audio parameters */
+	for (i = 0; i < ARRAY_SIZE(cdu_audio); i++) {
+		if (rate == cdu_audio[i].rate &&
+		    format == cdu_audio[i].format &&
+		    channels == cdu_audio[i].channels) {
+			found = 1;
+			break;
+		}
+	}
+	if (!found)
+		return -EINVAL;
+
+	/* Set the codec system clock for DAC and ADC */
+	ret = snd_soc_dai_set_sysclk(codec_dai, CLKIN_BCLK, cdu_audio[i].codecclk, SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		printk(KERN_ERR "can't set codec system clock\n");
+		return ret;
+	}
+
+	/* Set the cpu clock dividers to BCLK */
+	ret = snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_CMR_DIV, cdu_audio[i].cmrdiv);
+	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_TCMR_PERIOD, cdu_audio[i].period);
+	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_RCMR_PERIOD, cdu_audio[i].period);
+	if (ret < 0) {
+		printk(KERN_ERR "can't set cpu system clock\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct snd_soc_ops cdu_ops = {
+	.hw_params = cdu_hw_params,
+};
+
+static const struct snd_soc_dapm_widget cdu_dapm_widgets[] = {
+	SND_SOC_DAPM_HP("Headphone Jack", NULL),
+	SND_SOC_DAPM_LINE("Line Out", NULL),
+	SND_SOC_DAPM_MIC("Mic Jack", NULL),
+	SND_SOC_DAPM_LINE("Line In", NULL),
+};
+
+static const struct snd_soc_dapm_route intercon[] = {
+	/* Headphone connected to HPLOUT, HPROUT */
+	{"Headphone Jack", NULL, "HPLOUT"},
+	{"Headphone Jack", NULL, "HPROUT"},
+
+	/* Line Out connected to LLOUT, RLOUT */
+	{"Line Out", NULL, "LLOUT"},
+	{"Line Out", NULL, "RLOUT"},
+
+	/* Mic connected to (MIC3L | MIC3R) */
+	{"MIC3L", NULL, "Mic Bias 2V"},
+	{"MIC3R", NULL, "Mic Bias 2V"},
+	{"Mic Bias 2V", NULL, "Mic Jack"},
+
+	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
+	{"LINE1L", NULL, "Line In"},
+	{"LINE2L", NULL, "Line In"},
+	{"LINE1R", NULL, "Line In"},
+	{"LINE2R", NULL, "Line In"},
+};
+
+/*
+ * Logic for a aic3x as connected on a cdu board.
+ */
+static int cdu_aic3x_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_codec *codec = rtd->codec;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_dapm_context *dapm = &codec->dapm;
+	int ret;
+
+	printk(KERN_DEBUG "cdu_aic3x: cdu_aic3x_init called\n");
+
+	/* Add specific widgets */
+	snd_soc_dapm_new_controls(dapm, cdu_dapm_widgets,
+				  ARRAY_SIZE(cdu_dapm_widgets));
+	/* Set up specific audio path interconnects */
+	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
+
+	/* always connected */
+	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
+	snd_soc_dapm_enable_pin(dapm, "Line Out");
+	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
+	snd_soc_dapm_enable_pin(dapm, "Line In");
+
+	snd_soc_dapm_sync(dapm);
+
+	return 0;
+}
+
+static struct snd_soc_dai_link cdu_dai = {
+	.name		= "TLV320AIC3106",
+	.stream_name	= "PCM",
+	.cpu_dai_name	= "atmel-ssc-dai.0",
+	.codec_dai_name	= "tlv320aic3x-hifi",
+	.init = cdu_aic3x_init,
+	.platform_name	= "atmel-pcm-audio",
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
+	.codec_name	= "tlv320aic3x-codec.0-001b",
+#endif
+#if defined(CONFIG_SPI_MASTER)
+	.codec_name	= "spi1.3",
+#endif
+	.ops		= &cdu_ops,
+};
+
+static struct snd_soc_card snd_soc_cdu = {
+	.name		= "TLV320AIC3106",
+	.dai_link	= &cdu_dai,
+	.num_links	= 1,
+};
+
+static struct platform_device *cdu_snd_device;
+
+static int __init cdu_init(void)
+{
+	struct clk *pllb;
+	int ret;
+
+	ret = atmel_ssc_set_audio(0);
+	if (ret != 0) {
+		pr_err("Failed to set SSC 0 for audio: %d\n", ret);
+		return ret;
+	}
+
+	cdu_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!cdu_snd_device) {
+		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
+		ret = -ENOMEM;
+	}
+
+	platform_set_drvdata(cdu_snd_device, &snd_soc_cdu);
+
+	ret = platform_device_add(cdu_snd_device);
+	if (ret) {
+		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
+		goto err_device_add;
+	}
+
+	return ret;
+
+err_device_add:
+	platform_device_put(cdu_snd_device);
+err:
+	return ret;
+}
+
+static void __exit cdu_exit(void)
+{
+	platform_device_unregister(cdu_snd_device);
+	cdu_snd_device = NULL;
+}
+
+module_init(cdu_init);
+module_exit(cdu_exit);
+
+/* Module information */
+MODULE_AUTHOR("Jiri Prchal <jiri.prchal@aksignal.cz>");
+MODULE_DESCRIPTION("ALSA SoC CDU_AIC3X");
+MODULE_LICENSE("GPL");

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
  2011-03-24 10:43   ` [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X Prchal Jiří
@ 2011-03-24 20:07       ` Ryan Mallon
  0 siblings, 0 replies; 31+ messages in thread
From: Ryan Mallon @ 2011-03-24 20:07 UTC (permalink / raw)
  Cc: vbarinov, alsa-devel, alsa-devel, linux-kernel

On 03/24/2011 11:43 PM, Prchal Jiří wrote:
> Hi,
> this patch is for example how to put together AT91SAM9260 and TLV320AIC3106 controlled via SPI.
> It tooks me a lot of time to make it working, so I think it could be helpfull for other people.
> 
> In original source "snd-soc-afeb9260.c" which I use as example is BIG ERROR:
> In function "afeb9260_soc_init" is missing call of "atmel_ssc_set_audio(0);". It cause bug "PROBLEM: Asoc driver in
> 2.6.37.3 for AT91SAM9260 / TLV320AIC3X is broken" which I post some time ago.

Hi Jiri,

This patch is actually doing two things: adding board support for a new
at91sam9260 device and adding the audio glue for the new board. It
should be split into two patches. Quick review below.

~Ryan

> 
> Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
> Kernel version: 2.6.38
> Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
> ---
> 
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c	2011-03-24 09:15:23.852370981 +0100
> @@ -0,0 +1,345 @@
> +/*
> + * linux/arch/arm/mach-at91/board-cdu.c
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2006 Atmel
> + *  Copyright (C) 2011 AKsignal Brno
> + *                     jiri.prchal@aksignal.cz
> + *
> + * 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 <linux/types.h>
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/spi/spi.h>
> +#include <linux/clk.h>
> +#include <linux/spi/mcp23s08.h>
> +#include <linux/dma-mapping.h>
> +
> +#include <mach/hardware.h>
> +#include <asm/setup.h>
> +#include <asm/mach-types.h>
> +#include <asm/irq.h>
> +
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +#include <asm/mach/irq.h>
> +
> +#include <mach/board.h>
> +#include <mach/gpio.h>
> +#include <mach/at91sam9_smc.h>
> +
> +#include "sam9_smc.h"
> +#include "generic.h"
> +
> +static void __init cdu_map_io(void)
> +{
> +	/* Initialize processor: 6 MHz crystal */
> +	at91sam9260_initialize(6000000);
> +
> +	/* DBGU on ttyS0. (Rx & Tx only) */
> +	at91_register_uart(0, 0, 0);
> +
> +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
> +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
> +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
> +			   | ATMEL_UART_RI);
> +
> +	/* USART1 on ttyS2. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
> +
> +	/* USART2 on ttyS3. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
> +
> +	/* USART3 on ttyS4. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
> +
> +	/* USART4 on ttyS5. (Tx) */
> +	/* EBUS - transmit audio, no rx */
> +	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
> +
> +	/* set serial console to ttyS0 (ie, DBGU) */
> +	at91_set_serial_console(0);
> +}
> +
> +static void __init cdu_init_irq(void)
> +{
> +	at91sam9260_init_interrupts(NULL);
> +}
> +
> +/*
> + * USB Host port
> + */
> +static struct at91_usbh_data __initdata cdu_usbh_data = {
> +	.ports		= 2,
> +};
> +
> +/*
> + * USB Device port
> + */
> +static struct at91_udc_data __initdata cdu_udc_data = {
> +	.vbus_pin	= AT91_PIN_PC15,
> +	.pullup_pin	= 0,		/* pull-up driven by UDC */
> +};
> +
> +/*
> + * SPI devices.
> + */
> +#define MCP23S08_GPIO_BASE	128
> +
> +static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
> +	.chip[0].is_present	= true,
> +	.chip[0].pullups	= 0,
> +	.base			= MCP23S08_GPIO_BASE,
> +};
> +
> +static struct spi_board_info cdu_spi_devices[] = {
> +	{ /* ADC LTC2488 */
> +		.modalias	= "spidev",
> +		.chip_select	= 0,
> +		.max_speed_hz	= 1 * 1000 * 1000,
> +		.bus_num	= 1,
> +	},
> +	{ /* GPIO expander MCP23S08 */
> +		.modalias	= "mcp23s08",
> +		.chip_select	= 1,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.platform_data	= &mcp23s08_gpio_info,
> +		.mode		= SPI_MODE_3,
> +	},
> +	{ /* non volatile memory (F-RAM) FM25VN10 */
> +		.modalias	= "spidev",
> +		.chip_select	= 2,
> +		.max_speed_hz	= 1 * 1000 * 1000,
> +		.bus_num	= 1,
> +	},
> +	{ /* audiocodec TLV320AIC3106 */
> +		.modalias	= "tlv320aic3x-codec",
> +		.chip_select	= 3,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.mode		= SPI_MODE_1,
> +	},
> +};
> +
> +/*
> + * MACB Ethernet device
> + */
> +static struct at91_eth_data __initdata cdu_macb_data = {
> +	.phy_irq_pin	= 0, //nc,

Don't use // comments. This line can just be deleted since it default to
zero.

> +	.is_rmii	= 1,
> +};
> +
> +/*
> + * NAND flash
> + */
> +static struct mtd_partition __initdata cdu_nand_partition[] = {
> +	{
> +		.name   = "bootstrap",
> +		.offset = 0,
> +	  .size   = 0x40000,

Tabbing is messed here.

> +	},
> +	{
> +		.name   = "uboot",
> +		.offset = 0x40000,

You can use MTDPART_OFS_NXTBLK for the offset to align this partition
immediately after the previous one.

> +		.size   = (0xc0000 - 0x40000),

What's with the odd sizes? You should use the sizes from asm/sizes.h.

> +	},
> +	{
> +		.name   = "ubootenv",
> +		.offset = 0xc0000,
> +		.size   = (0x100000 - 0xc0000),
> +	},
> +	{
> +		.name   = "kernel",
> +		.offset = 0x100000,
> +		.size   = (0x400000 - 0x100000),
> +	},
> +	{
> +		.name   = "rootfs",
> +		.offset = 0x400000,
> +		.size   = (0x8000000 - 0x400000),
> +	},
> +};
> +
> +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
> +{
> +	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
> +	return cdu_nand_partition;
> +}
> +
> +static struct atmel_nand_data __initdata cdu_nand_data = {
> +	.ale		= 21,
> +	.cle		= 22,
> +//	.det_pin	= ... not connected

Delete this line.

> +	.rdy_pin	= AT91_PIN_PC13,
> +	.enable_pin	= AT91_PIN_PC14,
> +	.partition_info	= nand_partitions,
> +	.bus_width_16	= 0,
> +};
> +
> +static struct sam9_smc_config __initdata cdu_nand_smc_config = {
> +	.ncs_read_setup		= 0,
> +	.nrd_setup		= 1,
> +	.ncs_write_setup	= 0,
> +	.nwe_setup		= 1,
> +
> +	.ncs_read_pulse		= 3,
> +	.nrd_pulse		= 3,
> +	.ncs_write_pulse	= 3,
> +	.nwe_pulse		= 3,
> +
> +	.read_cycle		= 5,
> +	.write_cycle		= 5,
> +
> +	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
> +	.tdf_cycles		= 2,
> +};
> +
> +static void __init cdu_add_device_nand(void)
> +{
> +	/* setup bus-width (8 or 16) */
> +	if (cdu_nand_data.bus_width_16)
> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_16;
> +	else
> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;

bus_width_16 is explicitly set to zero above, so this logic should not
be needed.

> +	/* configure chip-select 3 (NAND) */
> +	sam9_smc_configure(3, &cdu_nand_smc_config);
> +
> +	at91_add_device_nand(&cdu_nand_data);
> +}
> +
> +/*
> +* MCI (SD/MMC)
> +*/
> +static struct at91_mmc_data __initdata ek_mmc_data = {
> +  .slot_b		= 0,
> +  .wire4		= 1,
> +  //	.det_pin	= ... not connected
> +  //	.wp_pin		= ... not connected
> +  //	.vcc_pin	= ... not connected

Delete these lines.

> +};
> +
> +/*
> + * LEDs
> + */
> +static struct gpio_led cdu_leds[] = {
> +	{
> +		.name			= "red",
> +		.gpio			= AT91_PIN_PC10,
> +		.default_trigger	= "timer",
> +	},
> +	{
> +		.name			= "green",
> +		.gpio			= AT91_PIN_PA5,
> +		.default_trigger	= "heartbeat",
> +	},
> +	{
> +		.name			= "yellow",
> +		.gpio			= AT91_PIN_PB20,
> +		.active_low		= 1,
> +		.default_trigger	= "mmc0",
> +	},
> +	{
> +		.name			= "blue",
> +		.gpio			= AT91_PIN_PB21,
> +		.active_low		= 1,
> +		.default_trigger	= "nand-disk",
> +	},
> +};
> +
> +/*
> + * GPIOs
> + */
> +static struct gpio gpios[] = {
> +	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
> +	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
> +	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
> +	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
> +	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
> +	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
> +
> +	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
> +	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
> +	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
> +	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
> +	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
> +	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
> +
> +	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
> +	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
> +	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
> +	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
> +	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
> +	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
> +
> +	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
> +	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
> +	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
> +	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
> +	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
> +	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
> +	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
> +};
> +
> +static void __init cdu_add_gpio (void)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE (gpios); i++) {
> +		gpio_request_one (gpios[i].gpio, gpios[i].flags, gpios[i].label);
> +	}

Nitpick, don't need braces on the for loop here. Also, remove the spaces
between cdu_add_gpiop, ARRAY_SIZE, and gpio_request_one and their
opening parenthesis.

> +}
> +
> +/*
> + * init
> + */
> +static void __init cdu_board_init(void)
> +{
> +	/* Serial */
> +	at91_add_device_serial();
> +	/* USB Host */
> +	at91_add_device_usbh(&cdu_usbh_data);
> +	/* USB Device */
> +	at91_add_device_udc(&cdu_udc_data);
> +	/* SPI */
> +	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
> +	/* NAND */
> +	cdu_add_device_nand();
> +	/* Ethernet */
> +	at91_add_device_eth(&cdu_macb_data);
> +	/* MMC */
> +	at91_add_device_mmc(0, &ek_mmc_data);
> +	/* SSC */
> +	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
> +	/* LEDs */
> +	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
> +	// GPIO
> +	cdu_add_gpio ();

I might be a bit alone on this, but I find this cut and paste comment
style for the at91 device initialisation awful. The function names are
very self explanatory and the comments only serve to make the init code
more difficult to read. Also, remove the // comment.

> +}
> +
> +MACHINE_START(AT91SAM9260EK, "CDU")
> +	/* Maintainer: Atmel */

Nice of you to assign maintainership of your board to Atmel :-). You
should possibly add a MAINTAINERS entry for this board.

> +	.boot_params	= AT91_SDRAM_BASE + 0x100,
> +	.timer		= &at91sam926x_timer,
> +	.map_io		= cdu_map_io,
> +	.init_irq	= cdu_init_irq,
> +	.init_machine	= cdu_board_init,
> +MACHINE_END
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
> @@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
>  	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
>  	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
> 
> +config MACH_CDU
> +	bool "CDU AKsignal board"
> +	help
> +	  Select this if you are using AKsignal CDU board
> +	  <http://www.aksignal.cz>
> +
>  config MACH_CAM60
>  	bool "KwikByte KB9260 (CAM60) board"
>  	help
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
> @@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92
> 
>  # AT91SAM9260 board-specific support
>  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
> +obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
>  obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
>  obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
>  obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o

The first patch, adding just the support for the cdu board should end here.

> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Kconfig
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig
> --- linux-2.6.38-vanilla/sound/soc/atmel/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig	2011-03-22 09:46:46.751566158 +0100
> @@ -50,3 +50,11 @@ config SND_AT91_SOC_AFEB9260
>  	select SND_SOC_TLV320AIC23
>  	help
>  	  Say Y here to support sound on AFEB9260 board.
> +
> +config SND_AT91_SOC_CDU
> +	tristate "SoC Audio support for CDU board"
> +	depends on ARCH_AT91 && MACH_CDU && SND_ATMEL_SOC
> +	select SND_ATMEL_SOC_SSC
> +	select SND_SOC_TLV320AIC3X
> +	help
> +	  Say Y here to support sound on CDU board.
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Makefile
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile
> --- linux-2.6.38-vanilla/sound/soc/atmel/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile	2011-03-16 09:26:17.000000000 +0100
> @@ -14,3 +14,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o
>  obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
>  obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
>  obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
> +obj-$(CONFIG_SND_AT91_SOC_CDU) += snd-soc-cdu.o
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c
> --- linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c	2011-03-24 09:27:55.404367652 +0100
> @@ -0,0 +1,264 @@
> +/*
> + * snd-soc-cdu  --  SoC audio for AT91SAM9260-based
> + * 			AKsignal CDU board.
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2008 Atmel
> + *  Copyright (C) 2011 AK signal Brno
> + *
> + * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
> + *          Jiri Prchal <jiri.prchal@aksignal.cz>
> + *
> + * Based on ati_b1_wm8731.c by:
> + * Frank Mandarino <fmandarino@endrelia.com>
> + * Copyright 2006 Endrelia Technologies Inc.
> + * Based on corgi.c by:
> + * Copyright 2005 Wolfson Microelectronics PLC.
> + * Copyright 2005 Openedhand Ltd.
> + *
> + * 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 <linux/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/kernel.h>
> +#include <linux/clk.h>
> +#include <linux/timer.h>
> +#include <linux/interrupt.h>
> +#include <linux/platform_device.h>
> +#include <linux/i2c.h>
> +
> +#include <linux/atmel-ssc.h>
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
> +
> +#include <asm/mach-types.h>
> +#include <mach/hardware.h>
> +#include <mach/gpio.h>

Note sure you need all of these includes. linux/interrupt.h,
linux/moduleparam.h, linux/timer.h and mach/gpio.h at least appear to be
uneccessary.

> +
> +#include "../codecs/tlv320aic3x.h"
> +#include "atmel-pcm.h"
> +#include "atmel_ssc_dai.h"
> +
> +struct {
> +	unsigned int channels;
> +	snd_pcm_format_t format;
> +	unsigned int rate;
> +	unsigned int codecclk;
> +	unsigned int cmrdiv;
> +	unsigned int period;
> +} cdu_audio[] = {
> +	/* 16 bit stereo modes */
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 8000, 2096000, 25, 130,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 16000, 2496000, 21, 77,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 32000, 2496000, 21, 38,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 48000, 2016000, 26, 20,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 96000, 4032000, 13, 20,},
> +
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 11025, 2381400, 22, 107,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 22050, 2381400, 22, 53,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 44100, 2381400, 22, 26,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 88200, 4762800, 11, 26,},
> +
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 11520, 2626560, 20, 113,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 23040, 2626560, 20, 56,},

Can these be calculated rather than using a table? The first two values
probably don't need to be in the table since they are always the same.

> +
> +};
> +
> +static int cdu_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
> +	int ret;
> +	int i, found = 0;
> +	snd_pcm_format_t format = params_format(params);
> +	unsigned int rate = params_rate(params);
> +	unsigned int channels = params_channels(params);
> +
> +	/* set codec DAI configuration */
> +	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);

Long lines should be broken to fit inside 80 characters.

> +	if (ret < 0)
> +		return ret;
> +
> +	/* set cpu DAI configuration */
> +	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* find the correct audio parameters */
> +	for (i = 0; i < ARRAY_SIZE(cdu_audio); i++) {
> +		if (rate == cdu_audio[i].rate &&
> +		    format == cdu_audio[i].format &&
> +		    channels == cdu_audio[i].channels) {
> +			found = 1;
> +			break;
> +		}
> +	}
> +	if (!found)
> +		return -EINVAL;

Should maybe do this before doing the dai_set_fmt's since we only
support some modes. Also:

	/* Only support 2 channel S16_LE */
	if (channels != 2 || format != SNDRV_PCM_FORMAT_S16_LE)
		return -EINVAL;

	/* Check rate support */
	for (i = 0; i < ARRAY_SIZE(cdc_audio); i++)
		if (rate == cdc_audio[i].rate) {
			found = 1;
			break;
		}
	if (!found)
		return -EINVAL;

> +
> +	/* Set the codec system clock for DAC and ADC */
> +	ret = snd_soc_dai_set_sysclk(codec_dai, CLKIN_BCLK, cdu_audio[i].codecclk, SND_SOC_CLOCK_IN);
> +	if (ret < 0) {
> +		printk(KERN_ERR "can't set codec system clock\n");

You should, I think, be able to do:

	struct device *dev = rtd->card->dev;

	dev_err(dev, "can't set codec system clock\n");

Same goes for other printks.

> +		return ret;
> +	}
> +
> +	/* Set the cpu clock dividers to BCLK */
> +	ret = snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_CMR_DIV, cdu_audio[i].cmrdiv);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_TCMR_PERIOD, cdu_audio[i].period);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_RCMR_PERIOD, cdu_audio[i].period);
> +	if (ret < 0) {
> +		printk(KERN_ERR "can't set cpu system clock\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static struct snd_soc_ops cdu_ops = {
> +	.hw_params = cdu_hw_params,
> +};
> +
> +static const struct snd_soc_dapm_widget cdu_dapm_widgets[] = {
> +	SND_SOC_DAPM_HP("Headphone Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line Out", NULL),
> +	SND_SOC_DAPM_MIC("Mic Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line In", NULL),
> +};
> +
> +static const struct snd_soc_dapm_route intercon[] = {
> +	/* Headphone connected to HPLOUT, HPROUT */
> +	{"Headphone Jack", NULL, "HPLOUT"},
> +	{"Headphone Jack", NULL, "HPROUT"},
> +
> +	/* Line Out connected to LLOUT, RLOUT */
> +	{"Line Out", NULL, "LLOUT"},
> +	{"Line Out", NULL, "RLOUT"},
> +
> +	/* Mic connected to (MIC3L | MIC3R) */
> +	{"MIC3L", NULL, "Mic Bias 2V"},
> +	{"MIC3R", NULL, "Mic Bias 2V"},
> +	{"Mic Bias 2V", NULL, "Mic Jack"},
> +
> +	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
> +	{"LINE1L", NULL, "Line In"},
> +	{"LINE2L", NULL, "Line In"},
> +	{"LINE1R", NULL, "Line In"},
> +	{"LINE2R", NULL, "Line In"},
> +};
> +
> +/*
> + * Logic for a aic3x as connected on a cdu board.
> + */
> +static int cdu_aic3x_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	struct snd_soc_codec *codec = rtd->codec;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dapm_context *dapm = &codec->dapm;
> +	int ret;
> +
> +	printk(KERN_DEBUG "cdu_aic3x: cdu_aic3x_init called\n");

Is this line really needed?

> +
> +	/* Add specific widgets */
> +	snd_soc_dapm_new_controls(dapm, cdu_dapm_widgets,
> +				  ARRAY_SIZE(cdu_dapm_widgets));
> +	/* Set up specific audio path interconnects */
> +	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
> +
> +	/* always connected */
> +	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
> +	snd_soc_dapm_enable_pin(dapm, "Line Out");
> +	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
> +	snd_soc_dapm_enable_pin(dapm, "Line In");
> +
> +	snd_soc_dapm_sync(dapm);

IIRC, you no longer need to explicitly call snd_soc_dapm_enable_pin and
snd_soc_dapm_sync. Somebody else can probably shed more light on this.

> +
> +	return 0;
> +}
> +
> +static struct snd_soc_dai_link cdu_dai = {
> +	.name		= "TLV320AIC3106",
> +	.stream_name	= "PCM",
> +	.cpu_dai_name	= "atmel-ssc-dai.0",
> +	.codec_dai_name	= "tlv320aic3x-hifi",
> +	.init = cdu_aic3x_init,

Tab-delimiting got messed here.

> +	.platform_name	= "atmel-pcm-audio",
> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
> +	.codec_name	= "tlv320aic3x-codec.0-001b",
> +#endif
> +#if defined(CONFIG_SPI_MASTER)
> +	.codec_name	= "spi1.3",
> +#endif

If both CONFIG_I2C and CONFIG_SPI_MASTER are set then you will have a
broken build. Which one does the CDU board use?

> +	.ops		= &cdu_ops,
> +};
> +
> +static struct snd_soc_card snd_soc_cdu = {
> +	.name		= "TLV320AIC3106",
> +	.dai_link	= &cdu_dai,
> +	.num_links	= 1,
> +};
> +
> +static struct platform_device *cdu_snd_device;
> +
> +static int __init cdu_init(void)
> +{
> +	struct clk *pllb;

Remove this line, pllb is never used in this function.

> +	int ret;
> +
> +	ret = atmel_ssc_set_audio(0);
> +	if (ret != 0) {

Nitpick. Just if (ret) is fine.

> +		pr_err("Failed to set SSC 0 for audio: %d\n", ret);
> +		return ret;
> +	}
> +
> +	cdu_snd_device = platform_device_alloc("soc-audio", -1);
> +	if (!cdu_snd_device) {
> +		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
> +		ret = -ENOMEM;
> +	}
> +
> +	platform_set_drvdata(cdu_snd_device, &snd_soc_cdu);
> +
> +	ret = platform_device_add(cdu_snd_device);
> +	if (ret) {
> +		printk(KERN_ERR "ASoC: Platform device allocation failed\n");

Use pr_err to be consistent.

> +		goto err_device_add;
> +	}
> +
> +	return ret;
> +
> +err_device_add:
> +	platform_device_put(cdu_snd_device);
> +err:
> +	return ret;
> +}
> +
> +static void __exit cdu_exit(void)
> +{
> +	platform_device_unregister(cdu_snd_device);
> +	cdu_snd_device = NULL;

I don't think you need to set cdu_snd_device to NULL here.

> +}
> +
> +module_init(cdu_init);
> +module_exit(cdu_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Jiri Prchal <jiri.prchal@aksignal.cz>");
> +MODULE_DESCRIPTION("ALSA SoC CDU_AIC3X");
> +MODULE_LICENSE("GPL");
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
@ 2011-03-24 20:07       ` Ryan Mallon
  0 siblings, 0 replies; 31+ messages in thread
From: Ryan Mallon @ 2011-03-24 20:07 UTC (permalink / raw)
  To: Prchal Jiří; +Cc: alsa-devel, alsa-devel, vbarinov, linux-kernel

On 03/24/2011 11:43 PM, Prchal Jiří wrote:
> Hi,
> this patch is for example how to put together AT91SAM9260 and TLV320AIC3106 controlled via SPI.
> It tooks me a lot of time to make it working, so I think it could be helpfull for other people.
> 
> In original source "snd-soc-afeb9260.c" which I use as example is BIG ERROR:
> In function "afeb9260_soc_init" is missing call of "atmel_ssc_set_audio(0);". It cause bug "PROBLEM: Asoc driver in
> 2.6.37.3 for AT91SAM9260 / TLV320AIC3X is broken" which I post some time ago.

Hi Jiri,

This patch is actually doing two things: adding board support for a new
at91sam9260 device and adding the audio glue for the new board. It
should be split into two patches. Quick review below.

~Ryan

> 
> Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
> Kernel version: 2.6.38
> Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
> ---
> 
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c	2011-03-24 09:15:23.852370981 +0100
> @@ -0,0 +1,345 @@
> +/*
> + * linux/arch/arm/mach-at91/board-cdu.c
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2006 Atmel
> + *  Copyright (C) 2011 AKsignal Brno
> + *                     jiri.prchal@aksignal.cz
> + *
> + * 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 <linux/types.h>
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/spi/spi.h>
> +#include <linux/clk.h>
> +#include <linux/spi/mcp23s08.h>
> +#include <linux/dma-mapping.h>
> +
> +#include <mach/hardware.h>
> +#include <asm/setup.h>
> +#include <asm/mach-types.h>
> +#include <asm/irq.h>
> +
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +#include <asm/mach/irq.h>
> +
> +#include <mach/board.h>
> +#include <mach/gpio.h>
> +#include <mach/at91sam9_smc.h>
> +
> +#include "sam9_smc.h"
> +#include "generic.h"
> +
> +static void __init cdu_map_io(void)
> +{
> +	/* Initialize processor: 6 MHz crystal */
> +	at91sam9260_initialize(6000000);
> +
> +	/* DBGU on ttyS0. (Rx & Tx only) */
> +	at91_register_uart(0, 0, 0);
> +
> +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
> +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
> +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
> +			   | ATMEL_UART_RI);
> +
> +	/* USART1 on ttyS2. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
> +
> +	/* USART2 on ttyS3. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
> +
> +	/* USART3 on ttyS4. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
> +
> +	/* USART4 on ttyS5. (Tx) */
> +	/* EBUS - transmit audio, no rx */
> +	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
> +
> +	/* set serial console to ttyS0 (ie, DBGU) */
> +	at91_set_serial_console(0);
> +}
> +
> +static void __init cdu_init_irq(void)
> +{
> +	at91sam9260_init_interrupts(NULL);
> +}
> +
> +/*
> + * USB Host port
> + */
> +static struct at91_usbh_data __initdata cdu_usbh_data = {
> +	.ports		= 2,
> +};
> +
> +/*
> + * USB Device port
> + */
> +static struct at91_udc_data __initdata cdu_udc_data = {
> +	.vbus_pin	= AT91_PIN_PC15,
> +	.pullup_pin	= 0,		/* pull-up driven by UDC */
> +};
> +
> +/*
> + * SPI devices.
> + */
> +#define MCP23S08_GPIO_BASE	128
> +
> +static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
> +	.chip[0].is_present	= true,
> +	.chip[0].pullups	= 0,
> +	.base			= MCP23S08_GPIO_BASE,
> +};
> +
> +static struct spi_board_info cdu_spi_devices[] = {
> +	{ /* ADC LTC2488 */
> +		.modalias	= "spidev",
> +		.chip_select	= 0,
> +		.max_speed_hz	= 1 * 1000 * 1000,
> +		.bus_num	= 1,
> +	},
> +	{ /* GPIO expander MCP23S08 */
> +		.modalias	= "mcp23s08",
> +		.chip_select	= 1,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.platform_data	= &mcp23s08_gpio_info,
> +		.mode		= SPI_MODE_3,
> +	},
> +	{ /* non volatile memory (F-RAM) FM25VN10 */
> +		.modalias	= "spidev",
> +		.chip_select	= 2,
> +		.max_speed_hz	= 1 * 1000 * 1000,
> +		.bus_num	= 1,
> +	},
> +	{ /* audiocodec TLV320AIC3106 */
> +		.modalias	= "tlv320aic3x-codec",
> +		.chip_select	= 3,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.mode		= SPI_MODE_1,
> +	},
> +};
> +
> +/*
> + * MACB Ethernet device
> + */
> +static struct at91_eth_data __initdata cdu_macb_data = {
> +	.phy_irq_pin	= 0, //nc,

Don't use // comments. This line can just be deleted since it default to
zero.

> +	.is_rmii	= 1,
> +};
> +
> +/*
> + * NAND flash
> + */
> +static struct mtd_partition __initdata cdu_nand_partition[] = {
> +	{
> +		.name   = "bootstrap",
> +		.offset = 0,
> +	  .size   = 0x40000,

Tabbing is messed here.

> +	},
> +	{
> +		.name   = "uboot",
> +		.offset = 0x40000,

You can use MTDPART_OFS_NXTBLK for the offset to align this partition
immediately after the previous one.

> +		.size   = (0xc0000 - 0x40000),

What's with the odd sizes? You should use the sizes from asm/sizes.h.

> +	},
> +	{
> +		.name   = "ubootenv",
> +		.offset = 0xc0000,
> +		.size   = (0x100000 - 0xc0000),
> +	},
> +	{
> +		.name   = "kernel",
> +		.offset = 0x100000,
> +		.size   = (0x400000 - 0x100000),
> +	},
> +	{
> +		.name   = "rootfs",
> +		.offset = 0x400000,
> +		.size   = (0x8000000 - 0x400000),
> +	},
> +};
> +
> +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
> +{
> +	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
> +	return cdu_nand_partition;
> +}
> +
> +static struct atmel_nand_data __initdata cdu_nand_data = {
> +	.ale		= 21,
> +	.cle		= 22,
> +//	.det_pin	= ... not connected

Delete this line.

> +	.rdy_pin	= AT91_PIN_PC13,
> +	.enable_pin	= AT91_PIN_PC14,
> +	.partition_info	= nand_partitions,
> +	.bus_width_16	= 0,
> +};
> +
> +static struct sam9_smc_config __initdata cdu_nand_smc_config = {
> +	.ncs_read_setup		= 0,
> +	.nrd_setup		= 1,
> +	.ncs_write_setup	= 0,
> +	.nwe_setup		= 1,
> +
> +	.ncs_read_pulse		= 3,
> +	.nrd_pulse		= 3,
> +	.ncs_write_pulse	= 3,
> +	.nwe_pulse		= 3,
> +
> +	.read_cycle		= 5,
> +	.write_cycle		= 5,
> +
> +	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
> +	.tdf_cycles		= 2,
> +};
> +
> +static void __init cdu_add_device_nand(void)
> +{
> +	/* setup bus-width (8 or 16) */
> +	if (cdu_nand_data.bus_width_16)
> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_16;
> +	else
> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;

bus_width_16 is explicitly set to zero above, so this logic should not
be needed.

> +	/* configure chip-select 3 (NAND) */
> +	sam9_smc_configure(3, &cdu_nand_smc_config);
> +
> +	at91_add_device_nand(&cdu_nand_data);
> +}
> +
> +/*
> +* MCI (SD/MMC)
> +*/
> +static struct at91_mmc_data __initdata ek_mmc_data = {
> +  .slot_b		= 0,
> +  .wire4		= 1,
> +  //	.det_pin	= ... not connected
> +  //	.wp_pin		= ... not connected
> +  //	.vcc_pin	= ... not connected

Delete these lines.

> +};
> +
> +/*
> + * LEDs
> + */
> +static struct gpio_led cdu_leds[] = {
> +	{
> +		.name			= "red",
> +		.gpio			= AT91_PIN_PC10,
> +		.default_trigger	= "timer",
> +	},
> +	{
> +		.name			= "green",
> +		.gpio			= AT91_PIN_PA5,
> +		.default_trigger	= "heartbeat",
> +	},
> +	{
> +		.name			= "yellow",
> +		.gpio			= AT91_PIN_PB20,
> +		.active_low		= 1,
> +		.default_trigger	= "mmc0",
> +	},
> +	{
> +		.name			= "blue",
> +		.gpio			= AT91_PIN_PB21,
> +		.active_low		= 1,
> +		.default_trigger	= "nand-disk",
> +	},
> +};
> +
> +/*
> + * GPIOs
> + */
> +static struct gpio gpios[] = {
> +	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
> +	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
> +	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
> +	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
> +	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
> +	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
> +
> +	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
> +	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
> +	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
> +	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
> +	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
> +	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
> +
> +	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
> +	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
> +	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
> +	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
> +	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
> +	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
> +
> +	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
> +	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
> +	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
> +	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
> +	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
> +	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
> +	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
> +};
> +
> +static void __init cdu_add_gpio (void)
> +{
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE (gpios); i++) {
> +		gpio_request_one (gpios[i].gpio, gpios[i].flags, gpios[i].label);
> +	}

Nitpick, don't need braces on the for loop here. Also, remove the spaces
between cdu_add_gpiop, ARRAY_SIZE, and gpio_request_one and their
opening parenthesis.

> +}
> +
> +/*
> + * init
> + */
> +static void __init cdu_board_init(void)
> +{
> +	/* Serial */
> +	at91_add_device_serial();
> +	/* USB Host */
> +	at91_add_device_usbh(&cdu_usbh_data);
> +	/* USB Device */
> +	at91_add_device_udc(&cdu_udc_data);
> +	/* SPI */
> +	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
> +	/* NAND */
> +	cdu_add_device_nand();
> +	/* Ethernet */
> +	at91_add_device_eth(&cdu_macb_data);
> +	/* MMC */
> +	at91_add_device_mmc(0, &ek_mmc_data);
> +	/* SSC */
> +	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
> +	/* LEDs */
> +	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
> +	// GPIO
> +	cdu_add_gpio ();

I might be a bit alone on this, but I find this cut and paste comment
style for the at91 device initialisation awful. The function names are
very self explanatory and the comments only serve to make the init code
more difficult to read. Also, remove the // comment.

> +}
> +
> +MACHINE_START(AT91SAM9260EK, "CDU")
> +	/* Maintainer: Atmel */

Nice of you to assign maintainership of your board to Atmel :-). You
should possibly add a MAINTAINERS entry for this board.

> +	.boot_params	= AT91_SDRAM_BASE + 0x100,
> +	.timer		= &at91sam926x_timer,
> +	.map_io		= cdu_map_io,
> +	.init_irq	= cdu_init_irq,
> +	.init_machine	= cdu_board_init,
> +MACHINE_END
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
> @@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
>  	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
>  	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
> 
> +config MACH_CDU
> +	bool "CDU AKsignal board"
> +	help
> +	  Select this if you are using AKsignal CDU board
> +	  <http://www.aksignal.cz>
> +
>  config MACH_CAM60
>  	bool "KwikByte KB9260 (CAM60) board"
>  	help
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
> @@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92
> 
>  # AT91SAM9260 board-specific support
>  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
> +obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
>  obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
>  obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
>  obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o

The first patch, adding just the support for the cdu board should end here.

> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Kconfig
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig
> --- linux-2.6.38-vanilla/sound/soc/atmel/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig	2011-03-22 09:46:46.751566158 +0100
> @@ -50,3 +50,11 @@ config SND_AT91_SOC_AFEB9260
>  	select SND_SOC_TLV320AIC23
>  	help
>  	  Say Y here to support sound on AFEB9260 board.
> +
> +config SND_AT91_SOC_CDU
> +	tristate "SoC Audio support for CDU board"
> +	depends on ARCH_AT91 && MACH_CDU && SND_ATMEL_SOC
> +	select SND_ATMEL_SOC_SSC
> +	select SND_SOC_TLV320AIC3X
> +	help
> +	  Say Y here to support sound on CDU board.
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Makefile
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile
> --- linux-2.6.38-vanilla/sound/soc/atmel/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile	2011-03-16 09:26:17.000000000 +0100
> @@ -14,3 +14,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o
>  obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
>  obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
>  obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
> +obj-$(CONFIG_SND_AT91_SOC_CDU) += snd-soc-cdu.o
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c
> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c
> --- linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c	2011-03-24 09:27:55.404367652 +0100
> @@ -0,0 +1,264 @@
> +/*
> + * snd-soc-cdu  --  SoC audio for AT91SAM9260-based
> + * 			AKsignal CDU board.
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2008 Atmel
> + *  Copyright (C) 2011 AK signal Brno
> + *
> + * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
> + *          Jiri Prchal <jiri.prchal@aksignal.cz>
> + *
> + * Based on ati_b1_wm8731.c by:
> + * Frank Mandarino <fmandarino@endrelia.com>
> + * Copyright 2006 Endrelia Technologies Inc.
> + * Based on corgi.c by:
> + * Copyright 2005 Wolfson Microelectronics PLC.
> + * Copyright 2005 Openedhand Ltd.
> + *
> + * 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 <linux/module.h>
> +#include <linux/moduleparam.h>
> +#include <linux/kernel.h>
> +#include <linux/clk.h>
> +#include <linux/timer.h>
> +#include <linux/interrupt.h>
> +#include <linux/platform_device.h>
> +#include <linux/i2c.h>
> +
> +#include <linux/atmel-ssc.h>
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
> +
> +#include <asm/mach-types.h>
> +#include <mach/hardware.h>
> +#include <mach/gpio.h>

Note sure you need all of these includes. linux/interrupt.h,
linux/moduleparam.h, linux/timer.h and mach/gpio.h at least appear to be
uneccessary.

> +
> +#include "../codecs/tlv320aic3x.h"
> +#include "atmel-pcm.h"
> +#include "atmel_ssc_dai.h"
> +
> +struct {
> +	unsigned int channels;
> +	snd_pcm_format_t format;
> +	unsigned int rate;
> +	unsigned int codecclk;
> +	unsigned int cmrdiv;
> +	unsigned int period;
> +} cdu_audio[] = {
> +	/* 16 bit stereo modes */
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 8000, 2096000, 25, 130,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 16000, 2496000, 21, 77,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 32000, 2496000, 21, 38,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 48000, 2016000, 26, 20,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 96000, 4032000, 13, 20,},
> +
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 11025, 2381400, 22, 107,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 22050, 2381400, 22, 53,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 44100, 2381400, 22, 26,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 88200, 4762800, 11, 26,},
> +
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 11520, 2626560, 20, 113,},
> +	{2, SNDRV_PCM_FORMAT_S16_LE, 23040, 2626560, 20, 56,},

Can these be calculated rather than using a table? The first two values
probably don't need to be in the table since they are always the same.

> +
> +};
> +
> +static int cdu_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
> +	int ret;
> +	int i, found = 0;
> +	snd_pcm_format_t format = params_format(params);
> +	unsigned int rate = params_rate(params);
> +	unsigned int channels = params_channels(params);
> +
> +	/* set codec DAI configuration */
> +	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);

Long lines should be broken to fit inside 80 characters.

> +	if (ret < 0)
> +		return ret;
> +
> +	/* set cpu DAI configuration */
> +	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* find the correct audio parameters */
> +	for (i = 0; i < ARRAY_SIZE(cdu_audio); i++) {
> +		if (rate == cdu_audio[i].rate &&
> +		    format == cdu_audio[i].format &&
> +		    channels == cdu_audio[i].channels) {
> +			found = 1;
> +			break;
> +		}
> +	}
> +	if (!found)
> +		return -EINVAL;

Should maybe do this before doing the dai_set_fmt's since we only
support some modes. Also:

	/* Only support 2 channel S16_LE */
	if (channels != 2 || format != SNDRV_PCM_FORMAT_S16_LE)
		return -EINVAL;

	/* Check rate support */
	for (i = 0; i < ARRAY_SIZE(cdc_audio); i++)
		if (rate == cdc_audio[i].rate) {
			found = 1;
			break;
		}
	if (!found)
		return -EINVAL;

> +
> +	/* Set the codec system clock for DAC and ADC */
> +	ret = snd_soc_dai_set_sysclk(codec_dai, CLKIN_BCLK, cdu_audio[i].codecclk, SND_SOC_CLOCK_IN);
> +	if (ret < 0) {
> +		printk(KERN_ERR "can't set codec system clock\n");

You should, I think, be able to do:

	struct device *dev = rtd->card->dev;

	dev_err(dev, "can't set codec system clock\n");

Same goes for other printks.

> +		return ret;
> +	}
> +
> +	/* Set the cpu clock dividers to BCLK */
> +	ret = snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_CMR_DIV, cdu_audio[i].cmrdiv);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_TCMR_PERIOD, cdu_audio[i].period);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_RCMR_PERIOD, cdu_audio[i].period);
> +	if (ret < 0) {
> +		printk(KERN_ERR "can't set cpu system clock\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static struct snd_soc_ops cdu_ops = {
> +	.hw_params = cdu_hw_params,
> +};
> +
> +static const struct snd_soc_dapm_widget cdu_dapm_widgets[] = {
> +	SND_SOC_DAPM_HP("Headphone Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line Out", NULL),
> +	SND_SOC_DAPM_MIC("Mic Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line In", NULL),
> +};
> +
> +static const struct snd_soc_dapm_route intercon[] = {
> +	/* Headphone connected to HPLOUT, HPROUT */
> +	{"Headphone Jack", NULL, "HPLOUT"},
> +	{"Headphone Jack", NULL, "HPROUT"},
> +
> +	/* Line Out connected to LLOUT, RLOUT */
> +	{"Line Out", NULL, "LLOUT"},
> +	{"Line Out", NULL, "RLOUT"},
> +
> +	/* Mic connected to (MIC3L | MIC3R) */
> +	{"MIC3L", NULL, "Mic Bias 2V"},
> +	{"MIC3R", NULL, "Mic Bias 2V"},
> +	{"Mic Bias 2V", NULL, "Mic Jack"},
> +
> +	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
> +	{"LINE1L", NULL, "Line In"},
> +	{"LINE2L", NULL, "Line In"},
> +	{"LINE1R", NULL, "Line In"},
> +	{"LINE2R", NULL, "Line In"},
> +};
> +
> +/*
> + * Logic for a aic3x as connected on a cdu board.
> + */
> +static int cdu_aic3x_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	struct snd_soc_codec *codec = rtd->codec;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dapm_context *dapm = &codec->dapm;
> +	int ret;
> +
> +	printk(KERN_DEBUG "cdu_aic3x: cdu_aic3x_init called\n");

Is this line really needed?

> +
> +	/* Add specific widgets */
> +	snd_soc_dapm_new_controls(dapm, cdu_dapm_widgets,
> +				  ARRAY_SIZE(cdu_dapm_widgets));
> +	/* Set up specific audio path interconnects */
> +	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
> +
> +	/* always connected */
> +	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
> +	snd_soc_dapm_enable_pin(dapm, "Line Out");
> +	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
> +	snd_soc_dapm_enable_pin(dapm, "Line In");
> +
> +	snd_soc_dapm_sync(dapm);

IIRC, you no longer need to explicitly call snd_soc_dapm_enable_pin and
snd_soc_dapm_sync. Somebody else can probably shed more light on this.

> +
> +	return 0;
> +}
> +
> +static struct snd_soc_dai_link cdu_dai = {
> +	.name		= "TLV320AIC3106",
> +	.stream_name	= "PCM",
> +	.cpu_dai_name	= "atmel-ssc-dai.0",
> +	.codec_dai_name	= "tlv320aic3x-hifi",
> +	.init = cdu_aic3x_init,

Tab-delimiting got messed here.

> +	.platform_name	= "atmel-pcm-audio",
> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
> +	.codec_name	= "tlv320aic3x-codec.0-001b",
> +#endif
> +#if defined(CONFIG_SPI_MASTER)
> +	.codec_name	= "spi1.3",
> +#endif

If both CONFIG_I2C and CONFIG_SPI_MASTER are set then you will have a
broken build. Which one does the CDU board use?

> +	.ops		= &cdu_ops,
> +};
> +
> +static struct snd_soc_card snd_soc_cdu = {
> +	.name		= "TLV320AIC3106",
> +	.dai_link	= &cdu_dai,
> +	.num_links	= 1,
> +};
> +
> +static struct platform_device *cdu_snd_device;
> +
> +static int __init cdu_init(void)
> +{
> +	struct clk *pllb;

Remove this line, pllb is never used in this function.

> +	int ret;
> +
> +	ret = atmel_ssc_set_audio(0);
> +	if (ret != 0) {

Nitpick. Just if (ret) is fine.

> +		pr_err("Failed to set SSC 0 for audio: %d\n", ret);
> +		return ret;
> +	}
> +
> +	cdu_snd_device = platform_device_alloc("soc-audio", -1);
> +	if (!cdu_snd_device) {
> +		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
> +		ret = -ENOMEM;
> +	}
> +
> +	platform_set_drvdata(cdu_snd_device, &snd_soc_cdu);
> +
> +	ret = platform_device_add(cdu_snd_device);
> +	if (ret) {
> +		printk(KERN_ERR "ASoC: Platform device allocation failed\n");

Use pr_err to be consistent.

> +		goto err_device_add;
> +	}
> +
> +	return ret;
> +
> +err_device_add:
> +	platform_device_put(cdu_snd_device);
> +err:
> +	return ret;
> +}
> +
> +static void __exit cdu_exit(void)
> +{
> +	platform_device_unregister(cdu_snd_device);
> +	cdu_snd_device = NULL;

I don't think you need to set cdu_snd_device to NULL here.

> +}
> +
> +module_init(cdu_init);
> +module_exit(cdu_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Jiri Prchal <jiri.prchal@aksignal.cz>");
> +MODULE_DESCRIPTION("ALSA SoC CDU_AIC3X");
> +MODULE_LICENSE("GPL");
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
  2011-03-24 10:20   ` [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK Prchal Jiří
@ 2011-04-02  8:26       ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2011-04-02  8:26 UTC (permalink / raw)
  To: Prchal Ji??; +Cc: vbarinov, alsa-devel, alsa-devel, linux-kernel

On Thu, Mar 24, 2011 at 11:20:45AM +0100, Prchal Ji?? wrote:
> Hi,
> this patch ads SPI communication for codecs TLV320AIC3X and clock input on GPIO2 or BCLK.
> Tested on TLV320AIC3106 and AT91SAM9260.
> TODO: Set the model in SPI probe the right way. I don't know how.

Register two SPI drivers with different names.

> This codec communicates on SPI in 1st byte: 7 MSB is register address, 1 LSB is read/write, 2nd byte data. For this
> reason there is new functions in soc-cache.c snd_soc_7_8_*.

This looks mostly good but there's some cleanups needed, mostly from
extra stuff which snuck in there, and you need to rebase against current
code.

As covered in SubmittingPatches you should always CC maintainers on
patches.

>  config SND_SOC_AD73311
>  	tristate
> -
> +

Random whitespace change, should be removed.

>   * Author:      Vladimir Barinov, <vbarinov@embeddedalley.com>
> + *              Jiri Prchal, <jiri.prchal@aksignal.cz

If you're going to do this you probably want a > in there.

>  {
>  	struct snd_soc_codec *codec = codec_dai->codec;
>  	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
> +	u8 data;
> +
> +	/* set external clock on GPIO2 or BCLK */
> +	data = snd_soc_read(codec, AIC3X_CLKGEN_CTRL_REG);
> +	data &= 0x0f;
> +	data |= ((clk_id << PLLCLK_IN_SHIFT) | (clk_id << CLKDIV_IN_SHIFT));
> +	snd_soc_write(codec, AIC3X_CLKGEN_CTRL_REG, data);

This looks like an unrelated change which is specific to your board.
You should add an interface for configuring this functionality .

>  	if (ret != 0) {
> -		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
> +		dev_err(codec->dev, "failed to set cache I/O: %d\n", ret);

Why are you decapitalising th estart of the sentance here?

> +static struct spi_driver aic3x_spi_driver = {
> +	.driver = {
> +		.name	= "tlv320aic3x-codec",
> +		.owner	= THIS_MODULE,

Remove the -codec from the driver name.

> +/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
> +static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
> +				     unsigned int reg)
> +{
> +	int ret;
> +	unsigned int val;

This won't apply against the current kernel and should be a separate
patch, it's a generic thing rather than part of the CODEC driver.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
@ 2011-04-02  8:26       ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2011-04-02  8:26 UTC (permalink / raw)
  To: Prchal Ji??; +Cc: alsa-devel, alsa-devel, vbarinov, linux-kernel

On Thu, Mar 24, 2011 at 11:20:45AM +0100, Prchal Ji?? wrote:
> Hi,
> this patch ads SPI communication for codecs TLV320AIC3X and clock input on GPIO2 or BCLK.
> Tested on TLV320AIC3106 and AT91SAM9260.
> TODO: Set the model in SPI probe the right way. I don't know how.

Register two SPI drivers with different names.

> This codec communicates on SPI in 1st byte: 7 MSB is register address, 1 LSB is read/write, 2nd byte data. For this
> reason there is new functions in soc-cache.c snd_soc_7_8_*.

This looks mostly good but there's some cleanups needed, mostly from
extra stuff which snuck in there, and you need to rebase against current
code.

As covered in SubmittingPatches you should always CC maintainers on
patches.

>  config SND_SOC_AD73311
>  	tristate
> -
> +

Random whitespace change, should be removed.

>   * Author:      Vladimir Barinov, <vbarinov@embeddedalley.com>
> + *              Jiri Prchal, <jiri.prchal@aksignal.cz

If you're going to do this you probably want a > in there.

>  {
>  	struct snd_soc_codec *codec = codec_dai->codec;
>  	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
> +	u8 data;
> +
> +	/* set external clock on GPIO2 or BCLK */
> +	data = snd_soc_read(codec, AIC3X_CLKGEN_CTRL_REG);
> +	data &= 0x0f;
> +	data |= ((clk_id << PLLCLK_IN_SHIFT) | (clk_id << CLKDIV_IN_SHIFT));
> +	snd_soc_write(codec, AIC3X_CLKGEN_CTRL_REG, data);

This looks like an unrelated change which is specific to your board.
You should add an interface for configuring this functionality .

>  	if (ret != 0) {
> -		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
> +		dev_err(codec->dev, "failed to set cache I/O: %d\n", ret);

Why are you decapitalising th estart of the sentance here?

> +static struct spi_driver aic3x_spi_driver = {
> +	.driver = {
> +		.name	= "tlv320aic3x-codec",
> +		.owner	= THIS_MODULE,

Remove the -codec from the driver name.

> +/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
> +static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
> +				     unsigned int reg)
> +{
> +	int ret;
> +	unsigned int val;

This won't apply against the current kernel and should be a separate
patch, it's a generic thing rather than part of the CODEC driver.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
  2011-04-02  8:26       ` [alsa-devel] " Mark Brown
  (?)
@ 2011-04-04  7:49       ` Prchal Jiří
  2011-04-04  8:03         ` Mark Brown
  -1 siblings, 1 reply; 31+ messages in thread
From: Prchal Jiří @ 2011-04-04  7:49 UTC (permalink / raw)
  To: Mark Brown, alsa-devel, alsa-devel; +Cc: vbarinov, linux-kernel



Dne 2.4.2011 10:26, Mark Brown napsal(a):
> On Thu, Mar 24, 2011 at 11:20:45AM +0100, Prchal Ji?? wrote:
>> Hi,
>> this patch ads SPI communication for codecs TLV320AIC3X and clock input on GPIO2 or BCLK.
>> Tested on TLV320AIC3106 and AT91SAM9260.
>> TODO: Set the model in SPI probe the right way. I don't know how.
> 
> Register two SPI drivers with different names.
???

>> This codec communicates on SPI in 1st byte: 7 MSB is register address, 1 LSB is read/write, 2nd byte data. For this
>> reason there is new functions in soc-cache.c snd_soc_7_8_*.
> 
> This looks mostly good but there's some cleanups needed, mostly from
> extra stuff which snuck in there, and you need to rebase against current
> code.
What cleanup? I copy functions snd_soc_8_8_* and made change to 7_8.

> As covered in SubmittingPatches you should always CC maintainers on
> patches.
Who is maintainer? I didn't find anyone, so I CC to author.

>>  config SND_SOC_AD73311
>>  	tristate
>> -
>> +
> 
> Random whitespace change, should be removed.
Yes.

>>   * Author:      Vladimir Barinov, <vbarinov@embeddedalley.com>
>> + *              Jiri Prchal, <jiri.prchal@aksignal.cz
> 
> If you're going to do this you probably want a > in there.
OK

>>  {
>>  	struct snd_soc_codec *codec = codec_dai->codec;
>>  	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
>> +	u8 data;
>> +
>> +	/* set external clock on GPIO2 or BCLK */
>> +	data = snd_soc_read(codec, AIC3X_CLKGEN_CTRL_REG);
>> +	data &= 0x0f;
>> +	data |= ((clk_id << PLLCLK_IN_SHIFT) | (clk_id << CLKDIV_IN_SHIFT));
>> +	snd_soc_write(codec, AIC3X_CLKGEN_CTRL_REG, data);
> 
> This looks like an unrelated change which is specific to your board.
> You should add an interface for configuring this functionality .
No, it's for all, who uses other clock source. Interface is standard function:
	/* Set the codec system clock for DAC and ADC */
	ret = snd_soc_dai_set_sysclk(codec_dai,
				     CLKIN_BCLK, cdu_audio[i].codecclk,
				     SND_SOC_CLOCK_IN);

>>  	if (ret != 0) {
>> -		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
>> +		dev_err(codec->dev, "failed to set cache I/O: %d\n", ret);
> 
> Why are you decapitalising th estart of the sentance here?
Corrected.

>> +static struct spi_driver aic3x_spi_driver = {
>> +	.driver = {
>> +		.name	= "tlv320aic3x-codec",
>> +		.owner	= THIS_MODULE,
> 
> Remove the -codec from the driver name.
Why? In I2C part it must be there, so should it be same?

>> +/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
>> +static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
>> +				     unsigned int reg)
>> +{
>> +	int ret;
>> +	unsigned int val;
> 
> This won't apply against the current kernel and should be a separate
> patch, it's a generic thing rather than part of the CODEC driver.
I split it to another PATCH.

> --
> To unsubscribe from this list: send the line "unsubscribe alsa-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/codecs/Kconfig
linux-2.6.38-patch/sound/soc/codecs/Kconfig
--- linux-2.6.38-vanilla/sound/soc/codecs/Kconfig	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/codecs/Kconfig	2011-04-04 08:30:12.115356779 +0200
@@ -37,7 +37,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
 	select SND_SOC_TLV320AIC23 if I2C
 	select SND_SOC_TLV320AIC26 if SPI_MASTER
-	select SND_SOC_TLV320AIC3X if I2C
+	select SND_SOC_TLV320AIC3X if SND_SOC_I2C_AND_SPI
 	select SND_SOC_TPA6130A2 if I2C
 	select SND_SOC_TLV320DAC33 if I2C
 	select SND_SOC_TWL4030 if TWL4030_CORE
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.c
linux-2.6.38-patch/sound/soc/codecs/tlv320aic3x.c
--- linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.c	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/codecs/tlv320aic3x.c	2011-04-04 08:31:33.521844547 +0200
@@ -2,7 +2,9 @@
  * ALSA SoC TLV320AIC3X codec driver
  *
  * Author:      Vladimir Barinov, <vbarinov@embeddedalley.com>
+ *              Jiri Prchal, <jiri.prchal@aksignal.cz>
  * Copyright:   (C) 2007 MontaVista Software, Inc., <source@mvista.com>
+ *              (C) 2011 AK signal Brno
  *
  * Based on sound/soc/codecs/wm8753.c by Liam Girdwood
  *
@@ -42,6 +44,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/spi/spi.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -864,9 +867,15 @@ static int aic3x_hw_params(struct snd_pc
 		snd_soc_write(codec, AIC3X_PLL_PROGA_REG, reg | PLL_ENABLE);
 	}

-	/* Route Left DAC to left channel input and
-	 * right DAC to right channel input */
-	data = (LDAC2LCH | RDAC2RCH);
+	/* If is stereo: Route Left DAC to left channel input and
+	 * right DAC to right channel input
+	 * else mono: route left input to both DAC
+	 */
+	if (params_channels(params) == 2)
+		data = (LDAC2LCH | RDAC2RCH);
+	else
+		data = (LDAC2LCH | RDAC2LCH);
+
 	data |= (fsref == 44100) ? FSREF_44100 : FSREF_48000;
 	if (params_rate(params) >= 64000)
 		data |= DUAL_RATE_MODE;
@@ -984,6 +993,13 @@ static int aic3x_set_dai_sysclk(struct s
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
 	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
+	u8 data;
+
+	/* set external clock on GPIO2 or BCLK */
+	data = snd_soc_read(codec, AIC3X_CLKGEN_CTRL_REG);
+	data &= 0x0f;
+	data |= ((clk_id << PLLCLK_IN_SHIFT) | (clk_id << CLKDIV_IN_SHIFT));
+	snd_soc_write(codec, AIC3X_CLKGEN_CTRL_REG, data);

 	aic3x->sysclk = freq;
 	return 0;
@@ -1371,7 +1387,10 @@ static int aic3x_probe(struct snd_soc_co
 	aic3x->codec = codec;
 	codec->dapm.idle_bias_off = 1;

-	ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type);
+	if (aic3x->control_type == SND_SOC_I2C)
+		ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type);
+	else
+		ret = snd_soc_codec_set_cache_io(codec, 7, 8, aic3x->control_type);
 	if (ret != 0) {
 		dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
 		return ret;
@@ -1472,6 +1491,54 @@ static struct snd_soc_codec_driver soc_c
 	.resume = aic3x_resume,
 };

+#if defined(CONFIG_SPI_MASTER)
+static int aic3x_spi_probe(struct spi_device *spi)
+{
+	struct aic3x_pdata *pdata = spi->dev.platform_data;
+	struct aic3x_priv *aic3x;
+	int ret;
+
+	aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL);
+	if (aic3x == NULL) {
+		dev_err(&spi->dev, "failed to create private data\n");
+		return -ENOMEM;
+	}
+
+	aic3x->control_type = SND_SOC_SPI;
+	spi_set_drvdata(spi, aic3x);
+
+	if (pdata) {
+		aic3x->gpio_reset = pdata->gpio_reset;
+		aic3x->setup = pdata->setup;
+	} else {
+		aic3x->gpio_reset = -1;
+	}
+
+	aic3x->model = AIC3X_MODEL_3X;
+
+	ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_aic3x, &aic3x_dai, 1);
+	if (ret < 0)
+		kfree(aic3x);
+	return ret;
+}
+
+static int __devexit aic3x_spi_remove(struct spi_device *spi)
+{
+	snd_soc_unregister_codec(&spi->dev);
+	kfree(spi_get_drvdata(spi));
+	return 0;
+}
+
+static struct spi_driver aic3x_spi_driver = {
+	.driver = {
+		.name	= "tlv320aic3x-codec",
+		.owner	= THIS_MODULE,
+	},
+	.probe		= aic3x_spi_probe,
+	.remove		= __devexit_p(aic3x_spi_remove),
+};
+#endif /* CONFIG_SPI_MASTER */
+
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 /*
  * AIC3X 2 wire address can be up to 4 devices with device addresses
@@ -1557,6 +1624,13 @@ static int __init aic3x_modinit(void)
 		       ret);
 	}
 #endif
+#if defined(CONFIG_SPI_MASTER)
+	ret = spi_register_driver(&aic3x_spi_driver);
+	if (ret != 0) {
+		printk(KERN_ERR "Failed to register AIC3X SPI driver: %d\n",
+		       ret);
+	}
+#endif
 	return ret;
 }
 module_init(aic3x_modinit);
@@ -1566,6 +1640,9 @@ static void __exit aic3x_exit(void)
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	i2c_del_driver(&aic3x_i2c_driver);
 #endif
+#if defined(CONFIG_SPI_MASTER)
+	spi_unregister_driver(&aic3x_spi_driver);
+#endif
 }
 module_exit(aic3x_exit);

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.h
linux-2.6.38-patch/sound/soc/codecs/tlv320aic3x.h
--- linux-2.6.38-vanilla/sound/soc/codecs/tlv320aic3x.h	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/codecs/tlv320aic3x.h	2011-03-25 12:15:06.620049184 +0100
@@ -163,6 +163,10 @@
 #define DUAL_RATE_MODE		((1 << 5) | (1 << 6))
 #define LDAC2LCH		(0x1 << 3)
 #define RDAC2RCH		(0x1 << 1)
+#define LDAC2RCH		(0x2 << 3)
+#define RDAC2LCH		(0x2 << 1)
+#define LDAC2MONOMIX		(0x3 << 3)
+#define RDAC2MONOMIX		(0x3 << 1)

 /* PLL registers bitfields */
 #define PLLP_SHIFT		0
@@ -178,6 +182,13 @@
 #define PLL_CLKIN_SHIFT		4
 #define MCLK_SOURCE		0x0
 #define PLL_CLKDIV_SHIFT	0
+#define PLLCLK_IN_SHIFT		4
+#define CLKDIV_IN_SHIFT		6
+/* clock in source */
+#define CLKIN_MCLK		0
+#define CLKIN_GPIO2		1
+#define CLKIN_BCLK		2
+

 /* Software reset register bits */
 #define SOFT_RESET		0x80

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] ALSA: ASoc: new functions snd_soc_7_8_*
  2011-04-02  8:26       ` [alsa-devel] " Mark Brown
  (?)
  (?)
@ 2011-04-04  8:01       ` Prchal Jiří
  2011-04-04  8:05           ` Mark Brown
  -1 siblings, 1 reply; 31+ messages in thread
From: Prchal Jiří @ 2011-04-04  8:01 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, alsa-devel, linux-kernel

Hi,
this is separated generic part of previous patch.
It contains read and write functions for codecs which communicate via SPI with 7bit register address, 1 LSB is
read/write and 2nd byte data.

Dne 2.4.2011 10:26, Mark Brown napsal(a):
>> +/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
>> +static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
>> +				     unsigned int reg)
>> +{
>> +	int ret;
>> +	unsigned int val;
> 
> This won't apply against the current kernel and should be a separate
> patch, it's a generic thing rather than part of the CODEC driver.
> --
> To unsubscribe from this list: send the line "unsubscribe alsa-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/soc-cache.c
linux-2.6.38-patch/sound/soc/soc-cache.c
--- linux-2.6.38-vanilla/sound/soc/soc-cache.c	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/soc-cache.c	2011-03-24 09:23:00.984373772 +0100
@@ -99,6 +99,58 @@ static int snd_soc_4_12_spi_write(void *
 #define snd_soc_4_12_spi_write NULL
 #endif

+/* special functions for codecs with 7 bit register address and LSB read/write (like TLV320AIC3X) */
+static unsigned int snd_soc_7_8_read(struct snd_soc_codec *codec,
+				     unsigned int reg)
+{
+	int ret;
+	unsigned int val;
+
+	if (reg >= codec->driver->reg_cache_size ||
+		snd_soc_codec_volatile_register(codec, reg)) {
+			if (codec->cache_only)
+				return -1;
+
+			BUG_ON(!codec->hw_read);
+			return codec->hw_read(codec, ((reg << 1) | 1));
+	}
+
+	ret = snd_soc_cache_read(codec, reg, &val);
+	if (ret < 0)
+		return -1;
+	return val;
+}
+
+static int snd_soc_7_8_write(struct snd_soc_codec *codec, unsigned int reg,
+			     unsigned int value)
+{
+	u8 data[2];
+	int ret;
+
+	data[0] = (reg << 1);
+	data[1] = value;
+
+	if (!snd_soc_codec_volatile_register(codec, reg) &&
+		reg < codec->driver->reg_cache_size) {
+		ret = snd_soc_cache_write(codec, reg, value);
+		if (ret < 0)
+			return -1;
+	}
+
+	if (codec->cache_only) {
+		codec->cache_sync = 1;
+		return 0;
+	}
+
+	ret = codec->hw_write(codec->control_data, data, 2);
+	if (ret == 2)
+		return 0;
+	if (ret < 0)
+		return ret;
+	else
+		return -EIO;
+}
+
 static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
 				     unsigned int reg)
 {
@@ -661,6 +713,11 @@ static struct {
 		.spi_write = snd_soc_4_12_spi_write,
 	},
 	{
+		.addr_bits = 7, .data_bits = 8,
+		.write = snd_soc_7_8_write, .read = snd_soc_7_8_read,
+		.spi_write = snd_soc_8_8_spi_write,
+	},
+	{
 		.addr_bits = 7, .data_bits = 9,
 		.write = snd_soc_7_9_write, .read = snd_soc_7_9_read,
 		.spi_write = snd_soc_7_9_spi_write,

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
  2011-04-04  7:49       ` Prchal Jiří
@ 2011-04-04  8:03         ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2011-04-04  8:03 UTC (permalink / raw)
  To: Prchal Jiří; +Cc: alsa-devel, alsa-devel, vbarinov, linux-kernel

On Mon, Apr 04, 2011 at 09:49:49AM +0200, Prchal Jiří wrote:
> Dne 2.4.2011 10:26, Mark Brown napsal(a):

> >> TODO: Set the model in SPI probe the right way. I don't know how.

> > Register two SPI drivers with different names.

> ???

Register a SPI driver per model.

> > This looks mostly good but there's some cleanups needed, mostly from
> > extra stuff which snuck in there, and you need to rebase against current
> > code.

> What cleanup? I copy functions snd_soc_8_8_* and made change to 7_8.

The comments I've made in the rest of the review such as removing random
whitespace updates.

> > As covered in SubmittingPatches you should always CC maintainers on
> > patches.

> Who is maintainer? I didn't find anyone, so I CC to author.

Myself and Liam Girdwood.  At the most basic level the people you'd
expect to apply the patch.

> >> +	/* set external clock on GPIO2 or BCLK */
> >> +	data = snd_soc_read(codec, AIC3X_CLKGEN_CTRL_REG);
> >> +	data &= 0x0f;
> >> +	data |= ((clk_id << PLLCLK_IN_SHIFT) | (clk_id << CLKDIV_IN_SHIFT));
> >> +	snd_soc_write(codec, AIC3X_CLKGEN_CTRL_REG, data);

> > This looks like an unrelated change which is specific to your board.
> > You should add an interface for configuring this functionality .

> No, it's for all, who uses other clock source. Interface is standard function:
> 	/* Set the codec system clock for DAC and ADC */
> 	ret = snd_soc_dai_set_sysclk(codec_dai,
> 				     CLKIN_BCLK, cdu_audio[i].codecclk,
> 				     SND_SOC_CLOCK_IN);

In that case you should submit a separate patch adding this
functionality, taking care to ensure that you don't break existing
users.

> >> +static struct spi_driver aic3x_spi_driver = {
> >> +	.driver = {
> >> +		.name	= "tlv320aic3x-codec",
> >> +		.owner	= THIS_MODULE,

> > Remove the -codec from the driver name.

> Why? In I2C part it must be there, so should it be same?

No, it should be removed from the I2C driver too.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] ALSA: ASoc: new functions snd_soc_7_8_*
  2011-04-04  8:01       ` [PATCH] ALSA: ASoc: new functions snd_soc_7_8_* Prchal Jiří
@ 2011-04-04  8:05           ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2011-04-04  8:05 UTC (permalink / raw)
  To: Prchal Jiří; +Cc: alsa-devel, alsa-devel, linux-kernel

On Mon, Apr 04, 2011 at 10:01:54AM +0200, Prchal Jiří wrote:
> Hi,
> this is separated generic part of previous patch.
> It contains read and write functions for codecs which communicate via SPI with 7bit register address, 1 LSB is
> read/write and 2nd byte data.

Please folow the patch submission processs in SubmittingPatches,
especially with regard to the formatting of the mail containing the
patch.

Also note that as I previously said:

> > This won't apply against the current kernel and should be a separate

> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/soc-cache.c
> linux-2.6.38-patch/sound/soc/soc-cache.c
> --- linux-2.6.38-vanilla/sound/soc/soc-cache.c	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/soc-cache.c	2011-03-24 09:23:00.984373772 +0100

There have been some substantial updates to this code in current
kernels.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] ALSA: ASoc: new functions snd_soc_7_8_*
@ 2011-04-04  8:05           ` Mark Brown
  0 siblings, 0 replies; 31+ messages in thread
From: Mark Brown @ 2011-04-04  8:05 UTC (permalink / raw)
  To: Prchal Jiří; +Cc: alsa-devel, alsa-devel, linux-kernel

On Mon, Apr 04, 2011 at 10:01:54AM +0200, Prchal Jiří wrote:
> Hi,
> this is separated generic part of previous patch.
> It contains read and write functions for codecs which communicate via SPI with 7bit register address, 1 LSB is
> read/write and 2nd byte data.

Please folow the patch submission processs in SubmittingPatches,
especially with regard to the formatting of the mail containing the
patch.

Also note that as I previously said:

> > This won't apply against the current kernel and should be a separate

> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/soc-cache.c
> linux-2.6.38-patch/sound/soc/soc-cache.c
> --- linux-2.6.38-vanilla/sound/soc/soc-cache.c	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/soc-cache.c	2011-03-24 09:23:00.984373772 +0100

There have been some substantial updates to this code in current
kernels.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
  2011-03-24 20:07       ` Ryan Mallon
  (?)
@ 2011-04-04  8:57       ` Prchal Jiří
  2011-04-04 20:07           ` Ryan Mallon
  -1 siblings, 1 reply; 31+ messages in thread
From: Prchal Jiří @ 2011-04-04  8:57 UTC (permalink / raw)
  To: Ryan Mallon; +Cc: alsa-devel, alsa-devel, vbarinov, linux-kernel

Hi,
this is separeted PATCH for glue AT91SAM9260 and TLV320AIC3X on CDU board.

Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
	[PATCH] ALSA: ASoc: new functions snd_soc_7_8_*
	[PATCH] ARCH arm: adding new board: CDU
Kernel version: 2.6.38
Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>

Dne 24.3.2011 21:07, Ryan Mallon napsal(a):
> On 03/24/2011 11:43 PM, Prchal Jiří wrote:
>> Hi,
>> this patch is for example how to put together AT91SAM9260 and TLV320AIC3106 controlled via SPI.
>> It tooks me a lot of time to make it working, so I think it could be helpfull for other people.
>>
>> In original source "snd-soc-afeb9260.c" which I use as example is BIG ERROR:
>> In function "afeb9260_soc_init" is missing call of "atmel_ssc_set_audio(0);". It cause bug "PROBLEM: Asoc driver in
>> 2.6.37.3 for AT91SAM9260 / TLV320AIC3X is broken" which I post some time ago.
> 
> Hi Jiri,
> 
> This patch is actually doing two things: adding board support for a new
> at91sam9260 device and adding the audio glue for the new board. It
> should be split into two patches. Quick review below.
> 
> ~Ryan
> 
I separate it.

>>
>> Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
>> Kernel version: 2.6.38
>> Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
>> ---
>>
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Kconfig
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig
>> --- linux-2.6.38-vanilla/sound/soc/atmel/Kconfig	2011-03-15 02:20:32.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Kconfig	2011-03-22 09:46:46.751566158 +0100
>> @@ -50,3 +50,11 @@ config SND_AT91_SOC_AFEB9260
>>  	select SND_SOC_TLV320AIC23
>>  	help
>>  	  Say Y here to support sound on AFEB9260 board.
>> +
>> +config SND_AT91_SOC_CDU
>> +	tristate "SoC Audio support for CDU board"
>> +	depends on ARCH_AT91 && MACH_CDU && SND_ATMEL_SOC
>> +	select SND_ATMEL_SOC_SSC
>> +	select SND_SOC_TLV320AIC3X
>> +	help
>> +	  Say Y here to support sound on CDU board.
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Makefile
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile
>> --- linux-2.6.38-vanilla/sound/soc/atmel/Makefile	2011-03-15 02:20:32.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/Makefile	2011-03-16 09:26:17.000000000 +0100
>> @@ -14,3 +14,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o
>>  obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
>>  obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
>>  obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
>> +obj-$(CONFIG_SND_AT91_SOC_CDU) += snd-soc-cdu.o
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c
>> --- linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c	1970-01-01 01:00:00.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/sound/soc/atmel/snd-soc-cdu.c	2011-03-24 09:27:55.404367652 +0100
>> @@ -0,0 +1,264 @@
>> +/*
>> + * snd-soc-cdu  --  SoC audio for AT91SAM9260-based
>> + * 			AKsignal CDU board.
>> + *
>> + *  Copyright (C) 2005 SAN People
>> + *  Copyright (C) 2008 Atmel
>> + *  Copyright (C) 2011 AK signal Brno
>> + *
>> + * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
>> + *          Jiri Prchal <jiri.prchal@aksignal.cz>
>> + *
>> + * Based on ati_b1_wm8731.c by:
>> + * Frank Mandarino <fmandarino@endrelia.com>
>> + * Copyright 2006 Endrelia Technologies Inc.
>> + * Based on corgi.c by:
>> + * Copyright 2005 Wolfson Microelectronics PLC.
>> + * Copyright 2005 Openedhand Ltd.
>> + *
>> + * 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 <linux/module.h>
>> +#include <linux/moduleparam.h>
>> +#include <linux/kernel.h>
>> +#include <linux/clk.h>
>> +#include <linux/timer.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/i2c.h>
>> +
>> +#include <linux/atmel-ssc.h>
>> +#include <sound/core.h>
>> +#include <sound/pcm.h>
>> +#include <sound/pcm_params.h>
>> +#include <sound/soc.h>
>> +
>> +#include <asm/mach-types.h>
>> +#include <mach/hardware.h>
>> +#include <mach/gpio.h>
> 
> Note sure you need all of these includes. linux/interrupt.h,
> linux/moduleparam.h, linux/timer.h and mach/gpio.h at least appear to be
> uneccessary.
Cleaned up.

> 
>> +
>> +#include "../codecs/tlv320aic3x.h"
>> +#include "atmel-pcm.h"
>> +#include "atmel_ssc_dai.h"
>> +
>> +struct {
>> +	unsigned int channels;
>> +	snd_pcm_format_t format;
>> +	unsigned int rate;
>> +	unsigned int codecclk;
>> +	unsigned int cmrdiv;
>> +	unsigned int period;
>> +} cdu_audio[] = {
>> +	/* 16 bit stereo modes */
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 8000, 2096000, 25, 130,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 16000, 2496000, 21, 77,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 32000, 2496000, 21, 38,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 48000, 2016000, 26, 20,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 96000, 4032000, 13, 20,},
>> +
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 11025, 2381400, 22, 107,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 22050, 2381400, 22, 53,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 44100, 2381400, 22, 26,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 88200, 4762800, 11, 26,},
>> +
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 11520, 2626560, 20, 113,},
>> +	{2, SNDRV_PCM_FORMAT_S16_LE, 23040, 2626560, 20, 56,},
> 
> Can these be calculated rather than using a table? The first two values
> probably don't need to be in the table since they are always the same.
Explained in new comment why it is table. I made the table smaller.

> 
>> +
>> +};
>> +
>> +static int cdu_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
>> +{
>> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
>> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
>> +	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
>> +	int ret;
>> +	int i, found = 0;
>> +	snd_pcm_format_t format = params_format(params);
>> +	unsigned int rate = params_rate(params);
>> +	unsigned int channels = params_channels(params);
>> +
>> +	/* set codec DAI configuration */
>> +	ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
> 
> Long lines should be broken to fit inside 80 characters.
OK.

> 
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	/* set cpu DAI configuration */
>> +	ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	/* find the correct audio parameters */
>> +	for (i = 0; i < ARRAY_SIZE(cdu_audio); i++) {
>> +		if (rate == cdu_audio[i].rate &&
>> +		    format == cdu_audio[i].format &&
>> +		    channels == cdu_audio[i].channels) {
>> +			found = 1;
>> +			break;
>> +		}
>> +	}
>> +	if (!found)
>> +		return -EINVAL;
> 
> Should maybe do this before doing the dai_set_fmt's since we only
> support some modes. Also:
> 
> 	/* Only support 2 channel S16_LE */
> 	if (channels != 2 || format != SNDRV_PCM_FORMAT_S16_LE)
> 		return -EINVAL;
> 
> 	/* Check rate support */
> 	for (i = 0; i < ARRAY_SIZE(cdc_audio); i++)
> 		if (rate == cdc_audio[i].rate) {
> 			found = 1;
> 			break;
> 		}
> 	if (!found)
> 		return -EINVAL;
> 
OK.

>> +
>> +	/* Set the codec system clock for DAC and ADC */
>> +	ret = snd_soc_dai_set_sysclk(codec_dai, CLKIN_BCLK, cdu_audio[i].codecclk, SND_SOC_CLOCK_IN);
>> +	if (ret < 0) {
>> +		printk(KERN_ERR "can't set codec system clock\n");
> 
> You should, I think, be able to do:
> 
> 	struct device *dev = rtd->card->dev;
> 
> 	dev_err(dev, "can't set codec system clock\n");
> 
> Same goes for other printks.
> 
OK.

>> +		return ret;
>> +	}
>> +
>> +	/* Set the cpu clock dividers to BCLK */
>> +	ret = snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_CMR_DIV, cdu_audio[i].cmrdiv);
>> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_TCMR_PERIOD, cdu_audio[i].period);
>> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai, ATMEL_SSC_RCMR_PERIOD, cdu_audio[i].period);
>> +	if (ret < 0) {
>> +		printk(KERN_ERR "can't set cpu system clock\n");
>> +		return ret;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static struct snd_soc_ops cdu_ops = {
>> +	.hw_params = cdu_hw_params,
>> +};
>> +
>> +static const struct snd_soc_dapm_widget cdu_dapm_widgets[] = {
>> +	SND_SOC_DAPM_HP("Headphone Jack", NULL),
>> +	SND_SOC_DAPM_LINE("Line Out", NULL),
>> +	SND_SOC_DAPM_MIC("Mic Jack", NULL),
>> +	SND_SOC_DAPM_LINE("Line In", NULL),
>> +};
>> +
>> +static const struct snd_soc_dapm_route intercon[] = {
>> +	/* Headphone connected to HPLOUT, HPROUT */
>> +	{"Headphone Jack", NULL, "HPLOUT"},
>> +	{"Headphone Jack", NULL, "HPROUT"},
>> +
>> +	/* Line Out connected to LLOUT, RLOUT */
>> +	{"Line Out", NULL, "LLOUT"},
>> +	{"Line Out", NULL, "RLOUT"},
>> +
>> +	/* Mic connected to (MIC3L | MIC3R) */
>> +	{"MIC3L", NULL, "Mic Bias 2V"},
>> +	{"MIC3R", NULL, "Mic Bias 2V"},
>> +	{"Mic Bias 2V", NULL, "Mic Jack"},
>> +
>> +	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
>> +	{"LINE1L", NULL, "Line In"},
>> +	{"LINE2L", NULL, "Line In"},
>> +	{"LINE1R", NULL, "Line In"},
>> +	{"LINE2R", NULL, "Line In"},
>> +};
>> +
>> +/*
>> + * Logic for a aic3x as connected on a cdu board.
>> + */
>> +static int cdu_aic3x_init(struct snd_soc_pcm_runtime *rtd)
>> +{
>> +	struct snd_soc_codec *codec = rtd->codec;
>> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
>> +	struct snd_soc_dapm_context *dapm = &codec->dapm;
>> +	int ret;
>> +
>> +	printk(KERN_DEBUG "cdu_aic3x: cdu_aic3x_init called\n");
> 
> Is this line really needed?
> 
NO, removed.

>> +
>> +	/* Add specific widgets */
>> +	snd_soc_dapm_new_controls(dapm, cdu_dapm_widgets,
>> +				  ARRAY_SIZE(cdu_dapm_widgets));
>> +	/* Set up specific audio path interconnects */
>> +	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
>> +
>> +	/* always connected */
>> +	snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
>> +	snd_soc_dapm_enable_pin(dapm, "Line Out");
>> +	snd_soc_dapm_enable_pin(dapm, "Mic Jack");
>> +	snd_soc_dapm_enable_pin(dapm, "Line In");
>> +
>> +	snd_soc_dapm_sync(dapm);
> 
> IIRC, you no longer need to explicitly call snd_soc_dapm_enable_pin and
> snd_soc_dapm_sync. Somebody else can probably shed more light on this.
> 
Removed.

>> +
>> +	return 0;
>> +}
>> +
>> +static struct snd_soc_dai_link cdu_dai = {
>> +	.name		= "TLV320AIC3106",
>> +	.stream_name	= "PCM",
>> +	.cpu_dai_name	= "atmel-ssc-dai.0",
>> +	.codec_dai_name	= "tlv320aic3x-hifi",
>> +	.init = cdu_aic3x_init,
> 
> Tab-delimiting got messed here.
> 
OK.

>> +	.platform_name	= "atmel-pcm-audio",
>> +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
>> +	.codec_name	= "tlv320aic3x-codec.0-001b",
>> +#endif
>> +#if defined(CONFIG_SPI_MASTER)
>> +	.codec_name	= "spi1.3",
>> +#endif
> 
> If both CONFIG_I2C and CONFIG_SPI_MASTER are set then you will have a
> broken build. Which one does the CDU board use?
> 
Since CDU use only SPI the I2C option removed.

>> +	.ops		= &cdu_ops,
>> +};
>> +
>> +static struct snd_soc_card snd_soc_cdu = {
>> +	.name		= "TLV320AIC3106",
>> +	.dai_link	= &cdu_dai,
>> +	.num_links	= 1,
>> +};
>> +
>> +static struct platform_device *cdu_snd_device;
>> +
>> +static int __init cdu_init(void)
>> +{
>> +	struct clk *pllb;
> 
> Remove this line, pllb is never used in this function.
> 
OK.

>> +	int ret;
>> +
>> +	ret = atmel_ssc_set_audio(0);
>> +	if (ret != 0) {
> 
> Nitpick. Just if (ret) is fine.
> 
OK.

>> +		pr_err("Failed to set SSC 0 for audio: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	cdu_snd_device = platform_device_alloc("soc-audio", -1);
>> +	if (!cdu_snd_device) {
>> +		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
>> +		ret = -ENOMEM;
>> +	}
>> +
>> +	platform_set_drvdata(cdu_snd_device, &snd_soc_cdu);
>> +
>> +	ret = platform_device_add(cdu_snd_device);
>> +	if (ret) {
>> +		printk(KERN_ERR "ASoC: Platform device allocation failed\n");
> 
> Use pr_err to be consistent.
> 
OK.

>> +		goto err_device_add;
>> +	}
>> +
>> +	return ret;
>> +
>> +err_device_add:
>> +	platform_device_put(cdu_snd_device);
>> +err:
>> +	return ret;
>> +}
>> +
>> +static void __exit cdu_exit(void)
>> +{
>> +	platform_device_unregister(cdu_snd_device);
>> +	cdu_snd_device = NULL;
> 
> I don't think you need to set cdu_snd_device to NULL here.
> 
OK.

>> +}
>> +
>> +module_init(cdu_init);
>> +module_exit(cdu_exit);
>> +
>> +/* Module information */
>> +MODULE_AUTHOR("Jiri Prchal <jiri.prchal@aksignal.cz>");
>> +MODULE_DESCRIPTION("ALSA SoC CDU_AIC3X");
>> +MODULE_LICENSE("GPL");
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Kconfig
linux-2.6.38-patch/sound/soc/atmel/Kconfig
--- linux-2.6.38-vanilla/sound/soc/atmel/Kconfig	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/atmel/Kconfig	2011-03-22 09:46:46.751566158 +0100
@@ -50,3 +50,11 @@ config SND_AT91_SOC_AFEB9260
 	select SND_SOC_TLV320AIC23
 	help
 	  Say Y here to support sound on AFEB9260 board.
+
+config SND_AT91_SOC_CDU
+	tristate "SoC Audio support for CDU board"
+	depends on ARCH_AT91 && MACH_CDU && SND_ATMEL_SOC
+	select SND_ATMEL_SOC_SSC
+	select SND_SOC_TLV320AIC3X
+	help
+	  Say Y here to support sound on CDU board.
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Makefile
linux-2.6.38-patch/sound/soc/atmel/Makefile
--- linux-2.6.38-vanilla/sound/soc/atmel/Makefile	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/atmel/Makefile	2011-03-16 09:26:17.000000000 +0100
@@ -14,3 +14,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o
 obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
 obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
 obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
+obj-$(CONFIG_SND_AT91_SOC_CDU) += snd-soc-cdu.o
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c
linux-2.6.38-patch/sound/soc/atmel/snd-soc-cdu.c
--- linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.38-patch/sound/soc/atmel/snd-soc-cdu.c	2011-03-25 13:42:07.545051043 +0100
@@ -0,0 +1,259 @@
+/*
+ * snd-soc-cdu  --  SoC audio for AT91SAM9260-based
+ * 			AKsignal CDU board.
+ *
+ *  Copyright (C) 2005 SAN People
+ *  Copyright (C) 2008 Atmel
+ *  Copyright (C) 2011 AK signal Brno
+ *
+ * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
+ *          Jiri Prchal <jiri.prchal@aksignal.cz>
+ *
+ * Based on ati_b1_wm8731.c by:
+ * Frank Mandarino <fmandarino@endrelia.com>
+ * Copyright 2006 Endrelia Technologies Inc.
+ * Based on corgi.c by:
+ * Copyright 2005 Wolfson Microelectronics PLC.
+ * Copyright 2005 Openedhand Ltd.
+ *
+ * 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 <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/platform_device.h>
+
+#include <linux/atmel-ssc.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+
+#include <asm/mach-types.h>
+#include <mach/hardware.h>
+
+#include "../codecs/tlv320aic3x.h"
+#include "atmel-pcm.h"
+#include "atmel_ssc_dai.h"
+
+/*
+ * Table of supported rates
+ * with their clock divider (cmrdiv) and number clock in frame (period + 1 * 2),
+ * codecclk sould be integer multiple of sample rate even if it is not exact true
+ * to avoid data on SSC underrun / overrun -
+ * CPU can not generate clock as fine as CODEC.
+ */
+struct {
+	unsigned int rate;
+	unsigned int codecclk;
+	unsigned int cmrdiv;
+	unsigned int period;
+} cdu_audio[] = {
+	{8000, 2096000, 25, 130,},
+	{16000, 2496000, 21, 77,},
+	{32000, 2496000, 21, 38,},
+	{48000, 2016000, 26, 20,},
+	{96000, 4032000, 13, 20,},
+
+	{11025, 2381400, 22, 107,},
+	{22050, 2381400, 22, 53,},
+	{44100, 2381400, 22, 26,},
+	{88200, 4762800, 11, 26,},
+
+	/* special rates for serial line transfer */
+	{11520, 2626560, 20, 113,},
+	{23040, 2626560, 20, 56,},
+	{46080, 2764800, 19, 29,},
+};
+
+static int cdu_hw_params(struct snd_pcm_substream *substream,
+			 struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
+	struct device *dev = rtd->card->dev;
+	int ret;
+	int i, found = 0;
+
+	/* set codec DAI configuration */
+	ret = snd_soc_dai_set_fmt(codec_dai,
+				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBS_CFS);
+	if (ret < 0)
+		return ret;
+
+	/* set cpu DAI configuration */
+	ret = snd_soc_dai_set_fmt(cpu_dai,
+				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+				  SND_SOC_DAIFMT_CBS_CFS);
+	if (ret < 0)
+		return ret;
+
+	/* Only support 1 or 2 channel S16_LE */
+	if ((params_channels(params) != 1 && params_channels(params) != 2) ||
+	   params_format(params) != SNDRV_PCM_FORMAT_S16_LE)
+		return -EINVAL;
+
+	/* Check rate support */
+	for (i = 0; i < ARRAY_SIZE(cdu_audio); i++)
+		if (params_rate(params) == cdu_audio[i].rate) {
+			found = 1;
+			break;
+		}
+	if (!found)
+		return -EINVAL;
+
+	/* Set the codec system clock for DAC and ADC */
+	ret = snd_soc_dai_set_sysclk(codec_dai,
+				     CLKIN_BCLK, cdu_audio[i].codecclk,
+				     SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(dev, "can't set codec system clock\n");
+		return ret;
+	}
+
+	/* Set the cpu clock dividers to BCLK */
+	ret = snd_soc_dai_set_clkdiv(cpu_dai,
+				     ATMEL_SSC_CMR_DIV, cdu_audio[i].cmrdiv);
+	ret |= snd_soc_dai_set_clkdiv(cpu_dai,
+				      ATMEL_SSC_TCMR_PERIOD,
+				      cdu_audio[i].period);
+	ret |= snd_soc_dai_set_clkdiv(cpu_dai,
+				      ATMEL_SSC_RCMR_PERIOD,
+				      cdu_audio[i].period);
+	if (ret < 0) {
+		dev_err(dev, "can't set cpu system clock\n");
+		return ret;
+	}
+
+	return 0;
+}
+
+static struct snd_soc_ops cdu_ops = {
+	.hw_params = cdu_hw_params,
+};
+
+static const struct snd_soc_dapm_widget cdu_dapm_widgets[] = {
+	SND_SOC_DAPM_HP("Headphone Jack", NULL),
+	SND_SOC_DAPM_LINE("Line Out", NULL),
+	SND_SOC_DAPM_MIC("Mic Jack", NULL),
+	SND_SOC_DAPM_LINE("Line In", NULL),
+};
+
+static const struct snd_soc_dapm_route intercon[] = {
+	/* Headphone connected to HPLOUT, HPROUT */
+	{"Headphone Jack", NULL, "HPLOUT"},
+	{"Headphone Jack", NULL, "HPROUT"},
+
+	/* Line Out connected to LLOUT, RLOUT */
+	{"Line Out", NULL, "LLOUT"},
+	{"Line Out", NULL, "RLOUT"},
+
+	/* Mic connected to (MIC3L | MIC3R) */
+	{"MIC3L", NULL, "Mic Bias 2V"},
+	{"MIC3R", NULL, "Mic Bias 2V"},
+	{"Mic Bias 2V", NULL, "Mic Jack"},
+
+	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
+	{"LINE1L", NULL, "Line In"},
+	{"LINE2L", NULL, "Line In"},
+	{"LINE1R", NULL, "Line In"},
+	{"LINE2R", NULL, "Line In"},
+};
+
+/*
+ * Logic for a aic3x as connected on a cdu board.
+ */
+static int cdu_aic3x_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_codec *codec = rtd->codec;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	struct snd_soc_dapm_context *dapm = &codec->dapm;
+	int ret;
+
+	/* Add specific widgets */
+	snd_soc_dapm_new_controls(dapm, cdu_dapm_widgets,
+				  ARRAY_SIZE(cdu_dapm_widgets));
+	/* Set up specific audio path interconnects */
+	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
+
+	return 0;
+}
+
+static struct snd_soc_dai_link cdu_dai = {
+	.name		= "TLV320AIC3106",
+	.stream_name	= "PCM",
+	.cpu_dai_name	= "atmel-ssc-dai.0",
+	.codec_dai_name	= "tlv320aic3x-hifi",
+	.init		= cdu_aic3x_init,
+	.platform_name	= "atmel-pcm-audio",
+	.codec_name	= "spi1.3",
+	.ops		= &cdu_ops,
+};
+
+static struct snd_soc_card snd_soc_cdu = {
+	.name		= "TLV320AIC3106",
+	.dai_link	= &cdu_dai,
+	.num_links	= 1,
+};
+
+static struct platform_device *cdu_snd_device;
+
+static int __init cdu_init(void)
+{
+	int ret;
+
+	ret = atmel_ssc_set_audio(0);
+	if (ret) {
+		pr_err("Failed to set SSC 0 for audio: %d\n", ret);
+		return ret;
+	}
+
+	cdu_snd_device = platform_device_alloc("soc-audio", -1);
+	if (!cdu_snd_device) {
+		pr_err("ASoC: Platform device allocation failed: %d\n", ret);
+		ret = -ENOMEM;
+	}
+
+	platform_set_drvdata(cdu_snd_device, &snd_soc_cdu);
+
+	ret = platform_device_add(cdu_snd_device);
+	if (ret) {
+		pr_err("ASoC: Platform device adding failed: %d\n", ret);
+		goto err_device_add;
+	}
+
+	return ret;
+
+err_device_add:
+	platform_device_put(cdu_snd_device);
+err:
+	return ret;
+}
+
+static void __exit cdu_exit(void)
+{
+	platform_device_unregister(cdu_snd_device);
+}
+
+module_init(cdu_init);
+module_exit(cdu_exit);
+
+/* Module information */
+MODULE_AUTHOR("Jiri Prchal <jiri.prchal@aksignal.cz>");
+MODULE_DESCRIPTION("ALSA SoC CDU_AIC3X");
+MODULE_LICENSE("GPL");

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] ARCH arm: adding new board: CDU
  2011-03-24 20:07       ` Ryan Mallon
@ 2011-04-04  9:10         ` Prchal Jiří
  -1 siblings, 0 replies; 31+ messages in thread
From: Prchal Jiří @ 2011-04-04  9:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,
this is separated PATCH adding new board CDU.

Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
	[PATCH] ALSA: ASoc: new functions snd_soc_7_8_*
	[PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
Kernel version: 2.6.38
Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>

Dne 24.3.2011 21:07, Ryan Mallon napsal(a):
> On 03/24/2011 11:43 PM, Prchal Ji?? wrote:
>> Hi,
>> this patch is for example how to put together AT91SAM9260 and TLV320AIC3106 controlled via SPI.
>> It tooks me a lot of time to make it working, so I think it could be helpfull for other people.
>>
>> In original source "snd-soc-afeb9260.c" which I use as example is BIG ERROR:
>> In function "afeb9260_soc_init" is missing call of "atmel_ssc_set_audio(0);". It cause bug "PROBLEM: Asoc driver in
>> 2.6.37.3 for AT91SAM9260 / TLV320AIC3X is broken" which I post some time ago.
> 
> Hi Jiri,
> 
> This patch is actually doing two things: adding board support for a new
> at91sam9260 device and adding the audio glue for the new board. It
> should be split into two patches. Quick review below.
> 
> ~Ryan
> 
>>
>> Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
>> Kernel version: 2.6.38
>> Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
>> ---
>>
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c
>> --- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c	2011-03-24 09:15:23.852370981 +0100
>> @@ -0,0 +1,345 @@
>> +/*
>> + * linux/arch/arm/mach-at91/board-cdu.c
>> + *
>> + *  Copyright (C) 2005 SAN People
>> + *  Copyright (C) 2006 Atmel
>> + *  Copyright (C) 2011 AKsignal Brno
>> + *                     jiri.prchal at aksignal.cz
>> + *
>> + * 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 <linux/types.h>
>> +#include <linux/init.h>
>> +#include <linux/mm.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/spi/spi.h>
>> +#include <linux/clk.h>
>> +#include <linux/spi/mcp23s08.h>
>> +#include <linux/dma-mapping.h>
>> +
>> +#include <mach/hardware.h>
>> +#include <asm/setup.h>
>> +#include <asm/mach-types.h>
>> +#include <asm/irq.h>
>> +
>> +#include <asm/mach/arch.h>
>> +#include <asm/mach/map.h>
>> +#include <asm/mach/irq.h>
>> +
>> +#include <mach/board.h>
>> +#include <mach/gpio.h>
>> +#include <mach/at91sam9_smc.h>
>> +
>> +#include "sam9_smc.h"
>> +#include "generic.h"
>> +
>> +static void __init cdu_map_io(void)
>> +{
>> +	/* Initialize processor: 6 MHz crystal */
>> +	at91sam9260_initialize(6000000);
>> +
>> +	/* DBGU on ttyS0. (Rx & Tx only) */
>> +	at91_register_uart(0, 0, 0);
>> +
>> +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
>> +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
>> +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
>> +			   | ATMEL_UART_RI);
>> +
>> +	/* USART1 on ttyS2. (Rx, Tx, RTS) */
>> +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
>> +
>> +	/* USART2 on ttyS3. (Rx, Tx, RTS) */
>> +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
>> +
>> +	/* USART3 on ttyS4. (Rx, Tx, RTS) */
>> +	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
>> +
>> +	/* USART4 on ttyS5. (Tx) */
>> +	/* EBUS - transmit audio, no rx */
>> +	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
>> +
>> +	/* set serial console to ttyS0 (ie, DBGU) */
>> +	at91_set_serial_console(0);
>> +}
>> +
>> +static void __init cdu_init_irq(void)
>> +{
>> +	at91sam9260_init_interrupts(NULL);
>> +}
>> +
>> +/*
>> + * USB Host port
>> + */
>> +static struct at91_usbh_data __initdata cdu_usbh_data = {
>> +	.ports		= 2,
>> +};
>> +
>> +/*
>> + * USB Device port
>> + */
>> +static struct at91_udc_data __initdata cdu_udc_data = {
>> +	.vbus_pin	= AT91_PIN_PC15,
>> +	.pullup_pin	= 0,		/* pull-up driven by UDC */
>> +};
>> +
>> +/*
>> + * SPI devices.
>> + */
>> +#define MCP23S08_GPIO_BASE	128
>> +
>> +static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
>> +	.chip[0].is_present	= true,
>> +	.chip[0].pullups	= 0,
>> +	.base			= MCP23S08_GPIO_BASE,
>> +};
>> +
>> +static struct spi_board_info cdu_spi_devices[] = {
>> +	{ /* ADC LTC2488 */
>> +		.modalias	= "spidev",
>> +		.chip_select	= 0,
>> +		.max_speed_hz	= 1 * 1000 * 1000,
>> +		.bus_num	= 1,
>> +	},
>> +	{ /* GPIO expander MCP23S08 */
>> +		.modalias	= "mcp23s08",
>> +		.chip_select	= 1,
>> +		.max_speed_hz	= 1000000,
>> +		.bus_num	= 1,
>> +		.platform_data	= &mcp23s08_gpio_info,
>> +		.mode		= SPI_MODE_3,
>> +	},
>> +	{ /* non volatile memory (F-RAM) FM25VN10 */
>> +		.modalias	= "spidev",
>> +		.chip_select	= 2,
>> +		.max_speed_hz	= 1 * 1000 * 1000,
>> +		.bus_num	= 1,
>> +	},
>> +	{ /* audiocodec TLV320AIC3106 */
>> +		.modalias	= "tlv320aic3x-codec",
>> +		.chip_select	= 3,
>> +		.max_speed_hz	= 1000000,
>> +		.bus_num	= 1,
>> +		.mode		= SPI_MODE_1,
>> +	},
>> +};
>> +
>> +/*
>> + * MACB Ethernet device
>> + */
>> +static struct at91_eth_data __initdata cdu_macb_data = {
>> +	.phy_irq_pin	= 0, //nc,
> 
> Don't use // comments. This line can just be deleted since it default to
> zero.
I'd like to keep this lines to explicitly see not connected pins.

> 
>> +	.is_rmii	= 1,
>> +};
>> +
>> +/*
>> + * NAND flash
>> + */
>> +static struct mtd_partition __initdata cdu_nand_partition[] = {
>> +	{
>> +		.name   = "bootstrap",
>> +		.offset = 0,
>> +	  .size   = 0x40000,
> 
> Tabbing is messed here.
> 
>> +	},
>> +	{
>> +		.name   = "uboot",
>> +		.offset = 0x40000,
> 
> You can use MTDPART_OFS_NXTBLK for the offset to align this partition
> immediately after the previous one.
> 
>> +		.size   = (0xc0000 - 0x40000),
> 
> What's with the odd sizes? You should use the sizes from asm/sizes.h.
Used sizes and offsets.

> 
>> +	},
>> +	{
>> +		.name   = "ubootenv",
>> +		.offset = 0xc0000,
>> +		.size   = (0x100000 - 0xc0000),
>> +	},
>> +	{
>> +		.name   = "kernel",
>> +		.offset = 0x100000,
>> +		.size   = (0x400000 - 0x100000),
>> +	},
>> +	{
>> +		.name   = "rootfs",
>> +		.offset = 0x400000,
>> +		.size   = (0x8000000 - 0x400000),
>> +	},
>> +};
>> +
>> +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
>> +{
>> +	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
>> +	return cdu_nand_partition;
>> +}
>> +
>> +static struct atmel_nand_data __initdata cdu_nand_data = {
>> +	.ale		= 21,
>> +	.cle		= 22,
>> +//	.det_pin	= ... not connected
> 
> Delete this line.
> 
>> +	.rdy_pin	= AT91_PIN_PC13,
>> +	.enable_pin	= AT91_PIN_PC14,
>> +	.partition_info	= nand_partitions,
>> +	.bus_width_16	= 0,
>> +};
>> +
>> +static struct sam9_smc_config __initdata cdu_nand_smc_config = {
>> +	.ncs_read_setup		= 0,
>> +	.nrd_setup		= 1,
>> +	.ncs_write_setup	= 0,
>> +	.nwe_setup		= 1,
>> +
>> +	.ncs_read_pulse		= 3,
>> +	.nrd_pulse		= 3,
>> +	.ncs_write_pulse	= 3,
>> +	.nwe_pulse		= 3,
>> +
>> +	.read_cycle		= 5,
>> +	.write_cycle		= 5,
>> +
>> +	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
>> +	.tdf_cycles		= 2,
>> +};
>> +
>> +static void __init cdu_add_device_nand(void)
>> +{
>> +	/* setup bus-width (8 or 16) */
>> +	if (cdu_nand_data.bus_width_16)
>> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_16;
>> +	else
>> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;
> 
> bus_width_16 is explicitly set to zero above, so this logic should not
> be needed.
> 
Removed.

>> +	/* configure chip-select 3 (NAND) */
>> +	sam9_smc_configure(3, &cdu_nand_smc_config);
>> +
>> +	at91_add_device_nand(&cdu_nand_data);
>> +}
>> +
>> +/*
>> +* MCI (SD/MMC)
>> +*/
>> +static struct at91_mmc_data __initdata ek_mmc_data = {
>> +  .slot_b		= 0,
>> +  .wire4		= 1,
>> +  //	.det_pin	= ... not connected
>> +  //	.wp_pin		= ... not connected
>> +  //	.vcc_pin	= ... not connected
> 
> Delete these lines.
> 
>> +};
>> +
>> +/*
>> + * LEDs
>> + */
>> +static struct gpio_led cdu_leds[] = {
>> +	{
>> +		.name			= "red",
>> +		.gpio			= AT91_PIN_PC10,
>> +		.default_trigger	= "timer",
>> +	},
>> +	{
>> +		.name			= "green",
>> +		.gpio			= AT91_PIN_PA5,
>> +		.default_trigger	= "heartbeat",
>> +	},
>> +	{
>> +		.name			= "yellow",
>> +		.gpio			= AT91_PIN_PB20,
>> +		.active_low		= 1,
>> +		.default_trigger	= "mmc0",
>> +	},
>> +	{
>> +		.name			= "blue",
>> +		.gpio			= AT91_PIN_PB21,
>> +		.active_low		= 1,
>> +		.default_trigger	= "nand-disk",
>> +	},
>> +};
>> +
>> +/*
>> + * GPIOs
>> + */
>> +static struct gpio gpios[] = {
>> +	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
>> +	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
>> +	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
>> +	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
>> +	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
>> +	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
>> +
>> +	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
>> +	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
>> +	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
>> +	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
>> +	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
>> +	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
>> +
>> +	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
>> +	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
>> +	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
>> +	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
>> +	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
>> +	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
>> +
>> +	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
>> +	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
>> +	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
>> +	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
>> +	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
>> +	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
>> +	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
>> +};
>> +
>> +static void __init cdu_add_gpio (void)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE (gpios); i++) {
>> +		gpio_request_one (gpios[i].gpio, gpios[i].flags, gpios[i].label);
>> +	}
> 
> Nitpick, don't need braces on the for loop here. Also, remove the spaces
> between cdu_add_gpiop, ARRAY_SIZE, and gpio_request_one and their
> opening parenthesis.
> 
There are two lines now.

>> +}
>> +
>> +/*
>> + * init
>> + */
>> +static void __init cdu_board_init(void)
>> +{
>> +	/* Serial */
>> +	at91_add_device_serial();
>> +	/* USB Host */
>> +	at91_add_device_usbh(&cdu_usbh_data);
>> +	/* USB Device */
>> +	at91_add_device_udc(&cdu_udc_data);
>> +	/* SPI */
>> +	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
>> +	/* NAND */
>> +	cdu_add_device_nand();
>> +	/* Ethernet */
>> +	at91_add_device_eth(&cdu_macb_data);
>> +	/* MMC */
>> +	at91_add_device_mmc(0, &ek_mmc_data);
>> +	/* SSC */
>> +	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
>> +	/* LEDs */
>> +	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
>> +	// GPIO
>> +	cdu_add_gpio ();
> 
> I might be a bit alone on this, but I find this cut and paste comment
> style for the at91 device initialisation awful. The function names are
> very self explanatory and the comments only serve to make the init code
> more difficult to read. Also, remove the // comment.
> 
Removed.

>> +}
>> +
>> +MACHINE_START(AT91SAM9260EK, "CDU")
>> +	/* Maintainer: Atmel */
> 
> Nice of you to assign maintainership of your board to Atmel :-). You
> should possibly add a MAINTAINERS entry for this board.
New maitainer.

> 
>> +	.boot_params	= AT91_SDRAM_BASE + 0x100,
>> +	.timer		= &at91sam926x_timer,
>> +	.map_io		= cdu_map_io,
>> +	.init_irq	= cdu_init_irq,
>> +	.init_machine	= cdu_board_init,
>> +MACHINE_END
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig
>> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
>> @@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
>>  	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
>>  	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
>>
>> +config MACH_CDU
>> +	bool "CDU AKsignal board"
>> +	help
>> +	  Select this if you are using AKsignal CDU board
>> +	  <http://www.aksignal.cz>
>> +
>>  config MACH_CAM60
>>  	bool "KwikByte KB9260 (CAM60) board"
>>  	help
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile
>> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
>> @@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92
>>
>>  # AT91SAM9260 board-specific support
>>  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
>> +obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
>>  obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
>>  obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
>>  obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o
> 
> The first patch, adding just the support for the cdu board should end here.
> 

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c
--- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c	2011-03-28 15:52:03.413048601 +0200
@@ -0,0 +1,332 @@
+/*
+ * linux/arch/arm/mach-at91/board-cdu.c
+ *
+ *  Copyright (C) 2005 SAN People
+ *  Copyright (C) 2006 Atmel
+ *  Copyright (C) 2011 AKsignal Brno
+ *                     jiri.prchal at aksignal.cz
+ *
+ * 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 <linux/types.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/clk.h>
+#include <linux/spi/mcp23s08.h>
+#include <linux/dma-mapping.h>
+
+#include <mach/hardware.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/irq.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/at91sam9_smc.h>
+
+#include "sam9_smc.h"
+#include "generic.h"
+
+static void __init cdu_map_io(void)
+{
+	/* Initialize processor: 6 MHz crystal */
+	at91sam9260_initialize(6000000);
+
+	/* DBGU on ttyS0. (Rx & Tx only) */
+	at91_register_uart(0, 0, 0);
+
+	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
+	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
+			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
+			   | ATMEL_UART_RI);
+
+	/* USART1 on ttyS2. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
+
+	/* USART2 on ttyS3. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
+
+	/* USART3 on ttyS4. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
+
+	/* USART4 on ttyS5. (Tx) */
+	/* EBUS - transmit audio, no rx */
+	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
+
+	/* set serial console to ttyS0 (ie, DBGU) */
+	at91_set_serial_console(0);
+}
+
+static void __init cdu_init_irq(void)
+{
+	at91sam9260_init_interrupts(NULL);
+}
+
+/*
+ * USB Host port
+ */
+static struct at91_usbh_data __initdata cdu_usbh_data = {
+	.ports		= 2,
+};
+
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata cdu_udc_data = {
+	.vbus_pin	= AT91_PIN_PC15,
+	.pullup_pin	= 0,		/* pull-up driven by UDC */
+};
+
+/*
+ * SPI devices.
+ */
+#define MCP23S08_GPIO_BASE	128
+
+static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
+	.chip[0].is_present	= true,
+	.chip[0].pullups	= 0,
+	.base			= MCP23S08_GPIO_BASE,
+};
+
+static struct spi_board_info cdu_spi_devices[] = {
+	{ /* ADC LTC2488 */
+		.modalias	= "spidev",
+		.chip_select	= 0,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 1,
+	},
+	{ /* GPIO expander MCP23S08 */
+		.modalias	= "mcp23s08",
+		.chip_select	= 1,
+		.max_speed_hz	= 1000000,
+		.bus_num	= 1,
+		.platform_data	= &mcp23s08_gpio_info,
+		.mode		= SPI_MODE_3,
+	},
+	{ /* non volatile memory (F-RAM) FM25VN10 */
+		.modalias	= "spidev",
+		.chip_select	= 2,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 1,
+	},
+	{ /* audiocodec TLV320AIC3106 */
+		.modalias	= "tlv320aic3x-codec",
+		.chip_select	= 3,
+		.max_speed_hz	= 1000000,
+		.bus_num	= 1,
+		.mode		= SPI_MODE_1,
+	},
+};
+
+/*
+ * MACB Ethernet device
+ */
+static struct at91_eth_data __initdata cdu_macb_data = {
+	/*.phy_irq_pin	= ... not connected */
+	.is_rmii	= 1,
+};
+
+/*
+ * NAND flash
+ */
+static struct mtd_partition __initdata cdu_nand_partition[] = {
+	{
+		.name   = "bootstrap",
+		.offset = 0,
+		.size   = SZ_256K,
+	},
+	{
+		.name   = "uboot",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = SZ_512K,
+	},
+	{
+		.name   = "ubootenv",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = SZ_256K,
+	},
+	{
+		.name   = "kernel",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = SZ_4M,
+	},
+	{
+		.name   = "rootfs",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = MTDPART_SIZ_FULL,
+	},
+};
+
+static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
+{
+	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
+	return cdu_nand_partition;
+}
+
+static struct atmel_nand_data __initdata cdu_nand_data = {
+	.ale		= 21,
+	.cle		= 22,
+	/*.det_pin	= ... not connected */
+	.rdy_pin	= AT91_PIN_PC13,
+	.enable_pin	= AT91_PIN_PC14,
+	.partition_info	= nand_partitions,
+	.bus_width_16	= 0,
+};
+
+static struct sam9_smc_config __initdata cdu_nand_smc_config = {
+	.ncs_read_setup		= 0,
+	.nrd_setup		= 1,
+	.ncs_write_setup	= 0,
+	.nwe_setup		= 1,
+
+	.ncs_read_pulse		= 3,
+	.nrd_pulse		= 3,
+	.ncs_write_pulse	= 3,
+	.nwe_pulse		= 3,
+
+	.read_cycle		= 5,
+	.write_cycle		= 5,
+
+	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
+	.tdf_cycles		= 2,
+};
+
+static void __init cdu_add_device_nand(void)
+{
+	/* setup bus-width 8 */
+	cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;
+
+	/* configure chip-select 3 (NAND) */
+	sam9_smc_configure(3, &cdu_nand_smc_config);
+
+	at91_add_device_nand(&cdu_nand_data);
+}
+
+/*
+* MCI (SD/MMC)
+*/
+static struct at91_mmc_data __initdata ek_mmc_data = {
+	.slot_b		= 0,
+	.wire4		= 1,
+	/*.det_pin	= ... not connected */
+	/*.wp_pin	= ... not connected */
+	/*.vcc_pin	= ... not connected */
+};
+
+/*
+ * LEDs
+ */
+static struct gpio_led cdu_leds[] = {
+	{
+		.name			= "red",
+		.gpio			= AT91_PIN_PC10,
+		.default_trigger	= "timer",
+	},
+	{
+		.name			= "green",
+		.gpio			= AT91_PIN_PA5,
+		.default_trigger	= "heartbeat",
+	},
+	{
+		.name			= "yellow",
+		.gpio			= AT91_PIN_PB20,
+		.active_low		= 1,
+		.default_trigger	= "mmc0",
+	},
+	{
+		.name			= "blue",
+		.gpio			= AT91_PIN_PB21,
+		.active_low		= 1,
+		.default_trigger	= "nand-disk",
+	},
+};
+
+/*
+ * GPIOs
+ */
+static struct gpio gpios[] = {
+	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
+	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
+	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
+	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
+	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
+	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
+
+	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
+	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
+	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
+	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
+	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
+	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
+
+	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
+	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
+	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
+	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
+	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
+	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
+
+	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
+	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
+	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
+	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
+	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
+	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
+	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
+};
+
+static void __init cdu_add_gpio(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
+		gpio_request_one(gpios[i].gpio, gpios[i].flags, gpios[i].label);
+		gpio_export_name(gpios[i].gpio, 0, gpios[i].label);
+	}
+}
+
+/*
+ * init
+ */
+static void __init cdu_board_init(void)
+{
+	at91_add_device_serial();
+	at91_add_device_usbh(&cdu_usbh_data);
+	at91_add_device_udc(&cdu_udc_data);
+	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
+	cdu_add_device_nand();
+	at91_add_device_eth(&cdu_macb_data);
+	at91_add_device_mmc(0, &ek_mmc_data);
+	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
+	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
+	cdu_add_gpio ();
+}
+
+MACHINE_START(AT91SAM9260EK, "CDU")
+	/* Maintainer: AKsignal Brno */
+	.boot_params	= AT91_SDRAM_BASE + 0x100,
+	.timer		= &at91sam926x_timer,
+	.map_io		= cdu_map_io,
+	.init_irq	= cdu_init_irq,
+	.init_machine	= cdu_board_init,
+MACHINE_END
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
linux-2.6.38-patch/arch/arm/mach-at91/Kconfig
--- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
@@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
 	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
 	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>

+config MACH_CDU
+	bool "CDU AKsignal board"
+	help
+	  Select this if you are using AKsignal CDU board
+	  <http://www.aksignal.cz>
+
 config MACH_CAM60
 	bool "KwikByte KB9260 (CAM60) board"
 	help
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
linux-2.6.38-patch/arch/arm/mach-at91/Makefile
--- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
@@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92

 # AT91SAM9260 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
+obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
 obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
 obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
 obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/MAINTAINERS linux-2.6.38-patch/MAINTAINERS
--- linux-2.6.38-vanilla/MAINTAINERS	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/MAINTAINERS	2011-03-25 08:37:56.693049978 +0100
@@ -1640,6 +1640,13 @@ F:	include/linux/can/error.h
 F:	include/linux/can/netlink.h
 F:	include/linux/can/platform/

+CDU BOARD
+M:	Jiri Prchal <jiri.prchal@aksignal.cz>
+L:	linux-arch at vger.kernel.org
+W:	http://www.linux4sam.org
+S:	Supported
+F:	arch/arm/mach-at91/
+
 CELL BROADBAND ENGINE ARCHITECTURE
 M:	Arnd Bergmann <arnd@arndb.de>
 L:	linuxppc-dev at lists.ozlabs.org
Soubory linux-2.6.38-vanilla/scripts/recordmcount a linux-2.6.38-patch/scripts/recordmcount jsou r??zn??

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] ARCH arm: adding new board: CDU
@ 2011-04-04  9:10         ` Prchal Jiří
  0 siblings, 0 replies; 31+ messages in thread
From: Prchal Jiří @ 2011-04-04  9:10 UTC (permalink / raw)
  To: Ryan Mallon, linux-arm-kernel
  Cc: linux, nicolas.ferre, plagnioj, linux-kernel

Hi,
this is separated PATCH adding new board CDU.

Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
	[PATCH] ALSA: ASoc: new functions snd_soc_7_8_*
	[PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
Kernel version: 2.6.38
Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>

Dne 24.3.2011 21:07, Ryan Mallon napsal(a):
> On 03/24/2011 11:43 PM, Prchal Jiří wrote:
>> Hi,
>> this patch is for example how to put together AT91SAM9260 and TLV320AIC3106 controlled via SPI.
>> It tooks me a lot of time to make it working, so I think it could be helpfull for other people.
>>
>> In original source "snd-soc-afeb9260.c" which I use as example is BIG ERROR:
>> In function "afeb9260_soc_init" is missing call of "atmel_ssc_set_audio(0);". It cause bug "PROBLEM: Asoc driver in
>> 2.6.37.3 for AT91SAM9260 / TLV320AIC3X is broken" which I post some time ago.
> 
> Hi Jiri,
> 
> This patch is actually doing two things: adding board support for a new
> at91sam9260 device and adding the audio glue for the new board. It
> should be split into two patches. Quick review below.
> 
> ~Ryan
> 
>>
>> Depend on: [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK
>> Kernel version: 2.6.38
>> Signed-off-by: Jiri Prchal <jiri.prchal@aksignal.cz>
>> ---
>>
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c
>> --- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/board-cdu.c	2011-03-24 09:15:23.852370981 +0100
>> @@ -0,0 +1,345 @@
>> +/*
>> + * linux/arch/arm/mach-at91/board-cdu.c
>> + *
>> + *  Copyright (C) 2005 SAN People
>> + *  Copyright (C) 2006 Atmel
>> + *  Copyright (C) 2011 AKsignal Brno
>> + *                     jiri.prchal@aksignal.cz
>> + *
>> + * 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 <linux/types.h>
>> +#include <linux/init.h>
>> +#include <linux/mm.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/spi/spi.h>
>> +#include <linux/clk.h>
>> +#include <linux/spi/mcp23s08.h>
>> +#include <linux/dma-mapping.h>
>> +
>> +#include <mach/hardware.h>
>> +#include <asm/setup.h>
>> +#include <asm/mach-types.h>
>> +#include <asm/irq.h>
>> +
>> +#include <asm/mach/arch.h>
>> +#include <asm/mach/map.h>
>> +#include <asm/mach/irq.h>
>> +
>> +#include <mach/board.h>
>> +#include <mach/gpio.h>
>> +#include <mach/at91sam9_smc.h>
>> +
>> +#include "sam9_smc.h"
>> +#include "generic.h"
>> +
>> +static void __init cdu_map_io(void)
>> +{
>> +	/* Initialize processor: 6 MHz crystal */
>> +	at91sam9260_initialize(6000000);
>> +
>> +	/* DBGU on ttyS0. (Rx & Tx only) */
>> +	at91_register_uart(0, 0, 0);
>> +
>> +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
>> +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
>> +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
>> +			   | ATMEL_UART_RI);
>> +
>> +	/* USART1 on ttyS2. (Rx, Tx, RTS) */
>> +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
>> +
>> +	/* USART2 on ttyS3. (Rx, Tx, RTS) */
>> +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
>> +
>> +	/* USART3 on ttyS4. (Rx, Tx, RTS) */
>> +	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
>> +
>> +	/* USART4 on ttyS5. (Tx) */
>> +	/* EBUS - transmit audio, no rx */
>> +	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
>> +
>> +	/* set serial console to ttyS0 (ie, DBGU) */
>> +	at91_set_serial_console(0);
>> +}
>> +
>> +static void __init cdu_init_irq(void)
>> +{
>> +	at91sam9260_init_interrupts(NULL);
>> +}
>> +
>> +/*
>> + * USB Host port
>> + */
>> +static struct at91_usbh_data __initdata cdu_usbh_data = {
>> +	.ports		= 2,
>> +};
>> +
>> +/*
>> + * USB Device port
>> + */
>> +static struct at91_udc_data __initdata cdu_udc_data = {
>> +	.vbus_pin	= AT91_PIN_PC15,
>> +	.pullup_pin	= 0,		/* pull-up driven by UDC */
>> +};
>> +
>> +/*
>> + * SPI devices.
>> + */
>> +#define MCP23S08_GPIO_BASE	128
>> +
>> +static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
>> +	.chip[0].is_present	= true,
>> +	.chip[0].pullups	= 0,
>> +	.base			= MCP23S08_GPIO_BASE,
>> +};
>> +
>> +static struct spi_board_info cdu_spi_devices[] = {
>> +	{ /* ADC LTC2488 */
>> +		.modalias	= "spidev",
>> +		.chip_select	= 0,
>> +		.max_speed_hz	= 1 * 1000 * 1000,
>> +		.bus_num	= 1,
>> +	},
>> +	{ /* GPIO expander MCP23S08 */
>> +		.modalias	= "mcp23s08",
>> +		.chip_select	= 1,
>> +		.max_speed_hz	= 1000000,
>> +		.bus_num	= 1,
>> +		.platform_data	= &mcp23s08_gpio_info,
>> +		.mode		= SPI_MODE_3,
>> +	},
>> +	{ /* non volatile memory (F-RAM) FM25VN10 */
>> +		.modalias	= "spidev",
>> +		.chip_select	= 2,
>> +		.max_speed_hz	= 1 * 1000 * 1000,
>> +		.bus_num	= 1,
>> +	},
>> +	{ /* audiocodec TLV320AIC3106 */
>> +		.modalias	= "tlv320aic3x-codec",
>> +		.chip_select	= 3,
>> +		.max_speed_hz	= 1000000,
>> +		.bus_num	= 1,
>> +		.mode		= SPI_MODE_1,
>> +	},
>> +};
>> +
>> +/*
>> + * MACB Ethernet device
>> + */
>> +static struct at91_eth_data __initdata cdu_macb_data = {
>> +	.phy_irq_pin	= 0, //nc,
> 
> Don't use // comments. This line can just be deleted since it default to
> zero.
I'd like to keep this lines to explicitly see not connected pins.

> 
>> +	.is_rmii	= 1,
>> +};
>> +
>> +/*
>> + * NAND flash
>> + */
>> +static struct mtd_partition __initdata cdu_nand_partition[] = {
>> +	{
>> +		.name   = "bootstrap",
>> +		.offset = 0,
>> +	  .size   = 0x40000,
> 
> Tabbing is messed here.
> 
>> +	},
>> +	{
>> +		.name   = "uboot",
>> +		.offset = 0x40000,
> 
> You can use MTDPART_OFS_NXTBLK for the offset to align this partition
> immediately after the previous one.
> 
>> +		.size   = (0xc0000 - 0x40000),
> 
> What's with the odd sizes? You should use the sizes from asm/sizes.h.
Used sizes and offsets.

> 
>> +	},
>> +	{
>> +		.name   = "ubootenv",
>> +		.offset = 0xc0000,
>> +		.size   = (0x100000 - 0xc0000),
>> +	},
>> +	{
>> +		.name   = "kernel",
>> +		.offset = 0x100000,
>> +		.size   = (0x400000 - 0x100000),
>> +	},
>> +	{
>> +		.name   = "rootfs",
>> +		.offset = 0x400000,
>> +		.size   = (0x8000000 - 0x400000),
>> +	},
>> +};
>> +
>> +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
>> +{
>> +	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
>> +	return cdu_nand_partition;
>> +}
>> +
>> +static struct atmel_nand_data __initdata cdu_nand_data = {
>> +	.ale		= 21,
>> +	.cle		= 22,
>> +//	.det_pin	= ... not connected
> 
> Delete this line.
> 
>> +	.rdy_pin	= AT91_PIN_PC13,
>> +	.enable_pin	= AT91_PIN_PC14,
>> +	.partition_info	= nand_partitions,
>> +	.bus_width_16	= 0,
>> +};
>> +
>> +static struct sam9_smc_config __initdata cdu_nand_smc_config = {
>> +	.ncs_read_setup		= 0,
>> +	.nrd_setup		= 1,
>> +	.ncs_write_setup	= 0,
>> +	.nwe_setup		= 1,
>> +
>> +	.ncs_read_pulse		= 3,
>> +	.nrd_pulse		= 3,
>> +	.ncs_write_pulse	= 3,
>> +	.nwe_pulse		= 3,
>> +
>> +	.read_cycle		= 5,
>> +	.write_cycle		= 5,
>> +
>> +	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
>> +	.tdf_cycles		= 2,
>> +};
>> +
>> +static void __init cdu_add_device_nand(void)
>> +{
>> +	/* setup bus-width (8 or 16) */
>> +	if (cdu_nand_data.bus_width_16)
>> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_16;
>> +	else
>> +		cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;
> 
> bus_width_16 is explicitly set to zero above, so this logic should not
> be needed.
> 
Removed.

>> +	/* configure chip-select 3 (NAND) */
>> +	sam9_smc_configure(3, &cdu_nand_smc_config);
>> +
>> +	at91_add_device_nand(&cdu_nand_data);
>> +}
>> +
>> +/*
>> +* MCI (SD/MMC)
>> +*/
>> +static struct at91_mmc_data __initdata ek_mmc_data = {
>> +  .slot_b		= 0,
>> +  .wire4		= 1,
>> +  //	.det_pin	= ... not connected
>> +  //	.wp_pin		= ... not connected
>> +  //	.vcc_pin	= ... not connected
> 
> Delete these lines.
> 
>> +};
>> +
>> +/*
>> + * LEDs
>> + */
>> +static struct gpio_led cdu_leds[] = {
>> +	{
>> +		.name			= "red",
>> +		.gpio			= AT91_PIN_PC10,
>> +		.default_trigger	= "timer",
>> +	},
>> +	{
>> +		.name			= "green",
>> +		.gpio			= AT91_PIN_PA5,
>> +		.default_trigger	= "heartbeat",
>> +	},
>> +	{
>> +		.name			= "yellow",
>> +		.gpio			= AT91_PIN_PB20,
>> +		.active_low		= 1,
>> +		.default_trigger	= "mmc0",
>> +	},
>> +	{
>> +		.name			= "blue",
>> +		.gpio			= AT91_PIN_PB21,
>> +		.active_low		= 1,
>> +		.default_trigger	= "nand-disk",
>> +	},
>> +};
>> +
>> +/*
>> + * GPIOs
>> + */
>> +static struct gpio gpios[] = {
>> +	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
>> +	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
>> +	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
>> +	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
>> +	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
>> +	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
>> +
>> +	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
>> +	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
>> +	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
>> +	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
>> +	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
>> +	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
>> +
>> +	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
>> +	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
>> +	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
>> +	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
>> +	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
>> +	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
>> +
>> +	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
>> +	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
>> +	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
>> +	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
>> +	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
>> +	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
>> +	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
>> +};
>> +
>> +static void __init cdu_add_gpio (void)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < ARRAY_SIZE (gpios); i++) {
>> +		gpio_request_one (gpios[i].gpio, gpios[i].flags, gpios[i].label);
>> +	}
> 
> Nitpick, don't need braces on the for loop here. Also, remove the spaces
> between cdu_add_gpiop, ARRAY_SIZE, and gpio_request_one and their
> opening parenthesis.
> 
There are two lines now.

>> +}
>> +
>> +/*
>> + * init
>> + */
>> +static void __init cdu_board_init(void)
>> +{
>> +	/* Serial */
>> +	at91_add_device_serial();
>> +	/* USB Host */
>> +	at91_add_device_usbh(&cdu_usbh_data);
>> +	/* USB Device */
>> +	at91_add_device_udc(&cdu_udc_data);
>> +	/* SPI */
>> +	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
>> +	/* NAND */
>> +	cdu_add_device_nand();
>> +	/* Ethernet */
>> +	at91_add_device_eth(&cdu_macb_data);
>> +	/* MMC */
>> +	at91_add_device_mmc(0, &ek_mmc_data);
>> +	/* SSC */
>> +	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
>> +	/* LEDs */
>> +	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
>> +	// GPIO
>> +	cdu_add_gpio ();
> 
> I might be a bit alone on this, but I find this cut and paste comment
> style for the at91 device initialisation awful. The function names are
> very self explanatory and the comments only serve to make the init code
> more difficult to read. Also, remove the // comment.
> 
Removed.

>> +}
>> +
>> +MACHINE_START(AT91SAM9260EK, "CDU")
>> +	/* Maintainer: Atmel */
> 
> Nice of you to assign maintainership of your board to Atmel :-). You
> should possibly add a MAINTAINERS entry for this board.
New maitainer.

> 
>> +	.boot_params	= AT91_SDRAM_BASE + 0x100,
>> +	.timer		= &at91sam926x_timer,
>> +	.map_io		= cdu_map_io,
>> +	.init_irq	= cdu_init_irq,
>> +	.init_machine	= cdu_board_init,
>> +MACHINE_END
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig
>> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
>> @@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
>>  	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
>>  	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
>>
>> +config MACH_CDU
>> +	bool "CDU AKsignal board"
>> +	help
>> +	  Select this if you are using AKsignal CDU board
>> +	  <http://www.aksignal.cz>
>> +
>>  config MACH_CAM60
>>  	bool "KwikByte KB9260 (CAM60) board"
>>  	help
>> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
>> /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile
>> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
>> +++ /home/prchal/arm/fw-cdu/linux/linux-2.6.38/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
>> @@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92
>>
>>  # AT91SAM9260 board-specific support
>>  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
>> +obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
>>  obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
>>  obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
>>  obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o
> 
> The first patch, adding just the support for the cdu board should end here.
> 

diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c
--- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c	2011-03-28 15:52:03.413048601 +0200
@@ -0,0 +1,332 @@
+/*
+ * linux/arch/arm/mach-at91/board-cdu.c
+ *
+ *  Copyright (C) 2005 SAN People
+ *  Copyright (C) 2006 Atmel
+ *  Copyright (C) 2011 AKsignal Brno
+ *                     jiri.prchal@aksignal.cz
+ *
+ * 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 <linux/types.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/spi/spi.h>
+#include <linux/clk.h>
+#include <linux/spi/mcp23s08.h>
+#include <linux/dma-mapping.h>
+
+#include <mach/hardware.h>
+#include <asm/setup.h>
+#include <asm/mach-types.h>
+#include <asm/irq.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <mach/board.h>
+#include <mach/gpio.h>
+#include <mach/at91sam9_smc.h>
+
+#include "sam9_smc.h"
+#include "generic.h"
+
+static void __init cdu_map_io(void)
+{
+	/* Initialize processor: 6 MHz crystal */
+	at91sam9260_initialize(6000000);
+
+	/* DBGU on ttyS0. (Rx & Tx only) */
+	at91_register_uart(0, 0, 0);
+
+	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
+	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
+			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
+			   | ATMEL_UART_RI);
+
+	/* USART1 on ttyS2. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
+
+	/* USART2 on ttyS3. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
+
+	/* USART3 on ttyS4. (Rx, Tx, RTS) */
+	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
+
+	/* USART4 on ttyS5. (Tx) */
+	/* EBUS - transmit audio, no rx */
+	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
+
+	/* set serial console to ttyS0 (ie, DBGU) */
+	at91_set_serial_console(0);
+}
+
+static void __init cdu_init_irq(void)
+{
+	at91sam9260_init_interrupts(NULL);
+}
+
+/*
+ * USB Host port
+ */
+static struct at91_usbh_data __initdata cdu_usbh_data = {
+	.ports		= 2,
+};
+
+/*
+ * USB Device port
+ */
+static struct at91_udc_data __initdata cdu_udc_data = {
+	.vbus_pin	= AT91_PIN_PC15,
+	.pullup_pin	= 0,		/* pull-up driven by UDC */
+};
+
+/*
+ * SPI devices.
+ */
+#define MCP23S08_GPIO_BASE	128
+
+static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
+	.chip[0].is_present	= true,
+	.chip[0].pullups	= 0,
+	.base			= MCP23S08_GPIO_BASE,
+};
+
+static struct spi_board_info cdu_spi_devices[] = {
+	{ /* ADC LTC2488 */
+		.modalias	= "spidev",
+		.chip_select	= 0,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 1,
+	},
+	{ /* GPIO expander MCP23S08 */
+		.modalias	= "mcp23s08",
+		.chip_select	= 1,
+		.max_speed_hz	= 1000000,
+		.bus_num	= 1,
+		.platform_data	= &mcp23s08_gpio_info,
+		.mode		= SPI_MODE_3,
+	},
+	{ /* non volatile memory (F-RAM) FM25VN10 */
+		.modalias	= "spidev",
+		.chip_select	= 2,
+		.max_speed_hz	= 1 * 1000 * 1000,
+		.bus_num	= 1,
+	},
+	{ /* audiocodec TLV320AIC3106 */
+		.modalias	= "tlv320aic3x-codec",
+		.chip_select	= 3,
+		.max_speed_hz	= 1000000,
+		.bus_num	= 1,
+		.mode		= SPI_MODE_1,
+	},
+};
+
+/*
+ * MACB Ethernet device
+ */
+static struct at91_eth_data __initdata cdu_macb_data = {
+	/*.phy_irq_pin	= ... not connected */
+	.is_rmii	= 1,
+};
+
+/*
+ * NAND flash
+ */
+static struct mtd_partition __initdata cdu_nand_partition[] = {
+	{
+		.name   = "bootstrap",
+		.offset = 0,
+		.size   = SZ_256K,
+	},
+	{
+		.name   = "uboot",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = SZ_512K,
+	},
+	{
+		.name   = "ubootenv",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = SZ_256K,
+	},
+	{
+		.name   = "kernel",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = SZ_4M,
+	},
+	{
+		.name   = "rootfs",
+		.offset = MTDPART_OFS_APPEND,
+		.size   = MTDPART_SIZ_FULL,
+	},
+};
+
+static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
+{
+	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
+	return cdu_nand_partition;
+}
+
+static struct atmel_nand_data __initdata cdu_nand_data = {
+	.ale		= 21,
+	.cle		= 22,
+	/*.det_pin	= ... not connected */
+	.rdy_pin	= AT91_PIN_PC13,
+	.enable_pin	= AT91_PIN_PC14,
+	.partition_info	= nand_partitions,
+	.bus_width_16	= 0,
+};
+
+static struct sam9_smc_config __initdata cdu_nand_smc_config = {
+	.ncs_read_setup		= 0,
+	.nrd_setup		= 1,
+	.ncs_write_setup	= 0,
+	.nwe_setup		= 1,
+
+	.ncs_read_pulse		= 3,
+	.nrd_pulse		= 3,
+	.ncs_write_pulse	= 3,
+	.nwe_pulse		= 3,
+
+	.read_cycle		= 5,
+	.write_cycle		= 5,
+
+	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
+	.tdf_cycles		= 2,
+};
+
+static void __init cdu_add_device_nand(void)
+{
+	/* setup bus-width 8 */
+	cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;
+
+	/* configure chip-select 3 (NAND) */
+	sam9_smc_configure(3, &cdu_nand_smc_config);
+
+	at91_add_device_nand(&cdu_nand_data);
+}
+
+/*
+* MCI (SD/MMC)
+*/
+static struct at91_mmc_data __initdata ek_mmc_data = {
+	.slot_b		= 0,
+	.wire4		= 1,
+	/*.det_pin	= ... not connected */
+	/*.wp_pin	= ... not connected */
+	/*.vcc_pin	= ... not connected */
+};
+
+/*
+ * LEDs
+ */
+static struct gpio_led cdu_leds[] = {
+	{
+		.name			= "red",
+		.gpio			= AT91_PIN_PC10,
+		.default_trigger	= "timer",
+	},
+	{
+		.name			= "green",
+		.gpio			= AT91_PIN_PA5,
+		.default_trigger	= "heartbeat",
+	},
+	{
+		.name			= "yellow",
+		.gpio			= AT91_PIN_PB20,
+		.active_low		= 1,
+		.default_trigger	= "mmc0",
+	},
+	{
+		.name			= "blue",
+		.gpio			= AT91_PIN_PB21,
+		.active_low		= 1,
+		.default_trigger	= "nand-disk",
+	},
+};
+
+/*
+ * GPIOs
+ */
+static struct gpio gpios[] = {
+	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
+	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
+	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
+	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
+	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
+	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
+
+	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
+	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
+	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
+	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
+	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
+	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
+
+	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
+	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
+	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
+	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
+	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
+	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
+
+	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
+	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
+	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
+	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
+	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
+	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
+	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
+};
+
+static void __init cdu_add_gpio(void)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
+		gpio_request_one(gpios[i].gpio, gpios[i].flags, gpios[i].label);
+		gpio_export_name(gpios[i].gpio, 0, gpios[i].label);
+	}
+}
+
+/*
+ * init
+ */
+static void __init cdu_board_init(void)
+{
+	at91_add_device_serial();
+	at91_add_device_usbh(&cdu_usbh_data);
+	at91_add_device_udc(&cdu_udc_data);
+	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
+	cdu_add_device_nand();
+	at91_add_device_eth(&cdu_macb_data);
+	at91_add_device_mmc(0, &ek_mmc_data);
+	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
+	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
+	cdu_add_gpio ();
+}
+
+MACHINE_START(AT91SAM9260EK, "CDU")
+	/* Maintainer: AKsignal Brno */
+	.boot_params	= AT91_SDRAM_BASE + 0x100,
+	.timer		= &at91sam926x_timer,
+	.map_io		= cdu_map_io,
+	.init_irq	= cdu_init_irq,
+	.init_machine	= cdu_board_init,
+MACHINE_END
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
linux-2.6.38-patch/arch/arm/mach-at91/Kconfig
--- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
@@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
 	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
 	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>

+config MACH_CDU
+	bool "CDU AKsignal board"
+	help
+	  Select this if you are using AKsignal CDU board
+	  <http://www.aksignal.cz>
+
 config MACH_CAM60
 	bool "KwikByte KB9260 (CAM60) board"
 	help
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
linux-2.6.38-patch/arch/arm/mach-at91/Makefile
--- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
@@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92

 # AT91SAM9260 board-specific support
 obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
+obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
 obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
 obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
 obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o
diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/MAINTAINERS linux-2.6.38-patch/MAINTAINERS
--- linux-2.6.38-vanilla/MAINTAINERS	2011-03-15 02:20:32.000000000 +0100
+++ linux-2.6.38-patch/MAINTAINERS	2011-03-25 08:37:56.693049978 +0100
@@ -1640,6 +1640,13 @@ F:	include/linux/can/error.h
 F:	include/linux/can/netlink.h
 F:	include/linux/can/platform/

+CDU BOARD
+M:	Jiri Prchal <jiri.prchal@aksignal.cz>
+L:	linux-arch@vger.kernel.org
+W:	http://www.linux4sam.org
+S:	Supported
+F:	arch/arm/mach-at91/
+
 CELL BROADBAND ENGINE ARCHITECTURE
 M:	Arnd Bergmann <arnd@arndb.de>
 L:	linuxppc-dev@lists.ozlabs.org
Soubory linux-2.6.38-vanilla/scripts/recordmcount a linux-2.6.38-patch/scripts/recordmcount jsou rĹŻznĂŠ

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] ARCH arm: adding new board: CDU
  2011-04-04  9:10         ` Prchal Jiří
@ 2011-04-04  9:16           ` Russell King - ARM Linux
  -1 siblings, 0 replies; 31+ messages in thread
From: Russell King - ARM Linux @ 2011-04-04  9:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 04, 2011 at 11:10:42AM +0200, Prchal Ji?? wrote:
> Hi,
> this is separated PATCH adding new board CDU.

What does this have to do with

"[PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers" ?

which is the message which you hit your mailer's "reply" button on?
Please don't pollute email threads.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] ARCH arm: adding new board: CDU
@ 2011-04-04  9:16           ` Russell King - ARM Linux
  0 siblings, 0 replies; 31+ messages in thread
From: Russell King - ARM Linux @ 2011-04-04  9:16 UTC (permalink / raw)
  To: Prchal Jiří
  Cc: Ryan Mallon, linux-arm-kernel, plagnioj, nicolas.ferre, linux,
	linux-kernel

On Mon, Apr 04, 2011 at 11:10:42AM +0200, Prchal Jiří wrote:
> Hi,
> this is separated PATCH adding new board CDU.

What does this have to do with

"[PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers" ?

which is the message which you hit your mailer's "reply" button on?
Please don't pollute email threads.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] ARCH arm: adding new board: CDU
  2011-04-04  9:16           ` Russell King - ARM Linux
@ 2011-04-04  9:24             ` Russell King - ARM Linux
  -1 siblings, 0 replies; 31+ messages in thread
From: Russell King - ARM Linux @ 2011-04-04  9:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 04, 2011 at 10:16:35AM +0100, Russell King - ARM Linux wrote:
> On Mon, Apr 04, 2011 at 11:10:42AM +0200, Prchal Ji?? wrote:
> > Hi,
> > this is separated PATCH adding new board CDU.
> 
> What does this have to do with
> 
> "[PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers" ?
> 
> which is the message which you hit your mailer's "reply" button on?
> Please don't pollute email threads.

Sorry, it's not as trivial as I thought.  For some reason your mailer is
introducing additional message IDs in the 'References' header which are
causing the message to be incorrectly threaded.  Here are the original
two messages:

From: Simon Horman <horms@verge.net.au>
Subject: [PATCH 0/2] mmc: zboot helpers
Message-Id: <1300949648-15078-1-git-send-email-horms@verge.net.au>

From: Simon Horman <horms@verge.net.au>
Subject: [PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers
Message-Id: <1300949648-15078-2-git-send-email-horms@verge.net.au>

And your messages:

From: Prchal Ji?? <jiri.prchal@aksignal.cz>
Subject: [PATCH] mmc, AT91: fix init fequency problem
References: <1300949648-15078-1-git-send-email-horms@verge.net.au>
        <1300949648-15078-2-git-send-email-horms@verge.net.au>
In-Reply-To: <1300949648-15078-2-git-send-email-horms@verge.net.au>

From: Prchal Ji?? <jiri.prchal@aksignal.cz>
Subject: [PATCH] ARCH arm: adding new board: CDU
References: <1300949648-15078-1-git-send-email-horms@verge.net.au>
        <1300949648-15078-2-git-send-email-horms@verge.net.au>
        <4D8B2068.60402@aksignal.cz> <4D8BA47B.8050904@bluewatersys.com>
In-Reply-To: <4D8BA47B.8050904@bluewatersys.com>

both of which reference Simon's unrelated emails.  No idea how you're
doing that, but both of your messages seem to be completely unrelated
to Simon's two.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] ARCH arm: adding new board: CDU
@ 2011-04-04  9:24             ` Russell King - ARM Linux
  0 siblings, 0 replies; 31+ messages in thread
From: Russell King - ARM Linux @ 2011-04-04  9:24 UTC (permalink / raw)
  To: Prchal Jiří
  Cc: nicolas.ferre, linux-kernel, Ryan Mallon, plagnioj, linux,
	linux-arm-kernel

On Mon, Apr 04, 2011 at 10:16:35AM +0100, Russell King - ARM Linux wrote:
> On Mon, Apr 04, 2011 at 11:10:42AM +0200, Prchal Jiří wrote:
> > Hi,
> > this is separated PATCH adding new board CDU.
> 
> What does this have to do with
> 
> "[PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers" ?
> 
> which is the message which you hit your mailer's "reply" button on?
> Please don't pollute email threads.

Sorry, it's not as trivial as I thought.  For some reason your mailer is
introducing additional message IDs in the 'References' header which are
causing the message to be incorrectly threaded.  Here are the original
two messages:

From: Simon Horman <horms@verge.net.au>
Subject: [PATCH 0/2] mmc: zboot helpers
Message-Id: <1300949648-15078-1-git-send-email-horms@verge.net.au>

From: Simon Horman <horms@verge.net.au>
Subject: [PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM zboot helpers
Message-Id: <1300949648-15078-2-git-send-email-horms@verge.net.au>

And your messages:

From: Prchal Ji■í <jiri.prchal@aksignal.cz>
Subject: [PATCH] mmc, AT91: fix init fequency problem
References: <1300949648-15078-1-git-send-email-horms@verge.net.au>
        <1300949648-15078-2-git-send-email-horms@verge.net.au>
In-Reply-To: <1300949648-15078-2-git-send-email-horms@verge.net.au>

From: Prchal Ji■í <jiri.prchal@aksignal.cz>
Subject: [PATCH] ARCH arm: adding new board: CDU
References: <1300949648-15078-1-git-send-email-horms@verge.net.au>
        <1300949648-15078-2-git-send-email-horms@verge.net.au>
        <4D8B2068.60402@aksignal.cz> <4D8BA47B.8050904@bluewatersys.com>
In-Reply-To: <4D8BA47B.8050904@bluewatersys.com>

both of which reference Simon's unrelated emails.  No idea how you're
doing that, but both of your messages seem to be completely unrelated
to Simon's two.

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
  2011-04-04  8:57       ` Prchal Jiří
@ 2011-04-04 20:07           ` Ryan Mallon
  0 siblings, 0 replies; 31+ messages in thread
From: Ryan Mallon @ 2011-04-04 20:07 UTC (permalink / raw)
  Cc: vbarinov, alsa-devel, alsa-devel, linux-kernel

On 04/04/2011 08:57 PM, Prchal Jiří wrote:
> Hi,
> this is separeted PATCH for glue AT91SAM9260 and TLV320AIC3X on CDU board.

Please repost this (and the other patch) as a new patch with a proper
change log. You should also Cc Liam Girdwood and Mark Brown, who
maintain the SoC audio system and will pick up this patch.

Some more comments below.

~Ryan

<snip>

> 
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Kconfig
> linux-2.6.38-patch/sound/soc/atmel/Kconfig
> --- linux-2.6.38-vanilla/sound/soc/atmel/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/atmel/Kconfig	2011-03-22 09:46:46.751566158 +0100
> @@ -50,3 +50,11 @@ config SND_AT91_SOC_AFEB9260
>  	select SND_SOC_TLV320AIC23
>  	help
>  	  Say Y here to support sound on AFEB9260 board.
> +
> +config SND_AT91_SOC_CDU
> +	tristate "SoC Audio support for CDU board"
> +	depends on ARCH_AT91 && MACH_CDU && SND_ATMEL_SOC
> +	select SND_ATMEL_SOC_SSC
> +	select SND_SOC_TLV320AIC3X
> +	help
> +	  Say Y here to support sound on CDU board.
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Makefile
> linux-2.6.38-patch/sound/soc/atmel/Makefile
> --- linux-2.6.38-vanilla/sound/soc/atmel/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/atmel/Makefile	2011-03-16 09:26:17.000000000 +0100
> @@ -14,3 +14,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o
>  obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
>  obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
>  obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
> +obj-$(CONFIG_SND_AT91_SOC_CDU) += snd-soc-cdu.o
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c
> linux-2.6.38-patch/sound/soc/atmel/snd-soc-cdu.c
> --- linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/atmel/snd-soc-cdu.c	2011-03-25 13:42:07.545051043 +0100
> @@ -0,0 +1,259 @@
> +/*
> + * snd-soc-cdu  --  SoC audio for AT91SAM9260-based
> + * 			AKsignal CDU board.
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2008 Atmel
> + *  Copyright (C) 2011 AK signal Brno
> + *
> + * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
> + *          Jiri Prchal <jiri.prchal@aksignal.cz>
> + *
> + * Based on ati_b1_wm8731.c by:
> + * Frank Mandarino <fmandarino@endrelia.com>
> + * Copyright 2006 Endrelia Technologies Inc.
> + * Based on corgi.c by:
> + * Copyright 2005 Wolfson Microelectronics PLC.
> + * Copyright 2005 Openedhand Ltd.
> + *
> + * 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 <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/clk.h>
> +#include <linux/platform_device.h>
> +
> +#include <linux/atmel-ssc.h>
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
> +
> +#include <asm/mach-types.h>
> +#include <mach/hardware.h>
> +
> +#include "../codecs/tlv320aic3x.h"
> +#include "atmel-pcm.h"
> +#include "atmel_ssc_dai.h"
> +
> +/*
> + * Table of supported rates
> + * with their clock divider (cmrdiv) and number clock in frame (period + 1 * 2),
> + * codecclk sould be integer multiple of sample rate even if it is not exact true
> + * to avoid data on SSC underrun / overrun -
> + * CPU can not generate clock as fine as CODEC.
> + */
> +struct {
> +	unsigned int rate;
> +	unsigned int codecclk;
> +	unsigned int cmrdiv;
> +	unsigned int period;
> +} cdu_audio[] = {

Should be static.

> +	{8000, 2096000, 25, 130,},
> +	{16000, 2496000, 21, 77,},
> +	{32000, 2496000, 21, 38,},
> +	{48000, 2016000, 26, 20,},
> +	{96000, 4032000, 13, 20,},
> +
> +	{11025, 2381400, 22, 107,},
> +	{22050, 2381400, 22, 53,},
> +	{44100, 2381400, 22, 26,},
> +	{88200, 4762800, 11, 26,},
> +
> +	/* special rates for serial line transfer */
> +	{11520, 2626560, 20, 113,},
> +	{23040, 2626560, 20, 56,},
> +	{46080, 2764800, 19, 29,},
> +};
> +
> +static int cdu_hw_params(struct snd_pcm_substream *substream,
> +			 struct snd_pcm_hw_params *params)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
> +	struct device *dev = rtd->card->dev;
> +	int ret;
> +	int i, found = 0;
> +
> +	/* set codec DAI configuration */
> +	ret = snd_soc_dai_set_fmt(codec_dai,
> +				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> +				  SND_SOC_DAIFMT_CBS_CFS);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* set cpu DAI configuration */
> +	ret = snd_soc_dai_set_fmt(cpu_dai,
> +				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> +				  SND_SOC_DAIFMT_CBS_CFS);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* Only support 1 or 2 channel S16_LE */
> +	if ((params_channels(params) != 1 && params_channels(params) != 2) ||
> +	   params_format(params) != SNDRV_PCM_FORMAT_S16_LE)
> +		return -EINVAL;
> +
> +	/* Check rate support */
> +	for (i = 0; i < ARRAY_SIZE(cdu_audio); i++)
> +		if (params_rate(params) == cdu_audio[i].rate) {
> +			found = 1;
> +			break;
> +		}
> +	if (!found)
> +		return -EINVAL;
> +
> +	/* Set the codec system clock for DAC and ADC */
> +	ret = snd_soc_dai_set_sysclk(codec_dai,
> +				     CLKIN_BCLK, cdu_audio[i].codecclk,
> +				     SND_SOC_CLOCK_IN);
> +	if (ret < 0) {
> +		dev_err(dev, "can't set codec system clock\n");
> +		return ret;
> +	}
> +
> +	/* Set the cpu clock dividers to BCLK */
> +	ret = snd_soc_dai_set_clkdiv(cpu_dai,
> +				     ATMEL_SSC_CMR_DIV, cdu_audio[i].cmrdiv);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai,
> +				      ATMEL_SSC_TCMR_PERIOD,
> +				      cdu_audio[i].period);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai,
> +				      ATMEL_SSC_RCMR_PERIOD,
> +				      cdu_audio[i].period);
> +	if (ret < 0) {

If more than one of the functions above returns an error then you will
end up with an odd value for ret here. Either test each one individually
and return the correct error code in each case, or return something more
sensible like -EINVAL below.

> +		dev_err(dev, "can't set cpu system clock\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static struct snd_soc_ops cdu_ops = {
> +	.hw_params = cdu_hw_params,
> +};
> +
> +static const struct snd_soc_dapm_widget cdu_dapm_widgets[] = {
> +	SND_SOC_DAPM_HP("Headphone Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line Out", NULL),
> +	SND_SOC_DAPM_MIC("Mic Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line In", NULL),
> +};
> +
> +static const struct snd_soc_dapm_route intercon[] = {
> +	/* Headphone connected to HPLOUT, HPROUT */
> +	{"Headphone Jack", NULL, "HPLOUT"},
> +	{"Headphone Jack", NULL, "HPROUT"},
> +
> +	/* Line Out connected to LLOUT, RLOUT */
> +	{"Line Out", NULL, "LLOUT"},
> +	{"Line Out", NULL, "RLOUT"},
> +
> +	/* Mic connected to (MIC3L | MIC3R) */
> +	{"MIC3L", NULL, "Mic Bias 2V"},
> +	{"MIC3R", NULL, "Mic Bias 2V"},
> +	{"Mic Bias 2V", NULL, "Mic Jack"},
> +
> +	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
> +	{"LINE1L", NULL, "Line In"},
> +	{"LINE2L", NULL, "Line In"},
> +	{"LINE1R", NULL, "Line In"},
> +	{"LINE2R", NULL, "Line In"},
> +};
> +
> +/*
> + * Logic for a aic3x as connected on a cdu board.
> + */
> +static int cdu_aic3x_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	struct snd_soc_codec *codec = rtd->codec;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dapm_context *dapm = &codec->dapm;
> +	int ret;
> +
> +	/* Add specific widgets */
> +	snd_soc_dapm_new_controls(dapm, cdu_dapm_widgets,
> +				  ARRAY_SIZE(cdu_dapm_widgets));
> +	/* Set up specific audio path interconnects */
> +	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
> +
> +	return 0;
> +}
> +
> +static struct snd_soc_dai_link cdu_dai = {
> +	.name		= "TLV320AIC3106",
> +	.stream_name	= "PCM",
> +	.cpu_dai_name	= "atmel-ssc-dai.0",
> +	.codec_dai_name	= "tlv320aic3x-hifi",
> +	.init		= cdu_aic3x_init,
> +	.platform_name	= "atmel-pcm-audio",
> +	.codec_name	= "spi1.3",
> +	.ops		= &cdu_ops,
> +};
> +
> +static struct snd_soc_card snd_soc_cdu = {
> +	.name		= "TLV320AIC3106",
> +	.dai_link	= &cdu_dai,
> +	.num_links	= 1,
> +};
> +
> +static struct platform_device *cdu_snd_device;
> +
> +static int __init cdu_init(void)
> +{
> +	int ret;
> +
> +	ret = atmel_ssc_set_audio(0);
> +	if (ret) {
> +		pr_err("Failed to set SSC 0 for audio: %d\n", ret);
> +		return ret;

goto err to be consistent.

> +	}
> +
> +	cdu_snd_device = platform_device_alloc("soc-audio", -1);
> +	if (!cdu_snd_device) {
> +		pr_err("ASoC: Platform device allocation failed: %d\n", ret);
> +		ret = -ENOMEM;

goto err?

> +	}
> +
> +	platform_set_drvdata(cdu_snd_device, &snd_soc_cdu);
> +
> +	ret = platform_device_add(cdu_snd_device);
> +	if (ret) {
> +		pr_err("ASoC: Platform device adding failed: %d\n", ret);
> +		goto err_device_add;
> +	}
> +
> +	return ret;
> +
> +err_device_add:
> +	platform_device_put(cdu_snd_device);
> +err:
> +	return ret;
> +}
> +
> +static void __exit cdu_exit(void)
> +{
> +	platform_device_unregister(cdu_snd_device);
> +}
> +
> +module_init(cdu_init);
> +module_exit(cdu_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Jiri Prchal <jiri.prchal@aksignal.cz>");
> +MODULE_DESCRIPTION("ALSA SoC CDU_AIC3X");
> +MODULE_LICENSE("GPL");


-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934
--
To unsubscribe from this list: send the line "unsubscribe alsa-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X
@ 2011-04-04 20:07           ` Ryan Mallon
  0 siblings, 0 replies; 31+ messages in thread
From: Ryan Mallon @ 2011-04-04 20:07 UTC (permalink / raw)
  To: Prchal Jiří; +Cc: alsa-devel, alsa-devel, vbarinov, linux-kernel

On 04/04/2011 08:57 PM, Prchal Jiří wrote:
> Hi,
> this is separeted PATCH for glue AT91SAM9260 and TLV320AIC3X on CDU board.

Please repost this (and the other patch) as a new patch with a proper
change log. You should also Cc Liam Girdwood and Mark Brown, who
maintain the SoC audio system and will pick up this patch.

Some more comments below.

~Ryan

<snip>

> 
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Kconfig
> linux-2.6.38-patch/sound/soc/atmel/Kconfig
> --- linux-2.6.38-vanilla/sound/soc/atmel/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/atmel/Kconfig	2011-03-22 09:46:46.751566158 +0100
> @@ -50,3 +50,11 @@ config SND_AT91_SOC_AFEB9260
>  	select SND_SOC_TLV320AIC23
>  	help
>  	  Say Y here to support sound on AFEB9260 board.
> +
> +config SND_AT91_SOC_CDU
> +	tristate "SoC Audio support for CDU board"
> +	depends on ARCH_AT91 && MACH_CDU && SND_ATMEL_SOC
> +	select SND_ATMEL_SOC_SSC
> +	select SND_SOC_TLV320AIC3X
> +	help
> +	  Say Y here to support sound on CDU board.
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/Makefile
> linux-2.6.38-patch/sound/soc/atmel/Makefile
> --- linux-2.6.38-vanilla/sound/soc/atmel/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/atmel/Makefile	2011-03-16 09:26:17.000000000 +0100
> @@ -14,3 +14,4 @@ snd-soc-playpaq-objs := playpaq_wm8510.o
>  obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
>  obj-$(CONFIG_SND_AT32_SOC_PLAYPAQ) += snd-soc-playpaq.o
>  obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
> +obj-$(CONFIG_SND_AT91_SOC_CDU) += snd-soc-cdu.o
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c
> linux-2.6.38-patch/sound/soc/atmel/snd-soc-cdu.c
> --- linux-2.6.38-vanilla/sound/soc/atmel/snd-soc-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6.38-patch/sound/soc/atmel/snd-soc-cdu.c	2011-03-25 13:42:07.545051043 +0100
> @@ -0,0 +1,259 @@
> +/*
> + * snd-soc-cdu  --  SoC audio for AT91SAM9260-based
> + * 			AKsignal CDU board.
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2008 Atmel
> + *  Copyright (C) 2011 AK signal Brno
> + *
> + * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
> + *          Jiri Prchal <jiri.prchal@aksignal.cz>
> + *
> + * Based on ati_b1_wm8731.c by:
> + * Frank Mandarino <fmandarino@endrelia.com>
> + * Copyright 2006 Endrelia Technologies Inc.
> + * Based on corgi.c by:
> + * Copyright 2005 Wolfson Microelectronics PLC.
> + * Copyright 2005 Openedhand Ltd.
> + *
> + * 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 <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/clk.h>
> +#include <linux/platform_device.h>
> +
> +#include <linux/atmel-ssc.h>
> +#include <sound/core.h>
> +#include <sound/pcm.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
> +
> +#include <asm/mach-types.h>
> +#include <mach/hardware.h>
> +
> +#include "../codecs/tlv320aic3x.h"
> +#include "atmel-pcm.h"
> +#include "atmel_ssc_dai.h"
> +
> +/*
> + * Table of supported rates
> + * with their clock divider (cmrdiv) and number clock in frame (period + 1 * 2),
> + * codecclk sould be integer multiple of sample rate even if it is not exact true
> + * to avoid data on SSC underrun / overrun -
> + * CPU can not generate clock as fine as CODEC.
> + */
> +struct {
> +	unsigned int rate;
> +	unsigned int codecclk;
> +	unsigned int cmrdiv;
> +	unsigned int period;
> +} cdu_audio[] = {

Should be static.

> +	{8000, 2096000, 25, 130,},
> +	{16000, 2496000, 21, 77,},
> +	{32000, 2496000, 21, 38,},
> +	{48000, 2016000, 26, 20,},
> +	{96000, 4032000, 13, 20,},
> +
> +	{11025, 2381400, 22, 107,},
> +	{22050, 2381400, 22, 53,},
> +	{44100, 2381400, 22, 26,},
> +	{88200, 4762800, 11, 26,},
> +
> +	/* special rates for serial line transfer */
> +	{11520, 2626560, 20, 113,},
> +	{23040, 2626560, 20, 56,},
> +	{46080, 2764800, 19, 29,},
> +};
> +
> +static int cdu_hw_params(struct snd_pcm_substream *substream,
> +			 struct snd_pcm_hw_params *params)
> +{
> +	struct snd_soc_pcm_runtime *rtd = substream->private_data;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
> +	struct device *dev = rtd->card->dev;
> +	int ret;
> +	int i, found = 0;
> +
> +	/* set codec DAI configuration */
> +	ret = snd_soc_dai_set_fmt(codec_dai,
> +				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> +				  SND_SOC_DAIFMT_CBS_CFS);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* set cpu DAI configuration */
> +	ret = snd_soc_dai_set_fmt(cpu_dai,
> +				  SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
> +				  SND_SOC_DAIFMT_CBS_CFS);
> +	if (ret < 0)
> +		return ret;
> +
> +	/* Only support 1 or 2 channel S16_LE */
> +	if ((params_channels(params) != 1 && params_channels(params) != 2) ||
> +	   params_format(params) != SNDRV_PCM_FORMAT_S16_LE)
> +		return -EINVAL;
> +
> +	/* Check rate support */
> +	for (i = 0; i < ARRAY_SIZE(cdu_audio); i++)
> +		if (params_rate(params) == cdu_audio[i].rate) {
> +			found = 1;
> +			break;
> +		}
> +	if (!found)
> +		return -EINVAL;
> +
> +	/* Set the codec system clock for DAC and ADC */
> +	ret = snd_soc_dai_set_sysclk(codec_dai,
> +				     CLKIN_BCLK, cdu_audio[i].codecclk,
> +				     SND_SOC_CLOCK_IN);
> +	if (ret < 0) {
> +		dev_err(dev, "can't set codec system clock\n");
> +		return ret;
> +	}
> +
> +	/* Set the cpu clock dividers to BCLK */
> +	ret = snd_soc_dai_set_clkdiv(cpu_dai,
> +				     ATMEL_SSC_CMR_DIV, cdu_audio[i].cmrdiv);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai,
> +				      ATMEL_SSC_TCMR_PERIOD,
> +				      cdu_audio[i].period);
> +	ret |= snd_soc_dai_set_clkdiv(cpu_dai,
> +				      ATMEL_SSC_RCMR_PERIOD,
> +				      cdu_audio[i].period);
> +	if (ret < 0) {

If more than one of the functions above returns an error then you will
end up with an odd value for ret here. Either test each one individually
and return the correct error code in each case, or return something more
sensible like -EINVAL below.

> +		dev_err(dev, "can't set cpu system clock\n");
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static struct snd_soc_ops cdu_ops = {
> +	.hw_params = cdu_hw_params,
> +};
> +
> +static const struct snd_soc_dapm_widget cdu_dapm_widgets[] = {
> +	SND_SOC_DAPM_HP("Headphone Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line Out", NULL),
> +	SND_SOC_DAPM_MIC("Mic Jack", NULL),
> +	SND_SOC_DAPM_LINE("Line In", NULL),
> +};
> +
> +static const struct snd_soc_dapm_route intercon[] = {
> +	/* Headphone connected to HPLOUT, HPROUT */
> +	{"Headphone Jack", NULL, "HPLOUT"},
> +	{"Headphone Jack", NULL, "HPROUT"},
> +
> +	/* Line Out connected to LLOUT, RLOUT */
> +	{"Line Out", NULL, "LLOUT"},
> +	{"Line Out", NULL, "RLOUT"},
> +
> +	/* Mic connected to (MIC3L | MIC3R) */
> +	{"MIC3L", NULL, "Mic Bias 2V"},
> +	{"MIC3R", NULL, "Mic Bias 2V"},
> +	{"Mic Bias 2V", NULL, "Mic Jack"},
> +
> +	/* Line In connected to (LINE1L | LINE2L), (LINE1R | LINE2R) */
> +	{"LINE1L", NULL, "Line In"},
> +	{"LINE2L", NULL, "Line In"},
> +	{"LINE1R", NULL, "Line In"},
> +	{"LINE2R", NULL, "Line In"},
> +};
> +
> +/*
> + * Logic for a aic3x as connected on a cdu board.
> + */
> +static int cdu_aic3x_init(struct snd_soc_pcm_runtime *rtd)
> +{
> +	struct snd_soc_codec *codec = rtd->codec;
> +	struct snd_soc_dai *codec_dai = rtd->codec_dai;
> +	struct snd_soc_dapm_context *dapm = &codec->dapm;
> +	int ret;
> +
> +	/* Add specific widgets */
> +	snd_soc_dapm_new_controls(dapm, cdu_dapm_widgets,
> +				  ARRAY_SIZE(cdu_dapm_widgets));
> +	/* Set up specific audio path interconnects */
> +	snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon));
> +
> +	return 0;
> +}
> +
> +static struct snd_soc_dai_link cdu_dai = {
> +	.name		= "TLV320AIC3106",
> +	.stream_name	= "PCM",
> +	.cpu_dai_name	= "atmel-ssc-dai.0",
> +	.codec_dai_name	= "tlv320aic3x-hifi",
> +	.init		= cdu_aic3x_init,
> +	.platform_name	= "atmel-pcm-audio",
> +	.codec_name	= "spi1.3",
> +	.ops		= &cdu_ops,
> +};
> +
> +static struct snd_soc_card snd_soc_cdu = {
> +	.name		= "TLV320AIC3106",
> +	.dai_link	= &cdu_dai,
> +	.num_links	= 1,
> +};
> +
> +static struct platform_device *cdu_snd_device;
> +
> +static int __init cdu_init(void)
> +{
> +	int ret;
> +
> +	ret = atmel_ssc_set_audio(0);
> +	if (ret) {
> +		pr_err("Failed to set SSC 0 for audio: %d\n", ret);
> +		return ret;

goto err to be consistent.

> +	}
> +
> +	cdu_snd_device = platform_device_alloc("soc-audio", -1);
> +	if (!cdu_snd_device) {
> +		pr_err("ASoC: Platform device allocation failed: %d\n", ret);
> +		ret = -ENOMEM;

goto err?

> +	}
> +
> +	platform_set_drvdata(cdu_snd_device, &snd_soc_cdu);
> +
> +	ret = platform_device_add(cdu_snd_device);
> +	if (ret) {
> +		pr_err("ASoC: Platform device adding failed: %d\n", ret);
> +		goto err_device_add;
> +	}
> +
> +	return ret;
> +
> +err_device_add:
> +	platform_device_put(cdu_snd_device);
> +err:
> +	return ret;
> +}
> +
> +static void __exit cdu_exit(void)
> +{
> +	platform_device_unregister(cdu_snd_device);
> +}
> +
> +module_init(cdu_init);
> +module_exit(cdu_exit);
> +
> +/* Module information */
> +MODULE_AUTHOR("Jiri Prchal <jiri.prchal@aksignal.cz>");
> +MODULE_DESCRIPTION("ALSA SoC CDU_AIC3X");
> +MODULE_LICENSE("GPL");


-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934

^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH] ARCH arm: adding new board: CDU
  2011-04-04  9:10         ` Prchal Jiří
@ 2011-04-04 20:25           ` Ryan Mallon
  -1 siblings, 0 replies; 31+ messages in thread
From: Ryan Mallon @ 2011-04-04 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 04/04/2011 09:10 PM, Prchal Ji?? wrote:
> Hi,
> this is separated PATCH adding new board CDU.

Please repost as a new email with a proper change log. This patch
shouldn't depend on the CDU audio driver patch. This should still build
and run, just without audio support.

Few more comments below.

~Ryan

<snip>

> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
> linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c	2011-03-28 15:52:03.413048601 +0200
> @@ -0,0 +1,332 @@
> +/*
> + * linux/arch/arm/mach-at91/board-cdu.c
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2006 Atmel
> + *  Copyright (C) 2011 AKsignal Brno
> + *                     jiri.prchal at aksignal.cz
> + *
> + * 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 <linux/types.h>
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/spi/spi.h>
> +#include <linux/clk.h>
> +#include <linux/spi/mcp23s08.h>
> +#include <linux/dma-mapping.h>
> +
> +#include <mach/hardware.h>
> +#include <asm/setup.h>
> +#include <asm/mach-types.h>
> +#include <asm/irq.h>
> +
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +#include <asm/mach/irq.h>
> +
> +#include <mach/board.h>
> +#include <mach/gpio.h>
> +#include <mach/at91sam9_smc.h>
> +
> +#include "sam9_smc.h"
> +#include "generic.h"
> +
> +static void __init cdu_map_io(void)
> +{
> +	/* Initialize processor: 6 MHz crystal */
> +	at91sam9260_initialize(6000000);
> +
> +	/* DBGU on ttyS0. (Rx & Tx only) */
> +	at91_register_uart(0, 0, 0);
> +
> +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
> +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
> +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
> +			   | ATMEL_UART_RI);
> +
> +	/* USART1 on ttyS2. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
> +
> +	/* USART2 on ttyS3. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
> +
> +	/* USART3 on ttyS4. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
> +
> +	/* USART4 on ttyS5. (Tx) */
> +	/* EBUS - transmit audio, no rx */
> +	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
> +
> +	/* set serial console to ttyS0 (ie, DBGU) */
> +	at91_set_serial_console(0);
> +}
> +
> +static void __init cdu_init_irq(void)
> +{
> +	at91sam9260_init_interrupts(NULL);
> +}
> +
> +/*
> + * USB Host port
> + */
> +static struct at91_usbh_data __initdata cdu_usbh_data = {
> +	.ports		= 2,
> +};
> +
> +/*
> + * USB Device port
> + */
> +static struct at91_udc_data __initdata cdu_udc_data = {
> +	.vbus_pin	= AT91_PIN_PC15,
> +	.pullup_pin	= 0,		/* pull-up driven by UDC */
> +};
> +
> +/*
> + * SPI devices.
> + */
> +#define MCP23S08_GPIO_BASE	128
> +
> +static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
> +	.chip[0].is_present	= true,
> +	.chip[0].pullups	= 0,
> +	.base			= MCP23S08_GPIO_BASE,
> +};
> +
> +static struct spi_board_info cdu_spi_devices[] = {
> +	{ /* ADC LTC2488 */
> +		.modalias	= "spidev",
> +		.chip_select	= 0,
> +		.max_speed_hz	= 1 * 1000 * 1000,

You have max_speed_hz set as (1 * 1000 * 1000) in some cases and 1000000
in others. Please be consistent. Nitpicky: chip_select and bus_num
should go next to each since they are related.

> +		.bus_num	= 1,
> +	},
> +	{ /* GPIO expander MCP23S08 */
> +		.modalias	= "mcp23s08",
> +		.chip_select	= 1,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.platform_data	= &mcp23s08_gpio_info,
> +		.mode		= SPI_MODE_3,
> +	},
> +	{ /* non volatile memory (F-RAM) FM25VN10 */
> +		.modalias	= "spidev",
> +		.chip_select	= 2,
> +		.max_speed_hz	= 1 * 1000 * 1000,
> +		.bus_num	= 1,
> +	},
> +	{ /* audiocodec TLV320AIC3106 */
> +		.modalias	= "tlv320aic3x-codec",
> +		.chip_select	= 3,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.mode		= SPI_MODE_1,
> +	},
> +};
> +
> +/*
> + * MACB Ethernet device
> + */
> +static struct at91_eth_data __initdata cdu_macb_data = {
> +	/*.phy_irq_pin	= ... not connected */

Delete this line.

> +	.is_rmii	= 1,
> +};
> +
> +/*
> + * NAND flash
> + */
> +static struct mtd_partition __initdata cdu_nand_partition[] = {
> +	{
> +		.name   = "bootstrap",
> +		.offset = 0,
> +		.size   = SZ_256K,
> +	},
> +	{
> +		.name   = "uboot",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = SZ_512K,
> +	},
> +	{
> +		.name   = "ubootenv",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = SZ_256K,
> +	},
> +	{
> +		.name   = "kernel",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = SZ_4M,
> +	},
> +	{
> +		.name   = "rootfs",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = MTDPART_SIZ_FULL,
> +	},
> +};
> +
> +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
> +{
> +	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
> +	return cdu_nand_partition;
> +}
> +
> +static struct atmel_nand_data __initdata cdu_nand_data = {
> +	.ale		= 21,
> +	.cle		= 22,
> +	/*.det_pin	= ... not connected */

Just delete this line.

> +	.rdy_pin	= AT91_PIN_PC13,
> +	.enable_pin	= AT91_PIN_PC14,
> +	.partition_info	= nand_partitions,
> +	.bus_width_16	= 0,
> +};
> +
> +static struct sam9_smc_config __initdata cdu_nand_smc_config = {
> +	.ncs_read_setup		= 0,
> +	.nrd_setup		= 1,
> +	.ncs_write_setup	= 0,
> +	.nwe_setup		= 1,
> +
> +	.ncs_read_pulse		= 3,
> +	.nrd_pulse		= 3,
> +	.ncs_write_pulse	= 3,
> +	.nwe_pulse		= 3,
> +
> +	.read_cycle		= 5,
> +	.write_cycle		= 5,
> +
> +	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,

Split this line since it runs over 80 columns (especially once you add |
AT91_SMC_DBW_8).

> +	.tdf_cycles		= 2,
> +};
> +
> +static void __init cdu_add_device_nand(void)
> +{
> +	/* setup bus-width 8 */
> +	cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;

Move this up into the initialisation above.

> +
> +	/* configure chip-select 3 (NAND) */
> +	sam9_smc_configure(3, &cdu_nand_smc_config);
> +
> +	at91_add_device_nand(&cdu_nand_data);
> +}
> +
> +/*
> +* MCI (SD/MMC)
> +*/
> +static struct at91_mmc_data __initdata ek_mmc_data = {
> +	.slot_b		= 0,
> +	.wire4		= 1,
> +	/*.det_pin	= ... not connected */
> +	/*.wp_pin	= ... not connected */
> +	/*.vcc_pin	= ... not connected */

Delete these lines.

> +};
> +
> +/*
> + * LEDs
> + */
> +static struct gpio_led cdu_leds[] = {
> +	{
> +		.name			= "red",
> +		.gpio			= AT91_PIN_PC10,
> +		.default_trigger	= "timer",
> +	},
> +	{
> +		.name			= "green",
> +		.gpio			= AT91_PIN_PA5,
> +		.default_trigger	= "heartbeat",
> +	},
> +	{
> +		.name			= "yellow",
> +		.gpio			= AT91_PIN_PB20,
> +		.active_low		= 1,
> +		.default_trigger	= "mmc0",
> +	},
> +	{
> +		.name			= "blue",
> +		.gpio			= AT91_PIN_PB21,
> +		.active_low		= 1,
> +		.default_trigger	= "nand-disk",
> +	},
> +};
> +
> +/*
> + * GPIOs
> + */
> +static struct gpio gpios[] = {
> +	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
> +	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
> +	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
> +	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
> +	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
> +	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
> +
> +	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
> +	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
> +	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
> +	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
> +	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
> +	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
> +
> +	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
> +	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
> +	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
> +	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
> +	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
> +	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
> +
> +	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
> +	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
> +	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
> +	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
> +	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
> +	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
> +	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
> +};
> +
> +static void __init cdu_add_gpio(void)
> +{

	gpio_request_array(gpios, ARRAY_SIZE(gpios));

> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
> +		gpio_request_one(gpios[i].gpio, gpios[i].flags, gpios[i].label);
> +		gpio_export_name(gpios[i].gpio, 0, gpios[i].label);

What does this function do? I can't find it anywhere.

> +	}
> +}
> +
> +/*
> + * init
> + */
> +static void __init cdu_board_init(void)
> +{
> +	at91_add_device_serial();
> +	at91_add_device_usbh(&cdu_usbh_data);
> +	at91_add_device_udc(&cdu_udc_data);
> +	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
> +	cdu_add_device_nand();
> +	at91_add_device_eth(&cdu_macb_data);
> +	at91_add_device_mmc(0, &ek_mmc_data);
> +	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
> +	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
> +	cdu_add_gpio ();

No space between gpio and ().

> +}
> +
> +MACHINE_START(AT91SAM9260EK, "CDU")
> +	/* Maintainer: AKsignal Brno */

Website/email contact?

> +	.boot_params	= AT91_SDRAM_BASE + 0x100,
> +	.timer		= &at91sam926x_timer,
> +	.map_io		= cdu_map_io,
> +	.init_irq	= cdu_init_irq,
> +	.init_machine	= cdu_board_init,
> +MACHINE_END
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
> linux-2.6.38-patch/arch/arm/mach-at91/Kconfig
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
> @@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
>  	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
>  	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
> 
> +config MACH_CDU
> +	bool "CDU AKsignal board"
> +	help
> +	  Select this if you are using AKsignal CDU board
> +	  <http://www.aksignal.cz>
> +
>  config MACH_CAM60
>  	bool "KwikByte KB9260 (CAM60) board"
>  	help
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
> linux-2.6.38-patch/arch/arm/mach-at91/Makefile
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
> @@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92
> 
>  # AT91SAM9260 board-specific support
>  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
> +obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
>  obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
>  obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
>  obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/MAINTAINERS linux-2.6.38-patch/MAINTAINERS
> --- linux-2.6.38-vanilla/MAINTAINERS	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/MAINTAINERS	2011-03-25 08:37:56.693049978 +0100
> @@ -1640,6 +1640,13 @@ F:	include/linux/can/error.h
>  F:	include/linux/can/netlink.h
>  F:	include/linux/can/platform/
> 
> +CDU BOARD
> +M:	Jiri Prchal <jiri.prchal@aksignal.cz>
> +L:	linux-arch at vger.kernel.org
> +W:	http://www.linux4sam.org
> +S:	Supported
> +F:	arch/arm/mach-at91/
> +
>  CELL BROADBAND ENGINE ARCHITECTURE
>  M:	Arnd Bergmann <arnd@arndb.de>
>  L:	linuxppc-dev at lists.ozlabs.org
> Soubory linux-2.6.38-vanilla/scripts/recordmcount a linux-2.6.38-patch/scripts/recordmcount jsou r??zn??


-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan at bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH] ARCH arm: adding new board: CDU
@ 2011-04-04 20:25           ` Ryan Mallon
  0 siblings, 0 replies; 31+ messages in thread
From: Ryan Mallon @ 2011-04-04 20:25 UTC (permalink / raw)
  To: Prchal Jiří
  Cc: linux-arm-kernel, linux, nicolas.ferre, plagnioj, linux-kernel

On 04/04/2011 09:10 PM, Prchal Jiří wrote:
> Hi,
> this is separated PATCH adding new board CDU.

Please repost as a new email with a proper change log. This patch
shouldn't depend on the CDU audio driver patch. This should still build
and run, just without audio support.

Few more comments below.

~Ryan

<snip>

> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c
> linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/board-cdu.c	1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6.38-patch/arch/arm/mach-at91/board-cdu.c	2011-03-28 15:52:03.413048601 +0200
> @@ -0,0 +1,332 @@
> +/*
> + * linux/arch/arm/mach-at91/board-cdu.c
> + *
> + *  Copyright (C) 2005 SAN People
> + *  Copyright (C) 2006 Atmel
> + *  Copyright (C) 2011 AKsignal Brno
> + *                     jiri.prchal@aksignal.cz
> + *
> + * 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 <linux/types.h>
> +#include <linux/init.h>
> +#include <linux/mm.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/spi/spi.h>
> +#include <linux/clk.h>
> +#include <linux/spi/mcp23s08.h>
> +#include <linux/dma-mapping.h>
> +
> +#include <mach/hardware.h>
> +#include <asm/setup.h>
> +#include <asm/mach-types.h>
> +#include <asm/irq.h>
> +
> +#include <asm/mach/arch.h>
> +#include <asm/mach/map.h>
> +#include <asm/mach/irq.h>
> +
> +#include <mach/board.h>
> +#include <mach/gpio.h>
> +#include <mach/at91sam9_smc.h>
> +
> +#include "sam9_smc.h"
> +#include "generic.h"
> +
> +static void __init cdu_map_io(void)
> +{
> +	/* Initialize processor: 6 MHz crystal */
> +	at91sam9260_initialize(6000000);
> +
> +	/* DBGU on ttyS0. (Rx & Tx only) */
> +	at91_register_uart(0, 0, 0);
> +
> +	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
> +	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
> +			   | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
> +			   | ATMEL_UART_RI);
> +
> +	/* USART1 on ttyS2. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_RTS);
> +
> +	/* USART2 on ttyS3. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_RTS);
> +
> +	/* USART3 on ttyS4. (Rx, Tx, RTS) */
> +	at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
> +
> +	/* USART4 on ttyS5. (Tx) */
> +	/* EBUS - transmit audio, no rx */
> +	/*at91_register_uart(AT91SAM9260_ID_US4, 5, 0);*/
> +
> +	/* set serial console to ttyS0 (ie, DBGU) */
> +	at91_set_serial_console(0);
> +}
> +
> +static void __init cdu_init_irq(void)
> +{
> +	at91sam9260_init_interrupts(NULL);
> +}
> +
> +/*
> + * USB Host port
> + */
> +static struct at91_usbh_data __initdata cdu_usbh_data = {
> +	.ports		= 2,
> +};
> +
> +/*
> + * USB Device port
> + */
> +static struct at91_udc_data __initdata cdu_udc_data = {
> +	.vbus_pin	= AT91_PIN_PC15,
> +	.pullup_pin	= 0,		/* pull-up driven by UDC */
> +};
> +
> +/*
> + * SPI devices.
> + */
> +#define MCP23S08_GPIO_BASE	128
> +
> +static const struct mcp23s08_platform_data mcp23s08_gpio_info = {
> +	.chip[0].is_present	= true,
> +	.chip[0].pullups	= 0,
> +	.base			= MCP23S08_GPIO_BASE,
> +};
> +
> +static struct spi_board_info cdu_spi_devices[] = {
> +	{ /* ADC LTC2488 */
> +		.modalias	= "spidev",
> +		.chip_select	= 0,
> +		.max_speed_hz	= 1 * 1000 * 1000,

You have max_speed_hz set as (1 * 1000 * 1000) in some cases and 1000000
in others. Please be consistent. Nitpicky: chip_select and bus_num
should go next to each since they are related.

> +		.bus_num	= 1,
> +	},
> +	{ /* GPIO expander MCP23S08 */
> +		.modalias	= "mcp23s08",
> +		.chip_select	= 1,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.platform_data	= &mcp23s08_gpio_info,
> +		.mode		= SPI_MODE_3,
> +	},
> +	{ /* non volatile memory (F-RAM) FM25VN10 */
> +		.modalias	= "spidev",
> +		.chip_select	= 2,
> +		.max_speed_hz	= 1 * 1000 * 1000,
> +		.bus_num	= 1,
> +	},
> +	{ /* audiocodec TLV320AIC3106 */
> +		.modalias	= "tlv320aic3x-codec",
> +		.chip_select	= 3,
> +		.max_speed_hz	= 1000000,
> +		.bus_num	= 1,
> +		.mode		= SPI_MODE_1,
> +	},
> +};
> +
> +/*
> + * MACB Ethernet device
> + */
> +static struct at91_eth_data __initdata cdu_macb_data = {
> +	/*.phy_irq_pin	= ... not connected */

Delete this line.

> +	.is_rmii	= 1,
> +};
> +
> +/*
> + * NAND flash
> + */
> +static struct mtd_partition __initdata cdu_nand_partition[] = {
> +	{
> +		.name   = "bootstrap",
> +		.offset = 0,
> +		.size   = SZ_256K,
> +	},
> +	{
> +		.name   = "uboot",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = SZ_512K,
> +	},
> +	{
> +		.name   = "ubootenv",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = SZ_256K,
> +	},
> +	{
> +		.name   = "kernel",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = SZ_4M,
> +	},
> +	{
> +		.name   = "rootfs",
> +		.offset = MTDPART_OFS_APPEND,
> +		.size   = MTDPART_SIZ_FULL,
> +	},
> +};
> +
> +static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
> +{
> +	*num_partitions = ARRAY_SIZE(cdu_nand_partition);
> +	return cdu_nand_partition;
> +}
> +
> +static struct atmel_nand_data __initdata cdu_nand_data = {
> +	.ale		= 21,
> +	.cle		= 22,
> +	/*.det_pin	= ... not connected */

Just delete this line.

> +	.rdy_pin	= AT91_PIN_PC13,
> +	.enable_pin	= AT91_PIN_PC14,
> +	.partition_info	= nand_partitions,
> +	.bus_width_16	= 0,
> +};
> +
> +static struct sam9_smc_config __initdata cdu_nand_smc_config = {
> +	.ncs_read_setup		= 0,
> +	.nrd_setup		= 1,
> +	.ncs_write_setup	= 0,
> +	.nwe_setup		= 1,
> +
> +	.ncs_read_pulse		= 3,
> +	.nrd_pulse		= 3,
> +	.ncs_write_pulse	= 3,
> +	.nwe_pulse		= 3,
> +
> +	.read_cycle		= 5,
> +	.write_cycle		= 5,
> +
> +	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,

Split this line since it runs over 80 columns (especially once you add |
AT91_SMC_DBW_8).

> +	.tdf_cycles		= 2,
> +};
> +
> +static void __init cdu_add_device_nand(void)
> +{
> +	/* setup bus-width 8 */
> +	cdu_nand_smc_config.mode |= AT91_SMC_DBW_8;

Move this up into the initialisation above.

> +
> +	/* configure chip-select 3 (NAND) */
> +	sam9_smc_configure(3, &cdu_nand_smc_config);
> +
> +	at91_add_device_nand(&cdu_nand_data);
> +}
> +
> +/*
> +* MCI (SD/MMC)
> +*/
> +static struct at91_mmc_data __initdata ek_mmc_data = {
> +	.slot_b		= 0,
> +	.wire4		= 1,
> +	/*.det_pin	= ... not connected */
> +	/*.wp_pin	= ... not connected */
> +	/*.vcc_pin	= ... not connected */

Delete these lines.

> +};
> +
> +/*
> + * LEDs
> + */
> +static struct gpio_led cdu_leds[] = {
> +	{
> +		.name			= "red",
> +		.gpio			= AT91_PIN_PC10,
> +		.default_trigger	= "timer",
> +	},
> +	{
> +		.name			= "green",
> +		.gpio			= AT91_PIN_PA5,
> +		.default_trigger	= "heartbeat",
> +	},
> +	{
> +		.name			= "yellow",
> +		.gpio			= AT91_PIN_PB20,
> +		.active_low		= 1,
> +		.default_trigger	= "mmc0",
> +	},
> +	{
> +		.name			= "blue",
> +		.gpio			= AT91_PIN_PB21,
> +		.active_low		= 1,
> +		.default_trigger	= "nand-disk",
> +	},
> +};
> +
> +/*
> + * GPIOs
> + */
> +static struct gpio gpios[] = {
> +	{ AT91_PIN_PA0,  GPIOF_OUT_INIT_LOW,  "ebus_dir"},
> +	{ AT91_PIN_PA1,  GPIOF_OUT_INIT_LOW,  "time_dir"},
> +	{ AT91_PIN_PB12, GPIOF_OUT_INIT_LOW,  "gsm_rst"},
> +	{ AT91_PIN_PB13, GPIOF_OUT_INIT_LOW,  "gsm_on"},
> +	{ AT91_PIN_PC2,  GPIOF_IN,            "por"},
> +	{ AT91_PIN_PC7,  GPIOF_OUT_INIT_HIGH, "spk_shdn"},
> +
> +	{ AT91_PIN_PC0,  GPIOF_IN,            "in13"},
> +	{ AT91_PIN_PC1,  GPIOF_IN,            "in14"},
> +	{ AT91_PIN_PA22, GPIOF_IN,            "in17"},
> +	{ AT91_PIN_PA23, GPIOF_IN,            "in18"},
> +	{ AT91_PIN_PA24, GPIOF_IN,            "in19"},
> +	{ AT91_PIN_PA25, GPIOF_IN,            "in20"},
> +
> +	{ AT91_PIN_PA26, GPIOF_OUT_INIT_LOW,  "out15"},
> +	{ AT91_PIN_PA27, GPIOF_OUT_INIT_LOW,  "out16"},
> +	{ AT91_PIN_PA28, GPIOF_OUT_INIT_LOW,  "out17"},
> +	{ AT91_PIN_PA29, GPIOF_OUT_INIT_LOW,  "out18"},
> +	{ AT91_PIN_PA30, GPIOF_OUT_INIT_LOW,  "out19"},
> +	{ AT91_PIN_PB29, GPIOF_OUT_INIT_LOW,  "out20"},
> +
> +	{ MCP23S08_GPIO_BASE + 0, GPIOF_IN,   "busadrp"},
> +	{ MCP23S08_GPIO_BASE + 2, GPIOF_IN,   "busadr5"},
> +	{ MCP23S08_GPIO_BASE + 3, GPIOF_IN,   "busadr4"},
> +	{ MCP23S08_GPIO_BASE + 4, GPIOF_IN,   "busadr3"},
> +	{ MCP23S08_GPIO_BASE + 5, GPIOF_IN,   "busadr2"},
> +	{ MCP23S08_GPIO_BASE + 6, GPIOF_IN,   "busadr1"},
> +	{ MCP23S08_GPIO_BASE + 7, GPIOF_IN,   "busadr0"},
> +};
> +
> +static void __init cdu_add_gpio(void)
> +{

	gpio_request_array(gpios, ARRAY_SIZE(gpios));

> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
> +		gpio_request_one(gpios[i].gpio, gpios[i].flags, gpios[i].label);
> +		gpio_export_name(gpios[i].gpio, 0, gpios[i].label);

What does this function do? I can't find it anywhere.

> +	}
> +}
> +
> +/*
> + * init
> + */
> +static void __init cdu_board_init(void)
> +{
> +	at91_add_device_serial();
> +	at91_add_device_usbh(&cdu_usbh_data);
> +	at91_add_device_udc(&cdu_udc_data);
> +	at91_add_device_spi(cdu_spi_devices, ARRAY_SIZE(cdu_spi_devices));
> +	cdu_add_device_nand();
> +	at91_add_device_eth(&cdu_macb_data);
> +	at91_add_device_mmc(0, &ek_mmc_data);
> +	at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK | ATMEL_SSC_TD | ATMEL_SSC_RD));
> +	at91_gpio_leds(cdu_leds, ARRAY_SIZE(cdu_leds));
> +	cdu_add_gpio ();

No space between gpio and ().

> +}
> +
> +MACHINE_START(AT91SAM9260EK, "CDU")
> +	/* Maintainer: AKsignal Brno */

Website/email contact?

> +	.boot_params	= AT91_SDRAM_BASE + 0x100,
> +	.timer		= &at91sam926x_timer,
> +	.map_io		= cdu_map_io,
> +	.init_irq	= cdu_init_irq,
> +	.init_machine	= cdu_board_init,
> +MACHINE_END
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig
> linux-2.6.38-patch/arch/arm/mach-at91/Kconfig
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Kconfig	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/arch/arm/mach-at91/Kconfig	2011-03-16 09:19:40.000000000 +0100
> @@ -213,6 +213,12 @@ config MACH_AT91SAM9260EK
>  	  Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
>  	  <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
> 
> +config MACH_CDU
> +	bool "CDU AKsignal board"
> +	help
> +	  Select this if you are using AKsignal CDU board
> +	  <http://www.aksignal.cz>
> +
>  config MACH_CAM60
>  	bool "KwikByte KB9260 (CAM60) board"
>  	help
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile
> linux-2.6.38-patch/arch/arm/mach-at91/Makefile
> --- linux-2.6.38-vanilla/arch/arm/mach-at91/Makefile	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/arch/arm/mach-at91/Makefile	2011-03-16 09:19:40.000000000 +0100
> @@ -40,6 +40,7 @@ obj-$(CONFIG_MACH_ECO920)	+= board-eco92
> 
>  # AT91SAM9260 board-specific support
>  obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
> +obj-$(CONFIG_MACH_CDU)		 += board-cdu.o
>  obj-$(CONFIG_MACH_CAM60)	+= board-cam60.o
>  obj-$(CONFIG_MACH_SAM9_L9260)	+= board-sam9-l9260.o
>  obj-$(CONFIG_MACH_USB_A9260)	+= board-usb-a9260.o
> diff -uprN -X linux-2.6.38-vanilla/Documentation/dontdiff linux-2.6.38-vanilla/MAINTAINERS linux-2.6.38-patch/MAINTAINERS
> --- linux-2.6.38-vanilla/MAINTAINERS	2011-03-15 02:20:32.000000000 +0100
> +++ linux-2.6.38-patch/MAINTAINERS	2011-03-25 08:37:56.693049978 +0100
> @@ -1640,6 +1640,13 @@ F:	include/linux/can/error.h
>  F:	include/linux/can/netlink.h
>  F:	include/linux/can/platform/
> 
> +CDU BOARD
> +M:	Jiri Prchal <jiri.prchal@aksignal.cz>
> +L:	linux-arch@vger.kernel.org
> +W:	http://www.linux4sam.org
> +S:	Supported
> +F:	arch/arm/mach-at91/
> +
>  CELL BROADBAND ENGINE ARCHITECTURE
>  M:	Arnd Bergmann <arnd@arndb.de>
>  L:	linuxppc-dev@lists.ozlabs.org
> Soubory linux-2.6.38-vanilla/scripts/recordmcount a linux-2.6.38-patch/scripts/recordmcount jsou rĹŻznĂŠ


-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@bluewatersys.com         	PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com	New Zealand
Phone: +64 3 3779127		Freecall: Australia 1800 148 751
Fax:   +64 3 3779135			  USA 1800 261 2934

^ permalink raw reply	[flat|nested] 31+ messages in thread

* PROBLEM: ARM: PCM plugin Ima-ADPCM doesn't work properly
  2011-03-24 20:07       ` Ryan Mallon
                         ` (2 preceding siblings ...)
  (?)
@ 2011-05-31 13:05       ` Prchal Jiří
  -1 siblings, 0 replies; 31+ messages in thread
From: Prchal Jiří @ 2011-05-31 13:05 UTC (permalink / raw)
  Cc: alsa-devel, alsa-devel, abramo

Hi,
I have a problem converting S16_LE to ADPCM using pcm plugin. Data from this conversion look like just sign in it. This 
problem is on ARM platform, on I686 it works fine. Both version 1.0.23.
Here is part of asound.conf:

pcm.toadpcm {
	type adpcm
	slave {
		pcm tofile
		format IMA_ADPCM
	}
}

And here begin of data from conversion on ARM, in hex:
38 00 00 00 00 00 88 00 00 00 88 00 00 88 00 88 88 00 88 88 88 88 88 88 88 00 88 88 88 88 88 88

and on I686:
3b 77 77 77 77 77 77 77 77 77 77 11 88 00 88 88 88 88 99 99 99 aa aa aa bb bb bb cc bb bb cc aa

Where could be the problem? I try to look in source, but if it works on some platform?
Thanks for help.

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2011-05-31 13:05 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-24  6:54 [PATCH 0/2] mmc: zboot helpers Simon Horman
2011-03-24  6:54 ` Simon Horman
2011-03-24  6:54 ` [PATCH 1/2] mmc, ARM: Rename SuperH Mobile ARM " Simon Horman
2011-03-24  6:54   ` Simon Horman
2011-03-24  9:10   ` [PATCH] mmc, AT91: fix init fequency problem Prchal Jiří
2011-03-24  9:10     ` Prchal Jiří
2011-03-24 10:20   ` [PATCH 1/2] ALSA: ASoc: TLV320AIC3X: ad SPI and clock on GPIO2 or BCLK Prchal Jiří
2011-04-02  8:26     ` Mark Brown
2011-04-02  8:26       ` [alsa-devel] " Mark Brown
2011-04-04  7:49       ` Prchal Jiří
2011-04-04  8:03         ` Mark Brown
2011-04-04  8:01       ` [PATCH] ALSA: ASoc: new functions snd_soc_7_8_* Prchal Jiří
2011-04-04  8:05         ` Mark Brown
2011-04-04  8:05           ` Mark Brown
2011-03-24 10:43   ` [PATCH 2/2] ALSA: ASoc: putting together AT91SAM9260 and TLV320AIC3X Prchal Jiří
2011-03-24 20:07     ` Ryan Mallon
2011-03-24 20:07       ` Ryan Mallon
2011-04-04  8:57       ` Prchal Jiří
2011-04-04 20:07         ` Ryan Mallon
2011-04-04 20:07           ` Ryan Mallon
2011-04-04  9:10       ` [PATCH] ARCH arm: adding new board: CDU Prchal Jiří
2011-04-04  9:10         ` Prchal Jiří
2011-04-04  9:16         ` Russell King - ARM Linux
2011-04-04  9:16           ` Russell King - ARM Linux
2011-04-04  9:24           ` Russell King - ARM Linux
2011-04-04  9:24             ` Russell King - ARM Linux
2011-04-04 20:25         ` Ryan Mallon
2011-04-04 20:25           ` Ryan Mallon
2011-05-31 13:05       ` PROBLEM: ARM: PCM plugin Ima-ADPCM doesn't work properly Prchal Jiří
2011-03-24  6:54 ` [PATCH 2/2] mmc: Add MMC_PROGRESS_* Simon Horman
2011-03-24  6:54   ` Simon Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.