From patchwork Thu Dec 27 06:03:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 13710 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A972A23F74 for ; Thu, 27 Dec 2012 05:56:59 +0000 (UTC) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by fiordland.canonical.com (Postfix) with ESMTP id 3D485A18423 for ; Thu, 27 Dec 2012 05:56:59 +0000 (UTC) Received: by mail-vc0-f174.google.com with SMTP id d16so9524726vcd.33 for ; Wed, 26 Dec 2012 21:56:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:dlp-filter:x-mtr:x-brightmail-tracker :x-brightmail-tracker:x-cfilter-loop:x-gm-message-state; bh=3LoYalw7wJ8JsrppFnWOtHtPQ2eLuwdg6e7QcO8kAxQ=; b=FPWaCb0qZu9PXbSqvZAa+sj3V1lefb1xJ7ZfSU9D2wB5g7PtBrdGp2ZPPkX4RcGuk/ i2n+0dOfjSNfuc7T8lMOch+MIlhnrPiav1IIoZg749lKstvPJQsrUg98ZUwrxNuYTbm9 /WtVNCNlGLZrQCaKCF5BSrnMpm3FXChCYfKTM9d6pv4VSdgHNN7ezObhC7gPflDM+QpU 33Of4NOFLPFwY5Sw4G2wKaY8RkA1D+p8PyVI/RjI1Eh+jDaLg69i2Mu6OA3MMNL6olMU 0GJ5MvjuQHDosQhlxGaaX31/DKeW1IsEi2XHFS9YQE5Dn+MwWX6kgOrwNv2DOiMVq+wh L/Iw== X-Received: by 10.220.218.197 with SMTP id hr5mr44161983vcb.8.1356587818741; Wed, 26 Dec 2012 21:56:58 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.214.195 with SMTP id oc3csp4982vec; Wed, 26 Dec 2012 21:56:58 -0800 (PST) X-Received: by 10.66.52.79 with SMTP id r15mr87293632pao.46.1356587814283; Wed, 26 Dec 2012 21:56:54 -0800 (PST) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id p7si28402078pav.340.2012.12.26.21.56.53; Wed, 26 Dec 2012 21:56:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MFO006YMDRMKSN0@mailout3.samsung.com>; Thu, 27 Dec 2012 14:56:52 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.126]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id E4.E7.01231.423EBD05; Thu, 27 Dec 2012 14:56:52 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-42-50dbe3249d94 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 64.E7.01231.423EBD05; Thu, 27 Dec 2012 14:56:52 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MFO009UDDU79J90@mmp1.samsung.com>; Thu, 27 Dec 2012 14:56:52 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org Subject: [PATCH 11/16 V2] Sound: WM8994: Add FDT support to codec Date: Thu, 27 Dec 2012 11:33:18 +0530 Message-id: <1356588203-24838-12-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1356588203-24838-1-git-send-email-rajeshwari.s@samsung.com> References: <1356588203-24838-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsWyRsSkTlfl8e0Ag3dfLC0err/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBlLP63h7XgsGLF3VMf2RsYW6S7GDk5JARMJPadWcgE YYtJXLi3nq2LkYtDSGApo8Scff+ZuxjZwYr2J0KEFzFKvOmbyQrhTGSSaLo1nQWkmU3ASGLr yWmMILaIgITEr/6rYDazQIzE6/0/2EBsYQFHiTtPnwPVc3CwCKhKHFhaDhLmFfCUWPZ4AyPE DQoSx6Z+ZQWxOYHiE64sA4sLCXhIfNlzHmwMi4CAxLfJh8DGSAjISmw6wAxyjoTAfTaJ/s4p zBBzJCUOrrjBMoFReAEjwypG0dSC5ILipPRcQ73ixNzi0rx0veT83E2MwFA8/e+Z1A7GlQ0W hxgFOBiVeHgVrW8HCLEmlhVX5h5ilOBgVhLhnb4ZKMSbklhZlVqUH19UmpNafIjRB+iSicxS osn5wDjJK4k3NDYxNzU2tTQyMjM1xSGsJM7b7JESICSQnliSmp2aWpBaBDOOiYNTqoFxfrDT ruCIp2uM6jT5Wnlz7lpt5sopj/lWyspad9ziyYq3AY2xXSL1UiGX7ml1aCXqs09l6aq3vT7D 4lzbsmVyX3lldb60/9vjsWfvNo0rXAZ8xd7/peRWlcT/yM7+rSxgb8dbe8x877Q54quVLV4d XLzdJL21xOtbWNeU6s21Cbe9V9UvdFViKc5INNRiLipOBADGBBWccgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeLIzCtJLcpLzFFi42I5/e+xgK7K49sBBldW6Vg8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzFj8bw9rwWHF irunPrI3MLZIdzGyc0gImEjsT+xi5ASyxCQu3FvP1sXIxSEksIhR4k3fTFYIZyKTRNOt6Swg VWwCRhJbT05jBLFFBCQkfvVfBbOZBWIkXu//wQZiCws4Stx5+hyonoODRUBV4sDScpAwr4Cn xLLHGxghlilIHJv6lRXE5gSKT7iyDCwuJOAh8WXPebYJjLwLGBlWMYqmFiQXFCel5xrqFSfm Fpfmpesl5+duYgQH+jOpHYwrGywOMQpwMCrx8Cpa3w4QYk0sK67MPcQowcGsJMI7fTNQiDcl sbIqtSg/vqg0J7X4EKMP0FETmaVEk/OBUZhXEm9obGJuamxqaWJhYmaJQ1hJnLfZIyVASCA9 sSQ1OzW1ILUIZhwTB6dUA2P88dd3yjS2/mDl/Nav8Superr70hN66Z/LZ35LZuy8U/pvo2ne gsLy/yk91e31gksLT08Qfsza7J5pLM5Ty7Vj+3mxOv6kow9PuTdKh+78oMaWZ3hcutxQtaxy Z0rYttO/Lx8+MKG0y0Fk68Glq2o1lh1guFwU9WnLErlZR7S2yDBmKpfq9SqxFGckGmoxFxUn AgAYCZGtoQIAAA== X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmgXvs+EMFo0BxuJXsjZmP0GwvNDzppYlLcozqd2y94IEbKj7H2CDlLjaRgu55aOwqz5u7t This patch adds FDT support to the codec. Signed-off-by: Rajeshwari Shinde Acked-by: Simon Glass --- Changes since V1: - removed unnecesarry blank lines. drivers/sound/wm8994.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/sound/wm8994.h | 6 +-- 2 files changed, 74 insertions(+), 6 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 293903a..3b673b4 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -26,9 +26,11 @@ #include #include #include +#include #include #include #include +#include #include "wm8994.h" #include "wm8994_registers.h" @@ -77,6 +79,7 @@ static int bclk_divs[] = { static struct wm8994_priv g_wm8994_info; static unsigned char g_wm8994_i2c_dev_addr; +static struct sound_codec_info g_codec_info; /* * Initialise I2C for wm 8994 @@ -747,13 +750,80 @@ err: return -1; } +/* + * 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_codec_values(struct sound_codec_info *pcodec_info, + const void *blob) +{ + int error = 0; +#ifdef CONFIG_OF_CONTROL + enum fdt_compat_id compat; + int node; + int parent; + + /* Get the node from FDT for codec */ + node = fdtdec_next_compatible(blob, 0, COMPAT_WOLFSON_WM8994_CODEC); + 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_S3C2440_I2C: + pcodec_info->i2c_bus = i2c_get_bus_num_fdt(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; + } +#else + 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); +#endif + + pcodec_info->codec_type = CODEC_WM_8994; + + if (error == -1) { + debug("fail to get wm8994 codec node properties\n"); + return -1; + } + + return 0; +} + /*wm8994 Device Initialisation */ -int wm8994_init(struct sound_codec_info *pcodec_info, - enum en_audio_interface aif_id, +int wm8994_init(const void *blob, enum en_audio_interface aif_id, int sampling_rate, int mclk_freq, int bits_per_sample, unsigned int channels) { int ret = 0; + struct sound_codec_info *pcodec_info = &g_codec_info; + + /* Get the codec Values */ + if (get_codec_values(pcodec_info, blob) < 0) { + debug("FDT Codec values failed\n"); + return -1; + } /* shift the device address by 1 for 7 bit addressing */ g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr; diff --git a/drivers/sound/wm8994.h b/drivers/sound/wm8994.h index a8f0de1..a1e8335 100644 --- a/drivers/sound/wm8994.h +++ b/drivers/sound/wm8994.h @@ -69,8 +69,7 @@ enum wm8994_type { /* * intialise wm8994 sound codec device for the given configuration * - * @param pcodec_info pointer value of the sound codec info structure - * parsed from device tree + * @param blob FDT node for codec values * @param aif_id enum value of codec interface port in which * soc i2s is connected * @param sampling_rate Sampling rate ranges between from 8khz to 96khz @@ -80,8 +79,7 @@ enum wm8994_type { * * @returns -1 for error and 0 Success. */ -int wm8994_init(struct sound_codec_info *pcodec_info, - enum en_audio_interface aif_id, +int wm8994_init(const void *blob, enum en_audio_interface aif_id, int sampling_rate, int mclk_freq, int bits_per_sample, unsigned int channels); #endif /*__WM8994_H__ */