blob: fb94162382e278c727c35d8beebc7fffde5f3640 [file] [log] [blame]
Magnus Damm6d9598e2010-11-17 10:59:31 +00001/*
2 * arch/arm/mach-shmobile/board-ag5evm.c
3 *
4 * Copyright (C) 2010 Takashi Yoshii <yoshii.takashi.zj@renesas.com>
5 * Copyright (C) 2009 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
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 */
21
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/irq.h>
26#include <linux/platform_device.h>
27#include <linux/delay.h>
28#include <linux/io.h>
29#include <linux/dma-mapping.h>
30#include <linux/serial_sci.h>
31#include <linux/smsc911x.h>
32#include <linux/gpio.h>
Yoshii Takashi2d22d482010-11-19 13:15:46 +000033#include <linux/input.h>
34#include <linux/input/sh_keysc.h>
Takashi YOSHII6bf45a12010-12-22 06:35:30 +000035#include <linux/mmc/host.h>
36#include <linux/mmc/sh_mmcif.h>
Yoshii Takashi2d22d482010-11-19 13:15:46 +000037
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +000038#include <sound/sh_fsi.h>
39
Magnus Damm6d9598e2010-11-17 10:59:31 +000040#include <mach/hardware.h>
41#include <mach/sh73a0.h>
42#include <mach/common.h>
43#include <asm/mach-types.h>
44#include <asm/mach/arch.h>
45#include <asm/mach/map.h>
46#include <asm/mach/time.h>
47#include <asm/hardware/gic.h>
48#include <asm/hardware/cache-l2x0.h>
49#include <asm/traps.h>
50
51static struct resource smsc9220_resources[] = {
52 [0] = {
53 .start = 0x14000000,
54 .end = 0x14000000 + SZ_64K - 1,
55 .flags = IORESOURCE_MEM,
56 },
57 [1] = {
58 .start = gic_spi(33), /* PINT1 */
59 .flags = IORESOURCE_IRQ,
60 },
61};
62
63static struct smsc911x_platform_config smsc9220_platdata = {
64 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
65 .phy_interface = PHY_INTERFACE_MODE_MII,
66 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
67 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
68};
69
70static struct platform_device eth_device = {
71 .name = "smsc911x",
72 .id = 0,
73 .dev = {
74 .platform_data = &smsc9220_platdata,
75 },
76 .resource = smsc9220_resources,
77 .num_resources = ARRAY_SIZE(smsc9220_resources),
78};
79
Yoshii Takashi2d22d482010-11-19 13:15:46 +000080static struct sh_keysc_info keysc_platdata = {
81 .mode = SH_KEYSC_MODE_6,
82 .scan_timing = 3,
83 .delay = 100,
84 .keycodes = {
85 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
86 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
87 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
88 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
89 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
90 KEY_COFFEE,
91 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
92 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
93 KEY_COMPUTER,
94 },
95};
96
97static struct resource keysc_resources[] = {
98 [0] = {
99 .name = "KEYSC",
100 .start = 0xe61b0000,
101 .end = 0xe61b0098 - 1,
102 .flags = IORESOURCE_MEM,
103 },
104 [1] = {
105 .start = gic_spi(71),
106 .flags = IORESOURCE_IRQ,
107 },
108};
109
110static struct platform_device keysc_device = {
111 .name = "sh_keysc",
112 .id = 0,
113 .num_resources = ARRAY_SIZE(keysc_resources),
114 .resource = keysc_resources,
115 .dev = {
116 .platform_data = &keysc_platdata,
117 },
118};
119
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000120/* FSI A */
121static struct sh_fsi_platform_info fsi_info = {
122 .porta_flags = SH_FSI_OUT_SLAVE_MODE |
123 SH_FSI_IN_SLAVE_MODE |
124 SH_FSI_OFMT(I2S) |
125 SH_FSI_IFMT(I2S),
126};
127
128static struct resource fsi_resources[] = {
129 [0] = {
130 .name = "FSI",
131 .start = 0xEC230000,
132 .end = 0xEC230400 - 1,
133 .flags = IORESOURCE_MEM,
134 },
135 [1] = {
136 .start = gic_spi(146),
137 .flags = IORESOURCE_IRQ,
138 },
139};
140
141static struct platform_device fsi_device = {
142 .name = "sh_fsi2",
143 .id = -1,
144 .num_resources = ARRAY_SIZE(fsi_resources),
145 .resource = fsi_resources,
146 .dev = {
147 .platform_data = &fsi_info,
148 },
149};
150
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000151static struct resource sh_mmcif_resources[] = {
152 [0] = {
153 .name = "MMCIF",
154 .start = 0xe6bd0000,
155 .end = 0xe6bd00ff,
156 .flags = IORESOURCE_MEM,
157 },
158 [1] = {
159 .start = gic_spi(141),
160 .flags = IORESOURCE_IRQ,
161 },
162 [2] = {
163 .start = gic_spi(140),
164 .flags = IORESOURCE_IRQ,
165 },
166};
167
168static struct sh_mmcif_plat_data sh_mmcif_platdata = {
169 .sup_pclk = 0,
170 .ocr = MMC_VDD_165_195,
171 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
172};
173
174static struct platform_device mmc_device = {
175 .name = "sh_mmcif",
176 .id = 0,
177 .dev = {
178 .dma_mask = NULL,
179 .coherent_dma_mask = 0xffffffff,
180 .platform_data = &sh_mmcif_platdata,
181 },
182 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
183 .resource = sh_mmcif_resources,
184};
185
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000186/* IrDA */
187static struct resource irda_resources[] = {
188 [0] = {
189 .start = 0xE6D00000,
190 .end = 0xE6D01FD4 - 1,
191 .flags = IORESOURCE_MEM,
192 },
193 [1] = {
194 .start = gic_spi(95),
195 .flags = IORESOURCE_IRQ,
196 },
197};
198
199static struct platform_device irda_device = {
200 .name = "sh_irda",
201 .id = 0,
202 .resource = irda_resources,
203 .num_resources = ARRAY_SIZE(irda_resources),
204};
205
Magnus Damm6d9598e2010-11-17 10:59:31 +0000206static struct platform_device *ag5evm_devices[] __initdata = {
207 &eth_device,
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000208 &keysc_device,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000209 &fsi_device,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000210 &mmc_device,
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000211 &irda_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000212};
213
214static struct map_desc ag5evm_io_desc[] __initdata = {
215 /* create a 1:1 entity map for 0xe6xxxxxx
216 * used by CPGA, INTC and PFC.
217 */
218 {
219 .virtual = 0xe6000000,
220 .pfn = __phys_to_pfn(0xe6000000),
221 .length = 256 << 20,
222 .type = MT_DEVICE_NONSHARED
223 },
224};
225
226static void __init ag5evm_map_io(void)
227{
228 iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
229
230 /* setup early devices and console here as well */
231 sh73a0_add_early_devices();
232 shmobile_setup_console();
233}
234
235#define PINTC_ADDR 0xe6900000
236#define PINTER0A (PINTC_ADDR + 0xa0)
237#define PINTCR0A (PINTC_ADDR + 0xb0)
238
239void __init ag5evm_init_irq(void)
240{
Magnus Damm5f53a562010-12-21 08:37:32 +0000241 sh73a0_init_irq();
242
Magnus Damm6d9598e2010-11-17 10:59:31 +0000243 /* setup PINT: enable PINTA2 as active low */
244 __raw_writel(__raw_readl(PINTER0A) | (1<<29), PINTER0A);
245 __raw_writew(__raw_readw(PINTCR0A) | (2<<10), PINTCR0A);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000246}
247
Magnus Damm6d9598e2010-11-17 10:59:31 +0000248static void __init ag5evm_init(void)
249{
Takashi YOSHII3256c782010-11-19 16:49:38 +0900250 sh73a0_pinmux_init();
251
Magnus Damm6d9598e2010-11-17 10:59:31 +0000252 /* enable SCIFA2 */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900253 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
254 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
255 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
256 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000257
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000258 /* enable KEYSC */
Takashi YOSHII5d781472010-12-22 06:30:19 +0000259 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
260 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
261 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
262 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
263 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
264 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
265 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
266 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000267 gpio_request(GPIO_FN_KEYOUT0, NULL);
268 gpio_request(GPIO_FN_KEYOUT1, NULL);
269 gpio_request(GPIO_FN_KEYOUT2, NULL);
270 gpio_request(GPIO_FN_KEYOUT3, NULL);
271 gpio_request(GPIO_FN_KEYOUT4, NULL);
272 gpio_request(GPIO_FN_KEYOUT5, NULL);
273 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
274 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
275 gpio_request(GPIO_FN_KEYOUT8, NULL);
276 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
277
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000278 /* enable I2C channel 2 and 3 */
Yoshii Takashi8e67b222010-11-19 13:21:32 +0000279 gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
280 gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
281 gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
282 gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
283
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000284 /* enable MMCIF */
285 gpio_request(GPIO_FN_MMCCLK0, NULL);
286 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
287 gpio_request(GPIO_FN_MMCD0_0, NULL);
288 gpio_request(GPIO_FN_MMCD0_1, NULL);
289 gpio_request(GPIO_FN_MMCD0_2, NULL);
290 gpio_request(GPIO_FN_MMCD0_3, NULL);
291 gpio_request(GPIO_FN_MMCD0_4, NULL);
292 gpio_request(GPIO_FN_MMCD0_5, NULL);
293 gpio_request(GPIO_FN_MMCD0_6, NULL);
294 gpio_request(GPIO_FN_MMCD0_7, NULL);
295 gpio_request(GPIO_PORT208, NULL); /* Reset */
296 gpio_direction_output(GPIO_PORT208, 1);
297
Magnus Damm6d9598e2010-11-17 10:59:31 +0000298 /* enable SMSC911X */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900299 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
300 gpio_direction_input(GPIO_PORT144);
301 gpio_request(GPIO_PORT145, NULL); /* RESET */
302 gpio_direction_output(GPIO_PORT145, 1);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000303
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000304 /* FSI A */
305 gpio_request(GPIO_FN_FSIACK, NULL);
306 gpio_request(GPIO_FN_FSIAILR, NULL);
307 gpio_request(GPIO_FN_FSIAIBT, NULL);
308 gpio_request(GPIO_FN_FSIAISLD, NULL);
309 gpio_request(GPIO_FN_FSIAOSLD, NULL);
310
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000311 /* IrDA */
312 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
313 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
314 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
315
Magnus Damm6d9598e2010-11-17 10:59:31 +0000316#ifdef CONFIG_CACHE_L2X0
317 /* Shared attribute override enable, 64K*8way */
318 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
319#endif
320 sh73a0_add_standard_devices();
321 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
322}
323
324static void __init ag5evm_timer_init(void)
325{
326 sh73a0_clock_init();
327 shmobile_timer.init();
328 return;
329}
330
331struct sys_timer ag5evm_timer = {
332 .init = ag5evm_timer_init,
333};
334
335MACHINE_START(AG5EVM, "ag5evm")
336 .map_io = ag5evm_map_io,
337 .init_irq = ag5evm_init_irq,
Magnus Damme74a9622010-12-28 08:27:10 +0000338 .handle_irq = shmobile_handle_irq_gic,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000339 .init_machine = ag5evm_init,
340 .timer = &ag5evm_timer,
341MACHINE_END