Skip to content

Commit f22c557

Browse files
committed
Merge tag 'riscv-for-linus-5.9-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - The CLINT driver has been split in two: one to handle the M-mode CLINT (memory mapped and used on NOMMU systems) and one to handle the S-mode CLINT (via SBI). - The addition of SiFive's drivers to rv32_defconfig * tag 'riscv-for-linus-5.9-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Add SiFive drivers to rv32_defconfig dt-bindings: timer: Add CLINT bindings RISC-V: Remove CLINT related code from timer and arch clocksource/drivers: Add CLINT timer driver RISC-V: Add mechanism to provide custom IPI operations
2 parents c0a4f5b + fc26f5b commit f22c557

File tree

19 files changed

+376
-153
lines changed

19 files changed

+376
-153
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/timer/sifive,clint.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: SiFive Core Local Interruptor
8+
9+
maintainers:
10+
- Palmer Dabbelt <[email protected]>
11+
- Anup Patel <[email protected]>
12+
13+
description:
14+
SiFive (and other RISC-V) SOCs include an implementation of the SiFive
15+
Core Local Interruptor (CLINT) for M-mode timer and M-mode inter-processor
16+
interrupts. It directly connects to the timer and inter-processor interrupt
17+
lines of various HARTs (or CPUs) so RISC-V per-HART (or per-CPU) local
18+
interrupt controller is the parent interrupt controller for CLINT device.
19+
The clock frequency of CLINT is specified via "timebase-frequency" DT
20+
property of "/cpus" DT node. The "timebase-frequency" DT property is
21+
described in Documentation/devicetree/bindings/riscv/cpus.yaml
22+
23+
properties:
24+
compatible:
25+
items:
26+
- const: sifive,fu540-c000-clint
27+
- const: sifive,clint0
28+
29+
description:
30+
Should be "sifive,<chip>-clint" and "sifive,clint<version>".
31+
Supported compatible strings are -
32+
"sifive,fu540-c000-clint" for the SiFive CLINT v0 as integrated
33+
onto the SiFive FU540 chip, and "sifive,clint0" for the SiFive
34+
CLINT v0 IP block with no chip integration tweaks.
35+
Please refer to sifive-blocks-ip-versioning.txt for details
36+
37+
reg:
38+
maxItems: 1
39+
40+
interrupts-extended:
41+
minItems: 1
42+
43+
additionalProperties: false
44+
45+
required:
46+
- compatible
47+
- reg
48+
- interrupts-extended
49+
50+
examples:
51+
- |
52+
timer@2000000 {
53+
compatible = "sifive,fu540-c000-clint", "sifive,clint0";
54+
interrupts-extended = <&cpu1intc 3 &cpu1intc 7
55+
&cpu2intc 3 &cpu2intc 7
56+
&cpu3intc 3 &cpu3intc 7
57+
&cpu4intc 3 &cpu4intc 7>;
58+
reg = <0x2000000 0x10000>;
59+
};
60+
...

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ config RISCV
8181
select PCI_DOMAINS_GENERIC if PCI
8282
select PCI_MSI if PCI
8383
select RISCV_INTC
84-
select RISCV_TIMER
84+
select RISCV_TIMER if RISCV_SBI
8585
select SPARSEMEM_STATIC if 32BIT
8686
select SPARSE_IRQ
8787
select SYSCTL_EXCEPTION_TRACE

arch/riscv/Kconfig.socs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ config SOC_SIFIVE
1212

1313
config SOC_VIRT
1414
bool "QEMU Virt Machine"
15+
select CLINT_TIMER if RISCV_M_MODE
1516
select POWER_RESET
1617
select POWER_RESET_SYSCON
1718
select POWER_RESET_SYSCON_POWEROFF
@@ -24,6 +25,7 @@ config SOC_VIRT
2425
config SOC_KENDRYTE
2526
bool "Kendryte K210 SoC"
2627
depends on !MMU
28+
select CLINT_TIMER if RISCV_M_MODE
2729
select SERIAL_SIFIVE if TTY
2830
select SERIAL_SIFIVE_CONSOLE if TTY
2931
select SIFIVE_PLIC

arch/riscv/configs/nommu_virt_defconfig

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ CONFIG_EXPERT=y
2626
CONFIG_SLOB=y
2727
# CONFIG_SLAB_MERGE_DEFAULT is not set
2828
# CONFIG_MMU is not set
29+
CONFIG_SOC_VIRT=y
2930
CONFIG_MAXPHYSMEM_2GB=y
3031
CONFIG_SMP=y
3132
CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0"
@@ -49,24 +50,20 @@ CONFIG_VIRTIO_BLK=y
4950
# CONFIG_SERIO is not set
5051
# CONFIG_LEGACY_PTYS is not set
5152
# CONFIG_LDISC_AUTOLOAD is not set
52-
# CONFIG_DEVMEM is not set
5353
CONFIG_SERIAL_8250=y
5454
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
5555
CONFIG_SERIAL_8250_CONSOLE=y
5656
CONFIG_SERIAL_8250_NR_UARTS=1
5757
CONFIG_SERIAL_8250_RUNTIME_UARTS=1
5858
CONFIG_SERIAL_OF_PLATFORM=y
5959
# CONFIG_HW_RANDOM is not set
60+
# CONFIG_DEVMEM is not set
6061
# CONFIG_HWMON is not set
61-
# CONFIG_LCD_CLASS_DEVICE is not set
62-
# CONFIG_BACKLIGHT_CLASS_DEVICE is not set
6362
# CONFIG_VGA_CONSOLE is not set
6463
# CONFIG_HID is not set
6564
# CONFIG_USB_SUPPORT is not set
6665
CONFIG_VIRTIO_MMIO=y
6766
CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
68-
CONFIG_SIFIVE_PLIC=y
69-
# CONFIG_VALIDATE_FS_PARSER is not set
7067
CONFIG_EXT2_FS=y
7168
# CONFIG_DNOTIFY is not set
7269
# CONFIG_INOTIFY_USER is not set

arch/riscv/configs/rv32_defconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CONFIG_CHECKPOINT_RESTORE=y
1414
CONFIG_BLK_DEV_INITRD=y
1515
CONFIG_EXPERT=y
1616
CONFIG_BPF_SYSCALL=y
17+
CONFIG_SOC_SIFIVE=y
1718
CONFIG_SOC_VIRT=y
1819
CONFIG_ARCH_RV32I=y
1920
CONFIG_SMP=y
@@ -62,6 +63,8 @@ CONFIG_HVC_RISCV_SBI=y
6263
CONFIG_VIRTIO_CONSOLE=y
6364
CONFIG_HW_RANDOM=y
6465
CONFIG_HW_RANDOM_VIRTIO=y
66+
CONFIG_SPI=y
67+
CONFIG_SPI_SIFIVE=y
6568
# CONFIG_PTP_1588_CLOCK is not set
6669
CONFIG_POWER_RESET=y
6770
CONFIG_DRM=y
@@ -77,6 +80,8 @@ CONFIG_USB_OHCI_HCD=y
7780
CONFIG_USB_OHCI_HCD_PLATFORM=y
7881
CONFIG_USB_STORAGE=y
7982
CONFIG_USB_UAS=y
83+
CONFIG_MMC=y
84+
CONFIG_MMC_SPI=y
8085
CONFIG_RTC_CLASS=y
8186
CONFIG_VIRTIO_PCI=y
8287
CONFIG_VIRTIO_BALLOON=y

arch/riscv/include/asm/clint.h

Lines changed: 0 additions & 39 deletions
This file was deleted.

arch/riscv/include/asm/smp.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
struct seq_file;
1616
extern unsigned long boot_cpu_hartid;
1717

18+
struct riscv_ipi_ops {
19+
void (*ipi_inject)(const struct cpumask *target);
20+
void (*ipi_clear)(void);
21+
};
22+
1823
#ifdef CONFIG_SMP
1924
/*
2025
* Mapping between linux logical cpu index and hartid.
@@ -40,6 +45,12 @@ void arch_send_call_function_single_ipi(int cpu);
4045
int riscv_hartid_to_cpuid(int hartid);
4146
void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out);
4247

48+
/* Set custom IPI operations */
49+
void riscv_set_ipi_ops(struct riscv_ipi_ops *ops);
50+
51+
/* Clear IPI for current CPU */
52+
void riscv_clear_ipi(void);
53+
4354
/* Secondary hart entry */
4455
asmlinkage void smp_callin(void);
4556

@@ -81,6 +92,14 @@ static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
8192
cpumask_set_cpu(boot_cpu_hartid, out);
8293
}
8394

95+
static inline void riscv_set_ipi_ops(struct riscv_ipi_ops *ops)
96+
{
97+
}
98+
99+
static inline void riscv_clear_ipi(void)
100+
{
101+
}
102+
84103
#endif /* CONFIG_SMP */
85104

86105
#if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP)

arch/riscv/include/asm/timex.h

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,27 @@
77
#define _ASM_RISCV_TIMEX_H
88

99
#include <asm/csr.h>
10-
#include <asm/mmio.h>
1110

1211
typedef unsigned long cycles_t;
1312

14-
extern u64 __iomem *riscv_time_val;
15-
extern u64 __iomem *riscv_time_cmp;
16-
17-
#ifdef CONFIG_64BIT
18-
#define mmio_get_cycles() readq_relaxed(riscv_time_val)
19-
#else
20-
#define mmio_get_cycles() readl_relaxed(riscv_time_val)
21-
#define mmio_get_cycles_hi() readl_relaxed(((u32 *)riscv_time_val) + 1)
22-
#endif
23-
2413
static inline cycles_t get_cycles(void)
2514
{
26-
if (IS_ENABLED(CONFIG_RISCV_SBI))
27-
return csr_read(CSR_TIME);
28-
return mmio_get_cycles();
15+
return csr_read(CSR_TIME);
2916
}
3017
#define get_cycles get_cycles
3118

19+
static inline u32 get_cycles_hi(void)
20+
{
21+
return csr_read(CSR_TIMEH);
22+
}
23+
#define get_cycles_hi get_cycles_hi
24+
3225
#ifdef CONFIG_64BIT
3326
static inline u64 get_cycles64(void)
3427
{
3528
return get_cycles();
3629
}
3730
#else /* CONFIG_64BIT */
38-
static inline u32 get_cycles_hi(void)
39-
{
40-
if (IS_ENABLED(CONFIG_RISCV_SBI))
41-
return csr_read(CSR_TIMEH);
42-
return mmio_get_cycles_hi();
43-
}
44-
4531
static inline u64 get_cycles64(void)
4632
{
4733
u32 hi, lo;

arch/riscv/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ obj-y += cacheinfo.o
3131
obj-y += patch.o
3232
obj-$(CONFIG_MMU) += vdso.o vdso/
3333

34-
obj-$(CONFIG_RISCV_M_MODE) += clint.o traps_misaligned.o
34+
obj-$(CONFIG_RISCV_M_MODE) += traps_misaligned.o
3535
obj-$(CONFIG_FPU) += fpu.o
3636
obj-$(CONFIG_SMP) += smpboot.o
3737
obj-$(CONFIG_SMP) += smp.o

arch/riscv/kernel/clint.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)