summaryrefslogtreecommitdiff
path: root/packages/linux/linux-gumstix-2.6.15/compact-flash.patch
blob: c3913a23dfdd0cbcdeb82ff410bf58d0621e3c6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
Index: linux-2.6.15gum/drivers/pcmcia/Makefile
===================================================================
--- linux-2.6.15gum.orig/drivers/pcmcia/Makefile
+++ linux-2.6.15gum/drivers/pcmcia/Makefile
@@ -68,4 +68,4 @@
 pxa2xx_cs-$(CONFIG_ARCH_LUBBOCK)		+= pxa2xx_lubbock.o sa1111_generic.o
 pxa2xx_cs-$(CONFIG_MACH_MAINSTONE)		+= pxa2xx_mainstone.o
 pxa2xx_cs-$(CONFIG_PXA_SHARPSL)			+= pxa2xx_sharpsl.o
-
+pxa2xx_cs-$(CONFIG_ARCH_GUMSTIX)		+= pxa2xx_gumstix.o
Index: linux-2.6.15gum/drivers/pcmcia/pxa2xx_gumstix.c
--- /dev/null
+++ linux-2.6.15gum/drivers/pcmcia/pxa2xx_gumstix.c
@@ -0,0 +1,157 @@
+/*
+ * linux/drivers/pcmcia/pxa2xx_gumstix.c
+ *
+ * Gumstix PCMCIA specific routines. Based on Mainstone
+ *
+ * Copyright 2004, Craig Hughes <craig@gumstix.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+
+#include <pcmcia/ss.h>
+
+#include <asm/hardware.h>
+#include <asm/delay.h>
+#include <asm/arch/pxa-regs.h>
+#include <asm/irq.h>
+
+#include <asm/arch/gumstix.h>
+
+#include "soc_common.h"
+
+static struct pcmcia_irqs irqs[] = {
+	{ 0, GUMSTIX_nPCD1_IRQ,		"CF nCD"     },
+	{ 0, GUMSTIX_nSTSCHG_IRQ,	"CF nSTSCHG" },
+};
+
+static int gumstix_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
+{
+	pxa_gpio_mode(GPIO8_RESET_MD);
+	GPSR(GPIO8_RESET) = GPIO_bit(GPIO8_RESET);
+	udelay(50);
+	GPCR(GPIO8_RESET) = GPIO_bit(GPIO8_RESET);
+
+	pxa_gpio_mode(GPIO4_nBVD1_MD);
+	pxa_gpio_mode(GPIO36_nBVD2_MD);
+	pxa_gpio_mode(GPIO11_nPCD1_MD);
+	pxa_gpio_mode(GPIO26_PRDY_nBSY0_MD);
+
+	/*
+	 * Setup default state of GPIO outputs
+	 * before we enable them as outputs.
+	 */
+	GPSR(GPIO48_nPOE) =
+		GPIO_bit(GPIO48_nPOE) |
+		GPIO_bit(GPIO49_nPWE) |
+		GPIO_bit(GPIO50_nPIOR) |
+		GPIO_bit(GPIO51_nPIOW) |
+		GPIO_bit(GPIO52_nPCE_1) |
+		GPIO_bit(GPIO53_nPCE_2);
+
+	pxa_gpio_mode(GPIO48_nPOE_MD);
+	pxa_gpio_mode(GPIO49_nPWE_MD);
+	pxa_gpio_mode(GPIO50_nPIOR_MD);
+	pxa_gpio_mode(GPIO51_nPIOW_MD);
+	pxa_gpio_mode(GPIO52_nPCE_1_MD);
+	pxa_gpio_mode(GPIO53_nPCE_2_MD);
+	pxa_gpio_mode(GPIO54_pSKTSEL_MD);
+	pxa_gpio_mode(GPIO55_nPREG_MD);
+	pxa_gpio_mode(GPIO56_nPWAIT_MD);
+	pxa_gpio_mode(GPIO57_nIOIS16_MD);                                                                                                                                                              
+
+	skt->irq = GUMSTIX_PRDY_nBSY0_IRQ;
+
+	return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static void gumstix_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
+{
+	soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static unsigned long gum_pcmcia_status;
+
+static void gumstix_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
+				    struct pcmcia_state *state)
+{
+	state->detect = !(GPLR(GPIO11_nPCD1) & GPIO_bit(GPIO11_nPCD1));
+	state->ready  = !!(GPLR(GPIO26_PRDY_nBSY0) & GPIO_bit(GPIO26_PRDY_nBSY0));
+	state->bvd1   = !!(GPLR(GPIO4_nBVD1) & GPIO_bit(GPIO4_nBVD1));
+	state->bvd2   = 1;
+	state->vs_3v  = 0;
+	state->vs_Xv  = 0;
+	state->wrprot = 0;
+}
+
+static int gumstix_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
+				       const socket_state_t *state)
+{
+	return 0;
+}
+
+static void gumstix_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
+{
+	soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static void gumstix_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
+{
+	soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static struct pcmcia_low_level gumstix_pcmcia_ops = {
+	.owner			= THIS_MODULE,
+	.hw_init		= gumstix_pcmcia_hw_init,
+	.hw_shutdown		= gumstix_pcmcia_hw_shutdown,
+	.socket_state		= gumstix_pcmcia_socket_state,
+	.configure_socket	= gumstix_pcmcia_configure_socket,
+	.socket_init		= gumstix_pcmcia_socket_init,
+	.socket_suspend		= gumstix_pcmcia_socket_suspend,
+	.nr			= 1,
+};
+
+static struct platform_device *gumstix_pcmcia_device;
+
+static int __init gumstix_pcmcia_init(void)
+{
+	int ret;
+
+	gumstix_pcmcia_device = kmalloc(sizeof(*gumstix_pcmcia_device), GFP_KERNEL);
+	if (!gumstix_pcmcia_device)
+		return -ENOMEM;
+	memset(gumstix_pcmcia_device, 0, sizeof(*gumstix_pcmcia_device));
+	gumstix_pcmcia_device->name = "pxa2xx-pcmcia";
+	gumstix_pcmcia_device->dev.platform_data = &gumstix_pcmcia_ops;
+
+	ret = platform_device_register(gumstix_pcmcia_device);
+	if (ret)
+		kfree(gumstix_pcmcia_device);
+
+	return ret;
+}
+
+static void __exit gumstix_pcmcia_exit(void)
+{
+	/*
+	 * This call is supposed to free our gumstix_pcmcia_device.
+	 * Unfortunately platform_device don't have a free method, and
+	 * we can't assume it's free of any reference at this point so we
+	 * can't free it either.
+	 */
+	platform_device_unregister(gumstix_pcmcia_device);
+}
+
+fs_initcall(gumstix_pcmcia_init);
+module_exit(gumstix_pcmcia_exit);
+
+MODULE_LICENSE("GPL");