[U-Boot] [PATCH 0/5] EXYNOS5: FDT support for Sound

This patch adds FDT support for Sound driver.
This patch is based on following patchset. "EXYNOS5: FDT Support for I2C"
Rajeshwari Shinde (5): EXYNOS5: FDT: Add sound device node data EXYNOS5: FDT: Add sound and codec device node informations EXYNOS5: FDT: Add compatible strings for sound Sound: Add FDT support to driver Sound: Add FDT support to CMD.
arch/arm/dts/exynos5250.dtsi | 5 + board/samsung/dts/exynos5250-smdk5250.dts | 20 +++ common/cmd_sound.c | 4 + drivers/sound/sound.c | 228 ++++++++++++++++++++++++++++- include/fdtdec.h | 3 + include/sound.h | 9 + lib/fdtdec.c | 2 + 7 files changed, 264 insertions(+), 7 deletions(-)

Add sound device node data for exynos
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- arch/arm/dts/exynos5250.dtsi | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi index e877e6c..3f750f0 100644 --- a/arch/arm/dts/exynos5250.dtsi +++ b/arch/arm/dts/exynos5250.dtsi @@ -97,4 +97,9 @@ reg = <0x12CD0000 0x100>; interrupts = <0 63 0>; }; + + sound@12d60000 { + compatible = "samsung,exynos-sound"; + reg = <0x12d60000 0x20>; + }; };

Hi Rajeshwari,
On Wed, Nov 7, 2012 at 9:37 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
Add sound device node data for exynos
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
I presume the kernel has no such driver so we cannot copy their binding? You should add the fdt bindings file here for sound - see doc/device-tree-bindings.
arch/arm/dts/exynos5250.dtsi | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/arch/arm/dts/exynos5250.dtsi b/arch/arm/dts/exynos5250.dtsi index e877e6c..3f750f0 100644 --- a/arch/arm/dts/exynos5250.dtsi +++ b/arch/arm/dts/exynos5250.dtsi @@ -97,4 +97,9 @@ reg = <0x12CD0000 0x100>; interrupts = <0 63 0>; };
sound@12d60000 {
compatible = "samsung,exynos-sound";
reg = <0x12d60000 0x20>;
};
};
1.7.4.4
Regards, Simon

Adds sound and codec device node parameters
Signed-off-by: R. Chandrasekar rcsekar@samsung.com Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- board/samsung/dts/exynos5250-smdk5250.dts | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/board/samsung/dts/exynos5250-smdk5250.dts b/board/samsung/dts/exynos5250-smdk5250.dts index 8722b36..6a500e1 100644 --- a/board/samsung/dts/exynos5250-smdk5250.dts +++ b/board/samsung/dts/exynos5250-smdk5250.dts @@ -50,4 +50,24 @@ samsung,slope = <268470274>; samsung,dc-value = <25>; }; + + sound@12d60000 { + samsung,i2s-epll-clock-frequency = <192000000>; + samsung,i2s-sampling-rate = <48000>; + samsung,i2s-bits-per-sample = <16>; + samsung,i2s-channels = <2>; + samsung,i2s-lr-clk-framesize = <256>; + samsung,i2s-bit-clk-framesize = <32>; + }; + + sound@12d60000 { + samsung,codec-type = "wm8994"; + }; + + i2c@12c70000 { + soundcodec@1a { + reg = <0x1a>; + compatible = "wolfson,wm8994-codec"; + }; + }; };

Hi,
On Wed, Nov 7, 2012 at 9:37 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
Adds sound and codec device node parameters
Signed-off-by: R. Chandrasekar rcsekar@samsung.com Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
The binding for all of this should be in the previous patch as mentioned.
board/samsung/dts/exynos5250-smdk5250.dts | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/board/samsung/dts/exynos5250-smdk5250.dts b/board/samsung/dts/exynos5250-smdk5250.dts index 8722b36..6a500e1 100644 --- a/board/samsung/dts/exynos5250-smdk5250.dts +++ b/board/samsung/dts/exynos5250-smdk5250.dts @@ -50,4 +50,24 @@ samsung,slope = <268470274>; samsung,dc-value = <25>; };
sound@12d60000 {
samsung,i2s-epll-clock-frequency = <192000000>;
samsung,i2s-sampling-rate = <48000>;
samsung,i2s-bits-per-sample = <16>;
samsung,i2s-channels = <2>;
samsung,i2s-lr-clk-framesize = <256>;
samsung,i2s-bit-clk-framesize = <32>;
};
sound@12d60000 {
samsung,codec-type = "wm8994";
This is the only thing that is odd to me. Maybe you want a phandle here pointing to the soundcodec node.
};
i2c@12c70000 {
soundcodec@1a {
reg = <0x1a>;
compatible = "wolfson,wm8994-codec";
Or maybe better a phandle here pointing to the sound node.
This soundcodec node should be found and examined by your wolfson driver, not the sound driver. So I think you need a few lines of code in the wolfson driver, and a call to the sound code to attach the driver.
At present you are teaching the sound module about different drivers, but that is a bit backwards. It should be possible in principle to add new sound drivers without touching the sound module. It also seems odd to put wm8994 twice in the fdt.
I know this is a fairly small change, but I think it is more correct.
};
};
};
1.7.4.4
Regards, Simon

Add required compatible information for sound driver.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- include/fdtdec.h | 3 +++ lib/fdtdec.c | 2 ++ 2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index d501d7e..a8dacac 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -70,6 +70,9 @@ enum fdt_compat_id { COMPAT_SAMSUNG_EXYNOS5_SROMC, /* Exynos5 SROMC */ COMPAT_SAMSUNG_EXYNOS_TMU, /* Exynos TMU */ COMPAT_SAMSUNG_S3C2440_I2C, /* Exynos I2C Controller */ + COMPAT_SAMSUNG_EXYNOS5_SOUND, /* Exynos Sound */ + COMPAT_WOLFSON_WM8994_CODEC, /* Wolfson WM8994 Sound Codec */ + COMPAT_SAMSUNG_EXYNOS_SPI, /* Exynos SPI */
COMPAT_COUNT, }; diff --git a/lib/fdtdec.c b/lib/fdtdec.c index dbfca1a..624d55e 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -47,6 +47,8 @@ static const char * const compat_names[COMPAT_COUNT] = { COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"), COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"), COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"), + COMPAT(SAMSUNG_EXYNOS5_SOUND, "samsung,exynos-sound"), + COMPAT(WOLFSON_WM8994_CODEC, "wolfson,wm8994-codec"), };
const char *fdtdec_get_compatible(enum fdt_compat_id id)

Hi Rajeshwari,
On Wed, Nov 7, 2012 at 9:37 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
Add required compatible information for sound driver.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
include/fdtdec.h | 3 +++ lib/fdtdec.c | 2 ++ 2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h index d501d7e..a8dacac 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -70,6 +70,9 @@ enum fdt_compat_id { COMPAT_SAMSUNG_EXYNOS5_SROMC, /* Exynos5 SROMC */ COMPAT_SAMSUNG_EXYNOS_TMU, /* Exynos TMU */ COMPAT_SAMSUNG_S3C2440_I2C, /* Exynos I2C Controller */
COMPAT_SAMSUNG_EXYNOS5_SOUND, /* Exynos Sound */
COMPAT_WOLFSON_WM8994_CODEC, /* Wolfson WM8994 Sound Codec */
COMPAT_SAMSUNG_EXYNOS_SPI, /* Exynos SPI */
suggest punting this
COMPAT_COUNT,
}; diff --git a/lib/fdtdec.c b/lib/fdtdec.c index dbfca1a..624d55e 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -47,6 +47,8 @@ static const char * const compat_names[COMPAT_COUNT] = { COMPAT(SAMSUNG_EXYNOS5_SROMC, "samsung,exynos-sromc"), COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"), COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"),
COMPAT(SAMSUNG_EXYNOS5_SOUND, "samsung,exynos-sound"),
COMPAT(WOLFSON_WM8994_CODEC, "wolfson,wm8994-codec"),
};
const char *fdtdec_get_compatible(enum fdt_compat_id id)
1.7.4.4
Regards, Simon

This patch adds FDT support to the driver.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- drivers/sound/sound.c | 228 +++++++++++++++++++++++++++++++++++++++++++++++-- include/sound.h | 9 ++ 2 files changed, 230 insertions(+), 7 deletions(-)
diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c index 4c74534..3a845c9 100644 --- a/drivers/sound/sound.c +++ b/drivers/sound/sound.c @@ -24,6 +24,8 @@ #include <malloc.h> #include <common.h> #include <asm/io.h> +#include <libfdt.h> +#include <fdtdec.h> #include <i2c.h> #include <i2s.h> #include <sound.h> @@ -37,12 +39,225 @@ static struct i2stx_info g_i2stx_pri; static struct sound_codec_info g_codec_info;
+ +#ifdef CONFIG_OF_CONTROL /* - * get_sound_fdt_values gets fdt values for i2s parameters + * get_sound_i2s_fdt_values gets fdt values for i2s parameters * * @param i2stx_info i2s transmitter transfer param structure * @param blob FDT blob */ +static int get_sound_i2s_fdt_values(struct i2stx_info *i2s, const void *blob) +{ + int node; + int error = 0; + int base; + + node = fdtdec_next_compatible(blob, 0, + COMPAT_SAMSUNG_EXYNOS5_SOUND); + if (node <= 0) { + debug("EXYNOS_SOUND: No node for sound in device tree\n"); + return -1; + } + + /* + * Get the pre-defined sound specific values from FDT. + * All of these are expected to be correct otherwise + * wrong register values in i2s setup parameters + * may result in no sound play. + */ + base = fdtdec_get_addr(blob, node, "reg"); + if (base == FDT_ADDR_T_NONE) { + debug("%s: Missing i2s base\n", __func__); + return -1; + } + i2s->base_address = base; + + i2s->audio_pll_clk = fdtdec_get_int(blob, + node, "samsung,i2s-epll-clock-frequency", -1); + error |= i2s->audio_pll_clk; + debug("audio_pll_clk = %d\n", i2s->audio_pll_clk); + i2s->samplingrate = fdtdec_get_int(blob, + node, "samsung,i2s-sampling-rate", -1); + error |= i2s->samplingrate; + debug("samplingrate = %d\n", i2s->samplingrate); + i2s->bitspersample = fdtdec_get_int(blob, + node, "samsung,i2s-bits-per-sample", -1); + error |= i2s->bitspersample; + debug("bitspersample = %d\n", i2s->bitspersample); + i2s->channels = fdtdec_get_int(blob, + node, "samsung,i2s-channels", -1); + error |= i2s->channels; + debug("channels = %d\n", i2s->channels); + i2s->rfs = fdtdec_get_int(blob, + node, "samsung,i2s-lr-clk-framesize", -1); + error |= i2s->rfs; + debug("rfs = %d\n", i2s->rfs); + i2s->bfs = fdtdec_get_int(blob, + node, "samsung,i2s-bit-clk-framesize", -1); + error |= i2s->bfs; + debug("bfs = %d\n", i2s->bfs); + if (error == -1) { + debug("fail to get sound i2s node properties\n"); + return -1; + } + + return 0; +} + +/* + * Gets fdt values for wm8994 config parameters + * + * @param pcodec_info codec information structure + * @param blob FDT blob + * @return int value, 0 for success + */ +static int get_sound_fdt_values(struct sound_codec_info *pcodec_info, + const void *blob, enum fdt_compat_id compat_id) +{ + enum fdt_compat_id compat; + int node; + int error = 0; + int parent; + + /* Get the node from FDT for codec */ + node = fdtdec_next_compatible(blob, 0, compat_id); + if (node <= 0) { + debug("EXYNOS_SOUND: No node for codec in device tree\n"); + debug("node = %d\n", node); + return -1; + } + + parent = fdt_parent_offset(blob, node); + if (parent < 0) { + debug("%s: Cannot find node parent\n", __func__); + return -1; + } + + compat = fdtdec_lookup(blob, parent); + switch (compat) { + case COMPAT_SAMSUNG_EXYNOS_SPI: + debug("%s: Support not added for SPI interface\n", __func__); + return -1; + break; + case COMPAT_SAMSUNG_S3C2440_I2C: + pcodec_info->i2c_bus = i2c_get_bus_num_fdt(blob, parent); + error |= pcodec_info->i2c_bus; + debug("i2c bus = %d\n", pcodec_info->i2c_bus); + pcodec_info->i2c_dev_addr = fdtdec_get_int(blob, node, + "reg", 0); + error |= pcodec_info->i2c_dev_addr; + debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr); + break; + default: + debug("%s: Unknown compat id %d\n", __func__, compat); + return -1; + } + + if (error == -1) { + debug("fail to get codec node properties\n"); + return -1; + } + + return 0; +} + +/* + * Gets fdt values for codec config parameters + * + * @param pcodec_info codec information structure + * @param blob FDT blob + * @return int value, 0 for success + */ +static int get_sound_codec_fdt_values(struct sound_codec_info *pcodec_info, + const void *blob) +{ + int node; + int error = 0; + const char *codectype; + + /* Get the node from FDT for sound */ + node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_SOUND); + if (node <= 0) { + debug("EXYNOS_SOUND: No node for sound in device tree\n"); + debug("node = %d\n", node); + return -1; + } + + /* + * Get the pre-defined sound codec specific values from FDT. + * All of these are expected to be correct otherwise sound + * can not be played + */ + codectype = fdt_getprop(blob, node, "samsung,codec-type", NULL); + debug("device = %s\n", codectype); + + if (!strcmp(codectype, "wm8994")) { + pcodec_info->codec_type = CODEC_WM_8994; + error = get_sound_fdt_values(pcodec_info, blob, + COMPAT_WOLFSON_WM8994_CODEC); + } else { + error = -1; + } + + if (error == -1) { + debug("fail to get sound codec node properties\n"); + return -1; + } + + return 0; +} + +int sound_init(const void *blob) +{ + int ret; + struct i2stx_info *pi2s_tx = &g_i2stx_pri; + struct sound_codec_info *pcodec_info = &g_codec_info; + + /* Get the I2S Values */ + if (get_sound_i2s_fdt_values(pi2s_tx, blob) < 0) { + debug(" FDT I2S values failed\n"); + return -1; + } + + /* Get the codec Values */ + if (get_sound_codec_fdt_values(pcodec_info, blob) < 0) { + debug("FDT Codec values failed\n"); + return -1; + } + + ret = i2s_tx_init(pi2s_tx); + if (ret) { + debug("%s: Failed to init i2c transmit: ret=%d\n", __func__, + ret); + return ret; + } + + /* Check the codec type and initialise the same */ + if (pcodec_info->codec_type == CODEC_WM_8994) { + ret = wm8994_init(pcodec_info, WM8994_AIF2, + pi2s_tx->samplingrate, + (pi2s_tx->samplingrate * (pi2s_tx->rfs)), + pi2s_tx->bitspersample, pi2s_tx->channels); + } else { + debug("%s: Unknown code type %d\n", __func__, + pcodec_info->codec_type); + return -1; + } + if (ret) { + debug("%s: Codec init failed\n", __func__); + return -1; + } + + return ret; +} + +#else +/* + * get_sound_values gets values for i2s parameters + * + * @param i2stx_info i2s transmitter transfer param structure + */ static void get_sound_i2s_values(struct i2stx_info *i2s) { i2s->base_address = samsung_get_base_i2s(); @@ -55,13 +270,12 @@ static void get_sound_i2s_values(struct i2stx_info *i2s) }
/* - * Gets fdt values for wm8994 config parameters + * Gets values for wm8994 config parameters * * @param pcodec_info codec information structure - * @param blob FDT blob * @return int value, 0 for success */ -static int get_sound_wm8994_values(struct sound_codec_info *pcodec_info) +static int get_sound_values(struct sound_codec_info *pcodec_info) { int error = 0;
@@ -89,10 +303,9 @@ static int get_sound_wm8994_values(struct sound_codec_info *pcodec_info) }
/* - * Gets fdt values for codec config parameters + * Gets values for codec config parameters * * @param pcodec_info codec information structure - * @param blob FDT blob * @return int value, 0 for success */ static int get_sound_codec_values(struct sound_codec_info *pcodec_info) @@ -104,7 +317,7 @@ static int get_sound_codec_values(struct sound_codec_info *pcodec_info)
if (!strcmp(codectype, "wm8994")) { pcodec_info->codec_type = CODEC_WM_8994; - error = get_sound_wm8994_values(pcodec_info); + error = get_sound_values(pcodec_info); } else { error = -1; } @@ -155,6 +368,7 @@ int sound_init(void)
return ret; } +#endif
/* * Generates square wave sound data for 1 second diff --git a/include/sound.h b/include/sound.h index ea0b115..aeb70ee 100644 --- a/include/sound.h +++ b/include/sound.h @@ -44,12 +44,21 @@ struct sound_codec_info { enum en_sound_codec codec_type; };
+#ifdef CONFIG_OF_CONTROL +/* + * Initialises audio sub system + * @param blob Pointer of device tree node. + * @return int value 0 for success, -1 for error + */ +int sound_init(const void *blob); +#else /* * Initialises audio sub system * * @return int value 0 for success, -1 for error */ int sound_init(void); +#endif
/* * plays the pcm data buffer in pcm_data.h through i2s1 to make the

Hi Rajeshwari,
On Wed, Nov 7, 2012 at 9:37 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch adds FDT support to the driver.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
drivers/sound/sound.c | 228 +++++++++++++++++++++++++++++++++++++++++++++++-- include/sound.h | 9 ++ 2 files changed, 230 insertions(+), 7 deletions(-)
diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c index 4c74534..3a845c9 100644 --- a/drivers/sound/sound.c +++ b/drivers/sound/sound.c @@ -24,6 +24,8 @@ #include <malloc.h> #include <common.h> #include <asm/io.h> +#include <libfdt.h> +#include <fdtdec.h> #include <i2c.h> #include <i2s.h> #include <sound.h> @@ -37,12 +39,225 @@ static struct i2stx_info g_i2stx_pri; static struct sound_codec_info g_codec_info;
+#ifdef CONFIG_OF_CONTROL /*
- get_sound_fdt_values gets fdt values for i2s parameters
*/
- get_sound_i2s_fdt_values gets fdt values for i2s parameters
- @param i2stx_info i2s transmitter transfer param structure
- @param blob FDT blob
+static int get_sound_i2s_fdt_values(struct i2stx_info *i2s, const void *blob) +{
int node;
int error = 0;
int base;
node = fdtdec_next_compatible(blob, 0,
COMPAT_SAMSUNG_EXYNOS5_SOUND);
if (node <= 0) {
debug("EXYNOS_SOUND: No node for sound in device tree\n");
return -1;
}
/*
* Get the pre-defined sound specific values from FDT.
* All of these are expected to be correct otherwise
* wrong register values in i2s setup parameters
* may result in no sound play.
*/
base = fdtdec_get_addr(blob, node, "reg");
if (base == FDT_ADDR_T_NONE) {
debug("%s: Missing i2s base\n", __func__);
return -1;
}
i2s->base_address = base;
i2s->audio_pll_clk = fdtdec_get_int(blob,
node, "samsung,i2s-epll-clock-frequency", -1);
error |= i2s->audio_pll_clk;
debug("audio_pll_clk = %d\n", i2s->audio_pll_clk);
i2s->samplingrate = fdtdec_get_int(blob,
node, "samsung,i2s-sampling-rate", -1);
error |= i2s->samplingrate;
debug("samplingrate = %d\n", i2s->samplingrate);
i2s->bitspersample = fdtdec_get_int(blob,
node, "samsung,i2s-bits-per-sample", -1);
error |= i2s->bitspersample;
debug("bitspersample = %d\n", i2s->bitspersample);
i2s->channels = fdtdec_get_int(blob,
node, "samsung,i2s-channels", -1);
error |= i2s->channels;
debug("channels = %d\n", i2s->channels);
i2s->rfs = fdtdec_get_int(blob,
node, "samsung,i2s-lr-clk-framesize", -1);
error |= i2s->rfs;
debug("rfs = %d\n", i2s->rfs);
i2s->bfs = fdtdec_get_int(blob,
node, "samsung,i2s-bit-clk-framesize", -1);
error |= i2s->bfs;
debug("bfs = %d\n", i2s->bfs);
if (error == -1) {
debug("fail to get sound i2s node properties\n");
return -1;
}
return 0;
+}
+/*
- Gets fdt values for wm8994 config parameters
Should not mention the particular codec here - this driver should work with any.
- @param pcodec_info codec information structure
- @param blob FDT blob
- @return int value, 0 for success
- */
+static int get_sound_fdt_values(struct sound_codec_info *pcodec_info,
const void *blob, enum fdt_compat_id compat_id)
+{
enum fdt_compat_id compat;
int node;
int error = 0;
int parent;
/* Get the node from FDT for codec */
node = fdtdec_next_compatible(blob, 0, compat_id);
if (node <= 0) {
debug("EXYNOS_SOUND: No node for codec in device tree\n");
debug("node = %d\n", node);
return -1;
}
parent = fdt_parent_offset(blob, node);
if (parent < 0) {
debug("%s: Cannot find node parent\n", __func__);
return -1;
}
compat = fdtdec_lookup(blob, parent);
switch (compat) {
case COMPAT_SAMSUNG_EXYNOS_SPI:
debug("%s: Support not added for SPI interface\n", __func__);
return -1;
break;
Perhaps just punt this spi code then?
case COMPAT_SAMSUNG_S3C2440_I2C:
pcodec_info->i2c_bus = i2c_get_bus_num_fdt(blob, parent);
error |= pcodec_info->i2c_bus;
debug("i2c bus = %d\n", pcodec_info->i2c_bus);
pcodec_info->i2c_dev_addr = fdtdec_get_int(blob, node,
"reg", 0);
error |= pcodec_info->i2c_dev_addr;
debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr);
break;
default:
debug("%s: Unknown compat id %d\n", __func__, compat);
return -1;
}
if (error == -1) {
debug("fail to get codec node properties\n");
return -1;
}
return 0;
+}
+/*
- Gets fdt values for codec config parameters
- @param pcodec_info codec information structure
- @param blob FDT blob
- @return int value, 0 for success
- */
+static int get_sound_codec_fdt_values(struct sound_codec_info *pcodec_info,
const void *blob)
+{
int node;
int error = 0;
const char *codectype;
/* Get the node from FDT for sound */
node = fdtdec_next_compatible(blob, 0, COMPAT_SAMSUNG_EXYNOS5_SOUND);
if (node <= 0) {
debug("EXYNOS_SOUND: No node for sound in device tree\n");
debug("node = %d\n", node);
return -1;
}
/*
* Get the pre-defined sound codec specific values from FDT.
* All of these are expected to be correct otherwise sound
* can not be played
*/
codectype = fdt_getprop(blob, node, "samsung,codec-type", NULL);
debug("device = %s\n", codectype);
if (!strcmp(codectype, "wm8994")) {
pcodec_info->codec_type = CODEC_WM_8994;
error = get_sound_fdt_values(pcodec_info, blob,
COMPAT_WOLFSON_WM8994_CODEC);
} else {
error = -1;
}
As mentioned I think this code should move into the wm8994 driver. You can just look for the compatible string there.
if (error == -1) {
debug("fail to get sound codec node properties\n");
return -1;
}
return 0;
+}
+int sound_init(const void *blob) +{
int ret;
struct i2stx_info *pi2s_tx = &g_i2stx_pri;
struct sound_codec_info *pcodec_info = &g_codec_info;
/* Get the I2S Values */
if (get_sound_i2s_fdt_values(pi2s_tx, blob) < 0) {
debug(" FDT I2S values failed\n");
return -1;
}
/* Get the codec Values */
if (get_sound_codec_fdt_values(pcodec_info, blob) < 0) {
debug("FDT Codec values failed\n");
return -1;
}
ret = i2s_tx_init(pi2s_tx);
if (ret) {
debug("%s: Failed to init i2c transmit: ret=%d\n", __func__,
ret);
return ret;
}
/* Check the codec type and initialise the same */
if (pcodec_info->codec_type == CODEC_WM_8994) {
ret = wm8994_init(pcodec_info, WM8994_AIF2,
pi2s_tx->samplingrate,
(pi2s_tx->samplingrate * (pi2s_tx->rfs)),
pi2s_tx->bitspersample, pi2s_tx->channels);
Perhaps the wm8994 driver should call sound_init() and pass a structure containing its functions for codec setup, etc. as needed? Seems better than calling out to different codecs in the generic sound driver.
} else {
debug("%s: Unknown code type %d\n", __func__,
pcodec_info->codec_type);
return -1;
}
if (ret) {
debug("%s: Codec init failed\n", __func__);
return -1;
}
return ret;
+}
+#else +/*
- get_sound_values gets values for i2s parameters
- @param i2stx_info i2s transmitter transfer param structure
- */
static void get_sound_i2s_values(struct i2stx_info *i2s) { i2s->base_address = samsung_get_base_i2s(); @@ -55,13 +270,12 @@ static void get_sound_i2s_values(struct i2stx_info *i2s) }
/*
- Gets fdt values for wm8994 config parameters
- Gets values for wm8994 config parameters
- @param pcodec_info codec information structure
*/
- @param blob FDT blob
- @return int value, 0 for success
-static int get_sound_wm8994_values(struct sound_codec_info *pcodec_info) +static int get_sound_values(struct sound_codec_info *pcodec_info) { int error = 0;
@@ -89,10 +303,9 @@ static int get_sound_wm8994_values(struct sound_codec_info *pcodec_info) }
/*
- Gets fdt values for codec config parameters
- Gets values for codec config parameters
- @param pcodec_info codec information structure
*/
- @param blob FDT blob
- @return int value, 0 for success
static int get_sound_codec_values(struct sound_codec_info *pcodec_info) @@ -104,7 +317,7 @@ static int get_sound_codec_values(struct sound_codec_info *pcodec_info)
if (!strcmp(codectype, "wm8994")) { pcodec_info->codec_type = CODEC_WM_8994;
error = get_sound_wm8994_values(pcodec_info);
error = get_sound_values(pcodec_info); } else { error = -1; }
@@ -155,6 +368,7 @@ int sound_init(void)
return ret;
} +#endif
/*
- Generates square wave sound data for 1 second
diff --git a/include/sound.h b/include/sound.h index ea0b115..aeb70ee 100644 --- a/include/sound.h +++ b/include/sound.h @@ -44,12 +44,21 @@ struct sound_codec_info { enum en_sound_codec codec_type; };
+#ifdef CONFIG_OF_CONTROL +/*
- Initialises audio sub system
- @param blob Pointer of device tree node.
- @return int value 0 for success, -1 for error
- */
+int sound_init(const void *blob); +#else
This is a bit ugly - you can just pass the blob even if CONFIG_OF_CONTROL is not set. It will be NULL. That avoids two function signatures.
/*
- Initialises audio sub system
- @return int value 0 for success, -1 for error
*/ int sound_init(void); +#endif
/*
- plays the pcm data buffer in pcm_data.h through i2s1 to make the
-- 1.7.4.4
Regards, Simon

This patch adds FDT support to sound init.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- common/cmd_sound.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/common/cmd_sound.c b/common/cmd_sound.c index 459d1eb..ad8669f 100644 --- a/common/cmd_sound.c +++ b/common/cmd_sound.c @@ -33,7 +33,11 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { int ret;
+#ifdef CONFIG_OF_CONTROL + ret = sound_init(gd->fdt_blob); +#else ret = sound_init(); +#endif if (ret) { printf("Initialise Audio driver failed\n"); return CMD_RET_FAILURE;

Hi Rajeshwari,
On Wed, Nov 7, 2012 at 9:37 PM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This patch adds FDT support to sound init.
Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
common/cmd_sound.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/common/cmd_sound.c b/common/cmd_sound.c index 459d1eb..ad8669f 100644 --- a/common/cmd_sound.c +++ b/common/cmd_sound.c @@ -33,7 +33,11 @@ static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { int ret;
+#ifdef CONFIG_OF_CONTROL
ret = sound_init(gd->fdt_blob);
+#else ret = sound_init(); +#endif
Same comment here.
if (ret) { printf("Initialise Audio driver failed\n"); return CMD_RET_FAILURE;
-- 1.7.4.4
Regards, Simon
participants (2)
-
Rajeshwari Shinde
-
Simon Glass