blob: a6ef18259da033ea7a9d6426f53575de1a35e027 [file] [log] [blame]
Alex Dubov4020f2d2006-10-04 02:15:37 -07001/*
2 * tifm_7xx1.c - TI FlashMedia driver
3 *
4 * Copyright (C) 2006 Alex Dubov <oakad@yahoo.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/tifm.h>
Andrew Mortonc4030692007-04-28 14:21:10 +020013#include <linux/dma-mapping.h>
Alex Dubov4020f2d2006-10-04 02:15:37 -070014
15#define DRIVER_NAME "tifm_7xx1"
Alex Dubov4552f0c2007-04-12 16:59:12 +100016#define DRIVER_VERSION "0.8"
17
18#define TIFM_IRQ_ENABLE 0x80000000
19#define TIFM_IRQ_SOCKMASK(x) (x)
20#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
21#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
22#define TIFM_IRQ_SETALL 0xffffffff
Alex Dubov4020f2d2006-10-04 02:15:37 -070023
Alex Dubov6113ed72007-04-12 16:59:17 +100024static void tifm_7xx1_dummy_eject(struct tifm_adapter *fm,
25 struct tifm_dev *sock)
26{
27}
28
Alex Dubov4020f2d2006-10-04 02:15:37 -070029static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
30{
Alex Dubov4020f2d2006-10-04 02:15:37 -070031 unsigned long flags;
32
33 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov7146f0d2006-12-18 14:20:06 +110034 fm->socket_change_set |= 1 << sock->socket_id;
Alex Dubov3540af82007-04-12 16:59:15 +100035 tifm_queue_work(&fm->media_switcher);
Alex Dubov4020f2d2006-10-04 02:15:37 -070036 spin_unlock_irqrestore(&fm->lock, flags);
37}
38
David Howells7d12e782006-10-05 14:55:46 +010039static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
Alex Dubov4020f2d2006-10-04 02:15:37 -070040{
41 struct tifm_adapter *fm = dev_id;
Alex Dubov217334d2006-12-11 01:55:31 +110042 struct tifm_dev *sock;
Alex Dubov91f8d012007-04-12 17:05:26 +100043 unsigned int irq_status, cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -070044
45 spin_lock(&fm->lock);
46 irq_status = readl(fm->addr + FM_INTERRUPT_STATUS);
47 if (irq_status == 0 || irq_status == (~0)) {
48 spin_unlock(&fm->lock);
49 return IRQ_NONE;
50 }
51
52 if (irq_status & TIFM_IRQ_ENABLE) {
53 writel(TIFM_IRQ_ENABLE, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
54
Alex Dubov8b40ada2006-12-11 01:55:36 +110055 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
Alex Dubov217334d2006-12-11 01:55:31 +110056 sock = fm->sockets[cnt];
Alex Dubov4552f0c2007-04-12 16:59:12 +100057 if (sock) {
58 if ((irq_status >> cnt) & TIFM_IRQ_FIFOMASK(1))
59 sock->data_event(sock);
60 if ((irq_status >> cnt) & TIFM_IRQ_CARDMASK(1))
61 sock->card_event(sock);
62 }
Alex Dubov4020f2d2006-10-04 02:15:37 -070063 }
Alex Dubov6412d922006-12-11 01:55:33 +110064
Alex Dubov8b40ada2006-12-11 01:55:36 +110065 fm->socket_change_set |= irq_status
66 & ((1 << fm->num_sockets) - 1);
Alex Dubov4020f2d2006-10-04 02:15:37 -070067 }
68 writel(irq_status, fm->addr + FM_INTERRUPT_STATUS);
69
Alex Dubov3540af82007-04-12 16:59:15 +100070 if (fm->finish_me)
71 complete_all(fm->finish_me);
72 else if (!fm->socket_change_set)
Alex Dubov7146f0d2006-12-18 14:20:06 +110073 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
74 else
Alex Dubov3540af82007-04-12 16:59:15 +100075 tifm_queue_work(&fm->media_switcher);
Alex Dubov4020f2d2006-10-04 02:15:37 -070076
77 spin_unlock(&fm->lock);
78 return IRQ_HANDLED;
79}
80
Alex Dubov342c0ec2007-04-12 16:59:16 +100081static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr)
Alex Dubov4020f2d2006-10-04 02:15:37 -070082{
83 unsigned int s_state;
84 int cnt;
85
86 writel(0x0e00, sock_addr + SOCK_CONTROL);
87
Alex Dubov342c0ec2007-04-12 16:59:16 +100088 for (cnt = 16; cnt <= 256; cnt <<= 1) {
Alex Dubov8b40ada2006-12-11 01:55:36 +110089 if (!(TIFM_SOCK_STATE_POWERED
90 & readl(sock_addr + SOCK_PRESENT_STATE)))
Alex Dubov4020f2d2006-10-04 02:15:37 -070091 break;
Alex Dubov342c0ec2007-04-12 16:59:16 +100092
93 msleep(cnt);
Alex Dubov4020f2d2006-10-04 02:15:37 -070094 }
95
96 s_state = readl(sock_addr + SOCK_PRESENT_STATE);
97 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state))
Alex Dubove23f2b82007-04-12 16:59:14 +100098 return 0;
Alex Dubov4020f2d2006-10-04 02:15:37 -070099
Alex Dubov342c0ec2007-04-12 16:59:16 +1000100 writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
101 sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700102
Alex Dubov342c0ec2007-04-12 16:59:16 +1000103 /* xd needs some extra time before power on */
104 if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7)
105 == TIFM_TYPE_XD)
106 msleep(40);
107
Alex Dubov055b8222007-05-01 20:14:55 -0700108 writel((s_state & TIFM_CTRL_POWER_MASK) | 0x0c00,
109 sock_addr + SOCK_CONTROL);
Alex Dubov342c0ec2007-04-12 16:59:16 +1000110 /* wait for power to stabilize */
111 msleep(20);
112 for (cnt = 16; cnt <= 256; cnt <<= 1) {
Alex Dubov8b40ada2006-12-11 01:55:36 +1100113 if ((TIFM_SOCK_STATE_POWERED
114 & readl(sock_addr + SOCK_PRESENT_STATE)))
Alex Dubov4020f2d2006-10-04 02:15:37 -0700115 break;
Alex Dubov342c0ec2007-04-12 16:59:16 +1000116
117 msleep(cnt);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700118 }
119
Alex Dubov342c0ec2007-04-12 16:59:16 +1000120 writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED),
121 sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700122
123 return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7;
124}
125
Alex Dubov055b8222007-05-01 20:14:55 -0700126inline static void tifm_7xx1_sock_power_off(char __iomem *sock_addr)
127{
128 writel((~TIFM_CTRL_POWER_MASK) & readl(sock_addr + SOCK_CONTROL),
129 sock_addr + SOCK_CONTROL);
130}
131
Al Viroe069d792006-10-09 20:29:43 +0100132inline static char __iomem *
133tifm_7xx1_sock_addr(char __iomem *base_addr, unsigned int sock_num)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700134{
135 return base_addr + ((sock_num + 1) << 10);
136}
137
Alex Dubov3540af82007-04-12 16:59:15 +1000138static void tifm_7xx1_switch_media(struct work_struct *work)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700139{
Alex Dubov3540af82007-04-12 16:59:15 +1000140 struct tifm_adapter *fm = container_of(work, struct tifm_adapter,
141 media_switcher);
Alex Dubov91f8d012007-04-12 17:05:26 +1000142 struct tifm_dev *sock;
Alex Dubov055b8222007-05-01 20:14:55 -0700143 char __iomem *sock_addr;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700144 unsigned long flags;
Alex Dubove23f2b82007-04-12 16:59:14 +1000145 unsigned char media_id;
Alex Dubov91f8d012007-04-12 17:05:26 +1000146 unsigned int socket_change_set, cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700147
Alex Dubov3540af82007-04-12 16:59:15 +1000148 spin_lock_irqsave(&fm->lock, flags);
149 socket_change_set = fm->socket_change_set;
150 fm->socket_change_set = 0;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100151
Tony Jones7dd817d2007-09-25 02:03:03 +0200152 dev_dbg(fm->dev.parent, "checking media set %x\n",
Alex Dubov3540af82007-04-12 16:59:15 +1000153 socket_change_set);
Alex Dubov6412d922006-12-11 01:55:33 +1100154
Alex Dubov3540af82007-04-12 16:59:15 +1000155 if (!socket_change_set) {
Alex Dubov4020f2d2006-10-04 02:15:37 -0700156 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov3540af82007-04-12 16:59:15 +1000157 return;
158 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700159
Alex Dubov2428a8f2007-04-12 16:59:18 +1000160 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
161 if (!(socket_change_set & (1 << cnt)))
162 continue;
163 sock = fm->sockets[cnt];
164 if (sock) {
165 printk(KERN_INFO
166 "%s : demand removing card from socket %u:%u\n",
Kay Sievers0bad16a2009-01-06 10:44:35 -0800167 dev_name(&fm->dev), fm->id, cnt);
Alex Dubov2428a8f2007-04-12 16:59:18 +1000168 fm->sockets[cnt] = NULL;
Alex Dubov055b8222007-05-01 20:14:55 -0700169 sock_addr = sock->addr;
Alex Dubov6412d922006-12-11 01:55:33 +1100170 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov2428a8f2007-04-12 16:59:18 +1000171 device_unregister(&sock->dev);
172 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov055b8222007-05-01 20:14:55 -0700173 tifm_7xx1_sock_power_off(sock_addr);
174 writel(0x0e00, sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700175 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700176
Alex Dubov2428a8f2007-04-12 16:59:18 +1000177 spin_unlock_irqrestore(&fm->lock, flags);
178
179 media_id = tifm_7xx1_toggle_sock_power(
180 tifm_7xx1_sock_addr(fm->addr, cnt));
181
182 // tifm_alloc_device will check if media_id is valid
183 sock = tifm_alloc_device(fm, cnt, media_id);
184 if (sock) {
185 sock->addr = tifm_7xx1_sock_addr(fm->addr, cnt);
186
187 if (!device_register(&sock->dev)) {
188 spin_lock_irqsave(&fm->lock, flags);
189 if (!fm->sockets[cnt]) {
190 fm->sockets[cnt] = sock;
191 sock = NULL;
192 }
193 spin_unlock_irqrestore(&fm->lock, flags);
194 }
195 if (sock)
196 tifm_free_device(&sock->dev);
197 }
198 spin_lock_irqsave(&fm->lock, flags);
199 }
200
Alex Dubov3540af82007-04-12 16:59:15 +1000201 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
202 | TIFM_IRQ_CARDMASK(socket_change_set),
203 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
204
205 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
206 | TIFM_IRQ_CARDMASK(socket_change_set),
207 fm->addr + FM_SET_INTERRUPT_ENABLE);
208
209 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
210 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700211}
212
Alex Dubov7146f0d2006-12-18 14:20:06 +1100213#ifdef CONFIG_PM
214
Alex Dubov4020f2d2006-10-04 02:15:37 -0700215static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state)
216{
Alex Dubov055b8222007-05-01 20:14:55 -0700217 struct tifm_adapter *fm = pci_get_drvdata(dev);
218 int cnt;
219
Alex Dubov7146f0d2006-12-18 14:20:06 +1100220 dev_dbg(&dev->dev, "suspending host\n");
Alex Dubov4020f2d2006-10-04 02:15:37 -0700221
Alex Dubov055b8222007-05-01 20:14:55 -0700222 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
223 if (fm->sockets[cnt])
224 tifm_7xx1_sock_power_off(fm->sockets[cnt]->addr);
225 }
226
Alex Dubov7146f0d2006-12-18 14:20:06 +1100227 pci_save_state(dev);
228 pci_enable_wake(dev, pci_choose_state(dev, state), 0);
229 pci_disable_device(dev);
230 pci_set_power_state(dev, pci_choose_state(dev, state));
Alex Dubov4020f2d2006-10-04 02:15:37 -0700231 return 0;
232}
233
234static int tifm_7xx1_resume(struct pci_dev *dev)
235{
236 struct tifm_adapter *fm = pci_get_drvdata(dev);
Alex Dubov88de1b22007-04-12 16:59:19 +1000237 int rc;
238 unsigned int good_sockets = 0, bad_sockets = 0;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700239 unsigned long flags;
Alex Dubove23f2b82007-04-12 16:59:14 +1000240 unsigned char new_ids[fm->num_sockets];
Alex Dubov3540af82007-04-12 16:59:15 +1000241 DECLARE_COMPLETION_ONSTACK(finish_resume);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700242
Alex Dubov7146f0d2006-12-18 14:20:06 +1100243 pci_set_power_state(dev, PCI_D0);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700244 pci_restore_state(dev);
Alex Dubov7146f0d2006-12-18 14:20:06 +1100245 rc = pci_enable_device(dev);
246 if (rc)
247 return rc;
248 pci_set_master(dev);
249
250 dev_dbg(&dev->dev, "resuming host\n");
251
Alex Dubov88de1b22007-04-12 16:59:19 +1000252 for (rc = 0; rc < fm->num_sockets; rc++)
253 new_ids[rc] = tifm_7xx1_toggle_sock_power(
254 tifm_7xx1_sock_addr(fm->addr, rc));
Alex Dubov7146f0d2006-12-18 14:20:06 +1100255 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov88de1b22007-04-12 16:59:19 +1000256 for (rc = 0; rc < fm->num_sockets; rc++) {
257 if (fm->sockets[rc]) {
258 if (fm->sockets[rc]->type == new_ids[rc])
259 good_sockets |= 1 << rc;
260 else
261 bad_sockets |= 1 << rc;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100262 }
263 }
264
265 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
266 fm->addr + FM_SET_INTERRUPT_ENABLE);
Alex Dubov88de1b22007-04-12 16:59:19 +1000267 dev_dbg(&dev->dev, "change sets on resume: good %x, bad %x\n",
268 good_sockets, bad_sockets);
269
270 fm->socket_change_set = 0;
271 if (good_sockets) {
Alex Dubov3540af82007-04-12 16:59:15 +1000272 fm->finish_me = &finish_resume;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100273 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov88de1b22007-04-12 16:59:19 +1000274 rc = wait_for_completion_timeout(&finish_resume, HZ);
275 dev_dbg(&dev->dev, "wait returned %d\n", rc);
276 writel(TIFM_IRQ_FIFOMASK(good_sockets)
277 | TIFM_IRQ_CARDMASK(good_sockets),
278 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
279 writel(TIFM_IRQ_FIFOMASK(good_sockets)
280 | TIFM_IRQ_CARDMASK(good_sockets),
281 fm->addr + FM_SET_INTERRUPT_ENABLE);
282 spin_lock_irqsave(&fm->lock, flags);
283 fm->finish_me = NULL;
284 fm->socket_change_set ^= good_sockets & fm->socket_change_set;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100285 }
286
Alex Dubov88de1b22007-04-12 16:59:19 +1000287 fm->socket_change_set |= bad_sockets;
288 if (fm->socket_change_set)
289 tifm_queue_work(&fm->media_switcher);
Alex Dubov7146f0d2006-12-18 14:20:06 +1100290
Alex Dubov4020f2d2006-10-04 02:15:37 -0700291 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov88de1b22007-04-12 16:59:19 +1000292 writel(TIFM_IRQ_ENABLE,
293 fm->addr + FM_SET_INTERRUPT_ENABLE);
294
Alex Dubov4020f2d2006-10-04 02:15:37 -0700295 return 0;
296}
297
Alex Dubov7146f0d2006-12-18 14:20:06 +1100298#else
299
300#define tifm_7xx1_suspend NULL
301#define tifm_7xx1_resume NULL
302
303#endif /* CONFIG_PM */
304
Alex Dubovbaf85322008-02-09 10:20:54 -0800305static int tifm_7xx1_dummy_has_ms_pif(struct tifm_adapter *fm,
306 struct tifm_dev *sock)
307{
308 return 0;
309}
310
311static int tifm_7xx1_has_ms_pif(struct tifm_adapter *fm, struct tifm_dev *sock)
312{
313 if (((fm->num_sockets == 4) && (sock->socket_id == 2))
314 || ((fm->num_sockets == 2) && (sock->socket_id == 0)))
315 return 1;
316
317 return 0;
318}
319
Alex Dubov4020f2d2006-10-04 02:15:37 -0700320static int tifm_7xx1_probe(struct pci_dev *dev,
Alex Dubov8b40ada2006-12-11 01:55:36 +1100321 const struct pci_device_id *dev_id)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700322{
323 struct tifm_adapter *fm;
324 int pci_dev_busy = 0;
325 int rc;
326
Yang Hongyang284901a2009-04-06 19:01:15 -0700327 rc = pci_set_dma_mask(dev, DMA_BIT_MASK(32));
Alex Dubov4020f2d2006-10-04 02:15:37 -0700328 if (rc)
329 return rc;
330
331 rc = pci_enable_device(dev);
332 if (rc)
333 return rc;
334
335 pci_set_master(dev);
336
337 rc = pci_request_regions(dev, DRIVER_NAME);
338 if (rc) {
339 pci_dev_busy = 1;
340 goto err_out;
341 }
342
343 pci_intx(dev, 1);
344
Alex Dubov6113ed72007-04-12 16:59:17 +1000345 fm = tifm_alloc_adapter(dev->device == PCI_DEVICE_ID_TI_XX21_XX11_FM
346 ? 4 : 2, &dev->dev);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700347 if (!fm) {
348 rc = -ENOMEM;
349 goto err_out_int;
350 }
351
Alex Dubov3540af82007-04-12 16:59:15 +1000352 INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700353 fm->eject = tifm_7xx1_eject;
Alex Dubovbaf85322008-02-09 10:20:54 -0800354 fm->has_ms_pif = tifm_7xx1_has_ms_pif;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700355 pci_set_drvdata(dev, fm);
356
Arjan van de Venbdbeed72009-01-06 14:40:39 -0800357 fm->addr = pci_ioremap_bar(dev, 0);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700358 if (!fm->addr)
359 goto err_out_free;
360
Jeff Garzikbc913b12007-06-01 00:46:47 -0700361 rc = request_irq(dev->irq, tifm_7xx1_isr, IRQF_SHARED, DRIVER_NAME, fm);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700362 if (rc)
363 goto err_out_unmap;
364
Alex Dubov3540af82007-04-12 16:59:15 +1000365 rc = tifm_add_adapter(fm);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700366 if (rc)
367 goto err_out_irq;
368
Alex Dubov6412d922006-12-11 01:55:33 +1100369 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
Alex Dubove4c70e82008-03-10 11:43:41 -0700370 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
371 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
Alex Dubov8b40ada2006-12-11 01:55:36 +1100372 fm->addr + FM_SET_INTERRUPT_ENABLE);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700373 return 0;
374
375err_out_irq:
376 free_irq(dev->irq, fm);
377err_out_unmap:
378 iounmap(fm->addr);
379err_out_free:
380 pci_set_drvdata(dev, NULL);
381 tifm_free_adapter(fm);
382err_out_int:
383 pci_intx(dev, 0);
384 pci_release_regions(dev);
385err_out:
386 if (!pci_dev_busy)
387 pci_disable_device(dev);
388 return rc;
389}
390
391static void tifm_7xx1_remove(struct pci_dev *dev)
392{
393 struct tifm_adapter *fm = pci_get_drvdata(dev);
Alex Dubov055b8222007-05-01 20:14:55 -0700394 int cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700395
Alex Dubov6113ed72007-04-12 16:59:17 +1000396 fm->eject = tifm_7xx1_dummy_eject;
Alex Dubovbaf85322008-02-09 10:20:54 -0800397 fm->has_ms_pif = tifm_7xx1_dummy_has_ms_pif;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100398 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
399 mmiowb();
400 free_irq(dev->irq, fm);
401
Alex Dubov4020f2d2006-10-04 02:15:37 -0700402 tifm_remove_adapter(fm);
403
Alex Dubov055b8222007-05-01 20:14:55 -0700404 for (cnt = 0; cnt < fm->num_sockets; cnt++)
405 tifm_7xx1_sock_power_off(tifm_7xx1_sock_addr(fm->addr, cnt));
406
Al Viroe069d792006-10-09 20:29:43 +0100407 pci_set_drvdata(dev, NULL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700408
409 iounmap(fm->addr);
410 pci_intx(dev, 0);
411 pci_release_regions(dev);
412
413 pci_disable_device(dev);
414 tifm_free_adapter(fm);
415}
416
417static struct pci_device_id tifm_7xx1_pci_tbl [] = {
Alex Dubovb5ad6762006-12-11 01:55:35 +1100418 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11_FM, PCI_ANY_ID,
419 PCI_ANY_ID, 0, 0, 0 }, /* xx21 - the one I have */
420 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12_FM, PCI_ANY_ID,
421 PCI_ANY_ID, 0, 0, 0 },
422 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX20_FM, PCI_ANY_ID,
423 PCI_ANY_ID, 0, 0, 0 },
Alex Dubov4020f2d2006-10-04 02:15:37 -0700424 { }
425};
426
427static struct pci_driver tifm_7xx1_driver = {
428 .name = DRIVER_NAME,
429 .id_table = tifm_7xx1_pci_tbl,
430 .probe = tifm_7xx1_probe,
431 .remove = tifm_7xx1_remove,
432 .suspend = tifm_7xx1_suspend,
433 .resume = tifm_7xx1_resume,
434};
435
436static int __init tifm_7xx1_init(void)
437{
438 return pci_register_driver(&tifm_7xx1_driver);
439}
440
441static void __exit tifm_7xx1_exit(void)
442{
443 pci_unregister_driver(&tifm_7xx1_driver);
444}
445
446MODULE_AUTHOR("Alex Dubov");
447MODULE_DESCRIPTION("TI FlashMedia host driver");
448MODULE_LICENSE("GPL");
449MODULE_DEVICE_TABLE(pci, tifm_7xx1_pci_tbl);
450MODULE_VERSION(DRIVER_VERSION);
451
452module_init(tifm_7xx1_init);
453module_exit(tifm_7xx1_exit);