mmc: tegra: full win should be 50% of partial win
R Raj Kumar [Wed, 17 Jul 2013 11:50:07 +0000 (16:50 +0530)]
Continue tuning procedure for full window calculation,
for the full window size is greater or equal to 50% of
partial window size, else choose partial window.

Bug 1368929

Signed-off-by: R Raj Kumar <rrajk@nvidia.com>
Reviewed-on: http://git-master/r/252339
(cherry picked from commit 9aec071afaa966a94c01f937ae67e0c4a54d455e)

Change-Id: Iaf3fc1dad0a1ee9928ab8c8eae795db048048a8e
Signed-off-by: Pavan Kunapuli <pkunapuli@nvidia.com>
Reviewed-on: http://git-master/r/278239
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Naveen Kumar Arepalli <naveenk@nvidia.com>
Tested-by: Naveen Kumar Arepalli <naveenk@nvidia.com>
Reviewed-by: R Raj Kumar <rrajk@nvidia.com>
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>

drivers/mmc/host/sdhci-tegra.c

index 7d30ede..c018e4d 100644 (file)
@@ -1594,6 +1594,7 @@ static unsigned int calculate_high_freq_tap_value(struct sdhci_host *sdhci,
        partial_win_start = (vmax_tap_data->partial_win -
                (vmax_tap_data->full_win_end -
                vmax_tap_data->full_win_begin));
+
        partial_win_tap = ((vmid_tap_data->partial_win - vmid_sampling_point) +
                (partial_win_start + vmax_sampling_point));
        partial_win_tap >>= 1;
@@ -1796,6 +1797,7 @@ static int sdhci_tegra_get_tap_window_data(struct sdhci_host *sdhci,
        struct tap_window_data *tap_data)
 {
        unsigned int tap_value;
+       unsigned int full_win_percentage = 0;
        int err = 0;
 
        if (!tap_data) {
@@ -1827,31 +1829,40 @@ static int sdhci_tegra_get_tap_window_data(struct sdhci_host *sdhci,
                }
        }
 
-       /* Get the full window start */
-       tap_value++;
-       tap_value = sdhci_tegra_scan_tap_values(sdhci, tap_value, true);
-       if (tap_value > MAX_TAP_VALUES) {
-               /* All tap values exhausted. No full window */
-               tap_data->abandon_full_win = true;
-               goto out;
-       } else {
-               tap_data->full_win_begin = tap_value;
-               /*
-                * If full win start is 0xFF, then set that as full win end
-                * and exit.
-                */
-               if (tap_value == MAX_TAP_VALUES) {
-                       tap_data->full_win_end = tap_value;
+       do {
+               /* Get the full window start */
+               tap_value++;
+               tap_value = sdhci_tegra_scan_tap_values(sdhci, tap_value, true);
+               if (tap_value > MAX_TAP_VALUES) {
+                       /* All tap values exhausted. No full window */
+                       tap_data->abandon_full_win = true;
                        goto out;
+               } else {
+                       tap_data->full_win_begin = tap_value;
+                       /*
+                        * If full win start is 0xFF, then set that as
+                        * full win end and exit.
+                        */
+                       if (tap_value == MAX_TAP_VALUES) {
+                               tap_data->full_win_end = tap_value;
+                               goto out;
+                       }
                }
-       }
 
-       /* Get the full window end */
-       tap_value++;
-       tap_value = sdhci_tegra_scan_tap_values(sdhci, tap_value, false);
-       tap_data->full_win_end = tap_value - 1;
-       if (tap_value > MAX_TAP_VALUES)
-               tap_data->full_win_end = MAX_TAP_VALUES;
+               /* Get the full window end */
+               tap_value++;
+               tap_value = sdhci_tegra_scan_tap_values(sdhci,
+                               tap_value, false);
+               tap_data->full_win_end = tap_value - 1;
+               if (tap_value > MAX_TAP_VALUES)
+                       tap_data->full_win_end = MAX_TAP_VALUES;
+               full_win_percentage = ((tap_data->full_win_end -
+                               tap_data->full_win_begin) * 100) /
+                               (tap_data->partial_win + 1);
+       } while (full_win_percentage < 50 && tap_value < MAX_TAP_VALUES);
+
+       if (full_win_percentage < 50)
+               tap_data->abandon_full_win = true;
 out:
        /*
         * Mark tuning as failed if both partial and full windows are