]>
Commit | Line | Data |
---|---|---|
f2aaf66d MD |
1 | /* |
2 | * G4EVM board support | |
3 | * | |
4 | * Copyright (C) 2010 Magnus Damm | |
5 | * Copyright (C) 2008 Yoshihiro Shimoda | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; version 2 of the License. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | #include <linux/kernel.h> | |
21 | #include <linux/init.h> | |
22 | #include <linux/interrupt.h> | |
23 | #include <linux/irq.h> | |
24 | #include <linux/platform_device.h> | |
25 | #include <linux/delay.h> | |
26 | #include <linux/mtd/mtd.h> | |
27 | #include <linux/mtd/partitions.h> | |
28 | #include <linux/mtd/physmap.h> | |
85f77ecf GL |
29 | #include <linux/regulator/fixed.h> |
30 | #include <linux/regulator/machine.h> | |
aa18ef60 | 31 | #include <linux/usb/r8a66597.h> |
f2aaf66d | 32 | #include <linux/io.h> |
6676a170 NH |
33 | #include <linux/input.h> |
34 | #include <linux/input/sh_keysc.h> | |
9213c000 | 35 | #include <linux/mmc/host.h> |
17e75d82 | 36 | #include <linux/mmc/sh_mobile_sdhi.h> |
276b4f62 | 37 | #include <linux/gpio.h> |
9b742024 | 38 | #include <linux/dma-mapping.h> |
250a2723 | 39 | #include <mach/irqs.h> |
276b4f62 | 40 | #include <mach/sh7377.h> |
f2aaf66d MD |
41 | #include <mach/common.h> |
42 | #include <asm/mach-types.h> | |
43 | #include <asm/mach/arch.h> | |
f2aaf66d | 44 | |
819ee867 KM |
45 | /* |
46 | * SDHI | |
47 | * | |
48 | * SDHI0 : card detection is possible | |
49 | * SDHI1 : card detection is impossible | |
50 | * | |
51 | * [G4-MAIN-BOARD] | |
52 | * JP74 : short # DBG_2V8A for SDHI0 | |
53 | * JP75 : NC # DBG_3V3A for SDHI0 | |
54 | * JP76 : NC # DBG_3V3A_SD for SDHI0 | |
55 | * JP77 : NC # 3V3A_SDIO for SDHI1 | |
56 | * JP78 : short # DBG_2V8A for SDHI1 | |
57 | * JP79 : NC # DBG_3V3A for SDHI1 | |
58 | * JP80 : NC # DBG_3V3A_SD for SDHI1 | |
59 | * | |
60 | * [G4-CORE-BOARD] | |
61 | * S32 : all off # to dissever from G3-CORE_DBG board | |
62 | * S33 : all off # to dissever from G3-CORE_DBG board | |
63 | * | |
64 | * [G3-CORE_DBG-BOARD] | |
65 | * S1 : all off # to dissever from G3-CORE_DBG board | |
66 | * S3 : all off # to dissever from G3-CORE_DBG board | |
67 | * S4 : all off # to dissever from G3-CORE_DBG board | |
68 | */ | |
69 | ||
f2aaf66d MD |
70 | static struct mtd_partition nor_flash_partitions[] = { |
71 | { | |
72 | .name = "loader", | |
73 | .offset = 0x00000000, | |
74 | .size = 512 * 1024, | |
75 | }, | |
76 | { | |
77 | .name = "bootenv", | |
78 | .offset = MTDPART_OFS_APPEND, | |
79 | .size = 512 * 1024, | |
80 | }, | |
81 | { | |
82 | .name = "kernel_ro", | |
83 | .offset = MTDPART_OFS_APPEND, | |
84 | .size = 8 * 1024 * 1024, | |
85 | .mask_flags = MTD_WRITEABLE, | |
86 | }, | |
87 | { | |
88 | .name = "kernel", | |
89 | .offset = MTDPART_OFS_APPEND, | |
90 | .size = 8 * 1024 * 1024, | |
91 | }, | |
92 | { | |
93 | .name = "data", | |
94 | .offset = MTDPART_OFS_APPEND, | |
95 | .size = MTDPART_SIZ_FULL, | |
96 | }, | |
97 | }; | |
98 | ||
99 | static struct physmap_flash_data nor_flash_data = { | |
100 | .width = 2, | |
101 | .parts = nor_flash_partitions, | |
102 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), | |
103 | }; | |
104 | ||
105 | static struct resource nor_flash_resources[] = { | |
106 | [0] = { | |
107 | .start = 0x00000000, | |
108 | .end = 0x08000000 - 1, | |
109 | .flags = IORESOURCE_MEM, | |
110 | } | |
111 | }; | |
112 | ||
113 | static struct platform_device nor_flash_device = { | |
114 | .name = "physmap-flash", | |
115 | .dev = { | |
116 | .platform_data = &nor_flash_data, | |
117 | }, | |
118 | .num_resources = ARRAY_SIZE(nor_flash_resources), | |
119 | .resource = nor_flash_resources, | |
120 | }; | |
121 | ||
aa18ef60 | 122 | /* USBHS */ |
d64a1b0a | 123 | static void usb_host_port_power(int port, int power) |
aa18ef60 NH |
124 | { |
125 | if (!power) /* only power-on supported for now */ | |
126 | return; | |
127 | ||
128 | /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */ | |
0a4b04dc | 129 | __raw_writew(__raw_readw(IOMEM(0xe6890008)) | 0x600, IOMEM(0xe6890008)); |
aa18ef60 NH |
130 | } |
131 | ||
132 | static struct r8a66597_platdata usb_host_data = { | |
133 | .on_chip = 1, | |
134 | .port_power = usb_host_port_power, | |
135 | }; | |
136 | ||
137 | static struct resource usb_host_resources[] = { | |
138 | [0] = { | |
139 | .name = "USBHS", | |
140 | .start = 0xe6890000, | |
141 | .end = 0xe68900e5, | |
142 | .flags = IORESOURCE_MEM, | |
143 | }, | |
144 | [1] = { | |
043296dd | 145 | .start = evt2irq(0x0a20), /* USBHS_USHI0 */ |
aa18ef60 NH |
146 | .flags = IORESOURCE_IRQ, |
147 | }, | |
148 | }; | |
149 | ||
150 | static struct platform_device usb_host_device = { | |
151 | .name = "r8a66597_hcd", | |
152 | .id = 0, | |
153 | .dev = { | |
154 | .platform_data = &usb_host_data, | |
155 | .dma_mask = NULL, | |
156 | .coherent_dma_mask = 0xffffffff, | |
157 | }, | |
158 | .num_resources = ARRAY_SIZE(usb_host_resources), | |
159 | .resource = usb_host_resources, | |
160 | }; | |
f2aaf66d | 161 | |
6676a170 NH |
162 | /* KEYSC */ |
163 | static struct sh_keysc_info keysc_info = { | |
164 | .mode = SH_KEYSC_MODE_5, | |
165 | .scan_timing = 3, | |
166 | .delay = 100, | |
167 | .keycodes = { | |
168 | KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, | |
169 | KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, | |
170 | KEY_M, KEY_N, KEY_U, KEY_P, KEY_Q, KEY_R, | |
171 | KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, | |
172 | KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP, KEY_WAKEUP, KEY_COFFEE, | |
173 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, | |
174 | KEY_6, KEY_7, KEY_8, KEY_9, KEY_STOP, KEY_COMPUTER, | |
175 | }, | |
176 | }; | |
177 | ||
178 | static struct resource keysc_resources[] = { | |
179 | [0] = { | |
180 | .name = "KEYSC", | |
181 | .start = 0xe61b0000, | |
182 | .end = 0xe61b000f, | |
183 | .flags = IORESOURCE_MEM, | |
184 | }, | |
185 | [1] = { | |
043296dd | 186 | .start = evt2irq(0x0be0), /* KEYSC_KEY */ |
6676a170 NH |
187 | .flags = IORESOURCE_IRQ, |
188 | }, | |
189 | }; | |
190 | ||
191 | static struct platform_device keysc_device = { | |
192 | .name = "sh_keysc", | |
193 | .id = 0, /* keysc0 clock */ | |
194 | .num_resources = ARRAY_SIZE(keysc_resources), | |
195 | .resource = keysc_resources, | |
196 | .dev = { | |
197 | .platform_data = &keysc_info, | |
198 | }, | |
199 | }; | |
200 | ||
85f77ecf GL |
201 | /* Fixed 3.3V regulator to be used by SDHI0 and SDHI1 */ |
202 | static struct regulator_consumer_supply fixed3v3_power_consumers[] = | |
203 | { | |
204 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), | |
205 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), | |
206 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"), | |
207 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"), | |
208 | }; | |
209 | ||
819ee867 | 210 | /* SDHI */ |
9213c000 MD |
211 | static struct sh_mobile_sdhi_info sdhi0_info = { |
212 | .tmio_caps = MMC_CAP_SDIO_IRQ, | |
213 | }; | |
214 | ||
819ee867 KM |
215 | static struct resource sdhi0_resources[] = { |
216 | [0] = { | |
217 | .name = "SDHI0", | |
218 | .start = 0xe6d50000, | |
1acd3de5 | 219 | .end = 0xe6d500ff, |
819ee867 KM |
220 | .flags = IORESOURCE_MEM, |
221 | }, | |
222 | [1] = { | |
043296dd | 223 | .start = evt2irq(0x0e00), /* SDHI0 */ |
819ee867 KM |
224 | .flags = IORESOURCE_IRQ, |
225 | }, | |
226 | }; | |
227 | ||
228 | static struct platform_device sdhi0_device = { | |
229 | .name = "sh_mobile_sdhi", | |
230 | .num_resources = ARRAY_SIZE(sdhi0_resources), | |
231 | .resource = sdhi0_resources, | |
232 | .id = 0, | |
9213c000 MD |
233 | .dev = { |
234 | .platform_data = &sdhi0_info, | |
235 | }, | |
236 | }; | |
237 | ||
238 | static struct sh_mobile_sdhi_info sdhi1_info = { | |
239 | .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ, | |
819ee867 KM |
240 | }; |
241 | ||
242 | static struct resource sdhi1_resources[] = { | |
243 | [0] = { | |
244 | .name = "SDHI1", | |
245 | .start = 0xe6d60000, | |
31d31fe7 | 246 | .end = 0xe6d600ff, |
819ee867 KM |
247 | .flags = IORESOURCE_MEM, |
248 | }, | |
249 | [1] = { | |
043296dd | 250 | .start = evt2irq(0x0e80), /* SDHI1 */ |
819ee867 KM |
251 | .flags = IORESOURCE_IRQ, |
252 | }, | |
253 | }; | |
254 | ||
255 | static struct platform_device sdhi1_device = { | |
256 | .name = "sh_mobile_sdhi", | |
257 | .num_resources = ARRAY_SIZE(sdhi1_resources), | |
258 | .resource = sdhi1_resources, | |
259 | .id = 1, | |
9213c000 MD |
260 | .dev = { |
261 | .platform_data = &sdhi1_info, | |
262 | }, | |
819ee867 KM |
263 | }; |
264 | ||
f2aaf66d MD |
265 | static struct platform_device *g4evm_devices[] __initdata = { |
266 | &nor_flash_device, | |
aa18ef60 | 267 | &usb_host_device, |
6676a170 | 268 | &keysc_device, |
819ee867 KM |
269 | &sdhi0_device, |
270 | &sdhi1_device, | |
f2aaf66d MD |
271 | }; |
272 | ||
0a4b04dc AB |
273 | #define GPIO_SDHID0_D0 IOMEM(0xe60520fc) |
274 | #define GPIO_SDHID0_D1 IOMEM(0xe60520fd) | |
275 | #define GPIO_SDHID0_D2 IOMEM(0xe60520fe) | |
276 | #define GPIO_SDHID0_D3 IOMEM(0xe60520ff) | |
277 | #define GPIO_SDHICMD0 IOMEM(0xe6052100) | |
819ee867 | 278 | |
0a4b04dc AB |
279 | #define GPIO_SDHID1_D0 IOMEM(0xe6052103) |
280 | #define GPIO_SDHID1_D1 IOMEM(0xe6052104) | |
281 | #define GPIO_SDHID1_D2 IOMEM(0xe6052105) | |
282 | #define GPIO_SDHID1_D3 IOMEM(0xe6052106) | |
283 | #define GPIO_SDHICMD1 IOMEM(0xe6052107) | |
819ee867 | 284 | |
f2aaf66d MD |
285 | static void __init g4evm_init(void) |
286 | { | |
85f77ecf GL |
287 | regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers, |
288 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); | |
289 | ||
276b4f62 NH |
290 | sh7377_pinmux_init(); |
291 | ||
292 | /* Lit DS14 LED */ | |
293 | gpio_request(GPIO_PORT109, NULL); | |
294 | gpio_direction_output(GPIO_PORT109, 1); | |
295 | gpio_export(GPIO_PORT109, 1); | |
296 | ||
297 | /* Lit DS15 LED */ | |
298 | gpio_request(GPIO_PORT110, NULL); | |
299 | gpio_direction_output(GPIO_PORT110, 1); | |
300 | gpio_export(GPIO_PORT110, 1); | |
301 | ||
302 | /* Lit DS16 LED */ | |
303 | gpio_request(GPIO_PORT112, NULL); | |
304 | gpio_direction_output(GPIO_PORT112, 1); | |
305 | gpio_export(GPIO_PORT112, 1); | |
306 | ||
307 | /* Lit DS17 LED */ | |
308 | gpio_request(GPIO_PORT113, NULL); | |
309 | gpio_direction_output(GPIO_PORT113, 1); | |
310 | gpio_export(GPIO_PORT113, 1); | |
311 | ||
aa18ef60 NH |
312 | /* USBHS */ |
313 | gpio_request(GPIO_FN_VBUS_0, NULL); | |
314 | gpio_request(GPIO_FN_PWEN, NULL); | |
315 | gpio_request(GPIO_FN_OVCN, NULL); | |
316 | gpio_request(GPIO_FN_OVCN2, NULL); | |
317 | gpio_request(GPIO_FN_EXTLP, NULL); | |
318 | gpio_request(GPIO_FN_IDIN, NULL); | |
319 | ||
aa18ef60 | 320 | /* setup USB phy */ |
0a4b04dc AB |
321 | __raw_writew(0x0200, IOMEM(0xe605810a)); /* USBCR1 */ |
322 | __raw_writew(0x00e0, IOMEM(0xe60581c0)); /* CPFCH */ | |
323 | __raw_writew(0x6010, IOMEM(0xe60581c6)); /* CGPOSR */ | |
324 | __raw_writew(0x8a0a, IOMEM(0xe605810c)); /* USBCR2 */ | |
aa18ef60 | 325 | |
6676a170 NH |
326 | /* KEYSC @ CN31 */ |
327 | gpio_request(GPIO_FN_PORT60_KEYOUT5, NULL); | |
328 | gpio_request(GPIO_FN_PORT61_KEYOUT4, NULL); | |
329 | gpio_request(GPIO_FN_PORT62_KEYOUT3, NULL); | |
330 | gpio_request(GPIO_FN_PORT63_KEYOUT2, NULL); | |
331 | gpio_request(GPIO_FN_PORT64_KEYOUT1, NULL); | |
332 | gpio_request(GPIO_FN_PORT65_KEYOUT0, NULL); | |
333 | gpio_request(GPIO_FN_PORT66_KEYIN0_PU, NULL); | |
334 | gpio_request(GPIO_FN_PORT67_KEYIN1_PU, NULL); | |
335 | gpio_request(GPIO_FN_PORT68_KEYIN2_PU, NULL); | |
336 | gpio_request(GPIO_FN_PORT69_KEYIN3_PU, NULL); | |
337 | gpio_request(GPIO_FN_PORT70_KEYIN4_PU, NULL); | |
338 | gpio_request(GPIO_FN_PORT71_KEYIN5_PU, NULL); | |
339 | gpio_request(GPIO_FN_PORT72_KEYIN6_PU, NULL); | |
340 | ||
819ee867 KM |
341 | /* SDHI0 */ |
342 | gpio_request(GPIO_FN_SDHICLK0, NULL); | |
343 | gpio_request(GPIO_FN_SDHICD0, NULL); | |
344 | gpio_request(GPIO_FN_SDHID0_0, NULL); | |
345 | gpio_request(GPIO_FN_SDHID0_1, NULL); | |
346 | gpio_request(GPIO_FN_SDHID0_2, NULL); | |
347 | gpio_request(GPIO_FN_SDHID0_3, NULL); | |
348 | gpio_request(GPIO_FN_SDHICMD0, NULL); | |
349 | gpio_request(GPIO_FN_SDHIWP0, NULL); | |
6f00294f KM |
350 | gpio_request_pullup(GPIO_SDHID0_D0); |
351 | gpio_request_pullup(GPIO_SDHID0_D1); | |
352 | gpio_request_pullup(GPIO_SDHID0_D2); | |
353 | gpio_request_pullup(GPIO_SDHID0_D3); | |
354 | gpio_request_pullup(GPIO_SDHICMD0); | |
819ee867 KM |
355 | |
356 | /* SDHI1 */ | |
357 | gpio_request(GPIO_FN_SDHICLK1, NULL); | |
358 | gpio_request(GPIO_FN_SDHID1_0, NULL); | |
359 | gpio_request(GPIO_FN_SDHID1_1, NULL); | |
360 | gpio_request(GPIO_FN_SDHID1_2, NULL); | |
361 | gpio_request(GPIO_FN_SDHID1_3, NULL); | |
362 | gpio_request(GPIO_FN_SDHICMD1, NULL); | |
6f00294f KM |
363 | gpio_request_pullup(GPIO_SDHID1_D0); |
364 | gpio_request_pullup(GPIO_SDHID1_D1); | |
365 | gpio_request_pullup(GPIO_SDHID1_D2); | |
366 | gpio_request_pullup(GPIO_SDHID1_D3); | |
367 | gpio_request_pullup(GPIO_SDHICMD1); | |
819ee867 | 368 | |
f2aaf66d MD |
369 | sh7377_add_standard_devices(); |
370 | ||
371 | platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices)); | |
372 | } | |
373 | ||
374 | MACHINE_START(G4EVM, "g4evm") | |
bfc46f3e MD |
375 | .map_io = sh7377_map_io, |
376 | .init_early = sh7377_add_early_devices, | |
f2aaf66d | 377 | .init_irq = sh7377_init_irq, |
863b1719 | 378 | .handle_irq = shmobile_handle_irq_intc, |
f2aaf66d | 379 | .init_machine = g4evm_init, |
21cc1b7e | 380 | .init_late = shmobile_init_late, |
03f7beef | 381 | .timer = &shmobile_timer, |
f2aaf66d | 382 | MACHINE_END |