From patchwork Mon May 18 22:35:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Eastwood X-Patchwork-Id: 6432491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4CAACC0432 for ; Mon, 18 May 2015 22:39:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7D92A203A5 for ; Mon, 18 May 2015 22:39:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0272203AB for ; Mon, 18 May 2015 22:39:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YuTf4-0006Jj-0a; Mon, 18 May 2015 22:37:26 +0000 Received: from mail-la0-x233.google.com ([2a00:1450:4010:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YuTeJ-00063W-TA for linux-arm-kernel@lists.infradead.org; Mon, 18 May 2015 22:36:43 +0000 Received: by lagv1 with SMTP id v1so240923663lag.3 for ; Mon, 18 May 2015 15:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KpUtswvxcN/MFU+2s2EIEIRnBLn9ajANKGYDhqk4sfc=; b=jfNZ2NxrIaFOCW6lARqujuAIiArS9bmS8IMBNfcHbckfgTHDteCLmPe6ZjTXp5MObO 8I0ZR9OBwsS/w8WQo44hRJDqC5TeXp1DDOymgu+A0Sf2icPGGHolMRcSUxdaFNNXg/14 jX5ZdtvLG3DVT2aydvnG4yscWdhAcUiLuUh7YUZ0cpxrcR+8cID+wh5t+cnjH/12BCmr +Mj03YwZC4dZk7yMOP+MLo1gS4gWPQ3xTxZsvYZvaFtk8sctafZAzpklFVg9Xv1Qq0zw mFfE2H4Gt2Y7Sj2sb+PBmYgTEUM1dD6uDKvtZVvNMEMGhYAQWQycdqrJSiHH5uCQrdFf Ez4A== X-Received: by 10.152.5.198 with SMTP id u6mr16997682lau.48.1431988577901; Mon, 18 May 2015 15:36:17 -0700 (PDT) Received: from localhost.localdomain ([90.149.48.183]) by mx.google.com with ESMTPSA id f7sm3066608lbc.9.2015.05.18.15.36.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 18 May 2015 15:36:17 -0700 (PDT) From: Joachim Eastwood To: mturquette@linaro.org, sboyd@codeaurora.org Subject: [PATCH v3 3/6] clk: add function to retrieve clk id from dt Date: Tue, 19 May 2015 00:35:56 +0200 Message-Id: <1431988559-23338-4-git-send-email-manabian@gmail.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1431988559-23338-1-git-send-email-manabian@gmail.com> References: <1431988559-23338-1-git-send-email-manabian@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150518_153640_139077_C61D06BD X-CRM114-Status: GOOD ( 11.18 ) X-Spam-Score: -0.8 (/) Cc: devicetree@vger.kernel.org, Joachim Eastwood , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ezequiel@vanguardiasur.com.ar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP of_clk_get_index can be used to retrieve the clock index/id from the device tree. This can be used in drivers to setup routing between different clock devices. Signed-off-by: Joachim Eastwood --- drivers/clk/clk.c | 18 ++++++++++++++++++ include/linux/clk-provider.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 459ce9da13e0..39d4cfc98811 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3060,6 +3060,24 @@ const char *of_clk_get_parent_name(struct device_node *np, int index) } EXPORT_SYMBOL_GPL(of_clk_get_parent_name); +int of_clk_get_index(struct device_node *np, int index) +{ + struct of_phandle_args clkspec; + int rc; + + if (index < 0) + return -EINVAL; + + rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, + &clkspec); + if (rc) + return -EINVAL; + + of_node_put(clkspec.np); + return clkspec.args_count ? clkspec.args[0] : -EINVAL; +} +EXPORT_SYMBOL_GPL(of_clk_get_index); + struct clock_provider { of_clk_init_cb_t clk_init_cb; struct device_node *np; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index df695313f975..70eed561319e 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -625,6 +625,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data); int of_clk_get_parent_count(struct device_node *np); const char *of_clk_get_parent_name(struct device_node *np, int index); +int of_clk_get_index(struct device_node *np, int index); void of_clk_init(const struct of_device_id *matches);