soundwire: sysfs: add slave status and device number before probe
[linux-2.6-microblaze.git] / arch / riscv / kernel / clint.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2019 Christoph Hellwig.
4  */
5
6 #include <linux/io.h>
7 #include <linux/of_address.h>
8 #include <linux/types.h>
9 #include <asm/clint.h>
10 #include <asm/csr.h>
11 #include <asm/timex.h>
12 #include <asm/smp.h>
13
14 /*
15  * This is the layout used by the SiFive clint, which is also shared by the qemu
16  * virt platform, and the Kendryte KD210 at least.
17  */
18 #define CLINT_IPI_OFF           0
19 #define CLINT_TIME_CMP_OFF      0x4000
20 #define CLINT_TIME_VAL_OFF      0xbff8
21
22 u32 __iomem *clint_ipi_base;
23
24 void clint_init_boot_cpu(void)
25 {
26         struct device_node *np;
27         void __iomem *base;
28
29         np = of_find_compatible_node(NULL, NULL, "riscv,clint0");
30         if (!np) {
31                 panic("clint not found");
32                 return;
33         }
34
35         base = of_iomap(np, 0);
36         if (!base)
37                 panic("could not map CLINT");
38
39         clint_ipi_base = base + CLINT_IPI_OFF;
40         riscv_time_cmp = base + CLINT_TIME_CMP_OFF;
41         riscv_time_val = base + CLINT_TIME_VAL_OFF;
42
43         clint_clear_ipi(boot_cpu_hartid);
44 }