From patchwork Thu May 1 09:56:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29449 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 74031203F3 for ; Thu, 1 May 2014 09:57:20 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hr9sf9611749vcb.3 for ; Thu, 01 May 2014 02:57:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=TCW/8o3msbhuuVB776MSpdein9aTM/m82yYCphWiK28=; b=LXqOQ/esXfxEbiV3ikMTI6u4oC47DawrtOBGY/g1UuUJB5kJC4Z/wC7HfMQHHvzAjz GQGGWfTCOG1pEHPfHvKmsv/8KLHrSZdLarOUOSXm4Xeua7eB/dCcTpZCsmnwK9KpQTnZ AdzQf8qw6kvTQfAuJ+Lbaf8rG3cO3WiKTPC7TBEREzqolUYVDxVoL/QKQAzR1DPYKgK0 m2FmksryBtdQDeMpRNzGgI/lKxDoFpn8PgrhhYhw6uFkfh7d0OSIh426tg7O4KGHWhe+ 8wnoc2gymiAfAS2bg+iVwDB6HWlI593mo/o+YP06CCBDcgqwj8CAcBhdGYy7E6Lx0OZI hcFg== X-Gm-Message-State: ALoCoQlprx1H34oxiZGE/UEIFbyUzwItkqkW0KEXBEs0CimApqOQuhoxNn7ElFNQoe8FWb5pHADD X-Received: by 10.52.146.45 with SMTP id sz13mr4506443vdb.6.1398938240185; Thu, 01 May 2014 02:57:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.36 with SMTP id y33ls978537qgd.82.gmail; Thu, 01 May 2014 02:57:20 -0700 (PDT) X-Received: by 10.58.211.69 with SMTP id na5mr483889vec.30.1398938240074; Thu, 01 May 2014 02:57:20 -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 ya4si5972956vec.55.2014.05.01.02.57.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:20 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so3699573veb.9 for ; Thu, 01 May 2014 02:57:20 -0700 (PDT) X-Received: by 10.58.107.65 with SMTP id ha1mr8339375veb.1.1398938239999; Thu, 01 May 2014 02:57:19 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp12888vcb; Thu, 1 May 2014 02:57:19 -0700 (PDT) X-Received: by 10.180.81.40 with SMTP id w8mr1458797wix.45.1398938239127; Thu, 01 May 2014 02:57:19 -0700 (PDT) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by mx.google.com with ESMTPS id b10si580336wiy.25.2014.05.01.02.57.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:19 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=209.85.212.182; Received: by mail-wi0-f182.google.com with SMTP id d1so402863wiv.15 for ; Thu, 01 May 2014 02:57:18 -0700 (PDT) X-Received: by 10.194.92.177 with SMTP id cn17mr8260225wjb.18.1398938238596; Thu, 01 May 2014 02:57:18 -0700 (PDT) Received: from lee--X1.home (host109-148-238-223.range109-148.btcentralplus.com. [109.148.238.223]) by mx.google.com with ESMTPSA id bj5sm2696494wib.3.2014.05.01.02.57.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:17 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, linux-mtd@lists.infradead.org, kernel@stlinux.com, Lee Jones Subject: [PATCH 06/47] mtd: nand: stm_nand_bch: IRQ support for ST's BCH NAND Controller driver Date: Thu, 1 May 2014 10:56:13 +0100 Message-Id: <1398938214-17847-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398938214-17847-1-git-send-email-lee.jones@linaro.org> References: <1398938214-17847-1-git-send-email-lee.jones@linaro.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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 2d6a81f..d73568c 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*/ @@ -221,6 +224,51 @@ const struct nand_timing_spec st_nand_onfi_timing_specs[] = { } }; +/* + * 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) @@ -252,6 +300,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); @@ -271,6 +320,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;