public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Figa <t.figa@samsung.com>
To: Thomas Abraham <thomas.abraham@linaro.org>
Cc: linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, linus.walleij@linaro.org,
	dong.aisheng@linaro.org, swarren@wwwdotorg.org,
	kgene.kim@samsung.com, patches@linaro.org, w.sang@pengutronix.de,
	ben-linux@fluff.org
Subject: Re: [PATCH 1/2] i2c: s3c2410: add optional pin configuration using pinctrl interface
Date: Thu, 06 Sep 2012 11:34:25 +0200	[thread overview]
Message-ID: <2444562.GB3nOHUb9M@amdc1227> (raw)
In-Reply-To: <1346923381-14144-2-git-send-email-thomas.abraham@linaro.org>

Hi,

This patch shows the problem of the need to explicitly migrate all drivers 
to pinctrl.

Maybe we should consider extending the pinctrl subsystem to set the default 
state automatically before binding a driver to a device, at least in case 
of DT-based platforms?

This would be similar to what is done currently with samsung-gpio bindings 
- the pin is being configured by custom xlate callback based on additional 
cells in GPIO specifier, when the driver retrieves the pin using 
of_get{_named,}_gpio without the need of setting it up in the driver.

Best regards,
-- 
Tomasz Figa
Samsung Poland R&D Center

On Thursday 06 of September 2012 14:53:00 Thomas Abraham wrote:
> Add optional support for i2c bus pin configuration using pinctrl
> interface
> 
> Cc: Ben Dooks <ben-linux@fluff.org>
> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
> ---
>  drivers/i2c/busses/i2c-s3c2410.c |   19 ++++++++++++++++---
>  1 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-s3c2410.c
> b/drivers/i2c/busses/i2c-s3c2410.c index 5ae3b02..f4b2d6f 100644
> --- a/drivers/i2c/busses/i2c-s3c2410.c
> +++ b/drivers/i2c/busses/i2c-s3c2410.c
> @@ -38,6 +38,7 @@
>  #include <linux/io.h>
>  #include <linux/of_i2c.h>
>  #include <linux/of_gpio.h>
> +#include <linux/pinctrl/consumer.h>
> 
>  #include <asm/irq.h>
> 
> @@ -83,6 +84,8 @@ struct s3c24xx_i2c {
> 
>  	struct s3c2410_platform_i2c	*pdata;
>  	int			gpios[2];
> +	struct pinctrl		*pctrl;
> +	struct pinctrl_state	*pctrl_state;
>  #ifdef CONFIG_CPU_FREQ
>  	struct notifier_block	freq_transition;
>  #endif
> @@ -859,11 +862,17 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c
> *i2c)
> 
>  	/* inititalise the gpio */
> 
> -	if (pdata->cfg_gpio)
> +	if (pdata->cfg_gpio) {
>  		pdata->cfg_gpio(to_platform_device(i2c->dev));
> -	else
> -		if (s3c24xx_i2c_parse_dt_gpio(i2c))
> +	} else if (!IS_ERR_OR_NULL(i2c->pctrl) &&
> +			!IS_ERR_OR_NULL(i2c->pctrl_state)) {
> +		if (pinctrl_select_state(i2c->pctrl, i2c->pctrl_state)) {
> +			dev_err(i2c->dev, "failed to configure io-pins\n");
> +			return -ENXIO;
> +		}
> +	} else if (s3c24xx_i2c_parse_dt_gpio(i2c)) {
>  			return -EINVAL;
> +	}
> 
>  	/* write slave address */
> 
> @@ -1013,6 +1022,10 @@ static int s3c24xx_i2c_probe(struct
> platform_device *pdev) i2c->adap.algo_data = i2c;
>  	i2c->adap.dev.parent = &pdev->dev;
> 
> +	i2c->pctrl = devm_pinctrl_get(i2c->dev);
> +	if (!IS_ERR_OR_NULL(i2c->pctrl))
> +		i2c->pctrl_state = pinctrl_lookup_state(i2c->pctrl, "default");
> +
>  	/* initialise the i2c controller */
> 
>  	ret = s3c24xx_i2c_init(i2c);

  reply	other threads:[~2012-09-06  9:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-06  9:22 [PATCH 0/2] i2c: s3c2410: allow pin pin configuration using pinctrl Thomas Abraham
2012-09-06  9:23 ` [PATCH 1/2] i2c: s3c2410: add optional pin configuration using pinctrl interface Thomas Abraham
2012-09-06  9:34   ` Tomasz Figa [this message]
2012-09-06 11:06     ` Thomas Abraham
2012-09-06 12:28       ` Tomasz Figa
2012-09-10 19:55         ` Linus Walleij
2012-09-10 19:21       ` Stephen Warren
     [not found]         ` <504E3DBA.3080603-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-09-17  7:28           ` Thomas Abraham
2012-09-10 20:02   ` Linus Walleij
     [not found]     ` <CACRpkdZ7kjfDQ-CNCcCv5fQwSqMez6sKSMUMLB=0Aviboiz=2g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-17  7:52       ` Thomas Abraham
     [not found] ` <1346923381-14144-1-git-send-email-thomas.abraham-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-09-06  9:23   ` [PATCH 2/2] ARM: dts: exynos4: allow i2c0 bus to be configured " Thomas Abraham
2012-09-06 10:13     ` Tomasz Figa
2012-09-06 11:14       ` Thomas Abraham
2012-09-10 19:23         ` Stephen Warren

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=2444562.GB3nOHUb9M@amdc1227 \
    --to=t.figa@samsung.com \
    --cc=ben-linux@fluff.org \
    --cc=dong.aisheng@linaro.org \
    --cc=kgene.kim@samsung.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=swarren@wwwdotorg.org \
    --cc=thomas.abraham@linaro.org \
    --cc=w.sang@pengutronix.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