blob: 7ce65bb23a8ee67d082dbeef1679a84f022253a6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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 Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/device.h>
11#include <linux/init.h>
12
Russell Kinga09e64f2008-08-05 16:14:15 +010013#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <asm/mach-types.h>
15#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010016#include <mach/simpad.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include "sa1100_generic.h"
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
20{
21
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010022 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Russell Kingb1d8a5f2012-01-13 23:06:48 +000024 skt->stat[SOC_STAT_CD].gpio = GPIO_CF_CD;
25 skt->stat[SOC_STAT_CD].name = "CF_CD";
26 skt->stat[SOC_STAT_RDY].gpio = GPIO_CF_IRQ;
27 skt->stat[SOC_STAT_RDY].name = "CF_RDY";
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
Russell Kingb1d8a5f2012-01-13 23:06:48 +000029 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
31
32static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
33{
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 /* Disable CF bus: */
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010035 /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/
36 simpad_clear_cs3_bit(PCMCIA_RESET);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037}
38
39static void
40simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
41 struct pcmcia_state *state)
42{
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010043 long cs3reg = simpad_get_cs3_ro();
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Russell Kingb1d8a5f2012-01-13 23:06:48 +000045 /* the detect signal is inverted - fix that up here */
46 state->detect = !state->detect;
47
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010048 state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */
49 state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010050
51 if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) ==
52 (PCMCIA_VS1|PCMCIA_VS2)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 state->vs_3v=0;
54 state->vs_Xv=0;
55 } else {
56 state->vs_3v=1;
57 state->vs_Xv=0;
58 }
59}
60
61static int
62simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
63 const socket_state_t *state)
64{
65 unsigned long flags;
66
67 local_irq_save(flags);
68
69 /* Murphy: see table of MIC2562a-1 */
70 switch (state->Vcc) {
71 case 0:
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010072 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 break;
74
75 case 33:
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010076 simpad_clear_cs3_bit(VCC_3V_EN|EN1);
77 simpad_set_cs3_bit(VCC_5V_EN|EN0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 break;
79
80 case 50:
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010081 simpad_clear_cs3_bit(VCC_5V_EN|EN1);
82 simpad_set_cs3_bit(VCC_3V_EN|EN0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 break;
84
85 default:
86 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
Harvey Harrison2e11cb42008-05-01 04:34:54 -070087 __func__, state->Vcc);
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +010088 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 local_irq_restore(flags);
90 return -1;
91 }
92
93
94 local_irq_restore(flags);
95
96 return 0;
97}
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
100{
Jochen Friedrichde0bc0d2011-08-18 21:50:31 +0100101 simpad_set_cs3_bit(PCMCIA_RESET);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102}
103
104static struct pcmcia_low_level simpad_pcmcia_ops = {
105 .owner = THIS_MODULE,
106 .hw_init = simpad_pcmcia_hw_init,
107 .hw_shutdown = simpad_pcmcia_hw_shutdown,
108 .socket_state = simpad_pcmcia_socket_state,
109 .configure_socket = simpad_pcmcia_configure_socket,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 .socket_suspend = simpad_pcmcia_socket_suspend,
111};
112
Bill Pemberton34cdf252012-11-19 13:23:12 -0500113int pcmcia_simpad_init(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114{
115 int ret = -ENODEV;
116
117 if (machine_is_simpad())
118 ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1);
119
120 return ret;
121}