Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Device Tree support for Rockchip SoCs |
| 4 | * |
| 5 | * Copyright (c) 2013 MundoReader S.L. |
| 6 | * Author: Heiko Stuebner <heiko@sntech.de> |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/init.h> |
Stephen Boyd | 62e59c4 | 2019-04-18 15:20:22 -0700 | [diff] [blame] | 11 | #include <linux/io.h> |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 12 | #include <linux/of_platform.h> |
| 13 | #include <linux/irqchip.h> |
Heiko Stübner | c9b75d5 | 2015-01-11 23:09:23 +0100 | [diff] [blame] | 14 | #include <linux/clk-provider.h> |
| 15 | #include <linux/clocksource.h> |
| 16 | #include <linux/mfd/syscon.h> |
| 17 | #include <linux/regmap.h> |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 18 | #include <asm/mach/arch.h> |
| 19 | #include <asm/mach/map.h> |
| 20 | #include <asm/hardware/cache-l2x0.h> |
Heiko Stuebner | a7a2b31 | 2013-06-17 22:29:23 +0200 | [diff] [blame] | 21 | #include "core.h" |
Chris Zhong | 9c1ec8e | 2014-12-01 16:52:17 +0800 | [diff] [blame] | 22 | #include "pm.h" |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 23 | |
Heiko Stuebner | 2a9fe3c | 2015-01-20 23:47:30 +0100 | [diff] [blame] | 24 | #define RK3288_TIMER6_7_PHYS 0xff810000 |
Heiko Stübner | c9b75d5 | 2015-01-11 23:09:23 +0100 | [diff] [blame] | 25 | |
| 26 | static void __init rockchip_timer_init(void) |
| 27 | { |
| 28 | if (of_machine_is_compatible("rockchip,rk3288")) { |
Heiko Stuebner | 2a9fe3c | 2015-01-20 23:47:30 +0100 | [diff] [blame] | 29 | void __iomem *reg_base; |
| 30 | |
| 31 | /* |
| 32 | * Most/all uboot versions for rk3288 don't enable timer7 |
| 33 | * which is needed for the architected timer to work. |
| 34 | * So make sure it is running during early boot. |
| 35 | */ |
| 36 | reg_base = ioremap(RK3288_TIMER6_7_PHYS, SZ_16K); |
| 37 | if (reg_base) { |
| 38 | writel(0, reg_base + 0x30); |
| 39 | writel(0xffffffff, reg_base + 0x20); |
| 40 | writel(0xffffffff, reg_base + 0x24); |
| 41 | writel(1, reg_base + 0x30); |
| 42 | dsb(); |
| 43 | iounmap(reg_base); |
| 44 | } else { |
| 45 | pr_err("rockchip: could not map timer7 registers\n"); |
| 46 | } |
Heiko Stübner | c9b75d5 | 2015-01-11 23:09:23 +0100 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | of_clk_init(NULL); |
Daniel Lezcano | ba5d08c | 2017-05-26 17:40:46 +0200 | [diff] [blame] | 50 | timer_probe(); |
Heiko Stübner | c9b75d5 | 2015-01-11 23:09:23 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Heiko Stuebner | 47b06fc2d | 2014-09-13 00:34:31 +0200 | [diff] [blame] | 53 | static void __init rockchip_dt_init(void) |
| 54 | { |
Chris Zhong | 9c1ec8e | 2014-12-01 16:52:17 +0800 | [diff] [blame] | 55 | rockchip_suspend_init(); |
Heiko Stuebner | 47b06fc2d | 2014-09-13 00:34:31 +0200 | [diff] [blame] | 56 | } |
| 57 | |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 58 | static const char * const rockchip_board_dt_compat[] = { |
| 59 | "rockchip,rk2928", |
| 60 | "rockchip,rk3066a", |
| 61 | "rockchip,rk3066b", |
| 62 | "rockchip,rk3188", |
Jeffy Chen | 2608224 | 2015-12-09 17:04:11 +0800 | [diff] [blame] | 63 | "rockchip,rk3228", |
Heiko Stuebner | 7a1917a | 2014-06-28 20:13:42 +0200 | [diff] [blame] | 64 | "rockchip,rk3288", |
Andy Yan | 51f6bfc | 2016-11-14 20:15:47 +0800 | [diff] [blame] | 65 | "rockchip,rv1108", |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 66 | NULL, |
| 67 | }; |
| 68 | |
Heiko Stuebner | 8c42124 | 2015-01-21 10:41:56 +0100 | [diff] [blame] | 69 | DT_MACHINE_START(ROCKCHIP_DT, "Rockchip (Device Tree)") |
Russell King | 2a2d2ff | 2014-04-28 15:27:59 +0100 | [diff] [blame] | 70 | .l2c_aux_val = 0, |
| 71 | .l2c_aux_mask = ~0, |
Heiko Stübner | c9b75d5 | 2015-01-11 23:09:23 +0100 | [diff] [blame] | 72 | .init_time = rockchip_timer_init, |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 73 | .dt_compat = rockchip_board_dt_compat, |
Heiko Stuebner | 47b06fc2d | 2014-09-13 00:34:31 +0200 | [diff] [blame] | 74 | .init_machine = rockchip_dt_init, |
Heiko Stuebner | d63dc051 | 2013-06-02 23:09:41 +0200 | [diff] [blame] | 75 | MACHINE_END |