linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] pinctrl: stm32: add changes to better manage
@ 2020-06-15 12:54 Alexandre Torgue
  2020-06-15 12:54 ` [PATCH 1/2] pinctrl: stm32: don't print an error on probe deferral during clock get Alexandre Torgue
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexandre Torgue @ 2020-06-15 12:54 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, linux-gpio, linux-stm32, alexandre.torgue

Hi,

Clocks and resets for GPIO banks could be defined but not yet ready when
stm32 pinctrl is probed. This series adds changes to manage probe defer
when a clock or a reset is not yet registered in the system.

regards
alex

Etienne Carriere (2):
  pinctrl: stm32: don't print an error on probe deferral during clock
    get
  pinctrl: stm32: defer probe if reset resource is not yet ready

 drivers/pinctrl/stm32/pinctrl-stm32.c | 35 +++++++++++++++++++--------
 1 file changed, 25 insertions(+), 10 deletions(-)

-- 
2.17.1


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

* [PATCH 1/2] pinctrl: stm32: don't print an error on probe deferral during clock get
  2020-06-15 12:54 [PATCH 0/2] pinctrl: stm32: add changes to better manage Alexandre Torgue
@ 2020-06-15 12:54 ` Alexandre Torgue
  2020-06-15 12:54 ` [PATCH 2/2] pinctrl: stm32: defer probe if reset resource is not yet ready Alexandre Torgue
  2020-06-20 21:06 ` [PATCH 0/2] pinctrl: stm32: add changes to better manage Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Torgue @ 2020-06-15 12:54 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, linux-gpio, linux-stm32, alexandre.torgue

From: Etienne Carriere <etienne.carriere@st.com>

Change STM32 pinctrl driver to not print an error trace when probe is
deferred due to clock resource. Probe defer issue (for clocks) could
occur during bank registering when some banks have already been registered.
In this case banks already registered should be released. To not waste time
in this case, it is better to check first if all clocks are available
before registering banks.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index a657cd829ce6..c15460ef2307 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -1217,12 +1217,6 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
 	if (IS_ERR(bank->base))
 		return PTR_ERR(bank->base);
 
-	bank->clk = of_clk_get_by_name(np, NULL);
-	if (IS_ERR(bank->clk)) {
-		dev_err(dev, "failed to get clk (%ld)\n", PTR_ERR(bank->clk));
-		return PTR_ERR(bank->clk);
-	}
-
 	err = clk_prepare(bank->clk);
 	if (err) {
 		dev_err(dev, "failed to prepare clk (%d)\n", err);
@@ -1517,6 +1511,23 @@ int stm32_pctl_probe(struct platform_device *pdev)
 	if (!pctl->banks)
 		return -ENOMEM;
 
+	i = 0;
+	for_each_available_child_of_node(np, child) {
+		struct stm32_gpio_bank *bank = &pctl->banks[i];
+
+		if (of_property_read_bool(child, "gpio-controller")) {
+			bank->clk = of_clk_get_by_name(child, NULL);
+			if (IS_ERR(bank->clk)) {
+				if (PTR_ERR(bank->clk) != -EPROBE_DEFER)
+					dev_err(dev,
+						"failed to get clk (%ld)\n",
+						PTR_ERR(bank->clk));
+				return PTR_ERR(bank->clk);
+			}
+			i++;
+		}
+	}
+
 	for_each_available_child_of_node(np, child) {
 		if (of_property_read_bool(child, "gpio-controller")) {
 			ret = stm32_gpiolib_register_bank(pctl, child);
-- 
2.17.1


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

* [PATCH 2/2] pinctrl: stm32: defer probe if reset resource is not yet ready
  2020-06-15 12:54 [PATCH 0/2] pinctrl: stm32: add changes to better manage Alexandre Torgue
  2020-06-15 12:54 ` [PATCH 1/2] pinctrl: stm32: don't print an error on probe deferral during clock get Alexandre Torgue
@ 2020-06-15 12:54 ` Alexandre Torgue
  2020-06-20 21:06 ` [PATCH 0/2] pinctrl: stm32: add changes to better manage Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Torgue @ 2020-06-15 12:54 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-kernel, linux-gpio, linux-stm32, alexandre.torgue

From: Etienne Carriere <etienne.carriere@st.com>

Defer probe when pin controller reset is defined in the system resources
but not yet probed.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index c15460ef2307..162535e7c94d 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -84,6 +84,7 @@ struct stm32_pinctrl_group {
 struct stm32_gpio_bank {
 	void __iomem *base;
 	struct clk *clk;
+	struct reset_control *rstc;
 	spinlock_t lock;
 	struct gpio_chip gpio_chip;
 	struct pinctrl_gpio_range range;
@@ -1202,13 +1203,11 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
 	struct of_phandle_args args;
 	struct device *dev = pctl->dev;
 	struct resource res;
-	struct reset_control *rstc;
 	int npins = STM32_GPIO_PINS_PER_BANK;
 	int bank_nr, err;
 
-	rstc = of_reset_control_get_exclusive(np, NULL);
-	if (!IS_ERR(rstc))
-		reset_control_deassert(rstc);
+	if (!IS_ERR(bank->rstc))
+		reset_control_deassert(bank->rstc);
 
 	if (of_address_to_resource(np, 0, &res))
 		return -ENODEV;
@@ -1516,6 +1515,11 @@ int stm32_pctl_probe(struct platform_device *pdev)
 		struct stm32_gpio_bank *bank = &pctl->banks[i];
 
 		if (of_property_read_bool(child, "gpio-controller")) {
+			bank->rstc = of_reset_control_get_exclusive(child,
+								    NULL);
+			if (PTR_ERR(bank->rstc) == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+
 			bank->clk = of_clk_get_by_name(child, NULL);
 			if (IS_ERR(bank->clk)) {
 				if (PTR_ERR(bank->clk) != -EPROBE_DEFER)
-- 
2.17.1


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

* Re: [PATCH 0/2] pinctrl: stm32: add changes to better manage
  2020-06-15 12:54 [PATCH 0/2] pinctrl: stm32: add changes to better manage Alexandre Torgue
  2020-06-15 12:54 ` [PATCH 1/2] pinctrl: stm32: don't print an error on probe deferral during clock get Alexandre Torgue
  2020-06-15 12:54 ` [PATCH 2/2] pinctrl: stm32: defer probe if reset resource is not yet ready Alexandre Torgue
@ 2020-06-20 21:06 ` Linus Walleij
  2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2020-06-20 21:06 UTC (permalink / raw)
  To: Alexandre Torgue; +Cc: linux-kernel, open list:GPIO SUBSYSTEM, linux-stm32

On Mon, Jun 15, 2020 at 2:54 PM Alexandre Torgue
<alexandre.torgue@st.com> wrote:

> Clocks and resets for GPIO banks could be defined but not yet ready when
> stm32 pinctrl is probed. This series adds changes to manage probe defer
> when a clock or a reset is not yet registered in the system.

Patches applied.

Yours,
Linus Walleij

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

end of thread, other threads:[~2020-06-20 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 12:54 [PATCH 0/2] pinctrl: stm32: add changes to better manage Alexandre Torgue
2020-06-15 12:54 ` [PATCH 1/2] pinctrl: stm32: don't print an error on probe deferral during clock get Alexandre Torgue
2020-06-15 12:54 ` [PATCH 2/2] pinctrl: stm32: defer probe if reset resource is not yet ready Alexandre Torgue
2020-06-20 21:06 ` [PATCH 0/2] pinctrl: stm32: add changes to better manage 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).