blob: 675660d951d093c021bd0e89f94bea879ad039e9 [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>
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>
Magnus Damm6d9598e2010-11-17 10:59:31 +000049#include <asm/hardware/gic.h>
50#include <asm/hardware/cache-l2x0.h>
51#include <asm/traps.h>
52
53static struct resource smsc9220_resources[] = {
54 [0] = {
55 .start = 0x14000000,
56 .end = 0x14000000 + SZ_64K - 1,
57 .flags = IORESOURCE_MEM,
58 },
59 [1] = {
Magnus Damm566aad32011-10-17 18:00:52 +090060 .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */
Magnus Damm6d9598e2010-11-17 10:59:31 +000061 .flags = IORESOURCE_IRQ,
62 },
63};
64
65static struct smsc911x_platform_config smsc9220_platdata = {
66 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
67 .phy_interface = PHY_INTERFACE_MODE_MII,
68 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
69 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
70};
71
72static struct platform_device eth_device = {
73 .name = "smsc911x",
74 .id = 0,
75 .dev = {
76 .platform_data = &smsc9220_platdata,
77 },
78 .resource = smsc9220_resources,
79 .num_resources = ARRAY_SIZE(smsc9220_resources),
80};
81
Yoshii Takashi2d22d482010-11-19 13:15:46 +000082static struct sh_keysc_info keysc_platdata = {
83 .mode = SH_KEYSC_MODE_6,
84 .scan_timing = 3,
85 .delay = 100,
86 .keycodes = {
87 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
88 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
89 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
90 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
91 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
92 KEY_COFFEE,
93 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
94 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
95 KEY_COMPUTER,
96 },
97};
98
99static struct resource keysc_resources[] = {
100 [0] = {
101 .name = "KEYSC",
102 .start = 0xe61b0000,
103 .end = 0xe61b0098 - 1,
104 .flags = IORESOURCE_MEM,
105 },
106 [1] = {
107 .start = gic_spi(71),
108 .flags = IORESOURCE_IRQ,
109 },
110};
111
112static struct platform_device keysc_device = {
113 .name = "sh_keysc",
114 .id = 0,
115 .num_resources = ARRAY_SIZE(keysc_resources),
116 .resource = keysc_resources,
117 .dev = {
118 .platform_data = &keysc_platdata,
119 },
120};
121
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000122/* FSI A */
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000123static struct resource fsi_resources[] = {
124 [0] = {
125 .name = "FSI",
126 .start = 0xEC230000,
127 .end = 0xEC230400 - 1,
128 .flags = IORESOURCE_MEM,
129 },
130 [1] = {
131 .start = gic_spi(146),
132 .flags = IORESOURCE_IRQ,
133 },
134};
135
136static struct platform_device fsi_device = {
137 .name = "sh_fsi2",
138 .id = -1,
139 .num_resources = ARRAY_SIZE(fsi_resources),
140 .resource = fsi_resources,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000141};
142
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000143static struct resource sh_mmcif_resources[] = {
144 [0] = {
145 .name = "MMCIF",
146 .start = 0xe6bd0000,
147 .end = 0xe6bd00ff,
148 .flags = IORESOURCE_MEM,
149 },
150 [1] = {
151 .start = gic_spi(141),
152 .flags = IORESOURCE_IRQ,
153 },
154 [2] = {
155 .start = gic_spi(140),
156 .flags = IORESOURCE_IRQ,
157 },
158};
159
160static struct sh_mmcif_plat_data sh_mmcif_platdata = {
161 .sup_pclk = 0,
162 .ocr = MMC_VDD_165_195,
163 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +0200164 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
165 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000166};
167
168static struct platform_device mmc_device = {
169 .name = "sh_mmcif",
170 .id = 0,
171 .dev = {
172 .dma_mask = NULL,
173 .coherent_dma_mask = 0xffffffff,
174 .platform_data = &sh_mmcif_platdata,
175 },
176 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
177 .resource = sh_mmcif_resources,
178};
179
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000180/* IrDA */
181static struct resource irda_resources[] = {
182 [0] = {
183 .start = 0xE6D00000,
184 .end = 0xE6D01FD4 - 1,
185 .flags = IORESOURCE_MEM,
186 },
187 [1] = {
188 .start = gic_spi(95),
189 .flags = IORESOURCE_IRQ,
190 },
191};
192
193static struct platform_device irda_device = {
194 .name = "sh_irda",
195 .id = 0,
196 .resource = irda_resources,
197 .num_resources = ARRAY_SIZE(irda_resources),
198};
199
Magnus Damm170c7ab2011-01-20 08:41:03 +0000200static unsigned char lcd_backlight_seq[3][2] = {
201 { 0x04, 0x07 },
202 { 0x23, 0x80 },
203 { 0x03, 0x01 },
204};
205
206static void lcd_backlight_on(void)
207{
208 struct i2c_adapter *a;
209 struct i2c_msg msg;
210 int k;
211
212 a = i2c_get_adapter(1);
213 for (k = 0; a && k < 3; k++) {
214 msg.addr = 0x6d;
215 msg.buf = &lcd_backlight_seq[k][0];
216 msg.len = 2;
217 msg.flags = 0;
218 if (i2c_transfer(a, &msg, 1) != 1)
219 break;
220 }
221}
222
223static void lcd_backlight_reset(void)
224{
225 gpio_set_value(GPIO_PORT235, 0);
226 mdelay(24);
227 gpio_set_value(GPIO_PORT235, 1);
228}
229
230static void lcd_on(void *board_data, struct fb_info *info)
231{
232 lcd_backlight_on();
233}
234
235static void lcd_off(void *board_data)
236{
237 lcd_backlight_reset();
238}
239
240/* LCDC0 */
241static const struct fb_videomode lcdc0_modes[] = {
242 {
243 .name = "R63302(QHD)",
244 .xres = 544,
245 .yres = 961,
246 .left_margin = 72,
247 .right_margin = 600,
248 .hsync_len = 16,
249 .upper_margin = 8,
250 .lower_margin = 8,
251 .vsync_len = 2,
252 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
253 },
254};
255
256static struct sh_mobile_lcdc_info lcdc0_info = {
257 .clock_source = LCDC_CLK_PERIPHERAL,
258 .ch[0] = {
259 .chan = LCDC_CHAN_MAINLCD,
260 .interface_type = RGB24,
261 .clock_divider = 1,
262 .flags = LCDC_FLAGS_DWPOL,
263 .lcd_size_cfg.width = 44,
264 .lcd_size_cfg.height = 79,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100265 .fourcc = V4L2_PIX_FMT_RGB565,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000266 .lcd_cfg = lcdc0_modes,
267 .num_cfg = ARRAY_SIZE(lcdc0_modes),
268 .board_cfg = {
269 .display_on = lcd_on,
270 .display_off = lcd_off,
271 },
272 }
273};
274
275static struct resource lcdc0_resources[] = {
276 [0] = {
277 .name = "LCDC0",
278 .start = 0xfe940000, /* P4-only space */
279 .end = 0xfe943fff,
280 .flags = IORESOURCE_MEM,
281 },
282 [1] = {
283 .start = intcs_evt2irq(0x580),
284 .flags = IORESOURCE_IRQ,
285 },
286};
287
288static struct platform_device lcdc0_device = {
289 .name = "sh_mobile_lcdc_fb",
290 .num_resources = ARRAY_SIZE(lcdc0_resources),
291 .resource = lcdc0_resources,
292 .id = 0,
293 .dev = {
294 .platform_data = &lcdc0_info,
295 .coherent_dma_mask = ~0,
296 },
297};
298
299/* MIPI-DSI */
300static struct resource mipidsi0_resources[] = {
301 [0] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000302 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000303 .start = 0xfeab0000,
304 .end = 0xfeab3fff,
305 .flags = IORESOURCE_MEM,
306 },
307 [1] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000308 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000309 .start = 0xfeab4000,
310 .end = 0xfeab7fff,
311 .flags = IORESOURCE_MEM,
312 },
313};
314
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800315static int sh_mipi_set_dot_clock(struct platform_device *pdev,
316 void __iomem *base,
317 int enable)
318{
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800319 struct clk *pck, *phy;
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800320 int ret;
321
322 pck = clk_get(&pdev->dev, "dsip_clk");
323 if (IS_ERR(pck)) {
324 ret = PTR_ERR(pck);
325 goto sh_mipi_set_dot_clock_pck_err;
326 }
327
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800328 phy = clk_get(&pdev->dev, "dsiphy_clk");
329 if (IS_ERR(phy)) {
330 ret = PTR_ERR(phy);
331 goto sh_mipi_set_dot_clock_phy_err;
332 }
333
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800334 if (enable) {
335 clk_set_rate(pck, clk_round_rate(pck, 24000000));
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800336 clk_set_rate(phy, clk_round_rate(pck, 510000000));
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800337 clk_enable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800338 clk_enable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800339 } else {
340 clk_disable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800341 clk_disable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800342 }
343
344 ret = 0;
345
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800346 clk_put(phy);
347sh_mipi_set_dot_clock_phy_err:
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800348 clk_put(pck);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800349sh_mipi_set_dot_clock_pck_err:
350 return ret;
351}
352
Magnus Damm170c7ab2011-01-20 08:41:03 +0000353static struct sh_mipi_dsi_info mipidsi0_info = {
354 .data_format = MIPI_RGB888,
355 .lcd_chan = &lcdc0_info.ch[0],
Kuninori Morimoto26c3d7a2011-11-08 20:34:43 -0800356 .lane = 2,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000357 .vsynw_offset = 20,
358 .clksrc = 1,
Kuninori Morimotoa2e62972011-11-08 20:35:27 -0800359 .flags = SH_MIPI_DSI_HSABM |
360 SH_MIPI_DSI_SYNC_PULSES_MODE |
361 SH_MIPI_DSI_HSbyteCLK,
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800362 .set_dot_clock = sh_mipi_set_dot_clock,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000363};
364
365static struct platform_device mipidsi0_device = {
366 .name = "sh-mipi-dsi",
367 .num_resources = ARRAY_SIZE(mipidsi0_resources),
368 .resource = mipidsi0_resources,
369 .id = 0,
370 .dev = {
371 .platform_data = &mipidsi0_info,
372 },
373};
374
Magnus Damm3087b902011-10-12 16:21:50 +0900375/* SDHI0 */
376static irqreturn_t ag5evm_sdhi0_gpio_cd(int irq, void *arg)
377{
378 struct device *dev = arg;
379 struct sh_mobile_sdhi_info *info = dev->platform_data;
380 struct tmio_mmc_data *pdata = info->pdata;
381
382 tmio_mmc_cd_wakeup(pdata);
383
384 return IRQ_HANDLED;
385}
386
Magnus Dammfb66c522011-05-23 05:10:36 +0000387static struct sh_mobile_sdhi_info sdhi0_info = {
Magnus Damm6820e692011-05-24 10:42:15 +0000388 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
389 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000390 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000391 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
392 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
393};
394
395static struct resource sdhi0_resources[] = {
396 [0] = {
397 .name = "SDHI0",
398 .start = 0xee100000,
399 .end = 0xee1000ff,
400 .flags = IORESOURCE_MEM,
401 },
402 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900403 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000404 .start = gic_spi(83),
405 .flags = IORESOURCE_IRQ,
406 },
407 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900408 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000409 .start = gic_spi(84),
410 .flags = IORESOURCE_IRQ,
411 },
412 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900413 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000414 .start = gic_spi(85),
415 .flags = IORESOURCE_IRQ,
416 },
417};
418
419static struct platform_device sdhi0_device = {
420 .name = "sh_mobile_sdhi",
421 .id = 0,
422 .num_resources = ARRAY_SIZE(sdhi0_resources),
423 .resource = sdhi0_resources,
424 .dev = {
425 .platform_data = &sdhi0_info,
426 },
427};
428
429void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
430{
431 gpio_set_value(GPIO_PORT114, state);
432}
433
Simon Horman9e05cdd2011-06-20 23:00:11 +0000434static struct sh_mobile_sdhi_info sh_sdhi1_info = {
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000435 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
Magnus Damm52942062011-06-09 09:02:25 +0000436 .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
Magnus Dammfb66c522011-05-23 05:10:36 +0000437 .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
438 .set_pwr = ag5evm_sdhi1_set_pwr,
439};
440
441static struct resource sdhi1_resources[] = {
442 [0] = {
443 .name = "SDHI1",
444 .start = 0xee120000,
445 .end = 0xee1200ff,
446 .flags = IORESOURCE_MEM,
447 },
448 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900449 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000450 .start = gic_spi(87),
451 .flags = IORESOURCE_IRQ,
452 },
453 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900454 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000455 .start = gic_spi(88),
456 .flags = IORESOURCE_IRQ,
457 },
458 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900459 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000460 .start = gic_spi(89),
461 .flags = IORESOURCE_IRQ,
462 },
463};
464
465static struct platform_device sdhi1_device = {
466 .name = "sh_mobile_sdhi",
467 .id = 1,
468 .dev = {
Simon Horman9e05cdd2011-06-20 23:00:11 +0000469 .platform_data = &sh_sdhi1_info,
Magnus Dammfb66c522011-05-23 05:10:36 +0000470 },
471 .num_resources = ARRAY_SIZE(sdhi1_resources),
472 .resource = sdhi1_resources,
473};
474
Magnus Damm6d9598e2010-11-17 10:59:31 +0000475static struct platform_device *ag5evm_devices[] __initdata = {
476 &eth_device,
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000477 &keysc_device,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000478 &fsi_device,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000479 &mmc_device,
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000480 &irda_device,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000481 &lcdc0_device,
482 &mipidsi0_device,
Magnus Dammfb66c522011-05-23 05:10:36 +0000483 &sdhi0_device,
484 &sdhi1_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000485};
486
Magnus Damm6d9598e2010-11-17 10:59:31 +0000487static void __init ag5evm_init(void)
488{
Takashi YOSHII3256c782010-11-19 16:49:38 +0900489 sh73a0_pinmux_init();
490
Magnus Damm6d9598e2010-11-17 10:59:31 +0000491 /* enable SCIFA2 */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900492 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
493 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
494 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
495 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000496
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000497 /* enable KEYSC */
Takashi YOSHII5d781472010-12-22 06:30:19 +0000498 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
499 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
500 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
501 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
502 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
503 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
504 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
505 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000506 gpio_request(GPIO_FN_KEYOUT0, NULL);
507 gpio_request(GPIO_FN_KEYOUT1, NULL);
508 gpio_request(GPIO_FN_KEYOUT2, NULL);
509 gpio_request(GPIO_FN_KEYOUT3, NULL);
510 gpio_request(GPIO_FN_KEYOUT4, NULL);
511 gpio_request(GPIO_FN_KEYOUT5, NULL);
512 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
513 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
514 gpio_request(GPIO_FN_KEYOUT8, NULL);
515 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
516
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000517 /* enable I2C channel 2 and 3 */
Yoshii Takashi8e67b222010-11-19 13:21:32 +0000518 gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
519 gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
520 gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
521 gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
522
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000523 /* enable MMCIF */
524 gpio_request(GPIO_FN_MMCCLK0, NULL);
525 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
Kuninori Morimoto052008e2011-11-10 18:44:24 -0800526 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
527 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
528 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
529 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
530 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
531 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
532 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
533 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000534 gpio_request(GPIO_PORT208, NULL); /* Reset */
535 gpio_direction_output(GPIO_PORT208, 1);
536
Magnus Damm6d9598e2010-11-17 10:59:31 +0000537 /* enable SMSC911X */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900538 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
539 gpio_direction_input(GPIO_PORT144);
540 gpio_request(GPIO_PORT145, NULL); /* RESET */
541 gpio_direction_output(GPIO_PORT145, 1);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000542
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000543 /* FSI A */
544 gpio_request(GPIO_FN_FSIACK, NULL);
545 gpio_request(GPIO_FN_FSIAILR, NULL);
546 gpio_request(GPIO_FN_FSIAIBT, NULL);
547 gpio_request(GPIO_FN_FSIAISLD, NULL);
548 gpio_request(GPIO_FN_FSIAOSLD, NULL);
549
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000550 /* IrDA */
551 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
552 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
553 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
554
Magnus Damm170c7ab2011-01-20 08:41:03 +0000555 /* LCD panel */
556 gpio_request(GPIO_PORT217, NULL); /* RESET */
557 gpio_direction_output(GPIO_PORT217, 0);
558 mdelay(1);
559 gpio_set_value(GPIO_PORT217, 1);
Magnus Dammf55398a2011-01-28 09:59:17 +0000560 mdelay(100);
Magnus Damm170c7ab2011-01-20 08:41:03 +0000561
562 /* LCD backlight controller */
563 gpio_request(GPIO_PORT235, NULL); /* RESET */
564 gpio_direction_output(GPIO_PORT235, 0);
565 lcd_backlight_reset();
566
Magnus Dammfb66c522011-05-23 05:10:36 +0000567 /* enable SDHI0 on CN15 [SD I/F] */
568 gpio_request(GPIO_FN_SDHICD0, NULL);
569 gpio_request(GPIO_FN_SDHIWP0, NULL);
570 gpio_request(GPIO_FN_SDHICMD0, NULL);
571 gpio_request(GPIO_FN_SDHICLK0, NULL);
572 gpio_request(GPIO_FN_SDHID0_3, NULL);
573 gpio_request(GPIO_FN_SDHID0_2, NULL);
574 gpio_request(GPIO_FN_SDHID0_1, NULL);
575 gpio_request(GPIO_FN_SDHID0_0, NULL);
576
Magnus Damm3087b902011-10-12 16:21:50 +0900577 if (!request_irq(intcs_evt2irq(0x3c0), ag5evm_sdhi0_gpio_cd,
578 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
579 "sdhi0 cd", &sdhi0_device.dev))
580 sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD;
581 else
582 pr_warn("Unable to setup SDHI0 GPIO IRQ\n");
583
Magnus Dammfb66c522011-05-23 05:10:36 +0000584 /* enable SDHI1 on CN4 [WLAN I/F] */
585 gpio_request(GPIO_FN_SDHICLK1, NULL);
586 gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
587 gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
588 gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
589 gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
590 gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
591 gpio_request(GPIO_PORT114, "sdhi1_power");
592 gpio_direction_output(GPIO_PORT114, 0);
593
Magnus Damm6d9598e2010-11-17 10:59:31 +0000594#ifdef CONFIG_CACHE_L2X0
595 /* Shared attribute override enable, 64K*8way */
596 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
597#endif
598 sh73a0_add_standard_devices();
599 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
600}
601
Magnus Damm6d9598e2010-11-17 10:59:31 +0000602MACHINE_START(AG5EVM, "ag5evm")
Magnus Damm50e15c32012-02-29 21:37:27 +0900603 .map_io = sh73a0_map_io,
604 .init_early = sh73a0_add_early_devices,
Magnus Dammeded9142011-11-22 15:31:40 +0900605 .nr_irqs = NR_IRQS_LEGACY,
Magnus Damm566aad32011-10-17 18:00:52 +0900606 .init_irq = sh73a0_init_irq,
Marc Zyngiera83d8e22011-09-06 10:23:45 +0100607 .handle_irq = gic_handle_irq,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000608 .init_machine = ag5evm_init,
Magnus Damm3be26fd2012-03-06 17:36:45 +0900609 .timer = &shmobile_timer,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000610MACHINE_END