From patchwork Tue Mar 25 08:19:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 333349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 33DCE14008F for ; Tue, 25 Mar 2014 20:53:37 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMva-0001ec-1y; Tue, 25 Mar 2014 08:41:46 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMv6-0003aW-6T; Tue, 25 Mar 2014 08:41:16 +0000 Received: from bombadil.infradead.org ([2001:1868:205::9]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMsB-0003B8-Cq for linux-mtd@merlin.infradead.org; Tue, 25 Mar 2014 08:38:15 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMbz-00029K-J3 for linux-mtd@lists.infradead.org; Tue, 25 Mar 2014 08:21:32 +0000 Received: by mail-wi0-f169.google.com with SMTP id hm4so3171526wib.0 for ; Tue, 25 Mar 2014 01:21:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=S32Jig1n6vQ929TDMUMbD1PhSS7jkIo895NUsyQfhdI=; b=bmQs+8eA9+4+g9L6HcESIccQyFsc0+SzBgoMJB0k4tiw91n5FA18cR6CilUsGINLep ZFqYh3rn6hhhrH1Tw3n3STDTtVkt4+SBie2Rumx0fg1Rrv2qDvIcx+MMCqfpfiGPpd9Z HpUeV6FXlbTDXscZrIWXegJmEh+J2r20WDFd4P+LIH3lN5e/Zkn6c9Q3sl1GUucDlD+h rmVxFlU7AUzKcv+RdoK0Ihd0a77gxYb0Tw42xIcbgqbQbS67KujrVNaoQdZJexfioAji 0clNhDf44JWK8BZSfc1HTLnfu+9EHEYes1d3d1eGUWPo/Mf1ziagBb72xQ85gn3eLr0b 3GxQ== X-Gm-Message-State: ALoCoQkdWnhbbWd+v3evMkdFlEu6/ClUGS0gjNn6wC7HC0ieDAL/pIjr+8BIqsoyTfkDqZdz66G8 X-Received: by 10.180.36.8 with SMTP id m8mr20223281wij.42.1395735669811; Tue, 25 Mar 2014 01:21:09 -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.21.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:21:09 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 27/47] mtd: nand: stm_nand_bch: write IBBT to Flash Date: Tue, 25 Mar 2014 08:19:44 +0000 Message-Id: <1395735604-26706-28-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_012131_786090_7E202963 X-CRM114-Status: UNSURE ( 9.35 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.169 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 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-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Write BBT contents to the first page of a specified block, then update the IBBT header and write it to last page of the same block. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index 2d03113..76ed99b 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -541,6 +541,35 @@ static void bch_fill_ibbt_header(struct nandi_controller *nandi, memcpy(ibbt_header->author, author, sizeof(author)); } +/* Write IBBT to Flash */ +static int bch_write_bbt_data(struct nandi_controller *nandi, + struct nandi_bbt_info *bbt_info, + uint32_t block, int bak, uint8_t vers) +{ + uint32_t page_size = nandi->info.mtd.writesize; + uint32_t block_size = nandi->info.mtd.erasesize; + struct nand_ibbt_bch_header *ibbt_header = + (struct nand_ibbt_bch_header *)nandi->page_buf; + loff_t offs; + + nandi->cached_page = -1; + + /* Write BBT contents to first page of block */ + offs = (loff_t)block << nandi->block_shift; + if (bch_write_page(nandi, offs, bbt_info->bbt) & NAND_STATUS_FAIL) + return 1; + + /* Update IBBT header and write to last page of block */ + memset(ibbt_header, 0xff, nandi->info.mtd.writesize); + bch_fill_ibbt_header(nandi, ibbt_header, bak, vers); + offs += block_size - page_size; + if (bch_write_page(nandi, offs, (uint8_t *)ibbt_header) & + NAND_STATUS_FAIL) + return 1; + + return 0; +} + /* Scan block for IBBT signature */ static int bch_find_ibbt_sig(struct nandi_controller *nandi, uint32_t block, int *bak, uint8_t *vers,