Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e0c7d767 authored by David Woodhouse's avatar David Woodhouse
Browse files

[MTD NAND] Indent all of drivers/mtd/nand/*.c.



It was just too painful to deal with.

Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 6943f8af
Loading
Loading
Loading
Loading
+73 −70
Original line number Diff line number Diff line
@@ -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

+26 −27
Original line number Diff line number Diff line
@@ -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

+15 −15
Original line number Diff line number Diff line
@@ -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");
+211 −204
Original line number Diff line number Diff line
@@ -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 @@ static inline int __init nftl_partscan(struct mtd_info *mtd,
}

/* 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);
+26 −27
Original line number Diff line number Diff line
@@ -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");
Loading