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