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