aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
committerLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
commit3d5271f9883cba7b54762bc4fe027d4172f06db7 (patch)
treeab8a881a14478598a0c8bda0d26c62cdccfffd6d /drivers/pcmcia
parent378b2556f4e09fa6f87ff0cb5c4395ff28257d02 (diff)
parent9115a6c787596e687df03010d97fccc5e0762506 (diff)
Pull release into acpica branch
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/Kconfig12
-rw-r--r--drivers/pcmcia/Makefile6
-rw-r--r--drivers/pcmcia/au1000_db1x00.c22
-rw-r--r--drivers/pcmcia/au1000_generic.c31
-rw-r--r--drivers/pcmcia/au1000_generic.h6
-rw-r--r--drivers/pcmcia/au1000_pb1x00.c2
-rw-r--r--drivers/pcmcia/au1000_xxs1500.c2
-rw-r--r--drivers/pcmcia/cardbus.c5
-rw-r--r--drivers/pcmcia/cistpl.c12
-rw-r--r--drivers/pcmcia/cs.c15
-rw-r--r--drivers/pcmcia/ds.c9
-rw-r--r--drivers/pcmcia/hd64465_ss.c22
-rw-r--r--drivers/pcmcia/i82365.c43
-rw-r--r--drivers/pcmcia/m32r_cfc.c26
-rw-r--r--drivers/pcmcia/m32r_pcc.c23
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c1272
-rw-r--r--drivers/pcmcia/omap_cf.c21
-rw-r--r--drivers/pcmcia/pxa2xx_base.c27
-rw-r--r--drivers/pcmcia/pxa2xx_mainstone.c2
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c151
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c18
-rw-r--r--drivers/pcmcia/sa1100_generic.c28
-rw-r--r--drivers/pcmcia/sa1111_generic.c2
-rw-r--r--drivers/pcmcia/soc_common.c14
-rw-r--r--drivers/pcmcia/socket_sysfs.c6
-rw-r--r--drivers/pcmcia/tcic.c22
-rw-r--r--drivers/pcmcia/ti113x.h118
-rw-r--r--drivers/pcmcia/vrc4171_card.c25
-rw-r--r--drivers/pcmcia/yenta_socket.c104
29 files changed, 1686 insertions, 360 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index ddc741e6ecbf..309eb557f9a3 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -146,7 +146,7 @@ config I82365
146 146
147config TCIC 147config TCIC
148 tristate "Databook TCIC host bridge support" 148 tristate "Databook TCIC host bridge support"
149 depends on PCMCIA 149 depends on PCMCIA && ISA
150 select PCCARD_NONSTATIC 150 select PCCARD_NONSTATIC
151 help 151 help
152 Say Y here to include support for the Databook TCIC family of PCMCIA 152 Say Y here to include support for the Databook TCIC family of PCMCIA
@@ -154,6 +154,16 @@ config TCIC
154 "Bridge" is the name used for the hardware inside your computer that 154 "Bridge" is the name used for the hardware inside your computer that
155 PCMCIA cards are plugged into. If unsure, say N. 155 PCMCIA cards are plugged into. If unsure, say N.
156 156
157config PCMCIA_M8XX
158 tristate "MPC8xx PCMCIA support"
159 depends on PCMCIA && PPC && 8xx
160 select PCCARD_NONSTATIC
161 help
162 Say Y here to include support for PowerPC 8xx series PCMCIA
163 controller.
164
165 This driver is also available as a module called m8xx_pcmcia.
166
157config HD64465_PCMCIA 167config HD64465_PCMCIA
158 tristate "HD64465 host bridge support" 168 tristate "HD64465 host bridge support"
159 depends on HD64465 && PCMCIA 169 depends on HD64465 && PCMCIA
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index a41fbb38fdcb..bcecf5133b7e 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_PD6729) += pd6729.o
25obj-$(CONFIG_I82365) += i82365.o 25obj-$(CONFIG_I82365) += i82365.o
26obj-$(CONFIG_I82092) += i82092.o 26obj-$(CONFIG_I82092) += i82092.o
27obj-$(CONFIG_TCIC) += tcic.o 27obj-$(CONFIG_TCIC) += tcic.o
28obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
28obj-$(CONFIG_HD64465_PCMCIA) += hd64465_ss.o 29obj-$(CONFIG_HD64465_PCMCIA) += hd64465_ss.o
29obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o 30obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o
30obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o 31obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o
@@ -42,12 +43,14 @@ pxa2xx_core-y += soc_common.o pxa2xx_base.o
42au1x00_ss-y += au1000_generic.o 43au1x00_ss-y += au1000_generic.o
43au1x00_ss-$(CONFIG_MIPS_PB1000) += au1000_pb1x00.o 44au1x00_ss-$(CONFIG_MIPS_PB1000) += au1000_pb1x00.o
44au1x00_ss-$(CONFIG_MIPS_PB1100) += au1000_pb1x00.o 45au1x00_ss-$(CONFIG_MIPS_PB1100) += au1000_pb1x00.o
46au1x00_ss-$(CONFIG_MIPS_PB1200) += au1000_db1x00.o
45au1x00_ss-$(CONFIG_MIPS_PB1500) += au1000_pb1x00.o 47au1x00_ss-$(CONFIG_MIPS_PB1500) += au1000_pb1x00.o
46au1x00_ss-$(CONFIG_MIPS_DB1000) += au1000_db1x00.o 48au1x00_ss-$(CONFIG_MIPS_DB1000) += au1000_db1x00.o
47au1x00_ss-$(CONFIG_MIPS_DB1100) += au1000_db1x00.o 49au1x00_ss-$(CONFIG_MIPS_DB1100) += au1000_db1x00.o
50au1x00_ss-$(CONFIG_MIPS_DB1200) += au1000_db1x00.o
48au1x00_ss-$(CONFIG_MIPS_DB1500) += au1000_db1x00.o 51au1x00_ss-$(CONFIG_MIPS_DB1500) += au1000_db1x00.o
49au1x00_ss-$(CONFIG_MIPS_DB1550) += au1000_db1x00.o 52au1x00_ss-$(CONFIG_MIPS_DB1550) += au1000_db1x00.o
50au1x00_ss-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o 53au1x00_ss-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o
51 54
52sa1111_cs-y += sa1111_generic.o 55sa1111_cs-y += sa1111_generic.o
53sa1111_cs-$(CONFIG_ASSABET_NEPONSET) += sa1100_neponset.o 56sa1111_cs-$(CONFIG_ASSABET_NEPONSET) += sa1100_neponset.o
@@ -57,6 +60,7 @@ sa1111_cs-$(CONFIG_SA1100_JORNADA720) += sa1100_jornada720.o
57sa1100_cs-y += sa1100_generic.o 60sa1100_cs-y += sa1100_generic.o
58sa1100_cs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o 61sa1100_cs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o
59sa1100_cs-$(CONFIG_SA1100_CERF) += sa1100_cerf.o 62sa1100_cs-$(CONFIG_SA1100_CERF) += sa1100_cerf.o
63sa1100_cs-$(CONFIG_SA1100_COLLIE) += pxa2xx_sharpsl.o
60sa1100_cs-$(CONFIG_SA1100_H3600) += sa1100_h3600.o 64sa1100_cs-$(CONFIG_SA1100_H3600) += sa1100_h3600.o
61sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o 65sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o
62sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o 66sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c
index 42cf8bfbcc98..abc13f28ba3f 100644
--- a/drivers/pcmcia/au1000_db1x00.c
+++ b/drivers/pcmcia/au1000_db1x00.c
@@ -30,6 +30,7 @@
30 * 30 *
31 */ 31 */
32 32
33#include <linux/config.h>
33#include <linux/module.h> 34#include <linux/module.h>
34#include <linux/kernel.h> 35#include <linux/kernel.h>
35#include <linux/errno.h> 36#include <linux/errno.h>
@@ -40,7 +41,15 @@
40#include <asm/irq.h> 41#include <asm/irq.h>
41#include <asm/signal.h> 42#include <asm/signal.h>
42#include <asm/mach-au1x00/au1000.h> 43#include <asm/mach-au1x00/au1000.h>
43#include <asm/mach-db1x00/db1x00.h> 44
45#if defined(CONFIG_MIPS_DB1200)
46 #include <db1200.h>
47#elif defined(CONFIG_MIPS_PB1200)
48 #include <pb1200.h>
49#else
50 #include <asm/mach-db1x00/db1x00.h>
51 static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
52#endif
44 53
45#include "au1000_generic.h" 54#include "au1000_generic.h"
46 55
@@ -50,7 +59,6 @@
50#define debug(x,args...) 59#define debug(x,args...)
51#endif 60#endif
52 61
53static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
54 62
55struct au1000_pcmcia_socket au1000_pcmcia_socket[PCMCIA_NUM_SOCKS]; 63struct au1000_pcmcia_socket au1000_pcmcia_socket[PCMCIA_NUM_SOCKS];
56extern int au1x00_pcmcia_socket_probe(struct device *, struct pcmcia_low_level *, int, int); 64extern int au1x00_pcmcia_socket_probe(struct device *, struct pcmcia_low_level *, int, int);
@@ -59,6 +67,8 @@ static int db1x00_pcmcia_hw_init(struct au1000_pcmcia_socket *skt)
59{ 67{
60#ifdef CONFIG_MIPS_DB1550 68#ifdef CONFIG_MIPS_DB1550
61 skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_3; 69 skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_3;
70#elif defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
71 skt->irq = skt->nr ? BOARD_PC1_INT : BOARD_PC0_INT;
62#else 72#else
63 skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_2; 73 skt->irq = skt->nr ? AU1000_GPIO_5 : AU1000_GPIO_2;
64#endif 74#endif
@@ -85,11 +95,19 @@ db1x00_pcmcia_socket_state(struct au1000_pcmcia_socket *skt, struct pcmcia_state
85 switch (skt->nr) { 95 switch (skt->nr) {
86 case 0: 96 case 0:
87 vs = bcsr->status & 0x3; 97 vs = bcsr->status & 0x3;
98#if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
99 inserted = BOARD_CARD_INSERTED(0);
100#else
88 inserted = !(bcsr->status & (1<<4)); 101 inserted = !(bcsr->status & (1<<4));
102#endif
89 break; 103 break;
90 case 1: 104 case 1:
91 vs = (bcsr->status & 0xC)>>2; 105 vs = (bcsr->status & 0xC)>>2;
106#if defined(CONFIG_MIPS_DB1200) || defined(CONFIG_MIPS_PB1200)
107 inserted = BOARD_CARD_INSERTED(1);
108#else
92 inserted = !(bcsr->status & (1<<5)); 109 inserted = !(bcsr->status & (1<<5));
110#endif
93 break; 111 break;
94 default:/* should never happen */ 112 default:/* should never happen */
95 return; 113 return;
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 470ef756252e..87302c548c24 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -42,7 +42,7 @@
42#include <linux/notifier.h> 42#include <linux/notifier.h>
43#include <linux/interrupt.h> 43#include <linux/interrupt.h>
44#include <linux/spinlock.h> 44#include <linux/spinlock.h>
45#include <linux/device.h> 45#include <linux/platform_device.h>
46 46
47#include <asm/io.h> 47#include <asm/io.h>
48#include <asm/irq.h> 48#include <asm/irq.h>
@@ -490,7 +490,7 @@ int au1x00_drv_pcmcia_remove(struct device *dev)
490 flush_scheduled_work(); 490 flush_scheduled_work();
491 skt->ops->hw_shutdown(skt); 491 skt->ops->hw_shutdown(skt);
492 au1x00_pcmcia_config_skt(skt, &dead_socket); 492 au1x00_pcmcia_config_skt(skt, &dead_socket);
493 iounmap(skt->virt_io); 493 iounmap(skt->virt_io + (u32)mips_io_port_base);
494 skt->virt_io = NULL; 494 skt->virt_io = NULL;
495 } 495 }
496 496
@@ -519,36 +519,15 @@ static int au1x00_drv_pcmcia_probe(struct device *dev)
519} 519}
520 520
521 521
522static int au1x00_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level)
523{
524 int ret = 0;
525 if (level == SUSPEND_SAVE_STATE)
526 ret = pcmcia_socket_dev_suspend(dev, state);
527 return ret;
528}
529
530static int au1x00_drv_pcmcia_resume(struct device *dev, u32 level)
531{
532 int ret = 0;
533 if (level == RESUME_RESTORE_STATE)
534 ret = pcmcia_socket_dev_resume(dev);
535 return ret;
536}
537
538
539static struct device_driver au1x00_pcmcia_driver = { 522static struct device_driver au1x00_pcmcia_driver = {
540 .probe = au1x00_drv_pcmcia_probe, 523 .probe = au1x00_drv_pcmcia_probe,
541 .remove = au1x00_drv_pcmcia_remove, 524 .remove = au1x00_drv_pcmcia_remove,
542 .name = "au1x00-pcmcia", 525 .name = "au1x00-pcmcia",
543 .bus = &platform_bus_type, 526 .bus = &platform_bus_type,
544 .suspend = au1x00_drv_pcmcia_suspend, 527 .suspend = pcmcia_socket_dev_suspend,
545 .resume = au1x00_drv_pcmcia_resume 528 .resume = pcmcia_socket_dev_resume,
546}; 529};
547 530
548static struct platform_device au1x00_device = {
549 .name = "au1x00-pcmcia",
550 .id = 0,
551};
552 531
553/* au1x00_pcmcia_init() 532/* au1x00_pcmcia_init()
554 * 533 *
@@ -562,7 +541,6 @@ static int __init au1x00_pcmcia_init(void)
562 int error = 0; 541 int error = 0;
563 if ((error = driver_register(&au1x00_pcmcia_driver))) 542 if ((error = driver_register(&au1x00_pcmcia_driver)))
564 return error; 543 return error;
565 platform_device_register(&au1x00_device);
566 return error; 544 return error;
567} 545}
568 546
@@ -573,7 +551,6 @@ static int __init au1x00_pcmcia_init(void)
573static void __exit au1x00_pcmcia_exit(void) 551static void __exit au1x00_pcmcia_exit(void)
574{ 552{
575 driver_unregister(&au1x00_pcmcia_driver); 553 driver_unregister(&au1x00_pcmcia_driver);
576 platform_device_unregister(&au1x00_device);
577} 554}
578 555
579module_init(au1x00_pcmcia_init); 556module_init(au1x00_pcmcia_init);
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h
index d5122b1ea94b..f2c970b5f4ff 100644
--- a/drivers/pcmcia/au1000_generic.h
+++ b/drivers/pcmcia/au1000_generic.h
@@ -22,6 +22,8 @@
22#define __ASM_AU1000_PCMCIA_H 22#define __ASM_AU1000_PCMCIA_H
23 23
24/* include the world */ 24/* include the world */
25#include <linux/config.h>
26
25#include <pcmcia/cs_types.h> 27#include <pcmcia/cs_types.h>
26#include <pcmcia/cs.h> 28#include <pcmcia/cs.h>
27#include <pcmcia/ss.h> 29#include <pcmcia/ss.h>
@@ -44,13 +46,13 @@
44/* pcmcia socket 1 needs external glue logic so the memory map 46/* pcmcia socket 1 needs external glue logic so the memory map
45 * differs from board to board. 47 * differs from board to board.
46 */ 48 */
47#if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1550) 49#if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1550) || defined(CONFIG_MIPS_PB1200)
48#define AU1X_SOCK1_IO 0xF08000000 50#define AU1X_SOCK1_IO 0xF08000000
49#define AU1X_SOCK1_PHYS_ATTR 0xF48000000 51#define AU1X_SOCK1_PHYS_ATTR 0xF48000000
50#define AU1X_SOCK1_PHYS_MEM 0xF88000000 52#define AU1X_SOCK1_PHYS_MEM 0xF88000000
51#define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4800000 53#define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4800000
52#define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8800000 54#define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8800000
53#elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550) 55#elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550) || defined(CONFIG_MIPS_DB1200)
54#define AU1X_SOCK1_IO 0xF04000000 56#define AU1X_SOCK1_IO 0xF04000000
55#define AU1X_SOCK1_PHYS_ATTR 0xF44000000 57#define AU1X_SOCK1_PHYS_ATTR 0xF44000000
56#define AU1X_SOCK1_PHYS_MEM 0xF84000000 58#define AU1X_SOCK1_PHYS_MEM 0xF84000000
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c
index d414a3bb50b9..fd5522ede867 100644
--- a/drivers/pcmcia/au1000_pb1x00.c
+++ b/drivers/pcmcia/au1000_pb1x00.c
@@ -21,6 +21,7 @@
21 * with this program; if not, write to the Free Software Foundation, Inc., 21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 22 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 */ 23 */
24#include <linux/config.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/init.h> 26#include <linux/init.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
@@ -30,7 +31,6 @@
30#include <linux/timer.h> 31#include <linux/timer.h>
31#include <linux/mm.h> 32#include <linux/mm.h>
32#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
33#include <linux/version.h>
34#include <linux/types.h> 34#include <linux/types.h>
35 35
36#include <pcmcia/cs_types.h> 36#include <pcmcia/cs_types.h>
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c
index f113b69d699b..01874b0bb03b 100644
--- a/drivers/pcmcia/au1000_xxs1500.c
+++ b/drivers/pcmcia/au1000_xxs1500.c
@@ -27,7 +27,6 @@
27 */ 27 */
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/config.h>
31#include <linux/delay.h> 30#include <linux/delay.h>
32#include <linux/ioport.h> 31#include <linux/ioport.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
@@ -35,7 +34,6 @@
35#include <linux/timer.h> 34#include <linux/timer.h>
36#include <linux/mm.h> 35#include <linux/mm.h>
37#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
38#include <linux/version.h>
39#include <linux/types.h> 37#include <linux/types.h>
40 38
41#include <pcmcia/cs_types.h> 39#include <pcmcia/cs_types.h>
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 1d755e20880c..3f6d51d11374 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -228,6 +228,11 @@ int cb_alloc(struct pcmcia_socket * s)
228 pci_bus_size_bridges(bus); 228 pci_bus_size_bridges(bus);
229 pci_bus_assign_resources(bus); 229 pci_bus_assign_resources(bus);
230 cardbus_assign_irqs(bus, s->pci_irq); 230 cardbus_assign_irqs(bus, s->pci_irq);
231
232 /* socket specific tune function */
233 if (s->tune_bridge)
234 s->tune_bridge(s, bus);
235
231 pci_enable_bridges(bus); 236 pci_enable_bridges(bus);
232 pci_bus_add_devices(bus); 237 pci_bus_add_devices(bus);
233 238
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 3afb682255a0..2dc3e611a9a3 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -334,10 +334,8 @@ void destroy_cis_cache(struct pcmcia_socket *s)
334 /* 334 /*
335 * If there was a fake CIS, destroy that as well. 335 * If there was a fake CIS, destroy that as well.
336 */ 336 */
337 if (s->fake_cis) { 337 kfree(s->fake_cis);
338 kfree(s->fake_cis); 338 s->fake_cis = NULL;
339 s->fake_cis = NULL;
340 }
341} 339}
342EXPORT_SYMBOL(destroy_cis_cache); 340EXPORT_SYMBOL(destroy_cis_cache);
343 341
@@ -386,10 +384,8 @@ int verify_cis_cache(struct pcmcia_socket *s)
386 384
387int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) 385int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis)
388{ 386{
389 if (s->fake_cis != NULL) { 387 kfree(s->fake_cis);
390 kfree(s->fake_cis); 388 s->fake_cis = NULL;
391 s->fake_cis = NULL;
392 }
393 if (cis->Length > CISTPL_MAX_CIS_SIZE) 389 if (cis->Length > CISTPL_MAX_CIS_SIZE)
394 return CS_BAD_SIZE; 390 return CS_BAD_SIZE;
395 s->fake_cis = kmalloc(cis->Length, GFP_KERNEL); 391 s->fake_cis = kmalloc(cis->Length, GFP_KERNEL);
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index fabd3529cebc..a30aa74304a2 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -331,10 +331,8 @@ static void shutdown_socket(struct pcmcia_socket *s)
331 cb_free(s); 331 cb_free(s);
332#endif 332#endif
333 s->functions = 0; 333 s->functions = 0;
334 if (s->config) { 334 kfree(s->config);
335 kfree(s->config); 335 s->config = NULL;
336 s->config = NULL;
337 }
338 336
339 { 337 {
340 int status; 338 int status;
@@ -515,6 +513,11 @@ static int socket_insert(struct pcmcia_socket *skt)
515 ret = socket_setup(skt, setup_delay); 513 ret = socket_setup(skt, setup_delay);
516 if (ret == CS_SUCCESS) { 514 if (ret == CS_SUCCESS) {
517 skt->state |= SOCKET_PRESENT; 515 skt->state |= SOCKET_PRESENT;
516
517 printk(KERN_NOTICE "pccard: %s card inserted into slot %d\n",
518 (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA",
519 skt->sock);
520
518#ifdef CONFIG_CARDBUS 521#ifdef CONFIG_CARDBUS
519 if (skt->state & SOCKET_CARDBUS) { 522 if (skt->state & SOCKET_CARDBUS) {
520 cb_alloc(skt); 523 cb_alloc(skt);
@@ -600,6 +603,7 @@ static int socket_resume(struct pcmcia_socket *skt)
600 603
601static void socket_remove(struct pcmcia_socket *skt) 604static void socket_remove(struct pcmcia_socket *skt)
602{ 605{
606 printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock);
603 socket_shutdown(skt); 607 socket_shutdown(skt);
604 cs_socket_put(skt); 608 cs_socket_put(skt);
605} 609}
@@ -689,6 +693,9 @@ static int pccardd(void *__skt)
689 schedule(); 693 schedule();
690 try_to_freeze(); 694 try_to_freeze();
691 } 695 }
696 /* make sure we are running before we exit */
697 set_current_state(TASK_RUNNING);
698
692 remove_wait_queue(&skt->thread_wait, &wait); 699 remove_wait_queue(&skt->thread_wait, &wait);
693 700
694 /* remove from the device core */ 701 /* remove from the device core */
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 080608c7381a..7f8219f3fd9e 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -544,6 +544,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
544 list_add_tail(&p_dev->socket_device_list, &s->devices_list); 544 list_add_tail(&p_dev->socket_device_list, &s->devices_list);
545 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 545 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
546 546
547 printk(KERN_NOTICE "pcmcia: registering new device %s\n",
548 p_dev->devname);
549
547 pcmcia_device_query(p_dev); 550 pcmcia_device_query(p_dev);
548 551
549 if (device_register(&p_dev->dev)) { 552 if (device_register(&p_dev->dev)) {
@@ -1157,7 +1160,8 @@ static struct pcmcia_callback pcmcia_bus_callback = {
1157 .requery = pcmcia_bus_rescan, 1160 .requery = pcmcia_bus_rescan,
1158}; 1161};
1159 1162
1160static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) 1163static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1164 struct class_interface *class_intf)
1161{ 1165{
1162 struct pcmcia_socket *socket = class_get_devdata(class_dev); 1166 struct pcmcia_socket *socket = class_get_devdata(class_dev);
1163 int ret; 1167 int ret;
@@ -1192,7 +1196,8 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev)
1192 return 0; 1196 return 0;
1193} 1197}
1194 1198
1195static void pcmcia_bus_remove_socket(struct class_device *class_dev) 1199static void pcmcia_bus_remove_socket(struct class_device *class_dev,
1200 struct class_interface *class_intf)
1196{ 1201{
1197 struct pcmcia_socket *socket = class_get_devdata(class_dev); 1202 struct pcmcia_socket *socket = class_get_devdata(class_dev);
1198 1203
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
index 316f8bcc878b..561706ba4499 100644
--- a/drivers/pcmcia/hd64465_ss.c
+++ b/drivers/pcmcia/hd64465_ss.c
@@ -37,7 +37,7 @@
37#include <asm/errno.h> 37#include <asm/errno.h>
38#include <linux/irq.h> 38#include <linux/irq.h>
39#include <linux/interrupt.h> 39#include <linux/interrupt.h>
40#include <linux/device.h> 40#include <linux/platform_device.h>
41 41
42#include <asm/io.h> 42#include <asm/io.h>
43#include <asm/hd64465/hd64465.h> 43#include <asm/hd64465/hd64465.h>
@@ -844,27 +844,11 @@ static void hs_exit_socket(hs_socket_t *sp)
844 local_irq_restore(flags); 844 local_irq_restore(flags);
845} 845}
846 846
847static int hd64465_suspend(struct device *dev, pm_message_t state, u32 level)
848{
849 int ret = 0;
850 if (level == SUSPEND_SAVE_STATE)
851 ret = pcmcia_socket_dev_suspend(dev, state);
852 return ret;
853}
854
855static int hd64465_resume(struct device *dev, u32 level)
856{
857 int ret = 0;
858 if (level == RESUME_RESTORE_STATE)
859 ret = pcmcia_socket_dev_resume(dev);
860 return ret;
861}
862
863static struct device_driver hd64465_driver = { 847static struct device_driver hd64465_driver = {
864 .name = "hd64465-pcmcia", 848 .name = "hd64465-pcmcia",
865 .bus = &platform_bus_type, 849 .bus = &platform_bus_type,
866 .suspend = hd64465_suspend, 850 .suspend = pcmcia_socket_dev_suspend,
867 .resume = hd64465_resume, 851 .resume = pcmcia_socket_dev_resume,
868}; 852};
869 853
870static struct platform_device hd64465_device = { 854static struct platform_device hd64465_device = {
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index a713015e8228..4d56bc9926d6 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -47,7 +47,7 @@
47#include <linux/delay.h> 47#include <linux/delay.h>
48#include <linux/workqueue.h> 48#include <linux/workqueue.h>
49#include <linux/interrupt.h> 49#include <linux/interrupt.h>
50#include <linux/device.h> 50#include <linux/platform_device.h>
51#include <linux/bitops.h> 51#include <linux/bitops.h>
52#include <asm/irq.h> 52#include <asm/irq.h>
53#include <asm/io.h> 53#include <asm/io.h>
@@ -1332,33 +1332,14 @@ static struct pccard_operations pcic_operations = {
1332 1332
1333/*====================================================================*/ 1333/*====================================================================*/
1334 1334
1335static int i82365_suspend(struct device *dev, pm_message_t state, u32 level)
1336{
1337 int ret = 0;
1338 if (level == SUSPEND_SAVE_STATE)
1339 ret = pcmcia_socket_dev_suspend(dev, state);
1340 return ret;
1341}
1342
1343static int i82365_resume(struct device *dev, u32 level)
1344{
1345 int ret = 0;
1346 if (level == RESUME_RESTORE_STATE)
1347 ret = pcmcia_socket_dev_resume(dev);
1348 return ret;
1349}
1350
1351static struct device_driver i82365_driver = { 1335static struct device_driver i82365_driver = {
1352 .name = "i82365", 1336 .name = "i82365",
1353 .bus = &platform_bus_type, 1337 .bus = &platform_bus_type,
1354 .suspend = i82365_suspend, 1338 .suspend = pcmcia_socket_dev_suspend,
1355 .resume = i82365_resume, 1339 .resume = pcmcia_socket_dev_resume,
1356}; 1340};
1357 1341
1358static struct platform_device i82365_device = { 1342static struct platform_device *i82365_device;
1359 .name = "i82365",
1360 .id = 0,
1361};
1362 1343
1363static int __init init_i82365(void) 1344static int __init init_i82365(void)
1364{ 1345{
@@ -1368,7 +1349,14 @@ static int __init init_i82365(void)
1368 if (ret) 1349 if (ret)
1369 return ret; 1350 return ret;
1370 1351
1371 ret = platform_device_register(&i82365_device); 1352 i82365_device = platform_device_alloc("i82365", 0);
1353 if (i82365_device) {
1354 ret = platform_device_add(i82365_device);
1355 if (ret)
1356 platform_device_put(i82365_device);
1357 } else
1358 ret = -ENOMEM;
1359
1372 if (ret) { 1360 if (ret) {
1373 driver_unregister(&i82365_driver); 1361 driver_unregister(&i82365_driver);
1374 return ret; 1362 return ret;
@@ -1381,7 +1369,8 @@ static int __init init_i82365(void)
1381 1369
1382 if (sockets == 0) { 1370 if (sockets == 0) {
1383 printk("not found.\n"); 1371 printk("not found.\n");
1384 platform_device_unregister(&i82365_device); 1372 platform_device_unregister(i82365_device);
1373 release_region(i365_base, 2);
1385 driver_unregister(&i82365_driver); 1374 driver_unregister(&i82365_driver);
1386 return -ENODEV; 1375 return -ENODEV;
1387 } 1376 }
@@ -1392,7 +1381,7 @@ static int __init init_i82365(void)
1392 1381
1393 /* register sockets with the pcmcia core */ 1382 /* register sockets with the pcmcia core */
1394 for (i = 0; i < sockets; i++) { 1383 for (i = 0; i < sockets; i++) {
1395 socket[i].socket.dev.dev = &i82365_device.dev; 1384 socket[i].socket.dev.dev = &i82365_device->dev;
1396 socket[i].socket.ops = &pcic_operations; 1385 socket[i].socket.ops = &pcic_operations;
1397 socket[i].socket.resource_ops = &pccard_nonstatic_ops; 1386 socket[i].socket.resource_ops = &pccard_nonstatic_ops;
1398 socket[i].socket.owner = THIS_MODULE; 1387 socket[i].socket.owner = THIS_MODULE;
@@ -1430,7 +1419,7 @@ static void __exit exit_i82365(void)
1430 if (socket[i].flags & IS_REGISTERED) 1419 if (socket[i].flags & IS_REGISTERED)
1431 pcmcia_unregister_socket(&socket[i].socket); 1420 pcmcia_unregister_socket(&socket[i].socket);
1432 } 1421 }
1433 platform_device_unregister(&i82365_device); 1422 platform_device_unregister(i82365_device);
1434 if (poll_interval != 0) 1423 if (poll_interval != 0)
1435 del_timer_sync(&poll_timer); 1424 del_timer_sync(&poll_timer);
1436 if (grab_irq != 0) 1425 if (grab_irq != 0)
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 65f3ee3d4d3c..078579ae6359 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -23,7 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/device.h> 26#include <linux/platform_device.h>
27#include <linux/bitops.h> 27#include <linux/bitops.h>
28#include <asm/irq.h> 28#include <asm/irq.h>
29#include <asm/io.h> 29#include <asm/io.h>
@@ -355,9 +355,10 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr, kio_addr_t ioaddr
355#ifndef CONFIG_PLAT_USRV 355#ifndef CONFIG_PLAT_USRV
356 /* insert interrupt */ 356 /* insert interrupt */
357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
358#ifndef CONFIG_PLAT_MAPPI3
358 /* eject interrupt */ 359 /* eject interrupt */
359 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 360 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
360 361#endif
361 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n"); 362 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n");
362 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01); 363 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01);
363#endif /* CONFIG_PLAT_USRV */ 364#endif /* CONFIG_PLAT_USRV */
@@ -731,28 +732,11 @@ static struct pccard_operations pcc_operations = {
731 732
732/*====================================================================*/ 733/*====================================================================*/
733 734
734static int m32r_pcc_suspend(struct device *dev, pm_message_t state, u32 level)
735{
736 int ret = 0;
737 if (level == SUSPEND_SAVE_STATE)
738 ret = pcmcia_socket_dev_suspend(dev, state);
739 return ret;
740}
741
742static int m32r_pcc_resume(struct device *dev, u32 level)
743{
744 int ret = 0;
745 if (level == RESUME_RESTORE_STATE)
746 ret = pcmcia_socket_dev_resume(dev);
747 return ret;
748}
749
750
751static struct device_driver pcc_driver = { 735static struct device_driver pcc_driver = {
752 .name = "cfc", 736 .name = "cfc",
753 .bus = &platform_bus_type, 737 .bus = &platform_bus_type,
754 .suspend = m32r_pcc_suspend, 738 .suspend = pcmcia_socket_dev_suspend,
755 .resume = m32r_pcc_resume, 739 .resume = pcmcia_socket_dev_resume,
756}; 740};
757 741
758static struct platform_device pcc_device = { 742static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 7b14d7efd68c..356a6fb416a1 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -23,7 +23,7 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/device.h> 26#include <linux/platform_device.h>
27#include <asm/irq.h> 27#include <asm/irq.h>
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/bitops.h> 29#include <asm/bitops.h>
@@ -695,28 +695,11 @@ static struct pccard_operations pcc_operations = {
695 695
696/*====================================================================*/ 696/*====================================================================*/
697 697
698static int m32r_pcc_suspend(struct device *dev, pm_message_t state, u32 level)
699{
700 int ret = 0;
701 if (level == SUSPEND_SAVE_STATE)
702 ret = pcmcia_socket_dev_suspend(dev, state);
703 return ret;
704}
705
706static int m32r_pcc_resume(struct device *dev, u32 level)
707{
708 int ret = 0;
709 if (level == RESUME_RESTORE_STATE)
710 ret = pcmcia_socket_dev_resume(dev);
711 return ret;
712}
713
714
715static struct device_driver pcc_driver = { 698static struct device_driver pcc_driver = {
716 .name = "pcc", 699 .name = "pcc",
717 .bus = &platform_bus_type, 700 .bus = &platform_bus_type,
718 .suspend = m32r_pcc_suspend, 701 .suspend = pcmcia_socket_dev_suspend,
719 .resume = m32r_pcc_resume, 702 .resume = pcmcia_socket_dev_resume,
720}; 703};
721 704
722static struct platform_device pcc_device = { 705static struct platform_device pcc_device = {
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
new file mode 100644
index 000000000000..6d9f71cfcb34
--- /dev/null
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -0,0 +1,1272 @@
1/*
2 * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
3 *
4 * (C) 1999-2000 Magnus Damm <damm@bitsmart.com>
5 * (C) 2001-2002 Montavista Software, Inc.
6 * <mlocke@mvista.com>
7 *
8 * Support for two slots by Cyclades Corporation
9 * <oliver.kurth@cyclades.de>
10 * Further fixes, v2.6 kernel port
11 * <marcelo.tosatti@cyclades.com>
12 *
13 * "The ExCA standard specifies that socket controllers should provide
14 * two IO and five memory windows per socket, which can be independently
15 * configured and positioned in the host address space and mapped to
16 * arbitrary segments of card address space. " - David A Hinds. 1999
17 *
18 * This controller does _not_ meet the ExCA standard.
19 *
20 * m8xx pcmcia controller brief info:
21 * + 8 windows (attrib, mem, i/o)
22 * + up to two slots (SLOT_A and SLOT_B)
23 * + inputpins, outputpins, event and mask registers.
24 * - no offset register. sigh.
25 *
26 * Because of the lacking offset register we must map the whole card.
27 * We assign each memory window PCMCIA_MEM_WIN_SIZE address space.
28 * Make sure there is (PCMCIA_MEM_WIN_SIZE * PCMCIA_MEM_WIN_NO
29 * * PCMCIA_SOCKETS_NO) bytes at PCMCIA_MEM_WIN_BASE.
30 * The i/o windows are dynamically allocated at PCMCIA_IO_WIN_BASE.
31 * They are maximum 64KByte each...
32 */
33
34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/types.h>
37#include <linux/fcntl.h>
38#include <linux/string.h>
39
40#include <asm/io.h>
41#include <asm/bitops.h>
42#include <asm/system.h>
43
44#include <linux/kernel.h>
45#include <linux/errno.h>
46#include <linux/sched.h>
47#include <linux/slab.h>
48#include <linux/timer.h>
49#include <linux/ioport.h>
50#include <linux/delay.h>
51#include <linux/interrupt.h>
52#include <linux/platform_device.h>
53
54#include <asm/mpc8xx.h>
55#include <asm/8xx_immap.h>
56#include <asm/irq.h>
57
58#include <pcmcia/version.h>
59#include <pcmcia/cs_types.h>
60#include <pcmcia/cs.h>
61#include <pcmcia/ss.h>
62
63#ifdef PCMCIA_DEBUG
64static int pc_debug = PCMCIA_DEBUG;
65module_param(pc_debug, int, 0);
66#define dprintk(args...) printk(KERN_DEBUG "m8xx_pcmcia: " args);
67#else
68#define dprintk(args...)
69#endif
70
71#define pcmcia_info(args...) printk(KERN_INFO "m8xx_pcmcia: "args)
72#define pcmcia_error(args...) printk(KERN_ERR "m8xx_pcmcia: "args)
73
74static const char *version = "Version 0.06, Aug 2005";
75MODULE_LICENSE("Dual MPL/GPL");
76
77#if !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B)
78
79/* The RPX series use SLOT_B */
80#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
81#define CONFIG_PCMCIA_SLOT_B
82#define CONFIG_BD_IS_MHZ
83#endif
84
85/* The ADS board use SLOT_A */
86#ifdef CONFIG_ADS
87#define CONFIG_PCMCIA_SLOT_A
88#define CONFIG_BD_IS_MHZ
89#endif
90
91/* The FADS series are a mess */
92#ifdef CONFIG_FADS
93#if defined(CONFIG_MPC860T) || defined(CONFIG_MPC860) || defined(CONFIG_MPC821)
94#define CONFIG_PCMCIA_SLOT_A
95#else
96#define CONFIG_PCMCIA_SLOT_B
97#endif
98#endif
99
100/* Cyclades ACS uses both slots */
101#ifdef CONFIG_PRxK
102#define CONFIG_PCMCIA_SLOT_A
103#define CONFIG_PCMCIA_SLOT_B
104#endif
105
106#endif /* !defined(CONFIG_PCMCIA_SLOT_A) && !defined(CONFIG_PCMCIA_SLOT_B) */
107
108#if defined(CONFIG_PCMCIA_SLOT_A) && defined(CONFIG_PCMCIA_SLOT_B)
109
110#define PCMCIA_SOCKETS_NO 2
111/* We have only 8 windows, dualsocket support will be limited. */
112#define PCMCIA_MEM_WIN_NO 2
113#define PCMCIA_IO_WIN_NO 2
114#define PCMCIA_SLOT_MSG "SLOT_A and SLOT_B"
115
116#elif defined(CONFIG_PCMCIA_SLOT_A) || defined(CONFIG_PCMCIA_SLOT_B)
117
118#define PCMCIA_SOCKETS_NO 1
119/* full support for one slot */
120#define PCMCIA_MEM_WIN_NO 5
121#define PCMCIA_IO_WIN_NO 2
122
123/* define _slot_ to be able to optimize macros */
124
125#ifdef CONFIG_PCMCIA_SLOT_A
126#define _slot_ 0
127#define PCMCIA_SLOT_MSG "SLOT_A"
128#else
129#define _slot_ 1
130#define PCMCIA_SLOT_MSG "SLOT_B"
131#endif
132
133#else
134#error m8xx_pcmcia: Bad configuration!
135#endif
136
137/* ------------------------------------------------------------------------- */
138
139#define PCMCIA_MEM_WIN_BASE 0xe0000000 /* base address for memory window 0 */
140#define PCMCIA_MEM_WIN_SIZE 0x04000000 /* each memory window is 64 MByte */
141#define PCMCIA_IO_WIN_BASE _IO_BASE /* base address for io window 0 */
142
143#define PCMCIA_SCHLVL PCMCIA_INTERRUPT /* Status Change Interrupt Level */
144
145/* ------------------------------------------------------------------------- */
146
147/* 2.4.x and newer has this always in HZ */
148#define M8XX_BUSFREQ ((((bd_t *)&(__res))->bi_busfreq))
149
150static int pcmcia_schlvl = PCMCIA_SCHLVL;
151
152static spinlock_t events_lock = SPIN_LOCK_UNLOCKED;
153
154
155#define PCMCIA_SOCKET_KEY_5V 1
156#define PCMCIA_SOCKET_KEY_LV 2
157
158/* look up table for pgcrx registers */
159static u32 *m8xx_pgcrx[2] = {
160 &((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pgcra,
161 &((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pgcrb
162};
163
164/*
165 * This structure is used to address each window in the PCMCIA controller.
166 *
167 * Keep in mind that we assume that pcmcia_win[n+1] is mapped directly
168 * after pcmcia_win[n]...
169 */
170
171struct pcmcia_win {
172 u32 br;
173 u32 or;
174};
175
176/*
177 * For some reason the hardware guys decided to make both slots share
178 * some registers.
179 *
180 * Could someone invent object oriented hardware ?
181 *
182 * The macros are used to get the right bit from the registers.
183 * SLOT_A : slot = 0
184 * SLOT_B : slot = 1
185 */
186
187#define M8XX_PCMCIA_VS1(slot) (0x80000000 >> (slot << 4))
188#define M8XX_PCMCIA_VS2(slot) (0x40000000 >> (slot << 4))
189#define M8XX_PCMCIA_VS_MASK(slot) (0xc0000000 >> (slot << 4))
190#define M8XX_PCMCIA_VS_SHIFT(slot) (30 - (slot << 4))
191
192#define M8XX_PCMCIA_WP(slot) (0x20000000 >> (slot << 4))
193#define M8XX_PCMCIA_CD2(slot) (0x10000000 >> (slot << 4))
194#define M8XX_PCMCIA_CD1(slot) (0x08000000 >> (slot << 4))
195#define M8XX_PCMCIA_BVD2(slot) (0x04000000 >> (slot << 4))
196#define M8XX_PCMCIA_BVD1(slot) (0x02000000 >> (slot << 4))
197#define M8XX_PCMCIA_RDY(slot) (0x01000000 >> (slot << 4))
198#define M8XX_PCMCIA_RDY_L(slot) (0x00800000 >> (slot << 4))
199#define M8XX_PCMCIA_RDY_H(slot) (0x00400000 >> (slot << 4))
200#define M8XX_PCMCIA_RDY_R(slot) (0x00200000 >> (slot << 4))
201#define M8XX_PCMCIA_RDY_F(slot) (0x00100000 >> (slot << 4))
202#define M8XX_PCMCIA_MASK(slot) (0xFFFF0000 >> (slot << 4))
203
204#define M8XX_PCMCIA_POR_VALID 0x00000001
205#define M8XX_PCMCIA_POR_WRPROT 0x00000002
206#define M8XX_PCMCIA_POR_ATTRMEM 0x00000010
207#define M8XX_PCMCIA_POR_IO 0x00000018
208#define M8XX_PCMCIA_POR_16BIT 0x00000040
209
210#define M8XX_PGCRX(slot) m8xx_pgcrx[slot]
211
212#define M8XX_PGCRX_CXOE 0x00000080
213#define M8XX_PGCRX_CXRESET 0x00000040
214
215/* we keep one lookup table per socket to check flags */
216
217#define PCMCIA_EVENTS_MAX 5 /* 4 max at a time + termination */
218
219struct event_table {
220 u32 regbit;
221 u32 eventbit;
222};
223
224struct socket_info {
225 void (*handler)(void *info, u32 events);
226 void *info;
227
228 u32 slot;
229
230 socket_state_t state;
231 struct pccard_mem_map mem_win[PCMCIA_MEM_WIN_NO];
232 struct pccard_io_map io_win[PCMCIA_IO_WIN_NO];
233 struct event_table events[PCMCIA_EVENTS_MAX];
234 struct pcmcia_socket socket;
235};
236
237static struct socket_info socket[PCMCIA_SOCKETS_NO];
238
239/*
240 * Search this table to see if the windowsize is
241 * supported...
242 */
243
244#define M8XX_SIZES_NO 32
245
246static const u32 m8xx_size_to_gray[M8XX_SIZES_NO] =
247{
248 0x00000001, 0x00000002, 0x00000008, 0x00000004,
249 0x00000080, 0x00000040, 0x00000010, 0x00000020,
250 0x00008000, 0x00004000, 0x00001000, 0x00002000,
251 0x00000100, 0x00000200, 0x00000800, 0x00000400,
252
253 0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
254 0x01000000, 0x02000000, 0xffffffff, 0x04000000,
255 0x00010000, 0x00020000, 0x00080000, 0x00040000,
256 0x00800000, 0x00400000, 0x00100000, 0x00200000
257};
258
259/* ------------------------------------------------------------------------- */
260
261static irqreturn_t m8xx_interrupt(int irq, void *dev, struct pt_regs *regs);
262
263#define PCMCIA_BMT_LIMIT (15*4) /* Bus Monitor Timeout value */
264
265/* ------------------------------------------------------------------------- */
266/* board specific stuff: */
267/* voltage_set(), hardware_enable() and hardware_disable() */
268/* ------------------------------------------------------------------------- */
269/* RPX Boards from Embedded Planet */
270
271#if defined(CONFIG_RPXCLASSIC) || defined(CONFIG_RPXLITE)
272
273/* The RPX boards seems to have it's bus monitor timeout set to 6*8 clocks.
274 * SYPCR is write once only, therefore must the slowest memory be faster
275 * than the bus monitor or we will get a machine check due to the bus timeout.
276 */
277
278#define PCMCIA_BOARD_MSG "RPX CLASSIC or RPX LITE"
279
280#undef PCMCIA_BMT_LIMIT
281#define PCMCIA_BMT_LIMIT (6*8)
282
283static int voltage_set(int slot, int vcc, int vpp)
284{
285 u32 reg = 0;
286
287 switch(vcc) {
288 case 0: break;
289 case 33:
290 reg |= BCSR1_PCVCTL4;
291 break;
292 case 50:
293 reg |= BCSR1_PCVCTL5;
294 break;
295 default:
296 return 1;
297 }
298
299 switch(vpp) {
300 case 0: break;
301 case 33:
302 case 50:
303 if(vcc == vpp)
304 reg |= BCSR1_PCVCTL6;
305 else
306 return 1;
307 break;
308 case 120:
309 reg |= BCSR1_PCVCTL7;
310 default:
311 return 1;
312 }
313
314 if(!((vcc == 50) || (vcc == 0)))
315 return 1;
316
317 /* first, turn off all power */
318
319 out_be32(((u32 *)RPX_CSR_ADDR), in_be32(((u32 *)RPX_CSR_ADDR)) & ~(BCSR1_PCVCTL4 | BCSR1_PCVCTL5 | BCSR1_PCVCTL6 | BCSR1_PCVCTL7));
320
321 /* enable new powersettings */
322
323 out_be32(((u32 *)RPX_CSR_ADDR), in_be32(((u32 *)RPX_CSR_ADDR)) | reg);
324
325 return 0;
326}
327
328#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
329#define hardware_enable(_slot_) /* No hardware to enable */
330#define hardware_disable(_slot_) /* No hardware to disable */
331
332#endif /* CONFIG_RPXCLASSIC */
333
334/* FADS Boards from Motorola */
335
336#if defined(CONFIG_FADS)
337
338#define PCMCIA_BOARD_MSG "FADS"
339
340static int voltage_set(int slot, int vcc, int vpp)
341{
342 u32 reg = 0;
343
344 switch(vcc) {
345 case 0:
346 break;
347 case 33:
348 reg |= BCSR1_PCCVCC0;
349 break;
350 case 50:
351 reg |= BCSR1_PCCVCC1;
352 break;
353 default:
354 return 1;
355 }
356
357 switch(vpp) {
358 case 0:
359 break;
360 case 33:
361 case 50:
362 if(vcc == vpp)
363 reg |= BCSR1_PCCVPP1;
364 else
365 return 1;
366 break;
367 case 120:
368 if ((vcc == 33) || (vcc == 50))
369 reg |= BCSR1_PCCVPP0;
370 else
371 return 1;
372 default:
373 return 1;
374 }
375
376 /* first, turn off all power */
377 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) & ~(BCSR1_PCCVCC_MASK | BCSR1_PCCVPP_MASK));
378
379 /* enable new powersettings */
380 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) | reg);
381
382 return 0;
383}
384
385#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
386
387static void hardware_enable(int slot)
388{
389 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) & ~BCSR1_PCCEN);
390}
391
392static void hardware_disable(int slot)
393{
394 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) | BCSR1_PCCEN);
395}
396
397#endif
398
399/* ------------------------------------------------------------------------- */
400/* Motorola MBX860 */
401
402#if defined(CONFIG_MBX)
403
404#define PCMCIA_BOARD_MSG "MBX"
405
406static int voltage_set(int slot, int vcc, int vpp)
407{
408 u8 reg = 0;
409
410 switch(vcc) {
411 case 0:
412 break;
413 case 33:
414 reg |= CSR2_VCC_33;
415 break;
416 case 50:
417 reg |= CSR2_VCC_50;
418 break;
419 default:
420 return 1;
421 }
422
423 switch(vpp) {
424 case 0:
425 break;
426 case 33:
427 case 50:
428 if(vcc == vpp)
429 reg |= CSR2_VPP_VCC;
430 else
431 return 1;
432 break;
433 case 120:
434 if ((vcc == 33) || (vcc == 50))
435 reg |= CSR2_VPP_12;
436 else
437 return 1;
438 default:
439 return 1;
440 }
441
442 /* first, turn off all power */
443 out_8(&((u8 *)MBX_CSR2_ADDR), in_8(&((u8 *)MBX_CSR2_ADDR)) & ~(CSR2_VCC_MASK | CSR2_VPP_MASK));
444
445 /* enable new powersettings */
446 out_8(&((u8 *)MBX_CSR2_ADDR), in_8(&((u8 *)MBX_CSR2_ADDR)) | reg);
447
448 return 0;
449}
450
451#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
452#define hardware_enable(_slot_) /* No hardware to enable */
453#define hardware_disable(_slot_) /* No hardware to disable */
454
455#endif /* CONFIG_MBX */
456
457#if defined(CONFIG_PRxK)
458#include <asm/cpld.h>
459extern volatile fpga_pc_regs *fpga_pc;
460
461#define PCMCIA_BOARD_MSG "MPC855T"
462
463static int voltage_set(int slot, int vcc, int vpp)
464{
465 u8 reg = 0;
466 u8 regread;
467 cpld_regs *ccpld = get_cpld();
468
469 switch(vcc) {
470 case 0:
471 break;
472 case 33:
473 reg |= PCMCIA_VCC_33;
474 break;
475 case 50:
476 reg |= PCMCIA_VCC_50;
477 break;
478 default:
479 return 1;
480 }
481
482 switch(vpp) {
483 case 0:
484 break;
485 case 33:
486 case 50:
487 if(vcc == vpp)
488 reg |= PCMCIA_VPP_VCC;
489 else
490 return 1;
491 break;
492 case 120:
493 if ((vcc == 33) || (vcc == 50))
494 reg |= PCMCIA_VPP_12;
495 else
496 return 1;
497 default:
498 return 1;
499 }
500
501 reg = reg >> (slot << 2);
502 regread = in_8(&ccpld->fpga_pc_ctl);
503 if (reg != (regread & ((PCMCIA_VCC_MASK | PCMCIA_VPP_MASK) >> (slot << 2)))) {
504 /* enable new powersettings */
505 regread = regread & ~((PCMCIA_VCC_MASK | PCMCIA_VPP_MASK) >> (slot << 2));
506 out_8(&ccpld->fpga_pc_ctl, reg | regread);
507 msleep(100);
508 }
509
510 return 0;
511}
512
513#define socket_get(_slot_) PCMCIA_SOCKET_KEY_LV
514#define hardware_enable(_slot_) /* No hardware to enable */
515#define hardware_disable(_slot_) /* No hardware to disable */
516
517#endif /* CONFIG_PRxK */
518
519static void m8xx_shutdown(void)
520{
521 u32 m, i;
522 struct pcmcia_win *w;
523
524 for(i = 0; i < PCMCIA_SOCKETS_NO; i++){
525 w = (void *) &((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pbr0;
526
527 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pscr, M8XX_PCMCIA_MASK(i));
528 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per, in_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per) & ~M8XX_PCMCIA_MASK(i));
529
530 /* turn off interrupt and disable CxOE */
531 out_be32(M8XX_PGCRX(i), M8XX_PGCRX_CXOE);
532
533 /* turn off memory windows */
534 for(m = 0; m < PCMCIA_MEM_WIN_NO; m++) {
535 out_be32(&w->or, 0); /* set to not valid */
536 w++;
537 }
538
539 /* turn off voltage */
540 voltage_set(i, 0, 0);
541
542 /* disable external hardware */
543 hardware_disable(i);
544 }
545
546 free_irq(pcmcia_schlvl, NULL);
547}
548
549static struct device_driver m8xx_driver = {
550 .name = "m8xx-pcmcia",
551 .bus = &platform_bus_type,
552 .suspend = pcmcia_socket_dev_suspend,
553 .resume = pcmcia_socket_dev_resume,
554};
555
556static struct platform_device m8xx_device = {
557 .name = "m8xx-pcmcia",
558 .id = 0,
559};
560
561static u32 pending_events[PCMCIA_SOCKETS_NO];
562static spinlock_t pending_event_lock = SPIN_LOCK_UNLOCKED;
563
564static irqreturn_t m8xx_interrupt(int irq, void *dev, struct pt_regs *regs)
565{
566 struct socket_info *s;
567 struct event_table *e;
568 unsigned int i, events, pscr, pipr, per;
569
570 dprintk("Interrupt!\n");
571 /* get interrupt sources */
572
573 pscr = in_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pscr);
574 pipr = in_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pipr);
575 per = in_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per);
576
577 for(i = 0; i < PCMCIA_SOCKETS_NO; i++) {
578 s = &socket[i];
579 e = &s->events[0];
580 events = 0;
581
582 while(e->regbit) {
583 if(pscr & e->regbit)
584 events |= e->eventbit;
585
586 e++;
587 }
588
589 /*
590 * report only if both card detect signals are the same
591 * not too nice done,
592 * we depend on that CD2 is the bit to the left of CD1...
593 */
594 if(events & SS_DETECT)
595 if(((pipr & M8XX_PCMCIA_CD2(i)) >> 1) ^
596 (pipr & M8XX_PCMCIA_CD1(i)))
597 {
598 events &= ~SS_DETECT;
599 }
600
601#ifdef PCMCIA_GLITCHY_CD
602 /*
603 * I've experienced CD problems with my ADS board.
604 * We make an extra check to see if there was a
605 * real change of Card detection.
606 */
607
608 if((events & SS_DETECT) &&
609 ((pipr &
610 (M8XX_PCMCIA_CD2(i) | M8XX_PCMCIA_CD1(i))) == 0) &&
611 (s->state.Vcc | s->state.Vpp)) {
612 events &= ~SS_DETECT;
613 /*printk( "CD glitch workaround - CD = 0x%08x!\n",
614 (pipr & (M8XX_PCMCIA_CD2(i)
615 | M8XX_PCMCIA_CD1(i))));*/
616 }
617#endif
618
619 /* call the handler */
620
621 dprintk("slot %u: events = 0x%02x, pscr = 0x%08x, "
622 "pipr = 0x%08x\n",
623 i, events, pscr, pipr);
624
625 if(events) {
626 spin_lock(&pending_event_lock);
627 pending_events[i] |= events;
628 spin_unlock(&pending_event_lock);
629 /*
630 * Turn off RDY_L bits in the PER mask on
631 * CD interrupt receival.
632 *
633 * They can generate bad interrupts on the
634 * ACS4,8,16,32. - marcelo
635 */
636 per &= ~M8XX_PCMCIA_RDY_L(0);
637 per &= ~M8XX_PCMCIA_RDY_L(1);
638
639 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per, per);
640
641 if (events)
642 pcmcia_parse_events(&socket[i].socket, events);
643 }
644 }
645
646 /* clear the interrupt sources */
647 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pscr, pscr);
648
649 dprintk("Interrupt done.\n");
650
651 return IRQ_HANDLED;
652}
653
654static u32 m8xx_get_graycode(u32 size)
655{
656 u32 k;
657
658 for(k = 0; k < M8XX_SIZES_NO; k++)
659 if(m8xx_size_to_gray[k] == size)
660 break;
661
662 if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
663 k = -1;
664
665 return k;
666}
667
668static u32 m8xx_get_speed(u32 ns, u32 is_io)
669{
670 u32 reg, clocks, psst, psl, psht;
671
672 if(!ns) {
673
674 /*
675 * We get called with IO maps setup to 0ns
676 * if not specified by the user.
677 * They should be 255ns.
678 */
679
680 if(is_io)
681 ns = 255;
682 else
683 ns = 100; /* fast memory if 0 */
684 }
685
686 /*
687 * In PSST, PSL, PSHT fields we tell the controller
688 * timing parameters in CLKOUT clock cycles.
689 * CLKOUT is the same as GCLK2_50.
690 */
691
692/* how we want to adjust the timing - in percent */
693
694#define ADJ 180 /* 80 % longer accesstime - to be sure */
695
696 clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
697 clocks = (clocks * ADJ) / (100*1000);
698 if(clocks >= PCMCIA_BMT_LIMIT) {
699 printk( "Max access time limit reached\n");
700 clocks = PCMCIA_BMT_LIMIT-1;
701 }
702
703 psst = clocks / 7; /* setup time */
704 psht = clocks / 7; /* hold time */
705 psl = (clocks * 5) / 7; /* strobe length */
706
707 psst += clocks - (psst + psht + psl);
708
709 reg = psst << 12;
710 reg |= psl << 7;
711 reg |= psht << 16;
712
713 return reg;
714}
715
716static int m8xx_get_status(struct pcmcia_socket *sock, unsigned int *value)
717{
718 int lsock = container_of(sock, struct socket_info, socket)->slot;
719 struct socket_info *s = &socket[lsock];
720 unsigned int pipr, reg;
721
722 pipr = in_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pipr);
723
724 *value = ((pipr & (M8XX_PCMCIA_CD1(lsock)
725 | M8XX_PCMCIA_CD2(lsock))) == 0) ? SS_DETECT : 0;
726 *value |= (pipr & M8XX_PCMCIA_WP(lsock)) ? SS_WRPROT : 0;
727
728 if (s->state.flags & SS_IOCARD)
729 *value |= (pipr & M8XX_PCMCIA_BVD1(lsock)) ? SS_STSCHG : 0;
730 else {
731 *value |= (pipr & M8XX_PCMCIA_RDY(lsock)) ? SS_READY : 0;
732 *value |= (pipr & M8XX_PCMCIA_BVD1(lsock)) ? SS_BATDEAD : 0;
733 *value |= (pipr & M8XX_PCMCIA_BVD2(lsock)) ? SS_BATWARN : 0;
734 }
735
736 if (s->state.Vcc | s->state.Vpp)
737 *value |= SS_POWERON;
738
739 /*
740 * Voltage detection:
741 * This driver only supports 16-Bit pc-cards.
742 * Cardbus is not handled here.
743 *
744 * To determine what voltage to use we must read the VS1 and VS2 pin.
745 * Depending on what socket type is present,
746 * different combinations mean different things.
747 *
748 * Card Key Socket Key VS1 VS2 Card Vcc for CIS parse
749 *
750 * 5V 5V, LV* NC NC 5V only 5V (if available)
751 *
752 * 5V 5V, LV* GND NC 5 or 3.3V as low as possible
753 *
754 * 5V 5V, LV* GND GND 5, 3.3, x.xV as low as possible
755 *
756 * LV* 5V - - shall not fit into socket
757 *
758 * LV* LV* GND NC 3.3V only 3.3V
759 *
760 * LV* LV* NC GND x.xV x.xV (if avail.)
761 *
762 * LV* LV* GND GND 3.3 or x.xV as low as possible
763 *
764 * *LV means Low Voltage
765 *
766 *
767 * That gives us the following table:
768 *
769 * Socket VS1 VS2 Voltage
770 *
771 * 5V NC NC 5V
772 * 5V NC GND none (should not be possible)
773 * 5V GND NC >= 3.3V
774 * 5V GND GND >= x.xV
775 *
776 * LV NC NC 5V (if available)
777 * LV NC GND x.xV (if available)
778 * LV GND NC 3.3V
779 * LV GND GND >= x.xV
780 *
781 * So, how do I determine if I have a 5V or a LV
782 * socket on my board? Look at the socket!
783 *
784 *
785 * Socket with 5V key:
786 * ++--------------------------------------------+
787 * || |
788 * || ||
789 * || ||
790 * | |
791 * +---------------------------------------------+
792 *
793 * Socket with LV key:
794 * ++--------------------------------------------+
795 * || |
796 * | ||
797 * | ||
798 * | |
799 * +---------------------------------------------+
800 *
801 *
802 * With other words - LV only cards does not fit
803 * into the 5V socket!
804 */
805
806 /* read out VS1 and VS2 */
807
808 reg = (pipr & M8XX_PCMCIA_VS_MASK(lsock))
809 >> M8XX_PCMCIA_VS_SHIFT(lsock);
810
811 if(socket_get(lsock) == PCMCIA_SOCKET_KEY_LV) {
812 switch(reg) {
813 case 1:
814 *value |= SS_3VCARD;
815 break; /* GND, NC - 3.3V only */
816 case 2:
817 *value |= SS_XVCARD;
818 break; /* NC. GND - x.xV only */
819 };
820 }
821
822 dprintk("GetStatus(%d) = %#2.2x\n", lsock, *value);
823 return 0;
824}
825
826static int m8xx_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
827{
828 int lsock = container_of(sock, struct socket_info, socket)->slot;
829 *state = socket[lsock].state; /* copy the whole structure */
830
831 dprintk("GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
832 "io_irq %d, csc_mask %#2.2x\n", lsock, state->flags,
833 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
834 return 0;
835}
836
837static int m8xx_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
838{
839 int lsock = container_of(sock, struct socket_info, socket)->slot;
840 struct socket_info *s = &socket[lsock];
841 struct event_table *e;
842 unsigned int reg;
843 unsigned long flags;
844
845 dprintk( "SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
846 "io_irq %d, csc_mask %#2.2x)\n", lsock, state->flags,
847 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
848
849 /* First, set voltage - bail out if invalid */
850 if(voltage_set(lsock, state->Vcc, state->Vpp))
851 return -EINVAL;
852
853 /* Take care of reset... */
854 if(state->flags & SS_RESET)
855 out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) | M8XX_PGCRX_CXRESET); /* active high */
856 else
857 out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) & ~M8XX_PGCRX_CXRESET);
858
859 /* ... and output enable. */
860
861 /* The CxOE signal is connected to a 74541 on the ADS.
862 I guess most other boards used the ADS as a reference.
863 I tried to control the CxOE signal with SS_OUTPUT_ENA,
864 but the reset signal seems connected via the 541.
865 If the CxOE is left high are some signals tristated and
866 no pullups are present -> the cards act wierd.
867 So right now the buffers are enabled if the power is on. */
868
869 if(state->Vcc || state->Vpp)
870 out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) & ~M8XX_PGCRX_CXOE); /* active low */
871 else
872 out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) | M8XX_PGCRX_CXOE);
873
874 /*
875 * We'd better turn off interrupts before
876 * we mess with the events-table..
877 */
878
879 spin_lock_irqsave(&events_lock, flags);
880
881 /*
882 * Play around with the interrupt mask to be able to
883 * give the events the generic pcmcia driver wants us to.
884 */
885
886 e = &s->events[0];
887 reg = 0;
888
889 if(state->csc_mask & SS_DETECT) {
890 e->eventbit = SS_DETECT;
891 reg |= e->regbit = (M8XX_PCMCIA_CD2(lsock)
892 | M8XX_PCMCIA_CD1(lsock));
893 e++;
894 }
895 if(state->flags & SS_IOCARD) {
896 /*
897 * I/O card
898 */
899 if(state->csc_mask & SS_STSCHG) {
900 e->eventbit = SS_STSCHG;
901 reg |= e->regbit = M8XX_PCMCIA_BVD1(lsock);
902 e++;
903 }
904 /*
905 * If io_irq is non-zero we should enable irq.
906 */
907 if(state->io_irq) {
908 out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) | mk_int_int_mask(state->io_irq) << 24);
909 /*
910 * Strange thing here:
911 * The manual does not tell us which interrupt
912 * the sources generate.
913 * Anyhow, I found out that RDY_L generates IREQLVL.
914 *
915 * We use level triggerd interrupts, and they don't
916 * have to be cleared in PSCR in the interrupt handler.
917 */
918 reg |= M8XX_PCMCIA_RDY_L(lsock);
919 }
920 else
921 out_be32(M8XX_PGCRX(lsock), in_be32(M8XX_PGCRX(lsock)) & 0x00ffffff);
922 }
923 else {
924 /*
925 * Memory card
926 */
927 if(state->csc_mask & SS_BATDEAD) {
928 e->eventbit = SS_BATDEAD;
929 reg |= e->regbit = M8XX_PCMCIA_BVD1(lsock);
930 e++;
931 }
932 if(state->csc_mask & SS_BATWARN) {
933 e->eventbit = SS_BATWARN;
934 reg |= e->regbit = M8XX_PCMCIA_BVD2(lsock);
935 e++;
936 }
937 /* What should I trigger on - low/high,raise,fall? */
938 if(state->csc_mask & SS_READY) {
939 e->eventbit = SS_READY;
940 reg |= e->regbit = 0; //??
941 e++;
942 }
943 }
944
945 e->regbit = 0; /* terminate list */
946
947 /*
948 * Clear the status changed .
949 * Port A and Port B share the same port.
950 * Writing ones will clear the bits.
951 */
952
953 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pscr, reg);
954
955 /*
956 * Write the mask.
957 * Port A and Port B share the same port.
958 * Need for read-modify-write.
959 * Ones will enable the interrupt.
960 */
961
962 /*
963 reg |= ((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per
964 & M8XX_PCMCIA_MASK(lsock);
965 */
966
967 reg |= in_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per) &
968 (M8XX_PCMCIA_MASK(0) | M8XX_PCMCIA_MASK(1));
969
970 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per, reg);
971
972 spin_unlock_irqrestore(&events_lock, flags);
973
974 /* copy the struct and modify the copy */
975
976 s->state = *state;
977
978 return 0;
979}
980
981static int m8xx_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io)
982{
983 int lsock = container_of(sock, struct socket_info, socket)->slot;
984
985 struct socket_info *s = &socket[lsock];
986 struct pcmcia_win *w;
987 unsigned int reg, winnr;
988
989#define M8XX_SIZE (io->stop - io->start + 1)
990#define M8XX_BASE (PCMCIA_IO_WIN_BASE + io->start)
991
992 dprintk( "SetIOMap(%d, %d, %#2.2x, %d ns, "
993 "%#4.4x-%#4.4x)\n", lsock, io->map, io->flags,
994 io->speed, io->start, io->stop);
995
996 if ((io->map >= PCMCIA_IO_WIN_NO) || (io->start > 0xffff)
997 || (io->stop > 0xffff) || (io->stop < io->start))
998 return -EINVAL;
999
1000 if((reg = m8xx_get_graycode(M8XX_SIZE)) == -1)
1001 return -EINVAL;
1002
1003 if(io->flags & MAP_ACTIVE) {
1004
1005 dprintk( "io->flags & MAP_ACTIVE\n");
1006
1007 winnr = (PCMCIA_MEM_WIN_NO * PCMCIA_SOCKETS_NO)
1008 + (lsock * PCMCIA_IO_WIN_NO) + io->map;
1009
1010 /* setup registers */
1011
1012 w = (void *) &((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pbr0;
1013 w += winnr;
1014
1015 out_be32(&w->or, 0); /* turn off window first */
1016 out_be32(&w->br, M8XX_BASE);
1017
1018 reg <<= 27;
1019 reg |= M8XX_PCMCIA_POR_IO |(lsock << 2);
1020
1021 reg |= m8xx_get_speed(io->speed, 1);
1022
1023 if(io->flags & MAP_WRPROT)
1024 reg |= M8XX_PCMCIA_POR_WRPROT;
1025
1026 /*if(io->flags & (MAP_16BIT | MAP_AUTOSZ))*/
1027 if(io->flags & MAP_16BIT)
1028 reg |= M8XX_PCMCIA_POR_16BIT;
1029
1030 if(io->flags & MAP_ACTIVE)
1031 reg |= M8XX_PCMCIA_POR_VALID;
1032
1033 out_be32(&w->or, reg);
1034
1035 dprintk("Socket %u: Mapped io window %u at %#8.8x, "
1036 "OR = %#8.8x.\n", lsock, io->map, w->br, w->or);
1037 } else {
1038 /* shutdown IO window */
1039 winnr = (PCMCIA_MEM_WIN_NO * PCMCIA_SOCKETS_NO)
1040 + (lsock * PCMCIA_IO_WIN_NO) + io->map;
1041
1042 /* setup registers */
1043
1044 w = (void *) &((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pbr0;
1045 w += winnr;
1046
1047 out_be32(&w->or, 0); /* turn off window */
1048 out_be32(&w->br, 0); /* turn off base address */
1049
1050 dprintk("Socket %u: Unmapped io window %u at %#8.8x, "
1051 "OR = %#8.8x.\n", lsock, io->map, w->br, w->or);
1052 }
1053
1054 /* copy the struct and modify the copy */
1055 s->io_win[io->map] = *io;
1056 s->io_win[io->map].flags &= (MAP_WRPROT
1057 | MAP_16BIT
1058 | MAP_ACTIVE);
1059 dprintk("SetIOMap exit\n");
1060
1061 return 0;
1062}
1063
1064static int m8xx_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *mem)
1065{
1066 int lsock = container_of(sock, struct socket_info, socket)->slot;
1067 struct socket_info *s = &socket[lsock];
1068 struct pcmcia_win *w;
1069 struct pccard_mem_map *old;
1070 unsigned int reg, winnr;
1071
1072 dprintk( "SetMemMap(%d, %d, %#2.2x, %d ns, "
1073 "%#5.5lx, %#5.5x)\n", lsock, mem->map, mem->flags,
1074 mem->speed, mem->static_start, mem->card_start);
1075
1076 if ((mem->map >= PCMCIA_MEM_WIN_NO)
1077// || ((mem->s) >= PCMCIA_MEM_WIN_SIZE)
1078 || (mem->card_start >= 0x04000000)
1079 || (mem->static_start & 0xfff) /* 4KByte resolution */
1080 || (mem->card_start & 0xfff))
1081 return -EINVAL;
1082
1083 if((reg = m8xx_get_graycode(PCMCIA_MEM_WIN_SIZE)) == -1) {
1084 printk( "Cannot set size to 0x%08x.\n", PCMCIA_MEM_WIN_SIZE);
1085 return -EINVAL;
1086 }
1087 reg <<= 27;
1088
1089 winnr = (lsock * PCMCIA_MEM_WIN_NO) + mem->map;
1090
1091 /* Setup the window in the pcmcia controller */
1092
1093 w = (void *) &((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pbr0;
1094 w += winnr;
1095
1096 reg |= lsock << 2;
1097
1098 reg |= m8xx_get_speed(mem->speed, 0);
1099
1100 if(mem->flags & MAP_ATTRIB)
1101 reg |= M8XX_PCMCIA_POR_ATTRMEM;
1102
1103 if(mem->flags & MAP_WRPROT)
1104 reg |= M8XX_PCMCIA_POR_WRPROT;
1105
1106 if(mem->flags & MAP_16BIT)
1107 reg |= M8XX_PCMCIA_POR_16BIT;
1108
1109 if(mem->flags & MAP_ACTIVE)
1110 reg |= M8XX_PCMCIA_POR_VALID;
1111
1112 out_be32(&w->or, reg);
1113
1114 dprintk("Socket %u: Mapped memory window %u at %#8.8x, "
1115 "OR = %#8.8x.\n", lsock, mem->map, w->br, w->or);
1116
1117 if(mem->flags & MAP_ACTIVE) {
1118 /* get the new base address */
1119 mem->static_start = PCMCIA_MEM_WIN_BASE +
1120 (PCMCIA_MEM_WIN_SIZE * winnr)
1121 + mem->card_start;
1122 }
1123
1124 dprintk("SetMemMap(%d, %d, %#2.2x, %d ns, "
1125 "%#5.5lx, %#5.5x)\n", lsock, mem->map, mem->flags,
1126 mem->speed, mem->static_start, mem->card_start);
1127
1128 /* copy the struct and modify the copy */
1129
1130 old = &s->mem_win[mem->map];
1131
1132 *old = *mem;
1133 old->flags &= (MAP_ATTRIB
1134 | MAP_WRPROT
1135 | MAP_16BIT
1136 | MAP_ACTIVE);
1137
1138 return 0;
1139}
1140
1141static int m8xx_sock_init(struct pcmcia_socket *sock)
1142{
1143 int i;
1144 pccard_io_map io = { 0, 0, 0, 0, 1 };
1145 pccard_mem_map mem = { 0, 0, 0, 0, 0, 0 };
1146
1147 dprintk( "sock_init(%d)\n", s);
1148
1149 m8xx_set_socket(sock, &dead_socket);
1150 for (i = 0; i < PCMCIA_IO_WIN_NO; i++) {
1151 io.map = i;
1152 m8xx_set_io_map(sock, &io);
1153 }
1154 for (i = 0; i < PCMCIA_MEM_WIN_NO; i++) {
1155 mem.map = i;
1156 m8xx_set_mem_map(sock, &mem);
1157 }
1158
1159 return 0;
1160
1161}
1162
1163static int m8xx_suspend(struct pcmcia_socket *sock)
1164{
1165 return m8xx_set_socket(sock, &dead_socket);
1166}
1167
1168static struct pccard_operations m8xx_services = {
1169 .init = m8xx_sock_init,
1170 .suspend = m8xx_suspend,
1171 .get_status = m8xx_get_status,
1172 .get_socket = m8xx_get_socket,
1173 .set_socket = m8xx_set_socket,
1174 .set_io_map = m8xx_set_io_map,
1175 .set_mem_map = m8xx_set_mem_map,
1176};
1177
1178static int __init m8xx_init(void)
1179{
1180 struct pcmcia_win *w;
1181 unsigned int i,m;
1182
1183 pcmcia_info("%s\n", version);
1184
1185 if (driver_register(&m8xx_driver))
1186 return -1;
1187
1188 pcmcia_info(PCMCIA_BOARD_MSG " using " PCMCIA_SLOT_MSG
1189 " with IRQ %u.\n", pcmcia_schlvl);
1190
1191 /* Configure Status change interrupt */
1192
1193 if(request_irq(pcmcia_schlvl, m8xx_interrupt, 0,
1194 "m8xx_pcmcia", NULL)) {
1195 pcmcia_error("Cannot allocate IRQ %u for SCHLVL!\n",
1196 pcmcia_schlvl);
1197 return -1;
1198 }
1199
1200 w = (void *) &((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pbr0;
1201
1202 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_pscr,
1203 M8XX_PCMCIA_MASK(0)| M8XX_PCMCIA_MASK(1));
1204
1205 out_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per,
1206 in_be32(&((immap_t *)IMAP_ADDR)->im_pcmcia.pcmc_per) &
1207 ~(M8XX_PCMCIA_MASK(0)| M8XX_PCMCIA_MASK(1)));
1208
1209/* connect interrupt and disable CxOE */
1210
1211 out_be32(M8XX_PGCRX(0), M8XX_PGCRX_CXOE | (mk_int_int_mask(pcmcia_schlvl) << 16));
1212 out_be32(M8XX_PGCRX(1), M8XX_PGCRX_CXOE | (mk_int_int_mask(pcmcia_schlvl) << 16));
1213
1214/* intialize the fixed memory windows */
1215
1216 for(i = 0; i < PCMCIA_SOCKETS_NO; i++){
1217 for(m = 0; m < PCMCIA_MEM_WIN_NO; m++) {
1218 out_be32(&w->br, PCMCIA_MEM_WIN_BASE +
1219 (PCMCIA_MEM_WIN_SIZE
1220 * (m + i * PCMCIA_MEM_WIN_NO)));
1221
1222 out_be32(&w->or, 0); /* set to not valid */
1223
1224 w++;
1225 }
1226 }
1227
1228/* turn off voltage */
1229 voltage_set(0, 0, 0);
1230 voltage_set(1, 0, 0);
1231
1232/* Enable external hardware */
1233 hardware_enable(0);
1234 hardware_enable(1);
1235
1236 platform_device_register(&m8xx_device);
1237
1238 for (i = 0 ; i < PCMCIA_SOCKETS_NO; i++) {
1239 socket[i].slot = i;
1240 socket[i].socket.owner = THIS_MODULE;
1241 socket[i].socket.features = SS_CAP_PCCARD | SS_CAP_MEM_ALIGN | SS_CAP_STATIC_MAP;
1242 socket[i].socket.irq_mask = 0x000;
1243 socket[i].socket.map_size = 0x1000;
1244 socket[i].socket.io_offset = 0;
1245 socket[i].socket.pci_irq = i ? 7 : 9;
1246 socket[i].socket.ops = &m8xx_services;
1247 socket[i].socket.resource_ops = &pccard_nonstatic_ops;
1248 socket[i].socket.cb_dev = NULL;
1249 socket[i].socket.dev.dev = &m8xx_device.dev;
1250 }
1251
1252 for (i = 0; i < PCMCIA_SOCKETS_NO; i++)
1253 pcmcia_register_socket(&socket[i].socket);
1254
1255 return 0;
1256}
1257
1258static void __exit m8xx_exit(void)
1259{
1260 int i;
1261
1262 for (i = 0; i < PCMCIA_SOCKETS_NO; i++)
1263 pcmcia_unregister_socket(&socket[i].socket);
1264
1265 m8xx_shutdown();
1266
1267 platform_device_unregister(&m8xx_device);
1268 driver_unregister(&m8xx_driver);
1269}
1270
1271module_init(m8xx_init);
1272module_exit(m8xx_exit);
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 08d1c9288264..47b5ade95bde 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -12,7 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/device.h> 15#include <linux/platform_device.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/delay.h> 18#include <linux/delay.h>
@@ -22,7 +22,6 @@
22 22
23#include <asm/hardware.h> 23#include <asm/hardware.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/mach-types.h>
26#include <asm/sizes.h> 25#include <asm/sizes.h>
27 26
28#include <asm/arch/mux.h> 27#include <asm/arch/mux.h>
@@ -330,27 +329,13 @@ static int __devexit omap_cf_remove(struct device *dev)
330 return 0; 329 return 0;
331} 330}
332 331
333static int omap_cf_suspend(struct device *dev, pm_message_t mesg, u32 level)
334{
335 if (level != SUSPEND_SAVE_STATE)
336 return 0;
337 return pcmcia_socket_dev_suspend(dev, mesg);
338}
339
340static int omap_cf_resume(struct device *dev, u32 level)
341{
342 if (level != RESUME_RESTORE_STATE)
343 return 0;
344 return pcmcia_socket_dev_resume(dev);
345}
346
347static struct device_driver omap_cf_driver = { 332static struct device_driver omap_cf_driver = {
348 .name = (char *) driver_name, 333 .name = (char *) driver_name,
349 .bus = &platform_bus_type, 334 .bus = &platform_bus_type,
350 .probe = omap_cf_probe, 335 .probe = omap_cf_probe,
351 .remove = __devexit_p(omap_cf_remove), 336 .remove = __devexit_p(omap_cf_remove),
352 .suspend = omap_cf_suspend, 337 .suspend = pcmcia_socket_dev_suspend,
353 .resume = omap_cf_resume, 338 .resume = pcmcia_socket_dev_resume,
354}; 339};
355 340
356static int __init omap_cf_init(void) 341static int __init omap_cf_init(void)
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 325c992f7d8f..7fa18fb814bc 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -23,6 +23,7 @@
23#include <linux/ioport.h> 23#include <linux/ioport.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26#include <linux/platform_device.h>
26 27
27#include <asm/hardware.h> 28#include <asm/hardware.h>
28#include <asm/io.h> 29#include <asm/io.h>
@@ -205,32 +206,20 @@ int pxa2xx_drv_pcmcia_probe(struct device *dev)
205} 206}
206EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe); 207EXPORT_SYMBOL(pxa2xx_drv_pcmcia_probe);
207 208
208static int pxa2xx_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level) 209static int pxa2xx_drv_pcmcia_resume(struct device *dev)
209{ 210{
210 int ret = 0; 211 struct pcmcia_low_level *ops = dev->platform_data;
211 if (level == SUSPEND_SAVE_STATE) 212 int nr = ops ? ops->nr : 0;
212 ret = pcmcia_socket_dev_suspend(dev, state);
213 return ret;
214}
215 213
216static int pxa2xx_drv_pcmcia_resume(struct device *dev, u32 level) 214 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
217{ 215
218 int ret = 0; 216 return pcmcia_socket_dev_resume(dev);
219 if (level == RESUME_RESTORE_STATE)
220 {
221 struct pcmcia_low_level *ops = dev->platform_data;
222 int nr = ops ? ops->nr : 0;
223
224 MECR = nr > 1 ? MECR_CIT | MECR_NOS : (nr > 0 ? MECR_CIT : 0);
225 ret = pcmcia_socket_dev_resume(dev);
226 }
227 return ret;
228} 217}
229 218
230static struct device_driver pxa2xx_pcmcia_driver = { 219static struct device_driver pxa2xx_pcmcia_driver = {
231 .probe = pxa2xx_drv_pcmcia_probe, 220 .probe = pxa2xx_drv_pcmcia_probe,
232 .remove = soc_common_drv_pcmcia_remove, 221 .remove = soc_common_drv_pcmcia_remove,
233 .suspend = pxa2xx_drv_pcmcia_suspend, 222 .suspend = pcmcia_socket_dev_suspend,
234 .resume = pxa2xx_drv_pcmcia_resume, 223 .resume = pxa2xx_drv_pcmcia_resume,
235 .name = "pxa2xx-pcmcia", 224 .name = "pxa2xx-pcmcia",
236 .bus = &platform_bus_type, 225 .bus = &platform_bus_type,
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c
index bbe69b07ce50..5209d8c7764f 100644
--- a/drivers/pcmcia/pxa2xx_mainstone.c
+++ b/drivers/pcmcia/pxa2xx_mainstone.c
@@ -17,7 +17,7 @@
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/errno.h> 18#include <linux/errno.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/device.h> 20#include <linux/platform_device.h>
21 21
22#include <pcmcia/ss.h> 22#include <pcmcia/ss.h>
23 23
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index a1178a600e3c..56c58831e80e 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -16,17 +16,26 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/errno.h> 17#include <linux/errno.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/device.h> 19#include <linux/platform_device.h>
20 20
21#include <asm/mach-types.h>
21#include <asm/hardware.h> 22#include <asm/hardware.h>
22#include <asm/irq.h> 23#include <asm/irq.h>
23#include <asm/hardware/scoop.h> 24#include <asm/hardware/scoop.h>
24#include <asm/arch/pxa-regs.h>
25 25
26#include "soc_common.h" 26#include "soc_common.h"
27 27
28#define NO_KEEP_VS 0x0001 28#define NO_KEEP_VS 0x0001
29 29
30/* PCMCIA to Scoop linkage
31
32 There is no easy way to link multiple scoop devices into one
33 single entity for the pxa2xx_pcmcia device so this structure
34 is used which is setup by the platform code
35*/
36struct scoop_pcmcia_config *platform_scoop_config;
37#define SCOOP_DEV platform_scoop_config->devs
38
30static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev) 39static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev)
31{ 40{
32 reset_scoop(scoopdev->dev); 41 reset_scoop(scoopdev->dev);
@@ -38,36 +47,16 @@ static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
38{ 47{
39 int ret; 48 int ret;
40 49
41 /* 50 if (platform_scoop_config->pcmcia_init)
42 * Setup default state of GPIO outputs 51 platform_scoop_config->pcmcia_init();
43 * before we enable them as outputs.
44 */
45 GPSR(GPIO48_nPOE) =
46 GPIO_bit(GPIO48_nPOE) |
47 GPIO_bit(GPIO49_nPWE) |
48 GPIO_bit(GPIO50_nPIOR) |
49 GPIO_bit(GPIO51_nPIOW) |
50 GPIO_bit(GPIO52_nPCE_1) |
51 GPIO_bit(GPIO53_nPCE_2);
52
53 pxa_gpio_mode(GPIO48_nPOE_MD);
54 pxa_gpio_mode(GPIO49_nPWE_MD);
55 pxa_gpio_mode(GPIO50_nPIOR_MD);
56 pxa_gpio_mode(GPIO51_nPIOW_MD);
57 pxa_gpio_mode(GPIO52_nPCE_1_MD);
58 pxa_gpio_mode(GPIO53_nPCE_2_MD);
59 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
60 pxa_gpio_mode(GPIO55_nPREG_MD);
61 pxa_gpio_mode(GPIO56_nPWAIT_MD);
62 pxa_gpio_mode(GPIO57_nIOIS16_MD);
63 52
64 /* Register interrupts */ 53 /* Register interrupts */
65 if (scoop_devs[skt->nr].cd_irq >= 0) { 54 if (SCOOP_DEV[skt->nr].cd_irq >= 0) {
66 struct pcmcia_irqs cd_irq; 55 struct pcmcia_irqs cd_irq;
67 56
68 cd_irq.sock = skt->nr; 57 cd_irq.sock = skt->nr;
69 cd_irq.irq = scoop_devs[skt->nr].cd_irq; 58 cd_irq.irq = SCOOP_DEV[skt->nr].cd_irq;
70 cd_irq.str = scoop_devs[skt->nr].cd_irq_str; 59 cd_irq.str = SCOOP_DEV[skt->nr].cd_irq_str;
71 ret = soc_pcmcia_request_irqs(skt, &cd_irq, 1); 60 ret = soc_pcmcia_request_irqs(skt, &cd_irq, 1);
72 61
73 if (ret) { 62 if (ret) {
@@ -76,19 +65,19 @@ static int sharpsl_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
76 } 65 }
77 } 66 }
78 67
79 skt->irq = scoop_devs[skt->nr].irq; 68 skt->irq = SCOOP_DEV[skt->nr].irq;
80 69
81 return 0; 70 return 0;
82} 71}
83 72
84static void sharpsl_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) 73static void sharpsl_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
85{ 74{
86 if (scoop_devs[skt->nr].cd_irq >= 0) { 75 if (SCOOP_DEV[skt->nr].cd_irq >= 0) {
87 struct pcmcia_irqs cd_irq; 76 struct pcmcia_irqs cd_irq;
88 77
89 cd_irq.sock = skt->nr; 78 cd_irq.sock = skt->nr;
90 cd_irq.irq = scoop_devs[skt->nr].cd_irq; 79 cd_irq.irq = SCOOP_DEV[skt->nr].cd_irq;
91 cd_irq.str = scoop_devs[skt->nr].cd_irq_str; 80 cd_irq.str = SCOOP_DEV[skt->nr].cd_irq_str;
92 soc_pcmcia_free_irqs(skt, &cd_irq, 1); 81 soc_pcmcia_free_irqs(skt, &cd_irq, 1);
93 } 82 }
94} 83}
@@ -98,9 +87,9 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
98 struct pcmcia_state *state) 87 struct pcmcia_state *state)
99{ 88{
100 unsigned short cpr, csr; 89 unsigned short cpr, csr;
101 struct device *scoop = scoop_devs[skt->nr].dev; 90 struct device *scoop = SCOOP_DEV[skt->nr].dev;
102 91
103 cpr = read_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_CPR); 92 cpr = read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR);
104 93
105 write_scoop_reg(scoop, SCOOP_IRM, 0x00FF); 94 write_scoop_reg(scoop, SCOOP_IRM, 0x00FF);
106 write_scoop_reg(scoop, SCOOP_ISR, 0x0000); 95 write_scoop_reg(scoop, SCOOP_ISR, 0x0000);
@@ -109,21 +98,25 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
109 if (csr & 0x0004) { 98 if (csr & 0x0004) {
110 /* card eject */ 99 /* card eject */
111 write_scoop_reg(scoop, SCOOP_CDR, 0x0000); 100 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
112 scoop_devs[skt->nr].keep_vs = NO_KEEP_VS; 101 SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS;
113 } 102 }
114 else if (!(scoop_devs[skt->nr].keep_vs & NO_KEEP_VS)) { 103 else if (!(SCOOP_DEV[skt->nr].keep_vs & NO_KEEP_VS)) {
115 /* keep vs1,vs2 */ 104 /* keep vs1,vs2 */
116 write_scoop_reg(scoop, SCOOP_CDR, 0x0000); 105 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
117 csr |= scoop_devs[skt->nr].keep_vs; 106 csr |= SCOOP_DEV[skt->nr].keep_vs;
118 } 107 }
119 else if (cpr & 0x0003) { 108 else if (cpr & 0x0003) {
120 /* power on */ 109 /* power on */
121 write_scoop_reg(scoop, SCOOP_CDR, 0x0000); 110 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
122 scoop_devs[skt->nr].keep_vs = (csr & 0x00C0); 111 SCOOP_DEV[skt->nr].keep_vs = (csr & 0x00C0);
123 } 112 }
124 else { 113 else {
125 /* card detect */ 114 /* card detect */
126 write_scoop_reg(scoop, SCOOP_CDR, 0x0002); 115 if ((machine_is_spitz() || machine_is_borzoi()) && skt->nr == 1) {
116 write_scoop_reg(scoop, SCOOP_CDR, 0x0000);
117 } else {
118 write_scoop_reg(scoop, SCOOP_CDR, 0x0002);
119 }
127 } 120 }
128 121
129 state->detect = (csr & 0x0004) ? 0 : 1; 122 state->detect = (csr & 0x0004) ? 0 : 1;
@@ -137,7 +130,6 @@ static void sharpsl_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
137 if ((cpr & 0x0080) && ((cpr & 0x8040) != 0x8040)) { 130 if ((cpr & 0x0080) && ((cpr & 0x8040) != 0x8040)) {
138 printk(KERN_ERR "sharpsl_pcmcia_socket_state(): CPR=%04X, Low voltage!\n", cpr); 131 printk(KERN_ERR "sharpsl_pcmcia_socket_state(): CPR=%04X, Low voltage!\n", cpr);
139 } 132 }
140
141} 133}
142 134
143 135
@@ -145,7 +137,7 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
145 const socket_state_t *state) 137 const socket_state_t *state)
146{ 138{
147 unsigned long flags; 139 unsigned long flags;
148 struct device *scoop = scoop_devs[skt->nr].dev; 140 struct device *scoop = SCOOP_DEV[skt->nr].dev;
149 141
150 unsigned short cpr, ncpr, ccr, nccr, mcr, nmcr, imr, nimr; 142 unsigned short cpr, ncpr, ccr, nccr, mcr, nmcr, imr, nimr;
151 143
@@ -170,8 +162,13 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
170 nccr = (ccr = read_scoop_reg(scoop, SCOOP_CCR)) & ~0x0080; 162 nccr = (ccr = read_scoop_reg(scoop, SCOOP_CCR)) & ~0x0080;
171 nimr = (imr = read_scoop_reg(scoop, SCOOP_IMR)) & ~0x003E; 163 nimr = (imr = read_scoop_reg(scoop, SCOOP_IMR)) & ~0x003E;
172 164
173 ncpr |= (state->Vcc == 33) ? 0x0001 : 165 if ((machine_is_spitz() || machine_is_borzoi() || machine_is_akita()) && skt->nr == 0) {
174 (state->Vcc == 50) ? 0x0002 : 0; 166 ncpr |= (state->Vcc == 33) ? 0x0002 :
167 (state->Vcc == 50) ? 0x0002 : 0;
168 } else {
169 ncpr |= (state->Vcc == 33) ? 0x0001 :
170 (state->Vcc == 50) ? 0x0002 : 0;
171 }
175 nmcr |= (state->flags&SS_IOCARD) ? 0x0010 : 0; 172 nmcr |= (state->flags&SS_IOCARD) ? 0x0010 : 0;
176 ncpr |= (state->flags&SS_OUTPUT_ENA) ? 0x0080 : 0; 173 ncpr |= (state->flags&SS_OUTPUT_ENA) ? 0x0080 : 0;
177 nccr |= (state->flags&SS_RESET)? 0x0080: 0; 174 nccr |= (state->flags&SS_RESET)? 0x0080: 0;
@@ -183,18 +180,22 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
183 ((skt->status&SS_WRPROT) ? 0x0008 : 0); 180 ((skt->status&SS_WRPROT) ? 0x0008 : 0);
184 181
185 if (!(ncpr & 0x0003)) { 182 if (!(ncpr & 0x0003)) {
186 scoop_devs[skt->nr].keep_rd = 0; 183 SCOOP_DEV[skt->nr].keep_rd = 0;
187 } else if (!scoop_devs[skt->nr].keep_rd) { 184 } else if (!SCOOP_DEV[skt->nr].keep_rd) {
188 if (nccr & 0x0080) 185 if (nccr & 0x0080)
189 scoop_devs[skt->nr].keep_rd = 1; 186 SCOOP_DEV[skt->nr].keep_rd = 1;
190 else 187 else
191 nccr |= 0x0080; 188 nccr |= 0x0080;
192 } 189 }
193 190
194 if (mcr != nmcr) 191 if (mcr != nmcr)
195 write_scoop_reg(scoop, SCOOP_MCR, nmcr); 192 write_scoop_reg(scoop, SCOOP_MCR, nmcr);
196 if (cpr != ncpr) 193 if (cpr != ncpr) {
197 write_scoop_reg(scoop, SCOOP_CPR, ncpr); 194 if (platform_scoop_config->power_ctrl)
195 platform_scoop_config->power_ctrl(scoop, ncpr , skt->nr);
196 else
197 write_scoop_reg(scoop, SCOOP_CPR, ncpr);
198 }
198 if (ccr != nccr) 199 if (ccr != nccr)
199 write_scoop_reg(scoop, SCOOP_CCR, nccr); 200 write_scoop_reg(scoop, SCOOP_CCR, nccr);
200 if (imr != nimr) 201 if (imr != nimr)
@@ -207,39 +208,62 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
207 208
208static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt) 209static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
209{ 210{
210 sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]); 211 sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]);
211 212
212 /* Enable interrupt */ 213 /* Enable interrupt */
213 write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_IMR, 0x00C0); 214 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_IMR, 0x00C0);
214 write_scoop_reg(scoop_devs[skt->nr].dev, SCOOP_MCR, 0x0101); 215 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_MCR, 0x0101);
215 scoop_devs[skt->nr].keep_vs = NO_KEEP_VS; 216 SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS;
217
218 if (machine_is_collie())
219 /* We need to disable SS_OUTPUT_ENA here. */
220 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080);
216} 221}
217 222
218static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) 223static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
219{ 224{
220 /* CF_BUS_OFF */ 225 /* CF_BUS_OFF */
221 sharpsl_pcmcia_init_reset(&scoop_devs[skt->nr]); 226 sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]);
227
228 if (machine_is_collie())
229 /* We need to disable SS_OUTPUT_ENA here. */
230 write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080);
222} 231}
223 232
224static struct pcmcia_low_level sharpsl_pcmcia_ops = { 233static struct pcmcia_low_level sharpsl_pcmcia_ops = {
225 .owner = THIS_MODULE, 234 .owner = THIS_MODULE,
226 .hw_init = sharpsl_pcmcia_hw_init, 235 .hw_init = sharpsl_pcmcia_hw_init,
227 .hw_shutdown = sharpsl_pcmcia_hw_shutdown, 236 .hw_shutdown = sharpsl_pcmcia_hw_shutdown,
228 .socket_state = sharpsl_pcmcia_socket_state, 237 .socket_state = sharpsl_pcmcia_socket_state,
229 .configure_socket = sharpsl_pcmcia_configure_socket, 238 .configure_socket = sharpsl_pcmcia_configure_socket,
230 .socket_init = sharpsl_pcmcia_socket_init, 239 .socket_init = sharpsl_pcmcia_socket_init,
231 .socket_suspend = sharpsl_pcmcia_socket_suspend, 240 .socket_suspend = sharpsl_pcmcia_socket_suspend,
232 .first = 0, 241 .first = 0,
233 .nr = 0, 242 .nr = 0,
234}; 243};
235 244
245#ifdef CONFIG_SA1100_COLLIE
246#include "sa11xx_base.h"
247
248int __init pcmcia_collie_init(struct device *dev)
249{
250 int ret = -ENODEV;
251
252 if (machine_is_collie())
253 ret = sa11xx_drv_pcmcia_probe(dev, &sharpsl_pcmcia_ops, 0, 1);
254
255 return ret;
256}
257
258#else
259
236static struct platform_device *sharpsl_pcmcia_device; 260static struct platform_device *sharpsl_pcmcia_device;
237 261
238static int __init sharpsl_pcmcia_init(void) 262static int __init sharpsl_pcmcia_init(void)
239{ 263{
240 int ret; 264 int ret;
241 265
242 sharpsl_pcmcia_ops.nr=scoop_num; 266 sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs;
243 sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); 267 sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL);
244 if (!sharpsl_pcmcia_device) 268 if (!sharpsl_pcmcia_device)
245 return -ENOMEM; 269 return -ENOMEM;
@@ -247,7 +271,7 @@ static int __init sharpsl_pcmcia_init(void)
247 memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device)); 271 memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device));
248 sharpsl_pcmcia_device->name = "pxa2xx-pcmcia"; 272 sharpsl_pcmcia_device->name = "pxa2xx-pcmcia";
249 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 273 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
250 sharpsl_pcmcia_device->dev.parent=scoop_devs[0].dev; 274 sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev;
251 275
252 ret = platform_device_register(sharpsl_pcmcia_device); 276 ret = platform_device_register(sharpsl_pcmcia_device);
253 if (ret) 277 if (ret)
@@ -269,6 +293,7 @@ static void __exit sharpsl_pcmcia_exit(void)
269 293
270fs_initcall(sharpsl_pcmcia_init); 294fs_initcall(sharpsl_pcmcia_init);
271module_exit(sharpsl_pcmcia_exit); 295module_exit(sharpsl_pcmcia_exit);
296#endif
272 297
273MODULE_DESCRIPTION("Sharp SL Series PCMCIA Support"); 298MODULE_DESCRIPTION("Sharp SL Series PCMCIA Support");
274MODULE_LICENSE("GPL"); 299MODULE_LICENSE("GPL");
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index c42455d20eb6..00960a379b9c 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -691,7 +691,7 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned
691 unsigned long size = end - start + 1; 691 unsigned long size = end - start + 1;
692 int ret = 0; 692 int ret = 0;
693 693
694 if (end <= start) 694 if (end < start)
695 return -EINVAL; 695 return -EINVAL;
696 696
697 down(&rsrc_sem); 697 down(&rsrc_sem);
@@ -724,7 +724,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
724 unsigned long size = end - start + 1; 724 unsigned long size = end - start + 1;
725 int ret = 0; 725 int ret = 0;
726 726
727 if (end <= start) 727 if (end < start)
728 return -EINVAL; 728 return -EINVAL;
729 729
730 if (end > IO_SPACE_LIMIT) 730 if (end > IO_SPACE_LIMIT)
@@ -779,7 +779,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
779 if (!s->cb_dev || !s->cb_dev->bus) 779 if (!s->cb_dev || !s->cb_dev->bus)
780 return -ENODEV; 780 return -ENODEV;
781 781
782#if defined(CONFIG_X86) || defined(CONFIG_X86_64) 782#if defined(CONFIG_X86)
783 /* If this is the root bus, the risk of hitting 783 /* If this is the root bus, the risk of hitting
784 * some strange system devices which aren't protected 784 * some strange system devices which aren't protected
785 * by either ACPI resource tables or properly requested 785 * by either ACPI resource tables or properly requested
@@ -817,7 +817,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
817 817
818 /* if we got at least one of IO, and one of MEM, we can be glad and 818 /* if we got at least one of IO, and one of MEM, we can be glad and
819 * activate the PCMCIA subsystem */ 819 * activate the PCMCIA subsystem */
820 if (done & (IORESOURCE_MEM | IORESOURCE_IO)) 820 if (done == (IORESOURCE_MEM | IORESOURCE_IO))
821 s->resource_setup_done = 1; 821 s->resource_setup_done = 1;
822 822
823 return 0; 823 return 0;
@@ -925,7 +925,7 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size
925 return -EINVAL; 925 return -EINVAL;
926 } 926 }
927 } 927 }
928 if (end_addr <= start_addr) 928 if (end_addr < start_addr)
929 return -EINVAL; 929 return -EINVAL;
930 930
931 ret = adjust_io(s, add, start_addr, end_addr); 931 ret = adjust_io(s, add, start_addr, end_addr);
@@ -977,7 +977,7 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz
977 return -EINVAL; 977 return -EINVAL;
978 } 978 }
979 } 979 }
980 if (end_addr <= start_addr) 980 if (end_addr < start_addr)
981 return -EINVAL; 981 return -EINVAL;
982 982
983 ret = adjust_memory(s, add, start_addr, end_addr); 983 ret = adjust_memory(s, add, start_addr, end_addr);
@@ -994,7 +994,8 @@ static struct class_device_attribute *pccard_rsrc_attributes[] = {
994 NULL, 994 NULL,
995}; 995};
996 996
997static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev) 997static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev,
998 struct class_interface *class_intf)
998{ 999{
999 struct pcmcia_socket *s = class_get_devdata(class_dev); 1000 struct pcmcia_socket *s = class_get_devdata(class_dev);
1000 struct class_device_attribute **attr; 1001 struct class_device_attribute **attr;
@@ -1011,7 +1012,8 @@ static int __devinit pccard_sysfs_add_rsrc(struct class_device *class_dev)
1011 return ret; 1012 return ret;
1012} 1013}
1013 1014
1014static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev) 1015static void __devexit pccard_sysfs_remove_rsrc(struct class_device *class_dev,
1016 struct class_interface *class_intf)
1015{ 1017{
1016 struct pcmcia_socket *s = class_get_devdata(class_dev); 1018 struct pcmcia_socket *s = class_get_devdata(class_dev);
1017 struct class_device_attribute **attr; 1019 struct class_device_attribute **attr;
diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c
index d4ed508b38be..6d441ec75c6a 100644
--- a/drivers/pcmcia/sa1100_generic.c
+++ b/drivers/pcmcia/sa1100_generic.c
@@ -33,13 +33,18 @@
33#include <linux/module.h> 33#include <linux/module.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/config.h> 35#include <linux/config.h>
36#include <linux/platform_device.h>
36 37
37#include <pcmcia/cs_types.h> 38#include <pcmcia/cs_types.h>
38#include <pcmcia/cs.h> 39#include <pcmcia/cs.h>
39#include <pcmcia/ss.h> 40#include <pcmcia/ss.h>
40 41
42#include <asm/hardware/scoop.h>
43
41#include "sa1100_generic.h" 44#include "sa1100_generic.h"
42 45
46int __init pcmcia_collie_init(struct device *dev);
47
43static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = { 48static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = {
44#ifdef CONFIG_SA1100_ASSABET 49#ifdef CONFIG_SA1100_ASSABET
45 pcmcia_assabet_init, 50 pcmcia_assabet_init,
@@ -56,6 +61,9 @@ static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = {
56#ifdef CONFIG_SA1100_SIMPAD 61#ifdef CONFIG_SA1100_SIMPAD
57 pcmcia_simpad_init, 62 pcmcia_simpad_init,
58#endif 63#endif
64#ifdef CONFIG_SA1100_COLLIE
65 pcmcia_collie_init,
66#endif
59}; 67};
60 68
61static int sa11x0_drv_pcmcia_probe(struct device *dev) 69static int sa11x0_drv_pcmcia_probe(struct device *dev)
@@ -74,29 +82,13 @@ static int sa11x0_drv_pcmcia_probe(struct device *dev)
74 return ret; 82 return ret;
75} 83}
76 84
77static int sa11x0_drv_pcmcia_suspend(struct device *dev, pm_message_t state, u32 level)
78{
79 int ret = 0;
80 if (level == SUSPEND_SAVE_STATE)
81 ret = pcmcia_socket_dev_suspend(dev, state);
82 return ret;
83}
84
85static int sa11x0_drv_pcmcia_resume(struct device *dev, u32 level)
86{
87 int ret = 0;
88 if (level == RESUME_RESTORE_STATE)
89 ret = pcmcia_socket_dev_resume(dev);
90 return ret;
91}
92
93static struct device_driver sa11x0_pcmcia_driver = { 85static struct device_driver sa11x0_pcmcia_driver = {
94 .probe = sa11x0_drv_pcmcia_probe, 86 .probe = sa11x0_drv_pcmcia_probe,
95 .remove = soc_common_drv_pcmcia_remove, 87 .remove = soc_common_drv_pcmcia_remove,
96 .name = "sa11x0-pcmcia", 88 .name = "sa11x0-pcmcia",
97 .bus = &platform_bus_type, 89 .bus = &platform_bus_type,
98 .suspend = sa11x0_drv_pcmcia_suspend, 90 .suspend = pcmcia_socket_dev_suspend,
99 .resume = sa11x0_drv_pcmcia_resume, 91 .resume = pcmcia_socket_dev_resume,
100}; 92};
101 93
102/* sa11x0_pcmcia_init() 94/* sa11x0_pcmcia_init()
diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c
index bb90a1448a53..81ded52c8959 100644
--- a/drivers/pcmcia/sa1111_generic.c
+++ b/drivers/pcmcia/sa1111_generic.c
@@ -122,7 +122,7 @@ void sa1111_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
122 122
123static int pcmcia_probe(struct sa1111_dev *dev) 123static int pcmcia_probe(struct sa1111_dev *dev)
124{ 124{
125 char *base; 125 void __iomem *base;
126 126
127 if (!request_mem_region(dev->res.start, 512, 127 if (!request_mem_region(dev->res.start, 512,
128 SA1111_DRIVER_NAME(dev))) 128 SA1111_DRIVER_NAME(dev)))
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 888b70e6a484..9e7ccd8a4321 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -66,7 +66,7 @@ void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func,
66 if (pc_debug > lvl) { 66 if (pc_debug > lvl) {
67 printk(KERN_DEBUG "skt%u: %s: ", skt->nr, func); 67 printk(KERN_DEBUG "skt%u: %s: ", skt->nr, func);
68 va_start(args, fmt); 68 va_start(args, fmt);
69 printk(fmt, args); 69 vprintk(fmt, args);
70 va_end(args); 70 va_end(args);
71 } 71 }
72} 72}
@@ -321,8 +321,6 @@ soc_common_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
321 * less punt all of this work and let the kernel handle the details 321 * less punt all of this work and let the kernel handle the details
322 * of power configuration, reset, &c. We also record the value of 322 * of power configuration, reset, &c. We also record the value of
323 * `state' in order to regurgitate it to the PCMCIA core later. 323 * `state' in order to regurgitate it to the PCMCIA core later.
324 *
325 * Returns: 0
326 */ 324 */
327static int 325static int
328soc_common_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state) 326soc_common_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
@@ -407,7 +405,7 @@ soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *m
407 * the map speed as requested, but override the address ranges 405 * the map speed as requested, but override the address ranges
408 * supplied by Card Services. 406 * supplied by Card Services.
409 * 407 *
410 * Returns: 0 on success, -1 on error 408 * Returns: 0 on success, -ERRNO on error
411 */ 409 */
412static int 410static int
413soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map) 411soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
@@ -655,8 +653,8 @@ static void soc_pcmcia_cpufreq_unregister(void)
655} 653}
656 654
657#else 655#else
658#define soc_pcmcia_cpufreq_register() 656static int soc_pcmcia_cpufreq_register(void) { return 0; }
659#define soc_pcmcia_cpufreq_unregister() 657static void soc_pcmcia_cpufreq_unregister(void) {}
660#endif 658#endif
661 659
662int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr) 660int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
@@ -738,7 +736,7 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
738 goto out_err_5; 736 goto out_err_5;
739 } 737 }
740 738
741 if ( list_empty(&soc_pcmcia_sockets) ) 739 if (list_empty(&soc_pcmcia_sockets))
742 soc_pcmcia_cpufreq_register(); 740 soc_pcmcia_cpufreq_register();
743 741
744 list_add(&skt->node, &soc_pcmcia_sockets); 742 list_add(&skt->node, &soc_pcmcia_sockets);
@@ -839,7 +837,7 @@ int soc_common_drv_pcmcia_remove(struct device *dev)
839 release_resource(&skt->res_io); 837 release_resource(&skt->res_io);
840 release_resource(&skt->res_skt); 838 release_resource(&skt->res_skt);
841 } 839 }
842 if ( list_empty(&soc_pcmcia_sockets) ) 840 if (list_empty(&soc_pcmcia_sockets))
843 soc_pcmcia_cpufreq_unregister(); 841 soc_pcmcia_cpufreq_unregister();
844 842
845 up(&soc_pcmcia_sockets_lock); 843 up(&soc_pcmcia_sockets_lock);
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 1040a6c1a8a4..4a3150a7854c 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -341,7 +341,8 @@ static struct bin_attribute pccard_cis_attr = {
341 .write = pccard_store_cis, 341 .write = pccard_store_cis,
342}; 342};
343 343
344static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) 344static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev,
345 struct class_interface *class_intf)
345{ 346{
346 struct class_device_attribute **attr; 347 struct class_device_attribute **attr;
347 int ret = 0; 348 int ret = 0;
@@ -357,7 +358,8 @@ static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev)
357 return ret; 358 return ret;
358} 359}
359 360
360static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev) 361static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev,
362 struct class_interface *class_intf)
361{ 363{
362 struct class_device_attribute **attr; 364 struct class_device_attribute **attr;
363 365
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index d5a61eae6119..e31263864377 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -44,7 +44,7 @@
44#include <linux/ioport.h> 44#include <linux/ioport.h>
45#include <linux/delay.h> 45#include <linux/delay.h>
46#include <linux/workqueue.h> 46#include <linux/workqueue.h>
47#include <linux/device.h> 47#include <linux/platform_device.h>
48#include <linux/bitops.h> 48#include <linux/bitops.h>
49 49
50#include <asm/io.h> 50#include <asm/io.h>
@@ -372,27 +372,11 @@ static int __init get_tcic_id(void)
372 372
373/*====================================================================*/ 373/*====================================================================*/
374 374
375static int tcic_drv_suspend(struct device *dev, pm_message_t state, u32 level)
376{
377 int ret = 0;
378 if (level == SUSPEND_SAVE_STATE)
379 ret = pcmcia_socket_dev_suspend(dev, state);
380 return ret;
381}
382
383static int tcic_drv_resume(struct device *dev, u32 level)
384{
385 int ret = 0;
386 if (level == RESUME_RESTORE_STATE)
387 ret = pcmcia_socket_dev_resume(dev);
388 return ret;
389}
390
391static struct device_driver tcic_driver = { 375static struct device_driver tcic_driver = {
392 .name = "tcic-pcmcia", 376 .name = "tcic-pcmcia",
393 .bus = &platform_bus_type, 377 .bus = &platform_bus_type,
394 .suspend = tcic_drv_suspend, 378 .suspend = pcmcia_socket_dev_suspend,
395 .resume = tcic_drv_resume, 379 .resume = pcmcia_socket_dev_resume,
396}; 380};
397 381
398static struct platform_device tcic_device = { 382static struct platform_device tcic_device = {
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index fbe233e19ceb..539b5cd1a598 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -59,6 +59,7 @@
59 59
60#define TI122X_SCR_SER_STEP 0xc0000000 60#define TI122X_SCR_SER_STEP 0xc0000000
61#define TI122X_SCR_INTRTIE 0x20000000 61#define TI122X_SCR_INTRTIE 0x20000000
62#define TIXX21_SCR_TIEALL 0x10000000
62#define TI122X_SCR_CBRSVD 0x00400000 63#define TI122X_SCR_CBRSVD 0x00400000
63#define TI122X_SCR_MRBURSTDN 0x00008000 64#define TI122X_SCR_MRBURSTDN 0x00008000
64#define TI122X_SCR_MRBURSTUP 0x00004000 65#define TI122X_SCR_MRBURSTUP 0x00004000
@@ -153,6 +154,12 @@
153/* EnE test register */ 154/* EnE test register */
154#define ENE_TEST_C9 0xc9 /* 8bit */ 155#define ENE_TEST_C9 0xc9 /* 8bit */
155#define ENE_TEST_C9_TLTENABLE 0x02 156#define ENE_TEST_C9_TLTENABLE 0x02
157#define ENE_TEST_C9_PFENABLE_F0 0x04
158#define ENE_TEST_C9_PFENABLE_F1 0x08
159#define ENE_TEST_C9_PFENABLE (ENE_TEST_C9_PFENABLE_F0 | ENE_TEST_C9_PFENABLE_F0)
160#define ENE_TEST_C9_WPDISALBLE_F0 0x40
161#define ENE_TEST_C9_WPDISALBLE_F1 0x80
162#define ENE_TEST_C9_WPDISALBLE (ENE_TEST_C9_WPDISALBLE_F0 | ENE_TEST_C9_WPDISALBLE_F1)
156 163
157/* 164/*
158 * Texas Instruments CardBus controller overrides. 165 * Texas Instruments CardBus controller overrides.
@@ -618,6 +625,7 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
618 int devfn; 625 int devfn;
619 unsigned int state; 626 unsigned int state;
620 int ret = 1; 627 int ret = 1;
628 u32 sysctl;
621 629
622 /* catch the two-slot controllers */ 630 /* catch the two-slot controllers */
623 switch (socket->dev->device) { 631 switch (socket->dev->device) {
@@ -640,6 +648,24 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
640 */ 648 */
641 break; 649 break;
642 650
651 case PCI_DEVICE_ID_TI_X515:
652 case PCI_DEVICE_ID_TI_X420:
653 case PCI_DEVICE_ID_TI_X620:
654 case PCI_DEVICE_ID_TI_XX21_XX11:
655 case PCI_DEVICE_ID_TI_7410:
656 case PCI_DEVICE_ID_TI_7610:
657 /*
658 * those are either single or dual slot CB with additional functions
659 * like 1394, smartcard reader, etc. check the TIEALL flag for them
660 * the TIEALL flag binds the IRQ of all functions toghether.
661 * we catch the single slot variants later.
662 */
663 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
664 if (sysctl & TIXX21_SCR_TIEALL)
665 return 0;
666
667 break;
668
643 /* single-slot controllers have the 2nd slot empty always :) */ 669 /* single-slot controllers have the 2nd slot empty always :) */
644 default: 670 default:
645 return 1; 671 return 1;
@@ -652,6 +678,15 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
652 if (!func) 678 if (!func)
653 return 1; 679 return 1;
654 680
681 /*
682 * check that the device id of both slots match. this is needed for the
683 * XX21 and the XX11 controller that share the same device id for single
684 * and dual slot controllers. return '2nd slot empty'. we already checked
685 * if the interrupt is tied to another function.
686 */
687 if (socket->dev->device != func->device)
688 goto out;
689
655 slot2 = pci_get_drvdata(func); 690 slot2 = pci_get_drvdata(func);
656 if (!slot2) 691 if (!slot2)
657 goto out; 692 goto out;
@@ -791,16 +826,6 @@ static int ti12xx_override(struct yenta_socket *socket)
791 config_writel(socket, TI113X_SYSTEM_CONTROL, val); 826 config_writel(socket, TI113X_SYSTEM_CONTROL, val);
792 827
793 /* 828 /*
794 * for EnE bridges only: clear testbit TLTEnable. this makes the
795 * RME Hammerfall DSP sound card working.
796 */
797 if (socket->dev->vendor == PCI_VENDOR_ID_ENE) {
798 u8 test_c9 = config_readb(socket, ENE_TEST_C9);
799 test_c9 &= ~ENE_TEST_C9_TLTENABLE;
800 config_writeb(socket, ENE_TEST_C9, test_c9);
801 }
802
803 /*
804 * Yenta expects controllers to use CSCINT to route 829 * Yenta expects controllers to use CSCINT to route
805 * CSC interrupts to PCI rather than INTVAL. 830 * CSC interrupts to PCI rather than INTVAL.
806 */ 831 */
@@ -841,5 +866,78 @@ static int ti1250_override(struct yenta_socket *socket)
841 return ti12xx_override(socket); 866 return ti12xx_override(socket);
842} 867}
843 868
869
870/**
871 * EnE specific part. EnE bridges are register compatible with TI bridges but
872 * have their own test registers and more important their own little problems.
873 * Some fixup code to make everybody happy (TM).
874 */
875
876#ifdef CONFIG_CARDBUS
877/**
878 * set/clear various test bits:
879 * Defaults to clear the bit.
880 * - mask (u8) defines what bits to change
881 * - bits (u8) is the values to change them to
882 * -> it's
883 * current = (current & ~mask) | bits
884 */
885/* pci ids of devices that wants to have the bit set */
886#define DEVID(_vend,_dev,_subvend,_subdev,mask,bits) { \
887 .vendor = _vend, \
888 .device = _dev, \
889 .subvendor = _subvend, \
890 .subdevice = _subdev, \
891 .driver_data = ((mask) << 8 | (bits)), \
892 }
893static struct pci_device_id ene_tune_tbl[] = {
894 /* Echo Audio products based on motorola DSP56301 and DSP56361 */
895 DEVID(PCI_VENDOR_ID_MOTOROLA, 0x1801, 0xECC0, PCI_ANY_ID,
896 ENE_TEST_C9_TLTENABLE | ENE_TEST_C9_PFENABLE, ENE_TEST_C9_TLTENABLE),
897 DEVID(PCI_VENDOR_ID_MOTOROLA, 0x3410, 0xECC0, PCI_ANY_ID,
898 ENE_TEST_C9_TLTENABLE | ENE_TEST_C9_PFENABLE, ENE_TEST_C9_TLTENABLE),
899
900 {}
901};
902
903static void ene_tune_bridge(struct pcmcia_socket *sock, struct pci_bus *bus)
904{
905 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
906 struct pci_dev *dev;
907 struct pci_device_id *id = NULL;
908 u8 test_c9, old_c9, mask, bits;
909
910 list_for_each_entry(dev, &bus->devices, bus_list) {
911 id = (struct pci_device_id *) pci_match_id(ene_tune_tbl, dev);
912 if (id)
913 break;
914 }
915
916 test_c9 = old_c9 = config_readb(socket, ENE_TEST_C9);
917 if (id) {
918 mask = (id->driver_data >> 8) & 0xFF;
919 bits = id->driver_data & 0xFF;
920
921 test_c9 = (test_c9 & ~mask) | bits;
922 }
923 else
924 /* default to clear TLTEnable bit, old behaviour */
925 test_c9 &= ~ENE_TEST_C9_TLTENABLE;
926
927 printk(KERN_INFO "yenta EnE: chaning testregister 0xC9, %02x -> %02x\n", old_c9, test_c9);
928 config_writeb(socket, ENE_TEST_C9, test_c9);
929}
930
931static int ene_override(struct yenta_socket *socket)
932{
933 /* install tune_bridge() function */
934 socket->socket.tune_bridge = ene_tune_bridge;
935
936 return ti1250_override(socket);
937}
938#else
939# define ene_override ti1250_override
940#endif
941
844#endif /* _LINUX_TI113X_H */ 942#endif /* _LINUX_TI113X_H */
845 943
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index 17bb2da6752b..38a028c725d4 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -24,6 +24,7 @@
24#include <linux/spinlock.h> 24#include <linux/spinlock.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/platform_device.h>
27 28
28#include <asm/io.h> 29#include <asm/io.h>
29 30
@@ -774,31 +775,11 @@ static int __devinit vrc4171_card_setup(char *options)
774 775
775__setup("vrc4171_card=", vrc4171_card_setup); 776__setup("vrc4171_card=", vrc4171_card_setup);
776 777
777static int vrc4171_card_suspend(struct device *dev, pm_message_t state, u32 level)
778{
779 int retval = 0;
780
781 if (level == SUSPEND_SAVE_STATE)
782 retval = pcmcia_socket_dev_suspend(dev, state);
783
784 return retval;
785}
786
787static int vrc4171_card_resume(struct device *dev, u32 level)
788{
789 int retval = 0;
790
791 if (level == RESUME_RESTORE_STATE)
792 retval = pcmcia_socket_dev_resume(dev);
793
794 return retval;
795}
796
797static struct device_driver vrc4171_card_driver = { 778static struct device_driver vrc4171_card_driver = {
798 .name = vrc4171_card_name, 779 .name = vrc4171_card_name,
799 .bus = &platform_bus_type, 780 .bus = &platform_bus_type,
800 .suspend = vrc4171_card_suspend, 781 .suspend = pcmcia_socket_dev_suspend,
801 .resume = vrc4171_card_resume, 782 .resume = pcmcia_socket_dev_resume,
802}; 783};
803 784
804static int __devinit vrc4171_card_init(void) 785static int __devinit vrc4171_card_init(void)
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index ba4d78e5b121..ec6ab65f0872 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -151,6 +151,40 @@ static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val)
151 readb(socket->base + 0x800 + reg + 1); 151 readb(socket->base + 0x800 + reg + 1);
152} 152}
153 153
154static ssize_t show_yenta_registers(struct device *yentadev, struct device_attribute *attr, char *buf)
155{
156 struct pci_dev *dev = to_pci_dev(yentadev);
157 struct yenta_socket *socket = pci_get_drvdata(dev);
158 int offset = 0, i;
159
160 offset = snprintf(buf, PAGE_SIZE, "CB registers:");
161 for (i = 0; i < 0x24; i += 4) {
162 unsigned val;
163 if (!(i & 15))
164 offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i);
165 val = cb_readl(socket, i);
166 offset += snprintf(buf + offset, PAGE_SIZE - offset, " %08x", val);
167 }
168
169 offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n\nExCA registers:");
170 for (i = 0; i < 0x45; i++) {
171 unsigned char val;
172 if (!(i & 7)) {
173 if (i & 8) {
174 memcpy(buf + offset, " -", 2);
175 offset += 2;
176 } else
177 offset += snprintf(buf + offset, PAGE_SIZE - offset, "\n%02x:", i);
178 }
179 val = exca_readb(socket, i);
180 offset += snprintf(buf + offset, PAGE_SIZE - offset, " %02x", val);
181 }
182 buf[offset++] = '\n';
183 return offset;
184}
185
186static DEVICE_ATTR(yenta_registers, S_IRUSR, show_yenta_registers, NULL);
187
154/* 188/*
155 * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend 189 * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend
156 * on what kind of card is inserted.. 190 * on what kind of card is inserted..
@@ -559,12 +593,6 @@ static void yenta_interrogate(struct yenta_socket *socket)
559static int yenta_sock_init(struct pcmcia_socket *sock) 593static int yenta_sock_init(struct pcmcia_socket *sock)
560{ 594{
561 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket); 595 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
562 u16 bridge;
563
564 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~CB_BRIDGE_INTR;
565 if (!socket->cb_irq)
566 bridge |= CB_BRIDGE_INTR;
567 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
568 596
569 exca_writeb(socket, I365_GBLCTL, 0x00); 597 exca_writeb(socket, I365_GBLCTL, 0x00);
570 exca_writeb(socket, I365_GENCTL, 0x00); 598 exca_writeb(socket, I365_GENCTL, 0x00);
@@ -771,6 +799,9 @@ static void yenta_close(struct pci_dev *dev)
771{ 799{
772 struct yenta_socket *sock = pci_get_drvdata(dev); 800 struct yenta_socket *sock = pci_get_drvdata(dev);
773 801
802 /* Remove the register attributes */
803 device_remove_file(&dev->dev, &dev_attr_yenta_registers);
804
774 /* we don't want a dying socket registered */ 805 /* we don't want a dying socket registered */
775 pcmcia_unregister_socket(&sock->socket); 806 pcmcia_unregister_socket(&sock->socket);
776 807
@@ -819,6 +850,7 @@ enum {
819 CARDBUS_TYPE_TOPIC95, 850 CARDBUS_TYPE_TOPIC95,
820 CARDBUS_TYPE_TOPIC97, 851 CARDBUS_TYPE_TOPIC97,
821 CARDBUS_TYPE_O2MICRO, 852 CARDBUS_TYPE_O2MICRO,
853 CARDBUS_TYPE_ENE,
822}; 854};
823 855
824/* 856/*
@@ -865,6 +897,12 @@ static struct cardbus_type cardbus_type[] = {
865 .override = o2micro_override, 897 .override = o2micro_override,
866 .restore_state = o2micro_restore_state, 898 .restore_state = o2micro_restore_state,
867 }, 899 },
900 [CARDBUS_TYPE_ENE] = {
901 .override = ene_override,
902 .save_state = ti_save_state,
903 .restore_state = ti_restore_state,
904 .sock_init = ti_init,
905 },
868}; 906};
869 907
870 908
@@ -883,16 +921,8 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
883{ 921{
884 int i; 922 int i;
885 unsigned long val; 923 unsigned long val;
886 u16 bridge_ctrl;
887 u32 mask; 924 u32 mask;
888 925
889 /* Set up ISA irq routing to probe the ISA irqs.. */
890 bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
891 if (!(bridge_ctrl & CB_BRIDGE_INTR)) {
892 bridge_ctrl |= CB_BRIDGE_INTR;
893 config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
894 }
895
896 /* 926 /*
897 * Probe for usable interrupts using the force 927 * Probe for usable interrupts using the force
898 * register to generate bogus card status events. 928 * register to generate bogus card status events.
@@ -914,9 +944,6 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
914 944
915 mask = probe_irq_mask(val) & 0xffff; 945 mask = probe_irq_mask(val) & 0xffff;
916 946
917 bridge_ctrl &= ~CB_BRIDGE_INTR;
918 config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
919
920 return mask; 947 return mask;
921} 948}
922 949
@@ -944,18 +971,11 @@ static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *re
944/* probes the PCI interrupt, use only on override functions */ 971/* probes the PCI interrupt, use only on override functions */
945static int yenta_probe_cb_irq(struct yenta_socket *socket) 972static int yenta_probe_cb_irq(struct yenta_socket *socket)
946{ 973{
947 u16 bridge_ctrl;
948
949 if (!socket->cb_irq) 974 if (!socket->cb_irq)
950 return -1; 975 return -1;
951 976
952 socket->probe_status = 0; 977 socket->probe_status = 0;
953 978
954 /* disable ISA interrupts */
955 bridge_ctrl = config_readw(socket, CB_BRIDGE_CONTROL);
956 bridge_ctrl &= ~CB_BRIDGE_INTR;
957 config_writew(socket, CB_BRIDGE_CONTROL, bridge_ctrl);
958
959 if (request_irq(socket->cb_irq, yenta_probe_handler, SA_SHIRQ, "yenta", socket)) { 979 if (request_irq(socket->cb_irq, yenta_probe_handler, SA_SHIRQ, "yenta", socket)) {
960 printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n"); 980 printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n");
961 return -1; 981 return -1;
@@ -966,7 +986,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket)
966 cb_writel(socket, CB_SOCKET_EVENT, -1); 986 cb_writel(socket, CB_SOCKET_EVENT, -1);
967 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK); 987 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
968 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS); 988 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
969 989
970 msleep(100); 990 msleep(100);
971 991
972 /* disable interrupts */ 992 /* disable interrupts */
@@ -1004,11 +1024,12 @@ static void yenta_config_init(struct yenta_socket *socket)
1004{ 1024{
1005 u16 bridge; 1025 u16 bridge;
1006 struct pci_dev *dev = socket->dev; 1026 struct pci_dev *dev = socket->dev;
1027 struct pci_bus_region region;
1007 1028
1008 pci_set_power_state(socket->dev, 0); 1029 pcibios_resource_to_bus(socket->dev, &region, &dev->resource[0]);
1009 1030
1010 config_writel(socket, CB_LEGACY_MODE_BASE, 0); 1031 config_writel(socket, CB_LEGACY_MODE_BASE, 0);
1011 config_writel(socket, PCI_BASE_ADDRESS_0, dev->resource[0].start); 1032 config_writel(socket, PCI_BASE_ADDRESS_0, region.start);
1012 config_writew(socket, PCI_COMMAND, 1033 config_writew(socket, PCI_COMMAND,
1013 PCI_COMMAND_IO | 1034 PCI_COMMAND_IO |
1014 PCI_COMMAND_MEMORY | 1035 PCI_COMMAND_MEMORY |
@@ -1031,8 +1052,8 @@ static void yenta_config_init(struct yenta_socket *socket)
1031 * - PCI interrupts enabled if a PCI interrupt exists.. 1052 * - PCI interrupts enabled if a PCI interrupt exists..
1032 */ 1053 */
1033 bridge = config_readw(socket, CB_BRIDGE_CONTROL); 1054 bridge = config_readw(socket, CB_BRIDGE_CONTROL);
1034 bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_INTR | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN); 1055 bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
1035 bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN | CB_BRIDGE_INTR; 1056 bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN;
1036 config_writew(socket, CB_BRIDGE_CONTROL, bridge); 1057 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
1037} 1058}
1038 1059
@@ -1154,8 +1175,11 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1154 1175
1155 /* Register it with the pcmcia layer.. */ 1176 /* Register it with the pcmcia layer.. */
1156 ret = pcmcia_register_socket(&socket->socket); 1177 ret = pcmcia_register_socket(&socket->socket);
1157 if (ret == 0) 1178 if (ret == 0) {
1179 /* Add the yenta register attributes */
1180 device_create_file(&dev->dev, &dev_attr_yenta_registers);
1158 goto out; 1181 goto out;
1182 }
1159 1183
1160 unmap: 1184 unmap:
1161 iounmap(socket->base); 1185 iounmap(socket->base);
@@ -1265,10 +1289,22 @@ static struct pci_device_id yenta_table [] = {
1265 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250), 1289 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250),
1266 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250), 1290 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250),
1267 1291
1268 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1211, TI12XX), 1292 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11, TI12XX),
1269 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, TI12XX), 1293 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X515, TI12XX),
1270 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, TI1250), 1294 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X420, TI12XX),
1271 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, TI12XX), 1295 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X620, TI12XX),
1296 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7410, TI12XX),
1297 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7510, TI12XX),
1298 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7610, TI12XX),
1299
1300 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_710, TI12XX),
1301 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_712, TI12XX),
1302 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_720, TI12XX),
1303 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_722, TI12XX),
1304 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1211, ENE),
1305 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE),
1306 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE),
1307 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE),
1272 1308
1273 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH), 1309 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
1274 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH), 1310 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),