ARM: shmobile: Select GPIO in case of the r8a7791 SoC
[deliverable/linux.git] / arch / arm / mach-shmobile / setup-r8a7791.c
CommitLineData
0d0771ab
HN
1/*
2 * r8a7791 processor support
3 *
4 * Copyright (C) 2013 Renesas Electronics Corporation
5 * Copyright (C) 2013 Renesas Solutions Corp.
6 * Copyright (C) 2013 Magnus Damm
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <linux/irq.h>
23#include <linux/kernel.h>
24#include <linux/of_platform.h>
454d320c 25#include <linux/platform_data/irq-renesas-irqc.h>
e6491d08 26#include <linux/serial_sci.h>
1bebd72a 27#include <linux/sh_timer.h>
0d0771ab 28#include <mach/common.h>
e6491d08 29#include <mach/irqs.h>
0d0771ab 30#include <mach/r8a7791.h>
cd8344f4 31#include <mach/rcar-gen2.h>
0d0771ab
HN
32#include <asm/mach/arch.h>
33
35040127
MD
34static const struct resource pfc_resources[] __initconst = {
35 DEFINE_RES_MEM(0xe6060000, 0x250),
36};
37
38#define r8a7791_register_pfc() \
39 platform_device_register_simple("pfc-r8a7791", -1, pfc_resources, \
40 ARRAY_SIZE(pfc_resources))
41
42void __init r8a7791_pinmux_init(void)
43{
44 r8a7791_register_pfc();
45}
46
e6491d08
YF
47#define SCIF_COMMON(scif_type, baseaddr, irq) \
48 .type = scif_type, \
49 .mapbase = baseaddr, \
50 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
51 .irqs = SCIx_IRQ_MUXED(irq)
52
53#define SCIFA_DATA(index, baseaddr, irq) \
54[index] = { \
55 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
56 .scbrr_algo_id = SCBRR_ALGO_4, \
57 .scscr = SCSCR_RE | SCSCR_TE, \
58}
59
60#define SCIFB_DATA(index, baseaddr, irq) \
61[index] = { \
62 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
63 .scbrr_algo_id = SCBRR_ALGO_4, \
64 .scscr = SCSCR_RE | SCSCR_TE, \
65}
66
67#define SCIF_DATA(index, baseaddr, irq) \
68[index] = { \
69 SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
70 .scbrr_algo_id = SCBRR_ALGO_2, \
71 .scscr = SCSCR_RE | SCSCR_TE, \
72}
73
74#define HSCIF_DATA(index, baseaddr, irq) \
75[index] = { \
76 SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \
77 .scbrr_algo_id = SCBRR_ALGO_6, \
78 .scscr = SCSCR_RE | SCSCR_TE, \
79}
80
81enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1,
82 SCIF2, SCIF3, SCIF4, SCIF5, SCIFA3, SCIFA4, SCIFA5 };
83
84static const struct plat_sci_port scif[] __initconst = {
85 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */
86 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */
87 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */
88 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */
89 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */
90 SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */
91 SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */
92 SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */
93 SCIF_DATA(SCIF2, 0xe6e58000, gic_spi(22)), /* SCIF2 */
94 SCIF_DATA(SCIF3, 0xe6ea8000, gic_spi(23)), /* SCIF3 */
95 SCIF_DATA(SCIF4, 0xe6ee0000, gic_spi(24)), /* SCIF4 */
96 SCIF_DATA(SCIF5, 0xe6ee8000, gic_spi(25)), /* SCIF5 */
97 SCIFA_DATA(SCIFA3, 0xe6c70000, gic_spi(29)), /* SCIFA3 */
98 SCIFA_DATA(SCIFA4, 0xe6c78000, gic_spi(30)), /* SCIFA4 */
99 SCIFA_DATA(SCIFA5, 0xe6c80000, gic_spi(31)), /* SCIFA5 */
100};
101
102static inline void r8a7791_register_scif(int idx)
103{
104 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
105 sizeof(struct plat_sci_port));
106}
107
1bebd72a
MD
108static const struct sh_timer_config cmt00_platform_data __initconst = {
109 .name = "CMT00",
110 .timer_bit = 0,
111 .clockevent_rating = 80,
112};
113
114static const struct resource cmt00_resources[] __initconst = {
115 DEFINE_RES_MEM(0xffca0510, 0x0c),
116 DEFINE_RES_MEM(0xffca0500, 0x04),
117 DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */
118};
119
120#define r8a7791_register_cmt(idx) \
121 platform_device_register_resndata(&platform_bus, "sh_cmt", \
122 idx, cmt##idx##_resources, \
123 ARRAY_SIZE(cmt##idx##_resources), \
124 &cmt##idx##_platform_data, \
125 sizeof(struct sh_timer_config))
126
454d320c
MD
127static struct renesas_irqc_config irqc0_data = {
128 .irq_base = irq_pin(0), /* IRQ0 -> IRQ9 */
129};
130
131static struct resource irqc0_resources[] = {
132 DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
133 DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
134 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
135 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
136 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
137 DEFINE_RES_IRQ(gic_spi(12)), /* IRQ4 */
138 DEFINE_RES_IRQ(gic_spi(13)), /* IRQ5 */
139 DEFINE_RES_IRQ(gic_spi(14)), /* IRQ6 */
140 DEFINE_RES_IRQ(gic_spi(15)), /* IRQ7 */
141 DEFINE_RES_IRQ(gic_spi(16)), /* IRQ8 */
142 DEFINE_RES_IRQ(gic_spi(17)), /* IRQ9 */
143};
144
145#define r8a7791_register_irqc(idx) \
146 platform_device_register_resndata(&platform_bus, "renesas_irqc", \
147 idx, irqc##idx##_resources, \
148 ARRAY_SIZE(irqc##idx##_resources), \
149 &irqc##idx##_data, \
150 sizeof(struct renesas_irqc_config))
151
e6491d08
YF
152void __init r8a7791_add_dt_devices(void)
153{
154 r8a7791_register_scif(SCIFA0);
155 r8a7791_register_scif(SCIFA1);
156 r8a7791_register_scif(SCIFB0);
157 r8a7791_register_scif(SCIFB1);
158 r8a7791_register_scif(SCIFB2);
159 r8a7791_register_scif(SCIFA2);
160 r8a7791_register_scif(SCIF0);
161 r8a7791_register_scif(SCIF1);
162 r8a7791_register_scif(SCIF2);
163 r8a7791_register_scif(SCIF3);
164 r8a7791_register_scif(SCIF4);
165 r8a7791_register_scif(SCIF5);
166 r8a7791_register_scif(SCIFA3);
167 r8a7791_register_scif(SCIFA4);
168 r8a7791_register_scif(SCIFA5);
1bebd72a
MD
169 r8a7791_register_cmt(00);
170}
171
4275881f
MD
172void __init r8a7791_add_standard_devices(void)
173{
174 r8a7791_add_dt_devices();
454d320c 175 r8a7791_register_irqc(0);
4275881f
MD
176}
177
1bebd72a
MD
178void __init r8a7791_init_early(void)
179{
180#ifndef CONFIG_ARM_ARCH_TIMER
181 shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
182#endif
e6491d08
YF
183}
184
0d0771ab
HN
185#ifdef CONFIG_USE_OF
186static const char *r8a7791_boards_compat_dt[] __initdata = {
187 "renesas,r8a7791",
188 NULL,
189};
190
191DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)")
687c27b0 192 .smp = smp_ops(r8a7791_smp_ops),
1bebd72a 193 .init_early = r8a7791_init_early,
cd8344f4 194 .init_time = rcar_gen2_timer_init,
0d0771ab
HN
195 .dt_compat = r8a7791_boards_compat_dt,
196MACHINE_END
197#endif /* CONFIG_USE_OF */
This page took 0.040955 seconds and 5 git commands to generate.