blob: 0ccf05a28a4b96686d76e908b54b949c298715cb [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 * linux/drivers/pcmcia/sa1100_neponset.c
4 *
5 * Neponset PCMCIA specific routines
6 */
7#include <linux/module.h>
8#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/device.h>
10#include <linux/errno.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>
Russell Kinga09e64f2008-08-05 16:14:15 +010015#include <mach/neponset.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/hardware/sa1111.h>
17
18#include "sa1111_generic.h"
19
20/*
21 * Neponset uses the Maxim MAX1600, with the following connections:
22 *
23 * MAX1600 Neponset
24 *
25 * A0VCC SA-1111 GPIO A<1>
26 * A1VCC SA-1111 GPIO A<0>
27 * A0VPP CPLD NCR A0VPP
28 * A1VPP CPLD NCR A1VPP
29 * B0VCC SA-1111 GPIO A<2>
30 * B1VCC SA-1111 GPIO A<3>
31 * B0VPP ground (slot B is CF)
32 * B1VPP ground (slot B is CF)
33 *
34 * VX VCC (5V)
35 * VY VCC3_3 (3.3V)
36 * 12INA 12V
37 * 12INB ground (slot B is CF)
38 *
39 * The MAX1600 CODE pin is tied to ground, placing the device in
40 * "Standard Intel code" mode. Refer to the Maxim data sheet for
41 * the corresponding truth table.
42 */
43
44static int
45neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
46{
Russell King - ARM Linux701a5dc2009-03-29 19:42:44 +010047 struct sa1111_pcmcia_socket *s = to_skt(skt);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 unsigned int ncr_mask, ncr_set, pa_dwr_mask, pa_dwr_set;
49 int ret;
50
51 switch (skt->nr) {
52 case 0:
53 pa_dwr_mask = GPIO_A0 | GPIO_A1;
54 ncr_mask = NCR_A0VPP | NCR_A1VPP;
55
56 if (state->Vpp == 0)
57 ncr_set = 0;
58 else if (state->Vpp == 120)
59 ncr_set = NCR_A1VPP;
60 else if (state->Vpp == state->Vcc)
61 ncr_set = NCR_A0VPP;
62 else {
63 printk(KERN_ERR "%s(): unrecognized VPP %u\n",
Harvey Harrison2e11cb42008-05-01 04:34:54 -070064 __func__, state->Vpp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 return -1;
66 }
67 break;
68
69 case 1:
70 pa_dwr_mask = GPIO_A2 | GPIO_A3;
71 ncr_mask = 0;
72 ncr_set = 0;
73
74 if (state->Vpp != state->Vcc && state->Vpp != 0) {
75 printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
Harvey Harrison2e11cb42008-05-01 04:34:54 -070076 __func__, state->Vpp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 return -1;
78 }
79 break;
80
81 default:
82 return -1;
83 }
84
85 /*
86 * pa_dwr_set is the mask for selecting Vcc on both sockets.
87 * pa_dwr_mask selects which bits (and therefore socket) we change.
88 */
89 switch (state->Vcc) {
90 default:
91 case 0: pa_dwr_set = 0; break;
92 case 33: pa_dwr_set = GPIO_A1|GPIO_A2; break;
93 case 50: pa_dwr_set = GPIO_A0|GPIO_A3; break;
94 }
95
96 ret = sa1111_pcmcia_configure_socket(skt, state);
97 if (ret == 0) {
Linus Torvalds9e4db1c2012-03-27 18:17:02 -070098 neponset_ncr_frob(ncr_mask, ncr_set);
Russell King - ARM Linux701a5dc2009-03-29 19:42:44 +010099 sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 }
101
Russell King65c77dc2012-01-16 09:27:33 +0000102 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103}
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105static struct pcmcia_low_level neponset_pcmcia_ops = {
106 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 .configure_socket = neponset_pcmcia_configure_socket,
Russell King - ARM Linux701a5dc2009-03-29 19:42:44 +0100108 .first = 0,
109 .nr = 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110};
111
Russell Kingb29cf622009-09-27 17:30:21 +0100112int pcmcia_neponset_init(struct sa1111_dev *sadev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113{
Russell King3f8df892016-09-02 10:14:20 +0100114 /*
115 * Set GPIO_A<3:0> to be outputs for the MAX1600,
116 * and switch to standby mode.
117 */
118 sa1111_set_io_dir(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0, 0);
119 sa1111_set_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0);
120 sa1111_set_sleep_io(sadev, GPIO_A0|GPIO_A1|GPIO_A2|GPIO_A3, 0);
121 sa11xx_drv_pcmcia_ops(&neponset_pcmcia_ops);
122 return sa1111_pcmcia_add(sadev, &neponset_pcmcia_ops,
123 sa11xx_drv_pcmcia_add_one);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124}