summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2018-11-28 08:57:23 -0500
committerRussell King <rmk+kernel@armlinux.org.uk>2018-12-04 17:37:38 -0500
commit34fdbe6456195f9f11e839cc4cdb9928d1ea8193 (patch)
treef4a186c880cac2d55e06cbdf2cfd9ca14e10c9f9
parente2125d0517c0be28c39890916048ea9cfe00b9bf (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>
-rw-r--r--arch/arm/mach-pxa/Kconfig1
-rw-r--r--arch/arm/mach-pxa/include/mach/mainstone.h4
-rw-r--r--arch/arm/mach-pxa/mainstone.c53
-rw-r--r--drivers/pcmcia/Kconfig1
-rw-r--r--drivers/pcmcia/pxa2xx_mainstone.c113
5 files changed, 93 insertions, 79 deletions
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index a68b34183107..fd724a71c2e1 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -46,6 +46,7 @@ config ARCH_LUBBOCK
46 46
47config MACH_MAINSTONE 47config MACH_MAINSTONE
48 bool "Intel HCDDBBVA0 Development Platform (aka Mainstone)" 48 bool "Intel HCDDBBVA0 Development Platform (aka Mainstone)"
49 select GPIO_REG
49 select PXA27x 50 select PXA27x
50 51
51config MACH_ZYLONITE 52config MACH_ZYLONITE
diff --git a/arch/arm/mach-pxa/include/mach/mainstone.h b/arch/arm/mach-pxa/include/mach/mainstone.h
index e82a7d31104e..474041a83d80 100644
--- a/arch/arm/mach-pxa/include/mach/mainstone.h
+++ b/arch/arm/mach-pxa/include/mach/mainstone.h
@@ -119,6 +119,10 @@
119#define MST_PCMCIA_PWR_VCC_33 0x8 /* voltage VCC = 3.3V */ 119#define MST_PCMCIA_PWR_VCC_33 0x8 /* voltage VCC = 3.3V */
120#define MST_PCMCIA_PWR_VCC_50 0x4 /* voltage VCC = 5.0V */ 120#define MST_PCMCIA_PWR_VCC_50 0x4 /* voltage VCC = 5.0V */
121 121
122#define MST_PCMCIA_INPUTS \
123 (MST_PCMCIA_nIRQ | MST_PCMCIA_nSPKR_BVD2 | MST_PCMCIA_nSTSCHG_BVD1 | \
124 MST_PCMCIA_nVS2 | MST_PCMCIA_nVS1 | MST_PCMCIA_nCD)
125
122/* board specific IRQs */ 126/* board specific IRQs */
123#define MAINSTONE_NR_IRQS IRQ_BOARD_START 127#define MAINSTONE_NR_IRQS IRQ_BOARD_START
124 128
diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index afd62a94fdbf..d40de190d630 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -13,6 +13,7 @@
13 * published by the Free Software Foundation. 13 * published by the Free Software Foundation.
14 */ 14 */
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16#include <linux/gpio/gpio-reg.h>
16#include <linux/gpio/machine.h> 17#include <linux/gpio/machine.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
@@ -507,12 +508,64 @@ static void __init mainstone_init_keypad(void)
507static inline void mainstone_init_keypad(void) {} 508static inline void mainstone_init_keypad(void) {}
508#endif 509#endif
509 510
511static int mst_pcmcia0_irqs[11] = {
512 [0 ... 10] = -1,
513 [5] = MAINSTONE_S0_CD_IRQ,
514 [8] = MAINSTONE_S0_STSCHG_IRQ,
515 [10] = MAINSTONE_S0_IRQ,
516};
517
518static int mst_pcmcia1_irqs[11] = {
519 [0 ... 10] = -1,
520 [5] = MAINSTONE_S1_CD_IRQ,
521 [8] = MAINSTONE_S1_STSCHG_IRQ,
522 [10] = MAINSTONE_S1_IRQ,
523};
524
525static struct gpiod_lookup_table mainstone_pcmcia_gpio_table = {
526 .dev_id = "pxa2xx-pcmcia",
527 .table = {
528 GPIO_LOOKUP("mst-pcmcia0", 0, "a0vpp", GPIO_ACTIVE_HIGH),
529 GPIO_LOOKUP("mst-pcmcia0", 1, "a1vpp", GPIO_ACTIVE_HIGH),
530 GPIO_LOOKUP("mst-pcmcia0", 2, "a0vcc", GPIO_ACTIVE_HIGH),
531 GPIO_LOOKUP("mst-pcmcia0", 3, "a1vcc", GPIO_ACTIVE_HIGH),
532 GPIO_LOOKUP("mst-pcmcia0", 4, "areset", GPIO_ACTIVE_HIGH),
533 GPIO_LOOKUP("mst-pcmcia0", 5, "adetect", GPIO_ACTIVE_LOW),
534 GPIO_LOOKUP("mst-pcmcia0", 6, "avs1", GPIO_ACTIVE_LOW),
535 GPIO_LOOKUP("mst-pcmcia0", 7, "avs2", GPIO_ACTIVE_LOW),
536 GPIO_LOOKUP("mst-pcmcia0", 8, "abvd1", GPIO_ACTIVE_HIGH),
537 GPIO_LOOKUP("mst-pcmcia0", 9, "abvd2", GPIO_ACTIVE_HIGH),
538 GPIO_LOOKUP("mst-pcmcia0", 10, "aready", GPIO_ACTIVE_HIGH),
539 GPIO_LOOKUP("mst-pcmcia1", 0, "b0vpp", GPIO_ACTIVE_HIGH),
540 GPIO_LOOKUP("mst-pcmcia1", 1, "b1vpp", GPIO_ACTIVE_HIGH),
541 GPIO_LOOKUP("mst-pcmcia1", 2, "b0vcc", GPIO_ACTIVE_HIGH),
542 GPIO_LOOKUP("mst-pcmcia1", 3, "b1vcc", GPIO_ACTIVE_HIGH),
543 GPIO_LOOKUP("mst-pcmcia1", 4, "breset", GPIO_ACTIVE_HIGH),
544 GPIO_LOOKUP("mst-pcmcia1", 5, "bdetect", GPIO_ACTIVE_LOW),
545 GPIO_LOOKUP("mst-pcmcia1", 6, "bvs1", GPIO_ACTIVE_LOW),
546 GPIO_LOOKUP("mst-pcmcia1", 7, "bvs2", GPIO_ACTIVE_LOW),
547 GPIO_LOOKUP("mst-pcmcia1", 8, "bbvd1", GPIO_ACTIVE_HIGH),
548 GPIO_LOOKUP("mst-pcmcia1", 9, "bbvd2", GPIO_ACTIVE_HIGH),
549 GPIO_LOOKUP("mst-pcmcia1", 10, "bready", GPIO_ACTIVE_HIGH),
550 { },
551 },
552};
553
510static void __init mainstone_init(void) 554static void __init mainstone_init(void)
511{ 555{
512 int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */ 556 int SW7 = 0; /* FIXME: get from SCR (Mst doc section 3.2.1.1) */
513 557
514 pxa2xx_mfp_config(ARRAY_AND_SIZE(mainstone_pin_config)); 558 pxa2xx_mfp_config(ARRAY_AND_SIZE(mainstone_pin_config));
515 559
560 /* Register board control register(s) as GPIOs */
561 gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA0, -1, 11,
562 "mst-pcmcia0", MST_PCMCIA_INPUTS, 0, NULL,
563 NULL, mst_pcmcia0_irqs);
564 gpio_reg_init(NULL, (void __iomem *)&MST_PCMCIA1, -1, 11,
565 "mst-pcmcia1", MST_PCMCIA_INPUTS, 0, NULL,
566 NULL, mst_pcmcia1_irqs);
567 gpiod_add_lookup_table(&mainstone_pcmcia_gpio_table);
568
516 pxa_set_ffuart_info(NULL); 569 pxa_set_ffuart_info(NULL);
517 pxa_set_btuart_info(NULL); 570 pxa_set_btuart_info(NULL);
518 pxa_set_stuart_info(NULL); 571 pxa_set_stuart_info(NULL);
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
33static int mst_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 29static 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
55static unsigned long mst_pcmcia_status[2]; 57static unsigned int mst_pcmcia_bvd1_status[2];
56 58
57static void mst_pcmcia_socket_state(struct soc_pcmcia_socket *skt, 59static 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
88static int mst_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, 78static 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
129static struct pcmcia_low_level mst_pcmcia_ops __initdata = { 84static struct pcmcia_low_level mst_pcmcia_ops __initdata = {