Patchwork [U-Boot,2/2] i2c: sh_i2c: Avoid using I2C prior to relocation

login
register
mail settings
Submitter Nobuhiro Iwamatsu
Date Oct. 11, 2013, 7:23 a.m.
Message ID <1381476234-23364-2-git-send-email-nobuhiro.iwamatsu.yj@renesas.com>
Download mbox | patch
Permalink /patch/282540/
State Accepted
Delegated to: Heiko Schocher
Headers show

Comments

Nobuhiro Iwamatsu - Oct. 11, 2013, 7:23 a.m.
If user uses the I2C in before the relocation, board of sh and rmobile
will not start. This will solve this problem.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
---
 drivers/i2c/sh_i2c.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
Heiko Schocher - Oct. 17, 2013, 6:23 a.m.
Hello Nobuhiro,

Am 11.10.2013 09:23, schrieb Nobuhiro Iwamatsu:
> If user uses the I2C in before the relocation, board of sh and rmobile
> will not start. This will solve this problem.
>
> Signed-off-by: Nobuhiro Iwamatsu<nobuhiro.iwamatsu.yj@renesas.com>
> ---
>   drivers/i2c/sh_i2c.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)

Applied to u-boot-i2c.git

Thanks!

bye,
Heiko

Patch

diff --git a/drivers/i2c/sh_i2c.c b/drivers/i2c/sh_i2c.c
index 58f8bf1..808202c 100644
--- a/drivers/i2c/sh_i2c.c
+++ b/drivers/i2c/sh_i2c.c
@@ -1,6 +1,6 @@ 
 /*
- * Copyright (C) 2011 Renesas Solutions Corp.
- * Copyright (C) 2011 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
+ * Copyright (C) 2011, 2013 Renesas Solutions Corp.
+ * Copyright (C) 2011, 2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -8,6 +8,8 @@ 
 #include <common.h>
 #include <asm/io.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Every register is 32bit aligned, but only 8bits in size */
 #define ureg(name) u8 name; u8 __pad_##name##0; u16 __pad_##name##1;
 struct sh_i2c {
@@ -240,6 +242,10 @@  void i2c_init(int speed, int slaveaddr)
 {
 	int num, denom, tmp;
 
+	/* No i2c support prior to relocation */
+	if (!(gd->flags & GD_FLG_RELOC))
+		return;
+
 #ifdef CONFIG_I2C_MULTI_BUS
 	current_bus = 0;
 #endif