From patchwork Tue Mar 25 08:19:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 26988 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B799720062 for ; Tue, 25 Mar 2014 08:25:38 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kq14sf292878pab.10 for ; Tue, 25 Mar 2014 01:25:37 -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=qyk+nHU2So2DTXIFsKVFmay54YLFLRuqnmv4Lg2VRTU=; b=Xv/8wDBdEbLNR6MlOk6omzQHbQ9+jDeituaC+W6v9iLhOyGBJed828Y42VqobI3o4q PrxB49wE+KCeNri5ouB4oYUJ0jT6v6mWHoXpqkT+unDVzugaR7YFLEX9ve/8R5FREDkm HXsGoNFsPlXEjbXkodccffpUmEqa9mPwAbnbu3VoZ5lL565mMfPi42b+/OhOfys3xp2d BqTzwauuJjHeRucUc4Q9buZGzf9g4TWbh+6Dk07johTUGXpLJNURGQR8rlYN2gGUcj5r zckfE29qOezaAp5LryzFlHj/8+fNdeVdqCezn1v0WZqaIEmmANFr410pERubI+cY5i7/ RXvg== X-Gm-Message-State: ALoCoQmxFCUQA/ikFMmLfBVJXuW7FkWLw3qicCJz5WqQiyLBYpXNlFKd23ZAoIbVGE6Veof0oQtL X-Received: by 10.66.141.231 with SMTP id rr7mr2997126pab.47.1395735937682; Tue, 25 Mar 2014 01:25:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.245 with SMTP id u108ls109769qge.79.gmail; Tue, 25 Mar 2014 01:25:37 -0700 (PDT) X-Received: by 10.220.114.135 with SMTP id e7mr5474266vcq.23.1395735937549; Tue, 25 Mar 2014 01:25:37 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id la9si3575151veb.200.2014.03.25.01.25.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:25:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.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.220.178; Received: by mail-vc0-f178.google.com with SMTP id im17so138504vcb.9 for ; Tue, 25 Mar 2014 01:25:37 -0700 (PDT) X-Received: by 10.58.57.67 with SMTP id g3mr53766318veq.3.1395735937459; Tue, 25 Mar 2014 01:25:37 -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 i9csp285508vck; Tue, 25 Mar 2014 01:25:36 -0700 (PDT) X-Received: by 10.180.72.195 with SMTP id f3mr19774436wiv.61.1395735935426; Tue, 25 Mar 2014 01:25:35 -0700 (PDT) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id k5si1844274wiw.1.2014.03.25.01.25.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Mar 2014 01:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMd6-0000M5-86; Tue, 25 Mar 2014 08:22:40 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMce-0002OC-PP; Tue, 25 Mar 2014 08:22:12 +0000 Received: from mail-wi0-f176.google.com ([209.85.212.176]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMbJ-000265-AN for linux-arm-kernel@lists.infradead.org; Tue, 25 Mar 2014 08:21:20 +0000 Received: by mail-wi0-f176.google.com with SMTP id r20so3186152wiv.9 for ; Tue, 25 Mar 2014 01:20:27 -0700 (PDT) X-Received: by 10.180.90.140 with SMTP id bw12mr5472233wib.18.1395735627726; Tue, 25 Mar 2014 01:20:27 -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.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:20:26 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 05/47] mtd: nand: stm_nand_bch: IRQ support for ST's BCH NAND Controller driver Date: Tue, 25 Mar 2014 08:19:22 +0000 Message-Id: <1395735604-26706-6-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_042049_742181_C5A3B102 X-CRM114-Status: GOOD ( 15.75 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.176 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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.220.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 Obtain IRQ number and request IRQ resource via the usual methods. We're also registering an IRQ handler to inform us of any completed tasks. Notice that we're starting to make use of the device struct that we defined before. In keeping with the subject of the patch, we're also adding the related local enable_irq() and disable_irq() methods. Again, these will be utilised in a greater capacity in latter commits. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index bd11070..76a0d02 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -15,11 +15,14 @@ #include #include #include +#include #include #include #include #include +#include "stm_nand_regs.h" + /* NANDi Controller (Hamming/BCH) */ struct nandi_controller { void __iomem *base; /* Controller base*/ @@ -54,6 +57,51 @@ struct nandi_controller { /* 'page_buf' */ }; +/* + * NANDi Interrupts (shared by Hamming and BCH controllers) + */ +static irqreturn_t nandi_irq_handler(int irq, void *dev) +{ + struct nandi_controller *nandi = dev; + unsigned int status; + + status = readl(nandi->base + NANDBCH_INT_STA); + + if (status & NANDBCH_INT_SEQNODESOVER) { + /* BCH */ + writel(NANDBCH_INT_CLR_SEQNODESOVER, + nandi->base + NANDBCH_INT_CLR); + complete(&nandi->seq_completed); + } + if (status & NAND_INT_RBN) { + /* Hamming */ + writel(NAND_INT_CLR_RBN, nandi->base + NANDHAM_INT_CLR); + complete(&nandi->rbn_completed); + } + + return IRQ_HANDLED; +} + +static void nandi_enable_interrupts(struct nandi_controller *nandi, + uint32_t irqs) +{ + uint32_t val; + + val = readl(nandi->base + NANDBCH_INT_EN); + val |= irqs; + writel(val, nandi->base + NANDBCH_INT_EN); +} + +static void nandi_disable_interrupts(struct nandi_controller *nandi, + uint32_t irqs) +{ + uint32_t val; + + val = readl(nandi->base + NANDBCH_INT_EN); + val &= ~irqs; + writel(val, nandi->base + NANDBCH_INT_EN); +} + static int remap_named_resource(struct platform_device *pdev, char *name, void __iomem **io_ptr) @@ -85,6 +133,7 @@ static struct nandi_controller * nandi_init_resources(struct platform_device *pdev) { struct nandi_controller *nandi; + int irq; int err; nandi = devm_kzalloc(&pdev->dev, sizeof(*nandi), GFP_KERNEL); @@ -104,6 +153,19 @@ nandi_init_resources(struct platform_device *pdev) if (err) return ERR_PTR(err); + irq = platform_get_irq_byname(pdev, "nand_irq"); + if (irq < 0) { + dev_err(&pdev->dev, "failed to find IRQ resource\n"); + return ERR_PTR(irq); + } + + err = devm_request_irq(&pdev->dev, irq, nandi_irq_handler, + IRQF_DISABLED, dev_name(&pdev->dev), nandi); + if (err) { + dev_err(&pdev->dev, "irq request failed\n"); + return ERR_PTR(err); + } + platform_set_drvdata(pdev, nandi); return nandi;