Skip to contentSkip to conversation

arm: mx5: Add fuse supply enable in fsl_iim

PATCH Superseded Sergey Alyoshin 2 participants 2 messages Dec 17, 2013

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm: mx5: Add fuse supply enable in fsl_iim

Enable fuse supply before fuse programming and disable after.

Tested on i.MX53 custom board by writing MAC addresses in fuse bank 1.

---
 arch/arm/cpu/armv7/mx5/clock.c           |   12 ++++++++++++
 arch/arm/include/asm/arch-mx5/clock.h    |    1 +
 arch/arm/include/asm/arch-mx5/crm_regs.h |    3 +++
 drivers/misc/fsl_iim.c                   |   17 ++++++++++++++++-
 4 files changed, 32 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx5/clock.c +12 -0
index fb3b128..2ca87e4 100644
@@ -749,6 +749,18 @@ void enable_nfc_clk(unsigned char enable)
 		MXC_CCM_CCGR5_EMI_ENFC(cg));
 }
 
+#ifdef CONFIG_FSL_IIM
+void enable_efuse_prog_supply(bool enable)
+{
+	if (enable)
+		setbits_le32(&mxc_ccm->cgpr,
+				MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE);
+	else
+		clrbits_le32(&mxc_ccm->cgpr,
+				MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE);
+}
+#endif
+
 /* Config main_bus_clock for periphs */
 static int config_periph_clk(u32 ref, u32 freq)
 {
arch/arm/include/asm/arch-mx5/clock.h +1 -0
index 9ee79ae..3db4112 100644
@@ -53,5 +53,6 @@ void enable_usboh3_clk(bool enable);
 void mxc_set_sata_internal_clock(void);
 int enable_i2c_clk(unsigned char enable, unsigned i2c_num);
 void enable_nfc_clk(unsigned char enable);
+void enable_efuse_prog_supply(bool enable);
 
 #endif /* __ASM_ARCH_CLOCK_H */
arch/arm/include/asm/arch-mx5/crm_regs.h +3 -0
index 392881c..efe57e0 100644
@@ -305,6 +305,9 @@ struct mxc_ccm_reg {
 /* Define the bits in register CCDR */
 #define MXC_CCM_CCDR_IPU_HS_MASK			(0x1 << 17)
 
+/* Define the bits in register CGPR */
+#define MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE		(1 << 4)
+
 /* Define the bits in register CCGRx */
 #define MXC_CCM_CCGR_CG_MASK				0x3
 #define MXC_CCM_CCGR_CG_OFF				0x0
drivers/misc/fsl_iim.c +16 -1
index 44ae7b1..8ac4d21 100644
@@ -16,6 +16,9 @@
 #ifndef CONFIG_MPC512X
 #include <asm/arch/imx-regs.h>
 #endif
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+#include <asm/arch/clock.h>
+#endif
 
 /* FSL IIM-specific constants */
 #define STAT_BUSY		0x80
@@ -93,6 +96,14 @@ struct fsl_iim {
 	} bank[8];
 };
 
+#if !defined(CONFIG_MX51) && !defined(CONFIG_MX53)
+#define enable_efuse_prog_supply(enable)
+#endif
+static void enable_fuse_prog(bool enable)
+{
+	enable_efuse_prog_supply(enable);
+}
+
 static int prepare_access(struct fsl_iim **regs, u32 bank, u32 word, int assert,
 				const char *caller)
 {
@@ -237,12 +248,16 @@ int fuse_prog(u32 bank, u32 word, u32 val)
 	if (ret)
 		return ret;
 
+	enable_fuse_prog(1);
 	for (bit = 0; val; bit++, val >>= 1)
 		if (val & 0x01) {
 			ret = prog_bit(regs, bank, word, bit);
-			if (ret)
+			if (ret) {
+				enable_fuse_prog(0);
 				return ret;
+			}
 		}
+	enable_fuse_prog(0);
 
 	return 0;
 }
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/1 arm: mx5: Add fuse supply enable in fsl_iim

Dear Sergey Alyoshin,

Quoted 6 lines · Sergey Alyoshin

Enable fuse supply before fuse programming and disable after.

Tested on i.MX53 custom board by writing MAC addresses in fuse bank 1.

Usually, SoB and other tags are at the end of commit messages, and authors do not tag their own patches with Tested-by. However, it is possible to add such information as notes that won't be committed by adding a '---' after the SoB line above.

Quoted 73 lines
---
 arch/arm/cpu/armv7/mx5/clock.c           |   12 ++++++++++++
 arch/arm/include/asm/arch-mx5/clock.h    |    1 +
 arch/arm/include/asm/arch-mx5/crm_regs.h |    3 +++
 drivers/misc/fsl_iim.c                   |   17 ++++++++++++++++-
 4 files changed, 32 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/mx5/clock.c +12 -0
index fb3b128..2ca87e4 100644
@@ -749,6 +749,18 @@ void enable_nfc_clk(unsigned char enable)
 		MXC_CCM_CCGR5_EMI_ENFC(cg));
 }
 
+#ifdef CONFIG_FSL_IIM
+void enable_efuse_prog_supply(bool enable)
+{
+	if (enable)
+		setbits_le32(&mxc_ccm->cgpr,
+				MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE);
+	else
+		clrbits_le32(&mxc_ccm->cgpr,
+				MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE);
+}
+#endif
+
 /* Config main_bus_clock for periphs */
 static int config_periph_clk(u32 ref, u32 freq)
 {
arch/arm/include/asm/arch-mx5/clock.h +1 -0
index 9ee79ae..3db4112 100644
@@ -53,5 +53,6 @@ void enable_usboh3_clk(bool enable);
 void mxc_set_sata_internal_clock(void);
 int enable_i2c_clk(unsigned char enable, unsigned i2c_num);
 void enable_nfc_clk(unsigned char enable);
+void enable_efuse_prog_supply(bool enable);
 
 #endif /* __ASM_ARCH_CLOCK_H */
arch/arm/include/asm/arch-mx5/crm_regs.h +3 -0
index 392881c..efe57e0 100644
@@ -305,6 +305,9 @@ struct mxc_ccm_reg {
 /* Define the bits in register CCDR */
 #define MXC_CCM_CCDR_IPU_HS_MASK			(0x1 << 17)
 
+/* Define the bits in register CGPR */
+#define MXC_CCM_CGPR_EFUSE_PROG_SUPPLY_GATE		(1 << 4)
+
 /* Define the bits in register CCGRx */
 #define MXC_CCM_CCGR_CG_MASK				0x3
 #define MXC_CCM_CCGR_CG_OFF				0x0
drivers/misc/fsl_iim.c +3 -0
index 44ae7b1..8ac4d21 100644
@@ -16,6 +16,9 @@
 #ifndef CONFIG_MPC512X
 #include <asm/arch/imx-regs.h>
 #endif
+#if defined(CONFIG_MX51) || defined(CONFIG_MX53)
+#include <asm/arch/clock.h>
+#endif
 
 /* FSL IIM-specific constants */
 #define STAT_BUSY		0x80
@@ -93,6 +96,14 @@ struct fsl_iim {
 	} bank[8];

drivers/misc/fsl_iim.c struct fsl_iim { · line 106

Quoted 10 lines
drivers/misc/fsl_iim.c +8 -0
 };
 
+#if !defined(CONFIG_MX51) && !defined(CONFIG_MX53)
+#define enable_efuse_prog_supply(enable)
+#endif
+static void enable_fuse_prog(bool enable)
+{
+	enable_efuse_prog_supply(enable);
+}
+

What I meant in my review is that this enable_fuse_prog() function could just be removed. I was probably unclear. Here, you just have to keep the #if + #define, and in the lines below you should just use enable_efuse_prog_supply() instead of enable_fuse_prog().

Quoted 23 lines
drivers/misc/fsl_iim.c +0 -0
 static int prepare_access(struct fsl_iim **regs, u32 bank, u32 word, int
 assert,
 				const char *caller)

{

drivers/misc/fsl_iim.c +5 -2
@@ -237,12 +248,16 @@ int fuse_prog(u32 bank, u32 word, u32 val)
 	if (ret)
 		return ret;
 
+	enable_fuse_prog(1);
 	for (bit = 0; val; bit++, val >>= 1)
 		if (val & 0x01) {
 			ret = prog_bit(regs, bank, word, bit);
-			if (ret)
+			if (ret) {
+				enable_fuse_prog(0);
 				return ret;
+			}
 		}
+	enable_fuse_prog(0);
 
 	return 0;
 }
--
Quoted 1 line

1.7.10.4

Best regards,
Beno?t