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