From patchwork Thu May 1 09:56:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29486 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 11EEC203F3 for ; Thu, 1 May 2014 09:58:34 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id x10sf12092326pdj.7 for ; Thu, 01 May 2014 02:58:34 -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=fa0bF/Ng7HCi/YOeu1Q0vzpfujY4WU12lSgoVmwWqus=; b=W9lSiUu3YtCTjpvA3qmFXmhqWOL6LRjLQnm5FuPG/FL+xsqxm4O40nWDt2rzIYlq3D mlgyc4vlTGOjbRjpMuw8QyHykEI6ptgMTSDuzL7YiLTxSrSJ7Y7pJ14n1/+HE2va2mke INgok2dpOXGMcbP4X+Qer/fZyP8PYye45sPaq0ZOyytugfvudceNQzh6ANZV2I8OUVNb R/9ITwJUotxVGkiOloSsgPjdljimWWYWqMsZL1ltTXM4hp9E1eAx0l6otYP2/1GRctTY jdVyib+qC5UpAWlvDRTaOMlaZ65cdPKIVvuILIlGrkvWX4Eo2+P1SY6yLZfXNE8sa+Gr xLuA== X-Gm-Message-State: ALoCoQkG+y3e0R0Ire5iqaybYB6m5YpAFaFNr+fs7kJN7r4Mk5Q3aF4W8Kg08vovy27BdvsnJ6xc X-Received: by 10.66.190.202 with SMTP id gs10mr5210702pac.0.1398938314150; Thu, 01 May 2014 02:58:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.35.210 with SMTP id n76ls1069194qgn.15.gmail; Thu, 01 May 2014 02:58:34 -0700 (PDT) X-Received: by 10.220.161.8 with SMTP id p8mr8160329vcx.4.1398938314036; Thu, 01 May 2014 02:58:34 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id xt10si5967185veb.112.2014.05.01.02.58.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:34 -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.182; Received: by mail-vc0-f182.google.com with SMTP id lf12so3786659vcb.27 for ; Thu, 01 May 2014 02:58:34 -0700 (PDT) X-Received: by 10.58.46.207 with SMTP id x15mr8416299vem.17.1398938313969; Thu, 01 May 2014 02:58:33 -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 ib8csp12979vcb; Thu, 1 May 2014 02:58:33 -0700 (PDT) X-Received: by 10.180.212.107 with SMTP id nj11mr1555049wic.40.1398938313059; Thu, 01 May 2014 02:58:33 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id fk3si579728wib.32.2014.05.01.02.58.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:33 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=209.85.212.178; Received: by mail-wi0-f178.google.com with SMTP id hm4so405300wib.11 for ; Thu, 01 May 2014 02:58:32 -0700 (PDT) X-Received: by 10.180.74.242 with SMTP id x18mr1555912wiv.20.1398938312566; Thu, 01 May 2014 02:58:32 -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.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:31 -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 43/47] mtd: nand: stm_nand_bch: read and write buffers (FLEX) Date: Thu, 1 May 2014 10:56:50 +0100 Message-Id: <1398938214-17847-44-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: , read or write in 4 Byte chunks at a time until there is less than 8 Bytes remaining, at which point split down into reading the reset a single Byte at a time. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index 046e435..ba6ac8f 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -770,6 +770,75 @@ static void flex_addr(struct nandi_controller *nandi, writel(addr, nandi->base + NANDHAM_FLEX_ADD); } +static void flex_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) +{ + struct nand_chip *chip = mtd->priv; + struct nandi_controller *nandi = chip->priv; + int aligned; + + emiss_nandi_select(STM_NANDI_HAMMING); + + /* Read bytes until buf is 4-byte aligned */ + while (len && ((unsigned int)buf & 0x3)) { + *buf++ = (uint8_t)(readl(nandi->base + NANDHAM_FLEX_DATA) + & 0xff); + len--; + }; + + /* Use 'BEATS_4'/readsl */ + if (len > 8) { + aligned = len & ~0x3; + writel(FLEX_DATA_CFG_BEATS_4 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAREAD_CONFIG); + + readsl(nandi->base + NANDHAM_FLEX_DATA, buf, aligned >> 2); + + buf += aligned; + len -= aligned; + + writel(FLEX_DATA_CFG_BEATS_1 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAREAD_CONFIG); + } + + /* Mop up remaining bytes */ + while (len > 0) { + *buf++ = (uint8_t)(readl(nandi->base + NANDHAM_FLEX_DATA) + & 0xff); + len--; + } +} + +static void flex_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) +{ + struct nand_chip *chip = mtd->priv; + struct nandi_controller *nandi = chip->priv; + int aligned; + + /* Write bytes until buf is 4-byte aligned */ + while (len && ((unsigned int)buf & 0x3)) { + writel(*buf++, nandi->base + NANDHAM_FLEX_DATA); + len--; + }; + + /* USE 'BEATS_4/writesl */ + if (len > 8) { + aligned = len & ~0x3; + writel(FLEX_DATA_CFG_BEATS_4 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAWRITE_CONFIG); + writesl(nandi->base + NANDHAM_FLEX_DATA, buf, aligned >> 2); + buf += aligned; + len -= aligned; + writel(FLEX_DATA_CFG_BEATS_1 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAWRITE_CONFIG); + } + + /* Mop up remaining bytes */ + while (len > 0) { + writel(*buf++, nandi->base + NANDHAM_FLEX_DATA); + len--; + } +} + static int flex_read_raw(struct nandi_controller *nandi, uint32_t page_addr, uint32_t col_addr, @@ -1416,6 +1485,9 @@ static void nandi_set_mtd_defaults(struct nandi_controller *nandi, chip->ecc.layout = &info->ecclayout; chip->options |= NAND_NO_SUBPAGE_WRITE; + chip->read_buf = flex_read_buf; + chip->write_buf = flex_write_buf; + chip->bbt_options |= NAND_BBT_USE_FLASH; /* mtd_info */