From patchwork Thu May 12 08:27:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 9077561 X-Patchwork-Delegate: horms@verge.net.au Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 227239FF69 for ; Thu, 12 May 2016 08:29:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4DB46201EC for ; Thu, 12 May 2016 08:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F32B201F5 for ; Thu, 12 May 2016 08:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbcELI3Q (ORCPT ); Thu, 12 May 2016 04:29:16 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:54507 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbcELI3N (ORCPT ); Thu, 12 May 2016 04:29:13 -0400 Received: from vsmta11.fe.internet.bosch.com (unknown [10.4.98.51]) by imta24.fe.bosch.de (Postfix) with ESMTP id 9510DD8021B for ; Thu, 12 May 2016 10:29:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1463041751; bh=nu3KwRthIQI56V1Oh3T2yBzBk08GY2DG69Rq4AJmH0c=; l=10; h=From:From:Reply-To:Sender; b=WMVRKyxXswfMLPVcBpskOMkyTz3kZ97VD0D/1USoRFF6nRz/1hnFXEwDhcIJ8tVla OuRyGkzV3/9zPWCPGstvPIVdU4bi+WWbj14sauv9UjB9SkojIKxzkvGV0dl7XUK7OT qnFgNXbI8dRVwbbyiPw4zKNh0qAAStZ73SGnPU0U= Received: from SI-HUB1000.de.bosch.com (vsgw24.fe.internet.bosch.com [10.4.98.24]) by vsmta11.fe.internet.bosch.com (Postfix) with ESMTP id 55A3D23802C3 for ; Thu, 12 May 2016 10:29:11 +0200 (CEST) Received: from hi-z08if.hi.de.bosch.com (10.34.209.31) by SI-HUB1000.de.bosch.com (10.4.103.106) with Microsoft SMTP Server id 14.3.195.1; Thu, 12 May 2016 10:29:09 +0200 Received: from hi-z08if.hi.de.bosch.com (localhost [127.0.0.1]) by hi-z08if.hi.de.bosch.com (Postfix) with ESMTP id 75EAB625EA0; Thu, 12 May 2016 10:27:26 +0200 (CEST) From: Dirk Behme To: Geert Uytterhoeven , Simon Horman , Subject: [PATCH 3/6] clk: renesas: rcar-gen3: Obtain MD pin values using syscon/regmap Date: Thu, 12 May 2016 10:27:18 +0200 Message-ID: <1463041641-27485-4-git-send-email-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.8.0 In-Reply-To: <1463041641-27485-1-git-send-email-dirk.behme@de.bosch.com> References: <1463041641-27485-1-git-send-email-dirk.behme@de.bosch.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22314.006 X-TMASE-MatchedRID: VaWjHXteqEBEQh7fEDskzuqwWVBfMuvoWjWsWQUWzVpHZg0gWH5yUR8+ XHETeZCzgML9UOgCBPdHfn7MYCDAPhLmJd2F/yFuhK8o4aoss8ooUVkB7ifJnrzZNXfJG3+avBo xFolJ+mCjEtGNJDz5hksJTq/V2+nLGAdnzrnkM48URSScn+QSXt0H8LFZNFG76sBnwpOylLNvCw QxDIopYLcz7gYUbl8Dux4Gq+3MPYwSAu8BWR0ZnRek68/6DfOvMK9Rhu9t+TNcCZv/uH0xjWvqV bqlkU9SS2SpB0fc0OBT1+u5jDncxCy/wVJcUjWMngzrwqoWU9c0c6HeJwIhmn7cGd19dSFd Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 From: Geert Uytterhoeven 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/renesas/r8a7795-cpg-mssr.c | 15 ++++++++++++++- drivers/clk/renesas/r8a7796-cpg-mssr.c | 15 ++++++++++++++- drivers/clk/renesas/rcar-gen3-cpg.c | 17 ----------------- drivers/clk/renesas/rcar-gen3-cpg.h | 1 - 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/clk/renesas/r8a7795-cpg-mssr.c b/drivers/clk/renesas/r8a7795-cpg-mssr.c index e53aff5..f956a1b 100644 --- a/drivers/clk/renesas/r8a7795-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7795-cpg-mssr.c @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include #include @@ -294,7 +297,17 @@ static const struct rcar_gen3_cpg_pll_config cpg_pll_configs[16] __initconst = { static int __init r8a7795_cpg_mssr_init(struct device *dev) { const struct rcar_gen3_cpg_pll_config *cpg_pll_config; - u32 cpg_mode = rcar_gen3_read_mode_pins(); + struct device_node *np = dev->of_node; + struct regmap *regmap; + u32 cpg_mode, 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)) { + dev_err(dev, "Failed to parse renesas,modemr\n"); + return -EINVAL; + } cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)]; if (!cpg_pll_config->extal_div) { diff --git a/drivers/clk/renesas/r8a7796-cpg-mssr.c b/drivers/clk/renesas/r8a7796-cpg-mssr.c index c84b549..2a0375d 100644 --- a/drivers/clk/renesas/r8a7796-cpg-mssr.c +++ b/drivers/clk/renesas/r8a7796-cpg-mssr.c @@ -16,6 +16,9 @@ #include #include #include +#include +#include +#include #include @@ -159,7 +162,17 @@ static const struct rcar_gen3_cpg_pll_config cpg_pll_configs[16] __initconst = { static int __init r8a7796_cpg_mssr_init(struct device *dev) { const struct rcar_gen3_cpg_pll_config *cpg_pll_config; - u32 cpg_mode = rcar_gen3_read_mode_pins(); + struct device_node *np = dev->of_node; + struct regmap *regmap; + u32 cpg_mode, 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)) { + dev_err(dev, "Failed to parse renesas,modemr\n"); + return -EINVAL; + } cpg_pll_config = &cpg_pll_configs[CPG_PLL_CONFIG_INDEX(cpg_mode)]; if (!cpg_pll_config->extal_div) { diff --git a/drivers/clk/renesas/rcar-gen3-cpg.c b/drivers/clk/renesas/rcar-gen3-cpg.c index bb4f2f9..9d76076 100644 --- a/drivers/clk/renesas/rcar-gen3-cpg.c +++ b/drivers/clk/renesas/rcar-gen3-cpg.c @@ -333,23 +333,6 @@ struct clk * __init rcar_gen3_cpg_clk_register(struct device *dev, __clk_get_name(parent), 0, mult, div); } -/* - * Reset register definitions. - */ -#define MODEMR 0xe6160060 - -u32 __init rcar_gen3_read_mode_pins(void) -{ - void __iomem *modemr = ioremap_nocache(MODEMR, 4); - u32 mode; - - BUG_ON(!modemr); - mode = ioread32(modemr); - iounmap(modemr); - - return mode; -} - int __init rcar_gen3_cpg_init(const struct rcar_gen3_cpg_pll_config *config, unsigned int clk_extalr) { diff --git a/drivers/clk/renesas/rcar-gen3-cpg.h b/drivers/clk/renesas/rcar-gen3-cpg.h index f699085..f788f48 100644 --- a/drivers/clk/renesas/rcar-gen3-cpg.h +++ b/drivers/clk/renesas/rcar-gen3-cpg.h @@ -33,7 +33,6 @@ struct rcar_gen3_cpg_pll_config { #define CPG_RCKCR 0x240 -u32 rcar_gen3_read_mode_pins(void); struct clk *rcar_gen3_cpg_clk_register(struct device *dev, const struct cpg_core_clk *core, const struct cpg_mssr_info *info, struct clk **clks, void __iomem *base);