From patchwork Fri Jan 27 09:24:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris BREZILLON X-Patchwork-Id: 9540865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 286FE60429 for ; Fri, 27 Jan 2017 09:25:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F34520952 for ; Fri, 27 Jan 2017 09:25:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11CE527FC0; Fri, 27 Jan 2017 09:25:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00 autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 965AE20952 for ; Fri, 27 Jan 2017 09:25:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cX2mC-0003c2-N0; Fri, 27 Jan 2017 09:25:00 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cX2lm-0003Z5-SK for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2017 09:24:36 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 1E12920DCE; Fri, 27 Jan 2017 10:24:18 +0100 (CET) Received: from localhost.localdomain (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id E487A20DCA; Fri, 27 Jan 2017 10:24:17 +0100 (CET) From: Boris Brezillon To: Nicolas Ferre , Alexandre Belloni Subject: [PATCH] memory: atmel-ebi: Enable the SMC clock if specified Date: Fri, 27 Jan 2017 10:24:09 +0100 Message-Id: <1485509049-372-1-git-send-email-boris.brezillon@free-electrons.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170127_012435_244258_BAF595F7 X-CRM114-Status: GOOD ( 13.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Boris Brezillon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Newer versions of the SMC block requires the SMC clock to be enabled before the SMC logic can be used. Signed-off-by: Boris Brezillon --- drivers/memory/atmel-ebi.c | 51 +++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c index 46657eaaedf6..4e83a8b92665 100644 --- a/drivers/memory/atmel-ebi.c +++ b/drivers/memory/atmel-ebi.c @@ -76,9 +76,11 @@ struct at91_ebi_caps { struct at91_ebi { struct clk *clk; - struct regmap *smc; struct regmap *matrix; - + struct { + struct regmap *regmap; + struct clk *clk; + } smc; struct regmap_field *ebi_csa; struct device *dev; @@ -395,22 +397,26 @@ static int at91sam9_ebi_init(struct at91_ebi *ebi) field.id_offset = AT91SAM9_SMC_GENERIC_BLK_SZ; field.reg = AT91SAM9_SMC_SETUP(AT91SAM9_SMC_GENERIC); - fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); if (IS_ERR(fields->setup)) return PTR_ERR(fields->setup); field.reg = AT91SAM9_SMC_PULSE(AT91SAM9_SMC_GENERIC); - fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); if (IS_ERR(fields->pulse)) return PTR_ERR(fields->pulse); field.reg = AT91SAM9_SMC_CYCLE(AT91SAM9_SMC_GENERIC); - fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); if (IS_ERR(fields->cycle)) return PTR_ERR(fields->cycle); field.reg = AT91SAM9_SMC_MODE(AT91SAM9_SMC_GENERIC); - fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); return PTR_ERR_OR_ZERO(fields->mode); } @@ -423,22 +429,26 @@ static int sama5d3_ebi_init(struct at91_ebi *ebi) field.id_offset = SAMA5_SMC_GENERIC_BLK_SZ; field.reg = AT91SAM9_SMC_SETUP(SAMA5_SMC_GENERIC); - fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->setup = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); if (IS_ERR(fields->setup)) return PTR_ERR(fields->setup); field.reg = AT91SAM9_SMC_PULSE(SAMA5_SMC_GENERIC); - fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->pulse = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); if (IS_ERR(fields->pulse)) return PTR_ERR(fields->pulse); field.reg = AT91SAM9_SMC_CYCLE(SAMA5_SMC_GENERIC); - fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->cycle = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); if (IS_ERR(fields->cycle)) return PTR_ERR(fields->cycle); field.reg = SAMA5_SMC_MODE(SAMA5_SMC_GENERIC); - fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc, field); + fields->mode = devm_regmap_field_alloc(ebi->dev, ebi->smc.regmap, + field); return PTR_ERR_OR_ZERO(fields->mode); } @@ -677,7 +687,7 @@ static int at91_ebi_dev_disable(struct at91_ebi *ebi, struct device_node *np) static int at91_ebi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *child, *np = dev->of_node; + struct device_node *child, *np = dev->of_node, *smc_np; const struct of_device_id *match; struct at91_ebi *ebi; int ret, reg_cells; @@ -702,9 +712,22 @@ static int at91_ebi_probe(struct platform_device *pdev) ebi->clk = clk; - ebi->smc = syscon_regmap_lookup_by_phandle(np, "atmel,smc"); - if (IS_ERR(ebi->smc)) - return PTR_ERR(ebi->smc); + smc_np = of_parse_phandle(dev->of_node, "atmel,smc", 0); + + ebi->smc.regmap = syscon_node_to_regmap(smc_np); + if (IS_ERR(ebi->smc.regmap)) + return PTR_ERR(ebi->smc.regmap); + + ebi->smc.clk = of_clk_get(smc_np, 0); + if (IS_ERR(ebi->smc.clk)) { + if (PTR_ERR(ebi->smc.clk) != -ENOENT) + return PTR_ERR(ebi->smc.clk); + + ebi->smc.clk = NULL; + } + ret = clk_prepare_enable(ebi->smc.clk); + if (ret) + return ret; /* * The sama5d3 does not provide an EBICSA register and thus does need