setup-sh7705.c 5.3 KB
Newer Older
1 2 3
/*
 * SH7705 Setup
 *
4
 *  Copyright (C) 2006 - 2009  Paul Mundt
5
 *  Copyright (C) 2007  Nobuhiro Iwamatsu
6 7 8 9 10 11 12
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 */
#include <linux/platform_device.h>
#include <linux/init.h>
M
Magnus Damm 已提交
13
#include <linux/irq.h>
14
#include <linux/serial.h>
15
#include <linux/serial_sci.h>
M
Magnus Damm 已提交
16
#include <linux/sh_timer.h>
17
#include <asm/rtc.h>
18

19
enum {
M
Magnus Damm 已提交
20 21 22 23 24
	UNUSED = 0,

	/* interrupt sources */
	IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
	PINT07, PINT815,
25 26 27

	DMAC, SCIF0, SCIF2, ADC_ADI, USB,

M
Magnus Damm 已提交
28
	TPU0, TPU1, TPU2, TPU3,
29
	TMU0, TMU1, TMU2,
M
Magnus Damm 已提交
30

31
	RTC, WDT, REF_RCMI,
M
Magnus Damm 已提交
32 33
};

34
static struct intc_vect vectors[] __initdata = {
35
	/* IRQ0->5 are handled in setup-sh3.c */
M
Magnus Damm 已提交
36
	INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
37 38 39 40 41 42
	INTC_VECT(DMAC, 0x800), INTC_VECT(DMAC, 0x820),
	INTC_VECT(DMAC, 0x840), INTC_VECT(DMAC, 0x860),
	INTC_VECT(SCIF0, 0x880), INTC_VECT(SCIF0, 0x8a0),
	INTC_VECT(SCIF0, 0x8e0),
	INTC_VECT(SCIF2, 0x900), INTC_VECT(SCIF2, 0x920),
	INTC_VECT(SCIF2, 0x960),
M
Magnus Damm 已提交
43
	INTC_VECT(ADC_ADI, 0x980),
44
	INTC_VECT(USB, 0xa20), INTC_VECT(USB, 0xa40),
M
Magnus Damm 已提交
45
	INTC_VECT(TPU0, 0xc00), INTC_VECT(TPU1, 0xc20),
46
	INTC_VECT(TPU2, 0xc80), INTC_VECT(TPU3, 0xca0),
M
Magnus Damm 已提交
47
	INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
48 49 50
	INTC_VECT(TMU2, 0x440), INTC_VECT(TMU2, 0x460),
	INTC_VECT(RTC, 0x480), INTC_VECT(RTC, 0x4a0),
	INTC_VECT(RTC, 0x4c0),
M
Magnus Damm 已提交
51 52 53 54
	INTC_VECT(WDT, 0x560),
	INTC_VECT(REF_RCMI, 0x580),
};

55
static struct intc_prio_reg prio_registers[] __initdata = {
56 57 58 59 60 61 62 63
	{ 0xfffffee2, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2, RTC } },
	{ 0xfffffee4, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, 0, 0 } },
	{ 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
	{ 0xa4000018, 0, 16, 4, /* IPRD */ { PINT07, PINT815, IRQ5, IRQ4 } },
	{ 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC, SCIF0, SCIF2, ADC_ADI } },
	{ 0xa4080000, 0, 16, 4, /* IPRF */ { 0, 0, USB } },
	{ 0xa4080002, 0, 16, 4, /* IPRG */ { TPU0, TPU1 } },
	{ 0xa4080004, 0, 16, 4, /* IPRH */ { TPU2, TPU3 } },
M
Magnus Damm 已提交
64 65 66

};

67
static DECLARE_INTC_DESC(intc_desc, "sh7705", vectors, NULL,
68
			 NULL, prio_registers, NULL);
M
Magnus Damm 已提交
69

70 71
static struct plat_sci_port sci_platform_data[] = {
	{
72
		.mapbase	= 0xa4410000,
73 74
		.flags		= UPF_BOOT_AUTOCONF,
		.type		= PORT_SCIF,
75
		.irqs		= { 56, 56, 56 },
76
	}, {
77
		.mapbase	= 0xa4400000,
78 79
		.flags		= UPF_BOOT_AUTOCONF,
		.type		= PORT_SCIF,
80
		.irqs		= { 52, 52, 52 },
81 82 83 84 85 86 87 88 89 90 91 92 93
	}, {
		.flags = 0,
	}
};

static struct platform_device sci_device = {
	.name		= "sh-sci",
	.id		= -1,
	.dev		= {
		.platform_data	= sci_platform_data,
	},
};

M
Magnus Damm 已提交
94 95 96 97 98 99 100 101 102 103 104 105
static struct resource rtc_resources[] = {
	[0] =	{
		.start	= 0xfffffec0,
		.end	= 0xfffffec0 + 0x1e,
		.flags  = IORESOURCE_IO,
	},
	[1] =	{
		.start  = 20,
		.flags	= IORESOURCE_IRQ,
	},
};

106 107 108 109
static struct sh_rtc_platform_info rtc_info = {
	.capabilities	= RTC_CAP_4_DIGIT_YEAR,
};

M
Magnus Damm 已提交
110 111 112 113 114
static struct platform_device rtc_device = {
	.name		= "sh-rtc",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(rtc_resources),
	.resource	= rtc_resources,
115 116 117
	.dev		= {
		.platform_data = &rtc_info,
	},
M
Magnus Damm 已提交
118 119
};

M
Magnus Damm 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
static struct sh_timer_config tmu0_platform_data = {
	.name = "TMU0",
	.channel_offset = 0x02,
	.timer_bit = 0,
	.clk = "module_clk",
	.clockevent_rating = 200,
};

static struct resource tmu0_resources[] = {
	[0] = {
		.name	= "TMU0",
		.start	= 0xfffffe94,
		.end	= 0xfffffe9f,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= 16,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device tmu0_device = {
	.name		= "sh_tmu",
	.id		= 0,
	.dev = {
		.platform_data	= &tmu0_platform_data,
	},
	.resource	= tmu0_resources,
	.num_resources	= ARRAY_SIZE(tmu0_resources),
};

static struct sh_timer_config tmu1_platform_data = {
	.name = "TMU1",
	.channel_offset = 0xe,
	.timer_bit = 1,
	.clk = "module_clk",
	.clocksource_rating = 200,
};

static struct resource tmu1_resources[] = {
	[0] = {
		.name	= "TMU1",
		.start	= 0xfffffea0,
		.end	= 0xfffffeab,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= 17,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device tmu1_device = {
	.name		= "sh_tmu",
	.id		= 1,
	.dev = {
		.platform_data	= &tmu1_platform_data,
	},
	.resource	= tmu1_resources,
	.num_resources	= ARRAY_SIZE(tmu1_resources),
};

static struct sh_timer_config tmu2_platform_data = {
	.name = "TMU2",
	.channel_offset = 0x1a,
	.timer_bit = 2,
	.clk = "module_clk",
};

static struct resource tmu2_resources[] = {
	[0] = {
		.name	= "TMU2",
		.start	= 0xfffffeac,
		.end	= 0xfffffebb,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= 18,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device tmu2_device = {
	.name		= "sh_tmu",
	.id		= 2,
	.dev = {
		.platform_data	= &tmu2_platform_data,
	},
	.resource	= tmu2_resources,
	.num_resources	= ARRAY_SIZE(tmu2_resources),
};

212
static struct platform_device *sh7705_devices[] __initdata = {
M
Magnus Damm 已提交
213 214 215
	&tmu0_device,
	&tmu1_device,
	&tmu2_device,
216
	&sci_device,
M
Magnus Damm 已提交
217
	&rtc_device,
218 219 220 221 222 223 224 225
};

static int __init sh7705_devices_setup(void)
{
	return platform_add_devices(sh7705_devices,
				    ARRAY_SIZE(sh7705_devices));
}
__initcall(sh7705_devices_setup);
226

M
Magnus Damm 已提交
227 228 229 230 231 232 233 234 235 236 237 238
static struct platform_device *sh7705_early_devices[] __initdata = {
	&tmu0_device,
	&tmu1_device,
	&tmu2_device,
};

void __init plat_early_device_setup(void)
{
	early_platform_add_devices(sh7705_early_devices,
				   ARRAY_SIZE(sh7705_early_devices));
}

239
void __init plat_irq_setup(void)
240
{
M
Magnus Damm 已提交
241
	register_intc_controller(&intc_desc);
242
	plat_irq_setup_sh3();
243
}