From patchwork Fri May 20 09:47:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9129047 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 B8A5E60762 for ; Fri, 20 May 2016 09:47:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA3A11FF6C for ; Fri, 20 May 2016 09:47:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CFCD25D91; Fri, 20 May 2016 09:47:13 +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 20F9B1FF6C for ; Fri, 20 May 2016 09:47:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932455AbcETJrM (ORCPT ); Fri, 20 May 2016 05:47:12 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:50180 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932274AbcETJrL (ORCPT ); Fri, 20 May 2016 05:47:11 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 20 May 2016 18:47:09 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 36AD452ACC; Fri, 20 May 2016 18:47:09 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 1E9751806F; Fri, 20 May 2016 18:47:09 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 1A5001800A; Fri, 20 May 2016 18:47:09 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id UAP01134; Fri, 20 May 2016 18:47:08 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="211713716" Received: from mail-pu1apc01lp0023.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.23]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 20 May 2016 18:47:07 +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=BZrL14vNwq1lzb+gnzGgEdv+0Bcfo9/dRJD/rZpJROo=; b=WVdqcsxfwAOZKpZX6HdhdY+hTPmdDDkemTo1aRsmYNJRGZqI1g/6DzZdJmjly1ca0kVDPlhac220Ma6vc8zCokRoy9HOzP5ik+F7gRuJSOwDKeP/FQReW0B99DBd4VmOhQ01/zry7GczmZt7EioiKrVbWqNW1/QFnil7yTRXnI4= 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 KL1PR06MB1704.apcprd06.prod.outlook.com (10.167.63.18) with Microsoft SMTP Server (TLS) id 15.1.497.12; Fri, 20 May 2016 09:47:02 +0000 Message-ID: <874m9trrrz.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 12/49] ASoC: simple-card-core: 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: <87lh35rs8w.wl%kuninori.morimoto.gx@renesas.com> References: <87lh35rs8w.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 20 May 2016 09:47:02 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS1PR01CA0006.jpnprd01.prod.outlook.com (10.161.225.144) To KL1PR06MB1704.apcprd06.prod.outlook.com (10.167.63.18) X-MS-Office365-Filtering-Correlation-Id: 5819ddca-b0b3-4bf9-f96b-08d38093b2bb X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1704; 2:ne71dnwv7eRO58jhH+zShXXN4NfNOta0XkwtiVfnPPRBi4hewsQf4zA67lTHPpXIZpH+EgXKrsrHLPeHYs+eRzDxt5k0ev74q5QWzEneC1VeCmRqAB8neuaKAM5SdiwtlDJ7iqF5Cwn7mXczNKKasJi19qs8dTiObPcQP9pU5/aUM9QaUCFNcgeUIviYGQvB; 3:DDoYRITllsvMtD44y3PBW3g8k2kIuc8LExEuh7qflM3lbFuDT1JScXgSzAI/j9P+pTtpyGouduUZWP22y5fiXTElEWXarsihGOZzYqEnjvHhhqIfNXp0ksisGZT97nQI; 25:S8g5FOsgfsWlB0/4tAJAqXu7wfsIiuSNUP8qdaLSyekqRxhBl5pTwuJiTdF9qhfMQG5Gqz5X+KoEVJ8FN88RLL3LO+s06ldBHScmpADgilYuI9RP5YaQRu9AaEO3+f5qADGSrazJCv14c5rW8BSTScKnmL9oZfs92prlwT2aSHDzC3HGRwacA75HfANdoJCJ2Ll/sOgjq79nTudq9dksPrtXGnJUlnd/KR+rO0ONqmKitdGoRfAMrlb9NTO065N5bvrC2MGoMmI8i41Zo2OZja9i7lDzZcavTC+EHVFGbHh/YyLS0YAnqMA63NYwL2Q2eNJwhCtKKqeWLUBcdBz5fbnohx3n9Hbz3Omz2+Xf6EdHSbHPB/+NkBCBMTYKVq7koP4k1D1WADAK5pMRYeegP7pTgXUY72sErU8DyKE38qs= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:KL1PR06MB1704; X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1704; 20:C7m0g0CQV9B401JCt9LAGg8DItvcmqJ0wWkbI7bhar7+E3ihAWK94ufLrQfrXf8W06sn5mmSCmB2uk0qraly1W3uJvE7sA7dJ9hjvz0f0C2CP4lxUFDW4+XSRE6PnLbZ3+NdsHndaZFFk2mXWXH+burZhSFr7FL2b7RUATPzLmQbNVAtp46sJZ2hrm5dluqwPZcpYEea9XbpzI348IwYuPV/vz4V/kTzYryRNWqhPkyJvzxRDzNo31GXKZd8AIyHy4SYcB98ggcvnJQOCa/vl1XF8o4KETBlJZopVD1eAUFgC/m+yJP3og0xIRdrMjU2Tpcg8hz39ip8TnRIsDjKbV35xObpjQtH1P3kdtqV3GAzz+cPok1PYKgW5lU2FD1lw6agL41j7LuzZOu55SXKELkMIziCZ/K87q12gDRNfz4qh+2ANOMWyxz1X7yLZOyGgt3n9q7eC63XDlXaOCp6LEBGE9/Wl4eQ7g6/jRiEaBJHp4tmibhWzaynspBVPoRY; 4:tkU+noRLtwZqGpXO3UawGHMbbJwSV3LOmx0CGFwY0eYeHQlHBBM5ApSgsJ2pRucZPfP991pHdwr86IYIjJE9ZCTfeLktVDp1G0Lbox65//c09GIJDjX1bwSVjmdmOF3FSuqjqh97E9Qq88flmTSo1/eJvkj05iH5dazigJMOyK+wc4FyXdcv1w7oTt7Pa+SFawzcH7swLiCYvQV/ONsy11Z7rqkM2nsIX5ogtxr3PvIcBN8eft8dWji8iOX2BIsoA9/0T2w/O3w5Z+miM6Y1TKB621IWmYLD8c+SO/CMrzpjveoV1/ZF++9Vr5zhhh+UhQrWjH1xJbb39//wFuxXklnYXFMl/pl83v+0iyi64/DKsWgdbVFyinhltDdwrsLoONEdksH5MQBLJqQU3wESZA== 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:KL1PR06MB1704; BCL:0; PCL:0; RULEID:; SRVR:KL1PR06MB1704; X-Forefront-PRVS: 09480768F8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(229853001)(8676002)(5008740100001)(23726003)(2950100001)(47776003)(77096005)(5004730100002)(86362001)(36756003)(66066001)(230783001)(53416004)(19580395003)(83506001)(3846002)(42186005)(50466002)(33646002)(2906002)(46406003)(4326007)(189998001)(6116002)(110136002)(50986999)(76176999)(54356999)(19580405001)(81166006)(92566002)(586003)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1PR06MB1704; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1704; 23:DBBfXSkSX7wxnTZ6cohbXZxDXDevA0Y5K8i+T51RRyj2/E4GDfgNzFvwhgLNZXGLDQFPmbdmAQQoGSMNhbyo0EMYJBsRfgd25NhKH2qKJ382iCufSKM5v5RlTUWt0MKc3z4ngPjM3kWgYrWFkJD0QOvysitstksRBHZbTpK7KljAhuSMRtFCH1LpTRjVuSl6gGdaDgsSqj9rSaapA9ihLSWxpiXuHHVpaCKopZApsfivRLdTZRbIAA782cZ0D2RPr6LV+JqC/0tv0GiWeWyFjRuu1OSEdmiV1Ju3ryisBAn9/Jg4Nufe8E4DZs2xzmu/9pxsgFEeU9ECOMX0rIiOjeaB9kFkpIYb8TShbGJRulDnd3DMTT88e4Dj3ieT0ahwi5+e/XTpopckqhpxJmNhO1ACfI9Kll/qMGkj0Almy7R+Y0himgqIx+OgjO2HBvyouK8nYLO0yNOksv4bQCcHm47ix9lNTeiB/qOXIJWu6dq+SLb52pQ/2GeyKM9nf3SLYLPedTFkmHNqN8YzorlaAhlRKJRSg0BoRdk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osticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2016 09:47:02.5329 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB1704 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_core.h | 8 ++++++++ sound/soc/generic/simple-card-core.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/sound/simple_card_core.h b/include/sound/simple_card_core.h index 41a66e8..5105b24 100644 --- a/include/sound/simple_card_core.h +++ b/include/sound/simple_card_core.h @@ -42,4 +42,12 @@ int asoc_simple_card_parse_card_route(struct snd_soc_card *card, int asoc_simple_card_parse_card_widgets(struct snd_soc_card *card, 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-core.c b/sound/soc/generic/simple-card-core.c index baabb50..1b01c07 100644 --- a/sound/soc/generic/simple-card-core.c +++ b/sound/soc/generic/simple-card-core.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 @@ -174,3 +175,32 @@ int asoc_simple_card_parse_card_widgets(struct snd_soc_card *card, return ret; } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_widgets); + +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);