From patchwork Fri May 19 14:32:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 9737389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4CA33601A1 for ; Fri, 19 May 2017 14:32:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4400F27F82 for ; Fri, 19 May 2017 14:32:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3670F280FC; Fri, 19 May 2017 14:32:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,FROM_WORDY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9DC927F82 for ; Fri, 19 May 2017 14:32:32 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3FCED266A53; Fri, 19 May 2017 16:32:30 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3263F266A73; Fri, 19 May 2017 16:32:29 +0200 (CEST) Received: from mail1.bemta3.messagelabs.com (mail1.bemta3.messagelabs.com [195.245.230.167]) by alsa0.perex.cz (Postfix) with ESMTP id C56A32667A5 for ; Fri, 19 May 2017 16:32:26 +0200 (CEST) Received: from [85.158.137.19] by server-7.bemta-3.messagelabs.com id 08/B2-02196-AF10F195; Fri, 19 May 2017 14:32:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLIsWRWlGSWpSXmKPExsUSt3Opse4vRvl Ig+dnmSyuXDzEZDH14RM2i29XOpgsLu+aw2bRuauf1WLD97WMDmweGz43sXnsnHWX3WPTqk42 j31vl7F5rN9ylcXj8ya5ALYo1sy8pPyKBNaMvRPushVck6nYfeQpawNjs2QXIxeHkMB6Rol/U x6zdjFyAjkVEotvdrCD2GwCFhKTTzxg62Lk4GARUJWYP98bJCwsECRx9tscVpBeEYEuRonVrx 6D1TMLlEts+TSRGaSeV8BB4vVUO5Awr4CgxMmZT1ggSiQkDr54wQyxykDi9IJGsLiEgL3E9Pd XwVolBPQlGo/FQoQNJb7P+gZVYi6xb8lE5gmM/LOQTJ2FZOoCRqZVjBrFqUVlqUW6RmZ6SUWZ 6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBwVzPwMC4g7Fhr98hRkkOJiVRXsfDcpFCf En5KZUZicUZ8UWlOanFhxhlODiUJHhnM8hHCgkWpaanVqRl5gDjCiYtwcGjJMKrCYwtId7igs Tc4sx0iNQpRkUpcd7pIH0CIImM0jy4NlgsX2KUlRLmZWRgYBDiKUgtys0sQZV/xSjOwagkzPs XZApPZl4J3PRXQIuZgBY3P5AGWVySiJCSamCUd2bM4lkxa+2aFaWeJrd5dipPdXzHun76zgtc cbqtYjb8t+68iIxfJsJQv0ft3j8unmZLoc+uK3Xr5EI0hJT8QpsS1xte6k7vEWg2sk940nfhW q38QoVDVZY9QvverFQ7dvWPjvKCyvuu+VWrGhL0Pe9YMer8f5UUOHFS0fT/V/1kTpzKSFJiKc 5INNRiLipOBABL6dI24AIAAA== X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-11.tower-39.messagelabs.com!1495204345!95290307!1 X-Originating-IP: [94.185.165.51] X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29355 invoked from network); 19 May 2017 14:32:25 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-11.tower-39.messagelabs.com with AES128-SHA encrypted SMTP; 19 May 2017 14:32:25 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.248.2; Fri, 19 May 2017 15:32:25 +0100 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 089823FBCD; Fri, 19 May 2017 15:32:25 +0100 (BST) From: Adam Thomson Date: Fri, 19 May 2017 15:32:25 +0100 To: Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai Message-ID: <20170519143225.089823FBCD@swsrvapps-01.diasemi.com> MIME-Version: 1.0 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 19/05/2017 08:02:00 Cc: alsa-devel@alsa-project.org, Support Opensource , linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: da7213: Update driver to use device_property* FW functions X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The driver now supports ACPI based initialisation as well as DT and old pdata methods. However the FW data handling still uses DT specific calls to read firmware data (of_property*) so for ACPI based initialisation the FW data will only be set to default values. This patch updates the FW handling to use device_property* calls instead so that both ACPI and DT are handled as expected. Signed-off-by: Adam Thomson --- sound/soc/codecs/da7213.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 024d83f..c3e1189 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -13,6 +13,8 @@ */ #include +#include +#include #include #include #include @@ -1606,12 +1608,12 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, } static struct da7213_platform_data - *da7213_of_to_pdata(struct snd_soc_codec *codec) + *da7213_fw_to_pdata(struct snd_soc_codec *codec) { - struct device_node *np = codec->dev->of_node; + struct device *dev = codec->dev; struct da7213_platform_data *pdata; - const char *of_str; - u32 of_val32; + const char *fw_str; + u32 fw_val32; pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) { @@ -1619,29 +1621,29 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, return NULL; } - if (of_property_read_u32(np, "dlg,micbias1-lvl", &of_val32) >= 0) - pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, of_val32); + if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) + pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, fw_val32); else pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; - if (of_property_read_u32(np, "dlg,micbias2-lvl", &of_val32) >= 0) - pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, of_val32); + if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) + pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, fw_val32); else pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; - if (!of_property_read_string(np, "dlg,dmic-data-sel", &of_str)) - pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, of_str); + if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) + pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, fw_str); else pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; - if (!of_property_read_string(np, "dlg,dmic-samplephase", &of_str)) + if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) pdata->dmic_samplephase = - da7213_of_dmic_samplephase(codec, of_str); + da7213_of_dmic_samplephase(codec, fw_str); else pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; - if (of_property_read_u32(np, "dlg,dmic-clkrate", &of_val32) >= 0) - pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, of_val32); + if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) + pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, fw_val32); else pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; @@ -1713,10 +1715,9 @@ static int da7213_probe(struct snd_soc_codec *codec) DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); /* Handle DT/Platform data */ - if (codec->dev->of_node) - da7213->pdata = da7213_of_to_pdata(codec); - else - da7213->pdata = dev_get_platdata(codec->dev); + da7213->pdata = dev_get_platdata(codec->dev); + if (!da7213->pdata) + da7213->pdata = da7213_fw_to_pdata(codec); /* Set platform data values */ if (da7213->pdata) {