Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * armadillo 800 eva board support |
| 3 | * |
| 4 | * Copyright (C) 2012 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@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/clk.h> |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 23 | #include <linux/delay.h> |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 24 | #include <linux/err.h> |
| 25 | #include <linux/kernel.h> |
Kuninori Morimoto | f7e7d31 | 2012-04-06 01:31:33 -0700 | [diff] [blame] | 26 | #include <linux/input.h> |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 27 | #include <linux/irq.h> |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/gpio.h> |
Kuninori Morimoto | f7e7d31 | 2012-04-06 01:31:33 -0700 | [diff] [blame] | 30 | #include <linux/gpio_keys.h> |
Kuninori Morimoto | d8fed1e | 2012-04-06 01:32:02 -0700 | [diff] [blame] | 31 | #include <linux/sh_eth.h> |
Kuninori Morimoto | dad29d1 | 2012-04-06 01:30:09 -0700 | [diff] [blame] | 32 | #include <linux/videodev2.h> |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 33 | #include <linux/usb/renesas_usbhs.h> |
Kuninori Morimoto | 49c0111 | 2012-04-24 02:09:19 -0700 | [diff] [blame] | 34 | #include <linux/mfd/tmio.h> |
| 35 | #include <linux/mmc/host.h> |
Kuninori Morimoto | 0a4266b | 2012-04-24 02:09:42 -0700 | [diff] [blame] | 36 | #include <linux/mmc/sh_mmcif.h> |
Kuninori Morimoto | 49c0111 | 2012-04-24 02:09:19 -0700 | [diff] [blame] | 37 | #include <linux/mmc/sh_mobile_sdhi.h> |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 38 | #include <mach/common.h> |
| 39 | #include <mach/irqs.h> |
| 40 | #include <asm/page.h> |
| 41 | #include <asm/mach-types.h> |
| 42 | #include <asm/mach/arch.h> |
| 43 | #include <asm/mach/map.h> |
| 44 | #include <asm/mach/time.h> |
| 45 | #include <asm/hardware/cache-l2x0.h> |
| 46 | #include <mach/r8a7740.h> |
Kuninori Morimoto | dad29d1 | 2012-04-06 01:30:09 -0700 | [diff] [blame] | 47 | #include <video/sh_mobile_lcdc.h> |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * CON1 Camera Module |
| 51 | * CON2 Extension Bus |
| 52 | * CON3 HDMI Output |
| 53 | * CON4 Composite Video Output |
| 54 | * CON5 H-UDI JTAG |
| 55 | * CON6 ARM JTAG |
| 56 | * CON7 SD1 |
| 57 | * CON8 SD2 |
| 58 | * CON9 RTC BackUp |
| 59 | * CON10 Monaural Mic Input |
| 60 | * CON11 Stereo Headphone Output |
| 61 | * CON12 Audio Line Output(L) |
| 62 | * CON13 Audio Line Output(R) |
| 63 | * CON14 AWL13 Module |
| 64 | * CON15 Extension |
| 65 | * CON16 LCD1 |
| 66 | * CON17 LCD2 |
| 67 | * CON19 Power Input |
| 68 | * CON20 USB1 |
| 69 | * CON21 USB2 |
| 70 | * CON22 Serial |
| 71 | * CON23 LAN |
| 72 | * CON24 USB3 |
| 73 | * LED1 Camera LED(Yellow) |
| 74 | * LED2 Power LED (Green) |
| 75 | * ED3-LED6 User LED(Yellow) |
| 76 | * LED7 LAN link LED(Green) |
| 77 | * LED8 LAN activity LED(Yellow) |
| 78 | */ |
| 79 | |
| 80 | /* |
| 81 | * DipSwitch |
| 82 | * |
| 83 | * SW1 |
| 84 | * |
| 85 | * -12345678-+---------------+---------------------------- |
| 86 | * 1 | boot | hermit |
| 87 | * 0 | boot | OS auto boot |
| 88 | * -12345678-+---------------+---------------------------- |
| 89 | * 00 | boot device | eMMC |
| 90 | * 10 | boot device | SDHI0 (CON7) |
| 91 | * 01 | boot device | - |
| 92 | * 11 | boot device | Extension Buss (CS0) |
| 93 | * -12345678-+---------------+---------------------------- |
| 94 | * 0 | Extension Bus | D8-D15 disable, eMMC enable |
| 95 | * 1 | Extension Bus | D8-D15 enable, eMMC disable |
| 96 | * -12345678-+---------------+---------------------------- |
Kuninori Morimoto | 2e3a5ef | 2012-04-24 02:09:31 -0700 | [diff] [blame] | 97 | * 0 | SDHI1 | COM8 disable, COM14 enable |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 98 | * 1 | SDHI1 | COM8 enable, COM14 disable |
| 99 | * -12345678-+---------------+---------------------------- |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 100 | * 0 | USB0 | COM20 enable, COM24 disable |
| 101 | * 1 | USB0 | COM20 disable, COM24 enable |
| 102 | * -12345678-+---------------+---------------------------- |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 103 | * 00 | JTAG | SH-X2 |
| 104 | * 10 | JTAG | ARM |
| 105 | * 01 | JTAG | - |
| 106 | * 11 | JTAG | Boundary Scan |
| 107 | *-----------+---------------+---------------------------- |
| 108 | */ |
| 109 | |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 110 | /* |
| 111 | * USB function |
| 112 | * |
| 113 | * When you use USB Function, |
| 114 | * set SW1.6 ON, and connect cable to CN24. |
| 115 | * |
| 116 | * USBF needs workaround on R8A7740 chip. |
| 117 | * These are a little bit complex. |
| 118 | * see |
| 119 | * usbhsf_power_ctrl() |
| 120 | * |
| 121 | * CAUTION |
| 122 | * |
| 123 | * It uses autonomy mode for USB hotplug at this point |
| 124 | * (= usbhs_private.platform_callback.get_vbus is NULL), |
| 125 | * since we don't know what's happen on PM control |
| 126 | * on this workaround. |
| 127 | */ |
| 128 | #define USBCR1 0xe605810a |
| 129 | #define USBH 0xC6700000 |
| 130 | #define USBH_USBCTR 0x10834 |
| 131 | |
| 132 | struct usbhsf_private { |
| 133 | struct clk *phy; |
| 134 | struct clk *usb24; |
| 135 | struct clk *pci; |
| 136 | struct clk *func; |
| 137 | struct clk *host; |
| 138 | void __iomem *usbh_base; |
| 139 | struct renesas_usbhs_platform_info info; |
| 140 | }; |
| 141 | |
| 142 | #define usbhsf_get_priv(pdev) \ |
| 143 | container_of(renesas_usbhs_get_info(pdev), \ |
| 144 | struct usbhsf_private, info) |
| 145 | |
| 146 | static int usbhsf_get_id(struct platform_device *pdev) |
| 147 | { |
| 148 | return USBHS_GADGET; |
| 149 | } |
| 150 | |
| 151 | static void usbhsf_power_ctrl(struct platform_device *pdev, |
| 152 | void __iomem *base, int enable) |
| 153 | { |
| 154 | struct usbhsf_private *priv = usbhsf_get_priv(pdev); |
| 155 | |
| 156 | /* |
| 157 | * Work around for USB Function. |
| 158 | * It needs USB host clock, and settings |
| 159 | */ |
| 160 | if (enable) { |
| 161 | /* |
| 162 | * enable all the related usb clocks |
| 163 | * for usb workaround |
| 164 | */ |
| 165 | clk_enable(priv->usb24); |
| 166 | clk_enable(priv->pci); |
| 167 | clk_enable(priv->host); |
| 168 | clk_enable(priv->func); |
| 169 | clk_enable(priv->phy); |
| 170 | |
| 171 | /* |
| 172 | * set USBCR1 |
| 173 | * |
| 174 | * Port1 is driven by USB function, |
| 175 | * Port2 is driven by USB HOST |
| 176 | * One HOST (Port1 or Port2 is HOST) |
| 177 | * USB PLL input clock = 24MHz |
| 178 | */ |
| 179 | __raw_writew(0xd750, USBCR1); |
| 180 | mdelay(1); |
| 181 | |
| 182 | /* |
| 183 | * start USB Host |
| 184 | */ |
| 185 | __raw_writel(0x0000000c, priv->usbh_base + USBH_USBCTR); |
| 186 | __raw_writel(0x00000008, priv->usbh_base + USBH_USBCTR); |
| 187 | mdelay(10); |
| 188 | |
| 189 | /* |
| 190 | * USB PHY Power ON |
| 191 | */ |
| 192 | __raw_writew(0xd770, USBCR1); |
| 193 | __raw_writew(0x4000, base + 0x102); /* USBF :: SUSPMODE */ |
| 194 | |
| 195 | } else { |
| 196 | __raw_writel(0x0000010f, priv->usbh_base + USBH_USBCTR); |
| 197 | __raw_writew(0xd7c0, USBCR1); /* GPIO */ |
| 198 | |
| 199 | clk_disable(priv->phy); |
| 200 | clk_disable(priv->func); /* usb work around */ |
| 201 | clk_disable(priv->host); /* usb work around */ |
| 202 | clk_disable(priv->pci); /* usb work around */ |
| 203 | clk_disable(priv->usb24); /* usb work around */ |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | static void usbhsf_hardware_exit(struct platform_device *pdev) |
| 208 | { |
| 209 | struct usbhsf_private *priv = usbhsf_get_priv(pdev); |
| 210 | |
| 211 | if (!IS_ERR(priv->phy)) |
| 212 | clk_put(priv->phy); |
| 213 | if (!IS_ERR(priv->usb24)) |
| 214 | clk_put(priv->usb24); |
| 215 | if (!IS_ERR(priv->pci)) |
| 216 | clk_put(priv->pci); |
| 217 | if (!IS_ERR(priv->host)) |
| 218 | clk_put(priv->host); |
| 219 | if (!IS_ERR(priv->func)) |
| 220 | clk_put(priv->func); |
| 221 | if (priv->usbh_base) |
| 222 | iounmap(priv->usbh_base); |
| 223 | |
| 224 | priv->phy = NULL; |
| 225 | priv->usb24 = NULL; |
| 226 | priv->pci = NULL; |
| 227 | priv->host = NULL; |
| 228 | priv->func = NULL; |
| 229 | priv->usbh_base = NULL; |
| 230 | } |
| 231 | |
| 232 | static int usbhsf_hardware_init(struct platform_device *pdev) |
| 233 | { |
| 234 | struct usbhsf_private *priv = usbhsf_get_priv(pdev); |
| 235 | |
| 236 | priv->phy = clk_get(&pdev->dev, "phy"); |
| 237 | priv->usb24 = clk_get(&pdev->dev, "usb24"); |
| 238 | priv->pci = clk_get(&pdev->dev, "pci"); |
| 239 | priv->func = clk_get(&pdev->dev, "func"); |
| 240 | priv->host = clk_get(&pdev->dev, "host"); |
| 241 | priv->usbh_base = ioremap_nocache(USBH, 0x20000); |
| 242 | |
| 243 | if (IS_ERR(priv->phy) || |
| 244 | IS_ERR(priv->usb24) || |
| 245 | IS_ERR(priv->pci) || |
| 246 | IS_ERR(priv->host) || |
| 247 | IS_ERR(priv->func) || |
| 248 | !priv->usbh_base) { |
| 249 | dev_err(&pdev->dev, "USB clock setting failed\n"); |
| 250 | usbhsf_hardware_exit(pdev); |
| 251 | return -EIO; |
| 252 | } |
| 253 | |
| 254 | /* usb24 use 1/1 of parent clock (= usb24s = 24MHz) */ |
| 255 | clk_set_rate(priv->usb24, |
| 256 | clk_get_rate(clk_get_parent(priv->usb24))); |
| 257 | |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | static struct usbhsf_private usbhsf_private = { |
| 262 | .info = { |
| 263 | .platform_callback = { |
| 264 | .get_id = usbhsf_get_id, |
| 265 | .hardware_init = usbhsf_hardware_init, |
| 266 | .hardware_exit = usbhsf_hardware_exit, |
| 267 | .power_ctrl = usbhsf_power_ctrl, |
| 268 | }, |
| 269 | .driver_param = { |
| 270 | .buswait_bwait = 5, |
| 271 | .detection_delay = 5, |
| 272 | }, |
| 273 | } |
| 274 | }; |
| 275 | |
| 276 | static struct resource usbhsf_resources[] = { |
| 277 | { |
| 278 | .name = "USBHS", |
| 279 | .start = 0xe6890000, |
| 280 | .end = 0xe6890104 - 1, |
| 281 | .flags = IORESOURCE_MEM, |
| 282 | }, |
| 283 | { |
| 284 | .start = evt2irq(0x0A20), |
| 285 | .flags = IORESOURCE_IRQ, |
| 286 | }, |
| 287 | }; |
| 288 | |
| 289 | static struct platform_device usbhsf_device = { |
| 290 | .name = "renesas_usbhs", |
| 291 | .dev = { |
| 292 | .platform_data = &usbhsf_private.info, |
| 293 | }, |
| 294 | .id = -1, |
| 295 | .num_resources = ARRAY_SIZE(usbhsf_resources), |
| 296 | .resource = usbhsf_resources, |
| 297 | }; |
| 298 | |
Kuninori Morimoto | d8fed1e | 2012-04-06 01:32:02 -0700 | [diff] [blame] | 299 | /* Ether */ |
| 300 | static struct sh_eth_plat_data sh_eth_platdata = { |
| 301 | .phy = 0x00, /* LAN8710A */ |
| 302 | .edmac_endian = EDMAC_LITTLE_ENDIAN, |
| 303 | .register_type = SH_ETH_REG_GIGABIT, |
| 304 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 305 | }; |
| 306 | |
| 307 | static struct resource sh_eth_resources[] = { |
| 308 | { |
| 309 | .start = 0xe9a00000, |
| 310 | .end = 0xe9a00800 - 1, |
| 311 | .flags = IORESOURCE_MEM, |
| 312 | }, { |
| 313 | .start = 0xe9a01800, |
| 314 | .end = 0xe9a02000 - 1, |
| 315 | .flags = IORESOURCE_MEM, |
| 316 | }, { |
| 317 | .start = evt2irq(0x0500), |
| 318 | .flags = IORESOURCE_IRQ, |
| 319 | }, |
| 320 | }; |
| 321 | |
| 322 | static struct platform_device sh_eth_device = { |
| 323 | .name = "sh-eth", |
Kuninori Morimoto | 9c18f23 | 2012-05-06 22:58:41 -0700 | [diff] [blame] | 324 | .id = -1, |
Kuninori Morimoto | d8fed1e | 2012-04-06 01:32:02 -0700 | [diff] [blame] | 325 | .dev = { |
| 326 | .platform_data = &sh_eth_platdata, |
| 327 | }, |
| 328 | .resource = sh_eth_resources, |
| 329 | .num_resources = ARRAY_SIZE(sh_eth_resources), |
| 330 | }; |
| 331 | |
Kuninori Morimoto | dad29d1 | 2012-04-06 01:30:09 -0700 | [diff] [blame] | 332 | /* LCDC */ |
| 333 | static struct fb_videomode lcdc0_mode = { |
| 334 | .name = "AMPIER/AM-800480", |
| 335 | .xres = 800, |
| 336 | .yres = 480, |
| 337 | .left_margin = 88, |
| 338 | .right_margin = 40, |
| 339 | .hsync_len = 128, |
| 340 | .upper_margin = 20, |
| 341 | .lower_margin = 5, |
| 342 | .vsync_len = 5, |
| 343 | .sync = 0, |
| 344 | }; |
| 345 | |
| 346 | static struct sh_mobile_lcdc_info lcdc0_info = { |
| 347 | .clock_source = LCDC_CLK_BUS, |
| 348 | .ch[0] = { |
| 349 | .chan = LCDC_CHAN_MAINLCD, |
| 350 | .fourcc = V4L2_PIX_FMT_RGB565, |
| 351 | .interface_type = RGB24, |
| 352 | .clock_divider = 5, |
| 353 | .flags = 0, |
| 354 | .lcd_modes = &lcdc0_mode, |
| 355 | .num_modes = 1, |
| 356 | .panel_cfg = { |
| 357 | .width = 111, |
| 358 | .height = 68, |
| 359 | }, |
| 360 | }, |
| 361 | }; |
| 362 | |
| 363 | static struct resource lcdc0_resources[] = { |
| 364 | [0] = { |
| 365 | .name = "LCD0", |
| 366 | .start = 0xfe940000, |
| 367 | .end = 0xfe943fff, |
| 368 | .flags = IORESOURCE_MEM, |
| 369 | }, |
| 370 | [1] = { |
| 371 | .start = intcs_evt2irq(0x580), |
| 372 | .flags = IORESOURCE_IRQ, |
| 373 | }, |
| 374 | }; |
| 375 | |
| 376 | static struct platform_device lcdc0_device = { |
| 377 | .name = "sh_mobile_lcdc_fb", |
| 378 | .num_resources = ARRAY_SIZE(lcdc0_resources), |
| 379 | .resource = lcdc0_resources, |
| 380 | .id = 0, |
| 381 | .dev = { |
| 382 | .platform_data = &lcdc0_info, |
| 383 | .coherent_dma_mask = ~0, |
| 384 | }, |
| 385 | }; |
| 386 | |
Kuninori Morimoto | f7e7d31 | 2012-04-06 01:31:33 -0700 | [diff] [blame] | 387 | /* GPIO KEY */ |
| 388 | #define GPIO_KEY(c, g, d) { .code = c, .gpio = g, .desc = d, .active_low = 1 } |
| 389 | |
| 390 | static struct gpio_keys_button gpio_buttons[] = { |
| 391 | GPIO_KEY(KEY_POWER, GPIO_PORT99, "SW1"), |
| 392 | GPIO_KEY(KEY_BACK, GPIO_PORT100, "SW2"), |
| 393 | GPIO_KEY(KEY_MENU, GPIO_PORT97, "SW3"), |
| 394 | GPIO_KEY(KEY_HOME, GPIO_PORT98, "SW4"), |
| 395 | }; |
| 396 | |
| 397 | static struct gpio_keys_platform_data gpio_key_info = { |
| 398 | .buttons = gpio_buttons, |
| 399 | .nbuttons = ARRAY_SIZE(gpio_buttons), |
| 400 | }; |
| 401 | |
| 402 | static struct platform_device gpio_keys_device = { |
| 403 | .name = "gpio-keys", |
| 404 | .id = -1, |
| 405 | .dev = { |
| 406 | .platform_data = &gpio_key_info, |
| 407 | }, |
| 408 | }; |
| 409 | |
Kuninori Morimoto | 49c0111 | 2012-04-24 02:09:19 -0700 | [diff] [blame] | 410 | /* SDHI0 */ |
| 411 | /* |
| 412 | * FIXME |
| 413 | * |
| 414 | * It use polling mode here, since |
| 415 | * CD (= Card Detect) pin is not connected to SDHI0_CD. |
| 416 | * We can use IRQ31 as card detect irq, |
| 417 | * but it needs chattering removal operation |
| 418 | */ |
| 419 | #define IRQ31 evt2irq(0x33E0) |
| 420 | static struct sh_mobile_sdhi_info sdhi0_info = { |
| 421 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |\ |
| 422 | MMC_CAP_NEEDS_POLL, |
| 423 | .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, |
| 424 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
| 425 | }; |
| 426 | |
| 427 | static struct resource sdhi0_resources[] = { |
| 428 | { |
| 429 | .name = "SDHI0", |
| 430 | .start = 0xe6850000, |
| 431 | .end = 0xe6850100 - 1, |
| 432 | .flags = IORESOURCE_MEM, |
| 433 | }, |
| 434 | /* |
| 435 | * no SH_MOBILE_SDHI_IRQ_CARD_DETECT here |
| 436 | */ |
| 437 | { |
| 438 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
| 439 | .start = evt2irq(0x0E20), |
| 440 | .flags = IORESOURCE_IRQ, |
| 441 | }, |
| 442 | { |
| 443 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
| 444 | .start = evt2irq(0x0E40), |
| 445 | .flags = IORESOURCE_IRQ, |
| 446 | }, |
| 447 | }; |
| 448 | |
| 449 | static struct platform_device sdhi0_device = { |
| 450 | .name = "sh_mobile_sdhi", |
| 451 | .id = 0, |
| 452 | .dev = { |
| 453 | .platform_data = &sdhi0_info, |
| 454 | }, |
| 455 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 456 | .resource = sdhi0_resources, |
| 457 | }; |
| 458 | |
Kuninori Morimoto | 2e3a5ef | 2012-04-24 02:09:31 -0700 | [diff] [blame] | 459 | /* SDHI1 */ |
| 460 | static struct sh_mobile_sdhi_info sdhi1_info = { |
| 461 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, |
| 462 | .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, |
| 463 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
| 464 | }; |
| 465 | |
| 466 | static struct resource sdhi1_resources[] = { |
| 467 | [0] = { |
| 468 | .name = "SDHI1", |
| 469 | .start = 0xe6860000, |
| 470 | .end = 0xe6860100 - 1, |
| 471 | .flags = IORESOURCE_MEM, |
| 472 | }, |
| 473 | [1] = { |
| 474 | .start = evt2irq(0x0E80), |
| 475 | .flags = IORESOURCE_IRQ, |
| 476 | }, |
| 477 | [2] = { |
| 478 | .start = evt2irq(0x0EA0), |
| 479 | .flags = IORESOURCE_IRQ, |
| 480 | }, |
| 481 | [3] = { |
| 482 | .start = evt2irq(0x0EC0), |
| 483 | .flags = IORESOURCE_IRQ, |
| 484 | }, |
| 485 | }; |
| 486 | |
| 487 | static struct platform_device sdhi1_device = { |
| 488 | .name = "sh_mobile_sdhi", |
| 489 | .id = 1, |
| 490 | .dev = { |
| 491 | .platform_data = &sdhi1_info, |
| 492 | }, |
| 493 | .num_resources = ARRAY_SIZE(sdhi1_resources), |
| 494 | .resource = sdhi1_resources, |
| 495 | }; |
| 496 | |
Kuninori Morimoto | 0a4266b | 2012-04-24 02:09:42 -0700 | [diff] [blame] | 497 | /* MMCIF */ |
| 498 | static struct sh_mmcif_plat_data sh_mmcif_plat = { |
| 499 | .sup_pclk = 0, |
| 500 | .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, |
| 501 | .caps = MMC_CAP_4_BIT_DATA | |
| 502 | MMC_CAP_8_BIT_DATA | |
| 503 | MMC_CAP_NONREMOVABLE, |
| 504 | }; |
| 505 | |
| 506 | static struct resource sh_mmcif_resources[] = { |
| 507 | [0] = { |
| 508 | .name = "MMCIF", |
| 509 | .start = 0xe6bd0000, |
| 510 | .end = 0xe6bd0100 - 1, |
| 511 | .flags = IORESOURCE_MEM, |
| 512 | }, |
| 513 | [1] = { |
| 514 | /* MMC ERR */ |
| 515 | .start = evt2irq(0x1AC0), |
| 516 | .flags = IORESOURCE_IRQ, |
| 517 | }, |
| 518 | [2] = { |
| 519 | /* MMC NOR */ |
| 520 | .start = evt2irq(0x1AE0), |
| 521 | .flags = IORESOURCE_IRQ, |
| 522 | }, |
| 523 | }; |
| 524 | |
| 525 | static struct platform_device sh_mmcif_device = { |
| 526 | .name = "sh_mmcif", |
| 527 | .id = -1, |
| 528 | .dev = { |
| 529 | .platform_data = &sh_mmcif_plat, |
| 530 | }, |
| 531 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), |
| 532 | .resource = sh_mmcif_resources, |
| 533 | }; |
| 534 | |
Kuninori Morimoto | 46cf668 | 2012-04-06 01:30:42 -0700 | [diff] [blame] | 535 | /* I2C */ |
| 536 | static struct i2c_board_info i2c0_devices[] = { |
| 537 | { |
| 538 | I2C_BOARD_INFO("st1232-ts", 0x55), |
| 539 | .irq = evt2irq(0x0340), |
| 540 | }, |
| 541 | }; |
| 542 | |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 543 | /* |
| 544 | * board devices |
| 545 | */ |
| 546 | static struct platform_device *eva_devices[] __initdata = { |
Kuninori Morimoto | dad29d1 | 2012-04-06 01:30:09 -0700 | [diff] [blame] | 547 | &lcdc0_device, |
Kuninori Morimoto | f7e7d31 | 2012-04-06 01:31:33 -0700 | [diff] [blame] | 548 | &gpio_keys_device, |
Kuninori Morimoto | d8fed1e | 2012-04-06 01:32:02 -0700 | [diff] [blame] | 549 | &sh_eth_device, |
Kuninori Morimoto | 49c0111 | 2012-04-24 02:09:19 -0700 | [diff] [blame] | 550 | &sdhi0_device, |
Kuninori Morimoto | 0a4266b | 2012-04-24 02:09:42 -0700 | [diff] [blame] | 551 | &sh_mmcif_device, |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 552 | }; |
| 553 | |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 554 | static void __init eva_clock_init(void) |
| 555 | { |
| 556 | struct clk *system = clk_get(NULL, "system_clk"); |
| 557 | struct clk *xtal1 = clk_get(NULL, "extal1"); |
| 558 | struct clk *usb24s = clk_get(NULL, "usb24s"); |
| 559 | |
| 560 | if (IS_ERR(system) || |
| 561 | IS_ERR(xtal1) || |
| 562 | IS_ERR(usb24s)) { |
| 563 | pr_err("armadillo800eva board clock init failed\n"); |
| 564 | goto clock_error; |
| 565 | } |
| 566 | |
| 567 | /* armadillo 800 eva extal1 is 24MHz */ |
| 568 | clk_set_rate(xtal1, 24000000); |
| 569 | |
| 570 | /* usb24s use extal1 (= system) clock (= 24MHz) */ |
| 571 | clk_set_parent(usb24s, system); |
| 572 | |
| 573 | clock_error: |
| 574 | if (!IS_ERR(system)) |
| 575 | clk_put(system); |
| 576 | if (!IS_ERR(xtal1)) |
| 577 | clk_put(xtal1); |
| 578 | if (!IS_ERR(usb24s)) |
| 579 | clk_put(usb24s); |
| 580 | } |
| 581 | |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 582 | /* |
| 583 | * board init |
| 584 | */ |
| 585 | static void __init eva_init(void) |
| 586 | { |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 587 | eva_clock_init(); |
| 588 | |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 589 | r8a7740_pinmux_init(); |
Kuninori Morimoto | d49679e | 2012-06-12 02:36:21 -0700 | [diff] [blame^] | 590 | r8a7740_meram_workaround(); |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 591 | |
| 592 | /* SCIFA1 */ |
| 593 | gpio_request(GPIO_FN_SCIFA1_RXD, NULL); |
| 594 | gpio_request(GPIO_FN_SCIFA1_TXD, NULL); |
| 595 | |
Kuninori Morimoto | dad29d1 | 2012-04-06 01:30:09 -0700 | [diff] [blame] | 596 | /* LCDC0 */ |
| 597 | gpio_request(GPIO_FN_LCDC0_SELECT, NULL); |
| 598 | gpio_request(GPIO_FN_LCD0_D0, NULL); |
| 599 | gpio_request(GPIO_FN_LCD0_D1, NULL); |
| 600 | gpio_request(GPIO_FN_LCD0_D2, NULL); |
| 601 | gpio_request(GPIO_FN_LCD0_D3, NULL); |
| 602 | gpio_request(GPIO_FN_LCD0_D4, NULL); |
| 603 | gpio_request(GPIO_FN_LCD0_D5, NULL); |
| 604 | gpio_request(GPIO_FN_LCD0_D6, NULL); |
| 605 | gpio_request(GPIO_FN_LCD0_D7, NULL); |
| 606 | gpio_request(GPIO_FN_LCD0_D8, NULL); |
| 607 | gpio_request(GPIO_FN_LCD0_D9, NULL); |
| 608 | gpio_request(GPIO_FN_LCD0_D10, NULL); |
| 609 | gpio_request(GPIO_FN_LCD0_D11, NULL); |
| 610 | gpio_request(GPIO_FN_LCD0_D12, NULL); |
| 611 | gpio_request(GPIO_FN_LCD0_D13, NULL); |
| 612 | gpio_request(GPIO_FN_LCD0_D14, NULL); |
| 613 | gpio_request(GPIO_FN_LCD0_D15, NULL); |
| 614 | gpio_request(GPIO_FN_LCD0_D16, NULL); |
| 615 | gpio_request(GPIO_FN_LCD0_D17, NULL); |
| 616 | gpio_request(GPIO_FN_LCD0_D18_PORT40, NULL); |
| 617 | gpio_request(GPIO_FN_LCD0_D19_PORT4, NULL); |
| 618 | gpio_request(GPIO_FN_LCD0_D20_PORT3, NULL); |
| 619 | gpio_request(GPIO_FN_LCD0_D21_PORT2, NULL); |
| 620 | gpio_request(GPIO_FN_LCD0_D22_PORT0, NULL); |
| 621 | gpio_request(GPIO_FN_LCD0_D23_PORT1, NULL); |
| 622 | gpio_request(GPIO_FN_LCD0_DCK, NULL); |
| 623 | gpio_request(GPIO_FN_LCD0_VSYN, NULL); |
| 624 | gpio_request(GPIO_FN_LCD0_HSYN, NULL); |
| 625 | gpio_request(GPIO_FN_LCD0_DISP, NULL); |
| 626 | gpio_request(GPIO_FN_LCD0_LCLK_PORT165, NULL); |
| 627 | |
| 628 | gpio_request(GPIO_PORT61, NULL); /* LCDDON */ |
| 629 | gpio_direction_output(GPIO_PORT61, 1); |
| 630 | |
| 631 | gpio_request(GPIO_PORT202, NULL); /* LCD0_LED_CONT */ |
| 632 | gpio_direction_output(GPIO_PORT202, 0); |
| 633 | |
Kuninori Morimoto | 46cf668 | 2012-04-06 01:30:42 -0700 | [diff] [blame] | 634 | /* Touchscreen */ |
| 635 | gpio_request(GPIO_FN_IRQ10, NULL); /* TP_INT */ |
| 636 | gpio_request(GPIO_PORT166, NULL); /* TP_RST_B */ |
| 637 | gpio_direction_output(GPIO_PORT166, 1); |
| 638 | |
Kuninori Morimoto | d8fed1e | 2012-04-06 01:32:02 -0700 | [diff] [blame] | 639 | /* GETHER */ |
| 640 | gpio_request(GPIO_FN_ET_CRS, NULL); |
| 641 | gpio_request(GPIO_FN_ET_MDC, NULL); |
| 642 | gpio_request(GPIO_FN_ET_MDIO, NULL); |
| 643 | gpio_request(GPIO_FN_ET_TX_ER, NULL); |
| 644 | gpio_request(GPIO_FN_ET_RX_ER, NULL); |
| 645 | gpio_request(GPIO_FN_ET_ERXD0, NULL); |
| 646 | gpio_request(GPIO_FN_ET_ERXD1, NULL); |
| 647 | gpio_request(GPIO_FN_ET_ERXD2, NULL); |
| 648 | gpio_request(GPIO_FN_ET_ERXD3, NULL); |
| 649 | gpio_request(GPIO_FN_ET_TX_CLK, NULL); |
| 650 | gpio_request(GPIO_FN_ET_TX_EN, NULL); |
| 651 | gpio_request(GPIO_FN_ET_ETXD0, NULL); |
| 652 | gpio_request(GPIO_FN_ET_ETXD1, NULL); |
| 653 | gpio_request(GPIO_FN_ET_ETXD2, NULL); |
| 654 | gpio_request(GPIO_FN_ET_ETXD3, NULL); |
| 655 | gpio_request(GPIO_FN_ET_PHY_INT, NULL); |
| 656 | gpio_request(GPIO_FN_ET_COL, NULL); |
| 657 | gpio_request(GPIO_FN_ET_RX_DV, NULL); |
| 658 | gpio_request(GPIO_FN_ET_RX_CLK, NULL); |
| 659 | |
| 660 | gpio_request(GPIO_PORT18, NULL); /* PHY_RST */ |
| 661 | gpio_direction_output(GPIO_PORT18, 1); |
| 662 | |
Kuninori Morimoto | 1c96293 | 2012-04-24 02:09:08 -0700 | [diff] [blame] | 663 | /* USB */ |
| 664 | gpio_request(GPIO_PORT159, NULL); /* USB_DEVICE_MODE */ |
| 665 | gpio_direction_input(GPIO_PORT159); |
| 666 | |
| 667 | if (gpio_get_value(GPIO_PORT159)) { |
| 668 | /* USB Host */ |
| 669 | } else { |
| 670 | /* USB Func */ |
| 671 | gpio_request(GPIO_FN_VBUS, NULL); |
| 672 | platform_device_register(&usbhsf_device); |
| 673 | } |
| 674 | |
Kuninori Morimoto | 49c0111 | 2012-04-24 02:09:19 -0700 | [diff] [blame] | 675 | /* SDHI0 */ |
| 676 | gpio_request(GPIO_FN_SDHI0_CMD, NULL); |
| 677 | gpio_request(GPIO_FN_SDHI0_CLK, NULL); |
| 678 | gpio_request(GPIO_FN_SDHI0_D0, NULL); |
| 679 | gpio_request(GPIO_FN_SDHI0_D1, NULL); |
| 680 | gpio_request(GPIO_FN_SDHI0_D2, NULL); |
| 681 | gpio_request(GPIO_FN_SDHI0_D3, NULL); |
| 682 | gpio_request(GPIO_FN_SDHI0_WP, NULL); |
| 683 | |
| 684 | gpio_request(GPIO_PORT17, NULL); /* SDHI0_18/33_B */ |
| 685 | gpio_request(GPIO_PORT74, NULL); /* SDHI0_PON */ |
| 686 | gpio_request(GPIO_PORT75, NULL); /* SDSLOT1_PON */ |
| 687 | gpio_direction_output(GPIO_PORT17, 0); |
| 688 | gpio_direction_output(GPIO_PORT74, 1); |
| 689 | gpio_direction_output(GPIO_PORT75, 1); |
| 690 | |
| 691 | /* we can use GPIO_FN_IRQ31_PORT167 here for SDHI0 CD irq */ |
| 692 | |
Kuninori Morimoto | dad29d1 | 2012-04-06 01:30:09 -0700 | [diff] [blame] | 693 | /* |
Kuninori Morimoto | 0a4266b | 2012-04-24 02:09:42 -0700 | [diff] [blame] | 694 | * MMCIF |
| 695 | * |
| 696 | * Here doesn't care SW1.4 status, |
| 697 | * since CON2 is not mounted. |
| 698 | */ |
| 699 | gpio_request(GPIO_FN_MMC1_CLK_PORT103, NULL); |
| 700 | gpio_request(GPIO_FN_MMC1_CMD_PORT104, NULL); |
| 701 | gpio_request(GPIO_FN_MMC1_D0_PORT149, NULL); |
| 702 | gpio_request(GPIO_FN_MMC1_D1_PORT148, NULL); |
| 703 | gpio_request(GPIO_FN_MMC1_D2_PORT147, NULL); |
| 704 | gpio_request(GPIO_FN_MMC1_D3_PORT146, NULL); |
| 705 | gpio_request(GPIO_FN_MMC1_D4_PORT145, NULL); |
| 706 | gpio_request(GPIO_FN_MMC1_D5_PORT144, NULL); |
| 707 | gpio_request(GPIO_FN_MMC1_D6_PORT143, NULL); |
| 708 | gpio_request(GPIO_FN_MMC1_D7_PORT142, NULL); |
| 709 | |
| 710 | /* |
Kuninori Morimoto | dad29d1 | 2012-04-06 01:30:09 -0700 | [diff] [blame] | 711 | * CAUTION |
| 712 | * |
| 713 | * DBGMD/LCDC0/FSIA MUX |
| 714 | * DBGMD_SELECT_B should be set after setting PFC Function. |
| 715 | */ |
| 716 | gpio_request(GPIO_PORT176, NULL); |
| 717 | gpio_direction_output(GPIO_PORT176, 1); |
| 718 | |
Kuninori Morimoto | 2e3a5ef | 2012-04-24 02:09:31 -0700 | [diff] [blame] | 719 | /* |
| 720 | * We can switch CON8/CON14 by SW1.5, |
| 721 | * but it needs after DBGMD_SELECT_B |
| 722 | */ |
| 723 | gpio_request(GPIO_PORT6, NULL); |
| 724 | gpio_direction_input(GPIO_PORT6); |
| 725 | if (gpio_get_value(GPIO_PORT6)) { |
| 726 | /* CON14 enable */ |
| 727 | } else { |
| 728 | /* CON8 (SDHI1) enable */ |
| 729 | gpio_request(GPIO_FN_SDHI1_CLK, NULL); |
| 730 | gpio_request(GPIO_FN_SDHI1_CMD, NULL); |
| 731 | gpio_request(GPIO_FN_SDHI1_D0, NULL); |
| 732 | gpio_request(GPIO_FN_SDHI1_D1, NULL); |
| 733 | gpio_request(GPIO_FN_SDHI1_D2, NULL); |
| 734 | gpio_request(GPIO_FN_SDHI1_D3, NULL); |
| 735 | gpio_request(GPIO_FN_SDHI1_CD, NULL); |
| 736 | gpio_request(GPIO_FN_SDHI1_WP, NULL); |
| 737 | |
| 738 | gpio_request(GPIO_PORT16, NULL); /* SDSLOT2_PON */ |
| 739 | gpio_direction_output(GPIO_PORT16, 1); |
| 740 | |
| 741 | platform_device_register(&sdhi1_device); |
| 742 | } |
| 743 | |
| 744 | |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 745 | #ifdef CONFIG_CACHE_L2X0 |
| 746 | /* Early BRESP enable, Shared attribute override enable, 32K*8way */ |
| 747 | l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff); |
| 748 | #endif |
| 749 | |
Kuninori Morimoto | 46cf668 | 2012-04-06 01:30:42 -0700 | [diff] [blame] | 750 | i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices)); |
| 751 | |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 752 | r8a7740_add_standard_devices(); |
| 753 | |
| 754 | platform_add_devices(eva_devices, |
| 755 | ARRAY_SIZE(eva_devices)); |
| 756 | } |
| 757 | |
| 758 | static void __init eva_earlytimer_init(void) |
| 759 | { |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 760 | r8a7740_clock_init(MD_CK0 | MD_CK2); |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 761 | shmobile_earlytimer_init(); |
| 762 | } |
| 763 | |
| 764 | static void __init eva_add_early_devices(void) |
| 765 | { |
| 766 | r8a7740_add_early_devices(); |
| 767 | |
| 768 | /* override timer setup with board-specific code */ |
| 769 | shmobile_timer.init = eva_earlytimer_init; |
| 770 | } |
| 771 | |
Magnus Damm | e6bf705 | 2012-05-14 19:54:41 +0900 | [diff] [blame] | 772 | static const char *eva_boards_compat_dt[] __initdata = { |
| 773 | "renesas,armadillo800eva", |
| 774 | NULL, |
| 775 | }; |
| 776 | |
| 777 | DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva") |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 778 | .map_io = r8a7740_map_io, |
| 779 | .init_early = eva_add_early_devices, |
| 780 | .init_irq = r8a7740_init_irq, |
| 781 | .handle_irq = shmobile_handle_irq_intc, |
| 782 | .init_machine = eva_init, |
| 783 | .timer = &shmobile_timer, |
Magnus Damm | e6bf705 | 2012-05-14 19:54:41 +0900 | [diff] [blame] | 784 | .dt_compat = eva_boards_compat_dt, |
Kuninori Morimoto | 4d22e56 | 2012-04-06 01:28:59 -0700 | [diff] [blame] | 785 | MACHINE_END |