* (c) 1999 Machine Vision Holdings, Inc.
* (c) 1999, 2000 David Woodhouse <dwmw2@infradead.org>
*
- * $Id: doc2001plus.c,v 1.8 2004/04/04 12:36:45 gleixner Exp $
+ * $Id: doc2001plus.c,v 1.14 2005/11/07 11:14:24 gleixner Exp $
*
* Released under GPL
*/
/* Perform the required delay cycles by writing to the NOP register */
-static void DoC_Delay(unsigned long docptr, int cycles)
+static void DoC_Delay(void __iomem * docptr, int cycles)
{
int i;
#define CDSN_CTRL_FR_B_MASK (CDSN_CTRL_FR_B0 | CDSN_CTRL_FR_B1)
/* DOC_WaitReady: Wait for RDY line to be asserted by the flash chip */
-static int _DoC_WaitReady(unsigned long docptr)
+static int _DoC_WaitReady(void __iomem * docptr)
{
unsigned int c = 0xffff;
return (c == 0);
}
-static inline int DoC_WaitReady(unsigned long docptr)
+static inline int DoC_WaitReady(void __iomem * docptr)
{
/* This is inline, to optimise the common case, where it's ready instantly */
int ret = 0;
* can detect. M-systems suggest always check this on any block level
* operation and setting to normal mode if in reset mode.
*/
-static inline void DoC_CheckASIC(unsigned long docptr)
+static inline void DoC_CheckASIC(void __iomem * docptr)
{
/* Make sure the DoC is in normal mode */
if ((ReadDOC(docptr, Mplus_DOCControl) & DOC_MODE_NORMAL) == 0) {
/* DoC_Command: Send a flash command to the flash chip through the Flash
* command register. Need 2 Write Pipeline Terminates to complete send.
*/
-static inline void DoC_Command(unsigned long docptr, unsigned char command,
+static void DoC_Command(void __iomem * docptr, unsigned char command,
unsigned char xtraflags)
{
WriteDOC(command, docptr, Mplus_FlashCmd);
unsigned long ofs, unsigned char xtraflags1,
unsigned char xtraflags2)
{
- unsigned long docptr = doc->virtadr;
+ void __iomem * docptr = doc->virtadr;
/* Allow for possible Mill Plus internal flash interleaving */
ofs >>= doc->interleave;
}
/* DoC_SelectChip: Select a given flash chip within the current floor */
-static int DoC_SelectChip(unsigned long docptr, int chip)
+static int DoC_SelectChip(void __iomem * docptr, int chip)
{
/* No choice for flash chip on Millennium Plus */
return 0;
}
/* DoC_SelectFloor: Select a given floor (bank of flash chips) */
-static int DoC_SelectFloor(unsigned long docptr, int floor)
+static int DoC_SelectFloor(void __iomem * docptr, int floor)
{
WriteDOC((floor & 0x3), docptr, Mplus_DeviceSelect);
return 0;
may not want it */
static unsigned int DoC_GetDataOffset(struct mtd_info *mtd, loff_t *from)
{
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
+ struct DiskOnChip *this = mtd->priv;
if (this->interleave) {
unsigned int ofs = *from & 0x3ff;
return cmd;
}
-static inline void MemReadDOC(unsigned long docptr, unsigned char *buf, int len)
+static inline void MemReadDOC(void __iomem * docptr, unsigned char *buf, int len)
{
#ifndef USE_MEMCPY
int i;
#endif
}
-static inline void MemWriteDOC(unsigned long docptr, unsigned char *buf, int len)
+static inline void MemWriteDOC(void __iomem * docptr, unsigned char *buf, int len)
{
#ifndef USE_MEMCPY
int i;
{
int mfr, id, i, j;
volatile char dummy;
- unsigned long docptr = doc->virtadr;
+ void __iomem * docptr = doc->virtadr;
/* Page in the required floor/chip */
DoC_SelectFloor(docptr, floor);
DoC_Command(docptr, NAND_CMD_RESET, 0);
DoC_WaitReady(docptr);
- /* Read the NAND chip ID: 1. Send ReadID command */
+ /* Read the NAND chip ID: 1. Send ReadID command */
DoC_Command(docptr, NAND_CMD_READID, 0);
- /* Read the NAND chip ID: 2. Send address byte zero */
+ /* Read the NAND chip ID: 2. Send address byte zero */
DoC_Address(doc, 1, 0x00, 0, 0x00);
WriteDOC(0, docptr, Mplus_FlashControl);
this->interleave = 1;
/* Check the ASIC agrees */
- if ( (this->interleave << 2) !=
+ if ( (this->interleave << 2) !=
(ReadDOC(this->virtadr, Mplus_Configuration) & 4)) {
u_char conf = ReadDOC(this->virtadr, Mplus_Configuration);
printk(KERN_NOTICE "Setting DiskOnChip Millennium Plus interleave to %s\n",
this->interleave?"on (16-bit)":"off (8-bit)");
conf ^= 4;
- WriteDOC(this->virtadr, conf, Mplus_Configuration);
+ WriteDOC(conf, this->virtadr, Mplus_Configuration);
}
/* For each floor, find the number of valid chips it contains */
return;
}
- /* Fill out the chip array with {floor, chipno} for each
+ /* Fill out the chip array with {floor, chipno} for each
* detected chip in the device. */
for (floor = 0, ret = 0; floor < MAX_FLOORS_MPLUS; floor++) {
for (chip = 0 ; chip < numchips[floor] ; chip++) {
tmp2 = ReadDOC(doc2->virtadr, Mplus_AliasResolution);
if (tmp1 != tmp2)
return 0;
-
+
WriteDOC((tmp1+1) % 0xff, doc1->virtadr, Mplus_AliasResolution);
tmp2 = ReadDOC(doc2->virtadr, Mplus_AliasResolution);
if (tmp2 == (tmp1+1) % 0xff)
*/
static void DoCMilPlus_init(struct mtd_info *mtd)
{
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
+ struct DiskOnChip *this = mtd->priv;
struct DiskOnChip *old = NULL;
/* We must avoid being called twice for the same device. */
if (docmilpluslist)
- old = (struct DiskOnChip *)docmilpluslist->priv;
+ old = docmilpluslist->priv;
while (old) {
if (DoCMilPlus_is_alias(this, old)) {
printk(KERN_NOTICE "Ignoring DiskOnChip Millennium "
"Plus at 0x%lX - already configured\n",
this->physadr);
- iounmap((void *)this->virtadr);
+ iounmap(this->virtadr);
kfree(mtd);
return;
}
if (old->nextdoc)
- old = (struct DiskOnChip *)old->nextdoc->priv;
+ old = old->nextdoc->priv;
else
old = NULL;
}
if (!this->totlen) {
kfree(mtd);
- iounmap((void *)this->virtadr);
+ iounmap(this->virtadr);
} else {
this->nextdoc = docmilpluslist;
docmilpluslist = mtd;
{
int i;
loff_t fofs;
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
- unsigned long docptr = this->virtadr;
+ struct DiskOnChip *this = mtd->priv;
+ void __iomem * docptr = this->virtadr;
struct Nand *mychip = &this->chips[from >> (this->chipshift)];
unsigned char *bp, buf[1056];
char c[32];
volatile char dummy;
loff_t fofs;
unsigned char syndrome[6];
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
- unsigned long docptr = this->virtadr;
+ struct DiskOnChip *this = mtd->priv;
+ void __iomem * docptr = this->virtadr;
struct Nand *mychip = &this->chips[from >> (this->chipshift)];
/* Don't allow read past end of device */
return -EINVAL;
/* Don't allow a single read to cross a 512-byte block boundary */
- if (from + len > ((from | 0x1ff) + 1))
+ if (from + len > ((from | 0x1ff) + 1))
len = ((from | 0x1ff) + 1) - from;
DoC_CheckASIC(docptr);
int i, before, ret = 0;
loff_t fto;
volatile char dummy;
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
- unsigned long docptr = this->virtadr;
+ struct DiskOnChip *this = mtd->priv;
+ void __iomem * docptr = this->virtadr;
struct Nand *mychip = &this->chips[to >> (this->chipshift)];
/* Don't allow write past end of device */
size_t *retlen, u_char *buf)
{
loff_t fofs, base;
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
- unsigned long docptr = this->virtadr;
+ struct DiskOnChip *this = mtd->priv;
+ void __iomem * docptr = this->virtadr;
struct Nand *mychip = &this->chips[ofs >> this->chipshift];
size_t i, size, got, want;
{
volatile char dummy;
loff_t fofs, base;
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
- unsigned long docptr = this->virtadr;
+ struct DiskOnChip *this = mtd->priv;
+ void __iomem * docptr = this->virtadr;
struct Nand *mychip = &this->chips[ofs >> this->chipshift];
size_t i, size, got, want;
int ret = 0;
int doc_erase(struct mtd_info *mtd, struct erase_info *instr)
{
volatile char dummy;
- struct DiskOnChip *this = (struct DiskOnChip *)mtd->priv;
+ struct DiskOnChip *this = mtd->priv;
__u32 ofs = instr->addr;
__u32 len = instr->len;
- unsigned long docptr = this->virtadr;
+ void __iomem * docptr = this->virtadr;
struct Nand *mychip = &this->chips[ofs >> this->chipshift];
DoC_CheckASIC(docptr);
- if (len != mtd->erasesize)
+ if (len != mtd->erasesize)
printk(KERN_WARNING "MTD: Erase not right size (%x != %x)n",
len, mtd->erasesize);
/* Disable flash internally */
WriteDOC(0, docptr, Mplus_FlashSelect);
- if (instr->callback)
- instr->callback(instr);
+ mtd_erase_callback(instr);
return 0;
}
*
****************************************************************************/
-int __init init_doc2001plus(void)
+static int __init init_doc2001plus(void)
{
inter_module_register(im_name, THIS_MODULE, &DoCMilPlus_init);
return 0;
struct DiskOnChip *this;
while ((mtd=docmilpluslist)) {
- this = (struct DiskOnChip *)mtd->priv;
+ this = mtd->priv;
docmilpluslist = this->nextdoc;
-
+
del_mtd_device(mtd);
-
- iounmap((void *)this->virtadr);
+
+ iounmap(this->virtadr);
kfree(this->chips);
kfree(mtd);
}