| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <mcall.h> |
| 4 | #include <stdint.h> |
| 5 | #include <device/mmio.h> |
| 6 | #include <soc/addressmap.h> |
| 7 | |
| 8 | #define CLINT_MTIME 0xBFF8 |
| 9 | #define CLINT_MTIMECMP 0x4000 |
| 10 | |
| 11 | void mtime_init(void) |
| 12 | { |
| 13 | long hart_id = read_csr(mhartid); |
| 14 | HLS()->time = (uint64_t *)(FU740_CLINT + CLINT_MTIME); |
| 15 | HLS()->timecmp = (uint64_t *)(FU740_CLINT + CLINT_MTIMECMP + 8 * hart_id); |
| 16 | } |
| 17 | |
| 18 | void set_msip(int hartid, int val) |
| 19 | { |
| 20 | write32((void *)(FU740_CLINT + 4 * (uintptr_t)hartid), !!val); |
| 21 | } |