blob: 068b754bc348ff20f1c091264cb80e3a09edf134 [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>
Paul Gortmaker04f47a02012-01-22 14:57:25 -050033#include <linux/videodev2.h>
Yoshii Takashi2d22d482010-11-19 13:15:46 +000034#include <linux/input.h>
35#include <linux/input/sh_keysc.h>
Takashi YOSHII6bf45a102010-12-22 06:35:30 +000036#include <linux/mmc/host.h>
37#include <linux/mmc/sh_mmcif.h>
Magnus Dammfb66c522011-05-23 05:10:36 +000038#include <linux/mmc/sh_mobile_sdhi.h>
39#include <linux/mfd/tmio.h>
Magnus Damm170c7ab2011-01-20 08:41:03 +000040#include <linux/sh_clk.h>
41#include <video/sh_mobile_lcdc.h>
42#include <video/sh_mipi_dsi.h>
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +000043#include <sound/sh_fsi.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000044#include <mach/hardware.h>
45#include <mach/sh73a0.h>
46#include <mach/common.h>
47#include <asm/mach-types.h>
48#include <asm/mach/arch.h>
49#include <asm/mach/map.h>
50#include <asm/mach/time.h>
51#include <asm/hardware/gic.h>
52#include <asm/hardware/cache-l2x0.h>
53#include <asm/traps.h>
54
55static struct resource smsc9220_resources[] = {
56 [0] = {
57 .start = 0x14000000,
58 .end = 0x14000000 + SZ_64K - 1,
59 .flags = IORESOURCE_MEM,
60 },
61 [1] = {
Magnus Damm566aad32011-10-17 18:00:52 +090062 .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */
Magnus Damm6d9598e2010-11-17 10:59:31 +000063 .flags = IORESOURCE_IRQ,
64 },
65};
66
67static struct smsc911x_platform_config smsc9220_platdata = {
68 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
69 .phy_interface = PHY_INTERFACE_MODE_MII,
70 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
71 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
72};
73
74static struct platform_device eth_device = {
75 .name = "smsc911x",
76 .id = 0,
77 .dev = {
78 .platform_data = &smsc9220_platdata,
79 },
80 .resource = smsc9220_resources,
81 .num_resources = ARRAY_SIZE(smsc9220_resources),
82};
83
Yoshii Takashi2d22d482010-11-19 13:15:46 +000084static struct sh_keysc_info keysc_platdata = {
85 .mode = SH_KEYSC_MODE_6,
86 .scan_timing = 3,
87 .delay = 100,
88 .keycodes = {
89 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
90 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
91 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
92 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
93 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
94 KEY_COFFEE,
95 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
96 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
97 KEY_COMPUTER,
98 },
99};
100
101static struct resource keysc_resources[] = {
102 [0] = {
103 .name = "KEYSC",
104 .start = 0xe61b0000,
105 .end = 0xe61b0098 - 1,
106 .flags = IORESOURCE_MEM,
107 },
108 [1] = {
109 .start = gic_spi(71),
110 .flags = IORESOURCE_IRQ,
111 },
112};
113
114static struct platform_device keysc_device = {
115 .name = "sh_keysc",
116 .id = 0,
117 .num_resources = ARRAY_SIZE(keysc_resources),
118 .resource = keysc_resources,
119 .dev = {
120 .platform_data = &keysc_platdata,
121 },
122};
123
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000124/* FSI A */
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000125static struct resource fsi_resources[] = {
126 [0] = {
127 .name = "FSI",
128 .start = 0xEC230000,
129 .end = 0xEC230400 - 1,
130 .flags = IORESOURCE_MEM,
131 },
132 [1] = {
133 .start = gic_spi(146),
134 .flags = IORESOURCE_IRQ,
135 },
136};
137
138static struct platform_device fsi_device = {
139 .name = "sh_fsi2",
140 .id = -1,
141 .num_resources = ARRAY_SIZE(fsi_resources),
142 .resource = fsi_resources,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000143};
144
Takashi YOSHII6bf45a102010-12-22 06:35:30 +0000145static struct resource sh_mmcif_resources[] = {
146 [0] = {
147 .name = "MMCIF",
148 .start = 0xe6bd0000,
149 .end = 0xe6bd00ff,
150 .flags = IORESOURCE_MEM,
151 },
152 [1] = {
153 .start = gic_spi(141),
154 .flags = IORESOURCE_IRQ,
155 },
156 [2] = {
157 .start = gic_spi(140),
158 .flags = IORESOURCE_IRQ,
159 },
160};
161
162static struct sh_mmcif_plat_data sh_mmcif_platdata = {
163 .sup_pclk = 0,
164 .ocr = MMC_VDD_165_195,
165 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +0200166 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
167 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Takashi YOSHII6bf45a102010-12-22 06:35:30 +0000168};
169
170static struct platform_device mmc_device = {
171 .name = "sh_mmcif",
172 .id = 0,
173 .dev = {
174 .dma_mask = NULL,
175 .coherent_dma_mask = 0xffffffff,
176 .platform_data = &sh_mmcif_platdata,
177 },
178 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
179 .resource = sh_mmcif_resources,
180};
181
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000182/* IrDA */
183static struct resource irda_resources[] = {
184 [0] = {
185 .start = 0xE6D00000,
186 .end = 0xE6D01FD4 - 1,
187 .flags = IORESOURCE_MEM,
188 },
189 [1] = {
190 .start = gic_spi(95),
191 .flags = IORESOURCE_IRQ,
192 },
193};
194
195static struct platform_device irda_device = {
196 .name = "sh_irda",
197 .id = 0,
198 .resource = irda_resources,
199 .num_resources = ARRAY_SIZE(irda_resources),
200};
201
Magnus Damm170c7ab2011-01-20 08:41:03 +0000202static unsigned char lcd_backlight_seq[3][2] = {
203 { 0x04, 0x07 },
204 { 0x23, 0x80 },
205 { 0x03, 0x01 },
206};
207
208static void lcd_backlight_on(void)
209{
210 struct i2c_adapter *a;
211 struct i2c_msg msg;
212 int k;
213
214 a = i2c_get_adapter(1);
215 for (k = 0; a && k < 3; k++) {
216 msg.addr = 0x6d;
217 msg.buf = &lcd_backlight_seq[k][0];
218 msg.len = 2;
219 msg.flags = 0;
220 if (i2c_transfer(a, &msg, 1) != 1)
221 break;
222 }
223}
224
225static void lcd_backlight_reset(void)
226{
227 gpio_set_value(GPIO_PORT235, 0);
228 mdelay(24);
229 gpio_set_value(GPIO_PORT235, 1);
230}
231
232static void lcd_on(void *board_data, struct fb_info *info)
233{
234 lcd_backlight_on();
235}
236
237static void lcd_off(void *board_data)
238{
239 lcd_backlight_reset();
240}
241
242/* LCDC0 */
243static const struct fb_videomode lcdc0_modes[] = {
244 {
245 .name = "R63302(QHD)",
246 .xres = 544,
247 .yres = 961,
248 .left_margin = 72,
249 .right_margin = 600,
250 .hsync_len = 16,
251 .upper_margin = 8,
252 .lower_margin = 8,
253 .vsync_len = 2,
254 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
255 },
256};
257
258static struct sh_mobile_lcdc_info lcdc0_info = {
259 .clock_source = LCDC_CLK_PERIPHERAL,
260 .ch[0] = {
261 .chan = LCDC_CHAN_MAINLCD,
262 .interface_type = RGB24,
263 .clock_divider = 1,
264 .flags = LCDC_FLAGS_DWPOL,
265 .lcd_size_cfg.width = 44,
266 .lcd_size_cfg.height = 79,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100267 .fourcc = V4L2_PIX_FMT_RGB565,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000268 .lcd_cfg = lcdc0_modes,
269 .num_cfg = ARRAY_SIZE(lcdc0_modes),
270 .board_cfg = {
271 .display_on = lcd_on,
272 .display_off = lcd_off,
273 },
274 }
275};
276
277static struct resource lcdc0_resources[] = {
278 [0] = {
279 .name = "LCDC0",
280 .start = 0xfe940000, /* P4-only space */
281 .end = 0xfe943fff,
282 .flags = IORESOURCE_MEM,
283 },
284 [1] = {
285 .start = intcs_evt2irq(0x580),
286 .flags = IORESOURCE_IRQ,
287 },
288};
289
290static struct platform_device lcdc0_device = {
291 .name = "sh_mobile_lcdc_fb",
292 .num_resources = ARRAY_SIZE(lcdc0_resources),
293 .resource = lcdc0_resources,
294 .id = 0,
295 .dev = {
296 .platform_data = &lcdc0_info,
297 .coherent_dma_mask = ~0,
298 },
299};
300
301/* MIPI-DSI */
302static struct resource mipidsi0_resources[] = {
303 [0] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000304 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000305 .start = 0xfeab0000,
306 .end = 0xfeab3fff,
307 .flags = IORESOURCE_MEM,
308 },
309 [1] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000310 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000311 .start = 0xfeab4000,
312 .end = 0xfeab7fff,
313 .flags = IORESOURCE_MEM,
314 },
315};
316
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800317static int sh_mipi_set_dot_clock(struct platform_device *pdev,
318 void __iomem *base,
319 int enable)
320{
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800321 struct clk *pck, *phy;
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800322 int ret;
323
324 pck = clk_get(&pdev->dev, "dsip_clk");
325 if (IS_ERR(pck)) {
326 ret = PTR_ERR(pck);
327 goto sh_mipi_set_dot_clock_pck_err;
328 }
329
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800330 phy = clk_get(&pdev->dev, "dsiphy_clk");
331 if (IS_ERR(phy)) {
332 ret = PTR_ERR(phy);
333 goto sh_mipi_set_dot_clock_phy_err;
334 }
335
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800336 if (enable) {
337 clk_set_rate(pck, clk_round_rate(pck, 24000000));
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800338 clk_set_rate(phy, clk_round_rate(pck, 510000000));
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800339 clk_enable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800340 clk_enable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800341 } else {
342 clk_disable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800343 clk_disable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800344 }
345
346 ret = 0;
347
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800348 clk_put(phy);
349sh_mipi_set_dot_clock_phy_err:
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800350 clk_put(pck);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800351sh_mipi_set_dot_clock_pck_err:
352 return ret;
353}
354
Magnus Damm170c7ab2011-01-20 08:41:03 +0000355static struct sh_mipi_dsi_info mipidsi0_info = {
356 .data_format = MIPI_RGB888,
357 .lcd_chan = &lcdc0_info.ch[0],
Kuninori Morimoto26c3d7a2011-11-08 20:34:43 -0800358 .lane = 2,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000359 .vsynw_offset = 20,
360 .clksrc = 1,
Kuninori Morimotoa2e62972011-11-08 20:35:27 -0800361 .flags = SH_MIPI_DSI_HSABM |
362 SH_MIPI_DSI_SYNC_PULSES_MODE |
363 SH_MIPI_DSI_HSbyteCLK,
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800364 .set_dot_clock = sh_mipi_set_dot_clock,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000365};
366
367static struct platform_device mipidsi0_device = {
368 .name = "sh-mipi-dsi",
369 .num_resources = ARRAY_SIZE(mipidsi0_resources),
370 .resource = mipidsi0_resources,
371 .id = 0,
372 .dev = {
373 .platform_data = &mipidsi0_info,
374 },
375};
376
Magnus Damm3087b902011-10-12 16:21:50 +0900377/* SDHI0 */
378static irqreturn_t ag5evm_sdhi0_gpio_cd(int irq, void *arg)
379{
380 struct device *dev = arg;
381 struct sh_mobile_sdhi_info *info = dev->platform_data;
382 struct tmio_mmc_data *pdata = info->pdata;
383
384 tmio_mmc_cd_wakeup(pdata);
385
386 return IRQ_HANDLED;
387}
388
Magnus Dammfb66c522011-05-23 05:10:36 +0000389static struct sh_mobile_sdhi_info sdhi0_info = {
Magnus Damm6820e692011-05-24 10:42:15 +0000390 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
391 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000392 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000393 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
394 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
395};
396
397static struct resource sdhi0_resources[] = {
398 [0] = {
399 .name = "SDHI0",
400 .start = 0xee100000,
401 .end = 0xee1000ff,
402 .flags = IORESOURCE_MEM,
403 },
404 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900405 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000406 .start = gic_spi(83),
407 .flags = IORESOURCE_IRQ,
408 },
409 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900410 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000411 .start = gic_spi(84),
412 .flags = IORESOURCE_IRQ,
413 },
414 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900415 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000416 .start = gic_spi(85),
417 .flags = IORESOURCE_IRQ,
418 },
419};
420
421static struct platform_device sdhi0_device = {
422 .name = "sh_mobile_sdhi",
423 .id = 0,
424 .num_resources = ARRAY_SIZE(sdhi0_resources),
425 .resource = sdhi0_resources,
426 .dev = {
427 .platform_data = &sdhi0_info,
428 },
429};
430
431void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
432{
433 gpio_set_value(GPIO_PORT114, state);
434}
435
Simon Horman9e05cdd2011-06-20 23:00:11 +0000436static struct sh_mobile_sdhi_info sh_sdhi1_info = {
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000437 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
Magnus Damm52942062011-06-09 09:02:25 +0000438 .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
Magnus Dammfb66c522011-05-23 05:10:36 +0000439 .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
440 .set_pwr = ag5evm_sdhi1_set_pwr,
441};
442
443static struct resource sdhi1_resources[] = {
444 [0] = {
445 .name = "SDHI1",
446 .start = 0xee120000,
447 .end = 0xee1200ff,
448 .flags = IORESOURCE_MEM,
449 },
450 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900451 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000452 .start = gic_spi(87),
453 .flags = IORESOURCE_IRQ,
454 },
455 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900456 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000457 .start = gic_spi(88),
458 .flags = IORESOURCE_IRQ,
459 },
460 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900461 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000462 .start = gic_spi(89),
463 .flags = IORESOURCE_IRQ,
464 },
465};
466
467static struct platform_device sdhi1_device = {
468 .name = "sh_mobile_sdhi",
469 .id = 1,
470 .dev = {
Simon Horman9e05cdd2011-06-20 23:00:11 +0000471 .platform_data = &sh_sdhi1_info,
Magnus Dammfb66c522011-05-23 05:10:36 +0000472 },
473 .num_resources = ARRAY_SIZE(sdhi1_resources),
474 .resource = sdhi1_resources,
475};
476
Magnus Damm6d9598e2010-11-17 10:59:31 +0000477static struct platform_device *ag5evm_devices[] __initdata = {
478 &eth_device,
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000479 &keysc_device,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000480 &fsi_device,
Takashi YOSHII6bf45a102010-12-22 06:35:30 +0000481 &mmc_device,
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000482 &irda_device,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000483 &lcdc0_device,
484 &mipidsi0_device,
Magnus Dammfb66c522011-05-23 05:10:36 +0000485 &sdhi0_device,
486 &sdhi1_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000487};
488
489static struct map_desc ag5evm_io_desc[] __initdata = {
490 /* create a 1:1 entity map for 0xe6xxxxxx
491 * used by CPGA, INTC and PFC.
492 */
493 {
494 .virtual = 0xe6000000,
495 .pfn = __phys_to_pfn(0xe6000000),
496 .length = 256 << 20,
497 .type = MT_DEVICE_NONSHARED
498 },
499};
500
501static void __init ag5evm_map_io(void)
502{
503 iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
504
505 /* setup early devices and console here as well */
506 sh73a0_add_early_devices();
507 shmobile_setup_console();
508}
509
Magnus Damm6d9598e2010-11-17 10:59:31 +0000510static void __init ag5evm_init(void)
511{
Takashi YOSHII3256c7892010-11-19 16:49:38 +0900512 sh73a0_pinmux_init();
513
Magnus Damm6d9598e2010-11-17 10:59:31 +0000514 /* enable SCIFA2 */
Takashi YOSHII3256c7892010-11-19 16:49:38 +0900515 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
516 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
517 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
518 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000519
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000520 /* enable KEYSC */
Takashi YOSHII5d781472010-12-22 06:30:19 +0000521 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
522 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
523 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
524 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
525 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
526 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
527 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
528 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000529 gpio_request(GPIO_FN_KEYOUT0, NULL);
530 gpio_request(GPIO_FN_KEYOUT1, NULL);
531 gpio_request(GPIO_FN_KEYOUT2, NULL);
532 gpio_request(GPIO_FN_KEYOUT3, NULL);
533 gpio_request(GPIO_FN_KEYOUT4, NULL);
534 gpio_request(GPIO_FN_KEYOUT5, NULL);
535 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
536 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
537 gpio_request(GPIO_FN_KEYOUT8, NULL);
538 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
539
Takashi YOSHII6bf45a102010-12-22 06:35:30 +0000540 /* enable I2C channel 2 and 3 */
Yoshii Takashi8e67b222010-11-19 13:21:32 +0000541 gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
542 gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
543 gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
544 gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
545
Takashi YOSHII6bf45a102010-12-22 06:35:30 +0000546 /* enable MMCIF */
547 gpio_request(GPIO_FN_MMCCLK0, NULL);
548 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
Kuninori Morimoto052008e2011-11-10 18:44:24 -0800549 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
550 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
551 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
552 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
553 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
554 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
555 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
556 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
Takashi YOSHII6bf45a102010-12-22 06:35:30 +0000557 gpio_request(GPIO_PORT208, NULL); /* Reset */
558 gpio_direction_output(GPIO_PORT208, 1);
559
Magnus Damm6d9598e2010-11-17 10:59:31 +0000560 /* enable SMSC911X */
Takashi YOSHII3256c7892010-11-19 16:49:38 +0900561 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
562 gpio_direction_input(GPIO_PORT144);
563 gpio_request(GPIO_PORT145, NULL); /* RESET */
564 gpio_direction_output(GPIO_PORT145, 1);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000565
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000566 /* FSI A */
567 gpio_request(GPIO_FN_FSIACK, NULL);
568 gpio_request(GPIO_FN_FSIAILR, NULL);
569 gpio_request(GPIO_FN_FSIAIBT, NULL);
570 gpio_request(GPIO_FN_FSIAISLD, NULL);
571 gpio_request(GPIO_FN_FSIAOSLD, NULL);
572
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000573 /* IrDA */
574 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
575 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
576 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
577
Magnus Damm170c7ab2011-01-20 08:41:03 +0000578 /* LCD panel */
579 gpio_request(GPIO_PORT217, NULL); /* RESET */
580 gpio_direction_output(GPIO_PORT217, 0);
581 mdelay(1);
582 gpio_set_value(GPIO_PORT217, 1);
Magnus Dammf55398a2011-01-28 09:59:17 +0000583 mdelay(100);
Magnus Damm170c7ab2011-01-20 08:41:03 +0000584
585 /* LCD backlight controller */
586 gpio_request(GPIO_PORT235, NULL); /* RESET */
587 gpio_direction_output(GPIO_PORT235, 0);
588 lcd_backlight_reset();
589
Magnus Dammfb66c522011-05-23 05:10:36 +0000590 /* enable SDHI0 on CN15 [SD I/F] */
591 gpio_request(GPIO_FN_SDHICD0, NULL);
592 gpio_request(GPIO_FN_SDHIWP0, NULL);
593 gpio_request(GPIO_FN_SDHICMD0, NULL);
594 gpio_request(GPIO_FN_SDHICLK0, NULL);
595 gpio_request(GPIO_FN_SDHID0_3, NULL);
596 gpio_request(GPIO_FN_SDHID0_2, NULL);
597 gpio_request(GPIO_FN_SDHID0_1, NULL);
598 gpio_request(GPIO_FN_SDHID0_0, NULL);
599
Magnus Damm3087b902011-10-12 16:21:50 +0900600 if (!request_irq(intcs_evt2irq(0x3c0), ag5evm_sdhi0_gpio_cd,
601 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
602 "sdhi0 cd", &sdhi0_device.dev))
603 sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD;
604 else
605 pr_warn("Unable to setup SDHI0 GPIO IRQ\n");
606
Magnus Dammfb66c522011-05-23 05:10:36 +0000607 /* enable SDHI1 on CN4 [WLAN I/F] */
608 gpio_request(GPIO_FN_SDHICLK1, NULL);
609 gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
610 gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
611 gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
612 gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
613 gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
614 gpio_request(GPIO_PORT114, "sdhi1_power");
615 gpio_direction_output(GPIO_PORT114, 0);
616
Magnus Damm6d9598e2010-11-17 10:59:31 +0000617#ifdef CONFIG_CACHE_L2X0
618 /* Shared attribute override enable, 64K*8way */
619 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
620#endif
621 sh73a0_add_standard_devices();
622 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
623}
624
625static void __init ag5evm_timer_init(void)
626{
627 sh73a0_clock_init();
628 shmobile_timer.init();
629 return;
630}
631
632struct sys_timer ag5evm_timer = {
633 .init = ag5evm_timer_init,
634};
635
636MACHINE_START(AG5EVM, "ag5evm")
637 .map_io = ag5evm_map_io,
Magnus Dammeded9142011-11-22 15:31:40 +0900638 .nr_irqs = NR_IRQS_LEGACY,
Magnus Damm566aad32011-10-17 18:00:52 +0900639 .init_irq = sh73a0_init_irq,
Marc Zyngiera83d8e22011-09-06 10:23:45 +0100640 .handle_irq = gic_handle_irq,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000641 .init_machine = ag5evm_init,
642 .timer = &ag5evm_timer,
643MACHINE_END