blob: 112553f0f9bfab6558b73326d59885079aef5456 [file] [log] [blame]
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001/*
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 Morimoto12c43092011-01-06 02:44:09 +000024#include <linux/delay.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000025#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 Morimoto1a44d722010-12-01 00:31:46 +000033#include <linux/i2c.h>
Kuninori Morimotod44deb32010-11-30 06:52:18 +000034#include <linux/leds.h>
Yusuke Goda6dff7da2010-12-14 14:18:03 +090035#include <linux/mfd/tmio.h>
36#include <linux/mmc/host.h>
Yusuke Goda41491b92010-12-15 08:31:04 +000037#include <linux/mmc/sh_mmcif.h>
Guennadi Liakhovetski17e75d82011-03-09 11:27:56 +010038#include <linux/mmc/sh_mobile_sdhi.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000039#include <linux/mtd/mtd.h>
40#include <linux/mtd/partitions.h>
41#include <linux/mtd/physmap.h>
Bastian Hecht2aab52e2012-03-01 10:48:41 +010042#include <linux/mtd/sh_flctl.h>
Laurent Pinchart26e19bd2013-03-06 14:22:11 +010043#include <linux/pinctrl/machine.h>
Laurent Pinchart3a8067f2013-11-28 16:17:58 +010044#include <linux/pinctrl/pinconf-generic.h>
Laurent Pinchart14bd03e2013-07-04 21:13:27 +020045#include <linux/platform_data/gpio_backlight.h>
Rafael J. Wysockib5e8d262011-08-25 15:34:19 +020046#include <linux/pm_clock.h>
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +020047#include <linux/regulator/fixed.h>
48#include <linux/regulator/machine.h>
Kuninori Morimoto2264c152010-11-29 02:21:37 +000049#include <linux/smsc911x.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000050#include <linux/sh_intc.h>
Tony SIMcd8ab002010-12-09 01:55:55 +000051#include <linux/tca6416_keypad.h>
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +000052#include <linux/usb/renesas_usbhs.h>
Jon Medhurst9b742022011-08-04 17:05:21 +010053#include <linux/dma-mapping.h>
Kuninori Morimoto12c43092011-01-06 02:44:09 +000054#include <video/sh_mobile_hdmi.h>
Kuninori Morimoto11fee462010-11-29 02:21:43 +000055#include <video/sh_mobile_lcdc.h>
Magnus Dammae37c8d2010-12-22 14:47:40 +000056#include <media/sh_mobile_ceu.h>
57#include <media/soc_camera.h>
58#include <media/soc_camera_platform.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000059#include <sound/sh_fsi.h>
Kuninori Morimotoaf8a2fe2012-04-08 21:18:28 -070060#include <sound/simple_card.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000061
Kuninori Morimoto920adc72010-11-29 02:21:21 +000062#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060063#include <mach/irqs.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000064#include <mach/sh7372.h>
65
66#include <asm/mach/arch.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000067#include <asm/mach-types.h>
68
Rob Herring66791852012-08-28 12:54:42 -050069#include "sh-gpio.h"
70
Kuninori Morimoto920adc72010-11-29 02:21:21 +000071/*
72 * Address Interface BusWidth note
73 * ------------------------------------------------------------------
74 * 0x0000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = ON
75 * 0x0800_0000 user area -
76 * 0x1000_0000 NOR Flash ROM (MCP) 16bit SW7 : bit1 = OFF
77 * 0x1400_0000 Ether (LAN9220) 16bit
78 * 0x1600_0000 user area - cannot use with NAND
79 * 0x1800_0000 user area -
80 * 0x1A00_0000 -
81 * 0x4000_0000 LPDDR2-SDRAM (POP) 32bit
82 */
83
Kuninori Morimoto4b82b682010-11-29 02:21:48 +000084/*
85 * CPU mode
86 *
87 * SW4 | Boot Area| Master | Remarks
88 * 1 | 2 | 3 | 4 | 5 | 6 | 8 | | Processor|
89 * ----+-----+-----+-----+-----+-----+-----+----------+----------+--------------
90 * ON | ON | OFF | ON | ON | OFF | OFF | External | System | External ROM
91 * ON | ON | ON | ON | ON | OFF | OFF | External | System | ROM Debug
92 * ON | ON | X | ON | OFF | OFF | OFF | Built-in | System | ROM Debug
93 * X | OFF | X | X | X | X | OFF | Built-in | System | MaskROM
94 * OFF | X | X | X | X | X | OFF | Built-in | System | MaskROM
95 * X | X | X | OFF | X | X | OFF | Built-in | System | MaskROM
96 * OFF | ON | OFF | X | X | OFF | ON | External | System | Standalone
97 * ON | OFF | OFF | X | X | OFF | ON | External | Realtime | Standalone
98*/
99
100/*
101 * NOR Flash ROM
102 *
103 * SW1 | SW2 | SW7 | NOR Flash ROM
104 * bit1 | bit1 bit2 | bit1 | Memory allocation
105 * ------+------------+------+------------------
106 * OFF | ON OFF | ON | Area 0
107 * OFF | ON OFF | OFF | Area 4
108 */
109
110/*
111 * SMSC 9220
112 *
113 * SW1 SMSC 9220
114 * -----------------------
115 * ON access disable
116 * OFF access enable
117 */
118
119/*
120 * NAND Flash ROM
121 *
122 * SW1 | SW2 | SW7 | NAND Flash ROM
123 * bit1 | bit1 bit2 | bit2 | Memory allocation
124 * ------+------------+------+------------------
125 * OFF | ON OFF | ON | FCE 0
126 * OFF | ON OFF | OFF | FCE 1
127 */
128
129/*
130 * External interrupt pin settings
131 *
132 * IRQX | pin setting | device | level
133 * ------+--------------------+--------------------+-------
134 * IRQ0 | ICR1A.IRQ0SA=0010 | SDHI2 card detect | Low
135 * IRQ6 | ICR1A.IRQ6SA=0011 | Ether(LAN9220) | High
Magnus Damme2a53b72011-06-09 07:03:37 +0000136 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000137 * IRQ8 | ICR2A.IRQ8SA=0010 | MMC/SD card detect | Low
138 * IRQ9 | ICR2A.IRQ9SA=0010 | KEY(TCA6408) | Low
139 * IRQ21 | ICR4A.IRQ21SA=0011 | Sensor(ADXL345) | High
140 * IRQ22 | ICR4A.IRQ22SA=0011 | Sensor(AK8975) | High
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000141 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000142
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000143/*
144 * USB
145 *
146 * USB0 : CN22 : Function
147 * USB1 : CN31 : Function/Host *1
148 *
149 * J30 (for CN31) *1
150 * ----------+---------------+-------------
151 * 1-2 short | VBUS 5V | Host
152 * open | external VBUS | Function
153 *
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000154 * CAUTION
155 *
156 * renesas_usbhs driver can use external interrupt mode
157 * (which come from USB-PHY) or autonomy mode (it use own interrupt)
158 * for detecting connection/disconnection when Function.
159 * USB will be power OFF while it has been disconnecting
160 * if external interrupt mode, and it is always power ON if autonomy mode,
161 *
162 * mackerel can not use external interrupt (IRQ7-PORT167) mode on "USB0",
163 * because Touchscreen is using IRQ7-PORT40.
164 * It is impossible to use IRQ7 demux on this board.
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000165 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000166
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000167/*
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900168 * SDHI0 (CN12)
169 *
170 * SW56 : OFF
171 *
172 */
173
174/* MMC /SDHI1 (CN7)
175 *
176 * I/O voltage : 1.8v
177 *
178 * Power voltage : 1.8v or 3.3v
Yusuke Goda41491b92010-12-15 08:31:04 +0000179 * J22 : select power voltage *1
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900180 * 1-2 pin : 1.8v
181 * 2-3 pin : 3.3v
182 *
Yusuke Goda41491b92010-12-15 08:31:04 +0000183 * *1
184 * Please change J22 depends the card to be used.
185 * MMC's OCR field set to support either voltage for the card inserted.
186 *
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900187 * SW1 | SW33
188 * | bit1 | bit2 | bit3 | bit4
189 * -------------+------+------+------+-------
Simon Horman2150dac2011-01-07 22:26:15 +0000190 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
191 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900192 *
193 */
194
195/*
196 * SDHI2 (CN23)
197 *
198 * microSD card sloct
199 *
200 */
201
202/*
Kuninori Morimoto6d9b7dd2012-01-18 16:37:07 -0800203 * FSI - AK4642
204 *
205 * it needs amixer settings for playing
206 *
Kuninori Morimotoffdfe2d2012-12-24 20:03:45 -0800207 * amixer set "Headphone Enable" on
Kuninori Morimoto6d9b7dd2012-01-18 16:37:07 -0800208 */
209
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200210/* Fixed 3.3V and 1.8V regulators to be used by multiple devices */
211static struct regulator_consumer_supply fixed1v8_power_consumers[] =
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000212{
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200213 /*
214 * J22 on mackerel switches mmcif.0 and sdhi.1 between 1.8V and 3.3V
215 * Since we cannot support both voltages, we support the default 1.8V
216 */
217 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.1"),
218 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.1"),
219 REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"),
220 REGULATOR_SUPPLY("vqmmc", "sh_mmcif.0"),
221};
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000222
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200223static struct regulator_consumer_supply fixed3v3_power_consumers[] =
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000224{
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200225 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
226 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.0"),
227 REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.2"),
228 REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi.2"),
229};
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000230
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200231/* Dummy supplies, where voltage doesn't matter */
232static struct regulator_consumer_supply dummy_supplies[] = {
233 REGULATOR_SUPPLY("vddvario", "smsc911x"),
234 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
235};
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000236
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000237/* MTD */
238static struct mtd_partition nor_flash_partitions[] = {
239 {
240 .name = "loader",
241 .offset = 0x00000000,
242 .size = 512 * 1024,
243 .mask_flags = MTD_WRITEABLE,
244 },
245 {
246 .name = "bootenv",
247 .offset = MTDPART_OFS_APPEND,
248 .size = 512 * 1024,
249 .mask_flags = MTD_WRITEABLE,
250 },
251 {
252 .name = "kernel_ro",
253 .offset = MTDPART_OFS_APPEND,
254 .size = 8 * 1024 * 1024,
255 .mask_flags = MTD_WRITEABLE,
256 },
257 {
258 .name = "kernel",
259 .offset = MTDPART_OFS_APPEND,
260 .size = 8 * 1024 * 1024,
261 },
262 {
263 .name = "data",
264 .offset = MTDPART_OFS_APPEND,
265 .size = MTDPART_SIZ_FULL,
266 },
267};
268
269static struct physmap_flash_data nor_flash_data = {
270 .width = 2,
271 .parts = nor_flash_partitions,
272 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
273};
274
275static struct resource nor_flash_resources[] = {
276 [0] = {
Magnus Damm487881c2011-09-27 18:29:31 +0900277 .start = 0x20000000, /* CS0 shadow instead of regular CS0 */
278 .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000279 .flags = IORESOURCE_MEM,
280 }
281};
282
283static struct platform_device nor_flash_device = {
284 .name = "physmap-flash",
285 .dev = {
286 .platform_data = &nor_flash_data,
287 },
288 .num_resources = ARRAY_SIZE(nor_flash_resources),
289 .resource = nor_flash_resources,
290};
291
Kuninori Morimoto2264c152010-11-29 02:21:37 +0000292/* SMSC */
293static struct resource smc911x_resources[] = {
294 {
295 .start = 0x14000000,
296 .end = 0x16000000 - 1,
297 .flags = IORESOURCE_MEM,
298 }, {
299 .start = evt2irq(0x02c0) /* IRQ6A */,
300 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
301 },
302};
303
304static struct smsc911x_platform_config smsc911x_info = {
305 .flags = SMSC911X_USE_16BIT | SMSC911X_SAVE_MAC_ADDRESS,
306 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
307 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
308};
309
310static struct platform_device smc911x_device = {
311 .name = "smsc911x",
312 .id = -1,
313 .num_resources = ARRAY_SIZE(smc911x_resources),
314 .resource = smc911x_resources,
315 .dev = {
316 .platform_data = &smsc911x_info,
317 },
318};
319
Damian1c7fcbe2011-05-24 07:01:22 +0000320/* MERAM */
321static struct sh_mobile_meram_info mackerel_meram_info = {
322 .addr_mode = SH_MOBILE_MERAM_MODE1,
323};
324
325static struct resource meram_resources[] = {
326 [0] = {
Laurent Pincharte71504d2011-09-11 23:30:45 +0200327 .name = "regs",
Damian1c7fcbe2011-05-24 07:01:22 +0000328 .start = 0xe8000000,
Laurent Pincharte71504d2011-09-11 23:30:45 +0200329 .end = 0xe807ffff,
330 .flags = IORESOURCE_MEM,
331 },
332 [1] = {
333 .name = "meram",
334 .start = 0xe8080000,
Damian1c7fcbe2011-05-24 07:01:22 +0000335 .end = 0xe81fffff,
336 .flags = IORESOURCE_MEM,
337 },
338};
339
340static struct platform_device meram_device = {
341 .name = "sh_mobile_meram",
342 .id = 0,
343 .num_resources = ARRAY_SIZE(meram_resources),
344 .resource = meram_resources,
345 .dev = {
346 .platform_data = &mackerel_meram_info,
347 },
348};
349
Laurent Pinchart14bd03e2013-07-04 21:13:27 +0200350/* LCDC and backlight */
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000351static struct fb_videomode mackerel_lcdc_modes[] = {
352 {
353 .name = "WVGA Panel",
354 .xres = 800,
355 .yres = 480,
356 .left_margin = 220,
357 .right_margin = 110,
358 .hsync_len = 70,
359 .upper_margin = 20,
360 .lower_margin = 5,
361 .vsync_len = 5,
362 .sync = 0,
363 },
364};
365
Laurent Pinchartc241a0e2011-09-11 23:30:45 +0200366static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
Damian1c7fcbe2011-05-24 07:01:22 +0000367 .icb[0] = {
Damian1c7fcbe2011-05-24 07:01:22 +0000368 .meram_size = 0x40,
369 },
370 .icb[1] = {
Damian1c7fcbe2011-05-24 07:01:22 +0000371 .meram_size = 0x40,
372 },
373};
374
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000375static struct sh_mobile_lcdc_info lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000376 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000377 .clock_source = LCDC_CLK_BUS,
378 .ch[0] = {
379 .chan = LCDC_CHAN_MAINLCD,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100380 .fourcc = V4L2_PIX_FMT_RGB565,
Laurent Pinchart93ff2592011-11-29 14:33:41 +0100381 .lcd_modes = mackerel_lcdc_modes,
382 .num_modes = ARRAY_SIZE(mackerel_lcdc_modes),
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000383 .interface_type = RGB24,
Kuninori Morimoto2c34e932011-03-02 09:05:21 +0000384 .clock_divider = 3,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000385 .flags = 0,
Laurent Pinchartafaad832011-09-11 22:59:04 +0200386 .panel_cfg = {
387 .width = 152,
388 .height = 91,
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000389 },
Damian1c7fcbe2011-05-24 07:01:22 +0000390 .meram_cfg = &lcd_meram_cfg,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000391 }
392};
393
394static struct resource lcdc_resources[] = {
395 [0] = {
396 .name = "LCDC",
397 .start = 0xfe940000,
398 .end = 0xfe943fff,
399 .flags = IORESOURCE_MEM,
400 },
401 [1] = {
402 .start = intcs_evt2irq(0x580),
403 .flags = IORESOURCE_IRQ,
404 },
405};
406
407static struct platform_device lcdc_device = {
408 .name = "sh_mobile_lcdc_fb",
409 .num_resources = ARRAY_SIZE(lcdc_resources),
410 .resource = lcdc_resources,
411 .dev = {
412 .platform_data = &lcdc_info,
Laurent Pinchartb6328a62013-12-16 19:16:09 +0100413 .coherent_dma_mask = DMA_BIT_MASK(32),
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000414 },
415};
416
Laurent Pinchart14bd03e2013-07-04 21:13:27 +0200417static struct gpio_backlight_platform_data gpio_backlight_data = {
418 .fbdev = &lcdc_device.dev,
419 .gpio = 31,
420 .def_value = 1,
421 .name = "backlight",
422};
423
424static struct platform_device gpio_backlight_device = {
425 .name = "gpio-backlight",
426 .dev = {
427 .platform_data = &gpio_backlight_data,
428 },
429};
430
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000431/* HDMI */
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000432static struct sh_mobile_hdmi_info hdmi_info = {
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000433 .flags = HDMI_SND_SRC_SPDIF,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000434};
435
436static struct resource hdmi_resources[] = {
437 [0] = {
438 .name = "HDMI",
439 .start = 0xe6be0000,
440 .end = 0xe6be00ff,
441 .flags = IORESOURCE_MEM,
442 },
443 [1] = {
444 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
445 .start = evt2irq(0x17e0),
446 .flags = IORESOURCE_IRQ,
447 },
448};
449
450static struct platform_device hdmi_device = {
451 .name = "sh-mobile-hdmi",
452 .num_resources = ARRAY_SIZE(hdmi_resources),
453 .resource = hdmi_resources,
454 .id = -1,
455 .dev = {
456 .platform_data = &hdmi_info,
457 },
458};
459
Laurent Pinchartc241a0e2011-09-11 23:30:45 +0200460static const struct sh_mobile_meram_cfg hdmi_meram_cfg = {
Laurent Pincharta1022ad2011-09-11 23:30:45 +0200461 .icb[0] = {
Laurent Pincharta1022ad2011-09-11 23:30:45 +0200462 .meram_size = 0x100,
463 },
464 .icb[1] = {
Laurent Pincharta1022ad2011-09-11 23:30:45 +0200465 .meram_size = 0x100,
466 },
467};
468
469static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
470 .meram_dev = &mackerel_meram_info,
471 .clock_source = LCDC_CLK_EXTERNAL,
472 .ch[0] = {
473 .chan = LCDC_CHAN_MAINLCD,
474 .fourcc = V4L2_PIX_FMT_RGB565,
475 .interface_type = RGB24,
476 .clock_divider = 1,
477 .flags = LCDC_FLAGS_DWPOL,
478 .meram_cfg = &hdmi_meram_cfg,
479 .tx_dev = &hdmi_device,
480 }
481};
482
483static struct resource hdmi_lcdc_resources[] = {
484 [0] = {
485 .name = "LCDC1",
486 .start = 0xfe944000,
487 .end = 0xfe947fff,
488 .flags = IORESOURCE_MEM,
489 },
490 [1] = {
491 .start = intcs_evt2irq(0x1780),
492 .flags = IORESOURCE_IRQ,
493 },
494};
495
496static struct platform_device hdmi_lcdc_device = {
497 .name = "sh_mobile_lcdc_fb",
498 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
499 .resource = hdmi_lcdc_resources,
500 .id = 1,
501 .dev = {
502 .platform_data = &hdmi_lcdc_info,
Laurent Pinchartb6328a62013-12-16 19:16:09 +0100503 .coherent_dma_mask = DMA_BIT_MASK(32),
Laurent Pincharta1022ad2011-09-11 23:30:45 +0200504 },
505};
506
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700507static struct asoc_simple_card_info fsi2_hdmi_info = {
508 .name = "HDMI",
509 .card = "FSI2B-HDMI",
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700510 .codec = "sh-mobile-hdmi",
511 .platform = "sh_fsi2",
Kuninori Morimoto313c84b2014-03-16 17:37:06 -0700512 .daifmt = SND_SOC_DAIFMT_CBS_CFS,
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800513 .cpu_dai = {
514 .name = "fsib-dai",
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800515 },
516 .codec_dai = {
517 .name = "sh_mobile_hdmi-hifi",
518 },
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700519};
520
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900521static struct platform_device fsi_hdmi_device = {
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700522 .name = "asoc-simple-card",
523 .id = 1,
524 .dev = {
525 .platform_data = &fsi2_hdmi_info,
Kuninori Morimotoffb83e82014-06-22 17:55:18 -0700526 .coherent_dma_mask = DMA_BIT_MASK(32),
527 .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask,
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700528 },
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900529};
530
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200531static void __init hdmi_init_pm_clock(void)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000532{
533 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
534 int ret;
535 long rate;
536
537 if (IS_ERR(hdmi_ick)) {
538 ret = PTR_ERR(hdmi_ick);
539 pr_err("Cannot get HDMI ICK: %d\n", ret);
540 goto out;
541 }
542
543 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
544 if (ret < 0) {
545 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
546 ret, sh7372_pllc2_clk.usecount);
547 goto out;
548 }
549
550 pr_debug("PLLC2 initial frequency %lu\n",
551 clk_get_rate(&sh7372_pllc2_clk));
552
553 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
Paul Walmsley90d423f2013-11-26 16:49:38 -0800554 if (rate <= 0) {
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000555 pr_err("Cannot get suitable rate: %ld\n", rate);
Paul Walmsley90d423f2013-11-26 16:49:38 -0800556 ret = -EINVAL;
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000557 goto out;
558 }
559
560 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
561 if (ret < 0) {
562 pr_err("Cannot set rate %ld: %d\n", rate, ret);
563 goto out;
564 }
565
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000566 pr_debug("PLLC2 set frequency %lu\n", rate);
567
568 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200569 if (ret < 0)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000570 pr_err("Cannot set HDMI parent: %d\n", ret);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000571
572out:
573 if (!IS_ERR(hdmi_ick))
574 clk_put(hdmi_ick);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000575}
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000576
Magnus Damme2a53b72011-06-09 07:03:37 +0000577/* USBHS0 is connected to CN22 which takes a USB Mini-B plug
578 *
579 * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug,
580 * but on this particular board IRQ7 is already used by
581 * the touch screen. This leaves us with software polling.
582 */
583#define USBHS0_POLL_INTERVAL (HZ * 5)
584
585struct usbhs_private {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000586 void __iomem *usbphyaddr;
587 void __iomem *usbcrcaddr;
Magnus Damme2a53b72011-06-09 07:03:37 +0000588 struct renesas_usbhs_platform_info info;
589 struct delayed_work work;
590 struct platform_device *pdev;
591};
592
593#define usbhs_get_priv(pdev) \
594 container_of(renesas_usbhs_get_info(pdev), \
595 struct usbhs_private, info)
596
597#define usbhs_is_connected(priv) \
598 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
599
600static int usbhs_get_vbus(struct platform_device *pdev)
601{
602 return usbhs_is_connected(usbhs_get_priv(pdev));
603}
604
Kuninori Morimoto225da3e2013-03-31 18:34:43 -0700605static int usbhs_phy_reset(struct platform_device *pdev)
Magnus Damme2a53b72011-06-09 07:03:37 +0000606{
607 struct usbhs_private *priv = usbhs_get_priv(pdev);
608
609 /* init phy */
610 __raw_writew(0x8a0a, priv->usbcrcaddr);
Kuninori Morimoto225da3e2013-03-31 18:34:43 -0700611
612 return 0;
Magnus Damme2a53b72011-06-09 07:03:37 +0000613}
614
615static int usbhs0_get_id(struct platform_device *pdev)
616{
617 return USBHS_GADGET;
618}
619
620static void usbhs0_work_function(struct work_struct *work)
621{
622 struct usbhs_private *priv = container_of(work, struct usbhs_private,
623 work.work);
624
625 renesas_usbhs_call_notify_hotplug(priv->pdev);
626 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
627}
628
629static int usbhs0_hardware_init(struct platform_device *pdev)
630{
631 struct usbhs_private *priv = usbhs_get_priv(pdev);
632
633 priv->pdev = pdev;
634 INIT_DELAYED_WORK(&priv->work, usbhs0_work_function);
635 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
636 return 0;
637}
638
Kuninori Morimoto225da3e2013-03-31 18:34:43 -0700639static int usbhs0_hardware_exit(struct platform_device *pdev)
Magnus Damme2a53b72011-06-09 07:03:37 +0000640{
641 struct usbhs_private *priv = usbhs_get_priv(pdev);
642
643 cancel_delayed_work_sync(&priv->work);
Kuninori Morimoto225da3e2013-03-31 18:34:43 -0700644
645 return 0;
Magnus Damme2a53b72011-06-09 07:03:37 +0000646}
647
Magnus Damme2a53b72011-06-09 07:03:37 +0000648static struct usbhs_private usbhs0_private = {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000649 .usbcrcaddr = IOMEM(0xe605810c), /* USBCR2 */
Magnus Damme2a53b72011-06-09 07:03:37 +0000650 .info = {
651 .platform_callback = {
652 .hardware_init = usbhs0_hardware_init,
653 .hardware_exit = usbhs0_hardware_exit,
654 .phy_reset = usbhs_phy_reset,
655 .get_id = usbhs0_get_id,
656 .get_vbus = usbhs_get_vbus,
657 },
658 .driver_param = {
659 .buswait_bwait = 4,
Kuninori Morimotofe437562011-06-17 08:21:21 +0000660 .d0_tx_id = SHDMA_SLAVE_USB0_TX,
661 .d1_rx_id = SHDMA_SLAVE_USB0_RX,
Magnus Damme2a53b72011-06-09 07:03:37 +0000662 },
663 },
664};
665
666static struct resource usbhs0_resources[] = {
667 [0] = {
668 .name = "USBHS0",
669 .start = 0xe6890000,
670 .end = 0xe68900e6 - 1,
671 .flags = IORESOURCE_MEM,
672 },
673 [1] = {
674 .start = evt2irq(0x1ca0) /* USB0_USB0I0 */,
675 .flags = IORESOURCE_IRQ,
676 },
677};
678
679static struct platform_device usbhs0_device = {
680 .name = "renesas_usbhs",
681 .id = 0,
682 .dev = {
683 .platform_data = &usbhs0_private.info,
684 },
685 .num_resources = ARRAY_SIZE(usbhs0_resources),
686 .resource = usbhs0_resources,
687};
688
689/* USBHS1 is connected to CN31 which takes a USB Mini-AB plug
690 *
691 * Use J30 to select between Host and Function. This setting
692 * can however not be detected by software. Hotplug of USBHS1
693 * is provided via IRQ8.
Kuninori Morimoto0ada2da52012-01-18 17:32:05 -0800694 *
695 * Current USB1 works as "USB Host".
696 * - set J30 "short"
697 *
698 * If you want to use it as "USB gadget",
699 * - J30 "open"
700 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
701 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
Kuninori Morimotoe26a6032012-08-05 22:47:00 -0700702 * - check usbhs0_device(pio)/usbhs1_device(irq) order in mackerel_devices.
Magnus Damme2a53b72011-06-09 07:03:37 +0000703 */
704#define IRQ8 evt2irq(0x0300)
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000705#define USB_PHY_MODE (1 << 4)
706#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
707#define USB_PHY_ON (1 << 1)
708#define USB_PHY_OFF (1 << 0)
709#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
710
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000711static irqreturn_t usbhs1_interrupt(int irq, void *data)
712{
713 struct platform_device *pdev = data;
714 struct usbhs_private *priv = usbhs_get_priv(pdev);
715
716 dev_dbg(&pdev->dev, "%s\n", __func__);
717
718 renesas_usbhs_call_notify_hotplug(pdev);
719
720 /* clear status */
721 __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR,
722 priv->usbphyaddr);
723
724 return IRQ_HANDLED;
725}
726
727static int usbhs1_hardware_init(struct platform_device *pdev)
728{
729 struct usbhs_private *priv = usbhs_get_priv(pdev);
730 int ret;
731
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000732 /* clear interrupt status */
733 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
734
Magnus Damme2a53b72011-06-09 07:03:37 +0000735 ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000736 dev_name(&pdev->dev), pdev);
737 if (ret) {
738 dev_err(&pdev->dev, "request_irq err\n");
739 return ret;
740 }
741
742 /* enable USB phy interrupt */
743 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr);
744
745 return 0;
746}
747
Kuninori Morimoto225da3e2013-03-31 18:34:43 -0700748static int usbhs1_hardware_exit(struct platform_device *pdev)
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000749{
750 struct usbhs_private *priv = usbhs_get_priv(pdev);
751
752 /* clear interrupt status */
753 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
754
Magnus Damme2a53b72011-06-09 07:03:37 +0000755 free_irq(IRQ8, pdev);
Kuninori Morimoto225da3e2013-03-31 18:34:43 -0700756
757 return 0;
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000758}
759
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000760static int usbhs1_get_id(struct platform_device *pdev)
761{
Kuninori Morimoto0ada2da52012-01-18 17:32:05 -0800762 return USBHS_HOST;
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000763}
764
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000765static u32 usbhs1_pipe_cfg[] = {
766 USB_ENDPOINT_XFER_CONTROL,
767 USB_ENDPOINT_XFER_ISOC,
768 USB_ENDPOINT_XFER_ISOC,
769 USB_ENDPOINT_XFER_BULK,
770 USB_ENDPOINT_XFER_BULK,
771 USB_ENDPOINT_XFER_BULK,
772 USB_ENDPOINT_XFER_INT,
773 USB_ENDPOINT_XFER_INT,
774 USB_ENDPOINT_XFER_INT,
775 USB_ENDPOINT_XFER_BULK,
776 USB_ENDPOINT_XFER_BULK,
777 USB_ENDPOINT_XFER_BULK,
778 USB_ENDPOINT_XFER_BULK,
779 USB_ENDPOINT_XFER_BULK,
780 USB_ENDPOINT_XFER_BULK,
781 USB_ENDPOINT_XFER_BULK,
782};
783
784static struct usbhs_private usbhs1_private = {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000785 .usbphyaddr = IOMEM(0xe60581e2), /* USBPHY1INTAP */
786 .usbcrcaddr = IOMEM(0xe6058130), /* USBCR4 */
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000787 .info = {
788 .platform_callback = {
789 .hardware_init = usbhs1_hardware_init,
790 .hardware_exit = usbhs1_hardware_exit,
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000791 .get_id = usbhs1_get_id,
Magnus Damme2a53b72011-06-09 07:03:37 +0000792 .phy_reset = usbhs_phy_reset,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000793 },
794 .driver_param = {
795 .buswait_bwait = 4,
Kuninori Morimotof427eb62011-10-10 22:06:12 -0700796 .has_otg = 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000797 .pipe_type = usbhs1_pipe_cfg,
798 .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg),
Kuninori Morimotofe437562011-06-17 08:21:21 +0000799 .d0_tx_id = SHDMA_SLAVE_USB1_TX,
800 .d1_rx_id = SHDMA_SLAVE_USB1_RX,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000801 },
802 },
803};
804
805static struct resource usbhs1_resources[] = {
806 [0] = {
Magnus Damme2a53b72011-06-09 07:03:37 +0000807 .name = "USBHS1",
808 .start = 0xe68b0000,
809 .end = 0xe68b00e6 - 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000810 .flags = IORESOURCE_MEM,
811 },
812 [1] = {
813 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
814 .flags = IORESOURCE_IRQ,
815 },
816};
817
818static struct platform_device usbhs1_device = {
819 .name = "renesas_usbhs",
820 .id = 1,
821 .dev = {
822 .platform_data = &usbhs1_private.info,
Kuninori Morimotoc8c32432012-11-07 19:09:01 -0800823 .dma_mask = &usbhs1_device.dev.coherent_dma_mask,
824 .coherent_dma_mask = DMA_BIT_MASK(32),
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000825 },
826 .num_resources = ARRAY_SIZE(usbhs1_resources),
827 .resource = usbhs1_resources,
828};
829
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000830/* LED */
831static struct gpio_led mackerel_leds[] = {
832 {
833 .name = "led0",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100834 .gpio = 0,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000835 .default_state = LEDS_GPIO_DEFSTATE_ON,
836 },
837 {
838 .name = "led1",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100839 .gpio = 1,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000840 .default_state = LEDS_GPIO_DEFSTATE_ON,
841 },
842 {
843 .name = "led2",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100844 .gpio = 2,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000845 .default_state = LEDS_GPIO_DEFSTATE_ON,
846 },
847 {
848 .name = "led3",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100849 .gpio = 159,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000850 .default_state = LEDS_GPIO_DEFSTATE_ON,
851 }
852};
853
854static struct gpio_led_platform_data mackerel_leds_pdata = {
855 .leds = mackerel_leds,
856 .num_leds = ARRAY_SIZE(mackerel_leds),
857};
858
859static struct platform_device leds_device = {
860 .name = "leds-gpio",
861 .id = 0,
862 .dev = {
863 .platform_data = &mackerel_leds_pdata,
864 },
865};
866
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000867/* FSI */
868#define IRQ_FSI evt2irq(0x1840)
869static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimotofec691e2012-02-03 00:58:48 -0800870 .port_a = {
Kuninori Morimotoc650a1f2012-04-01 18:40:14 -0700871 .tx_id = SHDMA_SLAVE_FSIA_TX,
872 .rx_id = SHDMA_SLAVE_FSIA_RX,
Kuninori Morimotofec691e2012-02-03 00:58:48 -0800873 },
874 .port_b = {
Kuninori Morimotoabca7582012-12-16 22:12:42 -0800875 .flags = SH_FSI_CLK_CPG |
876 SH_FSI_FMT_SPDIF,
Kuninori Morimotofec691e2012-02-03 00:58:48 -0800877 }
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000878};
879
880static struct resource fsi_resources[] = {
881 [0] = {
Kuninori Morimotoc650a1f2012-04-01 18:40:14 -0700882 /* we need 0xFE1F0000 to access DMA
883 * instead of 0xFE3C0000 */
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000884 .name = "FSI",
Kuninori Morimotoc650a1f2012-04-01 18:40:14 -0700885 .start = 0xFE1F0000,
886 .end = 0xFE1F0400 - 1,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000887 .flags = IORESOURCE_MEM,
888 },
889 [1] = {
890 .start = IRQ_FSI,
891 .flags = IORESOURCE_IRQ,
892 },
893};
894
895static struct platform_device fsi_device = {
896 .name = "sh_fsi2",
897 .id = -1,
898 .num_resources = ARRAY_SIZE(fsi_resources),
899 .resource = fsi_resources,
900 .dev = {
901 .platform_data = &fsi_info,
902 },
903};
904
Kuninori Morimotoaf8a2fe2012-04-08 21:18:28 -0700905static struct asoc_simple_card_info fsi2_ak4643_info = {
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800906 .name = "AK4643",
907 .card = "FSI2A-AK4643",
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800908 .codec = "ak4642-codec.0-0013",
909 .platform = "sh_fsi2",
Kuninori Morimotoc7a507e2014-03-13 17:56:25 -0700910 .daifmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800911 .cpu_dai = {
912 .name = "fsia-dai",
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800913 },
914 .codec_dai = {
915 .name = "ak4642-hifi",
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800916 .sysclk = 11289600,
917 },
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800918};
919
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000920static struct platform_device fsi_ak4643_device = {
Kuninori Morimotoaf8a2fe2012-04-08 21:18:28 -0700921 .name = "asoc-simple-card",
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800922 .dev = {
923 .platform_data = &fsi2_ak4643_info,
Kuninori Morimotoffb83e82014-06-22 17:55:18 -0700924 .coherent_dma_mask = DMA_BIT_MASK(32),
925 .dma_mask = &fsi_ak4643_device.dev.coherent_dma_mask,
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800926 },
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000927};
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000928
Bastian Hecht2aab52e2012-03-01 10:48:41 +0100929/* FLCTL */
930static struct mtd_partition nand_partition_info[] = {
931 {
932 .name = "system",
933 .offset = 0,
934 .size = 128 * 1024 * 1024,
935 },
936 {
937 .name = "userdata",
938 .offset = MTDPART_OFS_APPEND,
939 .size = 256 * 1024 * 1024,
940 },
941 {
942 .name = "cache",
943 .offset = MTDPART_OFS_APPEND,
944 .size = 128 * 1024 * 1024,
945 },
946};
947
948static struct resource nand_flash_resources[] = {
949 [0] = {
950 .start = 0xe6a30000,
951 .end = 0xe6a3009b,
952 .flags = IORESOURCE_MEM,
Bastian Hecht3042ac52012-11-20 01:05:00 +0100953 },
954 [1] = {
955 .start = evt2irq(0x0d80), /* flstei: status error irq */
956 .flags = IORESOURCE_IRQ,
957 },
Bastian Hecht2aab52e2012-03-01 10:48:41 +0100958};
959
960static struct sh_flctl_platform_data nand_flash_data = {
961 .parts = nand_partition_info,
962 .nr_parts = ARRAY_SIZE(nand_partition_info),
963 .flcmncr_val = CLK_16B_12L_4H | TYPESEL_SET
964 | SHBUSSEL | SEL_16BIT | SNAND_E,
965 .use_holden = 1,
966};
967
968static struct platform_device nand_flash_device = {
969 .name = "sh_flctl",
970 .resource = nand_flash_resources,
971 .num_resources = ARRAY_SIZE(nand_flash_resources),
972 .dev = {
973 .platform_data = &nand_flash_data,
974 },
975};
976
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900977/* SDHI0 */
978static struct sh_mobile_sdhi_info sdhi0_info = {
979 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
980 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Guennadi Liakhovetski2b3e38c2012-04-16 23:09:13 +0200981 .tmio_flags = TMIO_MMC_USE_GPIO_CD,
Magnus Dammda97da72011-01-06 10:55:41 +0000982 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100983 .cd_gpio = 172,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900984};
985
986static struct resource sdhi0_resources[] = {
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +0100987 {
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900988 .name = "SDHI0",
989 .start = 0xe6850000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100990 .end = 0xe68500ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900991 .flags = IORESOURCE_MEM,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +0100992 }, {
Guennadi Liakhovetski757688c2013-03-29 22:05:51 +0100993 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +0000994 .start = evt2irq(0x0e20) /* SDHI0_SDHI0I1 */,
995 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +0100996 }, {
Guennadi Liakhovetski757688c2013-03-29 22:05:51 +0100997 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +0000998 .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900999 .flags = IORESOURCE_IRQ,
1000 },
1001};
1002
1003static struct platform_device sdhi0_device = {
1004 .name = "sh_mobile_sdhi",
1005 .num_resources = ARRAY_SIZE(sdhi0_resources),
1006 .resource = sdhi0_resources,
1007 .id = 0,
1008 .dev = {
1009 .platform_data = &sdhi0_info,
1010 },
1011};
1012
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001013#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001014/* SDHI1 */
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001015
1016/* GPIO 41 can trigger IRQ8, but it is used by USBHS1, we have to poll */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001017static struct sh_mobile_sdhi_info sdhi1_info = {
1018 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
1019 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001020 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_USE_GPIO_CD,
Magnus Dammda97da72011-01-06 10:55:41 +00001021 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001022 MMC_CAP_NEEDS_POLL,
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001023 .cd_gpio = 41,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001024};
1025
1026static struct resource sdhi1_resources[] = {
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001027 {
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001028 .name = "SDHI1",
1029 .start = 0xe6860000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001030 .end = 0xe68600ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001031 .flags = IORESOURCE_MEM,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001032 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001033 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001034 .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
1035 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001036 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001037 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001038 .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001039 .flags = IORESOURCE_IRQ,
1040 },
1041};
1042
1043static struct platform_device sdhi1_device = {
1044 .name = "sh_mobile_sdhi",
1045 .num_resources = ARRAY_SIZE(sdhi1_resources),
1046 .resource = sdhi1_resources,
1047 .id = 1,
1048 .dev = {
1049 .platform_data = &sdhi1_info,
1050 },
1051};
Yusuke Goda41491b92010-12-15 08:31:04 +00001052#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001053
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001054/* SDHI2 */
1055
Yusuke Godada5d1f42011-01-07 09:48:36 +00001056/*
1057 * The card detect pin of the top SD/MMC slot (CN23) is active low and is
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001058 * connected to GPIO SCIFB_SCK of SH7372 (GPIO 162).
Yusuke Godada5d1f42011-01-07 09:48:36 +00001059 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001060static struct sh_mobile_sdhi_info sdhi2_info = {
1061 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
1062 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001063 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE | TMIO_MMC_USE_GPIO_CD,
Magnus Dammda97da72011-01-06 10:55:41 +00001064 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001065 MMC_CAP_NEEDS_POLL,
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001066 .cd_gpio = 162,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001067};
1068
1069static struct resource sdhi2_resources[] = {
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001070 {
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001071 .name = "SDHI2",
1072 .start = 0xe6870000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001073 .end = 0xe68700ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001074 .flags = IORESOURCE_MEM,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001075 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001076 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001077 .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */
1078 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001079 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001080 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001081 .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001082 .flags = IORESOURCE_IRQ,
1083 },
1084};
1085
1086static struct platform_device sdhi2_device = {
1087 .name = "sh_mobile_sdhi",
1088 .num_resources = ARRAY_SIZE(sdhi2_resources),
1089 .resource = sdhi2_resources,
1090 .id = 2,
1091 .dev = {
1092 .platform_data = &sdhi2_info,
1093 },
1094};
1095
Yusuke Goda41491b92010-12-15 08:31:04 +00001096/* SH_MMCIF */
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001097#if IS_ENABLED(CONFIG_MMC_SH_MMCIF)
Yusuke Goda41491b92010-12-15 08:31:04 +00001098static struct resource sh_mmcif_resources[] = {
1099 [0] = {
1100 .name = "MMCIF",
1101 .start = 0xE6BD0000,
1102 .end = 0xE6BD00FF,
1103 .flags = IORESOURCE_MEM,
1104 },
1105 [1] = {
1106 /* MMC ERR */
1107 .start = evt2irq(0x1ac0),
1108 .flags = IORESOURCE_IRQ,
1109 },
1110 [2] = {
1111 /* MMC NOR */
1112 .start = evt2irq(0x1ae0),
1113 .flags = IORESOURCE_IRQ,
1114 },
1115};
1116
1117static struct sh_mmcif_plat_data sh_mmcif_plat = {
1118 .sup_pclk = 0,
Yusuke Goda41491b92010-12-15 08:31:04 +00001119 .caps = MMC_CAP_4_BIT_DATA |
1120 MMC_CAP_8_BIT_DATA |
1121 MMC_CAP_NEEDS_POLL,
Guennadi Liakhovetskife0a1442013-03-29 22:05:50 +01001122 .use_cd_gpio = true,
1123 /* card detect pin for SD/MMC slot (CN7) */
1124 .cd_gpio = 41,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +02001125 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
1126 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Yusuke Goda41491b92010-12-15 08:31:04 +00001127};
1128
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001129static struct platform_device sh_mmcif_device = {
Yusuke Goda41491b92010-12-15 08:31:04 +00001130 .name = "sh_mmcif",
1131 .id = 0,
1132 .dev = {
1133 .dma_mask = NULL,
1134 .coherent_dma_mask = 0xffffffff,
1135 .platform_data = &sh_mmcif_plat,
1136 },
1137 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
1138 .resource = sh_mmcif_resources,
1139};
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001140#endif
Magnus Dammae37c8d2010-12-22 14:47:40 +00001141
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001142static int mackerel_camera_add(struct soc_camera_device *icd);
1143static void mackerel_camera_del(struct soc_camera_device *icd);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001144
1145static int camera_set_capture(struct soc_camera_platform_info *info,
1146 int enable)
1147{
1148 return 0; /* camera sensor always enabled */
1149}
1150
1151static struct soc_camera_platform_info camera_info = {
1152 .format_name = "UYVY",
1153 .format_depth = 16,
1154 .format = {
1155 .code = V4L2_MBUS_FMT_UYVY8_2X8,
1156 .colorspace = V4L2_COLORSPACE_SMPTE170M,
1157 .field = V4L2_FIELD_NONE,
1158 .width = 640,
1159 .height = 480,
1160 },
Guennadi Liakhovetskid1e87ed2011-07-27 10:48:40 -03001161 .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
1162 V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
1163 V4L2_MBUS_DATA_ACTIVE_HIGH,
1164 .mbus_type = V4L2_MBUS_PARALLEL,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001165 .set_capture = camera_set_capture,
1166};
1167
1168static struct soc_camera_link camera_link = {
1169 .bus_id = 0,
1170 .add_device = mackerel_camera_add,
1171 .del_device = mackerel_camera_del,
1172 .module_name = "soc_camera_platform",
1173 .priv = &camera_info,
1174};
1175
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001176static struct platform_device *camera_device;
Magnus Dammae37c8d2010-12-22 14:47:40 +00001177
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001178static void mackerel_camera_release(struct device *dev)
1179{
1180 soc_camera_platform_release(&camera_device);
1181}
Magnus Dammae37c8d2010-12-22 14:47:40 +00001182
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001183static int mackerel_camera_add(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001184{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001185 return soc_camera_platform_add(icd, &camera_device, &camera_link,
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001186 mackerel_camera_release, 0);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001187}
1188
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001189static void mackerel_camera_del(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001190{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001191 soc_camera_platform_del(icd, camera_device, &camera_link);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001192}
1193
1194static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
1195 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
Guennadi Liakhovetskief8f41f2012-04-16 23:09:04 +02001196 .max_width = 8188,
1197 .max_height = 8188,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001198};
1199
1200static struct resource ceu_resources[] = {
1201 [0] = {
1202 .name = "CEU",
1203 .start = 0xfe910000,
1204 .end = 0xfe91009f,
1205 .flags = IORESOURCE_MEM,
1206 },
1207 [1] = {
1208 .start = intcs_evt2irq(0x880),
1209 .flags = IORESOURCE_IRQ,
1210 },
1211 [2] = {
1212 /* place holder for contiguous memory */
1213 },
1214};
1215
1216static struct platform_device ceu_device = {
1217 .name = "sh_mobile_ceu",
1218 .id = 0, /* "ceu0" clock */
1219 .num_resources = ARRAY_SIZE(ceu_resources),
1220 .resource = ceu_resources,
1221 .dev = {
Guennadi Liakhovetski05a5f012011-03-23 09:29:16 +00001222 .platform_data = &sh_mobile_ceu_info,
1223 .coherent_dma_mask = 0xffffffff,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001224 },
1225};
1226
1227static struct platform_device mackerel_camera = {
1228 .name = "soc-camera-pdrv",
1229 .id = 0,
1230 .dev = {
1231 .platform_data = &camera_link,
1232 },
1233};
1234
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001235static struct platform_device *mackerel_devices[] __initdata = {
1236 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001237 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001238 &lcdc_device,
Laurent Pinchart14bd03e2013-07-04 21:13:27 +02001239 &gpio_backlight_device,
Kuninori Morimoto5a568552011-06-17 04:33:13 +00001240 &usbhs0_device,
Kuninori Morimotoe26a6032012-08-05 22:47:00 -07001241 &usbhs1_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +00001242 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001243 &fsi_device,
1244 &fsi_ak4643_device,
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +09001245 &fsi_hdmi_device,
Bastian Hecht2aab52e2012-03-01 10:48:41 +01001246 &nand_flash_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001247 &sdhi0_device,
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001248#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001249 &sdhi1_device,
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001250#else
1251 &sh_mmcif_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001252#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001253 &sdhi2_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001254 &ceu_device,
1255 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001256 &hdmi_device,
Laurent Pincharta1022ad2011-09-11 23:30:45 +02001257 &hdmi_lcdc_device,
Damian1c7fcbe2011-05-24 07:01:22 +00001258 &meram_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001259};
1260
Tony SIMcd8ab002010-12-09 01:55:55 +00001261/* Keypad Initialization */
1262#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
1263{ \
1264 .type = ev_type, \
1265 .code = ev_code, \
1266 .active_low = act_low, \
1267}
1268
1269#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
1270
1271static struct tca6416_button mackerel_gpio_keys[] = {
1272 KEYPAD_BUTTON_LOW(KEY_HOME),
1273 KEYPAD_BUTTON_LOW(KEY_MENU),
1274 KEYPAD_BUTTON_LOW(KEY_BACK),
1275 KEYPAD_BUTTON_LOW(KEY_POWER),
1276};
1277
1278static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
1279 .buttons = mackerel_gpio_keys,
1280 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
1281 .rep = 1,
1282 .use_polling = 0,
1283 .pinmask = 0x000F,
1284};
1285
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001286/* I2C */
Tony SIM6ae1e192011-01-11 09:47:59 +09001287#define IRQ7 evt2irq(0x02e0)
Tony SIMcd8ab002010-12-09 01:55:55 +00001288#define IRQ9 evt2irq(0x0320)
1289
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001290static struct i2c_board_info i2c0_devices[] = {
1291 {
1292 I2C_BOARD_INFO("ak4643", 0x13),
1293 },
Tony SIMcd8ab002010-12-09 01:55:55 +00001294 /* Keypad */
1295 {
1296 I2C_BOARD_INFO("tca6408-keys", 0x20),
1297 .platform_data = &mackerel_tca6416_keys_info,
1298 .irq = IRQ9,
1299 },
Tony SIM6ae1e192011-01-11 09:47:59 +09001300 /* Touchscreen */
1301 {
1302 I2C_BOARD_INFO("st1232-ts", 0x55),
1303 .irq = IRQ7,
1304 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001305};
1306
Tony SIM80f1dc7c2010-12-07 09:12:14 +00001307#define IRQ21 evt2irq(0x32a0)
1308
1309static struct i2c_board_info i2c1_devices[] = {
1310 /* Accelerometer */
1311 {
1312 I2C_BOARD_INFO("adxl34x", 0x53),
1313 .irq = IRQ21,
1314 },
1315};
1316
Laurent Pinchart3a8067f2013-11-28 16:17:58 +01001317static unsigned long pin_pulldown_conf[] = {
1318 PIN_CONF_PACKED(PIN_CONFIG_BIAS_PULL_DOWN, 0),
1319};
1320
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001321static const struct pinctrl_map mackerel_pinctrl_map[] = {
Laurent Pinchartcd87d902013-04-19 13:29:48 +02001322 /* ADXL34X */
1323 PIN_MAP_MUX_GROUP_DEFAULT("1-0053", "pfc-sh7372",
1324 "intc_irq21", "intc"),
Laurent Pinchart0acbc342013-04-19 13:29:48 +02001325 /* CEU */
1326 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1327 "ceu_data_0_7", "ceu"),
1328 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1329 "ceu_clk_0", "ceu"),
1330 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1331 "ceu_sync", "ceu"),
1332 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_ceu.0", "pfc-sh7372",
1333 "ceu_field", "ceu"),
Laurent Pinchart7e4f07d2013-04-19 13:29:48 +02001334 /* FLCTL */
1335 PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372",
1336 "flctl_data", "flctl"),
1337 PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372",
1338 "flctl_ce0", "flctl"),
1339 PIN_MAP_MUX_GROUP_DEFAULT("sh_flctl.0", "pfc-sh7372",
1340 "flctl_ctrl", "flctl"),
Laurent Pinchartd39a1572013-04-19 13:29:48 +02001341 /* FSIA (AK4643) */
1342 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372",
1343 "fsia_sclk_in", "fsia"),
1344 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372",
1345 "fsia_data_in", "fsia"),
1346 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.0", "pfc-sh7372",
1347 "fsia_data_out", "fsia"),
1348 /* FSIB (HDMI) */
1349 PIN_MAP_MUX_GROUP_DEFAULT("asoc-simple-card.1", "pfc-sh7372",
1350 "fsib_mclk_in", "fsib"),
Laurent Pinchartcfced2c2013-04-19 13:29:48 +02001351 /* HDMI */
1352 PIN_MAP_MUX_GROUP_DEFAULT("sh-mobile-hdmi", "pfc-sh7372",
1353 "hdmi", "hdmi"),
Laurent Pinchart845a8022013-04-19 13:29:48 +02001354 /* LCDC */
1355 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh7372",
1356 "lcd_data24", "lcd"),
1357 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_lcdc_fb.0", "pfc-sh7372",
1358 "lcd_sync", "lcd"),
Laurent Pinchart0dcea782013-04-19 13:29:48 +02001359 /* SCIFA0 */
1360 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-sh7372",
1361 "scifa0_data", "scifa0"),
1362 /* SCIFA2 (GT-720F GPS module) */
1363 PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.2", "pfc-sh7372",
1364 "scifa2_data", "scifa2"),
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001365 /* SDHI0 */
1366 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1367 "sdhi0_data4", "sdhi0"),
1368 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1369 "sdhi0_ctrl", "sdhi0"),
1370 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1371 "sdhi0_wp", "sdhi0"),
Laurent Pinchart886c5352013-04-19 13:29:48 +02001372 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1373 "intc_irq26_1", "intc"),
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001374 /* SDHI1 */
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001375#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001376 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
1377 "sdhi1_data4", "sdhi1"),
1378 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
1379 "sdhi1_ctrl", "sdhi1"),
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001380#else
1381 /* MMCIF */
1382 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
1383 "mmc0_data8_0", "mmc0"),
1384 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
1385 "mmc0_ctrl_0", "mmc0"),
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001386#endif
1387 /* SDHI2 */
1388 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
1389 "sdhi2_data4", "sdhi2"),
1390 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
1391 "sdhi2_ctrl", "sdhi2"),
Laurent Pinchart98f2d362013-04-19 13:29:48 +02001392 /* SMSC911X */
1393 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-sh7372",
1394 "bsc_cs5a", "bsc"),
1395 PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-sh7372",
1396 "intc_irq6_0", "intc"),
Laurent Pincharta4bb4882013-04-19 13:29:48 +02001397 /* ST1232 */
1398 PIN_MAP_MUX_GROUP_DEFAULT("0-0055", "pfc-sh7372",
1399 "intc_irq7_0", "intc"),
Laurent Pinchart47f90282013-04-19 13:29:48 +02001400 /* TCA6416 */
1401 PIN_MAP_MUX_GROUP_DEFAULT("0-0020", "pfc-sh7372",
1402 "intc_irq9_0", "intc"),
Laurent Pinchartc1351902013-04-19 13:29:48 +02001403 /* USBHS0 */
1404 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.0", "pfc-sh7372",
1405 "usb0_vbus", "usb0"),
Laurent Pinchart3a8067f2013-11-28 16:17:58 +01001406 PIN_MAP_CONFIGS_GROUP_DEFAULT("renesas_usbhs.0", "pfc-sh7372",
1407 "usb0_vbus", pin_pulldown_conf),
Laurent Pinchartc1351902013-04-19 13:29:48 +02001408 /* USBHS1 */
1409 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372",
1410 "usb1_vbus", "usb1"),
Laurent Pinchartb58c8e72013-12-14 15:45:01 +01001411 PIN_MAP_CONFIGS_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372",
Laurent Pinchart3a8067f2013-11-28 16:17:58 +01001412 "usb1_vbus", pin_pulldown_conf),
Laurent Pinchartc1351902013-04-19 13:29:48 +02001413 PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs.1", "pfc-sh7372",
1414 "usb1_otg_id_0", "usb1"),
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001415};
1416
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +00001417#define GPIO_PORT9CR IOMEM(0xE6051009)
1418#define GPIO_PORT10CR IOMEM(0xE605100A)
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +00001419#define SRCR4 IOMEM(0xe61580bc)
1420#define USCCR1 IOMEM(0xE6058144)
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001421static void __init mackerel_init(void)
1422{
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001423 struct pm_domain_device domain_devices[] = {
1424 { "A4LC", &lcdc_device, },
1425 { "A4LC", &hdmi_lcdc_device, },
1426 { "A4LC", &meram_device, },
1427 { "A4MP", &fsi_device, },
1428 { "A3SP", &usbhs0_device, },
1429 { "A3SP", &usbhs1_device, },
1430 { "A3SP", &nand_flash_device, },
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001431 { "A3SP", &sdhi0_device, },
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001432#if !IS_ENABLED(CONFIG_MMC_SH_MMCIF)
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001433 { "A3SP", &sdhi1_device, },
Guennadi Liakhovetski00ae9622013-03-29 22:05:52 +01001434#else
1435 { "A3SP", &sh_mmcif_device, },
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001436#endif
1437 { "A3SP", &sdhi2_device, },
1438 { "A4R", &ceu_device, },
Rafael J. Wysockib42879e2012-08-08 00:29:16 +02001439 };
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001440 u32 srcr4;
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001441 struct clk *clk;
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001442
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +02001443 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
1444 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
1445 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
1446 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
1447 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
1448
Magnus Damm12bb16d2012-03-06 16:30:18 +09001449 /* External clock source */
1450 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1451
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001452 pinctrl_register_mappings(mackerel_pinctrl_map,
1453 ARRAY_SIZE(mackerel_pinctrl_map));
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001454 sh7372_pinmux_init();
1455
Laurent Pinchart6d170aa2013-02-16 07:38:50 +01001456 gpio_request_one(151, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001457
Laurent Pinchartd39a1572013-04-19 13:29:48 +02001458 /* FSI2 port A (ak4643) */
Laurent Pinchart6d170aa2013-02-16 07:38:50 +01001459 gpio_request_one(161, GPIOF_OUT_INIT_LOW, NULL); /* slave */
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001460
Laurent Pinchart6d170aa2013-02-16 07:38:50 +01001461 gpio_request(9, NULL);
1462 gpio_request(10, NULL);
Kuninori Morimotoc721e0c2012-06-25 03:41:36 -07001463 gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1464 gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001465
1466 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1467
Laurent Pinchartd39a1572013-04-19 13:29:48 +02001468 /* FSI2 port B (HDMI) */
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001469 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1470
1471 /* set SPU2 clock to 119.6 MHz */
1472 clk = clk_get(NULL, "spu_clk");
1473 if (!IS_ERR(clk)) {
1474 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1475 clk_put(clk);
1476 }
1477
Laurent Pinchart47f90282013-04-19 13:29:48 +02001478 /* Keypad */
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001479 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
Tony SIMcd8ab002010-12-09 01:55:55 +00001480
Laurent Pincharta4bb4882013-04-19 13:29:48 +02001481 /* Touchscreen */
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001482 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
Tony SIM6ae1e192011-01-11 09:47:59 +09001483
Laurent Pinchartcd87d902013-04-19 13:29:48 +02001484 /* Accelerometer */
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001485 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001486
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001487 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1488 srcr4 = __raw_readl(SRCR4);
1489 __raw_writel(srcr4 | (1 << 13), SRCR4);
1490 udelay(50);
1491 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1492
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001493 i2c_register_board_info(0, i2c0_devices,
1494 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc7c2010-12-07 09:12:14 +00001495 i2c_register_board_info(1, i2c1_devices,
1496 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001497
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001498 sh7372_add_standard_devices();
1499
1500 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001501
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001502 rmobile_add_devices_to_domains(domain_devices,
1503 ARRAY_SIZE(domain_devices));
Rafael J. Wysockie3e01092011-07-01 22:13:56 +02001504
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001505 hdmi_init_pm_clock();
Magnus Damm97991652011-04-29 02:28:08 +09001506 sh7372_pm_init();
Kuninori Morimotoa41b6462011-07-10 10:11:57 +02001507 pm_clk_add(&fsi_device.dev, "spu2");
Magnus Damm5c3f96b2011-08-24 22:38:43 +02001508 pm_clk_add(&hdmi_lcdc_device.dev, "hdmi");
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001509}
1510
Nobuhiro Iwamatsu0ce53cd2012-10-24 14:48:00 +09001511static const char *mackerel_boards_compat_dt[] __initdata = {
1512 "renesas,mackerel",
1513 NULL,
1514};
1515
1516DT_MACHINE_START(MACKEREL_DT, "mackerel")
Arnd Bergmann426f1af2012-03-22 22:02:16 +00001517 .map_io = sh7372_map_io,
Magnus Damm5d7220ec2012-02-29 21:37:19 +09001518 .init_early = sh7372_add_early_devices,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001519 .init_irq = sh7372_init_irq,
Magnus Damm863b1712010-12-28 08:27:01 +00001520 .handle_irq = shmobile_handle_irq_intc,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001521 .init_machine = mackerel_init,
Rafael J. Wysockicaaca992012-08-22 12:27:24 +02001522 .init_late = sh7372_pm_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -07001523 .init_time = sh7372_earlytimer_init,
Nobuhiro Iwamatsu0ce53cd2012-10-24 14:48:00 +09001524 .dt_compat = mackerel_boards_compat_dt,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001525MACHINE_END