From patchwork Tue Mar 25 08:19:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 27003 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9CFCE20062 for ; Tue, 25 Mar 2014 08:43:50 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf591807oag.4 for ; Tue, 25 Mar 2014 01:43:49 -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=i/z9maSZhLbFaI9fmO+sDQVQ+nXodMfbjq+CR1RgRdQ=; b=H6aYVtdQ/b+MKOXEKgCW4DeEme4zzJ8W1ySu3MLcRarIffwOzHNf7GJC3f/JrUnhe5 mOA65msLvCtziBwk5/YwnmsEnjnPFwOeICAg2vA/dcHSuwE+Veq/M7bCs9RcD0qbMvhU Zxu0ruuRxlktmv+dLLV37U37XHveSCurxI8GpJGDKUpGgNBdfUvuIGaMiv9LrNkjNRv1 FSTzADCKm9/JL6Mfmaq+2YTMzrHLfA5fkHINgaZrTORGf0yhtjOIGcO7GXP9JcD0rlJy m8HQy9RxOJxFVV6BQ/jl9Et/Ad9jccBWpXYyxZTbZd8r2gNNC07rotShAYfofEVM6u7Y Gggw== X-Gm-Message-State: ALoCoQmOk3CFBHlRTjAcoWQAJi52IbhBhXkZ/XaK0Mxxy8J7YYpKCQDMuwhFak95WfDJUElc5+WC X-Received: by 10.43.14.137 with SMTP id pq9mr24831828icb.12.1395737029906; Tue, 25 Mar 2014 01:43:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.33 with SMTP id c30ls133676qge.9.gmail; Tue, 25 Mar 2014 01:43:49 -0700 (PDT) X-Received: by 10.52.242.167 with SMTP id wr7mr239214vdc.32.1395737029775; Tue, 25 Mar 2014 01:43:49 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id xt10si3583878veb.166.2014.03.25.01.43.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:43:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jx11so159033veb.3 for ; Tue, 25 Mar 2014 01:43:49 -0700 (PDT) X-Received: by 10.221.34.7 with SMTP id sq7mr22231443vcb.5.1395737029699; Tue, 25 Mar 2014 01:43:49 -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 i9csp286539vck; Tue, 25 Mar 2014 01:43:49 -0700 (PDT) X-Received: by 10.66.218.170 with SMTP id ph10mr76676380pac.53.1395737025809; Tue, 25 Mar 2014 01:43:45 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8si10890190pbs.500.2014.03.25.01.43.45; Tue, 25 Mar 2014 01:43:45 -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 S1752432AbaCYIng (ORCPT + 26 others); Tue, 25 Mar 2014 04:43:36 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:54904 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753112AbaCYIVU (ORCPT ); Tue, 25 Mar 2014 04:21:20 -0400 Received: by mail-wg0-f50.google.com with SMTP id x13so81558wgg.9 for ; Tue, 25 Mar 2014 01:21:19 -0700 (PDT) X-Received: by 10.180.188.229 with SMTP id gd5mr21321869wic.54.1395735679109; Tue, 25 Mar 2014 01:21:19 -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.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:21:18 -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 32/47] mtd: nand: stm_nand_bch: scan for BBMs and build memory-resident BBT Date: Tue, 25 Mar 2014 08:19:49 +0000 Message-Id: <1395735604-26706-33-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.128.172 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: , If at start-up time we can't find our own pre-built memory-resident BBT (e.g. at first run) this routine will search for factory set BBMs and duplicate them into our own BBT for local consumption. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index 29eeee8..d7d97720 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -703,6 +703,33 @@ static int nandi_scan_bad_block_markers_block(struct nandi_controller *nandi, return 0; } +/* Scan for BBMs and build memory-resident BBT */ +static int nandi_scan_build_bbt(struct nandi_controller *nandi, + struct nandi_bbt_info *bbt_info) +{ + struct mtd_info *mtd = &nandi->info.mtd; + struct nand_chip *chip = mtd->priv; + uint32_t page_size = mtd->writesize; + uint8_t *bbt = bbt_info->bbt; + uint32_t block; + + dev_dbg(nandi->dev, + "scan device for bad-block markers [bbt options = 0x%02x]\n", + chip->bbt_options); + + memset(bbt, 0xff, page_size); + bbt_info->bbt_vers[0] = 0; + bbt_info->bbt_vers[1] = 0; + bbt_info->bbt_block[0] = nandi->blocks_per_device - 1; + bbt_info->bbt_block[1] = nandi->blocks_per_device - 2; + + for (block = 0; block < nandi->blocks_per_device; block++) + if (nandi_scan_bad_block_markers_block(nandi, block)) + bbt_set_block_mark(bbt, block, BBT_MARK_BAD_FACTORY); + + return 0; +} + /* Populate IBBT BCH Header */ static void bch_fill_ibbt_header(struct nandi_controller *nandi, struct nand_ibbt_bch_header *ibbt_header,