From patchwork Thu May 1 09:56:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29473 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C8A1203F3 for ; Thu, 1 May 2014 09:58:11 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf15223063iec.4 for ; Thu, 01 May 2014 02:58:11 -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=1rJumm0l0uC2i9mmmnjifQNaf2P+slyPkaISOBBixoc=; b=ipFODK19uHF4DFvFeCmuNeAsQV7CmKqeoxsU/B2GFhp5LyOJ/RMaCBER17qpbu3en6 y4TLaLG4/lhmqYPAR4GxxqT7pAJqvRJ5p7I7Zudt1oB/Y0N8IgzVBBKX85/LEZDVm1SL PQqki+GKGVteSNeR7SUpcaQO2WUJ5FkYXL65nOESHCKU3gwdhDU079TiQYBTZpNpSOIb fkDm44ryczfLgKMv/IoqwIZh2fNKhzYNPZzY2lUVtDA2ZV0hWdaO/8omlCFLkHx4D6HM Iv8aGEv+3frdtotwnv2YWDL8DxhhwpwTjubETAk1SqW65v0/0wgCCheHVYvw33zhdoYb ogVw== X-Gm-Message-State: ALoCoQnh/UmcyRvq5yWP989g0ehQg6f6kn2KspqRhEpsw2pwzbtMUhrUHyuKyUvqcuufQei7wHzO X-Received: by 10.182.196.8 with SMTP id ii8mr5261292obc.5.1398938291079; Thu, 01 May 2014 02:58:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.87 with SMTP id v81ls1181242qge.0.gmail; Thu, 01 May 2014 02:58:11 -0700 (PDT) X-Received: by 10.220.159.4 with SMTP id h4mr8221361vcx.1.1398938290976; Thu, 01 May 2014 02:58:10 -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 y10si5965591vei.150.2014.05.01.02.58.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:10 -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 lf12so3654118vcb.41 for ; Thu, 01 May 2014 02:58:10 -0700 (PDT) X-Received: by 10.221.74.200 with SMTP id yx8mr8062456vcb.3.1398938290907; Thu, 01 May 2014 02:58:10 -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 ib8csp12953vcb; Thu, 1 May 2014 02:58:10 -0700 (PDT) X-Received: by 10.180.14.199 with SMTP id r7mr1593767wic.0.1398938289992; Thu, 01 May 2014 02:58:09 -0700 (PDT) Received: from mail-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) by mx.google.com with ESMTPS id gc6si564285wib.123.2014.05.01.02.58.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:09 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=74.125.82.172; Received: by mail-we0-f172.google.com with SMTP id u57so2913700wes.31 for ; Thu, 01 May 2014 02:58:09 -0700 (PDT) X-Received: by 10.194.60.4 with SMTP id d4mr8280318wjr.28.1398938289573; Thu, 01 May 2014 02:58:09 -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.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:08 -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 30/47] mtd: nand: stm_nand_bch: write IBBT to Flash Date: Thu, 1 May 2014 10:56:37 +0100 Message-Id: <1398938214-17847-31-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: , 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 bf8669b..8b70a36 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -758,6 +758,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,