From patchwork Thu May 1 09:56:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29475 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67BD8203F3 for ; Thu, 1 May 2014 09:58:15 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rp18sf14943755iec.1 for ; Thu, 01 May 2014 02:58:14 -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=7qVcPlfgbWv2EpCZe9qiDJJPvLiqxRtlQasns+dv2BQ=; b=HFm7Le3CPb6FTEY31WSPoAC6jM9LNHN6AChRpK1iOTFsYcl4zer142oZFmPyORrQ42 qDUkedlQQR663bVXbrx5IiQ86bfl4xn/eRwIsIOW8t7SREbFd/s9U/Fu+lBco9UbpPT5 t6AiloP4ZFU/PkDGXT+3Y/9N6NtyuhNKs/VV8DOQqMDMUYGtm7wI7deiqzdAVqxqlWvt 2eWnapHtes5RA6GQLTRywfHGnqS/T7ui0tV/q+uprlWFRYsgBbV1XSANB3GkMU2RXGAe V7g1sLaZC1is0gmfEy7EZTXF8YBMYDGkbo91X5JKjG9IygE8jy0vykXT1J8s42p9fBpX PHgA== X-Gm-Message-State: ALoCoQkUzk5C18LBsWaQ7b+bwPZ9S79PsgpKcfKn30TWanb4rsCNdWYgGtxHozWX8QTEmeVJdkEK X-Received: by 10.182.213.37 with SMTP id np5mr5270989obc.36.1398938294921; Thu, 01 May 2014 02:58:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.134 with SMTP id t6ls969773qgd.20.gmail; Thu, 01 May 2014 02:58:14 -0700 (PDT) X-Received: by 10.52.90.37 with SMTP id bt5mr6887150vdb.7.1398938294805; Thu, 01 May 2014 02:58:14 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id sw4si5952503vdc.102.2014.05.01.02.58.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:14 -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.176; Received: by mail-ve0-f176.google.com with SMTP id jz11so21158veb.21 for ; Thu, 01 May 2014 02:58:14 -0700 (PDT) X-Received: by 10.53.1.69 with SMTP id be5mr6755740vdd.27.1398938294746; Thu, 01 May 2014 02:58:14 -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 ib8csp12957vcb; Thu, 1 May 2014 02:58:14 -0700 (PDT) X-Received: by 10.180.13.208 with SMTP id j16mr1493006wic.58.1398938293856; Thu, 01 May 2014 02:58:13 -0700 (PDT) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by mx.google.com with ESMTPS id fj6si567610wic.105.2014.05.01.02.58.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:13 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=209.85.212.181; Received: by mail-wi0-f181.google.com with SMTP id f8so403698wiw.14 for ; Thu, 01 May 2014 02:58:13 -0700 (PDT) X-Received: by 10.180.126.33 with SMTP id mv1mr1574958wib.6.1398938293296; Thu, 01 May 2014 02:58:13 -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.58.11 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:12 -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 32/47] mtd: nand: stm_nand_bch: add Hamming-FLEX operations Date: Thu, 1 May 2014 10:56:39 +0100 Message-Id: <1398938214-17847-33-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; a check for Ready/NotBusy (RBn) (i.e. wait for current operation to finish and a method to issue Flex commands to the controller. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index e909d80..aba4bc5 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -719,6 +719,42 @@ static int bch_write(struct mtd_info *mtd, struct nand_chip *chip, } /* + * Hamming-FLEX operations + */ +static int flex_wait_rbn(struct nandi_controller *nandi) +{ + int ret; + + ret = wait_for_completion_timeout(&nandi->rbn_completed, HZ/2); + if (!ret) + dev_err(nandi->dev, "FLEX RBn timeout\n"); + + return ret; +} + +static void flex_cmd(struct nandi_controller *nandi, uint8_t cmd) +{ + uint32_t val; + + val = (FLEX_CMD_CSN | FLEX_CMD_BEATS_1 | cmd); + writel(val, nandi->base + NANDHAM_FLEX_CMD); +} + +static void flex_addr(struct nandi_controller *nandi, + uint32_t addr, int cycles) +{ + addr &= 0x00ffffff; + + BUG_ON(cycles < 1); + BUG_ON(cycles > 3); + + addr |= (FLEX_ADDR_CSN | FLEX_ADDR_ADD8_VALID); + addr |= (cycles & 0x3) << 28; + + writel(addr, nandi->base + NANDHAM_FLEX_ADD); +} + +/* * Bad Block Tables/Bad Block Markers */ #define BBT_MARK_BAD_FACTORY 0x0