diff mbox

[2/3] OMAP i2c: pinctrl-ify i2c-omap.c

Message ID 1348070841-23354-3-git-send-email-panto@antoniou-consulting.com (mailing list archive)
State New, archived
Headers show

Commit Message

Pantelis Antoniou Sept. 19, 2012, 4:07 p.m. UTC
Add support for pinctrl mux settings in the OMAP I2C driver.
If no such pinctl bindings are found a warning message is printed.

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
---
 drivers/i2c/busses/i2c-omap.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Tony Lindgren Sept. 18, 2012, 6:23 p.m. UTC | #1
* Pantelis Antoniou <panto@antoniou-consulting.com> [120918 11:13]:
> Add support for pinctrl mux settings in the OMAP I2C driver.
> If no such pinctl bindings are found a warning message is printed.
> 
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
>
> ---
>  drivers/i2c/busses/i2c-omap.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index b149e32..f722478 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -43,6 +43,8 @@
>  #include <linux/slab.h>
>  #include <linux/i2c-omap.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/err.h>
>  
>  /* I2C controller revisions */
>  #define OMAP_I2C_OMAP1_REV_2		0x20
> @@ -1057,6 +1059,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  	const struct of_device_id *match;
>  	int irq;
>  	int r;
> +	struct pinctrl *pinctrl;
>  
>  	/* NOTE: driver uses the static register mapping */
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1197,6 +1200,10 @@ omap_i2c_probe(struct platform_device *pdev)
>  
>  	of_i2c_register_devices(adap);
>  
> +	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> +	if (IS_ERR(pinctrl))
> +		dev_warn(dev->dev, "pins are not configured from the driver\n");
> +
>  	pm_runtime_mark_last_busy(dev->dev);
>  	pm_runtime_put_autosuspend(dev->dev);

This must be just a warning here as otherwise things will break
badly for drivers doing pinmuxing in bootloader only. Other than
that:

Acked-by: Tony Lindgren <tony@atomide.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pantelis Antoniou Sept. 18, 2012, 7:37 p.m. UTC | #2
Hi Tony,

On Sep 18, 2012, at 9:23 PM, Tony Lindgren wrote:

> * Pantelis Antoniou <panto@antoniou-consulting.com> [120918 11:13]:
>> Add support for pinctrl mux settings in the OMAP I2C driver.
>> If no such pinctl bindings are found a warning message is printed.
>> 
>> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
>> 
>> ---
>> drivers/i2c/busses/i2c-omap.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>> 
>> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
>> index b149e32..f722478 100644
>> --- a/drivers/i2c/busses/i2c-omap.c
>> +++ b/drivers/i2c/busses/i2c-omap.c
>> @@ -43,6 +43,8 @@
>> #include <linux/slab.h>
>> #include <linux/i2c-omap.h>
>> #include <linux/pm_runtime.h>
>> +#include <linux/pinctrl/consumer.h>
>> +#include <linux/err.h>
>> 
>> /* I2C controller revisions */
>> #define OMAP_I2C_OMAP1_REV_2		0x20
>> @@ -1057,6 +1059,7 @@ omap_i2c_probe(struct platform_device *pdev)
>> 	const struct of_device_id *match;
>> 	int irq;
>> 	int r;
>> +	struct pinctrl *pinctrl;
>> 
>> 	/* NOTE: driver uses the static register mapping */
>> 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> @@ -1197,6 +1200,10 @@ omap_i2c_probe(struct platform_device *pdev)
>> 
>> 	of_i2c_register_devices(adap);
>> 
>> +	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>> +	if (IS_ERR(pinctrl))
>> +		dev_warn(dev->dev, "pins are not configured from the driver\n");
>> +
>> 	pm_runtime_mark_last_busy(dev->dev);
>> 	pm_runtime_put_autosuspend(dev->dev);
> 
> This must be just a warning here as otherwise things will break
> badly for drivers doing pinmuxing in bootloader only. Other than
> that:
> 

It is just a warning indeed. Not many boards do the pinctrl dance yet.

> Acked-by: Tony Lindgren <tony@atomide.com>

Regards

-- Pantelis
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Shubhrajyoti Datta Sept. 19, 2012, 7:09 a.m. UTC | #3
On Wednesday 19 September 2012 09:37 PM, Pantelis Antoniou wrote:
>  #include <linux/pm_runtime.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/err.h>
err.h include may be removed.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pantelis Antoniou Sept. 19, 2012, 8:34 a.m. UTC | #4
Hi

On Sep 19, 2012, at 10:09 AM, Shubhrajyoti wrote:

> On Wednesday 19 September 2012 09:37 PM, Pantelis Antoniou wrote:
>> #include <linux/pm_runtime.h>
>> +#include <linux/pinctrl/consumer.h>
>> +#include <linux/err.h>
> err.h include may be removed.

Right, Updated patch series (without the message patch follows)...

Regards

-- Pantelis


--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pantelis Antoniou Sept. 20, 2012, 6:34 a.m. UTC | #5
Pinctrl-fy the OMAP I2C driver.

Due to the requirement of early usage of I2C for
regulators and such, earlier initialization of pinctrl
is required.

This patch series is against

git://gitorious.org/linus-tree/linus-tree.git for_3.7/i2c/big_cleanups

Note that the I2C DT bindings are against the linux-omap-dt tree
and that without https://patchwork.kernel.org/patch/1468531
queued for 3.7 scary messages will be printed on !DT platforms

Pantelis Antoniou (2):
  pinctrl: pinctrl-single must be initialized early.
  OMAP i2c: pinctrl-ify i2c-omap.c

 drivers/i2c/busses/i2c-omap.c    |  6 ++++++
 drivers/pinctrl/pinctrl-single.c | 12 +++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
Peter Ujfalusi Sept. 21, 2012, 7:29 a.m. UTC | #6
On 09/19/2012 07:07 PM, Pantelis Antoniou wrote:
> Add support for pinctrl mux settings in the OMAP I2C driver.
> If no such pinctl bindings are found a warning message is printed.
> 
> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
> ---
>  drivers/i2c/busses/i2c-omap.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index b149e32..f722478 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -43,6 +43,8 @@
>  #include <linux/slab.h>
>  #include <linux/i2c-omap.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/err.h>
>  
>  /* I2C controller revisions */
>  #define OMAP_I2C_OMAP1_REV_2		0x20
> @@ -1057,6 +1059,7 @@ omap_i2c_probe(struct platform_device *pdev)
>  	const struct of_device_id *match;
>  	int irq;
>  	int r;
> +	struct pinctrl *pinctrl;
>  
>  	/* NOTE: driver uses the static register mapping */
>  	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -1197,6 +1200,10 @@ omap_i2c_probe(struct platform_device *pdev)
>  
>  	of_i2c_register_devices(adap);
>  
> +	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
> +	if (IS_ERR(pinctrl))
> +		dev_warn(dev->dev, "pins are not configured from the driver\n");

Can you use &pdev->dev for the dev_warn() here?
the dev->dev is quite confusing especially since you used &pdev->dev for the
pinctrl call.

> +
>  	pm_runtime_mark_last_busy(dev->dev);
>  	pm_runtime_put_autosuspend(dev->dev);
>  
>
Pantelis Antoniou Sept. 21, 2012, 7:34 a.m. UTC | #7
On Sep 21, 2012, at 10:29 AM, Peter Ujfalusi wrote:

> On 09/19/2012 07:07 PM, Pantelis Antoniou wrote:
>> Add support for pinctrl mux settings in the OMAP I2C driver.
>> If no such pinctl bindings are found a warning message is printed.
>> 
>> Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
>> ---
>> drivers/i2c/busses/i2c-omap.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>> 
>> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
>> index b149e32..f722478 100644
>> --- a/drivers/i2c/busses/i2c-omap.c
>> +++ b/drivers/i2c/busses/i2c-omap.c
>> @@ -43,6 +43,8 @@
>> #include <linux/slab.h>
>> #include <linux/i2c-omap.h>
>> #include <linux/pm_runtime.h>
>> +#include <linux/pinctrl/consumer.h>
>> +#include <linux/err.h>
>> 
>> /* I2C controller revisions */
>> #define OMAP_I2C_OMAP1_REV_2		0x20
>> @@ -1057,6 +1059,7 @@ omap_i2c_probe(struct platform_device *pdev)
>> 	const struct of_device_id *match;
>> 	int irq;
>> 	int r;
>> +	struct pinctrl *pinctrl;
>> 
>> 	/* NOTE: driver uses the static register mapping */
>> 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> @@ -1197,6 +1200,10 @@ omap_i2c_probe(struct platform_device *pdev)
>> 
>> 	of_i2c_register_devices(adap);
>> 
>> +	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
>> +	if (IS_ERR(pinctrl))
>> +		dev_warn(dev->dev, "pins are not configured from the driver\n");
> 
> Can you use &pdev->dev for the dev_warn() here?
> the dev->dev is quite confusing especially since you used &pdev->dev for the
> pinctrl call.

Not really, since this is the device argument used in all dev_* calls in the function.

A few lines before you have:

> dev_err(dev->dev, "failure adding adapter\n");

And so on.

Using a different device argument there would be confusing.

> 
>> +
>> 	pm_runtime_mark_last_busy(dev->dev);
>> 	pm_runtime_put_autosuspend(dev->dev);
>> 
>> 
> 
> 
> -- 
> Péter


Regards

-- Pantelis

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index b149e32..f722478 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -43,6 +43,8 @@ 
 #include <linux/slab.h>
 #include <linux/i2c-omap.h>
 #include <linux/pm_runtime.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/err.h>
 
 /* I2C controller revisions */
 #define OMAP_I2C_OMAP1_REV_2		0x20
@@ -1057,6 +1059,7 @@  omap_i2c_probe(struct platform_device *pdev)
 	const struct of_device_id *match;
 	int irq;
 	int r;
+	struct pinctrl *pinctrl;
 
 	/* NOTE: driver uses the static register mapping */
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1197,6 +1200,10 @@  omap_i2c_probe(struct platform_device *pdev)
 
 	of_i2c_register_devices(adap);
 
+	pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
+	if (IS_ERR(pinctrl))
+		dev_warn(dev->dev, "pins are not configured from the driver\n");
+
 	pm_runtime_mark_last_busy(dev->dev);
 	pm_runtime_put_autosuspend(dev->dev);