diff options
author | Steven King <sfking@fdwdc.com> | 2010-01-22 15:43:03 -0500 |
---|---|---|
committer | Greg Ungerer <gerg@uclinux.org> | 2010-05-16 21:04:19 -0400 |
commit | 91d60417212fa6b100107384c5e4f5663ab69c8f (patch) | |
tree | 2e751a2df6a8e873b46d800d430d9cf617b9d399 /arch/m68knommu/platform/528x | |
parent | e40152ee1e1c7a63f4777791863215e3faa37a86 (diff) |
m68knommu: Coldfire QSPI platform support
Since Grant has added the coldfire-qspi driver to next-spi, here is the
platform support for the parts that have qspi hardware. This sets up
gpio to do the spi chip select using the default chip select pins; it should
be trivial for boards that require different or additional spi chip selects to
use other gpios as needed.
Signed-off-by: Steven King <sfking@fdwdc.com>
Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Diffstat (limited to 'arch/m68knommu/platform/528x')
-rw-r--r-- | arch/m68knommu/platform/528x/config.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/arch/m68knommu/platform/528x/config.c b/arch/m68knommu/platform/528x/config.c index 6e608d1836f1..76b743343bfa 100644 --- a/arch/m68knommu/platform/528x/config.c +++ b/arch/m68knommu/platform/528x/config.c | |||
@@ -17,10 +17,13 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include <linux/spi/spi.h> | ||
21 | #include <linux/gpio.h> | ||
20 | #include <asm/machdep.h> | 22 | #include <asm/machdep.h> |
21 | #include <asm/coldfire.h> | 23 | #include <asm/coldfire.h> |
22 | #include <asm/mcfsim.h> | 24 | #include <asm/mcfsim.h> |
23 | #include <asm/mcfuart.h> | 25 | #include <asm/mcfuart.h> |
26 | #include <asm/mcfqspi.h> | ||
24 | 27 | ||
25 | /***************************************************************************/ | 28 | /***************************************************************************/ |
26 | 29 | ||
@@ -76,10 +79,141 @@ static struct platform_device m528x_fec = { | |||
76 | .resource = m528x_fec_resources, | 79 | .resource = m528x_fec_resources, |
77 | }; | 80 | }; |
78 | 81 | ||
82 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | ||
83 | static struct resource m528x_qspi_resources[] = { | ||
84 | { | ||
85 | .start = MCFQSPI_IOBASE, | ||
86 | .end = MCFQSPI_IOBASE + MCFQSPI_IOSIZE - 1, | ||
87 | .flags = IORESOURCE_MEM, | ||
88 | }, | ||
89 | { | ||
90 | .start = MCFINT_VECBASE + MCFINT_QSPI, | ||
91 | .end = MCFINT_VECBASE + MCFINT_QSPI, | ||
92 | .flags = IORESOURCE_IRQ, | ||
93 | }, | ||
94 | }; | ||
95 | |||
96 | #define MCFQSPI_CS0 147 | ||
97 | #define MCFQSPI_CS1 148 | ||
98 | #define MCFQSPI_CS2 149 | ||
99 | #define MCFQSPI_CS3 150 | ||
100 | |||
101 | static int m528x_cs_setup(struct mcfqspi_cs_control *cs_control) | ||
102 | { | ||
103 | int status; | ||
104 | |||
105 | status = gpio_request(MCFQSPI_CS0, "MCFQSPI_CS0"); | ||
106 | if (status) { | ||
107 | pr_debug("gpio_request for MCFQSPI_CS0 failed\n"); | ||
108 | goto fail0; | ||
109 | } | ||
110 | status = gpio_direction_output(MCFQSPI_CS0, 1); | ||
111 | if (status) { | ||
112 | pr_debug("gpio_direction_output for MCFQSPI_CS0 failed\n"); | ||
113 | goto fail1; | ||
114 | } | ||
115 | |||
116 | status = gpio_request(MCFQSPI_CS1, "MCFQSPI_CS1"); | ||
117 | if (status) { | ||
118 | pr_debug("gpio_request for MCFQSPI_CS1 failed\n"); | ||
119 | goto fail1; | ||
120 | } | ||
121 | status = gpio_direction_output(MCFQSPI_CS1, 1); | ||
122 | if (status) { | ||
123 | pr_debug("gpio_direction_output for MCFQSPI_CS1 failed\n"); | ||
124 | goto fail2; | ||
125 | } | ||
126 | |||
127 | status = gpio_request(MCFQSPI_CS2, "MCFQSPI_CS2"); | ||
128 | if (status) { | ||
129 | pr_debug("gpio_request for MCFQSPI_CS2 failed\n"); | ||
130 | goto fail2; | ||
131 | } | ||
132 | status = gpio_direction_output(MCFQSPI_CS2, 1); | ||
133 | if (status) { | ||
134 | pr_debug("gpio_direction_output for MCFQSPI_CS2 failed\n"); | ||
135 | goto fail3; | ||
136 | } | ||
137 | |||
138 | status = gpio_request(MCFQSPI_CS3, "MCFQSPI_CS3"); | ||
139 | if (status) { | ||
140 | pr_debug("gpio_request for MCFQSPI_CS3 failed\n"); | ||
141 | goto fail3; | ||
142 | } | ||
143 | status = gpio_direction_output(MCFQSPI_CS3, 1); | ||
144 | if (status) { | ||
145 | pr_debug("gpio_direction_output for MCFQSPI_CS3 failed\n"); | ||
146 | goto fail4; | ||
147 | } | ||
148 | |||
149 | return 0; | ||
150 | |||
151 | fail4: | ||
152 | gpio_free(MCFQSPI_CS3); | ||
153 | fail3: | ||
154 | gpio_free(MCFQSPI_CS2); | ||
155 | fail2: | ||
156 | gpio_free(MCFQSPI_CS1); | ||
157 | fail1: | ||
158 | gpio_free(MCFQSPI_CS0); | ||
159 | fail0: | ||
160 | return status; | ||
161 | } | ||
162 | |||
163 | static void m528x_cs_teardown(struct mcfqspi_cs_control *cs_control) | ||
164 | { | ||
165 | gpio_free(MCFQSPI_CS3); | ||
166 | gpio_free(MCFQSPI_CS2); | ||
167 | gpio_free(MCFQSPI_CS1); | ||
168 | gpio_free(MCFQSPI_CS0); | ||
169 | } | ||
170 | |||
171 | static void m528x_cs_select(struct mcfqspi_cs_control *cs_control, | ||
172 | u8 chip_select, bool cs_high) | ||
173 | { | ||
174 | gpio_set_value(MCFQSPI_CS0 + chip_select, cs_high); | ||
175 | } | ||
176 | |||
177 | static void m528x_cs_deselect(struct mcfqspi_cs_control *cs_control, | ||
178 | u8 chip_select, bool cs_high) | ||
179 | { | ||
180 | gpio_set_value(MCFQSPI_CS0 + chip_select, !cs_high); | ||
181 | } | ||
182 | |||
183 | static struct mcfqspi_cs_control m528x_cs_control = { | ||
184 | .setup = m528x_cs_setup, | ||
185 | .teardown = m528x_cs_teardown, | ||
186 | .select = m528x_cs_select, | ||
187 | .deselect = m528x_cs_deselect, | ||
188 | }; | ||
189 | |||
190 | static struct mcfqspi_platform_data m528x_qspi_data = { | ||
191 | .bus_num = 0, | ||
192 | .num_chipselect = 4, | ||
193 | .cs_control = &m528x_cs_control, | ||
194 | }; | ||
195 | |||
196 | static struct platform_device m528x_qspi = { | ||
197 | .name = "mcfqspi", | ||
198 | .id = 0, | ||
199 | .num_resources = ARRAY_SIZE(m528x_qspi_resources), | ||
200 | .resource = m528x_qspi_resources, | ||
201 | .dev.platform_data = &m528x_qspi_data, | ||
202 | }; | ||
203 | |||
204 | static void __init m528x_qspi_init(void) | ||
205 | { | ||
206 | /* setup Port QS for QSPI with gpio CS control */ | ||
207 | __raw_writeb(0x07, MCFGPIO_PQSPAR); | ||
208 | } | ||
209 | #endif /* defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) */ | ||
79 | 210 | ||
80 | static struct platform_device *m528x_devices[] __initdata = { | 211 | static struct platform_device *m528x_devices[] __initdata = { |
81 | &m528x_uart, | 212 | &m528x_uart, |
82 | &m528x_fec, | 213 | &m528x_fec, |
214 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | ||
215 | &m528x_qspi, | ||
216 | #endif | ||
83 | }; | 217 | }; |
84 | 218 | ||
85 | /***************************************************************************/ | 219 | /***************************************************************************/ |
@@ -174,6 +308,9 @@ static int __init init_BSP(void) | |||
174 | mach_reset = m528x_cpu_reset; | 308 | mach_reset = m528x_cpu_reset; |
175 | m528x_uarts_init(); | 309 | m528x_uarts_init(); |
176 | m528x_fec_init(); | 310 | m528x_fec_init(); |
311 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | ||
312 | m528x_qspi_init(); | ||
313 | #endif | ||
177 | platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices)); | 314 | platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices)); |
178 | return 0; | 315 | return 0; |
179 | } | 316 | } |