Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 403e587e authored by Sujeev Dias's avatar Sujeev Dias Committed by Sujeev Dias
Browse files

mhi: core: calculate times based on given timer frequencies



Query timer frequencies for host and device and calculate time
based on them.

CRs-Fixed: 2377061
Change-Id: I8dba580505870f82bb6e2529d1e01c85c4aafd29
Acked-by: default avatarBhaumik Vasav Bhatt <bbhatt@qti.qualcomm.com>
Signed-off-by: default avatarSujeev Dias <sdias@codeaurora.org>
parent cf8acfa8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -534,6 +534,8 @@ int mhi_init_timesync(struct mhi_controller *mhi_cntrl)
	     !mhi_cntrl->lpm_enable)
		return -EINVAL;

	mhi_cntrl->local_timer_freq = arch_timer_get_cntfrq();

	/* register method supported */
	mhi_tsync = kzalloc(sizeof(*mhi_tsync), GFP_KERNEL);
	if (!mhi_tsync)
+5 −2
Original line number Diff line number Diff line
@@ -225,8 +225,11 @@ extern struct bus_type mhi_bus_type;
#define SOC_HW_VERSION_MINOR_VER_BMSK (0x000000FF)
#define SOC_HW_VERSION_MINOR_VER_SHFT (0)

/* convert ticks to micro seconds by dividing by 19.2 */
#define TIME_TICKS_TO_US(x) (div_u64((x) * 10, 192))
/* timesync time calculations */
#define LOCAL_TICKS_TO_US(x) (div_u64((x) * 100ULL, \
				(mhi_cntrl->local_timer_freq / 10000ULL)))
#define REMOTE_TICKS_TO_US(x) (div_u64((x) * 100ULL, \
				(mhi_cntrl->remote_timer_freq / 10000ULL)))

struct mhi_event_ctxt {
	u32 reserved : 8;
+2 −1
Original line number Diff line number Diff line
@@ -696,7 +696,8 @@ static ssize_t time_us_show(struct device *dev,
	}

	return scnprintf(buf, PAGE_SIZE, "local: %llu remote: %llu (us)\n",
			 TIME_TICKS_TO_US(t_host), TIME_TICKS_TO_US(t_device));
			 LOCAL_TICKS_TO_US(t_host),
			 REMOTE_TICKS_TO_US(t_device));
}
static DEVICE_ATTR_RO(time_us);

+2 −0
Original line number Diff line number Diff line
@@ -303,6 +303,8 @@ struct mhi_controller {
	/* supports time sync feature */
	struct mhi_timesync *mhi_tsync;
	struct mhi_device *tsync_dev;
	u64 local_timer_freq;
	u64 remote_timer_freq;

	/* kernel log level */
	enum MHI_DEBUG_LEVEL klog_lvl;