blob: a37a42f67088fada76104cf3d988d98f34aca3b7 [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>
Paul Gortmakereb12a672011-07-03 15:14:56 -040014#include <linux/module.h>
Alex Dubov4020f2d2006-10-04 02:15:37 -070015
16#define DRIVER_NAME "tifm_7xx1"
Alex Dubov4552f0c2007-04-12 16:59:12 +100017#define DRIVER_VERSION "0.8"
18
19#define TIFM_IRQ_ENABLE 0x80000000
20#define TIFM_IRQ_SOCKMASK(x) (x)
21#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
22#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
23#define TIFM_IRQ_SETALL 0xffffffff
Alex Dubov4020f2d2006-10-04 02:15:37 -070024
Alex Dubov6113ed72007-04-12 16:59:17 +100025static void tifm_7xx1_dummy_eject(struct tifm_adapter *fm,
26 struct tifm_dev *sock)
27{
28}
29
Alex Dubov4020f2d2006-10-04 02:15:37 -070030static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
31{
Alex Dubov4020f2d2006-10-04 02:15:37 -070032 unsigned long flags;
33
34 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov7146f0d2006-12-18 14:20:06 +110035 fm->socket_change_set |= 1 << sock->socket_id;
Alex Dubov3540af82007-04-12 16:59:15 +100036 tifm_queue_work(&fm->media_switcher);
Alex Dubov4020f2d2006-10-04 02:15:37 -070037 spin_unlock_irqrestore(&fm->lock, flags);
38}
39
David Howells7d12e782006-10-05 14:55:46 +010040static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
Alex Dubov4020f2d2006-10-04 02:15:37 -070041{
42 struct tifm_adapter *fm = dev_id;
Alex Dubov217334d2006-12-11 01:55:31 +110043 struct tifm_dev *sock;
Alex Dubov91f8d012007-04-12 17:05:26 +100044 unsigned int irq_status, cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -070045
46 spin_lock(&fm->lock);
47 irq_status = readl(fm->addr + FM_INTERRUPT_STATUS);
48 if (irq_status == 0 || irq_status == (~0)) {
49 spin_unlock(&fm->lock);
50 return IRQ_NONE;
51 }
52
53 if (irq_status & TIFM_IRQ_ENABLE) {
54 writel(TIFM_IRQ_ENABLE, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
55
Alex Dubov8b40ada2006-12-11 01:55:36 +110056 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
Alex Dubov217334d2006-12-11 01:55:31 +110057 sock = fm->sockets[cnt];
Alex Dubov4552f0c2007-04-12 16:59:12 +100058 if (sock) {
59 if ((irq_status >> cnt) & TIFM_IRQ_FIFOMASK(1))
60 sock->data_event(sock);
61 if ((irq_status >> cnt) & TIFM_IRQ_CARDMASK(1))
62 sock->card_event(sock);
63 }
Alex Dubov4020f2d2006-10-04 02:15:37 -070064 }
Alex Dubov6412d922006-12-11 01:55:33 +110065
Alex Dubov8b40ada2006-12-11 01:55:36 +110066 fm->socket_change_set |= irq_status
67 & ((1 << fm->num_sockets) - 1);
Alex Dubov4020f2d2006-10-04 02:15:37 -070068 }
69 writel(irq_status, fm->addr + FM_INTERRUPT_STATUS);
70
Alex Dubov3540af82007-04-12 16:59:15 +100071 if (fm->finish_me)
72 complete_all(fm->finish_me);
73 else if (!fm->socket_change_set)
Alex Dubov7146f0d2006-12-18 14:20:06 +110074 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
75 else
Alex Dubov3540af82007-04-12 16:59:15 +100076 tifm_queue_work(&fm->media_switcher);
Alex Dubov4020f2d2006-10-04 02:15:37 -070077
78 spin_unlock(&fm->lock);
79 return IRQ_HANDLED;
80}
81
Alex Dubov342c0ec2007-04-12 16:59:16 +100082static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr)
Alex Dubov4020f2d2006-10-04 02:15:37 -070083{
84 unsigned int s_state;
85 int cnt;
86
87 writel(0x0e00, sock_addr + SOCK_CONTROL);
88
Alex Dubov342c0ec2007-04-12 16:59:16 +100089 for (cnt = 16; cnt <= 256; cnt <<= 1) {
Alex Dubov8b40ada2006-12-11 01:55:36 +110090 if (!(TIFM_SOCK_STATE_POWERED
91 & readl(sock_addr + SOCK_PRESENT_STATE)))
Alex Dubov4020f2d2006-10-04 02:15:37 -070092 break;
Alex Dubov342c0ec2007-04-12 16:59:16 +100093
94 msleep(cnt);
Alex Dubov4020f2d2006-10-04 02:15:37 -070095 }
96
97 s_state = readl(sock_addr + SOCK_PRESENT_STATE);
98 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state))
Alex Dubove23f2b82007-04-12 16:59:14 +100099 return 0;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700100
Alex Dubov342c0ec2007-04-12 16:59:16 +1000101 writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
102 sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700103
Alex Dubov342c0ec2007-04-12 16:59:16 +1000104 /* xd needs some extra time before power on */
105 if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7)
106 == TIFM_TYPE_XD)
107 msleep(40);
108
Alex Dubov055b8222007-05-01 20:14:55 -0700109 writel((s_state & TIFM_CTRL_POWER_MASK) | 0x0c00,
110 sock_addr + SOCK_CONTROL);
Alex Dubov342c0ec2007-04-12 16:59:16 +1000111 /* wait for power to stabilize */
112 msleep(20);
113 for (cnt = 16; cnt <= 256; cnt <<= 1) {
Alex Dubov8b40ada2006-12-11 01:55:36 +1100114 if ((TIFM_SOCK_STATE_POWERED
115 & readl(sock_addr + SOCK_PRESENT_STATE)))
Alex Dubov4020f2d2006-10-04 02:15:37 -0700116 break;
Alex Dubov342c0ec2007-04-12 16:59:16 +1000117
118 msleep(cnt);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700119 }
120
Alex Dubov342c0ec2007-04-12 16:59:16 +1000121 writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED),
122 sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700123
124 return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7;
125}
126
Alex Dubov055b8222007-05-01 20:14:55 -0700127inline static void tifm_7xx1_sock_power_off(char __iomem *sock_addr)
128{
129 writel((~TIFM_CTRL_POWER_MASK) & readl(sock_addr + SOCK_CONTROL),
130 sock_addr + SOCK_CONTROL);
131}
132
Al Viroe069d792006-10-09 20:29:43 +0100133inline static char __iomem *
134tifm_7xx1_sock_addr(char __iomem *base_addr, unsigned int sock_num)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700135{
136 return base_addr + ((sock_num + 1) << 10);
137}
138
Alex Dubov3540af82007-04-12 16:59:15 +1000139static void tifm_7xx1_switch_media(struct work_struct *work)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700140{
Alex Dubov3540af82007-04-12 16:59:15 +1000141 struct tifm_adapter *fm = container_of(work, struct tifm_adapter,
142 media_switcher);
Alex Dubov91f8d012007-04-12 17:05:26 +1000143 struct tifm_dev *sock;
Alex Dubov055b8222007-05-01 20:14:55 -0700144 char __iomem *sock_addr;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700145 unsigned long flags;
Alex Dubove23f2b82007-04-12 16:59:14 +1000146 unsigned char media_id;
Alex Dubov91f8d012007-04-12 17:05:26 +1000147 unsigned int socket_change_set, cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700148
Alex Dubov3540af82007-04-12 16:59:15 +1000149 spin_lock_irqsave(&fm->lock, flags);
150 socket_change_set = fm->socket_change_set;
151 fm->socket_change_set = 0;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100152
Tony Jones7dd817d2007-09-25 02:03:03 +0200153 dev_dbg(fm->dev.parent, "checking media set %x\n",
Alex Dubov3540af82007-04-12 16:59:15 +1000154 socket_change_set);
Alex Dubov6412d922006-12-11 01:55:33 +1100155
Alex Dubov3540af82007-04-12 16:59:15 +1000156 if (!socket_change_set) {
Alex Dubov4020f2d2006-10-04 02:15:37 -0700157 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov3540af82007-04-12 16:59:15 +1000158 return;
159 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700160
Alex Dubov2428a8f2007-04-12 16:59:18 +1000161 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
162 if (!(socket_change_set & (1 << cnt)))
163 continue;
164 sock = fm->sockets[cnt];
165 if (sock) {
166 printk(KERN_INFO
167 "%s : demand removing card from socket %u:%u\n",
Kay Sievers0bad16a2009-01-06 10:44:35 -0800168 dev_name(&fm->dev), fm->id, cnt);
Alex Dubov2428a8f2007-04-12 16:59:18 +1000169 fm->sockets[cnt] = NULL;
Alex Dubov055b8222007-05-01 20:14:55 -0700170 sock_addr = sock->addr;
Alex Dubov6412d922006-12-11 01:55:33 +1100171 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov2428a8f2007-04-12 16:59:18 +1000172 device_unregister(&sock->dev);
173 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov055b8222007-05-01 20:14:55 -0700174 tifm_7xx1_sock_power_off(sock_addr);
175 writel(0x0e00, sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700176 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700177
Alex Dubov2428a8f2007-04-12 16:59:18 +1000178 spin_unlock_irqrestore(&fm->lock, flags);
179
180 media_id = tifm_7xx1_toggle_sock_power(
181 tifm_7xx1_sock_addr(fm->addr, cnt));
182
183 // tifm_alloc_device will check if media_id is valid
184 sock = tifm_alloc_device(fm, cnt, media_id);
185 if (sock) {
186 sock->addr = tifm_7xx1_sock_addr(fm->addr, cnt);
187
188 if (!device_register(&sock->dev)) {
189 spin_lock_irqsave(&fm->lock, flags);
190 if (!fm->sockets[cnt]) {
191 fm->sockets[cnt] = sock;
192 sock = NULL;
193 }
194 spin_unlock_irqrestore(&fm->lock, flags);
195 }
196 if (sock)
197 tifm_free_device(&sock->dev);
198 }
199 spin_lock_irqsave(&fm->lock, flags);
200 }
201
Alex Dubov3540af82007-04-12 16:59:15 +1000202 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
203 | TIFM_IRQ_CARDMASK(socket_change_set),
204 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
205
206 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
207 | TIFM_IRQ_CARDMASK(socket_change_set),
208 fm->addr + FM_SET_INTERRUPT_ENABLE);
209
210 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
211 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700212}
213
Alex Dubov7146f0d2006-12-18 14:20:06 +1100214#ifdef CONFIG_PM
215
Alex Dubov4020f2d2006-10-04 02:15:37 -0700216static int tifm_7xx1_suspend(struct pci_dev *dev, pm_message_t state)
217{
Alex Dubov055b8222007-05-01 20:14:55 -0700218 struct tifm_adapter *fm = pci_get_drvdata(dev);
219 int cnt;
220
Alex Dubov7146f0d2006-12-18 14:20:06 +1100221 dev_dbg(&dev->dev, "suspending host\n");
Alex Dubov4020f2d2006-10-04 02:15:37 -0700222
Alex Dubov055b8222007-05-01 20:14:55 -0700223 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
224 if (fm->sockets[cnt])
225 tifm_7xx1_sock_power_off(fm->sockets[cnt]->addr);
226 }
227
Alex Dubov7146f0d2006-12-18 14:20:06 +1100228 pci_save_state(dev);
229 pci_enable_wake(dev, pci_choose_state(dev, state), 0);
230 pci_disable_device(dev);
231 pci_set_power_state(dev, pci_choose_state(dev, state));
Alex Dubov4020f2d2006-10-04 02:15:37 -0700232 return 0;
233}
234
235static int tifm_7xx1_resume(struct pci_dev *dev)
236{
237 struct tifm_adapter *fm = pci_get_drvdata(dev);
Alex Dubov88de1b22007-04-12 16:59:19 +1000238 int rc;
Nicholas Mc Guirea819a222015-02-09 14:43:44 -0500239 unsigned long timeout;
Alex Dubov88de1b22007-04-12 16:59:19 +1000240 unsigned int good_sockets = 0, bad_sockets = 0;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700241 unsigned long flags;
Alex Dubove23f2b82007-04-12 16:59:14 +1000242 unsigned char new_ids[fm->num_sockets];
Alex Dubov3540af82007-04-12 16:59:15 +1000243 DECLARE_COMPLETION_ONSTACK(finish_resume);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700244
Alex Dubov7146f0d2006-12-18 14:20:06 +1100245 pci_set_power_state(dev, PCI_D0);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700246 pci_restore_state(dev);
Alex Dubov7146f0d2006-12-18 14:20:06 +1100247 rc = pci_enable_device(dev);
248 if (rc)
249 return rc;
250 pci_set_master(dev);
251
252 dev_dbg(&dev->dev, "resuming host\n");
253
Alex Dubov88de1b22007-04-12 16:59:19 +1000254 for (rc = 0; rc < fm->num_sockets; rc++)
255 new_ids[rc] = tifm_7xx1_toggle_sock_power(
256 tifm_7xx1_sock_addr(fm->addr, rc));
Alex Dubov7146f0d2006-12-18 14:20:06 +1100257 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov88de1b22007-04-12 16:59:19 +1000258 for (rc = 0; rc < fm->num_sockets; rc++) {
259 if (fm->sockets[rc]) {
260 if (fm->sockets[rc]->type == new_ids[rc])
261 good_sockets |= 1 << rc;
262 else
263 bad_sockets |= 1 << rc;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100264 }
265 }
266
267 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
268 fm->addr + FM_SET_INTERRUPT_ENABLE);
Alex Dubov88de1b22007-04-12 16:59:19 +1000269 dev_dbg(&dev->dev, "change sets on resume: good %x, bad %x\n",
270 good_sockets, bad_sockets);
271
272 fm->socket_change_set = 0;
273 if (good_sockets) {
Alex Dubov3540af82007-04-12 16:59:15 +1000274 fm->finish_me = &finish_resume;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100275 spin_unlock_irqrestore(&fm->lock, flags);
Nicholas Mc Guirea819a222015-02-09 14:43:44 -0500276 timeout = wait_for_completion_timeout(&finish_resume, HZ);
277 dev_dbg(&dev->dev, "wait returned %lu\n", timeout);
Alex Dubov88de1b22007-04-12 16:59:19 +1000278 writel(TIFM_IRQ_FIFOMASK(good_sockets)
279 | TIFM_IRQ_CARDMASK(good_sockets),
280 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
281 writel(TIFM_IRQ_FIFOMASK(good_sockets)
282 | TIFM_IRQ_CARDMASK(good_sockets),
283 fm->addr + FM_SET_INTERRUPT_ENABLE);
284 spin_lock_irqsave(&fm->lock, flags);
285 fm->finish_me = NULL;
286 fm->socket_change_set ^= good_sockets & fm->socket_change_set;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100287 }
288
Alex Dubov88de1b22007-04-12 16:59:19 +1000289 fm->socket_change_set |= bad_sockets;
290 if (fm->socket_change_set)
291 tifm_queue_work(&fm->media_switcher);
Alex Dubov7146f0d2006-12-18 14:20:06 +1100292
Alex Dubov4020f2d2006-10-04 02:15:37 -0700293 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov88de1b22007-04-12 16:59:19 +1000294 writel(TIFM_IRQ_ENABLE,
295 fm->addr + FM_SET_INTERRUPT_ENABLE);
296
Alex Dubov4020f2d2006-10-04 02:15:37 -0700297 return 0;
298}
299
Alex Dubov7146f0d2006-12-18 14:20:06 +1100300#else
301
302#define tifm_7xx1_suspend NULL
303#define tifm_7xx1_resume NULL
304
305#endif /* CONFIG_PM */
306
Alex Dubovbaf85322008-02-09 10:20:54 -0800307static int tifm_7xx1_dummy_has_ms_pif(struct tifm_adapter *fm,
308 struct tifm_dev *sock)
309{
310 return 0;
311}
312
313static int tifm_7xx1_has_ms_pif(struct tifm_adapter *fm, struct tifm_dev *sock)
314{
315 if (((fm->num_sockets == 4) && (sock->socket_id == 2))
316 || ((fm->num_sockets == 2) && (sock->socket_id == 0)))
317 return 1;
318
319 return 0;
320}
321
Alex Dubov4020f2d2006-10-04 02:15:37 -0700322static int tifm_7xx1_probe(struct pci_dev *dev,
Alex Dubov8b40ada2006-12-11 01:55:36 +1100323 const struct pci_device_id *dev_id)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700324{
325 struct tifm_adapter *fm;
326 int pci_dev_busy = 0;
327 int rc;
328
Yang Hongyang284901a2009-04-06 19:01:15 -0700329 rc = pci_set_dma_mask(dev, DMA_BIT_MASK(32));
Alex Dubov4020f2d2006-10-04 02:15:37 -0700330 if (rc)
331 return rc;
332
333 rc = pci_enable_device(dev);
334 if (rc)
335 return rc;
336
337 pci_set_master(dev);
338
339 rc = pci_request_regions(dev, DRIVER_NAME);
340 if (rc) {
341 pci_dev_busy = 1;
342 goto err_out;
343 }
344
345 pci_intx(dev, 1);
346
Alex Dubov6113ed72007-04-12 16:59:17 +1000347 fm = tifm_alloc_adapter(dev->device == PCI_DEVICE_ID_TI_XX21_XX11_FM
348 ? 4 : 2, &dev->dev);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700349 if (!fm) {
350 rc = -ENOMEM;
351 goto err_out_int;
352 }
353
Alex Dubov3540af82007-04-12 16:59:15 +1000354 INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700355 fm->eject = tifm_7xx1_eject;
Alex Dubovbaf85322008-02-09 10:20:54 -0800356 fm->has_ms_pif = tifm_7xx1_has_ms_pif;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700357 pci_set_drvdata(dev, fm);
358
Arjan van de Venbdbeed72009-01-06 14:40:39 -0800359 fm->addr = pci_ioremap_bar(dev, 0);
Wei Yongjun86d62752013-10-30 13:35:20 +0800360 if (!fm->addr) {
361 rc = -ENODEV;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700362 goto err_out_free;
Wei Yongjun86d62752013-10-30 13:35:20 +0800363 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700364
Jeff Garzikbc913b12007-06-01 00:46:47 -0700365 rc = request_irq(dev->irq, tifm_7xx1_isr, IRQF_SHARED, DRIVER_NAME, fm);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700366 if (rc)
367 goto err_out_unmap;
368
Alex Dubov3540af82007-04-12 16:59:15 +1000369 rc = tifm_add_adapter(fm);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700370 if (rc)
371 goto err_out_irq;
372
Alex Dubov6412d922006-12-11 01:55:33 +1100373 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
Alex Dubove4c70e82008-03-10 11:43:41 -0700374 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
375 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
Alex Dubov8b40ada2006-12-11 01:55:36 +1100376 fm->addr + FM_SET_INTERRUPT_ENABLE);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700377 return 0;
378
379err_out_irq:
380 free_irq(dev->irq, fm);
381err_out_unmap:
382 iounmap(fm->addr);
383err_out_free:
Alex Dubov4020f2d2006-10-04 02:15:37 -0700384 tifm_free_adapter(fm);
385err_out_int:
386 pci_intx(dev, 0);
387 pci_release_regions(dev);
388err_out:
389 if (!pci_dev_busy)
390 pci_disable_device(dev);
391 return rc;
392}
393
394static void tifm_7xx1_remove(struct pci_dev *dev)
395{
396 struct tifm_adapter *fm = pci_get_drvdata(dev);
Alex Dubov055b8222007-05-01 20:14:55 -0700397 int cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700398
Alex Dubov6113ed72007-04-12 16:59:17 +1000399 fm->eject = tifm_7xx1_dummy_eject;
Alex Dubovbaf85322008-02-09 10:20:54 -0800400 fm->has_ms_pif = tifm_7xx1_dummy_has_ms_pif;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100401 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
402 mmiowb();
403 free_irq(dev->irq, fm);
404
Alex Dubov4020f2d2006-10-04 02:15:37 -0700405 tifm_remove_adapter(fm);
406
Alex Dubov055b8222007-05-01 20:14:55 -0700407 for (cnt = 0; cnt < fm->num_sockets; cnt++)
408 tifm_7xx1_sock_power_off(tifm_7xx1_sock_addr(fm->addr, cnt));
409
Alex Dubov4020f2d2006-10-04 02:15:37 -0700410 iounmap(fm->addr);
411 pci_intx(dev, 0);
412 pci_release_regions(dev);
413
414 pci_disable_device(dev);
415 tifm_free_adapter(fm);
416}
417
418static struct pci_device_id tifm_7xx1_pci_tbl [] = {
Alex Dubovb5ad6762006-12-11 01:55:35 +1100419 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11_FM, PCI_ANY_ID,
420 PCI_ANY_ID, 0, 0, 0 }, /* xx21 - the one I have */
421 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12_FM, PCI_ANY_ID,
422 PCI_ANY_ID, 0, 0, 0 },
423 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX20_FM, PCI_ANY_ID,
424 PCI_ANY_ID, 0, 0, 0 },
Alex Dubov4020f2d2006-10-04 02:15:37 -0700425 { }
426};
427
428static struct pci_driver tifm_7xx1_driver = {
429 .name = DRIVER_NAME,
430 .id_table = tifm_7xx1_pci_tbl,
431 .probe = tifm_7xx1_probe,
432 .remove = tifm_7xx1_remove,
433 .suspend = tifm_7xx1_suspend,
434 .resume = tifm_7xx1_resume,
435};
436
Devendra Naga7e0b2cd2012-08-26 14:32:43 +0530437module_pci_driver(tifm_7xx1_driver);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700438MODULE_AUTHOR("Alex Dubov");
439MODULE_DESCRIPTION("TI FlashMedia host driver");
440MODULE_LICENSE("GPL");
441MODULE_DEVICE_TABLE(pci, tifm_7xx1_pci_tbl);
442MODULE_VERSION(DRIVER_VERSION);