From patchwork Tue Oct 18 15:45:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 78086 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp949691qge; Tue, 18 Oct 2016 08:47:00 -0700 (PDT) X-Received: by 10.99.114.29 with SMTP id n29mr1344974pgc.7.1476805620180; Tue, 18 Oct 2016 08:47:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si36341912pfk.159.2016.10.18.08.47.00; Tue, 18 Oct 2016 08:47:00 -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 S1030235AbcJRPq5 (ORCPT + 4 others); Tue, 18 Oct 2016 11:46:57 -0400 Received: from bear.ext.ti.com ([198.47.19.11]:42760 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964890AbcJRPq4 (ORCPT ); Tue, 18 Oct 2016 11:46:56 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id u9IFkX8N029978; Tue, 18 Oct 2016 10:46:33 -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 u9IFkXr5023516; Tue, 18 Oct 2016 10:46:33 -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:33 -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 u9IFkJXA006114; Tue, 18 Oct 2016 10:46:31 -0500 From: Tero Kristo To: , , , , CC: Subject: [PATCHv4 05/15] clk: ti: create clock aliases automatically for simple clock types Date: Tue, 18 Oct 2016 18:45:58 +0300 Message-ID: <1476805568-19264-6-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 This patch generates clock aliases automatically for simple clock types (fixed-clock, fixed-factor-clock), so that we don't need to add the data for these statically into tables. Signed-off-by: Tero Kristo --- drivers/clk/ti/clk.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) -- 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 91bad55..7fd9d8e 100644 --- a/drivers/clk/ti/clk.c +++ b/drivers/clk/ti/clk.c @@ -355,12 +355,20 @@ struct clk __init *ti_clk_register_clk(struct ti_clk *setup) return clk; } +static const struct of_device_id simple_clk_match_table[] __initconst = { + { .compatible = "fixed-clock" }, + { .compatible = "fixed-factor-clock" }, + { } +}; + int __init ti_clk_register_legacy_clks(struct ti_clk_alias *clks) { struct clk *clk; bool retry; struct ti_clk_alias *retry_clk; struct ti_clk_alias *tmp; + struct device_node *np; + int ret = 0; while (clks->clk) { clk = ti_clk_register_clk(clks->clk); @@ -370,7 +378,14 @@ int __init ti_clk_register_legacy_clks(struct ti_clk_alias *clks) } else { pr_err("register for %s failed: %ld\n", clks->clk->name, PTR_ERR(clk)); - return PTR_ERR(clk); + ret = PTR_ERR(clk); + /* + * Aliases still need to be added here, + * as we might be running on a + * transitional system that has old DT + * clock data in place. + */ + goto add_aliases; } } else { clks->lk.clk = clk; @@ -404,6 +419,18 @@ int __init ti_clk_register_legacy_clks(struct ti_clk_alias *clks) } } +add_aliases: + /* add clock aliases for any fixed-clocks / fixed-factor-clocks */ + if (of_have_populated_dt()) + for_each_matching_node(np, simple_clk_match_table) { + struct of_phandle_args clkspec; + + clkspec.np = np; + clk = of_clk_get_from_provider(&clkspec); + + ti_clk_add_alias(NULL, clk, np->name); + } + return 0; } #endif