linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Reid <preid@electromag.com.au>
To: nsekhar@ti.com, khilman@kernel.org, wsa@the-dreams.de,
	jarkko.nikula@linux.intel.com, andriy.shevchenko@linux.intel.com,
	mika.westerberg@linux.intel.com, preid@electromag.com.au,
	linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org
Subject: [PATCH v5 6/7] i2c: davinci: switch to using gpiod for bus recovery gpios
Date: Thu,  2 Nov 2017 10:40:29 +0800	[thread overview]
Message-ID: <1509590430-11968-7-git-send-email-preid@electromag.com.au> (raw)
In-Reply-To: <1509590430-11968-1-git-send-email-preid@electromag.com.au>

Change the driver to use the gpio descriptors for the bus recovery
information instead of the deprecated integer interface.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Phil Reid <preid@electromag.com.au>
---
 drivers/i2c/busses/i2c-davinci.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index 2ead9b9..2afb12a 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -294,7 +294,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
 }
 
 /*
- * This routine does i2c bus recovery by using i2c_generic_gpio_recovery
+ * This routine does i2c bus recovery by using i2c_generic_scl_recovery
  * which is provided by I2C Bus recovery infrastructure.
  */
 static void davinci_i2c_prepare_recovery(struct i2c_adapter *adap)
@@ -316,7 +316,7 @@ static void davinci_i2c_unprepare_recovery(struct i2c_adapter *adap)
 }
 
 static struct i2c_bus_recovery_info davinci_i2c_gpio_recovery_info = {
-	.recover_bus = i2c_generic_gpio_recovery,
+	.recover_bus = i2c_generic_scl_recovery,
 	.prepare_recovery = davinci_i2c_prepare_recovery,
 	.unprepare_recovery = davinci_i2c_unprepare_recovery,
 };
@@ -769,6 +769,7 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 	struct davinci_i2c_dev *dev;
 	struct i2c_adapter *adap;
 	struct resource *mem;
+	struct i2c_bus_recovery_info *rinfo;
 	int r, irq;
 
 	irq = platform_get_irq(pdev, 0);
@@ -869,9 +870,18 @@ static int davinci_i2c_probe(struct platform_device *pdev)
 	if (dev->pdata->has_pfunc)
 		adap->bus_recovery_info = &davinci_i2c_scl_recovery_info;
 	else if (dev->pdata->scl_pin) {
-		adap->bus_recovery_info = &davinci_i2c_gpio_recovery_info;
-		adap->bus_recovery_info->scl_gpio = dev->pdata->scl_pin;
-		adap->bus_recovery_info->sda_gpio = dev->pdata->sda_pin;
+		rinfo =  &davinci_i2c_gpio_recovery_info;
+		adap->bus_recovery_info = rinfo;
+		r = gpio_request_one(dev->pdata->scl_pin, GPIOF_OPEN_DRAIN |
+				     GPIOF_OUT_INIT_HIGH, "i2c-scl");
+		if (r)
+			goto err_unuse_clocks;
+		rinfo->scl_gpiod = gpio_to_desc(dev->pdata->scl_pin);
+
+		r = gpio_request_one(dev->pdata->sda_pin, GPIOF_IN, "i2c-sda");
+		if (r)
+			goto err_unuse_clocks;
+		rinfo->sda_gpiod = gpio_to_desc(dev->pdata->scl_pin);
 	}
 
 	adap->nr = pdev->id;
-- 
1.8.3.1

  parent reply	other threads:[~2017-11-02  2:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02  2:40 [PATCH v5 0/7] i2c: designware: add i2c gpio recovery option Phil Reid
2017-11-02  2:40 ` [PATCH v5 1/7] i2c: Switch to using gpiod interface for gpio bus recovery Phil Reid
2017-11-02  2:40 ` [PATCH v5 2/7] i2c: designware: move i2c_dw_plat_prepare_clk to common Phil Reid
2017-11-02  2:40 ` [PATCH v5 3/7] i2c: designware: rename i2c_dw_plat_prepare_clk to i2c_dw_prepare_clk Phil Reid
2017-11-02  2:40 ` [PATCH v5 4/7] i2c: designware: add i2c gpio recovery option Phil Reid
2017-11-06 16:09   ` Andy Shevchenko
2017-11-07  1:02     ` Phil Reid
2017-11-08  8:29       ` Tim Sander
2017-11-08  9:29         ` Andy Shevchenko
2017-11-10  6:55           ` Phil Reid
2017-11-10 16:12             ` Andy Shevchenko
2017-11-02  2:40 ` [PATCH v5 5/7] i2c: imx: switch to using gpiod for bus recovery gpios Phil Reid
2017-11-02  2:40 ` Phil Reid [this message]
2017-11-02 15:15   ` [PATCH v5 6/7] i2c: davinci: " Sekhar Nori
2017-11-02  2:40 ` [PATCH v5 7/7] i2c: remove legacy integer scl/sda gpio for recovery Phil Reid
2017-11-02 15:23   ` Jarkko Nikula
2017-11-27 17:51 ` [PATCH v5 0/7] i2c: designware: add i2c gpio recovery option Wolfram Sang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509590430-11968-7-git-send-email-preid@electromag.com.au \
    --to=preid@electromag.com.au \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=nsekhar@ti.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).