From patchwork Fri Dec 14 11:56:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 13577 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 E1B5A23FC0 for ; Fri, 14 Dec 2012 11:57:33 +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 78E3FA19567 for ; Fri, 14 Dec 2012 11:57:33 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so5709458ieb.11 for ; Fri, 14 Dec 2012 03:57:32 -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=3GAGClZy2rZFYcxNUNHbOaaiUvrZgedXTxnG1j6E3tM=; b=NDLGXTfClrcfwzKbdJyX86JlQMt6LKx1I2hlqB5OZw0CDRP0wyf0zrpyAkMiM/rwmX rI5NqeaHSpllK5AcBJKYS0h2AXP2HsSCRDyALtARZSRLlchDGm5y2D/77Fo49GUtLpdD HxpZryy+4J9y9er/9MoxbvyIRwU11eXk15KsMz7yoiOOUumZYA/kn3BBtkBOV6U2+p1J V8tjxA1ytdd4LOcsDMetlLGYd+wx7YVpnu9On+QSiEMsWCOtGcy19KIZwvXXdx4ZVa/W S+5wMuVD2LBmP2cXoxoMLqhpxQ/J4juZxRQT1IXpzfkfTIqdhLDlXYG5T08/aR6dZASi yXWw== Received: by 10.42.32.200 with SMTP id f8mr4237477icd.18.1355486252916; Fri, 14 Dec 2012 03:57:32 -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 n20csp67394igt; Fri, 14 Dec 2012 03:57:32 -0800 (PST) Received: by 10.66.89.199 with SMTP id bq7mr15303271pab.26.1355486252123; Fri, 14 Dec 2012 03:57:32 -0800 (PST) Received: from mailout1.samsung.com (mailout1.samsung.com. [203.254.224.24]) by mx.google.com with ESMTP id zs6si4689807pbc.151.2012.12.14.03.57.31; Fri, 14 Dec 2012 03:57:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.24 as permitted sender) client-ip=203.254.224.24; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.24 as permitted sender) smtp.mail=rajeshwari.s@samsung.com Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MF0000EIRVUMN00@mailout1.samsung.com>; Fri, 14 Dec 2012 20:57:30 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 1A.7E.12699.A241BC05; Fri, 14 Dec 2012 20:57:30 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-87-50cb142a29ba Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 49.7E.12699.7241BC05; Fri, 14 Dec 2012 20:57:27 +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 <0MF000GYFRKI4870@mmp2.samsung.com>; Fri, 14 Dec 2012 20:57:27 +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] Sound: WM8994: Add FDT support to codec Date: Fri, 14 Dec 2012 17:26:24 +0530 Message-id: <1355486189-432-11-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1355486189-432-1-git-send-email-rajeshwari.s@samsung.com> References: <1355486189-432-1-git-send-email-rajeshwari.s@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRmVeSWpSXmKPExsWyRsSkTldL5HSAwfQ1xhYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgyXq27yVZwRLHi+5q3LA2MzdJdjJwcEgImEp+bnzBD 2GISF+6tZ+ti5OIQEljKKDH99RY2mKLej8sZIRLTGSW+r1/KBOFMZJKYPO02WBWbgJHE1pPT GEFsEQEJiV/9V8FsZoEYidf7f4DVCAvYSXyeuRpsHYuAqsSpXYvYQWxeAXeJO493Q52hIHFs 6ldWEJsTKH7yzT2wuJCAm8SKnmVsEL0CEt8mH2LpYuQAqpeV2HSAGeQeCYHrbBITbzyFulpS 4uCKGywTGIUXMDKsYhRNLUguKE5KzzXSK07MLS7NS9dLzs/dxAgMyNP/nknvYFzVYHGIUYCD UYmH94PQqQAh1sSy4srcQ4wSHMxKIrySR4BCvCmJlVWpRfnxRaU5qcWHGH2ALpnILCWanA+M lrySeENjE3NTY1NLIyMzU1McwkrivM0eKQFCAumJJanZqakFqUUw45g4OKUaGLvb/t55rXNk SfJkhxp1kRiuchUeFs71fceunhJR7C5xKsi7fWRHl0cqSzDbbj6hiBKFoOXHIl5GW/6Le13Z LtOWZ2Fsd3bRuUTnwN4Lym2G33c/mcMv9i3vZtWiOXMOxkz7vCJvyqydTb9n3jvDPWs+524Z vVjVdWb7Z855xiglsvTidIFbC5VYijMSDbWYi4oTAdPQuIR1AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRmVeSWpSXmKPExsVy+t9jQV11kdMBBlfXGFg8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzHi17iZbwRHF iu9r3rI0MDZLdzFyckgImEj0flzOCGGLSVy4t56ti5GLQ0hgOqPE9/VLmSCciUwSk6fdZgOp YhMwkth6chpYh4iAhMSv/qtgNrNAjMTr/T/AaoQF7CQ+z1zNDGKzCKhKnNq1iB3E5hVwl7jz eDczxDYFiWNTv7KC2JxA8ZNv7oHFhQTcJFb0LGObwMi7gJFhFaNoakFyQXFSeq6RXnFibnFp Xrpecn7uJkZwuD+T3sG4qsHiEKMAB6MSD+8HoVMBQqyJZcWVuYcYJTiYlUR4JY8AhXhTEiur Uovy44tKc1KLDzH6AF01kVlKNDkfGIt5JfGGxibmpsamliYWJmaWOISVxHmbPVIChATSE0tS s1NTC1KLYMYxcXBKNTAKzOfkN+tzTOftMug7E+qz8Jrkg3T7FEGzZHHTFtGAL4/nMHsJlV6e 7aDqxd4e8T4jXfXbPDNehXD2d+vnOhdPLNdgZSt4zejI9mzLJJ5b4kyrnPvm9/xf+MB8h2rs l+OvLZfODZdNFH2bLXpu6c1iP560wwzzTn06eKz+XqSHRWKKUnltgRJLcUaioRZzUXEiACoQ U4SkAgAA X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmudoZr2d37U+YA77JHkcK0JOZhdUZyTPkvkiEBiCMsEXRC2qiO0tY4BuFHZCXH4XsLOBQw This patch adds FDT support to the codec. Signed-off-by: Rajeshwari Shinde Acked-by: Simon Glass --- Changes in V1: -Rebased on latest u-boot-samsung 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..a528502 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__ */