Commit 56c0e646c4f6aeb263d9bff01b3619d81a0b062e
1 parent
3c1eaec012
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
timer: cadence: Implement timer_get_boot_us
This function is required for adding bootstage support. Also enable it directly for ZynqMP R5 configuration. Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Showing 2 changed files with 24 additions and 0 deletions Side-by-side Diff
configs/xilinx_zynqmp_r5_defconfig
... | ... | @@ -5,10 +5,12 @@ |
5 | 5 | CONFIG_DEBUG_UART_CLOCK=100000000 |
6 | 6 | CONFIG_DEFAULT_DEVICE_TREE="zynqmp-r5" |
7 | 7 | CONFIG_DEBUG_UART=y |
8 | +CONFIG_BOOTSTAGE=y | |
8 | 9 | # CONFIG_DISPLAY_CPUINFO is not set |
9 | 10 | CONFIG_SYS_PROMPT="ZynqMP r5> " |
10 | 11 | # CONFIG_CMD_FLASH is not set |
11 | 12 | # CONFIG_CMD_SETEXPR is not set |
13 | +CONFIG_CMD_BOOTSTAGE=y | |
12 | 14 | CONFIG_OF_EMBED=y |
13 | 15 | CONFIG_DEBUG_UART_ZYNQ=y |
14 | 16 | CONFIG_ZYNQ_SERIAL=y |
drivers/timer/cadence-ttc.c
... | ... | @@ -31,6 +31,28 @@ |
31 | 31 | struct cadence_ttc_regs *regs; |
32 | 32 | }; |
33 | 33 | |
34 | +#if CONFIG_IS_ENABLED(BOOTSTAGE) | |
35 | +ulong timer_get_boot_us(void) | |
36 | +{ | |
37 | + u64 ticks = 0; | |
38 | + u32 rate = 1; | |
39 | + u64 us; | |
40 | + int ret; | |
41 | + | |
42 | + ret = dm_timer_init(); | |
43 | + if (!ret) { | |
44 | + /* The timer is available */ | |
45 | + rate = timer_get_rate(gd->timer); | |
46 | + timer_get_count(gd->timer, &ticks); | |
47 | + } else { | |
48 | + return 0; | |
49 | + } | |
50 | + | |
51 | + us = (ticks * 1000) / rate; | |
52 | + return us; | |
53 | +} | |
54 | +#endif | |
55 | + | |
34 | 56 | static int cadence_ttc_get_count(struct udevice *dev, u64 *count) |
35 | 57 | { |
36 | 58 | struct cadence_ttc_priv *priv = dev_get_priv(dev); |