]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
timer: cadence: Implement timer_get_boot_us
authorMichal Simek <michal.simek@xilinx.com>
Wed, 18 Apr 2018 12:03:56 +0000 (14:03 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Fri, 15 Jun 2018 06:06:31 +0000 (08:06 +0200)
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>
configs/xilinx_zynqmp_r5_defconfig
drivers/timer/cadence-ttc.c

index 52b3f75902cf6f7c8d348cfaeab2ff66f5f01ac2..9e667ff7d58a6687b2fe7ac01922615fbe5707bc 100644 (file)
@@ -5,10 +5,12 @@ CONFIG_DEBUG_UART_BASE=0xff010000
 CONFIG_DEBUG_UART_CLOCK=100000000
 CONFIG_DEFAULT_DEVICE_TREE="zynqmp-r5"
 CONFIG_DEBUG_UART=y
+CONFIG_BOOTSTAGE=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_SYS_PROMPT="ZynqMP r5> "
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_BOOTSTAGE=y
 CONFIG_OF_EMBED=y
 CONFIG_DEBUG_UART_ZYNQ=y
 CONFIG_ZYNQ_SERIAL=y
index 3541e5c841278fa308697ef94876406ebd7f9634..4125a078b385d8d5c2b3f0ee55c4e79ae6804149 100644 (file)
@@ -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);