From patchwork Tue Sep 1 15:12:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 7106081 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-sh@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 10F45BEEC1 for ; Tue, 1 Sep 2015 15:12:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C346205B1 for ; Tue, 1 Sep 2015 15:12:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 400B42058A for ; Tue, 1 Sep 2015 15:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753303AbbIAPMo (ORCPT ); Tue, 1 Sep 2015 11:12:44 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:37679 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752771AbbIAPMn (ORCPT ); Tue, 1 Sep 2015 11:12:43 -0400 Received: from ayla.of.borg ([31.5.182.137]) by albert.telenet-ops.be with bizsmtp id BrCg1r0072yGKqv06rCgln; Tue, 01 Sep 2015 17:12:41 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1ZWnEl-0004OQ-PS; Tue, 01 Sep 2015 17:12:39 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1ZWnEp-0000LK-2H; Tue, 01 Sep 2015 17:12:43 +0200 From: Geert Uytterhoeven To: Magnus Damm , Simon Horman Cc: Michael Turquette , Stephen Boyd , Rob Herring , Philipp Zabel , linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 3/6] clk: shmobile: rcar-gen3: Obtain MD pin values using syscon/regmap Date: Tue, 1 Sep 2015 17:12:38 +0200 Message-Id: <1441120361-1232-4-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441120361-1232-1-git-send-email-geert+renesas@glider.be> References: <1441120361-1232-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Obtain the values of the mode pins by reading the Mode Monitoring Register (MODEMR) using syscon and regmap. The syscon device and register offset to use are obtained from the "renesas,modemr" property in DT. Signed-off-by: Geert Uytterhoeven --- drivers/clk/shmobile/clk-rcar-gen3.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/drivers/clk/shmobile/clk-rcar-gen3.c b/drivers/clk/shmobile/clk-rcar-gen3.c index 4bf56dcf84a70ca5..43966656a30d0a4e 100644 --- a/drivers/clk/shmobile/clk-rcar-gen3.c +++ b/drivers/clk/shmobile/clk-rcar-gen3.c @@ -14,8 +14,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -51,28 +53,6 @@ struct rcar_gen3_cpg { */ #define rcar_clk_readl(cpg, _reg) readl(cpg->reg + _reg) -/* - * Reset register definitions. - */ -#define MODEMR 0xe6160060 - -static u32 rcar_gen3_read_mode_pins(void) -{ - static u32 mode; - static bool mode_valid; - - if (!mode_valid) { - void __iomem *modemr = ioremap_nocache(MODEMR, 4); - - BUG_ON(!modemr); - mode = ioread32(modemr); - iounmap(modemr); - mode_valid = true; - } - - return mode; -} - /* ----------------------------------------------------------------------------- * CPG Clock Data */ @@ -190,11 +170,18 @@ static void __init rcar_gen3_cpg_clocks_init(struct device_node *np) { const struct cpg_pll_config *config; struct rcar_gen3_cpg *cpg; - u32 cpg_mode; + struct regmap *regmap; + u32 reg, cpg_mode; unsigned int i; int num_clks; - cpg_mode = rcar_gen3_read_mode_pins(); + regmap = syscon_regmap_lookup_by_phandle(np, "renesas,modemr"); + if (IS_ERR(regmap) || + of_property_read_u32_index(np, "renesas,modemr", 1, ®) || + regmap_read(regmap, reg, &cpg_mode)) { + pr_err("%s: failed to parse renesas,modemr\n", np->full_name); + return; + } num_clks = of_property_count_u32_elems(np, "clock-indices"); if (num_clks < 0) {