]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
arm: tegra: soctherm: T13x fuse correction update
authorDiwakar Tundlam <dtundlam@nvidia.com>
Thu, 17 Apr 2014 20:36:28 +0000 (13:36 -0700)
committerSeema Khowala <seemaj@nvidia.com>
Wed, 23 Apr 2014 21:06:41 +0000 (14:06 -0700)
Added check for fuse revisions in T13x and pick the new fuse
corrections table for CP revs 0.9 or higher.

Bug 1429685

Change-Id: Ib0bfec7e122c22e67ef07b16a0ff7d9642c43644
Signed-off-by: Diwakar Tundlam <dtundlam@nvidia.com>
Reviewed-on: http://git-master/r/397819
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit

arch/arm/mach-tegra/tegra11_soctherm.c
drivers/misc/tegra-fuse/tegra12x_fuse_offsets.h

index fa25346abace2c836c1f7ce6ede0f9b91d63c2db..bc028c7cda1f02479390b19e9048c9536003f11c 100644 (file)
@@ -2583,6 +2583,7 @@ static struct soctherm_fuse_correction_war t12x_fuse_war2[] = {
        [TSENSE_PLLX] = { 1106500, -6729300 },
 };
 
+/* old ATE pattern */
 static struct soctherm_fuse_correction_war t13x_fuse_war1[] = {
        [TSENSE_CPU0] = { 1119800,  -6330400 },
        [TSENSE_CPU1] = { 1094100,  -3751800 },
@@ -2594,6 +2595,18 @@ static struct soctherm_fuse_correction_war t13x_fuse_war1[] = {
        [TSENSE_PLLX] = { 1150000, -11899000 },
 };
 
+/* new ATE pattern */
+static struct soctherm_fuse_correction_war t13x_fuse_war2[] = {
+       [TSENSE_CPU0] = { 1126600, -9433500 },
+       [TSENSE_CPU1] = { 1110800, -7383000 },
+       [TSENSE_CPU2] = { 1113800, -6215200 },
+       [TSENSE_CPU3] = { 1129600, -8196100 },
+       [TSENSE_MEM0] = { 1132900, -6755300 },
+       [TSENSE_MEM1] = { 1142300, -7374200 },
+       [TSENSE_GPU]  = { 1125100, -6350400 },
+       [TSENSE_PLLX] = { 1118100, -8208800 },
+};
+
 /**
  * soctherm_fuse_read_tsensor() - calculates therm_a and therm_b for a sensor
  * @sensor:    The sensor for which to calculate.
@@ -2621,6 +2634,7 @@ static int soctherm_fuse_read_tsensor(enum soctherm_sense sensor)
        fuse_rev = tegra_fuse_calib_base_get_cp(&base_cp, &shft_cp);
        if (fuse_rev < 0)
                return fuse_rev;
+       pr_debug("%s: fuse_rev %d\n", __func__, fuse_rev);
 
        tegra_fuse_get_tsensor_calib(sensor2tsensorcalib[sensor], &value);
 
@@ -2660,7 +2674,10 @@ static int soctherm_fuse_read_tsensor(enum soctherm_sense sensor)
                war = fuse_rev ?
                        &t12x_fuse_war1[sensor] : &t12x_fuse_war2[sensor];
        else if (IS_T13X)
-               war = &t13x_fuse_war1[sensor];
+               war = fuse_rev ?
+                       &t13x_fuse_war1[sensor] : &t13x_fuse_war2[sensor];
+       else
+               war = &no_fuse_war[sensor];
 
        therm_a = div64_s64_precise((s64)therm_a * war->a,
                                    (s64)1000000LL);
index 6a13c51eff7d5bdb7e5dab2376196c122ae54caa..df3b550bd7ed8e73ced8ad2af22c8f0dd1b70196 100644 (file)
@@ -126,10 +126,12 @@ DEVICE_ATTR(vp8_enable, 0440, tegra_fuse_show, tegra_fuse_store);
 DEVICE_ATTR(odm_lock, 0440, tegra_fuse_show, tegra_fuse_store);
 
 /*
- * Check CP fuse revision.
- *  ERROR:    -ve:     Negative return value
- *  CP/FT:     1:      Old style CP/FT fuse
- *  CP1/CP2:   0:      New style CP1/CP2 fuse (default)
+ * Check CP fuse revision. Return value (depending on chip) is as below:
+ *   Any: ERROR:      -ve:     Negative return value
+ *  T12x: CP/FT:       1:      Old style CP/FT fuse
+ *  T12x: CP1/CP2:     0:      New style CP1/CP2 fuse (default for t12x)
+ *  T13x: Old pattern: 1:      Old ATE pattern CP1/CP2 fuse
+ *  T13x: New pattern: 0:      New ATE pattern CP1/CP2 fuse (default for t13x)
  */
 static inline int fuse_cp_rev_check(void)
 {
@@ -144,26 +146,33 @@ static inline int fuse_cp_rev_check(void)
        if (!chip_id)
                chip_id = tegra_get_chipid();
 
-       /* T13x: No min CP rev (yet) */
-       if (chip_id == TEGRA_CHIPID_TEGRA13)
-               return 1; /* Use (old) CP/FT fuse style */
-
-       /* CP rev < 00.4 is unsupported */
-       if ((rev_major == 0) && (rev_minor < 4))
-               return -EINVAL;
+       /* T13x: all CP rev are valid */
+       if (chip_id == TEGRA_CHIPID_TEGRA13) {
+               /* CP rev < 00.9 is old ATE pattern */
+               if ((rev_major == 0) && (rev_minor < 9))
+                       return 1;
+               return 0; /* default new ATE pattern */
+       }
 
-       /* CP rev < 00.8 is CP/FT (old style) */
-       if ((rev_major == 0) && (rev_minor < 8))
-               return 1;
+       if (chip_id == TEGRA_CHIPID_TEGRA12) {
+               /* CP rev < 00.4 is unsupported */
+               if ((rev_major == 0) && (rev_minor < 4))
+                       return -EINVAL;
+               /* CP rev < 00.8 is CP/FT (old style) */
+               if ((rev_major == 0) && (rev_minor < 8))
+                       return 1;
+               return 0; /* default new CP1/CP2 fuse */
+       }
 
-       return 0;
+       return -EINVAL;
 }
 
 /*
  * Check FT fuse revision.
  * We check CP-rev and if it shows NEW style, we return ERROR.
  *  ERROR:    -ve:     Negative return value
- *  CP/FT:     0:      Old style CP/FT fuse (default)
+ *  CP/FT:     0:      Old style CP/FT fuse (default for t12x)
+ *  T13x:      1:      CP1/CP2 new ATE pattern (default for t13x)
  */
 static inline int fuse_ft_rev_check(void)
 {
@@ -171,23 +180,24 @@ static inline int fuse_ft_rev_check(void)
        u32 rev, rev_major, rev_minor;
        int check_cp = fuse_cp_rev_check();
 
-       rev = tegra_fuse_readl(FUSE_FT_REV);
-       rev_minor = rev & 0x1f;
-       rev_major = (rev >> 5) & 0x3f;
-       pr_debug("%s: FT rev %d.%d\n", __func__, rev_major, rev_minor);
-
        if (!chip_id)
                chip_id = tegra_get_chipid();
 
-       /* T13x: No min FT rev (yet) */
+       /* T13x does not use FT */
        if (chip_id == TEGRA_CHIPID_TEGRA13)
-               return 0;
+               return 1;
 
+       /* T12x */
        if (check_cp < 0)
                return check_cp;
        if (check_cp == 0)
                return -ENODEV; /* No FT rev in CP1/CP2 mode */
 
+       rev = tegra_fuse_readl(FUSE_FT_REV);
+       rev_minor = rev & 0x1f;
+       rev_major = (rev >> 5) & 0x3f;
+       pr_debug("%s: FT rev %d.%d\n", __func__, rev_major, rev_minor);
+
        /* FT rev < 00.5 is unsupported */
        if ((rev_major == 0) && (rev_minor < 5))
                return -EINVAL;
@@ -368,7 +378,7 @@ int tegra_fuse_calib_base_get_ft(u32 *base_ft, s32 *shifted_ft)
        if (check_cp < 0)
                return check_cp;
        /* when check_cp is 1, check_ft must be valid */
-       if (check_cp != 0 && check_ft != 0)
+       if (check_cp != 0 && check_ft < 0)
                return -EINVAL;
 
        val = tegra_fuse_readl(FUSE_TSENSOR_CALIB_8);