soc/tegra: fuse: Add RAM code reader helper
authorMikko Perttunen <mperttunen@nvidia.com>
Thu, 12 Mar 2015 14:47:55 +0000 (15:47 +0100)
committerThierry Reding <treding@nvidia.com>
Mon, 4 May 2015 12:21:21 +0000 (14:21 +0200)
Needed for the EMC and MC drivers to know what timings from the DT to
use.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/soc/tegra/fuse/tegra-apbmisc.c
include/soc/tegra/fuse.h

index 3bf5aba..73fad05 100644 (file)
 #define APBMISC_SIZE   0x64
 #define FUSE_SKU_INFO  0x10
 
+#define PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT     4
+#define PMC_STRAPPING_OPT_A_RAM_CODE_MASK_LONG \
+       (0xf << PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT)
+#define PMC_STRAPPING_OPT_A_RAM_CODE_MASK_SHORT        \
+       (0x3 << PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT)
+
 static void __iomem *apbmisc_base;
 static void __iomem *strapping_base;
+static bool long_ram_code;
 
 u32 tegra_read_chipid(void)
 {
@@ -54,6 +61,18 @@ u32 tegra_read_straps(void)
                return 0;
 }
 
+u32 tegra_read_ram_code(void)
+{
+       u32 straps = tegra_read_straps();
+
+       if (long_ram_code)
+               straps &= PMC_STRAPPING_OPT_A_RAM_CODE_MASK_LONG;
+       else
+               straps &= PMC_STRAPPING_OPT_A_RAM_CODE_MASK_SHORT;
+
+       return straps >> PMC_STRAPPING_OPT_A_RAM_CODE_SHIFT;
+}
+
 static const struct of_device_id apbmisc_match[] __initconst = {
        { .compatible = "nvidia,tegra20-apbmisc", },
        {},
@@ -112,4 +131,6 @@ void __init tegra_init_apbmisc(void)
        strapping_base = of_iomap(np, 1);
        if (!strapping_base)
                pr_err("ioremap tegra strapping_base failed\n");
+
+       long_ram_code = of_property_read_bool(np, "nvidia,long-ram-code");
 }
index b5f7b5f..b019e34 100644 (file)
@@ -56,6 +56,7 @@ struct tegra_sku_info {
 };
 
 u32 tegra_read_straps(void);
+u32 tegra_read_ram_code(void);
 u32 tegra_read_chipid(void);
 int tegra_fuse_readl(unsigned long offset, u32 *value);