From patchwork Wed Mar 17 11:21:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philby John X-Patchwork-Id: 86294 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2HBN0Qx029207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 17 Mar 2010 11:23:37 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o2HBN0cR002184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 17 Mar 2010 06:23:00 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o2HBMxA4018823 for ; Wed, 17 Mar 2010 06:23:00 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id CE1F380688 for ; Wed, 17 Mar 2010 05:22:46 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id EF39480626 for ; Wed, 17 Mar 2010 05:22:19 -0600 (CST) Received: from medina.ext.ti.com (localhost [127.0.0.1]) by dflp51.itg.ti.com (8.13.7/8.13.7) with ESMTP id o2HBMJUq026737 for ; Wed, 17 Mar 2010 06:22:19 -0500 (CDT) Received: from psmtp.com (na3sys009amx184.postini.com [74.125.149.165]) by medina.ext.ti.com (8.13.7/8.13.7) with SMTP id o2HBM7gU018019 for ; Wed, 17 Mar 2010 06:22:07 -0500 Received: from source ([74.125.83.45]) by na3sys009amx184.postini.com ([74.125.148.10]) with SMTP; Wed, 17 Mar 2010 11:22:07 GMT Received: by gwaa18 with SMTP id a18so415143gwa.4 for ; Wed, 17 Mar 2010 04:22:06 -0700 (PDT) Received: by 10.100.20.12 with SMTP id 12mr825586ant.188.1268824926483; Wed, 17 Mar 2010 04:22:06 -0700 (PDT) Received: from [10.0.0.5] ([122.172.53.0]) by mx.google.com with ESMTPS id 4sm428816yxd.16.2010.03.17.04.22.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Mar 2010 04:22:06 -0700 (PDT) Subject: [PATCH] i2c: Set SCL pin to gpio functionality before bus recovery From: Philby John To: linux-i2c@vger.kernel.org, "davinci-linux-open-source@linux.davincidsp.com" Date: Wed, 17 Mar 2010 16:51:56 +0530 Message-Id: <1268824916.4540.21.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 (2.24.5-2.fc10) X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:70.18742/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.5000) s cv gt3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list Reply-To: pjohn@mvista.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 17 Mar 2010 11:23:37 +0000 (UTC) diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c index aa48e3f..f4cbf54 100644 --- a/arch/arm/mach-davinci/board-dm355-evm.c +++ b/arch/arm/mach-davinci/board-dm355-evm.c @@ -111,7 +111,6 @@ static struct platform_device davinci_nand_device = { static struct davinci_i2c_platform_data i2c_pdata = { .bus_freq = 400 /* kHz */, .bus_delay = 0 /* usec */, - .sda_pin = 15, .scl_pin = 14, }; diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index 976e11b..19508e3 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c @@ -629,7 +629,6 @@ static struct i2c_board_info __initdata i2c_info[] = { static struct davinci_i2c_platform_data i2c_pdata = { .bus_freq = 20 /* kHz */, .bus_delay = 100 /* usec */, - .sda_pin = 44, .scl_pin = 43, }; diff --git a/arch/arm/mach-davinci/include/mach/i2c.h b/arch/arm/mach-davinci/include/mach/i2c.h index 39fdcea..95894ca 100644 --- a/arch/arm/mach-davinci/include/mach/i2c.h +++ b/arch/arm/mach-davinci/include/mach/i2c.h @@ -16,8 +16,7 @@ struct davinci_i2c_platform_data { unsigned int bus_freq; /* standard bus frequency (kHz) */ unsigned int bus_delay; /* post-transaction delay (usec) */ - unsigned int sda_pin; /* GPIO pin ID to use for SDA */ - unsigned int scl_pin; /* GPIO pin ID to use for SCL */ + unsigned int scl_pin; /* GPIO pin ID to use for SCL */ }; /* for board setup code */ diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 7a28e60..df909e3 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -64,6 +64,7 @@ #define DAVINCI_I2C_IVR_REG 0x28 #define DAVINCI_I2C_EMDR_REG 0x2c #define DAVINCI_I2C_PSC_REG 0x30 +#define DAVINCI_I2C_REVID2_REG 0x38 #define DAVINCI_I2C_IVR_AAS 0x07 #define DAVINCI_I2C_IVR_SCD 0x06 @@ -133,11 +134,21 @@ static inline u16 davinci_i2c_read_reg(struct davinci_i2c_dev *i2c_dev, int reg) } /* Generate a pulse on the i2c clock pin. */ -static void generic_i2c_clock_pulse(unsigned int scl_pin) +static void generic_i2c_clock_pulse(unsigned int revid, unsigned int scl_pin) { u16 i; + int ret; if (scl_pin) { + if (revid == 0x05) { + ret = gpio_request(scl_pin, "SCL Pin\n"); + if (ret) { + pr_warning("gpio request pin %d failed\n", + scl_pin); + return; + } + gpio_direction_output(scl_pin, 1); + } /* Send high and low on the SCL line */ for (i = 0; i < 9; i++) { gpio_set_value(scl_pin, 0); @@ -162,8 +173,10 @@ static void i2c_recover_bus(struct davinci_i2c_dev *dev) flag |= DAVINCI_I2C_MDR_NACK; /* write the data into mode register */ davinci_i2c_write_reg(dev, DAVINCI_I2C_MDR_REG, flag); - if (pdata) - generic_i2c_clock_pulse(pdata->scl_pin); + if (pdata) { + flag = davinci_i2c_read_reg(dev, DAVINCI_I2C_REVID2_REG); + generic_i2c_clock_pulse(flag, pdata->scl_pin); + } /* Send STOP */ flag = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG); flag |= DAVINCI_I2C_MDR_STP;