From patchwork Tue Mar 25 08:19:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 27013 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D099220062 for ; Tue, 25 Mar 2014 08:48:16 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id gq1sf593179obb.3 for ; Tue, 25 Mar 2014 01:48:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=n3752bvHeNmfHAjf97L0H4h1LfQIAPpHum3QzsFNnt8=; b=VFlE4Vw1ZQBc/+juHhoYHF47Hu1qxvQIM4wPRrO4aGhvpq8vizTrmEH7lMGtMMzj60 Kp5aLHB8yRHnN1YMYcI9fDiZt7LYX1citfzg84JhyFTdS2gPvTMWOqHFrNNoDRVniDpe +idlBqV+fYV8l8l+eSKqh3F+m+2xuN2MA8Xtf5vpeq7jNUT9dOxAqcgNX+zqeSNqG2OL RsW0+3JOXgOYtTtjv6D06ADc3lZ+pFFKQ7TS+5TP02kCwbYNKdDZHCt8syX8yF894hg0 mIcMSdp9wLLdo4cyYPyWrnYVuQNZ+vpXe49QREO/ft4O4kmcIYP3+saEUjo6mnuuNdqa rO2A== X-Gm-Message-State: ALoCoQlshGIFJooWZqmJtbNfWk0nZOYPeBO8BJQmIYh2GvvzQv0eartufrOJny6xSizHR1vEC9+2 X-Received: by 10.182.85.65 with SMTP id f1mr14081691obz.33.1395737296439; Tue, 25 Mar 2014 01:48:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.166 with SMTP id q35ls130697qga.89.gmail; Tue, 25 Mar 2014 01:48:16 -0700 (PDT) X-Received: by 10.220.103.141 with SMTP id k13mr380405vco.25.1395737296317; Tue, 25 Mar 2014 01:48:16 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id pe7si3581633vec.209.2014.03.25.01.48.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:48:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so153180veb.37 for ; Tue, 25 Mar 2014 01:48:16 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr54908534vcb.0.1395737296218; Tue, 25 Mar 2014 01:48:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp286745vck; Tue, 25 Mar 2014 01:48:15 -0700 (PDT) X-Received: by 10.181.9.65 with SMTP id dq1mr20279926wid.51.1395737294667; Tue, 25 Mar 2014 01:48:14 -0700 (PDT) Received: from casper.infradead.org (casper.infradead.org. [85.118.1.10]) by mx.google.com with ESMTPS id ev2si3261783wid.68.2014.03.25.01.48.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2014 01:48:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 85.118.1.10 as permitted sender) client-ip=85.118.1.10; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSN00-0004hs-TF; Tue, 25 Mar 2014 08:46:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMzr-00044c-Bl; Tue, 25 Mar 2014 08:46:11 +0000 Received: from bombadil.infradead.org ([2001:1868:205::9]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMsS-0003B8-J1 for linux-arm-kernel@merlin.infradead.org; Tue, 25 Mar 2014 08:38:32 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMbP-00024n-SY for linux-arm-kernel@lists.infradead.org; Tue, 25 Mar 2014 08:20:56 +0000 Received: by mail-wi0-f169.google.com with SMTP id hm4so3171058wib.0 for ; Tue, 25 Mar 2014 01:20:33 -0700 (PDT) X-Received: by 10.180.89.211 with SMTP id bq19mr21207403wib.58.1395735633097; Tue, 25 Mar 2014 01:20:33 -0700 (PDT) Received: from lee--X1.home (host109-148-113-193.range109-148.btcentralplus.com. [109.148.113.193]) by mx.google.com with ESMTPSA id k4sm5567676wib.19.2014.03.25.01.20.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:20:32 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 08/47] mtd: nand: stm_nand_bch: supply clock support Date: Tue, 25 Mar 2014 08:19:25 +0000 Message-Id: <1395735604-26706-9-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> References: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140325_012056_079527_42788AFC X-CRM114-Status: GOOD ( 11.89 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.169 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record Cc: angus.clark@st.com, kernel@stlinux.com, lee.jones@linaro.org, linux-mtd@lists.infradead.org, pekon@ti.com, computersforpeace@gmail.com, dwmw2@infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add support for clocks when, and only when, they are supplied. It is not yet compulsory to provide the BCH and EMI clocks, as Common Clk isn't supported Mainline yet. Until an implementation lands upstream all clocks located on STM boards default to always-on. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index 1a93f8d..cc0159e 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,9 @@ struct nandi_controller { void __iomem *base; /* Controller base*/ void __iomem *dma; /* DMA control base */ + + struct clk *bch_clk; + struct clk *emi_clk; /* IRQ-triggered Completions: */ struct completion seq_completed; /* SEQ Over */ struct completion rbn_completed; /* RBn */ @@ -103,6 +107,44 @@ static void nandi_disable_interrupts(struct nandi_controller *nandi, writel(val, nandi->base + NANDBCH_INT_EN); } +static void nandi_clk_enable(struct nandi_controller *nandi) +{ + if (nandi->emi_clk) + clk_prepare_enable(nandi->emi_clk); + if (nandi->bch_clk) + clk_prepare_enable(nandi->bch_clk); +} + +static void nandi_clk_disable(struct nandi_controller *nandi) +{ + if (nandi->emi_clk) + clk_disable_unprepare(nandi->emi_clk); + if (nandi->bch_clk) + clk_disable_unprepare(nandi->bch_clk); +} + +static struct clk *nandi_clk_setup(struct nandi_controller *nandi, + char *clkname) +{ + struct clk *clk; + int ret; + + clk = clk_get(nandi->dev, clkname); + if (IS_ERR_OR_NULL(clk)) { + dev_warn(nandi->dev, "Failed to get %s clock\n", clkname); + return NULL; + } + + ret = clk_prepare_enable(clk); + if (ret) { + dev_warn(nandi->dev, "Failed to enable %s clock\n", clkname); + clk_put(clk); + return NULL; + } + + return clk; +} + static void nandi_init_bch(struct nandi_controller *nandi, int emi_bank) { dev_dbg(nandi->dev, "%s\n", __func__); @@ -217,6 +259,9 @@ nandi_init_resources(struct platform_device *pdev) return ERR_PTR(err); } + nandi->emi_clk = nandi_clk_setup(nandi, "emi_clk"); + nandi->bch_clk = nandi_clk_setup(nandi, "bch_clk"); + platform_set_drvdata(pdev, nandi); return nandi; @@ -251,6 +296,10 @@ static int stm_nand_bch_probe(struct platform_device *pdev) static int stm_nand_bch_remove(struct platform_device *pdev) { + struct nandi_controller *nandi = platform_get_drvdata(pdev); + + nandi_clk_disable(nandi); + return 0; }