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.c91
1 files changed, 50 insertions, 41 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 689d6a79ffc0..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
@@ -52,7 +49,6 @@ static const int debug = 0;
52 49
53struct pcmciamtd_dev { 50struct pcmciamtd_dev {
54 struct pcmcia_device *p_dev; 51 struct pcmcia_device *p_dev;
55 dev_node_t node; /* device node */
56 caddr_t win_base; /* ioremapped address of PCMCIA window */ 52 caddr_t win_base; /* ioremapped address of PCMCIA window */
57 unsigned int win_size; /* size of window */ 53 unsigned int win_size; /* size of window */
58 unsigned int offset; /* offset into card the window currently points at */ 54 unsigned int offset; /* offset into card the window currently points at */
@@ -100,7 +96,9 @@ module_param(mem_type, int, 0);
100MODULE_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)");
101 97
102 98
103/* 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 */
104static caddr_t remap_window(struct map_info *map, unsigned long to) 102static caddr_t remap_window(struct map_info *map, unsigned long to)
105{ 103{
106 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 104 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
@@ -137,7 +135,7 @@ static map_word pcmcia_read8_remap(struct map_info *map, unsigned long ofs)
137 return d; 135 return d;
138 136
139 d.x[0] = readb(addr); 137 d.x[0] = readb(addr);
140 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]);
141 return d; 139 return d;
142} 140}
143 141
@@ -152,7 +150,7 @@ static map_word pcmcia_read16_remap(struct map_info *map, unsigned long ofs)
152 return d; 150 return d;
153 151
154 d.x[0] = readw(addr); 152 d.x[0] = readw(addr);
155 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]);
156 return d; 154 return d;
157} 155}
158 156
@@ -162,7 +160,7 @@ static void pcmcia_copy_from_remap(struct map_info *map, void *to, unsigned long
162 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 160 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
163 unsigned long win_size = dev->win_size; 161 unsigned long win_size = dev->win_size;
164 162
165 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 163 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
166 while(len) { 164 while(len) {
167 int toread = win_size - (from & (win_size-1)); 165 int toread = win_size - (from & (win_size-1));
168 caddr_t addr; 166 caddr_t addr;
@@ -190,7 +188,7 @@ static void pcmcia_write8_remap(struct map_info *map, map_word d, unsigned long
190 if(!addr) 188 if(!addr)
191 return; 189 return;
192 190
193 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]);
194 writeb(d.x[0], addr); 192 writeb(d.x[0], addr);
195} 193}
196 194
@@ -201,7 +199,7 @@ static void pcmcia_write16_remap(struct map_info *map, map_word d, unsigned long
201 if(!addr) 199 if(!addr)
202 return; 200 return;
203 201
204 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]);
205 writew(d.x[0], addr); 203 writew(d.x[0], addr);
206} 204}
207 205
@@ -211,7 +209,7 @@ static void pcmcia_copy_to_remap(struct map_info *map, unsigned long to, const v
211 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 209 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1;
212 unsigned long win_size = dev->win_size; 210 unsigned long win_size = dev->win_size;
213 211
214 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 212 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
215 while(len) { 213 while(len) {
216 int towrite = win_size - (to & (win_size-1)); 214 int towrite = win_size - (to & (win_size-1));
217 caddr_t addr; 215 caddr_t addr;
@@ -245,7 +243,8 @@ static map_word pcmcia_read8(struct map_info *map, unsigned long ofs)
245 return d; 243 return d;
246 244
247 d.x[0] = readb(win_base + ofs); 245 d.x[0] = readb(win_base + ofs);
248 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]);
249 return d; 248 return d;
250} 249}
251 250
@@ -259,7 +258,8 @@ static map_word pcmcia_read16(struct map_info *map, unsigned long ofs)
259 return d; 258 return d;
260 259
261 d.x[0] = readw(win_base + ofs); 260 d.x[0] = readw(win_base + ofs);
262 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]);
263 return d; 263 return d;
264} 264}
265 265
@@ -271,32 +271,34 @@ static void pcmcia_copy_from(struct map_info *map, void *to, unsigned long from,
271 if(DEV_REMOVED(map)) 271 if(DEV_REMOVED(map))
272 return; 272 return;
273 273
274 DEBUG(3, "to = %p from = %lu len = %u", to, from, len); 274 DEBUG(3, "to = %p from = %lu len = %zd", to, from, len);
275 memcpy_fromio(to, win_base + from, len); 275 memcpy_fromio(to, win_base + from, len);
276} 276}
277 277
278 278
279static 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)
280{ 280{
281 caddr_t win_base = (caddr_t)map->map_priv_2; 281 caddr_t win_base = (caddr_t)map->map_priv_2;
282 282
283 if(DEV_REMOVED(map)) 283 if(DEV_REMOVED(map))
284 return; 284 return;
285 285
286 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02x", adr, win_base + adr, d); 286 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%02lx",
287 writeb(d, win_base + adr); 287 adr, win_base + adr, d.x[0]);
288 writeb(d.x[0], win_base + adr);
288} 289}
289 290
290 291
291static 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)
292{ 293{
293 caddr_t win_base = (caddr_t)map->map_priv_2; 294 caddr_t win_base = (caddr_t)map->map_priv_2;
294 295
295 if(DEV_REMOVED(map)) 296 if(DEV_REMOVED(map))
296 return; 297 return;
297 298
298 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04x", adr, win_base + adr, d); 299 DEBUG(3, "adr = 0x%08lx (%p) data = 0x%04lx",
299 writew(d, win_base + adr); 300 adr, win_base + adr, d.x[0]);
301 writew(d.x[0], win_base + adr);
300} 302}
301 303
302 304
@@ -307,7 +309,7 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f
307 if(DEV_REMOVED(map)) 309 if(DEV_REMOVED(map))
308 return; 310 return;
309 311
310 DEBUG(3, "to = %lu from = %p len = %u", to, from, len); 312 DEBUG(3, "to = %lu from = %p len = %zd", to, from, len);
311 memcpy_toio(win_base + to, from, len); 313 memcpy_toio(win_base + to, from, len);
312} 314}
313 315
@@ -376,7 +378,8 @@ static int pcmciamtd_cistpl_jedec(struct pcmcia_device *p_dev,
376 if (!pcmcia_parse_tuple(tuple, &parse)) { 378 if (!pcmcia_parse_tuple(tuple, &parse)) {
377 cistpl_jedec_t *t = &parse.jedec; 379 cistpl_jedec_t *t = &parse.jedec;
378 for (i = 0; i < t->nid; i++) 380 for (i = 0; i < t->nid; i++)
379 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);
380 } 383 }
381 return -ENOSPC; 384 return -ENOSPC;
382} 385}
@@ -432,7 +435,7 @@ static int pcmciamtd_cistpl_geo(struct pcmcia_device *p_dev,
432} 435}
433 436
434 437
435static 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)
436{ 439{
437 int i; 440 int i;
438 441
@@ -477,7 +480,8 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link,
477 } 480 }
478 481
479 DEBUG(1, "Device: Size: %lu Width:%d Name: %s", 482 DEBUG(1, "Device: Size: %lu Width:%d Name: %s",
480 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);
481} 485}
482 486
483 487
@@ -490,7 +494,6 @@ static int pcmciamtd_config(struct pcmcia_device *link)
490{ 494{
491 struct pcmciamtd_dev *dev = link->priv; 495 struct pcmciamtd_dev *dev = link->priv;
492 struct mtd_info *mtd = NULL; 496 struct mtd_info *mtd = NULL;
493 cs_status_t status;
494 win_req_t req; 497 win_req_t req;
495 int ret; 498 int ret;
496 int i; 499 int i;
@@ -514,9 +517,11 @@ static int pcmciamtd_config(struct pcmcia_device *link)
514 if(setvpp == 1) 517 if(setvpp == 1)
515 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp; 518 dev->pcmcia_map.set_vpp = pcmciamtd_set_vpp;
516 519
517 /* 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
518 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
519 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 */
520 525
521 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; 526 req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE;
522 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;
@@ -544,7 +549,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
544 DEBUG(2, "dev->win_size = %d", dev->win_size); 549 DEBUG(2, "dev->win_size = %d", dev->win_size);
545 550
546 if(!dev->win_size) { 551 if(!dev->win_size) {
547 err("Cant allocate memory window"); 552 dev_err(&dev->p_dev->dev, "Cannot allocate memory window\n");
548 pcmciamtd_release(link); 553 pcmciamtd_release(link);
549 return -ENODEV; 554 return -ENODEV;
550 } 555 }
@@ -554,7 +559,8 @@ static int pcmciamtd_config(struct pcmcia_device *link)
554 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); 559 DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win);
555 dev->win_base = ioremap(req.Base, req.Size); 560 dev->win_base = ioremap(req.Base, req.Size);
556 if(!dev->win_base) { 561 if(!dev->win_base) {
557 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);
558 pcmciamtd_release(link); 564 pcmciamtd_release(link);
559 return -ENODEV; 565 return -ENODEV;
560 } 566 }
@@ -565,7 +571,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
565 dev->pcmcia_map.map_priv_1 = (unsigned long)dev; 571 dev->pcmcia_map.map_priv_1 = (unsigned long)dev;
566 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; 572 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win;
567 573
568 dev->vpp = (vpp) ? vpp : link->socket.socket.Vpp; 574 dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp;
569 link->conf.Attributes = 0; 575 link->conf.Attributes = 0;
570 if(setvpp == 2) { 576 if(setvpp == 2) {
571 link->conf.Vpp = dev->vpp; 577 link->conf.Vpp = dev->vpp;
@@ -601,7 +607,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
601 } 607 }
602 608
603 if(!mtd) { 609 if(!mtd) {
604 DEBUG(1, "Cant find an MTD"); 610 DEBUG(1, "Can not find an MTD");
605 pcmciamtd_release(link); 611 pcmciamtd_release(link);
606 return -ENODEV; 612 return -ENODEV;
607 } 613 }
@@ -612,8 +618,9 @@ static int pcmciamtd_config(struct pcmcia_device *link)
612 if(new_name) { 618 if(new_name) {
613 int size = 0; 619 int size = 0;
614 char unit = ' '; 620 char unit = ' ';
615 /* 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
616 size */ 622 * in the size
623 */
617 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */ 624 if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
618 size = mtd->size >> 10; 625 size = mtd->size >> 10;
619 unit = 'K'; 626 unit = 'K';
@@ -643,17 +650,15 @@ static int pcmciamtd_config(struct pcmcia_device *link)
643 if(add_mtd_device(mtd)) { 650 if(add_mtd_device(mtd)) {
644 map_destroy(mtd); 651 map_destroy(mtd);
645 dev->mtd_info = NULL; 652 dev->mtd_info = NULL;
646 err("Couldnt register MTD device"); 653 dev_err(&dev->p_dev->dev,
654 "Could not register the MTD device\n");
647 pcmciamtd_release(link); 655 pcmciamtd_release(link);
648 return -ENODEV; 656 return -ENODEV;
649 } 657 }
650 snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); 658 dev_info(&dev->p_dev->dev, "mtd%d: %s\n", mtd->index, mtd->name);
651 info("mtd%d: %s", mtd->index, mtd->name);
652 link->dev_node = &dev->node;
653 return 0; 659 return 0;
654 660
655 failed: 661 dev_err(&dev->p_dev->dev, "CS Error, exiting\n");
656 err("CS Error, exiting");
657 pcmciamtd_release(link); 662 pcmciamtd_release(link);
658 return -ENODEV; 663 return -ENODEV;
659} 664}
@@ -692,8 +697,9 @@ static void pcmciamtd_detach(struct pcmcia_device *link)
692 697
693 if(dev->mtd_info) { 698 if(dev->mtd_info) {
694 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);
695 map_destroy(dev->mtd_info); 702 map_destroy(dev->mtd_info);
696 info("mtd%d: Removed", dev->mtd_info->index);
697 } 703 }
698 704
699 pcmciamtd_release(link); 705 pcmciamtd_release(link);
@@ -737,8 +743,11 @@ static struct pcmcia_device_id pcmciamtd_ids[] = {
737 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8), 743 PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8),
738 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),
739 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),
740 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b), 748 PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b),
741 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),
742 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca), 751 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca),
743 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944), 752 PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944),
744 /* the following was commented out in pcmcia-cs-3.2.7 */ 753 /* the following was commented out in pcmcia-cs-3.2.7 */