aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/maps/pcmciamtd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/maps/pcmciamtd.c')
-rw-r--r--drivers/mtd/maps/pcmciamtd.c88
1 files changed, 50 insertions, 38 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 87b2b8ff331e..e699e6ac23df 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -40,10 +40,7 @@ MODULE_PARM_DESC(debug, "Set Debug Level 0=quiet, 5=noisy");
40static const int debug = 0; 40static const int debug = 0;
41#endif 41#endif
42 42
43#define err(format, arg...) printk(KERN_ERR "pcmciamtd: " format "\n" , ## arg)
44#define info(format, arg...) printk(KERN_INFO "pcmciamtd: " format "\n" , ## arg) 43#define info(format, arg...) printk(KERN_INFO "pcmciamtd: " format "\n" , ## arg)
45#define warn(format, arg...) printk(KERN_WARNING "pcmciamtd: " format "\n" , ## arg)
46
47 44
48#define DRIVER_DESC "PCMCIA Flash memory card driver" 45#define DRIVER_DESC "PCMCIA Flash memory card driver"
49 46
@@ -99,7 +96,9 @@ module_param(mem_type, int, 0);
99MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)"); 96MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)");
100 97
101 98
102/* read/write{8,16} copy_{from,to} routines with window remapping to access whole card */ 99/* read/write{8,16} copy_{from,to} routines with window remapping
100 * to access whole card
101 */
103static caddr_t remap_window(struct map_info *map, unsigned long to) 102static caddr_t remap_window(struct map_info *map, unsigned long to)
104{ 103{
105 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 104 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
@@ -136,7 +135,7 @@ static map_word pcmcia_read8_remap(struct map_info *map, unsigned long ofs)
136 return d; 135 return d;
137 136
138 d.x[0] = readb(addr); 137 d.x[0] = readb(addr);
139 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, addr, d.x[0]); 138 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02lx", ofs, addr, d.x[0]);
140 return d; 139 return d;
141} 140}
142 141
@@ -151,7 +150,7 @@ static map_word pcmcia_read16_remap(struct map_info *map, unsigned long ofs)
151 return d; 150 return d;
152 151
153 d.x[0] = readw(addr); 152 d.x[0] = readw(addr);
154 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, addr, d.x[0]); 153 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04lx", ofs, addr, d.x[0]);
155 return d; 154 return d;
156} 155}
157 156
@@ -161,7 +160,7 @@ static void pcmcia_copy_from_remap(struct map_info *map, void *to, unsigned long
161 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 160 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
162 unsigned long win_size = dev->win_size; 161 unsigned long win_size = dev->win_size;
163 162
164 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 163 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
165 while(len) { 164 while(len) {
166 int toread = win_size - (from & (win_size-1)); 165 int toread = win_size - (from & (win_size-1));
167 caddr_t addr; 166 caddr_t addr;
@@ -189,7 +188,7 @@ static void pcmcia_write8_remap(struct map_info *map, map_word d, unsigned long
189 if(!addr) 188 if(!addr)
190 return; 189 return;
191 190
192 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, addr, d.x[0]); 191 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx", adr, addr, d.x[0]);
193 writeb(d.x[0], addr); 192 writeb(d.x[0], addr);
194} 193}
195 194
@@ -200,7 +199,7 @@ static void pcmcia_write16_remap(struct map_info *map, map_word d, unsigned long
200 if(!addr) 199 if(!addr)
201 return; 200 return;
202 201
203 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, addr, d.x[0]); 202 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx", adr, addr, d.x[0]);
204 writew(d.x[0], addr); 203 writew(d.x[0], addr);
205} 204}
206 205
@@ -210,7 +209,7 @@ static void pcmcia_copy_to_remap(struct map_info *map, unsigned long to, const v
210 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 209 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
211 unsigned long win_size = dev->win_size; 210 unsigned long win_size = dev->win_size;
212 211
213 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 212 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
214 while(len) { 213 while(len) {
215 int towrite = win_size - (to & (win_size-1)); 214 int towrite = win_size - (to & (win_size-1));
216 caddr_t addr; 215 caddr_t addr;
@@ -244,7 +243,8 @@ static map_word pcmcia_read8(struct map_info *map, unsigned long ofs)
244 return d; 243 return d;
245 244
246 d.x[0] = readb(win_base + ofs); 245 d.x[0] = readb(win_base + ofs);
247 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02x", ofs, win_base + ofs, d.x[0]); 246 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%02lx",
247 ofs, win_base + ofs, d.x[0]);
248 return d; 248 return d;
249} 249}
250 250
@@ -258,7 +258,8 @@ static map_word pcmcia_read16(struct map_info *map, unsigned long ofs)
258 return d; 258 return d;
259 259
260 d.x[0] = readw(win_base + ofs); 260 d.x[0] = readw(win_base + ofs);
261 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04x", ofs, win_base + ofs, d.x[0]); 261 DEBUG(3, "ofs = 0x%08lx (%p) data = 0x%04lx",
262 ofs, win_base + ofs, d.x[0]);
262 return d; 263 return d;
263} 264}
264 265
@@ -270,32 +271,34 @@ static void pcmcia_copy_from(struct map_info *map, void *to, unsigned long from,
270 if(DEV_REMOVED(map)) 271 if(DEV_REMOVED(map))
271 return; 272 return;
272 273
273 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 274 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
274 memcpy_fromio(to, win_base + from, len); 275 memcpy_fromio(to, win_base + from, len);
275} 276}
276 277
277 278
278static void pcmcia_write8(struct map_info *map, u8 d, unsigned long adr) 279static void pcmcia_write8(struct map_info *map, map_word d, unsigned long adr)
279{ 280{
280 caddr_t win_base = (caddr_t)map->map_priv_2; 281 caddr_t win_base = (caddr_t)map->map_priv_2;
281 282
282 if(DEV_REMOVED(map)) 283 if(DEV_REMOVED(map))
283 return; 284 return;
284 285
285 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, win_base + adr, d); 286 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx",
286 writeb(d, win_base + adr); 287 adr, win_base + adr, d.x[0]);
288 writeb(d.x[0], win_base + adr);
287} 289}
288 290
289 291
290static void pcmcia_write16(struct map_info *map, u16 d, unsigned long adr) 292static void pcmcia_write16(struct map_info *map, map_word d, unsigned long adr)
291{ 293{
292 caddr_t win_base = (caddr_t)map->map_priv_2; 294 caddr_t win_base = (caddr_t)map->map_priv_2;
293 295
294 if(DEV_REMOVED(map)) 296 if(DEV_REMOVED(map))
295 return; 297 return;
296 298
297 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, win_base + adr, d); 299 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx",
298 writew(d, win_base + adr); 300 adr, win_base + adr, d.x[0]);
301 writew(d.x[0], win_base + adr);
299} 302}
300 303
301 304
@@ -306,7 +309,7 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f
306 if(DEV_REMOVED(map)) 309 if(DEV_REMOVED(map))
307 return; 310 return;
308 311
309 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 312 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
310 memcpy_toio(win_base + to, from, len); 313 memcpy_toio(win_base + to, from, len);
311} 314}
312 315
@@ -375,7 +378,8 @@ static int pcmciamtd_cistpl_jedec(struct pcmcia_device *p_dev,
375 if (!pcmcia_parse_tuple(tuple, &parse)) { 378 if (!pcmcia_parse_tuple(tuple, &parse)) {
376 cistpl_jedec_t *t = &parse.jedec; 379 cistpl_jedec_t *t = &parse.jedec;
377 for (i = 0; i < t->nid; i++) 380 for (i = 0; i < t->nid; i++)
378 DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info); 381 DEBUG(2, "JEDEC: 0x%02x 0x%02x",
382 t->id[i].mfr, t->id[i].info);
379 } 383 }
380 return -ENOSPC; 384 return -ENOSPC;
381} 385}
@@ -431,7 +435,7 @@ static int pcmciamtd_cistpl_geo(struct pcmcia_device *p_dev,
431} 435}
432 436
433 437
434static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) 438static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *p_dev, int *new_name)
435{ 439{
436 int i; 440 int i;
437 441
@@ -476,7 +480,8 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link,
476 } 480 }
477 481
478 DEBUG(1, "Device: Size: %lu Width:%d Name: %s", 482 DEBUG(1, "Device: Size: %lu Width:%d Name: %s",
479 dev->pcmcia_map.size, dev->pcmcia_map.bankwidth << 3, dev->mtd_name); 483 dev->pcmcia_map.size,
484 dev->pcmcia_map.bankwidth << 3, dev->mtd_name);
480} 485}
481 486
482 487
@@ -489,7 +494,6 @@ static int pcmciamtd_config(struct pcmcia_device *link)
489{ 494{
490 struct pcmciamtd_dev *dev = link->priv; 495 struct pcmciamtd_dev *dev = link->priv;
491 struct mtd_info *mtd = NULL; 496 struct mtd_info *mtd = NULL;
492 cs_status_t status;
493 win_req_t req; 497 win_req_t req;
494 int ret; 498 int ret;
495 int i; 499 int i;
@@ -513,9 +517,11 @@ static int pcmciamtd_config(struct pcmcia_device *link)
513 if(setvpp == 1) 517 if(setvpp == 1)
514 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp; 518 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp;
515 519
516 /* Request a memory window for PCMCIA. Some architeures can map windows upto the maximum 520 /* Request a memory window for PCMCIA. Some architeures can map windows
517 that PCMCIA can support (64MiB) - this is ideal and we aim for a window the size of the 521 * upto the maximum that PCMCIA can support (64MiB) - this is ideal and
518 whole card - otherwise we try smaller windows until we succeed */ 522 * we aim for a window the size of the whole card - otherwise we try
523 * smaller windows until we succeed
524 */
519 525
520 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; 526 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE;
521 req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; 527 req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16;
@@ -543,7 +549,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
543 DEBUG(2, "dev->win_size = %d", dev->win_size); 549 DEBUG(2, "dev->win_size = %d", dev->win_size);
544 550
545 if(!dev->win_size) { 551 if(!dev->win_size) {
546 err("Cant allocate memory window"); 552 dev_err(&dev->p_dev->dev, "Cannot allocate memory window\n");
547 pcmciamtd_release(link); 553 pcmciamtd_release(link);
548 return -ENODEV; 554 return -ENODEV;
549 } 555 }
@@ -553,7 +559,8 @@ static int pcmciamtd_config(struct pcmcia_device *link)
553 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); 559 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win);
554 dev->win_base = ioremap(req.Base, req.Size); 560 dev->win_base = ioremap(req.Base, req.Size);
555 if(!dev->win_base) { 561 if(!dev->win_base) {
556 err("ioremap(%lu, %u) failed", req.Base, req.Size); 562 dev_err(&dev->p_dev->dev, "ioremap(%lu, %u) failed\n",
563 req.Base, req.Size);
557 pcmciamtd_release(link); 564 pcmciamtd_release(link);
558 return -ENODEV; 565 return -ENODEV;
559 } 566 }
@@ -564,7 +571,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
564 dev->pcmcia_map.map_priv_1 = (unsigned long)dev; 571 dev->pcmcia_map.map_priv_1 = (unsigned long)dev;
565 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; 572 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win;
566 573
567 dev->vpp = (vpp) ? vpp : link->socket.socket.Vpp; 574 dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp;
568 link->conf.Attributes = 0; 575 link->conf.Attributes = 0;
569 if(setvpp == 2) { 576 if(setvpp == 2) {
570 link->conf.Vpp = dev->vpp; 577 link->conf.Vpp = dev->vpp;
@@ -600,7 +607,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
600 } 607 }
601 608
602 if(!mtd) { 609 if(!mtd) {
603 DEBUG(1, "Cant find an MTD"); 610 DEBUG(1, "Can not find an MTD");
604 pcmciamtd_release(link); 611 pcmciamtd_release(link);
605 return -ENODEV; 612 return -ENODEV;
606 } 613 }
@@ -611,8 +618,9 @@ static int pcmciamtd_config(struct pcmcia_device *link)
611 if(new_name) { 618 if(new_name) {
612 int size = 0; 619 int size = 0;
613 char unit = ' '; 620 char unit = ' ';
614 /* Since we are using a default name, make it better by adding in the 621 /* Since we are using a default name, make it better by adding
615 size */ 622 * in the size
623 */
616 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */ 624 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
617 size = mtd->size >> 10; 625 size = mtd->size >> 10;
618 unit = 'K'; 626 unit = 'K';
@@ -642,15 +650,15 @@ static int pcmciamtd_config(struct pcmcia_device *link)
642 if(add_mtd_device(mtd)) { 650 if(add_mtd_device(mtd)) {
643 map_destroy(mtd); 651 map_destroy(mtd);
644 dev->mtd_info = NULL; 652 dev->mtd_info = NULL;
645 err("Couldnt register MTD device"); 653 dev_err(&dev->p_dev->dev,
654 "Could not register the MTD device\n");
646 pcmciamtd_release(link); 655 pcmciamtd_release(link);
647 return -ENODEV; 656 return -ENODEV;
648 } 657 }
649 info("mtd%d: %s", mtd->index, mtd->name); 658 dev_info(&dev->p_dev->dev, "mtd%d: %s\n", mtd->index, mtd->name);
650 return 0; 659 return 0;
651 660
652 failed: 661 dev_err(&dev->p_dev->dev, "CS Error, exiting\n");
653 err("CS Error, exiting");
654 pcmciamtd_release(link); 662 pcmciamtd_release(link);
655 return -ENODEV; 663 return -ENODEV;
656} 664}
@@ -689,8 +697,9 @@ static void pcmciamtd_detach(struct pcmcia_device *link)
689 697
690 if(dev->mtd_info) { 698 if(dev->mtd_info) {
691 del_mtd_device(dev->mtd_info); 699 del_mtd_device(dev->mtd_info);
700 dev_info(&dev->p_dev->dev, "mtd%d: Removing\n",
701 dev->mtd_info->index);
692 map_destroy(dev->mtd_info); 702 map_destroy(dev->mtd_info);
693 info("mtd%d: Removed", dev->mtd_info->index);
694 } 703 }
695 704
696 pcmciamtd_release(link); 705 pcmciamtd_release(link);
@@ -734,8 +743,11 @@ static struct pcmcia_device_id pcmciamtd_ids[] = {
734 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8), 743 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8),
735 PCMCIA_DEVICE_PROD_ID12("KINGMAX TECHNOLOGY INC.", "SRAM 256K Bytes", 0x54d0c69c, 0xad12c29c), 744 PCMCIA_DEVICE_PROD_ID12("KINGMAX TECHNOLOGY INC.", "SRAM 256K Bytes", 0x54d0c69c, 0xad12c29c),
736 PCMCIA_DEVICE_PROD_ID12("Maxtor", "MAXFL MobileMax Flash Memory Card", 0xb68968c8, 0x2dfb47b0), 745 PCMCIA_DEVICE_PROD_ID12("Maxtor", "MAXFL MobileMax Flash Memory Card", 0xb68968c8, 0x2dfb47b0),
746 PCMCIA_DEVICE_PROD_ID123("M-Systems", "M-SYS Flash Memory Card", "(c) M-Systems", 0x7ed2ad87, 0x675dc3fb, 0x7aef3965),
747 PCMCIA_DEVICE_PROD_ID12("PRETEC", " 2MB SRAM CARD", 0xebf91155, 0x805360ca),
737 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b), 748 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b),
738 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB513EN20", 0xf9876baf, 0xe8d884ad), 749 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB513EN20", 0xf9876baf, 0xe8d884ad),
750 PCMCIA_DEVICE_PROD_ID12("SMART Modular Technologies", " 4MB FLASH Card", 0x96fd8277, 0x737a5b05),
739 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca), 751 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca),
740 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944), 752 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944),
741 /* the following was commented out in pcmcia-cs-3.2.7 */ 753 /* the following was commented out in pcmcia-cs-3.2.7 */