From patchwork Fri Mar 30 06:10:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Virdi X-Patchwork-Id: 149539 X-Patchwork-Delegate: hs@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id BCE0EB6F98 for ; Fri, 30 Mar 2012 17:10:54 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8D88128077; Fri, 30 Mar 2012 08:10:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id izQgRUvVtkMy; Fri, 30 Mar 2012 08:10:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5A85F28078; Fri, 30 Mar 2012 08:10:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0DEC328078 for ; Fri, 30 Mar 2012 08:10:46 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wT05AzZST3kv for ; Fri, 30 Mar 2012 08:10:45 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from eu1sys200aog119.obsmtp.com (eu1sys200aog119.obsmtp.com [207.126.144.147]) by theia.denx.de (Postfix) with ESMTPS id 352B228077 for ; Fri, 30 Mar 2012 08:10:42 +0200 (CEST) Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob119.postini.com ([207.126.147.11]) with SMTP ID DSNKT3VOXmCgG0NSuo0ImMIvGHsIUTB53GCy@postini.com; Fri, 30 Mar 2012 06:10:44 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id D2EB6B5; Fri, 30 Mar 2012 06:02:10 +0000 (GMT) Received: from Webmail-ap.st.com (eapex1hubcas3.st.com [10.80.176.67]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 4EA7971D; Fri, 30 Mar 2012 06:10:35 +0000 (GMT) Received: from localhost (10.199.7.86) by Webmail-ap.st.com (10.80.176.7) with Microsoft SMTP Server (TLS) id 8.3.192.1; Fri, 30 Mar 2012 14:09:34 +0800 From: Amit Virdi To: Date: Fri, 30 Mar 2012 11:40:17 +0530 Message-ID: X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1330334009-29452-1-git-send-email-amit.virdi@st.com> References: <1330334009-29452-1-git-send-email-amit.virdi@st.com> MIME-Version: 1.0 Cc: Michel Sanches , hs@denx.de, Armando Visconti , spear-devel@list.st.com, Amit Virdi , sr@denx.de Subject: [U-Boot] [PATCH] i2c:designware Turn off the ctrl when setting the speed X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Armando Visconti 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 Signed-off-by: Armando Visconti Signed-off-by: Amit Virdi --- drivers/i2c/designware_i2c.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) 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); } /*