Angel Pons | 5de47d0 | 2020-04-04 18:51:30 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 2 | |
| 3 | #include <mcall.h> |
Xiang Wang | 7c9540e | 2018-10-11 17:30:37 +0800 | [diff] [blame] | 4 | #include <stdint.h> |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 5 | #include <device/mmio.h> |
Xiang Wang | aa5f821 | 2018-08-27 13:32:32 +0800 | [diff] [blame] | 6 | #include <soc/addressmap.h> |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 7 | |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 8 | void mtime_init(void) |
| 9 | { |
Xiang Wang | aa5f821 | 2018-08-27 13:32:32 +0800 | [diff] [blame] | 10 | long hart_id = read_csr(mhartid); |
| 11 | HLS()->time = (uint64_t *)(FU540_CLINT + 0xbff8); |
| 12 | HLS()->timecmp = (uint64_t *)(FU540_CLINT + 0x4000 + 8 * hart_id); |
| 13 | } |
| 14 | |
| 15 | void set_msip(int hartid, int val) |
| 16 | { |
Xiang Wang | 7c9540e | 2018-10-11 17:30:37 +0800 | [diff] [blame] | 17 | write32((void *)(FU540_CLINT + 4 * (uintptr_t)hartid), !!val); |
Xiang Wang | 2e38dbe | 2018-08-28 16:34:29 +0800 | [diff] [blame] | 18 | } |