40 #include <linux/kernel.h>
42 #include <linux/module.h>
48 #include <mach/hardware.h>
54 #ifdef CONFIG_PCMCIA_DEBUG
60 int lvl,
const char *
fmt, ...)
79 #define to_soc_pcmcia_socket(x) \
80 container_of(x, struct soc_pcmcia_socket, socket)
83 calc_speed(
unsigned short *spds,
int num,
unsigned short dflt)
85 unsigned short speed = 0;
88 for (i = 0; i < num; i++)
114 for (i = 0; i <
nr; i++) {
115 if (skt->
stat[i].irq)
117 if (gpio_is_valid(skt->
stat[i].gpio))
121 if (skt->
ops->hw_shutdown)
122 skt->
ops->hw_shutdown(skt);
134 if (skt->
ops->hw_init) {
135 ret = skt->
ops->hw_init(skt);
141 if (gpio_is_valid(skt->
stat[i].gpio)) {
147 __soc_pcmcia_hw_shutdown(skt, i);
154 skt->
socket.pci_irq = irq;
156 skt->
stat[
i].irq = irq;
159 if (skt->
stat[i].irq) {
161 soc_common_pcmcia_interrupt,
163 skt->
stat[i].name, skt);
165 if (gpio_is_valid(skt->
stat[i].gpio))
167 __soc_pcmcia_hw_shutdown(skt, i);
181 if (skt->
stat[i].irq) {
192 if (skt->
stat[i].irq)
219 skt->
ops->socket_state(skt, &
state);
238 else if (
state.bvd2 == 0)
250 static int soc_common_pcmcia_config_skt(
255 ret = skt->
ops->configure_socket(skt, state);
275 "socket %d\n", skt->
nr);
293 debug(skt, 2,
"initializing socket\n");
294 if (skt->
ops->socket_init)
295 skt->
ops->socket_init(skt);
296 soc_pcmcia_hw_enable(skt);
310 static int soc_common_pcmcia_suspend(
struct pcmcia_socket *sock)
314 debug(skt, 2,
"suspending socket\n");
316 soc_pcmcia_hw_disable(skt);
317 if (skt->
ops->socket_suspend)
318 skt->
ops->socket_suspend(skt);
329 debug(skt, 4,
"entering PCMCIA monitoring thread\n");
335 status = soc_common_pcmcia_skt_state(skt);
340 spin_unlock_irqrestore(&status_lock, flags);
342 debug(skt, 4,
"events: %s%s%s%s%s%s\n",
343 events == 0 ?
"<NONE>" :
"",
356 static void soc_common_pcmcia_poll_event(
unsigned long dummy)
359 debug(skt, 4,
"polling for events\n");
363 soc_common_check_status(skt);
375 static irqreturn_t soc_common_pcmcia_interrupt(
int irq,
void *
dev)
379 debug(skt, 3,
"servicing IRQ %d\n", irq);
381 soc_common_check_status(skt);
403 soc_common_pcmcia_get_status(
struct pcmcia_socket *sock,
unsigned int *status)
407 skt->
status = soc_common_pcmcia_skt_state(skt);
421 static int soc_common_pcmcia_set_socket(
426 debug(skt, 2,
"mask: %s%s%s%s%s%s flags: %s%s%s%s%s%s Vcc %d Vpp %d irq %d\n",
427 (state->
csc_mask == 0) ?
"<NONE> " :
"",
433 (state->
flags == 0) ?
"<NONE> " :
"",
441 return soc_common_pcmcia_config_skt(skt, state);
453 static int soc_common_pcmcia_set_io_map(
459 debug(skt, 2,
"map %u speed %u start 0x%08llx stop 0x%08llx\n",
461 (
unsigned long long)map->
stop);
462 debug(skt, 2,
"flags: %s%s%s%s%s%s%s%s\n",
463 (map->
flags == 0) ?
"<NONE>" :
"",
486 skt->
ops->set_timing(skt);
507 static int soc_common_pcmcia_set_mem_map(
512 unsigned short speed = map->
speed;
514 debug(skt, 2,
"map %u speed %u card_start %08x\n",
516 debug(skt, 2,
"flags: %s%s%s%s%s%s%s%s\n",
517 (map->
flags == 0) ?
"<NONE>" :
"",
546 skt->
ops->set_timing(skt);
570 static struct bittbl conf_bits[] = {
579 static void dump_bits(
char **
p,
const char *
prefix,
585 b +=
sprintf(b,
"%-9s:", prefix);
586 for (i = 0; i < sz; i++)
587 if (val & bits[i].
mask)
607 dump_bits(&p,
"status", skt->
status,
618 if (skt->
ops->show_timing)
619 p += skt->
ops->show_timing(skt, p);
627 .init = soc_common_pcmcia_sock_init,
628 .suspend = soc_common_pcmcia_suspend,
629 .get_status = soc_common_pcmcia_get_status,
630 .set_socket = soc_common_pcmcia_set_socket,
631 .set_io_map = soc_common_pcmcia_set_io_map,
632 .set_mem_map = soc_common_pcmcia_set_mem_map,
639 #ifdef CONFIG_CPU_FREQ
649 if (skt->ops->frequency_change)
650 ret += skt->ops->frequency_change(skt, val, freqs);
660 static int soc_pcmcia_cpufreq_register(
void)
668 "notifier for PCMCIA (%d)\n", ret);
673 static void soc_pcmcia_cpufreq_unregister(
void)
704 soc_pcmcia_hw_shutdown(skt);
726 skt->
poll_timer.function = soc_common_pcmcia_poll_event;
754 list_add(&skt->
node, &soc_pcmcia_sockets);
761 skt->
ops->set_timing(skt);
763 ret = soc_pcmcia_hw_init(skt);
767 skt->
socket.ops = &soc_common_pcmcia_operations;
774 skt->
status = soc_common_pcmcia_skt_state(skt);
796 soc_pcmcia_hw_shutdown(skt);