From patchwork Thu May 1 09:56:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29478 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 32851203F3 for ; Thu, 1 May 2014 09:58:20 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id hq16sf9619677vcb.2 for ; Thu, 01 May 2014 02:58:20 -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=cPI3jC6FYmt4zzmR+/c/0g2Qdcyuyq28MshhUMOOu8g=; b=iX1FoFQ2ccEjtsSom+quQMK5exK7A+5Y8NG/w3/qBYfSGg3w2bluSkvUfiMQthh636 gJ7onvjWyPAAJKu/5VMj6xyrTV1I6FJL332ZwsKb1r87Z52OCTxQbJ1bRL3w8U2V5A7b GUz2dXrgKw7EPKiD8szFhzDF1eUtIYBFaPRuwpyRVq6oM5pmRBZ/19JDHYHlncqwyTyx 93T6QG5ChCg8BeLL8hWb9KlvXcodQkzixc+IPxVQan6Gcr0HHYKhLnkGkKCdP1XM1YSB FbRJqXWhKC1reiLtg2LiwiccjDCwFTfycqhD5GhG13Lj4uPkPpukFUAHhVbhXekfFihC IoZQ== X-Gm-Message-State: ALoCoQmHt1hjhYUODRtQn2BMvxKuzRAqAXoXZPY8K6SQNsp1glun0FL42pyWRgenHNnajynlA+7m X-Received: by 10.58.59.104 with SMTP id y8mr4916085veq.18.1398938299972; Thu, 01 May 2014 02:58:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.40 with SMTP id 37ls969176qgk.32.gmail; Thu, 01 May 2014 02:58:19 -0700 (PDT) X-Received: by 10.52.113.1 with SMTP id iu1mr427649vdb.35.1398938299835; Thu, 01 May 2014 02:58:19 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id c6si5967588veo.162.2014.05.01.02.58.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:19 -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.181; Received: by mail-vc0-f181.google.com with SMTP id hy4so3645220vcb.26 for ; Thu, 01 May 2014 02:58:19 -0700 (PDT) X-Received: by 10.52.166.102 with SMTP id zf6mr6835181vdb.2.1398938299777; Thu, 01 May 2014 02:58:19 -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 ib8csp12964vcb; Thu, 1 May 2014 02:58:19 -0700 (PDT) X-Received: by 10.180.7.227 with SMTP id m3mr1419470wia.59.1398938298979; Thu, 01 May 2014 02:58:18 -0700 (PDT) Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by mx.google.com with ESMTPS id l3si10544962wjb.109.2014.05.01.02.58.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:18 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=74.125.82.175; Received: by mail-we0-f175.google.com with SMTP id q58so2835686wes.6 for ; Thu, 01 May 2014 02:58:18 -0700 (PDT) X-Received: by 10.180.100.234 with SMTP id fb10mr1549591wib.26.1398938298453; Thu, 01 May 2014 02:58:18 -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.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:17 -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 35/47] mtd: nand: stm_nand_bch: scan for BBMs and build memory-resident BBT Date: Thu, 1 May 2014 10:56:42 +0100 Message-Id: <1398938214-17847-36-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: , 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 7d242ad..1569738 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -878,6 +878,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,