blob: ef0500a4c8ad75e89a42bf7a06ee9736272d27dc [file] [log] [blame]
Heiko Stuebnerd63dc052013-06-02 23:09:41 +02001/*
2 * Device Tree support for Rockchip SoCs
3 *
4 * Copyright (c) 2013 MundoReader S.L.
5 * Author: Heiko Stuebner <heiko@sntech.de>
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; either version 2 of the License, or
10 * (at your option) any later version.
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
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/of_platform.h>
21#include <linux/irqchip.h>
Heiko Stübnerc9b75d52015-01-11 23:09:23 +010022#include <linux/clk-provider.h>
23#include <linux/clocksource.h>
24#include <linux/mfd/syscon.h>
25#include <linux/regmap.h>
Heiko Stuebnerd63dc052013-06-02 23:09:41 +020026#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/hardware/cache-l2x0.h>
Heiko Stuebnera7a2b312013-06-17 22:29:23 +020029#include "core.h"
Chris Zhong9c1ec8e2014-12-01 16:52:17 +080030#include "pm.h"
Heiko Stuebnerd63dc052013-06-02 23:09:41 +020031
Heiko Stuebner2a9fe3c2015-01-20 23:47:30 +010032#define RK3288_TIMER6_7_PHYS 0xff810000
Heiko Stübnerc9b75d52015-01-11 23:09:23 +010033
34static void __init rockchip_timer_init(void)
35{
36 if (of_machine_is_compatible("rockchip,rk3288")) {
Heiko Stuebner2a9fe3c2015-01-20 23:47:30 +010037 void __iomem *reg_base;
38
39 /*
40 * Most/all uboot versions for rk3288 don't enable timer7
41 * which is needed for the architected timer to work.
42 * So make sure it is running during early boot.
43 */
44 reg_base = ioremap(RK3288_TIMER6_7_PHYS, SZ_16K);
45 if (reg_base) {
46 writel(0, reg_base + 0x30);
47 writel(0xffffffff, reg_base + 0x20);
48 writel(0xffffffff, reg_base + 0x24);
49 writel(1, reg_base + 0x30);
50 dsb();
51 iounmap(reg_base);
52 } else {
53 pr_err("rockchip: could not map timer7 registers\n");
54 }
Heiko Stübnerc9b75d52015-01-11 23:09:23 +010055 }
56
57 of_clk_init(NULL);
Marc Zyngier3722ed22015-09-28 15:49:18 +010058 clocksource_probe();
Heiko Stübnerc9b75d52015-01-11 23:09:23 +010059}
60
Heiko Stuebner47b06fc2d2014-09-13 00:34:31 +020061static void __init rockchip_dt_init(void)
62{
Chris Zhong9c1ec8e2014-12-01 16:52:17 +080063 rockchip_suspend_init();
Heiko Stuebner47b06fc2d2014-09-13 00:34:31 +020064}
65
Heiko Stuebnerd63dc052013-06-02 23:09:41 +020066static const char * const rockchip_board_dt_compat[] = {
67 "rockchip,rk2928",
68 "rockchip,rk3066a",
69 "rockchip,rk3066b",
70 "rockchip,rk3188",
Jeffy Chen26082242015-12-09 17:04:11 +080071 "rockchip,rk3228",
Heiko Stuebner7a1917a2014-06-28 20:13:42 +020072 "rockchip,rk3288",
Heiko Stuebnerd63dc052013-06-02 23:09:41 +020073 NULL,
74};
75
Heiko Stuebner8c421242015-01-21 10:41:56 +010076DT_MACHINE_START(ROCKCHIP_DT, "Rockchip (Device Tree)")
Russell King2a2d2ff2014-04-28 15:27:59 +010077 .l2c_aux_val = 0,
78 .l2c_aux_mask = ~0,
Heiko Stübnerc9b75d52015-01-11 23:09:23 +010079 .init_time = rockchip_timer_init,
Heiko Stuebnerd63dc052013-06-02 23:09:41 +020080 .dt_compat = rockchip_board_dt_compat,
Heiko Stuebner47b06fc2d2014-09-13 00:34:31 +020081 .init_machine = rockchip_dt_init,
Heiko Stuebnerd63dc052013-06-02 23:09:41 +020082MACHINE_END