qcacmn: Replace get_monotonic_boottime() with ktime_get_boottime()

get_monotonic_boottime() and similar functions have been replaced with
ktime_get_boottime() in newer driver versions. Change the calls to
get_monotonic_boottime() in the qdf wrapper to ktime_get_boottime().

Change-Id: I066ffbbcb3a51f8a080fd445397be028ee73ab2e
CRs-Fixed: 2558910
diff --git a/qdf/linux/src/i_qdf_time.h b/qdf/linux/src/i_qdf_time.h
index 6c1133e..80d3b46 100644
--- a/qdf/linux/src/i_qdf_time.h
+++ b/qdf/linux/src/i_qdf_time.h
@@ -252,11 +252,7 @@
  */
 static inline uint64_t __qdf_get_monotonic_boottime(void)
 {
-	struct timespec ts;
-
-	get_monotonic_boottime(&ts);
-
-	return ((uint64_t) ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
+	return (uint64_t)ktime_to_us(ktime_get_boottime());
 }
 
 #if defined (MSM_PLATFORM)
@@ -308,7 +304,13 @@
  * The time since system booted in nanoseconds
  */
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0))
+static inline uint64_t __qdf_get_bootbased_boottime_ns(void)
+{
+	return ktime_get_boottime_ns();
+}
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0))
 static inline uint64_t __qdf_get_bootbased_boottime_ns(void)
 {
 	return ktime_get_boot_ns();
diff --git a/qdf/linux/src/qdf_mc_timer.c b/qdf/linux/src/qdf_mc_timer.c
index a26601b..e5c2ed2 100644
--- a/qdf/linux/src/qdf_mc_timer.c
+++ b/qdf/linux/src/qdf_mc_timer.c
@@ -30,6 +30,7 @@
 #include "qdf_mem.h"
 #include <qdf_module.h>
 #include "qdf_timer.h"
+#include <linux/time64.h>
 
 /* Preprocessor definitions and constants */
 #define LINUX_TIMER_COOKIE 0x12341234
@@ -822,6 +823,17 @@
  * Return:
  * The current system time in milliseconds
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
+unsigned long qdf_mc_timer_get_system_time(void)
+{
+	struct timespec64 tv;
+
+	ktime_get_real_ts64(&tv);
+	return tv.tv_sec * 1000 + tv.tv_nsec / 1000000;
+}
+qdf_export_symbol(qdf_mc_timer_get_system_time);
+
+#else
 unsigned long qdf_mc_timer_get_system_time(void)
 {
 	struct timeval tv;
@@ -830,17 +842,32 @@
 	return tv.tv_sec * 1000 + tv.tv_usec / 1000;
 }
 qdf_export_symbol(qdf_mc_timer_get_system_time);
+#endif
 
 s64 qdf_get_monotonic_boottime_ns(void)
 {
-	struct timespec ts;
-
-	get_monotonic_boottime(&ts);
-
-	return timespec_to_ns(&ts);
+	return ktime_to_ns(ktime_get_boottime());
 }
 qdf_export_symbol(qdf_get_monotonic_boottime_ns);
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
+qdf_time_t qdf_get_time_of_the_day_ms(void)
+{
+	struct timespec64 tv;
+	qdf_time_t local_time;
+	struct rtc_time tm;
+
+	ktime_get_real_ts64(&tv);
+	local_time = (qdf_time_t)(tv.tv_sec - (sys_tz.tz_minuteswest * 60));
+	rtc_time_to_tm(local_time, &tm);
+
+	return (tm.tm_hour * 60 * 60 * 1000) +
+		(tm.tm_min * 60 * 1000) + (tm.tm_sec * 1000) +
+		(tv.tv_nsec / 1000000);
+}
+qdf_export_symbol(qdf_get_time_of_the_day_ms);
+
+#else
 qdf_time_t qdf_get_time_of_the_day_ms(void)
 {
 	struct timeval tv;
@@ -856,6 +883,7 @@
 		(tv.tv_usec / 1000);
 }
 qdf_export_symbol(qdf_get_time_of_the_day_ms);
+#endif
 
 /**
  * qdf_timer_module_deinit() - Deinitializes a QDF timer module.
@@ -871,6 +899,25 @@
 }
 qdf_export_symbol(qdf_timer_module_deinit);
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
+void qdf_get_time_of_the_day_in_hr_min_sec_usec(char *tbuf, int len)
+{
+	struct timespec64 tv;
+	struct rtc_time tm;
+	unsigned long local_time;
+
+	/* Format the Log time R#: [hr:min:sec.microsec] */
+	ktime_get_real_ts64(&tv);
+	/* Convert rtc to local time */
+	local_time = (u32)(tv.tv_sec - (sys_tz.tz_minuteswest * 60));
+	rtc_time_to_tm(local_time, &tm);
+	scnprintf(tbuf, len,
+		  "[%02d:%02d:%02d.%06lu]",
+		  tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_nsec / 1000);
+}
+qdf_export_symbol(qdf_get_time_of_the_day_in_hr_min_sec_usec);
+
+#else
 void qdf_get_time_of_the_day_in_hr_min_sec_usec(char *tbuf, int len)
 {
 	struct timeval tv;
@@ -887,3 +934,4 @@
 		tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec);
 }
 qdf_export_symbol(qdf_get_time_of_the_day_in_hr_min_sec_usec);
+#endif