ARM: shmobile: Use shmobile_init_delay() on r7s72100
[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 26#include <linux/serial_sci.h>
2c578a1b 27#include <linux/sh_dma.h>
99ade1a0 28#include <linux/sh_timer.h>
0468b2d6
MD
29#include <mach/r8a7790.h>
30#include <asm/mach/arch.h>
fd44aa5e 31#include "common.h"
74ac0de8 32#include "dma-register.h"
b6bab126 33#include "irqs.h"
62872989 34#include "rcar-gen2.h"
0468b2d6 35
2c578a1b
KM
36/* Audio-DMAC */
37#define AUDIO_DMAC_SLAVE(_id, _addr, t, r) \
38{ \
39 .slave_id = AUDIO_DMAC_SLAVE_## _id ##_TX, \
40 .addr = _addr + 0x8, \
41 .chcr = CHCR_TX(XMIT_SZ_32BIT), \
42 .mid_rid = t, \
43}, { \
44 .slave_id = AUDIO_DMAC_SLAVE_## _id ##_RX, \
45 .addr = _addr + 0xc, \
46 .chcr = CHCR_RX(XMIT_SZ_32BIT), \
47 .mid_rid = r, \
48}
49
50static const struct sh_dmae_slave_config r8a7790_audio_dmac_slaves[] = {
51 AUDIO_DMAC_SLAVE(SSI0, 0xec241000, 0x01, 0x02),
52 AUDIO_DMAC_SLAVE(SSI1, 0xec241040, 0x03, 0x04),
53 AUDIO_DMAC_SLAVE(SSI2, 0xec241080, 0x05, 0x06),
54 AUDIO_DMAC_SLAVE(SSI3, 0xec2410c0, 0x07, 0x08),
55 AUDIO_DMAC_SLAVE(SSI4, 0xec241100, 0x09, 0x0a),
56 AUDIO_DMAC_SLAVE(SSI5, 0xec241140, 0x0b, 0x0c),
57 AUDIO_DMAC_SLAVE(SSI6, 0xec241180, 0x0d, 0x0e),
58 AUDIO_DMAC_SLAVE(SSI7, 0xec2411c0, 0x0f, 0x10),
59 AUDIO_DMAC_SLAVE(SSI8, 0xec241200, 0x11, 0x12),
60 AUDIO_DMAC_SLAVE(SSI9, 0xec241240, 0x13, 0x14),
61};
62
63#define DMAE_CHANNEL(a, b) \
64{ \
65 .offset = (a) - 0x20, \
66 .dmars = (a) - 0x20 + 0x40, \
67 .chclr_bit = (b), \
68 .chclr_offset = 0x80 - 0x20, \
69}
70
71static const struct sh_dmae_channel r8a7790_audio_dmac_channels[] = {
72 DMAE_CHANNEL(0x8000, 0),
73 DMAE_CHANNEL(0x8080, 1),
74 DMAE_CHANNEL(0x8100, 2),
75 DMAE_CHANNEL(0x8180, 3),
76 DMAE_CHANNEL(0x8200, 4),
77 DMAE_CHANNEL(0x8280, 5),
78 DMAE_CHANNEL(0x8300, 6),
79 DMAE_CHANNEL(0x8380, 7),
80 DMAE_CHANNEL(0x8400, 8),
81 DMAE_CHANNEL(0x8480, 9),
82 DMAE_CHANNEL(0x8500, 10),
83 DMAE_CHANNEL(0x8580, 11),
84 DMAE_CHANNEL(0x8600, 12),
85};
86
87static struct sh_dmae_pdata r8a7790_audio_dmac_platform_data = {
88 .slave = r8a7790_audio_dmac_slaves,
89 .slave_num = ARRAY_SIZE(r8a7790_audio_dmac_slaves),
90 .channel = r8a7790_audio_dmac_channels,
91 .channel_num = ARRAY_SIZE(r8a7790_audio_dmac_channels),
92 .ts_low_shift = TS_LOW_SHIFT,
93 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
94 .ts_high_shift = TS_HI_SHIFT,
95 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
96 .ts_shift = dma_ts_shift,
97 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
98 .dmaor_init = DMAOR_DME,
99 .chclr_present = 1,
100 .chclr_bitwise = 1,
101};
102
103static struct resource r8a7790_audio_dmac_resources[] = {
104 /* Channel registers and DMAOR for low */
105 DEFINE_RES_MEM(0xec700020, 0x8663 - 0x20),
106 DEFINE_RES_IRQ(gic_spi(346)),
107 DEFINE_RES_NAMED(gic_spi(320), 13, NULL, IORESOURCE_IRQ),
108
109 /* Channel registers and DMAOR for hi */
110 DEFINE_RES_MEM(0xec720020, 0x8663 - 0x20), /* hi */
111 DEFINE_RES_IRQ(gic_spi(347)),
112 DEFINE_RES_NAMED(gic_spi(333), 13, NULL, IORESOURCE_IRQ),
113};
114
115#define r8a7790_register_audio_dmac(id) \
116 platform_device_register_resndata( \
117 &platform_bus, "sh-dma-engine", id, \
118 &r8a7790_audio_dmac_resources[id * 3], 3, \
119 &r8a7790_audio_dmac_platform_data, \
120 sizeof(r8a7790_audio_dmac_platform_data))
121
cde214a8 122static const struct resource pfc_resources[] __initconst = {
69e351d0
MD
123 DEFINE_RES_MEM(0xe6060000, 0x250),
124};
125
8d0b3bf7
MD
126#define r8a7790_register_pfc() \
127 platform_device_register_simple("pfc-r8a7790", -1, pfc_resources, \
128 ARRAY_SIZE(pfc_resources))
129
43ca9cbb 130#define R8A7790_GPIO(idx) \
cde214a8 131static const struct resource r8a7790_gpio##idx##_resources[] __initconst = { \
43ca9cbb
LP
132 DEFINE_RES_MEM(0xe6050000 + 0x1000 * (idx), 0x50), \
133 DEFINE_RES_IRQ(gic_spi(4 + (idx))), \
134}; \
135 \
cde214a8
LP
136static const struct gpio_rcar_config \
137r8a7790_gpio##idx##_platform_data __initconst = { \
43ca9cbb
LP
138 .gpio_base = 32 * (idx), \
139 .irq_base = 0, \
140 .number_of_pins = 32, \
141 .pctl_name = "pfc-r8a7790", \
d93906b8 142 .has_both_edge_trigger = 1, \
43ca9cbb
LP
143}; \
144
145R8A7790_GPIO(0);
146R8A7790_GPIO(1);
147R8A7790_GPIO(2);
148R8A7790_GPIO(3);
149R8A7790_GPIO(4);
150R8A7790_GPIO(5);
151
152#define r8a7790_register_gpio(idx) \
153 platform_device_register_resndata(&platform_bus, "gpio_rcar", idx, \
154 r8a7790_gpio##idx##_resources, \
155 ARRAY_SIZE(r8a7790_gpio##idx##_resources), \
156 &r8a7790_gpio##idx##_platform_data, \
157 sizeof(r8a7790_gpio##idx##_platform_data))
158
b448c904
KM
159static struct resource i2c_resources[] __initdata = {
160 /* I2C0 */
161 DEFINE_RES_MEM(0xE6508000, 0x40),
162 DEFINE_RES_IRQ(gic_spi(287)),
163 /* I2C1 */
164 DEFINE_RES_MEM(0xE6518000, 0x40),
165 DEFINE_RES_IRQ(gic_spi(288)),
166 /* I2C2 */
167 DEFINE_RES_MEM(0xE6530000, 0x40),
168 DEFINE_RES_IRQ(gic_spi(286)),
169 /* I2C3 */
170 DEFINE_RES_MEM(0xE6540000, 0x40),
171 DEFINE_RES_IRQ(gic_spi(290)),
172
173};
174
175#define r8a7790_register_i2c(idx) \
176 platform_device_register_simple( \
db455c78 177 "i2c-rcar_gen2", idx, \
b448c904
KM
178 i2c_resources + (2 * idx), 2); \
179
69e351d0
MD
180void __init r8a7790_pinmux_init(void)
181{
8d0b3bf7 182 r8a7790_register_pfc();
43ca9cbb
LP
183 r8a7790_register_gpio(0);
184 r8a7790_register_gpio(1);
185 r8a7790_register_gpio(2);
186 r8a7790_register_gpio(3);
187 r8a7790_register_gpio(4);
188 r8a7790_register_gpio(5);
69e351d0
MD
189}
190
6319ea50 191#define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \
302d8898
LP
192static struct plat_sci_port scif##index##_platform_data = { \
193 .type = scif_type, \
302d8898 194 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
302d8898 195 .scscr = _scscr, \
c0a384f5
LP
196}; \
197 \
198static struct resource scif##index##_resources[] = { \
199 DEFINE_RES_MEM(baseaddr, 0x100), \
200 DEFINE_RES_IRQ(irq), \
d44f8308
UH
201}
202
302d8898
LP
203#define R8A7790_SCIF(index, baseaddr, irq) \
204 __R8A7790_SCIF(PORT_SCIF, SCSCR_RE | SCSCR_TE, \
6319ea50 205 index, baseaddr, irq)
302d8898
LP
206
207#define R8A7790_SCIFA(index, baseaddr, irq) \
208 __R8A7790_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
6319ea50 209 index, baseaddr, irq)
302d8898
LP
210
211#define R8A7790_SCIFB(index, baseaddr, irq) \
212 __R8A7790_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
6319ea50 213 index, baseaddr, irq)
302d8898
LP
214
215#define R8A7790_HSCIF(index, baseaddr, irq) \
216 __R8A7790_SCIF(PORT_HSCIF, SCSCR_RE | SCSCR_TE, \
6319ea50 217 index, baseaddr, irq)
302d8898
LP
218
219R8A7790_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
220R8A7790_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
221R8A7790_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
222R8A7790_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
223R8A7790_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
224R8A7790_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
225R8A7790_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
226R8A7790_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
227R8A7790_HSCIF(8, 0xe62c0000, gic_spi(154)); /* HSCIF0 */
228R8A7790_HSCIF(9, 0xe62c8000, gic_spi(155)); /* HSCIF1 */
229
230#define r8a7790_register_scif(index) \
c0a384f5
LP
231 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
232 scif##index##_resources, \
233 ARRAY_SIZE(scif##index##_resources), \
234 &scif##index##_platform_data, \
235 sizeof(scif##index##_platform_data))
55d9fab2 236
cde214a8 237static const struct renesas_irqc_config irqc0_data __initconst = {
8f5ec0a5
MD
238 .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
239};
240
cde214a8 241static const struct resource irqc0_resources[] __initconst = {
8f5ec0a5
MD
242 DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
243 DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
244 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
245 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
246 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
247};
248
249#define r8a7790_register_irqc(idx) \
250 platform_device_register_resndata(&platform_bus, "renesas_irqc", \
251 idx, irqc##idx##_resources, \
252 ARRAY_SIZE(irqc##idx##_resources), \
253 &irqc##idx##_data, \
254 sizeof(struct renesas_irqc_config))
255
cde214a8 256static const struct resource thermal_resources[] __initconst = {
0b8eeba4
SH
257 DEFINE_RES_MEM(0xe61f0000, 0x14),
258 DEFINE_RES_MEM(0xe61f0100, 0x38),
259 DEFINE_RES_IRQ(gic_spi(69)),
260};
261
262#define r8a7790_register_thermal() \
263 platform_device_register_simple("rcar_thermal", -1, \
264 thermal_resources, \
265 ARRAY_SIZE(thermal_resources))
266
711ee6c8
LP
267static struct sh_timer_config cmt0_platform_data = {
268 .channels_mask = 0x60,
99ade1a0
MD
269};
270
711ee6c8
LP
271static struct resource cmt0_resources[] = {
272 DEFINE_RES_MEM(0xffca0000, 0x1004),
273 DEFINE_RES_IRQ(gic_spi(142)),
99ade1a0
MD
274};
275
276#define r8a7790_register_cmt(idx) \
711ee6c8 277 platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \
99ade1a0
MD
278 idx, cmt##idx##_resources, \
279 ARRAY_SIZE(cmt##idx##_resources), \
280 &cmt##idx##_platform_data, \
281 sizeof(struct sh_timer_config))
282
6dace67f 283void __init r8a7790_add_dt_devices(void)
4e9c4877
LP
284{
285 r8a7790_register_cmt(0);
286}
287
288void __init r8a7790_add_standard_devices(void)
0468b2d6 289{
302d8898
LP
290 r8a7790_register_scif(0);
291 r8a7790_register_scif(1);
292 r8a7790_register_scif(2);
293 r8a7790_register_scif(3);
294 r8a7790_register_scif(4);
295 r8a7790_register_scif(5);
296 r8a7790_register_scif(6);
297 r8a7790_register_scif(7);
298 r8a7790_register_scif(8);
299 r8a7790_register_scif(9);
6dace67f 300 r8a7790_add_dt_devices();
8f5ec0a5 301 r8a7790_register_irqc(0);
0b8eeba4 302 r8a7790_register_thermal();
f05b4b52
MD
303 r8a7790_register_i2c(0);
304 r8a7790_register_i2c(1);
305 r8a7790_register_i2c(2);
306 r8a7790_register_i2c(3);
307 r8a7790_register_audio_dmac(0);
308 r8a7790_register_audio_dmac(1);
0468b2d6
MD
309}
310
0efd7faa 311void __init r8a7790_init_early(void)
8333d8c9
MD
312{
313#ifndef CONFIG_ARM_ARCH_TIMER
314 shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
315#endif
316}
317
0468b2d6 318#ifdef CONFIG_USE_OF
0468b2d6 319
cde214a8 320static const char * const r8a7790_boards_compat_dt[] __initconst = {
0468b2d6
MD
321 "renesas,r8a7790",
322 NULL,
323};
324
325DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
ad09cb83 326 .smp = smp_ops(r8a7790_smp_ops),
0efd7faa 327 .init_early = r8a7790_init_early,
50c517d9 328 .init_time = rcar_gen2_timer_init,
0468b2d6
MD
329 .dt_compat = r8a7790_boards_compat_dt,
330MACHINE_END
331#endif /* CONFIG_USE_OF */
This page took 0.080625 seconds and 5 git commands to generate.