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: 27008 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 035CC20062 for ; Tue, 25 Mar 2014 08:45:12 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id uy17sf1889114igb.2 for ; Tue, 25 Mar 2014 01:45:12 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=g+djbM+kuSocXv5CnZaqmwSa+lEcb0LD0yQ/SjhwSxU=; b=AMAi2mdZ7mUusYw7N5qVS/TRmiAPgHQFMypFLMAG6XjKz2SFJ3wQBuny91KMHOedaT oW+ahi7Eml+7a/8VCeE+ZOBdlpAQLC/D12bw9kNhk8w09oH4vrIy/OEgz8k/jLmpJmF0 5xWzebKZp9UILGTEr8Vs1Q9SjnGjS8HJ7z/DK5CKwoONa+R9wJk0Sv7m/SpASt/r2818 F1pzFjjif6Adl+QN4tq/BMdRvDAyqSNJGbA8cLMlYh1o+cHXY9eiCd9ivEp2Bi5LgqQn xujRjxiN497YSddfSWLggHgCM+i4TR/kGGiYjGTBXMNyTkXw6fzbE6YdZKxP+ptXKdlH bjww== X-Gm-Message-State: ALoCoQlIbm2gcaGlIHzo4w20z5VHvMz9LV1Fz2WwITFTpQHi1jdK/6e+197jz99VYqyhPdKrV36V X-Received: by 10.182.87.2 with SMTP id t2mr27002453obz.2.1395737112440; Tue, 25 Mar 2014 01:45:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.87.233 with SMTP id r96ls154665qgd.98.gmail; Tue, 25 Mar 2014 01:45:12 -0700 (PDT) X-Received: by 10.52.128.231 with SMTP id nr7mr26099969vdb.17.1395737112365; Tue, 25 Mar 2014 01:45:12 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id j5si371931veb.129.2014.03.25.01.45.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:45:12 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id if17so154826vcb.8 for ; Tue, 25 Mar 2014 01:45:12 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr127499vcb.28.1395737112280; Tue, 25 Mar 2014 01:45:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp286613vck; Tue, 25 Mar 2014 01:45:11 -0700 (PDT) X-Received: by 10.66.139.100 with SMTP id qx4mr9313339pab.141.1395737111066; Tue, 25 Mar 2014 01:45:11 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dg5si10918250pbc.222.2014.03.25.01.45.10; Tue, 25 Mar 2014 01:45:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753098AbaCYIVQ (ORCPT + 26 others); Tue, 25 Mar 2014 04:21:16 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:37941 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752791AbaCYIVL (ORCPT ); Tue, 25 Mar 2014 04:21:11 -0400 Received: by mail-wg0-f42.google.com with SMTP id y10so75741wgg.13 for ; Tue, 25 Mar 2014 01:21:09 -0700 (PDT) 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 Cc: lee.jones@linaro.org, kernel@stlinux.com, computersforpeace@gmail.com, linux-mtd@lists.infradead.org, dwmw2@infradead.org, angus.clark@st.com, pekon@ti.com 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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: 209.85.220.177 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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,