aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/pmc551.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-04-10 14:30:45 -0400
committerDavid S. Miller <davem@davemloft.net>2012-04-10 14:30:45 -0400
commit06eb4eafbdc0796d741d139a44f1253278da8611 (patch)
treefbdb44317130c371928154c9e6903e699fe2b995 /drivers/mtd/devices/pmc551.c
parent32ed53b83ea5ec26a4dba90e18f5e0ff6c71eb48 (diff)
parentf68e556e23d1a4176b563bcb25d8baf2c5313f91 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Diffstat (limited to 'drivers/mtd/devices/pmc551.c')
-rw-r--r--drivers/mtd/devices/pmc551.c100
1 files changed, 47 insertions, 53 deletions
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index ecff765579dd..0c51b988e1f8 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -93,14 +93,49 @@
93#include <linux/fs.h> 93#include <linux/fs.h>
94#include <linux/ioctl.h> 94#include <linux/ioctl.h>
95#include <asm/io.h> 95#include <asm/io.h>
96#include <asm/system.h>
97#include <linux/pci.h> 96#include <linux/pci.h>
98
99#include <linux/mtd/mtd.h> 97#include <linux/mtd/mtd.h>
100#include <linux/mtd/pmc551.h> 98
99#define PMC551_VERSION \
100 "Ramix PMC551 PCI Mezzanine Ram Driver. (C) 1999,2000 Nortel Networks.\n"
101
102#define PCI_VENDOR_ID_V3_SEMI 0x11b0
103#define PCI_DEVICE_ID_V3_SEMI_V370PDC 0x0200
104
105#define PMC551_PCI_MEM_MAP0 0x50
106#define PMC551_PCI_MEM_MAP1 0x54
107#define PMC551_PCI_MEM_MAP_MAP_ADDR_MASK 0x3ff00000
108#define PMC551_PCI_MEM_MAP_APERTURE_MASK 0x000000f0
109#define PMC551_PCI_MEM_MAP_REG_EN 0x00000002
110#define PMC551_PCI_MEM_MAP_ENABLE 0x00000001
111
112#define PMC551_SDRAM_MA 0x60
113#define PMC551_SDRAM_CMD 0x62
114#define PMC551_DRAM_CFG 0x64
115#define PMC551_SYS_CTRL_REG 0x78
116
117#define PMC551_DRAM_BLK0 0x68
118#define PMC551_DRAM_BLK1 0x6c
119#define PMC551_DRAM_BLK2 0x70
120#define PMC551_DRAM_BLK3 0x74
121#define PMC551_DRAM_BLK_GET_SIZE(x) (524288 << ((x >> 4) & 0x0f))
122#define PMC551_DRAM_BLK_SET_COL_MUX(x, v) (((x) & ~0x00007000) | (((v) & 0x7) << 12))
123#define PMC551_DRAM_BLK_SET_ROW_MUX(x, v) (((x) & ~0x00000f00) | (((v) & 0xf) << 8))
124
125struct mypriv {
126 struct pci_dev *dev;
127 u_char *start;
128 u32 base_map0;
129 u32 curr_map0;
130 u32 asize;
131 struct mtd_info *nextpmc551;
132};
101 133
102static struct mtd_info *pmc551list; 134static struct mtd_info *pmc551list;
103 135
136static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
137 size_t *retlen, void **virt, resource_size_t *phys);
138
104static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr) 139static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)
105{ 140{
106 struct mypriv *priv = mtd->priv; 141 struct mypriv *priv = mtd->priv;
@@ -116,16 +151,6 @@ static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)
116#endif 151#endif
117 152
118 end = instr->addr + instr->len - 1; 153 end = instr->addr + instr->len - 1;
119
120 /* Is it past the end? */
121 if (end > mtd->size) {
122#ifdef CONFIG_MTD_PMC551_DEBUG
123 printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n",
124 (long)end, (long)mtd->size);
125#endif
126 return -EINVAL;
127 }
128
129 eoff_hi = end & ~(priv->asize - 1); 154 eoff_hi = end & ~(priv->asize - 1);
130 soff_hi = instr->addr & ~(priv->asize - 1); 155 soff_hi = instr->addr & ~(priv->asize - 1);
131 eoff_lo = end & (priv->asize - 1); 156 eoff_lo = end & (priv->asize - 1);
@@ -179,18 +204,6 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
179 printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len); 204 printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len);
180#endif 205#endif
181 206
182 if (from + len > mtd->size) {
183#ifdef CONFIG_MTD_PMC551_DEBUG
184 printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n",
185 (long)from + len, (long)mtd->size);
186#endif
187 return -EINVAL;
188 }
189
190 /* can we return a physical address with this driver? */
191 if (phys)
192 return -EINVAL;
193
194 soff_hi = from & ~(priv->asize - 1); 207 soff_hi = from & ~(priv->asize - 1);
195 soff_lo = from & (priv->asize - 1); 208 soff_lo = from & (priv->asize - 1);
196 209
@@ -206,11 +219,12 @@ static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
206 return 0; 219 return 0;
207} 220}
208 221
209static void pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 222static int pmc551_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
210{ 223{
211#ifdef CONFIG_MTD_PMC551_DEBUG 224#ifdef CONFIG_MTD_PMC551_DEBUG
212 printk(KERN_DEBUG "pmc551_unpoint()\n"); 225 printk(KERN_DEBUG "pmc551_unpoint()\n");
213#endif 226#endif
227 return 0;
214} 228}
215 229
216static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len, 230static 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,
229#endif 243#endif
230 244
231 end = from + len - 1; 245 end = from + len - 1;
232
233 /* Is it past the end? */
234 if (end > mtd->size) {
235#ifdef CONFIG_MTD_PMC551_DEBUG
236 printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n",
237 (long)end, (long)mtd->size);
238#endif
239 return -EINVAL;
240 }
241
242 soff_hi = from & ~(priv->asize - 1); 246 soff_hi = from & ~(priv->asize - 1);
243 eoff_hi = end & ~(priv->asize - 1); 247 eoff_hi = end & ~(priv->asize - 1);
244 soff_lo = from & (priv->asize - 1); 248 soff_lo = from & (priv->asize - 1);
@@ -296,16 +300,6 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,
296#endif 300#endif
297 301
298 end = to + len - 1; 302 end = to + len - 1;
299 /* Is it past the end? or did the u32 wrap? */
300 if (end > mtd->size) {
301#ifdef CONFIG_MTD_PMC551_DEBUG
302 printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, "
303 "size: %ld, to: %ld)\n", (long)end, (long)mtd->size,
304 (long)to);
305#endif
306 return -EINVAL;
307 }
308
309 soff_hi = to & ~(priv->asize - 1); 303 soff_hi = to & ~(priv->asize - 1);
310 eoff_hi = end & ~(priv->asize - 1); 304 eoff_hi = end & ~(priv->asize - 1);
311 soff_lo = to & (priv->asize - 1); 305 soff_lo = to & (priv->asize - 1);
@@ -359,7 +353,7 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,
359 * mechanism 353 * mechanism
360 * returns the size of the memory region found. 354 * returns the size of the memory region found.
361 */ 355 */
362static u32 fixup_pmc551(struct pci_dev *dev) 356static int fixup_pmc551(struct pci_dev *dev)
363{ 357{
364#ifdef CONFIG_MTD_PMC551_BUGFIX 358#ifdef CONFIG_MTD_PMC551_BUGFIX
365 u32 dram_data; 359 u32 dram_data;
@@ -669,7 +663,7 @@ static int __init init_pmc551(void)
669 struct mypriv *priv; 663 struct mypriv *priv;
670 int found = 0; 664 int found = 0;
671 struct mtd_info *mtd; 665 struct mtd_info *mtd;
672 u32 length = 0; 666 int length = 0;
673 667
674 if (msize) { 668 if (msize) {
675 msize = (1 << (ffs(msize) - 1)) << 20; 669 msize = (1 << (ffs(msize) - 1)) << 20;
@@ -787,11 +781,11 @@ static int __init init_pmc551(void)
787 781
788 mtd->size = msize; 782 mtd->size = msize;
789 mtd->flags = MTD_CAP_RAM; 783 mtd->flags = MTD_CAP_RAM;
790 mtd->erase = pmc551_erase; 784 mtd->_erase = pmc551_erase;
791 mtd->read = pmc551_read; 785 mtd->_read = pmc551_read;
792 mtd->write = pmc551_write; 786 mtd->_write = pmc551_write;
793 mtd->point = pmc551_point; 787 mtd->_point = pmc551_point;
794 mtd->unpoint = pmc551_unpoint; 788 mtd->_unpoint = pmc551_unpoint;
795 mtd->type = MTD_RAM; 789 mtd->type = MTD_RAM;
796 mtd->name = "PMC551 RAM board"; 790 mtd->name = "PMC551 RAM board";
797 mtd->erasesize = 0x10000; 791 mtd->erasesize = 0x10000;