Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[deliverable/linux.git] / arch / arm / mach-shmobile / setup-r8a7790.c
CommitLineData
0468b2d6
MD
1/*
2 * r8a7790 processor support
3 *
4 * Copyright (C) 2013 Renesas Solutions Corp.
5 * Copyright (C) 2013 Magnus Damm
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <linux/irq.h>
0468b2d6
MD
22#include <linux/kernel.h>
23#include <linux/of_platform.h>
43ca9cbb 24#include <linux/platform_data/gpio-rcar.h>
8f5ec0a5 25#include <linux/platform_data/irq-renesas-irqc.h>
99ade1a0
MD
26#include <linux/serial_sci.h>
27#include <linux/sh_timer.h>
0468b2d6
MD
28#include <mach/common.h>
29#include <mach/irqs.h>
30#include <mach/r8a7790.h>
31#include <asm/mach/arch.h>
32
cde214a8 33static const struct resource pfc_resources[] __initconst = {
69e351d0
MD
34 DEFINE_RES_MEM(0xe6060000, 0x250),
35};
36
43ca9cbb 37#define R8A7790_GPIO(idx) \
cde214a8 38static const struct resource r8a7790_gpio##idx##_resources[] __initconst = { \
43ca9cbb
LP
39 DEFINE_RES_MEM(0xe6050000 + 0x1000 * (idx), 0x50), \
40 DEFINE_RES_IRQ(gic_spi(4 + (idx))), \
41}; \
42 \
cde214a8
LP
43static const struct gpio_rcar_config \
44r8a7790_gpio##idx##_platform_data __initconst = { \
43ca9cbb
LP
45 .gpio_base = 32 * (idx), \
46 .irq_base = 0, \
47 .number_of_pins = 32, \
48 .pctl_name = "pfc-r8a7790", \
d93906b8 49 .has_both_edge_trigger = 1, \
43ca9cbb
LP
50}; \
51
52R8A7790_GPIO(0);
53R8A7790_GPIO(1);
54R8A7790_GPIO(2);
55R8A7790_GPIO(3);
56R8A7790_GPIO(4);
57R8A7790_GPIO(5);
58
59#define r8a7790_register_gpio(idx) \
60 platform_device_register_resndata(&platform_bus, "gpio_rcar", idx, \
61 r8a7790_gpio##idx##_resources, \
62 ARRAY_SIZE(r8a7790_gpio##idx##_resources), \
63 &r8a7790_gpio##idx##_platform_data, \
64 sizeof(r8a7790_gpio##idx##_platform_data))
65
69e351d0
MD
66void __init r8a7790_pinmux_init(void)
67{
68 platform_device_register_simple("pfc-r8a7790", -1, pfc_resources,
69 ARRAY_SIZE(pfc_resources));
43ca9cbb
LP
70 r8a7790_register_gpio(0);
71 r8a7790_register_gpio(1);
72 r8a7790_register_gpio(2);
73 r8a7790_register_gpio(3);
74 r8a7790_register_gpio(4);
75 r8a7790_register_gpio(5);
69e351d0
MD
76}
77
55d9fab2
MD
78#define SCIF_COMMON(scif_type, baseaddr, irq) \
79 .type = scif_type, \
80 .mapbase = baseaddr, \
81 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
82 .irqs = SCIx_IRQ_MUXED(irq)
83
84#define SCIFA_DATA(index, baseaddr, irq) \
85[index] = { \
86 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
87 .scbrr_algo_id = SCBRR_ALGO_4, \
88 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
89}
90
91#define SCIFB_DATA(index, baseaddr, irq) \
92[index] = { \
93 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
94 .scbrr_algo_id = SCBRR_ALGO_4, \
95 .scscr = SCSCR_RE | SCSCR_TE, \
96}
97
98#define SCIF_DATA(index, baseaddr, irq) \
99[index] = { \
100 SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
101 .scbrr_algo_id = SCBRR_ALGO_2, \
c972f024 102 .scscr = SCSCR_RE | SCSCR_TE, \
55d9fab2
MD
103}
104
d44f8308
UH
105#define HSCIF_DATA(index, baseaddr, irq) \
106[index] = { \
107 SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \
108 .scbrr_algo_id = SCBRR_ALGO_6, \
109 .scscr = SCSCR_RE | SCSCR_TE, \
110}
111
112enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1,
113 HSCIF0, HSCIF1 };
55d9fab2 114
cde214a8 115static const struct plat_sci_port scif[] __initconst = {
55d9fab2
MD
116 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */
117 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */
118 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */
119 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */
120 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */
121 SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */
122 SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */
123 SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */
d44f8308
UH
124 HSCIF_DATA(HSCIF0, 0xe62c0000, gic_spi(154)), /* HSCIF0 */
125 HSCIF_DATA(HSCIF1, 0xe62c8000, gic_spi(155)), /* HSCIF1 */
55d9fab2
MD
126};
127
128static inline void r8a7790_register_scif(int idx)
129{
130 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
131 sizeof(struct plat_sci_port));
132}
133
cde214a8 134static const struct renesas_irqc_config irqc0_data __initconst = {
8f5ec0a5
MD
135 .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
136};
137
cde214a8 138static const struct resource irqc0_resources[] __initconst = {
8f5ec0a5
MD
139 DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
140 DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
141 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
142 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
143 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
144};
145
146#define r8a7790_register_irqc(idx) \
147 platform_device_register_resndata(&platform_bus, "renesas_irqc", \
148 idx, irqc##idx##_resources, \
149 ARRAY_SIZE(irqc##idx##_resources), \
150 &irqc##idx##_data, \
151 sizeof(struct renesas_irqc_config))
152
cde214a8 153static const struct resource thermal_resources[] __initconst = {
0b8eeba4
SH
154 DEFINE_RES_MEM(0xe61f0000, 0x14),
155 DEFINE_RES_MEM(0xe61f0100, 0x38),
156 DEFINE_RES_IRQ(gic_spi(69)),
157};
158
159#define r8a7790_register_thermal() \
160 platform_device_register_simple("rcar_thermal", -1, \
161 thermal_resources, \
162 ARRAY_SIZE(thermal_resources))
163
cde214a8 164static const struct sh_timer_config cmt00_platform_data __initconst = {
99ade1a0
MD
165 .name = "CMT00",
166 .timer_bit = 0,
167 .clockevent_rating = 80,
168};
169
cde214a8 170static const struct resource cmt00_resources[] __initconst = {
99ade1a0
MD
171 DEFINE_RES_MEM(0xffca0510, 0x0c),
172 DEFINE_RES_MEM(0xffca0500, 0x04),
173 DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */
174};
175
176#define r8a7790_register_cmt(idx) \
177 platform_device_register_resndata(&platform_bus, "sh_cmt", \
178 idx, cmt##idx##_resources, \
179 ARRAY_SIZE(cmt##idx##_resources), \
180 &cmt##idx##_platform_data, \
181 sizeof(struct sh_timer_config))
182
6dace67f 183void __init r8a7790_add_dt_devices(void)
0468b2d6 184{
55d9fab2
MD
185 r8a7790_register_scif(SCIFA0);
186 r8a7790_register_scif(SCIFA1);
187 r8a7790_register_scif(SCIFB0);
188 r8a7790_register_scif(SCIFB1);
189 r8a7790_register_scif(SCIFB2);
190 r8a7790_register_scif(SCIFA2);
191 r8a7790_register_scif(SCIF0);
192 r8a7790_register_scif(SCIF1);
d44f8308
UH
193 r8a7790_register_scif(HSCIF0);
194 r8a7790_register_scif(HSCIF1);
6dace67f
SH
195 r8a7790_register_cmt(00);
196}
197
198void __init r8a7790_add_standard_devices(void)
199{
200 r8a7790_add_dt_devices();
8f5ec0a5 201 r8a7790_register_irqc(0);
0b8eeba4 202 r8a7790_register_thermal();
0468b2d6
MD
203}
204
0efd7faa 205void __init r8a7790_init_early(void)
8333d8c9
MD
206{
207#ifndef CONFIG_ARM_ARCH_TIMER
208 shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
209#endif
210}
211
0468b2d6 212#ifdef CONFIG_USE_OF
0468b2d6 213
cde214a8 214static const char * const r8a7790_boards_compat_dt[] __initconst = {
0468b2d6
MD
215 "renesas,r8a7790",
216 NULL,
217};
218
219DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
ad09cb83 220 .smp = smp_ops(r8a7790_smp_ops),
0efd7faa 221 .init_early = r8a7790_init_early,
50c517d9 222 .init_time = rcar_gen2_timer_init,
0468b2d6
MD
223 .dt_compat = r8a7790_boards_compat_dt,
224MACHINE_END
225#endif /* CONFIG_USE_OF */
This page took 0.077238 seconds and 5 git commands to generate.