aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-15 18:29:07 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-15 18:29:07 -0400
commit82638844d9a8581bbf33201cc209a14876eca167 (patch)
tree961d7f9360194421a71aa644a9d0c176a960ce49 /drivers/pcmcia
parent9982fbface82893e77d211fbabfbd229da6bdde6 (diff)
parent63cf13b77ab785e87c867defa8545e6d4a989774 (diff)
Merge branch 'linus' into cpus4096
Conflicts: arch/x86/xen/smp.c kernel/sched_rt.c net/iucv/iucv.c Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/Kconfig7
-rw-r--r--drivers/pcmcia/Makefile1
-rw-r--r--drivers/pcmcia/au1000_generic.h27
-rw-r--r--drivers/pcmcia/au1000_pb1x00.c1
-rw-r--r--drivers/pcmcia/au1000_xxs1500.c1
-rw-r--r--drivers/pcmcia/bfin_cf_pcmcia.c339
-rw-r--r--drivers/pcmcia/cardbus.c2
-rw-r--r--drivers/pcmcia/cistpl.c16
-rw-r--r--drivers/pcmcia/cs.c14
-rw-r--r--drivers/pcmcia/cs_internal.h13
-rw-r--r--drivers/pcmcia/ds.c12
-rw-r--r--drivers/pcmcia/hd64465_ss.c3
-rw-r--r--drivers/pcmcia/i82092.c2
-rw-r--r--drivers/pcmcia/i82092aa.h2
-rw-r--r--drivers/pcmcia/i82365.c39
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c3
-rw-r--r--drivers/pcmcia/omap_cf.c25
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c179
-rw-r--r--drivers/pcmcia/pcmcia_resource.c81
-rw-r--r--drivers/pcmcia/pxa2xx_base.c1
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x270.c15
-rw-r--r--drivers/pcmcia/pxa2xx_mainstone.c13
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c12
-rw-r--r--drivers/pcmcia/rsrc_mgr.c86
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c57
-rw-r--r--drivers/pcmcia/soc_common.h1
-rw-r--r--drivers/pcmcia/socket_sysfs.c8
-rw-r--r--drivers/pcmcia/ti113x.h4
28 files changed, 652 insertions, 312 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 1b0eb5aaf650..e45402adac3f 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -263,6 +263,13 @@ config OMAP_CF
263 Say Y here to support the CompactFlash controller on OMAP. 263 Say Y here to support the CompactFlash controller on OMAP.
264 Note that this doesn't support "True IDE" mode. 264 Note that this doesn't support "True IDE" mode.
265 265
266config BFIN_CFPCMCIA
267 tristate "Blackfin CompactFlash PCMCIA Driver"
268 depends on PCMCIA && BLACKFIN
269 help
270 Say Y here to support the CompactFlash PCMCIA driver for Blackfin.
271
272
266config AT91_CF 273config AT91_CF
267 tristate "AT91 CompactFlash Controller" 274 tristate "AT91 CompactFlash Controller"
268 depends on PCMCIA && ARCH_AT91RM9200 275 depends on PCMCIA && ARCH_AT91RM9200
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index 6f6478ba7174..85c6cc931f97 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_PCMCIA_AU1X00) += au1x00_ss.o
36obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o 36obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o
37obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o 37obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o
38obj-$(CONFIG_OMAP_CF) += omap_cf.o 38obj-$(CONFIG_OMAP_CF) += omap_cf.o
39obj-$(CONFIG_BFIN_CFPCMCIA) += bfin_cf_pcmcia.o
39obj-$(CONFIG_AT91_CF) += at91_cf.o 40obj-$(CONFIG_AT91_CF) += at91_cf.o
40obj-$(CONFIG_ELECTRA_CF) += electra_cf.o 41obj-$(CONFIG_ELECTRA_CF) += electra_cf.o
41 42
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h
index 1e467bb54077..a53ef5902518 100644
--- a/drivers/pcmcia/au1000_generic.h
+++ b/drivers/pcmcia/au1000_generic.h
@@ -26,7 +26,6 @@
26#include <pcmcia/cs_types.h> 26#include <pcmcia/cs_types.h>
27#include <pcmcia/cs.h> 27#include <pcmcia/cs.h>
28#include <pcmcia/ss.h> 28#include <pcmcia/ss.h>
29#include <pcmcia/bulkmem.h>
30#include <pcmcia/cistpl.h> 29#include <pcmcia/cistpl.h>
31#include "cs_internal.h" 30#include "cs_internal.h"
32 31
@@ -34,9 +33,9 @@
34#define AU1000_PCMCIA_IO_SPEED (255) 33#define AU1000_PCMCIA_IO_SPEED (255)
35#define AU1000_PCMCIA_MEM_SPEED (300) 34#define AU1000_PCMCIA_MEM_SPEED (300)
36 35
37#define AU1X_SOCK0_IO 0xF00000000 36#define AU1X_SOCK0_IO 0xF00000000ULL
38#define AU1X_SOCK0_PHYS_ATTR 0xF40000000 37#define AU1X_SOCK0_PHYS_ATTR 0xF40000000ULL
39#define AU1X_SOCK0_PHYS_MEM 0xF80000000 38#define AU1X_SOCK0_PHYS_MEM 0xF80000000ULL
40/* pseudo 32 bit phys addresses, which get fixed up to the 39/* pseudo 32 bit phys addresses, which get fixed up to the
41 * real 36 bit address in fixup_bigphys_addr() */ 40 * real 36 bit address in fixup_bigphys_addr() */
42#define AU1X_SOCK0_PSEUDO_PHYS_ATTR 0xF4000000 41#define AU1X_SOCK0_PSEUDO_PHYS_ATTR 0xF4000000
@@ -45,16 +44,20 @@
45/* pcmcia socket 1 needs external glue logic so the memory map 44/* pcmcia socket 1 needs external glue logic so the memory map
46 * differs from board to board. 45 * differs from board to board.
47 */ 46 */
48#if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1550) || defined(CONFIG_MIPS_PB1200) 47#if defined(CONFIG_MIPS_PB1000) || defined(CONFIG_MIPS_PB1100) || \
49#define AU1X_SOCK1_IO 0xF08000000 48 defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1550) || \
50#define AU1X_SOCK1_PHYS_ATTR 0xF48000000 49 defined(CONFIG_MIPS_PB1200)
51#define AU1X_SOCK1_PHYS_MEM 0xF88000000 50#define AU1X_SOCK1_IO 0xF08000000ULL
51#define AU1X_SOCK1_PHYS_ATTR 0xF48000000ULL
52#define AU1X_SOCK1_PHYS_MEM 0xF88000000ULL
52#define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4800000 53#define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4800000
53#define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8800000 54#define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8800000
54#elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550) || defined(CONFIG_MIPS_DB1200) 55#elif defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || \
55#define AU1X_SOCK1_IO 0xF04000000 56 defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550) || \
56#define AU1X_SOCK1_PHYS_ATTR 0xF44000000 57 defined(CONFIG_MIPS_DB1200)
57#define AU1X_SOCK1_PHYS_MEM 0xF84000000 58#define AU1X_SOCK1_IO 0xF04000000ULL
59#define AU1X_SOCK1_PHYS_ATTR 0xF44000000ULL
60#define AU1X_SOCK1_PHYS_MEM 0xF84000000ULL
58#define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4400000 61#define AU1X_SOCK1_PSEUDO_PHYS_ATTR 0xF4400000
59#define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8400000 62#define AU1X_SOCK1_PSEUDO_PHYS_MEM 0xF8400000
60#endif 63#endif
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c
index 157e41423a0a..aa1cd4d3aa29 100644
--- a/drivers/pcmcia/au1000_pb1x00.c
+++ b/drivers/pcmcia/au1000_pb1x00.c
@@ -35,7 +35,6 @@
35#include <pcmcia/cs_types.h> 35#include <pcmcia/cs_types.h>
36#include <pcmcia/cs.h> 36#include <pcmcia/cs.h>
37#include <pcmcia/ss.h> 37#include <pcmcia/ss.h>
38#include <pcmcia/bulkmem.h>
39#include <pcmcia/cistpl.h> 38#include <pcmcia/cistpl.h>
40#include <pcmcia/bus_ops.h> 39#include <pcmcia/bus_ops.h>
41#include "cs_internal.h" 40#include "cs_internal.h"
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c
index c78ed5347510..8a9b18cee847 100644
--- a/drivers/pcmcia/au1000_xxs1500.c
+++ b/drivers/pcmcia/au1000_xxs1500.c
@@ -39,7 +39,6 @@
39#include <pcmcia/cs_types.h> 39#include <pcmcia/cs_types.h>
40#include <pcmcia/cs.h> 40#include <pcmcia/cs.h>
41#include <pcmcia/ss.h> 41#include <pcmcia/ss.h>
42#include <pcmcia/bulkmem.h>
43#include <pcmcia/cistpl.h> 42#include <pcmcia/cistpl.h>
44#include <pcmcia/bus_ops.h> 43#include <pcmcia/bus_ops.h>
45#include "cs_internal.h" 44#include "cs_internal.h"
diff --git a/drivers/pcmcia/bfin_cf_pcmcia.c b/drivers/pcmcia/bfin_cf_pcmcia.c
new file mode 100644
index 000000000000..bb7338863fb9
--- /dev/null
+++ b/drivers/pcmcia/bfin_cf_pcmcia.c
@@ -0,0 +1,339 @@
1/*
2 * file: drivers/pcmcia/bfin_cf.c
3 *
4 * based on: drivers/pcmcia/omap_cf.c
5 * omap_cf.c -- OMAP 16xx CompactFlash controller driver
6 *
7 * Copyright (c) 2005 David Brownell
8 * Copyright (c) 2006-2008 Michael Hennerich Analog Devices Inc.
9 *
10 * bugs: enter bugs at http://blackfin.uclinux.org/
11 *
12 * this program is free software; you can redistribute it and/or modify
13 * it under the terms of the gnu general public license as published by
14 * the free software foundation; either version 2, or (at your option)
15 * any later version.
16 *
17 * this program is distributed in the hope that it will be useful,
18 * but without any warranty; without even the implied warranty of
19 * merchantability or fitness for a particular purpose. see the
20 * gnu general public license for more details.
21 *
22 * you should have received a copy of the gnu general public license
23 * along with this program; see the file copying.
24 * if not, write to the free software foundation,
25 * 59 temple place - suite 330, boston, ma 02111-1307, usa.
26 */
27
28#include <linux/module.h>
29#include <linux/kernel.h>
30#include <linux/sched.h>
31#include <linux/platform_device.h>
32#include <linux/errno.h>
33#include <linux/init.h>
34#include <linux/delay.h>
35#include <linux/interrupt.h>
36#include <linux/irq.h>
37#include <linux/io.h>
38
39#include <pcmcia/ss.h>
40#include <pcmcia/cisreg.h>
41#include <asm/gpio.h>
42
43#define SZ_1K 0x00000400
44#define SZ_8K 0x00002000
45#define SZ_2K (2 * SZ_1K)
46
47#define POLL_INTERVAL (2 * HZ)
48
49#define CF_ATASEL_ENA 0x20311802 /* Inverts RESET */
50#define CF_ATASEL_DIS 0x20311800
51
52#define bfin_cf_present(pfx) (gpio_get_value(pfx))
53
54/*--------------------------------------------------------------------------*/
55
56static const char driver_name[] = "bfin_cf_pcmcia";
57
58struct bfin_cf_socket {
59 struct pcmcia_socket socket;
60
61 struct timer_list timer;
62 unsigned present:1;
63 unsigned active:1;
64
65 struct platform_device *pdev;
66 unsigned long phys_cf_io;
67 unsigned long phys_cf_attr;
68 u_int irq;
69 u_short cd_pfx;
70};
71
72/*--------------------------------------------------------------------------*/
73static int bfin_cf_reset(void)
74{
75 outw(0, CF_ATASEL_ENA);
76 mdelay(200);
77 outw(0, CF_ATASEL_DIS);
78
79 return 0;
80}
81
82static int bfin_cf_ss_init(struct pcmcia_socket *s)
83{
84 return 0;
85}
86
87/* the timer is primarily to kick this socket's pccardd */
88static void bfin_cf_timer(unsigned long _cf)
89{
90 struct bfin_cf_socket *cf = (void *)_cf;
91 unsigned short present = bfin_cf_present(cf->cd_pfx);
92
93 if (present != cf->present) {
94 cf->present = present;
95 dev_dbg(&cf->pdev->dev, ": card %s\n",
96 present ? "present" : "gone");
97 pcmcia_parse_events(&cf->socket, SS_DETECT);
98 }
99
100 if (cf->active)
101 mod_timer(&cf->timer, jiffies + POLL_INTERVAL);
102}
103
104static int bfin_cf_get_status(struct pcmcia_socket *s, u_int *sp)
105{
106 struct bfin_cf_socket *cf;
107
108 if (!sp)
109 return -EINVAL;
110
111 cf = container_of(s, struct bfin_cf_socket, socket);
112
113 if (bfin_cf_present(cf->cd_pfx)) {
114 *sp = SS_READY | SS_DETECT | SS_POWERON | SS_3VCARD;
115 s->irq.AssignedIRQ = 0;
116 s->pci_irq = cf->irq;
117
118 } else
119 *sp = 0;
120 return 0;
121}
122
123static int
124bfin_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
125{
126
127 struct bfin_cf_socket *cf;
128 cf = container_of(sock, struct bfin_cf_socket, socket);
129
130 switch (s->Vcc) {
131 case 0:
132 case 33:
133 break;
134 case 50:
135 break;
136 default:
137 return -EINVAL;
138 }
139
140 if (s->flags & SS_RESET) {
141 disable_irq(cf->irq);
142 bfin_cf_reset();
143 enable_irq(cf->irq);
144 }
145
146 dev_dbg(&cf->pdev->dev, ": Vcc %d, io_irq %d, flags %04x csc %04x\n",
147 s->Vcc, s->io_irq, s->flags, s->csc_mask);
148
149 return 0;
150}
151
152static int bfin_cf_ss_suspend(struct pcmcia_socket *s)
153{
154 return bfin_cf_set_socket(s, &dead_socket);
155}
156
157/* regions are 2K each: mem, attrib, io (and reserved-for-ide) */
158
159static int bfin_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
160{
161 struct bfin_cf_socket *cf;
162
163 cf = container_of(s, struct bfin_cf_socket, socket);
164 io->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT;
165 io->start = cf->phys_cf_io;
166 io->stop = io->start + SZ_2K - 1;
167 return 0;
168}
169
170static int
171bfin_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map)
172{
173 struct bfin_cf_socket *cf;
174
175 if (map->card_start)
176 return -EINVAL;
177 cf = container_of(s, struct bfin_cf_socket, socket);
178 map->static_start = cf->phys_cf_io;
179 map->flags &= MAP_ACTIVE | MAP_ATTRIB | MAP_16BIT;
180 if (map->flags & MAP_ATTRIB)
181 map->static_start = cf->phys_cf_attr;
182
183 return 0;
184}
185
186static struct pccard_operations bfin_cf_ops = {
187 .init = bfin_cf_ss_init,
188 .suspend = bfin_cf_ss_suspend,
189 .get_status = bfin_cf_get_status,
190 .set_socket = bfin_cf_set_socket,
191 .set_io_map = bfin_cf_set_io_map,
192 .set_mem_map = bfin_cf_set_mem_map,
193};
194
195/*--------------------------------------------------------------------------*/
196
197static int __devinit bfin_cf_probe(struct platform_device *pdev)
198{
199 struct bfin_cf_socket *cf;
200 struct resource *io_mem, *attr_mem;
201 int irq;
202 unsigned short cd_pfx;
203 int status = 0;
204
205 dev_info(&pdev->dev, "Blackfin CompactFlash/PCMCIA Socket Driver\n");
206
207 irq = platform_get_irq(pdev, 0);
208 if (!irq)
209 return -EINVAL;
210
211 cd_pfx = platform_get_irq(pdev, 1); /*Card Detect GPIO PIN */
212
213 if (gpio_request(cd_pfx, "pcmcia: CD")) {
214 dev_err(&pdev->dev,
215 "Failed ro request Card Detect GPIO_%d\n",
216 cd_pfx);
217 return -EBUSY;
218 }
219 gpio_direction_input(cd_pfx);
220
221 cf = kzalloc(sizeof *cf, GFP_KERNEL);
222 if (!cf) {
223 gpio_free(cd_pfx);
224 return -ENOMEM;
225 }
226
227 cf->cd_pfx = cd_pfx;
228
229 setup_timer(&cf->timer, bfin_cf_timer, (unsigned long)cf);
230
231 cf->pdev = pdev;
232 platform_set_drvdata(pdev, cf);
233
234 cf->irq = irq;
235 cf->socket.pci_irq = irq;
236
237 set_irq_type(irq, IRQF_TRIGGER_LOW);
238
239 io_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
240 attr_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
241
242 if (!io_mem || !attr_mem)
243 goto fail0;
244
245 cf->phys_cf_io = io_mem->start;
246 cf->phys_cf_attr = attr_mem->start;
247
248 /* pcmcia layer only remaps "real" memory */
249 cf->socket.io_offset = (unsigned long)
250 ioremap(cf->phys_cf_io, SZ_2K);
251
252 if (!cf->socket.io_offset)
253 goto fail0;
254
255 dev_err(&pdev->dev, ": on irq %d\n", irq);
256
257 dev_dbg(&pdev->dev, ": %s\n",
258 bfin_cf_present(cf->cd_pfx) ? "present" : "(not present)");
259
260 cf->socket.owner = THIS_MODULE;
261 cf->socket.dev.parent = &pdev->dev;
262 cf->socket.ops = &bfin_cf_ops;
263 cf->socket.resource_ops = &pccard_static_ops;
264 cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP
265 | SS_CAP_MEM_ALIGN;
266 cf->socket.map_size = SZ_2K;
267
268 status = pcmcia_register_socket(&cf->socket);
269 if (status < 0)
270 goto fail2;
271
272 cf->active = 1;
273 mod_timer(&cf->timer, jiffies + POLL_INTERVAL);
274 return 0;
275
276fail2:
277 iounmap((void __iomem *)cf->socket.io_offset);
278 release_mem_region(cf->phys_cf_io, SZ_8K);
279
280fail0:
281 gpio_free(cf->cd_pfx);
282 kfree(cf);
283 platform_set_drvdata(pdev, NULL);
284
285 return status;
286}
287
288static int __devexit bfin_cf_remove(struct platform_device *pdev)
289{
290 struct bfin_cf_socket *cf = platform_get_drvdata(pdev);
291
292 gpio_free(cf->cd_pfx);
293 cf->active = 0;
294 pcmcia_unregister_socket(&cf->socket);
295 del_timer_sync(&cf->timer);
296 iounmap((void __iomem *)cf->socket.io_offset);
297 release_mem_region(cf->phys_cf_io, SZ_8K);
298 platform_set_drvdata(pdev, NULL);
299 kfree(cf);
300 return 0;
301}
302
303static int bfin_cf_suspend(struct platform_device *pdev, pm_message_t mesg)
304{
305 return pcmcia_socket_dev_suspend(&pdev->dev, mesg);
306}
307
308static int bfin_cf_resume(struct platform_device *pdev)
309{
310 return pcmcia_socket_dev_resume(&pdev->dev);
311}
312
313static struct platform_driver bfin_cf_driver = {
314 .driver = {
315 .name = (char *)driver_name,
316 .owner = THIS_MODULE,
317 },
318 .probe = bfin_cf_probe,
319 .remove = __devexit_p(bfin_cf_remove),
320 .suspend = bfin_cf_suspend,
321 .resume = bfin_cf_resume,
322};
323
324static int __init bfin_cf_init(void)
325{
326 return platform_driver_register(&bfin_cf_driver);
327}
328
329static void __exit bfin_cf_exit(void)
330{
331 platform_driver_unregister(&bfin_cf_driver);
332}
333
334module_init(bfin_cf_init);
335module_exit(bfin_cf_exit);
336
337MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>")
338MODULE_DESCRIPTION("BFIN CF/PCMCIA Driver");
339MODULE_LICENSE("GPL");
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index fb2f38dc92c5..911ca0e8dfc2 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -30,11 +30,9 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/io.h> 31#include <asm/io.h>
32 32
33#define IN_CARD_SERVICES
34#include <pcmcia/cs_types.h> 33#include <pcmcia/cs_types.h>
35#include <pcmcia/ss.h> 34#include <pcmcia/ss.h>
36#include <pcmcia/cs.h> 35#include <pcmcia/cs.h>
37#include <pcmcia/bulkmem.h>
38#include <pcmcia/cistpl.h> 36#include <pcmcia/cistpl.h>
39#include "cs_internal.h" 37#include "cs_internal.h"
40 38
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 36379535f9da..9fcff0c33619 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -30,7 +30,6 @@
30#include <pcmcia/cs_types.h> 30#include <pcmcia/cs_types.h>
31#include <pcmcia/ss.h> 31#include <pcmcia/ss.h>
32#include <pcmcia/cs.h> 32#include <pcmcia/cs.h>
33#include <pcmcia/bulkmem.h>
34#include <pcmcia/cisreg.h> 33#include <pcmcia/cisreg.h>
35#include <pcmcia/cistpl.h> 34#include <pcmcia/cistpl.h>
36#include "cs_internal.h" 35#include "cs_internal.h"
@@ -1439,10 +1438,11 @@ EXPORT_SYMBOL(pccard_read_tuple);
1439 1438
1440======================================================================*/ 1439======================================================================*/
1441 1440
1442int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_t *info) 1441int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned int *info)
1443{ 1442{
1444 tuple_t *tuple; 1443 tuple_t *tuple;
1445 cisparse_t *p; 1444 cisparse_t *p;
1445 unsigned int count = 0;
1446 int ret, reserved, dev_ok = 0, ident_ok = 0; 1446 int ret, reserved, dev_ok = 0, ident_ok = 0;
1447 1447
1448 if (!s) 1448 if (!s)
@@ -1457,7 +1457,7 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_
1457 return CS_OUT_OF_RESOURCE; 1457 return CS_OUT_OF_RESOURCE;
1458 } 1458 }
1459 1459
1460 info->Chains = reserved = 0; 1460 count = reserved = 0;
1461 tuple->DesiredTuple = RETURN_FIRST_TUPLE; 1461 tuple->DesiredTuple = RETURN_FIRST_TUPLE;
1462 tuple->Attributes = TUPLE_RETURN_COMMON; 1462 tuple->Attributes = TUPLE_RETURN_COMMON;
1463 ret = pccard_get_first_tuple(s, function, tuple); 1463 ret = pccard_get_first_tuple(s, function, tuple);
@@ -1482,7 +1482,7 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_
1482 if (!dev_ok && !ident_ok) 1482 if (!dev_ok && !ident_ok)
1483 goto done; 1483 goto done;
1484 1484
1485 for (info->Chains = 1; info->Chains < MAX_TUPLES; info->Chains++) { 1485 for (count = 1; count < MAX_TUPLES; count++) {
1486 ret = pccard_get_next_tuple(s, function, tuple); 1486 ret = pccard_get_next_tuple(s, function, tuple);
1487 if (ret != CS_SUCCESS) break; 1487 if (ret != CS_SUCCESS) break;
1488 if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || 1488 if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) ||
@@ -1490,11 +1490,13 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_
1490 ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff))) 1490 ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff)))
1491 reserved++; 1491 reserved++;
1492 } 1492 }
1493 if ((info->Chains == MAX_TUPLES) || (reserved > 5) || 1493 if ((count) || (reserved > 5) ||
1494 ((!dev_ok || !ident_ok) && (info->Chains > 10))) 1494 ((!dev_ok || !ident_ok) && (count > 10)))
1495 info->Chains = 0; 1495 count = 0;
1496 1496
1497done: 1497done:
1498 if (info)
1499 *info = count;
1498 kfree(tuple); 1500 kfree(tuple);
1499 kfree(p); 1501 kfree(p);
1500 return CS_SUCCESS; 1502 return CS_SUCCESS;
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 29276bd28295..d1207393fc3e 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -32,11 +32,9 @@
32#include <asm/system.h> 32#include <asm/system.h>
33#include <asm/irq.h> 33#include <asm/irq.h>
34 34
35#define IN_CARD_SERVICES
36#include <pcmcia/cs_types.h> 35#include <pcmcia/cs_types.h>
37#include <pcmcia/ss.h> 36#include <pcmcia/ss.h>
38#include <pcmcia/cs.h> 37#include <pcmcia/cs.h>
39#include <pcmcia/bulkmem.h>
40#include <pcmcia/cistpl.h> 38#include <pcmcia/cistpl.h>
41#include <pcmcia/cisreg.h> 39#include <pcmcia/cisreg.h>
42#include <pcmcia/ds.h> 40#include <pcmcia/ds.h>
@@ -238,7 +236,6 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
238 236
239 init_completion(&socket->socket_released); 237 init_completion(&socket->socket_released);
240 init_completion(&socket->thread_done); 238 init_completion(&socket->thread_done);
241 init_waitqueue_head(&socket->thread_wait);
242 mutex_init(&socket->skt_mutex); 239 mutex_init(&socket->skt_mutex);
243 spin_lock_init(&socket->thread_lock); 240 spin_lock_init(&socket->thread_lock);
244 241
@@ -278,10 +275,9 @@ void pcmcia_unregister_socket(struct pcmcia_socket *socket)
278 275
279 cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops); 276 cs_dbg(socket, 0, "pcmcia_unregister_socket(0x%p)\n", socket->ops);
280 277
281 if (socket->thread) { 278 if (socket->thread)
282 wake_up(&socket->thread_wait);
283 kthread_stop(socket->thread); 279 kthread_stop(socket->thread);
284 } 280
285 release_cis_mem(socket); 281 release_cis_mem(socket);
286 282
287 /* remove from our own list */ 283 /* remove from our own list */
@@ -635,7 +631,6 @@ static void socket_detect_change(struct pcmcia_socket *skt)
635static int pccardd(void *__skt) 631static int pccardd(void *__skt)
636{ 632{
637 struct pcmcia_socket *skt = __skt; 633 struct pcmcia_socket *skt = __skt;
638 DECLARE_WAITQUEUE(wait, current);
639 int ret; 634 int ret;
640 635
641 skt->thread = current; 636 skt->thread = current;
@@ -656,7 +651,6 @@ static int pccardd(void *__skt)
656 if (ret) 651 if (ret)
657 dev_warn(&skt->dev, "err %d adding socket attributes\n", ret); 652 dev_warn(&skt->dev, "err %d adding socket attributes\n", ret);
658 653
659 add_wait_queue(&skt->thread_wait, &wait);
660 complete(&skt->thread_done); 654 complete(&skt->thread_done);
661 655
662 set_freezable(); 656 set_freezable();
@@ -694,8 +688,6 @@ static int pccardd(void *__skt)
694 /* make sure we are running before we exit */ 688 /* make sure we are running before we exit */
695 set_current_state(TASK_RUNNING); 689 set_current_state(TASK_RUNNING);
696 690
697 remove_wait_queue(&skt->thread_wait, &wait);
698
699 /* remove from the device core */ 691 /* remove from the device core */
700 pccard_sysfs_remove_socket(&skt->dev); 692 pccard_sysfs_remove_socket(&skt->dev);
701 device_unregister(&skt->dev); 693 device_unregister(&skt->dev);
@@ -716,7 +708,7 @@ void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
716 s->thread_events |= events; 708 s->thread_events |= events;
717 spin_unlock_irqrestore(&s->thread_lock, flags); 709 spin_unlock_irqrestore(&s->thread_lock, flags);
718 710
719 wake_up(&s->thread_wait); 711 wake_up_process(s->thread);
720 } 712 }
721} /* pcmcia_parse_events */ 713} /* pcmcia_parse_events */
722EXPORT_SYMBOL(pcmcia_parse_events); 714EXPORT_SYMBOL(pcmcia_parse_events);
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index e7d5d141f24d..63dc1a28bda2 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -26,18 +26,6 @@
26#define CLIENT_WIN_REQ(i) (0x1<<(i)) 26#define CLIENT_WIN_REQ(i) (0x1<<(i))
27#define CLIENT_CARDBUS 0x8000 27#define CLIENT_CARDBUS 0x8000
28 28
29#define REGION_MAGIC 0xE3C9
30typedef struct region_t {
31 u_short region_magic;
32 u_short state;
33 dev_info_t dev_info;
34 struct pcmcia_device *mtd;
35 u_int MediaID;
36 region_info_t info;
37} region_t;
38
39#define REGION_STALE 0x01
40
41/* Each card function gets one of these guys */ 29/* Each card function gets one of these guys */
42typedef struct config_t { 30typedef struct config_t {
43 struct kref ref; 31 struct kref ref;
@@ -130,7 +118,6 @@ extern struct list_head pcmcia_socket_list;
130int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); 118int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req);
131int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config); 119int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config);
132int pccard_reset_card(struct pcmcia_socket *skt); 120int pccard_reset_card(struct pcmcia_socket *skt);
133int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, cs_status_t *status);
134 121
135 122
136struct pcmcia_callback{ 123struct pcmcia_callback{
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index e40775443d04..4174d9656e35 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -25,7 +25,6 @@
25#include <linux/kref.h> 25#include <linux/kref.h>
26#include <linux/dma-mapping.h> 26#include <linux/dma-mapping.h>
27 27
28#define IN_CARD_SERVICES
29#include <pcmcia/cs_types.h> 28#include <pcmcia/cs_types.h>
30#include <pcmcia/cs.h> 29#include <pcmcia/cs.h>
31#include <pcmcia/cistpl.h> 30#include <pcmcia/cistpl.h>
@@ -741,9 +740,8 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
741 740
742static int pcmcia_card_add(struct pcmcia_socket *s) 741static int pcmcia_card_add(struct pcmcia_socket *s)
743{ 742{
744 cisinfo_t cisinfo;
745 cistpl_longlink_mfc_t mfc; 743 cistpl_longlink_mfc_t mfc;
746 unsigned int no_funcs, i; 744 unsigned int no_funcs, i, no_chains;
747 int ret = 0; 745 int ret = 0;
748 746
749 if (!(s->resource_setup_done)) { 747 if (!(s->resource_setup_done)) {
@@ -757,8 +755,8 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
757 return -EAGAIN; /* try again, but later... */ 755 return -EAGAIN; /* try again, but later... */
758 } 756 }
759 757
760 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo); 758 ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains);
761 if (ret || !cisinfo.Chains) { 759 if (ret || !no_chains) {
762 ds_dbg(0, "invalid CIS or invalid resources\n"); 760 ds_dbg(0, "invalid CIS or invalid resources\n");
763 return -ENODEV; 761 return -ENODEV;
764 } 762 }
@@ -852,7 +850,7 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
852{ 850{
853 struct pcmcia_socket *s = dev->socket; 851 struct pcmcia_socket *s = dev->socket;
854 const struct firmware *fw; 852 const struct firmware *fw;
855 char path[20]; 853 char path[FIRMWARE_NAME_MAX];
856 int ret = -ENOMEM; 854 int ret = -ENOMEM;
857 int no_funcs; 855 int no_funcs;
858 int old_funcs; 856 int old_funcs;
@@ -864,7 +862,7 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
864 862
865 ds_dbg(1, "trying to load CIS file %s\n", filename); 863 ds_dbg(1, "trying to load CIS file %s\n", filename);
866 864
867 if (strlen(filename) > 14) { 865 if (strlen(filename) > (FIRMWARE_NAME_MAX - 1)) {
868 printk(KERN_WARNING "pcmcia: CIS filename is too long [%s]\n", 866 printk(KERN_WARNING "pcmcia: CIS filename is too long [%s]\n",
869 filename); 867 filename);
870 return -EINVAL; 868 return -EINVAL;
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
index f2e810f53c81..fb2bc1fb015d 100644
--- a/drivers/pcmcia/hd64465_ss.c
+++ b/drivers/pcmcia/hd64465_ss.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: hd64465_ss.c,v 1.7 2003/07/06 14:42:50 lethal Exp $
3 *
4 * Device driver for the PCMCIA controller module of the 2 * Device driver for the PCMCIA controller module of the
5 * Hitachi HD64465 handheld companion chip. 3 * Hitachi HD64465 handheld companion chip.
6 * 4 *
@@ -48,7 +46,6 @@
48#include <pcmcia/cistpl.h> 46#include <pcmcia/cistpl.h>
49#include <pcmcia/ds.h> 47#include <pcmcia/ds.h>
50#include <pcmcia/ss.h> 48#include <pcmcia/ss.h>
51#include <pcmcia/bulkmem.h>
52#include "cs_internal.h" 49#include "cs_internal.h"
53 50
54#define MODNAME "hd64465_ss" 51#define MODNAME "hd64465_ss"
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index e13618656ff7..46561face128 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -5,8 +5,6 @@
5 * 5 *
6 * Author: Arjan Van De Ven <arjanv@redhat.com> 6 * Author: Arjan Van De Ven <arjanv@redhat.com>
7 * Loosly based on i82365.c from the pcmcia-cs package 7 * Loosly based on i82365.c from the pcmcia-cs package
8 *
9 * $Id: i82092aa.c,v 1.2 2001/10/23 14:43:34 arjanv Exp $
10 */ 8 */
11 9
12#include <linux/kernel.h> 10#include <linux/kernel.h>
diff --git a/drivers/pcmcia/i82092aa.h b/drivers/pcmcia/i82092aa.h
index b0d453303c5d..8836d393ad02 100644
--- a/drivers/pcmcia/i82092aa.h
+++ b/drivers/pcmcia/i82092aa.h
@@ -3,8 +3,6 @@
3 3
4#include <linux/interrupt.h> 4#include <linux/interrupt.h>
5 5
6/* $Id: i82092aa.h,v 1.1.1.1 2001/09/19 14:53:15 dwmw2 Exp $ */
7
8/* Debuging defines */ 6/* Debuging defines */
9#ifdef NOTRACE 7#ifdef NOTRACE
10#define enter(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__) 8#define enter(x) printk("Enter: %s, %s line %i\n",x,__FILE__,__LINE__)
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index 32a2ab119798..68f6b2702bc4 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -1263,7 +1263,7 @@ static int __init init_i82365(void)
1263 1263
1264 ret = driver_register(&i82365_driver); 1264 ret = driver_register(&i82365_driver);
1265 if (ret) 1265 if (ret)
1266 return ret; 1266 goto err_out;
1267 1267
1268 i82365_device = platform_device_alloc("i82365", 0); 1268 i82365_device = platform_device_alloc("i82365", 0);
1269 if (i82365_device) { 1269 if (i82365_device) {
@@ -1273,10 +1273,8 @@ static int __init init_i82365(void)
1273 } else 1273 } else
1274 ret = -ENOMEM; 1274 ret = -ENOMEM;
1275 1275
1276 if (ret) { 1276 if (ret)
1277 driver_unregister(&i82365_driver); 1277 goto err_driver_unregister;
1278 return ret;
1279 }
1280 1278
1281 printk(KERN_INFO "Intel ISA PCIC probe: "); 1279 printk(KERN_INFO "Intel ISA PCIC probe: ");
1282 sockets = 0; 1280 sockets = 0;
@@ -1285,16 +1283,17 @@ static int __init init_i82365(void)
1285 1283
1286 if (sockets == 0) { 1284 if (sockets == 0) {
1287 printk("not found.\n"); 1285 printk("not found.\n");
1288 platform_device_unregister(i82365_device); 1286 ret = -ENODEV;
1289 release_region(i365_base, 2); 1287 goto err_dev_unregister;
1290 driver_unregister(&i82365_driver);
1291 return -ENODEV;
1292 } 1288 }
1293 1289
1294 /* Set up interrupt handler(s) */ 1290 /* Set up interrupt handler(s) */
1295 if (grab_irq != 0) 1291 if (grab_irq != 0)
1296 request_irq(cs_irq, pcic_interrupt, 0, "i82365", pcic_interrupt); 1292 ret = request_irq(cs_irq, pcic_interrupt, 0, "i82365", pcic_interrupt);
1297 1293
1294 if (ret)
1295 goto err_socket_release;
1296
1298 /* register sockets with the pcmcia core */ 1297 /* register sockets with the pcmcia core */
1299 for (i = 0; i < sockets; i++) { 1298 for (i = 0; i < sockets; i++) {
1300 socket[i].socket.dev.parent = &i82365_device->dev; 1299 socket[i].socket.dev.parent = &i82365_device->dev;
@@ -1324,7 +1323,23 @@ static int __init init_i82365(void)
1324 } 1323 }
1325 1324
1326 return 0; 1325 return 0;
1327 1326err_socket_release:
1327 for (i = 0; i < sockets; i++) {
1328 /* Turn off all interrupt sources! */
1329 i365_set(i, I365_CSCINT, 0);
1330 release_region(socket[i].ioaddr, 2);
1331 }
1332err_dev_unregister:
1333 platform_device_unregister(i82365_device);
1334 release_region(i365_base, 2);
1335#ifdef CONFIG_PNP
1336 if (i82365_pnpdev)
1337 pnp_disable_dev(i82365_pnpdev);
1338#endif
1339err_driver_unregister:
1340 driver_unregister(&i82365_driver);
1341err_out:
1342 return ret;
1328} /* init_i82365 */ 1343} /* init_i82365 */
1329 1344
1330static void __exit exit_i82365(void) 1345static void __exit exit_i82365(void)
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index ac70d2cb7dd4..13a5fbd50a07 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series. 2 * m8xx_pcmcia.c - Linux PCMCIA socket driver for the mpc8xx series.
3 * 3 *
4 * (C) 1999-2000 Magnus Damm <damm@bitsmart.com> 4 * (C) 1999-2000 Magnus Damm <damm@opensource.se>
5 * (C) 2001-2002 Montavista Software, Inc. 5 * (C) 2001-2002 Montavista Software, Inc.
6 * <mlocke@mvista.com> 6 * <mlocke@mvista.com>
7 * 7 *
@@ -60,7 +60,6 @@
60#include <asm/of_device.h> 60#include <asm/of_device.h>
61#include <asm/of_platform.h> 61#include <asm/of_platform.h>
62 62
63#include <pcmcia/version.h>
64#include <pcmcia/cs_types.h> 63#include <pcmcia/cs_types.h>
65#include <pcmcia/cs.h> 64#include <pcmcia/cs.h>
66#include <pcmcia/ss.h> 65#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/omap_cf.c b/drivers/pcmcia/omap_cf.c
index 46314b420765..569b746b5731 100644
--- a/drivers/pcmcia/omap_cf.c
+++ b/drivers/pcmcia/omap_cf.c
@@ -38,19 +38,19 @@
38#define CF_BASE 0xfffe2800 38#define CF_BASE 0xfffe2800
39 39
40/* status; read after IRQ */ 40/* status; read after IRQ */
41#define CF_STATUS_REG __REG16(CF_BASE + 0x00) 41#define CF_STATUS (CF_BASE + 0x00)
42# define CF_STATUS_BAD_READ (1 << 2) 42# define CF_STATUS_BAD_READ (1 << 2)
43# define CF_STATUS_BAD_WRITE (1 << 1) 43# define CF_STATUS_BAD_WRITE (1 << 1)
44# define CF_STATUS_CARD_DETECT (1 << 0) 44# define CF_STATUS_CARD_DETECT (1 << 0)
45 45
46/* which chipselect (CS0..CS3) is used for CF (active low) */ 46/* which chipselect (CS0..CS3) is used for CF (active low) */
47#define CF_CFG_REG __REG16(CF_BASE + 0x02) 47#define CF_CFG (CF_BASE + 0x02)
48 48
49/* card reset */ 49/* card reset */
50#define CF_CONTROL_REG __REG16(CF_BASE + 0x04) 50#define CF_CONTROL (CF_BASE + 0x04)
51# define CF_CONTROL_RESET (1 << 0) 51# define CF_CONTROL_RESET (1 << 0)
52 52
53#define omap_cf_present() (!(CF_STATUS_REG & CF_STATUS_CARD_DETECT)) 53#define omap_cf_present() (!(omap_readw(CF_STATUS) & CF_STATUS_CARD_DETECT))
54 54
55/*--------------------------------------------------------------------------*/ 55/*--------------------------------------------------------------------------*/
56 56
@@ -139,11 +139,11 @@ omap_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s)
139 return -EINVAL; 139 return -EINVAL;
140 } 140 }
141 141
142 control = CF_CONTROL_REG; 142 control = omap_readw(CF_CONTROL);
143 if (s->flags & SS_RESET) 143 if (s->flags & SS_RESET)
144 CF_CONTROL_REG = CF_CONTROL_RESET; 144 omap_writew(CF_CONTROL_RESET, CF_CONTROL);
145 else 145 else
146 CF_CONTROL_REG = 0; 146 omap_writew(0, CF_CONTROL);
147 147
148 pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n", 148 pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n",
149 driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask); 149 driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask);
@@ -270,7 +270,7 @@ static int __init omap_cf_probe(struct platform_device *pdev)
270 omap_cfg_reg(V10_1610_CF_IREQ); 270 omap_cfg_reg(V10_1610_CF_IREQ);
271 omap_cfg_reg(W10_1610_CF_RESET); 271 omap_cfg_reg(W10_1610_CF_RESET);
272 272
273 CF_CFG_REG = ~(1 << seg); 273 omap_writew(~(1 << seg), CF_CFG);
274 274
275 pr_info("%s: cs%d on irq %d\n", driver_name, seg, irq); 275 pr_info("%s: cs%d on irq %d\n", driver_name, seg, irq);
276 276
@@ -279,14 +279,15 @@ static int __init omap_cf_probe(struct platform_device *pdev)
279 * CF/PCMCIA variants... 279 * CF/PCMCIA variants...
280 */ 280 */
281 pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", driver_name, 281 pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", driver_name,
282 seg, EMIFS_CCS(seg), EMIFS_ACS(seg)); 282 seg, omap_readl(EMIFS_CCS(seg)), omap_readl(EMIFS_ACS(seg)));
283 EMIFS_CCS(seg) = 0x0004a1b3; /* synch mode 4 etc */ 283 omap_writel(0x0004a1b3, EMIFS_CCS(seg)); /* synch mode 4 etc */
284 EMIFS_ACS(seg) = 0x00000000; /* OE hold/setup */ 284 omap_writel(0x00000000, EMIFS_ACS(seg)); /* OE hold/setup */
285 285
286 /* CF uses armxor_ck, which is "always" available */ 286 /* CF uses armxor_ck, which is "always" available */
287 287
288 pr_debug("%s: sts %04x cfg %04x control %04x %s\n", driver_name, 288 pr_debug("%s: sts %04x cfg %04x control %04x %s\n", driver_name,
289 CF_STATUS_REG, CF_CFG_REG, CF_CONTROL_REG, 289 omap_readw(CF_STATUS), omap_readw(CF_CFG),
290 omap_readw(CF_CONTROL),
290 omap_cf_present() ? "present" : "(not present)"); 291 omap_cf_present() ? "present" : "(not present)");
291 292
292 cf->socket.owner = THIS_MODULE; 293 cf->socket.owner = THIS_MODULE;
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 5f186abca108..419f97fc9a62 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -27,12 +27,13 @@
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/poll.h> 28#include <linux/poll.h>
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/smp_lock.h>
30#include <linux/workqueue.h> 31#include <linux/workqueue.h>
31 32
32#define IN_CARD_SERVICES
33#include <pcmcia/cs_types.h> 33#include <pcmcia/cs_types.h>
34#include <pcmcia/cs.h> 34#include <pcmcia/cs.h>
35#include <pcmcia/cistpl.h> 35#include <pcmcia/cistpl.h>
36#include <pcmcia/cisreg.h>
36#include <pcmcia/ds.h> 37#include <pcmcia/ds.h>
37#include <pcmcia/ss.h> 38#include <pcmcia/ss.h>
38 39
@@ -138,6 +139,154 @@ static int proc_read_drivers(char *buf, char **start, off_t pos,
138} 139}
139#endif 140#endif
140 141
142
143#ifdef CONFIG_PCMCIA_PROBE
144
145static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
146{
147 int irq;
148 u32 mask;
149
150 irq = adj->resource.irq.IRQ;
151 if ((irq < 0) || (irq > 15))
152 return CS_BAD_IRQ;
153
154 if (adj->Action != REMOVE_MANAGED_RESOURCE)
155 return 0;
156
157 mask = 1 << irq;
158
159 if (!(s->irq_mask & mask))
160 return 0;
161
162 s->irq_mask &= ~mask;
163
164 return 0;
165}
166
167#else
168
169static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) {
170 return CS_SUCCESS;
171}
172
173#endif
174
175static int pcmcia_adjust_resource_info(adjust_t *adj)
176{
177 struct pcmcia_socket *s;
178 int ret = CS_UNSUPPORTED_FUNCTION;
179 unsigned long flags;
180
181 down_read(&pcmcia_socket_list_rwsem);
182 list_for_each_entry(s, &pcmcia_socket_list, socket_list) {
183
184 if (adj->Resource == RES_IRQ)
185 ret = adjust_irq(s, adj);
186
187 else if (s->resource_ops->add_io) {
188 unsigned long begin, end;
189
190 /* you can't use the old interface if the new
191 * one was used before */
192 spin_lock_irqsave(&s->lock, flags);
193 if ((s->resource_setup_new) &&
194 !(s->resource_setup_old)) {
195 spin_unlock_irqrestore(&s->lock, flags);
196 continue;
197 } else if (!(s->resource_setup_old))
198 s->resource_setup_old = 1;
199 spin_unlock_irqrestore(&s->lock, flags);
200
201 switch (adj->Resource) {
202 case RES_MEMORY_RANGE:
203 begin = adj->resource.memory.Base;
204 end = adj->resource.memory.Base + adj->resource.memory.Size - 1;
205 if (s->resource_ops->add_mem)
206 ret =s->resource_ops->add_mem(s, adj->Action, begin, end);
207 case RES_IO_RANGE:
208 begin = adj->resource.io.BasePort;
209 end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1;
210 if (s->resource_ops->add_io)
211 ret = s->resource_ops->add_io(s, adj->Action, begin, end);
212 }
213 if (!ret) {
214 /* as there's no way we know this is the
215 * last call to adjust_resource_info, we
216 * always need to assume this is the latest
217 * one... */
218 spin_lock_irqsave(&s->lock, flags);
219 s->resource_setup_done = 1;
220 spin_unlock_irqrestore(&s->lock, flags);
221 }
222 }
223 }
224 up_read(&pcmcia_socket_list_rwsem);
225
226 return (ret);
227}
228
229/** pccard_get_status
230 *
231 * Get the current socket state bits. We don't support the latched
232 * SocketState yet: I haven't seen any point for it.
233 */
234
235static int pccard_get_status(struct pcmcia_socket *s,
236 struct pcmcia_device *p_dev,
237 cs_status_t *status)
238{
239 config_t *c;
240 int val;
241
242 s->ops->get_status(s, &val);
243 status->CardState = status->SocketState = 0;
244 status->CardState |= (val & SS_DETECT) ? CS_EVENT_CARD_DETECT : 0;
245 status->CardState |= (val & SS_CARDBUS) ? CS_EVENT_CB_DETECT : 0;
246 status->CardState |= (val & SS_3VCARD) ? CS_EVENT_3VCARD : 0;
247 status->CardState |= (val & SS_XVCARD) ? CS_EVENT_XVCARD : 0;
248 if (s->state & SOCKET_SUSPEND)
249 status->CardState |= CS_EVENT_PM_SUSPEND;
250 if (!(s->state & SOCKET_PRESENT))
251 return CS_NO_CARD;
252
253 c = (p_dev) ? p_dev->function_config : NULL;
254
255 if ((c != NULL) && (c->state & CONFIG_LOCKED) &&
256 (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) {
257 u_char reg;
258 if (c->CardValues & PRESENT_PIN_REPLACE) {
259 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, &reg);
260 status->CardState |=
261 (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0;
262 status->CardState |=
263 (reg & PRR_READY_STATUS) ? CS_EVENT_READY_CHANGE : 0;
264 status->CardState |=
265 (reg & PRR_BVD2_STATUS) ? CS_EVENT_BATTERY_LOW : 0;
266 status->CardState |=
267 (reg & PRR_BVD1_STATUS) ? CS_EVENT_BATTERY_DEAD : 0;
268 } else {
269 /* No PRR? Then assume we're always ready */
270 status->CardState |= CS_EVENT_READY_CHANGE;
271 }
272 if (c->CardValues & PRESENT_EXT_STATUS) {
273 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, &reg);
274 status->CardState |=
275 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0;
276 }
277 return CS_SUCCESS;
278 }
279 status->CardState |=
280 (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0;
281 status->CardState |=
282 (val & SS_BATDEAD) ? CS_EVENT_BATTERY_DEAD : 0;
283 status->CardState |=
284 (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0;
285 status->CardState |=
286 (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0;
287 return CS_SUCCESS;
288} /* pccard_get_status */
289
141/*====================================================================== 290/*======================================================================
142 291
143 These manage a ring buffer of events pending for one user process 292 These manage a ring buffer of events pending for one user process
@@ -397,20 +546,27 @@ static int ds_open(struct inode *inode, struct file *file)
397 struct pcmcia_socket *s; 546 struct pcmcia_socket *s;
398 user_info_t *user; 547 user_info_t *user;
399 static int warning_printed = 0; 548 static int warning_printed = 0;
549 int ret = 0;
400 550
401 ds_dbg(0, "ds_open(socket %d)\n", i); 551 ds_dbg(0, "ds_open(socket %d)\n", i);
402 552
553 lock_kernel();
403 s = pcmcia_get_socket_by_nr(i); 554 s = pcmcia_get_socket_by_nr(i);
404 if (!s) 555 if (!s) {
405 return -ENODEV; 556 ret = -ENODEV;
557 goto out;
558 }
406 s = pcmcia_get_socket(s); 559 s = pcmcia_get_socket(s);
407 if (!s) 560 if (!s) {
408 return -ENODEV; 561 ret = -ENODEV;
562 goto out;
563 }
409 564
410 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { 565 if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
411 if (s->pcmcia_state.busy) { 566 if (s->pcmcia_state.busy) {
412 pcmcia_put_socket(s); 567 pcmcia_put_socket(s);
413 return -EBUSY; 568 ret = -EBUSY;
569 goto out;
414 } 570 }
415 else 571 else
416 s->pcmcia_state.busy = 1; 572 s->pcmcia_state.busy = 1;
@@ -419,7 +575,8 @@ static int ds_open(struct inode *inode, struct file *file)
419 user = kmalloc(sizeof(user_info_t), GFP_KERNEL); 575 user = kmalloc(sizeof(user_info_t), GFP_KERNEL);
420 if (!user) { 576 if (!user) {
421 pcmcia_put_socket(s); 577 pcmcia_put_socket(s);
422 return -ENOMEM; 578 ret = -ENOMEM;
579 goto out;
423 } 580 }
424 user->event_tail = user->event_head = 0; 581 user->event_tail = user->event_head = 0;
425 user->next = s->user; 582 user->next = s->user;
@@ -441,7 +598,9 @@ static int ds_open(struct inode *inode, struct file *file)
441 598
442 if (s->pcmcia_state.present) 599 if (s->pcmcia_state.present)
443 queue_event(user, CS_EVENT_CARD_INSERTION); 600 queue_event(user, CS_EVENT_CARD_INSERTION);
444 return 0; 601out:
602 unlock_kernel();
603 return ret;
445} /* ds_open */ 604} /* ds_open */
446 605
447/*====================================================================*/ 606/*====================================================================*/
@@ -546,8 +705,6 @@ static u_int ds_poll(struct file *file, poll_table *wait)
546 705
547/*====================================================================*/ 706/*====================================================================*/
548 707
549extern int pcmcia_adjust_resource_info(adjust_t *adj);
550
551static int ds_ioctl(struct inode * inode, struct file * file, 708static int ds_ioctl(struct inode * inode, struct file * file,
552 u_int cmd, u_long arg) 709 u_int cmd, u_long arg)
553{ 710{
@@ -649,7 +806,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
649 mutex_lock(&s->skt_mutex); 806 mutex_lock(&s->skt_mutex);
650 pcmcia_validate_mem(s); 807 pcmcia_validate_mem(s);
651 mutex_unlock(&s->skt_mutex); 808 mutex_unlock(&s->skt_mutex);
652 ret = pccard_validate_cis(s, BIND_FN_ALL, &buf->cisinfo); 809 ret = pccard_validate_cis(s, BIND_FN_ALL, &buf->cisinfo.Chains);
653 break; 810 break;
654 case DS_SUSPEND_CARD: 811 case DS_SUSPEND_CARD:
655 ret = pcmcia_suspend_card(s); 812 ret = pcmcia_suspend_card(s);
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 1d128fbd1a92..4884a18cf9e6 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -21,11 +21,9 @@
21#include <linux/pci.h> 21#include <linux/pci.h>
22#include <linux/device.h> 22#include <linux/device.h>
23 23
24#define IN_CARD_SERVICES
25#include <pcmcia/cs_types.h> 24#include <pcmcia/cs_types.h>
26#include <pcmcia/ss.h> 25#include <pcmcia/ss.h>
27#include <pcmcia/cs.h> 26#include <pcmcia/cs.h>
28#include <pcmcia/bulkmem.h>
29#include <pcmcia/cistpl.h> 27#include <pcmcia/cistpl.h>
30#include <pcmcia/cisreg.h> 28#include <pcmcia/cisreg.h>
31#include <pcmcia/ds.h> 29#include <pcmcia/ds.h>
@@ -311,74 +309,6 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle,
311EXPORT_SYMBOL(pcmcia_get_window); 309EXPORT_SYMBOL(pcmcia_get_window);
312 310
313 311
314/** pccard_get_status
315 *
316 * Get the current socket state bits. We don't support the latched
317 * SocketState yet: I haven't seen any point for it.
318 */
319
320int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev,
321 cs_status_t *status)
322{
323 config_t *c;
324 int val;
325
326 s->ops->get_status(s, &val);
327 status->CardState = status->SocketState = 0;
328 status->CardState |= (val & SS_DETECT) ? CS_EVENT_CARD_DETECT : 0;
329 status->CardState |= (val & SS_CARDBUS) ? CS_EVENT_CB_DETECT : 0;
330 status->CardState |= (val & SS_3VCARD) ? CS_EVENT_3VCARD : 0;
331 status->CardState |= (val & SS_XVCARD) ? CS_EVENT_XVCARD : 0;
332 if (s->state & SOCKET_SUSPEND)
333 status->CardState |= CS_EVENT_PM_SUSPEND;
334 if (!(s->state & SOCKET_PRESENT))
335 return CS_NO_CARD;
336
337 c = (p_dev) ? p_dev->function_config : NULL;
338
339 if ((c != NULL) && (c->state & CONFIG_LOCKED) &&
340 (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) {
341 u_char reg;
342 if (c->CardValues & PRESENT_PIN_REPLACE) {
343 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, &reg);
344 status->CardState |=
345 (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0;
346 status->CardState |=
347 (reg & PRR_READY_STATUS) ? CS_EVENT_READY_CHANGE : 0;
348 status->CardState |=
349 (reg & PRR_BVD2_STATUS) ? CS_EVENT_BATTERY_LOW : 0;
350 status->CardState |=
351 (reg & PRR_BVD1_STATUS) ? CS_EVENT_BATTERY_DEAD : 0;
352 } else {
353 /* No PRR? Then assume we're always ready */
354 status->CardState |= CS_EVENT_READY_CHANGE;
355 }
356 if (c->CardValues & PRESENT_EXT_STATUS) {
357 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, &reg);
358 status->CardState |=
359 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0;
360 }
361 return CS_SUCCESS;
362 }
363 status->CardState |=
364 (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0;
365 status->CardState |=
366 (val & SS_BATDEAD) ? CS_EVENT_BATTERY_DEAD : 0;
367 status->CardState |=
368 (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0;
369 status->CardState |=
370 (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0;
371 return CS_SUCCESS;
372} /* pccard_get_status */
373
374int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status)
375{
376 return pccard_get_status(p_dev->socket, p_dev, status);
377}
378EXPORT_SYMBOL(pcmcia_get_status);
379
380
381
382/** pcmcia_get_mem_page 312/** pcmcia_get_mem_page
383 * 313 *
384 * Change the card address of an already open memory window. 314 * Change the card address of an already open memory window.
@@ -812,6 +742,15 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
812 type = IRQF_SHARED; 742 type = IRQF_SHARED;
813 743
814#ifdef CONFIG_PCMCIA_PROBE 744#ifdef CONFIG_PCMCIA_PROBE
745
746#ifdef IRQ_NOAUTOEN
747 /* if the underlying IRQ infrastructure allows for it, only allocate
748 * the IRQ, but do not enable it
749 */
750 if (!(req->Attributes & IRQ_HANDLE_PRESENT))
751 type |= IRQ_NOAUTOEN;
752#endif /* IRQ_NOAUTOEN */
753
815 if (s->irq.AssignedIRQ != 0) { 754 if (s->irq.AssignedIRQ != 0) {
816 /* If the interrupt is already assigned, it must be the same */ 755 /* If the interrupt is already assigned, it must be the same */
817 irq = s->irq.AssignedIRQ; 756 irq = s->irq.AssignedIRQ;
@@ -966,7 +905,7 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev) {
966 pcmcia_release_configuration(p_dev); 905 pcmcia_release_configuration(p_dev);
967 pcmcia_release_io(p_dev, &p_dev->io); 906 pcmcia_release_io(p_dev, &p_dev->io);
968 pcmcia_release_irq(p_dev, &p_dev->irq); 907 pcmcia_release_irq(p_dev, &p_dev->irq);
969 if (&p_dev->win) 908 if (p_dev->win)
970 pcmcia_release_window(p_dev->win); 909 pcmcia_release_window(p_dev->win);
971} 910}
972EXPORT_SYMBOL(pcmcia_disable_device); 911EXPORT_SYMBOL(pcmcia_disable_device);
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 9414163c78e7..ccfdf1969a7f 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -33,7 +33,6 @@
33 33
34#include <pcmcia/cs_types.h> 34#include <pcmcia/cs_types.h>
35#include <pcmcia/ss.h> 35#include <pcmcia/ss.h>
36#include <pcmcia/bulkmem.h>
37#include <pcmcia/cistpl.h> 36#include <pcmcia/cistpl.h>
38 37
39#include "cs_internal.h" 38#include "cs_internal.h"
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c
index e7ab060ff118..f123fce65f2e 100644
--- a/drivers/pcmcia/pxa2xx_cm_x270.c
+++ b/drivers/pcmcia/pxa2xx_cm_x270.c
@@ -18,6 +18,7 @@
18 18
19#include <pcmcia/ss.h> 19#include <pcmcia/ss.h>
20#include <asm/hardware.h> 20#include <asm/hardware.h>
21#include <asm/mach-types.h>
21 22
22#include <asm/arch/pxa-regs.h> 23#include <asm/arch/pxa-regs.h>
23#include <asm/arch/pxa2xx-gpio.h> 24#include <asm/arch/pxa2xx-gpio.h>
@@ -130,7 +131,7 @@ static void cmx270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
130} 131}
131 132
132 133
133static struct pcmcia_low_level cmx270_pcmcia_ops = { 134static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
134 .owner = THIS_MODULE, 135 .owner = THIS_MODULE,
135 .hw_init = cmx270_pcmcia_hw_init, 136 .hw_init = cmx270_pcmcia_hw_init,
136 .hw_shutdown = cmx270_pcmcia_shutdown, 137 .hw_shutdown = cmx270_pcmcia_shutdown,
@@ -147,15 +148,21 @@ static int __init cmx270_pcmcia_init(void)
147{ 148{
148 int ret; 149 int ret;
149 150
151 if (!machine_is_armcore())
152 return -ENODEV;
153
150 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 154 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
151 155
152 if (!cmx270_pcmcia_device) 156 if (!cmx270_pcmcia_device)
153 return -ENOMEM; 157 return -ENOMEM;
154 158
155 cmx270_pcmcia_device->dev.platform_data = &cmx270_pcmcia_ops; 159 ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
160 sizeof(cmx270_pcmcia_ops));
156 161
157 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n"); 162 if (ret == 0) {
158 ret = platform_device_add(cmx270_pcmcia_device); 163 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
164 ret = platform_device_add(cmx270_pcmcia_device);
165 }
159 166
160 if (ret) 167 if (ret)
161 platform_device_put(cmx270_pcmcia_device); 168 platform_device_put(cmx270_pcmcia_device);
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c
index 145b85e0f02c..92d1cc33808c 100644
--- a/drivers/pcmcia/pxa2xx_mainstone.c
+++ b/drivers/pcmcia/pxa2xx_mainstone.c
@@ -22,6 +22,7 @@
22#include <pcmcia/ss.h> 22#include <pcmcia/ss.h>
23 23
24#include <asm/hardware.h> 24#include <asm/hardware.h>
25#include <asm/mach-types.h>
25#include <asm/irq.h> 26#include <asm/irq.h>
26 27
27#include <asm/arch/pxa-regs.h> 28#include <asm/arch/pxa-regs.h>
@@ -136,7 +137,7 @@ static void mst_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
136{ 137{
137} 138}
138 139
139static struct pcmcia_low_level mst_pcmcia_ops = { 140static struct pcmcia_low_level mst_pcmcia_ops __initdata = {
140 .owner = THIS_MODULE, 141 .owner = THIS_MODULE,
141 .hw_init = mst_pcmcia_hw_init, 142 .hw_init = mst_pcmcia_hw_init,
142 .hw_shutdown = mst_pcmcia_hw_shutdown, 143 .hw_shutdown = mst_pcmcia_hw_shutdown,
@@ -153,13 +154,17 @@ static int __init mst_pcmcia_init(void)
153{ 154{
154 int ret; 155 int ret;
155 156
157 if (!machine_is_mainstone())
158 return -ENODEV;
159
156 mst_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 160 mst_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
157 if (!mst_pcmcia_device) 161 if (!mst_pcmcia_device)
158 return -ENOMEM; 162 return -ENOMEM;
159 163
160 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; 164 ret = platform_device_add_data(mst_pcmcia_device, &mst_pcmcia_ops,
161 165 sizeof(mst_pcmcia_ops));
162 ret = platform_device_add(mst_pcmcia_device); 166 if (ret == 0)
167 ret = platform_device_add(mst_pcmcia_device);
163 168
164 if (ret) 169 if (ret)
165 platform_device_put(mst_pcmcia_device); 170 platform_device_put(mst_pcmcia_device);
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index d5c33bd78d68..d71f93d45833 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -222,7 +222,7 @@ static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
222 sharpsl_pcmcia_init_reset(skt); 222 sharpsl_pcmcia_init_reset(skt);
223} 223}
224 224
225static struct pcmcia_low_level sharpsl_pcmcia_ops = { 225static struct pcmcia_low_level sharpsl_pcmcia_ops __initdata = {
226 .owner = THIS_MODULE, 226 .owner = THIS_MODULE,
227 .hw_init = sharpsl_pcmcia_hw_init, 227 .hw_init = sharpsl_pcmcia_hw_init,
228 .hw_shutdown = sharpsl_pcmcia_hw_shutdown, 228 .hw_shutdown = sharpsl_pcmcia_hw_shutdown,
@@ -261,10 +261,12 @@ static int __init sharpsl_pcmcia_init(void)
261 if (!sharpsl_pcmcia_device) 261 if (!sharpsl_pcmcia_device)
262 return -ENOMEM; 262 return -ENOMEM;
263 263
264 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 264 ret = platform_device_add_data(sharpsl_pcmcia_device,
265 sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev; 265 &sharpsl_pcmcia_ops, sizeof(sharpsl_pcmcia_ops));
266 266 if (ret == 0) {
267 ret = platform_device_add(sharpsl_pcmcia_device); 267 sharpsl_pcmcia_device->dev.parent = platform_scoop_config->devs[0].dev;
268 ret = platform_device_add(sharpsl_pcmcia_device);
269 }
268 270
269 if (ret) 271 if (ret)
270 platform_device_put(sharpsl_pcmcia_device); 272 platform_device_put(sharpsl_pcmcia_device);
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
index ce2226273aaa..c0e2afc79e3e 100644
--- a/drivers/pcmcia/rsrc_mgr.c
+++ b/drivers/pcmcia/rsrc_mgr.c
@@ -21,86 +21,6 @@
21#include "cs_internal.h" 21#include "cs_internal.h"
22 22
23 23
24#ifdef CONFIG_PCMCIA_IOCTL
25
26#ifdef CONFIG_PCMCIA_PROBE
27
28static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
29{
30 int irq;
31 u32 mask;
32
33 irq = adj->resource.irq.IRQ;
34 if ((irq < 0) || (irq > 15))
35 return CS_BAD_IRQ;
36
37 if (adj->Action != REMOVE_MANAGED_RESOURCE)
38 return 0;
39
40 mask = 1 << irq;
41
42 if (!(s->irq_mask & mask))
43 return 0;
44
45 s->irq_mask &= ~mask;
46
47 return 0;
48}
49
50#else
51
52static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) {
53 return CS_SUCCESS;
54}
55
56#endif
57
58
59int pcmcia_adjust_resource_info(adjust_t *adj)
60{
61 struct pcmcia_socket *s;
62 int ret = CS_UNSUPPORTED_FUNCTION;
63 unsigned long flags;
64
65 down_read(&pcmcia_socket_list_rwsem);
66 list_for_each_entry(s, &pcmcia_socket_list, socket_list) {
67
68 if (adj->Resource == RES_IRQ)
69 ret = adjust_irq(s, adj);
70
71 else if (s->resource_ops->adjust_resource) {
72
73 /* you can't use the old interface if the new
74 * one was used before */
75 spin_lock_irqsave(&s->lock, flags);
76 if ((s->resource_setup_new) &&
77 !(s->resource_setup_old)) {
78 spin_unlock_irqrestore(&s->lock, flags);
79 continue;
80 } else if (!(s->resource_setup_old))
81 s->resource_setup_old = 1;
82 spin_unlock_irqrestore(&s->lock, flags);
83
84 ret = s->resource_ops->adjust_resource(s, adj);
85 if (!ret) {
86 /* as there's no way we know this is the
87 * last call to adjust_resource_info, we
88 * always need to assume this is the latest
89 * one... */
90 spin_lock_irqsave(&s->lock, flags);
91 s->resource_setup_done = 1;
92 spin_unlock_irqrestore(&s->lock, flags);
93 }
94 }
95 }
96 up_read(&pcmcia_socket_list_rwsem);
97
98 return (ret);
99}
100EXPORT_SYMBOL(pcmcia_adjust_resource_info);
101
102#endif
103
104int pcmcia_validate_mem(struct pcmcia_socket *s) 24int pcmcia_validate_mem(struct pcmcia_socket *s)
105{ 25{
106 if (s->resource_ops->validate_mem) 26 if (s->resource_ops->validate_mem)
@@ -164,7 +84,8 @@ struct pccard_resource_ops pccard_static_ops = {
164 .adjust_io_region = NULL, 84 .adjust_io_region = NULL,
165 .find_io = NULL, 85 .find_io = NULL,
166 .find_mem = NULL, 86 .find_mem = NULL,
167 .adjust_resource = NULL, 87 .add_io = NULL,
88 .add_mem = NULL,
168 .init = static_init, 89 .init = static_init,
169 .exit = NULL, 90 .exit = NULL,
170}; 91};
@@ -264,7 +185,8 @@ struct pccard_resource_ops pccard_iodyn_ops = {
264 .adjust_io_region = iodyn_adjust_io_region, 185 .adjust_io_region = iodyn_adjust_io_region,
265 .find_io = iodyn_find_io_region, 186 .find_io = iodyn_find_io_region,
266 .find_mem = NULL, 187 .find_mem = NULL,
267 .adjust_resource = NULL, 188 .add_io = NULL,
189 .add_mem = NULL,
268 .init = static_init, 190 .init = static_init,
269 .exit = NULL, 191 .exit = NULL,
270}; 192};
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 0fcf763b9175..d0c1d63d1891 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -31,7 +31,6 @@
31#include <pcmcia/cs_types.h> 31#include <pcmcia/cs_types.h>
32#include <pcmcia/ss.h> 32#include <pcmcia/ss.h>
33#include <pcmcia/cs.h> 33#include <pcmcia/cs.h>
34#include <pcmcia/bulkmem.h>
35#include <pcmcia/cistpl.h> 34#include <pcmcia/cistpl.h>
36#include "cs_internal.h" 35#include "cs_internal.h"
37 36
@@ -261,21 +260,22 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
261======================================================================*/ 260======================================================================*/
262 261
263/* Validation function for cards with a valid CIS */ 262/* Validation function for cards with a valid CIS */
264static int readable(struct pcmcia_socket *s, struct resource *res, cisinfo_t *info) 263static int readable(struct pcmcia_socket *s, struct resource *res,
264 unsigned int *count)
265{ 265{
266 int ret = -1; 266 int ret = -1;
267 267
268 s->cis_mem.res = res; 268 s->cis_mem.res = res;
269 s->cis_virt = ioremap(res->start, s->map_size); 269 s->cis_virt = ioremap(res->start, s->map_size);
270 if (s->cis_virt) { 270 if (s->cis_virt) {
271 ret = pccard_validate_cis(s, BIND_FN_ALL, info); 271 ret = pccard_validate_cis(s, BIND_FN_ALL, count);
272 /* invalidate mapping and CIS cache */ 272 /* invalidate mapping and CIS cache */
273 iounmap(s->cis_virt); 273 iounmap(s->cis_virt);
274 s->cis_virt = NULL; 274 s->cis_virt = NULL;
275 destroy_cis_cache(s); 275 destroy_cis_cache(s);
276 } 276 }
277 s->cis_mem.res = NULL; 277 s->cis_mem.res = NULL;
278 if ((ret != 0) || (info->Chains == 0)) 278 if ((ret != 0) || (count == 0))
279 return 0; 279 return 0;
280 return 1; 280 return 1;
281} 281}
@@ -316,7 +316,7 @@ static int
316cis_readable(struct pcmcia_socket *s, unsigned long base, unsigned long size) 316cis_readable(struct pcmcia_socket *s, unsigned long base, unsigned long size)
317{ 317{
318 struct resource *res1, *res2; 318 struct resource *res1, *res2;
319 cisinfo_t info1, info2; 319 unsigned int info1, info2;
320 int ret = 0; 320 int ret = 0;
321 321
322 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe"); 322 res1 = claim_region(s, base, size/2, IORESOURCE_MEM, "cs memory probe");
@@ -330,7 +330,7 @@ cis_readable(struct pcmcia_socket *s, unsigned long base, unsigned long size)
330 free_region(res2); 330 free_region(res2);
331 free_region(res1); 331 free_region(res1);
332 332
333 return (ret == 2) && (info1.Chains == info2.Chains); 333 return (ret == 2) && (info1 == info2);
334} 334}
335 335
336static int 336static int
@@ -766,21 +766,6 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long
766} 766}
767 767
768 768
769static int nonstatic_adjust_resource_info(struct pcmcia_socket *s, adjust_t *adj)
770{
771 unsigned long end;
772
773 switch (adj->Resource) {
774 case RES_MEMORY_RANGE:
775 end = adj->resource.memory.Base + adj->resource.memory.Size - 1;
776 return adjust_memory(s, adj->Action, adj->resource.memory.Base, end);
777 case RES_IO_RANGE:
778 end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1;
779 return adjust_io(s, adj->Action, adj->resource.io.BasePort, end);
780 }
781 return CS_UNSUPPORTED_FUNCTION;
782}
783
784#ifdef CONFIG_PCI 769#ifdef CONFIG_PCI
785static int nonstatic_autoadd_resources(struct pcmcia_socket *s) 770static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
786{ 771{
@@ -889,7 +874,8 @@ struct pccard_resource_ops pccard_nonstatic_ops = {
889 .adjust_io_region = nonstatic_adjust_io_region, 874 .adjust_io_region = nonstatic_adjust_io_region,
890 .find_io = nonstatic_find_io_region, 875 .find_io = nonstatic_find_io_region,
891 .find_mem = nonstatic_find_mem_region, 876 .find_mem = nonstatic_find_mem_region,
892 .adjust_resource = nonstatic_adjust_resource_info, 877 .add_io = adjust_io,
878 .add_mem = adjust_memory,
893 .init = nonstatic_init, 879 .init = nonstatic_init,
894 .exit = nonstatic_release_resource_db, 880 .exit = nonstatic_release_resource_db,
895}; 881};
@@ -1008,41 +994,34 @@ static ssize_t store_mem_db(struct device *dev,
1008} 994}
1009static DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, store_mem_db); 995static DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, store_mem_db);
1010 996
1011static struct device_attribute *pccard_rsrc_attributes[] = { 997static struct attribute *pccard_rsrc_attributes[] = {
1012 &dev_attr_available_resources_io, 998 &dev_attr_available_resources_io.attr,
1013 &dev_attr_available_resources_mem, 999 &dev_attr_available_resources_mem.attr,
1014 NULL, 1000 NULL,
1015}; 1001};
1016 1002
1003static const struct attribute_group rsrc_attributes = {
1004 .attrs = pccard_rsrc_attributes,
1005};
1006
1017static int __devinit pccard_sysfs_add_rsrc(struct device *dev, 1007static int __devinit pccard_sysfs_add_rsrc(struct device *dev,
1018 struct class_interface *class_intf) 1008 struct class_interface *class_intf)
1019{ 1009{
1020 struct pcmcia_socket *s = dev_get_drvdata(dev); 1010 struct pcmcia_socket *s = dev_get_drvdata(dev);
1021 struct device_attribute **attr; 1011
1022 int ret = 0;
1023 if (s->resource_ops != &pccard_nonstatic_ops) 1012 if (s->resource_ops != &pccard_nonstatic_ops)
1024 return 0; 1013 return 0;
1025 1014 return sysfs_create_group(&dev->kobj, &rsrc_attributes);
1026 for (attr = pccard_rsrc_attributes; *attr; attr++) {
1027 ret = device_create_file(dev, *attr);
1028 if (ret)
1029 break;
1030 }
1031
1032 return ret;
1033} 1015}
1034 1016
1035static void __devexit pccard_sysfs_remove_rsrc(struct device *dev, 1017static void __devexit pccard_sysfs_remove_rsrc(struct device *dev,
1036 struct class_interface *class_intf) 1018 struct class_interface *class_intf)
1037{ 1019{
1038 struct pcmcia_socket *s = dev_get_drvdata(dev); 1020 struct pcmcia_socket *s = dev_get_drvdata(dev);
1039 struct device_attribute **attr;
1040 1021
1041 if (s->resource_ops != &pccard_nonstatic_ops) 1022 if (s->resource_ops != &pccard_nonstatic_ops)
1042 return; 1023 return;
1043 1024 sysfs_remove_group(&dev->kobj, &rsrc_attributes);
1044 for (attr = pccard_rsrc_attributes; *attr; attr++)
1045 device_remove_file(dev, *attr);
1046} 1025}
1047 1026
1048static struct class_interface pccard_rsrc_interface __refdata = { 1027static struct class_interface pccard_rsrc_interface __refdata = {
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 1edc1da9d353..91ef6a0da3ab 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -14,7 +14,6 @@
14#include <pcmcia/cs_types.h> 14#include <pcmcia/cs_types.h>
15#include <pcmcia/cs.h> 15#include <pcmcia/cs.h>
16#include <pcmcia/ss.h> 16#include <pcmcia/ss.h>
17#include <pcmcia/bulkmem.h>
18#include <pcmcia/cistpl.h> 17#include <pcmcia/cistpl.h>
19#include "cs_internal.h" 18#include "cs_internal.h"
20 19
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 562384d6f321..006a29e91d83 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -27,11 +27,9 @@
27#include <asm/system.h> 27#include <asm/system.h>
28#include <asm/irq.h> 28#include <asm/irq.h>
29 29
30#define IN_CARD_SERVICES
31#include <pcmcia/cs_types.h> 30#include <pcmcia/cs_types.h>
32#include <pcmcia/ss.h> 31#include <pcmcia/ss.h>
33#include <pcmcia/cs.h> 32#include <pcmcia/cs.h>
34#include <pcmcia/bulkmem.h>
35#include <pcmcia/cistpl.h> 33#include <pcmcia/cistpl.h>
36#include <pcmcia/cisreg.h> 34#include <pcmcia/cisreg.h>
37#include <pcmcia/ds.h> 35#include <pcmcia/ds.h>
@@ -293,7 +291,7 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
293 count = 0; 291 count = 0;
294 else { 292 else {
295 struct pcmcia_socket *s; 293 struct pcmcia_socket *s;
296 cisinfo_t cisinfo; 294 unsigned int chains;
297 295
298 if (off + count > size) 296 if (off + count > size)
299 count = size - off; 297 count = size - off;
@@ -302,9 +300,9 @@ static ssize_t pccard_show_cis(struct kobject *kobj,
302 300
303 if (!(s->state & SOCKET_PRESENT)) 301 if (!(s->state & SOCKET_PRESENT))
304 return -ENODEV; 302 return -ENODEV;
305 if (pccard_validate_cis(s, BIND_FN_ALL, &cisinfo)) 303 if (pccard_validate_cis(s, BIND_FN_ALL, &chains))
306 return -EIO; 304 return -EIO;
307 if (!cisinfo.Chains) 305 if (!chains)
308 return -ENODATA; 306 return -ENODATA;
309 307
310 count = pccard_extract_cis(s, buf, off, count); 308 count = pccard_extract_cis(s, buf, off, count);
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index d29657bf1b40..129db7bd06c3 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -155,7 +155,7 @@
155#define ENE_TEST_C9_TLTENABLE 0x02 155#define ENE_TEST_C9_TLTENABLE 0x02
156#define ENE_TEST_C9_PFENABLE_F0 0x04 156#define ENE_TEST_C9_PFENABLE_F0 0x04
157#define ENE_TEST_C9_PFENABLE_F1 0x08 157#define ENE_TEST_C9_PFENABLE_F1 0x08
158#define ENE_TEST_C9_PFENABLE (ENE_TEST_C9_PFENABLE_F0 | ENE_TEST_C9_PFENABLE_F0) 158#define ENE_TEST_C9_PFENABLE (ENE_TEST_C9_PFENABLE_F0 | ENE_TEST_C9_PFENABLE_F1)
159#define ENE_TEST_C9_WPDISALBLE_F0 0x40 159#define ENE_TEST_C9_WPDISALBLE_F0 0x40
160#define ENE_TEST_C9_WPDISALBLE_F1 0x80 160#define ENE_TEST_C9_WPDISALBLE_F1 0x80
161#define ENE_TEST_C9_WPDISALBLE (ENE_TEST_C9_WPDISALBLE_F0 | ENE_TEST_C9_WPDISALBLE_F1) 161#define ENE_TEST_C9_WPDISALBLE (ENE_TEST_C9_WPDISALBLE_F0 | ENE_TEST_C9_WPDISALBLE_F1)
@@ -692,7 +692,7 @@ static int ti12xx_2nd_slot_empty(struct yenta_socket *socket)
692 goto out; 692 goto out;
693 693
694 /* check state */ 694 /* check state */
695 yenta_get_status(&socket->socket, &state); 695 yenta_get_status(&slot2->socket, &state);
696 if (state & SS_DETECT) { 696 if (state & SS_DETECT) {
697 ret = 0; 697 ret = 0;
698 goto out; 698 goto out;