1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (c) 2024 Aspeed Technology Inc. 4 */ 5 6 #include <asm/csr.h> 7 #include <asm/io.h> 8 #include <dm.h> 9 #include <errno.h> 10 #include <timer.h> 11 12 #define CSR_MCYCLE 0xb00 13 #define CSR_MCYCLEH 0xb80 14 ast_ibex_timer_get_count(struct udevice * dev)15static u64 ast_ibex_timer_get_count(struct udevice *dev) 16 { 17 uint32_t cnt_l, cnt_h; 18 19 cnt_l = csr_read(CSR_MCYCLE); 20 cnt_h = csr_read(CSR_MCYCLEH); 21 22 return ((uint64_t)cnt_h << 32) | cnt_l; 23 } 24 ast_ibex_timer_probe(struct udevice * dev)25static int ast_ibex_timer_probe(struct udevice *dev) 26 { 27 return 0; 28 } 29 30 static const struct timer_ops ast_ibex_timer_ops = { 31 .get_count = ast_ibex_timer_get_count, 32 }; 33 34 static const struct udevice_id ast_ibex_timer_ids[] = { 35 { .compatible = "aspeed,ast2700-ibex-timer" }, 36 { } 37 }; 38 39 U_BOOT_DRIVER(ast_ibex_timer) = { 40 .name = "ast_ibex_timer", 41 .id = UCLASS_TIMER, 42 .of_match = ast_ibex_timer_ids, 43 .probe = ast_ibex_timer_probe, 44 .ops = &ast_ibex_timer_ops, 45 }; 46