Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * mackerel board support |
| 3 | * |
| 4 | * Copyright (C) 2010 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 6 | * |
| 7 | * based on ap4evb |
| 8 | * Copyright (C) 2010 Magnus Damm |
| 9 | * Copyright (C) 2008 Yoshihiro Shimoda |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; version 2 of the License. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | */ |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/interrupt.h> |
| 27 | #include <linux/irq.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/gpio.h> |
| 30 | #include <linux/input.h> |
| 31 | #include <linux/io.h> |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 32 | #include <linux/i2c.h> |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 33 | #include <linux/leds.h> |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 34 | #include <linux/mfd/sh_mobile_sdhi.h> |
| 35 | #include <linux/mfd/tmio.h> |
| 36 | #include <linux/mmc/host.h> |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 37 | #include <linux/mmc/sh_mmcif.h> |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 38 | #include <linux/mtd/mtd.h> |
| 39 | #include <linux/mtd/partitions.h> |
| 40 | #include <linux/mtd/physmap.h> |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 41 | #include <linux/smsc911x.h> |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 42 | #include <linux/sh_intc.h> |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 43 | #include <linux/tca6416_keypad.h> |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 44 | #include <linux/usb/r8a66597.h> |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 45 | |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 46 | #include <video/sh_mobile_lcdc.h> |
| 47 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 48 | #include <sound/sh_fsi.h> |
| 49 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 50 | #include <mach/common.h> |
| 51 | #include <mach/sh7372.h> |
| 52 | |
| 53 | #include <asm/mach/arch.h> |
| 54 | #include <asm/mach/time.h> |
| 55 | #include <asm/mach/map.h> |
| 56 | #include <asm/mach-types.h> |
| 57 | |
| 58 | /* |
| 59 | * Address Interface BusWidth note |
| 60 | * ------------------------------------------------------------------ |
| 61 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON |
| 62 | * 0x0800_0000 user area - |
| 63 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF |
| 64 | * 0x1400_0000 Ether (LAN9220) 16bit |
| 65 | * 0x1600_0000 user area - cannot use with NAND |
| 66 | * 0x1800_0000 user area - |
| 67 | * 0x1A00_0000 - |
| 68 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit |
| 69 | */ |
| 70 | |
Kuninori Morimoto | 4b82b68 | 2010-11-29 02:21:48 +0000 | [diff] [blame] | 71 | /* |
| 72 | * CPU mode |
| 73 | * |
| 74 | * SW4 | Boot Area| Master | Remarks |
| 75 | * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor| |
| 76 | * ----+-----+-----+-----+-----+-----+-----+----------+----------+-------------- |
| 77 | * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM |
| 78 | * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug |
| 79 | * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug |
| 80 | * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM |
| 81 | * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM |
| 82 | * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM |
| 83 | * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone |
| 84 | * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone |
| 85 | */ |
| 86 | |
| 87 | /* |
| 88 | * NOR Flash ROM |
| 89 | * |
| 90 | * SW1 | SW2 | SW7 | NOR Flash ROM |
| 91 | * bit1 | bit1 bit2 | bit1 | Memory allocation |
| 92 | * ------+------------+------+------------------ |
| 93 | * OFF | ON OFF | ON | Area 0 |
| 94 | * OFF | ON OFF | OFF | Area 4 |
| 95 | */ |
| 96 | |
| 97 | /* |
| 98 | * SMSC 9220 |
| 99 | * |
| 100 | * SW1 SMSC 9220 |
| 101 | * ----------------------- |
| 102 | * ON access disable |
| 103 | * OFF access enable |
| 104 | */ |
| 105 | |
| 106 | /* |
| 107 | * NAND Flash ROM |
| 108 | * |
| 109 | * SW1 | SW2 | SW7 | NAND Flash ROM |
| 110 | * bit1 | bit1 bit2 | bit2 | Memory allocation |
| 111 | * ------+------------+------+------------------ |
| 112 | * OFF | ON OFF | ON | FCE 0 |
| 113 | * OFF | ON OFF | OFF | FCE 1 |
| 114 | */ |
| 115 | |
| 116 | /* |
| 117 | * External interrupt pin settings |
| 118 | * |
| 119 | * IRQX | pin setting | device | level |
| 120 | * ------+--------------------+--------------------+------- |
| 121 | * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low |
| 122 | * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High |
| 123 | * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Tuch Panel | Low |
| 124 | * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low |
| 125 | * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low |
| 126 | * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High |
| 127 | * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 128 | */ |
Kuninori Morimoto | 4b82b68 | 2010-11-29 02:21:48 +0000 | [diff] [blame] | 129 | |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 130 | /* |
| 131 | * USB |
| 132 | * |
| 133 | * USB0 : CN22 : Function |
| 134 | * USB1 : CN31 : Function/Host *1 |
| 135 | * |
| 136 | * J30 (for CN31) *1 |
| 137 | * ----------+---------------+------------- |
| 138 | * 1-2 short | VBUS 5V | Host |
| 139 | * open | external VBUS | Function |
| 140 | * |
| 141 | * *1 |
| 142 | * CN31 is used as Host in Linux. |
| 143 | */ |
Kuninori Morimoto | 4b82b68 | 2010-11-29 02:21:48 +0000 | [diff] [blame] | 144 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 145 | /* |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 146 | * SDHI0 (CN12) |
| 147 | * |
| 148 | * SW56 : OFF |
| 149 | * |
| 150 | */ |
| 151 | |
| 152 | /* MMC /SDHI1 (CN7) |
| 153 | * |
| 154 | * I/O voltage : 1.8v |
| 155 | * |
| 156 | * Power voltage : 1.8v or 3.3v |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 157 | * J22 : select power voltage *1 |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 158 | * 1-2 pin : 1.8v |
| 159 | * 2-3 pin : 3.3v |
| 160 | * |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 161 | * *1 |
| 162 | * Please change J22 depends the card to be used. |
| 163 | * MMC's OCR field set to support either voltage for the card inserted. |
| 164 | * |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 165 | * SW1 | SW33 |
| 166 | * | bit1 | bit2 | bit3 | bit4 |
| 167 | * -------------+------+------+------+------- |
| 168 | * MMC0 OFF | OFF | ON | ON | X |
| 169 | * MMC1 ON | OFF | ON | X | ON |
| 170 | * SDHI1 OFF | ON | X | OFF | ON |
| 171 | * |
| 172 | */ |
| 173 | |
| 174 | /* |
| 175 | * SDHI2 (CN23) |
| 176 | * |
| 177 | * microSD card sloct |
| 178 | * |
| 179 | */ |
| 180 | |
| 181 | /* |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 182 | * FIXME !! |
| 183 | * |
| 184 | * gpio_no_direction |
| 185 | * are quick_hack. |
| 186 | * |
| 187 | * current gpio frame work doesn't have |
| 188 | * the method to control only pull up/down/free. |
| 189 | * this function should be replaced by correct gpio function |
| 190 | */ |
| 191 | static void __init gpio_no_direction(u32 addr) |
| 192 | { |
| 193 | __raw_writeb(0x00, addr); |
| 194 | } |
| 195 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 196 | /* MTD */ |
| 197 | static struct mtd_partition nor_flash_partitions[] = { |
| 198 | { |
| 199 | .name = "loader", |
| 200 | .offset = 0x00000000, |
| 201 | .size = 512 * 1024, |
| 202 | .mask_flags = MTD_WRITEABLE, |
| 203 | }, |
| 204 | { |
| 205 | .name = "bootenv", |
| 206 | .offset = MTDPART_OFS_APPEND, |
| 207 | .size = 512 * 1024, |
| 208 | .mask_flags = MTD_WRITEABLE, |
| 209 | }, |
| 210 | { |
| 211 | .name = "kernel_ro", |
| 212 | .offset = MTDPART_OFS_APPEND, |
| 213 | .size = 8 * 1024 * 1024, |
| 214 | .mask_flags = MTD_WRITEABLE, |
| 215 | }, |
| 216 | { |
| 217 | .name = "kernel", |
| 218 | .offset = MTDPART_OFS_APPEND, |
| 219 | .size = 8 * 1024 * 1024, |
| 220 | }, |
| 221 | { |
| 222 | .name = "data", |
| 223 | .offset = MTDPART_OFS_APPEND, |
| 224 | .size = MTDPART_SIZ_FULL, |
| 225 | }, |
| 226 | }; |
| 227 | |
| 228 | static struct physmap_flash_data nor_flash_data = { |
| 229 | .width = 2, |
| 230 | .parts = nor_flash_partitions, |
| 231 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 232 | }; |
| 233 | |
| 234 | static struct resource nor_flash_resources[] = { |
| 235 | [0] = { |
| 236 | .start = 0x00000000, |
| 237 | .end = 0x08000000 - 1, |
| 238 | .flags = IORESOURCE_MEM, |
| 239 | } |
| 240 | }; |
| 241 | |
| 242 | static struct platform_device nor_flash_device = { |
| 243 | .name = "physmap-flash", |
| 244 | .dev = { |
| 245 | .platform_data = &nor_flash_data, |
| 246 | }, |
| 247 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 248 | .resource = nor_flash_resources, |
| 249 | }; |
| 250 | |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 251 | /* SMSC */ |
| 252 | static struct resource smc911x_resources[] = { |
| 253 | { |
| 254 | .start = 0x14000000, |
| 255 | .end = 0x16000000 - 1, |
| 256 | .flags = IORESOURCE_MEM, |
| 257 | }, { |
| 258 | .start = evt2irq(0x02c0) /* IRQ6A */, |
| 259 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 260 | }, |
| 261 | }; |
| 262 | |
| 263 | static struct smsc911x_platform_config smsc911x_info = { |
| 264 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 265 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 266 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 267 | }; |
| 268 | |
| 269 | static struct platform_device smc911x_device = { |
| 270 | .name = "smsc911x", |
| 271 | .id = -1, |
| 272 | .num_resources = ARRAY_SIZE(smc911x_resources), |
| 273 | .resource = smc911x_resources, |
| 274 | .dev = { |
| 275 | .platform_data = &smsc911x_info, |
| 276 | }, |
| 277 | }; |
| 278 | |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 279 | /* LCDC */ |
| 280 | static struct fb_videomode mackerel_lcdc_modes[] = { |
| 281 | { |
| 282 | .name = "WVGA Panel", |
| 283 | .xres = 800, |
| 284 | .yres = 480, |
| 285 | .left_margin = 220, |
| 286 | .right_margin = 110, |
| 287 | .hsync_len = 70, |
| 288 | .upper_margin = 20, |
| 289 | .lower_margin = 5, |
| 290 | .vsync_len = 5, |
| 291 | .sync = 0, |
| 292 | }, |
| 293 | }; |
| 294 | |
| 295 | static struct sh_mobile_lcdc_info lcdc_info = { |
| 296 | .clock_source = LCDC_CLK_BUS, |
| 297 | .ch[0] = { |
| 298 | .chan = LCDC_CHAN_MAINLCD, |
| 299 | .bpp = 16, |
| 300 | .lcd_cfg = mackerel_lcdc_modes, |
| 301 | .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes), |
| 302 | .interface_type = RGB24, |
| 303 | .clock_divider = 2, |
| 304 | .flags = 0, |
| 305 | .lcd_size_cfg.width = 152, |
| 306 | .lcd_size_cfg.height = 91, |
| 307 | } |
| 308 | }; |
| 309 | |
| 310 | static struct resource lcdc_resources[] = { |
| 311 | [0] = { |
| 312 | .name = "LCDC", |
| 313 | .start = 0xfe940000, |
| 314 | .end = 0xfe943fff, |
| 315 | .flags = IORESOURCE_MEM, |
| 316 | }, |
| 317 | [1] = { |
| 318 | .start = intcs_evt2irq(0x580), |
| 319 | .flags = IORESOURCE_IRQ, |
| 320 | }, |
| 321 | }; |
| 322 | |
| 323 | static struct platform_device lcdc_device = { |
| 324 | .name = "sh_mobile_lcdc_fb", |
| 325 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 326 | .resource = lcdc_resources, |
| 327 | .dev = { |
| 328 | .platform_data = &lcdc_info, |
| 329 | .coherent_dma_mask = ~0, |
| 330 | }, |
| 331 | }; |
| 332 | |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 333 | /* USB1 (Host) */ |
| 334 | static void usb1_host_port_power(int port, int power) |
| 335 | { |
| 336 | if (!power) /* only power-on is supported for now */ |
| 337 | return; |
| 338 | |
| 339 | /* set VBOUT/PWEN and EXTLP1 in DVSTCTR */ |
| 340 | __raw_writew(__raw_readw(0xE68B0008) | 0x600, 0xE68B0008); |
| 341 | } |
| 342 | |
| 343 | static struct r8a66597_platdata usb1_host_data = { |
| 344 | .on_chip = 1, |
| 345 | .port_power = usb1_host_port_power, |
| 346 | }; |
| 347 | |
| 348 | static struct resource usb1_host_resources[] = { |
| 349 | [0] = { |
| 350 | .name = "USBHS", |
| 351 | .start = 0xE68B0000, |
| 352 | .end = 0xE68B00E6 - 1, |
| 353 | .flags = IORESOURCE_MEM, |
| 354 | }, |
| 355 | [1] = { |
| 356 | .start = evt2irq(0x1ce0) /* USB1_USB1I0 */, |
| 357 | .flags = IORESOURCE_IRQ, |
| 358 | }, |
| 359 | }; |
| 360 | |
| 361 | static struct platform_device usb1_host_device = { |
| 362 | .name = "r8a66597_hcd", |
| 363 | .id = 1, |
| 364 | .dev = { |
| 365 | .dma_mask = NULL, /* not use dma */ |
| 366 | .coherent_dma_mask = 0xffffffff, |
| 367 | .platform_data = &usb1_host_data, |
| 368 | }, |
| 369 | .num_resources = ARRAY_SIZE(usb1_host_resources), |
| 370 | .resource = usb1_host_resources, |
| 371 | }; |
| 372 | |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 373 | /* LED */ |
| 374 | static struct gpio_led mackerel_leds[] = { |
| 375 | { |
| 376 | .name = "led0", |
| 377 | .gpio = GPIO_PORT0, |
| 378 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 379 | }, |
| 380 | { |
| 381 | .name = "led1", |
| 382 | .gpio = GPIO_PORT1, |
| 383 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 384 | }, |
| 385 | { |
| 386 | .name = "led2", |
| 387 | .gpio = GPIO_PORT2, |
| 388 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 389 | }, |
| 390 | { |
| 391 | .name = "led3", |
| 392 | .gpio = GPIO_PORT159, |
| 393 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 394 | } |
| 395 | }; |
| 396 | |
| 397 | static struct gpio_led_platform_data mackerel_leds_pdata = { |
| 398 | .leds = mackerel_leds, |
| 399 | .num_leds = ARRAY_SIZE(mackerel_leds), |
| 400 | }; |
| 401 | |
| 402 | static struct platform_device leds_device = { |
| 403 | .name = "leds-gpio", |
| 404 | .id = 0, |
| 405 | .dev = { |
| 406 | .platform_data = &mackerel_leds_pdata, |
| 407 | }, |
| 408 | }; |
| 409 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 410 | /* FSI */ |
| 411 | #define IRQ_FSI evt2irq(0x1840) |
| 412 | static struct sh_fsi_platform_info fsi_info = { |
| 413 | .porta_flags = SH_FSI_BRS_INV | |
| 414 | SH_FSI_OUT_SLAVE_MODE | |
| 415 | SH_FSI_IN_SLAVE_MODE | |
| 416 | SH_FSI_OFMT(PCM) | |
| 417 | SH_FSI_IFMT(PCM), |
| 418 | }; |
| 419 | |
| 420 | static struct resource fsi_resources[] = { |
| 421 | [0] = { |
| 422 | .name = "FSI", |
| 423 | .start = 0xFE3C0000, |
| 424 | .end = 0xFE3C0400 - 1, |
| 425 | .flags = IORESOURCE_MEM, |
| 426 | }, |
| 427 | [1] = { |
| 428 | .start = IRQ_FSI, |
| 429 | .flags = IORESOURCE_IRQ, |
| 430 | }, |
| 431 | }; |
| 432 | |
| 433 | static struct platform_device fsi_device = { |
| 434 | .name = "sh_fsi2", |
| 435 | .id = -1, |
| 436 | .num_resources = ARRAY_SIZE(fsi_resources), |
| 437 | .resource = fsi_resources, |
| 438 | .dev = { |
| 439 | .platform_data = &fsi_info, |
| 440 | }, |
| 441 | }; |
| 442 | |
| 443 | static struct platform_device fsi_ak4643_device = { |
| 444 | .name = "sh_fsi2_a_ak4643", |
| 445 | }; |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 446 | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 447 | /* |
| 448 | * The card detect pin of the top SD/MMC slot (CN7) is active low and is |
| 449 | * connected to GPIO A22 of SH7372 (GPIO_PORT41). |
| 450 | */ |
| 451 | static int slot_cn7_get_cd(struct platform_device *pdev) |
| 452 | { |
| 453 | if (gpio_is_valid(GPIO_PORT41)) |
| 454 | return !gpio_get_value(GPIO_PORT41); |
| 455 | else |
| 456 | return -ENXIO; |
| 457 | } |
| 458 | |
| 459 | /* SDHI0 */ |
| 460 | static struct sh_mobile_sdhi_info sdhi0_info = { |
| 461 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, |
| 462 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, |
| 463 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, |
| 464 | }; |
| 465 | |
| 466 | static struct resource sdhi0_resources[] = { |
| 467 | [0] = { |
| 468 | .name = "SDHI0", |
| 469 | .start = 0xe6850000, |
| 470 | .end = 0xe68501ff, |
| 471 | .flags = IORESOURCE_MEM, |
| 472 | }, |
| 473 | [1] = { |
| 474 | .start = evt2irq(0x0e00) /* SDHI0 */, |
| 475 | .flags = IORESOURCE_IRQ, |
| 476 | }, |
| 477 | }; |
| 478 | |
| 479 | static struct platform_device sdhi0_device = { |
| 480 | .name = "sh_mobile_sdhi", |
| 481 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 482 | .resource = sdhi0_resources, |
| 483 | .id = 0, |
| 484 | .dev = { |
| 485 | .platform_data = &sdhi0_info, |
| 486 | }, |
| 487 | }; |
| 488 | |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 489 | #if !defined(CONFIG_MMC_SH_MMCIF) |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 490 | /* SDHI1 */ |
| 491 | static struct sh_mobile_sdhi_info sdhi1_info = { |
| 492 | .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, |
| 493 | .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, |
| 494 | .tmio_ocr_mask = MMC_VDD_165_195, |
| 495 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, |
| 496 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | |
| 497 | MMC_CAP_NEEDS_POLL, |
| 498 | .get_cd = slot_cn7_get_cd, |
| 499 | }; |
| 500 | |
| 501 | static struct resource sdhi1_resources[] = { |
| 502 | [0] = { |
| 503 | .name = "SDHI1", |
| 504 | .start = 0xe6860000, |
| 505 | .end = 0xe68601ff, |
| 506 | .flags = IORESOURCE_MEM, |
| 507 | }, |
| 508 | [1] = { |
| 509 | .start = evt2irq(0x0e80), |
| 510 | .flags = IORESOURCE_IRQ, |
| 511 | }, |
| 512 | }; |
| 513 | |
| 514 | static struct platform_device sdhi1_device = { |
| 515 | .name = "sh_mobile_sdhi", |
| 516 | .num_resources = ARRAY_SIZE(sdhi1_resources), |
| 517 | .resource = sdhi1_resources, |
| 518 | .id = 1, |
| 519 | .dev = { |
| 520 | .platform_data = &sdhi1_info, |
| 521 | }, |
| 522 | }; |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 523 | #endif |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 524 | |
| 525 | /* SDHI2 */ |
| 526 | static struct sh_mobile_sdhi_info sdhi2_info = { |
| 527 | .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX, |
| 528 | .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX, |
| 529 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, |
| 530 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | |
| 531 | MMC_CAP_NEEDS_POLL, |
| 532 | }; |
| 533 | |
| 534 | static struct resource sdhi2_resources[] = { |
| 535 | [0] = { |
| 536 | .name = "SDHI2", |
| 537 | .start = 0xe6870000, |
| 538 | .end = 0xe68701ff, |
| 539 | .flags = IORESOURCE_MEM, |
| 540 | }, |
| 541 | [1] = { |
| 542 | .start = evt2irq(0x1200), |
| 543 | .flags = IORESOURCE_IRQ, |
| 544 | }, |
| 545 | }; |
| 546 | |
| 547 | static struct platform_device sdhi2_device = { |
| 548 | .name = "sh_mobile_sdhi", |
| 549 | .num_resources = ARRAY_SIZE(sdhi2_resources), |
| 550 | .resource = sdhi2_resources, |
| 551 | .id = 2, |
| 552 | .dev = { |
| 553 | .platform_data = &sdhi2_info, |
| 554 | }, |
| 555 | }; |
| 556 | |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 557 | /* SH_MMCIF */ |
| 558 | static struct resource sh_mmcif_resources[] = { |
| 559 | [0] = { |
| 560 | .name = "MMCIF", |
| 561 | .start = 0xE6BD0000, |
| 562 | .end = 0xE6BD00FF, |
| 563 | .flags = IORESOURCE_MEM, |
| 564 | }, |
| 565 | [1] = { |
| 566 | /* MMC ERR */ |
| 567 | .start = evt2irq(0x1ac0), |
| 568 | .flags = IORESOURCE_IRQ, |
| 569 | }, |
| 570 | [2] = { |
| 571 | /* MMC NOR */ |
| 572 | .start = evt2irq(0x1ae0), |
| 573 | .flags = IORESOURCE_IRQ, |
| 574 | }, |
| 575 | }; |
| 576 | |
| 577 | static struct sh_mmcif_plat_data sh_mmcif_plat = { |
| 578 | .sup_pclk = 0, |
| 579 | .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, |
| 580 | .caps = MMC_CAP_4_BIT_DATA | |
| 581 | MMC_CAP_8_BIT_DATA | |
| 582 | MMC_CAP_NEEDS_POLL, |
| 583 | .get_cd = slot_cn7_get_cd, |
| 584 | }; |
| 585 | |
| 586 | static struct platform_device sh_mmcif_device = { |
| 587 | .name = "sh_mmcif", |
| 588 | .id = 0, |
| 589 | .dev = { |
| 590 | .dma_mask = NULL, |
| 591 | .coherent_dma_mask = 0xffffffff, |
| 592 | .platform_data = &sh_mmcif_plat, |
| 593 | }, |
| 594 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), |
| 595 | .resource = sh_mmcif_resources, |
| 596 | }; |
| 597 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 598 | static struct platform_device *mackerel_devices[] __initdata = { |
| 599 | &nor_flash_device, |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 600 | &smc911x_device, |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 601 | &lcdc_device, |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 602 | &usb1_host_device, |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 603 | &leds_device, |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 604 | &fsi_device, |
| 605 | &fsi_ak4643_device, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 606 | &sdhi0_device, |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 607 | #if !defined(CONFIG_MMC_SH_MMCIF) |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 608 | &sdhi1_device, |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 609 | #endif |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 610 | &sdhi2_device, |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 611 | &sh_mmcif_device, |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 612 | }; |
| 613 | |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 614 | /* Keypad Initialization */ |
| 615 | #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \ |
| 616 | { \ |
| 617 | .type = ev_type, \ |
| 618 | .code = ev_code, \ |
| 619 | .active_low = act_low, \ |
| 620 | } |
| 621 | |
| 622 | #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1) |
| 623 | |
| 624 | static struct tca6416_button mackerel_gpio_keys[] = { |
| 625 | KEYPAD_BUTTON_LOW(KEY_HOME), |
| 626 | KEYPAD_BUTTON_LOW(KEY_MENU), |
| 627 | KEYPAD_BUTTON_LOW(KEY_BACK), |
| 628 | KEYPAD_BUTTON_LOW(KEY_POWER), |
| 629 | }; |
| 630 | |
| 631 | static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = { |
| 632 | .buttons = mackerel_gpio_keys, |
| 633 | .nbuttons = ARRAY_SIZE(mackerel_gpio_keys), |
| 634 | .rep = 1, |
| 635 | .use_polling = 0, |
| 636 | .pinmask = 0x000F, |
| 637 | }; |
| 638 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 639 | /* I2C */ |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 640 | #define IRQ9 evt2irq(0x0320) |
| 641 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 642 | static struct i2c_board_info i2c0_devices[] = { |
| 643 | { |
| 644 | I2C_BOARD_INFO("ak4643", 0x13), |
| 645 | }, |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 646 | /* Keypad */ |
| 647 | { |
| 648 | I2C_BOARD_INFO("tca6408-keys", 0x20), |
| 649 | .platform_data = &mackerel_tca6416_keys_info, |
| 650 | .irq = IRQ9, |
| 651 | }, |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 652 | }; |
| 653 | |
Tony SIM | 80f1dc7 | 2010-12-07 09:12:14 +0000 | [diff] [blame] | 654 | #define IRQ21 evt2irq(0x32a0) |
| 655 | |
| 656 | static struct i2c_board_info i2c1_devices[] = { |
| 657 | /* Accelerometer */ |
| 658 | { |
| 659 | I2C_BOARD_INFO("adxl34x", 0x53), |
| 660 | .irq = IRQ21, |
| 661 | }, |
| 662 | }; |
| 663 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 664 | static struct map_desc mackerel_io_desc[] __initdata = { |
| 665 | /* create a 1:1 entity map for 0xe6xxxxxx |
| 666 | * used by CPGA, INTC and PFC. |
| 667 | */ |
| 668 | { |
| 669 | .virtual = 0xe6000000, |
| 670 | .pfn = __phys_to_pfn(0xe6000000), |
| 671 | .length = 256 << 20, |
| 672 | .type = MT_DEVICE_NONSHARED |
| 673 | }, |
| 674 | }; |
| 675 | |
| 676 | static void __init mackerel_map_io(void) |
| 677 | { |
| 678 | iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc)); |
| 679 | |
| 680 | /* setup early devices and console here as well */ |
| 681 | sh7372_add_early_devices(); |
| 682 | shmobile_setup_console(); |
| 683 | } |
| 684 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 685 | #define GPIO_PORT9CR 0xE6051009 |
| 686 | #define GPIO_PORT10CR 0xE605100A |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 687 | static void __init mackerel_init(void) |
| 688 | { |
| 689 | sh7372_pinmux_init(); |
| 690 | |
| 691 | /* enable SCIFA0 */ |
| 692 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); |
| 693 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); |
| 694 | |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 695 | /* enable SMSC911X */ |
| 696 | gpio_request(GPIO_FN_CS5A, NULL); |
| 697 | gpio_request(GPIO_FN_IRQ6_39, NULL); |
| 698 | |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 699 | /* LCDC */ |
Kuninori Morimoto | eb87e67 | 2010-11-29 06:19:52 +0000 | [diff] [blame] | 700 | gpio_request(GPIO_FN_LCDD23, NULL); |
| 701 | gpio_request(GPIO_FN_LCDD22, NULL); |
| 702 | gpio_request(GPIO_FN_LCDD21, NULL); |
| 703 | gpio_request(GPIO_FN_LCDD20, NULL); |
| 704 | gpio_request(GPIO_FN_LCDD19, NULL); |
| 705 | gpio_request(GPIO_FN_LCDD18, NULL); |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 706 | gpio_request(GPIO_FN_LCDD17, NULL); |
| 707 | gpio_request(GPIO_FN_LCDD16, NULL); |
| 708 | gpio_request(GPIO_FN_LCDD15, NULL); |
| 709 | gpio_request(GPIO_FN_LCDD14, NULL); |
| 710 | gpio_request(GPIO_FN_LCDD13, NULL); |
| 711 | gpio_request(GPIO_FN_LCDD12, NULL); |
| 712 | gpio_request(GPIO_FN_LCDD11, NULL); |
| 713 | gpio_request(GPIO_FN_LCDD10, NULL); |
| 714 | gpio_request(GPIO_FN_LCDD9, NULL); |
| 715 | gpio_request(GPIO_FN_LCDD8, NULL); |
| 716 | gpio_request(GPIO_FN_LCDD7, NULL); |
| 717 | gpio_request(GPIO_FN_LCDD6, NULL); |
| 718 | gpio_request(GPIO_FN_LCDD5, NULL); |
| 719 | gpio_request(GPIO_FN_LCDD4, NULL); |
| 720 | gpio_request(GPIO_FN_LCDD3, NULL); |
| 721 | gpio_request(GPIO_FN_LCDD2, NULL); |
| 722 | gpio_request(GPIO_FN_LCDD1, NULL); |
| 723 | gpio_request(GPIO_FN_LCDD0, NULL); |
| 724 | gpio_request(GPIO_FN_LCDDISP, NULL); |
| 725 | gpio_request(GPIO_FN_LCDDCK, NULL); |
| 726 | |
| 727 | gpio_request(GPIO_PORT31, NULL); /* backlight */ |
| 728 | gpio_direction_output(GPIO_PORT31, 1); |
| 729 | |
| 730 | gpio_request(GPIO_PORT151, NULL); /* LCDDON */ |
| 731 | gpio_direction_output(GPIO_PORT151, 1); |
| 732 | |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 733 | /* USB enable */ |
| 734 | gpio_request(GPIO_FN_VBUS0_1, NULL); |
| 735 | gpio_request(GPIO_FN_IDIN_1_18, NULL); |
| 736 | gpio_request(GPIO_FN_PWEN_1_115, NULL); |
| 737 | gpio_request(GPIO_FN_OVCN_1_114, NULL); |
| 738 | gpio_request(GPIO_FN_EXTLP_1, NULL); |
| 739 | gpio_request(GPIO_FN_OVCN2_1, NULL); |
| 740 | |
| 741 | /* setup USB phy */ |
| 742 | __raw_writew(0x8a0a, 0xE6058130); /* USBCR2 */ |
| 743 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 744 | /* enable FSI2 port A (ak4643) */ |
| 745 | gpio_request(GPIO_FN_FSIAIBT, NULL); |
| 746 | gpio_request(GPIO_FN_FSIAILR, NULL); |
| 747 | gpio_request(GPIO_FN_FSIAISLD, NULL); |
| 748 | gpio_request(GPIO_FN_FSIAOSLD, NULL); |
| 749 | gpio_request(GPIO_PORT161, NULL); |
| 750 | gpio_direction_output(GPIO_PORT161, 0); /* slave */ |
| 751 | |
| 752 | gpio_request(GPIO_PORT9, NULL); |
| 753 | gpio_request(GPIO_PORT10, NULL); |
| 754 | gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ |
| 755 | gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ |
| 756 | |
| 757 | intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */ |
| 758 | |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 759 | /* enable Keypad */ |
| 760 | gpio_request(GPIO_FN_IRQ9_42, NULL); |
| 761 | set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH); |
| 762 | |
Tony SIM | 80f1dc7 | 2010-12-07 09:12:14 +0000 | [diff] [blame] | 763 | /* enable Accelerometer */ |
| 764 | gpio_request(GPIO_FN_IRQ21, NULL); |
| 765 | set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH); |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 766 | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 767 | /* enable SDHI0 */ |
| 768 | gpio_request(GPIO_FN_SDHICD0, NULL); |
| 769 | gpio_request(GPIO_FN_SDHIWP0, NULL); |
| 770 | gpio_request(GPIO_FN_SDHICMD0, NULL); |
| 771 | gpio_request(GPIO_FN_SDHICLK0, NULL); |
| 772 | gpio_request(GPIO_FN_SDHID0_3, NULL); |
| 773 | gpio_request(GPIO_FN_SDHID0_2, NULL); |
| 774 | gpio_request(GPIO_FN_SDHID0_1, NULL); |
| 775 | gpio_request(GPIO_FN_SDHID0_0, NULL); |
| 776 | |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 777 | #if !defined(CONFIG_MMC_SH_MMCIF) |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 778 | /* enable SDHI1 */ |
| 779 | gpio_request(GPIO_FN_SDHICMD1, NULL); |
| 780 | gpio_request(GPIO_FN_SDHICLK1, NULL); |
| 781 | gpio_request(GPIO_FN_SDHID1_3, NULL); |
| 782 | gpio_request(GPIO_FN_SDHID1_2, NULL); |
| 783 | gpio_request(GPIO_FN_SDHID1_1, NULL); |
| 784 | gpio_request(GPIO_FN_SDHID1_0, NULL); |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 785 | #endif |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 786 | /* card detect pin for MMC slot (CN7) */ |
| 787 | gpio_request(GPIO_PORT41, NULL); |
| 788 | gpio_direction_input(GPIO_PORT41); |
| 789 | |
| 790 | /* enable SDHI2 */ |
| 791 | gpio_request(GPIO_FN_SDHICMD2, NULL); |
| 792 | gpio_request(GPIO_FN_SDHICLK2, NULL); |
| 793 | gpio_request(GPIO_FN_SDHID2_3, NULL); |
| 794 | gpio_request(GPIO_FN_SDHID2_2, NULL); |
| 795 | gpio_request(GPIO_FN_SDHID2_1, NULL); |
| 796 | gpio_request(GPIO_FN_SDHID2_0, NULL); |
| 797 | |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 798 | /* MMCIF */ |
| 799 | gpio_request(GPIO_FN_MMCD0_0, NULL); |
| 800 | gpio_request(GPIO_FN_MMCD0_1, NULL); |
| 801 | gpio_request(GPIO_FN_MMCD0_2, NULL); |
| 802 | gpio_request(GPIO_FN_MMCD0_3, NULL); |
| 803 | gpio_request(GPIO_FN_MMCD0_4, NULL); |
| 804 | gpio_request(GPIO_FN_MMCD0_5, NULL); |
| 805 | gpio_request(GPIO_FN_MMCD0_6, NULL); |
| 806 | gpio_request(GPIO_FN_MMCD0_7, NULL); |
| 807 | gpio_request(GPIO_FN_MMCCMD0, NULL); |
| 808 | gpio_request(GPIO_FN_MMCCLK0, NULL); |
| 809 | |
Yusuke Goda | 56e78da | 2010-12-20 01:06:04 +0000 | [diff] [blame^] | 810 | /* enable GPS module (GT-720F) */ |
| 811 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); |
| 812 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); |
| 813 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 814 | i2c_register_board_info(0, i2c0_devices, |
| 815 | ARRAY_SIZE(i2c0_devices)); |
Tony SIM | 80f1dc7 | 2010-12-07 09:12:14 +0000 | [diff] [blame] | 816 | i2c_register_board_info(1, i2c1_devices, |
| 817 | ARRAY_SIZE(i2c1_devices)); |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 818 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 819 | sh7372_add_standard_devices(); |
| 820 | |
| 821 | platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); |
| 822 | } |
| 823 | |
| 824 | static void __init mackerel_timer_init(void) |
| 825 | { |
| 826 | sh7372_clock_init(); |
| 827 | shmobile_timer.init(); |
| 828 | } |
| 829 | |
| 830 | static struct sys_timer mackerel_timer = { |
| 831 | .init = mackerel_timer_init, |
| 832 | }; |
| 833 | |
| 834 | MACHINE_START(MACKEREL, "mackerel") |
| 835 | .map_io = mackerel_map_io, |
| 836 | .init_irq = sh7372_init_irq, |
| 837 | .init_machine = mackerel_init, |
| 838 | .timer = &mackerel_timer, |
| 839 | MACHINE_END |