* [PATCH] provide overrideable read_id()
@ 2004-08-24 0:28 Ian Molton
0 siblings, 0 replies; only message in thread
From: Ian Molton @ 2004-08-24 0:28 UTC (permalink / raw)
To: linux-mtd; +Cc: tglx
[-- Attachment #1: Type: text/plain, Size: 181 bytes --]
Hi.
Heres the patch(es) to allow read_id to be overridden. makes the code a
tad clearer too IMO. Default behaviour is preserved.
This supports the new TC6393XB Smartmedia driver.
[-- Attachment #2: include.diff --]
[-- Type: application/octet-stream, Size: 638 bytes --]
--- include/linux/mtd/nand.h 2004-07-07 23:00:26.000000000 +0100
+++ /home/ian/projects/e740/linux1/linux/kernel26/include/linux/mtd/nand.h 2004-08-20 17:08:00.409319171 +0100
@@ -281,6 +281,7 @@
void (*read_buf)(struct mtd_info *mtd, u_char *buf, int len);
int (*verify_buf)(struct mtd_info *mtd, const u_char *buf, int len);
void (*select_chip)(struct mtd_info *mtd, int chip);
+ void (*read_id)(struct mtd_info *mtd, int *maf_id, int *dev_id);
int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip);
int (*block_markbad)(struct mtd_info *mtd, loff_t ofs);
void (*hwcontrol)(struct mtd_info *mtd, int cmd);
[-- Attachment #3: driver.diff --]
[-- Type: application/octet-stream, Size: 2515 bytes --]
--- drivers/mtd/nand/nand_base.c 2004-08-09 23:00:18.000000000 +0100
+++ /home/ian/projects/e740/linux1/linux/kernel26/drivers/mtd/nand/nand_base.c 2004-08-24 00:29:44.000000000 +0100
@@ -37,7 +37,7 @@
* The AG-AND chips have nice features for speed improvement,
* which are not supported yet. Read / program 4 pages in one go.
*
- * $Id: nand_base.c,v 1.115 2004/08/09 13:19:45 dwmw2 Exp $
+ * $Id: nand_base.c,v 1.3 2004/08/23 23:29:44 spyro Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -164,6 +164,25 @@
return readb(this->IO_ADDR_R);
}
+/*
+ * nand_read_id - [DEFAULT] read the manufacturer and chip IDs
+ * @mtd: MTD device structure
+ * @maf_id: pointer to int to store maf. id in
+ * @dev_id: pointer to int to store device id in.
+ *
+ */
+static void nand_read_id(struct mtd_info *mtd, int *maf_id, int *dev_id)
+{
+ struct nand_chip *this = mtd->priv;
+
+ /* Send the command for reading device ID */
+ this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
+
+ /* Read manufacturer and device IDs */
+ *maf_id = this->read_byte(mtd);
+ *dev_id = this->read_byte(mtd);
+}
+
/**
* nand_write_byte - [DEFAULT] write one byte to the chip
* @mtd: MTD device structure
@@ -2235,6 +2254,8 @@
if (!this->select_chip)
this->select_chip = nand_select_chip;
+ if (!this->read_id)
+ this->read_id = nand_read_id;
if (!this->write_byte)
this->write_byte = busw ? nand_write_byte16 : nand_write_byte;
if (!this->read_byte)
@@ -2259,12 +2280,8 @@
/* Select the device */
this->select_chip(mtd, 0);
- /* Send the command for reading device ID */
- this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
-
- /* Read manufacturer and device IDs */
- nand_maf_id = this->read_byte(mtd);
- nand_dev_id = this->read_byte(mtd);
+ /* Read device ID */
+ this->read_id(mtd, &nand_maf_id, &nand_dev_id);
/* Print and store flash device information */
for (i = 0; nand_flash_ids[i].name != NULL; i++) {
@@ -2365,14 +2382,11 @@
}
for (i=1; i < maxchips; i++) {
+ int maf_id, dev_id;
this->select_chip(mtd, i);
+ this->read_id(mtd, &maf_id, &dev_id);
- /* Send the command for reading device ID */
- this->cmdfunc (mtd, NAND_CMD_READID, 0x00, -1);
-
- /* Read manufacturer and device IDs */
- if (nand_maf_id != this->read_byte(mtd) ||
- nand_dev_id != this->read_byte(mtd))
+ if (nand_maf_id != maf_id || nand_dev_id != nand_dev_id)
break;
}
if (i > 1)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-08-24 0:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-24 0:28 [PATCH] provide overrideable read_id() Ian Molton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox