summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e9d713e)
raw | patch | inline | side by side (parent: e9d713e)
author | Dave Gerlach <d-gerlach@ti.com> | |
Wed, 6 Jan 2016 20:41:54 +0000 (14:41 -0600) | ||
committer | Lokesh Vutla <lokeshvutla@ti.com> | |
Mon, 11 Jan 2016 05:47:43 +0000 (11:17 +0530) |
For AM437x, gpi2c_init relies on a static local variable 'init' to
ensure the i2c initialization routines only get called once from
bdbd76b04c15 ("ti: AM437x: Add gpi2c_init before attempting to
scale MPU voltage rail"). However, this function is called very early,
before BSS is available, so we cannot rely on the value of 'init' to be
zero on first access, especially after a warm reset. Because of this it
is possible that gpi2c_init never initializes i2c at all, leading to
MPU voltage scaling not happening which can cause boot to fail.
Also, we need to initialize the variable to a non-zero value so that the
compiler does not 'optimize' and place the value in bss anyway.
In order to avoid this, let's rename the variable to 'first_time' to
completely avoid any confusion, initialize it to true and then set the
variable to false after we run once so that we don't re-initialize i2c
when the function is called again.
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
ensure the i2c initialization routines only get called once from
bdbd76b04c15 ("ti: AM437x: Add gpi2c_init before attempting to
scale MPU voltage rail"). However, this function is called very early,
before BSS is available, so we cannot rely on the value of 'init' to be
zero on first access, especially after a warm reset. Because of this it
is possible that gpi2c_init never initializes i2c at all, leading to
MPU voltage scaling not happening which can cause boot to fail.
Also, we need to initialize the variable to a non-zero value so that the
compiler does not 'optimize' and place the value in bss anyway.
In order to avoid this, let's rename the variable to 'first_time' to
completely avoid any confusion, initialize it to true and then set the
variable to false after we run once so that we don't re-initialize i2c
when the function is called again.
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
board/ti/am43xx/board.c | patch | blob | history |
index 8227f11c5428274bc8e6d03487bced0bbe3325f4..3dac5d7d8d1f3bf1afae7633e33dc824a61208d3 100644 (file)
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
void gpi2c_init(void)
{
- static bool init;
+ static bool first_time = true;
- if (!init) {
+ if (first_time) {
enable_i2c0_pin_mux();
i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
- init = true;
+ first_time = false;
}
}