Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751631AbcLEFYM (ORCPT ); Mon, 5 Dec 2016 00:24:12 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:10857 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751570AbcLEFYG (ORCPT ); Mon, 5 Dec 2016 00:24:06 -0500 X-IronPort-AV: E=Sophos;i="5.33,302,1477926000"; d="scan'208";a="227740722" Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Message-ID: <87zikbuezr.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 3/3] ASoC: simple-card-utils: enable clocks/clock-names/clock-ranges User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Russell King - ARM Linux , Stephen Boyd , Rob Herring , Linux-ALSA , Linux-DT , Michael Turquette , Linux-Kernel , Mark Brown , , Linux-ARM In-Reply-To: <874m2jvtmw.wl%kuninori.morimoto.gx@renesas.com> References: <874m2jvtmw.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="US-ASCII" Date: Mon, 5 Dec 2016 05:23:56 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OSXPR01CA0004.jpnprd01.prod.outlook.com (10.167.143.157) To HK2PR0601MB1442.apcprd06.prod.outlook.com (10.165.182.148) X-MS-Office365-Filtering-Correlation-Id: 8b015ae0-9f3d-4969-5d4a-08d41ccee9b1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:HK2PR0601MB1442; X-Microsoft-Exchange-Diagnostics: 1;HK2PR0601MB1442;3:OtOvoxxvB6WqhFz4e8IywWer8HgoontmCh78stNha/sXMA0klfFDfUVKPQPl7ySLVVYG0XefSwD+egpz/0CIwHN/R9sj/Dg2Yn4E3chdlKIysaVKKf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Bb9AnWk+tqXl48vJLaxLFzl42mRS59hHW5jBg76JoSEGTlcNAT4OqDwRghpekagh+atmzuavNyMlxCuzRJNRcVylvi38OIDbxyAsKsZ1zJa6QszR3vVEt7RP3Pt58PFzHVIv4gc1QRfVTwoWsxP5PdMbAqMMB7g6Gnn8r9zBJDkFWqiO/9/ANCqKA==;20:1eNNC9f4msHyGLiH4dlgxfSrV5BLf3VCVf2VhOf/8TgQ8f4XSq1raHgNY47C7jcqwZJxiLSMmNkdp30juRoW7bbT3ptGqcvdY/FCa/oO7vmEy4i8vW0G6cMWk8Bt04nmi+cTKlA5uiUInOziPkXU4nEBuTT+iu91eXqgRgbT/LklJRZvnGxiOm8eAZBNI/HdAMhlTo+bExhxw3+HYOgN9zJr0PoVFK4ATktw97GKTckT+UbPH6dUnvQEeOrkVkjD2KQwTN8H7ejIuHeGBynBvP6d5hfM5gv/Rc13Rd3IR8wfpYBunG00R1TwQakQsFIHEsLOVA6xnoCwm9opNaq8WUwze43IUZPNVOjNDK/vMN5LbtsB6mpXFLgTAF1TF5AGJJY5GXE5jSr9cPFmZmDY4siL2+9Di5G8GnFq9FfUN6dMLoOGNbI4J620MGMRTkGXHMixwBB673qbhmIPbB9d41BUIdRz8MaMXySrNBSug1bVdkgyTvrK8RY1Y3kmH1DZ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(20161123558021)(6072148);SRVR:HK2PR0601MB1442;BCL:0;PCL:0;RULEID:;SRVR:HK2PR0601MB1442; X-Microsoft-Exchange-Diagnostics: 1;HK2PR0601MB1442;4:tYw4qCWPdajqGIPrWqIVbUhQjnwzkNXPtVPcS96A9pye/rsDyeDbvjxXitkpTRvXGMQKa65fSHwcXTP2cJEOzEQCObJD4M1bTXIt7KsN0wOb40aR6twaxINw3RwPCsTKduWHMPN+BtvwfbRMGkSNoECW6a5l3bm6VS59DFDShZAXDunqnVNJoKDpiY4wm7pEjchSo0/wpuUDR41NaK4HpODwVhURuM09qFNWuNtoZYUztsemiwOpP5I7+bW3OPLRG18QDetiZTlIWWROiQyg5f8DY3P8a5CeSWToLn2ligKPMqG3fOvMyOfLScqg4fafYwOdgqhAxCiw89MwzU6DVZFTmF5M1PEsqnOnJXnq04NXoCaZ0pAR3vzzwluICfM2TN+6zY9LrTs8XAYgu8fy1NPql0B26KXoau4RXppKgpXnH/SbbgqRQctnDJgu0eIyA4VBpl0n3vrap8WXOCMAuuNz8dmTXPhGIi0LCatliNlCHtwAHtxHM9HHHZHrE5RA+y3bnZMZizonCeH3OL5XmZWf3LZ2HwJGl5oGJzrIQ3eXOmy0BRw9YlXrbSOUhg6Red9r3M7Mue3i7Q+MmFBzO4asZmISmJJXP2sii8nvC4gQSQGBpTf3tznQGvCQgicq X-Forefront-PRVS: 0147E151B5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(68736007)(8676002)(46406003)(38730400001)(305945005)(81166006)(81156014)(36756003)(7736002)(230783001)(7846002)(101416001)(2950100002)(7416002)(39410400001)(5660300001)(33646002)(50986999)(39850400001)(76176999)(54356999)(69596002)(4001350100001)(50466002)(97736004)(5001770100001)(23726003)(106356001)(83506001)(105586002)(2906002)(6116002)(3846002)(92566002)(107886002)(47776003)(39450400002)(6486002)(189998001)(86362001)(66066001)(733004)(53416004)(42186005)(39840400001)(39860400001)(21314002)(921003)(1121003)(16060500001);DIR:OUT;SFP:1102;SCL:1;SRVR:HK2PR0601MB1442;H:morimoto-PC.renesas.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HK2PR0601MB1442;23:ZtHnDbkKJzpXnWQ4wAmE/eZ1Azk3J+HLUvj3PwB?= =?us-ascii?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5W9Liy2WbZyYIy5+txQ0iJeKLiDjjyNFRWdut2zZYj/zBDRez3xfDqg3c+b6PlPhNX5tKVclV/FXgO5H8aJEJW9sUmyyMu3gNC81QEQo4KilHCqKEuBagol3g/MnS7qQ==;24:dWiUS05rQ3XHKdggI31TP5npL28wQ3mtdtkGUxTpQTrcwBD+DixaBVUeRxkZlxYq41bXhuqCYopNwOuHC2uBoBZrVTiVtlFjo0BHmabg938= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HK2PR0601MB1442;7:3oRBglayindVKI1E1PrrS4a6OjQACs8q2/zgAy0NBRGq8aPDhmmTZpVPBJT+vMWIYcqTqpQB/oW2FI7L9a13f2OI/6IKhiN8J0/Be6Oj4y9rm3xF5QVay7kDYfuHiEF1lwJhzLFS3PiErxf2iDxoOv1UPICQ37HxFxfbgH1WeQQB1EcrL8Kva/Fug3w1g1iPdA+Kg3DDiCUpEF1TCyp/1ZUHILN6Y33kXdl9INQ68QOkNgGyfuCPX/Ou/ipfam0seuFHvivOQ4kQu8k1mT4lnkMpsCDNe8TngviwfNMqI5QQ14S2h9HP55hP4lFec2QZQXtnB3IdKzjlk/d5ARsU5HQRnpGxD02ETjBh/LOGC94es9BGqlPpcOEl88EE2kzxpYZoDRcMdOek+l+r+0CwmBviKSuC4TdcyM6biy2M6fKj80I0l8HmVghXKKomcpMJiLEK9Hd2twkJ2ei4AkEdSA==;20:YOqUDwZuKlJVZI6cUh41Vm7BdwvSG09d054ct8hiYoD8ZZK3vaMBmA2Qb3vu7eLaPRVLRn82LUlf+lIqdjaq8FTJlc9H1z1IJTh91jo0DJmdkKFMGbDf0yNywJKu2NNAyVXByaCl0TrHWLd/LdiGaaQ0kt3cf76WNn4V3emYP4A= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2016 05:23:56.5960 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1442 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3511 Lines: 146 From: Kuninori Morimoto Current simple-card is supporting this style for clocks sound { ... simple-audio-card,cpu { sound-dai = <&xxx>; clocks = <&cpu_clock>; }; simple-audio-card,codec { sound-dai = <&xxx>; clocks = <&codec_clock>; }; }; Now, it can support this style too, because we can use devm_get_clk_from_child() now. sound { ... clocks = <&cpu_clock>, <&codec_clock>; clock-names = "cpu", "codec"; clock-ranges; ... simple-audio-card,cpu { sound-dai = <&xxx>; }; simple-audio-card,codec { sound-dai = <&xxx>; }; }; Signed-off-by: Kuninori Morimoto --- .../devicetree/bindings/sound/simple-card.txt | 32 ++++++++++++++++++ sound/soc/generic/simple-card-utils.c | 39 +++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index c7a9393..43a710b 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -86,6 +86,7 @@ Optional CPU/CODEC subnodes properties: in dai startup() and disabled with clk_disable_unprepare() in dai shutdown(). + see Clock Example. Example 1 - single DAI link: @@ -199,3 +200,34 @@ sound { clocks = ... }; }; + + +Clock Example 1 - clock settings on each subnode + +sound { + ... + simple-audio-card,cpu { + sound-dai = <&xxx>; + clocks = <&cpu_clock>; + }; + simple-audio-card,codec { + sound-dai = <&xxx>; + clocks = <&codec_clock>; + }; +}; + +Clock Example 2 - clock settings by clocks + +sound { + ... + clocks = <&cpu_clock>, <&codec_clock>; + clock-names = "cpu", "codec"; + clock-ranges; + ... + simple-audio-card,cpu { + sound-dai = <&xxx>; + }; + simple-audio-card,codec { + sound-dai = <&xxx>; + }; +}; diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 4924575..c3031a5 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -104,15 +104,52 @@ int asoc_simple_card_parse_clk(struct device *dev, struct asoc_simple_dai *simple_dai) { struct clk *clk; + const char *con_id = NULL; + const char *port_name[] = { + "cpu", "codec" + }; u32 val; /* + * We can use this style if "con_id" is not NULL + * + * sound { + * ... + * clocks = <&xxx>, <&xxx>; + * clock-names = "cpu", "codec"; + * clock-ranges; + * + * simple-audio-card,cpu { + * sound-dai = <&xxx>; + * }; + * simple-audio-card,codec { + * sound-dai = <&xxx>; + * }; + * }; + */ + if (of_find_property(dev->of_node, "clock-names", NULL)) { + int i; + int port_len, node_len; + + for (i = 0; i < ARRAY_SIZE(port_name); i++) { + node_len = strlen(node->name); + port_len = strlen(port_name[i]); + + if (0 == strncmp(node->name + node_len - port_len, + port_name[i], port_len)) { + con_id = port_name[i]; + break; + } + } + } + + /* * Parse dai->sysclk come from "clocks = <&xxx>" * (if system has common clock) * or "system-clock-frequency = " * or device's module clock. */ - clk = devm_get_clk_from_child(dev, node, NULL); + clk = devm_get_clk_from_child(dev, node, con_id); if (!IS_ERR(clk)) { simple_dai->sysclk = clk_get_rate(clk); } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { -- 1.9.1