1 // SPDX-License-Identifier: GPL-2.0
3 * drivers/pcmcia/sa1100_h3600.c
5 * PCMCIA implementation routines for H3600
8 #include <linux/module.h>
9 #include <linux/kernel.h>
10 #include <linux/device.h>
11 #include <linux/interrupt.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/gpio.h>
16 #include <mach/hardware.h>
18 #include <asm/mach-types.h>
19 #include <mach/h3xxx.h>
21 #include "sa1100_generic.h"
23 static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
27 skt->stat[SOC_STAT_CD].name = skt->nr ? "pcmcia1-detect" : "pcmcia0-detect";
28 skt->stat[SOC_STAT_RDY].name = skt->nr ? "pcmcia1-ready" : "pcmcia0-ready";
30 err = soc_pcmcia_request_gpiods(skt);
36 err = gpio_request(H3XXX_EGPIO_OPT_NVRAM_ON, "OPT NVRAM ON");
39 err = gpio_direction_output(H3XXX_EGPIO_OPT_NVRAM_ON, 0);
42 err = gpio_request(H3XXX_EGPIO_OPT_ON, "OPT ON");
45 err = gpio_direction_output(H3XXX_EGPIO_OPT_ON, 0);
48 err = gpio_request(H3XXX_EGPIO_OPT_RESET, "OPT RESET");
51 err = gpio_direction_output(H3XXX_EGPIO_OPT_RESET, 0);
54 err = gpio_request(H3XXX_EGPIO_CARD_RESET, "PCMCIA CARD RESET");
57 err = gpio_direction_output(H3XXX_EGPIO_CARD_RESET, 0);
66 err06: gpio_free(H3XXX_EGPIO_CARD_RESET);
67 err05: gpio_free(H3XXX_EGPIO_OPT_RESET);
68 err04: gpio_free(H3XXX_EGPIO_OPT_ON);
69 err03: gpio_free(H3XXX_EGPIO_OPT_NVRAM_ON);
70 err01: gpio_free(H3XXX_GPIO_PCMCIA_IRQ0);
74 static void h3600_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
79 gpio_set_value(H3XXX_EGPIO_OPT_NVRAM_ON, 0);
80 gpio_set_value(H3XXX_EGPIO_OPT_ON, 0);
81 gpio_set_value(H3XXX_EGPIO_OPT_RESET, 1);
83 gpio_free(H3XXX_EGPIO_CARD_RESET);
84 gpio_free(H3XXX_EGPIO_OPT_RESET);
85 gpio_free(H3XXX_EGPIO_OPT_ON);
86 gpio_free(H3XXX_EGPIO_OPT_NVRAM_ON);
94 h3600_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
103 h3600_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
105 if (state->Vcc != 0 && state->Vcc != 33 && state->Vcc != 50) {
106 printk(KERN_ERR "h3600_pcmcia: unrecognized Vcc %u.%uV\n",
107 state->Vcc / 10, state->Vcc % 10);
111 gpio_set_value(H3XXX_EGPIO_CARD_RESET, !!(state->flags & SS_RESET));
113 /* Silently ignore Vpp, output enable, speaker enable. */
118 static void h3600_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
121 gpio_set_value(H3XXX_EGPIO_OPT_NVRAM_ON, 1);
122 gpio_set_value(H3XXX_EGPIO_OPT_ON, 1);
123 gpio_set_value(H3XXX_EGPIO_OPT_RESET, 0);
128 static void h3600_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
131 * FIXME: This doesn't fit well. We don't have the mechanism in
132 * the generic PCMCIA layer to deal with the idea of two sockets
133 * on one bus. We rely on the cs.c behaviour shutting down
134 * socket 0 then socket 1.
137 gpio_set_value(H3XXX_EGPIO_OPT_ON, 0);
138 gpio_set_value(H3XXX_EGPIO_OPT_NVRAM_ON, 0);
139 /* hmm, does this suck power? */
140 gpio_set_value(H3XXX_EGPIO_OPT_RESET, 1);
144 struct pcmcia_low_level h3600_pcmcia_ops = {
145 .owner = THIS_MODULE,
146 .hw_init = h3600_pcmcia_hw_init,
147 .hw_shutdown = h3600_pcmcia_hw_shutdown,
148 .socket_state = h3600_pcmcia_socket_state,
149 .configure_socket = h3600_pcmcia_configure_socket,
151 .socket_init = h3600_pcmcia_socket_init,
152 .socket_suspend = h3600_pcmcia_socket_suspend,
155 int pcmcia_h3600_init(struct device *dev)
159 if (machine_is_h3600() || machine_is_h3100())
160 ret = sa11xx_drv_pcmcia_probe(dev, &h3600_pcmcia_ops, 0, 2);