aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/pxa2xx_cm_x270.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pcmcia/pxa2xx_cm_x270.c')
-rw-r--r--drivers/pcmcia/pxa2xx_cm_x270.c108
1 files changed, 38 insertions, 70 deletions
diff --git a/drivers/pcmcia/pxa2xx_cm_x270.c b/drivers/pcmcia/pxa2xx_cm_x270.c
index e7ab060ff118..bb95db7d2b76 100644
--- a/drivers/pcmcia/pxa2xx_cm_x270.c
+++ b/drivers/pcmcia/pxa2xx_cm_x270.c
@@ -5,82 +5,60 @@
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 * 7 *
8 * Compulab Ltd., 2003, 2007 8 * Compulab Ltd., 2003, 2007, 2008
9 * Mike Rapoport <mike@compulab.co.il> 9 * Mike Rapoport <mike@compulab.co.il>
10 * 10 *
11 */ 11 */
12 12
13#include <linux/kernel.h>
14#include <linux/sched.h>
15#include <linux/platform_device.h> 13#include <linux/platform_device.h>
16#include <linux/irq.h> 14#include <linux/irq.h>
17#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/gpio.h>
18 17
19#include <pcmcia/ss.h> 18#include <asm/mach-types.h>
20#include <asm/hardware.h>
21
22#include <asm/arch/pxa-regs.h> 19#include <asm/arch/pxa-regs.h>
23#include <asm/arch/pxa2xx-gpio.h>
24#include <asm/arch/cm-x270.h>
25 20
26#include "soc_common.h" 21#include "soc_common.h"
27 22
23#define GPIO_PCMCIA_S0_CD_VALID (84)
24#define GPIO_PCMCIA_S0_RDYINT (82)
25#define GPIO_PCMCIA_RESET (53)
26
27#define PCMCIA_S0_CD_VALID IRQ_GPIO(GPIO_PCMCIA_S0_CD_VALID)
28#define PCMCIA_S0_RDYINT IRQ_GPIO(GPIO_PCMCIA_S0_RDYINT)
29
30
28static struct pcmcia_irqs irqs[] = { 31static struct pcmcia_irqs irqs[] = {
29 { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" }, 32 { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" },
30 { 1, PCMCIA_S1_CD_VALID, "PCMCIA1 CD" },
31}; 33};
32 34
33static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt) 35static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
34{ 36{
35 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) | 37 int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset");
36 GPIO_bit(GPIO49_nPWE) | 38 if (ret)
37 GPIO_bit(GPIO50_nPIOR) | 39 return ret;
38 GPIO_bit(GPIO51_nPIOW) | 40 gpio_direction_output(GPIO_PCMCIA_RESET, 0);
39 GPIO_bit(GPIO85_nPCE_1) | 41
40 GPIO_bit(GPIO54_nPCE_2); 42 skt->irq = PCMCIA_S0_RDYINT;
41 43 ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
42 pxa_gpio_mode(GPIO48_nPOE_MD); 44 if (!ret)
43 pxa_gpio_mode(GPIO49_nPWE_MD); 45 gpio_free(GPIO_PCMCIA_RESET);
44 pxa_gpio_mode(GPIO50_nPIOR_MD); 46
45 pxa_gpio_mode(GPIO51_nPIOW_MD); 47 return ret;
46 pxa_gpio_mode(GPIO85_nPCE_1_MD);
47 pxa_gpio_mode(GPIO54_nPCE_2_MD);
48 pxa_gpio_mode(GPIO55_nPREG_MD);
49 pxa_gpio_mode(GPIO56_nPWAIT_MD);
50 pxa_gpio_mode(GPIO57_nIOIS16_MD);
51
52 /* Reset signal */
53 pxa_gpio_mode(GPIO53_nPCE_2 | GPIO_OUT);
54 GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
55
56 set_irq_type(PCMCIA_S0_CD_VALID, IRQ_TYPE_EDGE_BOTH);
57 set_irq_type(PCMCIA_S1_CD_VALID, IRQ_TYPE_EDGE_BOTH);
58
59 /* irq's for slots: */
60 set_irq_type(PCMCIA_S0_RDYINT, IRQ_TYPE_EDGE_FALLING);
61 set_irq_type(PCMCIA_S1_RDYINT, IRQ_TYPE_EDGE_FALLING);
62
63 skt->irq = (skt->nr == 0) ? PCMCIA_S0_RDYINT : PCMCIA_S1_RDYINT;
64 return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
65} 48}
66 49
67static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket *skt) 50static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
68{ 51{
69 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs)); 52 soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
70 53 gpio_free(GPIO_PCMCIA_RESET);
71 set_irq_type(IRQ_TO_GPIO(PCMCIA_S0_CD_VALID), IRQ_TYPE_NONE);
72 set_irq_type(IRQ_TO_GPIO(PCMCIA_S1_CD_VALID), IRQ_TYPE_NONE);
73
74 set_irq_type(IRQ_TO_GPIO(PCMCIA_S0_RDYINT), IRQ_TYPE_NONE);
75 set_irq_type(IRQ_TO_GPIO(PCMCIA_S1_RDYINT), IRQ_TYPE_NONE);
76} 54}
77 55
78 56
79static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt, 57static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
80 struct pcmcia_state *state) 58 struct pcmcia_state *state)
81{ 59{
82 state->detect = (PCC_DETECT(skt->nr) == 0) ? 1 : 0; 60 state->detect = (gpio_get_value(GPIO_PCMCIA_S0_CD_VALID) == 0) ? 1 : 0;
83 state->ready = (PCC_READY(skt->nr) == 0) ? 0 : 1; 61 state->ready = (gpio_get_value(GPIO_PCMCIA_S0_RDYINT) == 0) ? 0 : 1;
84 state->bvd1 = 1; 62 state->bvd1 = 1;
85 state->bvd2 = 1; 63 state->bvd2 = 1;
86 state->vs_3v = 0; 64 state->vs_3v = 0;
@@ -92,32 +70,16 @@ static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
92static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, 70static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
93 const socket_state_t *state) 71 const socket_state_t *state)
94{ 72{
95 GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
96 pxa_gpio_mode(GPIO49_nPWE | GPIO_OUT);
97
98 switch (skt->nr) { 73 switch (skt->nr) {
99 case 0: 74 case 0:
100 if (state->flags & SS_RESET) { 75 if (state->flags & SS_RESET) {
101 GPCR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE); 76 gpio_set_value(GPIO_PCMCIA_RESET, 1);
102 GPSR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
103 udelay(10); 77 udelay(10);
104 GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2); 78 gpio_set_value(GPIO_PCMCIA_RESET, 0);
105 GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
106 }
107 break;
108 case 1:
109 if (state->flags & SS_RESET) {
110 GPCR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
111 GPSR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
112 udelay(10);
113 GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_nPCE_2);
114 GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nPWE);
115 } 79 }
116 break; 80 break;
117 } 81 }
118 82
119 pxa_gpio_mode(GPIO49_nPWE_MD);
120
121 return 0; 83 return 0;
122} 84}
123 85
@@ -130,7 +92,7 @@ static void cmx270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
130} 92}
131 93
132 94
133static struct pcmcia_low_level cmx270_pcmcia_ops = { 95static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
134 .owner = THIS_MODULE, 96 .owner = THIS_MODULE,
135 .hw_init = cmx270_pcmcia_hw_init, 97 .hw_init = cmx270_pcmcia_hw_init,
136 .hw_shutdown = cmx270_pcmcia_shutdown, 98 .hw_shutdown = cmx270_pcmcia_shutdown,
@@ -138,7 +100,7 @@ static struct pcmcia_low_level cmx270_pcmcia_ops = {
138 .configure_socket = cmx270_pcmcia_configure_socket, 100 .configure_socket = cmx270_pcmcia_configure_socket,
139 .socket_init = cmx270_pcmcia_socket_init, 101 .socket_init = cmx270_pcmcia_socket_init,
140 .socket_suspend = cmx270_pcmcia_socket_suspend, 102 .socket_suspend = cmx270_pcmcia_socket_suspend,
141 .nr = 2, 103 .nr = 1,
142}; 104};
143 105
144static struct platform_device *cmx270_pcmcia_device; 106static struct platform_device *cmx270_pcmcia_device;
@@ -147,15 +109,21 @@ static int __init cmx270_pcmcia_init(void)
147{ 109{
148 int ret; 110 int ret;
149 111
112 if (!machine_is_armcore())
113 return -ENODEV;
114
150 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1); 115 cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
151 116
152 if (!cmx270_pcmcia_device) 117 if (!cmx270_pcmcia_device)
153 return -ENOMEM; 118 return -ENOMEM;
154 119
155 cmx270_pcmcia_device->dev.platform_data = &cmx270_pcmcia_ops; 120 ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
121 sizeof(cmx270_pcmcia_ops));
156 122
157 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n"); 123 if (ret == 0) {
158 ret = platform_device_add(cmx270_pcmcia_device); 124 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
125 ret = platform_device_add(cmx270_pcmcia_device);
126 }
159 127
160 if (ret) 128 if (ret)
161 platform_device_put(cmx270_pcmcia_device); 129 platform_device_put(cmx270_pcmcia_device);