[MTD NAND] Indent all of drivers/mtd/nand/*.c.
It was just too painful to deal with. Signed-off-by: David Woodhouse <dwmw2@infradead.org>
This commit is contained in:
Родитель
6943f8af7d
Коммит
e0c7d76753
|
@ -47,13 +47,11 @@ static const struct mtd_partition partition_info[] = {
|
|||
{
|
||||
.name = "NAND FS 0",
|
||||
.offset = 0,
|
||||
.size = 8*1024*1024
|
||||
},
|
||||
.size = 8 * 1024 * 1024},
|
||||
{
|
||||
.name = "NAND FS 1",
|
||||
.offset = MTDPART_OFS_APPEND,
|
||||
.size = MTDPART_SIZ_FULL
|
||||
}
|
||||
.size = MTDPART_SIZ_FULL}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -277,25 +275,33 @@ static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
|
|||
|
||||
switch (cmd) {
|
||||
|
||||
case NAND_CTL_SETCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_CMD; break;
|
||||
case NAND_CTL_CLRCLE: this->IO_ADDR_W = p_nand + MEM_STNAND_DATA; break;
|
||||
case NAND_CTL_SETCLE:
|
||||
this->IO_ADDR_W = p_nand + MEM_STNAND_CMD;
|
||||
break;
|
||||
|
||||
case NAND_CTL_CLRCLE:
|
||||
this->IO_ADDR_W = p_nand + MEM_STNAND_DATA;
|
||||
break;
|
||||
|
||||
case NAND_CTL_SETALE:
|
||||
this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR;
|
||||
break;
|
||||
|
||||
case NAND_CTL_SETALE: this->IO_ADDR_W = p_nand + MEM_STNAND_ADDR; break;
|
||||
case NAND_CTL_CLRALE:
|
||||
this->IO_ADDR_W = p_nand + MEM_STNAND_DATA;
|
||||
/* FIXME: Nobody knows why this is neccecary,
|
||||
/* FIXME: Nobody knows why this is necessary,
|
||||
* but it works only that way */
|
||||
udelay(1);
|
||||
break;
|
||||
|
||||
case NAND_CTL_SETNCE:
|
||||
/* assert (force assert) chip enable */
|
||||
au_writel((1<<(4+NAND_CS)) , MEM_STNDCTL); break;
|
||||
au_writel((1 << (4 + NAND_CS)), MEM_STNDCTL);
|
||||
break;
|
||||
|
||||
case NAND_CTL_CLRNCE:
|
||||
/* deassert chip enable */
|
||||
au_writel(0, MEM_STNDCTL); break;
|
||||
au_writel(0, MEM_STNDCTL);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -324,8 +330,7 @@ int __init au1xxx_nand_init (void)
|
|||
u32 nand_phys;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
au1550_mtd = kmalloc (sizeof(struct mtd_info) +
|
||||
sizeof (struct nand_chip), GFP_KERNEL);
|
||||
au1550_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!au1550_mtd) {
|
||||
printk("Unable to allocate NAND MTD dev structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -335,13 +340,12 @@ int __init au1xxx_nand_init (void)
|
|||
this = (struct nand_chip *)(&au1550_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) au1550_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(au1550_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
au1550_mtd->priv = this;
|
||||
|
||||
|
||||
/* disable interrupts */
|
||||
au_writel(au_readl(MEM_STNDCTL) & ~(1 << 8), MEM_STNDCTL);
|
||||
|
||||
|
@ -352,8 +356,7 @@ int __init au1xxx_nand_init (void)
|
|||
/* set gpio206 high */
|
||||
au_writel(au_readl(GPIO2_DIR) & ~(1 << 6), GPIO2_DIR);
|
||||
|
||||
boot_swapboot = (au_readl(MEM_STSTAT) & (0x7<<1)) |
|
||||
((bcsr->status >> 6) & 0x1);
|
||||
boot_swapboot = (au_readl(MEM_STSTAT) & (0x7 << 1)) | ((bcsr->status >> 6) & 0x1);
|
||||
switch (boot_swapboot) {
|
||||
case 0:
|
||||
case 2:
|
||||
|
@ -432,7 +435,6 @@ int __init au1xxx_nand_init (void)
|
|||
if (NAND_CS == 3)
|
||||
nand_width = au_readl(MEM_STCFG3) & (1 << 22);
|
||||
|
||||
|
||||
/* Set address of hardware control function */
|
||||
this->hwcontrol = au1550_hwcontrol;
|
||||
this->dev_ready = au1550_device_ready;
|
||||
|
@ -491,6 +493,7 @@ static void __exit au1550_cleanup (void)
|
|||
/* Unmap */
|
||||
iounmap((void *)p_nand);
|
||||
}
|
||||
|
||||
module_exit(au1550_cleanup);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -95,9 +95,9 @@ static struct mtd_partition partition_info128k[] = {
|
|||
/*
|
||||
* hardware specific access to control-lines
|
||||
*/
|
||||
|
||||
static void autcpu12_hwcontrol(struct mtd_info *mtd, int cmd)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
|
||||
case NAND_CTL_SETCLE: (*(volatile unsigned char *) (autcpu12_io_base + autcpu12_pedr)) |= AUTCPU12_SMC_CLE; break;
|
||||
|
@ -130,8 +130,7 @@ int __init autcpu12_init (void)
|
|||
int err = 0;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
autcpu12_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
|
||||
GFP_KERNEL);
|
||||
autcpu12_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!autcpu12_mtd) {
|
||||
printk("Unable to allocate AUTCPU12 NAND MTD device structure.\n");
|
||||
err = -ENOMEM;
|
||||
|
@ -150,8 +149,8 @@ int __init autcpu12_init (void)
|
|||
this = (struct nand_chip *)(&autcpu12_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) autcpu12_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(autcpu12_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
autcpu12_mtd->priv = this;
|
||||
|
@ -183,12 +182,11 @@ int __init autcpu12_init (void)
|
|||
case SZ_32M: add_mtd_partitions(autcpu12_mtd, partition_info32k, NUM_PARTITIONS32K); break;
|
||||
case SZ_64M: add_mtd_partitions(autcpu12_mtd, partition_info64k, NUM_PARTITIONS64K); break;
|
||||
case SZ_128M: add_mtd_partitions(autcpu12_mtd, partition_info128k, NUM_PARTITIONS128K); break;
|
||||
default: {
|
||||
default:
|
||||
printk("Unsupported SmartMedia device\n");
|
||||
err = -ENXIO;
|
||||
goto out_ior;
|
||||
}
|
||||
}
|
||||
goto out;
|
||||
|
||||
out_ior:
|
||||
|
@ -216,6 +214,7 @@ static void __exit autcpu12_cleanup (void)
|
|||
/* Free the MTD device structure */
|
||||
kfree(autcpu12_mtd);
|
||||
}
|
||||
|
||||
module_exit(autcpu12_cleanup);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -160,7 +160,6 @@ static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd)
|
|||
writeb(ctl, mmio_base + MM_NAND_CTL);
|
||||
}
|
||||
|
||||
|
||||
static int cs553x_device_ready(struct mtd_info *mtd)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
|
@ -170,7 +169,6 @@ static int cs553x_device_ready(struct mtd_info *mtd)
|
|||
return (foo & CS_NAND_STS_FLASH_RDY) && !(foo & CS_NAND_CTLR_BUSY);
|
||||
}
|
||||
|
||||
|
||||
static void cs_enable_hwecc(struct mtd_info *mtd, int mode)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
|
@ -306,6 +304,7 @@ int __init cs553x_init(void)
|
|||
|
||||
return err;
|
||||
}
|
||||
|
||||
module_init(cs553x_init);
|
||||
|
||||
static void __exit cs553x_cleanup(void)
|
||||
|
@ -334,6 +333,7 @@ static void __exit cs553x_cleanup (void)
|
|||
kfree(mtd);
|
||||
}
|
||||
}
|
||||
|
||||
module_exit(cs553x_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -61,7 +61,7 @@ static unsigned long __initdata doc_locations[] = {
|
|||
0xff000000,
|
||||
#elif defined(CONFIG_MOMENCO_OCELOT_G) || defined (CONFIG_MOMENCO_OCELOT_C)
|
||||
0xff000000,
|
||||
##else
|
||||
#else
|
||||
#warning Unknown architecture for DiskOnChip. No default probe locations defined
|
||||
#endif
|
||||
0xffffffff };
|
||||
|
@ -84,6 +84,7 @@ struct doc_priv {
|
|||
/* This is the syndrome computed by the HW ecc generator upon reading an empty
|
||||
page, one with all 0xff for data and stored ecc code. */
|
||||
static u_char empty_read_syndrome[6] = { 0x26, 0xff, 0x6d, 0x47, 0x73, 0x7a };
|
||||
|
||||
/* This is the ecc value computed by the HW ecc generator upon writing an empty
|
||||
page, one with all 0xff for data. */
|
||||
static u_char empty_write_ecc[6] = { 0x4b, 0x00, 0xe2, 0x0e, 0x93, 0xf7 };
|
||||
|
@ -123,7 +124,6 @@ static unsigned long doc_config_location = CONFIG_MTD_NAND_DISKONCHIP_PROBE_ADDR
|
|||
module_param(doc_config_location, ulong, 0);
|
||||
MODULE_PARM_DESC(doc_config_location, "Physical memory address at which to probe for DiskOnChip");
|
||||
|
||||
|
||||
/* Sector size for HW ECC */
|
||||
#define SECTOR_SIZE 512
|
||||
/* The sector bytes are packed into NB_DATA 10 bit words */
|
||||
|
@ -205,8 +205,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc)
|
|||
can be modified since pos is even */
|
||||
index = (pos >> 3) ^ 1;
|
||||
bitpos = pos & 7;
|
||||
if ((index >= 0 && index < SECTOR_SIZE) ||
|
||||
index == (SECTOR_SIZE + 1)) {
|
||||
if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) {
|
||||
val = (uint8_t) (errval[i] >> (2 + bitpos));
|
||||
parity ^= val;
|
||||
if (index < SECTOR_SIZE)
|
||||
|
@ -216,8 +215,7 @@ static int doc_ecc_decode (struct rs_control *rs, uint8_t *data, uint8_t *ecc)
|
|||
bitpos = (bitpos + 10) & 7;
|
||||
if (bitpos == 0)
|
||||
bitpos = 8;
|
||||
if ((index >= 0 && index < SECTOR_SIZE) ||
|
||||
index == (SECTOR_SIZE + 1)) {
|
||||
if ((index >= 0 && index < SECTOR_SIZE) || index == (SECTOR_SIZE + 1)) {
|
||||
val = (uint8_t) (errval[i] << (8 - bitpos));
|
||||
parity ^= val;
|
||||
if (index < SECTOR_SIZE)
|
||||
|
@ -253,7 +251,8 @@ static int _DoC_WaitReady(struct doc_priv *doc)
|
|||
void __iomem *docptr = doc->virtadr;
|
||||
unsigned long timeo = jiffies + (HZ * 10);
|
||||
|
||||
if(debug) printk("_DoC_WaitReady...\n");
|
||||
if (debug)
|
||||
printk("_DoC_WaitReady...\n");
|
||||
/* Out-of-line routine to wait for chip response */
|
||||
if (DoC_is_MillenniumPlus(doc)) {
|
||||
while ((ReadDOC(docptr, Mplus_FlashControl) & CDSN_CTRL_FR_B_MASK) != CDSN_CTRL_FR_B_MASK) {
|
||||
|
@ -298,7 +297,8 @@ static inline int DoC_WaitReady(struct doc_priv *doc)
|
|||
DoC_Delay(doc, 2);
|
||||
}
|
||||
|
||||
if(debug) printk("DoC_WaitReady OK\n");
|
||||
if (debug)
|
||||
printk("DoC_WaitReady OK\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,8 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum)
|
|||
struct doc_priv *doc = this->priv;
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
|
||||
if(debug)printk("write_byte %02x\n", datum);
|
||||
if (debug)
|
||||
printk("write_byte %02x\n", datum);
|
||||
WriteDOC(datum, docptr, CDSNSlowIO);
|
||||
WriteDOC(datum, docptr, 2k_CDSN_IO);
|
||||
}
|
||||
|
@ -323,50 +324,52 @@ static u_char doc2000_read_byte(struct mtd_info *mtd)
|
|||
ReadDOC(docptr, CDSNSlowIO);
|
||||
DoC_Delay(doc, 2);
|
||||
ret = ReadDOC(docptr, 2k_CDSN_IO);
|
||||
if (debug) printk("read_byte returns %02x\n", ret);
|
||||
if (debug)
|
||||
printk("read_byte returns %02x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void doc2000_writebuf(struct mtd_info *mtd,
|
||||
const u_char *buf, int len)
|
||||
static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
if (debug)printk("writebuf of %d bytes: ", len);
|
||||
if (debug)
|
||||
printk("writebuf of %d bytes: ", len);
|
||||
for (i = 0; i < len; i++) {
|
||||
WriteDOC_(buf[i], docptr, DoC_2k_CDSN_IO + i);
|
||||
if (debug && i < 16)
|
||||
printk("%02x ", buf[i]);
|
||||
}
|
||||
if (debug) printk("\n");
|
||||
if (debug)
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
static void doc2000_readbuf(struct mtd_info *mtd,
|
||||
u_char *buf, int len)
|
||||
static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
|
||||
if (debug)printk("readbuf of %d bytes: ", len);
|
||||
if (debug)
|
||||
printk("readbuf of %d bytes: ", len);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
buf[i] = ReadDOC(docptr, 2k_CDSN_IO + i);
|
||||
}
|
||||
}
|
||||
|
||||
static void doc2000_readbuf_dword(struct mtd_info *mtd,
|
||||
u_char *buf, int len)
|
||||
static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
|
||||
if (debug) printk("readbuf_dword of %d bytes: ", len);
|
||||
if (debug)
|
||||
printk("readbuf_dword of %d bytes: ", len);
|
||||
|
||||
if (unlikely((((unsigned long)buf) | len) & 3)) {
|
||||
for (i = 0; i < len; i++) {
|
||||
|
@ -379,8 +382,7 @@ static void doc2000_readbuf_dword(struct mtd_info *mtd,
|
|||
}
|
||||
}
|
||||
|
||||
static int doc2000_verifybuf(struct mtd_info *mtd,
|
||||
const u_char *buf, int len)
|
||||
static int doc2000_verifybuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -503,8 +505,7 @@ static u_char doc2001_read_byte(struct mtd_info *mtd)
|
|||
return ReadDOC(docptr, LastDataRead);
|
||||
}
|
||||
|
||||
static void doc2001_writebuf(struct mtd_info *mtd,
|
||||
const u_char *buf, int len)
|
||||
static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -517,8 +518,7 @@ static void doc2001_writebuf(struct mtd_info *mtd,
|
|||
WriteDOC(0x00, docptr, WritePipeTerm);
|
||||
}
|
||||
|
||||
static void doc2001_readbuf(struct mtd_info *mtd,
|
||||
u_char *buf, int len)
|
||||
static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -535,8 +535,7 @@ static void doc2001_readbuf(struct mtd_info *mtd,
|
|||
buf[i] = ReadDOC(docptr, LastDataRead);
|
||||
}
|
||||
|
||||
static int doc2001_verifybuf(struct mtd_info *mtd,
|
||||
const u_char *buf, int len)
|
||||
static int doc2001_verifybuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -566,36 +565,38 @@ static u_char doc2001plus_read_byte(struct mtd_info *mtd)
|
|||
ReadDOC(docptr, Mplus_ReadPipeInit);
|
||||
ReadDOC(docptr, Mplus_ReadPipeInit);
|
||||
ret = ReadDOC(docptr, Mplus_LastDataRead);
|
||||
if (debug) printk("read_byte returns %02x\n", ret);
|
||||
if (debug)
|
||||
printk("read_byte returns %02x\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void doc2001plus_writebuf(struct mtd_info *mtd,
|
||||
const u_char *buf, int len)
|
||||
static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
|
||||
if (debug)printk("writebuf of %d bytes: ", len);
|
||||
if (debug)
|
||||
printk("writebuf of %d bytes: ", len);
|
||||
for (i = 0; i < len; i++) {
|
||||
WriteDOC_(buf[i], docptr, DoC_Mil_CDSN_IO + i);
|
||||
if (debug && i < 16)
|
||||
printk("%02x ", buf[i]);
|
||||
}
|
||||
if (debug) printk("\n");
|
||||
if (debug)
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
static void doc2001plus_readbuf(struct mtd_info *mtd,
|
||||
u_char *buf, int len)
|
||||
static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
|
||||
if (debug)printk("readbuf of %d bytes: ", len);
|
||||
if (debug)
|
||||
printk("readbuf of %d bytes: ", len);
|
||||
|
||||
/* Start read pipeline */
|
||||
ReadDOC(docptr, Mplus_ReadPipeInit);
|
||||
|
@ -614,18 +615,19 @@ static void doc2001plus_readbuf(struct mtd_info *mtd,
|
|||
buf[len - 1] = ReadDOC(docptr, Mplus_LastDataRead);
|
||||
if (debug && i < 16)
|
||||
printk("%02x ", buf[len - 1]);
|
||||
if (debug) printk("\n");
|
||||
if (debug)
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
static int doc2001plus_verifybuf(struct mtd_info *mtd,
|
||||
const u_char *buf, int len)
|
||||
static int doc2001plus_verifybuf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
void __iomem *docptr = doc->virtadr;
|
||||
int i;
|
||||
|
||||
if (debug)printk("verifybuf of %d bytes: ", len);
|
||||
if (debug)
|
||||
printk("verifybuf of %d bytes: ", len);
|
||||
|
||||
/* Start read pipeline */
|
||||
ReadDOC(docptr, Mplus_ReadPipeInit);
|
||||
|
@ -651,7 +653,8 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip)
|
|||
void __iomem *docptr = doc->virtadr;
|
||||
int floor = 0;
|
||||
|
||||
if(debug)printk("select chip (%d)\n", chip);
|
||||
if (debug)
|
||||
printk("select chip (%d)\n", chip);
|
||||
|
||||
if (chip == -1) {
|
||||
/* Disable flash internally */
|
||||
|
@ -677,7 +680,8 @@ static void doc200x_select_chip(struct mtd_info *mtd, int chip)
|
|||
void __iomem *docptr = doc->virtadr;
|
||||
int floor = 0;
|
||||
|
||||
if(debug)printk("select chip (%d)\n", chip);
|
||||
if (debug)
|
||||
printk("select chip (%d)\n", chip);
|
||||
|
||||
if (chip == -1)
|
||||
return;
|
||||
|
@ -729,7 +733,8 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd)
|
|||
doc->CDSNControl &= ~CDSN_CTRL_WP;
|
||||
break;
|
||||
}
|
||||
if (debug)printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl);
|
||||
if (debug)
|
||||
printk("hwcontrol(%d): %02x\n", cmd, doc->CDSNControl);
|
||||
WriteDOC(doc->CDSNControl, docptr, CDSNControl);
|
||||
/* 11.4.3 -- 4 NOPs after CSDNControl write */
|
||||
DoC_Delay(doc, 4);
|
||||
|
@ -793,7 +798,8 @@ static void doc2001plus_command (struct mtd_info *mtd, unsigned command, int col
|
|||
WriteDOC(0, docptr, Mplus_WritePipeTerm);
|
||||
WriteDOC(0, docptr, Mplus_WritePipeTerm);
|
||||
/* deassert ALE */
|
||||
if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || command == NAND_CMD_READOOB || command == NAND_CMD_READID)
|
||||
if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 ||
|
||||
command == NAND_CMD_READOOB || command == NAND_CMD_READID)
|
||||
WriteDOC(0, docptr, Mplus_FlashControl);
|
||||
}
|
||||
|
||||
|
@ -853,7 +859,8 @@ static int doc200x_dev_ready(struct mtd_info *mtd)
|
|||
printk("not ready\n");
|
||||
return 0;
|
||||
}
|
||||
if (debug)printk("was ready\n");
|
||||
if (debug)
|
||||
printk("was ready\n");
|
||||
return 1;
|
||||
} else {
|
||||
/* 11.4.2 -- must NOP four times before checking FR/B# */
|
||||
|
@ -865,7 +872,8 @@ static int doc200x_dev_ready(struct mtd_info *mtd)
|
|||
}
|
||||
/* 11.4.2 -- Must NOP twice if it's ready */
|
||||
DoC_Delay(doc, 2);
|
||||
if (debug)printk("was ready\n");
|
||||
if (debug)
|
||||
printk("was ready\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -916,8 +924,7 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode)
|
|||
}
|
||||
|
||||
/* This code is only called on write */
|
||||
static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
|
||||
unsigned char *ecc_code)
|
||||
static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -961,7 +968,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
|
|||
often. It could be optimized away by examining the data in
|
||||
the writebuf routine, and remembering the result. */
|
||||
for (i = 0; i < 512; i++) {
|
||||
if (dat[i] == 0xff) continue;
|
||||
if (dat[i] == 0xff)
|
||||
continue;
|
||||
emptymatch = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -969,7 +977,8 @@ static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
|
|||
/* If emptymatch still =1, we do have an all-0xff data buffer.
|
||||
Return all-0xff ecc value instead of the computed one, so
|
||||
it'll look just like a freshly-erased page. */
|
||||
if (emptymatch) memset(ecc_code, 0xff, 6);
|
||||
if (emptymatch)
|
||||
memset(ecc_code, 0xff, 6);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -1012,7 +1021,8 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
|
|||
all-0xff data and stored ecc block. Check the stored ecc. */
|
||||
if (emptymatch) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (read_ecc[i] == 0xff) continue;
|
||||
if (read_ecc[i] == 0xff)
|
||||
continue;
|
||||
emptymatch = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -1023,7 +1033,8 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
|
|||
often. It could be optimized away by examining the data in
|
||||
the readbuf routine, and remembering the result. */
|
||||
for (i = 0; i < 512; i++) {
|
||||
if (dat[i] == 0xff) continue;
|
||||
if (dat[i] == 0xff)
|
||||
continue;
|
||||
emptymatch = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -1032,7 +1043,8 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_
|
|||
erased block, in which case the ECC will not come out right.
|
||||
We'll suppress the error and tell the caller everything's
|
||||
OK. Because it is. */
|
||||
if (!emptymatch) ret = doc_ecc_decode (rs_decoder, dat, calc_ecc);
|
||||
if (!emptymatch)
|
||||
ret = doc_ecc_decode(rs_decoder, dat, calc_ecc);
|
||||
if (ret > 0)
|
||||
printk(KERN_ERR "doc200x_correct_data corrected %d errors\n", ret);
|
||||
}
|
||||
|
@ -1072,8 +1084,7 @@ static struct nand_oobinfo doc200x_oobinfo = {
|
|||
either "ANAND" or "BNAND". If findmirror=1, also look for the mirror media
|
||||
header. The page #s of the found media headers are placed in mh0_page and
|
||||
mh1_page in the DOC private structure. */
|
||||
static int __init find_media_headers(struct mtd_info *mtd, u_char *buf,
|
||||
const char *id, int findmirror)
|
||||
static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const char *id, int findmirror)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -1083,16 +1094,18 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf,
|
|||
|
||||
for (offs = 0; offs < mtd->size; offs += mtd->erasesize) {
|
||||
ret = mtd->read(mtd, offs, mtd->oobblock, &retlen, buf);
|
||||
if (retlen != mtd->oobblock) continue;
|
||||
if (retlen != mtd->oobblock)
|
||||
continue;
|
||||
if (ret) {
|
||||
printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n",
|
||||
offs);
|
||||
printk(KERN_WARNING "ECC error scanning DOC at 0x%x\n", offs);
|
||||
}
|
||||
if (memcmp(buf, id, 6)) continue;
|
||||
if (memcmp(buf, id, 6))
|
||||
continue;
|
||||
printk(KERN_INFO "Found DiskOnChip %s Media Header at 0x%x\n", id, offs);
|
||||
if (doc->mh0_page == -1) {
|
||||
doc->mh0_page = offs >> this->page_shift;
|
||||
if (!findmirror) return 1;
|
||||
if (!findmirror)
|
||||
return 1;
|
||||
continue;
|
||||
}
|
||||
doc->mh1_page = offs >> this->page_shift;
|
||||
|
@ -1114,8 +1127,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf,
|
|||
return 1;
|
||||
}
|
||||
|
||||
static inline int __init nftl_partscan(struct mtd_info *mtd,
|
||||
struct mtd_partition *parts)
|
||||
static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -1132,7 +1144,8 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
|
|||
printk(KERN_ERR "DiskOnChip mediaheader kmalloc failed!\n");
|
||||
return 0;
|
||||
}
|
||||
if (!(numheaders=find_media_headers(mtd, buf, "ANAND", 1))) goto out;
|
||||
if (!(numheaders = find_media_headers(mtd, buf, "ANAND", 1)))
|
||||
goto out;
|
||||
mh = (struct NFTLMediaHeader *)buf;
|
||||
|
||||
mh->NumEraseUnits = le16_to_cpu(mh->NumEraseUnits);
|
||||
|
@ -1217,8 +1230,7 @@ out:
|
|||
}
|
||||
|
||||
/* This is a stripped-down copy of the code in inftlmount.c */
|
||||
static inline int __init inftl_partscan(struct mtd_info *mtd,
|
||||
struct mtd_partition *parts)
|
||||
static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
struct doc_priv *doc = this->priv;
|
||||
|
@ -1241,7 +1253,8 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!find_media_headers(mtd, buf, "BNAND", 0)) goto out;
|
||||
if (!find_media_headers(mtd, buf, "BNAND", 0))
|
||||
goto out;
|
||||
doc->mh1_page = doc->mh0_page + (4096 >> this->page_shift);
|
||||
mh = (struct INFTLMediaHeader *)buf;
|
||||
|
||||
|
@ -1319,8 +1332,10 @@ static inline int __init inftl_partscan(struct mtd_info *mtd,
|
|||
parts[numparts].offset = ip->firstUnit << vshift;
|
||||
parts[numparts].size = (1 + ip->lastUnit - ip->firstUnit) << vshift;
|
||||
numparts++;
|
||||
if (ip->lastUnit > lastvunit) lastvunit = ip->lastUnit;
|
||||
if (ip->flags & INFTL_LAST) break;
|
||||
if (ip->lastUnit > lastvunit)
|
||||
lastvunit = ip->lastUnit;
|
||||
if (ip->flags & INFTL_LAST)
|
||||
break;
|
||||
}
|
||||
lastvunit++;
|
||||
if ((lastvunit << vshift) < end) {
|
||||
|
@ -1346,7 +1361,8 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd)
|
|||
/* On NFTL, we have to find the media headers before we can read the
|
||||
BBTs, since they're stored in the media header eraseblocks. */
|
||||
numparts = nftl_partscan(mtd, parts);
|
||||
if (!numparts) return -EIO;
|
||||
if (!numparts)
|
||||
return -EIO;
|
||||
this->bbt_td->options = NAND_BBT_ABSPAGE | NAND_BBT_8BIT |
|
||||
NAND_BBT_SAVECONTENT | NAND_BBT_WRITE |
|
||||
NAND_BBT_VERSION;
|
||||
|
@ -1393,8 +1409,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd)
|
|||
this->bbt_td->pages[0] = 2;
|
||||
this->bbt_md = NULL;
|
||||
} else {
|
||||
this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT |
|
||||
NAND_BBT_VERSION;
|
||||
this->bbt_td->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION;
|
||||
if (inftl_bbt_write)
|
||||
this->bbt_td->options |= NAND_BBT_WRITE;
|
||||
this->bbt_td->offs = 8;
|
||||
|
@ -1404,8 +1419,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd)
|
|||
this->bbt_td->reserved_block_code = 0x01;
|
||||
this->bbt_td->pattern = "MSYS_BBT";
|
||||
|
||||
this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT |
|
||||
NAND_BBT_VERSION;
|
||||
this->bbt_md->options = NAND_BBT_LASTBLOCK | NAND_BBT_8BIT | NAND_BBT_VERSION;
|
||||
if (inftl_bbt_write)
|
||||
this->bbt_md->options |= NAND_BBT_WRITE;
|
||||
this->bbt_md->offs = 8;
|
||||
|
@ -1425,7 +1439,8 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd)
|
|||
/* At least for now, require the INFTL Media Header. We could probably
|
||||
do without it for non-INFTL use, since all it gives us is
|
||||
autopartitioning, but I want to give it more thought. */
|
||||
if (!numparts) return -EIO;
|
||||
if (!numparts)
|
||||
return -EIO;
|
||||
add_mtd_device(mtd);
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
if (!no_autopart)
|
||||
|
@ -1535,16 +1550,12 @@ static int __init doc_probe(unsigned long physadr)
|
|||
save_control = ReadDOC(virtadr, DOCControl);
|
||||
|
||||
/* Reset the DiskOnChip ASIC */
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
|
||||
virtadr, DOCControl);
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET,
|
||||
virtadr, DOCControl);
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl);
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_RESET, virtadr, DOCControl);
|
||||
|
||||
/* Enable the DiskOnChip ASIC */
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
|
||||
virtadr, DOCControl);
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL,
|
||||
virtadr, DOCControl);
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl);
|
||||
WriteDOC(DOC_MODE_CLR_ERR | DOC_MODE_MDWREN | DOC_MODE_NORMAL, virtadr, DOCControl);
|
||||
|
||||
ChipID = ReadDOC(virtadr, ChipID);
|
||||
|
||||
|
@ -1564,15 +1575,13 @@ static int __init doc_probe(unsigned long physadr)
|
|||
ReadDOC(virtadr, Mplus_Power);
|
||||
|
||||
/* Reset the Millennium Plus ASIC */
|
||||
tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT |
|
||||
DOC_MODE_BDECT;
|
||||
tmp = DOC_MODE_RESET | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT;
|
||||
WriteDOC(tmp, virtadr, Mplus_DOCControl);
|
||||
WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm);
|
||||
|
||||
mdelay(1);
|
||||
/* Enable the Millennium Plus ASIC */
|
||||
tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT |
|
||||
DOC_MODE_BDECT;
|
||||
tmp = DOC_MODE_NORMAL | DOC_MODE_MDWREN | DOC_MODE_RST_LAT | DOC_MODE_BDECT;
|
||||
WriteDOC(tmp, virtadr, Mplus_DOCControl);
|
||||
WriteDOC(~tmp, virtadr, Mplus_CtrlConfirm);
|
||||
mdelay(1);
|
||||
|
@ -1642,9 +1651,7 @@ static int __init doc_probe(unsigned long physadr)
|
|||
printk(KERN_NOTICE "DiskOnChip found at 0x%lx\n", physadr);
|
||||
|
||||
len = sizeof(struct mtd_info) +
|
||||
sizeof(struct nand_chip) +
|
||||
sizeof(struct doc_priv) +
|
||||
(2 * sizeof(struct nand_bbt_descr));
|
||||
sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr));
|
||||
mtd = kmalloc(len, GFP_KERNEL);
|
||||
if (!mtd) {
|
||||
printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len);
|
||||
|
|
|
@ -66,11 +66,11 @@ static struct mtd_partition partition_info[] = {
|
|||
.offset = 0,
|
||||
.size = 8 * 1024 * 1024}
|
||||
};
|
||||
|
||||
#define NUM_PARTITIONS 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* hardware specific access to control-lines
|
||||
*/
|
||||
|
@ -108,6 +108,7 @@ static int ep7312_device_ready(struct mtd_info *mtd)
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
const char *part_probes[] = { "cmdlinepart", NULL };
|
||||
#endif
|
||||
|
@ -124,9 +125,7 @@ static int __init ep7312_init (void)
|
|||
void __iomem *ep7312_fio_base;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
ep7312_mtd = kmalloc(sizeof(struct mtd_info) +
|
||||
sizeof(struct nand_chip),
|
||||
GFP_KERNEL);
|
||||
ep7312_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!ep7312_mtd) {
|
||||
printk("Unable to allocate EDB7312 NAND MTD device structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -144,8 +143,8 @@ static int __init ep7312_init (void)
|
|||
this = (struct nand_chip *)(&ep7312_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) ep7312_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(ep7312_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
ep7312_mtd->priv = this;
|
||||
|
@ -170,11 +169,9 @@ static int __init ep7312_init (void)
|
|||
kfree(ep7312_mtd);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
ep7312_mtd->name = "edb7312-nand";
|
||||
mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes,
|
||||
&mtd_parts, 0);
|
||||
mtd_parts_nb = parse_mtd_partitions(ep7312_mtd, part_probes, &mtd_parts, 0);
|
||||
if (mtd_parts_nb > 0)
|
||||
part_type = "command line";
|
||||
else
|
||||
|
@ -193,6 +190,7 @@ static int __init ep7312_init (void)
|
|||
/* Return happy */
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(ep7312_init);
|
||||
|
||||
/*
|
||||
|
@ -211,6 +209,7 @@ static void __exit ep7312_cleanup (void)
|
|||
/* Free the MTD device structure */
|
||||
kfree(ep7312_mtd);
|
||||
}
|
||||
|
||||
module_exit(ep7312_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -49,11 +49,11 @@ static struct mtd_partition partition_info[] = {
|
|||
offset:0,
|
||||
size:16 * 1024 * 1024}
|
||||
};
|
||||
|
||||
#define NUM_PARTITIONS 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* hardware specific access to control-lines
|
||||
*/
|
||||
|
@ -119,9 +119,7 @@ static int __init h1910_init (void)
|
|||
}
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) +
|
||||
sizeof(struct nand_chip),
|
||||
GFP_KERNEL);
|
||||
h1910_nand_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!h1910_nand_mtd) {
|
||||
printk("Unable to allocate h1910 NAND MTD device structure.\n");
|
||||
iounmap((void *)nandaddr);
|
||||
|
@ -132,8 +130,8 @@ static int __init h1910_init (void)
|
|||
this = (struct nand_chip *)(&h1910_nand_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) h1910_nand_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(h1910_nand_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
h1910_nand_mtd->priv = this;
|
||||
|
@ -160,17 +158,14 @@ static int __init h1910_init (void)
|
|||
iounmap((void *)nandaddr);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_CMDLINE_PARTS
|
||||
mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts,
|
||||
"h1910-nand");
|
||||
mtd_parts_nb = parse_cmdline_partitions(h1910_nand_mtd, &mtd_parts, "h1910-nand");
|
||||
if (mtd_parts_nb > 0)
|
||||
part_type = "command line";
|
||||
else
|
||||
mtd_parts_nb = 0;
|
||||
#endif
|
||||
if (mtd_parts_nb == 0)
|
||||
{
|
||||
if (mtd_parts_nb == 0) {
|
||||
mtd_parts = partition_info;
|
||||
mtd_parts_nb = NUM_PARTITIONS;
|
||||
part_type = "static";
|
||||
|
@ -183,6 +178,7 @@ static int __init h1910_init (void)
|
|||
/* Return happy */
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(h1910_init);
|
||||
|
||||
/*
|
||||
|
@ -201,6 +197,7 @@ static void __exit h1910_cleanup (void)
|
|||
/* Free the MTD device structure */
|
||||
kfree(h1910_nand_mtd);
|
||||
}
|
||||
|
||||
module_exit(h1910_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -139,10 +139,10 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret
|
|||
static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
|
||||
size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
|
||||
static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf);
|
||||
static int nand_writev (struct mtd_info *mtd, const struct kvec *vecs,
|
||||
unsigned long count, loff_t to, size_t * retlen);
|
||||
static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen);
|
||||
static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
|
||||
unsigned long count, loff_t to, size_t * retlen, u_char *eccbuf, struct nand_oobinfo *oobsel);
|
||||
unsigned long count, loff_t to, size_t *retlen, u_char *eccbuf,
|
||||
struct nand_oobinfo *oobsel);
|
||||
static int nand_erase(struct mtd_info *mtd, struct erase_info *instr);
|
||||
static void nand_sync(struct mtd_info *mtd);
|
||||
|
||||
|
@ -647,7 +647,7 @@ static void nand_command (struct mtd_info *mtd, unsigned command, int column, in
|
|||
* @page_addr: the page address for this command, -1 if none
|
||||
*
|
||||
* Send command to NAND device. This is the version for the new large page devices
|
||||
* We dont have the seperate regions as we have in the small page devices.
|
||||
* We dont have the separate regions as we have in the small page devices.
|
||||
* We must emulate NAND_CMD_READOOB to keep the code compatible.
|
||||
*
|
||||
*/
|
||||
|
@ -661,7 +661,6 @@ static void nand_command_lp (struct mtd_info *mtd, unsigned command, int column,
|
|||
command = NAND_CMD_READ0;
|
||||
}
|
||||
|
||||
|
||||
/* Begin command latch cycle */
|
||||
this->hwcontrol(mtd, NAND_CTL_SETCLE);
|
||||
/* Write out the command to the device. */
|
||||
|
@ -1021,9 +1020,8 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
|
|||
for (i = 0; i < ecccnt; i++) {
|
||||
int idx = oobsel->eccpos[i];
|
||||
if (oobdata[idx] != oob_buf[oobofs + idx]) {
|
||||
DEBUG (MTD_DEBUG_LEVEL0,
|
||||
"%s: Failed ECC write "
|
||||
"verify, page 0x%08x, " "%6i bytes were succesful\n", __FUNCTION__, page, i);
|
||||
DEBUG(MTD_DEBUG_LEVEL0, "%s: Failed ECC write verify, page 0x%08x, %6i bytes were succesful\n",
|
||||
__FUNCTION__, page, i);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -1049,7 +1047,6 @@ static int nand_verify_pages (struct mtd_info *mtd, struct nand_chip *this, int
|
|||
if (!numpages)
|
||||
return 0;
|
||||
|
||||
|
||||
/* Check, if the chip supports auto page increment */
|
||||
if (!NAND_CANAUTOINCR(this))
|
||||
this->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
|
||||
|
@ -1080,7 +1077,6 @@ static int nand_read (struct mtd_info *mtd, loff_t from, size_t len, size_t * re
|
|||
return nand_do_read_ecc(mtd, from, len, retlen, buf, NULL, &mtd->oobinfo, 0xff);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_read_ecc - [MTD Interface] MTD compability function for nand_do_read_ecc
|
||||
* @mtd: MTD device structure
|
||||
|
@ -1102,7 +1098,6 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
|
|||
return nand_do_read_ecc(mtd, from, len, retlen, buf, oob_buf, oobsel, 0xff);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_do_read_ecc - [MTD Interface] Read data with ECC
|
||||
* @mtd: MTD device structure
|
||||
|
@ -1120,8 +1115,7 @@ static int nand_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
|
|||
* NAND read with ECC
|
||||
*/
|
||||
int nand_do_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
|
||||
size_t * retlen, u_char * buf, u_char * oob_buf,
|
||||
struct nand_oobinfo *oobsel, int flags)
|
||||
size_t *retlen, u_char *buf, u_char *oob_buf, struct nand_oobinfo *oobsel, int flags)
|
||||
{
|
||||
|
||||
int i, j, col, realpage, page, end, ecc, chipnr, sndcmd = 1;
|
||||
|
@ -1137,7 +1131,6 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
|
|||
int compareecc = 1;
|
||||
int oobreadlen;
|
||||
|
||||
|
||||
DEBUG(MTD_DEBUG_LEVEL3, "nand_read_ecc: from = 0x%08x, len = %i\n", (unsigned int)from, (int)len);
|
||||
|
||||
/* Do not allow reads past end of device */
|
||||
|
@ -1219,10 +1212,12 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
|
|||
eccsteps = this->eccsteps;
|
||||
|
||||
switch (eccmode) {
|
||||
case NAND_ECC_NONE: { /* No ECC, Read in a page */
|
||||
case NAND_ECC_NONE:{
|
||||
/* No ECC, Read in a page */
|
||||
static unsigned long lastwhinge = 0;
|
||||
if ((lastwhinge / HZ) != (jiffies / HZ)) {
|
||||
printk (KERN_WARNING "Reading data from NAND FLASH without ECC is not recommended\n");
|
||||
printk(KERN_WARNING
|
||||
"Reading data from NAND FLASH without ECC is not recommended\n");
|
||||
lastwhinge = jiffies;
|
||||
}
|
||||
this->read_buf(mtd, data_poi, end);
|
||||
|
@ -1274,7 +1269,7 @@ int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
|
|||
for (j = 0; j < oobsel->eccbytes; j++)
|
||||
ecc_code[j] = oob_data[oob_config[j]];
|
||||
|
||||
/* correct data, if neccecary */
|
||||
/* correct data, if necessary */
|
||||
for (i = 0, j = 0, datidx = 0; i < this->eccsteps; i++, datidx += ecc) {
|
||||
ecc_status = this->correct_data(mtd, &data_poi[datidx], &ecc_code[j], &ecc_calc[j]);
|
||||
|
||||
|
@ -1526,7 +1521,6 @@ int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer
|
||||
* @mtd: MTD device structure
|
||||
|
@ -1562,8 +1556,7 @@ static u_char * nand_prepare_oobbuf (struct mtd_info *mtd, u_char *fsbuf, struct
|
|||
|
||||
/* Check, if the buffer must be filled with ff again */
|
||||
if (this->oobdirty) {
|
||||
memset (this->oob_buf, 0xff,
|
||||
mtd->oobsize << (this->phys_erase_shift - this->page_shift));
|
||||
memset(this->oob_buf, 0xff, mtd->oobsize << (this->phys_erase_shift - this->page_shift));
|
||||
this->oobdirty = 0;
|
||||
}
|
||||
|
||||
|
@ -1618,7 +1611,8 @@ static int nand_write (struct mtd_info *mtd, loff_t to, size_t len, size_t * ret
|
|||
* NAND write with ECC
|
||||
*/
|
||||
static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
|
||||
size_t * retlen, const u_char * buf, u_char * eccbuf, struct nand_oobinfo *oobsel)
|
||||
size_t *retlen, const u_char *buf, u_char *eccbuf,
|
||||
struct nand_oobinfo *oobsel)
|
||||
{
|
||||
int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr;
|
||||
int autoplace = 0, numpages, totalpages;
|
||||
|
@ -1713,8 +1707,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
|
|||
if (!(page & (ppblock - 1))) {
|
||||
int ofs;
|
||||
this->data_poi = bufstart;
|
||||
ret = nand_verify_pages (mtd, this, startpage,
|
||||
page - startpage,
|
||||
ret = nand_verify_pages(mtd, this, startpage, page - startpage,
|
||||
oobbuf, oobsel, chipnr, (eccbuf != NULL));
|
||||
if (ret) {
|
||||
DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret);
|
||||
|
@ -1729,8 +1722,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
|
|||
numpages = min(totalpages, ppblock);
|
||||
page &= this->pagemask;
|
||||
startpage = page;
|
||||
oobbuf = nand_prepare_oobbuf (mtd, eccbuf, oobsel,
|
||||
autoplace, numpages);
|
||||
oobbuf = nand_prepare_oobbuf(mtd, eccbuf, oobsel, autoplace, numpages);
|
||||
oob = 0;
|
||||
/* Check, if we cross a chip boundary */
|
||||
if (!page) {
|
||||
|
@ -1743,8 +1735,7 @@ static int nand_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
|
|||
/* Verify the remaining pages */
|
||||
cmp:
|
||||
this->data_poi = bufstart;
|
||||
ret = nand_verify_pages (mtd, this, startpage, totalpages,
|
||||
oobbuf, oobsel, chipnr, (eccbuf != NULL));
|
||||
ret = nand_verify_pages(mtd, this, startpage, totalpages, oobbuf, oobsel, chipnr, (eccbuf != NULL));
|
||||
if (!ret)
|
||||
*retlen = written;
|
||||
else
|
||||
|
@ -1757,7 +1748,6 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_write_oob - [MTD Interface] NAND write out-of-band
|
||||
* @mtd: MTD device structure
|
||||
|
@ -1859,7 +1849,6 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_writev - [MTD Interface] compabilty function for nand_writev_ecc
|
||||
* @mtd: MTD device structure
|
||||
|
@ -1905,8 +1894,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
|
|||
for (i = 0; i < count; i++)
|
||||
total_len += (int)vecs[i].iov_len;
|
||||
|
||||
DEBUG (MTD_DEBUG_LEVEL3,
|
||||
"nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int) to, (unsigned int) total_len, count);
|
||||
DEBUG(MTD_DEBUG_LEVEL3, "nand_writev: to = 0x%08x, len = %i, count = %ld\n", (unsigned int)to, (unsigned int)total_len, count);
|
||||
|
||||
/* Do not allow write past end of page */
|
||||
if ((to + total_len) > mtd->size) {
|
||||
|
@ -2009,8 +1997,7 @@ static int nand_writev_ecc (struct mtd_info *mtd, const struct kvec *vecs, unsig
|
|||
bufstart = this->data_poi;
|
||||
numpages = 1;
|
||||
oobbuf = nand_prepare_oobbuf(mtd, NULL, oobsel, autoplace, numpages);
|
||||
ret = nand_write_page (mtd, this, page & this->pagemask,
|
||||
oobbuf, oobsel, 0);
|
||||
ret = nand_write_page(mtd, this, page & this->pagemask, oobbuf, oobsel, 0);
|
||||
if (ret)
|
||||
goto out;
|
||||
page++;
|
||||
|
@ -2107,8 +2094,7 @@ int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbb
|
|||
/* It is used to see if the current page is in the same */
|
||||
/* 256 block group and the same bank as the bbt. */
|
||||
|
||||
DEBUG (MTD_DEBUG_LEVEL3,
|
||||
"nand_erase: start = 0x%08x, len = %i\n", (unsigned int) instr->addr, (unsigned int) instr->len);
|
||||
DEBUG(MTD_DEBUG_LEVEL3, "nand_erase: start = 0x%08x, len = %i\n", (unsigned int)instr->addr, (unsigned int)instr->len);
|
||||
|
||||
/* Start address must align on block boundary */
|
||||
if (instr->addr & ((1 << this->phys_erase_shift) - 1)) {
|
||||
|
@ -2265,7 +2251,6 @@ static void nand_sync (struct mtd_info *mtd)
|
|||
nand_release_device(mtd);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_block_isbad - [MTD Interface] Check whether the block at the given offset is bad
|
||||
* @mtd: MTD device structure
|
||||
|
@ -2322,12 +2307,10 @@ static void nand_resume(struct mtd_info *mtd)
|
|||
if (this->state == FL_PM_SUSPENDED)
|
||||
nand_release_device(mtd);
|
||||
else
|
||||
printk(KERN_ERR "resume() called for the chip which is not "
|
||||
"in suspended state\n");
|
||||
printk(KERN_ERR "resume() called for the chip which is not in suspended state\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_scan - [NAND Interface] Scan for the NAND device
|
||||
* @mtd: MTD device structure
|
||||
|
@ -2399,7 +2382,8 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
|
|||
if (nand_dev_id != nand_flash_ids[i].id)
|
||||
continue;
|
||||
|
||||
if (!mtd->name) mtd->name = nand_flash_ids[i].name;
|
||||
if (!mtd->name)
|
||||
mtd->name = nand_flash_ids[i].name;
|
||||
this->chipsize = nand_flash_ids[i].chipsize << 20;
|
||||
|
||||
/* New devices have all the information in additional id bytes */
|
||||
|
@ -2444,8 +2428,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
|
|||
nand_manuf_ids[maf_id].name, mtd->name);
|
||||
printk(KERN_WARNING
|
||||
"NAND bus width %d instead %d bit\n",
|
||||
(this->options & NAND_BUSWIDTH_16) ? 16 : 8,
|
||||
busw ? 16 : 8);
|
||||
(this->options & NAND_BUSWIDTH_16) ? 16 : 8, busw ? 16 : 8);
|
||||
this->select_chip(mtd, -1);
|
||||
return 1;
|
||||
}
|
||||
|
@ -2456,13 +2439,12 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
|
|||
this->chip_shift = ffs(this->chipsize) - 1;
|
||||
|
||||
/* Set the bad block position */
|
||||
this->badblockpos = mtd->oobblock > 512 ?
|
||||
NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
|
||||
this->badblockpos = mtd->oobblock > 512 ? NAND_LARGE_BADBLOCK_POS : NAND_SMALL_BADBLOCK_POS;
|
||||
|
||||
/* Get chip options, preserve non chip based options */
|
||||
this->options &= ~NAND_CHIPOPTIONS_MSK;
|
||||
this->options |= nand_flash_ids[i].options & NAND_CHIPOPTIONS_MSK;
|
||||
/* Set this as a default. Board drivers can override it, if neccecary */
|
||||
/* Set this as a default. Board drivers can override it, if necessary */
|
||||
this->options |= NAND_NO_AUTOINCR;
|
||||
/* Check if this is a not a samsung device. Do not clear the options
|
||||
* for chips which are not having an extended id.
|
||||
|
@ -2506,7 +2488,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
|
|||
if (i > 1)
|
||||
printk(KERN_INFO "%d NAND chips detected\n", i);
|
||||
|
||||
/* Allocate buffers, if neccecary */
|
||||
/* Allocate buffers, if necessary */
|
||||
if (!this->oob_buf) {
|
||||
size_t len;
|
||||
len = mtd->oobsize << (this->phys_erase_shift - this->page_shift);
|
||||
|
@ -2555,8 +2537,7 @@ int nand_scan (struct mtd_info *mtd, int maxchips)
|
|||
this->autooob = &nand_oob_64;
|
||||
break;
|
||||
default:
|
||||
printk (KERN_WARNING "No oob scheme defined for oobsize %d\n",
|
||||
mtd->oobsize);
|
||||
printk(KERN_WARNING "No oob scheme defined for oobsize %d\n", mtd->oobsize);
|
||||
BUG();
|
||||
}
|
||||
}
|
||||
|
@ -2733,7 +2714,6 @@ void nand_release (struct mtd_info *mtd)
|
|||
EXPORT_SYMBOL_GPL(nand_scan);
|
||||
EXPORT_SYMBOL_GPL(nand_release);
|
||||
|
||||
|
||||
static int __init nand_base_init(void)
|
||||
{
|
||||
led_trigger_register_simple("nand-disk", &nand_led_trigger);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
*
|
||||
* Following assumptions are made:
|
||||
* - bbts start at a page boundary, if autolocated on a block boundary
|
||||
* - the space neccecary for a bbt in FLASH does not exceed a block boundary
|
||||
* - the space necessary for a bbt in FLASH does not exceed a block boundary
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -172,8 +172,7 @@ static int read_bbt (struct mtd_info *mtd, uint8_t *buf, int page, int num,
|
|||
uint8_t tmp = (dat >> j) & msk;
|
||||
if (tmp == msk)
|
||||
continue;
|
||||
if (reserved_block_code &&
|
||||
(tmp == reserved_block_code)) {
|
||||
if (reserved_block_code && (tmp == reserved_block_code)) {
|
||||
printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n",
|
||||
((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
|
||||
this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06);
|
||||
|
@ -242,8 +241,7 @@ static int read_abs_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_des
|
|||
* We assume that the bbt bits are in consecutive order.
|
||||
*
|
||||
*/
|
||||
static int read_abs_bbts (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td,
|
||||
struct nand_bbt_descr *md)
|
||||
static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
|
||||
|
@ -336,8 +334,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
|
|||
|
||||
/* Read the full oob until read_oob is fixed to
|
||||
* handle single byte reads for 16 bit buswidth */
|
||||
ret = mtd->read_oob(mtd, from + j * mtd->oobblock,
|
||||
mtd->oobsize, &retlen, buf);
|
||||
ret = mtd->read_oob(mtd, from + j * mtd->oobblock, mtd->oobsize, &retlen, buf);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -374,7 +371,7 @@ static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
|
|||
* block.
|
||||
* If the option NAND_BBT_PERCHIP is given, each chip is searched
|
||||
* for a bbt, which contains the bad block information of this chip.
|
||||
* This is neccecary to provide support for certain DOC devices.
|
||||
* This is necessary to provide support for certain DOC devices.
|
||||
*
|
||||
* The bbt ident pattern resides in the oob area of the first page
|
||||
* in a block.
|
||||
|
@ -433,7 +430,8 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
|
|||
if (td->pages[i] == -1)
|
||||
printk(KERN_WARNING "Bad block table not found for chip %d\n", i);
|
||||
else
|
||||
printk (KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i], td->version[i]);
|
||||
printk(KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i],
|
||||
td->version[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -447,8 +445,7 @@ static int search_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
|
|||
*
|
||||
* Search and read the bad block table(s)
|
||||
*/
|
||||
static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf,
|
||||
struct nand_bbt_descr *td, struct nand_bbt_descr *md)
|
||||
static int search_read_bbts(struct mtd_info *mtd, uint8_t * buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md)
|
||||
{
|
||||
/* Search the primary table */
|
||||
search_bbt(mtd, buf, td);
|
||||
|
@ -461,7 +458,6 @@ static int search_read_bbts (struct mtd_info *mtd, uint8_t *buf,
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* write_bbt - [GENERIC] (Re)write the bad block table
|
||||
*
|
||||
|
@ -569,7 +565,8 @@ write:
|
|||
res = mtd->read_ecc(mtd, to, len, &retlen, buf, &buf[len], &oobinfo);
|
||||
if (res < 0) {
|
||||
if (retlen != len) {
|
||||
printk (KERN_INFO "nand_bbt: Error reading block for writing the bad block table\n");
|
||||
printk(KERN_INFO
|
||||
"nand_bbt: Error reading block for writing the bad block table\n");
|
||||
return res;
|
||||
}
|
||||
printk(KERN_WARNING "nand_bbt: ECC error while reading block for writing bad block table\n");
|
||||
|
@ -653,15 +650,15 @@ static inline int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *
|
|||
}
|
||||
|
||||
/**
|
||||
* check_create - [GENERIC] create and write bbt(s) if neccecary
|
||||
* check_create - [GENERIC] create and write bbt(s) if necessary
|
||||
* @mtd: MTD device structure
|
||||
* @buf: temporary buffer
|
||||
* @bd: descriptor for the good/bad block search pattern
|
||||
*
|
||||
* The function checks the results of the previous call to read_bbt
|
||||
* and creates / updates the bbt(s) if neccecary
|
||||
* Creation is neccecary if no bbt was found for the chip/device
|
||||
* Update is neccecary if one of the tables is missing or the
|
||||
* and creates / updates the bbt(s) if necessary
|
||||
* Creation is necessary if no bbt was found for the chip/device
|
||||
* Update is necessary if one of the tables is missing or the
|
||||
* version nr. of one table is less than the other
|
||||
*/
|
||||
static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd)
|
||||
|
@ -795,7 +792,8 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td)
|
|||
for (i = 0; i < chips; i++) {
|
||||
if ((td->options & NAND_BBT_ABSPAGE) ||
|
||||
!(td->options & NAND_BBT_WRITE)) {
|
||||
if (td->pages[i] == -1) continue;
|
||||
if (td->pages[i] == -1)
|
||||
continue;
|
||||
block = td->pages[i] >> (this->bbt_erase_shift - this->page_shift);
|
||||
block <<= 1;
|
||||
oldval = this->bbt[(block >> 3)];
|
||||
|
@ -815,7 +813,8 @@ static void mark_bbt_region (struct mtd_info *mtd, struct nand_bbt_descr *td)
|
|||
oldval = this->bbt[(block >> 3)];
|
||||
newval = oldval | (0x2 << (block & 0x06));
|
||||
this->bbt[(block >> 3)] = newval;
|
||||
if (oldval != newval) update = 1;
|
||||
if (oldval != newval)
|
||||
update = 1;
|
||||
block += 2;
|
||||
}
|
||||
/* If we want reserved blocks to be recorded to flash, and some
|
||||
|
@ -901,7 +900,6 @@ int nand_scan_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* nand_update_bbt - [NAND Interface] update bad block table(s)
|
||||
* @mtd: MTD device structure
|
||||
|
@ -1057,7 +1055,6 @@ int nand_default_bbt (struct mtd_info *mtd)
|
|||
return nand_scan_bbt(mtd, &agand_flashbased);
|
||||
}
|
||||
|
||||
|
||||
/* Is a flash based bad block table requested ? */
|
||||
if (this->options & NAND_USE_FLASH_BBT) {
|
||||
/* Use the default pattern descriptors */
|
||||
|
@ -1066,8 +1063,7 @@ int nand_default_bbt (struct mtd_info *mtd)
|
|||
this->bbt_md = &bbt_mirror_descr;
|
||||
}
|
||||
if (!this->badblock_pattern) {
|
||||
this->badblock_pattern = (mtd->oobblock > 512) ?
|
||||
&largepage_flashbased : &smallpage_flashbased;
|
||||
this->badblock_pattern = (mtd->oobblock > 512) ? &largepage_flashbased : &smallpage_flashbased;
|
||||
}
|
||||
} else {
|
||||
this->bbt_td = NULL;
|
||||
|
@ -1101,9 +1097,12 @@ int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt)
|
|||
(unsigned int)offs, block >> 1, res);
|
||||
|
||||
switch ((int)res) {
|
||||
case 0x00: return 0;
|
||||
case 0x01: return 1;
|
||||
case 0x02: return allowbbt ? 0 : 1;
|
||||
case 0x00:
|
||||
return 0;
|
||||
case 0x01:
|
||||
return 1;
|
||||
case 0x02:
|
||||
return allowbbt ? 0 : 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ static const u_char nand_ecc_precalc_table[] = {
|
|||
0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* nand_trans_result - [GENERIC] create non-inverted ECC
|
||||
* @reg2: line parity reg 2
|
||||
|
@ -71,8 +70,7 @@ static const u_char nand_ecc_precalc_table[] = {
|
|||
*
|
||||
* Creates non-inverted ECC code from line parity
|
||||
*/
|
||||
static void nand_trans_result(u_char reg2, u_char reg3,
|
||||
u_char *ecc_code)
|
||||
static void nand_trans_result(u_char reg2, u_char reg3, u_char *ecc_code)
|
||||
{
|
||||
u_char a, b, i, tmp1, tmp2;
|
||||
|
||||
|
@ -168,8 +166,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha
|
|||
if ((d1 | d2 | d3) == 0) {
|
||||
/* No errors */
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
a = (d1 ^ (d1 >> 1)) & 0x55;
|
||||
b = (d2 ^ (d2 >> 1)) & 0x55;
|
||||
c = (d3 ^ (d3 >> 1)) & 0x54;
|
||||
|
@ -206,8 +203,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha
|
|||
a ^= (b << bit);
|
||||
dat[add] = a;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i = 0;
|
||||
while (d1) {
|
||||
if (d1 & 0x01)
|
||||
|
@ -230,8 +226,7 @@ int nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_cha
|
|||
read_ecc[1] = calc_ecc[1];
|
||||
read_ecc[2] = calc_ecc[2];
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Uncorrectable Error */
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -134,4 +134,4 @@ EXPORT_SYMBOL (nand_flash_ids);
|
|||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Thomas Gleixner <tglx@linutronix.de>");
|
||||
MODULE_DESCRIPTION ("Nand device & manufacturer ID's");
|
||||
MODULE_DESCRIPTION("Nand device & manufacturer IDs");
|
||||
|
|
|
@ -80,31 +80,31 @@ __setup("ppchameleonevb_fio_pbase=",ppchameleonevb_fio_pbase);
|
|||
* Define static partitions for flash devices
|
||||
*/
|
||||
static struct mtd_partition partition_info_hi[] = {
|
||||
{ name: "PPChameleon HI Nand Flash",
|
||||
offset: 0,
|
||||
size: 128*1024*1024 }
|
||||
{ .name = "PPChameleon HI Nand Flash",
|
||||
offset = 0,
|
||||
.size = 128 * 1024 * 1024
|
||||
}
|
||||
};
|
||||
|
||||
static struct mtd_partition partition_info_me[] = {
|
||||
{ name: "PPChameleon ME Nand Flash",
|
||||
offset: 0,
|
||||
size: 32*1024*1024 }
|
||||
{ .name = "PPChameleon ME Nand Flash",
|
||||
.offset = 0,
|
||||
.size = 32 * 1024 * 1024
|
||||
}
|
||||
};
|
||||
|
||||
static struct mtd_partition partition_info_evb[] = {
|
||||
{ name: "PPChameleonEVB Nand Flash",
|
||||
offset: 0,
|
||||
size: 32*1024*1024 }
|
||||
{ .name = "PPChameleonEVB Nand Flash",
|
||||
.offset = 0,
|
||||
.size = 32 * 1024 * 1024
|
||||
}
|
||||
};
|
||||
|
||||
#define NUM_PARTITIONS 1
|
||||
|
||||
extern int parse_cmdline_partitions(struct mtd_info *master,
|
||||
struct mtd_partition **pparts,
|
||||
const char *mtd_id);
|
||||
extern int parse_cmdline_partitions(struct mtd_info *master, struct mtd_partition **pparts, const char *mtd_id);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* hardware specific access to control-lines
|
||||
*/
|
||||
|
@ -194,13 +194,11 @@ static int __init ppchameleonevb_init (void)
|
|||
void __iomem *ppchameleon_fio_base;
|
||||
void __iomem *ppchameleonevb_fio_base;
|
||||
|
||||
|
||||
/*********************************
|
||||
* Processor module NAND (if any) *
|
||||
*********************************/
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
ppchameleon_mtd = kmalloc(sizeof(struct mtd_info) +
|
||||
sizeof(struct nand_chip), GFP_KERNEL);
|
||||
ppchameleon_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!ppchameleon_mtd) {
|
||||
printk("Unable to allocate PPChameleon NAND MTD device structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -218,8 +216,8 @@ static int __init ppchameleonevb_init (void)
|
|||
this = (struct nand_chip *)(&ppchameleon_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) ppchameleon_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(ppchameleon_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
ppchameleon_mtd->priv = this;
|
||||
|
@ -237,14 +235,16 @@ static int __init ppchameleonevb_init (void)
|
|||
/* three-state select */
|
||||
out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xC0FFFFFF);
|
||||
/* enable output driver */
|
||||
out_be32((volatile unsigned*)GPIO0_TCR, in_be32((volatile unsigned*)GPIO0_TCR) | NAND_nCE_GPIO_PIN | NAND_CLE_GPIO_PIN | NAND_ALE_GPIO_PIN);
|
||||
out_be32((volatile unsigned *)GPIO0_TCR,
|
||||
in_be32((volatile unsigned *)GPIO0_TCR) | NAND_nCE_GPIO_PIN | NAND_CLE_GPIO_PIN | NAND_ALE_GPIO_PIN);
|
||||
#ifdef USE_READY_BUSY_PIN
|
||||
/* three-state select */
|
||||
out_be32((volatile unsigned *)GPIO0_TSRH, in_be32((volatile unsigned *)GPIO0_TSRH) & 0xFF3FFFFF);
|
||||
/* high-impedecence */
|
||||
out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) & (~NAND_RB_GPIO_PIN));
|
||||
/* input select */
|
||||
out_be32((volatile unsigned*)GPIO0_ISR1H, (in_be32((volatile unsigned*)GPIO0_ISR1H) & 0xFF3FFFFF) | 0x00400000);
|
||||
out_be32((volatile unsigned *)GPIO0_ISR1H,
|
||||
(in_be32((volatile unsigned *)GPIO0_ISR1H) & 0xFF3FFFFF) | 0x00400000);
|
||||
#endif
|
||||
|
||||
/* insert callbacks */
|
||||
|
@ -264,7 +264,6 @@ static int __init ppchameleonevb_init (void)
|
|||
kfree(ppchameleon_mtd);
|
||||
goto nand_evb_init;
|
||||
}
|
||||
|
||||
#ifndef USE_READY_BUSY_PIN
|
||||
/* Adjust delay if necessary */
|
||||
if (ppchameleon_mtd->size == NAND_SMALL_SIZE)
|
||||
|
@ -279,8 +278,7 @@ static int __init ppchameleonevb_init (void)
|
|||
else
|
||||
mtd_parts_nb = 0;
|
||||
#endif
|
||||
if (mtd_parts_nb == 0)
|
||||
{
|
||||
if (mtd_parts_nb == 0) {
|
||||
if (ppchameleon_mtd->size == NAND_SMALL_SIZE)
|
||||
mtd_parts = partition_info_me;
|
||||
else
|
||||
|
@ -298,8 +296,7 @@ nand_evb_init:
|
|||
* EVB NAND (always present) *
|
||||
****************************/
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) +
|
||||
sizeof(struct nand_chip), GFP_KERNEL);
|
||||
ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!ppchameleonevb_mtd) {
|
||||
printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -317,8 +314,8 @@ nand_evb_init:
|
|||
this = (struct nand_chip *)(&ppchameleonevb_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) ppchameleonevb_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(ppchameleonevb_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
ppchameleonevb_mtd->priv = this;
|
||||
|
@ -346,7 +343,8 @@ nand_evb_init:
|
|||
/* high-impedecence */
|
||||
out_be32((volatile unsigned *)GPIO0_TCR, in_be32((volatile unsigned *)GPIO0_TCR) & (~NAND_EVB_RB_GPIO_PIN));
|
||||
/* input select */
|
||||
out_be32((volatile unsigned*)GPIO0_ISR1L, (in_be32((volatile unsigned*)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001);
|
||||
out_be32((volatile unsigned *)GPIO0_ISR1L,
|
||||
(in_be32((volatile unsigned *)GPIO0_ISR1L) & 0xFFFFFFFC) | 0x00000001);
|
||||
#endif
|
||||
|
||||
/* insert callbacks */
|
||||
|
@ -367,7 +365,6 @@ nand_evb_init:
|
|||
kfree(ppchameleonevb_mtd);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
ppchameleonevb_mtd->name = NAND_EVB_MTD_NAME;
|
||||
mtd_parts_nb = parse_mtd_partitions(ppchameleonevb_mtd, part_probes_evb, &mtd_parts, 0);
|
||||
|
@ -376,8 +373,7 @@ nand_evb_init:
|
|||
else
|
||||
mtd_parts_nb = 0;
|
||||
#endif
|
||||
if (mtd_parts_nb == 0)
|
||||
{
|
||||
if (mtd_parts_nb == 0) {
|
||||
mtd_parts = partition_info_evb;
|
||||
mtd_parts_nb = NUM_PARTITIONS;
|
||||
part_type = "static";
|
||||
|
@ -390,6 +386,7 @@ nand_evb_init:
|
|||
/* Return happy */
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(ppchameleonevb_init);
|
||||
|
||||
/*
|
||||
|
|
|
@ -100,9 +100,9 @@ static const struct mtd_partition partition_info[] = {
|
|||
{
|
||||
.name = "Renesas flash partition 1",
|
||||
.offset = 0,
|
||||
.size = MTDPART_SIZ_FULL
|
||||
},
|
||||
.size = MTDPART_SIZ_FULL},
|
||||
};
|
||||
|
||||
#define NUM_PARTITIONS 1
|
||||
|
||||
/*
|
||||
|
@ -134,8 +134,6 @@ static struct nand_bbt_descr rtc_from4_bbt_mirror_descr = {
|
|||
.pattern = mirror_pattern
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef RTC_FROM4_HWECC
|
||||
|
||||
/* the Reed Solomon control structure */
|
||||
|
@ -198,8 +196,6 @@ static uint8_t revbits[256] = {
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* rtc_from4_hwcontrol - hardware specific access to control-lines
|
||||
* @mtd: MTD device structure
|
||||
|
@ -240,7 +236,6 @@ static void rtc_from4_hwcontrol(struct mtd_info *mtd, int cmd)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rtc_from4_nand_select_chip - hardware specific chip select
|
||||
* @mtd: MTD device structure
|
||||
|
@ -271,7 +266,6 @@ static void rtc_from4_nand_select_chip(struct mtd_info *mtd, int chip)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rtc_from4_nand_device_ready - hardware specific ready/busy check
|
||||
* @mtd: MTD device structure
|
||||
|
@ -290,7 +284,6 @@ static int rtc_from4_nand_device_ready(struct mtd_info *mtd)
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* deplete - code to perform device recovery in case there was a power loss
|
||||
* @mtd: MTD device structure
|
||||
|
@ -323,7 +316,6 @@ static void deplete(struct mtd_info *mtd, int chip)
|
|||
|
||||
}
|
||||
|
||||
|
||||
#ifdef RTC_FROM4_HWECC
|
||||
/*
|
||||
* rtc_from4_enable_hwecc - hardware specific hardware ECC enable function
|
||||
|
@ -340,8 +332,7 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
|
|||
|
||||
switch (mode) {
|
||||
case NAND_ECC_READ:
|
||||
status = RTC_FROM4_RS_ECC_CTL_CLR
|
||||
| RTC_FROM4_RS_ECC_CTL_FD_E;
|
||||
status = RTC_FROM4_RS_ECC_CTL_CLR | RTC_FROM4_RS_ECC_CTL_FD_E;
|
||||
|
||||
*rs_ecc_ctl = status;
|
||||
break;
|
||||
|
@ -353,9 +344,7 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
|
|||
break;
|
||||
|
||||
case NAND_ECC_WRITE:
|
||||
status = RTC_FROM4_RS_ECC_CTL_CLR
|
||||
| RTC_FROM4_RS_ECC_CTL_GEN
|
||||
| RTC_FROM4_RS_ECC_CTL_FD_E;
|
||||
status = RTC_FROM4_RS_ECC_CTL_CLR | RTC_FROM4_RS_ECC_CTL_GEN | RTC_FROM4_RS_ECC_CTL_FD_E;
|
||||
|
||||
*rs_ecc_ctl = status;
|
||||
break;
|
||||
|
@ -367,7 +356,6 @@ static void rtc_from4_enable_hwecc(struct mtd_info *mtd, int mode)
|
|||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rtc_from4_calculate_ecc - hardware specific code to read ECC code
|
||||
* @mtd: MTD device structure
|
||||
|
@ -395,7 +383,6 @@ static void rtc_from4_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_c
|
|||
ecc_code[7] |= 0x0f; /* set the last four bits (not used) */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* rtc_from4_correct_data - hardware specific code to correct data using ECC code
|
||||
* @mtd: MTD device structure
|
||||
|
@ -430,16 +417,11 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha
|
|||
}
|
||||
|
||||
/* convert into 6 10bit syndrome fields */
|
||||
par[5] = rs_decoder->index_of[(((uint16_t)ecc[0] >> 0) & 0x0ff) |
|
||||
(((uint16_t)ecc[1] << 8) & 0x300)];
|
||||
par[4] = rs_decoder->index_of[(((uint16_t)ecc[1] >> 2) & 0x03f) |
|
||||
(((uint16_t)ecc[2] << 6) & 0x3c0)];
|
||||
par[3] = rs_decoder->index_of[(((uint16_t)ecc[2] >> 4) & 0x00f) |
|
||||
(((uint16_t)ecc[3] << 4) & 0x3f0)];
|
||||
par[2] = rs_decoder->index_of[(((uint16_t)ecc[3] >> 6) & 0x003) |
|
||||
(((uint16_t)ecc[4] << 2) & 0x3fc)];
|
||||
par[1] = rs_decoder->index_of[(((uint16_t)ecc[5] >> 0) & 0x0ff) |
|
||||
(((uint16_t)ecc[6] << 8) & 0x300)];
|
||||
par[5] = rs_decoder->index_of[(((uint16_t) ecc[0] >> 0) & 0x0ff) | (((uint16_t) ecc[1] << 8) & 0x300)];
|
||||
par[4] = rs_decoder->index_of[(((uint16_t) ecc[1] >> 2) & 0x03f) | (((uint16_t) ecc[2] << 6) & 0x3c0)];
|
||||
par[3] = rs_decoder->index_of[(((uint16_t) ecc[2] >> 4) & 0x00f) | (((uint16_t) ecc[3] << 4) & 0x3f0)];
|
||||
par[2] = rs_decoder->index_of[(((uint16_t) ecc[3] >> 6) & 0x003) | (((uint16_t) ecc[4] << 2) & 0x3fc)];
|
||||
par[1] = rs_decoder->index_of[(((uint16_t) ecc[5] >> 0) & 0x0ff) | (((uint16_t) ecc[6] << 8) & 0x300)];
|
||||
par[0] = (((uint16_t) ecc[6] >> 2) & 0x03f) | (((uint16_t) ecc[7] << 6) & 0x3c0);
|
||||
|
||||
/* Convert to computable syndrome */
|
||||
|
@ -456,13 +438,11 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha
|
|||
/* Let the library code do its magic. */
|
||||
res = decode_rs8(rs_decoder, (uint8_t *) buf, par, 512, syn, 0, NULL, 0xff, NULL);
|
||||
if (res > 0) {
|
||||
DEBUG (MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: "
|
||||
"ECC corrected %d errors on read\n", res);
|
||||
DEBUG(MTD_DEBUG_LEVEL0, "rtc_from4_correct_data: " "ECC corrected %d errors on read\n", res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* rtc_from4_errstat - perform additional error status checks
|
||||
* @mtd: MTD device structure
|
||||
|
@ -533,7 +513,6 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this, int s
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Main initialization routine
|
||||
*/
|
||||
|
@ -544,8 +523,7 @@ int __init rtc_from4_init (void)
|
|||
int i;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof (struct nand_chip),
|
||||
GFP_KERNEL);
|
||||
rtc_from4_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!rtc_from4_mtd) {
|
||||
printk("Unable to allocate Renesas NAND MTD device structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -555,8 +533,8 @@ int __init rtc_from4_init (void)
|
|||
this = (struct nand_chip *)(&rtc_from4_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) rtc_from4_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(rtc_from4_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
rtc_from4_mtd->priv = this;
|
||||
|
@ -652,8 +630,8 @@ int __init rtc_from4_init (void)
|
|||
/* Return happy */
|
||||
return 0;
|
||||
}
|
||||
module_init(rtc_from4_init);
|
||||
|
||||
module_init(rtc_from4_init);
|
||||
|
||||
/*
|
||||
* Clean up routine
|
||||
|
@ -674,10 +652,10 @@ static void __exit rtc_from4_cleanup (void)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
module_exit(rtc_from4_cleanup);
|
||||
#endif
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("d.marlin <dmarlin@redhat.com");
|
||||
MODULE_DESCRIPTION("Board-specific glue layer for AG-AND flash on Renesas FROM_BOARD4");
|
||||
|
||||
|
|
|
@ -149,8 +149,7 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
|
|||
pr_debug("result %d from %ld, %d\n", result, clk, wanted);
|
||||
|
||||
if (result > max) {
|
||||
printk("%d ns is too big for current clock rate %ld\n",
|
||||
wanted, clk);
|
||||
printk("%d ns is too big for current clock rate %ld\n", wanted, clk);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -164,8 +163,7 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
|
|||
|
||||
/* controller setup */
|
||||
|
||||
static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
|
||||
struct platform_device *pdev)
|
||||
static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, struct platform_device *pdev)
|
||||
{
|
||||
struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
|
||||
unsigned long clkrate = clk_get_rate(info->clk);
|
||||
|
@ -193,9 +191,7 @@ static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
|
|||
}
|
||||
|
||||
printk(KERN_INFO PFX "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns\n",
|
||||
tacls, to_ns(tacls, clkrate),
|
||||
twrph0, to_ns(twrph0, clkrate),
|
||||
twrph1, to_ns(twrph1, clkrate));
|
||||
tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate));
|
||||
|
||||
if (!info->is_s3c2440) {
|
||||
cfg = S3C2410_NFCONF_EN;
|
||||
|
@ -330,22 +326,16 @@ static int s3c2410_nand_devready(struct mtd_info *mtd)
|
|||
return readb(info->regs + S3C2410_NFSTAT) & S3C2410_NFSTAT_BUSY;
|
||||
}
|
||||
|
||||
|
||||
/* ECC handling functions */
|
||||
|
||||
static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
|
||||
u_char *read_ecc, u_char *calc_ecc)
|
||||
static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc)
|
||||
{
|
||||
pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n",
|
||||
mtd, dat, read_ecc, calc_ecc);
|
||||
pr_debug("s3c2410_nand_correct_data(%p,%p,%p,%p)\n", mtd, dat, read_ecc, calc_ecc);
|
||||
|
||||
pr_debug("eccs: read %02x,%02x,%02x vs calc %02x,%02x,%02x\n",
|
||||
read_ecc[0], read_ecc[1], read_ecc[2],
|
||||
calc_ecc[0], calc_ecc[1], calc_ecc[2]);
|
||||
read_ecc[0], read_ecc[1], read_ecc[2], calc_ecc[0], calc_ecc[1], calc_ecc[2]);
|
||||
|
||||
if (read_ecc[0] == calc_ecc[0] &&
|
||||
read_ecc[1] == calc_ecc[1] &&
|
||||
read_ecc[2] == calc_ecc[2])
|
||||
if (read_ecc[0] == calc_ecc[0] && read_ecc[1] == calc_ecc[1] && read_ecc[2] == calc_ecc[2])
|
||||
return 0;
|
||||
|
||||
/* we curently have no method for correcting the error */
|
||||
|
@ -378,8 +368,7 @@ static void s3c2440_nand_enable_hwecc(struct mtd_info *mtd, int mode)
|
|||
writel(ctrl | S3C2440_NFCONT_INITECC, info->regs + S3C2440_NFCONT);
|
||||
}
|
||||
|
||||
static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd,
|
||||
const u_char *dat, u_char *ecc_code)
|
||||
static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
|
||||
{
|
||||
struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
|
||||
|
||||
|
@ -387,15 +376,12 @@ static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd,
|
|||
ecc_code[1] = readb(info->regs + S3C2410_NFECC + 1);
|
||||
ecc_code[2] = readb(info->regs + S3C2410_NFECC + 2);
|
||||
|
||||
pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n",
|
||||
ecc_code[0], ecc_code[1], ecc_code[2]);
|
||||
pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", ecc_code[0], ecc_code[1], ecc_code[2]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd,
|
||||
const u_char *dat, u_char *ecc_code)
|
||||
static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
|
||||
{
|
||||
struct s3c2410_nand_info *info = s3c2410_nand_mtd_toinfo(mtd);
|
||||
unsigned long ecc = readl(info->regs + S3C2440_NFMECC0);
|
||||
|
@ -404,13 +390,11 @@ static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd,
|
|||
ecc_code[1] = ecc >> 8;
|
||||
ecc_code[2] = ecc >> 16;
|
||||
|
||||
pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n",
|
||||
ecc_code[0], ecc_code[1], ecc_code[2]);
|
||||
pr_debug("calculate_ecc: returning ecc %02x,%02x,%02x\n", ecc_code[0], ecc_code[1], ecc_code[2]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* over-ride the standard functions for a little more speed. We can
|
||||
* use read/write block to move the data buffers to/from the controller
|
||||
*/
|
||||
|
@ -421,8 +405,7 @@ static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
|
|||
readsb(this->IO_ADDR_R, buf, len);
|
||||
}
|
||||
|
||||
static void s3c2410_nand_write_buf(struct mtd_info *mtd,
|
||||
const u_char *buf, int len)
|
||||
static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
|
||||
{
|
||||
struct nand_chip *this = mtd->priv;
|
||||
writesb(this->IO_ADDR_W, buf, len);
|
||||
|
@ -488,9 +471,7 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info,
|
|||
return add_mtd_device(&mtd->mtd);
|
||||
|
||||
if (set->nr_partitions > 0 && set->partitions != NULL) {
|
||||
return add_mtd_partitions(&mtd->mtd,
|
||||
set->partitions,
|
||||
set->nr_partitions);
|
||||
return add_mtd_partitions(&mtd->mtd, set->partitions, set->nr_partitions);
|
||||
}
|
||||
|
||||
return add_mtd_device(&mtd->mtd);
|
||||
|
@ -654,13 +635,11 @@ static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440)
|
|||
nmtd = info->mtds;
|
||||
|
||||
for (setno = 0; setno < nr_sets; setno++, nmtd++) {
|
||||
pr_debug("initialising set %d (%p, info %p)\n",
|
||||
setno, nmtd, info);
|
||||
pr_debug("initialising set %d (%p, info %p)\n", setno, nmtd, info);
|
||||
|
||||
s3c2410_nand_init_chip(info, nmtd, sets);
|
||||
|
||||
nmtd->scan_res = nand_scan(&nmtd->mtd,
|
||||
(sets) ? sets->nr_chips : 1);
|
||||
nmtd->scan_res = nand_scan(&nmtd->mtd, (sets) ? sets->nr_chips : 1);
|
||||
|
||||
if (nmtd->scan_res == 0) {
|
||||
s3c2410_nand_add_partition(info, nmtd, sets);
|
||||
|
|
|
@ -46,7 +46,6 @@ static int sharpsl_phys_base = 0x0C000000;
|
|||
#define FLCLE (1 << 1)
|
||||
#define FLCE0 (1 << 0)
|
||||
|
||||
|
||||
/*
|
||||
* MTD structure for SharpSL
|
||||
*/
|
||||
|
@ -79,8 +78,7 @@ static struct mtd_partition sharpsl_nand_default_partition_info[] = {
|
|||
/*
|
||||
* hardware specific access to control-lines
|
||||
*/
|
||||
static void
|
||||
sharpsl_nand_hwcontrol(struct mtd_info* mtd, int cmd)
|
||||
static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case NAND_CTL_SETCLE:
|
||||
|
@ -132,21 +130,17 @@ static struct nand_oobinfo akita_oobinfo = {
|
|||
.oobfree = {{0x08, 0x09}}
|
||||
};
|
||||
|
||||
static int
|
||||
sharpsl_nand_dev_ready(struct mtd_info* mtd)
|
||||
static int sharpsl_nand_dev_ready(struct mtd_info *mtd)
|
||||
{
|
||||
return !((readb(FLASHCTL) & FLRYBY) == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
sharpsl_nand_enable_hwecc(struct mtd_info* mtd, int mode)
|
||||
static void sharpsl_nand_enable_hwecc(struct mtd_info *mtd, int mode)
|
||||
{
|
||||
writeb(0, ECCCLRR);
|
||||
}
|
||||
|
||||
static int
|
||||
sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat,
|
||||
u_char* ecc_code)
|
||||
static int sharpsl_nand_calculate_ecc(struct mtd_info *mtd, const u_char * dat, u_char * ecc_code)
|
||||
{
|
||||
ecc_code[0] = ~readb(ECCLPUB);
|
||||
ecc_code[1] = ~readb(ECCLPLB);
|
||||
|
@ -154,25 +148,21 @@ sharpsl_nand_calculate_ecc(struct mtd_info* mtd, const u_char* dat,
|
|||
return readb(ECCCNTR) != 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
const char *part_probes[] = { "cmdlinepart", NULL };
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Main initialization routine
|
||||
*/
|
||||
int __init
|
||||
sharpsl_nand_init(void)
|
||||
int __init sharpsl_nand_init(void)
|
||||
{
|
||||
struct nand_chip *this;
|
||||
struct mtd_partition *sharpsl_partition_info;
|
||||
int err = 0;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip),
|
||||
GFP_KERNEL);
|
||||
sharpsl_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!sharpsl_mtd) {
|
||||
printk("Unable to allocate SharpSL NAND MTD device structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -190,8 +180,8 @@ sharpsl_nand_init(void)
|
|||
this = (struct nand_chip *)(&sharpsl_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) sharpsl_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(sharpsl_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
sharpsl_mtd->priv = this;
|
||||
|
@ -230,8 +220,7 @@ sharpsl_nand_init(void)
|
|||
|
||||
/* Register the partitions */
|
||||
sharpsl_mtd->name = "sharpsl-nand";
|
||||
nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes,
|
||||
&sharpsl_partition_info, 0);
|
||||
nr_partitions = parse_mtd_partitions(sharpsl_mtd, part_probes, &sharpsl_partition_info, 0);
|
||||
|
||||
if (nr_partitions <= 0) {
|
||||
nr_partitions = DEFAULT_NUM_PARTITIONS;
|
||||
|
@ -261,6 +250,7 @@ sharpsl_nand_init(void)
|
|||
/* Return happy */
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(sharpsl_nand_init);
|
||||
|
||||
/*
|
||||
|
@ -279,6 +269,7 @@ static void __exit sharpsl_nand_cleanup(void)
|
|||
/* Free the MTD device structure */
|
||||
kfree(sharpsl_mtd);
|
||||
}
|
||||
|
||||
module_exit(sharpsl_nand_cleanup);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -71,22 +71,20 @@ static const struct mtd_partition partition_info[] = {
|
|||
{
|
||||
.name = "SPIA flash partition 1",
|
||||
.offset = 0,
|
||||
.size = 2*1024*1024
|
||||
},
|
||||
.size = 2 * 1024 * 1024},
|
||||
{
|
||||
.name = "SPIA flash partition 2",
|
||||
.offset = 2 * 1024 * 1024,
|
||||
.size = 6*1024*1024
|
||||
}
|
||||
.size = 6 * 1024 * 1024}
|
||||
};
|
||||
#define NUM_PARTITIONS 2
|
||||
|
||||
#define NUM_PARTITIONS 2
|
||||
|
||||
/*
|
||||
* hardware specific access to control-lines
|
||||
*/
|
||||
static void spia_hwcontrol(struct mtd_info *mtd, int cmd){
|
||||
|
||||
static void spia_hwcontrol(struct mtd_info *mtd, int cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
|
||||
case NAND_CTL_SETCLE: (*(volatile unsigned char *) (spia_io_base + spia_pedr)) |= 0x01; break;
|
||||
|
@ -108,8 +106,7 @@ int __init spia_init (void)
|
|||
struct nand_chip *this;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
spia_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
|
||||
GFP_KERNEL);
|
||||
spia_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!spia_mtd) {
|
||||
printk("Unable to allocate SPIA NAND MTD device structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -119,8 +116,8 @@ int __init spia_init (void)
|
|||
this = (struct nand_chip *)(&spia_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) spia_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(spia_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
spia_mtd->priv = this;
|
||||
|
@ -151,6 +148,7 @@ int __init spia_init (void)
|
|||
/* Return happy */
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(spia_init);
|
||||
|
||||
/*
|
||||
|
@ -165,6 +163,7 @@ static void __exit spia_cleanup (void)
|
|||
/* Free the MTD device structure */
|
||||
kfree(spia_mtd);
|
||||
}
|
||||
|
||||
module_exit(spia_cleanup);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ static void toto_hwcontrol(struct mtd_info *mtd, int cmd)
|
|||
|
||||
udelay(1); /* hopefully enough time for tc make proceding write to clear */
|
||||
switch (cmd) {
|
||||
|
||||
case NAND_CTL_SETCLE: T_NAND_CTL_SETCLE(cmd); break;
|
||||
case NAND_CTL_CLRCLE: T_NAND_CTL_CLRCLE(cmd); break;
|
||||
|
||||
|
@ -122,8 +121,7 @@ int __init toto_init (void)
|
|||
int err = 0;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
toto_mtd = kmalloc (sizeof(struct mtd_info) + sizeof (struct nand_chip),
|
||||
GFP_KERNEL);
|
||||
toto_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!toto_mtd) {
|
||||
printk(KERN_WARNING "Unable to allocate toto NAND MTD device structure.\n");
|
||||
err = -ENOMEM;
|
||||
|
@ -134,8 +132,8 @@ int __init toto_init (void)
|
|||
this = (struct nand_chip *)(&toto_mtd[1]);
|
||||
|
||||
/* Initialize structures */
|
||||
memset((char *) toto_mtd, 0, sizeof(struct mtd_info));
|
||||
memset((char *) this, 0, sizeof(struct nand_chip));
|
||||
memset(toto_mtd, 0, sizeof(struct mtd_info));
|
||||
memset(this, 0, sizeof(struct nand_chip));
|
||||
|
||||
/* Link the private data with the MTD structure */
|
||||
toto_mtd->priv = this;
|
||||
|
@ -157,8 +155,12 @@ int __init toto_init (void)
|
|||
|
||||
/* Register the partitions */
|
||||
switch (toto_mtd->size) {
|
||||
case SZ_64M: add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M); break;
|
||||
case SZ_32M: add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M); break;
|
||||
case SZ_64M:
|
||||
add_mtd_partitions(toto_mtd, partition_info64M, NUM_PARTITIONS64M);
|
||||
break;
|
||||
case SZ_32M:
|
||||
add_mtd_partitions(toto_mtd, partition_info32M, NUM_PARTITIONS32M);
|
||||
break;
|
||||
default:{
|
||||
printk(KERN_WARNING "Unsupported Nand device\n");
|
||||
err = -ENXIO;
|
||||
|
@ -198,6 +200,7 @@ static void __exit toto_cleanup (void)
|
|||
/* release gpios to system */
|
||||
gpiorelease(NAND_MASK);
|
||||
}
|
||||
|
||||
module_exit(toto_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
@ -132,8 +132,7 @@ static int __init ts7250_init(void)
|
|||
return -ENXIO;
|
||||
|
||||
/* Allocate memory for MTD device structure and private data */
|
||||
ts7250_mtd = kmalloc(sizeof(struct mtd_info) +
|
||||
sizeof(struct nand_chip), GFP_KERNEL);
|
||||
ts7250_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
|
||||
if (!ts7250_mtd) {
|
||||
printk("Unable to allocate TS7250 NAND MTD device structure.\n");
|
||||
return -ENOMEM;
|
||||
|
@ -163,11 +162,9 @@ static int __init ts7250_init(void)
|
|||
kfree(ts7250_mtd);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_MTD_PARTITIONS
|
||||
ts7250_mtd->name = "ts7250-nand";
|
||||
mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes,
|
||||
&mtd_parts, 0);
|
||||
mtd_parts_nb = parse_mtd_partitions(ts7250_mtd, part_probes, &mtd_parts, 0);
|
||||
if (mtd_parts_nb > 0)
|
||||
part_type = "command line";
|
||||
else
|
||||
|
@ -188,6 +185,7 @@ static int __init ts7250_init(void)
|
|||
/* Return happy */
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_init(ts7250_init);
|
||||
|
||||
/*
|
||||
|
@ -201,6 +199,7 @@ static void __exit ts7250_cleanup(void)
|
|||
/* Free the MTD device structure */
|
||||
kfree(ts7250_mtd);
|
||||
}
|
||||
|
||||
module_exit(ts7250_cleanup);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
Загрузка…
Ссылка в новой задаче