yenta_socket.c revision 9da4bc6d6a38c1c3d850c046d0aee324c1a2e52a
1/*
2 * Regular cardbus driver ("yenta_socket")
3 *
4 * (C) Copyright 1999, 2000 Linus Torvalds
5 *
6 * Changelog:
7 * Aug 2002: Manfred Spraul <manfred@colorfullife.com>
8 * 	Dynamically adjust the size of the bridge resource
9 *
10 * May 2003: Dominik Brodowski <linux@brodo.de>
11 * 	Merge pci_socket.c and yenta.c into one file
12 */
13#include <linux/init.h>
14#include <linux/pci.h>
15#include <linux/sched.h>
16#include <linux/workqueue.h>
17#include <linux/interrupt.h>
18#include <linux/delay.h>
19#include <linux/module.h>
20
21#include <pcmcia/cs_types.h>
22#include <pcmcia/ss.h>
23#include <pcmcia/cs.h>
24
25#include <asm/io.h>
26
27#include "yenta_socket.h"
28#include "i82365.h"
29
30static int disable_clkrun;
31module_param(disable_clkrun, bool, 0444);
32MODULE_PARM_DESC(disable_clkrun, "If PC card doesn't function properly, please try this option");
33
34static int isa_probe = 1;
35module_param(isa_probe, bool, 0444);
36MODULE_PARM_DESC(isa_probe, "If set ISA interrupts are probed (default). Set to N to disable probing");
37
38static int pwr_irqs_off;
39module_param(pwr_irqs_off, bool, 0644);
40MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!");
41
42#if 0
43#define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args)
44#else
45#define debug(x,args...)
46#endif
47
48/* Don't ask.. */
49#define to_cycles(ns)	((ns)/120)
50#define to_ns(cycles)	((cycles)*120)
51
52static int yenta_probe_cb_irq(struct yenta_socket *socket);
53
54
55static unsigned int override_bios;
56module_param(override_bios, uint, 0000);
57MODULE_PARM_DESC (override_bios, "yenta ignore bios resource allocation");
58
59/*
60 * Generate easy-to-use ways of reading a cardbus sockets
61 * regular memory space ("cb_xxx"), configuration space
62 * ("config_xxx") and compatibility space ("exca_xxxx")
63 */
64static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg)
65{
66	u32 val = readl(socket->base + reg);
67	debug("%p %04x %08x\n", socket, reg, val);
68	return val;
69}
70
71static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val)
72{
73	debug("%p %04x %08x\n", socket, reg, val);
74	writel(val, socket->base + reg);
75	readl(socket->base + reg); /* avoid problems with PCI write posting */
76}
77
78static inline u8 config_readb(struct yenta_socket *socket, unsigned offset)
79{
80	u8 val;
81	pci_read_config_byte(socket->dev, offset, &val);
82	debug("%p %04x %02x\n", socket, offset, val);
83	return val;
84}
85
86static inline u16 config_readw(struct yenta_socket *socket, unsigned offset)
87{
88	u16 val;
89	pci_read_config_word(socket->dev, offset, &val);
90	debug("%p %04x %04x\n", socket, offset, val);
91	return val;
92}
93
94static inline u32 config_readl(struct yenta_socket *socket, unsigned offset)
95{
96	u32 val;
97	pci_read_config_dword(socket->dev, offset, &val);
98	debug("%p %04x %08x\n", socket, offset, val);
99	return val;
100}
101
102static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val)
103{
104	debug("%p %04x %02x\n", socket, offset, val);
105	pci_write_config_byte(socket->dev, offset, val);
106}
107
108static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val)
109{
110	debug("%p %04x %04x\n", socket, offset, val);
111	pci_write_config_word(socket->dev, offset, val);
112}
113
114static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val)
115{
116	debug("%p %04x %08x\n", socket, offset, val);
117	pci_write_config_dword(socket->dev, offset, val);
118}
119
120static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg)
121{
122	u8 val = readb(socket->base + 0x800 + reg);
123	debug("%p %04x %02x\n", socket, reg, val);
124	return val;
125}
126
127static inline u8 exca_readw(struct yenta_socket *socket, unsigned reg)
128{
129	u16 val;
130	val = readb(socket->base + 0x800 + reg);
131	val |= readb(socket->base + 0x800 + reg + 1) << 8;
132	debug("%p %04x %04x\n", socket, reg, val);
133	return val;
134}
135
136static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val)
137{
138	debug("%p %04x %02x\n", socket, reg, val);
139	writeb(val, socket->base + 0x800 + reg);
140	readb(socket->base + 0x800 + reg); /* PCI write posting... */
141}
142
143static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val)
144{
145	debug("%p %04x %04x\n", socket, reg, val);
146	writeb(val, socket->base + 0x800 + reg);
147	writeb(val >> 8, socket->base + 0x800 + reg + 1);
148
149	/* PCI write posting... */
150	readb(socket->base + 0x800 + reg);
151	readb(socket->base + 0x800 + reg + 1);
152}
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
188/*
189 * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend
190 * on what kind of card is inserted..
191 */
192static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value)
193{
194	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
195	unsigned int val;
196	u32 state = cb_readl(socket, CB_SOCKET_STATE);
197
198	val  = (state & CB_3VCARD) ? SS_3VCARD : 0;
199	val |= (state & CB_XVCARD) ? SS_XVCARD : 0;
200	val |= (state & (CB_5VCARD | CB_3VCARD | CB_XVCARD | CB_YVCARD)) ? 0 : SS_PENDING;
201	val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? SS_PENDING : 0;
202
203
204	if (state & CB_CBCARD) {
205		val |= SS_CARDBUS;
206		val |= (state & CB_CARDSTS) ? SS_STSCHG : 0;
207		val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT;
208		val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0;
209	} else if (state & CB_16BITCARD) {
210		u8 status = exca_readb(socket, I365_STATUS);
211		val |= ((status & I365_CS_DETECT) == I365_CS_DETECT) ? SS_DETECT : 0;
212		if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) {
213			val |= (status & I365_CS_STSCHG) ? 0 : SS_STSCHG;
214		} else {
215			val |= (status & I365_CS_BVD1) ? 0 : SS_BATDEAD;
216			val |= (status & I365_CS_BVD2) ? 0 : SS_BATWARN;
217		}
218		val |= (status & I365_CS_WRPROT) ? SS_WRPROT : 0;
219		val |= (status & I365_CS_READY) ? SS_READY : 0;
220		val |= (status & I365_CS_POWERON) ? SS_POWERON : 0;
221	}
222
223	*value = val;
224	return 0;
225}
226
227static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
228{
229	/* some birdges require to use the ExCA registers to power 16bit cards */
230	if (!(cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) &&
231	    (socket->flags & YENTA_16BIT_POWER_EXCA)) {
232		u8 reg, old;
233		reg = old = exca_readb(socket, I365_POWER);
234		reg &= ~(I365_VCC_MASK | I365_VPP1_MASK | I365_VPP2_MASK);
235
236		/* i82365SL-DF style */
237		if (socket->flags & YENTA_16BIT_POWER_DF) {
238			switch (state->Vcc) {
239			case 33: reg |= I365_VCC_3V; break;
240			case 50: reg |= I365_VCC_5V; break;
241			default: reg = 0; break;
242			}
243			switch (state->Vpp) {
244			case 33:
245			case 50: reg |= I365_VPP1_5V; break;
246			case 120: reg |= I365_VPP1_12V; break;
247			}
248		} else {
249			/* i82365SL-B style */
250			switch (state->Vcc) {
251			case 50: reg |= I365_VCC_5V; break;
252			default: reg = 0; break;
253			}
254			switch (state->Vpp) {
255			case 50: reg |= I365_VPP1_5V | I365_VPP2_5V; break;
256			case 120: reg |= I365_VPP1_12V | I365_VPP2_12V; break;
257			}
258		}
259
260		if (reg != old)
261			exca_writeb(socket, I365_POWER, reg);
262	} else {
263		u32 reg = 0;	/* CB_SC_STPCLK? */
264		switch (state->Vcc) {
265		case 33: reg = CB_SC_VCC_3V; break;
266		case 50: reg = CB_SC_VCC_5V; break;
267		default: reg = 0; break;
268		}
269		switch (state->Vpp) {
270		case 33:  reg |= CB_SC_VPP_3V; break;
271		case 50:  reg |= CB_SC_VPP_5V; break;
272		case 120: reg |= CB_SC_VPP_12V; break;
273		}
274		if (reg != cb_readl(socket, CB_SOCKET_CONTROL))
275			cb_writel(socket, CB_SOCKET_CONTROL, reg);
276	}
277}
278
279static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
280{
281	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
282	u16 bridge;
283
284	yenta_set_power(socket, state);
285	socket->io_irq = state->io_irq;
286	bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~(CB_BRIDGE_CRST | CB_BRIDGE_INTR);
287	if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) {
288		u8 intr;
289		bridge |= (state->flags & SS_RESET) ? CB_BRIDGE_CRST : 0;
290
291		/* ISA interrupt control? */
292		intr = exca_readb(socket, I365_INTCTL);
293		intr = (intr & ~0xf);
294		if (!socket->cb_irq) {
295			intr |= state->io_irq;
296			bridge |= CB_BRIDGE_INTR;
297		}
298		exca_writeb(socket, I365_INTCTL, intr);
299	}  else {
300		u8 reg;
301
302		reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA);
303		reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET;
304		reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0;
305		if (state->io_irq != socket->cb_irq) {
306			reg |= state->io_irq;
307			bridge |= CB_BRIDGE_INTR;
308		}
309		exca_writeb(socket, I365_INTCTL, reg);
310
311		reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK);
312		reg |= I365_PWR_NORESET;
313		if (state->flags & SS_PWR_AUTO) reg |= I365_PWR_AUTO;
314		if (state->flags & SS_OUTPUT_ENA) reg |= I365_PWR_OUT;
315		if (exca_readb(socket, I365_POWER) != reg)
316			exca_writeb(socket, I365_POWER, reg);
317
318		/* CSC interrupt: no ISA irq for CSC */
319		reg = I365_CSC_DETECT;
320		if (state->flags & SS_IOCARD) {
321			if (state->csc_mask & SS_STSCHG) reg |= I365_CSC_STSCHG;
322		} else {
323			if (state->csc_mask & SS_BATDEAD) reg |= I365_CSC_BVD1;
324			if (state->csc_mask & SS_BATWARN) reg |= I365_CSC_BVD2;
325			if (state->csc_mask & SS_READY) reg |= I365_CSC_READY;
326		}
327		exca_writeb(socket, I365_CSCINT, reg);
328		exca_readb(socket, I365_CSC);
329		if(sock->zoom_video)
330			sock->zoom_video(sock, state->flags & SS_ZVCARD);
331	}
332	config_writew(socket, CB_BRIDGE_CONTROL, bridge);
333	/* Socket event mask: get card insert/remove events.. */
334	cb_writel(socket, CB_SOCKET_EVENT, -1);
335	cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
336	return 0;
337}
338
339static int yenta_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io)
340{
341	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
342	int map;
343	unsigned char ioctl, addr, enable;
344
345	map = io->map;
346
347	if (map > 1)
348		return -EINVAL;
349
350	enable = I365_ENA_IO(map);
351	addr = exca_readb(socket, I365_ADDRWIN);
352
353	/* Disable the window before changing it.. */
354	if (addr & enable) {
355		addr &= ~enable;
356		exca_writeb(socket, I365_ADDRWIN, addr);
357	}
358
359	exca_writew(socket, I365_IO(map)+I365_W_START, io->start);
360	exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop);
361
362	ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
363	if (io->flags & MAP_0WS) ioctl |= I365_IOCTL_0WS(map);
364	if (io->flags & MAP_16BIT) ioctl |= I365_IOCTL_16BIT(map);
365	if (io->flags & MAP_AUTOSZ) ioctl |= I365_IOCTL_IOCS16(map);
366	exca_writeb(socket, I365_IOCTL, ioctl);
367
368	if (io->flags & MAP_ACTIVE)
369		exca_writeb(socket, I365_ADDRWIN, addr | enable);
370	return 0;
371}
372
373static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *mem)
374{
375	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
376	struct pci_bus_region region;
377	int map;
378	unsigned char addr, enable;
379	unsigned int start, stop, card_start;
380	unsigned short word;
381
382	pcibios_resource_to_bus(socket->dev, &region, mem->res);
383
384	map = mem->map;
385	start = region.start;
386	stop = region.end;
387	card_start = mem->card_start;
388
389	if (map > 4 || start > stop || ((start ^ stop) >> 24) ||
390	    (card_start >> 26) || mem->speed > 1000)
391		return -EINVAL;
392
393	enable = I365_ENA_MEM(map);
394	addr = exca_readb(socket, I365_ADDRWIN);
395	if (addr & enable) {
396		addr &= ~enable;
397		exca_writeb(socket, I365_ADDRWIN, addr);
398	}
399
400	exca_writeb(socket, CB_MEM_PAGE(map), start >> 24);
401
402	word = (start >> 12) & 0x0fff;
403	if (mem->flags & MAP_16BIT)
404		word |= I365_MEM_16BIT;
405	if (mem->flags & MAP_0WS)
406		word |= I365_MEM_0WS;
407	exca_writew(socket, I365_MEM(map) + I365_W_START, word);
408
409	word = (stop >> 12) & 0x0fff;
410	switch (to_cycles(mem->speed)) {
411		case 0: break;
412		case 1:  word |= I365_MEM_WS0; break;
413		case 2:  word |= I365_MEM_WS1; break;
414		default: word |= I365_MEM_WS1 | I365_MEM_WS0; break;
415	}
416	exca_writew(socket, I365_MEM(map) + I365_W_STOP, word);
417
418	word = ((card_start - start) >> 12) & 0x3fff;
419	if (mem->flags & MAP_WRPROT)
420		word |= I365_MEM_WRPROT;
421	if (mem->flags & MAP_ATTRIB)
422		word |= I365_MEM_REG;
423	exca_writew(socket, I365_MEM(map) + I365_W_OFF, word);
424
425	if (mem->flags & MAP_ACTIVE)
426		exca_writeb(socket, I365_ADDRWIN, addr | enable);
427	return 0;
428}
429
430
431
432static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
433{
434	unsigned int events;
435	struct yenta_socket *socket = (struct yenta_socket *) dev_id;
436	u8 csc;
437	u32 cb_event;
438
439	/* Clear interrupt status for the event */
440	cb_event = cb_readl(socket, CB_SOCKET_EVENT);
441	cb_writel(socket, CB_SOCKET_EVENT, cb_event);
442
443	csc = exca_readb(socket, I365_CSC);
444
445	if (!(cb_event || csc))
446		return IRQ_NONE;
447
448	events = (cb_event & (CB_CD1EVENT | CB_CD2EVENT)) ? SS_DETECT : 0 ;
449	events |= (csc & I365_CSC_DETECT) ? SS_DETECT : 0;
450	if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) {
451		events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0;
452	} else {
453		events |= (csc & I365_CSC_BVD1) ? SS_BATDEAD : 0;
454		events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0;
455		events |= (csc & I365_CSC_READY) ? SS_READY : 0;
456	}
457
458	if (events)
459		pcmcia_parse_events(&socket->socket, events);
460
461	return IRQ_HANDLED;
462}
463
464static void yenta_interrupt_wrapper(unsigned long data)
465{
466	struct yenta_socket *socket = (struct yenta_socket *) data;
467
468	yenta_interrupt(0, (void *)socket, NULL);
469	socket->poll_timer.expires = jiffies + HZ;
470	add_timer(&socket->poll_timer);
471}
472
473static void yenta_clear_maps(struct yenta_socket *socket)
474{
475	int i;
476	struct resource res = { .start = 0, .end = 0x0fff };
477	pccard_io_map io = { 0, 0, 0, 0, 1 };
478	pccard_mem_map mem = { .res = &res, };
479
480	yenta_set_socket(&socket->socket, &dead_socket);
481	for (i = 0; i < 2; i++) {
482		io.map = i;
483		yenta_set_io_map(&socket->socket, &io);
484	}
485	for (i = 0; i < 5; i++) {
486		mem.map = i;
487		yenta_set_mem_map(&socket->socket, &mem);
488	}
489}
490
491/* redoes voltage interrogation if required */
492static void yenta_interrogate(struct yenta_socket *socket)
493{
494	u32 state;
495
496	state = cb_readl(socket, CB_SOCKET_STATE);
497	if (!(state & (CB_5VCARD | CB_3VCARD | CB_XVCARD | CB_YVCARD)) ||
498	    (state & (CB_CDETECT1 | CB_CDETECT2 | CB_NOTACARD | CB_BADVCCREQ)) ||
499	    ((state & (CB_16BITCARD | CB_CBCARD)) == (CB_16BITCARD | CB_CBCARD)))
500		cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
501}
502
503/* Called at resume and initialization events */
504static int yenta_sock_init(struct pcmcia_socket *sock)
505{
506	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
507
508	exca_writeb(socket, I365_GBLCTL, 0x00);
509	exca_writeb(socket, I365_GENCTL, 0x00);
510
511	/* Redo card voltage interrogation */
512	yenta_interrogate(socket);
513
514	yenta_clear_maps(socket);
515
516	if (socket->type && socket->type->sock_init)
517		socket->type->sock_init(socket);
518
519	/* Re-enable CSC interrupts */
520	cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
521
522	return 0;
523}
524
525static int yenta_sock_suspend(struct pcmcia_socket *sock)
526{
527	struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
528
529	/* Disable CSC interrupts */
530	cb_writel(socket, CB_SOCKET_MASK, 0x0);
531
532	return 0;
533}
534
535/*
536 * Use an adaptive allocation for the memory resource,
537 * sometimes the memory behind pci bridges is limited:
538 * 1/8 of the size of the io window of the parent.
539 * max 4 MB, min 16 kB. We try very hard to not get below
540 * the "ACC" values, though.
541 */
542#define BRIDGE_MEM_MAX 4*1024*1024
543#define BRIDGE_MEM_ACC 128*1024
544#define BRIDGE_MEM_MIN 16*1024
545
546#define BRIDGE_IO_MAX 512
547#define BRIDGE_IO_ACC 256
548#define BRIDGE_IO_MIN 32
549
550#ifndef PCIBIOS_MIN_CARDBUS_IO
551#define PCIBIOS_MIN_CARDBUS_IO PCIBIOS_MIN_IO
552#endif
553
554static int yenta_search_one_res(struct resource *root, struct resource *res,
555				u32 min)
556{
557	u32 align, size, start, end;
558
559	if (res->flags & IORESOURCE_IO) {
560		align = 1024;
561		size = BRIDGE_IO_MAX;
562		start = PCIBIOS_MIN_CARDBUS_IO;
563		end = ~0U;
564	} else {
565		unsigned long avail = root->end - root->start;
566		int i;
567		size = BRIDGE_MEM_MAX;
568		if (size > avail/8) {
569			size=(avail+1)/8;
570			/* round size down to next power of 2 */
571			i = 0;
572			while ((size /= 2) != 0)
573				i++;
574			size = 1 << i;
575		}
576		if (size < min)
577			size = min;
578		align = size;
579		start = PCIBIOS_MIN_MEM;
580		end = ~0U;
581	}
582
583	do {
584		if (allocate_resource(root, res, size, start, end, align,
585				      NULL, NULL)==0) {
586			return 1;
587		}
588		size = size/2;
589		align = size;
590	} while (size >= min);
591
592	return 0;
593}
594
595
596static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
597			    u32 min)
598{
599	int i;
600	for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) {
601		struct resource * root = socket->dev->bus->resource[i];
602		if (!root)
603			continue;
604
605		if ((res->flags ^ root->flags) &
606		    (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH))
607			continue; /* Wrong type */
608
609		if (yenta_search_one_res(root, res, min))
610			return 1;
611	}
612	return 0;
613}
614
615static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end)
616{
617	struct resource *root, *res;
618	struct pci_bus_region region;
619	unsigned mask;
620
621	res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr;
622	/* Already allocated? */
623	if (res->parent)
624		return 0;
625
626	/* The granularity of the memory limit is 4kB, on IO it's 4 bytes */
627	mask = ~0xfff;
628	if (type & IORESOURCE_IO)
629		mask = ~3;
630
631	res->name = socket->dev->subordinate->name;
632	res->flags = type;
633
634	region.start = config_readl(socket, addr_start) & mask;
635	region.end = config_readl(socket, addr_end) | ~mask;
636	if (region.start && region.end > region.start && !override_bios) {
637		pcibios_bus_to_resource(socket->dev, res, &region);
638		root = pci_find_parent_resource(socket->dev, res);
639		if (root && (request_resource(root, res) == 0))
640			return 0;
641		printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n",
642				pci_name(socket->dev), nr);
643	}
644
645	if (type & IORESOURCE_IO) {
646		if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) ||
647		    (yenta_search_res(socket, res, BRIDGE_IO_ACC)) ||
648		    (yenta_search_res(socket, res, BRIDGE_IO_MIN)))
649			return 1;
650	} else {
651		if (type & IORESOURCE_PREFETCH) {
652			if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
653			    (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
654			    (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
655				return 1;
656			/* Approximating prefetchable by non-prefetchable */
657			res->flags = IORESOURCE_MEM;
658		}
659		if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
660		    (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
661		    (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
662			return 1;
663	}
664
665	printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n",
666	       pci_name(socket->dev), type);
667	res->start = res->end = res->flags = 0;
668	return 0;
669}
670
671/*
672 * Allocate the bridge mappings for the device..
673 */
674static void yenta_allocate_resources(struct yenta_socket *socket)
675{
676	int program = 0;
677	program += yenta_allocate_res(socket, 0, IORESOURCE_IO,
678			   PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0);
679	program += yenta_allocate_res(socket, 1, IORESOURCE_IO,
680			   PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1);
681	program += yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH,
682			   PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0);
683	program += yenta_allocate_res(socket, 3, IORESOURCE_MEM,
684			   PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1);
685	if (program)
686		pci_setup_cardbus(socket->dev->subordinate);
687}
688
689
690/*
691 * Free the bridge mappings for the device..
692 */
693static void yenta_free_resources(struct yenta_socket *socket)
694{
695	int i;
696	for (i=0;i<4;i++) {
697		struct resource *res;
698		res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i;
699		if (res->start != 0 && res->end != 0)
700			release_resource(res);
701		res->start = res->end = res->flags = 0;
702	}
703}
704
705
706/*
707 * Close it down - release our resources and go home..
708 */
709static void yenta_close(struct pci_dev *dev)
710{
711	struct yenta_socket *sock = pci_get_drvdata(dev);
712
713	/* Remove the register attributes */
714	device_remove_file(&dev->dev, &dev_attr_yenta_registers);
715
716	/* we don't want a dying socket registered */
717	pcmcia_unregister_socket(&sock->socket);
718
719	/* Disable all events so we don't die in an IRQ storm */
720	cb_writel(sock, CB_SOCKET_MASK, 0x0);
721	exca_writeb(sock, I365_CSCINT, 0);
722
723	if (sock->cb_irq)
724		free_irq(sock->cb_irq, sock);
725	else
726		del_timer_sync(&sock->poll_timer);
727
728	if (sock->base)
729		iounmap(sock->base);
730	yenta_free_resources(sock);
731
732	pci_release_regions(dev);
733	pci_disable_device(dev);
734	pci_set_drvdata(dev, NULL);
735}
736
737
738static struct pccard_operations yenta_socket_operations = {
739	.init			= yenta_sock_init,
740	.suspend		= yenta_sock_suspend,
741	.get_status		= yenta_get_status,
742	.set_socket		= yenta_set_socket,
743	.set_io_map		= yenta_set_io_map,
744	.set_mem_map		= yenta_set_mem_map,
745};
746
747
748#include "ti113x.h"
749#include "ricoh.h"
750#include "topic.h"
751#include "o2micro.h"
752
753enum {
754	CARDBUS_TYPE_DEFAULT = -1,
755	CARDBUS_TYPE_TI,
756	CARDBUS_TYPE_TI113X,
757	CARDBUS_TYPE_TI12XX,
758	CARDBUS_TYPE_TI1250,
759	CARDBUS_TYPE_RICOH,
760	CARDBUS_TYPE_TOPIC95,
761	CARDBUS_TYPE_TOPIC97,
762	CARDBUS_TYPE_O2MICRO,
763	CARDBUS_TYPE_ENE,
764};
765
766/*
767 * Different cardbus controllers have slightly different
768 * initialization sequences etc details. List them here..
769 */
770static struct cardbus_type cardbus_type[] = {
771	[CARDBUS_TYPE_TI]	= {
772		.override	= ti_override,
773		.save_state	= ti_save_state,
774		.restore_state	= ti_restore_state,
775		.sock_init	= ti_init,
776	},
777	[CARDBUS_TYPE_TI113X]	= {
778		.override	= ti113x_override,
779		.save_state	= ti_save_state,
780		.restore_state	= ti_restore_state,
781		.sock_init	= ti_init,
782	},
783	[CARDBUS_TYPE_TI12XX]	= {
784		.override	= ti12xx_override,
785		.save_state	= ti_save_state,
786		.restore_state	= ti_restore_state,
787		.sock_init	= ti_init,
788	},
789	[CARDBUS_TYPE_TI1250]	= {
790		.override	= ti1250_override,
791		.save_state	= ti_save_state,
792		.restore_state	= ti_restore_state,
793		.sock_init	= ti_init,
794	},
795	[CARDBUS_TYPE_RICOH]	= {
796		.override	= ricoh_override,
797		.save_state	= ricoh_save_state,
798		.restore_state	= ricoh_restore_state,
799	},
800	[CARDBUS_TYPE_TOPIC95]	= {
801		.override	= topic95_override,
802	},
803	[CARDBUS_TYPE_TOPIC97]	= {
804		.override	= topic97_override,
805	},
806	[CARDBUS_TYPE_O2MICRO]	= {
807		.override	= o2micro_override,
808		.restore_state	= o2micro_restore_state,
809	},
810	[CARDBUS_TYPE_ENE]	= {
811		.override	= ene_override,
812		.save_state	= ti_save_state,
813		.restore_state	= ti_restore_state,
814		.sock_init	= ti_init,
815	},
816};
817
818
819/*
820 * Only probe "regular" interrupts, don't
821 * touch dangerous spots like the mouse irq,
822 * because there are mice that apparently
823 * get really confused if they get fondled
824 * too intimately.
825 *
826 * Default to 11, 10, 9, 7, 6, 5, 4, 3.
827 */
828static u32 isa_interrupts = 0x0ef8;
829
830static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
831{
832	int i;
833	unsigned long val;
834	u32 mask;
835
836	/*
837	 * Probe for usable interrupts using the force
838	 * register to generate bogus card status events.
839	 */
840	cb_writel(socket, CB_SOCKET_EVENT, -1);
841	cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
842	exca_writeb(socket, I365_CSCINT, 0);
843	val = probe_irq_on() & isa_irq_mask;
844	for (i = 1; i < 16; i++) {
845		if (!((val >> i) & 1))
846			continue;
847		exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
848		cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
849		udelay(100);
850		cb_writel(socket, CB_SOCKET_EVENT, -1);
851	}
852	cb_writel(socket, CB_SOCKET_MASK, 0);
853	exca_writeb(socket, I365_CSCINT, 0);
854
855	mask = probe_irq_mask(val) & 0xffff;
856
857	return mask;
858}
859
860
861/* interrupt handler, only used during probing */
862static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *regs)
863{
864	struct yenta_socket *socket = (struct yenta_socket *) dev_id;
865	u8 csc;
866        u32 cb_event;
867
868	/* Clear interrupt status for the event */
869	cb_event = cb_readl(socket, CB_SOCKET_EVENT);
870	cb_writel(socket, CB_SOCKET_EVENT, -1);
871	csc = exca_readb(socket, I365_CSC);
872
873	if (cb_event || csc) {
874		socket->probe_status = 1;
875		return IRQ_HANDLED;
876	}
877
878	return IRQ_NONE;
879}
880
881/* probes the PCI interrupt, use only on override functions */
882static int yenta_probe_cb_irq(struct yenta_socket *socket)
883{
884	if (!socket->cb_irq)
885		return -1;
886
887	socket->probe_status = 0;
888
889	if (request_irq(socket->cb_irq, yenta_probe_handler, SA_SHIRQ, "yenta", socket)) {
890		printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n");
891		return -1;
892	}
893
894	/* generate interrupt, wait */
895	exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG);
896	cb_writel(socket, CB_SOCKET_EVENT, -1);
897	cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
898	cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
899
900	msleep(100);
901
902	/* disable interrupts */
903	cb_writel(socket, CB_SOCKET_MASK, 0);
904	exca_writeb(socket, I365_CSCINT, 0);
905	cb_writel(socket, CB_SOCKET_EVENT, -1);
906	exca_readb(socket, I365_CSC);
907
908	free_irq(socket->cb_irq, socket);
909
910	return (int) socket->probe_status;
911}
912
913
914
915/*
916 * Set static data that doesn't need re-initializing..
917 */
918static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
919{
920	socket->socket.pci_irq = socket->cb_irq;
921	if (isa_probe)
922		socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
923	else
924		socket->socket.irq_mask = 0;
925
926	printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n",
927	       socket->socket.irq_mask, socket->cb_irq);
928}
929
930/*
931 * Initialize the standard cardbus registers
932 */
933static void yenta_config_init(struct yenta_socket *socket)
934{
935	u16 bridge;
936	struct pci_dev *dev = socket->dev;
937	struct pci_bus_region region;
938
939	pcibios_resource_to_bus(socket->dev, &region, &dev->resource[0]);
940
941	config_writel(socket, CB_LEGACY_MODE_BASE, 0);
942	config_writel(socket, PCI_BASE_ADDRESS_0, region.start);
943	config_writew(socket, PCI_COMMAND,
944			PCI_COMMAND_IO |
945			PCI_COMMAND_MEMORY |
946			PCI_COMMAND_MASTER |
947			PCI_COMMAND_WAIT);
948
949	/* MAGIC NUMBERS! Fixme */
950	config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
951	config_writeb(socket, PCI_LATENCY_TIMER, 168);
952	config_writel(socket, PCI_PRIMARY_BUS,
953		(176 << 24) |			   /* sec. latency timer */
954		(dev->subordinate->subordinate << 16) | /* subordinate bus */
955		(dev->subordinate->secondary << 8) |  /* secondary bus */
956		dev->subordinate->primary);		   /* primary bus */
957
958	/*
959	 * Set up the bridging state:
960	 *  - enable write posting.
961	 *  - memory window 0 prefetchable, window 1 non-prefetchable
962	 *  - PCI interrupts enabled if a PCI interrupt exists..
963	 */
964	bridge = config_readw(socket, CB_BRIDGE_CONTROL);
965	bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
966	bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN;
967	config_writew(socket, CB_BRIDGE_CONTROL, bridge);
968}
969
970/*
971 * Initialize a cardbus controller. Make sure we have a usable
972 * interrupt, and that we can map the cardbus area. Fill in the
973 * socket information structure..
974 */
975static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_id *id)
976{
977	struct yenta_socket *socket;
978	int ret;
979
980	/*
981	 * If we failed to assign proper bus numbers for this cardbus
982	 * controller during PCI probe, its subordinate pci_bus is NULL.
983	 * Bail out if so.
984	 */
985	if (!dev->subordinate) {
986		printk(KERN_ERR "Yenta: no bus associated with %s! "
987			"(try 'pci=assign-busses')\n", pci_name(dev));
988		return -ENODEV;
989	}
990
991	socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL);
992	if (!socket)
993		return -ENOMEM;
994	memset(socket, 0, sizeof(*socket));
995
996	/* prepare pcmcia_socket */
997	socket->socket.ops = &yenta_socket_operations;
998	socket->socket.resource_ops = &pccard_nonstatic_ops;
999	socket->socket.dev.dev = &dev->dev;
1000	socket->socket.driver_data = socket;
1001	socket->socket.owner = THIS_MODULE;
1002	socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD;
1003	socket->socket.map_size = 0x1000;
1004	socket->socket.cb_dev = dev;
1005
1006	/* prepare struct yenta_socket */
1007	socket->dev = dev;
1008	pci_set_drvdata(dev, socket);
1009
1010	/*
1011	 * Do some basic sanity checking..
1012	 */
1013	if (pci_enable_device(dev)) {
1014		ret = -EBUSY;
1015		goto free;
1016	}
1017
1018	ret = pci_request_regions(dev, "yenta_socket");
1019	if (ret)
1020		goto disable;
1021
1022	if (!pci_resource_start(dev, 0)) {
1023		printk(KERN_ERR "No cardbus resource!\n");
1024		ret = -ENODEV;
1025		goto release;
1026	}
1027
1028	/*
1029	 * Ok, start setup.. Map the cardbus registers,
1030	 * and request the IRQ.
1031	 */
1032	socket->base = ioremap(pci_resource_start(dev, 0), 0x1000);
1033	if (!socket->base) {
1034		ret = -ENOMEM;
1035		goto release;
1036	}
1037
1038	/*
1039	 * report the subsystem vendor and device for help debugging
1040	 * the irq stuff...
1041	 */
1042	printk(KERN_INFO "Yenta: CardBus bridge found at %s [%04x:%04x]\n",
1043		pci_name(dev), dev->subsystem_vendor, dev->subsystem_device);
1044
1045	yenta_config_init(socket);
1046
1047	/* Disable all events */
1048	cb_writel(socket, CB_SOCKET_MASK, 0x0);
1049
1050	/* Set up the bridge regions.. */
1051	yenta_allocate_resources(socket);
1052
1053	socket->cb_irq = dev->irq;
1054
1055	/* Do we have special options for the device? */
1056	if (id->driver_data != CARDBUS_TYPE_DEFAULT &&
1057	    id->driver_data < ARRAY_SIZE(cardbus_type)) {
1058		socket->type = &cardbus_type[id->driver_data];
1059
1060		ret = socket->type->override(socket);
1061		if (ret < 0)
1062			goto unmap;
1063	}
1064
1065	/* We must finish initialization here */
1066
1067	if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, SA_SHIRQ, "yenta", socket)) {
1068		/* No IRQ or request_irq failed. Poll */
1069		socket->cb_irq = 0; /* But zero is a valid IRQ number. */
1070		init_timer(&socket->poll_timer);
1071		socket->poll_timer.function = yenta_interrupt_wrapper;
1072		socket->poll_timer.data = (unsigned long)socket;
1073		socket->poll_timer.expires = jiffies + HZ;
1074		add_timer(&socket->poll_timer);
1075		printk(KERN_INFO "Yenta: no PCI IRQ, CardBus support disabled for this socket.\n"
1076		       KERN_INFO "Yenta: check your BIOS CardBus, BIOS IRQ or ACPI settings.\n");
1077	} else {
1078		socket->socket.features |= SS_CAP_CARDBUS;
1079	}
1080
1081	/* Figure out what the dang thing can do for the PCMCIA layer... */
1082	yenta_interrogate(socket);
1083	yenta_get_socket_capabilities(socket, isa_interrupts);
1084	printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
1085
1086	/* Register it with the pcmcia layer.. */
1087	ret = pcmcia_register_socket(&socket->socket);
1088	if (ret == 0) {
1089		/* Add the yenta register attributes */
1090		device_create_file(&dev->dev, &dev_attr_yenta_registers);
1091		goto out;
1092	}
1093
1094 unmap:
1095	iounmap(socket->base);
1096 release:
1097	pci_release_regions(dev);
1098 disable:
1099	pci_disable_device(dev);
1100 free:
1101	kfree(socket);
1102 out:
1103	return ret;
1104}
1105
1106
1107static int yenta_dev_suspend (struct pci_dev *dev, pm_message_t state)
1108{
1109	struct yenta_socket *socket = pci_get_drvdata(dev);
1110	int ret;
1111
1112	ret = pcmcia_socket_dev_suspend(&dev->dev, state);
1113
1114	if (socket) {
1115		if (socket->type && socket->type->save_state)
1116			socket->type->save_state(socket);
1117
1118		/* FIXME: pci_save_state needs to have a better interface */
1119		pci_save_state(dev);
1120		pci_read_config_dword(dev, 16*4, &socket->saved_state[0]);
1121		pci_read_config_dword(dev, 17*4, &socket->saved_state[1]);
1122		pci_disable_device(dev);
1123
1124		/*
1125		 * Some laptops (IBM T22) do not like us putting the Cardbus
1126		 * bridge into D3.  At a guess, some other laptop will
1127		 * probably require this, so leave it commented out for now.
1128		 */
1129		/* pci_set_power_state(dev, 3); */
1130	}
1131
1132	return ret;
1133}
1134
1135
1136static int yenta_dev_resume (struct pci_dev *dev)
1137{
1138	struct yenta_socket *socket = pci_get_drvdata(dev);
1139
1140	if (socket) {
1141		pci_set_power_state(dev, 0);
1142		/* FIXME: pci_restore_state needs to have a better interface */
1143		pci_restore_state(dev);
1144		pci_write_config_dword(dev, 16*4, socket->saved_state[0]);
1145		pci_write_config_dword(dev, 17*4, socket->saved_state[1]);
1146		pci_enable_device(dev);
1147		pci_set_master(dev);
1148
1149		if (socket->type && socket->type->restore_state)
1150			socket->type->restore_state(socket);
1151	}
1152
1153	return pcmcia_socket_dev_resume(&dev->dev);
1154}
1155
1156
1157#define CB_ID(vend,dev,type)				\
1158	{						\
1159		.vendor		= vend,			\
1160		.device		= dev,			\
1161		.subvendor	= PCI_ANY_ID,		\
1162		.subdevice	= PCI_ANY_ID,		\
1163		.class		= PCI_CLASS_BRIDGE_CARDBUS << 8, \
1164		.class_mask	= ~0,			\
1165		.driver_data	= CARDBUS_TYPE_##type,	\
1166	}
1167
1168static struct pci_device_id yenta_table [] = {
1169	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI),
1170
1171	/*
1172	 * TBD: Check if these TI variants can use more
1173	 * advanced overrides instead.  (I can't get the
1174	 * data sheets for these devices. --rmk)
1175	 */
1176	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI),
1177
1178	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X),
1179	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1131, TI113X),
1180
1181	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, TI12XX),
1182	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1220, TI12XX),
1183	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1221, TI12XX),
1184	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1225, TI12XX),
1185	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251A, TI12XX),
1186	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251B, TI12XX),
1187	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420, TI12XX),
1188	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1450, TI12XX),
1189	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1451A, TI12XX),
1190	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1510, TI12XX),
1191	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520, TI12XX),
1192	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1620, TI12XX),
1193	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4410, TI12XX),
1194	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4450, TI12XX),
1195	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4451, TI12XX),
1196	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4510, TI12XX),
1197	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4520, TI12XX),
1198
1199	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250),
1200	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250),
1201
1202	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11, TI12XX),
1203	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X515, TI12XX),
1204	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X420, TI12XX),
1205	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X620, TI12XX),
1206	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7410, TI12XX),
1207	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7510, TI12XX),
1208	CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7610, TI12XX),
1209
1210	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_710, TI12XX),
1211	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_712, TI12XX),
1212	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_720, TI12XX),
1213	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_722, TI12XX),
1214	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1211, ENE),
1215	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE),
1216	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE),
1217	CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE),
1218
1219	CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
1220	CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),
1221	CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH),
1222	CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH),
1223	CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH),
1224
1225	CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC95, TOPIC95),
1226	CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97),
1227	CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97),
1228
1229	CB_ID(PCI_VENDOR_ID_O2, PCI_ANY_ID, O2MICRO),
1230
1231	/* match any cardbus bridge */
1232	CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT),
1233	{ /* all zeroes */ }
1234};
1235MODULE_DEVICE_TABLE(pci, yenta_table);
1236
1237
1238static struct pci_driver yenta_cardbus_driver = {
1239	.name		= "yenta_cardbus",
1240	.id_table	= yenta_table,
1241	.probe		= yenta_probe,
1242	.remove		= __devexit_p(yenta_close),
1243	.suspend	= yenta_dev_suspend,
1244	.resume		= yenta_dev_resume,
1245};
1246
1247
1248static int __init yenta_socket_init(void)
1249{
1250	return pci_register_driver (&yenta_cardbus_driver);
1251}
1252
1253
1254static void __exit yenta_socket_exit (void)
1255{
1256	pci_unregister_driver (&yenta_cardbus_driver);
1257}
1258
1259
1260module_init(yenta_socket_init);
1261module_exit(yenta_socket_exit);
1262
1263MODULE_LICENSE("GPL");
1264