public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mx53loco: Fix revision of Dialog boards
@ 2012-05-28 14:00 Fabio Estevam
  2012-05-29 15:54 ` [U-Boot] [PATCH v2] " Fabio Estevam
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2012-05-28 14:00 UTC (permalink / raw)
  To: u-boot

Original code was assuming that the fuse revision version for all mx53loco boards
based on Dialog PMIC was the same, which is not the case.

Force the revision of Dialog-based boards to 0.

This fixes a kernel crash when Dialog PMIC is accessed in the kernel for rev E boards.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 board/freescale/mx53loco/mx53loco.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c
index dec966d..1db4137 100644
--- a/board/freescale/mx53loco/mx53loco.c
+++ b/board/freescale/mx53loco/mx53loco.c
@@ -41,6 +41,7 @@
 #include <fsl_pmic.h>
 
 DECLARE_GLOBAL_DATA_PTR;
+static u32 system_rev;
 
 int dram_init(void)
 {
@@ -62,16 +63,19 @@ void dram_init_banksize(void)
 	gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
 }
 
-u32 get_board_rev(void)
+u32 get_board_rev_from_fuse(void)
 {
 	struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
 	struct fuse_bank *bank = &iim->bank[0];
 	struct fuse_bank0_regs *fuse =
 		(struct fuse_bank0_regs *)bank->fuse_regs;
 
-	int rev = readl(&fuse->gp[6]);
+	return readl(&fuse->gp[6]);
+}
 
-	return (get_cpu_rev() & ~(0xF << 8)) | (rev & 0xF) << 8;
+u32 get_board_rev(void)
+{
+	return system_rev;
 }
 
 static void setup_iomux_uart(void)
@@ -329,6 +333,11 @@ static void setup_iomux_i2c(void)
 		PAD_CTL_ODE_OPENDRAIN_ENABLE);
 }
 
+static inline void setup_board_rev(int rev)
+{
+	system_rev |= (rev & 0xF) << 8;
+}
+
 static int power_init(void)
 {
 	unsigned int val;
@@ -350,6 +359,8 @@ static int power_init(void)
 		/* Set Vcc peripheral to 1.30V */
 		ret |= pmic_reg_write(p, DA9053_BUCKPRO_REG, 0x62);
 		ret |= pmic_reg_write(p, DA9053_SUPPLY_REG, 0x62);
+
+		setup_board_rev(0);
 	}
 
 	if (!i2c_probe(CONFIG_SYS_FSL_PMIC_I2C_ADDR)) {
@@ -379,6 +390,8 @@ static int power_init(void)
 		/* Set SWBST to 5V in auto mode */
 		val = SWBST_AUTO;
 		ret |= pmic_reg_write(p, SWBST_CTRL, val);
+
+		setup_board_rev(get_board_rev_from_fuse());
 	}
 
 	return ret;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2] mx53loco: Fix revision of Dialog boards
  2012-05-28 14:00 [U-Boot] [PATCH] mx53loco: Fix revision of Dialog boards Fabio Estevam
@ 2012-05-29 15:54 ` Fabio Estevam
  2012-06-12 17:19   ` Stefano Babic
  0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2012-05-29 15:54 UTC (permalink / raw)
  To: u-boot

Original code was assuming that the fuse revision version for all mx53loco boards
based on Dialog PMIC was the same, which is not the case.

Force the revision of all Dialog-based boards to 0.

This fixes a kernel crash when PMIC is accessed in the 2.6.35 kernel
for Dialog rev E boards.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Fix the PMIC detection. Let I2C probe to work earlier in board_init
instead of board_late_init().

 board/freescale/mx53loco/mx53loco.c |   19 +++++++------------
 include/configs/mx53loco.h          |    1 -
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c
index dec966d..445d022 100644
--- a/board/freescale/mx53loco/mx53loco.c
+++ b/board/freescale/mx53loco/mx53loco.c
@@ -71,6 +71,9 @@ u32 get_board_rev(void)
 
 	int rev = readl(&fuse->gp[6]);
 
+	if (!i2c_probe(CONFIG_SYS_DIALOG_PMIC_I2C_ADDR))
+		rev = 0;
+
 	return (get_cpu_rev() & ~(0xF << 8)) | (rev & 0xF) << 8;
 }
 
@@ -424,23 +427,15 @@ int print_cpuinfo(void)
 	return 0;
 }
 
-#ifdef CONFIG_BOARD_LATE_INIT
-int board_late_init(void)
-{
-	setup_iomux_i2c();
-	if (!power_init())
-		clock_1GHz();
-	print_cpuinfo();
-
-	return 0;
-}
-#endif
-
 int board_init(void)
 {
 	gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
 
 	mxc_set_sata_internal_clock();
+	setup_iomux_i2c();
+	if (!power_init())
+		clock_1GHz();
+	print_cpuinfo();
 
 	return 0;
 }
diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h
index eab0e27..1c8ca59 100644
--- a/include/configs/mx53loco.h
+++ b/include/configs/mx53loco.h
@@ -41,7 +41,6 @@
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 2 * 1024 * 1024)
 
 #define CONFIG_BOARD_EARLY_INIT_F
-#define CONFIG_BOARD_LATE_INIT
 #define CONFIG_MXC_GPIO
 #define CONFIG_REVISION_TAG
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2] mx53loco: Fix revision of Dialog boards
  2012-05-29 15:54 ` [U-Boot] [PATCH v2] " Fabio Estevam
@ 2012-06-12 17:19   ` Stefano Babic
  0 siblings, 0 replies; 3+ messages in thread
From: Stefano Babic @ 2012-06-12 17:19 UTC (permalink / raw)
  To: u-boot

On 29/05/2012 17:54, Fabio Estevam wrote:
> Original code was assuming that the fuse revision version for all mx53loco boards
> based on Dialog PMIC was the same, which is not the case.
> 
> Force the revision of all Dialog-based boards to 0.
> 
> This fixes a kernel crash when PMIC is accessed in the 2.6.35 kernel
> for Dialog rev E boards.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> Changes since v1:
> - Fix the PMIC detection. Let I2C probe to work earlier in board_init
> instead of board_late_init().
> 
>  board/freescale/mx53loco/mx53loco.c |   19 +++++++------------
>  include/configs/mx53loco.h          |    1 -
>  2 files changed, 7 insertions(+), 13 deletions(-)
> 

Applied to u-boot-imx, thanks.

Best regards,
Stefano Babic

-- 
=====================================================================
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
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-12 17:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-28 14:00 [U-Boot] [PATCH] mx53loco: Fix revision of Dialog boards Fabio Estevam
2012-05-29 15:54 ` [U-Boot] [PATCH v2] " Fabio Estevam
2012-06-12 17:19   ` Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox