blob: db6dbfbaf9f10e804618556144034fa34083c7be [file] [log] [blame]
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -08001/*
2 * R8A7740 processor support
3 *
4 * Copyright (C) 2011 Renesas Solutions Corp.
5 * Copyright (C) 2011 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
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.
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080015 */
16#include <linux/kernel.h>
17#include <linux/init.h>
Kuninori Morimoto6831f3a2011-11-10 18:46:23 -080018#include <linux/io.h>
Kuninori Morimoto70e3f3d2013-08-01 23:39:44 -070019#include <linux/irqchip.h>
20#include <linux/irqchip/arm-gic.h>
Magnus Damm755d57b2012-07-06 17:08:07 +090021#include <linux/of_platform.h>
Geert Uytterhoeven9e38b842014-06-20 18:53:03 +020022
Magnus Dammd3ab7222012-02-29 21:37:35 +090023#include <asm/mach/map.h>
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080024#include <asm/mach/arch.h>
Magnus Damm23e5bc02012-03-06 17:36:53 +090025#include <asm/mach/time.h>
Geert Uytterhoeven9e38b842014-06-20 18:53:03 +020026
Magnus Dammfd44aa52014-06-17 16:47:37 +090027#include "common.h"
Kuninori Morimoto6c01ba42011-11-10 18:45:52 -080028
Kuninori Morimotod49679e2012-06-12 02:36:21 -070029/*
30 * r8a7740 chip has lasting errata on MERAM buffer.
31 * this is work-around for it.
32 * see
33 * "Media RAM (MERAM)" on r8a7740 documentation
34 */
35#define MEBUFCNTR 0xFE950098
Geert Uytterhoeven44d88c72015-06-17 11:31:24 +020036static void __init r8a7740_meram_workaround(void)
Kuninori Morimotod49679e2012-06-12 02:36:21 -070037{
38 void __iomem *reg;
39
40 reg = ioremap_nocache(MEBUFCNTR, 4);
41 if (reg) {
42 iowrite32(0x01600164, reg);
43 iounmap(reg);
44 }
45}
46
Geert Uytterhoeven44d88c72015-06-17 11:31:24 +020047static void __init r8a7740_init_irq_of(void)
Kuninori Morimoto70e3f3d2013-08-01 23:39:44 -070048{
49 void __iomem *intc_prio_base = ioremap_nocache(0xe6900010, 0x10);
50 void __iomem *intc_msk_base = ioremap_nocache(0xe6900040, 0x10);
51 void __iomem *pfc_inta_ctrl = ioremap_nocache(0xe605807c, 0x4);
52
53 irqchip_init();
54
55 /* route signals to GIC */
56 iowrite32(0x0, pfc_inta_ctrl);
57
58 /*
59 * To mask the shared interrupt to SPI 149 we must ensure to set
60 * PRIO *and* MASK. Else we run into IRQ floods when registering
61 * the intc_irqpin devices
62 */
63 iowrite32(0x0, intc_prio_base + 0x0);
64 iowrite32(0x0, intc_prio_base + 0x4);
65 iowrite32(0x0, intc_prio_base + 0x8);
66 iowrite32(0x0, intc_prio_base + 0xc);
67 iowrite8(0xff, intc_msk_base + 0x0);
68 iowrite8(0xff, intc_msk_base + 0x4);
69 iowrite8(0xff, intc_msk_base + 0x8);
70 iowrite8(0xff, intc_msk_base + 0xc);
71
72 iounmap(intc_prio_base);
73 iounmap(intc_msk_base);
74 iounmap(pfc_inta_ctrl);
75}
76
Bastian Hecht744fdc82013-04-17 12:34:05 +020077static void __init r8a7740_generic_init(void)
78{
Magnus Dammc41215b2014-08-25 12:36:53 +090079 r8a7740_meram_workaround();
80
Simon Horman43330672014-08-12 09:04:42 +090081 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Bastian Hecht744fdc82013-04-17 12:34:05 +020082}
83
Nicolas Pitre19c233b2015-07-27 18:27:52 -040084static const char *const r8a7740_boards_compat_dt[] __initconst = {
Magnus Damm755d57b2012-07-06 17:08:07 +090085 "renesas,r8a7740",
86 NULL,
87};
88
Kuninori Morimotoa41acc42012-10-21 22:15:13 -070089DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
Geert Uytterhoeven4a6cc502015-11-23 14:56:01 +010090 .l2c_aux_val = 0,
91 .l2c_aux_mask = ~0,
Magnus Damma0c1fb02014-05-08 08:32:38 +090092 .init_early = shmobile_init_delay,
Bastian Hecht744fdc82013-04-17 12:34:05 +020093 .init_irq = r8a7740_init_irq_of,
94 .init_machine = r8a7740_generic_init,
Magnus Damm34b9fa42014-05-12 08:10:50 +090095 .init_late = shmobile_init_late,
Magnus Damm755d57b2012-07-06 17:08:07 +090096 .dt_compat = r8a7740_boards_compat_dt,
97MACHINE_END