mmc: tegra: select fixed tap hole margin values
Seshagir.H [Thu, 25 Sep 2014 12:51:49 +0000 (17:51 +0530)]
bug 200035711

Change-Id: I2efdabe31ec2ab5b6b0253f54484365e61890e91
Signed-off-by: Seshagir.H <sholi@nvidia.com>
Reviewed-on: http://git-master/r/538920
(cherry picked from commit ef940296b6f41e4669fe7da4c48bf34091af2512)
Reviewed-on: http://git-master/r/725516
GVS: Gerrit_Virtual_Submit
Reviewed-by: Jeetesh Burman <jburman@nvidia.com>
Tested-by: Jeetesh Burman <jburman@nvidia.com>
Reviewed-by: Naveen Kumar Arepalli <naveenk@nvidia.com>
Reviewed-by: Venkat Moganty <vmoganty@nvidia.com>

drivers/mmc/host/sdhci-tegra.c
include/linux/tegra-fuse.h

index add1615..1824380 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/devfreq.h>
 #include <linux/clk/tegra.h>
 #include <linux/tegra-soc.h>
+#include <linux/tegra-fuse.h>
 
 #include <linux/platform_data/mmc-sdhci-tegra.h>
 #include <mach/pinmux.h>
@@ -1927,9 +1928,6 @@ static int slide_window_start(struct sdhci_host *sdhci,
        struct tegra_tuning_data *tuning_data,
        int tap_value, enum tap_win_edge_attr edge_attr, int tap_hole)
 {
-       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci);
-       struct sdhci_tegra *tegra_host = pltfm_host->priv;
-       const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
        int tap_margin = 0;
 
        if (edge_attr == WIN_EDGE_BOUN_START) {
@@ -1939,12 +1937,8 @@ static int slide_window_start(struct sdhci_host *sdhci,
                        tap_value += (1000 / tuning_data->calc_values.t2t_vmax);
        } else if (edge_attr == WIN_EDGE_HOLE) {
                if (tap_hole >= 0) {
-                       if (soc_data->nvquirks & NVQUIRK_TMP_VAR_1_5_TAP_MARGIN)
-                               tap_margin = 2;
-                       else
-                               tap_margin = (((2 * (450 /
-                                       tuning_data->calc_values.t2t_vmax)) +
-                                       1) / 2);
+                       tap_margin = get_tuning_tap_hole_margins(sdhci,
+                                       tuning_data->calc_values.t2t_vmax);
                        tap_value += ((7 * tap_hole) / 100) + tap_margin;
                }
        }
@@ -1959,9 +1953,6 @@ static int slide_window_end(struct sdhci_host *sdhci,
        struct tegra_tuning_data *tuning_data,
        int tap_value, enum tap_win_edge_attr edge_attr, int tap_hole)
 {
-       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci);
-       struct sdhci_tegra *tegra_host = pltfm_host->priv;
-       const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data;
        int tap_margin = 0;
 
        if (edge_attr == WIN_EDGE_BOUN_END) {
@@ -1971,12 +1962,8 @@ static int slide_window_end(struct sdhci_host *sdhci,
        } else if (edge_attr == WIN_EDGE_HOLE) {
                if (tap_hole >= 0) {
                        tap_value = tap_hole;
-                       if (soc_data->nvquirks & NVQUIRK_TMP_VAR_1_5_TAP_MARGIN)
-                               tap_margin = 2;
-                       else
-                               tap_margin = (((2 * (450 /
-                                       tuning_data->calc_values.t2t_vmin)) +
-                                       1) / 2);
+                       tap_margin = get_tuning_tap_hole_margins(sdhci,
+                                       tuning_data->calc_values.t2t_vmin);
                }
                tap_value -= ((7 * tap_hole) / 100) + tap_margin;
        }
@@ -2878,21 +2865,18 @@ static int get_tuning_tap_hole_margins(struct sdhci_host *sdhci,
        int i;
        int tap_margin = 0;
 
-       if (soc_data->nvquirks & NVQUIRK_SELECT_FIXED_TAP_HOLE_MARGINS)  {
-               if (soc_data->tap_hole_margins) {
-                       tap_hole = soc_data->tap_hole_margins;
-                       dev_id = dev_name(mmc_dev(sdhci->mmc));
-                       for (i = 0; i < soc_data->tap_hole_margins_count; i++) {
-                               if (!strcmp(dev_id, tap_hole->dev_id))
-                                       return tap_hole->tap_hole_margin;
-                               tap_hole++;
-                       }
-               } else {
-                       dev_info(mmc_dev(sdhci->mmc),
-                               "Fixed tap hole margins missing\n");
+       if (soc_data->nvquirks & NVQUIRK_SELECT_FIXED_TAP_HOLE_MARGINS &&
+                       soc_data->tap_hole_margins) {
+               tap_hole = soc_data->tap_hole_margins;
+               dev_id = dev_name(mmc_dev(sdhci->mmc));
+               for (i = 0; i < soc_data->tap_hole_margins_count; i++) {
+                       if (!strcmp(dev_id, tap_hole->dev_id))
+                               return tap_hole->tap_hole_margin;
+                       tap_hole++;
                }
        }
-
+       dev_info(mmc_dev(sdhci->mmc),
+                               "Tap hole margins missing\n");
        /* if no margin are available calculate tap margin */
        tap_margin = (((2 * (450 / t2t_tuning_value)) +
                        1) / 2);
@@ -4404,6 +4388,26 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
        tegra_host->tap_cmd = TAP_CMD_TRIM_DEFAULT_VOLTAGE;
        tegra_host->speedo = plat->cpu_speedo;
        dev_info(mmc_dev(host->mmc), "Speedo value %d\n", tegra_host->speedo);
+
+       /* update t2t and tap_hole for automotive speedo */
+       if (tegra_is_soc_automotive_speedo() &&
+                       (soc_data == &soc_data_tegra12)) {
+               soc_data_tegra12.t2t_coeffs = t12x_automotive_tuning_coeffs;
+               soc_data_tegra12.t2t_coeffs_count =
+                               ARRAY_SIZE(t12x_automotive_tuning_coeffs);
+               soc_data_tegra12.tap_hole_coeffs =
+                               t12x_automotive_tap_hole_coeffs;
+               soc_data_tegra12.tap_hole_coeffs_count =
+                               ARRAY_SIZE(t12x_automotive_tap_hole_coeffs);
+               /* For automotive SDR50 mode POR frequency is 99Mhz */
+               soc_data_tegra12.tuning_freq_list[0] = 99000000;
+               soc_data_tegra12.nvquirks |=
+                               NVQUIRK_SELECT_FIXED_TAP_HOLE_MARGINS;
+               soc_data_tegra12.tap_hole_margins =
+                               t12x_automotive_tap_hole_margins;
+               soc_data_tegra12.tap_hole_margins_count =
+                               ARRAY_SIZE(t12x_automotive_tap_hole_margins);
+       }
        host->mmc->pm_caps |= plat->pm_caps;
        host->mmc->pm_flags |= plat->pm_flags;
 
index 0d2b9c9..3d72db3 100644 (file)
@@ -51,6 +51,14 @@ int tegra_cpu_process_id(void);
 int tegra_core_process_id(void);
 int tegra_gpu_process_id(void);
 int tegra_get_age(void);
+#if defined(CONFIG_ARCH_TEGRA_12x_SOC) && !defined(CONFIG_ARCH_TEGRA_13x_SOC)
+bool tegra_is_soc_automotive_speedo(void);
+#else
+static inline bool tegra_is_soc_automotive_speedo(void)
+{
+        return 0;
+}
+#endif
 
 int tegra_package_id(void);
 int tegra_cpu_speedo_id(void);