setup-sh7372.c 23.9 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/uio_driver.h>
26 27 28 29
#include <linux/delay.h>
#include <linux/input.h>
#include <linux/io.h>
#include <linux/serial_sci.h>
30
#include <linux/sh_dma.h>
31 32
#include <linux/sh_intc.h>
#include <linux/sh_timer.h>
33
#include <linux/pm_domain.h>
34
#include <mach/hardware.h>
35
#include <mach/sh7372.h>
36 37 38
#include <asm/mach-types.h>
#include <asm/mach/arch.h>

39
/* SCIFA0 */
40 41 42
static struct plat_sci_port scif0_platform_data = {
	.mapbase	= 0xe6c40000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
43 44
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
45
	.type		= PORT_SCIFA,
46 47
	.irqs		= { evt2irq(0x0c00), evt2irq(0x0c00),
			    evt2irq(0x0c00), evt2irq(0x0c00) },
48 49 50 51 52 53 54 55 56 57
};

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

58
/* SCIFA1 */
59 60 61
static struct plat_sci_port scif1_platform_data = {
	.mapbase	= 0xe6c50000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
62 63
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
64
	.type		= PORT_SCIFA,
65 66
	.irqs		= { evt2irq(0x0c20), evt2irq(0x0c20),
			    evt2irq(0x0c20), evt2irq(0x0c20) },
67 68 69 70 71 72 73 74 75 76
};

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

77
/* SCIFA2 */
78 79 80
static struct plat_sci_port scif2_platform_data = {
	.mapbase	= 0xe6c60000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
81 82
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
83
	.type		= PORT_SCIFA,
84 85
	.irqs		= { evt2irq(0x0c40), evt2irq(0x0c40),
			    evt2irq(0x0c40), evt2irq(0x0c40) },
86 87 88 89 90 91 92 93 94 95
};

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

96
/* SCIFA3 */
97 98 99
static struct plat_sci_port scif3_platform_data = {
	.mapbase	= 0xe6c70000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
100 101
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
102
	.type		= PORT_SCIFA,
103 104
	.irqs		= { evt2irq(0x0c60), evt2irq(0x0c60),
			    evt2irq(0x0c60), evt2irq(0x0c60) },
105 106 107 108 109 110 111 112 113 114
};

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

115
/* SCIFA4 */
116 117 118
static struct plat_sci_port scif4_platform_data = {
	.mapbase	= 0xe6c80000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
119 120
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
121
	.type		= PORT_SCIFA,
122 123
	.irqs		= { evt2irq(0x0d20), evt2irq(0x0d20),
			    evt2irq(0x0d20), evt2irq(0x0d20) },
124 125 126 127 128 129 130 131 132 133
};

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

134
/* SCIFA5 */
135 136 137
static struct plat_sci_port scif5_platform_data = {
	.mapbase	= 0xe6cb0000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
138 139
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
140
	.type		= PORT_SCIFA,
141 142
	.irqs		= { evt2irq(0x0d40), evt2irq(0x0d40),
			    evt2irq(0x0d40), evt2irq(0x0d40) },
143 144 145 146 147 148 149 150 151 152
};

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

153
/* SCIFB */
154 155 156
static struct plat_sci_port scif6_platform_data = {
	.mapbase	= 0xe6c30000,
	.flags		= UPF_BOOT_AUTOCONF,
P
Paul Mundt 已提交
157 158
	.scscr		= SCSCR_RE | SCSCR_TE,
	.scbrr_algo_id	= SCBRR_ALGO_4,
159
	.type		= PORT_SCIFB,
160 161
	.irqs		= { evt2irq(0x0d60), evt2irq(0x0d60),
			    evt2irq(0x0d60), evt2irq(0x0d60) },
162 163 164 165 166 167 168 169 170 171
};

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

172
/* CMT */
173 174 175 176
static struct sh_timer_config cmt2_platform_data = {
	.name = "CMT2",
	.channel_offset = 0x40,
	.timer_bit = 5,
177 178 179 180
	.clockevent_rating = 125,
	.clocksource_rating = 125,
};

181
static struct resource cmt2_resources[] = {
182
	[0] = {
183 184 185
		.name	= "CMT2",
		.start	= 0xe6130040,
		.end	= 0xe613004b,
186 187 188
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
189
		.start	= evt2irq(0x0b80), /* CMT2 */
190 191 192 193
		.flags	= IORESOURCE_IRQ,
	},
};

194
static struct platform_device cmt2_device = {
195
	.name		= "sh_cmt",
196
	.id		= 2,
197
	.dev = {
198
		.platform_data	= &cmt2_platform_data,
199
	},
200 201
	.resource	= cmt2_resources,
	.num_resources	= ARRAY_SIZE(cmt2_resources),
202 203
};

204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 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
/* 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),
};

265 266 267 268 269 270 271 272 273
/* I2C */
static struct resource iic0_resources[] = {
	[0] = {
		.name	= "IIC0",
		.start  = 0xFFF20000,
		.end    = 0xFFF20425 - 1,
		.flags  = IORESOURCE_MEM,
	},
	[1] = {
274 275
		.start  = intcs_evt2irq(0xe00), /* IIC0_ALI0 */
		.end    = intcs_evt2irq(0xe60), /* IIC0_DTEI0 */
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
		.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] = {
295 296
		.start  = evt2irq(0x780), /* IIC1_ALI1 */
		.end    = evt2irq(0x7e0), /* IIC1_DTEI1 */
297 298 299 300 301 302 303 304 305 306 307
		.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,
};

308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
/* DMA */
/* Transmit sizes and respective CHCR register values */
enum {
	XMIT_SZ_8BIT		= 0,
	XMIT_SZ_16BIT		= 1,
	XMIT_SZ_32BIT		= 2,
	XMIT_SZ_64BIT		= 7,
	XMIT_SZ_128BIT		= 3,
	XMIT_SZ_256BIT		= 4,
	XMIT_SZ_512BIT		= 5,
};

/* log2(size / 8) - used to calculate number of transfers */
#define TS_SHIFT {			\
	[XMIT_SZ_8BIT]		= 0,	\
	[XMIT_SZ_16BIT]		= 1,	\
	[XMIT_SZ_32BIT]		= 2,	\
	[XMIT_SZ_64BIT]		= 3,	\
	[XMIT_SZ_128BIT]	= 4,	\
	[XMIT_SZ_256BIT]	= 5,	\
	[XMIT_SZ_512BIT]	= 6,	\
}

#define TS_INDEX2VAL(i) ((((i) & 3) << 3) | \
			 (((i) & 0xc) << (20 - 2)))

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

448 449
#define SH7372_CHCLR 0x220

450 451 452 453 454
static const struct sh_dmae_channel sh7372_dmae_channels[] = {
	{
		.offset = 0,
		.dmars = 0,
		.dmars_bit = 0,
455
		.chclr_offset = SH7372_CHCLR + 0,
456 457 458 459
	}, {
		.offset = 0x10,
		.dmars = 0,
		.dmars_bit = 8,
460
		.chclr_offset = SH7372_CHCLR + 0x10,
461 462 463 464
	}, {
		.offset = 0x20,
		.dmars = 4,
		.dmars_bit = 0,
465
		.chclr_offset = SH7372_CHCLR + 0x20,
466 467 468 469
	}, {
		.offset = 0x30,
		.dmars = 4,
		.dmars_bit = 8,
470
		.chclr_offset = SH7372_CHCLR + 0x30,
471 472 473 474
	}, {
		.offset = 0x50,
		.dmars = 8,
		.dmars_bit = 0,
475
		.chclr_offset = SH7372_CHCLR + 0x50,
476 477 478 479
	}, {
		.offset = 0x60,
		.dmars = 8,
		.dmars_bit = 8,
480
		.chclr_offset = SH7372_CHCLR + 0x60,
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
	}
};

static const unsigned int ts_shift[] = TS_SHIFT;

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),
	.ts_low_shift	= 3,
	.ts_low_mask	= 0x18,
	.ts_high_shift	= (20 - 2),	/* 2 bits for shifted low TS */
	.ts_high_mask	= 0x00300000,
	.ts_shift	= ts_shift,
	.ts_shift_num	= ARRAY_SIZE(ts_shift),
	.dmaor_init	= DMAOR_DME,
498
	.chclr_present	= 1,
499 500 501 502 503 504 505
};

/* Resource order important! */
static struct resource sh7372_dmae0_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xfe008020,
506
		.end	= 0xfe00828f,
507 508 509 510 511 512 513 514 515
		.flags	= IORESOURCE_MEM,
	},
	{
		/* DMARSx */
		.start	= 0xfe009000,
		.end	= 0xfe00900b,
		.flags	= IORESOURCE_MEM,
	},
	{
516
		.name	= "error_irq",
517 518
		.start	= evt2irq(0x20c0),
		.end	= evt2irq(0x20c0),
519 520 521 522
		.flags	= IORESOURCE_IRQ,
	},
	{
		/* IRQ for channels 0-5 */
523 524
		.start	= evt2irq(0x2000),
		.end	= evt2irq(0x20a0),
525 526 527 528 529 530 531 532 533
		.flags	= IORESOURCE_IRQ,
	},
};

/* Resource order important! */
static struct resource sh7372_dmae1_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xfe018020,
534
		.end	= 0xfe01828f,
535 536 537 538 539 540 541 542 543
		.flags	= IORESOURCE_MEM,
	},
	{
		/* DMARSx */
		.start	= 0xfe019000,
		.end	= 0xfe01900b,
		.flags	= IORESOURCE_MEM,
	},
	{
544
		.name	= "error_irq",
545 546
		.start	= evt2irq(0x21c0),
		.end	= evt2irq(0x21c0),
547 548 549 550
		.flags	= IORESOURCE_IRQ,
	},
	{
		/* IRQ for channels 0-5 */
551 552
		.start	= evt2irq(0x2100),
		.end	= evt2irq(0x21a0),
553 554 555 556 557 558 559 560 561
		.flags	= IORESOURCE_IRQ,
	},
};

/* Resource order important! */
static struct resource sh7372_dmae2_resources[] = {
	{
		/* Channel registers and DMAOR */
		.start	= 0xfe028020,
562
		.end	= 0xfe02828f,
563 564 565 566 567 568 569 570 571
		.flags	= IORESOURCE_MEM,
	},
	{
		/* DMARSx */
		.start	= 0xfe029000,
		.end	= 0xfe02900b,
		.flags	= IORESOURCE_MEM,
	},
	{
572
		.name	= "error_irq",
573 574
		.start	= evt2irq(0x22c0),
		.end	= evt2irq(0x22c0),
575 576 577 578
		.flags	= IORESOURCE_IRQ,
	},
	{
		/* IRQ for channels 0-5 */
579 580
		.start	= evt2irq(0x2200),
		.end	= evt2irq(0x22a0),
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614
		.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,
	},
};

615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 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 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 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
/*
 * USB-DMAC
 */

unsigned int usbts_shift[] = {3, 4, 5};

enum {
	XMIT_SZ_8BYTE		= 0,
	XMIT_SZ_16BYTE		= 1,
	XMIT_SZ_32BYTE		= 2,
};

#define USBTS_INDEX2VAL(i) (((i) & 3) << 6)

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,
		.chcr		= USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
	}, {
		.slave_id	= SHDMA_SLAVE_USB0_RX,
		.chcr		= USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
	},
};

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),
	.ts_low_shift	= 6,
	.ts_low_mask	= 0xc0,
	.ts_high_shift	= 0,
	.ts_high_mask	= 0,
	.ts_shift	= usbts_shift,
	.ts_shift_num	= ARRAY_SIZE(usbts_shift),
	.dmaor_init	= DMAOR_DME,
	.chcr_offset	= 0x14,
	.chcr_ie_bit	= 1 << 5,
	.dmaor_is_32bit	= 1,
	.needs_tend_set	= 1,
	.no_dmars	= 1,
};

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,
		.chcr		= USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
	}, {
		.slave_id	= SHDMA_SLAVE_USB1_RX,
		.chcr		= USBTS_INDEX2VAL(XMIT_SZ_8BYTE),
	},
};

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),
	.ts_low_shift	= 6,
	.ts_low_mask	= 0xc0,
	.ts_high_shift	= 0,
	.ts_high_mask	= 0,
	.ts_shift	= usbts_shift,
	.ts_shift_num	= ARRAY_SIZE(usbts_shift),
	.dmaor_init	= DMAOR_DME,
	.chcr_offset	= 0x14,
	.chcr_ie_bit	= 1 << 5,
	.dmaor_is_32bit	= 1,
	.needs_tend_set	= 1,
	.no_dmars	= 1,
};

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,
	},
};

759 760 761 762 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
/* 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),
};

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

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

void __init sh7372_add_standard_devices(void)
{
1000
	sh7372_init_pm_domain(&sh7372_a4lc);
1001
	sh7372_init_pm_domain(&sh7372_a4mp);
1002
	sh7372_init_pm_domain(&sh7372_d4);
1003
	sh7372_init_pm_domain(&sh7372_a4r);
1004
	sh7372_init_pm_domain(&sh7372_a3rv);
1005
	sh7372_init_pm_domain(&sh7372_a3ri);
1006
	sh7372_init_pm_domain(&sh7372_a4s);
1007
	sh7372_init_pm_domain(&sh7372_a3sp);
1008
	sh7372_init_pm_domain(&sh7372_a3sg);
1009

1010
	sh7372_pm_add_subdomain(&sh7372_a4lc, &sh7372_a3rv);
1011
	sh7372_pm_add_subdomain(&sh7372_a4r, &sh7372_a4lc);
1012

1013 1014 1015
	sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sg);
	sh7372_pm_add_subdomain(&sh7372_a4s, &sh7372_a3sp);

1016 1017
	platform_add_devices(sh7372_early_devices,
			    ARRAY_SIZE(sh7372_early_devices));
1018 1019 1020

	platform_add_devices(sh7372_late_devices,
			    ARRAY_SIZE(sh7372_late_devices));
1021 1022

	sh7372_add_device_to_domain(&sh7372_a3rv, &vpu_device);
1023 1024
	sh7372_add_device_to_domain(&sh7372_a4mp, &spu0_device);
	sh7372_add_device_to_domain(&sh7372_a4mp, &spu1_device);
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037
	sh7372_add_device_to_domain(&sh7372_a3sp, &scif0_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &scif1_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &scif2_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &scif3_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &scif4_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &scif5_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &scif6_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &iic1_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &dma0_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &dma1_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &dma2_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma0_device);
	sh7372_add_device_to_domain(&sh7372_a3sp, &usb_dma1_device);
1038 1039 1040 1041 1042 1043
	sh7372_add_device_to_domain(&sh7372_a4r, &iic0_device);
	sh7372_add_device_to_domain(&sh7372_a4r, &veu0_device);
	sh7372_add_device_to_domain(&sh7372_a4r, &veu1_device);
	sh7372_add_device_to_domain(&sh7372_a4r, &veu2_device);
	sh7372_add_device_to_domain(&sh7372_a4r, &veu3_device);
	sh7372_add_device_to_domain(&sh7372_a4r, &jpu_device);
1044 1045
	sh7372_add_device_to_domain(&sh7372_a4r, &tmu00_device);
	sh7372_add_device_to_domain(&sh7372_a4r, &tmu01_device);
1046 1047 1048 1049 1050 1051 1052
}

void __init sh7372_add_early_devices(void)
{
	early_platform_add_devices(sh7372_early_devices,
				   ARRAY_SIZE(sh7372_early_devices));
}