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> |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 30 | #include <linux/regulator/fixed.h> |
| 31 | #include <linux/regulator/machine.h> |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 32 | #include <linux/serial_sci.h> |
| 33 | #include <linux/smsc911x.h> |
| 34 | #include <linux/gpio.h> |
Paul Gortmaker | 04f47a0 | 2012-01-22 14:57:25 -0500 | [diff] [blame] | 35 | #include <linux/videodev2.h> |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 36 | #include <linux/input.h> |
| 37 | #include <linux/input/sh_keysc.h> |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 38 | #include <linux/mmc/host.h> |
| 39 | #include <linux/mmc/sh_mmcif.h> |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 40 | #include <linux/mmc/sh_mobile_sdhi.h> |
| 41 | #include <linux/mfd/tmio.h> |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 42 | #include <linux/sh_clk.h> |
| 43 | #include <video/sh_mobile_lcdc.h> |
| 44 | #include <video/sh_mipi_dsi.h> |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 45 | #include <sound/sh_fsi.h> |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 46 | #include <mach/hardware.h> |
Rob Herring | 250a272 | 2012-01-03 16:57:33 -0600 | [diff] [blame] | 47 | #include <mach/irqs.h> |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 48 | #include <mach/sh73a0.h> |
| 49 | #include <mach/common.h> |
| 50 | #include <asm/mach-types.h> |
| 51 | #include <asm/mach/arch.h> |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 52 | #include <asm/hardware/gic.h> |
| 53 | #include <asm/hardware/cache-l2x0.h> |
| 54 | #include <asm/traps.h> |
| 55 | |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 56 | /* Dummy supplies, where voltage doesn't matter */ |
| 57 | static struct regulator_consumer_supply dummy_supplies[] = { |
| 58 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 59 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 60 | }; |
| 61 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 62 | static struct resource smsc9220_resources[] = { |
| 63 | [0] = { |
| 64 | .start = 0x14000000, |
| 65 | .end = 0x14000000 + SZ_64K - 1, |
| 66 | .flags = IORESOURCE_MEM, |
| 67 | }, |
| 68 | [1] = { |
Magnus Damm | 566aad3 | 2011-10-17 18:00:52 +0900 | [diff] [blame] | 69 | .start = SH73A0_PINT0_IRQ(2), /* PINTA2 */ |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 70 | .flags = IORESOURCE_IRQ, |
| 71 | }, |
| 72 | }; |
| 73 | |
| 74 | static struct smsc911x_platform_config smsc9220_platdata = { |
| 75 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 76 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 77 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 78 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 79 | }; |
| 80 | |
| 81 | static struct platform_device eth_device = { |
| 82 | .name = "smsc911x", |
| 83 | .id = 0, |
| 84 | .dev = { |
| 85 | .platform_data = &smsc9220_platdata, |
| 86 | }, |
| 87 | .resource = smsc9220_resources, |
| 88 | .num_resources = ARRAY_SIZE(smsc9220_resources), |
| 89 | }; |
| 90 | |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 91 | static struct sh_keysc_info keysc_platdata = { |
| 92 | .mode = SH_KEYSC_MODE_6, |
| 93 | .scan_timing = 3, |
| 94 | .delay = 100, |
| 95 | .keycodes = { |
| 96 | KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, |
| 97 | KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, |
| 98 | KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, |
| 99 | KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP, |
| 100 | KEY_SPACE, KEY_9, KEY_6, KEY_3, KEY_WAKEUP, KEY_RIGHT, \ |
| 101 | KEY_COFFEE, |
| 102 | KEY_0, KEY_8, KEY_5, KEY_2, KEY_DOWN, KEY_ENTER, KEY_UP, |
| 103 | KEY_KPASTERISK, KEY_7, KEY_4, KEY_1, KEY_STOP, KEY_LEFT, \ |
| 104 | KEY_COMPUTER, |
| 105 | }, |
| 106 | }; |
| 107 | |
| 108 | static struct resource keysc_resources[] = { |
| 109 | [0] = { |
| 110 | .name = "KEYSC", |
| 111 | .start = 0xe61b0000, |
| 112 | .end = 0xe61b0098 - 1, |
| 113 | .flags = IORESOURCE_MEM, |
| 114 | }, |
| 115 | [1] = { |
| 116 | .start = gic_spi(71), |
| 117 | .flags = IORESOURCE_IRQ, |
| 118 | }, |
| 119 | }; |
| 120 | |
| 121 | static struct platform_device keysc_device = { |
| 122 | .name = "sh_keysc", |
| 123 | .id = 0, |
| 124 | .num_resources = ARRAY_SIZE(keysc_resources), |
| 125 | .resource = keysc_resources, |
| 126 | .dev = { |
| 127 | .platform_data = &keysc_platdata, |
| 128 | }, |
| 129 | }; |
| 130 | |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 131 | /* FSI A */ |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 132 | static struct resource fsi_resources[] = { |
| 133 | [0] = { |
| 134 | .name = "FSI", |
| 135 | .start = 0xEC230000, |
| 136 | .end = 0xEC230400 - 1, |
| 137 | .flags = IORESOURCE_MEM, |
| 138 | }, |
| 139 | [1] = { |
| 140 | .start = gic_spi(146), |
| 141 | .flags = IORESOURCE_IRQ, |
| 142 | }, |
| 143 | }; |
| 144 | |
| 145 | static struct platform_device fsi_device = { |
| 146 | .name = "sh_fsi2", |
| 147 | .id = -1, |
| 148 | .num_resources = ARRAY_SIZE(fsi_resources), |
| 149 | .resource = fsi_resources, |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 150 | }; |
| 151 | |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 152 | /* Fixed 1.8V regulator to be used by MMCIF */ |
| 153 | static struct regulator_consumer_supply fixed1v8_power_consumers[] = |
| 154 | { |
| 155 | REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"), |
| 156 | REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"), |
| 157 | }; |
| 158 | |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 159 | static struct resource sh_mmcif_resources[] = { |
| 160 | [0] = { |
| 161 | .name = "MMCIF", |
| 162 | .start = 0xe6bd0000, |
| 163 | .end = 0xe6bd00ff, |
| 164 | .flags = IORESOURCE_MEM, |
| 165 | }, |
| 166 | [1] = { |
| 167 | .start = gic_spi(141), |
| 168 | .flags = IORESOURCE_IRQ, |
| 169 | }, |
| 170 | [2] = { |
| 171 | .start = gic_spi(140), |
| 172 | .flags = IORESOURCE_IRQ, |
| 173 | }, |
| 174 | }; |
| 175 | |
| 176 | static struct sh_mmcif_plat_data sh_mmcif_platdata = { |
| 177 | .sup_pclk = 0, |
| 178 | .ocr = MMC_VDD_165_195, |
| 179 | .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, |
Guennadi Liakhovetski | d5bb386 | 2011-08-30 18:26:44 +0200 | [diff] [blame] | 180 | .slave_id_tx = SHDMA_SLAVE_MMCIF_TX, |
| 181 | .slave_id_rx = SHDMA_SLAVE_MMCIF_RX, |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 182 | }; |
| 183 | |
| 184 | static struct platform_device mmc_device = { |
| 185 | .name = "sh_mmcif", |
| 186 | .id = 0, |
| 187 | .dev = { |
| 188 | .dma_mask = NULL, |
| 189 | .coherent_dma_mask = 0xffffffff, |
| 190 | .platform_data = &sh_mmcif_platdata, |
| 191 | }, |
| 192 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), |
| 193 | .resource = sh_mmcif_resources, |
| 194 | }; |
| 195 | |
Kuninori Morimoto | a33bb8a | 2011-01-14 11:00:41 +0000 | [diff] [blame] | 196 | /* IrDA */ |
| 197 | static struct resource irda_resources[] = { |
| 198 | [0] = { |
| 199 | .start = 0xE6D00000, |
| 200 | .end = 0xE6D01FD4 - 1, |
| 201 | .flags = IORESOURCE_MEM, |
| 202 | }, |
| 203 | [1] = { |
| 204 | .start = gic_spi(95), |
| 205 | .flags = IORESOURCE_IRQ, |
| 206 | }, |
| 207 | }; |
| 208 | |
| 209 | static struct platform_device irda_device = { |
| 210 | .name = "sh_irda", |
| 211 | .id = 0, |
| 212 | .resource = irda_resources, |
| 213 | .num_resources = ARRAY_SIZE(irda_resources), |
| 214 | }; |
| 215 | |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 216 | static unsigned char lcd_backlight_seq[3][2] = { |
| 217 | { 0x04, 0x07 }, |
| 218 | { 0x23, 0x80 }, |
| 219 | { 0x03, 0x01 }, |
| 220 | }; |
| 221 | |
| 222 | static void lcd_backlight_on(void) |
| 223 | { |
| 224 | struct i2c_adapter *a; |
| 225 | struct i2c_msg msg; |
| 226 | int k; |
| 227 | |
| 228 | a = i2c_get_adapter(1); |
| 229 | for (k = 0; a && k < 3; k++) { |
| 230 | msg.addr = 0x6d; |
| 231 | msg.buf = &lcd_backlight_seq[k][0]; |
| 232 | msg.len = 2; |
| 233 | msg.flags = 0; |
| 234 | if (i2c_transfer(a, &msg, 1) != 1) |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | static void lcd_backlight_reset(void) |
| 240 | { |
| 241 | gpio_set_value(GPIO_PORT235, 0); |
| 242 | mdelay(24); |
| 243 | gpio_set_value(GPIO_PORT235, 1); |
| 244 | } |
| 245 | |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 246 | /* LCDC0 */ |
| 247 | static const struct fb_videomode lcdc0_modes[] = { |
| 248 | { |
| 249 | .name = "R63302(QHD)", |
| 250 | .xres = 544, |
| 251 | .yres = 961, |
| 252 | .left_margin = 72, |
| 253 | .right_margin = 600, |
| 254 | .hsync_len = 16, |
| 255 | .upper_margin = 8, |
| 256 | .lower_margin = 8, |
| 257 | .vsync_len = 2, |
| 258 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT, |
| 259 | }, |
| 260 | }; |
| 261 | |
| 262 | static struct sh_mobile_lcdc_info lcdc0_info = { |
| 263 | .clock_source = LCDC_CLK_PERIPHERAL, |
| 264 | .ch[0] = { |
| 265 | .chan = LCDC_CHAN_MAINLCD, |
| 266 | .interface_type = RGB24, |
| 267 | .clock_divider = 1, |
| 268 | .flags = LCDC_FLAGS_DWPOL, |
Laurent Pinchart | edd153a | 2011-12-13 14:02:28 +0100 | [diff] [blame] | 269 | .fourcc = V4L2_PIX_FMT_RGB565, |
Laurent Pinchart | 93ff259 | 2011-11-29 14:33:41 +0100 | [diff] [blame] | 270 | .lcd_modes = lcdc0_modes, |
| 271 | .num_modes = ARRAY_SIZE(lcdc0_modes), |
Laurent Pinchart | afaad83 | 2011-09-11 22:59:04 +0200 | [diff] [blame] | 272 | .panel_cfg = { |
| 273 | .width = 44, |
| 274 | .height = 79, |
Laurent Pinchart | 018882a | 2011-09-11 22:59:04 +0200 | [diff] [blame] | 275 | .display_on = lcd_backlight_on, |
| 276 | .display_off = lcd_backlight_reset, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 277 | }, |
| 278 | } |
| 279 | }; |
| 280 | |
| 281 | static struct resource lcdc0_resources[] = { |
| 282 | [0] = { |
| 283 | .name = "LCDC0", |
| 284 | .start = 0xfe940000, /* P4-only space */ |
| 285 | .end = 0xfe943fff, |
| 286 | .flags = IORESOURCE_MEM, |
| 287 | }, |
| 288 | [1] = { |
| 289 | .start = intcs_evt2irq(0x580), |
| 290 | .flags = IORESOURCE_IRQ, |
| 291 | }, |
| 292 | }; |
| 293 | |
| 294 | static struct platform_device lcdc0_device = { |
| 295 | .name = "sh_mobile_lcdc_fb", |
| 296 | .num_resources = ARRAY_SIZE(lcdc0_resources), |
| 297 | .resource = lcdc0_resources, |
| 298 | .id = 0, |
| 299 | .dev = { |
| 300 | .platform_data = &lcdc0_info, |
| 301 | .coherent_dma_mask = ~0, |
| 302 | }, |
| 303 | }; |
| 304 | |
| 305 | /* MIPI-DSI */ |
| 306 | static struct resource mipidsi0_resources[] = { |
| 307 | [0] = { |
Magnus Damm | 6b36fdd | 2011-05-19 06:30:59 +0000 | [diff] [blame] | 308 | .name = "DSI0", |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 309 | .start = 0xfeab0000, |
| 310 | .end = 0xfeab3fff, |
| 311 | .flags = IORESOURCE_MEM, |
| 312 | }, |
| 313 | [1] = { |
Magnus Damm | 6b36fdd | 2011-05-19 06:30:59 +0000 | [diff] [blame] | 314 | .name = "DSI0", |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 315 | .start = 0xfeab4000, |
| 316 | .end = 0xfeab7fff, |
| 317 | .flags = IORESOURCE_MEM, |
| 318 | }, |
| 319 | }; |
| 320 | |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 321 | static int sh_mipi_set_dot_clock(struct platform_device *pdev, |
| 322 | void __iomem *base, |
| 323 | int enable) |
| 324 | { |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 325 | struct clk *pck, *phy; |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 326 | int ret; |
| 327 | |
| 328 | pck = clk_get(&pdev->dev, "dsip_clk"); |
| 329 | if (IS_ERR(pck)) { |
| 330 | ret = PTR_ERR(pck); |
| 331 | goto sh_mipi_set_dot_clock_pck_err; |
| 332 | } |
| 333 | |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 334 | phy = clk_get(&pdev->dev, "dsiphy_clk"); |
| 335 | if (IS_ERR(phy)) { |
| 336 | ret = PTR_ERR(phy); |
| 337 | goto sh_mipi_set_dot_clock_phy_err; |
| 338 | } |
| 339 | |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 340 | if (enable) { |
| 341 | clk_set_rate(pck, clk_round_rate(pck, 24000000)); |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 342 | clk_set_rate(phy, clk_round_rate(pck, 510000000)); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 343 | clk_enable(pck); |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 344 | clk_enable(phy); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 345 | } else { |
| 346 | clk_disable(pck); |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 347 | clk_disable(phy); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | ret = 0; |
| 351 | |
Kuninori Morimoto | f5948ba | 2012-01-22 21:10:02 -0800 | [diff] [blame] | 352 | clk_put(phy); |
| 353 | sh_mipi_set_dot_clock_phy_err: |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 354 | clk_put(pck); |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 355 | sh_mipi_set_dot_clock_pck_err: |
| 356 | return ret; |
| 357 | } |
| 358 | |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 359 | static struct sh_mipi_dsi_info mipidsi0_info = { |
| 360 | .data_format = MIPI_RGB888, |
| 361 | .lcd_chan = &lcdc0_info.ch[0], |
Kuninori Morimoto | 26c3d7a | 2011-11-08 20:34:43 -0800 | [diff] [blame] | 362 | .lane = 2, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 363 | .vsynw_offset = 20, |
| 364 | .clksrc = 1, |
Kuninori Morimoto | a2e6297 | 2011-11-08 20:35:27 -0800 | [diff] [blame] | 365 | .flags = SH_MIPI_DSI_HSABM | |
| 366 | SH_MIPI_DSI_SYNC_PULSES_MODE | |
| 367 | SH_MIPI_DSI_HSbyteCLK, |
Kuninori Morimoto | 5e47431 | 2011-11-08 20:35:14 -0800 | [diff] [blame] | 368 | .set_dot_clock = sh_mipi_set_dot_clock, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 369 | }; |
| 370 | |
| 371 | static struct platform_device mipidsi0_device = { |
| 372 | .name = "sh-mipi-dsi", |
| 373 | .num_resources = ARRAY_SIZE(mipidsi0_resources), |
| 374 | .resource = mipidsi0_resources, |
| 375 | .id = 0, |
| 376 | .dev = { |
| 377 | .platform_data = &mipidsi0_info, |
| 378 | }, |
| 379 | }; |
| 380 | |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 381 | /* Fixed 2.8V regulators to be used by SDHI0 */ |
| 382 | static struct regulator_consumer_supply fixed2v8_power_consumers[] = |
| 383 | { |
| 384 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"), |
| 385 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"), |
| 386 | }; |
| 387 | |
Magnus Damm | 3087b90 | 2011-10-12 16:21:50 +0900 | [diff] [blame] | 388 | /* SDHI0 */ |
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, |
Guennadi Liakhovetski | 173e2fe | 2012-04-16 23:09:19 +0200 | [diff] [blame] | 392 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_USE_GPIO_CD, |
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, |
Guennadi Liakhovetski | 173e2fe | 2012-04-16 23:09:19 +0200 | [diff] [blame] | 395 | .cd_gpio = GPIO_PORT251, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 396 | }; |
| 397 | |
| 398 | static struct resource sdhi0_resources[] = { |
| 399 | [0] = { |
| 400 | .name = "SDHI0", |
| 401 | .start = 0xee100000, |
| 402 | .end = 0xee1000ff, |
| 403 | .flags = IORESOURCE_MEM, |
| 404 | }, |
| 405 | [1] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 406 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 407 | .start = gic_spi(83), |
| 408 | .flags = IORESOURCE_IRQ, |
| 409 | }, |
| 410 | [2] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 411 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 412 | .start = gic_spi(84), |
| 413 | .flags = IORESOURCE_IRQ, |
| 414 | }, |
| 415 | [3] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 416 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 417 | .start = gic_spi(85), |
| 418 | .flags = IORESOURCE_IRQ, |
| 419 | }, |
| 420 | }; |
| 421 | |
| 422 | static struct platform_device sdhi0_device = { |
| 423 | .name = "sh_mobile_sdhi", |
| 424 | .id = 0, |
| 425 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 426 | .resource = sdhi0_resources, |
| 427 | .dev = { |
| 428 | .platform_data = &sdhi0_info, |
| 429 | }, |
| 430 | }; |
| 431 | |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 432 | /* Fixed 3.3V regulator to be used by SDHI1 */ |
| 433 | static struct regulator_consumer_supply cn4_power_consumers[] = |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 434 | { |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 435 | REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"), |
| 436 | REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"), |
| 437 | }; |
| 438 | |
| 439 | static struct regulator_init_data cn4_power_init_data = { |
| 440 | .constraints = { |
| 441 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, |
| 442 | }, |
| 443 | .num_consumer_supplies = ARRAY_SIZE(cn4_power_consumers), |
| 444 | .consumer_supplies = cn4_power_consumers, |
| 445 | }; |
| 446 | |
| 447 | static struct fixed_voltage_config cn4_power_info = { |
| 448 | .supply_name = "CN4 SD/MMC Vdd", |
| 449 | .microvolts = 3300000, |
| 450 | .gpio = GPIO_PORT114, |
| 451 | .enable_high = 1, |
| 452 | .init_data = &cn4_power_init_data, |
| 453 | }; |
| 454 | |
| 455 | static struct platform_device cn4_power = { |
| 456 | .name = "reg-fixed-voltage", |
| 457 | .id = 2, |
| 458 | .dev = { |
| 459 | .platform_data = &cn4_power_info, |
| 460 | }, |
| 461 | }; |
| 462 | |
| 463 | static void ag5evm_sdhi1_set_pwr(struct platform_device *pdev, int state) |
| 464 | { |
| 465 | static int power_gpio = -EINVAL; |
| 466 | |
| 467 | if (power_gpio < 0) { |
| 468 | int ret = gpio_request(GPIO_PORT114, "sdhi1_power"); |
| 469 | if (!ret) { |
| 470 | power_gpio = GPIO_PORT114; |
| 471 | gpio_direction_output(power_gpio, 0); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | /* |
| 476 | * If requesting the GPIO above failed, it means, that the regulator got |
| 477 | * probed and grabbed the GPIO, but we don't know, whether the sdhi |
| 478 | * driver already uses the regulator. If it doesn't, we have to toggle |
| 479 | * the GPIO ourselves, even though it is now owned by the fixed |
| 480 | * regulator driver. We have to live with the race in case the driver |
| 481 | * gets unloaded and the GPIO freed between these two steps. |
| 482 | */ |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 483 | gpio_set_value(GPIO_PORT114, state); |
| 484 | } |
| 485 | |
Simon Horman | 9e05cdd | 2011-06-20 23:00:11 +0000 | [diff] [blame] | 486 | static struct sh_mobile_sdhi_info sh_sdhi1_info = { |
Simon Horman | c5ad48f | 2011-06-20 23:00:12 +0000 | [diff] [blame] | 487 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_HAS_IDLE_WAIT, |
Magnus Damm | 5294206 | 2011-06-09 09:02:25 +0000 | [diff] [blame] | 488 | .tmio_caps = MMC_CAP_NONREMOVABLE | MMC_CAP_SDIO_IRQ, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 489 | .tmio_ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 490 | .set_pwr = ag5evm_sdhi1_set_pwr, |
| 491 | }; |
| 492 | |
| 493 | static struct resource sdhi1_resources[] = { |
| 494 | [0] = { |
| 495 | .name = "SDHI1", |
| 496 | .start = 0xee120000, |
| 497 | .end = 0xee1200ff, |
| 498 | .flags = IORESOURCE_MEM, |
| 499 | }, |
| 500 | [1] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 501 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 502 | .start = gic_spi(87), |
| 503 | .flags = IORESOURCE_IRQ, |
| 504 | }, |
| 505 | [2] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 506 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 507 | .start = gic_spi(88), |
| 508 | .flags = IORESOURCE_IRQ, |
| 509 | }, |
| 510 | [3] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 511 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 512 | .start = gic_spi(89), |
| 513 | .flags = IORESOURCE_IRQ, |
| 514 | }, |
| 515 | }; |
| 516 | |
| 517 | static struct platform_device sdhi1_device = { |
| 518 | .name = "sh_mobile_sdhi", |
| 519 | .id = 1, |
| 520 | .dev = { |
Simon Horman | 9e05cdd | 2011-06-20 23:00:11 +0000 | [diff] [blame] | 521 | .platform_data = &sh_sdhi1_info, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 522 | }, |
| 523 | .num_resources = ARRAY_SIZE(sdhi1_resources), |
| 524 | .resource = sdhi1_resources, |
| 525 | }; |
| 526 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 527 | static struct platform_device *ag5evm_devices[] __initdata = { |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 528 | &cn4_power, |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 529 | ð_device, |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 530 | &keysc_device, |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 531 | &fsi_device, |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 532 | &mmc_device, |
Kuninori Morimoto | a33bb8a | 2011-01-14 11:00:41 +0000 | [diff] [blame] | 533 | &irda_device, |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 534 | &lcdc0_device, |
| 535 | &mipidsi0_device, |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 536 | &sdhi0_device, |
| 537 | &sdhi1_device, |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 538 | }; |
| 539 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 540 | static void __init ag5evm_init(void) |
| 541 | { |
Guennadi Liakhovetski | 6add969 | 2012-06-29 09:32:29 +0200 | [diff] [blame] | 542 | regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers, |
| 543 | ARRAY_SIZE(fixed1v8_power_consumers), 1800000); |
| 544 | regulator_register_always_on(1, "fixed-2.8V", fixed2v8_power_consumers, |
| 545 | ARRAY_SIZE(fixed2v8_power_consumers), 3300000); |
| 546 | regulator_register_fixed(3, dummy_supplies, ARRAY_SIZE(dummy_supplies)); |
| 547 | |
Takashi YOSHII | 3256c789 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 548 | sh73a0_pinmux_init(); |
| 549 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 550 | /* enable SCIFA2 */ |
Takashi YOSHII | 3256c789 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 551 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); |
| 552 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); |
| 553 | gpio_request(GPIO_FN_SCIFA2_RTS1_, NULL); |
| 554 | gpio_request(GPIO_FN_SCIFA2_CTS1_, NULL); |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 555 | |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 556 | /* enable KEYSC */ |
Takashi YOSHII | 5d78147 | 2010-12-22 06:30:19 +0000 | [diff] [blame] | 557 | gpio_request(GPIO_FN_KEYIN0_PU, NULL); |
| 558 | gpio_request(GPIO_FN_KEYIN1_PU, NULL); |
| 559 | gpio_request(GPIO_FN_KEYIN2_PU, NULL); |
| 560 | gpio_request(GPIO_FN_KEYIN3_PU, NULL); |
| 561 | gpio_request(GPIO_FN_KEYIN4_PU, NULL); |
| 562 | gpio_request(GPIO_FN_KEYIN5_PU, NULL); |
| 563 | gpio_request(GPIO_FN_KEYIN6_PU, NULL); |
| 564 | gpio_request(GPIO_FN_KEYIN7_PU, NULL); |
Yoshii Takashi | 2d22d48 | 2010-11-19 13:15:46 +0000 | [diff] [blame] | 565 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
| 566 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
| 567 | gpio_request(GPIO_FN_KEYOUT2, NULL); |
| 568 | gpio_request(GPIO_FN_KEYOUT3, NULL); |
| 569 | gpio_request(GPIO_FN_KEYOUT4, NULL); |
| 570 | gpio_request(GPIO_FN_KEYOUT5, NULL); |
| 571 | gpio_request(GPIO_FN_PORT59_KEYOUT6, NULL); |
| 572 | gpio_request(GPIO_FN_PORT58_KEYOUT7, NULL); |
| 573 | gpio_request(GPIO_FN_KEYOUT8, NULL); |
| 574 | gpio_request(GPIO_FN_PORT149_KEYOUT9, NULL); |
| 575 | |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 576 | /* enable I2C channel 2 and 3 */ |
Yoshii Takashi | 8e67b22 | 2010-11-19 13:21:32 +0000 | [diff] [blame] | 577 | gpio_request(GPIO_FN_PORT236_I2C_SDA2, NULL); |
| 578 | gpio_request(GPIO_FN_PORT237_I2C_SCL2, NULL); |
| 579 | gpio_request(GPIO_FN_PORT248_I2C_SCL3, NULL); |
| 580 | gpio_request(GPIO_FN_PORT249_I2C_SDA3, NULL); |
| 581 | |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 582 | /* enable MMCIF */ |
| 583 | gpio_request(GPIO_FN_MMCCLK0, NULL); |
| 584 | gpio_request(GPIO_FN_MMCCMD0_PU, NULL); |
Kuninori Morimoto | 052008e | 2011-11-10 18:44:24 -0800 | [diff] [blame] | 585 | gpio_request(GPIO_FN_MMCD0_0_PU, NULL); |
| 586 | gpio_request(GPIO_FN_MMCD0_1_PU, NULL); |
| 587 | gpio_request(GPIO_FN_MMCD0_2_PU, NULL); |
| 588 | gpio_request(GPIO_FN_MMCD0_3_PU, NULL); |
| 589 | gpio_request(GPIO_FN_MMCD0_4_PU, NULL); |
| 590 | gpio_request(GPIO_FN_MMCD0_5_PU, NULL); |
| 591 | gpio_request(GPIO_FN_MMCD0_6_PU, NULL); |
| 592 | gpio_request(GPIO_FN_MMCD0_7_PU, NULL); |
Takashi YOSHII | 6bf45a10 | 2010-12-22 06:35:30 +0000 | [diff] [blame] | 593 | gpio_request(GPIO_PORT208, NULL); /* Reset */ |
| 594 | gpio_direction_output(GPIO_PORT208, 1); |
| 595 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 596 | /* enable SMSC911X */ |
Takashi YOSHII | 3256c789 | 2010-11-19 16:49:38 +0900 | [diff] [blame] | 597 | gpio_request(GPIO_PORT144, NULL); /* PINTA2 */ |
| 598 | gpio_direction_input(GPIO_PORT144); |
| 599 | gpio_request(GPIO_PORT145, NULL); /* RESET */ |
| 600 | gpio_direction_output(GPIO_PORT145, 1); |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 601 | |
Kuninori Morimoto | 208c7dc | 2010-11-29 02:10:08 +0000 | [diff] [blame] | 602 | /* FSI A */ |
| 603 | gpio_request(GPIO_FN_FSIACK, NULL); |
| 604 | gpio_request(GPIO_FN_FSIAILR, NULL); |
| 605 | gpio_request(GPIO_FN_FSIAIBT, NULL); |
| 606 | gpio_request(GPIO_FN_FSIAISLD, NULL); |
| 607 | gpio_request(GPIO_FN_FSIAOSLD, NULL); |
| 608 | |
Kuninori Morimoto | a33bb8a | 2011-01-14 11:00:41 +0000 | [diff] [blame] | 609 | /* IrDA */ |
| 610 | gpio_request(GPIO_FN_PORT241_IRDA_OUT, NULL); |
| 611 | gpio_request(GPIO_FN_PORT242_IRDA_IN, NULL); |
| 612 | gpio_request(GPIO_FN_PORT243_IRDA_FIRSEL, NULL); |
| 613 | |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 614 | /* LCD panel */ |
| 615 | gpio_request(GPIO_PORT217, NULL); /* RESET */ |
| 616 | gpio_direction_output(GPIO_PORT217, 0); |
| 617 | mdelay(1); |
| 618 | gpio_set_value(GPIO_PORT217, 1); |
Magnus Damm | f55398a | 2011-01-28 09:59:17 +0000 | [diff] [blame] | 619 | mdelay(100); |
Magnus Damm | 170c7ab | 2011-01-20 08:41:03 +0000 | [diff] [blame] | 620 | |
| 621 | /* LCD backlight controller */ |
| 622 | gpio_request(GPIO_PORT235, NULL); /* RESET */ |
| 623 | gpio_direction_output(GPIO_PORT235, 0); |
| 624 | lcd_backlight_reset(); |
| 625 | |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 626 | /* enable SDHI0 on CN15 [SD I/F] */ |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 627 | gpio_request(GPIO_FN_SDHIWP0, NULL); |
| 628 | gpio_request(GPIO_FN_SDHICMD0, NULL); |
| 629 | gpio_request(GPIO_FN_SDHICLK0, NULL); |
| 630 | gpio_request(GPIO_FN_SDHID0_3, NULL); |
| 631 | gpio_request(GPIO_FN_SDHID0_2, NULL); |
| 632 | gpio_request(GPIO_FN_SDHID0_1, NULL); |
| 633 | gpio_request(GPIO_FN_SDHID0_0, NULL); |
| 634 | |
| 635 | /* enable SDHI1 on CN4 [WLAN I/F] */ |
| 636 | gpio_request(GPIO_FN_SDHICLK1, NULL); |
| 637 | gpio_request(GPIO_FN_SDHICMD1_PU, NULL); |
| 638 | gpio_request(GPIO_FN_SDHID1_3_PU, NULL); |
| 639 | gpio_request(GPIO_FN_SDHID1_2_PU, NULL); |
| 640 | gpio_request(GPIO_FN_SDHID1_1_PU, NULL); |
| 641 | gpio_request(GPIO_FN_SDHID1_0_PU, NULL); |
Magnus Damm | fb66c52 | 2011-05-23 05:10:36 +0000 | [diff] [blame] | 642 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 643 | #ifdef CONFIG_CACHE_L2X0 |
| 644 | /* Shared attribute override enable, 64K*8way */ |
Rob Herring | a2a47ca | 2012-03-09 17:16:40 -0600 | [diff] [blame] | 645 | l2x0_init(IOMEM(0xf0100000), 0x00460000, 0xc2000fff); |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 646 | #endif |
| 647 | sh73a0_add_standard_devices(); |
| 648 | platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices)); |
| 649 | } |
| 650 | |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 651 | MACHINE_START(AG5EVM, "ag5evm") |
Marc Zyngier | a62580e | 2011-09-08 13:15:22 +0100 | [diff] [blame] | 652 | .smp = smp_ops(sh73a0_smp_ops), |
Magnus Damm | 50e15c3 | 2012-02-29 21:37:27 +0900 | [diff] [blame] | 653 | .map_io = sh73a0_map_io, |
| 654 | .init_early = sh73a0_add_early_devices, |
Magnus Damm | eded914 | 2011-11-22 15:31:40 +0900 | [diff] [blame] | 655 | .nr_irqs = NR_IRQS_LEGACY, |
Magnus Damm | 566aad3 | 2011-10-17 18:00:52 +0900 | [diff] [blame] | 656 | .init_irq = sh73a0_init_irq, |
Marc Zyngier | a83d8e2 | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 657 | .handle_irq = gic_handle_irq, |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 658 | .init_machine = ag5evm_init, |
Shawn Guo | 21cc1b7 | 2012-04-26 21:58:41 +0800 | [diff] [blame] | 659 | .init_late = shmobile_init_late, |
Magnus Damm | 3be26fd | 2012-03-06 17:36:45 +0900 | [diff] [blame] | 660 | .timer = &shmobile_timer, |
Magnus Damm | 6d9598e | 2010-11-17 10:59:31 +0000 | [diff] [blame] | 661 | MACHINE_END |