summaryrefslogtreecommitdiff
path: root/drivers/timer
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2018-04-18 14:03:56 +0200
committerMichal Simek <michal.simek@xilinx.com>2018-06-15 08:06:31 +0200
commit56c0e646c4f6aeb263d9bff01b3619d81a0b062e (patch)
tree9478f995d0f5821f0df80102287a2d7e09492c4b /drivers/timer
parent3c1eaec012ad3105b8bf787de0672d8739b5ec54 (diff)
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>
Diffstat (limited to 'drivers/timer')
-rw-r--r--drivers/timer/cadence-ttc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/timer/cadence-ttc.c b/drivers/timer/cadence-ttc.c
index 3541e5c841..4125a078b3 100644
--- a/drivers/timer/cadence-ttc.c
+++ b/drivers/timer/cadence-ttc.c
@@ -31,6 +31,28 @@ struct cadence_ttc_priv {
struct cadence_ttc_regs *regs;
};
+#if CONFIG_IS_ENABLED(BOOTSTAGE)
+ulong timer_get_boot_us(void)
+{
+ u64 ticks = 0;
+ u32 rate = 1;
+ u64 us;
+ int ret;
+
+ ret = dm_timer_init();
+ if (!ret) {
+ /* The timer is available */
+ rate = timer_get_rate(gd->timer);
+ timer_get_count(gd->timer, &ticks);
+ } else {
+ return 0;
+ }
+
+ us = (ticks * 1000) / rate;
+ return us;
+}
+#endif
+
static int cadence_ttc_get_count(struct udevice *dev, u64 *count)
{
struct cadence_ttc_priv *priv = dev_get_priv(dev);