Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/pcmcia/sa1100_shannon.c |
| 3 | * |
| 4 | * PCMCIA implementation routines for Shannon |
| 5 | * |
| 6 | */ |
| 7 | #include <linux/module.h> |
| 8 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/device.h> |
| 10 | #include <linux/init.h> |
| 11 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 12 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 14 | #include <mach/shannon.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <asm/irq.h> |
| 16 | #include "sa1100_generic.h" |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 19 | { |
| 20 | /* All those are inputs */ |
Russell King | 3b61436 | 2012-01-13 23:06:09 +0000 | [diff] [blame] | 21 | GAFR &= ~(GPIO_GPIO(SHANNON_GPIO_EJECT_0) | |
| 22 | GPIO_GPIO(SHANNON_GPIO_EJECT_1) | |
| 23 | GPIO_GPIO(SHANNON_GPIO_RDY_0) | |
| 24 | GPIO_GPIO(SHANNON_GPIO_RDY_1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Russell King | 3b61436 | 2012-01-13 23:06:09 +0000 | [diff] [blame] | 26 | if (skt->nr == 0) { |
| 27 | skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_0; |
| 28 | skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_0"; |
| 29 | skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_0; |
| 30 | skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_0"; |
| 31 | } else { |
| 32 | skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_1; |
| 33 | skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_1"; |
| 34 | skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_1; |
| 35 | skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_1"; |
| 36 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Russell King | 3b61436 | 2012-01-13 23:06:09 +0000 | [diff] [blame] | 38 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static void |
| 42 | shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt, |
| 43 | struct pcmcia_state *state) |
| 44 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | switch (skt->nr) { |
| 46 | case 0: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | state->bvd1 = 1; |
| 48 | state->bvd2 = 1; |
| 49 | state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */ |
| 50 | state->vs_Xv = 0; |
| 51 | break; |
| 52 | |
| 53 | case 1: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | state->bvd1 = 1; |
| 55 | state->bvd2 = 1; |
| 56 | state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */ |
| 57 | state->vs_Xv = 0; |
| 58 | break; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | static int |
| 63 | shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 64 | const socket_state_t *state) |
| 65 | { |
| 66 | switch (state->Vcc) { |
| 67 | case 0: /* power off */ |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 68 | printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | break; |
| 70 | case 50: |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 71 | printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | case 33: |
| 73 | break; |
| 74 | default: |
| 75 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 76 | __func__, state->Vcc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | return -1; |
| 78 | } |
| 79 | |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 80 | printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | /* Silently ignore Vpp, output enable, speaker enable. */ |
| 83 | |
| 84 | return 0; |
| 85 | } |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | static struct pcmcia_low_level shannon_pcmcia_ops = { |
| 88 | .owner = THIS_MODULE, |
| 89 | .hw_init = shannon_pcmcia_hw_init, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | .socket_state = shannon_pcmcia_socket_state, |
| 91 | .configure_socket = shannon_pcmcia_configure_socket, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
Uwe Kleine-König | 5b85e04 | 2010-11-04 10:46:14 +0100 | [diff] [blame] | 94 | int __devinit pcmcia_shannon_init(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | { |
| 96 | int ret = -ENODEV; |
| 97 | |
| 98 | if (machine_is_shannon()) |
| 99 | ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2); |
| 100 | |
| 101 | return ret; |
| 102 | } |