diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-25 15:03:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-25 15:03:17 -0400 |
commit | c19eb8f0d1bd442ed1aff0b413dd822620771c29 (patch) | |
tree | 607a1a99f24c484e68e60526c03a518c5f3799b5 /arch/m68knommu/platform/520x/config.c | |
parent | 99765cc7e393c8637abaaf0c73f28ec63370d35c (diff) | |
parent | 724b62b5f73e7d17c737ddb879e0543c886b20ce (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu:
arch/m68knommu/platform/68360/commproc.c: Checkpatch cleanup
arch/m68knommu/mm/fault.c: Checkpatch cleanup
m68knommu: improve short help of m68knommu/Kconfig/RAMSIZE for '0' case
m68knommu: remove un-used mcfsmc.h
m68knommu: add smc91x support for ColdFire NETtel boards
m68knommu: add smc91x support to ColdFire 5249 platform
m68knommu: remove size limit on non-MMU TASK_SIZE
m68knommu: fix broken use of BUAD_TABLE_SIZE in 68328serial driver
m68knommu: Coldfire QSPI platform support
Diffstat (limited to 'arch/m68knommu/platform/520x/config.c')
-rw-r--r-- | arch/m68knommu/platform/520x/config.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/arch/m68knommu/platform/520x/config.c b/arch/m68knommu/platform/520x/config.c index 92614de42cd3..71d2ba474c63 100644 --- a/arch/m68knommu/platform/520x/config.c +++ b/arch/m68knommu/platform/520x/config.c | |||
@@ -15,10 +15,13 @@ | |||
15 | #include <linux/param.h> | 15 | #include <linux/param.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/spi/spi.h> | ||
19 | #include <linux/gpio.h> | ||
18 | #include <asm/machdep.h> | 20 | #include <asm/machdep.h> |
19 | #include <asm/coldfire.h> | 21 | #include <asm/coldfire.h> |
20 | #include <asm/mcfsim.h> | 22 | #include <asm/mcfsim.h> |
21 | #include <asm/mcfuart.h> | 23 | #include <asm/mcfuart.h> |
24 | #include <asm/mcfqspi.h> | ||
22 | 25 | ||
23 | /***************************************************************************/ | 26 | /***************************************************************************/ |
24 | 27 | ||
@@ -74,9 +77,152 @@ static struct platform_device m520x_fec = { | |||
74 | .resource = m520x_fec_resources, | 77 | .resource = m520x_fec_resources, |
75 | }; | 78 | }; |
76 | 79 | ||
80 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | ||
81 | static struct resource m520x_qspi_resources[] = { | ||
82 | { | ||
83 | .start = MCFQSPI_IOBASE, | ||
84 | .end = MCFQSPI_IOBASE + MCFQSPI_IOSIZE - 1, | ||
85 | .flags = IORESOURCE_MEM, | ||
86 | }, | ||
87 | { | ||
88 | .start = MCFINT_VECBASE + MCFINT_QSPI, | ||
89 | .end = MCFINT_VECBASE + MCFINT_QSPI, | ||
90 | .flags = IORESOURCE_IRQ, | ||
91 | }, | ||
92 | }; | ||
93 | |||
94 | #define MCFQSPI_CS0 62 | ||
95 | #define MCFQSPI_CS1 63 | ||
96 | #define MCFQSPI_CS2 44 | ||
97 | |||
98 | static int m520x_cs_setup(struct mcfqspi_cs_control *cs_control) | ||
99 | { | ||
100 | int status; | ||
101 | |||
102 | status = gpio_request(MCFQSPI_CS0, "MCFQSPI_CS0"); | ||
103 | if (status) { | ||
104 | pr_debug("gpio_request for MCFQSPI_CS0 failed\n"); | ||
105 | goto fail0; | ||
106 | } | ||
107 | status = gpio_direction_output(MCFQSPI_CS0, 1); | ||
108 | if (status) { | ||
109 | pr_debug("gpio_direction_output for MCFQSPI_CS0 failed\n"); | ||
110 | goto fail1; | ||
111 | } | ||
112 | |||
113 | status = gpio_request(MCFQSPI_CS1, "MCFQSPI_CS1"); | ||
114 | if (status) { | ||
115 | pr_debug("gpio_request for MCFQSPI_CS1 failed\n"); | ||
116 | goto fail1; | ||
117 | } | ||
118 | status = gpio_direction_output(MCFQSPI_CS1, 1); | ||
119 | if (status) { | ||
120 | pr_debug("gpio_direction_output for MCFQSPI_CS1 failed\n"); | ||
121 | goto fail2; | ||
122 | } | ||
123 | |||
124 | status = gpio_request(MCFQSPI_CS2, "MCFQSPI_CS2"); | ||
125 | if (status) { | ||
126 | pr_debug("gpio_request for MCFQSPI_CS2 failed\n"); | ||
127 | goto fail2; | ||
128 | } | ||
129 | status = gpio_direction_output(MCFQSPI_CS2, 1); | ||
130 | if (status) { | ||
131 | pr_debug("gpio_direction_output for MCFQSPI_CS2 failed\n"); | ||
132 | goto fail3; | ||
133 | } | ||
134 | |||
135 | return 0; | ||
136 | |||
137 | fail3: | ||
138 | gpio_free(MCFQSPI_CS2); | ||
139 | fail2: | ||
140 | gpio_free(MCFQSPI_CS1); | ||
141 | fail1: | ||
142 | gpio_free(MCFQSPI_CS0); | ||
143 | fail0: | ||
144 | return status; | ||
145 | } | ||
146 | |||
147 | static void m520x_cs_teardown(struct mcfqspi_cs_control *cs_control) | ||
148 | { | ||
149 | gpio_free(MCFQSPI_CS2); | ||
150 | gpio_free(MCFQSPI_CS1); | ||
151 | gpio_free(MCFQSPI_CS0); | ||
152 | } | ||
153 | |||
154 | static void m520x_cs_select(struct mcfqspi_cs_control *cs_control, | ||
155 | u8 chip_select, bool cs_high) | ||
156 | { | ||
157 | switch (chip_select) { | ||
158 | case 0: | ||
159 | gpio_set_value(MCFQSPI_CS0, cs_high); | ||
160 | break; | ||
161 | case 1: | ||
162 | gpio_set_value(MCFQSPI_CS1, cs_high); | ||
163 | break; | ||
164 | case 2: | ||
165 | gpio_set_value(MCFQSPI_CS2, cs_high); | ||
166 | break; | ||
167 | } | ||
168 | } | ||
169 | |||
170 | static void m520x_cs_deselect(struct mcfqspi_cs_control *cs_control, | ||
171 | u8 chip_select, bool cs_high) | ||
172 | { | ||
173 | switch (chip_select) { | ||
174 | case 0: | ||
175 | gpio_set_value(MCFQSPI_CS0, !cs_high); | ||
176 | break; | ||
177 | case 1: | ||
178 | gpio_set_value(MCFQSPI_CS1, !cs_high); | ||
179 | break; | ||
180 | case 2: | ||
181 | gpio_set_value(MCFQSPI_CS2, !cs_high); | ||
182 | break; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | static struct mcfqspi_cs_control m520x_cs_control = { | ||
187 | .setup = m520x_cs_setup, | ||
188 | .teardown = m520x_cs_teardown, | ||
189 | .select = m520x_cs_select, | ||
190 | .deselect = m520x_cs_deselect, | ||
191 | }; | ||
192 | |||
193 | static struct mcfqspi_platform_data m520x_qspi_data = { | ||
194 | .bus_num = 0, | ||
195 | .num_chipselect = 3, | ||
196 | .cs_control = &m520x_cs_control, | ||
197 | }; | ||
198 | |||
199 | static struct platform_device m520x_qspi = { | ||
200 | .name = "mcfqspi", | ||
201 | .id = 0, | ||
202 | .num_resources = ARRAY_SIZE(m520x_qspi_resources), | ||
203 | .resource = m520x_qspi_resources, | ||
204 | .dev.platform_data = &m520x_qspi_data, | ||
205 | }; | ||
206 | |||
207 | static void __init m520x_qspi_init(void) | ||
208 | { | ||
209 | u16 par; | ||
210 | /* setup Port QS for QSPI with gpio CS control */ | ||
211 | writeb(0x3f, MCF_IPSBAR + MCF_GPIO_PAR_QSPI); | ||
212 | /* make U1CTS and U2RTS gpio for cs_control */ | ||
213 | par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART); | ||
214 | par &= 0x00ff; | ||
215 | writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART); | ||
216 | } | ||
217 | #endif /* defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) */ | ||
218 | |||
219 | |||
77 | static struct platform_device *m520x_devices[] __initdata = { | 220 | static struct platform_device *m520x_devices[] __initdata = { |
78 | &m520x_uart, | 221 | &m520x_uart, |
79 | &m520x_fec, | 222 | &m520x_fec, |
223 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | ||
224 | &m520x_qspi, | ||
225 | #endif | ||
80 | }; | 226 | }; |
81 | 227 | ||
82 | /***************************************************************************/ | 228 | /***************************************************************************/ |
@@ -147,6 +293,9 @@ void __init config_BSP(char *commandp, int size) | |||
147 | mach_reset = m520x_cpu_reset; | 293 | mach_reset = m520x_cpu_reset; |
148 | m520x_uarts_init(); | 294 | m520x_uarts_init(); |
149 | m520x_fec_init(); | 295 | m520x_fec_init(); |
296 | #if defined(CONFIG_SPI_COLDFIRE_QSPI) || defined(CONFIG_SPI_COLDFIRE_QSPI_MODULE) | ||
297 | m520x_qspi_init(); | ||
298 | #endif | ||
150 | } | 299 | } |
151 | 300 | ||
152 | /***************************************************************************/ | 301 | /***************************************************************************/ |