Commit a238f62b authored by Diogo Ivo's avatar Diogo Ivo Committed by Krzysztof Kozlowski

memory: tegra: Change macros to interpret parameter as integer

Convert the macros that manipulate the delay values to interpret their
index parameter as an integer to allow the introduction of loops.
Signed-off-by: default avatarDiogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Link: https://lore.kernel.org/r/20240704-tegra210_emcfreq-v4-4-3e450503c555@tecnico.ulisboa.ptSigned-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
parent c5f83622
...@@ -75,29 +75,29 @@ enum { ...@@ -75,29 +75,29 @@ enum {
* The division portion of the average operation. * The division portion of the average operation.
*/ */
#define __AVERAGE_PTFV(dev) \ #define __AVERAGE_PTFV(dev) \
({ next->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] = \ ({ next->ptfv_list[(dev)] = \
next->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] / \ next->ptfv_list[(dev)] / \
next->ptfv_list[PTFV_DVFS_SAMPLES_INDEX]; }) next->ptfv_list[PTFV_DVFS_SAMPLES_INDEX]; })
/* /*
* Convert val to fixed point and add it to the temporary average. * Convert val to fixed point and add it to the temporary average.
*/ */
#define __INCREMENT_PTFV(dev, val) \ #define __INCREMENT_PTFV(dev, val) \
({ next->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] += \ ({ next->ptfv_list[(dev)] += \
((val) * MOVAVG_PRECISION_FACTOR); }) ((val) * MOVAVG_PRECISION_FACTOR); })
/* /*
* Convert a moving average back to integral form and return the value. * Convert a moving average back to integral form and return the value.
*/ */
#define __MOVAVG_AC(timing, dev) \ #define __MOVAVG_AC(timing, dev) \
((timing)->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] / \ ((timing)->ptfv_list[(dev)] / \
MOVAVG_PRECISION_FACTOR) MOVAVG_PRECISION_FACTOR)
/* Weighted update. */ /* Weighted update. */
#define __WEIGHTED_UPDATE_PTFV(dev, nval) \ #define __WEIGHTED_UPDATE_PTFV(dev, nval) \
do { \ do { \
int w = PTFV_MOVAVG_WEIGHT_INDEX; \ int w = PTFV_MOVAVG_WEIGHT_INDEX; \
int dqs = PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX; \ int dqs = (dev); \
\ \
next->ptfv_list[dqs] = \ next->ptfv_list[dqs] = \
((nval * MOVAVG_PRECISION_FACTOR) + \ ((nval * MOVAVG_PRECISION_FACTOR) + \
...@@ -111,7 +111,7 @@ enum { ...@@ -111,7 +111,7 @@ enum {
/* Access a particular average. */ /* Access a particular average. */
#define __MOVAVG(timing, dev) \ #define __MOVAVG(timing, dev) \
((timing)->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX]) ((timing)->ptfv_list[(dev)])
static u32 update_clock_tree_delay(struct tegra210_emc *emc, int type) static u32 update_clock_tree_delay(struct tegra210_emc *emc, int type)
{ {
...@@ -418,6 +418,7 @@ static u32 periodic_compensation_handler(struct tegra210_emc *emc, u32 type, ...@@ -418,6 +418,7 @@ static u32 periodic_compensation_handler(struct tegra210_emc *emc, u32 type,
(nt)->ptfv_list[PTFV_DVFS_SAMPLES_INDEX]; }) (nt)->ptfv_list[PTFV_DVFS_SAMPLES_INDEX]; })
u32 i, adel = 0, samples = next->ptfv_list[PTFV_DVFS_SAMPLES_INDEX]; u32 i, adel = 0, samples = next->ptfv_list[PTFV_DVFS_SAMPLES_INDEX];
u32 idx;
if (!next->periodic_training) if (!next->periodic_training)
return 0; return 0;
...@@ -431,24 +432,12 @@ static u32 periodic_compensation_handler(struct tegra210_emc *emc, u32 type, ...@@ -431,24 +432,12 @@ static u32 periodic_compensation_handler(struct tegra210_emc *emc, u32 type,
* calibration then we can reuse the previous * calibration then we can reuse the previous
* frequencies EMA data. * frequencies EMA data.
*/ */
__COPY_EMA(next, last, C0D0U0); for (idx = 0; idx < DRAM_CLKTREE_NUM; idx++)
__COPY_EMA(next, last, C0D0U1); __COPY_EMA(next, last, idx);
__COPY_EMA(next, last, C1D0U0);
__COPY_EMA(next, last, C1D0U1);
__COPY_EMA(next, last, C0D1U0);
__COPY_EMA(next, last, C0D1U1);
__COPY_EMA(next, last, C1D1U0);
__COPY_EMA(next, last, C1D1U1);
} else { } else {
/* Reset the EMA.*/ /* Reset the EMA.*/
__MOVAVG(next, C0D0U0) = 0; for (idx = 0; idx < DRAM_CLKTREE_NUM; idx++)
__MOVAVG(next, C0D0U1) = 0; __MOVAVG(next, idx) = 0;
__MOVAVG(next, C1D0U0) = 0;
__MOVAVG(next, C1D0U1) = 0;
__MOVAVG(next, C0D1U0) = 0;
__MOVAVG(next, C0D1U1) = 0;
__MOVAVG(next, C1D1U0) = 0;
__MOVAVG(next, C1D1U1) = 0;
for (i = 0; i < samples; i++) { for (i = 0; i < samples; i++) {
/* Generate next sample of data. */ /* Generate next sample of data. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment