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