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

Commit 5d660bd3 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: clock-debug: Allow dividers between clocks and measurement logic"

parents 11a1c550 fe150fb4
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ static int clock_debug_measure_get(void *data, u64 *val)
{
	struct clk *clock = data, *par;
	int ret, is_hw_gated;
	unsigned long meas_rate, sw_rate;

	/* Check to see if the clock is in hardware gating mode */
	if (clock->ops->in_hwcg_mode)
@@ -104,6 +105,16 @@ static int clock_debug_measure_get(void *data, u64 *val)
			clock->ops->enable_hwcg(clock);
	}

	/*
	 * If there's a divider on the path from the clock output to the
	 * measurement circuitry, account for it by dividing the original clock
	 * rate with the rate set on the parent of the measure clock.
	 */
	meas_rate = clk_get_rate(clock);
	sw_rate = clk_get_rate(measure->parent);
	if (sw_rate && meas_rate >= (sw_rate * 2))
		*val *= DIV_ROUND_CLOSEST(meas_rate, sw_rate);

	return ret;
}