Linux 4.16.11
[linux/fpc-iii.git] / drivers / pcmcia / sa1100_simpad.c
blob7ce65bb23a8ee67d082dbeef1679a84f022253a6
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * drivers/pcmcia/sa1100_simpad.c
5 * PCMCIA implementation routines for simpad
7 */
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/device.h>
11 #include <linux/init.h>
13 #include <mach/hardware.h>
14 #include <asm/mach-types.h>
15 #include <asm/irq.h>
16 #include <mach/simpad.h>
17 #include "sa1100_generic.h"
19 static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
22 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
24 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";
29 return 0;
32 static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
34 /* Disable CF bus: */
35 /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/
36 simpad_clear_cs3_bit(PCMCIA_RESET);
39 static void
40 simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
41 struct pcmcia_state *state)
43 long cs3reg = simpad_get_cs3_ro();
45 /* the detect signal is inverted - fix that up here */
46 state->detect = !state->detect;
48 state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */
49 state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */
51 if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) ==
52 (PCMCIA_VS1|PCMCIA_VS2)) {
53 state->vs_3v=0;
54 state->vs_Xv=0;
55 } else {
56 state->vs_3v=1;
57 state->vs_Xv=0;
61 static int
62 simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
63 const socket_state_t *state)
65 unsigned long flags;
67 local_irq_save(flags);
69 /* Murphy: see table of MIC2562a-1 */
70 switch (state->Vcc) {
71 case 0:
72 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
73 break;
75 case 33:
76 simpad_clear_cs3_bit(VCC_3V_EN|EN1);
77 simpad_set_cs3_bit(VCC_5V_EN|EN0);
78 break;
80 case 50:
81 simpad_clear_cs3_bit(VCC_5V_EN|EN1);
82 simpad_set_cs3_bit(VCC_3V_EN|EN0);
83 break;
85 default:
86 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
87 __func__, state->Vcc);
88 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
89 local_irq_restore(flags);
90 return -1;
94 local_irq_restore(flags);
96 return 0;
99 static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
101 simpad_set_cs3_bit(PCMCIA_RESET);
104 static 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,
110 .socket_suspend = simpad_pcmcia_socket_suspend,
113 int pcmcia_simpad_init(struct device *dev)
115 int ret = -ENODEV;
117 if (machine_is_simpad())
118 ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1);
120 return ret;