]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
memory: tegra: Change macros to interpret parameter as integer
authorDiogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Thu, 4 Jul 2024 11:31:23 +0000 (12:31 +0100)
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Mon, 29 Jul 2024 15:35:20 +0000 (17:35 +0200)
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: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Link: https://lore.kernel.org/r/20240704-tegra210_emcfreq-v4-4-3e450503c555@tecnico.ulisboa.pt
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
drivers/memory/tegra/tegra210-emc-cc-r21021.c

index a9e19dfa985650240e6d95ad98cffa45d88fcbee..bfb01918270ec368ac580749cb018eb99a9f601c 100644 (file)
@@ -75,29 +75,29 @@ enum {
  * The division portion of the average operation.
  */
 #define __AVERAGE_PTFV(dev)                                            \
-       ({ next->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] =      \
-          next->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] /      \
+       ({ next->ptfv_list[(dev)] =                                     \
+          next->ptfv_list[(dev)] /                                     \
           next->ptfv_list[PTFV_DVFS_SAMPLES_INDEX]; })
 
 /*
  * Convert val to fixed point and add it to the temporary average.
  */
 #define __INCREMENT_PTFV(dev, val)                                     \
-       ({ next->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] +=     \
+       ({ next->ptfv_list[(dev)] +=                                    \
           ((val) * MOVAVG_PRECISION_FACTOR); })
 
 /*
  * Convert a moving average back to integral form and return the value.
  */
 #define __MOVAVG_AC(timing, dev)                                       \
-       ((timing)->ptfv_list[PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX] /    \
+       ((timing)->ptfv_list[(dev)] /                                   \
         MOVAVG_PRECISION_FACTOR)
 
 /* Weighted update. */
 #define __WEIGHTED_UPDATE_PTFV(dev, nval)                              \
        do {                                                            \
                int w = PTFV_MOVAVG_WEIGHT_INDEX;                       \
-               int dqs = PTFV_DQSOSC_MOVAVG_ ## dev ## _INDEX;         \
+               int dqs = (dev);                                                \
                                                                        \
                next->ptfv_list[dqs] =                                  \
                        ((nval * MOVAVG_PRECISION_FACTOR) +             \
@@ -111,7 +111,7 @@ enum {
 
 /* Access a particular average. */
 #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)
 {
@@ -418,6 +418,7 @@ static u32 periodic_compensation_handler(struct tegra210_emc *emc, u32 type,
           (nt)->ptfv_list[PTFV_DVFS_SAMPLES_INDEX]; })
 
        u32 i, adel = 0, samples = next->ptfv_list[PTFV_DVFS_SAMPLES_INDEX];
+       u32 idx;
 
        if (!next->periodic_training)
                return 0;
@@ -431,24 +432,12 @@ static u32 periodic_compensation_handler(struct tegra210_emc *emc, u32 type,
                         * calibration then we can reuse the previous
                         * frequencies EMA data.
                         */
-                       __COPY_EMA(next, last, C0D0U0);
-                       __COPY_EMA(next, last, C0D0U1);
-                       __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);
+                       for (idx = 0; idx < DRAM_CLKTREE_NUM; idx++)
+                               __COPY_EMA(next, last, idx);
                } else {
                        /* Reset the EMA.*/
-                       __MOVAVG(next, C0D0U0) = 0;
-                       __MOVAVG(next, C0D0U1) = 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 (idx = 0; idx < DRAM_CLKTREE_NUM; idx++)
+                               __MOVAVG(next, idx) = 0;
 
                        for (i = 0; i < samples; i++) {
                                /* Generate next sample of data. */