1 /*======================================================================
3 Common support code for the PCMCIA control functionality of
4 integrated SOCs like the SA-11x0 and PXA2xx microprocessors.
6 The contents of this file are subject to the Mozilla Public
7 License Version 1.1 (the "License"); you may not use this file
8 except in compliance with the License. You may obtain a copy of
9 the License at http://www.mozilla.org/MPL/
11 Software distributed under the License is distributed on an "AS
12 IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
13 implied. See the License for the specific language governing
14 rights and limitations under the License.
16 The initial developer of the original code is John G. Dorsey
17 <john+@cs.cmu.edu>. Portions created by John G. Dorsey are
18 Copyright (C) 1999 John G. Dorsey. All Rights Reserved.
20 Alternatively, the contents of this file may be used under the
21 terms of the GNU Public License version 2 (the "GPL"), in which
22 case the provisions of the GPL are applicable instead of the
23 above. If you wish to allow the use of your version of this file
24 only under the terms of the GPL and not to allow others to use
25 your version of this file under the MPL, indicate your decision
26 by deleting the provisions above and replace them with the notice
27 and other provisions required by the GPL. If you do not delete
28 the provisions above, a recipient may use your version of this
29 file under either the MPL or the GPL.
31 ======================================================================*/
34 #include <linux/module.h>
35 #include <linux/moduleparam.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/timer.h>
40 #include <linux/interrupt.h>
41 #include <linux/irq.h>
42 #include <linux/spinlock.h>
43 #include <linux/cpufreq.h>
45 #include <asm/hardware.h>
47 #include <asm/system.h>
49 #include "soc_common.h"
51 /* FIXME: platform dependent resource declaration has to move out of this file */
52 #ifdef CONFIG_ARCH_PXA
53 #include <asm/arch/pxa-regs.h>
59 module_param(pc_debug, int, 0644);
61 void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func,
62 int lvl, const char *fmt, ...)
66 printk(KERN_DEBUG "skt%u: %s: ", skt->nr, func);
75 #define to_soc_pcmcia_socket(x) container_of(x, struct soc_pcmcia_socket, socket)
78 calc_speed(unsigned short *spds, int num, unsigned short dflt)
80 unsigned short speed = 0;
83 for (i = 0; i < num; i++)
92 void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *skt, struct soc_pcmcia_timing *timing)
94 timing->io = calc_speed(skt->spd_io, MAX_IO_WIN, SOC_PCMCIA_IO_ACCESS);
95 timing->mem = calc_speed(skt->spd_mem, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS);
96 timing->attr = calc_speed(skt->spd_attr, MAX_WIN, SOC_PCMCIA_3V_MEM_ACCESS);
98 EXPORT_SYMBOL(soc_common_pcmcia_get_timing);
100 static unsigned int soc_common_pcmcia_skt_state(struct soc_pcmcia_socket *skt)
102 struct pcmcia_state state;
105 memset(&state, 0, sizeof(struct pcmcia_state));
107 skt->ops->socket_state(skt, &state);
109 stat = state.detect ? SS_DETECT : 0;
110 stat |= state.ready ? SS_READY : 0;
111 stat |= state.wrprot ? SS_WRPROT : 0;
112 stat |= state.vs_3v ? SS_3VCARD : 0;
113 stat |= state.vs_Xv ? SS_XVCARD : 0;
115 /* The power status of individual sockets is not available
116 * explicitly from the hardware, so we just remember the state
117 * and regurgitate it upon request:
119 stat |= skt->cs_state.Vcc ? SS_POWERON : 0;
121 if (skt->cs_state.flags & SS_IOCARD)
122 stat |= state.bvd1 ? SS_STSCHG : 0;
126 else if (state.bvd2 == 0)
133 * soc_common_pcmcia_config_skt
134 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136 * Convert PCMCIA socket state to our socket configure structure.
139 soc_common_pcmcia_config_skt(struct soc_pcmcia_socket *skt, socket_state_t *state)
143 ret = skt->ops->configure_socket(skt, state);
146 * This really needs a better solution. The IRQ
147 * may or may not be claimed by the driver.
149 if (skt->irq_state != 1 && state->io_irq) {
151 set_irq_type(skt->irq, IRQT_FALLING);
152 } else if (skt->irq_state == 1 && state->io_irq == 0) {
154 set_irq_type(skt->irq, IRQT_NOEDGE);
157 skt->cs_state = *state;
161 printk(KERN_ERR "soc_common_pcmcia: unable to configure "
162 "socket %d\n", skt->nr);
167 /* soc_common_pcmcia_sock_init()
168 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
170 * (Re-)Initialise the socket, turning on status interrupts
171 * and PCMCIA bus. This must wait for power to stabilise
172 * so that the card status signals report correctly.
176 static int soc_common_pcmcia_sock_init(struct pcmcia_socket *sock)
178 struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock);
180 debug(skt, 2, "initializing socket\n");
182 skt->ops->socket_init(skt);
188 * soc_common_pcmcia_suspend()
189 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
191 * Remove power on the socket, disable IRQs from the card.
192 * Turn off status interrupts, and disable the PCMCIA bus.
196 static int soc_common_pcmcia_suspend(struct pcmcia_socket *sock)
198 struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock);
200 debug(skt, 2, "suspending socket\n");
202 skt->ops->socket_suspend(skt);
207 static DEFINE_SPINLOCK(status_lock);
209 static void soc_common_check_status(struct soc_pcmcia_socket *skt)
213 debug(skt, 4, "entering PCMCIA monitoring thread\n");
219 status = soc_common_pcmcia_skt_state(skt);
221 spin_lock_irqsave(&status_lock, flags);
222 events = (status ^ skt->status) & skt->cs_state.csc_mask;
223 skt->status = status;
224 spin_unlock_irqrestore(&status_lock, flags);
226 debug(skt, 4, "events: %s%s%s%s%s%s\n",
227 events == 0 ? "<NONE>" : "",
228 events & SS_DETECT ? "DETECT " : "",
229 events & SS_READY ? "READY " : "",
230 events & SS_BATDEAD ? "BATDEAD " : "",
231 events & SS_BATWARN ? "BATWARN " : "",
232 events & SS_STSCHG ? "STSCHG " : "");
235 pcmcia_parse_events(&skt->socket, events);
239 /* Let's poll for events in addition to IRQs since IRQ only is unreliable... */
240 static void soc_common_pcmcia_poll_event(unsigned long dummy)
242 struct soc_pcmcia_socket *skt = (struct soc_pcmcia_socket *)dummy;
243 debug(skt, 4, "polling for events\n");
245 mod_timer(&skt->poll_timer, jiffies + SOC_PCMCIA_POLL_PERIOD);
247 soc_common_check_status(skt);
252 * Service routine for socket driver interrupts (requested by the
253 * low-level PCMCIA init() operation via soc_common_pcmcia_thread()).
254 * The actual interrupt-servicing work is performed by
255 * soc_common_pcmcia_thread(), largely because the Card Services event-
256 * handling code performs scheduling operations which cannot be
257 * executed from within an interrupt context.
259 static irqreturn_t soc_common_pcmcia_interrupt(int irq, void *dev, struct pt_regs *regs)
261 struct soc_pcmcia_socket *skt = dev;
263 debug(skt, 3, "servicing IRQ %d\n", irq);
265 soc_common_check_status(skt);
272 * Implements the get_status() operation for the in-kernel PCMCIA
273 * service (formerly SS_GetStatus in Card Services). Essentially just
274 * fills in bits in `status' according to internal driver state or
275 * the value of the voltage detect chipselect register.
277 * As a debugging note, during card startup, the PCMCIA core issues
278 * three set_socket() commands in a row the first with RESET deasserted,
279 * the second with RESET asserted, and the last with RESET deasserted
280 * again. Following the third set_socket(), a get_status() command will
281 * be issued. The kernel is looking for the SS_READY flag (see
282 * setup_socket(), reset_socket(), and unreset_socket() in cs.c).
287 soc_common_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status)
289 struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock);
291 skt->status = soc_common_pcmcia_skt_state(skt);
292 *status = skt->status;
299 * Implements the set_socket() operation for the in-kernel PCMCIA
300 * service (formerly SS_SetSocket in Card Services). We more or
301 * less punt all of this work and let the kernel handle the details
302 * of power configuration, reset, &c. We also record the value of
303 * `state' in order to regurgitate it to the PCMCIA core later.
306 soc_common_pcmcia_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
308 struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock);
310 debug(skt, 2, "mask: %s%s%s%s%s%sflags: %s%s%s%s%s%sVcc %d Vpp %d irq %d\n",
311 (state->csc_mask==0)?"<NONE> ":"",
312 (state->csc_mask&SS_DETECT)?"DETECT ":"",
313 (state->csc_mask&SS_READY)?"READY ":"",
314 (state->csc_mask&SS_BATDEAD)?"BATDEAD ":"",
315 (state->csc_mask&SS_BATWARN)?"BATWARN ":"",
316 (state->csc_mask&SS_STSCHG)?"STSCHG ":"",
317 (state->flags==0)?"<NONE> ":"",
318 (state->flags&SS_PWR_AUTO)?"PWR_AUTO ":"",
319 (state->flags&SS_IOCARD)?"IOCARD ":"",
320 (state->flags&SS_RESET)?"RESET ":"",
321 (state->flags&SS_SPKR_ENA)?"SPKR_ENA ":"",
322 (state->flags&SS_OUTPUT_ENA)?"OUTPUT_ENA ":"",
323 state->Vcc, state->Vpp, state->io_irq);
325 return soc_common_pcmcia_config_skt(skt, state);
330 * Implements the set_io_map() operation for the in-kernel PCMCIA
331 * service (formerly SS_SetIOMap in Card Services). We configure
332 * the map speed as requested, but override the address ranges
333 * supplied by Card Services.
335 * Returns: 0 on success, -1 on error
338 soc_common_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map)
340 struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock);
341 unsigned short speed = map->speed;
343 debug(skt, 2, "map %u speed %u start 0x%08x stop 0x%08x\n",
344 map->map, map->speed, map->start, map->stop);
345 debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n",
346 (map->flags==0)?"<NONE>":"",
347 (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
348 (map->flags&MAP_16BIT)?"16BIT ":"",
349 (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
350 (map->flags&MAP_0WS)?"0WS ":"",
351 (map->flags&MAP_WRPROT)?"WRPROT ":"",
352 (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"",
353 (map->flags&MAP_PREFETCH)?"PREFETCH ":"");
355 if (map->map >= MAX_IO_WIN) {
356 printk(KERN_ERR "%s(): map (%d) out of range\n", __FUNCTION__,
361 if (map->flags & MAP_ACTIVE) {
363 speed = SOC_PCMCIA_IO_ACCESS;
368 skt->spd_io[map->map] = speed;
369 skt->ops->set_timing(skt);
372 map->stop = PAGE_SIZE-1;
374 map->stop -= map->start;
375 map->stop += skt->socket.io_offset;
376 map->start = skt->socket.io_offset;
383 * Implements the set_mem_map() operation for the in-kernel PCMCIA
384 * service (formerly SS_SetMemMap in Card Services). We configure
385 * the map speed as requested, but override the address ranges
386 * supplied by Card Services.
388 * Returns: 0 on success, -ERRNO on error
391 soc_common_pcmcia_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map *map)
393 struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock);
394 struct resource *res;
395 unsigned short speed = map->speed;
397 debug(skt, 2, "map %u speed %u card_start %08x\n",
398 map->map, map->speed, map->card_start);
399 debug(skt, 2, "flags: %s%s%s%s%s%s%s%s\n",
400 (map->flags==0)?"<NONE>":"",
401 (map->flags&MAP_ACTIVE)?"ACTIVE ":"",
402 (map->flags&MAP_16BIT)?"16BIT ":"",
403 (map->flags&MAP_AUTOSZ)?"AUTOSZ ":"",
404 (map->flags&MAP_0WS)?"0WS ":"",
405 (map->flags&MAP_WRPROT)?"WRPROT ":"",
406 (map->flags&MAP_ATTRIB)?"ATTRIB ":"",
407 (map->flags&MAP_USE_WAIT)?"USE_WAIT ":"");
409 if (map->map >= MAX_WIN)
412 if (map->flags & MAP_ACTIVE) {
419 if (map->flags & MAP_ATTRIB) {
420 res = &skt->res_attr;
421 skt->spd_attr[map->map] = speed;
422 skt->spd_mem[map->map] = 0;
425 skt->spd_attr[map->map] = 0;
426 skt->spd_mem[map->map] = speed;
429 skt->ops->set_timing(skt);
431 map->static_start = res->start + map->card_start;
441 static struct bittbl status_bits[] = {
442 { SS_WRPROT, "SS_WRPROT" },
443 { SS_BATDEAD, "SS_BATDEAD" },
444 { SS_BATWARN, "SS_BATWARN" },
445 { SS_READY, "SS_READY" },
446 { SS_DETECT, "SS_DETECT" },
447 { SS_POWERON, "SS_POWERON" },
448 { SS_STSCHG, "SS_STSCHG" },
449 { SS_3VCARD, "SS_3VCARD" },
450 { SS_XVCARD, "SS_XVCARD" },
453 static struct bittbl conf_bits[] = {
454 { SS_PWR_AUTO, "SS_PWR_AUTO" },
455 { SS_IOCARD, "SS_IOCARD" },
456 { SS_RESET, "SS_RESET" },
457 { SS_DMA_MODE, "SS_DMA_MODE" },
458 { SS_SPKR_ENA, "SS_SPKR_ENA" },
459 { SS_OUTPUT_ENA, "SS_OUTPUT_ENA" },
463 dump_bits(char **p, const char *prefix, unsigned int val, struct bittbl *bits, int sz)
468 b += sprintf(b, "%-9s:", prefix);
469 for (i = 0; i < sz; i++)
470 if (val & bits[i].mask)
471 b += sprintf(b, " %s", bits[i].name);
477 * Implements the /sys/class/pcmcia_socket/??/status file.
479 * Returns: the number of characters added to the buffer
481 static ssize_t show_status(struct class_device *class_dev, char *buf)
483 struct soc_pcmcia_socket *skt =
484 container_of(class_dev, struct soc_pcmcia_socket, socket.dev);
487 p+=sprintf(p, "slot : %d\n", skt->nr);
489 dump_bits(&p, "status", skt->status,
490 status_bits, ARRAY_SIZE(status_bits));
491 dump_bits(&p, "csc_mask", skt->cs_state.csc_mask,
492 status_bits, ARRAY_SIZE(status_bits));
493 dump_bits(&p, "cs_flags", skt->cs_state.flags,
494 conf_bits, ARRAY_SIZE(conf_bits));
496 p+=sprintf(p, "Vcc : %d\n", skt->cs_state.Vcc);
497 p+=sprintf(p, "Vpp : %d\n", skt->cs_state.Vpp);
498 p+=sprintf(p, "IRQ : %d (%d)\n", skt->cs_state.io_irq, skt->irq);
499 if (skt->ops->show_timing)
500 p+=skt->ops->show_timing(skt, p);
504 static CLASS_DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
507 static struct pccard_operations soc_common_pcmcia_operations = {
508 .init = soc_common_pcmcia_sock_init,
509 .suspend = soc_common_pcmcia_suspend,
510 .get_status = soc_common_pcmcia_get_status,
511 .set_socket = soc_common_pcmcia_set_socket,
512 .set_io_map = soc_common_pcmcia_set_io_map,
513 .set_mem_map = soc_common_pcmcia_set_mem_map,
517 int soc_pcmcia_request_irqs(struct soc_pcmcia_socket *skt,
518 struct pcmcia_irqs *irqs, int nr)
522 for (i = 0; i < nr; i++) {
523 if (irqs[i].sock != skt->nr)
525 res = request_irq(irqs[i].irq, soc_common_pcmcia_interrupt,
526 IRQF_DISABLED, irqs[i].str, skt);
529 set_irq_type(irqs[i].irq, IRQT_NOEDGE);
533 printk(KERN_ERR "PCMCIA: request for IRQ%d failed (%d)\n",
537 if (irqs[i].sock == skt->nr)
538 free_irq(irqs[i].irq, skt);
542 EXPORT_SYMBOL(soc_pcmcia_request_irqs);
544 void soc_pcmcia_free_irqs(struct soc_pcmcia_socket *skt,
545 struct pcmcia_irqs *irqs, int nr)
549 for (i = 0; i < nr; i++)
550 if (irqs[i].sock == skt->nr)
551 free_irq(irqs[i].irq, skt);
553 EXPORT_SYMBOL(soc_pcmcia_free_irqs);
555 void soc_pcmcia_disable_irqs(struct soc_pcmcia_socket *skt,
556 struct pcmcia_irqs *irqs, int nr)
560 for (i = 0; i < nr; i++)
561 if (irqs[i].sock == skt->nr)
562 set_irq_type(irqs[i].irq, IRQT_NOEDGE);
564 EXPORT_SYMBOL(soc_pcmcia_disable_irqs);
566 void soc_pcmcia_enable_irqs(struct soc_pcmcia_socket *skt,
567 struct pcmcia_irqs *irqs, int nr)
571 for (i = 0; i < nr; i++)
572 if (irqs[i].sock == skt->nr) {
573 set_irq_type(irqs[i].irq, IRQT_RISING);
574 set_irq_type(irqs[i].irq, IRQT_BOTHEDGE);
577 EXPORT_SYMBOL(soc_pcmcia_enable_irqs);
580 LIST_HEAD(soc_pcmcia_sockets);
581 DECLARE_MUTEX(soc_pcmcia_sockets_lock);
583 static const char *skt_names[] = {
588 struct skt_dev_info {
590 struct soc_pcmcia_socket skt[0];
593 #define SKT_DEV_INFO_SIZE(n) \
594 (sizeof(struct skt_dev_info) + (n)*sizeof(struct soc_pcmcia_socket))
596 #ifdef CONFIG_CPU_FREQ
598 soc_pcmcia_notifier(struct notifier_block *nb, unsigned long val, void *data)
600 struct soc_pcmcia_socket *skt;
601 struct cpufreq_freqs *freqs = data;
604 down(&soc_pcmcia_sockets_lock);
605 list_for_each_entry(skt, &soc_pcmcia_sockets, node)
606 if ( skt->ops->frequency_change )
607 ret += skt->ops->frequency_change(skt, val, freqs);
608 up(&soc_pcmcia_sockets_lock);
613 static struct notifier_block soc_pcmcia_notifier_block = {
614 .notifier_call = soc_pcmcia_notifier
617 static int soc_pcmcia_cpufreq_register(void)
621 ret = cpufreq_register_notifier(&soc_pcmcia_notifier_block,
622 CPUFREQ_TRANSITION_NOTIFIER);
624 printk(KERN_ERR "Unable to register CPU frequency change "
625 "notifier for PCMCIA (%d)\n", ret);
629 static void soc_pcmcia_cpufreq_unregister(void)
631 cpufreq_unregister_notifier(&soc_pcmcia_notifier_block, CPUFREQ_TRANSITION_NOTIFIER);
635 static int soc_pcmcia_cpufreq_register(void) { return 0; }
636 static void soc_pcmcia_cpufreq_unregister(void) {}
639 int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr)
641 struct skt_dev_info *sinfo;
642 struct soc_pcmcia_socket *skt;
645 down(&soc_pcmcia_sockets_lock);
647 sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
656 * Initialise the per-socket structure.
658 for (i = 0; i < nr; i++) {
659 skt = &sinfo->skt[i];
661 skt->socket.ops = &soc_common_pcmcia_operations;
662 skt->socket.owner = ops->owner;
663 skt->socket.dev.dev = dev;
665 init_timer(&skt->poll_timer);
666 skt->poll_timer.function = soc_common_pcmcia_poll_event;
667 skt->poll_timer.data = (unsigned long)skt;
668 skt->poll_timer.expires = jiffies + SOC_PCMCIA_POLL_PERIOD;
675 skt->res_skt.start = _PCMCIA(skt->nr);
676 skt->res_skt.end = _PCMCIA(skt->nr) + PCMCIASp - 1;
677 skt->res_skt.name = skt_names[skt->nr];
678 skt->res_skt.flags = IORESOURCE_MEM;
680 ret = request_resource(&iomem_resource, &skt->res_skt);
684 skt->res_io.start = _PCMCIAIO(skt->nr);
685 skt->res_io.end = _PCMCIAIO(skt->nr) + PCMCIAIOSp - 1;
686 skt->res_io.name = "io";
687 skt->res_io.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
689 ret = request_resource(&skt->res_skt, &skt->res_io);
693 skt->res_mem.start = _PCMCIAMem(skt->nr);
694 skt->res_mem.end = _PCMCIAMem(skt->nr) + PCMCIAMemSp - 1;
695 skt->res_mem.name = "memory";
696 skt->res_mem.flags = IORESOURCE_MEM;
698 ret = request_resource(&skt->res_skt, &skt->res_mem);
702 skt->res_attr.start = _PCMCIAAttr(skt->nr);
703 skt->res_attr.end = _PCMCIAAttr(skt->nr) + PCMCIAAttrSp - 1;
704 skt->res_attr.name = "attribute";
705 skt->res_attr.flags = IORESOURCE_MEM;
707 ret = request_resource(&skt->res_skt, &skt->res_attr);
711 skt->virt_io = ioremap(skt->res_io.start, 0x10000);
712 if (skt->virt_io == NULL) {
717 if (list_empty(&soc_pcmcia_sockets))
718 soc_pcmcia_cpufreq_register();
720 list_add(&skt->node, &soc_pcmcia_sockets);
723 * We initialize default socket timing here, because
724 * we are not guaranteed to see a SetIOMap operation at
727 ops->set_timing(skt);
729 ret = ops->hw_init(skt);
733 skt->socket.features = SS_CAP_STATIC_MAP|SS_CAP_PCCARD;
734 skt->socket.resource_ops = &pccard_static_ops;
735 skt->socket.irq_mask = 0;
736 skt->socket.map_size = PAGE_SIZE;
737 skt->socket.pci_irq = skt->irq;
738 skt->socket.io_offset = (unsigned long)skt->virt_io;
740 skt->status = soc_common_pcmcia_skt_state(skt);
742 ret = pcmcia_register_socket(&skt->socket);
746 WARN_ON(skt->socket.sock != i);
748 add_timer(&skt->poll_timer);
750 class_device_create_file(&skt->socket.dev, &class_device_attr_status);
753 dev_set_drvdata(dev, sinfo);
758 skt = &sinfo->skt[i];
760 del_timer_sync(&skt->poll_timer);
761 pcmcia_unregister_socket(&skt->socket);
764 flush_scheduled_work();
766 ops->hw_shutdown(skt);
768 list_del(&skt->node);
769 iounmap(skt->virt_io);
771 release_resource(&skt->res_attr);
773 release_resource(&skt->res_mem);
775 release_resource(&skt->res_io);
777 release_resource(&skt->res_skt);
785 up(&soc_pcmcia_sockets_lock);
789 int soc_common_drv_pcmcia_remove(struct device *dev)
791 struct skt_dev_info *sinfo = dev_get_drvdata(dev);
794 dev_set_drvdata(dev, NULL);
796 down(&soc_pcmcia_sockets_lock);
797 for (i = 0; i < sinfo->nskt; i++) {
798 struct soc_pcmcia_socket *skt = &sinfo->skt[i];
800 del_timer_sync(&skt->poll_timer);
802 pcmcia_unregister_socket(&skt->socket);
804 flush_scheduled_work();
806 skt->ops->hw_shutdown(skt);
808 soc_common_pcmcia_config_skt(skt, &dead_socket);
810 list_del(&skt->node);
811 iounmap(skt->virt_io);
813 release_resource(&skt->res_attr);
814 release_resource(&skt->res_mem);
815 release_resource(&skt->res_io);
816 release_resource(&skt->res_skt);
818 if (list_empty(&soc_pcmcia_sockets))
819 soc_pcmcia_cpufreq_unregister();
821 up(&soc_pcmcia_sockets_lock);