From patchwork Wed Dec 22 13:23:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Hui-R64343 X-Patchwork-Id: 76408 X-Patchwork-Delegate: sbabic@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 087A5B6F1E for ; Thu, 23 Dec 2010 00:44:38 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 10E7D28130; Wed, 22 Dec 2010 14:44:36 +0100 (CET) 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 pTU-Em4AEYtY; Wed, 22 Dec 2010 14:44:35 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8F0DB28121; Wed, 22 Dec 2010 14:44:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 460A728121 for ; Wed, 22 Dec 2010 14:44:31 +0100 (CET) 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 2E5IkYlq1Ciy for ; Wed, 22 Dec 2010 14:44:29 +0100 (CET) X-Greylist: delayed 905 seconds by postgrey-1.27 at theia; Wed, 22 Dec 2010 14:44:27 CET 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 VA3EHSOBE005.bigfish.com (va3ehsobe005.messaging.microsoft.com [216.32.180.31]) by theia.denx.de (Postfix) with ESMTPS id 07CAF2811C for ; Wed, 22 Dec 2010 14:44:27 +0100 (CET) Received: from mail21-va3-R.bigfish.com (10.7.14.247) by VA3EHSOBE005.bigfish.com (10.7.40.25) with Microsoft SMTP Server id 14.1.225.8; Wed, 22 Dec 2010 13:29:21 +0000 Received: from mail21-va3 (localhost.localdomain [127.0.0.1]) by mail21-va3-R.bigfish.com (Postfix) with ESMTP id 07ED9A50272; Wed, 22 Dec 2010 13:29:20 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h62h) X-Spam-TCS-SCL: 1:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:de01egw02.freescale.net; RD:de01egw02.freescale.net; EFVD:NLI Received: from mail21-va3 (localhost.localdomain [127.0.0.1]) by mail21-va3 (MessageSwitch) id 1293024531747099_8055; Wed, 22 Dec 2010 13:28:51 +0000 (UTC) Received: from VA3EHSMHS023.bigfish.com (unknown [10.7.14.248]) by mail21-va3.bigfish.com (Postfix) with ESMTP id 2FFD98E806F; Wed, 22 Dec 2010 13:28:48 +0000 (UTC) Received: from de01egw02.freescale.net (192.88.165.103) by VA3EHSMHS023.bigfish.com (10.7.99.33) with Microsoft SMTP Server (TLS) id 14.1.225.8; Wed, 22 Dec 2010 13:28:40 +0000 Received: from az33smr01.freescale.net (az33smr01.freescale.net [10.64.34.199]) by de01egw02.freescale.net (8.14.3/8.14.3) with ESMTP id oBMDSdfj024475; Wed, 22 Dec 2010 06:28:39 -0700 (MST) Received: from localhost.localdomain (r64343-desktop.ap.freescale.net [10.192.242.36]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id oBMDSVeg006421; Wed, 22 Dec 2010 07:28:37 -0600 (CST) From: Jason Liu To: Date: Wed, 22 Dec 2010 21:23:31 +0800 Message-ID: <1293024212-4858-2-git-send-email-r64343@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1293024212-4858-1-git-send-email-r64343@freescale.com> References: <1293024212-4858-1-git-send-email-r64343@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com Subject: [U-Boot] [PATCH v2 2/3] mxc_i2c: add support for MX53 processor X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 This patch add I2C support for Freescale MX53 processor Signed-off-by: Jason Liu --- Changes for v2: -address the comments of Heiko, add #if defined(CONFIG_MX31) to avoid break MX31 build. Move CONFIG_HARD_I2C to the top of the file and fix the error message from: #error "define CONFIG_SYS_I2C_PORT to use the I2C driver" to #error "define CONFIG_SYS_I2C_MXxx_PORTx to use the I2C driver" --- drivers/i2c/mxc_i2c.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c old mode 100644 new mode 100755 index 8e10fbb..95d27ae --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -26,8 +26,14 @@ #if defined(CONFIG_HARD_I2C) +#ifdef CONFIG_MX31 #include #include +#endif + +#if defined(CONFIG_MX53) +#include +#endif #define IADR 0x00 #define IFDR 0x04 @@ -56,8 +62,12 @@ #elif defined (CONFIG_SYS_I2C_MX31_PORT3) #define I2C_BASE 0x43f84000 #define I2C_CLK_OFFSET 30 +#elif defined(CONFIG_SYS_I2C_MX53_PORT1) +#define I2C_BASE I2C1_BASE_ADDR +#elif defined(CONFIG_SYS_I2C_MX53_PORT2) +#define I2C_BASE I2C2_BASE_ADDR #else -#error "define CONFIG_SYS_I2C_MX31_PORTx to use the mx31 I2C driver" +#error "define CONFIG_SYS_I2C_MXxx_PORTx to use the I2C driver" #endif #ifdef DEBUG @@ -72,11 +82,16 @@ static u16 div[] = { 30, 32, 36, 42, 48, 52, 60, 72, 80, 88, 104, 128, 144, void i2c_init(int speed, int unused) { - int freq = mx31_get_ipg_clk(); + int freq; int i; +#ifdef CONFIG_MX31 + freq = mx31_get_ipg_clk(); /* start the required I2C clock */ __REG(CCM_CGR0) = __REG(CCM_CGR0) | (3 << I2C_CLK_OFFSET); +#else + freq = mxc_get_clock(MXC_IPG_PERCLK); +#endif for (i = 0; i < 0x1f; i++) if (freq / div[i] <= speed)