blob: 6bd08b127fa4edce8f457ed3af91c5c8de8b6686 [file] [log] [blame]
Magnus Damm0468b2d2013-03-28 00:49:34 +09001/*
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>
Magnus Damm0468b2d2013-03-28 00:49:34 +090022#include <linux/kernel.h>
23#include <linux/of_platform.h>
Laurent Pinchart43ca9cb2013-04-08 11:36:17 +020024#include <linux/platform_data/gpio-rcar.h>
Magnus Damm8f5ec0a2013-03-28 00:49:54 +090025#include <linux/platform_data/irq-renesas-irqc.h>
Magnus Damm99ade1a2013-06-28 20:27:04 +090026#include <linux/serial_sci.h>
Kuninori Morimoto2c578a12014-01-06 00:32:54 -080027#include <linux/sh_dma.h>
Magnus Damm99ade1a2013-06-28 20:27:04 +090028#include <linux/sh_timer.h>
Magnus Damm0468b2d2013-03-28 00:49:34 +090029#include <mach/common.h>
Kuninori Morimoto2c578a12014-01-06 00:32:54 -080030#include <mach/dma-register.h>
Magnus Damm0468b2d2013-03-28 00:49:34 +090031#include <mach/irqs.h>
32#include <mach/r8a7790.h>
33#include <asm/mach/arch.h>
34
Kuninori Morimoto2c578a12014-01-06 00:32:54 -080035/* Audio-DMAC */
36#define AUDIO_DMAC_SLAVE(_id, _addr, t, r) \
37{ \
38 .slave_id = AUDIO_DMAC_SLAVE_## _id ##_TX, \
39 .addr = _addr + 0x8, \
40 .chcr = CHCR_TX(XMIT_SZ_32BIT), \
41 .mid_rid = t, \
42}, { \
43 .slave_id = AUDIO_DMAC_SLAVE_## _id ##_RX, \
44 .addr = _addr + 0xc, \
45 .chcr = CHCR_RX(XMIT_SZ_32BIT), \
46 .mid_rid = r, \
47}
48
49static const struct sh_dmae_slave_config r8a7790_audio_dmac_slaves[] = {
50 AUDIO_DMAC_SLAVE(SSI0, 0xec241000, 0x01, 0x02),
51 AUDIO_DMAC_SLAVE(SSI1, 0xec241040, 0x03, 0x04),
52 AUDIO_DMAC_SLAVE(SSI2, 0xec241080, 0x05, 0x06),
53 AUDIO_DMAC_SLAVE(SSI3, 0xec2410c0, 0x07, 0x08),
54 AUDIO_DMAC_SLAVE(SSI4, 0xec241100, 0x09, 0x0a),
55 AUDIO_DMAC_SLAVE(SSI5, 0xec241140, 0x0b, 0x0c),
56 AUDIO_DMAC_SLAVE(SSI6, 0xec241180, 0x0d, 0x0e),
57 AUDIO_DMAC_SLAVE(SSI7, 0xec2411c0, 0x0f, 0x10),
58 AUDIO_DMAC_SLAVE(SSI8, 0xec241200, 0x11, 0x12),
59 AUDIO_DMAC_SLAVE(SSI9, 0xec241240, 0x13, 0x14),
60};
61
62#define DMAE_CHANNEL(a, b) \
63{ \
64 .offset = (a) - 0x20, \
65 .dmars = (a) - 0x20 + 0x40, \
66 .chclr_bit = (b), \
67 .chclr_offset = 0x80 - 0x20, \
68}
69
70static const struct sh_dmae_channel r8a7790_audio_dmac_channels[] = {
71 DMAE_CHANNEL(0x8000, 0),
72 DMAE_CHANNEL(0x8080, 1),
73 DMAE_CHANNEL(0x8100, 2),
74 DMAE_CHANNEL(0x8180, 3),
75 DMAE_CHANNEL(0x8200, 4),
76 DMAE_CHANNEL(0x8280, 5),
77 DMAE_CHANNEL(0x8300, 6),
78 DMAE_CHANNEL(0x8380, 7),
79 DMAE_CHANNEL(0x8400, 8),
80 DMAE_CHANNEL(0x8480, 9),
81 DMAE_CHANNEL(0x8500, 10),
82 DMAE_CHANNEL(0x8580, 11),
83 DMAE_CHANNEL(0x8600, 12),
84};
85
86static struct sh_dmae_pdata r8a7790_audio_dmac_platform_data = {
87 .slave = r8a7790_audio_dmac_slaves,
88 .slave_num = ARRAY_SIZE(r8a7790_audio_dmac_slaves),
89 .channel = r8a7790_audio_dmac_channels,
90 .channel_num = ARRAY_SIZE(r8a7790_audio_dmac_channels),
91 .ts_low_shift = TS_LOW_SHIFT,
92 .ts_low_mask = TS_LOW_BIT << TS_LOW_SHIFT,
93 .ts_high_shift = TS_HI_SHIFT,
94 .ts_high_mask = TS_HI_BIT << TS_HI_SHIFT,
95 .ts_shift = dma_ts_shift,
96 .ts_shift_num = ARRAY_SIZE(dma_ts_shift),
97 .dmaor_init = DMAOR_DME,
98 .chclr_present = 1,
99 .chclr_bitwise = 1,
100};
101
102static struct resource r8a7790_audio_dmac_resources[] = {
103 /* Channel registers and DMAOR for low */
104 DEFINE_RES_MEM(0xec700020, 0x8663 - 0x20),
105 DEFINE_RES_IRQ(gic_spi(346)),
106 DEFINE_RES_NAMED(gic_spi(320), 13, NULL, IORESOURCE_IRQ),
107
108 /* Channel registers and DMAOR for hi */
109 DEFINE_RES_MEM(0xec720020, 0x8663 - 0x20), /* hi */
110 DEFINE_RES_IRQ(gic_spi(347)),
111 DEFINE_RES_NAMED(gic_spi(333), 13, NULL, IORESOURCE_IRQ),
112};
113
114#define r8a7790_register_audio_dmac(id) \
115 platform_device_register_resndata( \
116 &platform_bus, "sh-dma-engine", id, \
117 &r8a7790_audio_dmac_resources[id * 3], 3, \
118 &r8a7790_audio_dmac_platform_data, \
119 sizeof(r8a7790_audio_dmac_platform_data))
120
Laurent Pinchartcde214a2013-08-08 00:34:53 +0200121static const struct resource pfc_resources[] __initconst = {
Magnus Damm69e351d2013-03-28 00:50:03 +0900122 DEFINE_RES_MEM(0xe6060000, 0x250),
123};
124
Magnus Damm8d0b3bf2013-10-17 06:51:46 +0900125#define r8a7790_register_pfc() \
126 platform_device_register_simple("pfc-r8a7790", -1, pfc_resources, \
127 ARRAY_SIZE(pfc_resources))
128
Laurent Pinchart43ca9cb2013-04-08 11:36:17 +0200129#define R8A7790_GPIO(idx) \
Laurent Pinchartcde214a2013-08-08 00:34:53 +0200130static const struct resource r8a7790_gpio##idx##_resources[] __initconst = { \
Laurent Pinchart43ca9cb2013-04-08 11:36:17 +0200131 DEFINE_RES_MEM(0xe6050000 + 0x1000 * (idx), 0x50), \
132 DEFINE_RES_IRQ(gic_spi(4 + (idx))), \
133}; \
134 \
Laurent Pinchartcde214a2013-08-08 00:34:53 +0200135static const struct gpio_rcar_config \
136r8a7790_gpio##idx##_platform_data __initconst = { \
Laurent Pinchart43ca9cb2013-04-08 11:36:17 +0200137 .gpio_base = 32 * (idx), \
138 .irq_base = 0, \
139 .number_of_pins = 32, \
140 .pctl_name = "pfc-r8a7790", \
Simon Hormand93906b82013-05-13 17:53:52 +0900141 .has_both_edge_trigger = 1, \
Laurent Pinchart43ca9cb2013-04-08 11:36:17 +0200142}; \
143
144R8A7790_GPIO(0);
145R8A7790_GPIO(1);
146R8A7790_GPIO(2);
147R8A7790_GPIO(3);
148R8A7790_GPIO(4);
149R8A7790_GPIO(5);
150
151#define r8a7790_register_gpio(idx) \
152 platform_device_register_resndata(&platform_bus, "gpio_rcar", idx, \
153 r8a7790_gpio##idx##_resources, \
154 ARRAY_SIZE(r8a7790_gpio##idx##_resources), \
155 &r8a7790_gpio##idx##_platform_data, \
156 sizeof(r8a7790_gpio##idx##_platform_data))
157
Kuninori Morimotob448c902013-11-28 19:02:12 -0800158static struct resource i2c_resources[] __initdata = {
159 /* I2C0 */
160 DEFINE_RES_MEM(0xE6508000, 0x40),
161 DEFINE_RES_IRQ(gic_spi(287)),
162 /* I2C1 */
163 DEFINE_RES_MEM(0xE6518000, 0x40),
164 DEFINE_RES_IRQ(gic_spi(288)),
165 /* I2C2 */
166 DEFINE_RES_MEM(0xE6530000, 0x40),
167 DEFINE_RES_IRQ(gic_spi(286)),
168 /* I2C3 */
169 DEFINE_RES_MEM(0xE6540000, 0x40),
170 DEFINE_RES_IRQ(gic_spi(290)),
171
172};
173
174#define r8a7790_register_i2c(idx) \
175 platform_device_register_simple( \
Valentine Barshakdb455c72013-12-27 14:58:08 +0400176 "i2c-rcar_gen2", idx, \
Kuninori Morimotob448c902013-11-28 19:02:12 -0800177 i2c_resources + (2 * idx), 2); \
178
Magnus Damm69e351d2013-03-28 00:50:03 +0900179void __init r8a7790_pinmux_init(void)
180{
Magnus Damm8d0b3bf2013-10-17 06:51:46 +0900181 r8a7790_register_pfc();
Laurent Pinchart43ca9cb2013-04-08 11:36:17 +0200182 r8a7790_register_gpio(0);
183 r8a7790_register_gpio(1);
184 r8a7790_register_gpio(2);
185 r8a7790_register_gpio(3);
186 r8a7790_register_gpio(4);
187 r8a7790_register_gpio(5);
Magnus Damm69e351d2013-03-28 00:50:03 +0900188}
189
Laurent Pinchart6319ea52013-12-06 10:59:46 +0100190#define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \
Laurent Pinchart302d8892013-11-03 13:50:31 +0100191static struct plat_sci_port scif##index##_platform_data = { \
192 .type = scif_type, \
Laurent Pinchart302d8892013-11-03 13:50:31 +0100193 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
Laurent Pinchart302d8892013-11-03 13:50:31 +0100194 .scscr = _scscr, \
Laurent Pinchartc0a384f2013-11-01 01:44:07 +0100195}; \
196 \
197static struct resource scif##index##_resources[] = { \
198 DEFINE_RES_MEM(baseaddr, 0x100), \
199 DEFINE_RES_IRQ(irq), \
Magnus Damm55d9fab2013-03-28 00:49:44 +0900200}
201
Laurent Pinchart302d8892013-11-03 13:50:31 +0100202#define R8A7790_SCIF(index, baseaddr, irq) \
203 __R8A7790_SCIF(PORT_SCIF, SCSCR_RE | SCSCR_TE, \
Laurent Pinchart6319ea52013-12-06 10:59:46 +0100204 index, baseaddr, irq)
Magnus Damm55d9fab2013-03-28 00:49:44 +0900205
Laurent Pinchart302d8892013-11-03 13:50:31 +0100206#define R8A7790_SCIFA(index, baseaddr, irq) \
207 __R8A7790_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
Laurent Pinchart6319ea52013-12-06 10:59:46 +0100208 index, baseaddr, irq)
Magnus Damm55d9fab2013-03-28 00:49:44 +0900209
Laurent Pinchart302d8892013-11-03 13:50:31 +0100210#define R8A7790_SCIFB(index, baseaddr, irq) \
211 __R8A7790_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
Laurent Pinchart6319ea52013-12-06 10:59:46 +0100212 index, baseaddr, irq)
Ulrich Hechtd44f8302013-05-31 17:57:02 +0200213
Laurent Pinchart302d8892013-11-03 13:50:31 +0100214#define R8A7790_HSCIF(index, baseaddr, irq) \
215 __R8A7790_SCIF(PORT_HSCIF, SCSCR_RE | SCSCR_TE, \
Laurent Pinchart6319ea52013-12-06 10:59:46 +0100216 index, baseaddr, irq)
Magnus Damm55d9fab2013-03-28 00:49:44 +0900217
Laurent Pinchart302d8892013-11-03 13:50:31 +0100218R8A7790_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
219R8A7790_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
220R8A7790_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
221R8A7790_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
222R8A7790_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
223R8A7790_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
224R8A7790_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
225R8A7790_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
226R8A7790_HSCIF(8, 0xe62c0000, gic_spi(154)); /* HSCIF0 */
227R8A7790_HSCIF(9, 0xe62c8000, gic_spi(155)); /* HSCIF1 */
Magnus Damm55d9fab2013-03-28 00:49:44 +0900228
Laurent Pinchart302d8892013-11-03 13:50:31 +0100229#define r8a7790_register_scif(index) \
Laurent Pinchartc0a384f2013-11-01 01:44:07 +0100230 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
231 scif##index##_resources, \
232 ARRAY_SIZE(scif##index##_resources), \
233 &scif##index##_platform_data, \
234 sizeof(scif##index##_platform_data))
Magnus Damm55d9fab2013-03-28 00:49:44 +0900235
Laurent Pinchartcde214a2013-08-08 00:34:53 +0200236static const struct renesas_irqc_config irqc0_data __initconst = {
Magnus Damm8f5ec0a2013-03-28 00:49:54 +0900237 .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
238};
239
Laurent Pinchartcde214a2013-08-08 00:34:53 +0200240static const struct resource irqc0_resources[] __initconst = {
Magnus Damm8f5ec0a2013-03-28 00:49:54 +0900241 DEFINE_RES_MEM(0xe61c0000, 0x200), /* IRQC Event Detector Block_0 */
242 DEFINE_RES_IRQ(gic_spi(0)), /* IRQ0 */
243 DEFINE_RES_IRQ(gic_spi(1)), /* IRQ1 */
244 DEFINE_RES_IRQ(gic_spi(2)), /* IRQ2 */
245 DEFINE_RES_IRQ(gic_spi(3)), /* IRQ3 */
246};
247
248#define r8a7790_register_irqc(idx) \
249 platform_device_register_resndata(&platform_bus, "renesas_irqc", \
250 idx, irqc##idx##_resources, \
251 ARRAY_SIZE(irqc##idx##_resources), \
252 &irqc##idx##_data, \
253 sizeof(struct renesas_irqc_config))
254
Laurent Pinchartcde214a2013-08-08 00:34:53 +0200255static const struct resource thermal_resources[] __initconst = {
Simon Horman0b8eeba2013-06-26 16:22:21 +0900256 DEFINE_RES_MEM(0xe61f0000, 0x14),
257 DEFINE_RES_MEM(0xe61f0100, 0x38),
258 DEFINE_RES_IRQ(gic_spi(69)),
259};
260
261#define r8a7790_register_thermal() \
262 platform_device_register_simple("rcar_thermal", -1, \
263 thermal_resources, \
264 ARRAY_SIZE(thermal_resources))
265
Laurent Pinchart711ee6c2014-04-23 13:15:13 +0200266static struct sh_timer_config cmt0_platform_data = {
267 .channels_mask = 0x60,
Magnus Damm99ade1a2013-06-28 20:27:04 +0900268};
269
Laurent Pinchart711ee6c2014-04-23 13:15:13 +0200270static struct resource cmt0_resources[] = {
271 DEFINE_RES_MEM(0xffca0000, 0x1004),
272 DEFINE_RES_IRQ(gic_spi(142)),
Magnus Damm99ade1a2013-06-28 20:27:04 +0900273};
274
275#define r8a7790_register_cmt(idx) \
Laurent Pinchart711ee6c2014-04-23 13:15:13 +0200276 platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \
Magnus Damm99ade1a2013-06-28 20:27:04 +0900277 idx, cmt##idx##_resources, \
278 ARRAY_SIZE(cmt##idx##_resources), \
279 &cmt##idx##_platform_data, \
280 sizeof(struct sh_timer_config))
281
Simon Horman6dace672013-06-28 13:42:16 +0900282void __init r8a7790_add_dt_devices(void)
Magnus Damm0468b2d2013-03-28 00:49:34 +0900283{
Laurent Pinchart4e9c4872014-04-30 02:31:45 +0200284 r8a7790_register_cmt(0);
285}
286
287void __init r8a7790_add_standard_devices(void)
288{
Laurent Pinchart302d8892013-11-03 13:50:31 +0100289 r8a7790_register_scif(0);
290 r8a7790_register_scif(1);
291 r8a7790_register_scif(2);
292 r8a7790_register_scif(3);
293 r8a7790_register_scif(4);
294 r8a7790_register_scif(5);
295 r8a7790_register_scif(6);
296 r8a7790_register_scif(7);
297 r8a7790_register_scif(8);
298 r8a7790_register_scif(9);
Simon Horman6dace672013-06-28 13:42:16 +0900299 r8a7790_add_dt_devices();
Magnus Damm8f5ec0a2013-03-28 00:49:54 +0900300 r8a7790_register_irqc(0);
Simon Horman0b8eeba2013-06-26 16:22:21 +0900301 r8a7790_register_thermal();
Magnus Dammf05b4b52014-02-24 14:49:07 +0900302 r8a7790_register_i2c(0);
303 r8a7790_register_i2c(1);
304 r8a7790_register_i2c(2);
305 r8a7790_register_i2c(3);
306 r8a7790_register_audio_dmac(0);
307 r8a7790_register_audio_dmac(1);
Magnus Damm0468b2d2013-03-28 00:49:34 +0900308}
309
Magnus Damm0efd7fa2013-08-08 07:27:01 +0900310void __init r8a7790_init_early(void)
Magnus Damm8333d8c2013-06-28 20:27:13 +0900311{
312#ifndef CONFIG_ARM_ARCH_TIMER
313 shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
314#endif
315}
316
Magnus Damm0468b2d2013-03-28 00:49:34 +0900317#ifdef CONFIG_USE_OF
Magnus Damm0468b2d2013-03-28 00:49:34 +0900318
Laurent Pinchartcde214a2013-08-08 00:34:53 +0200319static const char * const r8a7790_boards_compat_dt[] __initconst = {
Magnus Damm0468b2d2013-03-28 00:49:34 +0900320 "renesas,r8a7790",
321 NULL,
322};
323
324DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
Magnus Dammad09cb82013-08-29 08:22:07 +0900325 .smp = smp_ops(r8a7790_smp_ops),
Magnus Damm0efd7fa2013-08-08 07:27:01 +0900326 .init_early = r8a7790_init_early,
Magnus Damm50c517d2013-09-12 09:32:49 +0900327 .init_time = rcar_gen2_timer_init,
Magnus Damm0468b2d2013-03-28 00:49:34 +0900328 .dt_compat = r8a7790_boards_compat_dt,
329MACHINE_END
330#endif /* CONFIG_USE_OF */