Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * AP4EVB board support |
| 3 | * |
| 4 | * Copyright (C) 2010 Magnus Damm |
| 5 | * Copyright (C) 2008 Yoshihiro Shimoda |
| 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 | */ |
Guennadi Liakhovetski | 8eda2f2 | 2010-05-23 14:04:03 +0000 | [diff] [blame] | 20 | #include <linux/clk.h> |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 21 | #include <linux/kernel.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/irq.h> |
| 25 | #include <linux/platform_device.h> |
| 26 | #include <linux/delay.h> |
Guennadi Liakhovetski | 69bf6f45 | 2010-05-04 14:07:15 +0000 | [diff] [blame^] | 27 | #include <linux/mfd/sh_mobile_sdhi.h> |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 28 | #include <linux/mtd/mtd.h> |
| 29 | #include <linux/mtd/partitions.h> |
| 30 | #include <linux/mtd/physmap.h> |
Kuninori Morimoto | 91cf508 | 2010-03-11 10:42:52 +0000 | [diff] [blame] | 31 | #include <linux/i2c.h> |
| 32 | #include <linux/i2c/tsc2007.h> |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 33 | #include <linux/io.h> |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 34 | #include <linux/smsc911x.h> |
| 35 | #include <linux/gpio.h> |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 36 | #include <linux/input.h> |
| 37 | #include <linux/input/sh_keysc.h> |
Kuninori Morimoto | fb54d26 | 2010-04-13 06:16:32 +0000 | [diff] [blame] | 38 | #include <linux/usb/r8a66597.h> |
Guennadi Liakhovetski | 8eda2f2 | 2010-05-23 14:04:03 +0000 | [diff] [blame] | 39 | |
| 40 | #include <video/sh_mobile_lcdc.h> |
| 41 | #include <video/sh_mipi_dsi.h> |
| 42 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 43 | #include <mach/common.h> |
Guennadi Liakhovetski | 8eda2f2 | 2010-05-23 14:04:03 +0000 | [diff] [blame] | 44 | #include <mach/irqs.h> |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 45 | #include <mach/sh7372.h> |
Guennadi Liakhovetski | 8eda2f2 | 2010-05-23 14:04:03 +0000 | [diff] [blame] | 46 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 47 | #include <asm/mach-types.h> |
| 48 | #include <asm/mach/arch.h> |
| 49 | #include <asm/mach/map.h> |
Magnus Damm | 495b3ce | 2010-05-12 14:21:34 +0000 | [diff] [blame] | 50 | #include <asm/mach/time.h> |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 51 | |
Kuninori Morimoto | 02624a1 | 2010-02-18 17:58:19 +0900 | [diff] [blame] | 52 | /* |
| 53 | * Address Interface BusWidth note |
| 54 | * ------------------------------------------------------------------ |
| 55 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON |
| 56 | * 0x0800_0000 user area - |
| 57 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF |
| 58 | * 0x1400_0000 Ether (LAN9220) 16bit |
| 59 | * 0x1600_0000 user area - cannot use with NAND |
| 60 | * 0x1800_0000 user area - |
| 61 | * 0x1A00_0000 - |
| 62 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit |
| 63 | */ |
| 64 | |
| 65 | /* |
| 66 | * NOR Flash ROM |
| 67 | * |
| 68 | * SW1 | SW2 | SW7 | NOR Flash ROM |
| 69 | * bit1 | bit1 bit2 | bit1 | Memory allocation |
| 70 | * ------+------------+------+------------------ |
| 71 | * OFF | ON OFF | ON | Area 0 |
| 72 | * OFF | ON OFF | OFF | Area 4 |
| 73 | */ |
| 74 | |
| 75 | /* |
| 76 | * NAND Flash ROM |
| 77 | * |
| 78 | * SW1 | SW2 | SW7 | NAND Flash ROM |
| 79 | * bit1 | bit1 bit2 | bit2 | Memory allocation |
| 80 | * ------+------------+------+------------------ |
| 81 | * OFF | ON OFF | ON | FCE 0 |
| 82 | * OFF | ON OFF | OFF | FCE 1 |
| 83 | */ |
| 84 | |
| 85 | /* |
| 86 | * SMSC 9220 |
| 87 | * |
| 88 | * SW1 SMSC 9220 |
| 89 | * ----------------------- |
| 90 | * ON access disable |
| 91 | * OFF access enable |
| 92 | */ |
| 93 | |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 94 | /* |
Kuninori Morimoto | dda128d | 2010-03-12 10:07:55 +0000 | [diff] [blame] | 95 | * LCD / IRQ / KEYSC / IrDA |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 96 | * |
Kuninori Morimoto | dda128d | 2010-03-12 10:07:55 +0000 | [diff] [blame] | 97 | * IRQ = IRQ26 (TS), IRQ27 (VIO), IRQ28 (TouchScreen) |
| 98 | * LCD = 2nd LCDC |
| 99 | * |
| 100 | * | SW43 | |
| 101 | * SW3 | ON | OFF | |
| 102 | * -------------+-----------------------+---------------+ |
| 103 | * ON | KEY / IrDA | LCD | |
| 104 | * OFF | KEY / IrDA / IRQ | IRQ | |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 105 | */ |
| 106 | |
Kuninori Morimoto | fb54d26 | 2010-04-13 06:16:32 +0000 | [diff] [blame] | 107 | /* |
| 108 | * USB |
| 109 | * |
| 110 | * J7 : 1-2 MAX3355E VBUS |
| 111 | * 2-3 DC 5.0V |
| 112 | * |
| 113 | * S39: bit2: off |
| 114 | */ |
| 115 | |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 116 | /* MTD */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 117 | static struct mtd_partition nor_flash_partitions[] = { |
| 118 | { |
| 119 | .name = "loader", |
| 120 | .offset = 0x00000000, |
| 121 | .size = 512 * 1024, |
| 122 | }, |
| 123 | { |
| 124 | .name = "bootenv", |
| 125 | .offset = MTDPART_OFS_APPEND, |
| 126 | .size = 512 * 1024, |
| 127 | }, |
| 128 | { |
| 129 | .name = "kernel_ro", |
| 130 | .offset = MTDPART_OFS_APPEND, |
| 131 | .size = 8 * 1024 * 1024, |
| 132 | .mask_flags = MTD_WRITEABLE, |
| 133 | }, |
| 134 | { |
| 135 | .name = "kernel", |
| 136 | .offset = MTDPART_OFS_APPEND, |
| 137 | .size = 8 * 1024 * 1024, |
| 138 | }, |
| 139 | { |
| 140 | .name = "data", |
| 141 | .offset = MTDPART_OFS_APPEND, |
| 142 | .size = MTDPART_SIZ_FULL, |
| 143 | }, |
| 144 | }; |
| 145 | |
| 146 | static struct physmap_flash_data nor_flash_data = { |
| 147 | .width = 2, |
| 148 | .parts = nor_flash_partitions, |
| 149 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 150 | }; |
| 151 | |
| 152 | static struct resource nor_flash_resources[] = { |
| 153 | [0] = { |
| 154 | .start = 0x00000000, |
| 155 | .end = 0x08000000 - 1, |
| 156 | .flags = IORESOURCE_MEM, |
| 157 | } |
| 158 | }; |
| 159 | |
| 160 | static struct platform_device nor_flash_device = { |
| 161 | .name = "physmap-flash", |
| 162 | .dev = { |
| 163 | .platform_data = &nor_flash_data, |
| 164 | }, |
| 165 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 166 | .resource = nor_flash_resources, |
| 167 | }; |
| 168 | |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 169 | /* SMSC 9220 */ |
| 170 | static struct resource smc911x_resources[] = { |
| 171 | { |
| 172 | .start = 0x14000000, |
| 173 | .end = 0x16000000 - 1, |
| 174 | .flags = IORESOURCE_MEM, |
| 175 | }, { |
Magnus Damm | 33c9607 | 2010-05-20 14:41:00 +0000 | [diff] [blame] | 176 | .start = evt2irq(0x02c0) /* IRQ6A */, |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 177 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 178 | }, |
| 179 | }; |
| 180 | |
| 181 | static struct smsc911x_platform_config smsc911x_info = { |
| 182 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 183 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 184 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 185 | }; |
| 186 | |
| 187 | static struct platform_device smc911x_device = { |
| 188 | .name = "smsc911x", |
| 189 | .id = -1, |
| 190 | .num_resources = ARRAY_SIZE(smc911x_resources), |
| 191 | .resource = smc911x_resources, |
| 192 | .dev = { |
| 193 | .platform_data = &smsc911x_info, |
| 194 | }, |
| 195 | }; |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 196 | |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 197 | /* KEYSC (Needs SW43 set to ON) */ |
| 198 | static struct sh_keysc_info keysc_info = { |
| 199 | .mode = SH_KEYSC_MODE_1, |
| 200 | .scan_timing = 3, |
| 201 | .delay = 2500, |
| 202 | .keycodes = { |
| 203 | KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, |
| 204 | KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, |
| 205 | KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, |
| 206 | KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, |
| 207 | KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, |
| 208 | }, |
| 209 | }; |
| 210 | |
| 211 | static struct resource keysc_resources[] = { |
| 212 | [0] = { |
| 213 | .name = "KEYSC", |
| 214 | .start = 0xe61b0000, |
| 215 | .end = 0xe61b0063, |
| 216 | .flags = IORESOURCE_MEM, |
| 217 | }, |
| 218 | [1] = { |
Magnus Damm | 33c9607 | 2010-05-20 14:41:00 +0000 | [diff] [blame] | 219 | .start = evt2irq(0x0be0), /* KEYSC_KEY */ |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 220 | .flags = IORESOURCE_IRQ, |
| 221 | }, |
| 222 | }; |
| 223 | |
| 224 | static struct platform_device keysc_device = { |
| 225 | .name = "sh_keysc", |
| 226 | .id = 0, /* "keysc0" clock */ |
| 227 | .num_resources = ARRAY_SIZE(keysc_resources), |
| 228 | .resource = keysc_resources, |
| 229 | .dev = { |
| 230 | .platform_data = &keysc_info, |
| 231 | }, |
| 232 | }; |
| 233 | |
Magnus Damm | 3a14d03 | 2010-03-10 09:26:44 +0000 | [diff] [blame] | 234 | /* SDHI0 */ |
Guennadi Liakhovetski | 69bf6f45 | 2010-05-04 14:07:15 +0000 | [diff] [blame^] | 235 | static struct sh_mobile_sdhi_info sdhi0_info = { |
| 236 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, |
| 237 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, |
| 238 | }; |
| 239 | |
Magnus Damm | 3a14d03 | 2010-03-10 09:26:44 +0000 | [diff] [blame] | 240 | static struct resource sdhi0_resources[] = { |
| 241 | [0] = { |
| 242 | .name = "SDHI0", |
| 243 | .start = 0xe6850000, |
| 244 | .end = 0xe68501ff, |
| 245 | .flags = IORESOURCE_MEM, |
| 246 | }, |
| 247 | [1] = { |
Magnus Damm | 33c9607 | 2010-05-20 14:41:00 +0000 | [diff] [blame] | 248 | .start = evt2irq(0x0e00) /* SDHI0 */, |
Magnus Damm | 3a14d03 | 2010-03-10 09:26:44 +0000 | [diff] [blame] | 249 | .flags = IORESOURCE_IRQ, |
| 250 | }, |
| 251 | }; |
| 252 | |
| 253 | static struct platform_device sdhi0_device = { |
| 254 | .name = "sh_mobile_sdhi", |
| 255 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 256 | .resource = sdhi0_resources, |
| 257 | .id = 0, |
Guennadi Liakhovetski | 69bf6f45 | 2010-05-04 14:07:15 +0000 | [diff] [blame^] | 258 | .dev = { |
| 259 | .platform_data = &sdhi0_info, |
| 260 | }, |
Magnus Damm | 3a14d03 | 2010-03-10 09:26:44 +0000 | [diff] [blame] | 261 | }; |
| 262 | |
Kuninori Morimoto | fb54d26 | 2010-04-13 06:16:32 +0000 | [diff] [blame] | 263 | /* USB1 */ |
| 264 | void usb1_host_port_power(int port, int power) |
| 265 | { |
| 266 | if (!power) /* only power-on supported for now */ |
| 267 | return; |
| 268 | |
| 269 | /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */ |
| 270 | __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008); |
| 271 | } |
| 272 | |
| 273 | static struct r8a66597_platdata usb1_host_data = { |
| 274 | .on_chip = 1, |
| 275 | .port_power = usb1_host_port_power, |
| 276 | }; |
| 277 | |
| 278 | static struct resource usb1_host_resources[] = { |
| 279 | [0] = { |
| 280 | .name = "USBHS", |
| 281 | .start = 0xE68B0000, |
| 282 | .end = 0xE68B00E6 - 1, |
| 283 | .flags = IORESOURCE_MEM, |
| 284 | }, |
| 285 | [1] = { |
Magnus Damm | 33c9607 | 2010-05-20 14:41:00 +0000 | [diff] [blame] | 286 | .start = evt2irq(0x1ce0) /* USB1_USB1I0 */, |
Kuninori Morimoto | fb54d26 | 2010-04-13 06:16:32 +0000 | [diff] [blame] | 287 | .flags = IORESOURCE_IRQ, |
| 288 | }, |
| 289 | }; |
| 290 | |
| 291 | static struct platform_device usb1_host_device = { |
| 292 | .name = "r8a66597_hcd", |
| 293 | .id = 1, |
| 294 | .dev = { |
| 295 | .dma_mask = NULL, /* not use dma */ |
| 296 | .coherent_dma_mask = 0xffffffff, |
| 297 | .platform_data = &usb1_host_data, |
| 298 | }, |
| 299 | .num_resources = ARRAY_SIZE(usb1_host_resources), |
| 300 | .resource = usb1_host_resources, |
| 301 | }; |
| 302 | |
Guennadi Liakhovetski | 8eda2f2 | 2010-05-23 14:04:03 +0000 | [diff] [blame] | 303 | static struct sh_mobile_lcdc_info sh_mobile_lcdc_info = { |
| 304 | .clock_source = LCDC_CLK_PERIPHERAL, /* One of interface clocks */ |
| 305 | .ch[0] = { |
| 306 | .chan = LCDC_CHAN_MAINLCD, |
| 307 | .bpp = 16, |
| 308 | .interface_type = RGB24, |
| 309 | .clock_divider = 1, |
| 310 | .flags = LCDC_FLAGS_DWPOL, |
| 311 | .lcd_cfg = { |
| 312 | .name = "R63302(QHD)", |
| 313 | .xres = 544, |
| 314 | .yres = 961, |
| 315 | .left_margin = 72, |
| 316 | .right_margin = 600, |
| 317 | .hsync_len = 16, |
| 318 | .upper_margin = 8, |
| 319 | .lower_margin = 8, |
| 320 | .vsync_len = 2, |
| 321 | .sync = FB_SYNC_VERT_HIGH_ACT | FB_SYNC_HOR_HIGH_ACT, |
| 322 | }, |
| 323 | .lcd_size_cfg = { |
| 324 | .width = 44, |
| 325 | .height = 79, |
| 326 | }, |
| 327 | } |
| 328 | }; |
| 329 | |
| 330 | static struct resource lcdc_resources[] = { |
| 331 | [0] = { |
| 332 | .name = "LCDC", |
| 333 | .start = 0xfe940000, /* P4-only space */ |
| 334 | .end = 0xfe943fff, |
| 335 | .flags = IORESOURCE_MEM, |
| 336 | }, |
| 337 | [1] = { |
| 338 | .start = intcs_evt2irq(0x580), |
| 339 | .flags = IORESOURCE_IRQ, |
| 340 | }, |
| 341 | }; |
| 342 | |
| 343 | static struct platform_device lcdc_device = { |
| 344 | .name = "sh_mobile_lcdc_fb", |
| 345 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 346 | .resource = lcdc_resources, |
| 347 | .dev = { |
| 348 | .platform_data = &sh_mobile_lcdc_info, |
| 349 | .coherent_dma_mask = ~0, |
| 350 | }, |
| 351 | }; |
| 352 | |
| 353 | static struct resource mipidsi0_resources[] = { |
| 354 | [0] = { |
| 355 | .start = 0xffc60000, |
| 356 | .end = 0xffc68fff, |
| 357 | .flags = IORESOURCE_MEM, |
| 358 | }, |
| 359 | }; |
| 360 | |
| 361 | static struct sh_mipi_dsi_info mipidsi0_info = { |
| 362 | .data_format = MIPI_RGB888, |
| 363 | .lcd_chan = &sh_mobile_lcdc_info.ch[0], |
| 364 | }; |
| 365 | |
| 366 | static struct platform_device mipidsi0_device = { |
| 367 | .name = "sh-mipi-dsi", |
| 368 | .num_resources = ARRAY_SIZE(mipidsi0_resources), |
| 369 | .resource = mipidsi0_resources, |
| 370 | .id = 0, |
| 371 | .dev = { |
| 372 | .platform_data = &mipidsi0_info, |
| 373 | }, |
| 374 | }; |
| 375 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 376 | static struct platform_device *ap4evb_devices[] __initdata = { |
| 377 | &nor_flash_device, |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 378 | &smc911x_device, |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 379 | &keysc_device, |
Magnus Damm | 3a14d03 | 2010-03-10 09:26:44 +0000 | [diff] [blame] | 380 | &sdhi0_device, |
Kuninori Morimoto | fb54d26 | 2010-04-13 06:16:32 +0000 | [diff] [blame] | 381 | &usb1_host_device, |
Guennadi Liakhovetski | 8eda2f2 | 2010-05-23 14:04:03 +0000 | [diff] [blame] | 382 | &lcdc_device, |
| 383 | &mipidsi0_device, |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 384 | }; |
| 385 | |
Kuninori Morimoto | dda128d | 2010-03-12 10:07:55 +0000 | [diff] [blame] | 386 | /* TouchScreen (Needs SW3 set to OFF) */ |
Magnus Damm | 33c9607 | 2010-05-20 14:41:00 +0000 | [diff] [blame] | 387 | #define IRQ28 evt2irq(0x3380) /* IRQ28A */ |
Kuninori Morimoto | 91cf508 | 2010-03-11 10:42:52 +0000 | [diff] [blame] | 388 | struct tsc2007_platform_data tsc2007_info = { |
| 389 | .model = 2007, |
| 390 | .x_plate_ohms = 180, |
| 391 | }; |
| 392 | |
| 393 | /* I2C */ |
| 394 | static struct i2c_board_info i2c1_devices[] = { |
| 395 | { |
Kuninori Morimoto | 8fc883c | 2010-03-11 07:34:37 +0000 | [diff] [blame] | 396 | I2C_BOARD_INFO("r2025sd", 0x32), |
| 397 | }, |
| 398 | { |
Kuninori Morimoto | 91cf508 | 2010-03-11 10:42:52 +0000 | [diff] [blame] | 399 | I2C_BOARD_INFO("tsc2007", 0x48), |
| 400 | .type = "tsc2007", |
| 401 | .platform_data = &tsc2007_info, |
| 402 | .irq = IRQ28, |
| 403 | }, |
| 404 | }; |
| 405 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 406 | static struct map_desc ap4evb_io_desc[] __initdata = { |
| 407 | /* create a 1:1 entity map for 0xe6xxxxxx |
| 408 | * used by CPGA, INTC and PFC. |
| 409 | */ |
| 410 | { |
| 411 | .virtual = 0xe6000000, |
| 412 | .pfn = __phys_to_pfn(0xe6000000), |
| 413 | .length = 256 << 20, |
| 414 | .type = MT_DEVICE_NONSHARED |
| 415 | }, |
| 416 | }; |
| 417 | |
| 418 | static void __init ap4evb_map_io(void) |
| 419 | { |
| 420 | iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc)); |
| 421 | |
Magnus Damm | 495b3ce | 2010-05-12 14:21:34 +0000 | [diff] [blame] | 422 | /* setup early devices and console here as well */ |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 423 | sh7372_add_early_devices(); |
Magnus Damm | 4ae04ac | 2010-02-08 11:02:54 +0000 | [diff] [blame] | 424 | shmobile_setup_console(); |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 425 | } |
| 426 | |
Guennadi Liakhovetski | 8eda2f2 | 2010-05-23 14:04:03 +0000 | [diff] [blame] | 427 | /* This function will disappear when we switch to (runtime) PM */ |
| 428 | static int __init ap4evb_init_display_clk(void) |
| 429 | { |
| 430 | struct clk *lcdc_clk; |
| 431 | struct clk *dsitx_clk; |
| 432 | int ret; |
| 433 | |
| 434 | lcdc_clk = clk_get(&lcdc_device.dev, "sh_mobile_lcdc_fb.0"); |
| 435 | if (IS_ERR(lcdc_clk)) |
| 436 | return PTR_ERR(lcdc_clk); |
| 437 | |
| 438 | dsitx_clk = clk_get(&mipidsi0_device.dev, "sh-mipi-dsi.0"); |
| 439 | if (IS_ERR(dsitx_clk)) { |
| 440 | ret = PTR_ERR(dsitx_clk); |
| 441 | goto eclkdsitxget; |
| 442 | } |
| 443 | |
| 444 | ret = clk_enable(lcdc_clk); |
| 445 | if (ret < 0) |
| 446 | goto eclklcdcon; |
| 447 | |
| 448 | ret = clk_enable(dsitx_clk); |
| 449 | if (ret < 0) |
| 450 | goto eclkdsitxon; |
| 451 | |
| 452 | return 0; |
| 453 | |
| 454 | eclkdsitxon: |
| 455 | clk_disable(lcdc_clk); |
| 456 | eclklcdcon: |
| 457 | clk_put(dsitx_clk); |
| 458 | eclkdsitxget: |
| 459 | clk_put(lcdc_clk); |
| 460 | |
| 461 | return ret; |
| 462 | } |
| 463 | |
| 464 | device_initcall(ap4evb_init_display_clk); |
| 465 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 466 | static void __init ap4evb_init(void) |
| 467 | { |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 468 | sh7372_pinmux_init(); |
| 469 | |
Kuninori Morimoto | b228b48 | 2010-02-18 16:44:41 +0900 | [diff] [blame] | 470 | /* enable SCIFA0 */ |
| 471 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); |
| 472 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); |
| 473 | |
Kuninori Morimoto | 1b7e067 | 2010-02-17 09:30:14 +0000 | [diff] [blame] | 474 | /* enable SMSC911X */ |
| 475 | gpio_request(GPIO_FN_CS5A, NULL); |
| 476 | gpio_request(GPIO_FN_IRQ6_39, NULL); |
| 477 | |
Kuninori Morimoto | 5098280 | 2010-02-22 09:20:39 +0000 | [diff] [blame] | 478 | /* enable LED 1 - 4 */ |
| 479 | gpio_request(GPIO_PORT185, NULL); |
| 480 | gpio_request(GPIO_PORT186, NULL); |
| 481 | gpio_request(GPIO_PORT187, NULL); |
| 482 | gpio_request(GPIO_PORT188, NULL); |
| 483 | gpio_direction_output(GPIO_PORT185, 1); |
| 484 | gpio_direction_output(GPIO_PORT186, 1); |
| 485 | gpio_direction_output(GPIO_PORT187, 1); |
| 486 | gpio_direction_output(GPIO_PORT188, 1); |
| 487 | gpio_export(GPIO_PORT185, 0); |
| 488 | gpio_export(GPIO_PORT186, 0); |
| 489 | gpio_export(GPIO_PORT187, 0); |
| 490 | gpio_export(GPIO_PORT188, 0); |
| 491 | |
Kuninori Morimoto | 8cb3a2e | 2010-02-22 09:30:12 +0000 | [diff] [blame] | 492 | /* enable Debug switch (S6) */ |
| 493 | gpio_request(GPIO_PORT32, NULL); |
| 494 | gpio_request(GPIO_PORT33, NULL); |
| 495 | gpio_request(GPIO_PORT34, NULL); |
| 496 | gpio_request(GPIO_PORT35, NULL); |
| 497 | gpio_direction_input(GPIO_PORT32); |
| 498 | gpio_direction_input(GPIO_PORT33); |
| 499 | gpio_direction_input(GPIO_PORT34); |
| 500 | gpio_direction_input(GPIO_PORT35); |
| 501 | gpio_export(GPIO_PORT32, 0); |
| 502 | gpio_export(GPIO_PORT33, 0); |
| 503 | gpio_export(GPIO_PORT34, 0); |
| 504 | gpio_export(GPIO_PORT35, 0); |
| 505 | |
Kuninori Morimoto | 17ccb83 | 2010-02-23 07:07:01 +0000 | [diff] [blame] | 506 | /* enable KEYSC */ |
| 507 | gpio_request(GPIO_FN_KEYOUT0, NULL); |
| 508 | gpio_request(GPIO_FN_KEYOUT1, NULL); |
| 509 | gpio_request(GPIO_FN_KEYOUT2, NULL); |
| 510 | gpio_request(GPIO_FN_KEYOUT3, NULL); |
| 511 | gpio_request(GPIO_FN_KEYOUT4, NULL); |
| 512 | gpio_request(GPIO_FN_KEYIN0_136, NULL); |
| 513 | gpio_request(GPIO_FN_KEYIN1_135, NULL); |
| 514 | gpio_request(GPIO_FN_KEYIN2_134, NULL); |
| 515 | gpio_request(GPIO_FN_KEYIN3_133, NULL); |
| 516 | gpio_request(GPIO_FN_KEYIN4, NULL); |
| 517 | |
Magnus Damm | 3a14d03 | 2010-03-10 09:26:44 +0000 | [diff] [blame] | 518 | /* SDHI0 */ |
| 519 | gpio_request(GPIO_FN_SDHICD0, NULL); |
| 520 | gpio_request(GPIO_FN_SDHIWP0, NULL); |
| 521 | gpio_request(GPIO_FN_SDHICMD0, NULL); |
| 522 | gpio_request(GPIO_FN_SDHICLK0, NULL); |
| 523 | gpio_request(GPIO_FN_SDHID0_3, NULL); |
| 524 | gpio_request(GPIO_FN_SDHID0_2, NULL); |
| 525 | gpio_request(GPIO_FN_SDHID0_1, NULL); |
| 526 | gpio_request(GPIO_FN_SDHID0_0, NULL); |
| 527 | |
Kuninori Morimoto | 91cf508 | 2010-03-11 10:42:52 +0000 | [diff] [blame] | 528 | /* enable TouchScreen */ |
| 529 | gpio_request(GPIO_FN_IRQ28_123, NULL); |
| 530 | set_irq_type(IRQ28, IRQ_TYPE_LEVEL_LOW); |
| 531 | |
| 532 | i2c_register_board_info(1, i2c1_devices, |
| 533 | ARRAY_SIZE(i2c1_devices)); |
| 534 | |
Kuninori Morimoto | fb54d26 | 2010-04-13 06:16:32 +0000 | [diff] [blame] | 535 | /* USB enable */ |
| 536 | gpio_request(GPIO_FN_VBUS0_1, NULL); |
| 537 | gpio_request(GPIO_FN_IDIN_1_18, NULL); |
| 538 | gpio_request(GPIO_FN_PWEN_1_115, NULL); |
| 539 | gpio_request(GPIO_FN_OVCN_1_114, NULL); |
| 540 | gpio_request(GPIO_FN_EXTLP_1, NULL); |
| 541 | gpio_request(GPIO_FN_OVCN2_1, NULL); |
| 542 | |
| 543 | /* setup USB phy */ |
| 544 | __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */ |
| 545 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 546 | sh7372_add_standard_devices(); |
| 547 | |
| 548 | platform_add_devices(ap4evb_devices, ARRAY_SIZE(ap4evb_devices)); |
| 549 | } |
| 550 | |
Magnus Damm | 495b3ce | 2010-05-12 14:21:34 +0000 | [diff] [blame] | 551 | static void __init ap4evb_timer_init(void) |
| 552 | { |
| 553 | sh7372_clock_init(); |
| 554 | shmobile_timer.init(); |
| 555 | } |
| 556 | |
| 557 | static struct sys_timer ap4evb_timer = { |
| 558 | .init = ap4evb_timer_init, |
| 559 | }; |
| 560 | |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 561 | MACHINE_START(AP4EVB, "ap4evb") |
| 562 | .phys_io = 0xe6000000, |
| 563 | .io_pg_offst = ((0xe6000000) >> 18) & 0xfffc, |
| 564 | .map_io = ap4evb_map_io, |
| 565 | .init_irq = sh7372_init_irq, |
| 566 | .init_machine = ap4evb_init, |
Magnus Damm | 495b3ce | 2010-05-12 14:21:34 +0000 | [diff] [blame] | 567 | .timer = &ap4evb_timer, |
Magnus Damm | 2b7eda6 | 2010-02-05 11:14:58 +0000 | [diff] [blame] | 568 | MACHINE_END |