Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/pcmcia/sa1100_simpad.c |
| 3 | * |
| 4 | * PCMCIA implementation routines for simpad |
| 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> |
| 14 | #include <asm/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 15 | #include <mach/simpad.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include "sa1100_generic.h" |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 19 | { |
| 20 | |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 21 | simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Russell King | b1d8a5f | 2012-01-13 23:06:48 +0000 | [diff] [blame] | 23 | skt->stat[SOC_STAT_CD].gpio = GPIO_CF_CD; |
| 24 | skt->stat[SOC_STAT_CD].name = "CF_CD"; |
| 25 | skt->stat[SOC_STAT_RDY].gpio = GPIO_CF_IRQ; |
| 26 | skt->stat[SOC_STAT_RDY].name = "CF_RDY"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Russell King | b1d8a5f | 2012-01-13 23:06:48 +0000 | [diff] [blame] | 28 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) |
| 32 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | /* Disable CF bus: */ |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 34 | /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/ |
| 35 | simpad_clear_cs3_bit(PCMCIA_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static void |
| 39 | simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt, |
| 40 | struct pcmcia_state *state) |
| 41 | { |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 42 | long cs3reg = simpad_get_cs3_ro(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
Russell King | b1d8a5f | 2012-01-13 23:06:48 +0000 | [diff] [blame] | 44 | /* the detect signal is inverted - fix that up here */ |
| 45 | state->detect = !state->detect; |
| 46 | |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 47 | state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */ |
| 48 | state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */ |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 49 | |
| 50 | if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) == |
| 51 | (PCMCIA_VS1|PCMCIA_VS2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | state->vs_3v=0; |
| 53 | state->vs_Xv=0; |
| 54 | } else { |
| 55 | state->vs_3v=1; |
| 56 | state->vs_Xv=0; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | static int |
| 61 | simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 62 | const socket_state_t *state) |
| 63 | { |
| 64 | unsigned long flags; |
| 65 | |
| 66 | local_irq_save(flags); |
| 67 | |
| 68 | /* Murphy: see table of MIC2562a-1 */ |
| 69 | switch (state->Vcc) { |
| 70 | case 0: |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 71 | simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | break; |
| 73 | |
| 74 | case 33: |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 75 | simpad_clear_cs3_bit(VCC_3V_EN|EN1); |
| 76 | simpad_set_cs3_bit(VCC_5V_EN|EN0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | break; |
| 78 | |
| 79 | case 50: |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 80 | simpad_clear_cs3_bit(VCC_5V_EN|EN1); |
| 81 | simpad_set_cs3_bit(VCC_3V_EN|EN0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | break; |
| 83 | |
| 84 | default: |
| 85 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 86 | __func__, state->Vcc); |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 87 | simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | local_irq_restore(flags); |
| 89 | return -1; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | local_irq_restore(flags); |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) |
| 99 | { |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 100 | simpad_set_cs3_bit(PCMCIA_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | static struct pcmcia_low_level simpad_pcmcia_ops = { |
| 104 | .owner = THIS_MODULE, |
| 105 | .hw_init = simpad_pcmcia_hw_init, |
| 106 | .hw_shutdown = simpad_pcmcia_hw_shutdown, |
| 107 | .socket_state = simpad_pcmcia_socket_state, |
| 108 | .configure_socket = simpad_pcmcia_configure_socket, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | .socket_suspend = simpad_pcmcia_socket_suspend, |
| 110 | }; |
| 111 | |
Uwe Kleine-König | 5b85e04 | 2010-11-04 10:46:14 +0100 | [diff] [blame] | 112 | int __devinit pcmcia_simpad_init(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | { |
| 114 | int ret = -ENODEV; |
| 115 | |
| 116 | if (machine_is_simpad()) |
| 117 | ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1); |
| 118 | |
| 119 | return ret; |
| 120 | } |