linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Allow pinctrl framework to create links
@ 2019-05-22 15:29 Benjamin Gaignard
  2019-05-22 15:29 ` [PATCH 1/2] pinctrl: Allow to create link between controller and consumer Benjamin Gaignard
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Benjamin Gaignard @ 2019-05-22 15:29 UTC (permalink / raw)
  To: linus.walleij, alexandre.torgue, amelie.delaunay
  Cc: linux-gpio, linux-kernel, linux-stm32, linux-arm-kernel,
	benjamin.gaignard, Benjamin Gaignard

Some pin controllers may need to ensure suspend/resume calls ordering between
themselves and their clients.
That is the case for STMFX (an I2C GPIO expender) which need to be suspended
after all it clients to let them call pinctrl_pm_select_sleep_state() before
perform it own suspend function. It is the same problem for resume but in
reverse order.

This series allow to let pinctrl core knows if a controller would like to
create link between itself and it client by setting create_link to true.

Benjamin Gaignard (2):
  pinctrl: Allow to create link between controller and consumer
  pinctrl: stmfx: enable links creations

 drivers/pinctrl/core.c          | 11 +++++++++++
 drivers/pinctrl/pinctrl-stmfx.c |  1 +
 include/linux/pinctrl/pinctrl.h |  2 ++
 3 files changed, 14 insertions(+)

-- 
2.15.0


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

* [PATCH 1/2] pinctrl: Allow to create link between controller and consumer
  2019-05-22 15:29 [PATCH 0/2] Allow pinctrl framework to create links Benjamin Gaignard
@ 2019-05-22 15:29 ` Benjamin Gaignard
  2019-05-22 15:29 ` [PATCH 2/2] pinctrl: stmfx: enable links creations Benjamin Gaignard
  2019-05-23  7:37 ` [PATCH 0/2] Allow pinctrl framework to create links Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Benjamin Gaignard @ 2019-05-22 15:29 UTC (permalink / raw)
  To: linus.walleij, alexandre.torgue, amelie.delaunay
  Cc: linux-gpio, linux-kernel, linux-stm32, linux-arm-kernel,
	benjamin.gaignard, Benjamin Gaignard

Pin controller may want to create a link between itself and its clients
to be sure of suspend/resume call ordering.
Introduce create_link field in pinctrl_desc structure to let pinctrl core
knows that controller expect to create a link.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
---
 drivers/pinctrl/core.c          | 11 +++++++++++
 include/linux/pinctrl/pinctrl.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index c6ff4d5fa482..40b647f3dc7d 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1216,6 +1216,15 @@ struct pinctrl_state *pinctrl_lookup_state(struct pinctrl *p,
 }
 EXPORT_SYMBOL_GPL(pinctrl_lookup_state);
 
+static void pinctrl_link_add(struct pinctrl_dev *pctldev,
+			     struct device *consumer)
+{
+	if (pctldev->desc->create_link)
+		device_link_add(consumer, pctldev->dev,
+				DL_FLAG_PM_RUNTIME |
+				DL_FLAG_AUTOREMOVE_CONSUMER);
+}
+
 /**
  * pinctrl_commit_state() - select/activate/program a pinctrl state to HW
  * @p: the pinctrl handle for the device that requests configuration
@@ -1261,6 +1270,8 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
 		if (ret < 0) {
 			goto unapply_new_state;
 		}
+
+		pinctrl_link_add(setting->pctldev, p->dev);
 	}
 
 	p->state = state;
diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
index 8f5dbb84547a..11a42ccf4b0a 100644
--- a/include/linux/pinctrl/pinctrl.h
+++ b/include/linux/pinctrl/pinctrl.h
@@ -125,6 +125,7 @@ struct pinctrl_ops {
  *	the hardware description
  * @custom_conf_items: Information how to print @params in debugfs, must be
  *	the same size as the @custom_params, i.e. @num_custom_params
+ * @create_link: If true create a link between pinctrl and it consumer
  */
 struct pinctrl_desc {
 	const char *name;
@@ -139,6 +140,7 @@ struct pinctrl_desc {
 	const struct pinconf_generic_params *custom_params;
 	const struct pin_config_item *custom_conf_items;
 #endif
+	bool create_link;
 };
 
 /* External interface to pin controller */
-- 
2.15.0


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

* [PATCH 2/2] pinctrl: stmfx: enable links creations
  2019-05-22 15:29 [PATCH 0/2] Allow pinctrl framework to create links Benjamin Gaignard
  2019-05-22 15:29 ` [PATCH 1/2] pinctrl: Allow to create link between controller and consumer Benjamin Gaignard
@ 2019-05-22 15:29 ` Benjamin Gaignard
  2019-05-23  7:37 ` [PATCH 0/2] Allow pinctrl framework to create links Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Benjamin Gaignard @ 2019-05-22 15:29 UTC (permalink / raw)
  To: linus.walleij, alexandre.torgue, amelie.delaunay
  Cc: linux-gpio, linux-kernel, linux-stm32, linux-arm-kernel,
	benjamin.gaignard, Benjamin Gaignard

Set create_link to inform pinctrl core that stmfx wants to create
link with its consumers.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
---
 drivers/pinctrl/pinctrl-stmfx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/pinctrl-stmfx.c b/drivers/pinctrl/pinctrl-stmfx.c
index eba872ce4a7c..55a9f145b4d9 100644
--- a/drivers/pinctrl/pinctrl-stmfx.c
+++ b/drivers/pinctrl/pinctrl-stmfx.c
@@ -622,6 +622,7 @@ static int stmfx_pinctrl_probe(struct platform_device *pdev)
 	pctl->pctl_desc.pins = stmfx_pins;
 	pctl->pctl_desc.npins = ARRAY_SIZE(stmfx_pins);
 	pctl->pctl_desc.owner = THIS_MODULE;
+	pctl->pctl_desc.create_link = true;
 
 	ret = devm_pinctrl_register_and_init(pctl->dev, &pctl->pctl_desc,
 					     pctl, &pctl->pctl_dev);
-- 
2.15.0


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

* Re: [PATCH 0/2] Allow pinctrl framework to create links
  2019-05-22 15:29 [PATCH 0/2] Allow pinctrl framework to create links Benjamin Gaignard
  2019-05-22 15:29 ` [PATCH 1/2] pinctrl: Allow to create link between controller and consumer Benjamin Gaignard
  2019-05-22 15:29 ` [PATCH 2/2] pinctrl: stmfx: enable links creations Benjamin Gaignard
@ 2019-05-23  7:37 ` Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2019-05-23  7:37 UTC (permalink / raw)
  To: Benjamin Gaignard
  Cc: Alexandre TORGUE, Amelie Delaunay, open list:GPIO SUBSYSTEM,
	linux-kernel, linux-stm32, Linux ARM, Benjamin Gaignard

Hi Benjamin!

On Wed, May 22, 2019 at 5:29 PM Benjamin Gaignard
<benjamin.gaignard@st.com> wrote:

> Some pin controllers may need to ensure suspend/resume calls ordering between
> themselves and their clients.
> That is the case for STMFX (an I2C GPIO expender) which need to be suspended
> after all it clients to let them call pinctrl_pm_select_sleep_state() before
> perform it own suspend function. It is the same problem for resume but in
> reverse order.
>
> This series allow to let pinctrl core knows if a controller would like to
> create link between itself and it client by setting create_link to true.

I changed the name of the boolt to "link_consumers" and applied!

I will send patches for all other pin controllers that are I2C or other
slow bus based, as they will definately need this. Let's see what
happens!

Yours,
Linus Walleij

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

end of thread, other threads:[~2019-05-23  7:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 15:29 [PATCH 0/2] Allow pinctrl framework to create links Benjamin Gaignard
2019-05-22 15:29 ` [PATCH 1/2] pinctrl: Allow to create link between controller and consumer Benjamin Gaignard
2019-05-22 15:29 ` [PATCH 2/2] pinctrl: stmfx: enable links creations Benjamin Gaignard
2019-05-23  7:37 ` [PATCH 0/2] Allow pinctrl framework to create links Linus Walleij

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).