]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/misc/fsl_iim.c
tpm: tpm_tis_i2c: Merge struct tpm_dev into tpm_chip
[karo-tx-uboot.git] / drivers / misc / fsl_iim.c
index 9179fbb0db923bacf57d0b3b61b0423b296a879f..008919f99b64bbc0b9cb09a4b925c5327133ea20 100644 (file)
@@ -6,23 +6,7 @@
  * Copyright 2008 Silicon Turnkey Express, Inc.
  * Martha Marx <mmarx@silicontkx.com>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -32,6 +16,9 @@
 #ifndef CONFIG_MPC512X
 #include <asm/arch/imx-regs.h>
 #endif
+#if defined(CONFIG_SOC_MX51) || defined(CONFIG_SOC_MX53)
+#include <asm/arch/clock.h>
+#endif
 
 /* FSL IIM-specific constants */
 #define STAT_BUSY              0x80
@@ -102,13 +89,17 @@ struct fsl_iim {
        u32 sdat;
        u32 prev;
        u32 srev;
-       u32 prg_p;
+       u32 preg_p;
        u32 scs[0x1f5];
        struct {
                u32 word[0x100];
        } bank[8];
 };
 
+#if !defined(CONFIG_SOC_MX51) && !defined(CONFIG_SOC_MX53)
+#define enable_efuse_prog_supply(enable)
+#endif
+
 static int prepare_access(struct fsl_iim **regs, u32 bank, u32 word, int assert,
                                const char *caller)
 {
@@ -178,7 +169,7 @@ static void direct_access(struct fsl_iim *regs, u32 bank, u32 word, u32 bit,
        iim_write32(&regs->ua, bank << 3 | word >> 5);
        iim_write32(&regs->la, (word << 3 | bit) & 0xff);
        if (fctl == FCTL_PRG)
-               iim_write32(&regs->prg_p, 0xaa);
+               iim_write32(&regs->preg_p, 0xaa);
        iim_setbits32(&regs->fctl, fctl);
        while (iim_read32(&regs->stat) & STAT_BUSY)
                udelay(20);
@@ -217,7 +208,7 @@ static int prog_bit(struct fsl_iim *regs, u32 bank, u32 word, u32 bit)
 
        clear_status(regs);
        direct_access(regs, bank, word, bit, FCTL_PRG, &stat, &err);
-       iim_write32(&regs->prg_p, 0x00);
+       iim_write32(&regs->preg_p, 0x00);
 
        if (err & ERR_PRGE) {
                puts("fsl_iim fuse_prog(): Program error\n");
@@ -253,12 +244,16 @@ int fuse_prog(u32 bank, u32 word, u32 val)
        if (ret)
                return ret;
 
+       enable_efuse_prog_supply(1);
        for (bit = 0; val; bit++, val >>= 1)
                if (val & 0x01) {
                        ret = prog_bit(regs, bank, word, bit);
-                       if (ret)
+                       if (ret) {
+                               enable_efuse_prog_supply(0);
                                return ret;
+                       }
                }
+       enable_efuse_prog_supply(0);
 
        return 0;
 }