You need to sign in or sign up before continuing.
setup-sh7372.c 24.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
/*
 * sh7372 processor support
 *
 * Copyright (C) 2010  Magnus Damm
 * Copyright (C) 2008  Yoshihiro Shimoda
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
25
#include <linux/of_platform.h>
26
#include <linux/uio_driver.h>
27 28 29 30
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/io.h>
#include <linux/serial_sci.h>
31
#include <linux/sh_dma.h>
32 33
#include <linux/sh_intc.h>
#include <linux/sh_timer.h>
34
#include <linux/pm_domain.h>
35
#include <linux/dma-mapping.h>
36
#include <mach/dma-register.h>
37
#include <mach/hardware.h>
R
Rob Herring 已提交
38
#include <mach/irqs.h>
39
#include <mach/sh7372.h>
40 41
#include <mach/common.h>
#include <asm/mach/map.h>
42 43
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
44
#include <asm/mach/time.h>
45

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
static struct map_desc sh7372_io_desc[] __initdata = {
	/* create a 1:1 entity map for 0xe6xxxxxx
	 * used by CPGA, INTC and PFC.
	 */
	{
		.virtual	= 0xe6000000,
		.pfn		= __phys_to_pfn(0xe6000000),
		.length		= 256 << 20,
		.type		= MT_DEVICE_NONSHARED
	},
};

void __init sh7372_map_io(void)
{
	iotable_init(sh7372_io_desc, ARRAY_SIZE(sh7372_io_desc));
61 62 63 64 65 66

	/*
	 * DMA memory at 0xff200000 - 0xffdfffff. The default 2MB size isn't
	 * enough to allocate the frame buffer memory.
	 */
	init_consistent_dma_size(12 << 20);
67
}
68

69
/* SCIFA0 */
70 71 72
static struct plat_sci_port scif0_platform_data = {
	.mapbase	= 0xe6c40000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
73 74
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
75
	.type		= PORT_SCIFA,
76 77
	.irqs		= { evt2irq(0x0c00), evt2irq(0x0c00),
			    evt2irq(0x0c00), evt2irq(0x0c00) },
78 79 80 81 82 83 84 85 86 87
};

static struct platform_device scif0_device = {
	.name		= "sh-sci",
	.id		= 0,
	.dev		= {
		.platform_data	= &scif0_platform_data,
	},
};

88
/* SCIFA1 */
89 90 91
static struct plat_sci_port scif1_platform_data = {
	.mapbase	= 0xe6c50000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
92 93
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
94
	.type		= PORT_SCIFA,
95 96
	.irqs		= { evt2irq(0x0c20), evt2irq(0x0c20),
			    evt2irq(0x0c20), evt2irq(0x0c20) },
97 98 99 100 101 102 103 104 105 106
};

static struct platform_device scif1_device = {
	.name		= "sh-sci",
	.id		= 1,
	.dev		= {
		.platform_data	= &scif1_platform_data,
	},
};

107
/* SCIFA2 */
108 109 110
static struct plat_sci_port scif2_platform_data = {
	.mapbase	= 0xe6c60000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
111 112
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
113
	.type		= PORT_SCIFA,
114 115
	.irqs		= { evt2irq(0x0c40), evt2irq(0x0c40),
			    evt2irq(0x0c40), evt2irq(0x0c40) },
116 117 118 119 120 121 122 123 124 125
};

static struct platform_device scif2_device = {
	.name		= "sh-sci",
	.id		= 2,
	.dev		= {
		.platform_data	= &scif2_platform_data,
	},
};

126
/* SCIFA3 */
127 128 129
static struct plat_sci_port scif3_platform_data = {
	.mapbase	= 0xe6c70000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
130 131
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
132
	.type		= PORT_SCIFA,
133 134
	.irqs		= { evt2irq(0x0c60), evt2irq(0x0c60),
			    evt2irq(0x0c60), evt2irq(0x0c60) },
135 136 137 138 139 140 141 142 143 144
};

static struct platform_device scif3_device = {
	.name		= "sh-sci",
	.id		= 3,
	.dev		= {
		.platform_data	= &scif3_platform_data,
	},
};

145
/* SCIFA4 */
146 147 148
static struct plat_sci_port scif4_platform_data = {
	.mapbase	= 0xe6c80000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
149 150
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
151
	.type		= PORT_SCIFA,
152 153
	.irqs		= { evt2irq(0x0d20), evt2irq(0x0d20),
			    evt2irq(0x0d20), evt2irq(0x0d20) },
154 155 156 157 158 159 160 161 162 163
};

static struct platform_device scif4_device = {
	.name		= "sh-sci",
	.id		= 4,
	.dev		= {
		.platform_data	= &scif4_platform_data,
	},
};

164
/* SCIFA5 */
165 166 167
static struct plat_sci_port scif5_platform_data = {
	.mapbase	= 0xe6cb0000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
168 169
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
170
	.type		= PORT_SCIFA,
171 172
	.irqs		= { evt2irq(0x0d40), evt2irq(0x0d40),
			    evt2irq(0x0d40), evt2irq(0x0d40) },
173 174 175 176 177 178 179 180 181 182
};

static struct platform_device scif5_device = {
	.name		= "sh-sci",
	.id		= 5,
	.dev		= {
		.platform_data	= &scif5_platform_data,
	},
};

183
/* SCIFB */
184 185 186
static struct plat_sci_port scif6_platform_data = {
	.mapbase	= 0xe6c30000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
187 188
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
189
	.type		= PORT_SCIFB,
190 191
	.irqs		= { evt2irq(0x0d60), evt2irq(0x0d60),
			    evt2irq(0x0d60), evt2irq(0x0d60) },
192 193 194 195 196 197 198 199 200 201
};

static struct platform_device scif6_device = {
	.name		= "sh-sci",
	.id		= 6,
	.dev		= {
		.platform_data	= &scif6_platform_data,
	},
};

202
/* CMT */
203 204 205 206
static struct sh_timer_config cmt2_platform_data = {
	.name = "CMT2",
	.channel_offset = 0x40,
	.timer_bit = 5,
207 208 209 210
	.clockevent_rating = 125,
	.clocksource_rating = 125,
};

211
static struct resource cmt2_resources[] = {
212
	[0] = {
213 214 215
		.name	= "CMT2",
		.start	= 0xe6130040,
		.end	= 0xe613004b,
216 217 218
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
219
		.start	= evt2irq(0x0b80), /* CMT2 */
220 221 222 223
		.flags	= IORESOURCE_IRQ,
	},
};

224
static struct platform_device cmt2_device = {
225
	.name		= "sh_cmt",
226
	.id		= 2,
227
	.dev = {
228
		.platform_data	= &cmt2_platform_data,
229
	},
230 231
	.resource	= cmt2_resources,
	.num_resources	= ARRAY_SIZE(cmt2_resources),
232 233
};

234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
/* TMU */
static struct sh_timer_config tmu00_platform_data = {
	.name = "TMU00",
	.channel_offset = 0x4,
	.timer_bit = 0,
	.clockevent_rating = 200,
};

static struct resource tmu00_resources[] = {
	[0] = {
		.name	= "TMU00",
		.start	= 0xfff60008,
		.end	= 0xfff60013,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= intcs_evt2irq(0xe80), /* TMU_TUNI0 */
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device tmu00_device = {
	.name		= "sh_tmu",
	.id		= 0,
	.dev = {
		.platform_data	= &tmu00_platform_data,
	},
	.resource	= tmu00_resources,
	.num_resources	= ARRAY_SIZE(tmu00_resources),
};

static struct sh_timer_config tmu01_platform_data = {
	.name = "TMU01",
	.channel_offset = 0x10,
	.timer_bit = 1,
	.clocksource_rating = 200,
};

static struct resource tmu01_resources[] = {
	[0] = {
		.name	= "TMU01",
		.start	= 0xfff60014,
		.end	= 0xfff6001f,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= intcs_evt2irq(0xea0), /* TMU_TUNI1 */
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device tmu01_device = {
	.name		= "sh_tmu",
	.id		= 1,
	.dev = {
		.platform_data	= &tmu01_platform_data,
	},
	.resource	= tmu01_resources,
	.num_resources	= ARRAY_SIZE(tmu01_resources),
};

295 296 297 298 299 300 301 302 303
/* I2C */
static struct resource iic0_resources[] = {
	[0] = {
		.name	= "IIC0",
		.start  = 0xFFF20000,
		.end    = 0xFFF20425 - 1,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
304 305
		.start  = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
		.end    = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device iic0_device = {
	.name           = "i2c-sh_mobile",
	.id             = 0, /* "i2c0" clock */
	.num_resources  = ARRAY_SIZE(iic0_resources),
	.resource       = iic0_resources,
};

static struct resource iic1_resources[] = {
	[0] = {
		.name	= "IIC1",
		.start  = 0xE6C20000,
		.end    = 0xE6C20425 - 1,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
325 326
		.start  = evt2irq(0x780), /* IIC1_ALI1 */
		.end    = evt2irq(0x7e0), /* IIC1_DTEI1 */
327 328 329 330 331 332 333 334 335 336 337
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device iic1_device = {
	.name           = "i2c-sh_mobile",
	.id             = 1, /* "i2c1" clock */
	.num_resources  = ARRAY_SIZE(iic1_resources),
	.resource       = iic1_resources,
};

338 339 340
/* DMA */
static const struct sh_dmae_slave_config sh7372_dmae_slaves[] = {
	{
341 342
		.slave_id	= SHDMA_SLAVE_SCIF0_TX,
		.addr		= 0xe6c40020,
343
		.chcr		= CHCR_TX(XMIT_SZ_8BIT),
344 345 346 347
		.mid_rid	= 0x21,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF0_RX,
		.addr		= 0xe6c40024,
348
		.chcr		= CHCR_RX(XMIT_SZ_8BIT),
349 350 351 352
		.mid_rid	= 0x22,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF1_TX,
		.addr		= 0xe6c50020,
353
		.chcr		= CHCR_TX(XMIT_SZ_8BIT),
354 355 356 357
		.mid_rid	= 0x25,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF1_RX,
		.addr		= 0xe6c50024,
358
		.chcr		= CHCR_RX(XMIT_SZ_8BIT),
359 360 361 362
		.mid_rid	= 0x26,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF2_TX,
		.addr		= 0xe6c60020,
363
		.chcr		= CHCR_TX(XMIT_SZ_8BIT),
364 365 366 367
		.mid_rid	= 0x29,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF2_RX,
		.addr		= 0xe6c60024,
368
		.chcr		= CHCR_RX(XMIT_SZ_8BIT),
369 370 371 372
		.mid_rid	= 0x2a,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF3_TX,
		.addr		= 0xe6c70020,
373
		.chcr		= CHCR_TX(XMIT_SZ_8BIT),
374 375 376 377
		.mid_rid	= 0x2d,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF3_RX,
		.addr		= 0xe6c70024,
378
		.chcr		= CHCR_RX(XMIT_SZ_8BIT),
379 380 381 382
		.mid_rid	= 0x2e,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF4_TX,
		.addr		= 0xe6c80020,
383
		.chcr		= CHCR_TX(XMIT_SZ_8BIT),
384 385 386 387
		.mid_rid	= 0x39,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF4_RX,
		.addr		= 0xe6c80024,
388
		.chcr		= CHCR_RX(XMIT_SZ_8BIT),
389 390 391 392
		.mid_rid	= 0x3a,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF5_TX,
		.addr		= 0xe6cb0020,
393
		.chcr		= CHCR_TX(XMIT_SZ_8BIT),
394 395 396 397
		.mid_rid	= 0x35,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF5_RX,
		.addr		= 0xe6cb0024,
398
		.chcr		= CHCR_RX(XMIT_SZ_8BIT),
399 400 401 402
		.mid_rid	= 0x36,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF6_TX,
		.addr		= 0xe6c30040,
403
		.chcr		= CHCR_TX(XMIT_SZ_8BIT),
404 405 406 407
		.mid_rid	= 0x3d,
	}, {
		.slave_id	= SHDMA_SLAVE_SCIF6_RX,
		.addr		= 0xe6c30060,
408
		.chcr		= CHCR_RX(XMIT_SZ_8BIT),
409 410
		.mid_rid	= 0x3e,
	}, {
411 412
		.slave_id	= SHDMA_SLAVE_SDHI0_TX,
		.addr		= 0xe6850030,
413
		.chcr		= CHCR_TX(XMIT_SZ_16BIT),
414 415 416 417
		.mid_rid	= 0xc1,
	}, {
		.slave_id	= SHDMA_SLAVE_SDHI0_RX,
		.addr		= 0xe6850030,
418
		.chcr		= CHCR_RX(XMIT_SZ_16BIT),
419 420 421 422
		.mid_rid	= 0xc2,
	}, {
		.slave_id	= SHDMA_SLAVE_SDHI1_TX,
		.addr		= 0xe6860030,
423
		.chcr		= CHCR_TX(XMIT_SZ_16BIT),
424 425 426 427
		.mid_rid	= 0xc9,
	}, {
		.slave_id	= SHDMA_SLAVE_SDHI1_RX,
		.addr		= 0xe6860030,
428
		.chcr		= CHCR_RX(XMIT_SZ_16BIT),
429 430 431 432
		.mid_rid	= 0xca,
	}, {
		.slave_id	= SHDMA_SLAVE_SDHI2_TX,
		.addr		= 0xe6870030,
433
		.chcr		= CHCR_TX(XMIT_SZ_16BIT),
434 435 436 437
		.mid_rid	= 0xcd,
	}, {
		.slave_id	= SHDMA_SLAVE_SDHI2_RX,
		.addr		= 0xe6870030,
438
		.chcr		= CHCR_RX(XMIT_SZ_16BIT),
439
		.mid_rid	= 0xce,
440 441 442
	}, {
		.slave_id	= SHDMA_SLAVE_FSIA_TX,
		.addr		= 0xfe1f0024,
443
		.chcr		= CHCR_TX(XMIT_SZ_32BIT),
444 445 446 447
		.mid_rid	= 0xb1,
	}, {
		.slave_id	= SHDMA_SLAVE_FSIA_RX,
		.addr		= 0xfe1f0020,
448
		.chcr		= CHCR_RX(XMIT_SZ_32BIT),
449
		.mid_rid	= 0xb2,
450 451 452
	}, {
		.slave_id	= SHDMA_SLAVE_MMCIF_TX,
		.addr		= 0xe6bd0034,
453
		.chcr		= CHCR_TX(XMIT_SZ_32BIT),
454 455 456 457
		.mid_rid	= 0xd1,
	}, {
		.slave_id	= SHDMA_SLAVE_MMCIF_RX,
		.addr		= 0xe6bd0034,
458
		.chcr		= CHCR_RX(XMIT_SZ_32BIT),
459
		.mid_rid	= 0xd2,
460 461 462
	},
};

463
#define SH7372_CHCLR (0x220 - 0x20)
464

465 466 467 468 469
static const struct sh_dmae_channel sh7372_dmae_channels[] = {
	{
		.offset = 0,
		.dmars = 0,
		.dmars_bit = 0,
470
		.chclr_offset = SH7372_CHCLR + 0,
471 472 473 474
	}, {
		.offset = 0x10,
		.dmars = 0,
		.dmars_bit = 8,
475
		.chclr_offset = SH7372_CHCLR + 0x10,
476 477 478 479
	}, {
		.offset = 0x20,
		.dmars = 4,
		.dmars_bit = 0,
480
		.chclr_offset = SH7372_CHCLR + 0x20,
481 482 483 484
	}, {
		.offset = 0x30,
		.dmars = 4,
		.dmars_bit = 8,
485
		.chclr_offset = SH7372_CHCLR + 0x30,
486 487 488 489
	}, {
		.offset = 0x50,
		.dmars = 8,
		.dmars_bit = 0,
490
		.chclr_offset = SH7372_CHCLR + 0x50,
491 492 493 494
	}, {
		.offset = 0x60,
		.dmars = 8,
		.dmars_bit = 8,
495
		.chclr_offset = SH7372_CHCLR + 0x60,
496 497 498 499 500 501 502 503
	}
};

static struct sh_dmae_pdata dma_platform_data = {
	.slave		= sh7372_dmae_slaves,
	.slave_num	= ARRAY_SIZE(sh7372_dmae_slaves),
	.channel	= sh7372_dmae_channels,
	.channel_num	= ARRAY_SIZE(sh7372_dmae_channels),
504 505 506 507 508 509
	.ts_low_shift	= TS_LOW_SHIFT,
	.ts_low_mask	= TS_LOW_BIT << TS_LOW_SHIFT,
	.ts_high_shift	= TS_HI_SHIFT,
	.ts_high_mask	= TS_HI_BIT << TS_HI_SHIFT,
	.ts_shift	= dma_ts_shift,
	.ts_shift_num	= ARRAY_SIZE(dma_ts_shift),
510
	.dmaor_init	= DMAOR_DME,
511
	.chclr_present	= 1,
512 513 514 515 516 517 518
};

/* Resource order important! */
static struct resource sh7372_dmae0_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xfe008020,
519
		.end	= 0xfe00828f,
520 521 522 523 524 525 526 527 528
		.flags	= IORESOURCE_MEM,
	},
	{
		/* DMARSx */
		.start	= 0xfe009000,
		.end	= 0xfe00900b,
		.flags	= IORESOURCE_MEM,
	},
	{
529
		.name	= "error_irq",
530 531
		.start	= evt2irq(0x20c0),
		.end	= evt2irq(0x20c0),
532 533 534 535
		.flags	= IORESOURCE_IRQ,
	},
	{
		/* IRQ for channels 0-5 */
536 537
		.start	= evt2irq(0x2000),
		.end	= evt2irq(0x20a0),
538 539 540 541 542 543 544 545 546
		.flags	= IORESOURCE_IRQ,
	},
};

/* Resource order important! */
static struct resource sh7372_dmae1_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xfe018020,
547
		.end	= 0xfe01828f,
548 549 550 551 552 553 554 555 556
		.flags	= IORESOURCE_MEM,
	},
	{
		/* DMARSx */
		.start	= 0xfe019000,
		.end	= 0xfe01900b,
		.flags	= IORESOURCE_MEM,
	},
	{
557
		.name	= "error_irq",
558 559
		.start	= evt2irq(0x21c0),
		.end	= evt2irq(0x21c0),
560 561 562 563
		.flags	= IORESOURCE_IRQ,
	},
	{
		/* IRQ for channels 0-5 */
564 565
		.start	= evt2irq(0x2100),
		.end	= evt2irq(0x21a0),
566 567 568 569 570 571 572 573 574
		.flags	= IORESOURCE_IRQ,
	},
};

/* Resource order important! */
static struct resource sh7372_dmae2_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xfe028020,
575
		.end	= 0xfe02828f,
576 577 578 579 580 581 582 583 584
		.flags	= IORESOURCE_MEM,
	},
	{
		/* DMARSx */
		.start	= 0xfe029000,
		.end	= 0xfe02900b,
		.flags	= IORESOURCE_MEM,
	},
	{
585
		.name	= "error_irq",
586 587
		.start	= evt2irq(0x22c0),
		.end	= evt2irq(0x22c0),
588 589 590 591
		.flags	= IORESOURCE_IRQ,
	},
	{
		/* IRQ for channels 0-5 */
592 593
		.start	= evt2irq(0x2200),
		.end	= evt2irq(0x22a0),
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device dma0_device = {
	.name		= "sh-dma-engine",
	.id		= 0,
	.resource	= sh7372_dmae0_resources,
	.num_resources	= ARRAY_SIZE(sh7372_dmae0_resources),
	.dev		= {
		.platform_data	= &dma_platform_data,
	},
};

static struct platform_device dma1_device = {
	.name		= "sh-dma-engine",
	.id		= 1,
	.resource	= sh7372_dmae1_resources,
	.num_resources	= ARRAY_SIZE(sh7372_dmae1_resources),
	.dev		= {
		.platform_data	= &dma_platform_data,
	},
};

static struct platform_device dma2_device = {
	.name		= "sh-dma-engine",
	.id		= 2,
	.resource	= sh7372_dmae2_resources,
	.num_resources	= ARRAY_SIZE(sh7372_dmae2_resources),
	.dev		= {
		.platform_data	= &dma_platform_data,
	},
};

628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
/*
 * USB-DMAC
 */
static const struct sh_dmae_channel sh7372_usb_dmae_channels[] = {
	{
		.offset = 0,
	}, {
		.offset = 0x20,
	},
};

/* USB DMAC0 */
static const struct sh_dmae_slave_config sh7372_usb_dmae0_slaves[] = {
	{
		.slave_id	= SHDMA_SLAVE_USB0_TX,
643
		.chcr		= USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
644 645
	}, {
		.slave_id	= SHDMA_SLAVE_USB0_RX,
646
		.chcr		= USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
647 648 649 650 651 652 653 654
	},
};

static struct sh_dmae_pdata usb_dma0_platform_data = {
	.slave		= sh7372_usb_dmae0_slaves,
	.slave_num	= ARRAY_SIZE(sh7372_usb_dmae0_slaves),
	.channel	= sh7372_usb_dmae_channels,
	.channel_num	= ARRAY_SIZE(sh7372_usb_dmae_channels),
655 656 657 658 659 660
	.ts_low_shift	= USBTS_LOW_SHIFT,
	.ts_low_mask	= USBTS_LOW_BIT << USBTS_LOW_SHIFT,
	.ts_high_shift	= USBTS_HI_SHIFT,
	.ts_high_mask	= USBTS_HI_BIT << USBTS_HI_SHIFT,
	.ts_shift	= dma_usbts_shift,
	.ts_shift_num	= ARRAY_SIZE(dma_usbts_shift),
661 662 663 664 665 666
	.dmaor_init	= DMAOR_DME,
	.chcr_offset	= 0x14,
	.chcr_ie_bit	= 1 << 5,
	.dmaor_is_32bit	= 1,
	.needs_tend_set	= 1,
	.no_dmars	= 1,
667
	.slave_only	= 1,
668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
};

static struct resource sh7372_usb_dmae0_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xe68a0020,
		.end	= 0xe68a0064 - 1,
		.flags	= IORESOURCE_MEM,
	},
	{
		/* VCR/SWR/DMICR */
		.start	= 0xe68a0000,
		.end	= 0xe68a0014 - 1,
		.flags	= IORESOURCE_MEM,
	},
	{
		/* IRQ for channels */
		.start	= evt2irq(0x0a00),
		.end	= evt2irq(0x0a00),
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device usb_dma0_device = {
	.name		= "sh-dma-engine",
	.id		= 3,
	.resource	= sh7372_usb_dmae0_resources,
	.num_resources	= ARRAY_SIZE(sh7372_usb_dmae0_resources),
	.dev		= {
		.platform_data	= &usb_dma0_platform_data,
	},
};

/* USB DMAC1 */
static const struct sh_dmae_slave_config sh7372_usb_dmae1_slaves[] = {
	{
		.slave_id	= SHDMA_SLAVE_USB1_TX,
705
		.chcr		= USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
706 707
	}, {
		.slave_id	= SHDMA_SLAVE_USB1_RX,
708
		.chcr		= USBTS_INDEX2VAL(USBTS_XMIT_SZ_8BYTE),
709 710 711 712 713 714 715 716
	},
};

static struct sh_dmae_pdata usb_dma1_platform_data = {
	.slave		= sh7372_usb_dmae1_slaves,
	.slave_num	= ARRAY_SIZE(sh7372_usb_dmae1_slaves),
	.channel	= sh7372_usb_dmae_channels,
	.channel_num	= ARRAY_SIZE(sh7372_usb_dmae_channels),
717 718 719 720 721 722
	.ts_low_shift	= USBTS_LOW_SHIFT,
	.ts_low_mask	= USBTS_LOW_BIT << USBTS_LOW_SHIFT,
	.ts_high_shift	= USBTS_HI_SHIFT,
	.ts_high_mask	= USBTS_HI_BIT << USBTS_HI_SHIFT,
	.ts_shift	= dma_usbts_shift,
	.ts_shift_num	= ARRAY_SIZE(dma_usbts_shift),
723 724 725 726 727 728
	.dmaor_init	= DMAOR_DME,
	.chcr_offset	= 0x14,
	.chcr_ie_bit	= 1 << 5,
	.dmaor_is_32bit	= 1,
	.needs_tend_set	= 1,
	.no_dmars	= 1,
729
	.slave_only	= 1,
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
};

static struct resource sh7372_usb_dmae1_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xe68c0020,
		.end	= 0xe68c0064 - 1,
		.flags	= IORESOURCE_MEM,
	},
	{
		/* VCR/SWR/DMICR */
		.start	= 0xe68c0000,
		.end	= 0xe68c0014 - 1,
		.flags	= IORESOURCE_MEM,
	},
	{
		/* IRQ for channels */
		.start	= evt2irq(0x1d00),
		.end	= evt2irq(0x1d00),
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device usb_dma1_device = {
	.name		= "sh-dma-engine",
	.id		= 4,
	.resource	= sh7372_usb_dmae1_resources,
	.num_resources	= ARRAY_SIZE(sh7372_usb_dmae1_resources),
	.dev		= {
		.platform_data	= &usb_dma1_platform_data,
	},
};

763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970
/* VPU */
static struct uio_info vpu_platform_data = {
	.name = "VPU5HG",
	.version = "0",
	.irq = intcs_evt2irq(0x980),
};

static struct resource vpu_resources[] = {
	[0] = {
		.name	= "VPU",
		.start	= 0xfe900000,
		.end	= 0xfe900157,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device vpu_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 0,
	.dev = {
		.platform_data	= &vpu_platform_data,
	},
	.resource	= vpu_resources,
	.num_resources	= ARRAY_SIZE(vpu_resources),
};

/* VEU0 */
static struct uio_info veu0_platform_data = {
	.name = "VEU0",
	.version = "0",
	.irq = intcs_evt2irq(0x700),
};

static struct resource veu0_resources[] = {
	[0] = {
		.name	= "VEU0",
		.start	= 0xfe920000,
		.end	= 0xfe9200cb,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device veu0_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 1,
	.dev = {
		.platform_data	= &veu0_platform_data,
	},
	.resource	= veu0_resources,
	.num_resources	= ARRAY_SIZE(veu0_resources),
};

/* VEU1 */
static struct uio_info veu1_platform_data = {
	.name = "VEU1",
	.version = "0",
	.irq = intcs_evt2irq(0x720),
};

static struct resource veu1_resources[] = {
	[0] = {
		.name	= "VEU1",
		.start	= 0xfe924000,
		.end	= 0xfe9240cb,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device veu1_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 2,
	.dev = {
		.platform_data	= &veu1_platform_data,
	},
	.resource	= veu1_resources,
	.num_resources	= ARRAY_SIZE(veu1_resources),
};

/* VEU2 */
static struct uio_info veu2_platform_data = {
	.name = "VEU2",
	.version = "0",
	.irq = intcs_evt2irq(0x740),
};

static struct resource veu2_resources[] = {
	[0] = {
		.name	= "VEU2",
		.start	= 0xfe928000,
		.end	= 0xfe928307,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device veu2_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 3,
	.dev = {
		.platform_data	= &veu2_platform_data,
	},
	.resource	= veu2_resources,
	.num_resources	= ARRAY_SIZE(veu2_resources),
};

/* VEU3 */
static struct uio_info veu3_platform_data = {
	.name = "VEU3",
	.version = "0",
	.irq = intcs_evt2irq(0x760),
};

static struct resource veu3_resources[] = {
	[0] = {
		.name	= "VEU3",
		.start	= 0xfe92c000,
		.end	= 0xfe92c307,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device veu3_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 4,
	.dev = {
		.platform_data	= &veu3_platform_data,
	},
	.resource	= veu3_resources,
	.num_resources	= ARRAY_SIZE(veu3_resources),
};

/* JPU */
static struct uio_info jpu_platform_data = {
	.name = "JPU",
	.version = "0",
	.irq = intcs_evt2irq(0x560),
};

static struct resource jpu_resources[] = {
	[0] = {
		.name	= "JPU",
		.start	= 0xfe980000,
		.end	= 0xfe9902d3,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device jpu_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 5,
	.dev = {
		.platform_data	= &jpu_platform_data,
	},
	.resource	= jpu_resources,
	.num_resources	= ARRAY_SIZE(jpu_resources),
};

/* SPU2DSP0 */
static struct uio_info spu0_platform_data = {
	.name = "SPU2DSP0",
	.version = "0",
	.irq = evt2irq(0x1800),
};

static struct resource spu0_resources[] = {
	[0] = {
		.name	= "SPU2DSP0",
		.start	= 0xfe200000,
		.end	= 0xfe2fffff,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device spu0_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 6,
	.dev = {
		.platform_data	= &spu0_platform_data,
	},
	.resource	= spu0_resources,
	.num_resources	= ARRAY_SIZE(spu0_resources),
};

/* SPU2DSP1 */
static struct uio_info spu1_platform_data = {
	.name = "SPU2DSP1",
	.version = "0",
	.irq = evt2irq(0x1820),
};

static struct resource spu1_resources[] = {
	[0] = {
		.name	= "SPU2DSP1",
		.start	= 0xfe300000,
		.end	= 0xfe3fffff,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device spu1_device = {
	.name		= "uio_pdrv_genirq",
	.id		= 7,
	.dev = {
		.platform_data	= &spu1_platform_data,
	},
	.resource	= spu1_resources,
	.num_resources	= ARRAY_SIZE(spu1_resources),
};

971 972 973 974 975 976 977 978
static struct platform_device *sh7372_early_devices[] __initdata = {
	&scif0_device,
	&scif1_device,
	&scif2_device,
	&scif3_device,
	&scif4_device,
	&scif5_device,
	&scif6_device,
979
	&cmt2_device,
980 981
	&tmu00_device,
	&tmu01_device,
982 983 984
};

static struct platform_device *sh7372_late_devices[] __initdata = {
985 986
	&iic0_device,
	&iic1_device,
987 988 989
	&dma0_device,
	&dma1_device,
	&dma2_device,
990 991
	&usb_dma0_device,
	&usb_dma1_device,
992 993 994 995 996 997 998 999
	&vpu_device,
	&veu0_device,
	&veu1_device,
	&veu2_device,
	&veu3_device,
	&jpu_device,
	&spu0_device,
	&spu1_device,
1000 1001 1002 1003
};

void __init sh7372_add_standard_devices(void)
{
1004
	sh7372_init_pm_domains();
1005

1006 1007
	platform_add_devices(sh7372_early_devices,
			    ARRAY_SIZE(sh7372_early_devices));
1008 1009 1010

	platform_add_devices(sh7372_late_devices,
			    ARRAY_SIZE(sh7372_late_devices));
1011

1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
	rmobile_add_device_to_domain("A3RV", &vpu_device);
	rmobile_add_device_to_domain("A4MP", &spu0_device);
	rmobile_add_device_to_domain("A4MP", &spu1_device);
	rmobile_add_device_to_domain("A3SP", &scif0_device);
	rmobile_add_device_to_domain("A3SP", &scif1_device);
	rmobile_add_device_to_domain("A3SP", &scif2_device);
	rmobile_add_device_to_domain("A3SP", &scif3_device);
	rmobile_add_device_to_domain("A3SP", &scif4_device);
	rmobile_add_device_to_domain("A3SP", &scif5_device);
	rmobile_add_device_to_domain("A3SP", &scif6_device);
	rmobile_add_device_to_domain("A3SP", &iic1_device);
	rmobile_add_device_to_domain("A3SP", &dma0_device);
	rmobile_add_device_to_domain("A3SP", &dma1_device);
	rmobile_add_device_to_domain("A3SP", &dma2_device);
	rmobile_add_device_to_domain("A3SP", &usb_dma0_device);
	rmobile_add_device_to_domain("A3SP", &usb_dma1_device);
	rmobile_add_device_to_domain("A4R", &iic0_device);
	rmobile_add_device_to_domain("A4R", &veu0_device);
	rmobile_add_device_to_domain("A4R", &veu1_device);
	rmobile_add_device_to_domain("A4R", &veu2_device);
	rmobile_add_device_to_domain("A4R", &veu3_device);
	rmobile_add_device_to_domain("A4R", &jpu_device);
	rmobile_add_device_to_domain("A4R", &tmu00_device);
	rmobile_add_device_to_domain("A4R", &tmu01_device);
1036 1037
}

1038 1039 1040 1041 1042 1043
static void __init sh7372_earlytimer_init(void)
{
	sh7372_clock_init();
	shmobile_earlytimer_init();
}

1044 1045 1046 1047
void __init sh7372_add_early_devices(void)
{
	early_platform_add_devices(sh7372_early_devices,
				   ARRAY_SIZE(sh7372_early_devices));
1048 1049 1050

	/* setup early console here as well */
	shmobile_setup_console();
1051 1052 1053

	/* override timer setup with soc-specific code */
	shmobile_timer.init = sh7372_earlytimer_init;
1054
}
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101

#ifdef CONFIG_USE_OF

void __init sh7372_add_early_devices_dt(void)
{
	shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */

	early_platform_add_devices(sh7372_early_devices,
				   ARRAY_SIZE(sh7372_early_devices));

	/* setup early console here as well */
	shmobile_setup_console();
}

static const struct of_dev_auxdata sh7372_auxdata_lookup[] __initconst = {
	{ }
};

void __init sh7372_add_standard_devices_dt(void)
{
	/* clocks are setup late during boot in the case of DT */
	sh7372_clock_init();

	platform_add_devices(sh7372_early_devices,
			    ARRAY_SIZE(sh7372_early_devices));

	of_platform_populate(NULL, of_default_bus_match_table,
			     sh7372_auxdata_lookup, NULL);
}

static const char *sh7372_boards_compat_dt[] __initdata = {
	"renesas,sh7372",
	NULL,
};

DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
	.map_io		= sh7372_map_io,
	.init_early	= sh7372_add_early_devices_dt,
	.nr_irqs	= NR_IRQS_LEGACY,
	.init_irq	= sh7372_init_irq,
	.handle_irq	= shmobile_handle_irq_intc,
	.init_machine	= sh7372_add_standard_devices_dt,
	.timer		= &shmobile_timer,
	.dt_compat	= sh7372_boards_compat_dt,
MACHINE_END

#endif /* CONFIG_USE_OF */