From patchwork Tue Jul 7 14:10:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 6733231 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0FF6C9F536 for ; Tue, 7 Jul 2015 14:10:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 25B3C205C2 for ; Tue, 7 Jul 2015 14:10:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31E2A20626 for ; Tue, 7 Jul 2015 14:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757291AbbGGOKW (ORCPT ); Tue, 7 Jul 2015 10:10:22 -0400 Received: from laurent.telenet-ops.be ([195.130.137.89]:39835 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757830AbbGGOKS (ORCPT ); Tue, 7 Jul 2015 10:10:18 -0400 Received: from ayla.of.borg ([84.193.93.87]) by laurent.telenet-ops.be with bizsmtp id pSAF1q00J1t5w8s01SAFrc; Tue, 07 Jul 2015 16:10:16 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1ZCTZf-00063z-2C; Tue, 07 Jul 2015 16:10:15 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1ZCTZj-0005Lr-Dv; Tue, 07 Jul 2015 16:10:19 +0200 From: Geert Uytterhoeven To: Simon Horman , Magnus Damm , Michael Turquette , Stephen Boyd Cc: Laurent Pinchart , Ulrich Hecht , linux-sh@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven Subject: [PATCH/RFC 01/11] clk: shmobile: rcar-gen2: Obtain MD pin values using syscon/regmap Date: Tue, 7 Jul 2015 16:10:07 +0200 Message-Id: <1436278217-20522-2-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436278217-20522-1-git-send-email-geert+renesas@glider.be> References: <1436278217-20522-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=-7.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 MD 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. Fall back to calling rcar_gen2_read_mode_pins() in the R-Car Gen2 platform code for backward-compatibility with old DTs. TODO Document "renesas,modemr" property in DT binding doc. Signed-off-by: Geert Uytterhoeven --- drivers/clk/shmobile/clk-rcar-gen2.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/clk/shmobile/clk-rcar-gen2.c b/drivers/clk/shmobile/clk-rcar-gen2.c index 745496f7ee9c7402..b121a49f7575a97b 100644 --- a/drivers/clk/shmobile/clk-rcar-gen2.c +++ b/drivers/clk/shmobile/clk-rcar-gen2.c @@ -15,8 +15,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -368,9 +370,22 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np) { const struct cpg_pll_config *config; struct rcar_gen2_cpg *cpg; + struct regmap *regmap; struct clk **clks; unsigned int i; int num_clks; + u32 reg; + + 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)) { + /* Backward-compatibility with old DT */ + extern u32 rcar_gen2_read_mode_pins(void); + + pr_warn("%s: failed to parse renesas,modemr\n", np->full_name); + cpg_mode = rcar_gen2_read_mode_pins(); + } num_clks = of_property_count_strings(np, "clock-output-names"); if (num_clks < 0) {