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 | */ |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 24 | #include <linux/delay.h> |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 25 | #include <linux/kernel.h> |
| 26 | #include <linux/init.h> |
| 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/irq.h> |
| 29 | #include <linux/platform_device.h> |
| 30 | #include <linux/gpio.h> |
| 31 | #include <linux/input.h> |
| 32 | #include <linux/io.h> |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 33 | #include <linux/i2c.h> |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 34 | #include <linux/leds.h> |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 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> |
Guennadi Liakhovetski | 17e75d8 | 2011-03-09 11:27:56 +0100 | [diff] [blame] | 38 | #include <linux/mmc/sh_mobile_sdhi.h> |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 39 | #include <linux/mtd/mtd.h> |
| 40 | #include <linux/mtd/partitions.h> |
| 41 | #include <linux/mtd/physmap.h> |
Rafael J. Wysocki | b5e8d26 | 2011-08-25 15:34:19 +0200 | [diff] [blame] | 42 | #include <linux/pm_clock.h> |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 43 | #include <linux/smsc911x.h> |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 44 | #include <linux/sh_intc.h> |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 45 | #include <linux/tca6416_keypad.h> |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 46 | #include <linux/usb/renesas_usbhs.h> |
Jon Medhurst | 9b74202 | 2011-08-04 17:05:21 +0100 | [diff] [blame] | 47 | #include <linux/dma-mapping.h> |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 48 | |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 49 | #include <video/sh_mobile_hdmi.h> |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 50 | #include <video/sh_mobile_lcdc.h> |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 51 | #include <media/sh_mobile_ceu.h> |
| 52 | #include <media/soc_camera.h> |
| 53 | #include <media/soc_camera_platform.h> |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 54 | #include <sound/sh_fsi.h> |
| 55 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 56 | #include <mach/common.h> |
| 57 | #include <mach/sh7372.h> |
| 58 | |
| 59 | #include <asm/mach/arch.h> |
| 60 | #include <asm/mach/time.h> |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 61 | #include <asm/mach-types.h> |
| 62 | |
| 63 | /* |
| 64 | * Address Interface BusWidth note |
| 65 | * ------------------------------------------------------------------ |
| 66 | * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON |
| 67 | * 0x0800_0000 user area - |
| 68 | * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF |
| 69 | * 0x1400_0000 Ether (LAN9220) 16bit |
| 70 | * 0x1600_0000 user area - cannot use with NAND |
| 71 | * 0x1800_0000 user area - |
| 72 | * 0x1A00_0000 - |
| 73 | * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit |
| 74 | */ |
| 75 | |
Kuninori Morimoto | 4b82b68 | 2010-11-29 02:21:48 +0000 | [diff] [blame] | 76 | /* |
| 77 | * CPU mode |
| 78 | * |
| 79 | * SW4 | Boot Area| Master | Remarks |
| 80 | * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor| |
| 81 | * ----+-----+-----+-----+-----+-----+-----+----------+----------+-------------- |
| 82 | * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM |
| 83 | * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug |
| 84 | * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug |
| 85 | * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM |
| 86 | * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM |
| 87 | * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM |
| 88 | * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone |
| 89 | * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone |
| 90 | */ |
| 91 | |
| 92 | /* |
| 93 | * NOR Flash ROM |
| 94 | * |
| 95 | * SW1 | SW2 | SW7 | NOR Flash ROM |
| 96 | * bit1 | bit1 bit2 | bit1 | Memory allocation |
| 97 | * ------+------------+------+------------------ |
| 98 | * OFF | ON OFF | ON | Area 0 |
| 99 | * OFF | ON OFF | OFF | Area 4 |
| 100 | */ |
| 101 | |
| 102 | /* |
| 103 | * SMSC 9220 |
| 104 | * |
| 105 | * SW1 SMSC 9220 |
| 106 | * ----------------------- |
| 107 | * ON access disable |
| 108 | * OFF access enable |
| 109 | */ |
| 110 | |
| 111 | /* |
| 112 | * NAND Flash ROM |
| 113 | * |
| 114 | * SW1 | SW2 | SW7 | NAND Flash ROM |
| 115 | * bit1 | bit1 bit2 | bit2 | Memory allocation |
| 116 | * ------+------------+------+------------------ |
| 117 | * OFF | ON OFF | ON | FCE 0 |
| 118 | * OFF | ON OFF | OFF | FCE 1 |
| 119 | */ |
| 120 | |
| 121 | /* |
| 122 | * External interrupt pin settings |
| 123 | * |
| 124 | * IRQX | pin setting | device | level |
| 125 | * ------+--------------------+--------------------+------- |
| 126 | * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low |
| 127 | * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 128 | * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low |
Kuninori Morimoto | 4b82b68 | 2010-11-29 02:21:48 +0000 | [diff] [blame] | 129 | * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low |
| 130 | * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low |
| 131 | * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High |
| 132 | * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 133 | */ |
Kuninori Morimoto | 4b82b68 | 2010-11-29 02:21:48 +0000 | [diff] [blame] | 134 | |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 135 | /* |
| 136 | * USB |
| 137 | * |
| 138 | * USB0 : CN22 : Function |
| 139 | * USB1 : CN31 : Function/Host *1 |
| 140 | * |
| 141 | * J30 (for CN31) *1 |
| 142 | * ----------+---------------+------------- |
| 143 | * 1-2 short | VBUS 5V | Host |
| 144 | * open | external VBUS | Function |
| 145 | * |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 146 | * CAUTION |
| 147 | * |
| 148 | * renesas_usbhs driver can use external interrupt mode |
| 149 | * (which come from USB-PHY) or autonomy mode (it use own interrupt) |
| 150 | * for detecting connection/disconnection when Function. |
| 151 | * USB will be power OFF while it has been disconnecting |
| 152 | * if external interrupt mode, and it is always power ON if autonomy mode, |
| 153 | * |
| 154 | * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0", |
| 155 | * because Touchscreen is using IRQ7-PORT40. |
| 156 | * It is impossible to use IRQ7 demux on this board. |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 157 | */ |
Kuninori Morimoto | 4b82b68 | 2010-11-29 02:21:48 +0000 | [diff] [blame] | 158 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 159 | /* |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 160 | * SDHI0 (CN12) |
| 161 | * |
| 162 | * SW56 : OFF |
| 163 | * |
| 164 | */ |
| 165 | |
| 166 | /* MMC /SDHI1 (CN7) |
| 167 | * |
| 168 | * I/O voltage : 1.8v |
| 169 | * |
| 170 | * Power voltage : 1.8v or 3.3v |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 171 | * J22 : select power voltage *1 |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 172 | * 1-2 pin : 1.8v |
| 173 | * 2-3 pin : 3.3v |
| 174 | * |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 175 | * *1 |
| 176 | * Please change J22 depends the card to be used. |
| 177 | * MMC's OCR field set to support either voltage for the card inserted. |
| 178 | * |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 179 | * SW1 | SW33 |
| 180 | * | bit1 | bit2 | bit3 | bit4 |
| 181 | * -------------+------+------+------+------- |
Simon Horman | 2150dac | 2011-01-07 22:26:15 +0000 | [diff] [blame] | 182 | * MMC0 OFF | OFF | X | ON | X (Use MMCIF) |
| 183 | * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI) |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 184 | * |
| 185 | */ |
| 186 | |
| 187 | /* |
| 188 | * SDHI2 (CN23) |
| 189 | * |
| 190 | * microSD card sloct |
| 191 | * |
| 192 | */ |
| 193 | |
| 194 | /* |
Kuninori Morimoto | 6d9b7dd | 2012-01-18 16:37:07 -0800 | [diff] [blame] | 195 | * FSI - AK4642 |
| 196 | * |
| 197 | * it needs amixer settings for playing |
| 198 | * |
| 199 | * amixer set "Headphone" on |
| 200 | * amixer set "HPOUTL Mixer DACH" on |
| 201 | * amixer set "HPOUTR Mixer DACH" on |
| 202 | */ |
| 203 | |
| 204 | /* |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 205 | * FIXME !! |
| 206 | * |
| 207 | * gpio_no_direction |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 208 | * gpio_pull_down |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 209 | * are quick_hack. |
| 210 | * |
| 211 | * current gpio frame work doesn't have |
| 212 | * the method to control only pull up/down/free. |
| 213 | * this function should be replaced by correct gpio function |
| 214 | */ |
| 215 | static void __init gpio_no_direction(u32 addr) |
| 216 | { |
| 217 | __raw_writeb(0x00, addr); |
| 218 | } |
| 219 | |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 220 | static void __init gpio_pull_down(u32 addr) |
| 221 | { |
| 222 | u8 data = __raw_readb(addr); |
| 223 | |
| 224 | data &= 0x0F; |
| 225 | data |= 0xA0; |
| 226 | |
| 227 | __raw_writeb(data, addr); |
| 228 | } |
| 229 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 230 | /* MTD */ |
| 231 | static struct mtd_partition nor_flash_partitions[] = { |
| 232 | { |
| 233 | .name = "loader", |
| 234 | .offset = 0x00000000, |
| 235 | .size = 512 * 1024, |
| 236 | .mask_flags = MTD_WRITEABLE, |
| 237 | }, |
| 238 | { |
| 239 | .name = "bootenv", |
| 240 | .offset = MTDPART_OFS_APPEND, |
| 241 | .size = 512 * 1024, |
| 242 | .mask_flags = MTD_WRITEABLE, |
| 243 | }, |
| 244 | { |
| 245 | .name = "kernel_ro", |
| 246 | .offset = MTDPART_OFS_APPEND, |
| 247 | .size = 8 * 1024 * 1024, |
| 248 | .mask_flags = MTD_WRITEABLE, |
| 249 | }, |
| 250 | { |
| 251 | .name = "kernel", |
| 252 | .offset = MTDPART_OFS_APPEND, |
| 253 | .size = 8 * 1024 * 1024, |
| 254 | }, |
| 255 | { |
| 256 | .name = "data", |
| 257 | .offset = MTDPART_OFS_APPEND, |
| 258 | .size = MTDPART_SIZ_FULL, |
| 259 | }, |
| 260 | }; |
| 261 | |
| 262 | static struct physmap_flash_data nor_flash_data = { |
| 263 | .width = 2, |
| 264 | .parts = nor_flash_partitions, |
| 265 | .nr_parts = ARRAY_SIZE(nor_flash_partitions), |
| 266 | }; |
| 267 | |
| 268 | static struct resource nor_flash_resources[] = { |
| 269 | [0] = { |
Magnus Damm | 487881c | 2011-09-27 18:29:31 +0900 | [diff] [blame] | 270 | .start = 0x20000000, /* CS0 shadow instead of regular CS0 */ |
| 271 | .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */ |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 272 | .flags = IORESOURCE_MEM, |
| 273 | } |
| 274 | }; |
| 275 | |
| 276 | static struct platform_device nor_flash_device = { |
| 277 | .name = "physmap-flash", |
| 278 | .dev = { |
| 279 | .platform_data = &nor_flash_data, |
| 280 | }, |
| 281 | .num_resources = ARRAY_SIZE(nor_flash_resources), |
| 282 | .resource = nor_flash_resources, |
| 283 | }; |
| 284 | |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 285 | /* SMSC */ |
| 286 | static struct resource smc911x_resources[] = { |
| 287 | { |
| 288 | .start = 0x14000000, |
| 289 | .end = 0x16000000 - 1, |
| 290 | .flags = IORESOURCE_MEM, |
| 291 | }, { |
| 292 | .start = evt2irq(0x02c0) /* IRQ6A */, |
| 293 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL, |
| 294 | }, |
| 295 | }; |
| 296 | |
| 297 | static struct smsc911x_platform_config smsc911x_info = { |
| 298 | .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS, |
| 299 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 300 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 301 | }; |
| 302 | |
| 303 | static struct platform_device smc911x_device = { |
| 304 | .name = "smsc911x", |
| 305 | .id = -1, |
| 306 | .num_resources = ARRAY_SIZE(smc911x_resources), |
| 307 | .resource = smc911x_resources, |
| 308 | .dev = { |
| 309 | .platform_data = &smsc911x_info, |
| 310 | }, |
| 311 | }; |
| 312 | |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 313 | /* MERAM */ |
| 314 | static struct sh_mobile_meram_info mackerel_meram_info = { |
| 315 | .addr_mode = SH_MOBILE_MERAM_MODE1, |
| 316 | }; |
| 317 | |
| 318 | static struct resource meram_resources[] = { |
| 319 | [0] = { |
| 320 | .name = "MERAM", |
| 321 | .start = 0xe8000000, |
| 322 | .end = 0xe81fffff, |
| 323 | .flags = IORESOURCE_MEM, |
| 324 | }, |
| 325 | }; |
| 326 | |
| 327 | static struct platform_device meram_device = { |
| 328 | .name = "sh_mobile_meram", |
| 329 | .id = 0, |
| 330 | .num_resources = ARRAY_SIZE(meram_resources), |
| 331 | .resource = meram_resources, |
| 332 | .dev = { |
| 333 | .platform_data = &mackerel_meram_info, |
| 334 | }, |
| 335 | }; |
| 336 | |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 337 | /* LCDC */ |
| 338 | static struct fb_videomode mackerel_lcdc_modes[] = { |
| 339 | { |
| 340 | .name = "WVGA Panel", |
| 341 | .xres = 800, |
| 342 | .yres = 480, |
| 343 | .left_margin = 220, |
| 344 | .right_margin = 110, |
| 345 | .hsync_len = 70, |
| 346 | .upper_margin = 20, |
| 347 | .lower_margin = 5, |
| 348 | .vsync_len = 5, |
| 349 | .sync = 0, |
| 350 | }, |
| 351 | }; |
| 352 | |
Magnus Damm | 1fbdfcd | 2011-03-21 07:49:45 +0000 | [diff] [blame] | 353 | static int mackerel_set_brightness(void *board_data, int brightness) |
| 354 | { |
| 355 | gpio_set_value(GPIO_PORT31, brightness); |
| 356 | |
| 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | static int mackerel_get_brightness(void *board_data) |
| 361 | { |
| 362 | return gpio_get_value(GPIO_PORT31); |
| 363 | } |
| 364 | |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 365 | static struct sh_mobile_meram_cfg lcd_meram_cfg = { |
| 366 | .icb[0] = { |
| 367 | .marker_icb = 28, |
| 368 | .cache_icb = 24, |
| 369 | .meram_offset = 0x0, |
| 370 | .meram_size = 0x40, |
| 371 | }, |
| 372 | .icb[1] = { |
| 373 | .marker_icb = 29, |
| 374 | .cache_icb = 25, |
| 375 | .meram_offset = 0x40, |
| 376 | .meram_size = 0x40, |
| 377 | }, |
| 378 | }; |
| 379 | |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 380 | static struct sh_mobile_lcdc_info lcdc_info = { |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 381 | .meram_dev = &mackerel_meram_info, |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 382 | .clock_source = LCDC_CLK_BUS, |
| 383 | .ch[0] = { |
| 384 | .chan = LCDC_CHAN_MAINLCD, |
Laurent Pinchart | edd153a | 2011-12-13 14:02:28 +0100 | [diff] [blame] | 385 | .fourcc = V4L2_PIX_FMT_RGB565, |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 386 | .lcd_cfg = mackerel_lcdc_modes, |
| 387 | .num_cfg = ARRAY_SIZE(mackerel_lcdc_modes), |
| 388 | .interface_type = RGB24, |
Kuninori Morimoto | 2c34e93 | 2011-03-02 09:05:21 +0000 | [diff] [blame] | 389 | .clock_divider = 3, |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 390 | .flags = 0, |
| 391 | .lcd_size_cfg.width = 152, |
| 392 | .lcd_size_cfg.height = 91, |
Magnus Damm | 1fbdfcd | 2011-03-21 07:49:45 +0000 | [diff] [blame] | 393 | .board_cfg = { |
| 394 | .set_brightness = mackerel_set_brightness, |
| 395 | .get_brightness = mackerel_get_brightness, |
| 396 | }, |
| 397 | .bl_info = { |
| 398 | .name = "sh_mobile_lcdc_bl", |
| 399 | .max_brightness = 1, |
| 400 | }, |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 401 | .meram_cfg = &lcd_meram_cfg, |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 402 | } |
| 403 | }; |
| 404 | |
| 405 | static struct resource lcdc_resources[] = { |
| 406 | [0] = { |
| 407 | .name = "LCDC", |
| 408 | .start = 0xfe940000, |
| 409 | .end = 0xfe943fff, |
| 410 | .flags = IORESOURCE_MEM, |
| 411 | }, |
| 412 | [1] = { |
| 413 | .start = intcs_evt2irq(0x580), |
| 414 | .flags = IORESOURCE_IRQ, |
| 415 | }, |
| 416 | }; |
| 417 | |
| 418 | static struct platform_device lcdc_device = { |
| 419 | .name = "sh_mobile_lcdc_fb", |
| 420 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 421 | .resource = lcdc_resources, |
| 422 | .dev = { |
| 423 | .platform_data = &lcdc_info, |
| 424 | .coherent_dma_mask = ~0, |
| 425 | }, |
| 426 | }; |
| 427 | |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 428 | static struct sh_mobile_meram_cfg hdmi_meram_cfg = { |
| 429 | .icb[0] = { |
| 430 | .marker_icb = 30, |
| 431 | .cache_icb = 26, |
| 432 | .meram_offset = 0x80, |
| 433 | .meram_size = 0x100, |
| 434 | }, |
| 435 | .icb[1] = { |
| 436 | .marker_icb = 31, |
| 437 | .cache_icb = 27, |
| 438 | .meram_offset = 0x180, |
| 439 | .meram_size = 0x100, |
| 440 | }, |
| 441 | }; |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 442 | /* HDMI */ |
| 443 | static struct sh_mobile_lcdc_info hdmi_lcdc_info = { |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 444 | .meram_dev = &mackerel_meram_info, |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 445 | .clock_source = LCDC_CLK_EXTERNAL, |
| 446 | .ch[0] = { |
| 447 | .chan = LCDC_CHAN_MAINLCD, |
Laurent Pinchart | edd153a | 2011-12-13 14:02:28 +0100 | [diff] [blame] | 448 | .fourcc = V4L2_PIX_FMT_RGB565, |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 449 | .interface_type = RGB24, |
| 450 | .clock_divider = 1, |
| 451 | .flags = LCDC_FLAGS_DWPOL, |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 452 | .meram_cfg = &hdmi_meram_cfg, |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 453 | } |
| 454 | }; |
| 455 | |
| 456 | static struct resource hdmi_lcdc_resources[] = { |
| 457 | [0] = { |
| 458 | .name = "LCDC1", |
| 459 | .start = 0xfe944000, |
| 460 | .end = 0xfe947fff, |
| 461 | .flags = IORESOURCE_MEM, |
| 462 | }, |
| 463 | [1] = { |
| 464 | .start = intcs_evt2irq(0x1780), |
| 465 | .flags = IORESOURCE_IRQ, |
| 466 | }, |
| 467 | }; |
| 468 | |
| 469 | static struct platform_device hdmi_lcdc_device = { |
| 470 | .name = "sh_mobile_lcdc_fb", |
| 471 | .num_resources = ARRAY_SIZE(hdmi_lcdc_resources), |
| 472 | .resource = hdmi_lcdc_resources, |
| 473 | .id = 1, |
| 474 | .dev = { |
| 475 | .platform_data = &hdmi_lcdc_info, |
| 476 | .coherent_dma_mask = ~0, |
| 477 | }, |
| 478 | }; |
| 479 | |
| 480 | static struct sh_mobile_hdmi_info hdmi_info = { |
| 481 | .lcd_chan = &hdmi_lcdc_info.ch[0], |
| 482 | .lcd_dev = &hdmi_lcdc_device.dev, |
Kuninori Morimoto | 98d27b8 | 2011-01-06 02:44:15 +0000 | [diff] [blame] | 483 | .flags = HDMI_SND_SRC_SPDIF, |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 484 | }; |
| 485 | |
| 486 | static struct resource hdmi_resources[] = { |
| 487 | [0] = { |
| 488 | .name = "HDMI", |
| 489 | .start = 0xe6be0000, |
| 490 | .end = 0xe6be00ff, |
| 491 | .flags = IORESOURCE_MEM, |
| 492 | }, |
| 493 | [1] = { |
| 494 | /* There's also an HDMI interrupt on INTCS @ 0x18e0 */ |
| 495 | .start = evt2irq(0x17e0), |
| 496 | .flags = IORESOURCE_IRQ, |
| 497 | }, |
| 498 | }; |
| 499 | |
| 500 | static struct platform_device hdmi_device = { |
| 501 | .name = "sh-mobile-hdmi", |
| 502 | .num_resources = ARRAY_SIZE(hdmi_resources), |
| 503 | .resource = hdmi_resources, |
| 504 | .id = -1, |
| 505 | .dev = { |
| 506 | .platform_data = &hdmi_info, |
| 507 | }, |
| 508 | }; |
| 509 | |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 510 | static struct platform_device fsi_hdmi_device = { |
| 511 | .name = "sh_fsi2_b_hdmi", |
| 512 | }; |
| 513 | |
Guennadi Liakhovetski | 2ce51f8 | 2011-04-04 17:08:05 +0200 | [diff] [blame] | 514 | static void __init hdmi_init_pm_clock(void) |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 515 | { |
| 516 | struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick"); |
| 517 | int ret; |
| 518 | long rate; |
| 519 | |
| 520 | if (IS_ERR(hdmi_ick)) { |
| 521 | ret = PTR_ERR(hdmi_ick); |
| 522 | pr_err("Cannot get HDMI ICK: %d\n", ret); |
| 523 | goto out; |
| 524 | } |
| 525 | |
| 526 | ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk); |
| 527 | if (ret < 0) { |
| 528 | pr_err("Cannot set PLLC2 parent: %d, %d users\n", |
| 529 | ret, sh7372_pllc2_clk.usecount); |
| 530 | goto out; |
| 531 | } |
| 532 | |
| 533 | pr_debug("PLLC2 initial frequency %lu\n", |
| 534 | clk_get_rate(&sh7372_pllc2_clk)); |
| 535 | |
| 536 | rate = clk_round_rate(&sh7372_pllc2_clk, 594000000); |
| 537 | if (rate < 0) { |
| 538 | pr_err("Cannot get suitable rate: %ld\n", rate); |
| 539 | ret = rate; |
| 540 | goto out; |
| 541 | } |
| 542 | |
| 543 | ret = clk_set_rate(&sh7372_pllc2_clk, rate); |
| 544 | if (ret < 0) { |
| 545 | pr_err("Cannot set rate %ld: %d\n", rate, ret); |
| 546 | goto out; |
| 547 | } |
| 548 | |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 549 | pr_debug("PLLC2 set frequency %lu\n", rate); |
| 550 | |
| 551 | ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk); |
Guennadi Liakhovetski | 2ce51f8 | 2011-04-04 17:08:05 +0200 | [diff] [blame] | 552 | if (ret < 0) |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 553 | pr_err("Cannot set HDMI parent: %d\n", ret); |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 554 | |
| 555 | out: |
| 556 | if (!IS_ERR(hdmi_ick)) |
| 557 | clk_put(hdmi_ick); |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 558 | } |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 559 | |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 560 | /* USBHS0 is connected to CN22 which takes a USB Mini-B plug |
| 561 | * |
| 562 | * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug, |
| 563 | * but on this particular board IRQ7 is already used by |
| 564 | * the touch screen. This leaves us with software polling. |
| 565 | */ |
| 566 | #define USBHS0_POLL_INTERVAL (HZ * 5) |
| 567 | |
| 568 | struct usbhs_private { |
| 569 | unsigned int usbphyaddr; |
| 570 | unsigned int usbcrcaddr; |
| 571 | struct renesas_usbhs_platform_info info; |
| 572 | struct delayed_work work; |
| 573 | struct platform_device *pdev; |
| 574 | }; |
| 575 | |
| 576 | #define usbhs_get_priv(pdev) \ |
| 577 | container_of(renesas_usbhs_get_info(pdev), \ |
| 578 | struct usbhs_private, info) |
| 579 | |
| 580 | #define usbhs_is_connected(priv) \ |
| 581 | (!((1 << 7) & __raw_readw(priv->usbcrcaddr))) |
| 582 | |
| 583 | static int usbhs_get_vbus(struct platform_device *pdev) |
| 584 | { |
| 585 | return usbhs_is_connected(usbhs_get_priv(pdev)); |
| 586 | } |
| 587 | |
| 588 | static void usbhs_phy_reset(struct platform_device *pdev) |
| 589 | { |
| 590 | struct usbhs_private *priv = usbhs_get_priv(pdev); |
| 591 | |
| 592 | /* init phy */ |
| 593 | __raw_writew(0x8a0a, priv->usbcrcaddr); |
| 594 | } |
| 595 | |
| 596 | static int usbhs0_get_id(struct platform_device *pdev) |
| 597 | { |
| 598 | return USBHS_GADGET; |
| 599 | } |
| 600 | |
| 601 | static void usbhs0_work_function(struct work_struct *work) |
| 602 | { |
| 603 | struct usbhs_private *priv = container_of(work, struct usbhs_private, |
| 604 | work.work); |
| 605 | |
| 606 | renesas_usbhs_call_notify_hotplug(priv->pdev); |
| 607 | schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL); |
| 608 | } |
| 609 | |
| 610 | static int usbhs0_hardware_init(struct platform_device *pdev) |
| 611 | { |
| 612 | struct usbhs_private *priv = usbhs_get_priv(pdev); |
| 613 | |
| 614 | priv->pdev = pdev; |
| 615 | INIT_DELAYED_WORK(&priv->work, usbhs0_work_function); |
| 616 | schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL); |
| 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | static void usbhs0_hardware_exit(struct platform_device *pdev) |
| 621 | { |
| 622 | struct usbhs_private *priv = usbhs_get_priv(pdev); |
| 623 | |
| 624 | cancel_delayed_work_sync(&priv->work); |
| 625 | } |
| 626 | |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 627 | static struct usbhs_private usbhs0_private = { |
| 628 | .usbcrcaddr = 0xe605810c, /* USBCR2 */ |
| 629 | .info = { |
| 630 | .platform_callback = { |
| 631 | .hardware_init = usbhs0_hardware_init, |
| 632 | .hardware_exit = usbhs0_hardware_exit, |
| 633 | .phy_reset = usbhs_phy_reset, |
| 634 | .get_id = usbhs0_get_id, |
| 635 | .get_vbus = usbhs_get_vbus, |
| 636 | }, |
| 637 | .driver_param = { |
| 638 | .buswait_bwait = 4, |
Kuninori Morimoto | fe43756 | 2011-06-17 08:21:21 +0000 | [diff] [blame] | 639 | .d0_tx_id = SHDMA_SLAVE_USB0_TX, |
| 640 | .d1_rx_id = SHDMA_SLAVE_USB0_RX, |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 641 | }, |
| 642 | }, |
| 643 | }; |
| 644 | |
| 645 | static struct resource usbhs0_resources[] = { |
| 646 | [0] = { |
| 647 | .name = "USBHS0", |
| 648 | .start = 0xe6890000, |
| 649 | .end = 0xe68900e6 - 1, |
| 650 | .flags = IORESOURCE_MEM, |
| 651 | }, |
| 652 | [1] = { |
| 653 | .start = evt2irq(0x1ca0) /* USB0_USB0I0 */, |
| 654 | .flags = IORESOURCE_IRQ, |
| 655 | }, |
| 656 | }; |
| 657 | |
| 658 | static struct platform_device usbhs0_device = { |
| 659 | .name = "renesas_usbhs", |
| 660 | .id = 0, |
| 661 | .dev = { |
| 662 | .platform_data = &usbhs0_private.info, |
| 663 | }, |
| 664 | .num_resources = ARRAY_SIZE(usbhs0_resources), |
| 665 | .resource = usbhs0_resources, |
| 666 | }; |
| 667 | |
| 668 | /* USBHS1 is connected to CN31 which takes a USB Mini-AB plug |
| 669 | * |
| 670 | * Use J30 to select between Host and Function. This setting |
| 671 | * can however not be detected by software. Hotplug of USBHS1 |
| 672 | * is provided via IRQ8. |
Kuninori Morimoto | 0ada2da5 | 2012-01-18 17:32:05 -0800 | [diff] [blame] | 673 | * |
| 674 | * Current USB1 works as "USB Host". |
| 675 | * - set J30 "short" |
| 676 | * |
| 677 | * If you want to use it as "USB gadget", |
| 678 | * - J30 "open" |
| 679 | * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET |
| 680 | * - add .get_vbus = usbhs_get_vbus in usbhs1_private |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 681 | */ |
| 682 | #define IRQ8 evt2irq(0x0300) |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 683 | #define USB_PHY_MODE (1 << 4) |
| 684 | #define USB_PHY_INT_EN ((1 << 3) | (1 << 2)) |
| 685 | #define USB_PHY_ON (1 << 1) |
| 686 | #define USB_PHY_OFF (1 << 0) |
| 687 | #define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF) |
| 688 | |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 689 | static irqreturn_t usbhs1_interrupt(int irq, void *data) |
| 690 | { |
| 691 | struct platform_device *pdev = data; |
| 692 | struct usbhs_private *priv = usbhs_get_priv(pdev); |
| 693 | |
| 694 | dev_dbg(&pdev->dev, "%s\n", __func__); |
| 695 | |
| 696 | renesas_usbhs_call_notify_hotplug(pdev); |
| 697 | |
| 698 | /* clear status */ |
| 699 | __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR, |
| 700 | priv->usbphyaddr); |
| 701 | |
| 702 | return IRQ_HANDLED; |
| 703 | } |
| 704 | |
| 705 | static int usbhs1_hardware_init(struct platform_device *pdev) |
| 706 | { |
| 707 | struct usbhs_private *priv = usbhs_get_priv(pdev); |
| 708 | int ret; |
| 709 | |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 710 | /* clear interrupt status */ |
| 711 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr); |
| 712 | |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 713 | ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH, |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 714 | dev_name(&pdev->dev), pdev); |
| 715 | if (ret) { |
| 716 | dev_err(&pdev->dev, "request_irq err\n"); |
| 717 | return ret; |
| 718 | } |
| 719 | |
| 720 | /* enable USB phy interrupt */ |
| 721 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr); |
| 722 | |
| 723 | return 0; |
| 724 | } |
| 725 | |
| 726 | static void usbhs1_hardware_exit(struct platform_device *pdev) |
| 727 | { |
| 728 | struct usbhs_private *priv = usbhs_get_priv(pdev); |
| 729 | |
| 730 | /* clear interrupt status */ |
| 731 | __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr); |
| 732 | |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 733 | free_irq(IRQ8, pdev); |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 734 | } |
| 735 | |
Kuninori Morimoto | 05a7929 | 2011-06-15 06:16:35 +0000 | [diff] [blame] | 736 | static int usbhs1_get_id(struct platform_device *pdev) |
| 737 | { |
Kuninori Morimoto | 0ada2da5 | 2012-01-18 17:32:05 -0800 | [diff] [blame] | 738 | return USBHS_HOST; |
Kuninori Morimoto | 05a7929 | 2011-06-15 06:16:35 +0000 | [diff] [blame] | 739 | } |
| 740 | |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 741 | static u32 usbhs1_pipe_cfg[] = { |
| 742 | USB_ENDPOINT_XFER_CONTROL, |
| 743 | USB_ENDPOINT_XFER_ISOC, |
| 744 | USB_ENDPOINT_XFER_ISOC, |
| 745 | USB_ENDPOINT_XFER_BULK, |
| 746 | USB_ENDPOINT_XFER_BULK, |
| 747 | USB_ENDPOINT_XFER_BULK, |
| 748 | USB_ENDPOINT_XFER_INT, |
| 749 | USB_ENDPOINT_XFER_INT, |
| 750 | USB_ENDPOINT_XFER_INT, |
| 751 | USB_ENDPOINT_XFER_BULK, |
| 752 | USB_ENDPOINT_XFER_BULK, |
| 753 | USB_ENDPOINT_XFER_BULK, |
| 754 | USB_ENDPOINT_XFER_BULK, |
| 755 | USB_ENDPOINT_XFER_BULK, |
| 756 | USB_ENDPOINT_XFER_BULK, |
| 757 | USB_ENDPOINT_XFER_BULK, |
| 758 | }; |
| 759 | |
| 760 | static struct usbhs_private usbhs1_private = { |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 761 | .usbphyaddr = 0xe60581e2, /* USBPHY1INTAP */ |
| 762 | .usbcrcaddr = 0xe6058130, /* USBCR4 */ |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 763 | .info = { |
| 764 | .platform_callback = { |
| 765 | .hardware_init = usbhs1_hardware_init, |
| 766 | .hardware_exit = usbhs1_hardware_exit, |
Kuninori Morimoto | 05a7929 | 2011-06-15 06:16:35 +0000 | [diff] [blame] | 767 | .get_id = usbhs1_get_id, |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 768 | .phy_reset = usbhs_phy_reset, |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 769 | }, |
| 770 | .driver_param = { |
| 771 | .buswait_bwait = 4, |
Kuninori Morimoto | f427eb6 | 2011-10-10 22:06:12 -0700 | [diff] [blame] | 772 | .has_otg = 1, |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 773 | .pipe_type = usbhs1_pipe_cfg, |
| 774 | .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg), |
Kuninori Morimoto | fe43756 | 2011-06-17 08:21:21 +0000 | [diff] [blame] | 775 | .d0_tx_id = SHDMA_SLAVE_USB1_TX, |
| 776 | .d1_rx_id = SHDMA_SLAVE_USB1_RX, |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 777 | }, |
| 778 | }, |
| 779 | }; |
| 780 | |
| 781 | static struct resource usbhs1_resources[] = { |
| 782 | [0] = { |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 783 | .name = "USBHS1", |
| 784 | .start = 0xe68b0000, |
| 785 | .end = 0xe68b00e6 - 1, |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 786 | .flags = IORESOURCE_MEM, |
| 787 | }, |
| 788 | [1] = { |
| 789 | .start = evt2irq(0x1ce0) /* USB1_USB1I0 */, |
| 790 | .flags = IORESOURCE_IRQ, |
| 791 | }, |
| 792 | }; |
| 793 | |
| 794 | static struct platform_device usbhs1_device = { |
| 795 | .name = "renesas_usbhs", |
| 796 | .id = 1, |
| 797 | .dev = { |
| 798 | .platform_data = &usbhs1_private.info, |
| 799 | }, |
| 800 | .num_resources = ARRAY_SIZE(usbhs1_resources), |
| 801 | .resource = usbhs1_resources, |
| 802 | }; |
| 803 | |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 804 | /* LED */ |
| 805 | static struct gpio_led mackerel_leds[] = { |
| 806 | { |
| 807 | .name = "led0", |
| 808 | .gpio = GPIO_PORT0, |
| 809 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 810 | }, |
| 811 | { |
| 812 | .name = "led1", |
| 813 | .gpio = GPIO_PORT1, |
| 814 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 815 | }, |
| 816 | { |
| 817 | .name = "led2", |
| 818 | .gpio = GPIO_PORT2, |
| 819 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 820 | }, |
| 821 | { |
| 822 | .name = "led3", |
| 823 | .gpio = GPIO_PORT159, |
| 824 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 825 | } |
| 826 | }; |
| 827 | |
| 828 | static struct gpio_led_platform_data mackerel_leds_pdata = { |
| 829 | .leds = mackerel_leds, |
| 830 | .num_leds = ARRAY_SIZE(mackerel_leds), |
| 831 | }; |
| 832 | |
| 833 | static struct platform_device leds_device = { |
| 834 | .name = "leds-gpio", |
| 835 | .id = 0, |
| 836 | .dev = { |
| 837 | .platform_data = &mackerel_leds_pdata, |
| 838 | }, |
| 839 | }; |
| 840 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 841 | /* FSI */ |
| 842 | #define IRQ_FSI evt2irq(0x1840) |
Kuninori Morimoto | 98d27b8 | 2011-01-06 02:44:15 +0000 | [diff] [blame] | 843 | static int __fsi_set_round_rate(struct clk *clk, long rate, int enable) |
| 844 | { |
| 845 | int ret; |
| 846 | |
| 847 | if (rate <= 0) |
| 848 | return 0; |
| 849 | |
| 850 | if (!enable) { |
| 851 | clk_disable(clk); |
| 852 | return 0; |
| 853 | } |
| 854 | |
| 855 | ret = clk_set_rate(clk, clk_round_rate(clk, rate)); |
| 856 | if (ret < 0) |
| 857 | return ret; |
| 858 | |
| 859 | return clk_enable(clk); |
| 860 | } |
| 861 | |
| 862 | static int fsi_set_rate(struct device *dev, int is_porta, int rate, int enable) |
| 863 | { |
| 864 | struct clk *fsib_clk; |
| 865 | struct clk *fdiv_clk = &sh7372_fsidivb_clk; |
| 866 | long fsib_rate = 0; |
| 867 | long fdiv_rate = 0; |
| 868 | int ackmd_bpfmd; |
| 869 | int ret; |
| 870 | |
| 871 | /* FSIA is slave mode. nothing to do here */ |
| 872 | if (is_porta) |
| 873 | return 0; |
| 874 | |
| 875 | /* clock start */ |
| 876 | switch (rate) { |
| 877 | case 44100: |
| 878 | fsib_rate = rate * 256; |
| 879 | ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64; |
| 880 | break; |
| 881 | case 48000: |
| 882 | fsib_rate = 85428000; /* around 48kHz x 256 x 7 */ |
| 883 | fdiv_rate = rate * 256; |
| 884 | ackmd_bpfmd = SH_FSI_ACKMD_256 | SH_FSI_BPFMD_64; |
| 885 | break; |
| 886 | default: |
| 887 | pr_err("unsupported rate in FSI2 port B\n"); |
| 888 | return -EINVAL; |
| 889 | } |
| 890 | |
| 891 | /* FSI B setting */ |
| 892 | fsib_clk = clk_get(dev, "ickb"); |
| 893 | if (IS_ERR(fsib_clk)) |
| 894 | return -EIO; |
| 895 | |
| 896 | /* fsib */ |
| 897 | ret = __fsi_set_round_rate(fsib_clk, fsib_rate, enable); |
| 898 | if (ret < 0) |
| 899 | goto fsi_set_rate_end; |
| 900 | |
| 901 | /* FSI DIV */ |
| 902 | ret = __fsi_set_round_rate(fdiv_clk, fdiv_rate, enable); |
| 903 | if (ret < 0) { |
| 904 | /* disable FSI B */ |
| 905 | if (enable) |
| 906 | __fsi_set_round_rate(fsib_clk, fsib_rate, 0); |
| 907 | goto fsi_set_rate_end; |
| 908 | } |
| 909 | |
| 910 | ret = ackmd_bpfmd; |
| 911 | |
| 912 | fsi_set_rate_end: |
| 913 | clk_put(fsib_clk); |
| 914 | return ret; |
| 915 | } |
| 916 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 917 | static struct sh_fsi_platform_info fsi_info = { |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 918 | .porta_flags = SH_FSI_BRS_INV, |
Kuninori Morimoto | 98d27b8 | 2011-01-06 02:44:15 +0000 | [diff] [blame] | 919 | |
| 920 | .portb_flags = SH_FSI_BRS_INV | |
| 921 | SH_FSI_BRM_INV | |
| 922 | SH_FSI_LRS_INV | |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 923 | SH_FSI_FMT_SPDIF, |
Kuninori Morimoto | 98d27b8 | 2011-01-06 02:44:15 +0000 | [diff] [blame] | 924 | |
| 925 | .set_rate = fsi_set_rate, |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 926 | }; |
| 927 | |
| 928 | static struct resource fsi_resources[] = { |
| 929 | [0] = { |
| 930 | .name = "FSI", |
| 931 | .start = 0xFE3C0000, |
| 932 | .end = 0xFE3C0400 - 1, |
| 933 | .flags = IORESOURCE_MEM, |
| 934 | }, |
| 935 | [1] = { |
| 936 | .start = IRQ_FSI, |
| 937 | .flags = IORESOURCE_IRQ, |
| 938 | }, |
| 939 | }; |
| 940 | |
| 941 | static struct platform_device fsi_device = { |
| 942 | .name = "sh_fsi2", |
| 943 | .id = -1, |
| 944 | .num_resources = ARRAY_SIZE(fsi_resources), |
| 945 | .resource = fsi_resources, |
| 946 | .dev = { |
| 947 | .platform_data = &fsi_info, |
| 948 | }, |
| 949 | }; |
| 950 | |
Kuninori Morimoto | 45f3121 | 2011-11-23 16:55:34 -0800 | [diff] [blame] | 951 | static struct fsi_ak4642_info fsi2_ak4643_info = { |
| 952 | .name = "AK4643", |
| 953 | .card = "FSI2A-AK4643", |
| 954 | .cpu_dai = "fsia-dai", |
| 955 | .codec = "ak4642-codec.0-0013", |
| 956 | .platform = "sh_fsi2", |
| 957 | .id = FSI_PORT_A, |
| 958 | }; |
| 959 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 960 | static struct platform_device fsi_ak4643_device = { |
Kuninori Morimoto | 45f3121 | 2011-11-23 16:55:34 -0800 | [diff] [blame] | 961 | .name = "fsi-ak4642-audio", |
| 962 | .dev = { |
| 963 | .platform_data = &fsi2_ak4643_info, |
| 964 | }, |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 965 | }; |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 966 | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 967 | /* |
| 968 | * The card detect pin of the top SD/MMC slot (CN7) is active low and is |
| 969 | * connected to GPIO A22 of SH7372 (GPIO_PORT41). |
| 970 | */ |
| 971 | static int slot_cn7_get_cd(struct platform_device *pdev) |
| 972 | { |
Magnus Damm | ceb50f3 | 2011-01-12 10:43:07 +0000 | [diff] [blame] | 973 | return !gpio_get_value(GPIO_PORT41); |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 974 | } |
| 975 | |
| 976 | /* SDHI0 */ |
Guennadi Liakhovetski | 4bff4a7 | 2011-05-11 16:51:20 +0000 | [diff] [blame] | 977 | static irqreturn_t mackerel_sdhi0_gpio_cd(int irq, void *arg) |
| 978 | { |
| 979 | struct device *dev = arg; |
| 980 | struct sh_mobile_sdhi_info *info = dev->platform_data; |
| 981 | struct tmio_mmc_data *pdata = info->pdata; |
| 982 | |
| 983 | tmio_mmc_cd_wakeup(pdata); |
| 984 | |
| 985 | return IRQ_HANDLED; |
| 986 | } |
| 987 | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 988 | static struct sh_mobile_sdhi_info sdhi0_info = { |
| 989 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, |
| 990 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, |
Magnus Damm | da97da7 | 2011-01-06 10:55:41 +0000 | [diff] [blame] | 991 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 992 | }; |
| 993 | |
| 994 | static struct resource sdhi0_resources[] = { |
| 995 | [0] = { |
| 996 | .name = "SDHI0", |
| 997 | .start = 0xe6850000, |
Guennadi Liakhovetski | 31d31fe7 | 2011-03-09 13:09:27 +0100 | [diff] [blame] | 998 | .end = 0xe68500ff, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 999 | .flags = IORESOURCE_MEM, |
| 1000 | }, |
| 1001 | [1] = { |
Simon Horman | 2007aea | 2011-04-27 07:43:58 +0000 | [diff] [blame] | 1002 | .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */, |
| 1003 | .flags = IORESOURCE_IRQ, |
| 1004 | }, |
| 1005 | [2] = { |
| 1006 | .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */, |
| 1007 | .flags = IORESOURCE_IRQ, |
| 1008 | }, |
| 1009 | [3] = { |
| 1010 | .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1011 | .flags = IORESOURCE_IRQ, |
| 1012 | }, |
| 1013 | }; |
| 1014 | |
| 1015 | static struct platform_device sdhi0_device = { |
| 1016 | .name = "sh_mobile_sdhi", |
| 1017 | .num_resources = ARRAY_SIZE(sdhi0_resources), |
| 1018 | .resource = sdhi0_resources, |
| 1019 | .id = 0, |
| 1020 | .dev = { |
| 1021 | .platform_data = &sdhi0_info, |
| 1022 | }, |
| 1023 | }; |
| 1024 | |
Guennadi Liakhovetski | 5bcd751 | 2011-05-05 15:56:27 +0000 | [diff] [blame] | 1025 | #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1026 | /* SDHI1 */ |
| 1027 | static struct sh_mobile_sdhi_info sdhi1_info = { |
| 1028 | .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, |
| 1029 | .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, |
| 1030 | .tmio_ocr_mask = MMC_VDD_165_195, |
| 1031 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, |
Magnus Damm | da97da7 | 2011-01-06 10:55:41 +0000 | [diff] [blame] | 1032 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1033 | MMC_CAP_NEEDS_POLL, |
| 1034 | .get_cd = slot_cn7_get_cd, |
| 1035 | }; |
| 1036 | |
| 1037 | static struct resource sdhi1_resources[] = { |
| 1038 | [0] = { |
| 1039 | .name = "SDHI1", |
| 1040 | .start = 0xe6860000, |
Guennadi Liakhovetski | 31d31fe7 | 2011-03-09 13:09:27 +0100 | [diff] [blame] | 1041 | .end = 0xe68600ff, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1042 | .flags = IORESOURCE_MEM, |
| 1043 | }, |
| 1044 | [1] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 1045 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, |
Simon Horman | 2007aea | 2011-04-27 07:43:58 +0000 | [diff] [blame] | 1046 | .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */ |
| 1047 | .flags = IORESOURCE_IRQ, |
| 1048 | }, |
| 1049 | [2] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 1050 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
Simon Horman | 2007aea | 2011-04-27 07:43:58 +0000 | [diff] [blame] | 1051 | .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */ |
| 1052 | .flags = IORESOURCE_IRQ, |
| 1053 | }, |
| 1054 | [3] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 1055 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
Simon Horman | 2007aea | 2011-04-27 07:43:58 +0000 | [diff] [blame] | 1056 | .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */ |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1057 | .flags = IORESOURCE_IRQ, |
| 1058 | }, |
| 1059 | }; |
| 1060 | |
| 1061 | static struct platform_device sdhi1_device = { |
| 1062 | .name = "sh_mobile_sdhi", |
| 1063 | .num_resources = ARRAY_SIZE(sdhi1_resources), |
| 1064 | .resource = sdhi1_resources, |
| 1065 | .id = 1, |
| 1066 | .dev = { |
| 1067 | .platform_data = &sdhi1_info, |
| 1068 | }, |
| 1069 | }; |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 1070 | #endif |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1071 | |
Yusuke Goda | da5d1f4 | 2011-01-07 09:48:36 +0000 | [diff] [blame] | 1072 | /* |
| 1073 | * The card detect pin of the top SD/MMC slot (CN23) is active low and is |
| 1074 | * connected to GPIO SCIFB_SCK of SH7372 (GPIO_PORT162). |
| 1075 | */ |
| 1076 | static int slot_cn23_get_cd(struct platform_device *pdev) |
| 1077 | { |
| 1078 | return !gpio_get_value(GPIO_PORT162); |
| 1079 | } |
| 1080 | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1081 | /* SDHI2 */ |
| 1082 | static struct sh_mobile_sdhi_info sdhi2_info = { |
| 1083 | .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX, |
| 1084 | .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX, |
| 1085 | .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE, |
Magnus Damm | da97da7 | 2011-01-06 10:55:41 +0000 | [diff] [blame] | 1086 | .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1087 | MMC_CAP_NEEDS_POLL, |
Yusuke Goda | da5d1f4 | 2011-01-07 09:48:36 +0000 | [diff] [blame] | 1088 | .get_cd = slot_cn23_get_cd, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1089 | }; |
| 1090 | |
| 1091 | static struct resource sdhi2_resources[] = { |
| 1092 | [0] = { |
| 1093 | .name = "SDHI2", |
| 1094 | .start = 0xe6870000, |
Guennadi Liakhovetski | 31d31fe7 | 2011-03-09 13:09:27 +0100 | [diff] [blame] | 1095 | .end = 0xe68700ff, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1096 | .flags = IORESOURCE_MEM, |
| 1097 | }, |
| 1098 | [1] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 1099 | .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT, |
Simon Horman | 2007aea | 2011-04-27 07:43:58 +0000 | [diff] [blame] | 1100 | .start = evt2irq(0x1200), /* SDHI2_SDHI2I0 */ |
| 1101 | .flags = IORESOURCE_IRQ, |
| 1102 | }, |
| 1103 | [2] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 1104 | .name = SH_MOBILE_SDHI_IRQ_SDCARD, |
Simon Horman | 2007aea | 2011-04-27 07:43:58 +0000 | [diff] [blame] | 1105 | .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */ |
| 1106 | .flags = IORESOURCE_IRQ, |
| 1107 | }, |
| 1108 | [3] = { |
Simon Horman | cb2ccc3 | 2011-08-25 10:27:28 +0900 | [diff] [blame] | 1109 | .name = SH_MOBILE_SDHI_IRQ_SDIO, |
Simon Horman | 2007aea | 2011-04-27 07:43:58 +0000 | [diff] [blame] | 1110 | .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */ |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1111 | .flags = IORESOURCE_IRQ, |
| 1112 | }, |
| 1113 | }; |
| 1114 | |
| 1115 | static struct platform_device sdhi2_device = { |
| 1116 | .name = "sh_mobile_sdhi", |
| 1117 | .num_resources = ARRAY_SIZE(sdhi2_resources), |
| 1118 | .resource = sdhi2_resources, |
| 1119 | .id = 2, |
| 1120 | .dev = { |
| 1121 | .platform_data = &sdhi2_info, |
| 1122 | }, |
| 1123 | }; |
| 1124 | |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 1125 | /* SH_MMCIF */ |
| 1126 | static struct resource sh_mmcif_resources[] = { |
| 1127 | [0] = { |
| 1128 | .name = "MMCIF", |
| 1129 | .start = 0xE6BD0000, |
| 1130 | .end = 0xE6BD00FF, |
| 1131 | .flags = IORESOURCE_MEM, |
| 1132 | }, |
| 1133 | [1] = { |
| 1134 | /* MMC ERR */ |
| 1135 | .start = evt2irq(0x1ac0), |
| 1136 | .flags = IORESOURCE_IRQ, |
| 1137 | }, |
| 1138 | [2] = { |
| 1139 | /* MMC NOR */ |
| 1140 | .start = evt2irq(0x1ae0), |
| 1141 | .flags = IORESOURCE_IRQ, |
| 1142 | }, |
| 1143 | }; |
| 1144 | |
| 1145 | static struct sh_mmcif_plat_data sh_mmcif_plat = { |
| 1146 | .sup_pclk = 0, |
| 1147 | .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, |
| 1148 | .caps = MMC_CAP_4_BIT_DATA | |
| 1149 | MMC_CAP_8_BIT_DATA | |
| 1150 | MMC_CAP_NEEDS_POLL, |
| 1151 | .get_cd = slot_cn7_get_cd, |
Guennadi Liakhovetski | d5bb386 | 2011-08-30 18:26:44 +0200 | [diff] [blame] | 1152 | .slave_id_tx = SHDMA_SLAVE_MMCIF_TX, |
| 1153 | .slave_id_rx = SHDMA_SLAVE_MMCIF_RX, |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 1154 | }; |
| 1155 | |
| 1156 | static struct platform_device sh_mmcif_device = { |
| 1157 | .name = "sh_mmcif", |
| 1158 | .id = 0, |
| 1159 | .dev = { |
| 1160 | .dma_mask = NULL, |
| 1161 | .coherent_dma_mask = 0xffffffff, |
| 1162 | .platform_data = &sh_mmcif_plat, |
| 1163 | }, |
| 1164 | .num_resources = ARRAY_SIZE(sh_mmcif_resources), |
| 1165 | .resource = sh_mmcif_resources, |
| 1166 | }; |
| 1167 | |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1168 | |
Guennadi Liakhovetski | 7dfff95 | 2011-07-15 20:03:38 -0300 | [diff] [blame] | 1169 | static int mackerel_camera_add(struct soc_camera_device *icd); |
| 1170 | static void mackerel_camera_del(struct soc_camera_device *icd); |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1171 | |
| 1172 | static int camera_set_capture(struct soc_camera_platform_info *info, |
| 1173 | int enable) |
| 1174 | { |
| 1175 | return 0; /* camera sensor always enabled */ |
| 1176 | } |
| 1177 | |
| 1178 | static struct soc_camera_platform_info camera_info = { |
| 1179 | .format_name = "UYVY", |
| 1180 | .format_depth = 16, |
| 1181 | .format = { |
| 1182 | .code = V4L2_MBUS_FMT_UYVY8_2X8, |
| 1183 | .colorspace = V4L2_COLORSPACE_SMPTE170M, |
| 1184 | .field = V4L2_FIELD_NONE, |
| 1185 | .width = 640, |
| 1186 | .height = 480, |
| 1187 | }, |
Guennadi Liakhovetski | d1e87ed | 2011-07-27 10:48:40 -0300 | [diff] [blame] | 1188 | .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER | |
| 1189 | V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH | |
| 1190 | V4L2_MBUS_DATA_ACTIVE_HIGH, |
| 1191 | .mbus_type = V4L2_MBUS_PARALLEL, |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1192 | .set_capture = camera_set_capture, |
| 1193 | }; |
| 1194 | |
| 1195 | static struct soc_camera_link camera_link = { |
| 1196 | .bus_id = 0, |
| 1197 | .add_device = mackerel_camera_add, |
| 1198 | .del_device = mackerel_camera_del, |
| 1199 | .module_name = "soc_camera_platform", |
| 1200 | .priv = &camera_info, |
| 1201 | }; |
| 1202 | |
Guennadi Liakhovetski | 86a7314 | 2011-02-22 09:57:49 +0000 | [diff] [blame] | 1203 | static struct platform_device *camera_device; |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1204 | |
Guennadi Liakhovetski | 86a7314 | 2011-02-22 09:57:49 +0000 | [diff] [blame] | 1205 | static void mackerel_camera_release(struct device *dev) |
| 1206 | { |
| 1207 | soc_camera_platform_release(&camera_device); |
| 1208 | } |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1209 | |
Guennadi Liakhovetski | 7dfff95 | 2011-07-15 20:03:38 -0300 | [diff] [blame] | 1210 | static int mackerel_camera_add(struct soc_camera_device *icd) |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1211 | { |
Guennadi Liakhovetski | 7dfff95 | 2011-07-15 20:03:38 -0300 | [diff] [blame] | 1212 | return soc_camera_platform_add(icd, &camera_device, &camera_link, |
Guennadi Liakhovetski | 86a7314 | 2011-02-22 09:57:49 +0000 | [diff] [blame] | 1213 | mackerel_camera_release, 0); |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1214 | } |
| 1215 | |
Guennadi Liakhovetski | 7dfff95 | 2011-07-15 20:03:38 -0300 | [diff] [blame] | 1216 | static void mackerel_camera_del(struct soc_camera_device *icd) |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1217 | { |
Guennadi Liakhovetski | 7dfff95 | 2011-07-15 20:03:38 -0300 | [diff] [blame] | 1218 | soc_camera_platform_del(icd, camera_device, &camera_link); |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1219 | } |
| 1220 | |
| 1221 | static struct sh_mobile_ceu_info sh_mobile_ceu_info = { |
| 1222 | .flags = SH_CEU_FLAG_USE_8BIT_BUS, |
| 1223 | }; |
| 1224 | |
| 1225 | static struct resource ceu_resources[] = { |
| 1226 | [0] = { |
| 1227 | .name = "CEU", |
| 1228 | .start = 0xfe910000, |
| 1229 | .end = 0xfe91009f, |
| 1230 | .flags = IORESOURCE_MEM, |
| 1231 | }, |
| 1232 | [1] = { |
| 1233 | .start = intcs_evt2irq(0x880), |
| 1234 | .flags = IORESOURCE_IRQ, |
| 1235 | }, |
| 1236 | [2] = { |
| 1237 | /* place holder for contiguous memory */ |
| 1238 | }, |
| 1239 | }; |
| 1240 | |
| 1241 | static struct platform_device ceu_device = { |
| 1242 | .name = "sh_mobile_ceu", |
| 1243 | .id = 0, /* "ceu0" clock */ |
| 1244 | .num_resources = ARRAY_SIZE(ceu_resources), |
| 1245 | .resource = ceu_resources, |
| 1246 | .dev = { |
Guennadi Liakhovetski | 05a5f01 | 2011-03-23 09:29:16 +0000 | [diff] [blame] | 1247 | .platform_data = &sh_mobile_ceu_info, |
| 1248 | .coherent_dma_mask = 0xffffffff, |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1249 | }, |
| 1250 | }; |
| 1251 | |
| 1252 | static struct platform_device mackerel_camera = { |
| 1253 | .name = "soc-camera-pdrv", |
| 1254 | .id = 0, |
| 1255 | .dev = { |
| 1256 | .platform_data = &camera_link, |
| 1257 | }, |
| 1258 | }; |
| 1259 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1260 | static struct platform_device *mackerel_devices[] __initdata = { |
| 1261 | &nor_flash_device, |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 1262 | &smc911x_device, |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 1263 | &lcdc_device, |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 1264 | &usbhs1_device, |
Kuninori Morimoto | 5a56855 | 2011-06-17 04:33:13 +0000 | [diff] [blame] | 1265 | &usbhs0_device, |
Kuninori Morimoto | d44deb3 | 2010-11-30 06:52:18 +0000 | [diff] [blame] | 1266 | &leds_device, |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1267 | &fsi_device, |
| 1268 | &fsi_ak4643_device, |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 1269 | &fsi_hdmi_device, |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1270 | &sdhi0_device, |
Guennadi Liakhovetski | 5bcd751 | 2011-05-05 15:56:27 +0000 | [diff] [blame] | 1271 | #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1272 | &sdhi1_device, |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 1273 | #endif |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1274 | &sdhi2_device, |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 1275 | &sh_mmcif_device, |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1276 | &ceu_device, |
| 1277 | &mackerel_camera, |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 1278 | &hdmi_lcdc_device, |
| 1279 | &hdmi_device, |
Damian | 1c7fcbe | 2011-05-24 07:01:22 +0000 | [diff] [blame] | 1280 | &meram_device, |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1281 | }; |
| 1282 | |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 1283 | /* Keypad Initialization */ |
| 1284 | #define KEYPAD_BUTTON(ev_type, ev_code, act_low) \ |
| 1285 | { \ |
| 1286 | .type = ev_type, \ |
| 1287 | .code = ev_code, \ |
| 1288 | .active_low = act_low, \ |
| 1289 | } |
| 1290 | |
| 1291 | #define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1) |
| 1292 | |
| 1293 | static struct tca6416_button mackerel_gpio_keys[] = { |
| 1294 | KEYPAD_BUTTON_LOW(KEY_HOME), |
| 1295 | KEYPAD_BUTTON_LOW(KEY_MENU), |
| 1296 | KEYPAD_BUTTON_LOW(KEY_BACK), |
| 1297 | KEYPAD_BUTTON_LOW(KEY_POWER), |
| 1298 | }; |
| 1299 | |
| 1300 | static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = { |
| 1301 | .buttons = mackerel_gpio_keys, |
| 1302 | .nbuttons = ARRAY_SIZE(mackerel_gpio_keys), |
| 1303 | .rep = 1, |
| 1304 | .use_polling = 0, |
| 1305 | .pinmask = 0x000F, |
| 1306 | }; |
| 1307 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1308 | /* I2C */ |
Tony SIM | 6ae1e19 | 2011-01-11 09:47:59 +0900 | [diff] [blame] | 1309 | #define IRQ7 evt2irq(0x02e0) |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 1310 | #define IRQ9 evt2irq(0x0320) |
| 1311 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1312 | static struct i2c_board_info i2c0_devices[] = { |
| 1313 | { |
| 1314 | I2C_BOARD_INFO("ak4643", 0x13), |
| 1315 | }, |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 1316 | /* Keypad */ |
| 1317 | { |
| 1318 | I2C_BOARD_INFO("tca6408-keys", 0x20), |
| 1319 | .platform_data = &mackerel_tca6416_keys_info, |
| 1320 | .irq = IRQ9, |
| 1321 | }, |
Tony SIM | 6ae1e19 | 2011-01-11 09:47:59 +0900 | [diff] [blame] | 1322 | /* Touchscreen */ |
| 1323 | { |
| 1324 | I2C_BOARD_INFO("st1232-ts", 0x55), |
| 1325 | .irq = IRQ7, |
| 1326 | }, |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1327 | }; |
| 1328 | |
Tony SIM | 80f1dc7 | 2010-12-07 09:12:14 +0000 | [diff] [blame] | 1329 | #define IRQ21 evt2irq(0x32a0) |
| 1330 | |
| 1331 | static struct i2c_board_info i2c1_devices[] = { |
| 1332 | /* Accelerometer */ |
| 1333 | { |
| 1334 | I2C_BOARD_INFO("adxl34x", 0x53), |
| 1335 | .irq = IRQ21, |
| 1336 | }, |
| 1337 | }; |
| 1338 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1339 | #define GPIO_PORT9CR 0xE6051009 |
| 1340 | #define GPIO_PORT10CR 0xE605100A |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 1341 | #define GPIO_PORT167CR 0xE60520A7 |
Kuninori Morimoto | 66ee3be | 2011-05-25 07:56:25 +0000 | [diff] [blame] | 1342 | #define GPIO_PORT168CR 0xE60520A8 |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 1343 | #define SRCR4 0xe61580bc |
Kuninori Morimoto | 98d27b8 | 2011-01-06 02:44:15 +0000 | [diff] [blame] | 1344 | #define USCCR1 0xE6058144 |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1345 | static void __init mackerel_init(void) |
| 1346 | { |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 1347 | u32 srcr4; |
Kuninori Morimoto | 98d27b8 | 2011-01-06 02:44:15 +0000 | [diff] [blame] | 1348 | struct clk *clk; |
Guennadi Liakhovetski | 4bff4a7 | 2011-05-11 16:51:20 +0000 | [diff] [blame] | 1349 | int ret; |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 1350 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1351 | sh7372_pinmux_init(); |
| 1352 | |
| 1353 | /* enable SCIFA0 */ |
| 1354 | gpio_request(GPIO_FN_SCIFA0_TXD, NULL); |
| 1355 | gpio_request(GPIO_FN_SCIFA0_RXD, NULL); |
| 1356 | |
Kuninori Morimoto | 2264c15 | 2010-11-29 02:21:37 +0000 | [diff] [blame] | 1357 | /* enable SMSC911X */ |
| 1358 | gpio_request(GPIO_FN_CS5A, NULL); |
| 1359 | gpio_request(GPIO_FN_IRQ6_39, NULL); |
| 1360 | |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 1361 | /* LCDC */ |
Kuninori Morimoto | eb87e67 | 2010-11-29 06:19:52 +0000 | [diff] [blame] | 1362 | gpio_request(GPIO_FN_LCDD23, NULL); |
| 1363 | gpio_request(GPIO_FN_LCDD22, NULL); |
| 1364 | gpio_request(GPIO_FN_LCDD21, NULL); |
| 1365 | gpio_request(GPIO_FN_LCDD20, NULL); |
| 1366 | gpio_request(GPIO_FN_LCDD19, NULL); |
| 1367 | gpio_request(GPIO_FN_LCDD18, NULL); |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 1368 | gpio_request(GPIO_FN_LCDD17, NULL); |
| 1369 | gpio_request(GPIO_FN_LCDD16, NULL); |
| 1370 | gpio_request(GPIO_FN_LCDD15, NULL); |
| 1371 | gpio_request(GPIO_FN_LCDD14, NULL); |
| 1372 | gpio_request(GPIO_FN_LCDD13, NULL); |
| 1373 | gpio_request(GPIO_FN_LCDD12, NULL); |
| 1374 | gpio_request(GPIO_FN_LCDD11, NULL); |
| 1375 | gpio_request(GPIO_FN_LCDD10, NULL); |
| 1376 | gpio_request(GPIO_FN_LCDD9, NULL); |
| 1377 | gpio_request(GPIO_FN_LCDD8, NULL); |
| 1378 | gpio_request(GPIO_FN_LCDD7, NULL); |
| 1379 | gpio_request(GPIO_FN_LCDD6, NULL); |
| 1380 | gpio_request(GPIO_FN_LCDD5, NULL); |
| 1381 | gpio_request(GPIO_FN_LCDD4, NULL); |
| 1382 | gpio_request(GPIO_FN_LCDD3, NULL); |
| 1383 | gpio_request(GPIO_FN_LCDD2, NULL); |
| 1384 | gpio_request(GPIO_FN_LCDD1, NULL); |
| 1385 | gpio_request(GPIO_FN_LCDD0, NULL); |
| 1386 | gpio_request(GPIO_FN_LCDDISP, NULL); |
| 1387 | gpio_request(GPIO_FN_LCDDCK, NULL); |
| 1388 | |
| 1389 | gpio_request(GPIO_PORT31, NULL); /* backlight */ |
Magnus Damm | 1fbdfcd | 2011-03-21 07:49:45 +0000 | [diff] [blame] | 1390 | gpio_direction_output(GPIO_PORT31, 0); /* off by default */ |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 1391 | |
| 1392 | gpio_request(GPIO_PORT151, NULL); /* LCDDON */ |
| 1393 | gpio_direction_output(GPIO_PORT151, 1); |
| 1394 | |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 1395 | /* USBHS0 */ |
| 1396 | gpio_request(GPIO_FN_VBUS0_0, NULL); |
| 1397 | gpio_pull_down(GPIO_PORT168CR); /* VBUS0_0 pull down */ |
Kuninori Morimoto | 25338f2 | 2010-11-30 04:37:33 +0000 | [diff] [blame] | 1398 | |
Magnus Damm | e2a53b7 | 2011-06-09 07:03:37 +0000 | [diff] [blame] | 1399 | /* USBHS1 */ |
| 1400 | gpio_request(GPIO_FN_VBUS0_1, NULL); |
| 1401 | gpio_pull_down(GPIO_PORT167CR); /* VBUS0_1 pull down */ |
| 1402 | gpio_request(GPIO_FN_IDIN_1_113, NULL); |
| 1403 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1404 | /* enable FSI2 port A (ak4643) */ |
| 1405 | gpio_request(GPIO_FN_FSIAIBT, NULL); |
| 1406 | gpio_request(GPIO_FN_FSIAILR, NULL); |
| 1407 | gpio_request(GPIO_FN_FSIAISLD, NULL); |
| 1408 | gpio_request(GPIO_FN_FSIAOSLD, NULL); |
| 1409 | gpio_request(GPIO_PORT161, NULL); |
| 1410 | gpio_direction_output(GPIO_PORT161, 0); /* slave */ |
| 1411 | |
| 1412 | gpio_request(GPIO_PORT9, NULL); |
| 1413 | gpio_request(GPIO_PORT10, NULL); |
| 1414 | gpio_no_direction(GPIO_PORT9CR); /* FSIAOBT needs no direction */ |
| 1415 | gpio_no_direction(GPIO_PORT10CR); /* FSIAOLR needs no direction */ |
| 1416 | |
| 1417 | intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */ |
| 1418 | |
Kuninori Morimoto | 98d27b8 | 2011-01-06 02:44:15 +0000 | [diff] [blame] | 1419 | /* setup FSI2 port B (HDMI) */ |
| 1420 | gpio_request(GPIO_FN_FSIBCK, NULL); |
| 1421 | __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */ |
| 1422 | |
| 1423 | /* set SPU2 clock to 119.6 MHz */ |
| 1424 | clk = clk_get(NULL, "spu_clk"); |
| 1425 | if (!IS_ERR(clk)) { |
| 1426 | clk_set_rate(clk, clk_round_rate(clk, 119600000)); |
| 1427 | clk_put(clk); |
| 1428 | } |
| 1429 | |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 1430 | /* enable Keypad */ |
| 1431 | gpio_request(GPIO_FN_IRQ9_42, NULL); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 1432 | irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH); |
Tony SIM | cd8ab00 | 2010-12-09 01:55:55 +0000 | [diff] [blame] | 1433 | |
Tony SIM | 6ae1e19 | 2011-01-11 09:47:59 +0900 | [diff] [blame] | 1434 | /* enable Touchscreen */ |
| 1435 | gpio_request(GPIO_FN_IRQ7_40, NULL); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 1436 | irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW); |
Tony SIM | 6ae1e19 | 2011-01-11 09:47:59 +0900 | [diff] [blame] | 1437 | |
Tony SIM | 80f1dc7 | 2010-12-07 09:12:14 +0000 | [diff] [blame] | 1438 | /* enable Accelerometer */ |
| 1439 | gpio_request(GPIO_FN_IRQ21, NULL); |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 1440 | irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH); |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1441 | |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1442 | /* enable SDHI0 */ |
| 1443 | gpio_request(GPIO_FN_SDHICD0, NULL); |
| 1444 | gpio_request(GPIO_FN_SDHIWP0, NULL); |
| 1445 | gpio_request(GPIO_FN_SDHICMD0, NULL); |
| 1446 | gpio_request(GPIO_FN_SDHICLK0, NULL); |
| 1447 | gpio_request(GPIO_FN_SDHID0_3, NULL); |
| 1448 | gpio_request(GPIO_FN_SDHID0_2, NULL); |
| 1449 | gpio_request(GPIO_FN_SDHID0_1, NULL); |
| 1450 | gpio_request(GPIO_FN_SDHID0_0, NULL); |
| 1451 | |
Guennadi Liakhovetski | 4bff4a7 | 2011-05-11 16:51:20 +0000 | [diff] [blame] | 1452 | ret = request_irq(evt2irq(0x3340), mackerel_sdhi0_gpio_cd, |
| 1453 | IRQF_TRIGGER_FALLING, "sdhi0 cd", &sdhi0_device.dev); |
| 1454 | if (!ret) |
| 1455 | sdhi0_info.tmio_flags |= TMIO_MMC_HAS_COLD_CD; |
| 1456 | else |
| 1457 | pr_err("Cannot get IRQ #%d: %d\n", evt2irq(0x3340), ret); |
| 1458 | |
Guennadi Liakhovetski | 5bcd751 | 2011-05-05 15:56:27 +0000 | [diff] [blame] | 1459 | #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1460 | /* enable SDHI1 */ |
| 1461 | gpio_request(GPIO_FN_SDHICMD1, NULL); |
| 1462 | gpio_request(GPIO_FN_SDHICLK1, NULL); |
| 1463 | gpio_request(GPIO_FN_SDHID1_3, NULL); |
| 1464 | gpio_request(GPIO_FN_SDHID1_2, NULL); |
| 1465 | gpio_request(GPIO_FN_SDHID1_1, NULL); |
| 1466 | gpio_request(GPIO_FN_SDHID1_0, NULL); |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 1467 | #endif |
Yusuke Goda | 6dff7da | 2010-12-14 14:18:03 +0900 | [diff] [blame] | 1468 | /* card detect pin for MMC slot (CN7) */ |
| 1469 | gpio_request(GPIO_PORT41, NULL); |
| 1470 | gpio_direction_input(GPIO_PORT41); |
| 1471 | |
| 1472 | /* enable SDHI2 */ |
| 1473 | gpio_request(GPIO_FN_SDHICMD2, NULL); |
| 1474 | gpio_request(GPIO_FN_SDHICLK2, NULL); |
| 1475 | gpio_request(GPIO_FN_SDHID2_3, NULL); |
| 1476 | gpio_request(GPIO_FN_SDHID2_2, NULL); |
| 1477 | gpio_request(GPIO_FN_SDHID2_1, NULL); |
| 1478 | gpio_request(GPIO_FN_SDHID2_0, NULL); |
| 1479 | |
Yusuke Goda | da5d1f4 | 2011-01-07 09:48:36 +0000 | [diff] [blame] | 1480 | /* card detect pin for microSD slot (CN23) */ |
| 1481 | gpio_request(GPIO_PORT162, NULL); |
| 1482 | gpio_direction_input(GPIO_PORT162); |
| 1483 | |
Yusuke Goda | 41491b9 | 2010-12-15 08:31:04 +0000 | [diff] [blame] | 1484 | /* MMCIF */ |
| 1485 | gpio_request(GPIO_FN_MMCD0_0, NULL); |
| 1486 | gpio_request(GPIO_FN_MMCD0_1, NULL); |
| 1487 | gpio_request(GPIO_FN_MMCD0_2, NULL); |
| 1488 | gpio_request(GPIO_FN_MMCD0_3, NULL); |
| 1489 | gpio_request(GPIO_FN_MMCD0_4, NULL); |
| 1490 | gpio_request(GPIO_FN_MMCD0_5, NULL); |
| 1491 | gpio_request(GPIO_FN_MMCD0_6, NULL); |
| 1492 | gpio_request(GPIO_FN_MMCD0_7, NULL); |
| 1493 | gpio_request(GPIO_FN_MMCCMD0, NULL); |
| 1494 | gpio_request(GPIO_FN_MMCCLK0, NULL); |
| 1495 | |
Yusuke Goda | 56e78da | 2010-12-20 01:06:04 +0000 | [diff] [blame] | 1496 | /* enable GPS module (GT-720F) */ |
| 1497 | gpio_request(GPIO_FN_SCIFA2_TXD1, NULL); |
| 1498 | gpio_request(GPIO_FN_SCIFA2_RXD1, NULL); |
| 1499 | |
Magnus Damm | ae37c8d | 2010-12-22 14:47:40 +0000 | [diff] [blame] | 1500 | /* CEU */ |
| 1501 | gpio_request(GPIO_FN_VIO_CLK, NULL); |
| 1502 | gpio_request(GPIO_FN_VIO_VD, NULL); |
| 1503 | gpio_request(GPIO_FN_VIO_HD, NULL); |
| 1504 | gpio_request(GPIO_FN_VIO_FIELD, NULL); |
| 1505 | gpio_request(GPIO_FN_VIO_CKO, NULL); |
| 1506 | gpio_request(GPIO_FN_VIO_D7, NULL); |
| 1507 | gpio_request(GPIO_FN_VIO_D6, NULL); |
| 1508 | gpio_request(GPIO_FN_VIO_D5, NULL); |
| 1509 | gpio_request(GPIO_FN_VIO_D4, NULL); |
| 1510 | gpio_request(GPIO_FN_VIO_D3, NULL); |
| 1511 | gpio_request(GPIO_FN_VIO_D2, NULL); |
| 1512 | gpio_request(GPIO_FN_VIO_D1, NULL); |
| 1513 | gpio_request(GPIO_FN_VIO_D0, NULL); |
| 1514 | |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 1515 | /* HDMI */ |
| 1516 | gpio_request(GPIO_FN_HDMI_HPD, NULL); |
| 1517 | gpio_request(GPIO_FN_HDMI_CEC, NULL); |
| 1518 | |
| 1519 | /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */ |
| 1520 | srcr4 = __raw_readl(SRCR4); |
| 1521 | __raw_writel(srcr4 | (1 << 13), SRCR4); |
| 1522 | udelay(50); |
| 1523 | __raw_writel(srcr4 & ~(1 << 13), SRCR4); |
| 1524 | |
Kuninori Morimoto | 1a44d72 | 2010-12-01 00:31:46 +0000 | [diff] [blame] | 1525 | i2c_register_board_info(0, i2c0_devices, |
| 1526 | ARRAY_SIZE(i2c0_devices)); |
Tony SIM | 80f1dc7 | 2010-12-07 09:12:14 +0000 | [diff] [blame] | 1527 | i2c_register_board_info(1, i2c1_devices, |
| 1528 | ARRAY_SIZE(i2c1_devices)); |
Kuninori Morimoto | 11fee46 | 2010-11-29 02:21:43 +0000 | [diff] [blame] | 1529 | |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1530 | sh7372_add_standard_devices(); |
| 1531 | |
| 1532 | platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices)); |
Guennadi Liakhovetski | 2ce51f8 | 2011-04-04 17:08:05 +0200 | [diff] [blame] | 1533 | |
Rafael J. Wysocki | e3e0109 | 2011-07-01 22:13:56 +0200 | [diff] [blame] | 1534 | sh7372_add_device_to_domain(&sh7372_a4lc, &lcdc_device); |
| 1535 | sh7372_add_device_to_domain(&sh7372_a4lc, &hdmi_lcdc_device); |
Damian | 91142bf | 2011-06-22 07:49:52 +0000 | [diff] [blame] | 1536 | sh7372_add_device_to_domain(&sh7372_a4lc, &meram_device); |
Kuninori Morimoto | c1ba5bb | 2011-07-10 10:12:08 +0200 | [diff] [blame] | 1537 | sh7372_add_device_to_domain(&sh7372_a4mp, &fsi_device); |
Magnus Damm | d93f5cd | 2011-10-19 23:52:41 +0200 | [diff] [blame] | 1538 | sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs0_device); |
| 1539 | sh7372_add_device_to_domain(&sh7372_a3sp, &usbhs1_device); |
| 1540 | sh7372_add_device_to_domain(&sh7372_a3sp, &sh_mmcif_device); |
| 1541 | sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi0_device); |
| 1542 | #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) |
| 1543 | sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi1_device); |
| 1544 | #endif |
| 1545 | sh7372_add_device_to_domain(&sh7372_a3sp, &sdhi2_device); |
Magnus Damm | 382414b | 2011-10-19 23:52:50 +0200 | [diff] [blame] | 1546 | sh7372_add_device_to_domain(&sh7372_a4r, &ceu_device); |
Rafael J. Wysocki | e3e0109 | 2011-07-01 22:13:56 +0200 | [diff] [blame] | 1547 | |
Guennadi Liakhovetski | 2ce51f8 | 2011-04-04 17:08:05 +0200 | [diff] [blame] | 1548 | hdmi_init_pm_clock(); |
Magnus Damm | 9799165 | 2011-04-29 02:28:08 +0900 | [diff] [blame] | 1549 | sh7372_pm_init(); |
Kuninori Morimoto | a41b646 | 2011-07-10 10:11:57 +0200 | [diff] [blame] | 1550 | pm_clk_add(&fsi_device.dev, "spu2"); |
Magnus Damm | 5c3f96b | 2011-08-24 22:38:43 +0200 | [diff] [blame] | 1551 | pm_clk_add(&hdmi_lcdc_device.dev, "hdmi"); |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1552 | } |
| 1553 | |
| 1554 | static void __init mackerel_timer_init(void) |
| 1555 | { |
| 1556 | sh7372_clock_init(); |
| 1557 | shmobile_timer.init(); |
Kuninori Morimoto | 12c4309 | 2011-01-06 02:44:09 +0000 | [diff] [blame] | 1558 | |
| 1559 | /* External clock source */ |
| 1560 | clk_set_rate(&sh7372_dv_clki_clk, 27000000); |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1561 | } |
| 1562 | |
| 1563 | static struct sys_timer mackerel_timer = { |
| 1564 | .init = mackerel_timer_init, |
| 1565 | }; |
| 1566 | |
| 1567 | MACHINE_START(MACKEREL, "mackerel") |
Magnus Damm | 5d7220ec | 2012-02-29 21:37:19 +0900 | [diff] [blame^] | 1568 | .map_io = sh7372_map_io, |
| 1569 | .init_early = sh7372_add_early_devices, |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1570 | .init_irq = sh7372_init_irq, |
Magnus Damm | 863b171 | 2010-12-28 08:27:01 +0000 | [diff] [blame] | 1571 | .handle_irq = shmobile_handle_irq_intc, |
Kuninori Morimoto | 920adc7 | 2010-11-29 02:21:21 +0000 | [diff] [blame] | 1572 | .init_machine = mackerel_init, |
| 1573 | .timer = &mackerel_timer, |
| 1574 | MACHINE_END |