Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * drivers/pcmcia/sa1100_simpad.c |
| 4 | * |
| 5 | * PCMCIA implementation routines for simpad |
| 6 | * |
| 7 | */ |
| 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 | |
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/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 | 64b2f12 | 2016-08-31 08:49:48 +0100 | [diff] [blame] | 23 | skt->stat[SOC_STAT_CD].name = "cf-detect"; |
| 24 | skt->stat[SOC_STAT_RDY].name = "cf-ready"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Russell King | 64b2f12 | 2016-08-31 08:49:48 +0100 | [diff] [blame] | 26 | return soc_pcmcia_request_gpiods(skt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) |
| 30 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /* Disable CF bus: */ |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 32 | /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/ |
| 33 | simpad_clear_cs3_bit(PCMCIA_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | static void |
| 37 | simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt, |
| 38 | struct pcmcia_state *state) |
| 39 | { |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 40 | long cs3reg = simpad_get_cs3_ro(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 42 | state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */ |
| 43 | state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */ |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 44 | |
| 45 | if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) == |
| 46 | (PCMCIA_VS1|PCMCIA_VS2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | state->vs_3v=0; |
| 48 | state->vs_Xv=0; |
| 49 | } else { |
| 50 | state->vs_3v=1; |
| 51 | state->vs_Xv=0; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | static int |
| 56 | simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
| 57 | const socket_state_t *state) |
| 58 | { |
| 59 | unsigned long flags; |
| 60 | |
| 61 | local_irq_save(flags); |
| 62 | |
| 63 | /* Murphy: see table of MIC2562a-1 */ |
| 64 | switch (state->Vcc) { |
| 65 | case 0: |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 66 | simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | break; |
| 68 | |
| 69 | case 33: |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 70 | simpad_clear_cs3_bit(VCC_3V_EN|EN1); |
| 71 | simpad_set_cs3_bit(VCC_5V_EN|EN0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | break; |
| 73 | |
| 74 | case 50: |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 75 | simpad_clear_cs3_bit(VCC_5V_EN|EN1); |
| 76 | simpad_set_cs3_bit(VCC_3V_EN|EN0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | break; |
| 78 | |
| 79 | default: |
| 80 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", |
Harvey Harrison | 2e11cb4 | 2008-05-01 04:34:54 -0700 | [diff] [blame] | 81 | __func__, state->Vcc); |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 82 | simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | local_irq_restore(flags); |
| 84 | return -1; |
| 85 | } |
| 86 | |
| 87 | |
| 88 | local_irq_restore(flags); |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) |
| 94 | { |
Jochen Friedrich | de0bc0d | 2011-08-18 21:50:31 +0100 | [diff] [blame] | 95 | simpad_set_cs3_bit(PCMCIA_RESET); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | static struct pcmcia_low_level simpad_pcmcia_ops = { |
| 99 | .owner = THIS_MODULE, |
| 100 | .hw_init = simpad_pcmcia_hw_init, |
| 101 | .hw_shutdown = simpad_pcmcia_hw_shutdown, |
| 102 | .socket_state = simpad_pcmcia_socket_state, |
| 103 | .configure_socket = simpad_pcmcia_configure_socket, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | .socket_suspend = simpad_pcmcia_socket_suspend, |
| 105 | }; |
| 106 | |
Bill Pemberton | 34cdf25 | 2012-11-19 13:23:12 -0500 | [diff] [blame] | 107 | int pcmcia_simpad_init(struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { |
| 109 | int ret = -ENODEV; |
| 110 | |
| 111 | if (machine_is_simpad()) |
| 112 | ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1); |
| 113 | |
| 114 | return ret; |
| 115 | } |