Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * KZM-A9-GT board support |
| 3 | * |
| 4 | * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 19 | |
| 20 | #include <linux/delay.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 21 | #include <linux/gpio.h> |
| 22 | #include <linux/io.h> |
| 23 | #include <linux/irq.h> |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 24 | #include <linux/i2c.h> |
Kuninori Morimoto | cc2512b | 2012-04-22 23:53:40 -0700 | [diff] [blame] | 25 | #include <linux/mmc/host.h> |
| 26 | #include <linux/mmc/sh_mmcif.h> |
Kuninori Morimoto | 7775a93 | 2012-04-22 23:53:59 -0700 | [diff] [blame^] | 27 | #include <linux/mmc/sh_mobile_sdhi.h> |
| 28 | #include <linux/mfd/tmio.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 29 | #include <linux/platform_device.h> |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 30 | #include <linux/smsc911x.h> |
Kuninori Morimoto | dd81818 | 2012-04-10 20:58:10 -0700 | [diff] [blame] | 31 | #include <linux/usb/r8a66597.h> |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 32 | #include <linux/videodev2.h> |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 33 | #include <mach/irqs.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 34 | #include <mach/sh73a0.h> |
| 35 | #include <mach/common.h> |
| 36 | #include <asm/hardware/cache-l2x0.h> |
| 37 | #include <asm/hardware/gic.h> |
| 38 | #include <asm/mach-types.h> |
| 39 | #include <asm/mach/arch.h> |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 40 | #include <video/sh_mobile_lcdc.h> |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 41 | |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 42 | /* SMSC 9221 */ |
| 43 | static struct resource smsc9221_resources[] = { |
| 44 | [0] = { |
| 45 | .start = 0x10000000, /* CS4 */ |
| 46 | .end = 0x100000ff, |
| 47 | .flags = IORESOURCE_MEM, |
| 48 | }, |
| 49 | [1] = { |
| 50 | .start = intcs_evt2irq(0x260), /* IRQ3 */ |
| 51 | .flags = IORESOURCE_IRQ, |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | static struct smsc911x_platform_config smsc9221_platdata = { |
| 56 | .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 57 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 58 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 59 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 60 | }; |
| 61 | |
| 62 | static struct platform_device smsc_device = { |
| 63 | .name = "smsc911x", |
| 64 | .dev = { |
| 65 | .platform_data = &smsc9221_platdata, |
| 66 | }, |
| 67 | .resource = smsc9221_resources, |
| 68 | .num_resources = ARRAY_SIZE(smsc9221_resources), |
| 69 | }; |
| 70 | |
Kuninori Morimoto | dd81818 | 2012-04-10 20:58:10 -0700 | [diff] [blame] | 71 | /* USB external chip */ |
| 72 | static struct r8a66597_platdata usb_host_data = { |
| 73 | .on_chip = 0, |
| 74 | .xtal = R8A66597_PLATDATA_XTAL_48MHZ, |
| 75 | }; |
| 76 | |
| 77 | static struct resource usb_resources[] = { |
| 78 | [0] = { |
| 79 | .start = 0x10010000, |
| 80 | .end = 0x1001ffff - 1, |
| 81 | .flags = IORESOURCE_MEM, |
| 82 | }, |
| 83 | [1] = { |
| 84 | .start = intcs_evt2irq(0x220), /* IRQ1 */ |
| 85 | .flags = IORESOURCE_IRQ, |
| 86 | }, |
| 87 | }; |
| 88 | |
| 89 | static struct platform_device usb_host_device = { |
| 90 | .name = "r8a66597_hcd", |
| 91 | .dev = { |
| 92 | .platform_data = &usb_host_data, |
| 93 | .dma_mask = NULL, |
| 94 | .coherent_dma_mask = 0xffffffff, |
| 95 | }, |
| 96 | .num_resources = ARRAY_SIZE(usb_resources), |
| 97 | .resource = usb_resources, |
| 98 | }; |
| 99 | |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 100 | /* LCDC */ |
| 101 | static struct fb_videomode kzm_lcdc_mode = { |
| 102 | .name = "WVGA Panel", |
| 103 | .xres = 800, |
| 104 | .yres = 480, |
| 105 | .left_margin = 220, |
| 106 | .right_margin = 110, |
| 107 | .hsync_len = 70, |
| 108 | .upper_margin = 20, |
| 109 | .lower_margin = 5, |
| 110 | .vsync_len = 5, |
| 111 | .sync = 0, |
| 112 | }; |
| 113 | |
| 114 | static struct sh_mobile_lcdc_info lcdc_info = { |
| 115 | .clock_source = LCDC_CLK_BUS, |
| 116 | .ch[0] = { |
| 117 | .chan = LCDC_CHAN_MAINLCD, |
| 118 | .fourcc = V4L2_PIX_FMT_RGB565, |
| 119 | .interface_type = RGB24, |
| 120 | .lcd_modes = &kzm_lcdc_mode, |
| 121 | .num_modes = 1, |
| 122 | .clock_divider = 5, |
| 123 | .flags = 0, |
| 124 | .panel_cfg = { |
| 125 | .width = 152, |
| 126 | .height = 91, |
| 127 | }, |
| 128 | } |
| 129 | }; |
| 130 | |
| 131 | static struct resource lcdc_resources[] = { |
| 132 | [0] = { |
| 133 | .name = "LCDC", |
| 134 | .start = 0xfe940000, |
| 135 | .end = 0xfe943fff, |
| 136 | .flags = IORESOURCE_MEM, |
| 137 | }, |
| 138 | [1] = { |
| 139 | .start = intcs_evt2irq(0x580), |
| 140 | .flags = IORESOURCE_IRQ, |
| 141 | }, |
| 142 | }; |
| 143 | |
| 144 | static struct platform_device lcdc_device = { |
| 145 | .name = "sh_mobile_lcdc_fb", |
| 146 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 147 | .resource = lcdc_resources, |
| 148 | .dev = { |
| 149 | .platform_data = &lcdc_info, |
| 150 | .coherent_dma_mask = ~0, |
| 151 | }, |
| 152 | }; |
| 153 | |
Kuninori Morimoto | cc2512b | 2012-04-22 23:53:40 -0700 | [diff] [blame] | 154 | /* MMCIF */ |
| 155 | static struct resource sh_mmcif_resources[] = { |
| 156 | [0] = { |
| 157 | .name = "MMCIF", |
| 158 | .start = 0xe6bd0000, |
| 159 | .end = 0xe6bd00ff, |
| 160 | .flags = IORESOURCE_MEM, |
| 161 | }, |
| 162 | [1] = { |
| 163 | .start = gic_spi(141), |
| 164 | .flags = IORESOURCE_IRQ, |
| 165 | }, |
| 166 | [2] = { |
| 167 | .start = gic_spi(140), |
| 168 | .flags = IORESOURCE_IRQ, |
| 169 | }, |
| 170 | }; |
| 171 | |
| 172 | static struct sh_mmcif_plat_data sh_mmcif_platdata = { |
| 173 | .ocr = MMC_VDD_165_195, |
| 174 | .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, |
| 175 | }; |
| 176 | |
| 177 | static struct platform_device mmc_device = { |
| 178 | .name = "sh_mmcif", |
| 179 | .dev = { |
| 180 | .dma_mask = NULL, |
| 181 | .coherent_dma_mask = 0xffffffff, |
| 182 | .platform_data = &sh_mmcif_platdata, |
| 183 | }, |
| 184 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), |
| 185 | .resource = sh_mmcif_resources, |
| 186 | }; |
| 187 | |
Kuninori Morimoto | 7775a93 | 2012-04-22 23:53:59 -0700 | [diff] [blame^] | 188 | /* SDHI */ |
| 189 | static struct sh_mobile_sdhi_info sdhi0_info = { |
| 190 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
| 191 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, |
| 192 | .tmio_ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29, |
| 193 | }; |
| 194 | |
| 195 | static struct resource sdhi0_resources[] = { |
| 196 | [0] = { |
| 197 | .name = "SDHI0", |
| 198 | .start = 0xee100000, |
| 199 | .end = 0xee1000ff, |
| 200 | .flags = IORESOURCE_MEM, |
| 201 | }, |
| 202 | [1] = { |
| 203 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, |
| 204 | .start = gic_spi(83), |
| 205 | .flags = IORESOURCE_IRQ, |
| 206 | }, |
| 207 | [2] = { |
| 208 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
| 209 | .start = gic_spi(84), |
| 210 | .flags = IORESOURCE_IRQ, |
| 211 | }, |
| 212 | [3] = { |
| 213 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
| 214 | .start = gic_spi(85), |
| 215 | .flags = IORESOURCE_IRQ, |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | static struct platform_device sdhi0_device = { |
| 220 | .name = "sh_mobile_sdhi", |
| 221 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 222 | .resource = sdhi0_resources, |
| 223 | .dev = { |
| 224 | .platform_data = &sdhi0_info, |
| 225 | }, |
| 226 | }; |
| 227 | |
| 228 | /* I2C */ |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 229 | static struct i2c_board_info i2c1_devices[] = { |
| 230 | { |
| 231 | I2C_BOARD_INFO("st1232-ts", 0x55), |
| 232 | .irq = intcs_evt2irq(0x300), /* IRQ8 */ |
| 233 | }, |
| 234 | }; |
| 235 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 236 | static struct platform_device *kzm_devices[] __initdata = { |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 237 | &smsc_device, |
Kuninori Morimoto | dd81818 | 2012-04-10 20:58:10 -0700 | [diff] [blame] | 238 | &usb_host_device, |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 239 | &lcdc_device, |
Kuninori Morimoto | cc2512b | 2012-04-22 23:53:40 -0700 | [diff] [blame] | 240 | &mmc_device, |
Kuninori Morimoto | 7775a93 | 2012-04-22 23:53:59 -0700 | [diff] [blame^] | 241 | &sdhi0_device, |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 242 | }; |
| 243 | |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 244 | /* |
| 245 | * FIXME |
| 246 | * |
| 247 | * This is quick hack for enabling LCDC backlight |
| 248 | */ |
| 249 | static int __init as3711_enable_lcdc_backlight(void) |
| 250 | { |
| 251 | struct i2c_adapter *a = i2c_get_adapter(0); |
| 252 | struct i2c_msg msg; |
| 253 | int i, ret; |
| 254 | __u8 magic[] = { |
| 255 | 0x40, 0x2a, |
| 256 | 0x43, 0x3c, |
| 257 | 0x44, 0x3c, |
| 258 | 0x45, 0x3c, |
| 259 | 0x54, 0x03, |
| 260 | 0x51, 0x00, |
| 261 | 0x51, 0x01, |
| 262 | 0xff, 0x00, /* wait */ |
| 263 | 0x43, 0xf0, |
| 264 | 0x44, 0xf0, |
| 265 | 0x45, 0xf0, |
| 266 | }; |
| 267 | |
| 268 | if (!machine_is_kzm9g()) |
| 269 | return 0; |
| 270 | |
| 271 | if (!a) |
| 272 | return 0; |
| 273 | |
| 274 | msg.addr = 0x40; |
| 275 | msg.len = 2; |
| 276 | msg.flags = 0; |
| 277 | |
| 278 | for (i = 0; i < ARRAY_SIZE(magic); i += 2) { |
| 279 | msg.buf = magic + i; |
| 280 | |
| 281 | if (0xff == msg.buf[0]) { |
| 282 | udelay(500); |
| 283 | continue; |
| 284 | } |
| 285 | |
| 286 | ret = i2c_transfer(a, &msg, 1); |
| 287 | if (ret < 0) { |
| 288 | pr_err("i2c transfer fail\n"); |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | return 0; |
| 294 | } |
| 295 | device_initcall(as3711_enable_lcdc_backlight); |
| 296 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 297 | static void __init kzm_init(void) |
| 298 | { |
| 299 | sh73a0_pinmux_init(); |
| 300 | |
| 301 | /* enable SCIFA4 */ |
| 302 | gpio_request(GPIO_FN_SCIFA4_TXD, NULL); |
| 303 | gpio_request(GPIO_FN_SCIFA4_RXD, NULL); |
| 304 | gpio_request(GPIO_FN_SCIFA4_RTS_, NULL); |
| 305 | gpio_request(GPIO_FN_SCIFA4_CTS_, NULL); |
| 306 | |
Kuninori Morimoto | c15c425 | 2012-04-10 20:57:58 -0700 | [diff] [blame] | 307 | /* CS4 for SMSC/USB */ |
| 308 | gpio_request(GPIO_FN_CS4_, NULL); /* CS4 */ |
| 309 | |
| 310 | /* SMSC */ |
| 311 | gpio_request(GPIO_PORT224, NULL); /* IRQ3 */ |
| 312 | gpio_direction_input(GPIO_PORT224); |
| 313 | |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 314 | /* LCDC */ |
| 315 | gpio_request(GPIO_FN_LCDD23, NULL); |
| 316 | gpio_request(GPIO_FN_LCDD22, NULL); |
| 317 | gpio_request(GPIO_FN_LCDD21, NULL); |
| 318 | gpio_request(GPIO_FN_LCDD20, NULL); |
| 319 | gpio_request(GPIO_FN_LCDD19, NULL); |
| 320 | gpio_request(GPIO_FN_LCDD18, NULL); |
| 321 | gpio_request(GPIO_FN_LCDD17, NULL); |
| 322 | gpio_request(GPIO_FN_LCDD16, NULL); |
| 323 | gpio_request(GPIO_FN_LCDD15, NULL); |
| 324 | gpio_request(GPIO_FN_LCDD14, NULL); |
| 325 | gpio_request(GPIO_FN_LCDD13, NULL); |
| 326 | gpio_request(GPIO_FN_LCDD12, NULL); |
| 327 | gpio_request(GPIO_FN_LCDD11, NULL); |
| 328 | gpio_request(GPIO_FN_LCDD10, NULL); |
| 329 | gpio_request(GPIO_FN_LCDD9, NULL); |
| 330 | gpio_request(GPIO_FN_LCDD8, NULL); |
| 331 | gpio_request(GPIO_FN_LCDD7, NULL); |
| 332 | gpio_request(GPIO_FN_LCDD6, NULL); |
| 333 | gpio_request(GPIO_FN_LCDD5, NULL); |
| 334 | gpio_request(GPIO_FN_LCDD4, NULL); |
| 335 | gpio_request(GPIO_FN_LCDD3, NULL); |
| 336 | gpio_request(GPIO_FN_LCDD2, NULL); |
| 337 | gpio_request(GPIO_FN_LCDD1, NULL); |
| 338 | gpio_request(GPIO_FN_LCDD0, NULL); |
| 339 | gpio_request(GPIO_FN_LCDDISP, NULL); |
| 340 | gpio_request(GPIO_FN_LCDDCK, NULL); |
| 341 | |
Kuninori Morimoto | 601df61 | 2012-04-22 23:53:24 -0700 | [diff] [blame] | 342 | gpio_request(GPIO_PORT222, NULL); /* LCDCDON */ |
| 343 | gpio_request(GPIO_PORT226, NULL); /* SC */ |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 344 | gpio_direction_output(GPIO_PORT222, 1); |
Kuninori Morimoto | 601df61 | 2012-04-22 23:53:24 -0700 | [diff] [blame] | 345 | gpio_direction_output(GPIO_PORT226, 1); |
Kuninori Morimoto | 2678611 | 2012-04-10 20:58:33 -0700 | [diff] [blame] | 346 | |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 347 | /* Touchscreen */ |
| 348 | gpio_request(GPIO_PORT223, NULL); /* IRQ8 */ |
| 349 | gpio_direction_input(GPIO_PORT223); |
| 350 | |
Kuninori Morimoto | cc2512b | 2012-04-22 23:53:40 -0700 | [diff] [blame] | 351 | /* enable MMCIF */ |
| 352 | gpio_request(GPIO_FN_MMCCLK0, NULL); |
| 353 | gpio_request(GPIO_FN_MMCCMD0_PU, NULL); |
| 354 | gpio_request(GPIO_FN_MMCD0_0_PU, NULL); |
| 355 | gpio_request(GPIO_FN_MMCD0_1_PU, NULL); |
| 356 | gpio_request(GPIO_FN_MMCD0_2_PU, NULL); |
| 357 | gpio_request(GPIO_FN_MMCD0_3_PU, NULL); |
| 358 | gpio_request(GPIO_FN_MMCD0_4_PU, NULL); |
| 359 | gpio_request(GPIO_FN_MMCD0_5_PU, NULL); |
| 360 | gpio_request(GPIO_FN_MMCD0_6_PU, NULL); |
| 361 | gpio_request(GPIO_FN_MMCD0_7_PU, NULL); |
| 362 | |
Kuninori Morimoto | 7775a93 | 2012-04-22 23:53:59 -0700 | [diff] [blame^] | 363 | /* enable SD */ |
| 364 | gpio_request(GPIO_FN_SDHIWP0, NULL); |
| 365 | gpio_request(GPIO_FN_SDHICD0, NULL); |
| 366 | gpio_request(GPIO_FN_SDHICMD0, NULL); |
| 367 | gpio_request(GPIO_FN_SDHICLK0, NULL); |
| 368 | gpio_request(GPIO_FN_SDHID0_3, NULL); |
| 369 | gpio_request(GPIO_FN_SDHID0_2, NULL); |
| 370 | gpio_request(GPIO_FN_SDHID0_1, NULL); |
| 371 | gpio_request(GPIO_FN_SDHID0_0, NULL); |
| 372 | gpio_request(GPIO_FN_SDHI0_VCCQ_MC0_ON, NULL); |
| 373 | gpio_request(GPIO_PORT15, NULL); |
| 374 | gpio_direction_output(GPIO_PORT15, 1); /* power */ |
| 375 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 376 | #ifdef CONFIG_CACHE_L2X0 |
| 377 | /* Early BRESP enable, Shared attribute override enable, 64K*8way */ |
| 378 | l2x0_init(IOMEM(0xf0100000), 0x40460000, 0x82000fff); |
| 379 | #endif |
| 380 | |
Kuninori Morimoto | 407c052 | 2012-04-10 20:58:45 -0700 | [diff] [blame] | 381 | i2c_register_board_info(1, i2c1_devices, ARRAY_SIZE(i2c1_devices)); |
| 382 | |
Kuninori Morimoto | 9b93e24 | 2012-04-10 20:57:31 -0700 | [diff] [blame] | 383 | sh73a0_add_standard_devices(); |
| 384 | platform_add_devices(kzm_devices, ARRAY_SIZE(kzm_devices)); |
| 385 | } |
| 386 | |
| 387 | MACHINE_START(KZM9G, "kzm9g") |
| 388 | .map_io = sh73a0_map_io, |
| 389 | .init_early = sh73a0_add_early_devices, |
| 390 | .nr_irqs = NR_IRQS_LEGACY, |
| 391 | .init_irq = sh73a0_init_irq, |
| 392 | .handle_irq = gic_handle_irq, |
| 393 | .init_machine = kzm_init, |
| 394 | .timer = &shmobile_timer, |
| 395 | MACHINE_END |