From patchwork Thu May 1 09:56:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29465 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8650E203F3 for ; Thu, 1 May 2014 09:57:54 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id cm18sf5022690qab.9 for ; Thu, 01 May 2014 02:57:54 -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=Ch5/qSrAR8uyJf1Gtrqm+TW0xIMsP99MeMMKlp4piVE=; b=NO1IR+91BG5vucgdwV++Z4YhySAJLlp2CkeZMjxHJyC1x7PUPYadOp3TAP7iWr85Nn Z8NdkpLtiayPIA4p2U/Xtf6FAutu3WB4/9YXhJASJgcfSe2Sane5tiJkUD2kIOaXlR/y GsWHEzne4WWcFNBNo0GR1znQy7cwi2iT4dC7XTcv1e39Iv7ehBfRhOPnFkoG5GvmmVF2 iC+y5Ln9S5RZGI5wNhGTqDiwUcgF8Bho0I2ZZsV1brtw9GsbF5fQKWG3WhhhelMyqUCa wCFwZW3w3uNiILFlFRUXl4NfDIMUUCLt0a6msnv+JD2oLluQ0BW0FZTQtFDC3yp8uKQC Z9Aw== X-Gm-Message-State: ALoCoQknAFh7MQXj0LP+84JDOaEQvwss2DDzTvpAlwG0UEiJFddz2IUJh1XAOr2IkwBCGky0M1NF X-Received: by 10.58.22.70 with SMTP id b6mr5303821vef.13.1398938274319; Thu, 01 May 2014 02:57:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.43.135 with SMTP id e7ls1049922qga.70.gmail; Thu, 01 May 2014 02:57:54 -0700 (PDT) X-Received: by 10.52.137.174 with SMTP id qj14mr843997vdb.32.1398938274224; Thu, 01 May 2014 02:57:54 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id u5si5946716vdo.166.2014.05.01.02.57.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:54 -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.220.175; Received: by mail-vc0-f175.google.com with SMTP id lh4so3651797vcb.6 for ; Thu, 01 May 2014 02:57:54 -0700 (PDT) X-Received: by 10.58.46.207 with SMTP id x15mr8413611vem.17.1398938274162; Thu, 01 May 2014 02:57:54 -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 ib8csp12933vcb; Thu, 1 May 2014 02:57:53 -0700 (PDT) X-Received: by 10.180.80.232 with SMTP id u8mr1491972wix.13.1398938273212; Thu, 01 May 2014 02:57:53 -0700 (PDT) Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by mx.google.com with ESMTPS id bi7si573429wib.67.2014.05.01.02.57.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:53 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=74.125.82.177; Received: by mail-we0-f177.google.com with SMTP id t60so2787785wes.8 for ; Thu, 01 May 2014 02:57:52 -0700 (PDT) X-Received: by 10.180.207.10 with SMTP id ls10mr1558578wic.22.1398938272737; Thu, 01 May 2014 02:57:52 -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.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:57:51 -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 22/47] mtd: nand: stm_nand_bch: provide shared BCH operations Date: Thu, 1 May 2014 10:56:29 +0100 Message-Id: <1398938214-17847-23-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: , Including one for programming the BCH sequence, taking care not to program two registers marked 'reserved' in the NANDi specification. Failing to take this precaution results in an imprecise data exception on ARM platforms. We also add an operation which waits on a completion timeout (released by the IRQ handler). Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index 5be7889..40767b8 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -431,6 +431,34 @@ static void nandi_disable_interrupts(struct nandi_controller *nandi, } /* + * BCH Operations + */ +static inline void bch_load_prog_cpu(struct nandi_controller *nandi, + struct bch_prog *prog) +{ + uint32_t *src = (uint32_t *)prog; + uint32_t *dst = (uint32_t *)(nandi->base + NANDBCH_ADDRESS_REG_1); + int i; + + for (i = 0; i < 16; i++) { + /* Skip registers marked as "reserved" */ + if (i != 11 && i != 14) + writel(*src, dst); + dst++; + src++; + } +} + +static void bch_wait_seq(struct nandi_controller *nandi) +{ + int ret; + + ret = wait_for_completion_timeout(&nandi->seq_completed, HZ/2); + if (!ret) + dev_err(nandi->dev, "BCH Seq timeout\n"); +} + +/* * Initialisation */ static int bch_check_compatibility(struct nandi_controller *nandi,