blob: 3bb5bf16000c1516bc82dd3d2b041bdc06c1b1f0 [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>
22#include <linux/irqchip.h>
23#include <linux/kernel.h>
24#include <linux/of_platform.h>
Magnus Damm55d9fab2013-03-28 00:49:44 +090025#include <linux/serial_sci.h>
Magnus Damm0468b2d2013-03-28 00:49:34 +090026#include <mach/common.h>
27#include <mach/irqs.h>
28#include <mach/r8a7790.h>
29#include <asm/mach/arch.h>
30
Magnus Damm55d9fab2013-03-28 00:49:44 +090031#define SCIF_COMMON(scif_type, baseaddr, irq) \
32 .type = scif_type, \
33 .mapbase = baseaddr, \
34 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
35 .irqs = SCIx_IRQ_MUXED(irq)
36
37#define SCIFA_DATA(index, baseaddr, irq) \
38[index] = { \
39 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
40 .scbrr_algo_id = SCBRR_ALGO_4, \
41 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
42}
43
44#define SCIFB_DATA(index, baseaddr, irq) \
45[index] = { \
46 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
47 .scbrr_algo_id = SCBRR_ALGO_4, \
48 .scscr = SCSCR_RE | SCSCR_TE, \
49}
50
51#define SCIF_DATA(index, baseaddr, irq) \
52[index] = { \
53 SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
54 .scbrr_algo_id = SCBRR_ALGO_2, \
55 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
56}
57
58enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1 };
59
60static const struct plat_sci_port scif[] = {
61 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */
62 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */
63 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */
64 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */
65 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */
66 SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */
67 SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */
68 SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */
69};
70
71static inline void r8a7790_register_scif(int idx)
72{
73 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx],
74 sizeof(struct plat_sci_port));
75}
76
Magnus Damm0468b2d2013-03-28 00:49:34 +090077void __init r8a7790_add_standard_devices(void)
78{
Magnus Damm55d9fab2013-03-28 00:49:44 +090079 r8a7790_register_scif(SCIFA0);
80 r8a7790_register_scif(SCIFA1);
81 r8a7790_register_scif(SCIFB0);
82 r8a7790_register_scif(SCIFB1);
83 r8a7790_register_scif(SCIFB2);
84 r8a7790_register_scif(SCIFA2);
85 r8a7790_register_scif(SCIF0);
86 r8a7790_register_scif(SCIF1);
Magnus Damm0468b2d2013-03-28 00:49:34 +090087}
88
89#ifdef CONFIG_USE_OF
90void __init r8a7790_add_standard_devices_dt(void)
91{
92 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
93}
94
95static const char *r8a7790_boards_compat_dt[] __initdata = {
96 "renesas,r8a7790",
97 NULL,
98};
99
100DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
101 .init_irq = irqchip_init,
102 .init_machine = r8a7790_add_standard_devices_dt,
103 .init_time = shmobile_timer_init,
104 .dt_compat = r8a7790_boards_compat_dt,
105MACHINE_END
106#endif /* CONFIG_USE_OF */