From patchwork Tue Jul 19 02:52:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9235831 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 DF602600CB for ; Tue, 19 Jul 2016 02:52:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5EA026490 for ; Tue, 19 Jul 2016 02:52:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B627E26C2F; Tue, 19 Jul 2016 02:52:58 +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 0F7A426490 for ; Tue, 19 Jul 2016 02:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752360AbcGSCw5 (ORCPT ); Mon, 18 Jul 2016 22:52:57 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:32165 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752308AbcGSCwz (ORCPT ); Mon, 18 Jul 2016 22:52:55 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie4.idc.renesas.com with ESMTP; 19 Jul 2016 11:52:53 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 4D09E4C214; Tue, 19 Jul 2016 11:52:53 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 308332806D; Tue, 19 Jul 2016 11:52:53 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 2775928070; Tue, 19 Jul 2016 11:52:53 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id MAB30361; Tue, 19 Jul 2016 11:52:53 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="215867054" Received: from mail-sg2apc01lp0242.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.242]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 19 Jul 2016 11:52:51 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qESdaV36Q2uGgdc9RMCNp6+3URJKDk52OpYg2vPAXAQ=; b=C4ga56DnOHyuTu19ULeQeiR2zddCxzuek6rVTs3wKANVgX6MM8X0ISfbNmUk/xfUdGtOIqEX7GWYzPAFjsdhPimYkD590dFZj7s3JeNugYDNr8Z/43ic9WCJ+iXVpr/kkY4IazPcVn6UytfasZB+U6/vi4MBHhC1DROCqnkcO8g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by PS1PR0601MB1451.apcprd06.prod.outlook.com (10.165.210.155) with Microsoft SMTP Server (TLS) id 15.1.539.14; Tue, 19 Jul 2016 02:52:48 +0000 Message-ID: <87mvlemjlr.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/7] 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: <87oa5umjoe.wl%kuninori.morimoto.gx@renesas.com> References: <87oa5umjoe.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Tue, 19 Jul 2016 02:52:48 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS2PR01CA0082.jpnprd01.prod.outlook.com (10.165.51.170) To PS1PR0601MB1451.apcprd06.prod.outlook.com (10.165.210.155) X-MS-Office365-Filtering-Correlation-Id: 287c374f-beb9-4fbe-acb2-08d3af7fc524 X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1451; 2:X0l4/AcxSMdnJE2/aXqpcfgsVCZ6gnu8YrWU3rKPN4oepLudWwe/UI0kQ+rBtfyrXpe1Oxr9br2fxAXI0z3XkVC6aE+OckYdEeNLVZz+nYLwVboVgmSqjph3dSAlan72l2nLcxp77JVTGodgvYgPu6MM36Z0xV59ThKwyg51wHUX1XBfIKysCQYVFlDRdxUV; 3:UIemebZ49OnyjiKxsQqIbnAjSGipDdzNwEthXVSUInFvBS5kJnvm3DQfH96Kp/0CZhyj9gYrLJzwBtV7qxW3YfSDDgtmScTTdsdBJpzeS9ehqYpRg/jr4Rof5K7LmAq8 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:PS1PR0601MB1451; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1451; 25:yWci+cOrWqj8G2CeV44Xm82J6OoCiKQVItTpixduG3YGFWgnmEJCVim0RiO8rF3RL1ztjG1yfdH8UnHTbuB+s1WafBobnjUX0K17poRPKsMKnXzkc/s4wsqPH723IC6panZnpfcqeNovgVmAcxodCwDs2pdIKv+jr4PbhncFDqub1GbLbjxQ4gCQNkn05Om/BHUIG5hNi3RdIHWKRRGFjhPrQFPhqnn9B+aLQMTKI2Cbr7zFV78C4OC6gAR7dz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ND2e9h13a6Dw4YlQ58DEccX2KZRos2E9F54tXC1BRxD4xZu74FR8jcLbrjgVqos0oj7V921Gh5y5z3eNTcDWxV+O4QqtF1KWO9HAGgE44rWY5pCZs4b8k+BELtUl5eyFKT0JJTNNCvt4QBzON86lHBv1u9E7W1A9b; 4:9XAYGB8s8Us1fwS9bEPqbp3Z9CUl2H7kZfrVJD7xrNrm3qEKA3aYGo7acHpwikvYY+8WpuKsV2kzfTQQCtQUHhmWGaj7Z9Pj/vkm6/Olkpnnm4HLiT1k68QQH2KqTb+9sJ06oCaSexnZysvN/Pvlq4AWcMIShwdk5DJ5AjBmxvt5oN+2Qh87V59JrPAEql3dTS/qJLDQMvHqf5FMJRRxtbdv/hd1QnM+McSuW8nAMVZ8RVcld929OpGUKc9Asxy4XWpzeIdxOo8ax0kWnO58nAv8lU6HUe16PVz2FfmbN1nbU78GVJb2YAT7MS1eIVZgp9ojt6pYAfK/CmOT04GW2V/9zC2R52F5Pvms3K2RTrGlPY2p1YndCzrl7jV4985L025/MhrOfVqc664naFARlg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:PS1PR0601MB1451; BCL:0; PCL:0; RULEID:; SRVR:PS1PR0601MB1451; X-Forefront-PRVS: 000800954F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(101416001)(53416004)(6116002)(3846002)(586003)(23726003)(230783001)(229853001)(77096005)(2906002)(33646002)(4326007)(50986999)(76176999)(106356001)(97736004)(47776003)(4001350100001)(69596002)(42186005)(7736002)(7846002)(189998001)(54356999)(105586002)(81166006)(81156014)(8676002)(46406003)(305945005)(83506001)(50466002)(86362001)(110136002)(19580395003)(92566002)(66066001)(2950100001)(68736007)(36756003)(19580405001)(21314002)(2004002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR0601MB1451; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; PS1PR0601MB1451; 23:LbAknQSEh2mN2etHWgwjAfPzGOAsGKacFADzBky?= =?us-ascii?Q?NMqNiszPu5+9opfu0ol7e4kMXdoOyyoF8aOgi1kmeoQ04FtNYcWYy61Qtcp6?= =?us-ascii?Q?5evFq40fx74YLmwDGYdf7vH6ihu7HZNkum8tBYzc404RSfz3ru1EiFnAeGBC?= =?us-ascii?Q?1o9kKJjRLdX7OSjkmg79RdVsTySCU0sZ68yG/BvptpKvEjOkSdQlS2MN3Vg3?= =?us-ascii?Q?AwOUgx1sLyKitNwdLFeCxBlgzK+qlbZ3m7apPctTP8WdMDP5KI1/BzDU/DAL?= =?us-ascii?Q?ue/ZXPPmQjgUkHJtd203aEV56FP1RXB2e+To+t5+sGz9yZRgikijenwbJbbr?= =?us-ascii?Q?4VgkBotuYZ0PvMURMUQgh8K6RXiFKD20qRFXbKA3PrkPXI1ybAGZ1a469m26?= =?us-ascii?Q?9LcBcGTOlibHN8+qKwGKMfTGybKxakuD/5aLj8JvqfAoy+gPNjUkL2b3R9Jy?= =?us-ascii?Q?vKCyWAphsEfUP3heEZhxyiJdAPv3GtUqGmZ32bbIYVjEpL9EV9rvktbogJKI?= =?us-ascii?Q?EHkcxE0suMyeoEvNqoddQ7gNFWpWKzKrZ8ODiHuRHEKOXDFALds9+2+oT68q?= =?us-ascii?Q?2fYwLDqFRKpQuCA3eePZBTLD0GkB7ckPX0lIT11lajhjzFAGfNoAZAkgqUWO?= =?us-ascii?Q?qE19zxW/ystnQHtHagYkc4srRUYEE9M7lRifMObhTGsAGjzAepjZLwv7HwO7?= =?us-ascii?Q?C6lTAcs7w127hVYGCfXv9sq1qPJxawbmlfc2jQsA8sbeDtxbAfzu8oPNAQbs?= =?us-ascii?Q?uzAmIdzABvsSI1OqF8D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ywN+l18ZpBFOTRjRLAtaWKFwIYAe0MWrRdoeM61w==; 24:fBawlZuAlrhEB/fTeRJlE74uNJp332VNX66/akdGsCkv+56gPENGGh30Roya7qhRrunHu4/8oQIvQDq0z1Dmv60ImqzPwuHMJ/ZqrNGAXXU=; 7:cl4IzB3qztf7jfuT51IEFilpbzSKrxtri3zuGk6FGQ+H6f2VXHRC4/4W7NfR5Y+U01fSEaHAfMxHVm5AhYcF9SOJLaoHAYd4Rjjso6o258jkL+R0bpQOgSH8O22ofmjMeIOICIlYJ8PlImonWViAuZa6QX52BTD/C/DW3oMTdF6fqquQymZqgEun8MsUTHMDxbUNXq+oGR1/ztzggXX7WsOPTsL04RJ6FrQbzTFYTYajjBNY5/tfLm9o1IExm+I8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1451; 20:PK1tPhhJVCBzGYCKLMnV67jGWgqK8Zfyrto/9KFDn29bygOK9w+/8K2uByXKoLbopcGAaNeVMT+MVvHGZuGBQoi98jj1xCYy9Rk7zveYTpFHZzR+V7x/gSrvGcgJLxgJ/PYRWe6UbnnAGyO5wF2Fxwz2xnsXBc0mpUM3phpaPKo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2016 02:52:48.7679 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR0601MB1451 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 --- previous -> this - keep clk on simple_dai->clk in last pattern include/sound/simple_card_utils.h | 8 ++++++++ sound/soc/generic/simple-card-utils.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 86088ae..1392eb5 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -33,4 +33,12 @@ int asoc_simple_card_set_dailink_name(struct device *dev, int asoc_simple_card_parse_card_name(struct snd_soc_card *card, char *prefix); +#define asoc_simple_card_parse_clk_cpu(node, dai_link, simple_dai) \ + asoc_simple_card_parse_clk(node, dai_link->cpu_of_node, simple_dai) +#define asoc_simple_card_parse_clk_codec(node, dai_link, simple_dai) \ + asoc_simple_card_parse_clk(node, dai_link->codec_of_node, simple_dai) +int asoc_simple_card_parse_clk(struct device_node *node, + struct device_node *dai_of_node, + 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 d89a9a1..2d1aab7 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 @@ -95,3 +96,34 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card, return 0; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name); + +int asoc_simple_card_parse_clk(struct device_node *node, + struct device_node *dai_of_node, + 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(node, 0); + if (!IS_ERR(clk)) { + simple_dai->sysclk = clk_get_rate(clk); + simple_dai->clk = clk; + } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { + simple_dai->sysclk = val; + } else { + clk = of_clk_get(dai_of_node, 0); + if (!IS_ERR(clk)) { + simple_dai->sysclk = clk_get_rate(clk); + simple_dai->clk = clk; + } + } + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);