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