From patchwork Tue Apr 5 21:38:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardiner X-Patchwork-Id: 688811 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p35Lf4Zu008827 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 5 Apr 2011 21:41:24 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p35LdIFr017470 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 5 Apr 2011 16:39:18 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id p35LdHHB002373; Tue, 5 Apr 2011 16:39:17 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 3B5B380628; Tue, 5 Apr 2011 16:39:13 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id ED59F80626 for ; Tue, 5 Apr 2011 16:38:20 -0500 (CDT) Received: from white.ext.ti.com (localhost [127.0.0.1]) by dflp52.itg.ti.com (8.13.7/8.13.7) with ESMTP id p35LcJXn006527 for ; Tue, 5 Apr 2011 16:38:19 -0500 (CDT) Received: from psmtp.com (na3sys009amx219.postini.com [74.125.149.59]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id p35LcIiu016824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 5 Apr 2011 16:38:18 -0500 Received: from na3sys009aog108.obsmtp.com ([209.85.213.182]) (using TLSv1) by na3sys009amx219.postini.com ([74.125.148.10]) with SMTP; Tue, 05 Apr 2011 21:38:19 GMT Received: from mail-yx0-f182.google.com ([209.85.213.182]) (using TLSv1) by na3sys009aob108.postini.com ([74.125.148.12]) with SMTP ID DSNKTZuLys4Eoqi7lprS34BPWZhoj4WhhaRt@postini.com; Tue, 05 Apr 2011 14:38:18 PDT Received: by mail-yx0-f182.google.com with SMTP id 31so391769yxl.13 for ; Tue, 05 Apr 2011 14:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nanometrics.ca; s=google; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=iCvGXjqwGIqyLafsbwIqF+jGPsFEHTNgz57/9gScjTk=; b=Xddsq5qWvdY54fYGU39gB+BSNTMyFHqR6yy24Mdm+SHxUaSFUXtIn/JtMSuPXOSAeF pNh6I+nutqz4rWt1j85joS307Vtst82YcSGWTaJZcR0c10O7Hg/W/jirMWKGyCa9oSAY +bcOkpznZw+8cOg/yjW9STOBFCNKgWkE6meXg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=nanometrics.ca; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=CZ0QsrQxJUPp6Zoaw4TJA+zaPP0EP/p5FsNmEYchGr/0z7ZUcJWRc/f0fHGQrVXcMk W/3LOZsaLQ9wt4qRBjBSYjKYn8eO0NmJrrw+XFacrzQ25oil06oQnApkm+TMpdH1nRoN RMCgKVba2D/K5NdPKeplEtyHVsVG9iJvfwp7s= Received: by 10.91.33.37 with SMTP id l37mr1080466agj.60.1302039497994; Tue, 05 Apr 2011 14:38:17 -0700 (PDT) Received: from localhost.localdomain ([206.191.47.130]) by mx.google.com with ESMTPS id c24sm6932367ana.21.2011.04.05.14.38.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Apr 2011 14:38:17 -0700 (PDT) From: Ben Gardiner To: davinci-linux-open-source@linux.davincidsp.com, linux-i2c@vger.kernel.org, Sekhar Nori , Ben Dooks Subject: [PATCH 3/6] i2c-davinci: introduce a dev-> function pointer for scl pulsing Date: Tue, 5 Apr 2011 17:38:06 -0400 Message-Id: <392ee718990c7f0f315d2273a1c74337149a0e1b.1302031487.git.bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: X-pstn-levels: (S:99.90000/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.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [db-null] Cc: linux-kernel@vger.kernel.org, Bastian Ruppert , Philby John , Ben Dooks , linux-arm-kernel@lists.infradead.org X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 05 Apr 2011 21:41:25 +0000 (UTC) The current implementation of the I2C recovery routine checks whether platform data ->scl_pin has been assigned and if so, the generic_i2c_clock_pulse routine is executed. In preparation for an alternative recovery routine; introduce a pulse_scl function pointer to the driver private structure and assign it the value of generic_i2c_clock_pulse on init if the scl_pin is assigned in platform data. Signed-off-by: Ben Gardiner Cc: Sekhar Nori Cc: Ben Dooks --- drivers/i2c/busses/i2c-davinci.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c index 7011222..0a2c697 100644 --- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c @@ -110,6 +110,7 @@ struct davinci_i2c_dev { int stop; u8 terminate; struct i2c_adapter adapter; + void (*pulse_scl) (struct davinci_i2c_dev *dev); #ifdef CONFIG_CPU_FREQ struct completion xfr_complete; struct notifier_block freq_transition; @@ -165,16 +166,17 @@ static void i2c_davinci_dump_regs(struct davinci_i2c_dev *dev) } /* Generate a pulse on the i2c clock pin. */ -static void generic_i2c_clock_pulse(unsigned int scl_pin) +static void generic_i2c_clock_pulse(struct davinci_i2c_dev *dev) { + struct davinci_i2c_platform_data *pdata = dev->dev->platform_data; u16 i; - if (scl_pin) { + if (pdata->scl_pin) { /* Send high and low on the SCL line */ for (i = 0; i < 9; i++) { - gpio_set_value(scl_pin, 0); + gpio_set_value(pdata->scl_pin, 0); udelay(20); - gpio_set_value(scl_pin, 1); + gpio_set_value(pdata->scl_pin, 1); udelay(20); } } @@ -186,7 +188,6 @@ static void generic_i2c_clock_pulse(unsigned int scl_pin) static void i2c_recover_bus(struct davinci_i2c_dev *dev) { u32 flag = 0; - struct davinci_i2c_platform_data *pdata = dev->dev->platform_data; i2c_davinci_dump_regs(dev); dev_err(dev->dev, "initiating i2c bus recovery\n"); @@ -195,8 +196,8 @@ 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 (dev->pulse_scl) + dev->pulse_scl(dev); /* Send STOP */ flag = davinci_i2c_read_reg(dev, DAVINCI_I2C_MDR_REG); flag |= DAVINCI_I2C_MDR_STP; @@ -669,6 +670,7 @@ static struct i2c_algorithm i2c_davinci_algo = { static int davinci_i2c_probe(struct platform_device *pdev) { + struct davinci_i2c_platform_data *pdata; struct davinci_i2c_dev *dev; struct i2c_adapter *adap; struct resource *mem, *irq, *ioarea; @@ -751,6 +753,10 @@ static int davinci_i2c_probe(struct platform_device *pdev) goto err_free_irq; } + pdata = dev->dev->platform_data; + if (pdata->scl_pin) + dev->pulse_scl = generic_i2c_clock_pulse; + return 0; err_free_irq: