blob: 178bfd12de9f03fcceb678b67c06b0a6daffdd54 [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>
Laurent Pinchartb5012cd2013-01-03 12:54:28 +010026#include <linux/pinctrl/machine.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000027#include <linux/platform_device.h>
28#include <linux/delay.h>
29#include <linux/io.h>
30#include <linux/dma-mapping.h>
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +020031#include <linux/regulator/fixed.h>
32#include <linux/regulator/machine.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000033#include <linux/serial_sci.h>
34#include <linux/smsc911x.h>
35#include <linux/gpio.h>
Paul Gortmaker04f47a02012-01-22 14:57:25 -050036#include <linux/videodev2.h>
Yoshii Takashi2d22d482010-11-19 13:15:46 +000037#include <linux/input.h>
38#include <linux/input/sh_keysc.h>
Takashi YOSHII6bf45a12010-12-22 06:35:30 +000039#include <linux/mmc/host.h>
40#include <linux/mmc/sh_mmcif.h>
Magnus Dammfb66c522011-05-23 05:10:36 +000041#include <linux/mmc/sh_mobile_sdhi.h>
42#include <linux/mfd/tmio.h>
Magnus Damm170c7ab2011-01-20 08:41:03 +000043#include <linux/sh_clk.h>
Rob Herring520f7bd2012-12-27 13:10:24 -060044#include <linux/irqchip/arm-gic.h>
Magnus Damm170c7ab2011-01-20 08:41:03 +000045#include <video/sh_mobile_lcdc.h>
46#include <video/sh_mipi_dsi.h>
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +000047#include <sound/sh_fsi.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000048#include <mach/hardware.h>
Rob Herring250a2722012-01-03 16:57:33 -060049#include <mach/irqs.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000050#include <mach/sh73a0.h>
51#include <mach/common.h>
52#include <asm/mach-types.h>
53#include <asm/mach/arch.h>
Magnus Damm6d9598e2010-11-17 10:59:31 +000054#include <asm/hardware/cache-l2x0.h>
55#include <asm/traps.h>
56
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +020057/* Dummy supplies, where voltage doesn't matter */
58static struct regulator_consumer_supply dummy_supplies[] = {
59 REGULATOR_SUPPLY("vddvario", "smsc911x"),
60 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
61};
62
Magnus Damm6d9598e2010-11-17 10:59:31 +000063static struct resource smsc9220_resources[] = {
64 [0] = {
65 .start = 0x14000000,
66 .end = 0x14000000 + SZ_64K - 1,
67 .flags = IORESOURCE_MEM,
68 },
69 [1] = {
Magnus Damm566aad32011-10-17 18:00:52 +090070 .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */
Magnus Damm6d9598e2010-11-17 10:59:31 +000071 .flags = IORESOURCE_IRQ,
72 },
73};
74
75static struct smsc911x_platform_config smsc9220_platdata = {
76 .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
77 .phy_interface = PHY_INTERFACE_MODE_MII,
78 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
79 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
80};
81
82static struct platform_device eth_device = {
83 .name = "smsc911x",
84 .id = 0,
85 .dev = {
86 .platform_data = &smsc9220_platdata,
87 },
88 .resource = smsc9220_resources,
89 .num_resources = ARRAY_SIZE(smsc9220_resources),
90};
91
Yoshii Takashi2d22d482010-11-19 13:15:46 +000092static struct sh_keysc_info keysc_platdata = {
93 .mode = SH_KEYSC_MODE_6,
94 .scan_timing = 3,
95 .delay = 100,
96 .keycodes = {
97 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
98 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
99 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
100 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
101 KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \
102 KEY_COFFEE,
103 KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP,
104 KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \
105 KEY_COMPUTER,
106 },
107};
108
109static struct resource keysc_resources[] = {
110 [0] = {
111 .name = "KEYSC",
112 .start = 0xe61b0000,
113 .end = 0xe61b0098 - 1,
114 .flags = IORESOURCE_MEM,
115 },
116 [1] = {
117 .start = gic_spi(71),
118 .flags = IORESOURCE_IRQ,
119 },
120};
121
122static struct platform_device keysc_device = {
123 .name = "sh_keysc",
124 .id = 0,
125 .num_resources = ARRAY_SIZE(keysc_resources),
126 .resource = keysc_resources,
127 .dev = {
128 .platform_data = &keysc_platdata,
129 },
130};
131
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000132/* FSI A */
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000133static struct resource fsi_resources[] = {
134 [0] = {
135 .name = "FSI",
136 .start = 0xEC230000,
137 .end = 0xEC230400 - 1,
138 .flags = IORESOURCE_MEM,
139 },
140 [1] = {
141 .start = gic_spi(146),
142 .flags = IORESOURCE_IRQ,
143 },
144};
145
146static struct platform_device fsi_device = {
147 .name = "sh_fsi2",
148 .id = -1,
149 .num_resources = ARRAY_SIZE(fsi_resources),
150 .resource = fsi_resources,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000151};
152
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200153/* Fixed 1.8V regulator to be used by MMCIF */
154static struct regulator_consumer_supply fixed1v8_power_consumers[] =
155{
156 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
157 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
158};
159
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000160static struct resource sh_mmcif_resources[] = {
161 [0] = {
162 .name = "MMCIF",
163 .start = 0xe6bd0000,
164 .end = 0xe6bd00ff,
165 .flags = IORESOURCE_MEM,
166 },
167 [1] = {
168 .start = gic_spi(141),
169 .flags = IORESOURCE_IRQ,
170 },
171 [2] = {
172 .start = gic_spi(140),
173 .flags = IORESOURCE_IRQ,
174 },
175};
176
177static struct sh_mmcif_plat_data sh_mmcif_platdata = {
178 .sup_pclk = 0,
179 .ocr = MMC_VDD_165_195,
180 .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +0200181 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
182 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000183};
184
185static struct platform_device mmc_device = {
186 .name = "sh_mmcif",
187 .id = 0,
188 .dev = {
189 .dma_mask = NULL,
190 .coherent_dma_mask = 0xffffffff,
191 .platform_data = &sh_mmcif_platdata,
192 },
193 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
194 .resource = sh_mmcif_resources,
195};
196
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000197/* IrDA */
198static struct resource irda_resources[] = {
199 [0] = {
200 .start = 0xE6D00000,
201 .end = 0xE6D01FD4 - 1,
202 .flags = IORESOURCE_MEM,
203 },
204 [1] = {
205 .start = gic_spi(95),
206 .flags = IORESOURCE_IRQ,
207 },
208};
209
210static struct platform_device irda_device = {
211 .name = "sh_irda",
212 .id = 0,
213 .resource = irda_resources,
214 .num_resources = ARRAY_SIZE(irda_resources),
215};
216
Laurent Pinchart7a4fcf92012-08-13 16:11:32 +0200217/* MIPI-DSI */
218static struct resource mipidsi0_resources[] = {
219 [0] = {
220 .name = "DSI0",
221 .start = 0xfeab0000,
222 .end = 0xfeab3fff,
223 .flags = IORESOURCE_MEM,
224 },
225 [1] = {
226 .name = "DSI0",
227 .start = 0xfeab4000,
228 .end = 0xfeab7fff,
229 .flags = IORESOURCE_MEM,
230 },
231};
232
233static int sh_mipi_set_dot_clock(struct platform_device *pdev,
234 void __iomem *base,
235 int enable)
236{
237 struct clk *pck, *phy;
238 int ret;
239
240 pck = clk_get(&pdev->dev, "dsip_clk");
241 if (IS_ERR(pck)) {
242 ret = PTR_ERR(pck);
243 goto sh_mipi_set_dot_clock_pck_err;
244 }
245
246 phy = clk_get(&pdev->dev, "dsiphy_clk");
247 if (IS_ERR(phy)) {
248 ret = PTR_ERR(phy);
249 goto sh_mipi_set_dot_clock_phy_err;
250 }
251
252 if (enable) {
253 clk_set_rate(pck, clk_round_rate(pck, 24000000));
254 clk_set_rate(phy, clk_round_rate(pck, 510000000));
255 clk_enable(pck);
256 clk_enable(phy);
257 } else {
258 clk_disable(pck);
259 clk_disable(phy);
260 }
261
262 ret = 0;
263
264 clk_put(phy);
265sh_mipi_set_dot_clock_phy_err:
266 clk_put(pck);
267sh_mipi_set_dot_clock_pck_err:
268 return ret;
269}
270
Laurent Pinchart7a4fcf92012-08-13 16:11:32 +0200271static struct sh_mipi_dsi_info mipidsi0_info = {
272 .data_format = MIPI_RGB888,
Laurent Pinchart772f5d12012-08-14 12:21:17 +0200273 .channel = LCDC_CHAN_MAINLCD,
Laurent Pinchart7a4fcf92012-08-13 16:11:32 +0200274 .lane = 2,
275 .vsynw_offset = 20,
276 .clksrc = 1,
277 .flags = SH_MIPI_DSI_HSABM |
278 SH_MIPI_DSI_SYNC_PULSES_MODE |
279 SH_MIPI_DSI_HSbyteCLK,
280 .set_dot_clock = sh_mipi_set_dot_clock,
281};
282
283static struct platform_device mipidsi0_device = {
284 .name = "sh-mipi-dsi",
285 .num_resources = ARRAY_SIZE(mipidsi0_resources),
286 .resource = mipidsi0_resources,
287 .id = 0,
288 .dev = {
289 .platform_data = &mipidsi0_info,
290 },
291};
292
Magnus Damm170c7ab2011-01-20 08:41:03 +0000293static unsigned char lcd_backlight_seq[3][2] = {
294 { 0x04, 0x07 },
295 { 0x23, 0x80 },
296 { 0x03, 0x01 },
297};
298
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200299static int lcd_backlight_set_brightness(int brightness)
Magnus Damm170c7ab2011-01-20 08:41:03 +0000300{
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200301 struct i2c_adapter *adap;
Magnus Damm170c7ab2011-01-20 08:41:03 +0000302 struct i2c_msg msg;
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200303 unsigned int i;
304 int ret;
Magnus Damm170c7ab2011-01-20 08:41:03 +0000305
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200306 if (brightness == 0) {
307 /* Reset the chip */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100308 gpio_set_value(235, 0);
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200309 mdelay(24);
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100310 gpio_set_value(235, 1);
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200311 return 0;
312 }
313
314 adap = i2c_get_adapter(1);
315 if (adap == NULL)
316 return -ENODEV;
317
318 for (i = 0; i < ARRAY_SIZE(lcd_backlight_seq); i++) {
Magnus Damm170c7ab2011-01-20 08:41:03 +0000319 msg.addr = 0x6d;
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200320 msg.buf = &lcd_backlight_seq[i][0];
Magnus Damm170c7ab2011-01-20 08:41:03 +0000321 msg.len = 2;
322 msg.flags = 0;
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200323
324 ret = i2c_transfer(adap, &msg, 1);
325 if (ret < 0)
Magnus Damm170c7ab2011-01-20 08:41:03 +0000326 break;
327 }
Magnus Damm170c7ab2011-01-20 08:41:03 +0000328
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200329 i2c_put_adapter(adap);
330 return ret < 0 ? ret : 0;
Magnus Damm170c7ab2011-01-20 08:41:03 +0000331}
332
Magnus Damm170c7ab2011-01-20 08:41:03 +0000333/* LCDC0 */
334static const struct fb_videomode lcdc0_modes[] = {
335 {
336 .name = "R63302(QHD)",
337 .xres = 544,
338 .yres = 961,
339 .left_margin = 72,
340 .right_margin = 600,
341 .hsync_len = 16,
342 .upper_margin = 8,
343 .lower_margin = 8,
344 .vsync_len = 2,
345 .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT,
346 },
347};
348
349static struct sh_mobile_lcdc_info lcdc0_info = {
350 .clock_source = LCDC_CLK_PERIPHERAL,
351 .ch[0] = {
352 .chan = LCDC_CHAN_MAINLCD,
353 .interface_type = RGB24,
354 .clock_divider = 1,
355 .flags = LCDC_FLAGS_DWPOL,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100356 .fourcc = V4L2_PIX_FMT_RGB565,
Laurent Pinchart93ff2592011-11-29 14:33:41 +0100357 .lcd_modes = lcdc0_modes,
358 .num_modes = ARRAY_SIZE(lcdc0_modes),
Laurent Pinchartafaad832011-09-11 22:59:04 +0200359 .panel_cfg = {
360 .width = 44,
361 .height = 79,
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200362 },
363 .bl_info = {
364 .name = "sh_mobile_lcdc_bl",
365 .max_brightness = 1,
366 .set_brightness = lcd_backlight_set_brightness,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000367 },
Laurent Pinchart7a4fcf92012-08-13 16:11:32 +0200368 .tx_dev = &mipidsi0_device,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000369 }
370};
371
372static struct resource lcdc0_resources[] = {
373 [0] = {
374 .name = "LCDC0",
375 .start = 0xfe940000, /* P4-only space */
376 .end = 0xfe943fff,
377 .flags = IORESOURCE_MEM,
378 },
379 [1] = {
380 .start = intcs_evt2irq(0x580),
381 .flags = IORESOURCE_IRQ,
382 },
383};
384
385static struct platform_device lcdc0_device = {
386 .name = "sh_mobile_lcdc_fb",
387 .num_resources = ARRAY_SIZE(lcdc0_resources),
388 .resource = lcdc0_resources,
389 .id = 0,
390 .dev = {
391 .platform_data = &lcdc0_info,
392 .coherent_dma_mask = ~0,
393 },
394};
395
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200396/* Fixed 2.8V regulators to be used by SDHI0 */
397static struct regulator_consumer_supply fixed2v8_power_consumers[] =
398{
399 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
400 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
401};
402
Magnus Damm3087b902011-10-12 16:21:50 +0900403/* SDHI0 */
Magnus Dammfb66c522011-05-23 05:10:36 +0000404static struct sh_mobile_sdhi_info sdhi0_info = {
Magnus Damm6820e692011-05-24 10:42:15 +0000405 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
406 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Guennadi Liakhovetski173e2fe2012-04-16 23:09:19 +0200407 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000408 .tmio_caps = MMC_CAP_SD_HIGHSPEED,
409 .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100410 .cd_gpio = 251,
Magnus Dammfb66c522011-05-23 05:10:36 +0000411};
412
413static struct resource sdhi0_resources[] = {
414 [0] = {
415 .name = "SDHI0",
416 .start = 0xee100000,
417 .end = 0xee1000ff,
418 .flags = IORESOURCE_MEM,
419 },
420 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900421 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000422 .start = gic_spi(83),
423 .flags = IORESOURCE_IRQ,
424 },
425 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900426 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000427 .start = gic_spi(84),
428 .flags = IORESOURCE_IRQ,
429 },
430 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900431 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000432 .start = gic_spi(85),
433 .flags = IORESOURCE_IRQ,
434 },
435};
436
437static struct platform_device sdhi0_device = {
438 .name = "sh_mobile_sdhi",
439 .id = 0,
440 .num_resources = ARRAY_SIZE(sdhi0_resources),
441 .resource = sdhi0_resources,
442 .dev = {
443 .platform_data = &sdhi0_info,
444 },
445};
446
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200447/* Fixed 3.3V regulator to be used by SDHI1 */
448static struct regulator_consumer_supply cn4_power_consumers[] =
Magnus Dammfb66c522011-05-23 05:10:36 +0000449{
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200450 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
451 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
452};
453
454static struct regulator_init_data cn4_power_init_data = {
455 .constraints = {
456 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
457 },
458 .num_consumer_supplies = ARRAY_SIZE(cn4_power_consumers),
459 .consumer_supplies = cn4_power_consumers,
460};
461
462static struct fixed_voltage_config cn4_power_info = {
463 .supply_name = "CN4 SD/MMC Vdd",
464 .microvolts = 3300000,
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100465 .gpio = 114,
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200466 .enable_high = 1,
467 .init_data = &cn4_power_init_data,
468};
469
470static struct platform_device cn4_power = {
471 .name = "reg-fixed-voltage",
472 .id = 2,
473 .dev = {
474 .platform_data = &cn4_power_info,
475 },
476};
477
478static void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state)
479{
480 static int power_gpio = -EINVAL;
481
482 if (power_gpio < 0) {
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100483 int ret = gpio_request_one(114, GPIOF_OUT_INIT_LOW,
Laurent Pinchartf3347b72013-01-24 13:16:28 +0100484 "sdhi1_power");
485 if (!ret)
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100486 power_gpio = 114;
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200487 }
488
489 /*
490 * If requesting the GPIO above failed, it means, that the regulator got
491 * probed and grabbed the GPIO, but we don't know, whether the sdhi
492 * driver already uses the regulator. If it doesn't, we have to toggle
493 * the GPIO ourselves, even though it is now owned by the fixed
494 * regulator driver. We have to live with the race in case the driver
495 * gets unloaded and the GPIO freed between these two steps.
496 */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100497 gpio_set_value(114, state);
Magnus Dammfb66c522011-05-23 05:10:36 +0000498}
499
Simon Horman9e05cdd2011-06-20 23:00:11 +0000500static struct sh_mobile_sdhi_info sh_sdhi1_info = {
Simon Hormanc5ad48f2011-06-20 23:00:12 +0000501 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT,
Magnus Damm52942062011-06-09 09:02:25 +0000502 .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ,
Magnus Dammfb66c522011-05-23 05:10:36 +0000503 .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
504 .set_pwr = ag5evm_sdhi1_set_pwr,
505};
506
507static struct resource sdhi1_resources[] = {
508 [0] = {
509 .name = "SDHI1",
510 .start = 0xee120000,
511 .end = 0xee1200ff,
512 .flags = IORESOURCE_MEM,
513 },
514 [1] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900515 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
Magnus Dammfb66c522011-05-23 05:10:36 +0000516 .start = gic_spi(87),
517 .flags = IORESOURCE_IRQ,
518 },
519 [2] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900520 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Magnus Dammfb66c522011-05-23 05:10:36 +0000521 .start = gic_spi(88),
522 .flags = IORESOURCE_IRQ,
523 },
524 [3] = {
Simon Hormancb2ccc32011-08-25 10:27:28 +0900525 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Magnus Dammfb66c522011-05-23 05:10:36 +0000526 .start = gic_spi(89),
527 .flags = IORESOURCE_IRQ,
528 },
529};
530
531static struct platform_device sdhi1_device = {
532 .name = "sh_mobile_sdhi",
533 .id = 1,
534 .dev = {
Simon Horman9e05cdd2011-06-20 23:00:11 +0000535 .platform_data = &sh_sdhi1_info,
Magnus Dammfb66c522011-05-23 05:10:36 +0000536 },
537 .num_resources = ARRAY_SIZE(sdhi1_resources),
538 .resource = sdhi1_resources,
539};
540
Magnus Damm6d9598e2010-11-17 10:59:31 +0000541static struct platform_device *ag5evm_devices[] __initdata = {
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200542 &cn4_power,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000543 &eth_device,
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000544 &keysc_device,
Kuninori Morimoto208c7dc2010-11-29 02:10:08 +0000545 &fsi_device,
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000546 &mmc_device,
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000547 &irda_device,
Magnus Damm170c7ab2011-01-20 08:41:03 +0000548 &mipidsi0_device,
Laurent Pinchart7a4fcf92012-08-13 16:11:32 +0200549 &lcdc0_device,
Magnus Dammfb66c522011-05-23 05:10:36 +0000550 &sdhi0_device,
551 &sdhi1_device,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000552};
553
Laurent Pinchartb5012cd2013-01-03 12:54:28 +0100554static const struct pinctrl_map ag5evm_pinctrl_map[] = {
Laurent Pinchart9723b792013-01-03 12:54:28 +0100555 /* FSIA */
556 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
557 "fsia_mclk_in", "fsia"),
558 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
559 "fsia_sclk_in", "fsia"),
560 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
561 "fsia_data_in", "fsia"),
562 PIN_MAP_MUX_GROUP_DEFAULT("sh_fsi2.0", "pfc-sh73a0",
563 "fsia_data_out", "fsia"),
Laurent Pinchart63d6fc92013-01-03 12:54:28 +0100564 /* I2C2 & I2C3 */
565 PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.2", "pfc-sh73a0",
566 "i2c2_0", "i2c2"),
567 PIN_MAP_MUX_GROUP_DEFAULT("i2c-sh_mobile.3", "pfc-sh73a0",
568 "i2c3_0", "i2c3"),
Laurent Pinchartb5012cd2013-01-03 12:54:28 +0100569 /* SCIFA2 */
570 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-sh73a0",
571 "scifa2_data_0", "scifa2"),
572 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-sh73a0",
573 "scifa2_ctrl_0", "scifa2"),
574};
575
Magnus Damm6d9598e2010-11-17 10:59:31 +0000576static void __init ag5evm_init(void)
577{
Guennadi Liakhovetski6add9692012-06-29 09:32:29 +0200578 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
579 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
580 regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers,
581 ARRAY_SIZE(fixed2v8_power_consumers), 3300000);
582 regulator_register_fixed(3, dummy_supplies, ARRAY_SIZE(dummy_supplies));
583
Laurent Pinchartb5012cd2013-01-03 12:54:28 +0100584 pinctrl_register_mappings(ag5evm_pinctrl_map,
585 ARRAY_SIZE(ag5evm_pinctrl_map));
Takashi YOSHII3256c782010-11-19 16:49:38 +0900586 sh73a0_pinmux_init();
587
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000588 /* enable KEYSC */
Takashi YOSHII5d781472010-12-22 06:30:19 +0000589 gpio_request(GPIO_FN_KEYIN0_PU, NULL);
590 gpio_request(GPIO_FN_KEYIN1_PU, NULL);
591 gpio_request(GPIO_FN_KEYIN2_PU, NULL);
592 gpio_request(GPIO_FN_KEYIN3_PU, NULL);
593 gpio_request(GPIO_FN_KEYIN4_PU, NULL);
594 gpio_request(GPIO_FN_KEYIN5_PU, NULL);
595 gpio_request(GPIO_FN_KEYIN6_PU, NULL);
596 gpio_request(GPIO_FN_KEYIN7_PU, NULL);
Yoshii Takashi2d22d482010-11-19 13:15:46 +0000597 gpio_request(GPIO_FN_KEYOUT0, NULL);
598 gpio_request(GPIO_FN_KEYOUT1, NULL);
599 gpio_request(GPIO_FN_KEYOUT2, NULL);
600 gpio_request(GPIO_FN_KEYOUT3, NULL);
601 gpio_request(GPIO_FN_KEYOUT4, NULL);
602 gpio_request(GPIO_FN_KEYOUT5, NULL);
603 gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL);
604 gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL);
605 gpio_request(GPIO_FN_KEYOUT8, NULL);
606 gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL);
607
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000608 /* enable MMCIF */
609 gpio_request(GPIO_FN_MMCCLK0, NULL);
610 gpio_request(GPIO_FN_MMCCMD0_PU, NULL);
Kuninori Morimoto052008e2011-11-10 18:44:24 -0800611 gpio_request(GPIO_FN_MMCD0_0_PU, NULL);
612 gpio_request(GPIO_FN_MMCD0_1_PU, NULL);
613 gpio_request(GPIO_FN_MMCD0_2_PU, NULL);
614 gpio_request(GPIO_FN_MMCD0_3_PU, NULL);
615 gpio_request(GPIO_FN_MMCD0_4_PU, NULL);
616 gpio_request(GPIO_FN_MMCD0_5_PU, NULL);
617 gpio_request(GPIO_FN_MMCD0_6_PU, NULL);
618 gpio_request(GPIO_FN_MMCD0_7_PU, NULL);
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100619 gpio_request_one(208, GPIOF_OUT_INIT_HIGH, NULL); /* Reset */
Takashi YOSHII6bf45a12010-12-22 06:35:30 +0000620
Magnus Damm6d9598e2010-11-17 10:59:31 +0000621 /* enable SMSC911X */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100622 gpio_request_one(144, GPIOF_IN, NULL); /* PINTA2 */
623 gpio_request_one(145, GPIOF_OUT_INIT_HIGH, NULL); /* RESET */
Magnus Damm6d9598e2010-11-17 10:59:31 +0000624
Kuninori Morimotoa33bb8a2011-01-14 11:00:41 +0000625 /* IrDA */
626 gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL);
627 gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL);
628 gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL);
629
Magnus Damm170c7ab2011-01-20 08:41:03 +0000630 /* LCD panel */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100631 gpio_request_one(217, GPIOF_OUT_INIT_LOW, NULL); /* RESET */
Magnus Damm170c7ab2011-01-20 08:41:03 +0000632 mdelay(1);
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100633 gpio_set_value(217, 1);
Magnus Dammf55398a2011-01-28 09:59:17 +0000634 mdelay(100);
Magnus Damm170c7ab2011-01-20 08:41:03 +0000635
636 /* LCD backlight controller */
Guennadi Liakhovetskib58e5fa2013-02-12 16:50:02 +0100637 gpio_request_one(235, GPIOF_OUT_INIT_LOW, NULL); /* RESET */
Laurent Pinchart37f4dd12012-08-15 18:25:27 +0200638 lcd_backlight_set_brightness(0);
Magnus Damm170c7ab2011-01-20 08:41:03 +0000639
Magnus Dammfb66c522011-05-23 05:10:36 +0000640 /* enable SDHI0 on CN15 [SD I/F] */
Magnus Dammfb66c522011-05-23 05:10:36 +0000641 gpio_request(GPIO_FN_SDHIWP0, NULL);
642 gpio_request(GPIO_FN_SDHICMD0, NULL);
643 gpio_request(GPIO_FN_SDHICLK0, NULL);
644 gpio_request(GPIO_FN_SDHID0_3, NULL);
645 gpio_request(GPIO_FN_SDHID0_2, NULL);
646 gpio_request(GPIO_FN_SDHID0_1, NULL);
647 gpio_request(GPIO_FN_SDHID0_0, NULL);
648
649 /* enable SDHI1 on CN4 [WLAN I/F] */
650 gpio_request(GPIO_FN_SDHICLK1, NULL);
651 gpio_request(GPIO_FN_SDHICMD1_PU, NULL);
652 gpio_request(GPIO_FN_SDHID1_3_PU, NULL);
653 gpio_request(GPIO_FN_SDHID1_2_PU, NULL);
654 gpio_request(GPIO_FN_SDHID1_1_PU, NULL);
655 gpio_request(GPIO_FN_SDHID1_0_PU, NULL);
Magnus Dammfb66c522011-05-23 05:10:36 +0000656
Magnus Damm6d9598e2010-11-17 10:59:31 +0000657#ifdef CONFIG_CACHE_L2X0
658 /* Shared attribute override enable, 64K*8way */
Rob Herringa2a47ca2012-03-09 17:16:40 -0600659 l2x0_init(IOMEM(0xf0100000), 0x00460000, 0xc2000fff);
Magnus Damm6d9598e2010-11-17 10:59:31 +0000660#endif
661 sh73a0_add_standard_devices();
662 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
663}
664
Magnus Damm6d9598e2010-11-17 10:59:31 +0000665MACHINE_START(AG5EVM, "ag5evm")
Marc Zyngiera62580e2011-09-08 13:15:22 +0100666 .smp = smp_ops(sh73a0_smp_ops),
Magnus Damm50e15c32012-02-29 21:37:27 +0900667 .map_io = sh73a0_map_io,
668 .init_early = sh73a0_add_early_devices,
Magnus Dammeded9142011-11-22 15:31:40 +0900669 .nr_irqs = NR_IRQS_LEGACY,
Magnus Damm566aad32011-10-17 18:00:52 +0900670 .init_irq = sh73a0_init_irq,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000671 .init_machine = ag5evm_init,
Shawn Guo21cc1b72012-04-26 21:58:41 +0800672 .init_late = shmobile_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700673 .init_time = sh73a0_earlytimer_init,
Magnus Damm6d9598e2010-11-17 10:59:31 +0000674MACHINE_END