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

Commit 03b45949 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: core: add time synchronized logs support"

parents bd793710 c3894ffe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -712,6 +712,7 @@ static struct mhi_controller *mhi_register_controller(struct pci_dev *pci_dev)
	mhi_cntrl->lpm_disable = mhi_lpm_disable;
	mhi_cntrl->lpm_enable = mhi_lpm_enable;
	mhi_cntrl->time_get = mhi_time_get;
	mhi_cntrl->remote_timer_freq = 19200000;

	ret = of_register_mhi_controller(mhi_cntrl);
	if (ret)
+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)
+15 −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;
@@ -755,6 +758,16 @@ void mhi_destroy_timesync(struct mhi_controller *mhi_cntrl);
int mhi_create_vote_sysfs(struct mhi_controller *mhi_cntrl);
void mhi_destroy_vote_sysfs(struct mhi_controller *mhi_cntrl);

/* timesync log support */
static inline void mhi_timesync_log(struct mhi_controller *mhi_cntrl)
{
	struct mhi_timesync *mhi_tsync = mhi_cntrl->mhi_tsync;

	if (mhi_tsync && mhi_cntrl->tsync_log)
		mhi_cntrl->tsync_log(mhi_cntrl,
				     readq_no_log(mhi_tsync->time_reg));
}

/* memory allocation methods */
static inline void *mhi_alloc_coherent(struct mhi_controller *mhi_cntrl,
				       size_t size,
+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);

+3 −0
Original line number Diff line number Diff line
@@ -136,6 +136,9 @@ enum MHI_PM_STATE __must_check mhi_tryset_pm_state(
	MHI_VERB("Transition to pm state from:%s to:%s\n",
		 to_mhi_pm_state_str(cur_state), to_mhi_pm_state_str(state));

	if (MHI_REG_ACCESS_VALID(cur_state) || MHI_REG_ACCESS_VALID(state))
		mhi_timesync_log(mhi_cntrl);

	mhi_cntrl->pm_state = state;
	return mhi_cntrl->pm_state;
}
Loading