1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2ff80aa57SRussell King /*
3ff80aa57SRussell King  * linux/drivers/pcmcia/sa1100_neponset.c
4ff80aa57SRussell King  *
5ff80aa57SRussell King  * Neponset PCMCIA specific routines
6ff80aa57SRussell King  */
7ff80aa57SRussell King #include <linux/module.h>
8ff80aa57SRussell King #include <linux/kernel.h>
9ff80aa57SRussell King #include <linux/device.h>
10ff80aa57SRussell King #include <linux/errno.h>
11ff80aa57SRussell King #include <linux/init.h>
12ff80aa57SRussell King 
13ff80aa57SRussell King #include <asm/mach-types.h>
14ff80aa57SRussell King 
15ff80aa57SRussell King #include "sa1111_generic.h"
16e2125d05SRussell King #include "max1600.h"
17ff80aa57SRussell King 
18ff80aa57SRussell King /*
19ff80aa57SRussell King  * Neponset uses the Maxim MAX1600, with the following connections:
20ff80aa57SRussell King  *
21ff80aa57SRussell King  *   MAX1600      Neponset
22ff80aa57SRussell King  *
23ff80aa57SRussell King  *    A0VCC        SA-1111 GPIO A<1>
24ff80aa57SRussell King  *    A1VCC        SA-1111 GPIO A<0>
25ff80aa57SRussell King  *    A0VPP        CPLD NCR A0VPP
26ff80aa57SRussell King  *    A1VPP        CPLD NCR A1VPP
27ff80aa57SRussell King  *    B0VCC        SA-1111 GPIO A<2>
28ff80aa57SRussell King  *    B1VCC        SA-1111 GPIO A<3>
29ff80aa57SRussell King  *    B0VPP        ground (slot B is CF)
30ff80aa57SRussell King  *    B1VPP        ground (slot B is CF)
31ff80aa57SRussell King  *
32ff80aa57SRussell King  *     VX          VCC (5V)
33ff80aa57SRussell King  *     VY          VCC3_3 (3.3V)
34ff80aa57SRussell King  *     12INA       12V
35ff80aa57SRussell King  *     12INB       ground (slot B is CF)
36ff80aa57SRussell King  *
37ff80aa57SRussell King  * The MAX1600 CODE pin is tied to ground, placing the device in
38ff80aa57SRussell King  * "Standard Intel code" mode. Refer to the Maxim data sheet for
39ff80aa57SRussell King  * the corresponding truth table.
40ff80aa57SRussell King  */
neponset_pcmcia_hw_init(struct soc_pcmcia_socket * skt)41e2125d05SRussell King static int neponset_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
42e2125d05SRussell King {
43e2125d05SRussell King 	struct max1600 *m;
44e2125d05SRussell King 	int ret;
45e2125d05SRussell King 
46e2125d05SRussell King 	ret = max1600_init(skt->socket.dev.parent, &m,
47e2125d05SRussell King 			   skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A,
48e2125d05SRussell King 			   MAX1600_CODE_LOW);
49e2125d05SRussell King 	if (ret == 0)
50e2125d05SRussell King 		skt->driver_data = m;
51e2125d05SRussell King 
52e2125d05SRussell King 	return ret;
53e2125d05SRussell King }
54ff80aa57SRussell King 
55ff80aa57SRussell King static int
neponset_pcmcia_configure_socket(struct soc_pcmcia_socket * skt,const socket_state_t * state)56ff80aa57SRussell King neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
57ff80aa57SRussell King {
58e2125d05SRussell King 	struct max1600 *m = skt->driver_data;
59ff80aa57SRussell King 	int ret;
60ff80aa57SRussell King 
61ff80aa57SRussell King 	ret = sa1111_pcmcia_configure_socket(skt, state);
62e2125d05SRussell King 	if (ret == 0)
63e2125d05SRussell King 		ret = max1600_configure(m, state->Vcc, state->Vpp);
64ff80aa57SRussell King 
65ff80aa57SRussell King 	return ret;
66ff80aa57SRussell King }
67ff80aa57SRussell King 
68ff80aa57SRussell King static struct pcmcia_low_level neponset_pcmcia_ops = {
69ff80aa57SRussell King 	.owner			= THIS_MODULE,
70e2125d05SRussell King 	.hw_init		= neponset_pcmcia_hw_init,
71ff80aa57SRussell King 	.configure_socket	= neponset_pcmcia_configure_socket,
72ff80aa57SRussell King 	.first			= 0,
73ff80aa57SRussell King 	.nr			= 2,
74ff80aa57SRussell King };
75ff80aa57SRussell King 
pcmcia_neponset_init(struct sa1111_dev * sadev)76ff80aa57SRussell King int pcmcia_neponset_init(struct sa1111_dev *sadev)
77ff80aa57SRussell King {
78ff80aa57SRussell King 	sa11xx_drv_pcmcia_ops(&neponset_pcmcia_ops);
793f8df892SRussell King 	return sa1111_pcmcia_add(sadev, &neponset_pcmcia_ops,
80ff80aa57SRussell King 				 sa11xx_drv_pcmcia_add_one);
81ff80aa57SRussell King }
82