Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 1 | /* |
| 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 Gortmaker | 04f47a0 | 2012-01-22 14:57:25 -0500 | [diff] [blame] | 33 | #include <linux/videodev2.h> |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 34 | #include <linux/input.h> |
| 35 | #include <linux/input/sh_keysc.h> |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 36 | #include <linux/mmc/host.h> |
| 37 | #include <linux/mmc/sh_mmcif.h> |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 38 | #include <linux/mmc/sh_mobile_sdhi.h> |
| 39 | #include <linux/mfd/tmio.h> |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 40 | #include <linux/sh_clk.h> |
| 41 | #include <video/sh_mobile_lcdc.h> |
| 42 | #include <video/sh_mipi_dsi.h> |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 43 | #include <sound/sh_fsi.h> |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 44 | #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 | |
| 55 | static struct resource smsc9220_resources[] = { |
| 56 | [0] = { |
| 57 | .start = 0x14000000, |
| 58 | .end = 0x14000000 + SZ_64K - 1, |
| 59 | .flags = IORESOURCE_MEM, |
| 60 | }, |
| 61 | [1] = { |
Magnus Damm | 566aad3 | 2011-10-17 18:00:52 +0900 | [diff] [blame] | 62 | .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 63 | .flags = IORESOURCE_IRQ, |
| 64 | }, |
| 65 | }; |
| 66 | |
| 67 | static 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 | |
| 74 | static 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 Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 84 | static 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 | |
| 101 | static 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 | |
| 114 | static 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 Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 124 | /* FSI A */ |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 125 | static 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 | |
| 138 | static struct platform_device fsi_device = { |
| 139 | .name = "sh_fsi2", |
| 140 | .id = -1, |
| 141 | .num_resources = ARRAY_SIZE(fsi_resources), |
| 142 | .resource = fsi_resources, |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 143 | }; |
| 144 | |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 145 | static 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 | |
| 162 | static 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 Liakhovetski | d5bb386 | 2011-08-30 18:26:44 +0200 | [diff] [blame] | 166 | .slave_id_tx = SHDMA_SLAVE_MMCIF_TX, |
| 167 | .slave_id_rx = SHDMA_SLAVE_MMCIF_RX, |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 168 | }; |
| 169 | |
| 170 | static 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 Morimoto | a33bb8a | 2011-01-14 11:00:41 +0000 | [diff] [blame] | 182 | /* IrDA */ |
| 183 | static 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 | |
| 195 | static 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 Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 202 | static unsigned char lcd_backlight_seq[3][2] = { |
| 203 | { 0x04, 0x07 }, |
| 204 | { 0x23, 0x80 }, |
| 205 | { 0x03, 0x01 }, |
| 206 | }; |
| 207 | |
| 208 | static 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 | |
| 225 | static 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 | |
| 232 | static void lcd_on(void *board_data, struct fb_info *info) |
| 233 | { |
| 234 | lcd_backlight_on(); |
| 235 | } |
| 236 | |
| 237 | static void lcd_off(void *board_data) |
| 238 | { |
| 239 | lcd_backlight_reset(); |
| 240 | } |
| 241 | |
| 242 | /* LCDC0 */ |
| 243 | static 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 | |
| 258 | static 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 Pinchart | edd153a | 2011-12-13 14:02:28 +0100 | [diff] [blame] | 267 | .fourcc = V4L2_PIX_FMT_RGB565, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 268 | .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 | |
| 277 | static 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 | |
| 290 | static 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 */ |
| 302 | static struct resource mipidsi0_resources[] = { |
| 303 | [0] = { |
Magnus Damm | 6b36fdd | 2011-05-19 06:30:59 +0000 | [diff] [blame] | 304 | .name = "DSI0", |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 305 | .start = 0xfeab0000, |
| 306 | .end = 0xfeab3fff, |
| 307 | .flags = IORESOURCE_MEM, |
| 308 | }, |
| 309 | [1] = { |
Magnus Damm | 6b36fdd | 2011-05-19 06:30:59 +0000 | [diff] [blame] | 310 | .name = "DSI0", |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 311 | .start = 0xfeab4000, |
| 312 | .end = 0xfeab7fff, |
| 313 | .flags = IORESOURCE_MEM, |
| 314 | }, |
| 315 | }; |
| 316 | |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 317 | static int sh_mipi_set_dot_clock(struct platform_device *pdev, |
| 318 | void __iomem *base, |
| 319 | int enable) |
| 320 | { |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 321 | struct clk *pck, *phy; |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 322 | 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 Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 330 | 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 Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 336 | if (enable) { |
| 337 | clk_set_rate(pck, clk_round_rate(pck, 24000000)); |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 338 | clk_set_rate(phy, clk_round_rate(pck, 510000000)); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 339 | clk_enable(pck); |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 340 | clk_enable(phy); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 341 | } else { |
| 342 | clk_disable(pck); |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 343 | clk_disable(phy); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | ret = 0; |
| 347 | |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 348 | clk_put(phy); |
| 349 | sh_mipi_set_dot_clock_phy_err: |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 350 | clk_put(pck); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 351 | sh_mipi_set_dot_clock_pck_err: |
| 352 | return ret; |
| 353 | } |
| 354 | |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 355 | static struct sh_mipi_dsi_info mipidsi0_info = { |
| 356 | .data_format = MIPI_RGB888, |
| 357 | .lcd_chan = &lcdc0_info.ch[0], |
Kuninori Morimoto | 26c3d7a | 2011-11-08 20:34:43 -0800 | [diff] [blame] | 358 | .lane = 2, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 359 | .vsynw_offset = 20, |
| 360 | .clksrc = 1, |
Kuninori Morimoto | a2e6297 | 2011-11-08 20:35:27 -0800 | [diff] [blame] | 361 | .flags = SH_MIPI_DSI_HSABM | |
| 362 | SH_MIPI_DSI_SYNC_PULSES_MODE | |
| 363 | SH_MIPI_DSI_HSbyteCLK, |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 364 | .set_dot_clock = sh_mipi_set_dot_clock, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 365 | }; |
| 366 | |
| 367 | static 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 Damm | 3087b90 | 2011-10-12 16:21:50 +0900 | [diff] [blame] | 377 | /* SDHI0 */ |
| 378 | static 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 Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 389 | static struct sh_mobile_sdhi_info sdhi0_info = { |
Magnus Damm | 6820e69 | 2011-05-24 10:42:15 +0000 | [diff] [blame] | 390 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, |
| 391 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, |
Simon Horman | c5ad48f | 2011-06-20 23:00:12 +0000 | [diff] [blame] | 392 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 393 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, |
| 394 | .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 395 | }; |
| 396 | |
| 397 | static struct resource sdhi0_resources[] = { |
| 398 | [0] = { |
| 399 | .name = "SDHI0", |
| 400 | .start = 0xee100000, |
| 401 | .end = 0xee1000ff, |
| 402 | .flags = IORESOURCE_MEM, |
| 403 | }, |
| 404 | [1] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 405 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 406 | .start = gic_spi(83), |
| 407 | .flags = IORESOURCE_IRQ, |
| 408 | }, |
| 409 | [2] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 410 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 411 | .start = gic_spi(84), |
| 412 | .flags = IORESOURCE_IRQ, |
| 413 | }, |
| 414 | [3] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 415 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 416 | .start = gic_spi(85), |
| 417 | .flags = IORESOURCE_IRQ, |
| 418 | }, |
| 419 | }; |
| 420 | |
| 421 | static 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 | |
| 431 | void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state) |
| 432 | { |
| 433 | gpio_set_value(GPIO_PORT114, state); |
| 434 | } |
| 435 | |
Simon Horman | 9e05cdd | 2011-06-20 23:00:11 +0000 | [diff] [blame] | 436 | static struct sh_mobile_sdhi_info sh_sdhi1_info = { |
Simon Horman | c5ad48f | 2011-06-20 23:00:12 +0000 | [diff] [blame] | 437 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT, |
Magnus Damm | 5294206 | 2011-06-09 09:02:25 +0000 | [diff] [blame] | 438 | .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 439 | .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 440 | .set_pwr = ag5evm_sdhi1_set_pwr, |
| 441 | }; |
| 442 | |
| 443 | static struct resource sdhi1_resources[] = { |
| 444 | [0] = { |
| 445 | .name = "SDHI1", |
| 446 | .start = 0xee120000, |
| 447 | .end = 0xee1200ff, |
| 448 | .flags = IORESOURCE_MEM, |
| 449 | }, |
| 450 | [1] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 451 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 452 | .start = gic_spi(87), |
| 453 | .flags = IORESOURCE_IRQ, |
| 454 | }, |
| 455 | [2] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 456 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 457 | .start = gic_spi(88), |
| 458 | .flags = IORESOURCE_IRQ, |
| 459 | }, |
| 460 | [3] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 461 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 462 | .start = gic_spi(89), |
| 463 | .flags = IORESOURCE_IRQ, |
| 464 | }, |
| 465 | }; |
| 466 | |
| 467 | static struct platform_device sdhi1_device = { |
| 468 | .name = "sh_mobile_sdhi", |
| 469 | .id = 1, |
| 470 | .dev = { |
Simon Horman | 9e05cdd | 2011-06-20 23:00:11 +0000 | [diff] [blame] | 471 | .platform_data = &sh_sdhi1_info, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 472 | }, |
| 473 | .num_resources = ARRAY_SIZE(sdhi1_resources), |
| 474 | .resource = sdhi1_resources, |
| 475 | }; |
| 476 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 477 | static struct platform_device *ag5evm_devices[] __initdata = { |
| 478 | ð_device, |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 479 | &keysc_device, |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 480 | &fsi_device, |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 481 | &mmc_device, |
Kuninori Morimoto | a33bb8a | 2011-01-14 11:00:41 +0000 | [diff] [blame] | 482 | &irda_device, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 483 | &lcdc0_device, |
| 484 | &mipidsi0_device, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 485 | &sdhi0_device, |
| 486 | &sdhi1_device, |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 487 | }; |
| 488 | |
| 489 | static 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 | |
| 501 | static 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 Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 510 | static void __init ag5evm_init(void) |
| 511 | { |
Takashi YOSHII | 3256c789 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 512 | sh73a0_pinmux_init(); |
| 513 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 514 | /* enable SCIFA2 */ |
Takashi YOSHII | 3256c789 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 515 | 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 Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 519 | |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 520 | /* enable KEYSC */ |
Takashi YOSHII | 5d78147 | 2010-12-22 06:30:19 +0000 | [diff] [blame] | 521 | 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 Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 529 | 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 YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 540 | /* enable I2C channel 2 and 3 */ |
Yoshii Takashi | 8e67b22 | 2010-11-19 13:21:32 +0000 | [diff] [blame] | 541 | 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 YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 546 | /* enable MMCIF */ |
| 547 | gpio_request(GPIO_FN_MMCCLK0, NULL); |
| 548 | gpio_request(GPIO_FN_MMCCMD0_PU, NULL); |
Kuninori Morimoto | 052008e | 2011-11-10 18:44:24 -0800 | [diff] [blame] | 549 | 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 YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 557 | gpio_request(GPIO_PORT208, NULL); /* Reset */ |
| 558 | gpio_direction_output(GPIO_PORT208, 1); |
| 559 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 560 | /* enable SMSC911X */ |
Takashi YOSHII | 3256c789 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 561 | 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 Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 565 | |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 566 | /* 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 Morimoto | a33bb8a | 2011-01-14 11:00:41 +0000 | [diff] [blame] | 573 | /* 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 Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 578 | /* 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 Damm | f55398a | 2011-01-28 09:59:17 +0000 | [diff] [blame] | 583 | mdelay(100); |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 584 | |
| 585 | /* LCD backlight controller */ |
| 586 | gpio_request(GPIO_PORT235, NULL); /* RESET */ |
| 587 | gpio_direction_output(GPIO_PORT235, 0); |
| 588 | lcd_backlight_reset(); |
| 589 | |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 590 | /* 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 Damm | 3087b90 | 2011-10-12 16:21:50 +0900 | [diff] [blame] | 600 | 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 Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 607 | /* 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 Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 617 | #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 | |
| 625 | static void __init ag5evm_timer_init(void) |
| 626 | { |
| 627 | sh73a0_clock_init(); |
| 628 | shmobile_timer.init(); |
| 629 | return; |
| 630 | } |
| 631 | |
| 632 | struct sys_timer ag5evm_timer = { |
| 633 | .init = ag5evm_timer_init, |
| 634 | }; |
| 635 | |
| 636 | MACHINE_START(AG5EVM, "ag5evm") |
| 637 | .map_io = ag5evm_map_io, |
Magnus Damm | eded914 | 2011-11-22 15:31:40 +0900 | [diff] [blame] | 638 | .nr_irqs = NR_IRQS_LEGACY, |
Magnus Damm | 566aad3 | 2011-10-17 18:00:52 +0900 | [diff] [blame] | 639 | .init_irq = sh73a0_init_irq, |
Marc Zyngier | a83d8e2 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 640 | .handle_irq = gic_handle_irq, |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 641 | .init_machine = ag5evm_init, |
| 642 | .timer = &ag5evm_timer, |
| 643 | MACHINE_END |