diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2018-11-28 08:57:23 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2018-12-04 17:37:38 -0500 |
commit | 34fdbe6456195f9f11e839cc4cdb9928d1ea8193 (patch) | |
tree | f4a186c880cac2d55e06cbdf2cfd9ca14e10c9f9 /drivers/pcmcia | |
parent | e2125d0517c0be28c39890916048ea9cfe00b9bf (diff) |
ARM: pxa/mainstone: switch PCMCIA to MAX1600 library and gpiod APIs
Convert mainstone to use the MAX1600 library and gpiod APIs for socket
status and control signals.
Acked-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/Kconfig | 1 | ||||
-rw-r--r-- | drivers/pcmcia/pxa2xx_mainstone.c | 113 |
2 files changed, 35 insertions, 79 deletions
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 8e8db3aa9fce..9ac3d4a68075 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -211,6 +211,7 @@ config PCMCIA_PXA2XX | |||
211 | || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ | 211 | || MACH_VPAC270 || MACH_BALLOON3 || MACH_COLIBRI \ |
212 | || MACH_COLIBRI320 || MACH_H4700) | 212 | || MACH_COLIBRI320 || MACH_H4700) |
213 | select PCMCIA_SOC_COMMON | 213 | select PCMCIA_SOC_COMMON |
214 | select PCMCIA_MAX1600 if MACH_MAINSTONE | ||
214 | help | 215 | help |
215 | Say Y here to include support for the PXA2xx PCMCIA controller | 216 | Say Y here to include support for the PXA2xx PCMCIA controller |
216 | 217 | ||
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c index 7e32e25cdcb2..770c7bf0171d 100644 --- a/drivers/pcmcia/pxa2xx_mainstone.c +++ b/drivers/pcmcia/pxa2xx_mainstone.c | |||
@@ -11,56 +11,55 @@ | |||
11 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
12 | * published by the Free Software Foundation. | 12 | * published by the Free Software Foundation. |
13 | */ | 13 | */ |
14 | 14 | #include <linux/gpio/consumer.h> | |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/interrupt.h> | ||
17 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
18 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | 21 | ||
22 | #include <pcmcia/ss.h> | 22 | #include <pcmcia/ss.h> |
23 | 23 | ||
24 | #include <asm/mach-types.h> | 24 | #include <asm/mach-types.h> |
25 | #include <asm/irq.h> | ||
26 | |||
27 | #include <mach/pxa2xx-regs.h> | ||
28 | #include <mach/mainstone.h> | ||
29 | 25 | ||
30 | #include "soc_common.h" | 26 | #include "soc_common.h" |
31 | 27 | #include "max1600.h" | |
32 | 28 | ||
33 | static int mst_pcmcia_hw_init(struct soc_pcmcia_socket *skt) | 29 | static int mst_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
34 | { | 30 | { |
35 | /* | 31 | struct device *dev = skt->socket.dev.parent; |
36 | * Setup default state of GPIO outputs | 32 | struct max1600 *m; |
37 | * before we enable them as outputs. | 33 | int ret; |
38 | */ | 34 | |
39 | if (skt->nr == 0) { | 35 | skt->stat[SOC_STAT_CD].name = skt->nr ? "bdetect" : "adetect"; |
40 | skt->socket.pci_irq = MAINSTONE_S0_IRQ; | 36 | skt->stat[SOC_STAT_BVD1].name = skt->nr ? "bbvd1" : "abvd1"; |
41 | skt->stat[SOC_STAT_CD].irq = MAINSTONE_S0_CD_IRQ; | 37 | skt->stat[SOC_STAT_BVD2].name = skt->nr ? "bbvd2" : "abvd2"; |
42 | skt->stat[SOC_STAT_CD].name = "PCMCIA0 CD"; | 38 | skt->stat[SOC_STAT_RDY].name = skt->nr ? "bready" : "aready"; |
43 | skt->stat[SOC_STAT_BVD1].irq = MAINSTONE_S0_STSCHG_IRQ; | 39 | skt->stat[SOC_STAT_VS1].name = skt->nr ? "bvs1" : "avs1"; |
44 | skt->stat[SOC_STAT_BVD1].name = "PCMCIA0 STSCHG"; | 40 | skt->stat[SOC_STAT_VS2].name = skt->nr ? "bvs2" : "avs2"; |
45 | } else { | 41 | |
46 | skt->socket.pci_irq = MAINSTONE_S1_IRQ; | 42 | skt->gpio_reset = devm_gpiod_get(dev, skt->nr ? "breset" : "areset", |
47 | skt->stat[SOC_STAT_CD].irq = MAINSTONE_S1_CD_IRQ; | 43 | GPIOD_OUT_HIGH); |
48 | skt->stat[SOC_STAT_CD].name = "PCMCIA1 CD"; | 44 | if (IS_ERR(skt->gpio_reset)) |
49 | skt->stat[SOC_STAT_BVD1].irq = MAINSTONE_S1_STSCHG_IRQ; | 45 | return PTR_ERR(skt->gpio_reset); |
50 | skt->stat[SOC_STAT_BVD1].name = "PCMCIA1 STSCHG"; | 46 | |
51 | } | 47 | ret = max1600_init(dev, &m, skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A, |
52 | return 0; | 48 | MAX1600_CODE_HIGH); |
49 | if (ret) | ||
50 | return ret; | ||
51 | |||
52 | skt->driver_data = m; | ||
53 | |||
54 | return soc_pcmcia_request_gpiods(skt); | ||
53 | } | 55 | } |
54 | 56 | ||
55 | static unsigned long mst_pcmcia_status[2]; | 57 | static unsigned int mst_pcmcia_bvd1_status[2]; |
56 | 58 | ||
57 | static void mst_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | 59 | static void mst_pcmcia_socket_state(struct soc_pcmcia_socket *skt, |
58 | struct pcmcia_state *state) | 60 | struct pcmcia_state *state) |
59 | { | 61 | { |
60 | unsigned long status, flip; | 62 | unsigned int flip = mst_pcmcia_bvd1_status[skt->nr] ^ state->bvd1; |
61 | |||
62 | status = (skt->nr == 0) ? MST_PCMCIA0 : MST_PCMCIA1; | ||
63 | flip = (status ^ mst_pcmcia_status[skt->nr]) & MST_PCMCIA_nSTSCHG_BVD1; | ||
64 | 63 | ||
65 | /* | 64 | /* |
66 | * Workaround for STSCHG which can't be deasserted: | 65 | * Workaround for STSCHG which can't be deasserted: |
@@ -68,62 +67,18 @@ static void mst_pcmcia_socket_state(struct soc_pcmcia_socket *skt, | |||
68 | * as needed to avoid IRQ locks. | 67 | * as needed to avoid IRQ locks. |
69 | */ | 68 | */ |
70 | if (flip) { | 69 | if (flip) { |
71 | mst_pcmcia_status[skt->nr] = status; | 70 | mst_pcmcia_bvd1_status[skt->nr] = state->bvd1; |
72 | if (status & MST_PCMCIA_nSTSCHG_BVD1) | 71 | if (state->bvd1) |
73 | enable_irq( (skt->nr == 0) ? MAINSTONE_S0_STSCHG_IRQ | 72 | enable_irq(skt->stat[SOC_STAT_BVD1].irq); |
74 | : MAINSTONE_S1_STSCHG_IRQ ); | ||
75 | else | 73 | else |
76 | disable_irq( (skt->nr == 0) ? MAINSTONE_S0_STSCHG_IRQ | 74 | disable_irq(skt->stat[SOC_STAT_BVD2].irq); |
77 | : MAINSTONE_S1_STSCHG_IRQ ); | ||
78 | } | 75 | } |
79 | |||
80 | state->detect = (status & MST_PCMCIA_nCD) ? 0 : 1; | ||
81 | state->ready = (status & MST_PCMCIA_nIRQ) ? 1 : 0; | ||
82 | state->bvd1 = (status & MST_PCMCIA_nSTSCHG_BVD1) ? 1 : 0; | ||
83 | state->bvd2 = (status & MST_PCMCIA_nSPKR_BVD2) ? 1 : 0; | ||
84 | state->vs_3v = (status & MST_PCMCIA_nVS1) ? 0 : 1; | ||
85 | state->vs_Xv = (status & MST_PCMCIA_nVS2) ? 0 : 1; | ||
86 | } | 76 | } |
87 | 77 | ||
88 | static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, | 78 | static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, |
89 | const socket_state_t *state) | 79 | const socket_state_t *state) |
90 | { | 80 | { |
91 | unsigned long power = 0; | 81 | return max1600_configure(skt->driver_data, state->Vcc, state->Vpp); |
92 | int ret = 0; | ||
93 | |||
94 | switch (state->Vcc) { | ||
95 | case 0: power |= MST_PCMCIA_PWR_VCC_0; break; | ||
96 | case 33: power |= MST_PCMCIA_PWR_VCC_33; break; | ||
97 | case 50: power |= MST_PCMCIA_PWR_VCC_50; break; | ||
98 | default: | ||
99 | printk(KERN_ERR "%s(): bad Vcc %u\n", | ||
100 | __func__, state->Vcc); | ||
101 | ret = -1; | ||
102 | } | ||
103 | |||
104 | switch (state->Vpp) { | ||
105 | case 0: power |= MST_PCMCIA_PWR_VPP_0; break; | ||
106 | case 120: power |= MST_PCMCIA_PWR_VPP_120; break; | ||
107 | default: | ||
108 | if(state->Vpp == state->Vcc) { | ||
109 | power |= MST_PCMCIA_PWR_VPP_VCC; | ||
110 | } else { | ||
111 | printk(KERN_ERR "%s(): bad Vpp %u\n", | ||
112 | __func__, state->Vpp); | ||
113 | ret = -1; | ||
114 | } | ||
115 | } | ||
116 | |||
117 | if (state->flags & SS_RESET) | ||
118 | power |= MST_PCMCIA_RESET; | ||
119 | |||
120 | switch (skt->nr) { | ||
121 | case 0: MST_PCMCIA0 = power; break; | ||
122 | case 1: MST_PCMCIA1 = power; break; | ||
123 | default: ret = -1; | ||
124 | } | ||
125 | |||
126 | return ret; | ||
127 | } | 82 | } |
128 | 83 | ||
129 | static struct pcmcia_low_level mst_pcmcia_ops __initdata = { | 84 | static struct pcmcia_low_level mst_pcmcia_ops __initdata = { |