From patchwork Wed Jul 28 05:56:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 60090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BAD5CB6EF7 for ; Wed, 28 Jul 2010 15:58:54 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OdzdV-0003FR-Ss; Wed, 28 Jul 2010 05:57:01 +0000 Received: from mail-px0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1Odzct-0002n7-KB; Wed, 28 Jul 2010 05:56:24 +0000 Received: by mail-px0-f177.google.com with SMTP id 13so924820pxi.36 for ; Tue, 27 Jul 2010 22:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=gHU5WPKv+M9HPFhsH443YlBfba2OKvkxOXvjt7+j7QQ=; b=MvuTACYVep0FY50rGYSWYK2wqZTbWB6FL69E65n7qb6E34fB42Z+Hh0kEGTUJEzg8P bVNAVgABt0XsJjD0Ia/00cYl9krc2NYFdC+8Fn2yPSG+3k74Q6BU12PpnoRCu06Y6Tdk cRIsoXXioD4CZ9wJ6plBB0rj37gXGP/ifGR20= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=mgx4b4NFKbQBQEbYqDhOZfKcOvOKzf7N5ozJjKoaOmsXEXleecQQFauZscivxSPwgr O7Ucp4bXi7aRmHb+/iOQbuB79/hui7ZjMuvFyLE14k1eVSidSTR4KP5Ur/D5jBBtjYYV qvHXSSOF8Bk3fo0wAdsXnMvi+KNALsdOK9SJ4= MIME-Version: 1.0 Received: by 10.142.154.5 with SMTP id b5mr7539468wfe.316.1280296583182; Tue, 27 Jul 2010 22:56:23 -0700 (PDT) Received: by 10.142.54.6 with HTTP; Tue, 27 Jul 2010 22:56:23 -0700 (PDT) Date: Wed, 28 Jul 2010 13:56:23 +0800 Message-ID: Subject: [PATCH 05/29] pxa3xx_nand: set oob length in the runtime From: Haojian Zhuang To: Eric Miao , linux-arm-kernel , David Woodhouse , David Woodhouse , Marc Kleine-Budde , linux-mtd@lists.infradead.org, Lei Wen X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100728_015623_805012_8031A177 X-CRM114-Status: GOOD ( 16.23 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (haojian.zhuang[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From 66073b51eb2431545c581556e42ec1358cf72a70 Mon Sep 17 00:00:00 2001 From: Lei Wen Date: Tue, 22 Jun 2010 21:01:04 +0800 Subject: [PATCH 05/29] pxa3xx_nand: set oob length in the runtime For different command need different oob requirement, set the proper oob length by different cmd. Signed-off-by: Lei Wen --- drivers/mtd/nand/pxa3xx_nand.c | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) } @@ -334,6 +341,7 @@ static int prepare_other_cmd(struct pxa3xx_nand_info *info, uint16_t cmd) info->ndcb1 = 0; info->ndcb2 = 0; + info->oob_size = 0; if (cmd == cmdset->read_id) { info->ndcb0 |= NDCB0_CMD_TYPE(3); info->data_size = 8; @@ -402,6 +410,9 @@ static int handle_data_pio(struct pxa3xx_nand_info *info) case STATE_PIO_WRITING: __raw_writesl(info->mmio_base + NDDB, info->data_buff, DIV_ROUND_UP(info->data_size, 4)); + if (info->oob_size > 0) + __raw_writesl(info->mmio_base + NDDB, info->oob_buff, + DIV_ROUND_UP(info->oob_size, 4)); enable_int(info, NDSR_CS0_BBD | NDSR_CS0_CMDD); @@ -414,6 +425,9 @@ static int handle_data_pio(struct pxa3xx_nand_info *info) case STATE_PIO_READING: __raw_readsl(info->mmio_base + NDDB, info->data_buff, DIV_ROUND_UP(info->data_size, 4)); + if (info->oob_size > 0) + __raw_readsl(info->mmio_base + NDDB, info->oob_buff, + DIV_ROUND_UP(info->oob_size, 4)); break; default: @@ -429,7 +443,7 @@ static int handle_data_pio(struct pxa3xx_nand_info *info) static void start_data_dma(struct pxa3xx_nand_info *info, int dir_out) { struct pxa_dma_desc *desc = info->data_desc; - int dma_len = ALIGN(info->data_size, 32); + int dma_len = ALIGN(info->data_size + info->oob_size, 32); desc->ddadr = DDADR_STOP; desc->dcmd = DCMD_ENDIRQEN | DCMD_WIDTH4 | DCMD_BURST32 | dma_len; @@ -835,7 +849,6 @@ static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info, info->cmdset = f->cmdset; info->page_size = f->page_size; info->oob_buff = info->data_buff + f->page_size; - info->oob_size = (f->page_size == 2048) ? 64 : 16; info->read_id_bytes = (f->page_size == 2048) ? 4 : 2; /* calculate addressing information */ @@ -894,8 +907,6 @@ static int pxa3xx_nand_detect_config(struct pxa3xx_nand_info *info) i = __ffs(page_per_block * info->page_size); num_blocks = type->chipsize << (20 - i); - info->oob_size = (info->page_size == 2048) ? 64 : 16; - /* calculate addressing information */ info->col_addr_cycles = (info->page_size == 2048) ? 2 : 1; diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c index 50e08db..26c0286 100644 --- a/drivers/mtd/nand/pxa3xx_nand.c +++ b/drivers/mtd/nand/pxa3xx_nand.c @@ -274,13 +274,20 @@ static int wait_for_event(struct pxa3xx_nand_info *info, uint32_t event) static void pxa3xx_set_datasize(struct pxa3xx_nand_info *info) { - /* calculate data size */ + int oob_enable = info->reg_ndcr & NDCR_SPARE_EN; + + info->data_size = info->page_size; + if (!oob_enable) { + info->oob_size = 0; + return; + } + switch (info->page_size) { case 2048: - info->data_size = (info->use_ecc) ? 2088 : 2112; + info->oob_size = (info->use_ecc) ? 40 : 64; break; case 512: - info->data_size = (info->use_ecc) ? 520 : 528; + info->oob_size = (info->use_ecc) ? 8 : 16; break; }