From patchwork Mon Apr 19 15:20:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 50471 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 AB63BB7D0E for ; Tue, 20 Apr 2010 01:23:30 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O3smr-0007hu-Mg; Mon, 19 Apr 2010 15:21:25 +0000 Received: from fg-out-1718.google.com ([72.14.220.153]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O3smp-0007gI-2O for linux-mtd@lists.infradead.org; Mon, 19 Apr 2010 15:21:24 +0000 Received: by fg-out-1718.google.com with SMTP id e21so2666547fga.0 for ; Mon, 19 Apr 2010 08:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=RCFh0XrwnPyLVQPXRRenrmwJBv61RvhwasTBaDmu02w=; b=UjyNosp09AW4+Ab0KAF5+fr57hwReb+zmknj/R/EeRUIfYOCjK8pbfyV39EA+AjCji eMVMlQYy/141MEaJpKtg2VJuyfcc3FuyBJc9JPTt21UVOBUEkJZkd0QWb8nrSqeqzqv1 Plania4p/LeFInNTeLoLCvAkT5t8rwuojKZlE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=VZ/h8/S7EYHIQTncIWlATzBzVA920JVpOCRJwH8Z5kERzs9vzvMbiESM+Lmxml2aJ8 oIvYTXTqyQFLmC11vrRG+uGogu0qBO0mlajrClKqvNiI1qqgBph9VbZt9DsZDcqa17BI xW5dnLRlkXArjAj/mhaxBq73b1RxDsDQ/CPSo= Received: by 10.223.99.156 with SMTP id u28mr285448fan.53.1271690447846; Mon, 19 Apr 2010 08:20:47 -0700 (PDT) Received: from localhost.localdomain ([77.124.182.29]) by mx.google.com with ESMTPS id 23sm2083247mun.31.2010.04.19.08.20.45 (version=SSLv3 cipher=RC4-MD5); Mon, 19 Apr 2010 08:20:47 -0700 (PDT) From: Maxim Levitsky To: David Woodhouse Subject: [PATCH] MTD: sm_common: split smartmedia and xD table Date: Mon, 19 Apr 2010 18:20:41 +0300 Message-Id: <1271690441-25088-1-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.0.4 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100419_112123_364824_F82C04FB X-CRM114-Status: GOOD ( 16.84 ) 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 FREEMAIL_FROM Sender email is freemail (maximlevitsky[at]gmail.com) -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [72.14.220.153 listed in list.dnswl.org] -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 Cc: linux-mtd@lists.infradead.org, Maxim Levitsky 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: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 2GB xD card, and 4MB SmartMedia ROM card share same ID, so to make both work split xD and smartmedia ID tables. Hardware driver must be able to know which type it handles (and probably just one). Signed-off-by: Maxim Levitsky --- drivers/mtd/nand/r852.c | 2 +- drivers/mtd/nand/sm_common.c | 37 +++++++++++++++++++++---------------- drivers/mtd/nand/sm_common.h | 2 +- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c index 96bfbd8..6dfbb47 100644 --- a/drivers/mtd/nand/r852.c +++ b/drivers/mtd/nand/r852.c @@ -666,7 +666,7 @@ int r852_register_nand_device(struct r852_device *dev) r852_engine_enable(dev); - if (sm_register_device(dev->mtd)) + if (sm_register_device(dev->mtd, dev->sm)) goto error2; if (device_create_file(&dev->mtd->dev, &dev_attr_media_type)) diff --git a/drivers/mtd/nand/sm_common.c b/drivers/mtd/nand/sm_common.c index aae0b9a..ac80fb3 100644 --- a/drivers/mtd/nand/sm_common.c +++ b/drivers/mtd/nand/sm_common.c @@ -68,8 +68,6 @@ static int sm_block_markbad(struct mtd_info *mtd, loff_t ofs) static struct nand_flash_dev nand_smartmedia_flash_ids[] = { - - /* SmartMedia */ {"SmartMedia 1MiB 5V", 0x6e, 256, 1, 0x1000, 0}, {"SmartMedia 1MiB 3,3V", 0xe8, 256, 1, 0x1000, 0}, {"SmartMedia 1MiB 3,3V", 0xec, 256, 1, 0x1000, 0}, @@ -82,28 +80,34 @@ static struct nand_flash_dev nand_smartmedia_flash_ids[] = { {"SmartMedia 4MiB 3,3V ROM", 0xd5, 512, 4, 0x2000, NAND_ROM}, {"SmartMedia 8MiB 3,3V", 0xe6, 512, 8, 0x2000, 0}, {"SmartMedia 8MiB 3,3V ROM", 0xd6, 512, 8, 0x2000, NAND_ROM}, - -#define XD_TYPEM (NAND_NO_AUTOINCR | NAND_BROKEN_XD) - /* xD / SmartMedia */ - {"SmartMedia/xD 16MiB 3,3V", 0x73, 512, 16, 0x4000, 0}, + {"SmartMedia 16MiB 3,3V", 0x73, 512, 16, 0x4000, 0}, {"SmartMedia 16MiB 3,3V ROM", 0x57, 512, 16, 0x4000, NAND_ROM}, - {"SmartMedia/xD 32MiB 3,3V", 0x75, 512, 32, 0x4000, 0}, + {"SmartMedia 32MiB 3,3V", 0x75, 512, 32, 0x4000, 0}, {"SmartMedia 32MiB 3,3V ROM", 0x58, 512, 32, 0x4000, NAND_ROM}, - {"SmartMedia/xD 64MiB 3,3V", 0x76, 512, 64, 0x4000, 0}, + {"SmartMedia 64MiB 3,3V", 0x76, 512, 64, 0x4000, 0}, {"SmartMedia 64MiB 3,3V ROM", 0xd9, 512, 64, 0x4000, NAND_ROM}, - {"SmartMedia/xD 128MiB 3,3V", 0x79, 512, 128, 0x4000, 0}, + {"SmartMedia 128MiB 3,3V", 0x79, 512, 128, 0x4000, 0}, {"SmartMedia 128MiB 3,3V ROM", 0xda, 512, 128, 0x4000, NAND_ROM}, - {"SmartMedia/xD 256MiB 3,3V", 0x71, 512, 256, 0x4000, XD_TYPEM}, + {"SmartMedia 256MiB 3,3V", 0x71, 512, 256, 0x4000 }, {"SmartMedia 256MiB 3,3V ROM", 0x5b, 512, 256, 0x4000, NAND_ROM}, + {NULL,} +}; - /* xD only */ - {"xD 512MiB 3,3V", 0xDC, 512, 512, 0x4000, XD_TYPEM}, - {"xD 1GiB 3,3V", 0xD3, 512, 1024, 0x4000, XD_TYPEM}, - {"xD 2GiB 3,3V", 0xD5, 512, 2048, 0x4000, XD_TYPEM}, +#define XD_TYPEM (NAND_NO_AUTOINCR | NAND_BROKEN_XD) +static struct nand_flash_dev nand_xd_flash_ids[] = { + + {"xD 16MiB 3,3V", 0x73, 512, 16, 0x4000, 0}, + {"xD 32MiB 3,3V", 0x75, 512, 32, 0x4000, 0}, + {"xD 64MiB 3,3V", 0x76, 512, 64, 0x4000, 0}, + {"xD 128MiB 3,3V", 0x79, 512, 128, 0x4000, 0}, + {"xD 256MiB 3,3V", 0x71, 512, 256, 0x4000, XD_TYPEM}, + {"xD 512MiB 3,3V", 0xdc, 512, 512, 0x4000, XD_TYPEM}, + {"xD 1GiB 3,3V", 0xd3, 512, 1024, 0x4000, XD_TYPEM}, + {"xD 2GiB 3,3V", 0xd5, 512, 2048, 0x4000, XD_TYPEM}, {NULL,} }; -int sm_register_device(struct mtd_info *mtd) +int sm_register_device(struct mtd_info *mtd, int smartmedia) { struct nand_chip *chip = (struct nand_chip *)mtd->priv; int ret; @@ -111,7 +115,8 @@ int sm_register_device(struct mtd_info *mtd) chip->options |= NAND_SKIP_BBTSCAN; /* Scan for card properties */ - ret = nand_scan_ident(mtd, 1, nand_smartmedia_flash_ids); + ret = nand_scan_ident(mtd, 1, smartmedia ? + nand_smartmedia_flash_ids : nand_xd_flash_ids); if (ret) return ret; diff --git a/drivers/mtd/nand/sm_common.h b/drivers/mtd/nand/sm_common.h index 18284f5..00f4a83 100644 --- a/drivers/mtd/nand/sm_common.h +++ b/drivers/mtd/nand/sm_common.h @@ -36,7 +36,7 @@ struct sm_oob { #define SM_SMALL_OOB_SIZE 8 -extern int sm_register_device(struct mtd_info *mtd); +extern int sm_register_device(struct mtd_info *mtd, int smartmedia); static inline int sm_sector_valid(struct sm_oob *oob)