From patchwork Tue Oct 18 15:46:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 9382455 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 05FD16086B for ; Tue, 18 Oct 2016 15:47:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB01F2965A for ; Tue, 18 Oct 2016 15:47:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF6ED29672; Tue, 18 Oct 2016 15: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,RCVD_IN_DNSWL_HI autolearn=unavailable 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 8E3E02966B for ; Tue, 18 Oct 2016 15:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936453AbcJRPrN (ORCPT ); Tue, 18 Oct 2016 11:47:13 -0400 Received: from arroyo.ext.ti.com ([198.47.19.12]:42234 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935555AbcJRPrM (ORCPT ); Tue, 18 Oct 2016 11:47:12 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id u9IFkkFD023170; Tue, 18 Oct 2016 10:46:46 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9IFkkTD023655; Tue, 18 Oct 2016 10:46:46 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Tue, 18 Oct 2016 10:46:46 -0500 Received: from gomoku.home (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9IFkJXF006114; Tue, 18 Oct 2016 10:46:44 -0500 From: Tero Kristo To: , , , , CC: Subject: [PATCHv4 10/15] clk: ti: add support API for fetching memmap index Date: Tue, 18 Oct 2016 18:46:03 +0300 Message-ID: <1476805568-19264-11-git-send-email-t-kristo@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476805568-19264-1-git-send-email-t-kristo@ti.com> References: <1476805568-19264-1-git-send-email-t-kristo@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Searches for a memmap index for a given node. Checks against all the registered iomaps and sees if the node is registered for this. Signed-off-by: Tero Kristo --- drivers/clk/ti/clk.c | 24 ++++++++++++++++++++++++ drivers/clk/ti/clock.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c index 7a445f4..8bebda4 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -39,6 +39,7 @@ struct clk_iomap { struct regmap *regmap; void __iomem *mem; + struct device_node *node; }; static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS]; @@ -199,6 +200,28 @@ void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index) } /** + * ti_clk_get_memmap_index - get memory mapping index for a node + * @node: device node pointer to find memmap index for + * + * Finds a matching memory mapping index for a node. Returns the index + * to the mapping, or negative error value in failure. + */ +int ti_clk_get_memmap_index(struct device_node *node) +{ + int i; + + for (i = 0; i < CLK_MAX_MEMMAPS; i++) { + if (!clk_memmaps[i]) + continue; + + if (clk_memmaps[i]->node == node) + return i; + } + + return -ENOENT; +} + +/** * omap2_clk_provider_init - init master clock provider * @parent: master node * @index: internal index for clk_reg_ops @@ -234,6 +257,7 @@ int __init omap2_clk_provider_init(struct device_node *parent, int index, io->regmap = syscon; io->mem = mem; + io->node = parent; clk_memmaps[index] = io; diff --git a/drivers/clk/ti/clock.h b/drivers/clk/ti/clock.h index 9c85a51..9b8a5f2 100644 --- a/drivers/clk/ti/clock.h +++ b/drivers/clk/ti/clock.h @@ -203,6 +203,7 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw, struct clk *ti_clk_register_clk(struct ti_clk *setup); int ti_clk_register_clks(struct ti_clk_alias *clks); +int ti_clk_get_memmap_index(struct device_node *node); void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index); void ti_dt_clocks_register(struct ti_dt_clk *oclks); int ti_clk_retry_init(struct device_node *node, struct clk_hw *hw,