blob: 228f2eb1d4762791542e6ab157621b8de6b10827 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Alex Dubov4020f2d2006-10-04 02:15:37 -07002/*
3 * tifm_7xx1.c - TI FlashMedia driver
4 *
5 * Copyright (C) 2006 Alex Dubov <oakad@yahoo.com>
Alex Dubov4020f2d2006-10-04 02:15:37 -07006 */
7
8#include <linux/tifm.h>
Andrew Mortonc4030692007-04-28 14:21:10 +02009#include <linux/dma-mapping.h>
Paul Gortmakereb12a672011-07-03 15:14:56 -040010#include <linux/module.h>
Alex Dubov4020f2d2006-10-04 02:15:37 -070011
12#define DRIVER_NAME "tifm_7xx1"
Alex Dubov4552f0c2007-04-12 16:59:12 +100013#define DRIVER_VERSION "0.8"
14
15#define TIFM_IRQ_ENABLE 0x80000000
16#define TIFM_IRQ_SOCKMASK(x) (x)
17#define TIFM_IRQ_CARDMASK(x) ((x) << 8)
18#define TIFM_IRQ_FIFOMASK(x) ((x) << 16)
19#define TIFM_IRQ_SETALL 0xffffffff
Alex Dubov4020f2d2006-10-04 02:15:37 -070020
Alex Dubov6113ed732007-04-12 16:59:17 +100021static void tifm_7xx1_dummy_eject(struct tifm_adapter *fm,
22 struct tifm_dev *sock)
23{
24}
25
Alex Dubov4020f2d2006-10-04 02:15:37 -070026static void tifm_7xx1_eject(struct tifm_adapter *fm, struct tifm_dev *sock)
27{
Alex Dubov4020f2d2006-10-04 02:15:37 -070028 unsigned long flags;
29
30 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov7146f0d2006-12-18 14:20:06 +110031 fm->socket_change_set |= 1 << sock->socket_id;
Alex Dubov3540af8ff2007-04-12 16:59:15 +100032 tifm_queue_work(&fm->media_switcher);
Alex Dubov4020f2d2006-10-04 02:15:37 -070033 spin_unlock_irqrestore(&fm->lock, flags);
34}
35
David Howells7d12e782006-10-05 14:55:46 +010036static irqreturn_t tifm_7xx1_isr(int irq, void *dev_id)
Alex Dubov4020f2d2006-10-04 02:15:37 -070037{
38 struct tifm_adapter *fm = dev_id;
Alex Dubov217334d2006-12-11 01:55:31 +110039 struct tifm_dev *sock;
Alex Dubov91f8d012007-04-12 17:05:26 +100040 unsigned int irq_status, cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -070041
42 spin_lock(&fm->lock);
43 irq_status = readl(fm->addr + FM_INTERRUPT_STATUS);
44 if (irq_status == 0 || irq_status == (~0)) {
45 spin_unlock(&fm->lock);
46 return IRQ_NONE;
47 }
48
49 if (irq_status & TIFM_IRQ_ENABLE) {
50 writel(TIFM_IRQ_ENABLE, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
51
Alex Dubov8b40ada2006-12-11 01:55:36 +110052 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
Alex Dubov217334d2006-12-11 01:55:31 +110053 sock = fm->sockets[cnt];
Alex Dubov4552f0c2007-04-12 16:59:12 +100054 if (sock) {
55 if ((irq_status >> cnt) & TIFM_IRQ_FIFOMASK(1))
56 sock->data_event(sock);
57 if ((irq_status >> cnt) & TIFM_IRQ_CARDMASK(1))
58 sock->card_event(sock);
59 }
Alex Dubov4020f2d2006-10-04 02:15:37 -070060 }
Alex Dubov6412d922006-12-11 01:55:33 +110061
Alex Dubov8b40ada2006-12-11 01:55:36 +110062 fm->socket_change_set |= irq_status
63 & ((1 << fm->num_sockets) - 1);
Alex Dubov4020f2d2006-10-04 02:15:37 -070064 }
65 writel(irq_status, fm->addr + FM_INTERRUPT_STATUS);
66
Alex Dubov3540af8ff2007-04-12 16:59:15 +100067 if (fm->finish_me)
68 complete_all(fm->finish_me);
69 else if (!fm->socket_change_set)
Alex Dubov7146f0d2006-12-18 14:20:06 +110070 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
71 else
Alex Dubov3540af8ff2007-04-12 16:59:15 +100072 tifm_queue_work(&fm->media_switcher);
Alex Dubov4020f2d2006-10-04 02:15:37 -070073
74 spin_unlock(&fm->lock);
75 return IRQ_HANDLED;
76}
77
Alex Dubov342c0ec2007-04-12 16:59:16 +100078static unsigned char tifm_7xx1_toggle_sock_power(char __iomem *sock_addr)
Alex Dubov4020f2d2006-10-04 02:15:37 -070079{
80 unsigned int s_state;
81 int cnt;
82
83 writel(0x0e00, sock_addr + SOCK_CONTROL);
84
Alex Dubov342c0ec2007-04-12 16:59:16 +100085 for (cnt = 16; cnt <= 256; cnt <<= 1) {
Alex Dubov8b40ada2006-12-11 01:55:36 +110086 if (!(TIFM_SOCK_STATE_POWERED
87 & readl(sock_addr + SOCK_PRESENT_STATE)))
Alex Dubov4020f2d2006-10-04 02:15:37 -070088 break;
Alex Dubov342c0ec2007-04-12 16:59:16 +100089
90 msleep(cnt);
Alex Dubov4020f2d2006-10-04 02:15:37 -070091 }
92
93 s_state = readl(sock_addr + SOCK_PRESENT_STATE);
94 if (!(TIFM_SOCK_STATE_OCCUPIED & s_state))
Alex Dubove23f2b82007-04-12 16:59:14 +100095 return 0;
Alex Dubov4020f2d2006-10-04 02:15:37 -070096
Alex Dubov342c0ec2007-04-12 16:59:16 +100097 writel(readl(sock_addr + SOCK_CONTROL) | TIFM_CTRL_LED,
98 sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -070099
Alex Dubov342c0ec2007-04-12 16:59:16 +1000100 /* xd needs some extra time before power on */
101 if (((readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7)
102 == TIFM_TYPE_XD)
103 msleep(40);
104
Alex Dubov055b8222007-05-01 20:14:55 -0700105 writel((s_state & TIFM_CTRL_POWER_MASK) | 0x0c00,
106 sock_addr + SOCK_CONTROL);
Alex Dubov342c0ec2007-04-12 16:59:16 +1000107 /* wait for power to stabilize */
108 msleep(20);
109 for (cnt = 16; cnt <= 256; cnt <<= 1) {
Alex Dubov8b40ada2006-12-11 01:55:36 +1100110 if ((TIFM_SOCK_STATE_POWERED
111 & readl(sock_addr + SOCK_PRESENT_STATE)))
Alex Dubov4020f2d2006-10-04 02:15:37 -0700112 break;
Alex Dubov342c0ec2007-04-12 16:59:16 +1000113
114 msleep(cnt);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700115 }
116
Alex Dubov342c0ec2007-04-12 16:59:16 +1000117 writel(readl(sock_addr + SOCK_CONTROL) & (~TIFM_CTRL_LED),
118 sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700119
120 return (readl(sock_addr + SOCK_PRESENT_STATE) >> 4) & 7;
121}
122
Alex Dubov055b8222007-05-01 20:14:55 -0700123inline static void tifm_7xx1_sock_power_off(char __iomem *sock_addr)
124{
125 writel((~TIFM_CTRL_POWER_MASK) & readl(sock_addr + SOCK_CONTROL),
126 sock_addr + SOCK_CONTROL);
127}
128
Al Viroe069d792006-10-09 20:29:43 +0100129inline static char __iomem *
130tifm_7xx1_sock_addr(char __iomem *base_addr, unsigned int sock_num)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700131{
132 return base_addr + ((sock_num + 1) << 10);
133}
134
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000135static void tifm_7xx1_switch_media(struct work_struct *work)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700136{
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000137 struct tifm_adapter *fm = container_of(work, struct tifm_adapter,
138 media_switcher);
Alex Dubov91f8d012007-04-12 17:05:26 +1000139 struct tifm_dev *sock;
Alex Dubov055b8222007-05-01 20:14:55 -0700140 char __iomem *sock_addr;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700141 unsigned long flags;
Alex Dubove23f2b82007-04-12 16:59:14 +1000142 unsigned char media_id;
Alex Dubov91f8d012007-04-12 17:05:26 +1000143 unsigned int socket_change_set, cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700144
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000145 spin_lock_irqsave(&fm->lock, flags);
146 socket_change_set = fm->socket_change_set;
147 fm->socket_change_set = 0;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100148
Tony Jones7dd817d2007-09-25 02:03:03 +0200149 dev_dbg(fm->dev.parent, "checking media set %x\n",
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000150 socket_change_set);
Alex Dubov6412d922006-12-11 01:55:33 +1100151
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000152 if (!socket_change_set) {
Alex Dubov4020f2d2006-10-04 02:15:37 -0700153 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000154 return;
155 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700156
Alex Dubov2428a8f2007-04-12 16:59:18 +1000157 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
158 if (!(socket_change_set & (1 << cnt)))
159 continue;
160 sock = fm->sockets[cnt];
161 if (sock) {
162 printk(KERN_INFO
163 "%s : demand removing card from socket %u:%u\n",
Kay Sievers0bad16a2009-01-06 10:44:35 -0800164 dev_name(&fm->dev), fm->id, cnt);
Alex Dubov2428a8f2007-04-12 16:59:18 +1000165 fm->sockets[cnt] = NULL;
Alex Dubov055b8222007-05-01 20:14:55 -0700166 sock_addr = sock->addr;
Alex Dubov6412d922006-12-11 01:55:33 +1100167 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov2428a8f2007-04-12 16:59:18 +1000168 device_unregister(&sock->dev);
169 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov055b8222007-05-01 20:14:55 -0700170 tifm_7xx1_sock_power_off(sock_addr);
171 writel(0x0e00, sock_addr + SOCK_CONTROL);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700172 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700173
Alex Dubov2428a8f2007-04-12 16:59:18 +1000174 spin_unlock_irqrestore(&fm->lock, flags);
175
176 media_id = tifm_7xx1_toggle_sock_power(
177 tifm_7xx1_sock_addr(fm->addr, cnt));
178
179 // tifm_alloc_device will check if media_id is valid
180 sock = tifm_alloc_device(fm, cnt, media_id);
181 if (sock) {
182 sock->addr = tifm_7xx1_sock_addr(fm->addr, cnt);
183
184 if (!device_register(&sock->dev)) {
185 spin_lock_irqsave(&fm->lock, flags);
186 if (!fm->sockets[cnt]) {
187 fm->sockets[cnt] = sock;
188 sock = NULL;
189 }
190 spin_unlock_irqrestore(&fm->lock, flags);
191 }
192 if (sock)
193 tifm_free_device(&sock->dev);
194 }
195 spin_lock_irqsave(&fm->lock, flags);
196 }
197
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000198 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
199 | TIFM_IRQ_CARDMASK(socket_change_set),
200 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
201
202 writel(TIFM_IRQ_FIFOMASK(socket_change_set)
203 | TIFM_IRQ_CARDMASK(socket_change_set),
204 fm->addr + FM_SET_INTERRUPT_ENABLE);
205
206 writel(TIFM_IRQ_ENABLE, fm->addr + FM_SET_INTERRUPT_ENABLE);
207 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700208}
209
Vaibhav Guptaff249c12020-06-29 13:45:29 +0530210static int __maybe_unused tifm_7xx1_suspend(struct device *dev_d)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700211{
Vaibhav Guptaff249c12020-06-29 13:45:29 +0530212 struct pci_dev *dev = to_pci_dev(dev_d);
Alex Dubov055b8222007-05-01 20:14:55 -0700213 struct tifm_adapter *fm = pci_get_drvdata(dev);
214 int cnt;
215
Alex Dubov7146f0d2006-12-18 14:20:06 +1100216 dev_dbg(&dev->dev, "suspending host\n");
Alex Dubov4020f2d2006-10-04 02:15:37 -0700217
Alex Dubov055b8222007-05-01 20:14:55 -0700218 for (cnt = 0; cnt < fm->num_sockets; cnt++) {
219 if (fm->sockets[cnt])
220 tifm_7xx1_sock_power_off(fm->sockets[cnt]->addr);
221 }
222
Vaibhav Guptaff249c12020-06-29 13:45:29 +0530223 device_wakeup_disable(dev_d);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700224 return 0;
225}
226
Vaibhav Guptaff249c12020-06-29 13:45:29 +0530227static int __maybe_unused tifm_7xx1_resume(struct device *dev_d)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700228{
Vaibhav Guptaff249c12020-06-29 13:45:29 +0530229 struct pci_dev *dev = to_pci_dev(dev_d);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700230 struct tifm_adapter *fm = pci_get_drvdata(dev);
Alex Dubov88de1b22007-04-12 16:59:19 +1000231 int rc;
Nicholas Mc Guirea819a222015-02-09 14:43:44 -0500232 unsigned long timeout;
Alex Dubov88de1b22007-04-12 16:59:19 +1000233 unsigned int good_sockets = 0, bad_sockets = 0;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700234 unsigned long flags;
Laura Abbottc13884a2018-04-10 18:04:12 -0700235 /* Maximum number of entries is 4 */
236 unsigned char new_ids[4];
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000237 DECLARE_COMPLETION_ONSTACK(finish_resume);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700238
Laura Abbottc13884a2018-04-10 18:04:12 -0700239 if (WARN_ON(fm->num_sockets > ARRAY_SIZE(new_ids)))
240 return -ENXIO;
241
Alex Dubov7146f0d2006-12-18 14:20:06 +1100242 pci_set_master(dev);
243
244 dev_dbg(&dev->dev, "resuming host\n");
245
Alex Dubov88de1b22007-04-12 16:59:19 +1000246 for (rc = 0; rc < fm->num_sockets; rc++)
247 new_ids[rc] = tifm_7xx1_toggle_sock_power(
248 tifm_7xx1_sock_addr(fm->addr, rc));
Alex Dubov7146f0d2006-12-18 14:20:06 +1100249 spin_lock_irqsave(&fm->lock, flags);
Alex Dubov88de1b22007-04-12 16:59:19 +1000250 for (rc = 0; rc < fm->num_sockets; rc++) {
251 if (fm->sockets[rc]) {
252 if (fm->sockets[rc]->type == new_ids[rc])
253 good_sockets |= 1 << rc;
254 else
255 bad_sockets |= 1 << rc;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100256 }
257 }
258
259 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
260 fm->addr + FM_SET_INTERRUPT_ENABLE);
Alex Dubov88de1b22007-04-12 16:59:19 +1000261 dev_dbg(&dev->dev, "change sets on resume: good %x, bad %x\n",
262 good_sockets, bad_sockets);
263
264 fm->socket_change_set = 0;
265 if (good_sockets) {
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000266 fm->finish_me = &finish_resume;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100267 spin_unlock_irqrestore(&fm->lock, flags);
Nicholas Mc Guirea819a222015-02-09 14:43:44 -0500268 timeout = wait_for_completion_timeout(&finish_resume, HZ);
269 dev_dbg(&dev->dev, "wait returned %lu\n", timeout);
Alex Dubov88de1b22007-04-12 16:59:19 +1000270 writel(TIFM_IRQ_FIFOMASK(good_sockets)
271 | TIFM_IRQ_CARDMASK(good_sockets),
272 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
273 writel(TIFM_IRQ_FIFOMASK(good_sockets)
274 | TIFM_IRQ_CARDMASK(good_sockets),
275 fm->addr + FM_SET_INTERRUPT_ENABLE);
276 spin_lock_irqsave(&fm->lock, flags);
277 fm->finish_me = NULL;
278 fm->socket_change_set ^= good_sockets & fm->socket_change_set;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100279 }
280
Alex Dubov88de1b22007-04-12 16:59:19 +1000281 fm->socket_change_set |= bad_sockets;
282 if (fm->socket_change_set)
283 tifm_queue_work(&fm->media_switcher);
Alex Dubov7146f0d2006-12-18 14:20:06 +1100284
Alex Dubov4020f2d2006-10-04 02:15:37 -0700285 spin_unlock_irqrestore(&fm->lock, flags);
Alex Dubov88de1b22007-04-12 16:59:19 +1000286 writel(TIFM_IRQ_ENABLE,
287 fm->addr + FM_SET_INTERRUPT_ENABLE);
288
Alex Dubov4020f2d2006-10-04 02:15:37 -0700289 return 0;
290}
291
Alex Dubovbaf85322008-02-09 10:20:54 -0800292static int tifm_7xx1_dummy_has_ms_pif(struct tifm_adapter *fm,
293 struct tifm_dev *sock)
294{
295 return 0;
296}
297
298static int tifm_7xx1_has_ms_pif(struct tifm_adapter *fm, struct tifm_dev *sock)
299{
300 if (((fm->num_sockets == 4) && (sock->socket_id == 2))
301 || ((fm->num_sockets == 2) && (sock->socket_id == 0)))
302 return 1;
303
304 return 0;
305}
306
Alex Dubov4020f2d2006-10-04 02:15:37 -0700307static int tifm_7xx1_probe(struct pci_dev *dev,
Alex Dubov8b40ada2006-12-11 01:55:36 +1100308 const struct pci_device_id *dev_id)
Alex Dubov4020f2d2006-10-04 02:15:37 -0700309{
310 struct tifm_adapter *fm;
311 int pci_dev_busy = 0;
312 int rc;
313
Yang Hongyang284901a2009-04-06 19:01:15 -0700314 rc = pci_set_dma_mask(dev, DMA_BIT_MASK(32));
Alex Dubov4020f2d2006-10-04 02:15:37 -0700315 if (rc)
316 return rc;
317
318 rc = pci_enable_device(dev);
319 if (rc)
320 return rc;
321
322 pci_set_master(dev);
323
324 rc = pci_request_regions(dev, DRIVER_NAME);
325 if (rc) {
326 pci_dev_busy = 1;
327 goto err_out;
328 }
329
330 pci_intx(dev, 1);
331
Alex Dubov6113ed732007-04-12 16:59:17 +1000332 fm = tifm_alloc_adapter(dev->device == PCI_DEVICE_ID_TI_XX21_XX11_FM
333 ? 4 : 2, &dev->dev);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700334 if (!fm) {
335 rc = -ENOMEM;
336 goto err_out_int;
337 }
338
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000339 INIT_WORK(&fm->media_switcher, tifm_7xx1_switch_media);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700340 fm->eject = tifm_7xx1_eject;
Alex Dubovbaf85322008-02-09 10:20:54 -0800341 fm->has_ms_pif = tifm_7xx1_has_ms_pif;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700342 pci_set_drvdata(dev, fm);
343
Arjan van de Venbdbeed72009-01-06 14:40:39 -0800344 fm->addr = pci_ioremap_bar(dev, 0);
Wei Yongjun86d62752013-10-30 13:35:20 +0800345 if (!fm->addr) {
346 rc = -ENODEV;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700347 goto err_out_free;
Wei Yongjun86d62752013-10-30 13:35:20 +0800348 }
Alex Dubov4020f2d2006-10-04 02:15:37 -0700349
Jeff Garzikbc913b12007-06-01 00:46:47 -0700350 rc = request_irq(dev->irq, tifm_7xx1_isr, IRQF_SHARED, DRIVER_NAME, fm);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700351 if (rc)
352 goto err_out_unmap;
353
Alex Dubov3540af8ff2007-04-12 16:59:15 +1000354 rc = tifm_add_adapter(fm);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700355 if (rc)
356 goto err_out_irq;
357
Alex Dubov6412d922006-12-11 01:55:33 +1100358 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
Alex Dubove4c70e82008-03-10 11:43:41 -0700359 fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
360 writel(TIFM_IRQ_ENABLE | TIFM_IRQ_SOCKMASK((1 << fm->num_sockets) - 1),
Alex Dubov8b40ada2006-12-11 01:55:36 +1100361 fm->addr + FM_SET_INTERRUPT_ENABLE);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700362 return 0;
363
364err_out_irq:
365 free_irq(dev->irq, fm);
366err_out_unmap:
367 iounmap(fm->addr);
368err_out_free:
Alex Dubov4020f2d2006-10-04 02:15:37 -0700369 tifm_free_adapter(fm);
370err_out_int:
371 pci_intx(dev, 0);
372 pci_release_regions(dev);
373err_out:
374 if (!pci_dev_busy)
375 pci_disable_device(dev);
376 return rc;
377}
378
379static void tifm_7xx1_remove(struct pci_dev *dev)
380{
381 struct tifm_adapter *fm = pci_get_drvdata(dev);
Alex Dubov055b8222007-05-01 20:14:55 -0700382 int cnt;
Alex Dubov4020f2d2006-10-04 02:15:37 -0700383
Alex Dubov6113ed732007-04-12 16:59:17 +1000384 fm->eject = tifm_7xx1_dummy_eject;
Alex Dubovbaf85322008-02-09 10:20:54 -0800385 fm->has_ms_pif = tifm_7xx1_dummy_has_ms_pif;
Alex Dubov7146f0d2006-12-18 14:20:06 +1100386 writel(TIFM_IRQ_SETALL, fm->addr + FM_CLEAR_INTERRUPT_ENABLE);
Alex Dubov7146f0d2006-12-18 14:20:06 +1100387 free_irq(dev->irq, fm);
388
Alex Dubov4020f2d2006-10-04 02:15:37 -0700389 tifm_remove_adapter(fm);
390
Alex Dubov055b8222007-05-01 20:14:55 -0700391 for (cnt = 0; cnt < fm->num_sockets; cnt++)
392 tifm_7xx1_sock_power_off(tifm_7xx1_sock_addr(fm->addr, cnt));
393
Alex Dubov4020f2d2006-10-04 02:15:37 -0700394 iounmap(fm->addr);
395 pci_intx(dev, 0);
396 pci_release_regions(dev);
397
398 pci_disable_device(dev);
399 tifm_free_adapter(fm);
400}
401
Arvind Yadav404147b2017-07-30 10:56:36 +0530402static const struct pci_device_id tifm_7xx1_pci_tbl[] = {
Alex Dubovb5ad6762006-12-11 01:55:35 +1100403 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX21_XX11_FM, PCI_ANY_ID,
404 PCI_ANY_ID, 0, 0, 0 }, /* xx21 - the one I have */
405 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX12_FM, PCI_ANY_ID,
406 PCI_ANY_ID, 0, 0, 0 },
407 { PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XX20_FM, PCI_ANY_ID,
408 PCI_ANY_ID, 0, 0, 0 },
Alex Dubov4020f2d2006-10-04 02:15:37 -0700409 { }
410};
411
Vaibhav Guptaff249c12020-06-29 13:45:29 +0530412static SIMPLE_DEV_PM_OPS(tifm_7xx1_pm_ops, tifm_7xx1_suspend, tifm_7xx1_resume);
413
Alex Dubov4020f2d2006-10-04 02:15:37 -0700414static struct pci_driver tifm_7xx1_driver = {
415 .name = DRIVER_NAME,
416 .id_table = tifm_7xx1_pci_tbl,
417 .probe = tifm_7xx1_probe,
418 .remove = tifm_7xx1_remove,
Vaibhav Guptaff249c12020-06-29 13:45:29 +0530419 .driver.pm = &tifm_7xx1_pm_ops,
Alex Dubov4020f2d2006-10-04 02:15:37 -0700420};
421
Devendra Naga7e0b2cd2012-08-26 14:32:43 +0530422module_pci_driver(tifm_7xx1_driver);
Alex Dubov4020f2d2006-10-04 02:15:37 -0700423MODULE_AUTHOR("Alex Dubov");
424MODULE_DESCRIPTION("TI FlashMedia host driver");
425MODULE_LICENSE("GPL");
426MODULE_DEVICE_TABLE(pci, tifm_7xx1_pci_tbl);
427MODULE_VERSION(DRIVER_VERSION);