Merge tag 'regmap-fix-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux/fpc-iii.git] / drivers / pcmcia / sa1100_simpad.c
blob784ada5b8c4fa364a2deab7bbf857cb07014e651
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 <mach/simpad.h>
16 #include "sa1100_generic.h"
18 static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
21 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
23 skt->stat[SOC_STAT_CD].name = "cf-detect";
24 skt->stat[SOC_STAT_RDY].name = "cf-ready";
26 return soc_pcmcia_request_gpiods(skt);
29 static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
31 /* Disable CF bus: */
32 /*simpad_set_cs3_bit(PCMCIA_BUFF_DIS);*/
33 simpad_clear_cs3_bit(PCMCIA_RESET);
36 static void
37 simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
38 struct pcmcia_state *state)
40 long cs3reg = simpad_get_cs3_ro();
42 /* bvd1 might be cs3reg & PCMCIA_BVD1 */
43 /* bvd2 might be cs3reg & PCMCIA_BVD2 */
45 if ((cs3reg & (PCMCIA_VS1|PCMCIA_VS2)) ==
46 (PCMCIA_VS1|PCMCIA_VS2)) {
47 state->vs_3v=0;
48 state->vs_Xv=0;
49 } else {
50 state->vs_3v=1;
51 state->vs_Xv=0;
55 static int
56 simpad_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
57 const socket_state_t *state)
59 unsigned long flags;
61 local_irq_save(flags);
63 /* Murphy: see table of MIC2562a-1 */
64 switch (state->Vcc) {
65 case 0:
66 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
67 break;
69 case 33:
70 simpad_clear_cs3_bit(VCC_3V_EN|EN1);
71 simpad_set_cs3_bit(VCC_5V_EN|EN0);
72 break;
74 case 50:
75 simpad_clear_cs3_bit(VCC_5V_EN|EN1);
76 simpad_set_cs3_bit(VCC_3V_EN|EN0);
77 break;
79 default:
80 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
81 __func__, state->Vcc);
82 simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1);
83 local_irq_restore(flags);
84 return -1;
88 local_irq_restore(flags);
90 return 0;
93 static void simpad_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
95 simpad_set_cs3_bit(PCMCIA_RESET);
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,
104 .socket_suspend = simpad_pcmcia_socket_suspend,
107 int pcmcia_simpad_init(struct device *dev)
109 int ret = -ENODEV;
111 if (machine_is_simpad())
112 ret = sa11xx_drv_pcmcia_probe(dev, &simpad_pcmcia_ops, 1, 1);
114 return ret;