diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-21 17:25:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-21 17:25:16 -0400 |
commit | b65378898c2eefb20f419632c1199bc0592e2f79 (patch) | |
tree | 052bb72d329c44790f91fc8097b8500d4774d02c /drivers/mtd | |
parent | 157b6ceb13e4b4148ee03dd517dbe88748943125 (diff) | |
parent | 5b917a1420d3d1a9c8da49fb0090692dc9aaee86 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (22 commits)
pcmcia: synclink_cs: fix information leak to userland
pcmcia: don't call flush_scheduled_work() spuriously
serial_cs: drop spurious flush_scheduled_work() call
pcmcia/yenta: guide users in case of problems with O2-bridges
pcmcia: fix unused function compile warning
pcmcia: vrc4173_cardu: Fix error path for pci_release_regions and pci_disable_device
pcmcia: add a few debug statements
pcmcia: remove obsolete and wrong comments
pcmcia: avoid messages on module (un)loading
pcmcia: move driver name to struct pcmcia_driver
pcmcia: remove the "Finally, report what we've done" message
pcmcia: use autoconfiguration feature for ioports and iomem
pcmcia: introduce autoconfiguration feature
pcmcia: Documentation update
pcmcia: convert pcmcia_request_configuration to pcmcia_enable_device
pcmcia: move config_{base,index,regs} to struct pcmcia_device
pcmcia: simplify IntType
pcmcia: simplify Status, ExtStatus register access
pcmcia: remove Pin, Copy configuration register access
pcmcia: move Vpp setup to struct pcmcia_device
...
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 102 |
1 files changed, 35 insertions, 67 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index e9ca5ba7d9d2..57a1acfe22c4 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -16,7 +16,6 @@ | |||
16 | #include <asm/io.h> | 16 | #include <asm/io.h> |
17 | #include <asm/system.h> | 17 | #include <asm/system.h> |
18 | 18 | ||
19 | #include <pcmcia/cs.h> | ||
20 | #include <pcmcia/cistpl.h> | 19 | #include <pcmcia/cistpl.h> |
21 | #include <pcmcia/ds.h> | 20 | #include <pcmcia/ds.h> |
22 | 21 | ||
@@ -101,7 +100,7 @@ MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)") | |||
101 | static caddr_t remap_window(struct map_info *map, unsigned long to) | 100 | static caddr_t remap_window(struct map_info *map, unsigned long to) |
102 | { | 101 | { |
103 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; | 102 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
104 | window_handle_t win = (window_handle_t)map->map_priv_2; | 103 | struct resource *win = (struct resource *) map->map_priv_2; |
105 | unsigned int offset; | 104 | unsigned int offset; |
106 | int ret; | 105 | int ret; |
107 | 106 | ||
@@ -316,30 +315,19 @@ static void pcmciamtd_set_vpp(struct map_info *map, int on) | |||
316 | { | 315 | { |
317 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; | 316 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
318 | struct pcmcia_device *link = dev->p_dev; | 317 | struct pcmcia_device *link = dev->p_dev; |
319 | modconf_t mod; | ||
320 | int ret; | ||
321 | |||
322 | mod.Attributes = CONF_VPP1_CHANGE_VALID | CONF_VPP2_CHANGE_VALID; | ||
323 | mod.Vcc = 0; | ||
324 | mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0; | ||
325 | 318 | ||
326 | DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); | 319 | DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); |
327 | ret = pcmcia_modify_configuration(link, &mod); | 320 | pcmcia_fixup_vpp(link, on ? dev->vpp : 0); |
328 | } | 321 | } |
329 | 322 | ||
330 | 323 | ||
331 | /* After a card is removed, pcmciamtd_release() will unregister the | ||
332 | * device, and release the PCMCIA configuration. If the device is | ||
333 | * still open, this will be postponed until it is closed. | ||
334 | */ | ||
335 | |||
336 | static void pcmciamtd_release(struct pcmcia_device *link) | 324 | static void pcmciamtd_release(struct pcmcia_device *link) |
337 | { | 325 | { |
338 | struct pcmciamtd_dev *dev = link->priv; | 326 | struct pcmciamtd_dev *dev = link->priv; |
339 | 327 | ||
340 | DEBUG(3, "link = 0x%p", link); | 328 | DEBUG(3, "link = 0x%p", link); |
341 | 329 | ||
342 | if (link->win) { | 330 | if (link->resource[2]->end) { |
343 | if(dev->win_base) { | 331 | if(dev->win_base) { |
344 | iounmap(dev->win_base); | 332 | iounmap(dev->win_base); |
345 | dev->win_base = NULL; | 333 | dev->win_base = NULL; |
@@ -482,18 +470,12 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *p_dev | |||
482 | } | 470 | } |
483 | 471 | ||
484 | 472 | ||
485 | /* pcmciamtd_config() is scheduled to run after a CARD_INSERTION event | ||
486 | * is received, to configure the PCMCIA socket, and to make the | ||
487 | * MTD device available to the system. | ||
488 | */ | ||
489 | |||
490 | static int pcmciamtd_config(struct pcmcia_device *link) | 473 | static int pcmciamtd_config(struct pcmcia_device *link) |
491 | { | 474 | { |
492 | struct pcmciamtd_dev *dev = link->priv; | 475 | struct pcmciamtd_dev *dev = link->priv; |
493 | struct mtd_info *mtd = NULL; | 476 | struct mtd_info *mtd = NULL; |
494 | win_req_t req; | ||
495 | int ret; | 477 | int ret; |
496 | int i; | 478 | int i, j = 0; |
497 | static char *probes[] = { "jedec_probe", "cfi_probe" }; | 479 | static char *probes[] = { "jedec_probe", "cfi_probe" }; |
498 | int new_name = 0; | 480 | int new_name = 0; |
499 | 481 | ||
@@ -520,28 +502,34 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
520 | * smaller windows until we succeed | 502 | * smaller windows until we succeed |
521 | */ | 503 | */ |
522 | 504 | ||
523 | req.Attributes = WIN_MEMORY_TYPE_CM | WIN_ENABLE; | 505 | link->resource[2]->flags |= WIN_MEMORY_TYPE_CM | WIN_ENABLE; |
524 | req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; | 506 | link->resource[2]->flags |= (dev->pcmcia_map.bankwidth == 1) ? |
525 | req.Base = 0; | 507 | WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; |
526 | req.AccessSpeed = mem_speed; | 508 | link->resource[2]->start = 0; |
527 | link->win = (window_handle_t)link; | 509 | link->resource[2]->end = (force_size) ? force_size << 20 : |
528 | req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR; | 510 | MAX_PCMCIA_ADDR; |
529 | dev->win_size = 0; | 511 | dev->win_size = 0; |
530 | 512 | ||
531 | do { | 513 | do { |
532 | int ret; | 514 | int ret; |
533 | DEBUG(2, "requesting window with size = %dKiB memspeed = %d", | 515 | DEBUG(2, "requesting window with size = %luKiB memspeed = %d", |
534 | req.Size >> 10, req.AccessSpeed); | 516 | (unsigned long) resource_size(link->resource[2]) >> 10, |
535 | ret = pcmcia_request_window(link, &req, &link->win); | 517 | mem_speed); |
518 | ret = pcmcia_request_window(link, link->resource[2], mem_speed); | ||
536 | DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); | 519 | DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); |
537 | if(ret) { | 520 | if(ret) { |
538 | req.Size >>= 1; | 521 | j++; |
522 | link->resource[2]->start = 0; | ||
523 | link->resource[2]->end = (force_size) ? | ||
524 | force_size << 20 : MAX_PCMCIA_ADDR; | ||
525 | link->resource[2]->end >>= j; | ||
539 | } else { | 526 | } else { |
540 | DEBUG(2, "Got window of size %dKiB", req.Size >> 10); | 527 | DEBUG(2, "Got window of size %luKiB", (unsigned long) |
541 | dev->win_size = req.Size; | 528 | resource_size(link->resource[2]) >> 10); |
529 | dev->win_size = resource_size(link->resource[2]); | ||
542 | break; | 530 | break; |
543 | } | 531 | } |
544 | } while(req.Size >= 0x1000); | 532 | } while (link->resource[2]->end >= 0x1000); |
545 | 533 | ||
546 | DEBUG(2, "dev->win_size = %d", dev->win_size); | 534 | DEBUG(2, "dev->win_size = %d", dev->win_size); |
547 | 535 | ||
@@ -553,33 +541,31 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
553 | DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); | 541 | DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); |
554 | 542 | ||
555 | /* Get write protect status */ | 543 | /* Get write protect status */ |
556 | DEBUG(2, "window handle = 0x%8.8lx", (unsigned long)link->win); | 544 | dev->win_base = ioremap(link->resource[2]->start, |
557 | dev->win_base = ioremap(req.Base, req.Size); | 545 | resource_size(link->resource[2])); |
558 | if(!dev->win_base) { | 546 | if(!dev->win_base) { |
559 | dev_err(&dev->p_dev->dev, "ioremap(%lu, %u) failed\n", | 547 | dev_err(&dev->p_dev->dev, "ioremap(%pR) failed\n", |
560 | req.Base, req.Size); | 548 | link->resource[2]); |
561 | pcmciamtd_release(link); | 549 | pcmciamtd_release(link); |
562 | return -ENODEV; | 550 | return -ENODEV; |
563 | } | 551 | } |
564 | DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x", | 552 | DEBUG(1, "mapped window dev = %p @ %pR, base = %p", |
565 | dev, req.Base, dev->win_base, req.Size); | 553 | dev, link->resource[2], dev->win_base); |
566 | 554 | ||
567 | dev->offset = 0; | 555 | dev->offset = 0; |
568 | dev->pcmcia_map.map_priv_1 = (unsigned long)dev; | 556 | dev->pcmcia_map.map_priv_1 = (unsigned long)dev; |
569 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; | 557 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->resource[2]; |
570 | 558 | ||
571 | dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp; | 559 | dev->vpp = (vpp) ? vpp : link->socket->socket.Vpp; |
572 | link->conf.Attributes = 0; | ||
573 | if(setvpp == 2) { | 560 | if(setvpp == 2) { |
574 | link->conf.Vpp = dev->vpp; | 561 | link->vpp = dev->vpp; |
575 | } else { | 562 | } else { |
576 | link->conf.Vpp = 0; | 563 | link->vpp = 0; |
577 | } | 564 | } |
578 | 565 | ||
579 | link->conf.IntType = INT_MEMORY; | 566 | link->config_index = 0; |
580 | link->conf.ConfigIndex = 0; | ||
581 | DEBUG(2, "Setting Configuration"); | 567 | DEBUG(2, "Setting Configuration"); |
582 | ret = pcmcia_request_configuration(link, &link->conf); | 568 | ret = pcmcia_enable_device(link); |
583 | if (ret != 0) { | 569 | if (ret != 0) { |
584 | if (dev->win_base) { | 570 | if (dev->win_base) { |
585 | iounmap(dev->win_base); | 571 | iounmap(dev->win_base); |
@@ -680,12 +666,6 @@ static int pcmciamtd_resume(struct pcmcia_device *dev) | |||
680 | } | 666 | } |
681 | 667 | ||
682 | 668 | ||
683 | /* This deletes a driver "instance". The device is de-registered | ||
684 | * with Card Services. If it has been released, all local data | ||
685 | * structures are freed. Otherwise, the structures will be freed | ||
686 | * when the device is released. | ||
687 | */ | ||
688 | |||
689 | static void pcmciamtd_detach(struct pcmcia_device *link) | 669 | static void pcmciamtd_detach(struct pcmcia_device *link) |
690 | { | 670 | { |
691 | struct pcmciamtd_dev *dev = link->priv; | 671 | struct pcmciamtd_dev *dev = link->priv; |
@@ -703,11 +683,6 @@ static void pcmciamtd_detach(struct pcmcia_device *link) | |||
703 | } | 683 | } |
704 | 684 | ||
705 | 685 | ||
706 | /* pcmciamtd_attach() creates an "instance" of the driver, allocating | ||
707 | * local data structures for one device. The device is registered | ||
708 | * with Card Services. | ||
709 | */ | ||
710 | |||
711 | static int pcmciamtd_probe(struct pcmcia_device *link) | 686 | static int pcmciamtd_probe(struct pcmcia_device *link) |
712 | { | 687 | { |
713 | struct pcmciamtd_dev *dev; | 688 | struct pcmciamtd_dev *dev; |
@@ -720,9 +695,6 @@ static int pcmciamtd_probe(struct pcmcia_device *link) | |||
720 | dev->p_dev = link; | 695 | dev->p_dev = link; |
721 | link->priv = dev; | 696 | link->priv = dev; |
722 | 697 | ||
723 | link->conf.Attributes = 0; | ||
724 | link->conf.IntType = INT_MEMORY; | ||
725 | |||
726 | return pcmciamtd_config(link); | 698 | return pcmciamtd_config(link); |
727 | } | 699 | } |
728 | 700 | ||
@@ -757,9 +729,7 @@ static struct pcmcia_device_id pcmciamtd_ids[] = { | |||
757 | MODULE_DEVICE_TABLE(pcmcia, pcmciamtd_ids); | 729 | MODULE_DEVICE_TABLE(pcmcia, pcmciamtd_ids); |
758 | 730 | ||
759 | static struct pcmcia_driver pcmciamtd_driver = { | 731 | static struct pcmcia_driver pcmciamtd_driver = { |
760 | .drv = { | 732 | .name = "pcmciamtd", |
761 | .name = "pcmciamtd" | ||
762 | }, | ||
763 | .probe = pcmciamtd_probe, | 733 | .probe = pcmciamtd_probe, |
764 | .remove = pcmciamtd_detach, | 734 | .remove = pcmciamtd_detach, |
765 | .owner = THIS_MODULE, | 735 | .owner = THIS_MODULE, |
@@ -771,8 +741,6 @@ static struct pcmcia_driver pcmciamtd_driver = { | |||
771 | 741 | ||
772 | static int __init init_pcmciamtd(void) | 742 | static int __init init_pcmciamtd(void) |
773 | { | 743 | { |
774 | info(DRIVER_DESC); | ||
775 | |||
776 | if(bankwidth && bankwidth != 1 && bankwidth != 2) { | 744 | if(bankwidth && bankwidth != 1 && bankwidth != 2) { |
777 | info("bad bankwidth (%d), using default", bankwidth); | 745 | info("bad bankwidth (%d), using default", bankwidth); |
778 | bankwidth = 2; | 746 | bankwidth = 2; |