diff options
author | Tom Rini <trini@konsulko.com> | 2024-09-12 09:03:40 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-09-12 09:03:40 -0600 |
commit | 9eb0d731d800b4fbc8e9ed0178fec0d6f201d911 (patch) | |
tree | e569bf502dc6a4dcef4fe06b9a13209bc8d33366 /drivers/timer/ast_ibex_timer.c | |
parent | 2857b983f8d0dfcf2d1659d1fd4b1ea24f37c4ec (diff) | |
parent | 2db018d2ca5ebd7acc717f0b1959ee67fcd2b0a1 (diff) |
Merge branch 'next' of https://source.denx.de/u-boot/custodians/u-boot-riscv into next
CI result shows no issue:
https://source.denx.de/u-boot/custodians/u-boot-riscv/-/pipelines/22315
----------------------------------------------------------------
- Aspeed: Add AST2700 board (Ibex RISC-V core) support
- Add timer, dram controller, network support
- Sophgo: Add clock controller support for Milk-V Duo
Diffstat (limited to 'drivers/timer/ast_ibex_timer.c')
-rw-r--r-- | drivers/timer/ast_ibex_timer.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/timer/ast_ibex_timer.c b/drivers/timer/ast_ibex_timer.c new file mode 100644 index 00000000000..261839661e9 --- /dev/null +++ b/drivers/timer/ast_ibex_timer.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2024 Aspeed Technology Inc. + */ + +#include <asm/csr.h> +#include <asm/io.h> +#include <dm.h> +#include <errno.h> +#include <timer.h> + +#define CSR_MCYCLE 0xb00 +#define CSR_MCYCLEH 0xb80 + +static u64 ast_ibex_timer_get_count(struct udevice *dev) +{ + uint32_t cnt_l, cnt_h; + + cnt_l = csr_read(CSR_MCYCLE); + cnt_h = csr_read(CSR_MCYCLEH); + + return ((uint64_t)cnt_h << 32) | cnt_l; +} + +static int ast_ibex_timer_probe(struct udevice *dev) +{ + return 0; +} + +static const struct timer_ops ast_ibex_timer_ops = { + .get_count = ast_ibex_timer_get_count, +}; + +static const struct udevice_id ast_ibex_timer_ids[] = { + { .compatible = "aspeed,ast2700-ibex-timer" }, + { } +}; + +U_BOOT_DRIVER(ast_ibex_timer) = { + .name = "ast_ibex_timer", + .id = UCLASS_TIMER, + .of_match = ast_ibex_timer_ids, + .probe = ast_ibex_timer_probe, + .ops = &ast_ibex_timer_ops, +}; |