Linux 2.6.33-rc6
[cris-mirror.git] / drivers / pcmcia / yenta_socket.c
blobe4d12acdd525d2a5acb1337f52d2c3a2fc441c9e
1 /*
2 * Regular cardbus driver ("yenta_socket")
4 * (C) Copyright 1999, 2000 Linus Torvalds
6 * Changelog:
7 * Aug 2002: Manfred Spraul <manfred@colorfullife.com>
8 * Dynamically adjust the size of the bridge resource
10 * May 2003: Dominik Brodowski <linux@brodo.de>
11 * Merge pci_socket.c and yenta.c into one file
13 #include <linux/init.h>
14 #include <linux/pci.h>
15 #include <linux/workqueue.h>
16 #include <linux/interrupt.h>
17 #include <linux/delay.h>
18 #include <linux/module.h>
19 #include <linux/io.h>
21 #include <pcmcia/cs_types.h>
22 #include <pcmcia/ss.h>
23 #include <pcmcia/cs.h>
25 #include "yenta_socket.h"
26 #include "i82365.h"
28 static int disable_clkrun;
29 module_param(disable_clkrun, bool, 0444);
30 MODULE_PARM_DESC(disable_clkrun, "If PC card doesn't function properly, please try this option");
32 static int isa_probe = 1;
33 module_param(isa_probe, bool, 0444);
34 MODULE_PARM_DESC(isa_probe, "If set ISA interrupts are probed (default). Set to N to disable probing");
36 static int pwr_irqs_off;
37 module_param(pwr_irqs_off, bool, 0644);
38 MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!");
40 #define debug(x, s, args...) dev_dbg(&s->dev->dev, x, ##args)
42 /* Don't ask.. */
43 #define to_cycles(ns) ((ns)/120)
44 #define to_ns(cycles) ((cycles)*120)
47 * yenta PCI irq probing.
48 * currently only used in the TI/EnE initialization code
50 #ifdef CONFIG_YENTA_TI
51 static int yenta_probe_cb_irq(struct yenta_socket *socket);
52 #endif
55 static unsigned int override_bios;
56 module_param(override_bios, uint, 0000);
57 MODULE_PARM_DESC(override_bios, "yenta ignore bios resource allocation");
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")
64 static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg)
66 u32 val = readl(socket->base + reg);
67 debug("%04x %08x\n", socket, reg, val);
68 return val;
71 static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val)
73 debug("%04x %08x\n", socket, reg, val);
74 writel(val, socket->base + reg);
75 readl(socket->base + reg); /* avoid problems with PCI write posting */
78 static inline u8 config_readb(struct yenta_socket *socket, unsigned offset)
80 u8 val;
81 pci_read_config_byte(socket->dev, offset, &val);
82 debug("%04x %02x\n", socket, offset, val);
83 return val;
86 static inline u16 config_readw(struct yenta_socket *socket, unsigned offset)
88 u16 val;
89 pci_read_config_word(socket->dev, offset, &val);
90 debug("%04x %04x\n", socket, offset, val);
91 return val;
94 static inline u32 config_readl(struct yenta_socket *socket, unsigned offset)
96 u32 val;
97 pci_read_config_dword(socket->dev, offset, &val);
98 debug("%04x %08x\n", socket, offset, val);
99 return val;
102 static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val)
104 debug("%04x %02x\n", socket, offset, val);
105 pci_write_config_byte(socket->dev, offset, val);
108 static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val)
110 debug("%04x %04x\n", socket, offset, val);
111 pci_write_config_word(socket->dev, offset, val);
114 static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val)
116 debug("%04x %08x\n", socket, offset, val);
117 pci_write_config_dword(socket->dev, offset, val);
120 static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg)
122 u8 val = readb(socket->base + 0x800 + reg);
123 debug("%04x %02x\n", socket, reg, val);
124 return val;
127 static inline u8 exca_readw(struct yenta_socket *socket, unsigned reg)
129 u16 val;
130 val = readb(socket->base + 0x800 + reg);
131 val |= readb(socket->base + 0x800 + reg + 1) << 8;
132 debug("%04x %04x\n", socket, reg, val);
133 return val;
136 static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val)
138 debug("%04x %02x\n", socket, reg, val);
139 writeb(val, socket->base + 0x800 + reg);
140 readb(socket->base + 0x800 + reg); /* PCI write posting... */
143 static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val)
145 debug("%04x %04x\n", socket, reg, val);
146 writeb(val, socket->base + 0x800 + reg);
147 writeb(val >> 8, socket->base + 0x800 + reg + 1);
149 /* PCI write posting... */
150 readb(socket->base + 0x800 + reg);
151 readb(socket->base + 0x800 + reg + 1);
154 static ssize_t show_yenta_registers(struct device *yentadev, struct device_attribute *attr, char *buf)
156 struct pci_dev *dev = to_pci_dev(yentadev);
157 struct yenta_socket *socket = pci_get_drvdata(dev);
158 int offset = 0, i;
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);
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);
179 val = exca_readb(socket, i);
180 offset += snprintf(buf + offset, PAGE_SIZE - offset, " %02x", val);
182 buf[offset++] = '\n';
183 return offset;
186 static DEVICE_ATTR(yenta_registers, S_IRUSR, show_yenta_registers, NULL);
189 * Ugh, mixed-mode cardbus and 16-bit pccard state: things depend
190 * on what kind of card is inserted..
192 static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value)
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);
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;
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;
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;
223 *value = val;
224 return 0;
227 static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
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);
236 /* i82365SL-DF style */
237 if (socket->flags & YENTA_16BIT_POWER_DF) {
238 switch (state->Vcc) {
239 case 33:
240 reg |= I365_VCC_3V;
241 break;
242 case 50:
243 reg |= I365_VCC_5V;
244 break;
245 default:
246 reg = 0;
247 break;
249 switch (state->Vpp) {
250 case 33:
251 case 50:
252 reg |= I365_VPP1_5V;
253 break;
254 case 120:
255 reg |= I365_VPP1_12V;
256 break;
258 } else {
259 /* i82365SL-B style */
260 switch (state->Vcc) {
261 case 50:
262 reg |= I365_VCC_5V;
263 break;
264 default:
265 reg = 0;
266 break;
268 switch (state->Vpp) {
269 case 50:
270 reg |= I365_VPP1_5V | I365_VPP2_5V;
271 break;
272 case 120:
273 reg |= I365_VPP1_12V | I365_VPP2_12V;
274 break;
278 if (reg != old)
279 exca_writeb(socket, I365_POWER, reg);
280 } else {
281 u32 reg = 0; /* CB_SC_STPCLK? */
282 switch (state->Vcc) {
283 case 33:
284 reg = CB_SC_VCC_3V;
285 break;
286 case 50:
287 reg = CB_SC_VCC_5V;
288 break;
289 default:
290 reg = 0;
291 break;
293 switch (state->Vpp) {
294 case 33:
295 reg |= CB_SC_VPP_3V;
296 break;
297 case 50:
298 reg |= CB_SC_VPP_5V;
299 break;
300 case 120:
301 reg |= CB_SC_VPP_12V;
302 break;
304 if (reg != cb_readl(socket, CB_SOCKET_CONTROL))
305 cb_writel(socket, CB_SOCKET_CONTROL, reg);
309 static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
311 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
312 u16 bridge;
314 /* if powering down: do it immediately */
315 if (state->Vcc == 0)
316 yenta_set_power(socket, state);
318 socket->io_irq = state->io_irq;
319 bridge = config_readw(socket, CB_BRIDGE_CONTROL) & ~(CB_BRIDGE_CRST | CB_BRIDGE_INTR);
320 if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) {
321 u8 intr;
322 bridge |= (state->flags & SS_RESET) ? CB_BRIDGE_CRST : 0;
324 /* ISA interrupt control? */
325 intr = exca_readb(socket, I365_INTCTL);
326 intr = (intr & ~0xf);
327 if (!socket->cb_irq) {
328 intr |= state->io_irq;
329 bridge |= CB_BRIDGE_INTR;
331 exca_writeb(socket, I365_INTCTL, intr);
332 } else {
333 u8 reg;
335 reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA);
336 reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET;
337 reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0;
338 if (state->io_irq != socket->cb_irq) {
339 reg |= state->io_irq;
340 bridge |= CB_BRIDGE_INTR;
342 exca_writeb(socket, I365_INTCTL, reg);
344 reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK);
345 reg |= I365_PWR_NORESET;
346 if (state->flags & SS_PWR_AUTO)
347 reg |= I365_PWR_AUTO;
348 if (state->flags & SS_OUTPUT_ENA)
349 reg |= I365_PWR_OUT;
350 if (exca_readb(socket, I365_POWER) != reg)
351 exca_writeb(socket, I365_POWER, reg);
353 /* CSC interrupt: no ISA irq for CSC */
354 reg = I365_CSC_DETECT;
355 if (state->flags & SS_IOCARD) {
356 if (state->csc_mask & SS_STSCHG)
357 reg |= I365_CSC_STSCHG;
358 } else {
359 if (state->csc_mask & SS_BATDEAD)
360 reg |= I365_CSC_BVD1;
361 if (state->csc_mask & SS_BATWARN)
362 reg |= I365_CSC_BVD2;
363 if (state->csc_mask & SS_READY)
364 reg |= I365_CSC_READY;
366 exca_writeb(socket, I365_CSCINT, reg);
367 exca_readb(socket, I365_CSC);
368 if (sock->zoom_video)
369 sock->zoom_video(sock, state->flags & SS_ZVCARD);
371 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
372 /* Socket event mask: get card insert/remove events.. */
373 cb_writel(socket, CB_SOCKET_EVENT, -1);
374 cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
376 /* if powering up: do it as the last step when the socket is configured */
377 if (state->Vcc != 0)
378 yenta_set_power(socket, state);
379 return 0;
382 static int yenta_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io)
384 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
385 int map;
386 unsigned char ioctl, addr, enable;
388 map = io->map;
390 if (map > 1)
391 return -EINVAL;
393 enable = I365_ENA_IO(map);
394 addr = exca_readb(socket, I365_ADDRWIN);
396 /* Disable the window before changing it.. */
397 if (addr & enable) {
398 addr &= ~enable;
399 exca_writeb(socket, I365_ADDRWIN, addr);
402 exca_writew(socket, I365_IO(map)+I365_W_START, io->start);
403 exca_writew(socket, I365_IO(map)+I365_W_STOP, io->stop);
405 ioctl = exca_readb(socket, I365_IOCTL) & ~I365_IOCTL_MASK(map);
406 if (io->flags & MAP_0WS)
407 ioctl |= I365_IOCTL_0WS(map);
408 if (io->flags & MAP_16BIT)
409 ioctl |= I365_IOCTL_16BIT(map);
410 if (io->flags & MAP_AUTOSZ)
411 ioctl |= I365_IOCTL_IOCS16(map);
412 exca_writeb(socket, I365_IOCTL, ioctl);
414 if (io->flags & MAP_ACTIVE)
415 exca_writeb(socket, I365_ADDRWIN, addr | enable);
416 return 0;
419 static int yenta_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *mem)
421 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
422 struct pci_bus_region region;
423 int map;
424 unsigned char addr, enable;
425 unsigned int start, stop, card_start;
426 unsigned short word;
428 pcibios_resource_to_bus(socket->dev, &region, mem->res);
430 map = mem->map;
431 start = region.start;
432 stop = region.end;
433 card_start = mem->card_start;
435 if (map > 4 || start > stop || ((start ^ stop) >> 24) ||
436 (card_start >> 26) || mem->speed > 1000)
437 return -EINVAL;
439 enable = I365_ENA_MEM(map);
440 addr = exca_readb(socket, I365_ADDRWIN);
441 if (addr & enable) {
442 addr &= ~enable;
443 exca_writeb(socket, I365_ADDRWIN, addr);
446 exca_writeb(socket, CB_MEM_PAGE(map), start >> 24);
448 word = (start >> 12) & 0x0fff;
449 if (mem->flags & MAP_16BIT)
450 word |= I365_MEM_16BIT;
451 if (mem->flags & MAP_0WS)
452 word |= I365_MEM_0WS;
453 exca_writew(socket, I365_MEM(map) + I365_W_START, word);
455 word = (stop >> 12) & 0x0fff;
456 switch (to_cycles(mem->speed)) {
457 case 0:
458 break;
459 case 1:
460 word |= I365_MEM_WS0;
461 break;
462 case 2:
463 word |= I365_MEM_WS1;
464 break;
465 default:
466 word |= I365_MEM_WS1 | I365_MEM_WS0;
467 break;
469 exca_writew(socket, I365_MEM(map) + I365_W_STOP, word);
471 word = ((card_start - start) >> 12) & 0x3fff;
472 if (mem->flags & MAP_WRPROT)
473 word |= I365_MEM_WRPROT;
474 if (mem->flags & MAP_ATTRIB)
475 word |= I365_MEM_REG;
476 exca_writew(socket, I365_MEM(map) + I365_W_OFF, word);
478 if (mem->flags & MAP_ACTIVE)
479 exca_writeb(socket, I365_ADDRWIN, addr | enable);
480 return 0;
485 static irqreturn_t yenta_interrupt(int irq, void *dev_id)
487 unsigned int events;
488 struct yenta_socket *socket = (struct yenta_socket *) dev_id;
489 u8 csc;
490 u32 cb_event;
492 /* Clear interrupt status for the event */
493 cb_event = cb_readl(socket, CB_SOCKET_EVENT);
494 cb_writel(socket, CB_SOCKET_EVENT, cb_event);
496 csc = exca_readb(socket, I365_CSC);
498 if (!(cb_event || csc))
499 return IRQ_NONE;
501 events = (cb_event & (CB_CD1EVENT | CB_CD2EVENT)) ? SS_DETECT : 0 ;
502 events |= (csc & I365_CSC_DETECT) ? SS_DETECT : 0;
503 if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) {
504 events |= (csc & I365_CSC_STSCHG) ? SS_STSCHG : 0;
505 } else {
506 events |= (csc & I365_CSC_BVD1) ? SS_BATDEAD : 0;
507 events |= (csc & I365_CSC_BVD2) ? SS_BATWARN : 0;
508 events |= (csc & I365_CSC_READY) ? SS_READY : 0;
511 if (events)
512 pcmcia_parse_events(&socket->socket, events);
514 return IRQ_HANDLED;
517 static void yenta_interrupt_wrapper(unsigned long data)
519 struct yenta_socket *socket = (struct yenta_socket *) data;
521 yenta_interrupt(0, (void *)socket);
522 socket->poll_timer.expires = jiffies + HZ;
523 add_timer(&socket->poll_timer);
526 static void yenta_clear_maps(struct yenta_socket *socket)
528 int i;
529 struct resource res = { .start = 0, .end = 0x0fff };
530 pccard_io_map io = { 0, 0, 0, 0, 1 };
531 pccard_mem_map mem = { .res = &res, };
533 yenta_set_socket(&socket->socket, &dead_socket);
534 for (i = 0; i < 2; i++) {
535 io.map = i;
536 yenta_set_io_map(&socket->socket, &io);
538 for (i = 0; i < 5; i++) {
539 mem.map = i;
540 yenta_set_mem_map(&socket->socket, &mem);
544 /* redoes voltage interrogation if required */
545 static void yenta_interrogate(struct yenta_socket *socket)
547 u32 state;
549 state = cb_readl(socket, CB_SOCKET_STATE);
550 if (!(state & (CB_5VCARD | CB_3VCARD | CB_XVCARD | CB_YVCARD)) ||
551 (state & (CB_CDETECT1 | CB_CDETECT2 | CB_NOTACARD | CB_BADVCCREQ)) ||
552 ((state & (CB_16BITCARD | CB_CBCARD)) == (CB_16BITCARD | CB_CBCARD)))
553 cb_writel(socket, CB_SOCKET_FORCE, CB_CVSTEST);
556 /* Called at resume and initialization events */
557 static int yenta_sock_init(struct pcmcia_socket *sock)
559 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
561 exca_writeb(socket, I365_GBLCTL, 0x00);
562 exca_writeb(socket, I365_GENCTL, 0x00);
564 /* Redo card voltage interrogation */
565 yenta_interrogate(socket);
567 yenta_clear_maps(socket);
569 if (socket->type && socket->type->sock_init)
570 socket->type->sock_init(socket);
572 /* Re-enable CSC interrupts */
573 cb_writel(socket, CB_SOCKET_MASK, CB_CDMASK);
575 return 0;
578 static int yenta_sock_suspend(struct pcmcia_socket *sock)
580 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
582 /* Disable CSC interrupts */
583 cb_writel(socket, CB_SOCKET_MASK, 0x0);
585 return 0;
589 * Use an adaptive allocation for the memory resource,
590 * sometimes the memory behind pci bridges is limited:
591 * 1/8 of the size of the io window of the parent.
592 * max 4 MB, min 16 kB. We try very hard to not get below
593 * the "ACC" values, though.
595 #define BRIDGE_MEM_MAX (4*1024*1024)
596 #define BRIDGE_MEM_ACC (128*1024)
597 #define BRIDGE_MEM_MIN (16*1024)
599 #define BRIDGE_IO_MAX 512
600 #define BRIDGE_IO_ACC 256
601 #define BRIDGE_IO_MIN 32
603 #ifndef PCIBIOS_MIN_CARDBUS_IO
604 #define PCIBIOS_MIN_CARDBUS_IO PCIBIOS_MIN_IO
605 #endif
607 static int yenta_search_one_res(struct resource *root, struct resource *res,
608 u32 min)
610 u32 align, size, start, end;
612 if (res->flags & IORESOURCE_IO) {
613 align = 1024;
614 size = BRIDGE_IO_MAX;
615 start = PCIBIOS_MIN_CARDBUS_IO;
616 end = ~0U;
617 } else {
618 unsigned long avail = root->end - root->start;
619 int i;
620 size = BRIDGE_MEM_MAX;
621 if (size > avail/8) {
622 size = (avail+1)/8;
623 /* round size down to next power of 2 */
624 i = 0;
625 while ((size /= 2) != 0)
626 i++;
627 size = 1 << i;
629 if (size < min)
630 size = min;
631 align = size;
632 start = PCIBIOS_MIN_MEM;
633 end = ~0U;
636 do {
637 if (allocate_resource(root, res, size, start, end, align,
638 NULL, NULL) == 0) {
639 return 1;
641 size = size/2;
642 align = size;
643 } while (size >= min);
645 return 0;
649 static int yenta_search_res(struct yenta_socket *socket, struct resource *res,
650 u32 min)
652 int i;
653 for (i = 0; i < PCI_BUS_NUM_RESOURCES; i++) {
654 struct resource *root = socket->dev->bus->resource[i];
655 if (!root)
656 continue;
658 if ((res->flags ^ root->flags) &
659 (IORESOURCE_IO | IORESOURCE_MEM | IORESOURCE_PREFETCH))
660 continue; /* Wrong type */
662 if (yenta_search_one_res(root, res, min))
663 return 1;
665 return 0;
668 static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type, int addr_start, int addr_end)
670 struct pci_dev *dev = socket->dev;
671 struct resource *res;
672 struct pci_bus_region region;
673 unsigned mask;
675 res = dev->resource + PCI_BRIDGE_RESOURCES + nr;
676 /* Already allocated? */
677 if (res->parent)
678 return 0;
680 /* The granularity of the memory limit is 4kB, on IO it's 4 bytes */
681 mask = ~0xfff;
682 if (type & IORESOURCE_IO)
683 mask = ~3;
685 res->name = dev->subordinate->name;
686 res->flags = type;
688 region.start = config_readl(socket, addr_start) & mask;
689 region.end = config_readl(socket, addr_end) | ~mask;
690 if (region.start && region.end > region.start && !override_bios) {
691 pcibios_bus_to_resource(dev, res, &region);
692 if (pci_claim_resource(dev, PCI_BRIDGE_RESOURCES + nr) == 0)
693 return 0;
694 dev_printk(KERN_INFO, &dev->dev,
695 "Preassigned resource %d busy or not available, "
696 "reconfiguring...\n",
697 nr);
700 if (type & IORESOURCE_IO) {
701 if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) ||
702 (yenta_search_res(socket, res, BRIDGE_IO_ACC)) ||
703 (yenta_search_res(socket, res, BRIDGE_IO_MIN)))
704 return 1;
705 } else {
706 if (type & IORESOURCE_PREFETCH) {
707 if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
708 (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
709 (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
710 return 1;
711 /* Approximating prefetchable by non-prefetchable */
712 res->flags = IORESOURCE_MEM;
714 if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
715 (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
716 (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
717 return 1;
720 dev_printk(KERN_INFO, &dev->dev,
721 "no resource of type %x available, trying to continue...\n",
722 type);
723 res->start = res->end = res->flags = 0;
724 return 0;
728 * Allocate the bridge mappings for the device..
730 static void yenta_allocate_resources(struct yenta_socket *socket)
732 int program = 0;
733 program += yenta_allocate_res(socket, 0, IORESOURCE_IO,
734 PCI_CB_IO_BASE_0, PCI_CB_IO_LIMIT_0);
735 program += yenta_allocate_res(socket, 1, IORESOURCE_IO,
736 PCI_CB_IO_BASE_1, PCI_CB_IO_LIMIT_1);
737 program += yenta_allocate_res(socket, 2, IORESOURCE_MEM|IORESOURCE_PREFETCH,
738 PCI_CB_MEMORY_BASE_0, PCI_CB_MEMORY_LIMIT_0);
739 program += yenta_allocate_res(socket, 3, IORESOURCE_MEM,
740 PCI_CB_MEMORY_BASE_1, PCI_CB_MEMORY_LIMIT_1);
741 if (program)
742 pci_setup_cardbus(socket->dev->subordinate);
747 * Free the bridge mappings for the device..
749 static void yenta_free_resources(struct yenta_socket *socket)
751 int i;
752 for (i = 0; i < 4; i++) {
753 struct resource *res;
754 res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i;
755 if (res->start != 0 && res->end != 0)
756 release_resource(res);
757 res->start = res->end = res->flags = 0;
763 * Close it down - release our resources and go home..
765 static void __devexit yenta_close(struct pci_dev *dev)
767 struct yenta_socket *sock = pci_get_drvdata(dev);
769 /* Remove the register attributes */
770 device_remove_file(&dev->dev, &dev_attr_yenta_registers);
772 /* we don't want a dying socket registered */
773 pcmcia_unregister_socket(&sock->socket);
775 /* Disable all events so we don't die in an IRQ storm */
776 cb_writel(sock, CB_SOCKET_MASK, 0x0);
777 exca_writeb(sock, I365_CSCINT, 0);
779 if (sock->cb_irq)
780 free_irq(sock->cb_irq, sock);
781 else
782 del_timer_sync(&sock->poll_timer);
784 if (sock->base)
785 iounmap(sock->base);
786 yenta_free_resources(sock);
788 pci_release_regions(dev);
789 pci_disable_device(dev);
790 pci_set_drvdata(dev, NULL);
794 static struct pccard_operations yenta_socket_operations = {
795 .init = yenta_sock_init,
796 .suspend = yenta_sock_suspend,
797 .get_status = yenta_get_status,
798 .set_socket = yenta_set_socket,
799 .set_io_map = yenta_set_io_map,
800 .set_mem_map = yenta_set_mem_map,
804 #ifdef CONFIG_YENTA_TI
805 #include "ti113x.h"
806 #endif
807 #ifdef CONFIG_YENTA_RICOH
808 #include "ricoh.h"
809 #endif
810 #ifdef CONFIG_YENTA_TOSHIBA
811 #include "topic.h"
812 #endif
813 #ifdef CONFIG_YENTA_O2
814 #include "o2micro.h"
815 #endif
817 enum {
818 CARDBUS_TYPE_DEFAULT = -1,
819 CARDBUS_TYPE_TI,
820 CARDBUS_TYPE_TI113X,
821 CARDBUS_TYPE_TI12XX,
822 CARDBUS_TYPE_TI1250,
823 CARDBUS_TYPE_RICOH,
824 CARDBUS_TYPE_TOPIC95,
825 CARDBUS_TYPE_TOPIC97,
826 CARDBUS_TYPE_O2MICRO,
827 CARDBUS_TYPE_ENE,
831 * Different cardbus controllers have slightly different
832 * initialization sequences etc details. List them here..
834 static struct cardbus_type cardbus_type[] = {
835 #ifdef CONFIG_YENTA_TI
836 [CARDBUS_TYPE_TI] = {
837 .override = ti_override,
838 .save_state = ti_save_state,
839 .restore_state = ti_restore_state,
840 .sock_init = ti_init,
842 [CARDBUS_TYPE_TI113X] = {
843 .override = ti113x_override,
844 .save_state = ti_save_state,
845 .restore_state = ti_restore_state,
846 .sock_init = ti_init,
848 [CARDBUS_TYPE_TI12XX] = {
849 .override = ti12xx_override,
850 .save_state = ti_save_state,
851 .restore_state = ti_restore_state,
852 .sock_init = ti_init,
854 [CARDBUS_TYPE_TI1250] = {
855 .override = ti1250_override,
856 .save_state = ti_save_state,
857 .restore_state = ti_restore_state,
858 .sock_init = ti_init,
860 #endif
861 #ifdef CONFIG_YENTA_RICOH
862 [CARDBUS_TYPE_RICOH] = {
863 .override = ricoh_override,
864 .save_state = ricoh_save_state,
865 .restore_state = ricoh_restore_state,
867 #endif
868 #ifdef CONFIG_YENTA_TOSHIBA
869 [CARDBUS_TYPE_TOPIC95] = {
870 .override = topic95_override,
872 [CARDBUS_TYPE_TOPIC97] = {
873 .override = topic97_override,
875 #endif
876 #ifdef CONFIG_YENTA_O2
877 [CARDBUS_TYPE_O2MICRO] = {
878 .override = o2micro_override,
879 .restore_state = o2micro_restore_state,
881 #endif
882 #ifdef CONFIG_YENTA_TI
883 [CARDBUS_TYPE_ENE] = {
884 .override = ene_override,
885 .save_state = ti_save_state,
886 .restore_state = ti_restore_state,
887 .sock_init = ti_init,
889 #endif
894 * Only probe "regular" interrupts, don't
895 * touch dangerous spots like the mouse irq,
896 * because there are mice that apparently
897 * get really confused if they get fondled
898 * too intimately.
900 * Default to 11, 10, 9, 7, 6, 5, 4, 3.
902 static u32 isa_interrupts = 0x0ef8;
904 static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mask)
906 int i;
907 unsigned long val;
908 u32 mask;
911 * Probe for usable interrupts using the force
912 * register to generate bogus card status events.
914 cb_writel(socket, CB_SOCKET_EVENT, -1);
915 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
916 exca_writeb(socket, I365_CSCINT, 0);
917 val = probe_irq_on() & isa_irq_mask;
918 for (i = 1; i < 16; i++) {
919 if (!((val >> i) & 1))
920 continue;
921 exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG | (i << 4));
922 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
923 udelay(100);
924 cb_writel(socket, CB_SOCKET_EVENT, -1);
926 cb_writel(socket, CB_SOCKET_MASK, 0);
927 exca_writeb(socket, I365_CSCINT, 0);
929 mask = probe_irq_mask(val) & 0xffff;
931 return mask;
936 * yenta PCI irq probing.
937 * currently only used in the TI/EnE initialization code
939 #ifdef CONFIG_YENTA_TI
941 /* interrupt handler, only used during probing */
942 static irqreturn_t yenta_probe_handler(int irq, void *dev_id)
944 struct yenta_socket *socket = (struct yenta_socket *) dev_id;
945 u8 csc;
946 u32 cb_event;
948 /* Clear interrupt status for the event */
949 cb_event = cb_readl(socket, CB_SOCKET_EVENT);
950 cb_writel(socket, CB_SOCKET_EVENT, -1);
951 csc = exca_readb(socket, I365_CSC);
953 if (cb_event || csc) {
954 socket->probe_status = 1;
955 return IRQ_HANDLED;
958 return IRQ_NONE;
961 /* probes the PCI interrupt, use only on override functions */
962 static int yenta_probe_cb_irq(struct yenta_socket *socket)
964 if (!socket->cb_irq)
965 return -1;
967 socket->probe_status = 0;
969 if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) {
970 dev_printk(KERN_WARNING, &socket->dev->dev,
971 "request_irq() in yenta_probe_cb_irq() failed!\n");
972 return -1;
975 /* generate interrupt, wait */
976 exca_writeb(socket, I365_CSCINT, I365_CSC_STSCHG);
977 cb_writel(socket, CB_SOCKET_EVENT, -1);
978 cb_writel(socket, CB_SOCKET_MASK, CB_CSTSMASK);
979 cb_writel(socket, CB_SOCKET_FORCE, CB_FCARDSTS);
981 msleep(100);
983 /* disable interrupts */
984 cb_writel(socket, CB_SOCKET_MASK, 0);
985 exca_writeb(socket, I365_CSCINT, 0);
986 cb_writel(socket, CB_SOCKET_EVENT, -1);
987 exca_readb(socket, I365_CSC);
989 free_irq(socket->cb_irq, socket);
991 return (int) socket->probe_status;
994 #endif /* CONFIG_YENTA_TI */
998 * Set static data that doesn't need re-initializing..
1000 static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_irq_mask)
1002 socket->socket.pci_irq = socket->cb_irq;
1003 if (isa_probe)
1004 socket->socket.irq_mask = yenta_probe_irq(socket, isa_irq_mask);
1005 else
1006 socket->socket.irq_mask = 0;
1008 dev_printk(KERN_INFO, &socket->dev->dev,
1009 "ISA IRQ mask 0x%04x, PCI irq %d\n",
1010 socket->socket.irq_mask, socket->cb_irq);
1014 * Initialize the standard cardbus registers
1016 static void yenta_config_init(struct yenta_socket *socket)
1018 u16 bridge;
1019 struct pci_dev *dev = socket->dev;
1020 struct pci_bus_region region;
1022 pcibios_resource_to_bus(socket->dev, &region, &dev->resource[0]);
1024 config_writel(socket, CB_LEGACY_MODE_BASE, 0);
1025 config_writel(socket, PCI_BASE_ADDRESS_0, region.start);
1026 config_writew(socket, PCI_COMMAND,
1027 PCI_COMMAND_IO |
1028 PCI_COMMAND_MEMORY |
1029 PCI_COMMAND_MASTER |
1030 PCI_COMMAND_WAIT);
1032 /* MAGIC NUMBERS! Fixme */
1033 config_writeb(socket, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4);
1034 config_writeb(socket, PCI_LATENCY_TIMER, 168);
1035 config_writel(socket, PCI_PRIMARY_BUS,
1036 (176 << 24) | /* sec. latency timer */
1037 (dev->subordinate->subordinate << 16) | /* subordinate bus */
1038 (dev->subordinate->secondary << 8) | /* secondary bus */
1039 dev->subordinate->primary); /* primary bus */
1042 * Set up the bridging state:
1043 * - enable write posting.
1044 * - memory window 0 prefetchable, window 1 non-prefetchable
1045 * - PCI interrupts enabled if a PCI interrupt exists..
1047 bridge = config_readw(socket, CB_BRIDGE_CONTROL);
1048 bridge &= ~(CB_BRIDGE_CRST | CB_BRIDGE_PREFETCH1 | CB_BRIDGE_ISAEN | CB_BRIDGE_VGAEN);
1049 bridge |= CB_BRIDGE_PREFETCH0 | CB_BRIDGE_POSTEN;
1050 config_writew(socket, CB_BRIDGE_CONTROL, bridge);
1054 * yenta_fixup_parent_bridge - Fix subordinate bus# of the parent bridge
1055 * @cardbus_bridge: The PCI bus which the CardBus bridge bridges to
1057 * Checks if devices on the bus which the CardBus bridge bridges to would be
1058 * invisible during PCI scans because of a misconfigured subordinate number
1059 * of the parent brige - some BIOSes seem to be too lazy to set it right.
1060 * Does the fixup carefully by checking how far it can go without conflicts.
1061 * See http\://bugzilla.kernel.org/show_bug.cgi?id=2944 for more information.
1063 static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
1065 struct list_head *tmp;
1066 unsigned char upper_limit;
1068 * We only check and fix the parent bridge: All systems which need
1069 * this fixup that have been reviewed are laptops and the only bridge
1070 * which needed fixing was the parent bridge of the CardBus bridge:
1072 struct pci_bus *bridge_to_fix = cardbus_bridge->parent;
1074 /* Check bus numbers are already set up correctly: */
1075 if (bridge_to_fix->subordinate >= cardbus_bridge->subordinate)
1076 return; /* The subordinate number is ok, nothing to do */
1078 if (!bridge_to_fix->parent)
1079 return; /* Root bridges are ok */
1081 /* stay within the limits of the bus range of the parent: */
1082 upper_limit = bridge_to_fix->parent->subordinate;
1084 /* check the bus ranges of all silbling bridges to prevent overlap */
1085 list_for_each(tmp, &bridge_to_fix->parent->children) {
1086 struct pci_bus *silbling = pci_bus_b(tmp);
1088 * If the silbling has a higher secondary bus number
1089 * and it's secondary is equal or smaller than our
1090 * current upper limit, set the new upper limit to
1091 * the bus number below the silbling's range:
1093 if (silbling->secondary > bridge_to_fix->subordinate
1094 && silbling->secondary <= upper_limit)
1095 upper_limit = silbling->secondary - 1;
1098 /* Show that the wanted subordinate number is not possible: */
1099 if (cardbus_bridge->subordinate > upper_limit)
1100 dev_printk(KERN_WARNING, &cardbus_bridge->dev,
1101 "Upper limit for fixing this "
1102 "bridge's parent bridge: #%02x\n", upper_limit);
1104 /* If we have room to increase the bridge's subordinate number, */
1105 if (bridge_to_fix->subordinate < upper_limit) {
1107 /* use the highest number of the hidden bus, within limits */
1108 unsigned char subordinate_to_assign =
1109 min(cardbus_bridge->subordinate, upper_limit);
1111 dev_printk(KERN_INFO, &bridge_to_fix->dev,
1112 "Raising subordinate bus# of parent "
1113 "bus (#%02x) from #%02x to #%02x\n",
1114 bridge_to_fix->number,
1115 bridge_to_fix->subordinate, subordinate_to_assign);
1117 /* Save the new subordinate in the bus struct of the bridge */
1118 bridge_to_fix->subordinate = subordinate_to_assign;
1120 /* and update the PCI config space with the new subordinate */
1121 pci_write_config_byte(bridge_to_fix->self,
1122 PCI_SUBORDINATE_BUS, bridge_to_fix->subordinate);
1127 * Initialize a cardbus controller. Make sure we have a usable
1128 * interrupt, and that we can map the cardbus area. Fill in the
1129 * socket information structure..
1131 static int __devinit yenta_probe(struct pci_dev *dev, const struct pci_device_id *id)
1133 struct yenta_socket *socket;
1134 int ret;
1137 * If we failed to assign proper bus numbers for this cardbus
1138 * controller during PCI probe, its subordinate pci_bus is NULL.
1139 * Bail out if so.
1141 if (!dev->subordinate) {
1142 dev_printk(KERN_ERR, &dev->dev, "no bus associated! "
1143 "(try 'pci=assign-busses')\n");
1144 return -ENODEV;
1147 socket = kzalloc(sizeof(struct yenta_socket), GFP_KERNEL);
1148 if (!socket)
1149 return -ENOMEM;
1151 /* prepare pcmcia_socket */
1152 socket->socket.ops = &yenta_socket_operations;
1153 socket->socket.resource_ops = &pccard_nonstatic_ops;
1154 socket->socket.dev.parent = &dev->dev;
1155 socket->socket.driver_data = socket;
1156 socket->socket.owner = THIS_MODULE;
1157 socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD;
1158 socket->socket.map_size = 0x1000;
1159 socket->socket.cb_dev = dev;
1161 /* prepare struct yenta_socket */
1162 socket->dev = dev;
1163 pci_set_drvdata(dev, socket);
1166 * Do some basic sanity checking..
1168 if (pci_enable_device(dev)) {
1169 ret = -EBUSY;
1170 goto free;
1173 ret = pci_request_regions(dev, "yenta_socket");
1174 if (ret)
1175 goto disable;
1177 if (!pci_resource_start(dev, 0)) {
1178 dev_printk(KERN_ERR, &dev->dev, "No cardbus resource!\n");
1179 ret = -ENODEV;
1180 goto release;
1184 * Ok, start setup.. Map the cardbus registers,
1185 * and request the IRQ.
1187 socket->base = ioremap(pci_resource_start(dev, 0), 0x1000);
1188 if (!socket->base) {
1189 ret = -ENOMEM;
1190 goto release;
1194 * report the subsystem vendor and device for help debugging
1195 * the irq stuff...
1197 dev_printk(KERN_INFO, &dev->dev, "CardBus bridge found [%04x:%04x]\n",
1198 dev->subsystem_vendor, dev->subsystem_device);
1200 yenta_config_init(socket);
1202 /* Disable all events */
1203 cb_writel(socket, CB_SOCKET_MASK, 0x0);
1205 /* Set up the bridge regions.. */
1206 yenta_allocate_resources(socket);
1208 socket->cb_irq = dev->irq;
1210 /* Do we have special options for the device? */
1211 if (id->driver_data != CARDBUS_TYPE_DEFAULT &&
1212 id->driver_data < ARRAY_SIZE(cardbus_type)) {
1213 socket->type = &cardbus_type[id->driver_data];
1215 ret = socket->type->override(socket);
1216 if (ret < 0)
1217 goto unmap;
1220 /* We must finish initialization here */
1222 if (!socket->cb_irq || request_irq(socket->cb_irq, yenta_interrupt, IRQF_SHARED, "yenta", socket)) {
1223 /* No IRQ or request_irq failed. Poll */
1224 socket->cb_irq = 0; /* But zero is a valid IRQ number. */
1225 init_timer(&socket->poll_timer);
1226 socket->poll_timer.function = yenta_interrupt_wrapper;
1227 socket->poll_timer.data = (unsigned long)socket;
1228 socket->poll_timer.expires = jiffies + HZ;
1229 add_timer(&socket->poll_timer);
1230 dev_printk(KERN_INFO, &dev->dev,
1231 "no PCI IRQ, CardBus support disabled for this "
1232 "socket.\n");
1233 dev_printk(KERN_INFO, &dev->dev,
1234 "check your BIOS CardBus, BIOS IRQ or ACPI "
1235 "settings.\n");
1236 } else {
1237 socket->socket.features |= SS_CAP_CARDBUS;
1240 /* Figure out what the dang thing can do for the PCMCIA layer... */
1241 yenta_interrogate(socket);
1242 yenta_get_socket_capabilities(socket, isa_interrupts);
1243 dev_printk(KERN_INFO, &dev->dev,
1244 "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
1246 yenta_fixup_parent_bridge(dev->subordinate);
1248 /* Register it with the pcmcia layer.. */
1249 ret = pcmcia_register_socket(&socket->socket);
1250 if (ret == 0) {
1251 /* Add the yenta register attributes */
1252 ret = device_create_file(&dev->dev, &dev_attr_yenta_registers);
1253 if (ret == 0)
1254 goto out;
1256 /* error path... */
1257 pcmcia_unregister_socket(&socket->socket);
1260 unmap:
1261 iounmap(socket->base);
1262 release:
1263 pci_release_regions(dev);
1264 disable:
1265 pci_disable_device(dev);
1266 free:
1267 kfree(socket);
1268 out:
1269 return ret;
1272 #ifdef CONFIG_PM
1273 static int yenta_dev_suspend_noirq(struct device *dev)
1275 struct pci_dev *pdev = to_pci_dev(dev);
1276 struct yenta_socket *socket = pci_get_drvdata(pdev);
1277 int ret;
1279 ret = pcmcia_socket_dev_suspend(dev);
1281 if (!socket)
1282 return ret;
1284 if (socket->type && socket->type->save_state)
1285 socket->type->save_state(socket);
1287 pci_save_state(pdev);
1288 pci_read_config_dword(pdev, 16*4, &socket->saved_state[0]);
1289 pci_read_config_dword(pdev, 17*4, &socket->saved_state[1]);
1290 pci_disable_device(pdev);
1293 * Some laptops (IBM T22) do not like us putting the Cardbus
1294 * bridge into D3. At a guess, some other laptop will
1295 * probably require this, so leave it commented out for now.
1297 /* pci_set_power_state(dev, 3); */
1299 return ret;
1302 static int yenta_dev_resume_noirq(struct device *dev)
1304 struct pci_dev *pdev = to_pci_dev(dev);
1305 struct yenta_socket *socket = pci_get_drvdata(pdev);
1306 int ret;
1308 if (!socket)
1309 return 0;
1311 pci_write_config_dword(pdev, 16*4, socket->saved_state[0]);
1312 pci_write_config_dword(pdev, 17*4, socket->saved_state[1]);
1314 ret = pci_enable_device(pdev);
1315 if (ret)
1316 return ret;
1318 pci_set_master(pdev);
1320 if (socket->type && socket->type->restore_state)
1321 socket->type->restore_state(socket);
1323 pcmcia_socket_dev_early_resume(dev);
1324 return 0;
1327 static int yenta_dev_resume(struct device *dev)
1329 pcmcia_socket_dev_late_resume(dev);
1330 return 0;
1333 static const struct dev_pm_ops yenta_pm_ops = {
1334 .suspend_noirq = yenta_dev_suspend_noirq,
1335 .resume_noirq = yenta_dev_resume_noirq,
1336 .resume = yenta_dev_resume,
1337 .freeze_noirq = yenta_dev_suspend_noirq,
1338 .thaw_noirq = yenta_dev_resume_noirq,
1339 .thaw = yenta_dev_resume,
1340 .poweroff_noirq = yenta_dev_suspend_noirq,
1341 .restore_noirq = yenta_dev_resume_noirq,
1342 .restore = yenta_dev_resume,
1345 #define YENTA_PM_OPS (&yenta_pm_ops)
1346 #else
1347 #define YENTA_PM_OPS NULL
1348 #endif
1350 #define CB_ID(vend, dev, type) \
1352 .vendor = vend, \
1353 .device = dev, \
1354 .subvendor = PCI_ANY_ID, \
1355 .subdevice = PCI_ANY_ID, \
1356 .class = PCI_CLASS_BRIDGE_CARDBUS << 8, \
1357 .class_mask = ~0, \
1358 .driver_data = CARDBUS_TYPE_##type, \
1361 static struct pci_device_id yenta_table[] = {
1362 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1031, TI),
1365 * TBD: Check if these TI variants can use more
1366 * advanced overrides instead. (I can't get the
1367 * data sheets for these devices. --rmk)
1369 #ifdef CONFIG_YENTA_TI
1370 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI),
1372 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X),
1373 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1131, TI113X),
1375 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1211, TI12XX),
1376 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1220, TI12XX),
1377 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1221, TI12XX),
1378 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1225, TI12XX),
1379 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251A, TI12XX),
1380 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1251B, TI12XX),
1381 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420, TI12XX),
1382 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1450, TI12XX),
1383 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1451A, TI12XX),
1384 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1510, TI12XX),
1385 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520, TI12XX),
1386 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1620, TI12XX),
1387 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4410, TI12XX),
1388 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4450, TI12XX),
1389 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4451, TI12XX),
1390 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4510, TI12XX),
1391 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_4520, TI12XX),
1393 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1250, TI1250),
1394 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1410, TI1250),
1396 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11, TI12XX),
1397 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X515, TI12XX),
1398 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12, TI12XX),
1399 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X420, TI12XX),
1400 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_X620, TI12XX),
1401 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7410, TI12XX),
1402 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7510, TI12XX),
1403 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_7610, TI12XX),
1405 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_710, TI12XX),
1406 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_712, TI12XX),
1407 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_720, TI12XX),
1408 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_722, TI12XX),
1409 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1211, ENE),
1410 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE),
1411 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE),
1412 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE),
1413 #endif /* CONFIG_YENTA_TI */
1415 #ifdef CONFIG_YENTA_RICOH
1416 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
1417 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),
1418 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH),
1419 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH),
1420 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH),
1421 #endif
1423 #ifdef CONFIG_YENTA_TOSHIBA
1424 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC95, TOPIC95),
1425 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97),
1426 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97),
1427 #endif
1429 #ifdef CONFIG_YENTA_O2
1430 CB_ID(PCI_VENDOR_ID_O2, PCI_ANY_ID, O2MICRO),
1431 #endif
1433 /* match any cardbus bridge */
1434 CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT),
1435 { /* all zeroes */ }
1437 MODULE_DEVICE_TABLE(pci, yenta_table);
1440 static struct pci_driver yenta_cardbus_driver = {
1441 .name = "yenta_cardbus",
1442 .id_table = yenta_table,
1443 .probe = yenta_probe,
1444 .remove = __devexit_p(yenta_close),
1445 .driver.pm = YENTA_PM_OPS,
1449 static int __init yenta_socket_init(void)
1451 return pci_register_driver(&yenta_cardbus_driver);
1455 static void __exit yenta_socket_exit(void)
1457 pci_unregister_driver(&yenta_cardbus_driver);
1461 module_init(yenta_socket_init);
1462 module_exit(yenta_socket_exit);
1464 MODULE_LICENSE("GPL");