Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/pcmcia/sa1100_cerf.c |
| 3 | * |
| 4 | * PCMCIA implementation routines for CerfBoard |
| 5 | * Based off the Assabet. |
| 6 | * |
| 7 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/module.h> |
| 9 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/device.h> |
| 11 | #include <linux/init.h> |
| 12 | #include <linux/delay.h> |
| 13 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 14 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/mach-types.h> |
| 16 | #include <asm/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 17 | #include <mach/cerf.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include "sa1100_generic.h" |
| 19 | |
| 20 | #define CERF_SOCKET 1 |
| 21 | |
| 22 | static struct pcmcia_irqs irqs[] = { |
| 23 | { CERF_SOCKET, CERF_IRQ_GPIO_CF_CD, "CF_CD" }, |
| 24 | { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD2, "CF_BVD2" }, |
| 25 | { CERF_SOCKET, CERF_IRQ_GPIO_CF_BVD1, "CF_BVD1" } |
| 26 | }; |
| 27 | |
| 28 | static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 29 | { |
Russell King - ARM Linux | 66024db | 2009-03-29 22:45:26 +0100 | [diff] [blame] | 30 | skt->socket.pci_irq = CERF_IRQ_GPIO_CF_IRQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs)); |
| 33 | } |
| 34 | |
| 35 | static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) |
| 36 | { |
| 37 | soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); |
| 38 | } |
| 39 | |
| 40 | static void |
| 41 | cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state) |
| 42 | { |
| 43 | unsigned long levels = GPLR; |
| 44 | |
| 45 | state->detect = (levels & CERF_GPIO_CF_CD) ?0:1; |
| 46 | state->ready = (levels & CERF_GPIO_CF_IRQ) ?1:0; |
| 47 | state->bvd1 = (levels & CERF_GPIO_CF_BVD1)?1:0; |
| 48 | state->bvd2 = (levels & CERF_GPIO_CF_BVD2)?1:0; |
| 49 | state->wrprot = 0; |
| 50 | state->vs_3v = 1; |
| 51 | state->vs_Xv = 0; |
| 52 | } |
| 53 | |
| 54 | static int |
| 55 | cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 56 | const socket_state_t *state) |
| 57 | { |
| 58 | switch (state->Vcc) { |
| 59 | case 0: |
| 60 | case 50: |
| 61 | case 33: |
| 62 | break; |
| 63 | |
| 64 | default: |
| 65 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 66 | __func__, state->Vcc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | return -1; |
| 68 | } |
| 69 | |
| 70 | if (state->flags & SS_RESET) { |
| 71 | GPSR = CERF_GPIO_CF_RESET; |
| 72 | } else { |
| 73 | GPCR = CERF_GPIO_CF_RESET; |
| 74 | } |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static void cerf_pcmcia_socket_init(struct soc_pcmcia_socket *skt) |
| 80 | { |
| 81 | soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs)); |
| 82 | } |
| 83 | |
| 84 | static void cerf_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) |
| 85 | { |
| 86 | soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs)); |
| 87 | } |
| 88 | |
| 89 | static struct pcmcia_low_level cerf_pcmcia_ops = { |
| 90 | .owner = THIS_MODULE, |
| 91 | .hw_init = cerf_pcmcia_hw_init, |
| 92 | .hw_shutdown = cerf_pcmcia_hw_shutdown, |
| 93 | .socket_state = cerf_pcmcia_socket_state, |
| 94 | .configure_socket = cerf_pcmcia_configure_socket, |
| 95 | |
| 96 | .socket_init = cerf_pcmcia_socket_init, |
| 97 | .socket_suspend = cerf_pcmcia_socket_suspend, |
| 98 | }; |
| 99 | |
Uwe Kleine-König | 5b85e04 | 2010-11-04 10:46:14 +0100 | [diff] [blame] | 100 | int __devinit pcmcia_cerf_init(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | { |
| 102 | int ret = -ENODEV; |
| 103 | |
| 104 | if (machine_is_cerf()) |
| 105 | ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1); |
| 106 | |
| 107 | return ret; |
| 108 | } |