From patchwork Tue May 31 09:02:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9143859 X-Patchwork-Delegate: geert@linux-m68k.org 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 D10F360757 for ; Tue, 31 May 2016 09:02:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4D1D27E72 for ; Tue, 31 May 2016 09:02:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8AA32821C; Tue, 31 May 2016 09:02:29 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C27327E72 for ; Tue, 31 May 2016 09:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756749AbcEaJC2 (ORCPT ); Tue, 31 May 2016 05:02:28 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:57863 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756695AbcEaJC1 (ORCPT ); Tue, 31 May 2016 05:02:27 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 31 May 2016 18:02:25 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 6A67650192; Tue, 31 May 2016 18:02:25 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 5B6F42806E; Tue, 31 May 2016 18:02:25 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 545862806D; Tue, 31 May 2016 18:02:25 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id UAE10737; Tue, 31 May 2016 18:02:25 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="212431735" Received: from mail-sg2apc01lp0246.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.246]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 31 May 2016 18:02:24 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=6xLrww/T4Vpf0fY4yC1H91KA2xzqBg4+YREJ2ZqJspY=; b=C+N82eil49+Vody4UBJ5A+yAxFPQcxLZpC0OaiBlajfpV5glDv/cB0W+p81T6r1Qw6eTnfuwJEqnCSC8PNpYjBPYyR9XW/X6HX7ISqLk4D7gxTuiw3SWtbeoxRDM+8GxtTk3vrjN/w+Tdoy/JcxeeyLFJxSS3UBmyDYFtIBs288= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by SG2PR06MB1710.apcprd06.prod.outlook.com (10.167.82.140) with Microsoft SMTP Server (TLS) id 15.1.506.9; Tue, 31 May 2016 09:02:22 +0000 Message-ID: <8737oysj1d.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 09/39 v2] ASoC: simple-card-utils: add asoc_simple_card_parse_clk() User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown CC: Linux-ALSA , Liam Girdwood , Simon , In-Reply-To: <87fusysjam.wl%kuninori.morimoto.gx@renesas.com> References: <87fusysjam.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Tue, 31 May 2016 09:02:22 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0051.jpnprd01.prod.outlook.com (10.165.51.139) To SG2PR06MB1710.apcprd06.prod.outlook.com (10.167.82.140) X-MS-Office365-Filtering-Correlation-Id: d86d33e9-9457-403e-54fd-08d3893247b3 X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1710; 2:79sfh9iJwuBvAQGdy3gafeqshr0U8c7XuEIfcFLlkuB+CRpl8OCkIDrg02rPd3Lrcf2VKTMnJ7JmbrwDcDEVq7kIzhivPWn8DR1As5DmtwBiQv8fmh2U7KlA/sR0xMn4B0hsbqbzMgMlfQl5aTpuXKAZNtfX7rn1mQfQiNbRbrecovJ/pqyhyZqzT3FPBBhx; 3:Ho9VOBivGTUa3qrougZ205weYVETq6hv6IH6zhRntqAkqXHrK7Av2exv2JRDrPh9p0jDbNvMy92d58cdaIma0Jd9uXqe5Sono1Hzr8qgzdPeYhxplQ7etF2bHAwXdpJv X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB1710; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1710; 25:YoWU7lkN4TV9+RlVp843j7IZwIgrYGsc1RV66viqgN16Yqvb15WKhWSU5BuuXtzc/4Sz467xDNdw3d1rWhFi7L3MgxpwiRzZt0ap39spt8h68k4dDrVoEW5UFdZ4aLHtFhI9f+/Nm+MU/E72OGJG9AYQZ+LK+S11Eq2E0oVTEMEFcJmrPeYn9TLThw7blSgvvmnVNrzPJDpdaO9ACTKZgPpeb92vfpMm2AeyxFbALThoSLUWE7SfLAvijcVD5LbTTqyBSWRwvZmAf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g7AhOCbodcLxwrQCfMzTS3CkoLMlSsZ23mpDaqiLyWh8XRrFgF2FeV4j+Ym6CJ/8Tu0+HY/6XRMd1A1WanA/r9Wyh00isM5dZ00wZsq3LArIIxQk7h/bjTx2GEaHJ/Mjn4v/BMsIWJo07h5l0z97zM8iRNK6ElGY1EReSbaD6BeBRgFQwWl60mHBiD86w+7TxtwfnC43updOyXJy1a2mD28aUNvAnu3bm+Dw4EuMPf88hfgrmCAyeBU8AaTMPOa7EIkLL2BdJJlWGomCXMyWwg+mQktZ+KJPlcSqUI/rACYjY6iKeP8eZGEj+4GuPQshsQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:SG2PR06MB1710; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1710; X-Forefront-PRVS: 095972DF2F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(77096005)(42186005)(23726003)(6116002)(3846002)(2950100001)(586003)(92566002)(230783001)(4326007)(2906002)(53416004)(5004730100002)(33646002)(189998001)(4001350100001)(46406003)(81166006)(76176999)(83506001)(54356999)(50986999)(19580395003)(8676002)(36756003)(47776003)(86362001)(19580405001)(110136002)(66066001)(229853001)(50466002)(5008740100001)(2004002)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1710; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB1710; 23:YIfDAYa0mrTQY0i76VwqTnpGtMfwQEZflDnmle9CG?= =?us-ascii?Q?YcOPHXTHMF2gcWn80ZbkE3wEMVFSMO/hdm6brHmiHsOAnAEPfLExKhoLBp7f?= =?us-ascii?Q?baASICZ5CitEtnGDVq0lf0PWqnL14mxtAmR5GKnw9gh7h5Ym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/wdexXQRmksxy8wyau5vmu+cuUdFxU++Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1710; 5:9em5O9J9mHU917/0YV+UXLeOg5caYBaihn4GvD+8aC622VpPWsK5gqs/q8CsSJFZDIwMf2XVFgYCrXDCaslX8Lbdnzzzz5hYjGTkuoPO7YOKcgeWq7ozkPTnrVFwuFIkTOkOotEZjauAheMYmZlfDw==; 24:y9ZLGnK5wVpUngK8ghKDH0+fB2WEhrhPJ7Zc6CEkzsEV1TGs2+VdabA4htq0p1cH/lxccLPfpByu8y76voYfUKkjhGmkG55OOOtdj2tqJxk=; 7:5aPIjHIIkhq0+l+s3CbmAJ47xkkJnDyvK+3FHJufc44GIiZc0wBTh1ewiqSNdzaDem1jfUjLX0S/KR2HftzDWMCTsHJnKne4zKQaJSdOISCDLDzbMclFbBy0paxsJ+VHvyGo3tAdq8JTTgdE2UgA4aRuDaFYA9nYWlayL7/QxLUBcKMA4WR+nvu4fBMXsPEo; 20:leg7WpwAYiV4Y1Zo2ICQSp7yylWW4ACCLhaFntQHxJ+9rAmcHAXbpD5DUqikkW3A/4cJPnK/np2Xe+wIzde4CzIRqAXsKxVdxP+LtZYaWEevAZrzoyblMxex9OqQaB7wq46ivF0tPwnWPVV3qXyQg4rwpVESEYmZfrINPTjDlmE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2016 09:02:22.7270 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1710 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current simple-card can get clock via DT clocks or "system-clock-frequency" property. This patch makes it simple style standard Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 8 ++++++++ sound/soc/generic/simple-card-utils.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 89172aa..b8a8649 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -38,4 +38,12 @@ int asoc_simple_card_parse_card_prefix(struct snd_soc_card *card, struct snd_soc_codec_conf *codec_conf, char *prefix); +#define asoc_simple_card_parse_clk_cpu(port_np, dai_link, simple_dai)\ + asoc_simple_card_parse_clk(port_np, dai_link->cpu_of_node, simple_dai) +#define asoc_simple_card_parse_clk_codec(port_np, dai_link, simple_dai) \ + asoc_simple_card_parse_clk(port_np, dai_link->codec_of_node, simple_dai) +int asoc_simple_card_parse_clk(struct device_node *port_np, + struct device_node *endpoint_np, + struct asoc_simple_dai *simple_dai); + #endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 439fc01..dbf4b00 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -7,6 +7,7 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#include #include #include @@ -142,3 +143,32 @@ int asoc_simple_card_parse_card_prefix(struct snd_soc_card *card, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_prefix); + +int asoc_simple_card_parse_clk(struct device_node *port_np, + struct device_node *endpoint_np, + struct asoc_simple_dai *simple_dai) +{ + struct clk *clk; + u32 val; + + /* + * Parse dai->sysclk come from "clocks = <&xxx>" + * (if system has common clock) + * or "system-clock-frequency = " + * or device's module clock. + */ + clk = of_clk_get(port_np, 0); + if (!IS_ERR(clk)) { + simple_dai->sysclk = clk_get_rate(clk); + simple_dai->clk = clk; + } else if (!of_property_read_u32(port_np, "system-clock-frequency", &val)) { + simple_dai->sysclk = val; + } else { + clk = of_clk_get(endpoint_np, 0); + if (!IS_ERR(clk)) + simple_dai->sysclk = clk_get_rate(clk); + } + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);