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