ARM: tegra: dvfs: Add chip sku override
Ray Poudrier [Fri, 9 Dec 2011 01:38:25 +0000 (17:38 -0800)]
Based on command line parameter, override the sku

Bug 925878

Signed-off-by: Ray Poudrier <rapoudrier@nvidia.com>
Reviewed-on: http://git-master/r/83241
(cherry picked from commit 24df2878418fc0c5f2b2dd20130df91a23dd042e)

Change-Id: Ic8d2408c6e408fcf28f9b64f12866971b753b41e
Reviewed-on: http://git-master/r/88864
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>

arch/arm/mach-tegra/common.c
arch/arm/mach-tegra/fuse.h
arch/arm/mach-tegra/tegra3_speedo.c

index f9902cf..0127146 100644 (file)
@@ -141,6 +141,7 @@ void tegra_assert_system_reset(char mode, const char *cmd)
 #endif
 }
 static int modem_id;
+static int sku_override;
 static int debug_uart_port_id;
 static enum audio_codec_type audio_codec_name;
 static enum image_type board_image_type = system_image;
@@ -476,6 +477,21 @@ static int __init tegra_bootloader_fb_arg(char *options)
 }
 early_param("tegra_fbmem", tegra_bootloader_fb_arg);
 
+static int __init tegra_sku_override(char *id)
+{
+       char *p = id;
+
+       sku_override = memparse(p, &p);
+
+       return 0;
+}
+early_param("sku_override", tegra_sku_override);
+
+int tegra_get_sku_override(void)
+{
+       return sku_override;
+}
+
 static int __init tegra_vpr_arg(char *options)
 {
        char *p = options;
@@ -694,8 +710,6 @@ int tegra_get_modem_id(void)
 
 __setup("modem_id=", tegra_modem_id);
 
-
-
 /*
  * Tegra has a protected aperture that prevents access by most non-CPU
  * memory masters to addresses above the aperture value.  Enabling it
index 88ea840..37f591a 100644 (file)
@@ -42,6 +42,7 @@ int tegra_package_id(void);
 int tegra_cpu_speedo_id(void);
 int tegra_cpu_speedo_mv(void);
 int tegra_core_speedo_mv(void);
+int tegra_get_sku_override(void);
 #else
 static inline int tegra_package_id(void) { return -1; }
 static inline int tegra_cpu_speedo_id(void) { return 0; }
index 35e601b..bd880bc 100644 (file)
@@ -345,6 +345,9 @@ void tegra_init_speedo_data(void)
 {
        u32 cpu_speedo_val, core_speedo_val;
        int iv;
+       int fuse_sku = tegra_sku_id();
+       int sku_override = tegra_get_sku_override();
+       int new_sku = fuse_sku;
 
        /* Package info: 4 bits - 0,3:reserved 1:MID 2:DSC */
        package_id = tegra_fuse_readl(FUSE_PACKAGE_INFO) & 0x0F;
@@ -353,7 +356,66 @@ void tegra_init_speedo_data(void)
        BUG_ON(ARRAY_SIZE(cpu_process_speedos) !=
               ARRAY_SIZE(core_process_speedos));
 
-       rev_sku_to_speedo_ids(tegra_get_revision(), tegra_sku_id());
+       /* SKU Overrides
+       * T33   => T30, T30L
+       * T33S  => T30S, T30SL
+       * T30   => T30L
+       * T30S  => T30SL
+       * AP33  => AP30
+       */
+       switch (sku_override) {
+       case 1:
+               /* Base sku override */
+               if (fuse_sku == 0x80) {
+                       if (package_id == 1) {
+                               /* T33 to T30 */
+                               pr_info("%s: SKU OR: T33->T30\n", __func__);
+                               new_sku = 0x81;
+                       } else if (package_id == 2) {
+                               /* T33S->T30S */
+                               pr_info("%s: SKU OR: T33S->T30S\n", __func__);
+                               new_sku = 0x83;
+                       }
+               } else if (fuse_sku == 0x81) {
+                       if (package_id == 2) {
+                               /* AP33->AP30 */
+                               pr_info("%s: SKU OR: AP33->AP30\n", __func__);
+                               new_sku = 0x87;
+                       }
+               }
+               break;
+       case 2:
+               /* L sku override */
+               if (fuse_sku == 0x80) {
+                       if (package_id == 1) {
+                               /* T33->T30L */
+                               pr_info("%s: SKU OR: T33->T30L\n", __func__);
+                               new_sku = 0x83;
+                       } else if (package_id == 2) {
+                               /* T33S->T33SL */
+                               pr_info("%s: SKU OR: T33S->T30SL\n", __func__);
+                               new_sku = 0x8f;
+                       }
+               } else if (fuse_sku == 0x81) {
+                       if (package_id == 1) {
+                               pr_info("%s: SKU OR: T30->T30L\n", __func__);
+                               /* T30->T30L */
+                               new_sku = 0x83;
+                       }
+               } else if (fuse_sku == 0x83) {
+                       if (package_id == 2) {
+                               pr_info("%s: SKU OR: T30S->T30SL\n", __func__);
+                               /* T30S to T30SL */
+                               new_sku = 0x8f;
+                       }
+               }
+               break;
+       default:
+               /* no override */
+               break;
+       }
+
+       rev_sku_to_speedo_ids(tegra_get_revision(), new_sku);
        BUG_ON(threshold_index >= ARRAY_SIZE(cpu_process_speedos));
 
        fuse_speedo_calib(&cpu_speedo_val, &core_speedo_val);