Skip to contentSkip to conversation

imx: Homogenize and fix fuse register definitions

PATCH New Benoît Thébaudeau 2 participants 25 messages Apr 23, 2013 – Apr 28, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/10 imx: Homogenize and fix fuse register definitions

IIM:
- Homogenize prg_p naming (the reference manuals are not always self-consistent for that).
- Add missing SCSx and bank registers.
- Fix the number of banks on i.MX53.

OCOTP:
- Rename iim to ocotp in order to avoid confusion.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the reference manual.
- Merge the existing spinoff gp1 fuse definition on i.MX6.
- Fix the number of banks on i.MX6.

---
Changes in v4:
- Convert spaces to tabs.

Changes in v3:
- Rebase against latest u-boot-imx/master.
- Fix the number of banks on i.MX6.
- Rename iim to ocotp on i.MX6 in order to avoid confusion, and merge in the existing gp1 fuse definition.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the reference manual.

Changes in v2:
- Rebase against latest master.

 arch/arm/cpu/armv7/mx6/soc.c                  |    4 ++--
 arch/arm/include/asm/arch-mx25/imx-regs.h     |    8 ++++++--
 arch/arm/include/asm/arch-mx27/imx-regs.h     |    2 +-
 arch/arm/include/asm/arch-mx31/imx-regs.h     |    9 +++++++--
 arch/arm/include/asm/arch-mx35/imx-regs.h     |    7 ++++++-
 arch/arm/include/asm/arch-mx5/imx-regs.h      |    6 +++++-
 arch/arm/include/asm/arch-mx6/imx-regs.h      |   19 +++++++------------
 board/freescale/mx6qsabreauto/mx6qsabreauto.c |    5 ++++-
 8 files changed, 38 insertions(+), 22 deletions(-)
arch/arm/cpu/armv7/mx6/soc.c +2 -2
index 69b8487..fc436fb 100644
@@ -172,8 +172,8 @@ void enable_caches(void)
 #if defined(CONFIG_FEC_MXC)
 void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
-	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
-	struct fuse_bank *bank = &iim->bank[4];
+	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+	struct fuse_bank *bank = &ocotp->bank[4];
 	struct fuse_bank4_regs *fuse =
 			(struct fuse_bank4_regs *)bank->fuse_regs;
 
arch/arm/include/asm/arch-mx25/imx-regs.h +6 -2
index 5f4b543..99c32d4 100644
@@ -113,8 +113,12 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
-	u32 res1[0x1f5];
+	u32 iim_prg_p;
+	u32 iim_scs0;
+	u32 iim_scs1;
+	u32 iim_scs2;
+	u32 iim_scs3;
+	u32 res1[0x1f1];
 	struct fuse_bank {
 		u32 fuse_regs[0x20];
 		u32 fuse_rsvd[0xe0];
arch/arm/include/asm/arch-mx27/imx-regs.h +1 -1
index 2f6c823..aee058f 100644
@@ -176,7 +176,7 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
+	u32 iim_prg_p;
 	u32 iim_scs0;
 	u32 iim_scs1;
 	u32 iim_scs2;
arch/arm/include/asm/arch-mx31/imx-regs.h +7 -2
index 3f58318..f67f49c 100644
@@ -68,7 +68,7 @@ struct cspi_regs {
 	u32 test;
 };
 
-/* IIM Control Registers */
+/* IIM control registers */
 struct iim_regs {
 	u32 iim_stat;
 	u32 iim_statm;
@@ -80,11 +80,16 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
+	u32 iim_prg_p;
 	u32 iim_scs0;
 	u32 iim_scs1;
 	u32 iim_scs2;
 	u32 iim_scs3;
+	u32 res[0x1f1];
+	struct fuse_bank {
+		u32 fuse_regs[0x20];
+		u32 fuse_rsvd[0xe0];
+	} bank[3];
 };
 
 struct iomuxc_regs {
arch/arm/include/asm/arch-mx35/imx-regs.h +6 -1
index 7f337be..64546d2 100644
@@ -262,11 +262,16 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
+	u32 iim_prg_p;
 	u32 iim_scs0;
 	u32 iim_scs1;
 	u32 iim_scs2;
 	u32 iim_scs3;
+	u32 res1[0x1f1];
+	struct fuse_bank {
+		u32 fuse_regs[0x20];
+		u32 fuse_rsvd[0xe0];
+	} bank[3];
 };
 
 /* General Purpose Timer (GPT) registers */
arch/arm/include/asm/arch-mx5/imx-regs.h +5 -1
index a71cc13..b237d5f 100644
@@ -499,7 +499,7 @@ struct iim_regs {
 	u32	sdat;
 	u32	prev;
 	u32	srev;
-	u32	preg_p;
+	u32	prg_p;
 	u32	scs0;
 	u32	scs1;
 	u32	scs2;
@@ -508,7 +508,11 @@ struct iim_regs {
 	struct fuse_bank {
 		u32	fuse_regs[0x20];
 		u32	fuse_rsvd[0xe0];
+#if defined(CONFIG_MX51)
 	} bank[4];
+#elif defined(CONFIG_MX53)
+	} bank[5];
+#endif
 };
 
 struct fuse_bank0_regs {
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -12
index 0e4d8fa..680e752 100644
@@ -229,7 +229,6 @@
 
 #define CHIP_REV_1_0                 0x10
 #define IRAM_SIZE                    0x00040000
-#define IMX_IIM_BASE                 OCOTP_BASE_ADDR
 #define FEC_QUIRK_ENET_MAC
 
 #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
@@ -258,12 +257,6 @@ struct src {
 	u32     gpr10;
 };
 
-/* OCOTP Registers */
-struct ocotp_regs {
-	u32	reserved[0x198];
-	u32	gp1;	/* 0x660 */
-};
-
 /* GPR3 bitfields */
 #define IOMUXC_GPR3_GPU_DBG_OFFSET		29
 #define IOMUXC_GPR3_GPU_DBG_MASK		(3<<IOMUXC_GPR3_GPU_DBG_OFFSET)
@@ -438,7 +431,7 @@ struct cspi_regs {
 	ECSPI5_BASE_ADDR
 #endif
 
-struct iim_regs {
+struct ocotp_regs {
 	u32	ctrl;
 	u32	ctrl_set;
 	u32     ctrl_clr;
@@ -449,9 +442,9 @@ struct iim_regs {
 	u32     rsvd1[3];
 	u32     read_ctrl;
 	u32     rsvd2[3];
-	u32     fuse_data;
+	u32	read_fuse_data;
 	u32     rsvd3[3];
-	u32     sticky;
+	u32	sw_sticky;
 	u32     rsvd4[3];
 	u32     scs;
 	u32     scs_set;
@@ -466,7 +459,7 @@ struct iim_regs {
 
 	struct fuse_bank {
 		u32	fuse_regs[0x20];
-	} bank[15];
+	} bank[16];
 };
 
 struct fuse_bank4_regs {
@@ -477,7 +470,9 @@ struct fuse_bank4_regs {
 	u32	mac_addr_low;
 	u32     rsvd2[3];
 	u32     mac_addr_high;
-	u32	rsvd3[0x13];
+	u32	rsvd3[0xb];
+	u32	gp1;
+	u32	rsvd4[7];
 };
 
 struct aipstz_regs {
board/freescale/mx6qsabreauto/mx6qsabreauto.c +4 -1
index aec3286..a3afa58 100644
@@ -179,7 +179,10 @@ static int mx6sabre_rev(void)
 	 * i.MX6Q ARD RevB: 0x02
 	 */
 	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
-	int reg = readl(&ocotp->gp1);
+	struct fuse_bank *bank = &ocotp->bank[4];
+	struct fuse_bank4_regs *fuse =
+			(struct fuse_bank4_regs *)bank->fuse_regs;
+	int reg = readl(&fuse->gp1);
 	int ret;
 
 	switch (reg >> 8 & 0x0F) {
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v4 1/10 imx: Homogenize and fix fuse register definitions

Quoted 15 lines · Beno?t Th?baudeau

IIM:
- Homogenize prg_p naming (the reference manuals are not always self-consistent
for that).
- Add missing SCSx and bank registers.
- Fix the number of banks on i.MX53.

OCOTP:
- Rename iim to ocotp in order to avoid confusion.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the
reference manual.
- Merge the existing spinoff gp1 fuse definition on i.MX6.
- Fix the number of banks on i.MX6.

Quoted 1 line

FYI, I have build- and runtime-tested this series on i.MX25/35/51/6, and build-tested it on mpc512x.

Note that the original OCOTP driver from Freescale has several bugs in the function setting the timing register:
- It sets tRELAX to 15.2 ns although it should be > 16.2 ns (for 66-MHz IPG clock).
- It uses DEF_RELAX instead of relax to set strobe_prog/read, i.e. it mixes ns with IPG clock cycles. The result is tPGM = 10.6 ?s instead of 10 ?s (but 9 ?s < tPGM < 11 ?s is still satisfied), and tRD = 636 ns > 36 ns. So just by chance, this does not break the hardware behavior.
- It unexpectedly clears the WAIT bit-field, which has a non-zero reset value.

Best regards,
Beno?t

#2 lore raw

PATCH v4 2/10 imx: Add useful fuse definitions

In reply to Benoît Thébaudeau

Define the UID (SoC unique ID) fuses, and the fuses available for the user.

---
Changes in v4:
- Add i.MX6 UID.

Changes in v3:
- Add i.MX6 GP2.

Changes in v2:
- Rebase against latest master.

 arch/arm/include/asm/arch-mx25/imx-regs.h |   11 ++++++++++-
 arch/arm/include/asm/arch-mx31/imx-regs.h |   12 ++++++++++++
 arch/arm/include/asm/arch-mx35/imx-regs.h |   12 ++++++++++++
 arch/arm/include/asm/arch-mx5/imx-regs.h  |   16 +++++++++++++++-
 arch/arm/include/asm/arch-mx6/imx-regs.h  |   13 ++++++++++++-
 5 files changed, 61 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-mx25/imx-regs.h +10 -1
index 99c32d4..cf7bb5a 100644
@@ -126,10 +126,19 @@ struct iim_regs {
 };
 
 struct fuse_bank0_regs {
-	u32 fuse0_25[0x1a];
+	u32 fuse0_7[8];
+	u32 uid[8];
+	u32 fuse16_25[0xa];
 	u32 mac_addr[6];
 };
 
+struct fuse_bank1_regs {
+	u32 fuse0_21[0x16];
+	u32 usr5;
+	u32 fuse23_29[7];
+	u32 usr6[2];
+};
+
 /* Multi-Layer AHB Crossbar Switch (MAX) registers */
 struct max_regs {
 	u32 mpr0;
arch/arm/include/asm/arch-mx31/imx-regs.h +12 -0
index f67f49c..5d8d8f4 100644
@@ -92,6 +92,18 @@ struct iim_regs {
 	} bank[3];
 };
 
+struct fuse_bank0_regs {
+	u32 fuse0_5[6];
+	u32 usr;
+	u32 fuse7_15[9];
+};
+
+struct fuse_bank2_regs {
+	u32 fuse0;
+	u32 uid[8];
+	u32 fuse9_15[7];
+};
+
 struct iomuxc_regs {
 	u32 unused1;
 	u32 unused2;
arch/arm/include/asm/arch-mx35/imx-regs.h +12 -0
index 64546d2..63c6e24 100644
@@ -274,6 +274,18 @@ struct iim_regs {
 	} bank[3];
 };
 
+struct fuse_bank0_regs {
+	u32 fuse0_7[8];
+	u32 uid[8];
+	u32 fuse16_31[0x10];
+};
+
+struct fuse_bank1_regs {
+	u32 fuse0_21[0x16];
+	u32 usr;
+	u32 fuse23_31[9];
+};
+
 /* General Purpose Timer (GPT) registers */
 struct gpt_regs {
 	u32 ctrl;	/* control */
arch/arm/include/asm/arch-mx5/imx-regs.h +15 -1
index b237d5f..559547c 100644
@@ -516,8 +516,14 @@ struct iim_regs {
 };
 
 struct fuse_bank0_regs {
-	u32	fuse0_23[24];
+	u32	fuse0_7[8];
+	u32	uid[8];
+	u32	fuse16_23[8];
+#if defined(CONFIG_MX51)
+	u32	imei[8];
+#elif defined(CONFIG_MX53)
 	u32	gp[8];
+#endif
 };
 
 struct fuse_bank1_regs {
@@ -526,6 +532,14 @@ struct fuse_bank1_regs {
 	u32	fuse15_31[0x11];
 };
 
+#if defined(CONFIG_MX53)
+struct fuse_bank4_regs {
+	u32	fuse0_4[5];
+	u32	gp[3];
+	u32	fuse8_31[0x18];
+};
+#endif
+
 #endif /* __ASSEMBLER__*/
 
 #endif				/* __ASM_ARCH_MX5_IMX_REGS_H__ */
arch/arm/include/asm/arch-mx6/imx-regs.h +12 -1
index 680e752..03abb2a 100644
@@ -462,6 +462,15 @@ struct ocotp_regs {
 	} bank[16];
 };
 
+struct fuse_bank0_regs {
+	u32	lock;
+	u32	rsvd0[3];
+	u32	uid_low;
+	u32	rsvd1[3];
+	u32	uid_high;
+	u32	rsvd2[0x17];
+};
+
 struct fuse_bank4_regs {
 	u32	sjc_resp_low;
 	u32     rsvd0[3];
@@ -472,7 +481,9 @@ struct fuse_bank4_regs {
 	u32     mac_addr_high;
 	u32	rsvd3[0xb];
 	u32	gp1;
-	u32	rsvd4[7];
+	u32	rsvd4[3];
+	u32	gp2;
+	u32	rsvd5[3];
 };
 
 struct aipstz_regs {
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v4 2/10 imx: Add useful fuse definitions

Quoted 4 lines · Beno?t Th?baudeau

Define the UID (SoC unique ID) fuses, and the fuses available for the user.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#4 lore raw

PATCH v4 3/10 Add fuse API and commands

In reply to Benoît Thébaudeau

This can be useful for fuse-like hardware, OTP SoC options, etc.

---
Changes in v4:
- Remove the bit interface.
- Add more details to the documentation of the programming operation.

Changes in v3:
- Rebase against latest u-boot-imx/master.
- Update copyright years.
- Rename the "ovride" command to "override" as it is nicer to read.
- For obvious safety reasons, ask the user to confirm each fuse programming operation, unless the '-y' command line option was given, which can be used in scripts.
- Rename "row" to "word" since it is less confusing and it is vocabulary common to iim and ocotp in the reference manuals.
- Add doc/README.fuse.

Changes in v2:
- Rebase against latest master.

 README                   |    1 +
 common/Makefile          |    1 +
 common/cmd_fuse.c        |  168 ++++++++++++++++++++++++++++++++++++++++++++++
 doc/README.fuse          |   67 ++++++++++++++++++
 include/config_cmd_all.h |    1 +
 include/fuse.h           |   44 ++++++++++++
 6 files changed, 282 insertions(+)
 create mode 100644 common/cmd_fuse.c
 create mode 100644 doc/README.fuse
 create mode 100644 include/fuse.h
README +1 -0
index 0bc0af5..7f9f547 100644
@@ -844,6 +844,7 @@ The following options need to be configured:
 		CONFIG_CMD_FDOS		* Dos diskette Support
 		CONFIG_CMD_FLASH	  flinfo, erase, protect
 		CONFIG_CMD_FPGA		  FPGA device initialization support
+		CONFIG_CMD_FUSE		  Device fuse support
 		CONFIG_CMD_GETTIME	* Get time since boot
 		CONFIG_CMD_GO		* the 'go' command (exec code)
 		CONFIG_CMD_GREPENV	* search environment
common/Makefile +1 -0
index 0e0fff1..1cfb132 100644
@@ -111,6 +111,7 @@ ifdef CONFIG_FPGA
 COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o
 endif
 COBJS-$(CONFIG_CMD_FS_GENERIC) += cmd_fs.o
+COBJS-$(CONFIG_CMD_FUSE) += cmd_fuse.o
 COBJS-$(CONFIG_CMD_GETTIME) += cmd_gettime.o
 COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o
 COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o
common/cmd_fuse.c new file +168 -0

168 lines not on this page · raw message

doc/README.fuse new file +67 -0

67 lines not on this page · raw message

include/config_cmd_all.h +1 -0
index 53a2f05..d847069 100644
@@ -40,6 +40,7 @@
 #define CONFIG_CMD_FDOS		/* Floppy DOS support		*/
 #define CONFIG_CMD_FLASH	/* flinfo, erase, protect	*/
 #define CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
+#define CONFIG_CMD_FUSE		/* Device fuse support		*/
 #define CONFIG_CMD_GETTIME	/* Get time since boot         */
 #define CONFIG_CMD_HASH		/* calculate hash / digest	*/
 #define CONFIG_CMD_HWFLOW	/* RTS/CTS hw flow control	*/
include/fuse.h new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#5 lore raw

PATCH v4 3/10 Add fuse API and commands

Quoted 4 lines · Beno?t Th?baudeau

This can be useful for fuse-like hardware, OTP SoC options, etc.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#6 lore raw

PATCH v4 4/10 Add fsl_iim driver

In reply to Benoît Thébaudeau

Add a fsl_iim driver common to i.MX and MPC.

---
Changes in v4:
- Remove the bit interface.
- Fix the checkpatch warning about the usage of volatile.
- Remove useless quotes in #error.
- Unsplit long error messages for grep-ability.
- Remove useless #include-s.
- Drop CONFIG_SYS_FSL_IIM_ADDR.
- Use iim_setbits32() where appropriate.
- Create helper functions to remove duplicate code and to improve code readability.

Changes in v3:
- Update copyright years.
- Rename "row" to "word" since it is less confusing and it is vocabulary common to iim and ocotp in the reference manuals.
- Add doc/README.fsl_iim.

Changes in v2:
- Rebase against latest master.

 arch/arm/include/asm/arch-mx25/imx-regs.h |    1 +
 arch/arm/include/asm/arch-mx27/imx-regs.h |    1 +
 arch/arm/include/asm/arch-mx31/imx-regs.h |    1 +
 arch/powerpc/include/asm/immap_512x.h     |    2 +
 doc/README.fsl_iim                        |   48 +++++
 drivers/misc/Makefile                     |    1 +
 drivers/misc/fsl_iim.c                    |  286 +++++++++++++++++++++++++++++
 7 files changed, 340 insertions(+)
 create mode 100644 doc/README.fsl_iim
 create mode 100644 drivers/misc/fsl_iim.c
arch/arm/include/asm/arch-mx25/imx-regs.h +1 -0
index cf7bb5a..206ac76 100644
@@ -253,6 +253,7 @@ struct aips_regs {
 #define IMX_PWM1_BASE		(0x53FE0000)
 #define IMX_RTIC_BASE		(0x53FEC000)
 #define IMX_IIM_BASE		(0x53FF0000)
+#define IIM_BASE_ADDR		IMX_IIM_BASE
 #define IMX_USB_BASE		(0x53FF4000)
 #define IMX_USB_PORT_OFFSET	0x200
 #define IMX_CSI_BASE		(0x53FF8000)
arch/arm/include/asm/arch-mx27/imx-regs.h +1 -0
index aee058f..8867e9f 100644
@@ -222,6 +222,7 @@ struct fuse_bank0_regs {
 #define IMX_PLL_BASE		(0x27000 + IMX_IO_BASE)
 #define IMX_SYSTEM_CTL_BASE	(0x27800 + IMX_IO_BASE)
 #define IMX_IIM_BASE		(0x28000 + IMX_IO_BASE)
+#define IIM_BASE_ADDR		IMX_IIM_BASE
 #define IMX_FEC_BASE		(0x2b000 + IMX_IO_BASE)
 
 #define IMX_ESD_BASE		(0xD8001000)
arch/arm/include/asm/arch-mx31/imx-regs.h +1 -0
index 5d8d8f4..67fddac 100644
@@ -574,6 +574,7 @@ struct esdc_regs {
 #define CCMR_CKIH	(2 << 1)
 
 #define MX31_IIM_BASE_ADDR	0x5001C000
+#define IIM_BASE_ADDR		MX31_IIM_BASE_ADDR
 
 #define PDR0_CSI_PODF(x)	(((x) & 0x3f) << 26)
 #define PDR0_CSI_PRDF(x)	(((x) & 0x7) << 23)
arch/powerpc/include/asm/immap_512x.h +2 -0
index d96e536..8248219 100644
@@ -1272,4 +1272,6 @@ static inline u32 get_pata_base (void)
 #define CONFIG_SYS_MPC512x_USB_ADDR \
 			(CONFIG_SYS_IMMR + CONFIG_SYS_MPC512x_USB_OFFSET)
 
+#define IIM_BASE_ADDR	(CONFIG_SYS_IMMR + offsetof(immap_t, iim))
+
 #endif /* __IMMAP_512x__ */
doc/README.fsl_iim new file +48 -0

48 lines not on this page · raw message

drivers/misc/Makefile +1 -0
index 8cdc3b6..c6dadd4 100644
@@ -28,6 +28,7 @@ LIB	:= $(obj)libmisc.o
 COBJS-$(CONFIG_ALI152X) += ali512x.o
 COBJS-$(CONFIG_DS4510)  += ds4510.o
 COBJS-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
+COBJS-$(CONFIG_FSL_IIM) += fsl_iim.o
 COBJS-$(CONFIG_GPIO_LED) += gpio_led.o
 COBJS-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 COBJS-$(CONFIG_NS87308) += ns87308.o
drivers/misc/fsl_iim.c new file +286 -0

286 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#7 lore raw

PATCH v4 4/10 Add fsl_iim driver

Quoted 24 lines · Beno?t Th?baudeau

Add a fsl_iim driver common to i.MX and MPC.

---
Changes in v4:
- Remove the bit interface.
- Fix the checkpatch warning about the usage of volatile.
- Remove useless quotes in #error.
- Unsplit long error messages for grep-ability.
- Remove useless #include-s.
- Drop CONFIG_SYS_FSL_IIM_ADDR.
- Use iim_setbits32() where appropriate.
- Create helper functions to remove duplicate code and to improve code readability.

Changes in v3:
- Update copyright years.
- Rename "row" to "word" since it is less confusing and it is vocabulary common to iim and ocotp in the reference manuals.
- Add doc/README.fsl_iim.

Changes in v2:
- Rebase against latest master.

Quoted 11 lines
 arch/arm/include/asm/arch-mx25/imx-regs.h |    1 +
 arch/arm/include/asm/arch-mx27/imx-regs.h |    1 +
 arch/arm/include/asm/arch-mx31/imx-regs.h |    1 +
 arch/powerpc/include/asm/immap_512x.h     |    2 +
 doc/README.fsl_iim                        |   48 +++++
 drivers/misc/Makefile                     |    1 +
 drivers/misc/fsl_iim.c                    |  286 +++++++++++++++++++++++++++++
 7 files changed, 340 insertions(+)
 create mode 100644 doc/README.fsl_iim
 create mode 100644 drivers/misc/fsl_iim.c

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#8 lore raw

PATCH v4 5/10 mpc: iim: Switch to common fsl_iim

In reply to Benoît Thébaudeau

Make all mpc512x code point to the new common fsl_iim driver, and remove the former mpc512x-specific iim driver.

---
Changes in v4:
- Rebase against latest master.
- Make CONFIG_FSL_IIM and CONFIG_CMD_FUSE definitions consistent across all config files.
- Add a detailed patch description.

Changes in v3: None
Changes in v2:
- Rebase against latest master.

 arch/powerpc/cpu/mpc512x/Makefile   |    1 -
 arch/powerpc/cpu/mpc512x/cpu_init.c |    2 +-
 arch/powerpc/cpu/mpc512x/iim.c      |  394 -----------------------------------
 include/configs/ac14xx.h            |    5 +
 include/configs/aria.h              |    2 +-
 include/configs/mecp5123.h          |    2 +-
 include/configs/mpc5121ads.h        |    2 +-
 include/configs/pdm360ng.h          |    7 +
 8 files changed, 16 insertions(+), 399 deletions(-)
 delete mode 100644 arch/powerpc/cpu/mpc512x/iim.c
arch/powerpc/cpu/mpc512x/Makefile +0 -1
index b53232f..4f4c9ec 100644
@@ -38,7 +38,6 @@ COBJS-y += serial.o
 COBJS-y += speed.o
 COBJS-$(CONFIG_FSL_DIU_FB) += diu.o
 COBJS-$(CONFIG_CMD_IDE) += ide.o
-COBJS-$(CONFIG_IIM) += iim.o
 COBJS-$(CONFIG_PCI) += pci.o
 
 # Stub implementations of cache management functions for USB
arch/powerpc/cpu/mpc512x/cpu_init.c +1 -1
index b308cb4..0e20ded 100644
@@ -201,7 +201,7 @@ void cpu_init_f (volatile immap_t * im)
 	 */
 	out_be32(&im->clk.sccr[0], SCCR1_CLOCKS_EN);
 	out_be32(&im->clk.sccr[1], SCCR2_CLOCKS_EN);
-#if defined(CONFIG_IIM) || defined(CONFIG_CMD_FUSE)
+#if defined(CONFIG_FSL_IIM) || defined(CONFIG_CMD_FUSE)
 	setbits_be32(&im->clk.sccr[1], CLOCK_SCCR2_IIM_EN);
 #endif
 }
arch/powerpc/cpu/mpc512x/iim.c deleted +0 -394

394 lines not on this page · raw message

include/configs/ac14xx.h +5 -0
index ac7e877..7cb10fb 100644
@@ -368,6 +368,11 @@
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
 /*
+ * IIM - IC Identification Module
+ */
+#undef CONFIG_FSL_IIM
+
+/*
  * EEPROM configuration for Atmel AT24C01:
  * 8-bit addresses, 30ms write delay, 32-Byte Page Write Mode
  */
include/configs/aria.h +1 -1
index b425399..5318aaf 100644
@@ -383,7 +383,7 @@
 /*
  * IIM - IC Identification Module
  */
-#undef CONFIG_IIM
+#undef CONFIG_FSL_IIM
 
 /*
  * EEPROM configuration for Atmel AT24C32A-10TQ-2.7:
include/configs/mecp5123.h +1 -1
index af30257..c4f245b 100644
@@ -275,7 +275,7 @@
 /*
  * IIM - IC Identification Module
  */
-#undef CONFIG_IIM
+#undef CONFIG_FSL_IIM
 
 /*
  * EEPROM configuration
include/configs/mpc5121ads.h +1 -1
index 6e6af62..64ce52d 100644
@@ -370,7 +370,7 @@
 /*
  * IIM - IC Identification Module
  */
-#undef CONFIG_IIM
+#undef CONFIG_FSL_IIM
 
 /*
  * EEPROM configuration
include/configs/pdm360ng.h +7 -0
index 306abcc..db95cb0 100644
@@ -341,6 +341,11 @@
 #define CONFIG_SYS_I2C_SLAVE		0x7F
 
 /*
+ * IIM - IC Identification Module
+ */
+#undef CONFIG_FSL_IIM
+
+/*
  * EEPROM configuration
  */
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		2	/* 16-bit EEPROM addr */
@@ -402,6 +407,8 @@
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_REGINFO
 
+#undef CONFIG_CMD_FUSE
+
 #ifdef CONFIG_VIDEO
 #define CONFIG_CMD_BMP
 #endif
Signature · 1 line
1.7.10.4
#9 lore raw

PATCH v4 5/10 mpc: iim: Switch to common fsl_iim

Quoted 5 lines · Beno?t Th?baudeau

Make all mpc512x code point to the new common fsl_iim driver, and remove the former mpc512x-specific iim driver.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#10 lore raw

PATCH v4 6/10 mx51evk: Enable support for iim

In reply to Benoît Thébaudeau

This allows to test the iim driver in the mainline tree.

---
Changes in v4:
- Drop CONFIG_SYS_FSL_IIM_ADDR.

Changes in v3:
- New patch.

Changes in v2: None

 include/configs/mx51evk.h |    3 +++
 1 file changed, 3 insertions(+)
include/configs/mx51evk.h +3 -0
index cb3d938..6a8a319 100644
@@ -53,6 +53,9 @@
 /*
  * Hardware drivers
  */
+#define CONFIG_FSL_IIM
+#define CONFIG_CMD_FUSE
+
 #define CONFIG_MXC_UART
 #define CONFIG_MXC_UART_BASE	UART1_BASE
 #define CONFIG_MXC_GPIO
Signature · 1 line
1.7.10.4
#11 lore raw

PATCH v4 6/10 mx51evk: Enable support for iim

Quoted 4 lines · Beno?t Th?baudeau

This allows to test the iim driver in the mainline tree.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#12 lore raw

PATCH v4 7/10 Add mxc_ocotp driver

In reply to Benoît Thébaudeau

Add an mxc_ocotp driver for i.MX6.

---
Changes in v4:
- New patch.

Changes in v3: None
Changes in v2: None

 arch/arm/cpu/armv7/mx6/clock.c        |   14 +++
 arch/arm/include/asm/arch-mx6/clock.h |    1 +
 doc/README.mxc_ocotp                  |   50 ++++++++
 drivers/misc/Makefile                 |    1 +
 drivers/misc/mxc_ocotp.c              |  216 +++++++++++++++++++++++++++++++++
 5 files changed, 282 insertions(+)
 create mode 100644 doc/README.mxc_ocotp
 create mode 100644 drivers/misc/mxc_ocotp.c
arch/arm/cpu/armv7/mx6/clock.c +14 -0
index 8cba4fd..3c0d908 100644
@@ -37,6 +37,20 @@ enum pll_clocks {
 
 struct mxc_ccm_reg *imx_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 
+#ifdef CONFIG_MXC_OCOTP
+void enable_ocotp_clk(unsigned char enable)
+{
+	u32 reg;
+
+	reg = __raw_readl(&imx_ccm->CCGR2);
+	if (enable)
+		reg |= MXC_CCM_CCGR2_OCOTP_CTRL_MASK;
+	else
+		reg &= ~MXC_CCM_CCGR2_OCOTP_CTRL_MASK;
+	__raw_writel(reg, &imx_ccm->CCGR2);
+}
+#endif
+
 void enable_usboh3_clk(unsigned char enable)
 {
 	u32 reg;
arch/arm/include/asm/arch-mx6/clock.h +1 -0
index db377cc..cfd4edc 100644
@@ -61,6 +61,7 @@ enum mxc_clock {
 u32 imx_get_uartclk(void);
 u32 imx_get_fecclk(void);
 unsigned int mxc_get_clock(enum mxc_clock clk);
+void enable_ocotp_clk(unsigned char enable);
 void enable_usboh3_clk(unsigned char enable);
 int enable_sata_clock(void);
 int enable_i2c_clk(unsigned char enable, unsigned i2c_num);
doc/README.mxc_ocotp new file +50 -0

50 lines not on this page · raw message

drivers/misc/Makefile +1 -0
index c6dadd4..5d869b4 100644
@@ -31,6 +31,7 @@ COBJS-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
 COBJS-$(CONFIG_FSL_IIM) += fsl_iim.o
 COBJS-$(CONFIG_GPIO_LED) += gpio_led.o
 COBJS-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
+COBJS-$(CONFIG_MXC_OCOTP) += mxc_ocotp.o
 COBJS-$(CONFIG_NS87308) += ns87308.o
 COBJS-$(CONFIG_PDSP188x) += pdsp188x.o
 COBJS-$(CONFIG_STATUS_LED) += status_led.o
drivers/misc/mxc_ocotp.c new file +216 -0

216 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#13 lore raw

PATCH v4 7/10 Add mxc_ocotp driver

Quoted 4 lines · Beno?t Th?baudeau

Add an mxc_ocotp driver for i.MX6.

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#14 lore raw

PATCH v4 8/10 mx6qsabrelite: Enable support for ocotp

In reply to Benoît Thébaudeau

---
Changes in v4:
- New patch.

Changes in v3: None
Changes in v2: None

 include/configs/mx6qsabrelite.h |    5 +++++
 1 file changed, 5 insertions(+)
include/configs/mx6qsabrelite.h +5 -0
index 6d4b837..b814418 100644
@@ -47,6 +47,11 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_MXC_GPIO
 
+#define CONFIG_CMD_FUSE
+#ifdef CONFIG_CMD_FUSE
+#define CONFIG_MXC_OCOTP
+#endif
+
 #define CONFIG_MXC_UART
 #define CONFIG_MXC_UART_BASE	       UART2_BASE
 
Signature · 1 line
1.7.10.4
#15 lore raw

PATCH v4 8/10 mx6qsabrelite: Enable support for ocotp

Quoted 2 lines · Beno?t Th?baudeau

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#16 lore raw

PATCH v4 9/10 nitrogen6x: Enable support for ocotp

In reply to Benoît Thébaudeau

---
Changes in v4:
- New patch.

Changes in v3: None
Changes in v2: None

 include/configs/nitrogen6x.h |    5 +++++
 1 file changed, 5 insertions(+)
include/configs/nitrogen6x.h +5 -0
index 93e7fe4..aea91bc 100644
@@ -44,6 +44,11 @@
 #define CONFIG_MISC_INIT_R
 #define CONFIG_MXC_GPIO
 
+#define CONFIG_CMD_FUSE
+#ifdef CONFIG_CMD_FUSE
+#define CONFIG_MXC_OCOTP
+#endif
+
 #define CONFIG_MXC_UART
 #define CONFIG_MXC_UART_BASE	       UART2_BASE
 
Signature · 1 line
1.7.10.4
#17 lore raw

PATCH v4 9/10 nitrogen6x: Enable support for ocotp

Quoted 2 lines · Beno?t Th?baudeau

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#18 lore raw

PATCH v4 10/10 imx: Document fuse assignments for MAC addresses

In reply to Benoît Thébaudeau

---
Changes in v4:
- Word as "i.MX6 SoC" instead of as "i.MX6x SoCs".

Changes in v3:
- New patch.

Changes in v2: None

 doc/README.imx25 |   10 ++++++++++
 doc/README.imx27 |   10 ++++++++++
 doc/README.imx5  |    6 ++++++
 doc/README.imx6  |   10 ++++++++++
 4 files changed, 36 insertions(+)
 create mode 100644 doc/README.imx25
 create mode 100644 doc/README.imx27
 create mode 100644 doc/README.imx6
doc/README.imx25 new file +10 -0
new file mode 100644
index 0000000..0ca21b6
@@ -0,0 +1,10 @@
+U-Boot for Freescale i.MX25
+
+This file contains information for the port of U-Boot to the Freescale i.MX25
+SoC.
+
+1. CONVENTIONS FOR FUSE ASSIGNMENTS
+-----------------------------------
+
+1.1 MAC Address: It is stored in the words 26 to 31 of fuse bank 0, using the
+    natural MAC byte order (i.e. MSB first).
doc/README.imx27 new file +10 -0
new file mode 100644
index 0000000..6f92cb4
@@ -0,0 +1,10 @@
+U-Boot for Freescale i.MX27
+
+This file contains information for the port of U-Boot to the Freescale i.MX27
+SoC.
+
+1. CONVENTIONS FOR FUSE ASSIGNMENTS
+-----------------------------------
+
+1.1 MAC Address: It is stored in the words 4 to 9 of fuse bank 0, using the
+    reversed MAC byte order (i.e. LSB first).
doc/README.imx5 +6 -0
index e08941e..c5312b6 100644
@@ -20,3 +20,9 @@ i.MX5x SoCs.
     This option should be enabled for boards having a SYS_ON_OFF_CTL signal
     connected to GPIO1[23] and triggering the MAIN_PWR_ON signal like in the
     reference designs.
+
+2. CONVENTIONS FOR FUSE ASSIGNMENTS
+-----------------------------------
+
+2.1 MAC Address: It is stored in the words 9 to 14 of fuse bank 1, using the
+    natural MAC byte order (i.e. MSB first).
doc/README.imx6 new file +10 -0
new file mode 100644
index 0000000..513a06e
@@ -0,0 +1,10 @@
+U-Boot for Freescale i.MX6
+
+This file contains information for the port of U-Boot to the Freescale i.MX6
+SoC.
+
+1. CONVENTIONS FOR FUSE ASSIGNMENTS
+-----------------------------------
+
+1.1 MAC Address: It is stored in fuse bank 4, with the 32 lsbs in word 2 and the
+    16 msbs in word 3.
Signature · 1 line
1.7.10.4
#19 lore raw

PATCH v4 10/10 imx: Document fuse assignments for MAC addresses

Quoted 2 lines · Beno?t Th?baudeau

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#20 lore raw

PATCH v4 1/10 imx: Homogenize and fix fuse register definitions

In reply to Benoît Thébaudeau
Quoted 13 lines · Beno?t Th?baudeau

IIM:
- Homogenize prg_p naming (the reference manuals are not always self-consistent for that).
- Add missing SCSx and bank registers.
- Fix the number of banks on i.MX53.

OCOTP:
- Rename iim to ocotp in order to avoid confusion.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the reference manual.
- Merge the existing spinoff gp1 fuse definition on i.MX6.
- Fix the number of banks on i.MX6.

Quoted 2 lines

---

Very nice work, Beno?t !

Best regards,
Stefano Babic

Quoted 232 lines

Changes in v4:
- Convert spaces to tabs.

Changes in v3:
- Rebase against latest u-boot-imx/master.
- Fix the number of banks on i.MX6.
- Rename iim to ocotp on i.MX6 in order to avoid confusion, and merge in the existing gp1 fuse definition.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the reference manual.

Changes in v2:
- Rebase against latest master.

 arch/arm/cpu/armv7/mx6/soc.c                  |    4 ++--
 arch/arm/include/asm/arch-mx25/imx-regs.h     |    8 ++++++--
 arch/arm/include/asm/arch-mx27/imx-regs.h     |    2 +-
 arch/arm/include/asm/arch-mx31/imx-regs.h     |    9 +++++++--
 arch/arm/include/asm/arch-mx35/imx-regs.h     |    7 ++++++-
 arch/arm/include/asm/arch-mx5/imx-regs.h      |    6 +++++-
 arch/arm/include/asm/arch-mx6/imx-regs.h      |   19 +++++++------------
 board/freescale/mx6qsabreauto/mx6qsabreauto.c |    5 ++++-
 8 files changed, 38 insertions(+), 22 deletions(-)
arch/arm/cpu/armv7/mx6/soc.c +2 -2
index 69b8487..fc436fb 100644
@@ -172,8 +172,8 @@ void enable_caches(void)
 #if defined(CONFIG_FEC_MXC)
 void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
 {
-	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
-	struct fuse_bank *bank = &iim->bank[4];
+	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+	struct fuse_bank *bank = &ocotp->bank[4];
 	struct fuse_bank4_regs *fuse =
 			(struct fuse_bank4_regs *)bank->fuse_regs;
 
arch/arm/include/asm/arch-mx25/imx-regs.h +6 -2
index 5f4b543..99c32d4 100644
@@ -113,8 +113,12 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
-	u32 res1[0x1f5];
+	u32 iim_prg_p;
+	u32 iim_scs0;
+	u32 iim_scs1;
+	u32 iim_scs2;
+	u32 iim_scs3;
+	u32 res1[0x1f1];
 	struct fuse_bank {
 		u32 fuse_regs[0x20];
 		u32 fuse_rsvd[0xe0];
arch/arm/include/asm/arch-mx27/imx-regs.h +1 -1
index 2f6c823..aee058f 100644
@@ -176,7 +176,7 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
+	u32 iim_prg_p;
 	u32 iim_scs0;
 	u32 iim_scs1;
 	u32 iim_scs2;
arch/arm/include/asm/arch-mx31/imx-regs.h +7 -2
index 3f58318..f67f49c 100644
@@ -68,7 +68,7 @@ struct cspi_regs {
 	u32 test;
 };
 
-/* IIM Control Registers */
+/* IIM control registers */
 struct iim_regs {
 	u32 iim_stat;
 	u32 iim_statm;
@@ -80,11 +80,16 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
+	u32 iim_prg_p;
 	u32 iim_scs0;
 	u32 iim_scs1;
 	u32 iim_scs2;
 	u32 iim_scs3;
+	u32 res[0x1f1];
+	struct fuse_bank {
+		u32 fuse_regs[0x20];
+		u32 fuse_rsvd[0xe0];
+	} bank[3];
 };
 
 struct iomuxc_regs {
arch/arm/include/asm/arch-mx35/imx-regs.h +6 -1
index 7f337be..64546d2 100644
@@ -262,11 +262,16 @@ struct iim_regs {
 	u32 iim_sdat;
 	u32 iim_prev;
 	u32 iim_srev;
-	u32 iim_prog_p;
+	u32 iim_prg_p;
 	u32 iim_scs0;
 	u32 iim_scs1;
 	u32 iim_scs2;
 	u32 iim_scs3;
+	u32 res1[0x1f1];
+	struct fuse_bank {
+		u32 fuse_regs[0x20];
+		u32 fuse_rsvd[0xe0];
+	} bank[3];
 };
 
 /* General Purpose Timer (GPT) registers */
arch/arm/include/asm/arch-mx5/imx-regs.h +5 -1
index a71cc13..b237d5f 100644
@@ -499,7 +499,7 @@ struct iim_regs {
 	u32	sdat;
 	u32	prev;
 	u32	srev;
-	u32	preg_p;
+	u32	prg_p;
 	u32	scs0;
 	u32	scs1;
 	u32	scs2;
@@ -508,7 +508,11 @@ struct iim_regs {
 	struct fuse_bank {
 		u32	fuse_regs[0x20];
 		u32	fuse_rsvd[0xe0];
+#if defined(CONFIG_MX51)
 	} bank[4];
+#elif defined(CONFIG_MX53)
+	} bank[5];
+#endif
 };
 
 struct fuse_bank0_regs {
arch/arm/include/asm/arch-mx6/imx-regs.h +7 -12
index 0e4d8fa..680e752 100644
@@ -229,7 +229,6 @@
 
 #define CHIP_REV_1_0                 0x10
 #define IRAM_SIZE                    0x00040000
-#define IMX_IIM_BASE                 OCOTP_BASE_ADDR
 #define FEC_QUIRK_ENET_MAC
 
 #if !(defined(__KERNEL_STRICT_NAMES) || defined(__ASSEMBLY__))
@@ -258,12 +257,6 @@ struct src {
 	u32     gpr10;
 };
 
-/* OCOTP Registers */
-struct ocotp_regs {
-	u32	reserved[0x198];
-	u32	gp1;	/* 0x660 */
-};
-
 /* GPR3 bitfields */
 #define IOMUXC_GPR3_GPU_DBG_OFFSET		29
 #define IOMUXC_GPR3_GPU_DBG_MASK		(3<<IOMUXC_GPR3_GPU_DBG_OFFSET)
@@ -438,7 +431,7 @@ struct cspi_regs {
 	ECSPI5_BASE_ADDR
 #endif
 
-struct iim_regs {
+struct ocotp_regs {
 	u32	ctrl;
 	u32	ctrl_set;
 	u32     ctrl_clr;
@@ -449,9 +442,9 @@ struct iim_regs {
 	u32     rsvd1[3];
 	u32     read_ctrl;
 	u32     rsvd2[3];
-	u32     fuse_data;
+	u32	read_fuse_data;
 	u32     rsvd3[3];
-	u32     sticky;
+	u32	sw_sticky;
 	u32     rsvd4[3];
 	u32     scs;
 	u32     scs_set;
@@ -466,7 +459,7 @@ struct iim_regs {
 
 	struct fuse_bank {
 		u32	fuse_regs[0x20];
-	} bank[15];
+	} bank[16];
 };
 
 struct fuse_bank4_regs {
@@ -477,7 +470,9 @@ struct fuse_bank4_regs {
 	u32	mac_addr_low;
 	u32     rsvd2[3];
 	u32     mac_addr_high;
-	u32	rsvd3[0x13];
+	u32	rsvd3[0xb];
+	u32	gp1;
+	u32	rsvd4[7];
 };
 
 struct aipstz_regs {
board/freescale/mx6qsabreauto/mx6qsabreauto.c +4 -1
index aec3286..a3afa58 100644
@@ -179,7 +179,10 @@ static int mx6sabre_rev(void)
 	 * i.MX6Q ARD RevB: 0x02
 	 */
 	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
-	int reg = readl(&ocotp->gp1);
+	struct fuse_bank *bank = &ocotp->bank[4];
+	struct fuse_bank4_regs *fuse =
+			(struct fuse_bank4_regs *)bank->fuse_regs;
+	int reg = readl(&fuse->gp1);
 	int ret;
 
 	switch (reg >> 8 & 0x0F) {
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#21 lore raw

PATCH v4 1/10 imx: Homogenize and fix fuse register definitions

In reply to Benoît Thébaudeau
Quoted 13 lines · Beno?t Th?baudeau

IIM:
- Homogenize prg_p naming (the reference manuals are not always self-consistent for that).
- Add missing SCSx and bank registers.
- Fix the number of banks on i.MX53.

OCOTP:
- Rename iim to ocotp in order to avoid confusion.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the reference manual.
- Merge the existing spinoff gp1 fuse definition on i.MX6.
- Fix the number of banks on i.MX6.

Quoted 2 lines

---

Hi Beno?t.

I would like to apply your patches and I see some warning from clearpatch. Some of them are very annoying and I think to ignore them, but before doing that I ask to ML about it. It seems to me that checkpatch make stonger tests as in the past, and I do not know if all of them are meaningful. Or better, I do not think they are.

Here the warnings:

CHECK: Alignment should match open parenthesis
#589: FILE: common/cmd_fuse.c:77:
+ if (argc < 2 || strtou32(argv[0], 0, &bank) ||
+ strtou32(argv[1], 0, &word))

CHECK: Alignment should match open parenthesis
#637: FILE: common/cmd_fuse.c:125:
+ printf("Programming bank %u word 0x%.8x to 0x%.8x...\n",
+ bank, word, val);

I would say that this enforcement is crap. The code in the patch is easy to read. I want to ignore this warning.

WARNING: quoted string split across lines
#653: FILE: common/cmd_fuse.c:141:
+ printf("Overriding bank %u word 0x%.8x with "
+ "0x%.8x...\n", bank, word, val);

Again, this is the solution when a line is too long. checkpatch complains if a line is too long, and in case of static string complains that is splitted. This is too much, I would like to ignore also this one.

CHECK: Alignment should match open parenthesis
#1102: FILE: drivers/misc/fsl_iim.c:118:
+ if (bank >= ARRAY_SIZE((*regs)->bank) ||
+ word >= ARRAY_SIZE((*regs)->bank[0].word) ||

Ditto

WARNING: line over 80 characters
#1190: FILE: drivers/misc/fsl_iim.c:206:
+ puts("fsl_iim fuse_sense(): Explicit sense cycle did not complete\n");

Ok, this is the one that must be fixed, even if then we have the warning with "quoted string"

WARNING: line over 80 characters
#2017: FILE: drivers/misc/mxc_ocotp.c:8:
+ *
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/drivers/misc/imx_otp.c?h=imx_v2009.08_1.1.0&id=9aa74e6,

Ditto

CHECK: Alignment should match open parenthesis
#2088: FILE: drivers/misc/mxc_ocotp.c:79:
+ if (bank >= ARRAY_SIZE((*regs)->bank) ||
+ word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) >> 2 ||

I will not care about this.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#22 lore raw

PATCH v4 1/10 imx: Homogenize and fix fuse register definitions

Hi Stefano,

Quoted 19 lines · Stefano Babic
Quoted 15 lines · Beno?t Th?baudeau

IIM:
- Homogenize prg_p naming (the reference manuals are not always self-consistent
for that).
- Add missing SCSx and bank registers.
- Fix the number of banks on i.MX53.

OCOTP:
- Rename iim to ocotp in order to avoid confusion.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the
reference manual.
- Merge the existing spinoff gp1 fuse definition on i.MX6.
- Fix the number of banks on i.MX6.

Quoted 2 lines

---

Quoted 7 lines

Hi Beno?t.

I would like to apply your patches and I see some warning from clearpatch. Some of them are very annoying and I think to ignore them, but before doing that I ask to ML about it. It seems to me that checkpatch make stonger tests as in the past, and I do not know if all of them are meaningful. Or better, I do not think they are.

Indeed, I have noticed that too since last release. I ignored those on purpose because they all seem wrong.

Quoted 13 lines

Here the warnings:

CHECK: Alignment should match open parenthesis
#589: FILE: common/cmd_fuse.c:77:

(quoted diff) +2 -0
+	if (argc < 2 || strtou32(argv[0], 0, &bank) ||
+			strtou32(argv[1], 0, &word))

CHECK: Alignment should match open parenthesis
#637: FILE: common/cmd_fuse.c:125:

(quoted diff) +2 -0
+			printf("Programming bank %u word 0x%.8x to 0x%.8x...\n",
+					bank, word, val);
Quoted 2 lines

I would say that this enforcement is crap. The code in the patch is easy to read. I want to ignore this warning.

Yes, and that's usual Linux coding style, which is the official coding style for U-Boot as well.

I'd say that the rule here should be to indent such lines at least at the position of the opening parenthesis of the previous line, and that the indentation should be at least 1 or 2 more tabs than on the previous line, which is the case in my code above.

Quoted 9 lines

WARNING: quoted string split across lines
#653: FILE: common/cmd_fuse.c:141:

(quoted diff) +2 -0
+			printf("Overriding bank %u word 0x%.8x with "
+					"0x%.8x...\n", bank, word, val);

Again, this is the solution when a line is too long. checkpatch complains if a line is too long, and in case of static string complains that is splitted. This is too much, I would like to ignore also this one.

Yes. The purpose of not splitting long literal strings is only grep-ability of error messages. Here, it is neither an error message nor a constant sub-string of it that is split away.

Quoted 12 lines

CHECK: Alignment should match open parenthesis
#1102: FILE: drivers/misc/fsl_iim.c:118:

(quoted diff) +2 -0
+	if (bank >= ARRAY_SIZE((*regs)->bank) ||
+			word >= ARRAY_SIZE((*regs)->bank[0].word) ||

Ditto

WARNING: line over 80 characters
#1190: FILE: drivers/misc/fsl_iim.c:206:

(quoted diff) +1 -0
+		puts("fsl_iim fuse_sense(): Explicit sense cycle did not complete\n");
Quoted 2 lines

Ok, this is the one that must be fixed, even if then we have the warning with "quoted string"

Initially, this line was less than 80 characters because I had split the string. But checkpatch complained about the literal string being split, so I kept it on a single line, which makes sense here for grep-ability: It is an error message, and all parts of this string are constant (i.e. not printf-ed). And Scott Wood had already made me do such changes in the past. What should I do?

Would it be possible to have an official detailed coding style everybody agrees on somewhere? Apparently, the rules are not the same for all custodians.

Quoted 6 lines

WARNING: line over 80 characters
#2017: FILE: drivers/misc/mxc_ocotp.c:8:
+ *
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/drivers/misc/imx_otp.c?h=imx_v2009.08_1.1.0&id=9aa74e6,

Ditto

I did not know what to do with this one. As it is a URL, I considered it as unsplittable. So should the 80-character limit really apply here too?

Quoted 6 lines

CHECK: Alignment should match open parenthesis
#2088: FILE: drivers/misc/mxc_ocotp.c:79:

(quoted diff) +2 -0
+	if (bank >= ARRAY_SIZE((*regs)->bank) ||
+			word >= ARRAY_SIZE((*regs)->bank[0].fuse_regs) >> 2 ||

I will not care about this.

OK.

Best regards,
Beno?t

#23 lore raw

PATCH v4 1/10 imx: Homogenize and fix fuse register definitions

Quoted 2 lines · Beno?t Th?baudeau

Hi Stefano,

Hi Beno?t,

Quoted 8 lines
Quoted 5 lines

I would like to apply your patches and I see some warning from clearpatch. Some of them are very annoying and I think to ignore them, but before doing that I ask to ML about it. It seems to me that checkpatch make stonger tests as in the past, and I do not know if all of them are meaningful. Or better, I do not think they are.

Indeed, I have noticed that too since last release. I ignored those on purpose because they all seem wrong.

Agree, some of them are non-sense

Quoted 5 lines
Quoted 2 lines

I would say that this enforcement is crap. The code in the patch is easy to read. I want to ignore this warning.

Yes, and that's usual Linux coding style, which is the official coding style for U-Boot as well.

Right.

Quoted 13 lines
Quoted 13 lines

CHECK: Alignment should match open parenthesis
#1102: FILE: drivers/misc/fsl_iim.c:118:

(quoted diff) +2 -0
+	if (bank >= ARRAY_SIZE((*regs)->bank) ||
+			word >= ARRAY_SIZE((*regs)->bank[0].word) ||

Ditto

WARNING: line over 80 characters
#1190: FILE: drivers/misc/fsl_iim.c:206:

(quoted diff) +1 -0
+		puts("fsl_iim fuse_sense(): Explicit sense cycle did not complete\n");
Quoted 8 lines
Quoted 2 lines

Ok, this is the one that must be fixed, even if then we have the warning with "quoted string"

Initially, this line was less than 80 characters because I had split the string. But checkpatch complained about the literal string being split, so I kept it on a single line, which makes sense here for grep-ability: It is an error message, and all parts of this string are constant (i.e. not printf-ed). And Scott Wood had already made me do such changes in the past. What should I do?

Do not change - for me it is ok, and we have explained here why we think it is right.

Quoted 3 lines

Would it be possible to have an official detailed coding style everybody agrees on somewhere? Apparently, the rules are not the same for all custodians.

Really U-Boot follows the same code-styling as Linux, or it should be. checkpatch should help us to have the same rules, but apparently it does not (or not always).

Quoted 10 lines
Quoted 7 lines

WARNING: line over 80 characters
#2017: FILE: drivers/misc/mxc_ocotp.c:8:
+ *
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/drivers/misc/imx_otp.c?h=imx_v2009.08_1.1.0&id=9aa74e6,

Ditto

I did not know what to do with this one. As it is a URL, I considered it as unsplittable. So should the 80-character limit really apply here too?

Yes, sorry, this is a URL - IMHO it is ok.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#24 lore raw

PATCH v4 1/10 imx: Homogenize and fix fuse register definitions

In reply to Benoît Thébaudeau
Quoted 13 lines · Beno?t Th?baudeau

IIM:
- Homogenize prg_p naming (the reference manuals are not always self-consistent for that).
- Add missing SCSx and bank registers.
- Fix the number of banks on i.MX53.

OCOTP:
- Rename iim to ocotp in order to avoid confusion.
- Rename fuse_data to read_fuse_data, and sticky to sw_sticky, according to the reference manual.
- Merge the existing spinoff gp1 fuse definition on i.MX6.
- Fix the number of banks on i.MX6.

Quoted 2 lines

---

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================