blob: 8aea3a2dd889ef73bb0be3a961497bd3ad8bbc7e [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 YOSHII6bf45a12010-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>
Laurent Pincharte9db93a2012-03-01 14:57:11 +010041#include <linux/videodev2.h>
Magnus Damm170c7ab2011-01-20 08:41:03 +000042#include <video/sh_mobile_lcdc.h>
43#include <video/sh_mipi_dsi.h>
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +000044#include <sound/sh_fsi.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000045#include <mach/hardware.h>
46#include <mach/sh73a0.h>
47#include <mach/common.h>
48#include <asm/mach-types.h>
49#include <asm/mach/arch.h>
50#include <asm/mach/map.h>
51#include <asm/mach/time.h>
52#include <asm/hardware/gic.h>
53#include <asm/hardware/cache-l2x0.h>
54#include <asm/traps.h>
55
56static struct resource smsc9220_resources[] = {
57 [0] = {
58 .start = 0x14000000,
59 .end = 0x14000000 + SZ_64K - 1,
60 .flags = IORESOURCE_MEM,
61 },
62 [1] = {
Magnus Damm566aad32011-10-17 18:00:52 +090063 .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */
Magnus Damm6d9598e2010-11-17 10:59:31 +000064 .flags = IORESOURCE_IRQ,
65 },
66};
67
68static struct smsc911x_platform_config smsc9220_platdata = {
69 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
70 .phy_interface = PHY_INTERFACE_MODE_MII,
71 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
72 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
73};
74
75static struct platform_device eth_device = {
76 .name = "smsc911x",
77 .id = 0,
78 .dev = {
79 .platform_data = &smsc9220_platdata,
80 },
81 .resource = smsc9220_resources,
82 .num_resources = ARRAY_SIZE(smsc9220_resources),
83};
84
Yoshii Takashi2d22d482010-11-19 13:15:46 +000085static struct sh_keysc_info keysc_platdata = {
86 .mode = SH_KEYSC_MODE_6,
87 .scan_timing = 3,
88 .delay = 100,
89 .keycodes = {
90 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
91 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
92 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
93 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
94 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
95 KEY_COFFEE,
96 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
97 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
98 KEY_COMPUTER,
99 },
100};
101
102static struct resource keysc_resources[] = {
103 [0] = {
104 .name = "KEYSC",
105 .start = 0xe61b0000,
106 .end = 0xe61b0098 - 1,
107 .flags = IORESOURCE_MEM,
108 },
109 [1] = {
110 .start = gic_spi(71),
111 .flags = IORESOURCE_IRQ,
112 },
113};
114
115static struct platform_device keysc_device = {
116 .name = "sh_keysc",
117 .id = 0,
118 .num_resources = ARRAY_SIZE(keysc_resources),
119 .resource = keysc_resources,
120 .dev = {
121 .platform_data = &keysc_platdata,
122 },
123};
124
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000125/* FSI A */
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000126static struct resource fsi_resources[] = {
127 [0] = {
128 .name = "FSI",
129 .start = 0xEC230000,
130 .end = 0xEC230400 - 1,
131 .flags = IORESOURCE_MEM,
132 },
133 [1] = {
134 .start = gic_spi(146),
135 .flags = IORESOURCE_IRQ,
136 },
137};
138
139static struct platform_device fsi_device = {
140 .name = "sh_fsi2",
141 .id = -1,
142 .num_resources = ARRAY_SIZE(fsi_resources),
143 .resource = fsi_resources,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000144};
145
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000146static struct resource sh_mmcif_resources[] = {
147 [0] = {
148 .name = "MMCIF",
149 .start = 0xe6bd0000,
150 .end = 0xe6bd00ff,
151 .flags = IORESOURCE_MEM,
152 },
153 [1] = {
154 .start = gic_spi(141),
155 .flags = IORESOURCE_IRQ,
156 },
157 [2] = {
158 .start = gic_spi(140),
159 .flags = IORESOURCE_IRQ,
160 },
161};
162
163static struct sh_mmcif_plat_data sh_mmcif_platdata = {
164 .sup_pclk = 0,
165 .ocr = MMC_VDD_165_195,
166 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +0200167 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
168 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000169};
170
171static struct platform_device mmc_device = {
172 .name = "sh_mmcif",
173 .id = 0,
174 .dev = {
175 .dma_mask = NULL,
176 .coherent_dma_mask = 0xffffffff,
177 .platform_data = &sh_mmcif_platdata,
178 },
179 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
180 .resource = sh_mmcif_resources,
181};
182
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000183/* IrDA */
184static struct resource irda_resources[] = {
185 [0] = {
186 .start = 0xE6D00000,
187 .end = 0xE6D01FD4 - 1,
188 .flags = IORESOURCE_MEM,
189 },
190 [1] = {
191 .start = gic_spi(95),
192 .flags = IORESOURCE_IRQ,
193 },
194};
195
196static struct platform_device irda_device = {
197 .name = "sh_irda",
198 .id = 0,
199 .resource = irda_resources,
200 .num_resources = ARRAY_SIZE(irda_resources),
201};
202
Magnus Damm170c7ab2011-01-20 08:41:03 +0000203static unsigned char lcd_backlight_seq[3][2] = {
204 { 0x04, 0x07 },
205 { 0x23, 0x80 },
206 { 0x03, 0x01 },
207};
208
209static void lcd_backlight_on(void)
210{
211 struct i2c_adapter *a;
212 struct i2c_msg msg;
213 int k;
214
215 a = i2c_get_adapter(1);
216 for (k = 0; a && k < 3; k++) {
217 msg.addr = 0x6d;
218 msg.buf = &lcd_backlight_seq[k][0];
219 msg.len = 2;
220 msg.flags = 0;
221 if (i2c_transfer(a, &msg, 1) != 1)
222 break;
223 }
224}
225
226static void lcd_backlight_reset(void)
227{
228 gpio_set_value(GPIO_PORT235, 0);
229 mdelay(24);
230 gpio_set_value(GPIO_PORT235, 1);
231}
232
233static void lcd_on(void *board_data, struct fb_info *info)
234{
235 lcd_backlight_on();
236}
237
238static void lcd_off(void *board_data)
239{
240 lcd_backlight_reset();
241}
242
243/* LCDC0 */
244static const struct fb_videomode lcdc0_modes[] = {
245 {
246 .name = "R63302(QHD)",
247 .xres = 544,
248 .yres = 961,
249 .left_margin = 72,
250 .right_margin = 600,
251 .hsync_len = 16,
252 .upper_margin = 8,
253 .lower_margin = 8,
254 .vsync_len = 2,
255 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
256 },
257};
258
259static struct sh_mobile_lcdc_info lcdc0_info = {
260 .clock_source = LCDC_CLK_PERIPHERAL,
261 .ch[0] = {
262 .chan = LCDC_CHAN_MAINLCD,
263 .interface_type = RGB24,
264 .clock_divider = 1,
265 .flags = LCDC_FLAGS_DWPOL,
266 .lcd_size_cfg.width = 44,
267 .lcd_size_cfg.height = 79,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100268 .fourcc = V4L2_PIX_FMT_RGB565,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000269 .lcd_cfg = lcdc0_modes,
270 .num_cfg = ARRAY_SIZE(lcdc0_modes),
271 .board_cfg = {
272 .display_on = lcd_on,
273 .display_off = lcd_off,
274 },
275 }
276};
277
278static struct resource lcdc0_resources[] = {
279 [0] = {
280 .name = "LCDC0",
281 .start = 0xfe940000, /* P4-only space */
282 .end = 0xfe943fff,
283 .flags = IORESOURCE_MEM,
284 },
285 [1] = {
286 .start = intcs_evt2irq(0x580),
287 .flags = IORESOURCE_IRQ,
288 },
289};
290
291static struct platform_device lcdc0_device = {
292 .name = "sh_mobile_lcdc_fb",
293 .num_resources = ARRAY_SIZE(lcdc0_resources),
294 .resource = lcdc0_resources,
295 .id = 0,
296 .dev = {
297 .platform_data = &lcdc0_info,
298 .coherent_dma_mask = ~0,
299 },
300};
301
302/* MIPI-DSI */
303static struct resource mipidsi0_resources[] = {
304 [0] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000305 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000306 .start = 0xfeab0000,
307 .end = 0xfeab3fff,
308 .flags = IORESOURCE_MEM,
309 },
310 [1] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000311 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000312 .start = 0xfeab4000,
313 .end = 0xfeab7fff,
314 .flags = IORESOURCE_MEM,
315 },
316};
317
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800318static int sh_mipi_set_dot_clock(struct platform_device *pdev,
319 void __iomem *base,
320 int enable)
321{
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800322 struct clk *pck, *phy;
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800323 int ret;
324
325 pck = clk_get(&pdev->dev, "dsip_clk");
326 if (IS_ERR(pck)) {
327 ret = PTR_ERR(pck);
328 goto sh_mipi_set_dot_clock_pck_err;
329 }
330
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800331 phy = clk_get(&pdev->dev, "dsiphy_clk");
332 if (IS_ERR(phy)) {
333 ret = PTR_ERR(phy);
334 goto sh_mipi_set_dot_clock_phy_err;
335 }
336
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800337 if (enable) {
338 clk_set_rate(pck, clk_round_rate(pck, 24000000));
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800339 clk_set_rate(phy, clk_round_rate(pck, 510000000));
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800340 clk_enable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800341 clk_enable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800342 } else {
343 clk_disable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800344 clk_disable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800345 }
346
347 ret = 0;
348
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800349 clk_put(phy);
350sh_mipi_set_dot_clock_phy_err:
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800351 clk_put(pck);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800352sh_mipi_set_dot_clock_pck_err:
353 return ret;
354}
355
Magnus Damm170c7ab2011-01-20 08:41:03 +0000356static struct sh_mipi_dsi_info mipidsi0_info = {
357 .data_format = MIPI_RGB888,
358 .lcd_chan = &lcdc0_info.ch[0],
Kuninori Morimoto26c3d7a2011-11-08 20:34:43 -0800359 .lane = 2,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000360 .vsynw_offset = 20,
361 .clksrc = 1,
Kuninori Morimotoa2e62972011-11-08 20:35:27 -0800362 .flags = SH_MIPI_DSI_HSABM |
363 SH_MIPI_DSI_SYNC_PULSES_MODE |
364 SH_MIPI_DSI_HSbyteCLK,
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800365 .set_dot_clock = sh_mipi_set_dot_clock,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000366};
367
368static struct platform_device mipidsi0_device = {
369 .name = "sh-mipi-dsi",
370 .num_resources = ARRAY_SIZE(mipidsi0_resources),
371 .resource = mipidsi0_resources,
372 .id = 0,
373 .dev = {
374 .platform_data = &mipidsi0_info,
375 },
376};
377
Magnus Damm3087b902011-10-12 16:21:50 +0900378/* SDHI0 */
379static irqreturn_t ag5evm_sdhi0_gpio_cd(int irq, void *arg)
380{
381 struct device *dev = arg;
382 struct sh_mobile_sdhi_info *info = dev->platform_data;
383 struct tmio_mmc_data *pdata = info->pdata;
384
385 tmio_mmc_cd_wakeup(pdata);
386
387 return IRQ_HANDLED;
388}
389
Magnus Dammfb66c522011-05-23 05:10:36 +0000390static struct sh_mobile_sdhi_info sdhi0_info = {
Magnus Damm6820e692011-05-24 10:42:15 +0000391 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
392 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000393 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000394 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
395 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
396};
397
398static struct resource sdhi0_resources[] = {
399 [0] = {
400 .name = "SDHI0",
401 .start = 0xee100000,
402 .end = 0xee1000ff,
403 .flags = IORESOURCE_MEM,
404 },
405 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900406 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000407 .start = gic_spi(83),
408 .flags = IORESOURCE_IRQ,
409 },
410 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900411 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000412 .start = gic_spi(84),
413 .flags = IORESOURCE_IRQ,
414 },
415 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900416 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000417 .start = gic_spi(85),
418 .flags = IORESOURCE_IRQ,
419 },
420};
421
422static struct platform_device sdhi0_device = {
423 .name = "sh_mobile_sdhi",
424 .id = 0,
425 .num_resources = ARRAY_SIZE(sdhi0_resources),
426 .resource = sdhi0_resources,
427 .dev = {
428 .platform_data = &sdhi0_info,
429 },
430};
431
432void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
433{
434 gpio_set_value(GPIO_PORT114, state);
435}
436
Simon Horman9e05cdd2011-06-20 23:00:11 +0000437static struct sh_mobile_sdhi_info sh_sdhi1_info = {
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000438 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
Magnus Damm52942062011-06-09 09:02:25 +0000439 .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
Magnus Dammfb66c522011-05-23 05:10:36 +0000440 .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
441 .set_pwr = ag5evm_sdhi1_set_pwr,
442};
443
444static struct resource sdhi1_resources[] = {
445 [0] = {
446 .name = "SDHI1",
447 .start = 0xee120000,
448 .end = 0xee1200ff,
449 .flags = IORESOURCE_MEM,
450 },
451 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900452 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000453 .start = gic_spi(87),
454 .flags = IORESOURCE_IRQ,
455 },
456 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900457 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000458 .start = gic_spi(88),
459 .flags = IORESOURCE_IRQ,
460 },
461 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900462 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000463 .start = gic_spi(89),
464 .flags = IORESOURCE_IRQ,
465 },
466};
467
468static struct platform_device sdhi1_device = {
469 .name = "sh_mobile_sdhi",
470 .id = 1,
471 .dev = {
Simon Horman9e05cdd2011-06-20 23:00:11 +0000472 .platform_data = &sh_sdhi1_info,
Magnus Dammfb66c522011-05-23 05:10:36 +0000473 },
474 .num_resources = ARRAY_SIZE(sdhi1_resources),
475 .resource = sdhi1_resources,
476};
477
Magnus Damm6d9598e2010-11-17 10:59:31 +0000478static struct platform_device *ag5evm_devices[] __initdata = {
479 &eth_device,
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000480 &keysc_device,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000481 &fsi_device,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000482 &mmc_device,
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000483 &irda_device,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000484 &lcdc0_device,
485 &mipidsi0_device,
Magnus Dammfb66c522011-05-23 05:10:36 +0000486 &sdhi0_device,
487 &sdhi1_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000488};
489
490static struct map_desc ag5evm_io_desc[] __initdata = {
491 /* create a 1:1 entity map for 0xe6xxxxxx
492 * used by CPGA, INTC and PFC.
493 */
494 {
495 .virtual = 0xe6000000,
496 .pfn = __phys_to_pfn(0xe6000000),
497 .length = 256 << 20,
498 .type = MT_DEVICE_NONSHARED
499 },
500};
501
502static void __init ag5evm_map_io(void)
503{
504 iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
505
506 /* setup early devices and console here as well */
507 sh73a0_add_early_devices();
508 shmobile_setup_console();
509}
510
Magnus Damm6d9598e2010-11-17 10:59:31 +0000511static void __init ag5evm_init(void)
512{
Takashi YOSHII3256c782010-11-19 16:49:38 +0900513 sh73a0_pinmux_init();
514
Magnus Damm6d9598e2010-11-17 10:59:31 +0000515 /* enable SCIFA2 */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900516 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
517 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
518 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
519 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000520
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000521 /* enable KEYSC */
Takashi YOSHII5d781472010-12-22 06:30:19 +0000522 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
523 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
524 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
525 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
526 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
527 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
528 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
529 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000530 gpio_request(GPIO_FN_KEYOUT0, NULL);
531 gpio_request(GPIO_FN_KEYOUT1, NULL);
532 gpio_request(GPIO_FN_KEYOUT2, NULL);
533 gpio_request(GPIO_FN_KEYOUT3, NULL);
534 gpio_request(GPIO_FN_KEYOUT4, NULL);
535 gpio_request(GPIO_FN_KEYOUT5, NULL);
536 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
537 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
538 gpio_request(GPIO_FN_KEYOUT8, NULL);
539 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
540
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000541 /* enable I2C channel 2 and 3 */
Yoshii Takashi8e67b222010-11-19 13:21:32 +0000542 gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
543 gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
544 gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
545 gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
546
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000547 /* enable MMCIF */
548 gpio_request(GPIO_FN_MMCCLK0, NULL);
549 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
Kuninori Morimoto052008e2011-11-10 18:44:24 -0800550 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
551 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
552 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
553 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
554 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
555 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
556 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
557 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000558 gpio_request(GPIO_PORT208, NULL); /* Reset */
559 gpio_direction_output(GPIO_PORT208, 1);
560
Magnus Damm6d9598e2010-11-17 10:59:31 +0000561 /* enable SMSC911X */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900562 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
563 gpio_direction_input(GPIO_PORT144);
564 gpio_request(GPIO_PORT145, NULL); /* RESET */
565 gpio_direction_output(GPIO_PORT145, 1);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000566
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000567 /* FSI A */
568 gpio_request(GPIO_FN_FSIACK, NULL);
569 gpio_request(GPIO_FN_FSIAILR, NULL);
570 gpio_request(GPIO_FN_FSIAIBT, NULL);
571 gpio_request(GPIO_FN_FSIAISLD, NULL);
572 gpio_request(GPIO_FN_FSIAOSLD, NULL);
573
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000574 /* IrDA */
575 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
576 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
577 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
578
Magnus Damm170c7ab2011-01-20 08:41:03 +0000579 /* LCD panel */
580 gpio_request(GPIO_PORT217, NULL); /* RESET */
581 gpio_direction_output(GPIO_PORT217, 0);
582 mdelay(1);
583 gpio_set_value(GPIO_PORT217, 1);
Magnus Dammf55398a2011-01-28 09:59:17 +0000584 mdelay(100);
Magnus Damm170c7ab2011-01-20 08:41:03 +0000585
586 /* LCD backlight controller */
587 gpio_request(GPIO_PORT235, NULL); /* RESET */
588 gpio_direction_output(GPIO_PORT235, 0);
589 lcd_backlight_reset();
590
Magnus Dammfb66c522011-05-23 05:10:36 +0000591 /* enable SDHI0 on CN15 [SD I/F] */
592 gpio_request(GPIO_FN_SDHICD0, NULL);
593 gpio_request(GPIO_FN_SDHIWP0, NULL);
594 gpio_request(GPIO_FN_SDHICMD0, NULL);
595 gpio_request(GPIO_FN_SDHICLK0, NULL);
596 gpio_request(GPIO_FN_SDHID0_3, NULL);
597 gpio_request(GPIO_FN_SDHID0_2, NULL);
598 gpio_request(GPIO_FN_SDHID0_1, NULL);
599 gpio_request(GPIO_FN_SDHID0_0, NULL);
600
Magnus Damm3087b902011-10-12 16:21:50 +0900601 if (!request_irq(intcs_evt2irq(0x3c0), ag5evm_sdhi0_gpio_cd,
602 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
603 "sdhi0 cd", &sdhi0_device.dev))
604 sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD;
605 else
606 pr_warn("Unable to setup SDHI0 GPIO IRQ\n");
607
Magnus Dammfb66c522011-05-23 05:10:36 +0000608 /* enable SDHI1 on CN4 [WLAN I/F] */
609 gpio_request(GPIO_FN_SDHICLK1, NULL);
610 gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
611 gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
612 gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
613 gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
614 gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
615 gpio_request(GPIO_PORT114, "sdhi1_power");
616 gpio_direction_output(GPIO_PORT114, 0);
617
Magnus Damm6d9598e2010-11-17 10:59:31 +0000618#ifdef CONFIG_CACHE_L2X0
619 /* Shared attribute override enable, 64K*8way */
620 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
621#endif
622 sh73a0_add_standard_devices();
623 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
624}
625
626static void __init ag5evm_timer_init(void)
627{
628 sh73a0_clock_init();
629 shmobile_timer.init();
630 return;
631}
632
633struct sys_timer ag5evm_timer = {
634 .init = ag5evm_timer_init,
635};
636
637MACHINE_START(AG5EVM, "ag5evm")
638 .map_io = ag5evm_map_io,
Magnus Dammeded9142011-11-22 15:31:40 +0900639 .nr_irqs = NR_IRQS_LEGACY,
Magnus Damm566aad32011-10-17 18:00:52 +0900640 .init_irq = sh73a0_init_irq,
Marc Zyngiera83d8e22011-09-06 10:23:45 +0100641 .handle_irq = gic_handle_irq,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000642 .init_machine = ag5evm_init,
643 .timer = &ag5evm_timer,
644MACHINE_END