blob: c4f80d4e40263ecae9ccf7d9ab17641dba0c09f4 [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>
Rafael J. Wysockib5e8d262011-08-25 15:34:19 +020044#include <linux/pm_clock.h>
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +020045#include <linux/regulator/fixed.h>
46#include <linux/regulator/machine.h>
Kuninori Morimoto2264c152010-11-29 02:21:37 +000047#include <linux/smsc911x.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000048#include <linux/sh_intc.h>
Tony SIMcd8ab002010-12-09 01:55:55 +000049#include <linux/tca6416_keypad.h>
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +000050#include <linux/usb/renesas_usbhs.h>
Jon Medhurst9b742022011-08-04 17:05:21 +010051#include <linux/dma-mapping.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000052
Kuninori Morimoto12c43092011-01-06 02:44:09 +000053#include <video/sh_mobile_hdmi.h>
Kuninori Morimoto11fee462010-11-29 02:21:43 +000054#include <video/sh_mobile_lcdc.h>
Magnus Dammae37c8d2010-12-22 14:47:40 +000055#include <media/sh_mobile_ceu.h>
56#include <media/soc_camera.h>
57#include <media/soc_camera_platform.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000058#include <sound/sh_fsi.h>
Kuninori Morimotoaf8a2fe2012-04-08 21:18:28 -070059#include <sound/simple_card.h>
Kuninori Morimoto1a44d722010-12-01 00:31:46 +000060
Kuninori Morimoto920adc72010-11-29 02:21:21 +000061#include <mach/common.h>
Rob Herring250a2722012-01-03 16:57:33 -060062#include <mach/irqs.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000063#include <mach/sh7372.h>
64
65#include <asm/mach/arch.h>
Kuninori Morimoto920adc72010-11-29 02:21:21 +000066#include <asm/mach-types.h>
67
Rob Herring66791852012-08-28 12:54:42 -050068#include "sh-gpio.h"
69
Kuninori Morimoto920adc72010-11-29 02:21:21 +000070/*
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 Morimoto4b82b682010-11-29 02:21:48 +000083/*
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 Damme2a53b72011-06-09 07:03:37 +0000135 * IRQ7 | ICR1A.IRQ7SA=0010 | LCD Touch Panel | Low
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000136 * 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 Morimoto25338f22010-11-30 04:37:33 +0000140 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000141
Kuninori Morimoto25338f22010-11-30 04:37:33 +0000142/*
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 Morimoto66ee3be2011-05-25 07:56:25 +0000153 * 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 Morimoto25338f22010-11-30 04:37:33 +0000164 */
Kuninori Morimoto4b82b682010-11-29 02:21:48 +0000165
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000166/*
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900167 * 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 Goda41491b92010-12-15 08:31:04 +0000178 * J22 : select power voltage *1
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900179 * 1-2 pin : 1.8v
180 * 2-3 pin : 3.3v
181 *
Yusuke Goda41491b92010-12-15 08:31:04 +0000182 * *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 Goda6dff7da2010-12-14 14:18:03 +0900186 * SW1 | SW33
187 * | bit1 | bit2 | bit3 | bit4
188 * -------------+------+------+------+-------
Simon Horman2150dac2011-01-07 22:26:15 +0000189 * MMC0 OFF | OFF | X | ON | X (Use MMCIF)
190 * SDHI1 OFF | ON | X | OFF | X (Use MFD_SH_MOBILE_SDHI)
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900191 *
192 */
193
194/*
195 * SDHI2 (CN23)
196 *
197 * microSD card sloct
198 *
199 */
200
201/*
Kuninori Morimoto6d9b7dd2012-01-18 16:37:07 -0800202 * FSI - AK4642
203 *
204 * it needs amixer settings for playing
205 *
Kuninori Morimotoffdfe2d2012-12-24 20:03:45 -0800206 * amixer set "Headphone Enable" on
Kuninori Morimoto6d9b7dd2012-01-18 16:37:07 -0800207 */
208
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200209/* Fixed 3.3V and 1.8V regulators to be used by multiple devices */
210static struct regulator_consumer_supply fixed1v8_power_consumers[] =
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000211{
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200212 /*
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 Morimoto1a44d722010-12-01 00:31:46 +0000221
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200222static struct regulator_consumer_supply fixed3v3_power_consumers[] =
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000223{
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200224 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 Morimoto66ee3be2011-05-25 07:56:25 +0000229
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +0200230/* Dummy supplies, where voltage doesn't matter */
231static struct regulator_consumer_supply dummy_supplies[] = {
232 REGULATOR_SUPPLY("vddvario", "smsc911x"),
233 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
234};
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000235
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000236/* MTD */
237static 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
268static 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
274static struct resource nor_flash_resources[] = {
275 [0] = {
Magnus Damm487881c2011-09-27 18:29:31 +0900276 .start = 0x20000000, /* CS0 shadow instead of regular CS0 */
277 .end = 0x28000000 - 1, /* needed by USB MASK ROM boot */
Kuninori Morimoto920adc72010-11-29 02:21:21 +0000278 .flags = IORESOURCE_MEM,
279 }
280};
281
282static 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 Morimoto2264c152010-11-29 02:21:37 +0000291/* SMSC */
292static 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
303static 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
309static 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
Damian1c7fcbe2011-05-24 07:01:22 +0000319/* MERAM */
320static struct sh_mobile_meram_info mackerel_meram_info = {
321 .addr_mode = SH_MOBILE_MERAM_MODE1,
322};
323
324static struct resource meram_resources[] = {
325 [0] = {
Laurent Pincharte71504d2011-09-11 23:30:45 +0200326 .name = "regs",
Damian1c7fcbe2011-05-24 07:01:22 +0000327 .start = 0xe8000000,
Laurent Pincharte71504d2011-09-11 23:30:45 +0200328 .end = 0xe807ffff,
329 .flags = IORESOURCE_MEM,
330 },
331 [1] = {
332 .name = "meram",
333 .start = 0xe8080000,
Damian1c7fcbe2011-05-24 07:01:22 +0000334 .end = 0xe81fffff,
335 .flags = IORESOURCE_MEM,
336 },
337};
338
339static 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
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000349/* LCDC */
350static 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 Pinchart018882a2011-09-11 22:59:04 +0200365static int mackerel_set_brightness(int brightness)
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000366{
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100367 gpio_set_value(31, brightness);
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000368
369 return 0;
370}
371
Laurent Pinchartc241a0e2011-09-11 23:30:45 +0200372static const struct sh_mobile_meram_cfg lcd_meram_cfg = {
Damian1c7fcbe2011-05-24 07:01:22 +0000373 .icb[0] = {
Damian1c7fcbe2011-05-24 07:01:22 +0000374 .meram_size = 0x40,
375 },
376 .icb[1] = {
Damian1c7fcbe2011-05-24 07:01:22 +0000377 .meram_size = 0x40,
378 },
379};
380
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000381static struct sh_mobile_lcdc_info lcdc_info = {
Damian1c7fcbe2011-05-24 07:01:22 +0000382 .meram_dev = &mackerel_meram_info,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000383 .clock_source = LCDC_CLK_BUS,
384 .ch[0] = {
385 .chan = LCDC_CHAN_MAINLCD,
Laurent Pinchartedd153a2011-12-13 14:02:28 +0100386 .fourcc = V4L2_PIX_FMT_RGB565,
Laurent Pinchart93ff2592011-11-29 14:33:41 +0100387 .lcd_modes = mackerel_lcdc_modes,
388 .num_modes = ARRAY_SIZE(mackerel_lcdc_modes),
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000389 .interface_type = RGB24,
Kuninori Morimoto2c34e932011-03-02 09:05:21 +0000390 .clock_divider = 3,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000391 .flags = 0,
Laurent Pinchartafaad832011-09-11 22:59:04 +0200392 .panel_cfg = {
393 .width = 152,
394 .height = 91,
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000395 },
396 .bl_info = {
397 .name = "sh_mobile_lcdc_bl",
398 .max_brightness = 1,
Laurent Pinchart43059b02011-09-11 22:59:04 +0200399 .set_brightness = mackerel_set_brightness,
Magnus Damm1fbdfcd2011-03-21 07:49:45 +0000400 },
Damian1c7fcbe2011-05-24 07:01:22 +0000401 .meram_cfg = &lcd_meram_cfg,
Kuninori Morimoto11fee462010-11-29 02:21:43 +0000402 }
403};
404
405static struct resource lcdc_resources[] = {
406 [0] = {
407 .name = "LCDC",
408 .start = 0xfe940000,
409 .end = 0xfe943fff,
410 .flags = IORESOURCE_MEM,
411 },
412 [1] = {
413 .start = intcs_evt2irq(0x580),
414 .flags = IORESOURCE_IRQ,
415 },
416};
417
418static struct platform_device lcdc_device = {
419 .name = "sh_mobile_lcdc_fb",
420 .num_resources = ARRAY_SIZE(lcdc_resources),
421 .resource = lcdc_resources,
422 .dev = {
423 .platform_data = &lcdc_info,
424 .coherent_dma_mask = ~0,
425 },
426};
427
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000428/* HDMI */
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000429static struct sh_mobile_hdmi_info hdmi_info = {
Kuninori Morimoto98d27b82011-01-06 02:44:15 +0000430 .flags = HDMI_SND_SRC_SPDIF,
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000431};
432
433static struct resource hdmi_resources[] = {
434 [0] = {
435 .name = "HDMI",
436 .start = 0xe6be0000,
437 .end = 0xe6be00ff,
438 .flags = IORESOURCE_MEM,
439 },
440 [1] = {
441 /* There's also an HDMI interrupt on INTCS @ 0x18e0 */
442 .start = evt2irq(0x17e0),
443 .flags = IORESOURCE_IRQ,
444 },
445};
446
447static struct platform_device hdmi_device = {
448 .name = "sh-mobile-hdmi",
449 .num_resources = ARRAY_SIZE(hdmi_resources),
450 .resource = hdmi_resources,
451 .id = -1,
452 .dev = {
453 .platform_data = &hdmi_info,
454 },
455};
456
Laurent Pinchartc241a0e2011-09-11 23:30:45 +0200457static const struct sh_mobile_meram_cfg hdmi_meram_cfg = {
Laurent Pincharta1022ad2011-09-11 23:30:45 +0200458 .icb[0] = {
Laurent Pincharta1022ad2011-09-11 23:30:45 +0200459 .meram_size = 0x100,
460 },
461 .icb[1] = {
Laurent Pincharta1022ad2011-09-11 23:30:45 +0200462 .meram_size = 0x100,
463 },
464};
465
466static struct sh_mobile_lcdc_info hdmi_lcdc_info = {
467 .meram_dev = &mackerel_meram_info,
468 .clock_source = LCDC_CLK_EXTERNAL,
469 .ch[0] = {
470 .chan = LCDC_CHAN_MAINLCD,
471 .fourcc = V4L2_PIX_FMT_RGB565,
472 .interface_type = RGB24,
473 .clock_divider = 1,
474 .flags = LCDC_FLAGS_DWPOL,
475 .meram_cfg = &hdmi_meram_cfg,
476 .tx_dev = &hdmi_device,
477 }
478};
479
480static struct resource hdmi_lcdc_resources[] = {
481 [0] = {
482 .name = "LCDC1",
483 .start = 0xfe944000,
484 .end = 0xfe947fff,
485 .flags = IORESOURCE_MEM,
486 },
487 [1] = {
488 .start = intcs_evt2irq(0x1780),
489 .flags = IORESOURCE_IRQ,
490 },
491};
492
493static struct platform_device hdmi_lcdc_device = {
494 .name = "sh_mobile_lcdc_fb",
495 .num_resources = ARRAY_SIZE(hdmi_lcdc_resources),
496 .resource = hdmi_lcdc_resources,
497 .id = 1,
498 .dev = {
499 .platform_data = &hdmi_lcdc_info,
500 .coherent_dma_mask = ~0,
501 },
502};
503
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700504static struct asoc_simple_card_info fsi2_hdmi_info = {
505 .name = "HDMI",
506 .card = "FSI2B-HDMI",
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700507 .codec = "sh-mobile-hdmi",
508 .platform = "sh_fsi2",
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800509 .cpu_dai = {
510 .name = "fsib-dai",
511 .fmt = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF,
512 },
513 .codec_dai = {
514 .name = "sh_mobile_hdmi-hifi",
515 },
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700516};
517
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900518static struct platform_device fsi_hdmi_device = {
Kuninori Morimotofa063b42012-04-08 21:18:58 -0700519 .name = "asoc-simple-card",
520 .id = 1,
521 .dev = {
522 .platform_data = &fsi2_hdmi_info,
523 },
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +0900524};
525
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200526static void __init hdmi_init_pm_clock(void)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000527{
528 struct clk *hdmi_ick = clk_get(&hdmi_device.dev, "ick");
529 int ret;
530 long rate;
531
532 if (IS_ERR(hdmi_ick)) {
533 ret = PTR_ERR(hdmi_ick);
534 pr_err("Cannot get HDMI ICK: %d\n", ret);
535 goto out;
536 }
537
538 ret = clk_set_parent(&sh7372_pllc2_clk, &sh7372_dv_clki_div2_clk);
539 if (ret < 0) {
540 pr_err("Cannot set PLLC2 parent: %d, %d users\n",
541 ret, sh7372_pllc2_clk.usecount);
542 goto out;
543 }
544
545 pr_debug("PLLC2 initial frequency %lu\n",
546 clk_get_rate(&sh7372_pllc2_clk));
547
548 rate = clk_round_rate(&sh7372_pllc2_clk, 594000000);
549 if (rate < 0) {
550 pr_err("Cannot get suitable rate: %ld\n", rate);
551 ret = rate;
552 goto out;
553 }
554
555 ret = clk_set_rate(&sh7372_pllc2_clk, rate);
556 if (ret < 0) {
557 pr_err("Cannot set rate %ld: %d\n", rate, ret);
558 goto out;
559 }
560
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000561 pr_debug("PLLC2 set frequency %lu\n", rate);
562
563 ret = clk_set_parent(hdmi_ick, &sh7372_pllc2_clk);
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +0200564 if (ret < 0)
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000565 pr_err("Cannot set HDMI parent: %d\n", ret);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000566
567out:
568 if (!IS_ERR(hdmi_ick))
569 clk_put(hdmi_ick);
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000570}
Kuninori Morimoto12c43092011-01-06 02:44:09 +0000571
Magnus Damme2a53b72011-06-09 07:03:37 +0000572/* USBHS0 is connected to CN22 which takes a USB Mini-B plug
573 *
574 * The sh7372 SoC has IRQ7 set aside for USBHS0 hotplug,
575 * but on this particular board IRQ7 is already used by
576 * the touch screen. This leaves us with software polling.
577 */
578#define USBHS0_POLL_INTERVAL (HZ * 5)
579
580struct usbhs_private {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000581 void __iomem *usbphyaddr;
582 void __iomem *usbcrcaddr;
Magnus Damme2a53b72011-06-09 07:03:37 +0000583 struct renesas_usbhs_platform_info info;
584 struct delayed_work work;
585 struct platform_device *pdev;
586};
587
588#define usbhs_get_priv(pdev) \
589 container_of(renesas_usbhs_get_info(pdev), \
590 struct usbhs_private, info)
591
592#define usbhs_is_connected(priv) \
593 (!((1 << 7) & __raw_readw(priv->usbcrcaddr)))
594
595static int usbhs_get_vbus(struct platform_device *pdev)
596{
597 return usbhs_is_connected(usbhs_get_priv(pdev));
598}
599
600static void usbhs_phy_reset(struct platform_device *pdev)
601{
602 struct usbhs_private *priv = usbhs_get_priv(pdev);
603
604 /* init phy */
605 __raw_writew(0x8a0a, priv->usbcrcaddr);
606}
607
608static int usbhs0_get_id(struct platform_device *pdev)
609{
610 return USBHS_GADGET;
611}
612
613static void usbhs0_work_function(struct work_struct *work)
614{
615 struct usbhs_private *priv = container_of(work, struct usbhs_private,
616 work.work);
617
618 renesas_usbhs_call_notify_hotplug(priv->pdev);
619 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
620}
621
622static int usbhs0_hardware_init(struct platform_device *pdev)
623{
624 struct usbhs_private *priv = usbhs_get_priv(pdev);
625
626 priv->pdev = pdev;
627 INIT_DELAYED_WORK(&priv->work, usbhs0_work_function);
628 schedule_delayed_work(&priv->work, USBHS0_POLL_INTERVAL);
629 return 0;
630}
631
632static void usbhs0_hardware_exit(struct platform_device *pdev)
633{
634 struct usbhs_private *priv = usbhs_get_priv(pdev);
635
636 cancel_delayed_work_sync(&priv->work);
637}
638
Magnus Damme2a53b72011-06-09 07:03:37 +0000639static struct usbhs_private usbhs0_private = {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000640 .usbcrcaddr = IOMEM(0xe605810c), /* USBCR2 */
Magnus Damme2a53b72011-06-09 07:03:37 +0000641 .info = {
642 .platform_callback = {
643 .hardware_init = usbhs0_hardware_init,
644 .hardware_exit = usbhs0_hardware_exit,
645 .phy_reset = usbhs_phy_reset,
646 .get_id = usbhs0_get_id,
647 .get_vbus = usbhs_get_vbus,
648 },
649 .driver_param = {
650 .buswait_bwait = 4,
Kuninori Morimotofe437562011-06-17 08:21:21 +0000651 .d0_tx_id = SHDMA_SLAVE_USB0_TX,
652 .d1_rx_id = SHDMA_SLAVE_USB0_RX,
Magnus Damme2a53b72011-06-09 07:03:37 +0000653 },
654 },
655};
656
657static struct resource usbhs0_resources[] = {
658 [0] = {
659 .name = "USBHS0",
660 .start = 0xe6890000,
661 .end = 0xe68900e6 - 1,
662 .flags = IORESOURCE_MEM,
663 },
664 [1] = {
665 .start = evt2irq(0x1ca0) /* USB0_USB0I0 */,
666 .flags = IORESOURCE_IRQ,
667 },
668};
669
670static struct platform_device usbhs0_device = {
671 .name = "renesas_usbhs",
672 .id = 0,
673 .dev = {
674 .platform_data = &usbhs0_private.info,
675 },
676 .num_resources = ARRAY_SIZE(usbhs0_resources),
677 .resource = usbhs0_resources,
678};
679
680/* USBHS1 is connected to CN31 which takes a USB Mini-AB plug
681 *
682 * Use J30 to select between Host and Function. This setting
683 * can however not be detected by software. Hotplug of USBHS1
684 * is provided via IRQ8.
Kuninori Morimoto0ada2da52012-01-18 17:32:05 -0800685 *
686 * Current USB1 works as "USB Host".
687 * - set J30 "short"
688 *
689 * If you want to use it as "USB gadget",
690 * - J30 "open"
691 * - modify usbhs1_get_id() USBHS_HOST -> USBHS_GADGET
692 * - add .get_vbus = usbhs_get_vbus in usbhs1_private
Kuninori Morimotoe26a6032012-08-05 22:47:00 -0700693 * - check usbhs0_device(pio)/usbhs1_device(irq) order in mackerel_devices.
Magnus Damme2a53b72011-06-09 07:03:37 +0000694 */
695#define IRQ8 evt2irq(0x0300)
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000696#define USB_PHY_MODE (1 << 4)
697#define USB_PHY_INT_EN ((1 << 3) | (1 << 2))
698#define USB_PHY_ON (1 << 1)
699#define USB_PHY_OFF (1 << 0)
700#define USB_PHY_INT_CLR (USB_PHY_ON | USB_PHY_OFF)
701
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000702static irqreturn_t usbhs1_interrupt(int irq, void *data)
703{
704 struct platform_device *pdev = data;
705 struct usbhs_private *priv = usbhs_get_priv(pdev);
706
707 dev_dbg(&pdev->dev, "%s\n", __func__);
708
709 renesas_usbhs_call_notify_hotplug(pdev);
710
711 /* clear status */
712 __raw_writew(__raw_readw(priv->usbphyaddr) | USB_PHY_INT_CLR,
713 priv->usbphyaddr);
714
715 return IRQ_HANDLED;
716}
717
718static int usbhs1_hardware_init(struct platform_device *pdev)
719{
720 struct usbhs_private *priv = usbhs_get_priv(pdev);
721 int ret;
722
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000723 /* clear interrupt status */
724 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
725
Magnus Damme2a53b72011-06-09 07:03:37 +0000726 ret = request_irq(IRQ8, usbhs1_interrupt, IRQF_TRIGGER_HIGH,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000727 dev_name(&pdev->dev), pdev);
728 if (ret) {
729 dev_err(&pdev->dev, "request_irq err\n");
730 return ret;
731 }
732
733 /* enable USB phy interrupt */
734 __raw_writew(USB_PHY_MODE | USB_PHY_INT_EN, priv->usbphyaddr);
735
736 return 0;
737}
738
739static void usbhs1_hardware_exit(struct platform_device *pdev)
740{
741 struct usbhs_private *priv = usbhs_get_priv(pdev);
742
743 /* clear interrupt status */
744 __raw_writew(USB_PHY_MODE | USB_PHY_INT_CLR, priv->usbphyaddr);
745
Magnus Damme2a53b72011-06-09 07:03:37 +0000746 free_irq(IRQ8, pdev);
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000747}
748
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000749static int usbhs1_get_id(struct platform_device *pdev)
750{
Kuninori Morimoto0ada2da52012-01-18 17:32:05 -0800751 return USBHS_HOST;
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000752}
753
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000754static u32 usbhs1_pipe_cfg[] = {
755 USB_ENDPOINT_XFER_CONTROL,
756 USB_ENDPOINT_XFER_ISOC,
757 USB_ENDPOINT_XFER_ISOC,
758 USB_ENDPOINT_XFER_BULK,
759 USB_ENDPOINT_XFER_BULK,
760 USB_ENDPOINT_XFER_BULK,
761 USB_ENDPOINT_XFER_INT,
762 USB_ENDPOINT_XFER_INT,
763 USB_ENDPOINT_XFER_INT,
764 USB_ENDPOINT_XFER_BULK,
765 USB_ENDPOINT_XFER_BULK,
766 USB_ENDPOINT_XFER_BULK,
767 USB_ENDPOINT_XFER_BULK,
768 USB_ENDPOINT_XFER_BULK,
769 USB_ENDPOINT_XFER_BULK,
770 USB_ENDPOINT_XFER_BULK,
771};
772
773static struct usbhs_private usbhs1_private = {
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +0000774 .usbphyaddr = IOMEM(0xe60581e2), /* USBPHY1INTAP */
775 .usbcrcaddr = IOMEM(0xe6058130), /* USBCR4 */
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000776 .info = {
777 .platform_callback = {
778 .hardware_init = usbhs1_hardware_init,
779 .hardware_exit = usbhs1_hardware_exit,
Kuninori Morimoto05a79292011-06-15 06:16:35 +0000780 .get_id = usbhs1_get_id,
Magnus Damme2a53b72011-06-09 07:03:37 +0000781 .phy_reset = usbhs_phy_reset,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000782 },
783 .driver_param = {
784 .buswait_bwait = 4,
Kuninori Morimotof427eb62011-10-10 22:06:12 -0700785 .has_otg = 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000786 .pipe_type = usbhs1_pipe_cfg,
787 .pipe_size = ARRAY_SIZE(usbhs1_pipe_cfg),
Kuninori Morimotofe437562011-06-17 08:21:21 +0000788 .d0_tx_id = SHDMA_SLAVE_USB1_TX,
789 .d1_rx_id = SHDMA_SLAVE_USB1_RX,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000790 },
791 },
792};
793
794static struct resource usbhs1_resources[] = {
795 [0] = {
Magnus Damme2a53b72011-06-09 07:03:37 +0000796 .name = "USBHS1",
797 .start = 0xe68b0000,
798 .end = 0xe68b00e6 - 1,
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000799 .flags = IORESOURCE_MEM,
800 },
801 [1] = {
802 .start = evt2irq(0x1ce0) /* USB1_USB1I0 */,
803 .flags = IORESOURCE_IRQ,
804 },
805};
806
807static struct platform_device usbhs1_device = {
808 .name = "renesas_usbhs",
809 .id = 1,
810 .dev = {
811 .platform_data = &usbhs1_private.info,
Kuninori Morimotoc8c32432012-11-07 19:09:01 -0800812 .dma_mask = &usbhs1_device.dev.coherent_dma_mask,
813 .coherent_dma_mask = DMA_BIT_MASK(32),
Kuninori Morimoto66ee3be2011-05-25 07:56:25 +0000814 },
815 .num_resources = ARRAY_SIZE(usbhs1_resources),
816 .resource = usbhs1_resources,
817};
818
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000819/* LED */
820static struct gpio_led mackerel_leds[] = {
821 {
822 .name = "led0",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100823 .gpio = 0,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000824 .default_state = LEDS_GPIO_DEFSTATE_ON,
825 },
826 {
827 .name = "led1",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100828 .gpio = 1,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000829 .default_state = LEDS_GPIO_DEFSTATE_ON,
830 },
831 {
832 .name = "led2",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100833 .gpio = 2,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000834 .default_state = LEDS_GPIO_DEFSTATE_ON,
835 },
836 {
837 .name = "led3",
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100838 .gpio = 159,
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000839 .default_state = LEDS_GPIO_DEFSTATE_ON,
840 }
841};
842
843static struct gpio_led_platform_data mackerel_leds_pdata = {
844 .leds = mackerel_leds,
845 .num_leds = ARRAY_SIZE(mackerel_leds),
846};
847
848static struct platform_device leds_device = {
849 .name = "leds-gpio",
850 .id = 0,
851 .dev = {
852 .platform_data = &mackerel_leds_pdata,
853 },
854};
855
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000856/* FSI */
857#define IRQ_FSI evt2irq(0x1840)
858static struct sh_fsi_platform_info fsi_info = {
Kuninori Morimotofec691e2012-02-03 00:58:48 -0800859 .port_a = {
Kuninori Morimotoc650a1f2012-04-01 18:40:14 -0700860 .tx_id = SHDMA_SLAVE_FSIA_TX,
861 .rx_id = SHDMA_SLAVE_FSIA_RX,
Kuninori Morimotofec691e2012-02-03 00:58:48 -0800862 },
863 .port_b = {
Kuninori Morimotoabca7582012-12-16 22:12:42 -0800864 .flags = SH_FSI_CLK_CPG |
865 SH_FSI_FMT_SPDIF,
Kuninori Morimotofec691e2012-02-03 00:58:48 -0800866 }
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000867};
868
869static struct resource fsi_resources[] = {
870 [0] = {
Kuninori Morimotoc650a1f2012-04-01 18:40:14 -0700871 /* we need 0xFE1F0000 to access DMA
872 * instead of 0xFE3C0000 */
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000873 .name = "FSI",
Kuninori Morimotoc650a1f2012-04-01 18:40:14 -0700874 .start = 0xFE1F0000,
875 .end = 0xFE1F0400 - 1,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000876 .flags = IORESOURCE_MEM,
877 },
878 [1] = {
879 .start = IRQ_FSI,
880 .flags = IORESOURCE_IRQ,
881 },
882};
883
884static struct platform_device fsi_device = {
885 .name = "sh_fsi2",
886 .id = -1,
887 .num_resources = ARRAY_SIZE(fsi_resources),
888 .resource = fsi_resources,
889 .dev = {
890 .platform_data = &fsi_info,
891 },
892};
893
Kuninori Morimotoaf8a2fe2012-04-08 21:18:28 -0700894static struct asoc_simple_card_info fsi2_ak4643_info = {
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800895 .name = "AK4643",
896 .card = "FSI2A-AK4643",
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800897 .codec = "ak4642-codec.0-0013",
898 .platform = "sh_fsi2",
Kuninori Morimotoa4a29922013-01-10 16:49:11 -0800899 .daifmt = SND_SOC_DAIFMT_LEFT_J,
900 .cpu_dai = {
901 .name = "fsia-dai",
902 .fmt = SND_SOC_DAIFMT_CBS_CFS,
903 },
904 .codec_dai = {
905 .name = "ak4642-hifi",
906 .fmt = SND_SOC_DAIFMT_CBM_CFM,
907 .sysclk = 11289600,
908 },
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800909};
910
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000911static struct platform_device fsi_ak4643_device = {
Kuninori Morimotoaf8a2fe2012-04-08 21:18:28 -0700912 .name = "asoc-simple-card",
Kuninori Morimoto45f31212011-11-23 16:55:34 -0800913 .dev = {
914 .platform_data = &fsi2_ak4643_info,
915 },
Kuninori Morimoto1a44d722010-12-01 00:31:46 +0000916};
Kuninori Morimotod44deb32010-11-30 06:52:18 +0000917
Bastian Hecht2aab52e2012-03-01 10:48:41 +0100918/* FLCTL */
919static struct mtd_partition nand_partition_info[] = {
920 {
921 .name = "system",
922 .offset = 0,
923 .size = 128 * 1024 * 1024,
924 },
925 {
926 .name = "userdata",
927 .offset = MTDPART_OFS_APPEND,
928 .size = 256 * 1024 * 1024,
929 },
930 {
931 .name = "cache",
932 .offset = MTDPART_OFS_APPEND,
933 .size = 128 * 1024 * 1024,
934 },
935};
936
937static struct resource nand_flash_resources[] = {
938 [0] = {
939 .start = 0xe6a30000,
940 .end = 0xe6a3009b,
941 .flags = IORESOURCE_MEM,
Bastian Hecht3042ac52012-11-20 01:05:00 +0100942 },
943 [1] = {
944 .start = evt2irq(0x0d80), /* flstei: status error irq */
945 .flags = IORESOURCE_IRQ,
946 },
Bastian Hecht2aab52e2012-03-01 10:48:41 +0100947};
948
949static struct sh_flctl_platform_data nand_flash_data = {
950 .parts = nand_partition_info,
951 .nr_parts = ARRAY_SIZE(nand_partition_info),
952 .flcmncr_val = CLK_16B_12L_4H | TYPESEL_SET
953 | SHBUSSEL | SEL_16BIT | SNAND_E,
954 .use_holden = 1,
955};
956
957static struct platform_device nand_flash_device = {
958 .name = "sh_flctl",
959 .resource = nand_flash_resources,
960 .num_resources = ARRAY_SIZE(nand_flash_resources),
961 .dev = {
962 .platform_data = &nand_flash_data,
963 },
964};
965
Simon Hormanac22dde2013-03-21 20:18:12 +0900966/*
967 * The card detect pin of the top SD/MMC slot (CN7) is active low and is
968 * connected to GPIO A22 of SH7372 (GPIO 41).
969 */
970static int slot_cn7_get_cd(struct platform_device *pdev)
971{
972 return !gpio_get_value(41);
973}
974
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900975/* SDHI0 */
976static struct sh_mobile_sdhi_info sdhi0_info = {
977 .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX,
978 .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX,
Guennadi Liakhovetski2b3e38c2012-04-16 23:09:13 +0200979 .tmio_flags = TMIO_MMC_USE_GPIO_CD,
Magnus Dammda97da72011-01-06 10:55:41 +0000980 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
Laurent Pinchart6d170aa2013-02-16 07:38:50 +0100981 .cd_gpio = 172,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900982};
983
984static struct resource sdhi0_resources[] = {
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +0100985 {
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900986 .name = "SDHI0",
987 .start = 0xe6850000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +0100988 .end = 0xe68500ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900989 .flags = IORESOURCE_MEM,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +0100990 }, {
Simon Horman2007aea2011-04-27 07:43:58 +0000991 .start = evt2irq(0x0e00) /* SDHI0_SDHI0I0 */,
992 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +0100993 }, {
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 }, {
Simon Horman2007aea2011-04-27 07:43:58 +0000997 .start = evt2irq(0x0e40) /* SDHI0_SDHI0I2 */,
Yusuke Goda6dff7da2010-12-14 14:18:03 +0900998 .flags = IORESOURCE_IRQ,
999 },
1000};
1001
1002static struct platform_device sdhi0_device = {
1003 .name = "sh_mobile_sdhi",
1004 .num_resources = ARRAY_SIZE(sdhi0_resources),
1005 .resource = sdhi0_resources,
1006 .id = 0,
1007 .dev = {
1008 .platform_data = &sdhi0_info,
1009 },
1010};
1011
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001012#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001013/* SDHI1 */
1014static struct sh_mobile_sdhi_info sdhi1_info = {
1015 .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX,
1016 .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX,
Simon Hormanac22dde2013-03-21 20:18:12 +09001017 .tmio_ocr_mask = MMC_VDD_165_195,
1018 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +00001019 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001020 MMC_CAP_NEEDS_POLL,
Simon Hormanac22dde2013-03-21 20:18:12 +09001021 .get_cd = slot_cn7_get_cd,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001022};
1023
1024static struct resource sdhi1_resources[] = {
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001025 {
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001026 .name = "SDHI1",
1027 .start = 0xe6860000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001028 .end = 0xe68600ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001029 .flags = IORESOURCE_MEM,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001030 }, {
Simon Hormanac22dde2013-03-21 20:18:12 +09001031 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
1032 .start = evt2irq(0x0e80), /* SDHI1_SDHI1I0 */
1033 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001034 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001035 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001036 .start = evt2irq(0x0ea0), /* SDHI1_SDHI1I1 */
1037 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001038 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001039 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001040 .start = evt2irq(0x0ec0), /* SDHI1_SDHI1I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001041 .flags = IORESOURCE_IRQ,
1042 },
1043};
1044
1045static struct platform_device sdhi1_device = {
1046 .name = "sh_mobile_sdhi",
1047 .num_resources = ARRAY_SIZE(sdhi1_resources),
1048 .resource = sdhi1_resources,
1049 .id = 1,
1050 .dev = {
1051 .platform_data = &sdhi1_info,
1052 },
1053};
Yusuke Goda41491b92010-12-15 08:31:04 +00001054#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001055
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
Simon Hormanac22dde2013-03-21 20:18:12 +09001058 * connected to GPIO SCIFB_SCK of SH7372 (162).
Yusuke Godada5d1f42011-01-07 09:48:36 +00001059 */
Simon Hormanac22dde2013-03-21 20:18:12 +09001060static int slot_cn23_get_cd(struct platform_device *pdev)
1061{
1062 return !gpio_get_value(162);
1063}
1064
1065/* SDHI2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001066static struct sh_mobile_sdhi_info sdhi2_info = {
1067 .dma_slave_tx = SHDMA_SLAVE_SDHI2_TX,
1068 .dma_slave_rx = SHDMA_SLAVE_SDHI2_RX,
Simon Hormanac22dde2013-03-21 20:18:12 +09001069 .tmio_flags = TMIO_MMC_WRPROTECT_DISABLE,
Magnus Dammda97da72011-01-06 10:55:41 +00001070 .tmio_caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001071 MMC_CAP_NEEDS_POLL,
Simon Hormanac22dde2013-03-21 20:18:12 +09001072 .get_cd = slot_cn23_get_cd,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001073};
1074
1075static struct resource sdhi2_resources[] = {
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001076 {
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001077 .name = "SDHI2",
1078 .start = 0xe6870000,
Guennadi Liakhovetski31d31fe72011-03-09 13:09:27 +01001079 .end = 0xe68700ff,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001080 .flags = IORESOURCE_MEM,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001081 }, {
Simon Hormanac22dde2013-03-21 20:18:12 +09001082 .name = SH_MOBILE_SDHI_IRQ_CARD_DETECT,
1083 .start = evt2irq(0x1200), /* SDHI2_SDHI2I0 */
1084 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001085 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001086 .name = SH_MOBILE_SDHI_IRQ_SDCARD,
Simon Horman2007aea2011-04-27 07:43:58 +00001087 .start = evt2irq(0x1220), /* SDHI2_SDHI2I1 */
1088 .flags = IORESOURCE_IRQ,
Guennadi Liakhovetskifb7a89c2013-03-29 22:05:48 +01001089 }, {
Simon Hormancb2ccc32011-08-25 10:27:28 +09001090 .name = SH_MOBILE_SDHI_IRQ_SDIO,
Simon Horman2007aea2011-04-27 07:43:58 +00001091 .start = evt2irq(0x1240), /* SDHI2_SDHI2I2 */
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001092 .flags = IORESOURCE_IRQ,
1093 },
1094};
1095
1096static struct platform_device sdhi2_device = {
1097 .name = "sh_mobile_sdhi",
1098 .num_resources = ARRAY_SIZE(sdhi2_resources),
1099 .resource = sdhi2_resources,
1100 .id = 2,
1101 .dev = {
1102 .platform_data = &sdhi2_info,
1103 },
1104};
1105
Yusuke Goda41491b92010-12-15 08:31:04 +00001106/* SH_MMCIF */
1107static struct resource sh_mmcif_resources[] = {
1108 [0] = {
1109 .name = "MMCIF",
1110 .start = 0xE6BD0000,
1111 .end = 0xE6BD00FF,
1112 .flags = IORESOURCE_MEM,
1113 },
1114 [1] = {
1115 /* MMC ERR */
1116 .start = evt2irq(0x1ac0),
1117 .flags = IORESOURCE_IRQ,
1118 },
1119 [2] = {
1120 /* MMC NOR */
1121 .start = evt2irq(0x1ae0),
1122 .flags = IORESOURCE_IRQ,
1123 },
1124};
1125
1126static struct sh_mmcif_plat_data sh_mmcif_plat = {
1127 .sup_pclk = 0,
Simon Hormanac22dde2013-03-21 20:18:12 +09001128 .ocr = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34,
Yusuke Goda41491b92010-12-15 08:31:04 +00001129 .caps = MMC_CAP_4_BIT_DATA |
1130 MMC_CAP_8_BIT_DATA |
1131 MMC_CAP_NEEDS_POLL,
Simon Hormanac22dde2013-03-21 20:18:12 +09001132 .get_cd = slot_cn7_get_cd,
Guennadi Liakhovetskid5bb3862011-08-30 18:26:44 +02001133 .slave_id_tx = SHDMA_SLAVE_MMCIF_TX,
1134 .slave_id_rx = SHDMA_SLAVE_MMCIF_RX,
Yusuke Goda41491b92010-12-15 08:31:04 +00001135};
1136
Arnd Bergmannb3425eb2013-02-14 23:26:54 +01001137static struct platform_device sh_mmcif_device __maybe_unused = {
Yusuke Goda41491b92010-12-15 08:31:04 +00001138 .name = "sh_mmcif",
1139 .id = 0,
1140 .dev = {
1141 .dma_mask = NULL,
1142 .coherent_dma_mask = 0xffffffff,
1143 .platform_data = &sh_mmcif_plat,
1144 },
1145 .num_resources = ARRAY_SIZE(sh_mmcif_resources),
1146 .resource = sh_mmcif_resources,
1147};
1148
Magnus Dammae37c8d2010-12-22 14:47:40 +00001149
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001150static int mackerel_camera_add(struct soc_camera_device *icd);
1151static void mackerel_camera_del(struct soc_camera_device *icd);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001152
1153static int camera_set_capture(struct soc_camera_platform_info *info,
1154 int enable)
1155{
1156 return 0; /* camera sensor always enabled */
1157}
1158
1159static struct soc_camera_platform_info camera_info = {
1160 .format_name = "UYVY",
1161 .format_depth = 16,
1162 .format = {
1163 .code = V4L2_MBUS_FMT_UYVY8_2X8,
1164 .colorspace = V4L2_COLORSPACE_SMPTE170M,
1165 .field = V4L2_FIELD_NONE,
1166 .width = 640,
1167 .height = 480,
1168 },
Guennadi Liakhovetskid1e87ed2011-07-27 10:48:40 -03001169 .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER |
1170 V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH |
1171 V4L2_MBUS_DATA_ACTIVE_HIGH,
1172 .mbus_type = V4L2_MBUS_PARALLEL,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001173 .set_capture = camera_set_capture,
1174};
1175
1176static struct soc_camera_link camera_link = {
1177 .bus_id = 0,
1178 .add_device = mackerel_camera_add,
1179 .del_device = mackerel_camera_del,
1180 .module_name = "soc_camera_platform",
1181 .priv = &camera_info,
1182};
1183
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001184static struct platform_device *camera_device;
Magnus Dammae37c8d2010-12-22 14:47:40 +00001185
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001186static void mackerel_camera_release(struct device *dev)
1187{
1188 soc_camera_platform_release(&camera_device);
1189}
Magnus Dammae37c8d2010-12-22 14:47:40 +00001190
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001191static int mackerel_camera_add(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001192{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001193 return soc_camera_platform_add(icd, &camera_device, &camera_link,
Guennadi Liakhovetski86a73142011-02-22 09:57:49 +00001194 mackerel_camera_release, 0);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001195}
1196
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001197static void mackerel_camera_del(struct soc_camera_device *icd)
Magnus Dammae37c8d2010-12-22 14:47:40 +00001198{
Guennadi Liakhovetski7dfff952011-07-15 20:03:38 -03001199 soc_camera_platform_del(icd, camera_device, &camera_link);
Magnus Dammae37c8d2010-12-22 14:47:40 +00001200}
1201
1202static struct sh_mobile_ceu_info sh_mobile_ceu_info = {
1203 .flags = SH_CEU_FLAG_USE_8BIT_BUS,
Guennadi Liakhovetskief8f41f2012-04-16 23:09:04 +02001204 .max_width = 8188,
1205 .max_height = 8188,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001206};
1207
1208static struct resource ceu_resources[] = {
1209 [0] = {
1210 .name = "CEU",
1211 .start = 0xfe910000,
1212 .end = 0xfe91009f,
1213 .flags = IORESOURCE_MEM,
1214 },
1215 [1] = {
1216 .start = intcs_evt2irq(0x880),
1217 .flags = IORESOURCE_IRQ,
1218 },
1219 [2] = {
1220 /* place holder for contiguous memory */
1221 },
1222};
1223
1224static struct platform_device ceu_device = {
1225 .name = "sh_mobile_ceu",
1226 .id = 0, /* "ceu0" clock */
1227 .num_resources = ARRAY_SIZE(ceu_resources),
1228 .resource = ceu_resources,
1229 .dev = {
Guennadi Liakhovetski05a5f012011-03-23 09:29:16 +00001230 .platform_data = &sh_mobile_ceu_info,
1231 .coherent_dma_mask = 0xffffffff,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001232 },
1233};
1234
1235static struct platform_device mackerel_camera = {
1236 .name = "soc-camera-pdrv",
1237 .id = 0,
1238 .dev = {
1239 .platform_data = &camera_link,
1240 },
1241};
1242
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001243static struct platform_device *mackerel_devices[] __initdata = {
1244 &nor_flash_device,
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001245 &smc911x_device,
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001246 &lcdc_device,
Kuninori Morimoto5a568552011-06-17 04:33:13 +00001247 &usbhs0_device,
Kuninori Morimotoe26a6032012-08-05 22:47:00 -07001248 &usbhs1_device,
Kuninori Morimotod44deb32010-11-30 06:52:18 +00001249 &leds_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001250 &fsi_device,
1251 &fsi_ak4643_device,
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +09001252 &fsi_hdmi_device,
Bastian Hecht2aab52e2012-03-01 10:48:41 +01001253 &nand_flash_device,
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001254 &sdhi0_device,
Guennadi Liakhovetski5bcd7512011-05-05 15:56:27 +00001255#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001256 &sdhi1_device,
Yusuke Goda41491b92010-12-15 08:31:04 +00001257#endif
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001258 &sdhi2_device,
Simon Hormanac22dde2013-03-21 20:18:12 +09001259 &sh_mmcif_device,
Magnus Dammae37c8d2010-12-22 14:47:40 +00001260 &ceu_device,
1261 &mackerel_camera,
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001262 &hdmi_device,
Laurent Pincharta1022ad2011-09-11 23:30:45 +02001263 &hdmi_lcdc_device,
Damian1c7fcbe2011-05-24 07:01:22 +00001264 &meram_device,
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001265};
1266
Tony SIMcd8ab002010-12-09 01:55:55 +00001267/* Keypad Initialization */
1268#define KEYPAD_BUTTON(ev_type, ev_code, act_low) \
1269{ \
1270 .type = ev_type, \
1271 .code = ev_code, \
1272 .active_low = act_low, \
1273}
1274
1275#define KEYPAD_BUTTON_LOW(event_code) KEYPAD_BUTTON(EV_KEY, event_code, 1)
1276
1277static struct tca6416_button mackerel_gpio_keys[] = {
1278 KEYPAD_BUTTON_LOW(KEY_HOME),
1279 KEYPAD_BUTTON_LOW(KEY_MENU),
1280 KEYPAD_BUTTON_LOW(KEY_BACK),
1281 KEYPAD_BUTTON_LOW(KEY_POWER),
1282};
1283
1284static struct tca6416_keys_platform_data mackerel_tca6416_keys_info = {
1285 .buttons = mackerel_gpio_keys,
1286 .nbuttons = ARRAY_SIZE(mackerel_gpio_keys),
1287 .rep = 1,
1288 .use_polling = 0,
1289 .pinmask = 0x000F,
1290};
1291
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001292/* I2C */
Tony SIM6ae1e192011-01-11 09:47:59 +09001293#define IRQ7 evt2irq(0x02e0)
Tony SIMcd8ab002010-12-09 01:55:55 +00001294#define IRQ9 evt2irq(0x0320)
1295
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001296static struct i2c_board_info i2c0_devices[] = {
1297 {
1298 I2C_BOARD_INFO("ak4643", 0x13),
1299 },
Tony SIMcd8ab002010-12-09 01:55:55 +00001300 /* Keypad */
1301 {
1302 I2C_BOARD_INFO("tca6408-keys", 0x20),
1303 .platform_data = &mackerel_tca6416_keys_info,
1304 .irq = IRQ9,
1305 },
Tony SIM6ae1e192011-01-11 09:47:59 +09001306 /* Touchscreen */
1307 {
1308 I2C_BOARD_INFO("st1232-ts", 0x55),
1309 .irq = IRQ7,
1310 },
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001311};
1312
Tony SIM80f1dc72010-12-07 09:12:14 +00001313#define IRQ21 evt2irq(0x32a0)
1314
1315static struct i2c_board_info i2c1_devices[] = {
1316 /* Accelerometer */
1317 {
1318 I2C_BOARD_INFO("adxl34x", 0x53),
1319 .irq = IRQ21,
1320 },
1321};
1322
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001323static const struct pinctrl_map mackerel_pinctrl_map[] = {
1324 /* MMCIF */
1325 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
1326 "mmc0_data8_0", "mmc0"),
1327 PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-sh7372",
1328 "mmc0_ctrl_0", "mmc0"),
1329 /* SDHI0 */
1330 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1331 "sdhi0_data4", "sdhi0"),
1332 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1333 "sdhi0_ctrl", "sdhi0"),
1334 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-sh7372",
1335 "sdhi0_wp", "sdhi0"),
1336 /* SDHI1 */
1337#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1338 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
1339 "sdhi1_data4", "sdhi1"),
1340 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-sh7372",
1341 "sdhi1_ctrl", "sdhi1"),
1342#endif
1343 /* SDHI2 */
1344 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
1345 "sdhi2_data4", "sdhi2"),
1346 PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-sh7372",
1347 "sdhi2_ctrl", "sdhi2"),
1348};
1349
Arnd Bergmann0a4b04d2012-09-14 20:08:08 +00001350#define GPIO_PORT9CR IOMEM(0xE6051009)
1351#define GPIO_PORT10CR IOMEM(0xE605100A)
1352#define GPIO_PORT167CR IOMEM(0xE60520A7)
1353#define GPIO_PORT168CR IOMEM(0xE60520A8)
1354#define SRCR4 IOMEM(0xe61580bc)
1355#define USCCR1 IOMEM(0xE6058144)
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001356static void __init mackerel_init(void)
1357{
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001358 struct pm_domain_device domain_devices[] = {
1359 { "A4LC", &lcdc_device, },
1360 { "A4LC", &hdmi_lcdc_device, },
1361 { "A4LC", &meram_device, },
1362 { "A4MP", &fsi_device, },
1363 { "A3SP", &usbhs0_device, },
1364 { "A3SP", &usbhs1_device, },
1365 { "A3SP", &nand_flash_device, },
Simon Hormanac22dde2013-03-21 20:18:12 +09001366 { "A3SP", &sh_mmcif_device, },
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001367 { "A3SP", &sdhi0_device, },
1368#if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE)
1369 { "A3SP", &sdhi1_device, },
1370#endif
1371 { "A3SP", &sdhi2_device, },
1372 { "A4R", &ceu_device, },
Rafael J. Wysockib42879e2012-08-08 00:29:16 +02001373 };
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001374 u32 srcr4;
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001375 struct clk *clk;
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001376
Guennadi Liakhovetski70ccb282012-06-27 00:32:23 +02001377 regulator_register_always_on(0, "fixed-1.8V", fixed1v8_power_consumers,
1378 ARRAY_SIZE(fixed1v8_power_consumers), 1800000);
1379 regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers,
1380 ARRAY_SIZE(fixed3v3_power_consumers), 3300000);
1381 regulator_register_fixed(2, dummy_supplies, ARRAY_SIZE(dummy_supplies));
1382
Magnus Damm12bb16d2012-03-06 16:30:18 +09001383 /* External clock source */
1384 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1385
Laurent Pinchart26e19bd2013-03-06 14:22:11 +01001386 pinctrl_register_mappings(mackerel_pinctrl_map,
1387 ARRAY_SIZE(mackerel_pinctrl_map));
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001388 sh7372_pinmux_init();
1389
1390 /* enable SCIFA0 */
1391 gpio_request(GPIO_FN_SCIFA0_TXD, NULL);
1392 gpio_request(GPIO_FN_SCIFA0_RXD, NULL);
1393
Kuninori Morimoto2264c152010-11-29 02:21:37 +00001394 /* enable SMSC911X */
1395 gpio_request(GPIO_FN_CS5A, NULL);
1396 gpio_request(GPIO_FN_IRQ6_39, NULL);
1397
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001398 /* LCDC */
Kuninori Morimotoeb87e672010-11-29 06:19:52 +00001399 gpio_request(GPIO_FN_LCDD23, NULL);
1400 gpio_request(GPIO_FN_LCDD22, NULL);
1401 gpio_request(GPIO_FN_LCDD21, NULL);
1402 gpio_request(GPIO_FN_LCDD20, NULL);
1403 gpio_request(GPIO_FN_LCDD19, NULL);
1404 gpio_request(GPIO_FN_LCDD18, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001405 gpio_request(GPIO_FN_LCDD17, NULL);
1406 gpio_request(GPIO_FN_LCDD16, NULL);
1407 gpio_request(GPIO_FN_LCDD15, NULL);
1408 gpio_request(GPIO_FN_LCDD14, NULL);
1409 gpio_request(GPIO_FN_LCDD13, NULL);
1410 gpio_request(GPIO_FN_LCDD12, NULL);
1411 gpio_request(GPIO_FN_LCDD11, NULL);
1412 gpio_request(GPIO_FN_LCDD10, NULL);
1413 gpio_request(GPIO_FN_LCDD9, NULL);
1414 gpio_request(GPIO_FN_LCDD8, NULL);
1415 gpio_request(GPIO_FN_LCDD7, NULL);
1416 gpio_request(GPIO_FN_LCDD6, NULL);
1417 gpio_request(GPIO_FN_LCDD5, NULL);
1418 gpio_request(GPIO_FN_LCDD4, NULL);
1419 gpio_request(GPIO_FN_LCDD3, NULL);
1420 gpio_request(GPIO_FN_LCDD2, NULL);
1421 gpio_request(GPIO_FN_LCDD1, NULL);
1422 gpio_request(GPIO_FN_LCDD0, NULL);
1423 gpio_request(GPIO_FN_LCDDISP, NULL);
1424 gpio_request(GPIO_FN_LCDDCK, NULL);
1425
Laurent Pinchartf96be912013-01-24 13:16:35 +01001426 /* backlight, off by default */
Laurent Pinchart6d170aa2013-02-16 07:38:50 +01001427 gpio_request_one(31, GPIOF_OUT_INIT_LOW, NULL);
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001428
Laurent Pinchart6d170aa2013-02-16 07:38:50 +01001429 gpio_request_one(151, GPIOF_OUT_INIT_HIGH, NULL); /* LCDDON */
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001430
Magnus Damme2a53b72011-06-09 07:03:37 +00001431 /* USBHS0 */
1432 gpio_request(GPIO_FN_VBUS0_0, NULL);
Kuninori Morimotoc721e0c2012-06-25 03:41:36 -07001433 gpio_request_pulldown(GPIO_PORT168CR); /* VBUS0_0 pull down */
Kuninori Morimoto25338f22010-11-30 04:37:33 +00001434
Magnus Damme2a53b72011-06-09 07:03:37 +00001435 /* USBHS1 */
1436 gpio_request(GPIO_FN_VBUS0_1, NULL);
Kuninori Morimotoc721e0c2012-06-25 03:41:36 -07001437 gpio_request_pulldown(GPIO_PORT167CR); /* VBUS0_1 pull down */
Magnus Damme2a53b72011-06-09 07:03:37 +00001438 gpio_request(GPIO_FN_IDIN_1_113, NULL);
1439
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001440 /* enable FSI2 port A (ak4643) */
1441 gpio_request(GPIO_FN_FSIAIBT, NULL);
1442 gpio_request(GPIO_FN_FSIAILR, NULL);
1443 gpio_request(GPIO_FN_FSIAISLD, NULL);
1444 gpio_request(GPIO_FN_FSIAOSLD, NULL);
Laurent Pinchart6d170aa2013-02-16 07:38:50 +01001445 gpio_request_one(161, GPIOF_OUT_INIT_LOW, NULL); /* slave */
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001446
Laurent Pinchart6d170aa2013-02-16 07:38:50 +01001447 gpio_request(9, NULL);
1448 gpio_request(10, NULL);
Kuninori Morimotoc721e0c2012-06-25 03:41:36 -07001449 gpio_direction_none(GPIO_PORT9CR); /* FSIAOBT needs no direction */
1450 gpio_direction_none(GPIO_PORT10CR); /* FSIAOLR needs no direction */
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001451
1452 intc_set_priority(IRQ_FSI, 3); /* irq priority FSI(3) > SMSC911X(2) */
1453
Kuninori Morimoto98d27b82011-01-06 02:44:15 +00001454 /* setup FSI2 port B (HDMI) */
1455 gpio_request(GPIO_FN_FSIBCK, NULL);
1456 __raw_writew(__raw_readw(USCCR1) & ~(1 << 6), USCCR1); /* use SPDIF */
1457
1458 /* set SPU2 clock to 119.6 MHz */
1459 clk = clk_get(NULL, "spu_clk");
1460 if (!IS_ERR(clk)) {
1461 clk_set_rate(clk, clk_round_rate(clk, 119600000));
1462 clk_put(clk);
1463 }
1464
Tony SIMcd8ab002010-12-09 01:55:55 +00001465 /* enable Keypad */
1466 gpio_request(GPIO_FN_IRQ9_42, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001467 irq_set_irq_type(IRQ9, IRQ_TYPE_LEVEL_HIGH);
Tony SIMcd8ab002010-12-09 01:55:55 +00001468
Tony SIM6ae1e192011-01-11 09:47:59 +09001469 /* enable Touchscreen */
1470 gpio_request(GPIO_FN_IRQ7_40, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001471 irq_set_irq_type(IRQ7, IRQ_TYPE_LEVEL_LOW);
Tony SIM6ae1e192011-01-11 09:47:59 +09001472
Tony SIM80f1dc72010-12-07 09:12:14 +00001473 /* enable Accelerometer */
1474 gpio_request(GPIO_FN_IRQ21, NULL);
Thomas Gleixner6845664a2011-03-24 13:25:22 +01001475 irq_set_irq_type(IRQ21, IRQ_TYPE_LEVEL_HIGH);
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001476
Guennadi Liakhovetski56fb5232012-06-20 12:15:59 +02001477 /* SDHI0 PORT172 card-detect IRQ26 */
1478 gpio_request(GPIO_FN_IRQ26_172, NULL);
1479
Simon Hormanac22dde2013-03-21 20:18:12 +09001480 /* card detect pin for MMC slot (CN7) */
1481 gpio_request_one(41, GPIOF_IN, NULL);
Yusuke Goda6dff7da2010-12-14 14:18:03 +09001482
Simon Hormanac22dde2013-03-21 20:18:12 +09001483 /* card detect pin for microSD slot (CN23) */
1484 gpio_request_one(162, GPIOF_IN, NULL);
Yusuke Godada5d1f42011-01-07 09:48:36 +00001485
Bastian Hecht2aab52e2012-03-01 10:48:41 +01001486 /* FLCTL */
1487 gpio_request(GPIO_FN_D0_NAF0, NULL);
1488 gpio_request(GPIO_FN_D1_NAF1, NULL);
1489 gpio_request(GPIO_FN_D2_NAF2, NULL);
1490 gpio_request(GPIO_FN_D3_NAF3, NULL);
1491 gpio_request(GPIO_FN_D4_NAF4, NULL);
1492 gpio_request(GPIO_FN_D5_NAF5, NULL);
1493 gpio_request(GPIO_FN_D6_NAF6, NULL);
1494 gpio_request(GPIO_FN_D7_NAF7, NULL);
1495 gpio_request(GPIO_FN_D8_NAF8, NULL);
1496 gpio_request(GPIO_FN_D9_NAF9, NULL);
1497 gpio_request(GPIO_FN_D10_NAF10, NULL);
1498 gpio_request(GPIO_FN_D11_NAF11, NULL);
1499 gpio_request(GPIO_FN_D12_NAF12, NULL);
1500 gpio_request(GPIO_FN_D13_NAF13, NULL);
1501 gpio_request(GPIO_FN_D14_NAF14, NULL);
1502 gpio_request(GPIO_FN_D15_NAF15, NULL);
1503 gpio_request(GPIO_FN_FCE0, NULL);
1504 gpio_request(GPIO_FN_WE0_FWE, NULL);
1505 gpio_request(GPIO_FN_FRB, NULL);
1506 gpio_request(GPIO_FN_A4_FOE, NULL);
1507 gpio_request(GPIO_FN_A5_FCDE, NULL);
1508 gpio_request(GPIO_FN_RD_FSC, NULL);
1509
Yusuke Goda56e78da2010-12-20 01:06:04 +00001510 /* enable GPS module (GT-720F) */
1511 gpio_request(GPIO_FN_SCIFA2_TXD1, NULL);
1512 gpio_request(GPIO_FN_SCIFA2_RXD1, NULL);
1513
Magnus Dammae37c8d2010-12-22 14:47:40 +00001514 /* CEU */
1515 gpio_request(GPIO_FN_VIO_CLK, NULL);
1516 gpio_request(GPIO_FN_VIO_VD, NULL);
1517 gpio_request(GPIO_FN_VIO_HD, NULL);
1518 gpio_request(GPIO_FN_VIO_FIELD, NULL);
1519 gpio_request(GPIO_FN_VIO_CKO, NULL);
1520 gpio_request(GPIO_FN_VIO_D7, NULL);
1521 gpio_request(GPIO_FN_VIO_D6, NULL);
1522 gpio_request(GPIO_FN_VIO_D5, NULL);
1523 gpio_request(GPIO_FN_VIO_D4, NULL);
1524 gpio_request(GPIO_FN_VIO_D3, NULL);
1525 gpio_request(GPIO_FN_VIO_D2, NULL);
1526 gpio_request(GPIO_FN_VIO_D1, NULL);
1527 gpio_request(GPIO_FN_VIO_D0, NULL);
1528
Kuninori Morimoto12c43092011-01-06 02:44:09 +00001529 /* HDMI */
1530 gpio_request(GPIO_FN_HDMI_HPD, NULL);
1531 gpio_request(GPIO_FN_HDMI_CEC, NULL);
1532
1533 /* Reset HDMI, must be held at least one EXTALR (32768Hz) period */
1534 srcr4 = __raw_readl(SRCR4);
1535 __raw_writel(srcr4 | (1 << 13), SRCR4);
1536 udelay(50);
1537 __raw_writel(srcr4 & ~(1 << 13), SRCR4);
1538
Kuninori Morimoto1a44d722010-12-01 00:31:46 +00001539 i2c_register_board_info(0, i2c0_devices,
1540 ARRAY_SIZE(i2c0_devices));
Tony SIM80f1dc72010-12-07 09:12:14 +00001541 i2c_register_board_info(1, i2c1_devices,
1542 ARRAY_SIZE(i2c1_devices));
Kuninori Morimoto11fee462010-11-29 02:21:43 +00001543
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001544 sh7372_add_standard_devices();
1545
1546 platform_add_devices(mackerel_devices, ARRAY_SIZE(mackerel_devices));
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001547
Rafael J. Wysockiac18e022012-08-15 20:56:26 +02001548 rmobile_add_devices_to_domains(domain_devices,
1549 ARRAY_SIZE(domain_devices));
Rafael J. Wysockie3e01092011-07-01 22:13:56 +02001550
Guennadi Liakhovetski2ce51f82011-04-04 17:08:05 +02001551 hdmi_init_pm_clock();
Magnus Damm97991652011-04-29 02:28:08 +09001552 sh7372_pm_init();
Kuninori Morimotoa41b6462011-07-10 10:11:57 +02001553 pm_clk_add(&fsi_device.dev, "spu2");
Magnus Damm5c3f96b2011-08-24 22:38:43 +02001554 pm_clk_add(&hdmi_lcdc_device.dev, "hdmi");
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001555}
1556
Nobuhiro Iwamatsu0ce53cd2012-10-24 14:48:00 +09001557static const char *mackerel_boards_compat_dt[] __initdata = {
1558 "renesas,mackerel",
1559 NULL,
1560};
1561
1562DT_MACHINE_START(MACKEREL_DT, "mackerel")
Arnd Bergmann426f1af2012-03-22 22:02:16 +00001563 .map_io = sh7372_map_io,
Magnus Damm5d7220ec2012-02-29 21:37:19 +09001564 .init_early = sh7372_add_early_devices,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001565 .init_irq = sh7372_init_irq,
Magnus Damm863b1712010-12-28 08:27:01 +00001566 .handle_irq = shmobile_handle_irq_intc,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001567 .init_machine = mackerel_init,
Rafael J. Wysockicaaca992012-08-22 12:27:24 +02001568 .init_late = sh7372_pm_init_late,
Stephen Warren6bb27d72012-11-08 12:40:59 -07001569 .init_time = sh7372_earlytimer_init,
Nobuhiro Iwamatsu0ce53cd2012-10-24 14:48:00 +09001570 .dt_compat = mackerel_boards_compat_dt,
Kuninori Morimoto920adc72010-11-29 02:21:21 +00001571MACHINE_END