Patchwork [U-Boot] i2c:designware Turn off the ctrl when setting the speed

login
register
mail settings
Submitter Amit Virdi
Date March 30, 2012, 6:10 a.m.
Message ID <d8f2409d37dc18c40bb14173a25fc6f3e0beea15.1333087445.git.amit.virdi@st.com>
Download mbox | patch
Permalink /patch/149539/
State Accepted
Commit 5e3e8dda51c46faedb124c0ffd6136e2ef09ae52
Delegated to: Heiko Schocher
Headers show

Comments

Amit Virdi - March 30, 2012, 6:10 a.m.
From: Armando Visconti <armando.visconti@st.com>

The designware i2c controller must be turned off before
setting the speed in IC_CON register, as stated in the
section 6.3.1 of the dw_apb_i2c_db.pdf.

Signed-off-by: Michel Sanches <michel.sanches@st.com>
Signed-off-by: Armando Visconti <armando.visconti@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
 drivers/i2c/designware_i2c.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
Heiko Schocher - April 24, 2012, 9:11 a.m.
Hello Amit,

Amit Virdi wrote:
> From: Armando Visconti <armando.visconti@st.com>
> 
> The designware i2c controller must be turned off before
> setting the speed in IC_CON register, as stated in the
> section 6.3.1 of the dw_apb_i2c_db.pdf.
> 
> Signed-off-by: Michel Sanches <michel.sanches@st.com>
> Signed-off-by: Armando Visconti <armando.visconti@st.com>
> Signed-off-by: Amit Virdi <amit.virdi@st.com>
> ---
>  drivers/i2c/designware_i2c.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)

Applied to u-boot-i2c.git

Thanks!

bye
Heiko

Patch

diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
index d352146..6d118ac 100644
--- a/drivers/i2c/designware_i2c.c
+++ b/drivers/i2c/designware_i2c.c
@@ -40,6 +40,13 @@  static void set_speed(int i2c_spd)
 	unsigned int cntl;
 	unsigned int hcnt, lcnt;
 	unsigned int high, low;
+	unsigned int enbl;
+
+	/* to set speed cltr must be disabled */
+	enbl = readl(&i2c_regs_p->ic_enable);
+	enbl &= ~IC_ENABLE_0B;
+	writel(enbl, &i2c_regs_p->ic_enable);
+
 
 	cntl = (readl(&i2c_regs_p->ic_con) & (~IC_CON_SPD_MSK));
 
@@ -71,6 +78,10 @@  static void set_speed(int i2c_spd)
 
 	lcnt = (IC_CLK * low) / NANO_TO_MICRO;
 	writel(lcnt, &i2c_regs_p->ic_fs_scl_lcnt);
+
+	/* re-enable i2c ctrl back now that speed is set */
+	enbl |= IC_ENABLE_0B;
+	writel(enbl, &i2c_regs_p->ic_enable);
 }
 
 /*