Add wm8904 based audio machine driver for Atmel EK board
The following ek board based on it
- at91sam9n12ek
- sama5d3xek (d31, d33, d34, d35)
Signed-off-by: Bo Shen
---
This patch is only for Atmel SoC with wm8904 codec machine driver
only, temp no change for dts file, as there are many changes to dts
file in mailing list for atmel SoC now, so hold on for dts change,
after that will send the dts file patches
Change in v2:
- Update the binding doc, add widgets describe of codec and board
- set sysclk after set pll
- using bias level trasition to decide enable/disable clock
- return real error code instead of return -1
Todo:
- After the at91 clock move to common clock framework, then rework
the clock in this driver
---
.../devicetree/bindings/sound/atmel-wm8904.txt | 55 +
sound/soc/atmel/Kconfig| 10 +
sound/soc/atmel/Makefile |2 +
sound/soc/atmel/atmel_wm8904.c | 254
4 files changed, 321 insertions(+)
create mode 100644 Documentation/devicetree/bindings/sound/atmel-wm8904.txt
create mode 100644 sound/soc/atmel/atmel_wm8904.c
diff --git a/Documentation/devicetree/bindings/sound/atmel-wm8904.txt
b/Documentation/devicetree/bindings/sound/atmel-wm8904.txt
new file mode 100644
index 000..8bbe50c
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/atmel-wm8904.txt
@@ -0,0 +1,55 @@
+Atmel ASoC driver with wm8904 audio codec complex
+
+Required properties:
+ - compatible: "atmel,asoc-wm8904"
+ - atmel,model: The user-visible name of this sound complex.
+ - atmel,audio-routing: A list of the connections between audio components.
+Each entry is a pair of strings, the first being the connection's sink,
+the second being the connection's source. Valid names for sources and
+sinks are the WM8904's pins, and the jacks on the board:
+
+WM8904 pins:
+
+* IN1L
+* IN1R
+* IN2L
+* IN2R
+* IN3L
+* IN3R
+* HPOUTL
+* HPOUTR
+* LINEOUTL
+* LINEOUTR
+* MICBIAS
+
+Board connectors:
+
+* Headphone Jack
+* Line In Jack
+* Mic
+
+ - atmel,ssc-controller: The phandle of the SSC controller
+ - atmel,audio-codec: The phandle of the WM8904 audio codec
+
+Optional properties:
+ - pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt
+
+Example:
+sound {
+ compatible = "atmel,asoc-wm8904";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_pck0_as_mck>;
+
+ atmel,model = "wm8904 @ AT91SAM9N12EK";
+
+ atmel,audio-routing =
+ "Headphone Jack", "HPOUTL",
+ "Headphone Jack", "HPOUTR",
+ "IN2L", "Line In Jack",
+ "IN2R", "Line In Jack",
+ "Mic", "MICBIAS",
+ "IN1L", "Mic";
+
+ atmel,ssc-controller = <&ssc0>;
+ atmel,audio-codec = <&wm8904>;
+};
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
index 1c0b185..986323b 100644
--- a/sound/soc/atmel/Kconfig
+++ b/sound/soc/atmel/Kconfig
@@ -33,6 +33,16 @@ config SND_AT91_SOC_SAM9G20_WM8731
Say Y if you want to add support for SoC audio on WM8731-based
AT91sam9g20 evaluation board.
+config SND_ATMEL_SOC_WM8904
+ tristate "Atmel ASoC driver for boards using WM8904 codec"
+ depends on ARCH_AT91 && ATMEL_SSC && SND_ATMEL_SOC
+ select SND_ATMEL_SOC_SSC
+ select SND_ATMEL_SOC_DMA
+ select SND_SOC_WM8904
+ help
+ Say Y if you want to add support for Atmel ASoC driver for boards
using
+ WM8904 codec.
+
config SND_AT91_SOC_AFEB9260
tristate "SoC Audio support for AFEB9260 board"
depends on ARCH_AT91 && ATMEL_SSC && ARCH_AT91 && MACH_AFEB9260 &&
SND_ATMEL_SOC
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile
index 41967cc..922d4da 100644
--- a/sound/soc/atmel/Makefile
+++ b/sound/soc/atmel/Makefile
@@ -11,6 +11,8 @@ obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o
# AT91 Machine Support
snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o
+snd-atmel-soc-wm8904-objs := atmel_wm8904.o
obj-$(CONFIG_SND_AT91_SOC_SAM9G20_WM8731) += snd-soc-sam9g20-wm8731.o
+obj-$(CONFIG_SND_ATMEL_SOC_WM8904) += snd-atmel-soc-wm8904.o
obj-$(CONFIG_SND_AT91_SOC_AFEB9260) += snd-soc-afeb9260.o
diff --git a/sound/soc/atmel/atmel_wm8904.c b/sound/soc/atmel/atmel_wm8904.c
new file mode 100644
index 000..7222380
--- /dev/null
+++ b/sound/soc/atmel/atmel_wm8904.c
@@ -0,0 +1,254 @@
+/*
+ * atmel_wm8904 - Atmel ASoC driver for boards with WM8904 codec.
+ *
+ * Copyright (C) 2012 Atmel
+ *
+ * Author: Bo Shen
+ *
+ * GPLv2 or later
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include "../codecs/wm8904.h"
+#include "atmel_ssc_dai.h"
+
+#define MCLK_RATE 32768
+
+static struct clk *mclk;
+
+static const struct snd_soc_dapm_widget atmel_asoc_wm8904_dapm_widgets[] = {
+ SND_SOC_DAPM_HP("Headphone Jack",