From patchwork Wed Nov 28 06:10:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 13260 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 1171723E08 for ; Wed, 28 Nov 2012 06:03:59 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id B4FF4A19326 for ; Wed, 28 Nov 2012 06:03:58 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so7678022ieb.11 for ; Tue, 27 Nov 2012 22:03:58 -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=BFmn6h+ETXT6Ve5RbjetB9DDmS0siPKS+NOQoSjCcFI=; b=HVmaH6wAQZrh4zpG0XZGOkNEzquIwsE+5lh4ubFxoLEVq3Qx6Z0pqV/JJdCK1Ks2cX YCG4n7WqiJ3xe1jRetuqNsivtTr+dyH5fC21in7Af3lJGE6ftFFGJTW5Pb0LubjZvI3x qTpPejX80t4hxua9WE3XTrEwItLEf3zeVJ5rPmceH8XW13882ep98cIYm6KtDxxZXpKY ZtMf6YtCfenx599a0K78q+szR4g7YZt9/x6/agLgyDCKWapjQfIaa3acYRI/dZGk1upk vGfwyGaa68IAlSkkyQlEZX1Dze5Q1D8Liq0WvqLiPmc3cQohIsNb1Fy0R+vnvOHR1WQi U4dQ== Received: by 10.50.42.168 with SMTP id p8mr17851992igl.57.1354082638483; Tue, 27 Nov 2012 22:03: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.50.67.148 with SMTP id n20csp594643igt; Tue, 27 Nov 2012 22:03:58 -0800 (PST) Received: by 10.66.81.198 with SMTP id c6mr39015061pay.50.1354082637822; Tue, 27 Nov 2012 22:03:57 -0800 (PST) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id o4si27066224paw.344.2012.11.27.22.03.57; Tue, 27 Nov 2012 22:03:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) smtp.mail=rajeshwari.s@samsung.com 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 <0ME600F8MOUKS7K0@mailout2.samsung.com>; Wed, 28 Nov 2012 15:03:56 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D2.31.01231.B49A5B05; Wed, 28 Nov 2012 15:03:55 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-26-50b5a94b33ee Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 82.31.01231.B49A5B05; Wed, 28 Nov 2012 15:03:55 +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>; Wed, 28 Nov 2012 15:03:55 +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 6/7 V2] Sound: WM8994: Add FDT support to codec Date: Wed, 28 Nov 2012 11:40:12 +0530 Message-id: <1354083013-5213-7-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+NgFnrILMWRmVeSWpSXmKPExsWyRsSkWtd75dYAg+4TKhYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyjn24wVrwW7Hi5tZ3jA2My6W7GDk4JARMJJZvsexi 5AQyxSQu3FvP1sXIxSEksJRRYt6Jz2wQCROJKYfvMUEkpjNKbH69mBXCmcgkMefkK1aQKjYB I4mtJ6cxgtgiAhISv/qvgtnMAjESr/f/AJskLGAv0bVjPpjNIqAqMWfhPXYQm1fAXeLpjW+M ENsUJI5N/Qo2k1PAQ+Je7yKwGiGgmhXNu5kgegUkvk0+xALxgazEpgPMIPdICNxmk1gy+w8z xBxJiYMrbrBMYBRewMiwilE0tSC5oDgpPddQrzgxt7g0L10vOT93EyMwHE//eya1g3Flg8Uh RgEORiUeXgfHrQFCrIllxZW5hxglOJiVRHh52oBCvCmJlVWpRfnxRaU5qcWHGH2ALpnILCWa nA+MlbySeENjE3NTY1NLIyMzU1McwkrivM0eKQFCAumJJanZqakFqUUw45g4OKUaGPOOvhPb GnLQ1WVZji1v//uHyrvtw2/5XhZ7wV65wTQ3/M21lt8tEfknZ24/F5glU1LEFhslNknhw/+X PKbVO9pnL+iXXvXuxEkZ42ue370LN2fmWf9NVResPn9mh1LOsebdbxJ7e01u1TwVTJp3bBtD 4vHbK46pZp9Jr8nufh9X3atiV2p+VImlOCPRUIu5qDgRAKRoyrt0AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsVy+t9jQV3vlVsDDN6flbF4uP4mi8WUw19Y HJg87lzbwxbAGNXAaJORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+Ti E6DrlpkDNFtJoSwxpxQoFJBYXKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmHHsww3Wgt+K FTe3vmNsYFwu3cXIySEhYCIx5fA9JghbTOLCvfVsXYxcHEIC0xklNr9ezArhTGSSmHPyFStI FZuAkcTWk9MYQWwRAQmJX/1XwWxmgRiJ1/t/sIHYwgL2El075oPZLAKqEnMW3mMHsXkF3CWe 3vjGCLFNQeLY1K9gMzkFPCTu9S4CqxECqlnRvJtpAiPvAkaGVYyiqQXJBcVJ6bmGesWJucWl eel6yfm5mxjB4f5MagfjygaLQ4wCHIxKPLwOjlsDhFgTy4orcw8xSnAwK4nw8rQBhXhTEiur Uovy44tKc1KLDzH6AF01kVlKNDkfGIt5JfGGxibmpsamliYWJmaWOISVxHmbPVIChATSE0tS s1NTC1KLYMYxcXBKNTBu2j7z4+GLj01+ifrv0D0qvsxQuOi+8uzn/8/arp1ffeH+9uuz5+xt b4zWkty8yix6cfjLL0EflDONPRTzTUwy66tq3yWZvz7V3nfeRKBdP3rKQq0NT+NYY33KXrPu LbGXqV/xmktTxSL+xHklXkWHua978/pq2a/EvxRXu5/xh+//gtqXXMeUWIozEg21mIuKEwG4 +kBupAIAAA== X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQlZaeF9w+s9KmBpjHmZ4oB3Ak9bxJQyIFle4TdFCPoShLUsgHwNm/Ce8IyesFv+R5dEfTBh This patch adds FDT support to the codec. Signed-off-by: Rajeshwari Shinde --- Changes in V2: - New patch. drivers/sound/wm8994.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/sound/wm8994.h | 6 +-- 2 files changed, 83 insertions(+), 6 deletions(-) diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c index 293903a..4352b21 100644 --- a/drivers/sound/wm8994.c +++ b/drivers/sound/wm8994.c @@ -31,6 +31,11 @@ #include #include "wm8994.h" #include "wm8994_registers.h" +#ifdef CONFIG_OF_CONTROL +#include +#else +#include +#endif /* defines for wm8994 system clock selection */ #define SEL_MCLK1 0x00 @@ -77,6 +82,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 +753,86 @@ 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 = fd_dec_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 */ +#ifdef CONFIG_OF_CONTROL + if (get_codec_values(pcodec_info, blob) < 0) { +#else + if (get_codec_values(pcodec_info, NULL) < 0) { +#endif + 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__ */