From patchwork Thu Nov 29 07:55:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 13287 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 5B6A22425C for ; Thu, 29 Nov 2012 07:49:40 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0C434A19D15 for ; Thu, 29 Nov 2012 07:49:39 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so7675615iag.11 for ; Wed, 28 Nov 2012 23:49:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to: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=ni4zvTXobn+BBkHlh50IY8KwYzQUzHEfAec/u786ZUw=; b=JUfBjZtpe8lmxM7HM6olQyvyBMRIrJxCU3Nv+UHxyI3Yi9zQVQO9iU7beK35/oYJ2K krqX+8K8x6teV8vW14H5icQoQ/4AyXGr9bpA0I7qmQ8ZzNrOagzP5afmsOb46xrtEISl Gt7VE65DmAkuyQ2Fq9pcux3fxGw0ynlLr1GFcogMK6xv/ZUXwBiuXpMvvl9AIfoBgLtg /jIT58TiQwyA6Oo9vpFEEK+9G8yTJObm7s+WW7YaRCzyu7M/Q0E5VrYC6iesFPcDIufy LDgHRXjIyeQxjYwwHGe+cUGZG/lpB/HVfVUG/2/CsxtS/klNmNecfHjPHgoF7YyysvGE PS+w== Received: by 10.50.161.169 with SMTP id xt9mr24248472igb.62.1354175379815; Wed, 28 Nov 2012 23:49:39 -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.50.67.148 with SMTP id n20csp806391igt; Wed, 28 Nov 2012 23:49:39 -0800 (PST) Received: by 10.68.134.233 with SMTP id pn9mr66339304pbb.125.1354175378965; Wed, 28 Nov 2012 23:49:38 -0800 (PST) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id t9si1374421paz.26.2012.11.28.23.49.38; Wed, 28 Nov 2012 23:49:38 -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 epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ME800ESVOE9P630@mailout3.samsung.com>; Thu, 29 Nov 2012 16:49:38 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 42.94.12699.29317B05; Thu, 29 Nov 2012 16:49:38 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-70-50b7139278c8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E1.94.12699.19317B05; Thu, 29 Nov 2012 16:49:37 +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 <0ME800LQWOECLB50@mmp2.samsung.com>; Thu, 29 Nov 2012 16:49:37 +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 5/6 V3] Sound: WM8994: Add FDT support to codec Date: Thu, 29 Nov 2012 13:25:51 +0530 Message-id: <1354175752-17233-6-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1354175752-17233-1-git-send-email-rajeshwari.s@samsung.com> References: <1354175752-17233-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsWyRsSkSneS8PYAg3ktPBYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyTn3sZi24o1ix5Mtm5gbGLukuRk4OCQETiXtHWpgh bDGJC/fWs3UxcnEICSxllJjx7DFQggOsaP0ZqPh0Rom2TXOgnIlMEh96v7OCdLMJGElsPTmN EcQWEZCQ+NV/FcxmFoiReL3/BxvIIGEBe4lpc8HKWQRUJT6+u8cCYvMKeEjs3HQb6ggFiWNT v4LVcAp4Snza1AVmCwHVbFi9hhGiV0Di2+RDLBC3yUpsOsAMco6EwG02iSeHXrFDzJGUOLji BssERuEFjAyrGEVTC5ILipPSc430ihNzi0vz0vWS83M3MQKD8fS/Z9I7GFc1WBxiFOBgVOLh 3Wi5LUCINbGsuDL3EKMEB7OSCK/mH6AQb0piZVVqUX58UWlOavEhRh+gSyYyS4km5wMjJa8k 3tDYxNzU2NTSyMjM1BSHsJI4b7NHSoCQQHpiSWp2ampBahHMOCYOTqkGxnZG6y+u2Xpb5+o/ Wi/CF2Hx36I7TSH4yTxJtu0rrKbVNz9Vm3Qt/qvzYmOGoriFTewVoY9lr7UHxDXz/ROYyun0 vebkbDe1p7P1+Io+rd6nf4Vfh33dKgkt2fUs0jf5t2p4HlrI+5NxuzGjAcuTDaV+M19or08S 9DbQjvkXc4DjmzXL0tIQJZbijERDLeai4kQACNOaInMCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeLIzCtJLcpLzFFi42I5/e+xoO5E4e0BBjuWWVs8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzDj1sZu14I5i xZIvm5kbGLukuxg5OCQETCTWn2HrYuQEMsUkLtxbD2RzcQgJTGeUaNs0B8qZyCTxofc7K0gV m4CRxNaT0xhBbBEBCYlf/VfBbGaBGInX+3+wgQwVFrCXmDYXrJxFQFXi47t7LCA2r4CHxM5N t5khlilIHJv6FayGU8BT4tOmLjBbCKhmw+o1jBMYeRcwMqxiFE0tSC4oTkrPNdIrTswtLs1L 10vOz93ECA71Z9I7GFc1WBxiFOBgVOLh3Wi5LUCINbGsuDL3EKMEB7OSCK/mH6AQb0piZVVq UX58UWlOavEhRh+gqyYyS4km5wPjMK8k3tDYxNzU2NTSxMLEzBKHsJI4b7NHSoCQQHpiSWp2 ampBahHMOCYOTqkGRt4ti/5bc7G7RW9x9BL1N006Nnfh856quSKPNrSq3J6/2vvNATnh40Ii M349ULwkz/w84XuphffLwq8moXXJOwxXM8x6c6Lm5NxLp2LuuvZcFlFbsajuk+WNla9Lveao NO/5+N93ks22it6eDpXfrr+9zNb1lK6/Nfflkx/PGG+0vDnyLM72M5MSS3FGoqEWc1FxIgBz 6QfpogIAAA== X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmonPQol6zNTZ+Qvzy2jG9trsN2yrjGsftFRBjyxXGMxHafZS0gxMriLg4vQChSTxUFKZVs This patch adds FDT support to the codec. Signed-off-by: Rajeshwari Shinde Acked-by: Simon Glass --- Changes in V2: - New patch. Changes in V3: - Removed #ifdef CONFIG_OF_CONTROL where ever not required. drivers/sound/wm8994.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/sound/wm8994.h | 6 +-- 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 293903a..ce79472 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,82 @@ 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__ */