diff options
Diffstat (limited to 'drivers/mtd/devices/pmc551.c')
| -rw-r--r-- | drivers/mtd/devices/pmc551.c | 117 | 
1 files changed, 53 insertions, 64 deletions
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index ef0aba0ce58..f02603e1bfe 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c @@ -93,14 +93,49 @@  #include <linux/fs.h>  #include <linux/ioctl.h>  #include <asm/io.h> -#include <asm/system.h>  #include <linux/pci.h> -  #include <linux/mtd/mtd.h> -#include <linux/mtd/pmc551.h> + +#define PMC551_VERSION \ +	"Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n" + +#define PCI_VENDOR_ID_V3_SEMI 0x11b0 +#define PCI_DEVICE_ID_V3_SEMI_V370PDC 0x0200 + +#define PMC551_PCI_MEM_MAP0 0x50 +#define PMC551_PCI_MEM_MAP1 0x54 +#define PMC551_PCI_MEM_MAP_MAP_ADDR_MASK 0x3ff00000 +#define PMC551_PCI_MEM_MAP_APERTURE_MASK 0x000000f0 +#define PMC551_PCI_MEM_MAP_REG_EN 0x00000002 +#define PMC551_PCI_MEM_MAP_ENABLE 0x00000001 + +#define PMC551_SDRAM_MA  0x60 +#define PMC551_SDRAM_CMD 0x62 +#define PMC551_DRAM_CFG  0x64 +#define PMC551_SYS_CTRL_REG 0x78 + +#define PMC551_DRAM_BLK0 0x68 +#define PMC551_DRAM_BLK1 0x6c +#define PMC551_DRAM_BLK2 0x70 +#define PMC551_DRAM_BLK3 0x74 +#define PMC551_DRAM_BLK_GET_SIZE(x) (524288 << ((x >> 4) & 0x0f)) +#define PMC551_DRAM_BLK_SET_COL_MUX(x, v) (((x) & ~0x00007000) | (((v) & 0x7) << 12)) +#define PMC551_DRAM_BLK_SET_ROW_MUX(x, v) (((x) & ~0x00000f00) | (((v) & 0xf) << 8)) + +struct mypriv { +	struct pci_dev *dev; +	u_char *start; +	u32 base_map0; +	u32 curr_map0; +	u32 asize; +	struct mtd_info *nextpmc551; +};  static struct mtd_info *pmc551list; +static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len, +			size_t *retlen, void **virt, resource_size_t *phys); +  static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)  {  	struct mypriv *priv = mtd->priv; @@ -116,16 +151,6 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)  #endif  	end = instr->addr + instr->len - 1; - -	/* Is it past the end? */ -	if (end > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -		printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n", -			(long)end, (long)mtd->size); -#endif -		return -EINVAL; -	} -  	eoff_hi = end & ~(priv->asize - 1);  	soff_hi = instr->addr & ~(priv->asize - 1);  	eoff_lo = end & (priv->asize - 1); @@ -179,18 +204,6 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,  	printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len);  #endif -	if (from + len > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -		printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n", -			(long)from + len, (long)mtd->size); -#endif -		return -EINVAL; -	} - -	/* can we return a physical address with this driver? */ -	if (phys) -		return -EINVAL; -  	soff_hi = from & ~(priv->asize - 1);  	soff_lo = from & (priv->asize - 1); @@ -206,11 +219,12 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,  	return 0;  } -static void pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len) +static int pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len)  {  #ifdef CONFIG_MTD_PMC551_DEBUG  	printk(KERN_DEBUG "pmc551_unpoint()\n");  #endif +	return 0;  }  static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, @@ -229,16 +243,6 @@ static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,  #endif  	end = from + len - 1; - -	/* Is it past the end? */ -	if (end > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -		printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n", -			(long)end, (long)mtd->size); -#endif -		return -EINVAL; -	} -  	soff_hi = from & ~(priv->asize - 1);  	eoff_hi = end & ~(priv->asize - 1);  	soff_lo = from & (priv->asize - 1); @@ -296,16 +300,6 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,  #endif  	end = to + len - 1; -	/* Is it past the end?  or did the u32 wrap? */ -	if (end > mtd->size) { -#ifdef CONFIG_MTD_PMC551_DEBUG -		printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, " -			"size: %ld, to: %ld)\n", (long)end, (long)mtd->size, -			(long)to); -#endif -		return -EINVAL; -	} -  	soff_hi = to & ~(priv->asize - 1);  	eoff_hi = end & ~(priv->asize - 1);  	soff_lo = to & (priv->asize - 1); @@ -351,7 +345,7 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,   * Fixup routines for the V370PDC   * PCI device ID 0x020011b0   * - * This function basicly kick starts the DRAM oboard the card and gets it + * This function basically kick starts the DRAM oboard the card and gets it   * ready to be used.  Before this is done the device reads VERY erratic, so   * much that it can crash the Linux 2.2.x series kernels when a user cat's   * /proc/pci .. though that is mainly a kernel bug in handling the PCI DEVSEL @@ -359,7 +353,7 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,   * mechanism   * returns the size of the memory region found.   */ -static u32 fixup_pmc551(struct pci_dev *dev) +static int fixup_pmc551(struct pci_dev *dev)  {  #ifdef CONFIG_MTD_PMC551_BUGFIX  	u32 dram_data; @@ -540,7 +534,7 @@ static u32 fixup_pmc551(struct pci_dev *dev)  	/*  	 * Check to make certain the DEVSEL is set correctly, this device -	 * has a tendancy to assert DEVSEL and TRDY when a write is performed +	 * has a tendency to assert DEVSEL and TRDY when a write is performed  	 * to the memory when memory is read-only  	 */  	if ((cmd & PCI_STATUS_DEVSEL_MASK) != 0x0) { @@ -669,7 +663,7 @@ static int __init init_pmc551(void)  	struct mypriv *priv;  	int found = 0;  	struct mtd_info *mtd; -	u32 length = 0; +	int length = 0;  	if (msize) {  		msize = (1 << (ffs(msize) - 1)) << 20; @@ -731,16 +725,11 @@ static int __init init_pmc551(void)  		}  		mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); -		if (!mtd) { -			printk(KERN_NOTICE "pmc551: Cannot allocate new MTD " -				"device.\n"); +		if (!mtd)  			break; -		}  		priv = kzalloc(sizeof(struct mypriv), GFP_KERNEL);  		if (!priv) { -			printk(KERN_NOTICE "pmc551: Cannot allocate new MTD " -				"device.\n");  			kfree(mtd);  			break;  		} @@ -787,18 +776,18 @@ static int __init init_pmc551(void)  		mtd->size = msize;  		mtd->flags = MTD_CAP_RAM; -		mtd->erase = pmc551_erase; -		mtd->read = pmc551_read; -		mtd->write = pmc551_write; -		mtd->point = pmc551_point; -		mtd->unpoint = pmc551_unpoint; +		mtd->_erase = pmc551_erase; +		mtd->_read = pmc551_read; +		mtd->_write = pmc551_write; +		mtd->_point = pmc551_point; +		mtd->_unpoint = pmc551_unpoint;  		mtd->type = MTD_RAM;  		mtd->name = "PMC551 RAM board";  		mtd->erasesize = 0x10000;  		mtd->writesize = 1;  		mtd->owner = THIS_MODULE; -		if (add_mtd_device(mtd)) { +		if (mtd_device_register(mtd, NULL, 0)) {  			printk(KERN_NOTICE "pmc551: Failed to register new device\n");  			pci_iounmap(PCI_Device, priv->start);  			kfree(mtd->priv); @@ -806,7 +795,7 @@ static int __init init_pmc551(void)  			break;  		} -		/* Keep a reference as the add_mtd_device worked */ +		/* Keep a reference as the mtd_device_register worked */  		pci_dev_get(PCI_Device);  		printk(KERN_NOTICE "Registered pmc551 memory device.\n"); @@ -856,7 +845,7 @@ static void __exit cleanup_pmc551(void)  		pci_dev_put(priv->dev);  		kfree(mtd->priv); -		del_mtd_device(mtd); +		mtd_device_unregister(mtd);  		kfree(mtd);  		found++;  	}  | 
