rk3026: add efuse support
authorchenxing <chenxing@rock-chips.com>
Thu, 26 Sep 2013 04:09:27 +0000 (12:09 +0800)
committerchenxing <chenxing@rock-chips.com>
Thu, 26 Sep 2013 04:39:39 +0000 (12:39 +0800)
arch/arm/mach-rk2928/include/mach/io.h
arch/arm/mach-rk2928/io.c
arch/arm/mach-rk3026/clock_data.c
arch/arm/plat-rk/efuse.c
arch/arm/plat-rk/include/plat/efuse.h

index 6ed2a61a4cba35a565647c28f7e7e486dcce5a9f..7f49841a92ae28e9c0208b9d4347a77acb4ba995 100755 (executable)
 
 #define RK2928_EFUSE_PHYS       0x20090000
 #define RK2928_EFUSE_SIZE       SZ_4K
+#define RK2928_EFUSE_BASE       RK2928_IO_TO_VIRT1(RK2928_EFUSE_PHYS)
 
 #define GIC_CPU_BASE            RK2928_GICC_BASE
 #define GIC_DIST_BASE           RK2928_GICD_BASE
index 900b12adc0ad6fe475cc5f8f76ea7766a796df01..c45dd64f2cbf4f3f0beac03142c363db20747fb4 100755 (executable)
@@ -51,6 +51,7 @@ static struct map_desc rk2928_io_desc[] __initdata = {
        RK2928_DEVICE(DDR_PHY),
        RK2928_DEVICE(RKI2C0),
        RK2928_DEVICE(RKI2C1),
+       RK2928_DEVICE(EFUSE),
 };
 
 void __init rk2928_map_common_io(void)
index 94c4ccd566abee4cb3e8a216f32d923355a7471d..4b979a70fbb5a7d66e8cf4a84abc4ebef016f27a 100755 (executable)
@@ -2879,6 +2879,7 @@ static void __init rk2928_clock_common_init(unsigned long gpll_rate, unsigned lo
 
        //rk_dump_clock_info();
 }
+#include <plat/efuse.h>
 void __init _rk2928_clock_data_init(unsigned long gpll, unsigned long cpll, int flags)
 {
        struct clk_lookup *clk;
@@ -2895,6 +2896,8 @@ void __init _rk2928_clock_data_init(unsigned long gpll, unsigned long cpll, int
                clk_register(clk->clk);
        }
 
+       rk_efuse_init();
+
        CLKDATA_DBG("clk_recalculate_root_clocks_nolock\n");
        div_clk_for_pll_init();
        clk_recalculate_root_clocks_nolock();
index 8584964f60d8a1b120881cf2ae623aaf8004ed1f..c4fe7b9610f8be6b737338a51956fe94e7d45889 100644 (file)
 #define efuse_writel(val, offset)      writel_relaxed(val, RK30_EFUSE_BASE + offset)
 #endif
 
+#if defined(CONFIG_ARCH_RK3026)
+#define efuse_readl(offset)             readl_relaxed(RK2928_EFUSE_BASE + offset)
+#define efuse_writel(val, offset)       writel_relaxed(val, RK2928_EFUSE_BASE + offset)
+#endif
+
 u8 efuse_buf[32 + 1] = {0, 0};
 
 static int efuse_readregs(u32 addr, u32 length, u8 *buf)
@@ -59,7 +64,38 @@ static int efuse_readregs(u32 addr, u32 length, u8 *buf)
 
 void rk_efuse_init(void)
 {
+#if defined(CONFIG_ARCH_RK3026)
+       u8 tmp_buf[32];
+       int i, j, err = 0;
+
+       efuse_readregs(0x0, 32, efuse_buf);
+
+       /*
+        * i = 10,      need time = 2,860,875   ns
+        * i = 100,     need time = 27,327,000  ns
+        */
+       for (i = 0; i < 10; i++){
+               efuse_readregs(0x0, 32, tmp_buf);
+               for (j = 0; j < 32; j++){
+                       if (efuse_buf[j] != tmp_buf[j]){
+                               printk(KERN_WARNING ":%s:rk3026 efuse bit err\n", __func__);
+                               efuse_readregs(0x0, 32, efuse_buf);
+                               i = 0;
+                               err++;
+                               break;
+                       }
+               }
+
+               if (err >= 500) {
+                       printk(KERN_ERR "%s:rk3026 get efuse err\n", __func__);
+                       efuse_buf[5] = 0x00;    /* set default SOC version */
+                       efuse_buf[22] = 0x00;   /* clean msg about leakage */
+                       break;
+               }
+       }
+#else
        efuse_readregs(0x0, 32, efuse_buf);
+#endif
 }
 
 int rk_pll_flag(void)
@@ -89,3 +125,8 @@ int rk3028_version_val(void)
 {
        return efuse_buf[5];
 }
+
+int rk3026_version_val(void)
+{
+       return efuse_buf[5];
+}
index 9583cc363c6a24674e2d0af54e6a611258465c50..bd7bf24897d00c64978e1efdc99690833476ceeb 100644 (file)
@@ -4,7 +4,11 @@
 #include <asm/types.h>
 
 /* eFuse controller register */
+#if defined(CONFIG_ARCH_RK3026)
+#define EFUSE_A_SHIFT          (8)
+#else
 #define EFUSE_A_SHIFT          (6)
+#endif
 #define EFUSE_A_MASK           (0xFF)
 //#define EFUSE_PD             (1 << 5)
 //#define EFUSE_PS             (1 << 4)
@@ -22,5 +26,6 @@ int rk_pll_flag(void);
 int rk_tflag(void);
 int rk_leakage_val(void);
 int rk3028_version_val(void);
+int rk3026_version_val(void);
 
 #endif