blob: cd894a200d52148b08aa59e73cdbebc5edacf376 [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/mach/time.h>
50#include <asm/hardware/gic.h>
51#include <asm/hardware/cache-l2x0.h>
52#include <asm/traps.h>
53
54static struct resource smsc9220_resources[] = {
55 [0] = {
56 .start = 0x14000000,
57 .end = 0x14000000 + SZ_64K - 1,
58 .flags = IORESOURCE_MEM,
59 },
60 [1] = {
Magnus Damm566aad32011-10-17 18:00:52 +090061 .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */
Magnus Damm6d9598e2010-11-17 10:59:31 +000062 .flags = IORESOURCE_IRQ,
63 },
64};
65
66static struct smsc911x_platform_config smsc9220_platdata = {
67 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
68 .phy_interface = PHY_INTERFACE_MODE_MII,
69 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
70 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
71};
72
73static struct platform_device eth_device = {
74 .name = "smsc911x",
75 .id = 0,
76 .dev = {
77 .platform_data = &smsc9220_platdata,
78 },
79 .resource = smsc9220_resources,
80 .num_resources = ARRAY_SIZE(smsc9220_resources),
81};
82
Yoshii Takashi2d22d482010-11-19 13:15:46 +000083static struct sh_keysc_info keysc_platdata = {
84 .mode = SH_KEYSC_MODE_6,
85 .scan_timing = 3,
86 .delay = 100,
87 .keycodes = {
88 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
89 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
90 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
91 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
92 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
93 KEY_COFFEE,
94 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
95 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
96 KEY_COMPUTER,
97 },
98};
99
100static struct resource keysc_resources[] = {
101 [0] = {
102 .name = "KEYSC",
103 .start = 0xe61b0000,
104 .end = 0xe61b0098 - 1,
105 .flags = IORESOURCE_MEM,
106 },
107 [1] = {
108 .start = gic_spi(71),
109 .flags = IORESOURCE_IRQ,
110 },
111};
112
113static struct platform_device keysc_device = {
114 .name = "sh_keysc",
115 .id = 0,
116 .num_resources = ARRAY_SIZE(keysc_resources),
117 .resource = keysc_resources,
118 .dev = {
119 .platform_data = &keysc_platdata,
120 },
121};
122
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000123/* FSI A */
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000124static struct resource fsi_resources[] = {
125 [0] = {
126 .name = "FSI",
127 .start = 0xEC230000,
128 .end = 0xEC230400 - 1,
129 .flags = IORESOURCE_MEM,
130 },
131 [1] = {
132 .start = gic_spi(146),
133 .flags = IORESOURCE_IRQ,
134 },
135};
136
137static struct platform_device fsi_device = {
138 .name = "sh_fsi2",
139 .id = -1,
140 .num_resources = ARRAY_SIZE(fsi_resources),
141 .resource = fsi_resources,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000142};
143
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000144static struct resource sh_mmcif_resources[] = {
145 [0] = {
146 .name = "MMCIF",
147 .start = 0xe6bd0000,
148 .end = 0xe6bd00ff,
149 .flags = IORESOURCE_MEM,
150 },
151 [1] = {
152 .start = gic_spi(141),
153 .flags = IORESOURCE_IRQ,
154 },
155 [2] = {
156 .start = gic_spi(140),
157 .flags = IORESOURCE_IRQ,
158 },
159};
160
161static struct sh_mmcif_plat_data sh_mmcif_platdata = {
162 .sup_pclk = 0,
163 .ocr = MMC_VDD_165_195,
164 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +0200165 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
166 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000167};
168
169static struct platform_device mmc_device = {
170 .name = "sh_mmcif",
171 .id = 0,
172 .dev = {
173 .dma_mask = NULL,
174 .coherent_dma_mask = 0xffffffff,
175 .platform_data = &sh_mmcif_platdata,
176 },
177 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
178 .resource = sh_mmcif_resources,
179};
180
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000181/* IrDA */
182static struct resource irda_resources[] = {
183 [0] = {
184 .start = 0xE6D00000,
185 .end = 0xE6D01FD4 - 1,
186 .flags = IORESOURCE_MEM,
187 },
188 [1] = {
189 .start = gic_spi(95),
190 .flags = IORESOURCE_IRQ,
191 },
192};
193
194static struct platform_device irda_device = {
195 .name = "sh_irda",
196 .id = 0,
197 .resource = irda_resources,
198 .num_resources = ARRAY_SIZE(irda_resources),
199};
200
Magnus Damm170c7ab2011-01-20 08:41:03 +0000201static unsigned char lcd_backlight_seq[3][2] = {
202 { 0x04, 0x07 },
203 { 0x23, 0x80 },
204 { 0x03, 0x01 },
205};
206
207static void lcd_backlight_on(void)
208{
209 struct i2c_adapter *a;
210 struct i2c_msg msg;
211 int k;
212
213 a = i2c_get_adapter(1);
214 for (k = 0; a && k < 3; k++) {
215 msg.addr = 0x6d;
216 msg.buf = &lcd_backlight_seq[k][0];
217 msg.len = 2;
218 msg.flags = 0;
219 if (i2c_transfer(a, &msg, 1) != 1)
220 break;
221 }
222}
223
224static void lcd_backlight_reset(void)
225{
226 gpio_set_value(GPIO_PORT235, 0);
227 mdelay(24);
228 gpio_set_value(GPIO_PORT235, 1);
229}
230
231static void lcd_on(void *board_data, struct fb_info *info)
232{
233 lcd_backlight_on();
234}
235
236static void lcd_off(void *board_data)
237{
238 lcd_backlight_reset();
239}
240
241/* LCDC0 */
242static const struct fb_videomode lcdc0_modes[] = {
243 {
244 .name = "R63302(QHD)",
245 .xres = 544,
246 .yres = 961,
247 .left_margin = 72,
248 .right_margin = 600,
249 .hsync_len = 16,
250 .upper_margin = 8,
251 .lower_margin = 8,
252 .vsync_len = 2,
253 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
254 },
255};
256
257static struct sh_mobile_lcdc_info lcdc0_info = {
258 .clock_source = LCDC_CLK_PERIPHERAL,
259 .ch[0] = {
260 .chan = LCDC_CHAN_MAINLCD,
261 .interface_type = RGB24,
262 .clock_divider = 1,
263 .flags = LCDC_FLAGS_DWPOL,
264 .lcd_size_cfg.width = 44,
265 .lcd_size_cfg.height = 79,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100266 .fourcc = V4L2_PIX_FMT_RGB565,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000267 .lcd_cfg = lcdc0_modes,
268 .num_cfg = ARRAY_SIZE(lcdc0_modes),
269 .board_cfg = {
270 .display_on = lcd_on,
271 .display_off = lcd_off,
272 },
273 }
274};
275
276static struct resource lcdc0_resources[] = {
277 [0] = {
278 .name = "LCDC0",
279 .start = 0xfe940000, /* P4-only space */
280 .end = 0xfe943fff,
281 .flags = IORESOURCE_MEM,
282 },
283 [1] = {
284 .start = intcs_evt2irq(0x580),
285 .flags = IORESOURCE_IRQ,
286 },
287};
288
289static struct platform_device lcdc0_device = {
290 .name = "sh_mobile_lcdc_fb",
291 .num_resources = ARRAY_SIZE(lcdc0_resources),
292 .resource = lcdc0_resources,
293 .id = 0,
294 .dev = {
295 .platform_data = &lcdc0_info,
296 .coherent_dma_mask = ~0,
297 },
298};
299
300/* MIPI-DSI */
301static struct resource mipidsi0_resources[] = {
302 [0] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000303 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000304 .start = 0xfeab0000,
305 .end = 0xfeab3fff,
306 .flags = IORESOURCE_MEM,
307 },
308 [1] = {
Magnus Damm6b36fdd2011-05-19 06:30:59 +0000309 .name = "DSI0",
Magnus Damm170c7ab2011-01-20 08:41:03 +0000310 .start = 0xfeab4000,
311 .end = 0xfeab7fff,
312 .flags = IORESOURCE_MEM,
313 },
314};
315
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800316static int sh_mipi_set_dot_clock(struct platform_device *pdev,
317 void __iomem *base,
318 int enable)
319{
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800320 struct clk *pck, *phy;
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800321 int ret;
322
323 pck = clk_get(&pdev->dev, "dsip_clk");
324 if (IS_ERR(pck)) {
325 ret = PTR_ERR(pck);
326 goto sh_mipi_set_dot_clock_pck_err;
327 }
328
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800329 phy = clk_get(&pdev->dev, "dsiphy_clk");
330 if (IS_ERR(phy)) {
331 ret = PTR_ERR(phy);
332 goto sh_mipi_set_dot_clock_phy_err;
333 }
334
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800335 if (enable) {
336 clk_set_rate(pck, clk_round_rate(pck, 24000000));
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800337 clk_set_rate(phy, clk_round_rate(pck, 510000000));
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800338 clk_enable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800339 clk_enable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800340 } else {
341 clk_disable(pck);
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800342 clk_disable(phy);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800343 }
344
345 ret = 0;
346
Kuninori Morimotof5948ba2012-01-22 21:10:02 -0800347 clk_put(phy);
348sh_mipi_set_dot_clock_phy_err:
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800349 clk_put(pck);
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800350sh_mipi_set_dot_clock_pck_err:
351 return ret;
352}
353
Magnus Damm170c7ab2011-01-20 08:41:03 +0000354static struct sh_mipi_dsi_info mipidsi0_info = {
355 .data_format = MIPI_RGB888,
356 .lcd_chan = &lcdc0_info.ch[0],
Kuninori Morimoto26c3d7a2011-11-08 20:34:43 -0800357 .lane = 2,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000358 .vsynw_offset = 20,
359 .clksrc = 1,
Kuninori Morimotoa2e62972011-11-08 20:35:27 -0800360 .flags = SH_MIPI_DSI_HSABM |
361 SH_MIPI_DSI_SYNC_PULSES_MODE |
362 SH_MIPI_DSI_HSbyteCLK,
Kuninori Morimoto5e474312011-11-08 20:35:14 -0800363 .set_dot_clock = sh_mipi_set_dot_clock,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000364};
365
366static struct platform_device mipidsi0_device = {
367 .name = "sh-mipi-dsi",
368 .num_resources = ARRAY_SIZE(mipidsi0_resources),
369 .resource = mipidsi0_resources,
370 .id = 0,
371 .dev = {
372 .platform_data = &mipidsi0_info,
373 },
374};
375
Magnus Damm3087b902011-10-12 16:21:50 +0900376/* SDHI0 */
377static irqreturn_t ag5evm_sdhi0_gpio_cd(int irq, void *arg)
378{
379 struct device *dev = arg;
380 struct sh_mobile_sdhi_info *info = dev->platform_data;
381 struct tmio_mmc_data *pdata = info->pdata;
382
383 tmio_mmc_cd_wakeup(pdata);
384
385 return IRQ_HANDLED;
386}
387
Magnus Dammfb66c522011-05-23 05:10:36 +0000388static struct sh_mobile_sdhi_info sdhi0_info = {
Magnus Damm6820e692011-05-24 10:42:15 +0000389 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
390 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000391 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000392 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
393 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
394};
395
396static struct resource sdhi0_resources[] = {
397 [0] = {
398 .name = "SDHI0",
399 .start = 0xee100000,
400 .end = 0xee1000ff,
401 .flags = IORESOURCE_MEM,
402 },
403 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900404 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000405 .start = gic_spi(83),
406 .flags = IORESOURCE_IRQ,
407 },
408 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900409 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000410 .start = gic_spi(84),
411 .flags = IORESOURCE_IRQ,
412 },
413 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900414 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000415 .start = gic_spi(85),
416 .flags = IORESOURCE_IRQ,
417 },
418};
419
420static struct platform_device sdhi0_device = {
421 .name = "sh_mobile_sdhi",
422 .id = 0,
423 .num_resources = ARRAY_SIZE(sdhi0_resources),
424 .resource = sdhi0_resources,
425 .dev = {
426 .platform_data = &sdhi0_info,
427 },
428};
429
430void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
431{
432 gpio_set_value(GPIO_PORT114, state);
433}
434
Simon Horman9e05cdd2011-06-20 23:00:11 +0000435static struct sh_mobile_sdhi_info sh_sdhi1_info = {
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000436 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
Magnus Damm52942062011-06-09 09:02:25 +0000437 .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
Magnus Dammfb66c522011-05-23 05:10:36 +0000438 .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
439 .set_pwr = ag5evm_sdhi1_set_pwr,
440};
441
442static struct resource sdhi1_resources[] = {
443 [0] = {
444 .name = "SDHI1",
445 .start = 0xee120000,
446 .end = 0xee1200ff,
447 .flags = IORESOURCE_MEM,
448 },
449 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900450 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000451 .start = gic_spi(87),
452 .flags = IORESOURCE_IRQ,
453 },
454 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900455 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000456 .start = gic_spi(88),
457 .flags = IORESOURCE_IRQ,
458 },
459 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900460 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000461 .start = gic_spi(89),
462 .flags = IORESOURCE_IRQ,
463 },
464};
465
466static struct platform_device sdhi1_device = {
467 .name = "sh_mobile_sdhi",
468 .id = 1,
469 .dev = {
Simon Horman9e05cdd2011-06-20 23:00:11 +0000470 .platform_data = &sh_sdhi1_info,
Magnus Dammfb66c522011-05-23 05:10:36 +0000471 },
472 .num_resources = ARRAY_SIZE(sdhi1_resources),
473 .resource = sdhi1_resources,
474};
475
Magnus Damm6d9598e2010-11-17 10:59:31 +0000476static struct platform_device *ag5evm_devices[] __initdata = {
477 &eth_device,
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000478 &keysc_device,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000479 &fsi_device,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000480 &mmc_device,
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000481 &irda_device,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000482 &lcdc0_device,
483 &mipidsi0_device,
Magnus Dammfb66c522011-05-23 05:10:36 +0000484 &sdhi0_device,
485 &sdhi1_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000486};
487
Magnus Damm6d9598e2010-11-17 10:59:31 +0000488static void __init ag5evm_init(void)
489{
Takashi YOSHII3256c782010-11-19 16:49:38 +0900490 sh73a0_pinmux_init();
491
Magnus Damm6d9598e2010-11-17 10:59:31 +0000492 /* enable SCIFA2 */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900493 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
494 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
495 gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL);
496 gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000497
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000498 /* enable KEYSC */
Takashi YOSHII5d781472010-12-22 06:30:19 +0000499 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
500 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
501 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
502 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
503 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
504 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
505 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
506 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000507 gpio_request(GPIO_FN_KEYOUT0, NULL);
508 gpio_request(GPIO_FN_KEYOUT1, NULL);
509 gpio_request(GPIO_FN_KEYOUT2, NULL);
510 gpio_request(GPIO_FN_KEYOUT3, NULL);
511 gpio_request(GPIO_FN_KEYOUT4, NULL);
512 gpio_request(GPIO_FN_KEYOUT5, NULL);
513 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
514 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
515 gpio_request(GPIO_FN_KEYOUT8, NULL);
516 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
517
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000518 /* enable I2C channel 2 and 3 */
Yoshii Takashi8e67b222010-11-19 13:21:32 +0000519 gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL);
520 gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL);
521 gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL);
522 gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL);
523
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000524 /* enable MMCIF */
525 gpio_request(GPIO_FN_MMCCLK0, NULL);
526 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
Kuninori Morimoto052008e2011-11-10 18:44:24 -0800527 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
528 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
529 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
530 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
531 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
532 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
533 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
534 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000535 gpio_request(GPIO_PORT208, NULL); /* Reset */
536 gpio_direction_output(GPIO_PORT208, 1);
537
Magnus Damm6d9598e2010-11-17 10:59:31 +0000538 /* enable SMSC911X */
Takashi YOSHII3256c782010-11-19 16:49:38 +0900539 gpio_request(GPIO_PORT144, NULL); /* PINTA2 */
540 gpio_direction_input(GPIO_PORT144);
541 gpio_request(GPIO_PORT145, NULL); /* RESET */
542 gpio_direction_output(GPIO_PORT145, 1);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000543
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000544 /* FSI A */
545 gpio_request(GPIO_FN_FSIACK, NULL);
546 gpio_request(GPIO_FN_FSIAILR, NULL);
547 gpio_request(GPIO_FN_FSIAIBT, NULL);
548 gpio_request(GPIO_FN_FSIAISLD, NULL);
549 gpio_request(GPIO_FN_FSIAOSLD, NULL);
550
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000551 /* IrDA */
552 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
553 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
554 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
555
Magnus Damm170c7ab2011-01-20 08:41:03 +0000556 /* LCD panel */
557 gpio_request(GPIO_PORT217, NULL); /* RESET */
558 gpio_direction_output(GPIO_PORT217, 0);
559 mdelay(1);
560 gpio_set_value(GPIO_PORT217, 1);
Magnus Dammf55398a2011-01-28 09:59:17 +0000561 mdelay(100);
Magnus Damm170c7ab2011-01-20 08:41:03 +0000562
563 /* LCD backlight controller */
564 gpio_request(GPIO_PORT235, NULL); /* RESET */
565 gpio_direction_output(GPIO_PORT235, 0);
566 lcd_backlight_reset();
567
Magnus Dammfb66c522011-05-23 05:10:36 +0000568 /* enable SDHI0 on CN15 [SD I/F] */
569 gpio_request(GPIO_FN_SDHICD0, NULL);
570 gpio_request(GPIO_FN_SDHIWP0, NULL);
571 gpio_request(GPIO_FN_SDHICMD0, NULL);
572 gpio_request(GPIO_FN_SDHICLK0, NULL);
573 gpio_request(GPIO_FN_SDHID0_3, NULL);
574 gpio_request(GPIO_FN_SDHID0_2, NULL);
575 gpio_request(GPIO_FN_SDHID0_1, NULL);
576 gpio_request(GPIO_FN_SDHID0_0, NULL);
577
Magnus Damm3087b902011-10-12 16:21:50 +0900578 if (!request_irq(intcs_evt2irq(0x3c0), ag5evm_sdhi0_gpio_cd,
579 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
580 "sdhi0 cd", &sdhi0_device.dev))
581 sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD;
582 else
583 pr_warn("Unable to setup SDHI0 GPIO IRQ\n");
584
Magnus Dammfb66c522011-05-23 05:10:36 +0000585 /* enable SDHI1 on CN4 [WLAN I/F] */
586 gpio_request(GPIO_FN_SDHICLK1, NULL);
587 gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
588 gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
589 gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
590 gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
591 gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
592 gpio_request(GPIO_PORT114, "sdhi1_power");
593 gpio_direction_output(GPIO_PORT114, 0);
594
Magnus Damm6d9598e2010-11-17 10:59:31 +0000595#ifdef CONFIG_CACHE_L2X0
596 /* Shared attribute override enable, 64K*8way */
597 l2x0_init(__io(0xf0100000), 0x00460000, 0xc2000fff);
598#endif
599 sh73a0_add_standard_devices();
600 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
601}
602
603static void __init ag5evm_timer_init(void)
604{
605 sh73a0_clock_init();
606 shmobile_timer.init();
607 return;
608}
609
610struct sys_timer ag5evm_timer = {
611 .init = ag5evm_timer_init,
612};
613
614MACHINE_START(AG5EVM, "ag5evm")
Magnus Damm50e15c32012-02-29 21:37:27 +0900615 .map_io = sh73a0_map_io,
616 .init_early = sh73a0_add_early_devices,
Magnus Dammeded9142011-11-22 15:31:40 +0900617 .nr_irqs = NR_IRQS_LEGACY,
Magnus Damm566aad32011-10-17 18:00:52 +0900618 .init_irq = sh73a0_init_irq,
Marc Zyngiera83d8e22011-09-06 10:23:45 +0100619 .handle_irq = gic_handle_irq,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000620 .init_machine = ag5evm_init,
621 .timer = &ag5evm_timer,
622MACHINE_END