From patchwork Wed Nov 28 06:10:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Birje X-Patchwork-Id: 202370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 5A4AE2C0095 for ; Wed, 28 Nov 2012 17:05:00 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7D5534A0BD; Wed, 28 Nov 2012 07:04:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C1LWMoHUYE6P; Wed, 28 Nov 2012 07:04:42 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 35A9F4A0BE; Wed, 28 Nov 2012 07:04:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A719D4A094 for ; Wed, 28 Nov 2012 07:04:04 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JFFLek30Zf8t for ; Wed, 28 Nov 2012 07:04:03 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by theia.denx.de (Postfix) with ESMTP id 4B55D4A09C for ; Wed, 28 Nov 2012 07:03:57 +0100 (CET) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ME6007O8OTV45L0@mailout2.samsung.com> for u-boot@lists.denx.de; Wed, 28 Nov 2012 15:03:54 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 31.31.01231.A49A5B05; Wed, 28 Nov 2012 15:03:54 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-19-50b5a94a0a01 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D0.31.01231.A49A5B05; Wed, 28 Nov 2012 15:03:54 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0ME600J1EOU4G930@mmp2.samsung.com> for u-boot@lists.denx.de; Wed, 28 Nov 2012 15:03:53 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Date: Wed, 28 Nov 2012 11:40:11 +0530 Message-id: <1354083013-5213-6-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1354083013-5213-1-git-send-email-rajeshwari.s@samsung.com> References: <1354083013-5213-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsWyRsSkWtdr5dYAg9ubBSze7u1kd2D0OHtn B2MAYxSXTUpqTmZZapG+XQJXRsOrLraCFruKd9cdGhiPGnYxcnJICJhIzDrymwXCFpO4cG89 WxcjF4eQwFJGiWcdTcwwRZ2z97CC2EIC0xklFk2vgChaxSTRdWo5WIJNwEhi68lpjCC2iICE xK/+q2A2s0CMxOv9P9hAbGEBC4kl90E2cHCwCKhKrJ9nDxLmFXCX6FrwhxVil4LEsalfwWxO AQ+Je72L2CH2ukus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UYRN5O00/q6d/+M7Jy2SOyOlNzGLLcpDfvP1l7Zb VI5NP+zRWrRaPzJZ34/faLKu8rFPnLNn3D5uvejyXfeIFREOOnfuTOttjk2Z9ihjhcpqgx1x u+6ynNioza4ZdUN0i+5rifmOJSceT9++mfmpAfcdXiWW4oxEQy3mouJEAPYShMOcAgAA X-CFilter-Loop: Reflected Cc: patches@linaro.org Subject: [U-Boot] [PATCH 5/7 V2] Sound: Add FDT support to driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This patch adds FDT support to the sound driver. Signed-off-by: Rajeshwari Shinde --- Changes in V2: - Made single function to get i2s values,codec init and sount init in both FDT and non FDT support case. drivers/sound/sound.c | 179 +++++++++++++++++++++++++++++------------------- include/sound.h | 4 +- 2 files changed, 110 insertions(+), 73 deletions(-) diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c index 4c74534..bc87a9b 100644 --- a/drivers/sound/sound.c +++ b/drivers/sound/sound.c @@ -28,108 +28,160 @@ #include #include #include "wm8994.h" +#ifdef CONFIG_OF_CONTROL +#include +#include +#else #include +#endif /* defines */ #define SOUND_400_HZ 400 #define SOUND_BITS_IN_BYTE 8 static struct i2stx_info g_i2stx_pri; -static struct sound_codec_info g_codec_info; /* - * get_sound_fdt_values gets fdt values for i2s parameters + * get_sound_i2s_values gets values for i2s parameters * * @param i2stx_info i2s transmitter transfer param structure - * @param blob FDT blob + * @param blob FDT blob if enabled else NULL */ -static void get_sound_i2s_values(struct i2stx_info *i2s) -{ - i2s->base_address = samsung_get_base_i2s(); - i2s->audio_pll_clk = I2S_PLL_CLK; - i2s->samplingrate = I2S_SAMPLING_RATE; - i2s->bitspersample = I2S_BITS_PER_SAMPLE; - i2s->channels = I2S_CHANNELS; - i2s->rfs = I2S_RFS; - i2s->bfs = I2S_BFS; -} - -/* - * 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_wm8994_values(struct sound_codec_info *pcodec_info) +static int get_sound_i2s_values(struct i2stx_info *i2s, const void *blob) { +#ifdef CONFIG_OF_CONTROL + int node; int error = 0; + int base; - switch (AUDIO_COMPAT) { - case AUDIO_COMPAT_SPI: - debug("%s: Support not added for SPI interface\n", __func__); + 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; - break; - case AUDIO_COMPAT_I2C: - pcodec_info->i2c_bus = AUDIO_I2C_BUS; - pcodec_info->i2c_dev_addr = AUDIO_I2C_REG; - debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr); - break; - default: - debug("%s: Unknown compat id %d\n", __func__, AUDIO_COMPAT); + } + + /* + * 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 wm8994 codec node properties\n"); + debug("fail to get sound i2s node properties\n"); return -1; } - +#else + i2s->base_address = samsung_get_base_i2s(); + i2s->audio_pll_clk = I2S_PLL_CLK; + i2s->samplingrate = I2S_SAMPLING_RATE; + i2s->bitspersample = I2S_BITS_PER_SAMPLE; + i2s->channels = I2S_CHANNELS; + i2s->rfs = I2S_RFS; + i2s->bfs = I2S_BFS; +#endif return 0; } /* - * Gets fdt values for codec config parameters + * Init codec * - * @param pcodec_info codec information structure - * @param blob FDT blob - * @return int value, 0 for success + * @param blob FDT blob + * @param pi2s_tx i2s parameters required by codec + * @return int value, 0 for success */ -static int get_sound_codec_values(struct sound_codec_info *pcodec_info) +static int codec_init(const void *blob, struct i2stx_info *pi2s_tx) { - int error = 0; + int ret; const char *codectype; +#ifdef CONFIG_OF_CONTROL + int node; - codectype = AUDIO_CODEC; + /* 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); +#else + codectype = AUDIO_CODEC; +#endif if (!strcmp(codectype, "wm8994")) { - pcodec_info->codec_type = CODEC_WM_8994; - error = get_sound_wm8994_values(pcodec_info); + /* Check the codec type and initialise the same */ + ret = wm8994_init(blob, WM8994_AIF2, + pi2s_tx->samplingrate, + (pi2s_tx->samplingrate * (pi2s_tx->rfs)), + pi2s_tx->bitspersample, pi2s_tx->channels); } else { - error = -1; + debug("%s: Unknown code type %s\n", __func__, + codectype); + return -1; } - - if (error == -1) { - debug("fail to get sound codec node properties\n"); + if (ret) { + debug("%s: Codec init failed\n", __func__); return -1; } return 0; } -int sound_init(void) +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; +#ifdef CONFIG_OF_CONTROL /* Get the I2S Values */ - get_sound_i2s_values(pi2s_tx); - - /* Get the codec Values */ - if (get_sound_codec_values(pcodec_info) < 0) + if (get_sound_i2s_values(pi2s_tx, blob) < 0) { + debug(" FDT I2S values failed\n"); return -1; - + } + codec_init(blob, pi2s_tx); +#else + /* Get the I2S Values */ + get_sound_i2s_values(pi2s_tx, NULL); + codec_init(NULL, pi2s_tx); +#endif ret = i2s_tx_init(pi2s_tx); if (ret) { debug("%s: Failed to init i2c transmit: ret=%d\n", __func__, @@ -137,21 +189,6 @@ int sound_init(void) 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; } diff --git a/include/sound.h b/include/sound.h index ea0b115..a9cbeed 100644 --- a/include/sound.h +++ b/include/sound.h @@ -46,10 +46,10 @@ struct sound_codec_info { /* * Initialises audio sub system - * + * @param blob Pointer of device tree node. * @return int value 0 for success, -1 for error */ -int sound_init(void); +int sound_init(const void *blob); /* * plays the pcm data buffer in pcm_data.h through i2s1 to make the