All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time
@ 2014-01-11  0:50 Andrew Bresticker
       [not found] ` <1389401416-29892-1-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2014-01-13 17:02 ` Stephen Warren
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Bresticker @ 2014-01-11  0:50 UTC (permalink / raw)
  To: Stephen Warren, Linus Walleij
  Cc: Thierry Reding, linux-tegra, linux-kernel, Andrew Bresticker

Many devices rely on pinctrl/pinmux settings being applied
before probing and some of these may probe before device_initcall
time (e.g. i2c at subsys_initcall).  Move Tegra1x4 pinctrl driver
registration to arch_initcall time so that proper pin settings
can be applied earlier.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
 drivers/pinctrl/pinctrl-tegra114.c | 13 ++++++++++++-
 drivers/pinctrl/pinctrl-tegra124.c | 13 ++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-tegra114.c b/drivers/pinctrl/pinctrl-tegra114.c
index 93c9e38..5d0c950 100644
--- a/drivers/pinctrl/pinctrl-tegra114.c
+++ b/drivers/pinctrl/pinctrl-tegra114.c
@@ -2761,7 +2761,18 @@ static struct platform_driver tegra114_pinctrl_driver = {
 	.probe = tegra114_pinctrl_probe,
 	.remove = tegra_pinctrl_remove,
 };
-module_platform_driver(tegra114_pinctrl_driver);
+
+static int __init tegra114_pinctrl_init(void)
+{
+	return platform_driver_register(&tegra114_pinctrl_driver);
+}
+arch_initcall(tegra114_pinctrl_init);
+
+static void __exit tegra114_pinctrl_exit(void)
+{
+	platform_driver_unregister(&tegra114_pinctrl_driver);
+}
+module_exit(tegra114_pinctrl_exit);
 
 MODULE_AUTHOR("Pritesh Raithatha <praithatha@nvidia.com>");
 MODULE_DESCRIPTION("NVIDIA Tegra114 pinctrl driver");
diff --git a/drivers/pinctrl/pinctrl-tegra124.c b/drivers/pinctrl/pinctrl-tegra124.c
index c20e0e1..02ac976 100644
--- a/drivers/pinctrl/pinctrl-tegra124.c
+++ b/drivers/pinctrl/pinctrl-tegra124.c
@@ -3130,7 +3130,18 @@ static struct platform_driver tegra124_pinctrl_driver = {
 	.probe = tegra124_pinctrl_probe,
 	.remove = tegra_pinctrl_remove,
 };
-module_platform_driver(tegra124_pinctrl_driver);
+
+static int __init tegra124_pinctrl_init(void)
+{
+	return platform_driver_register(&tegra124_pinctrl_driver);
+}
+arch_initcall(tegra124_pinctrl_init);
+
+static void __exit tegra124_pinctrl_exit(void)
+{
+	platform_driver_unregister(&tegra124_pinctrl_driver);
+}
+module_exit(tegra124_pinctrl_exit);
 
 MODULE_AUTHOR("Ashwini Ghuge <aghuge@nvidia.com>");
 MODULE_DESCRIPTION("NVIDIA Tegra124 pinctrl driver");
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time
  2014-01-11  0:50 [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time Andrew Bresticker
@ 2014-01-13  9:02     ` Thierry Reding
  2014-01-13 17:02 ` Stephen Warren
  1 sibling, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2014-01-13  9:02 UTC (permalink / raw)
  To: Andrew Bresticker
  Cc: Stephen Warren, Linus Walleij,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]

On Fri, Jan 10, 2014 at 04:50:16PM -0800, Andrew Bresticker wrote:
> Many devices rely on pinctrl/pinmux settings being applied
> before probing and some of these may probe before device_initcall
> time (e.g. i2c at subsys_initcall).  Move Tegra1x4 pinctrl driver
> registration to arch_initcall time so that proper pin settings
> can be applied earlier.
> 
> Signed-off-by: Andrew Bresticker <abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> ---
>  drivers/pinctrl/pinctrl-tegra114.c | 13 ++++++++++++-
>  drivers/pinctrl/pinctrl-tegra124.c | 13 ++++++++++++-
>  2 files changed, 24 insertions(+), 2 deletions(-)

I wonder if a better approach would be to add pin control and pin mux
settings for devices that explicitly need them to the device tree nodes
of the devices themselves. That way they should be able to use deferred
probing to handle this kind of dependency rather than relying on magic
initcall ordering.

This does make the Tegra114 and Tegra124 drivers consistent with what we
have on Tegra20 an Tegra30, though, so perhaps pinctrl is one of the few
exceptions where initcall ordering would be okay.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time
@ 2014-01-13  9:02     ` Thierry Reding
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2014-01-13  9:02 UTC (permalink / raw)
  To: Andrew Bresticker
  Cc: Stephen Warren, Linus Walleij, linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]

On Fri, Jan 10, 2014 at 04:50:16PM -0800, Andrew Bresticker wrote:
> Many devices rely on pinctrl/pinmux settings being applied
> before probing and some of these may probe before device_initcall
> time (e.g. i2c at subsys_initcall).  Move Tegra1x4 pinctrl driver
> registration to arch_initcall time so that proper pin settings
> can be applied earlier.
> 
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
> ---
>  drivers/pinctrl/pinctrl-tegra114.c | 13 ++++++++++++-
>  drivers/pinctrl/pinctrl-tegra124.c | 13 ++++++++++++-
>  2 files changed, 24 insertions(+), 2 deletions(-)

I wonder if a better approach would be to add pin control and pin mux
settings for devices that explicitly need them to the device tree nodes
of the devices themselves. That way they should be able to use deferred
probing to handle this kind of dependency rather than relying on magic
initcall ordering.

This does make the Tegra114 and Tegra124 drivers consistent with what we
have on Tegra20 an Tegra30, though, so perhaps pinctrl is one of the few
exceptions where initcall ordering would be okay.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time
  2014-01-11  0:50 [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time Andrew Bresticker
       [not found] ` <1389401416-29892-1-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2014-01-13 17:02 ` Stephen Warren
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2014-01-13 17:02 UTC (permalink / raw)
  To: Andrew Bresticker, Linus Walleij
  Cc: Thierry Reding, linux-tegra, linux-kernel

On 01/10/2014 05:50 PM, Andrew Bresticker wrote:
> Many devices rely on pinctrl/pinmux settings being applied
> before probing and some of these may probe before device_initcall
> time (e.g. i2c at subsys_initcall).  Move Tegra1x4 pinctrl driver
> registration to arch_initcall time so that proper pin settings
> can be applied earlier.

NAK. We shouldn't play games with initcall levels to achieve probe
ordering. It's not scalable and there's no actual guarantee it'll
produce the desired result.

Instead, if one device depends on another, it should do so explicitly.
In other words, the device that relies on a particular pinctrl setting
should have a pinctrl state defined, that references the pin controller,
which then triggers deferred probe until the pin controller is initialized.

Since we initialize the whole pinctrl setup in one go in a state
associated with the pin controller, rather than as separate states
associated with each device, you'll need to have the leaf devices
reference an empty pinctrl state defined in the desired pin controller.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time
  2014-01-13  9:02     ` Thierry Reding
@ 2014-01-13 17:03         ` Stephen Warren
  -1 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2014-01-13 17:03 UTC (permalink / raw)
  To: Thierry Reding, Andrew Bresticker
  Cc: Linus Walleij, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 01/13/2014 02:02 AM, Thierry Reding wrote:
> On Fri, Jan 10, 2014 at 04:50:16PM -0800, Andrew Bresticker wrote:
>> Many devices rely on pinctrl/pinmux settings being applied
>> before probing and some of these may probe before device_initcall
>> time (e.g. i2c at subsys_initcall).  Move Tegra1x4 pinctrl driver
>> registration to arch_initcall time so that proper pin settings
>> can be applied earlier.
>>
>> Signed-off-by: Andrew Bresticker <abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
>> ---
>>  drivers/pinctrl/pinctrl-tegra114.c | 13 ++++++++++++-
>>  drivers/pinctrl/pinctrl-tegra124.c | 13 ++++++++++++-
>>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> I wonder if a better approach would be to add pin control and pin mux
> settings for devices that explicitly need them to the device tree nodes
> of the devices themselves.

We can't do that; the entire pinctrl state needs to be programmed at
once to avoid the conflict of multiple pins/groups being muxed to the
same function. However, we can make this work with empty states I believe.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time
@ 2014-01-13 17:03         ` Stephen Warren
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2014-01-13 17:03 UTC (permalink / raw)
  To: Thierry Reding, Andrew Bresticker
  Cc: Linus Walleij, linux-tegra, linux-kernel

On 01/13/2014 02:02 AM, Thierry Reding wrote:
> On Fri, Jan 10, 2014 at 04:50:16PM -0800, Andrew Bresticker wrote:
>> Many devices rely on pinctrl/pinmux settings being applied
>> before probing and some of these may probe before device_initcall
>> time (e.g. i2c at subsys_initcall).  Move Tegra1x4 pinctrl driver
>> registration to arch_initcall time so that proper pin settings
>> can be applied earlier.
>>
>> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
>> ---
>>  drivers/pinctrl/pinctrl-tegra114.c | 13 ++++++++++++-
>>  drivers/pinctrl/pinctrl-tegra124.c | 13 ++++++++++++-
>>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> I wonder if a better approach would be to add pin control and pin mux
> settings for devices that explicitly need them to the device tree nodes
> of the devices themselves.

We can't do that; the entire pinctrl state needs to be programmed at
once to avoid the conflict of multiple pins/groups being muxed to the
same function. However, we can make this work with empty states I believe.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-01-13 17:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-11  0:50 [PATCH] pinctrl: tegra1x4: initialize at arch_initcall time Andrew Bresticker
     [not found] ` <1389401416-29892-1-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2014-01-13  9:02   ` Thierry Reding
2014-01-13  9:02     ` Thierry Reding
     [not found]     ` <20140113090223.GA16296-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2014-01-13 17:03       ` Stephen Warren
2014-01-13 17:03         ` Stephen Warren
2014-01-13 17:02 ` Stephen Warren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.