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: 78092 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp949802qge; Tue, 18 Oct 2016 08:47:13 -0700 (PDT) X-Received: by 10.99.251.69 with SMTP id w5mr1383848pgj.108.1476805633800; Tue, 18 Oct 2016 08:47:13 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si15911523paf.193.2016.10.18.08.47.13; Tue, 18 Oct 2016 08:47:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936453AbcJRPrN (ORCPT + 4 others); 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 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(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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,