All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] i2c: designware: add pinctrl for recovery info as an option
@ 2022-12-14 10:27 Hanna Hawa
  2022-12-14 11:42 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Hanna Hawa @ 2022-12-14 10:27 UTC (permalink / raw)
  To: jarkko.nikula, andriy.shevchenko, mika.westerberg, jsd
  Cc: linux-i2c, linux-kernel, dwmw, benh, ronenk, talel, jonnyc,
	hanochu, farbere, itamark, hhhawa

The current implementation of designware recovery mechanism fit for
specific device (Intel / Altera Cyclone V SOC) which have two separated
"wired" GPIOs to the i2c bus via the SOC FPGA for the i2c recovery.

This change add ability to get the pinctrl for the i2c recovery in order
to switch between pin configuration (I2C and GPIO functionality) if the
pinctrl exists.

Signed-off-by: Hanna Hawa <hhhawa@amazon.com>
---
 drivers/i2c/busses/i2c-designware-master.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index dc3c5a15a95b..478318b1d35f 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
@@ -832,6 +833,14 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev)
 	struct i2c_adapter *adap = &dev->adapter;
 	struct gpio_desc *gpio;
 
+	rinfo->pinctrl = devm_pinctrl_get(dev->dev);
+	if (IS_ERR(rinfo->pinctrl)) {
+		if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		rinfo->pinctrl = NULL;
+		dev_dbg(dev->dev, "can't get pinctrl for i2c recovery\n");
+	}
+
 	gpio = devm_gpiod_get_optional(dev->dev, "scl", GPIOD_OUT_HIGH);
 	if (IS_ERR_OR_NULL(gpio))
 		return PTR_ERR_OR_ZERO(gpio);
-- 
2.38.1


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

* Re: [PATCH 1/1] i2c: designware: add pinctrl for recovery info as an option
  2022-12-14 10:27 [PATCH 1/1] i2c: designware: add pinctrl for recovery info as an option Hanna Hawa
@ 2022-12-14 11:42 ` Andy Shevchenko
  2022-12-14 13:43   ` Hawa, Hanna
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-12-14 11:42 UTC (permalink / raw)
  To: Hanna Hawa
  Cc: jarkko.nikula, mika.westerberg, jsd, linux-i2c, linux-kernel,
	dwmw, benh, ronenk, talel, jonnyc, hanochu, farbere, itamark

On Wed, Dec 14, 2022 at 10:27:07AM +0000, Hanna Hawa wrote:
> The current implementation of designware recovery mechanism fit for
> specific device (Intel / Altera Cyclone V SOC) which have two separated
> "wired" GPIOs to the i2c bus via the SOC FPGA for the i2c recovery.
> 
> This change add ability to get the pinctrl for the i2c recovery in order
> to switch between pin configuration (I2C and GPIO functionality) if the
> pinctrl exists.

...

> +	rinfo->pinctrl = devm_pinctrl_get(dev->dev);
> +	if (IS_ERR(rinfo->pinctrl)) {
> +		if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER)
> +			return -EPROBE_DEFER;
> +		rinfo->pinctrl = NULL;
> +		dev_dbg(dev->dev, "can't get pinctrl for i2c recovery\n");
> +	}

Can you explain, why pinctrl_bind_pins() is not enough?

(You may also refer to the ab78029ecc34 ("drivers/pinctrl: grab default handles
 from device core") for more details.)

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 1/1] i2c: designware: add pinctrl for recovery info as an option
  2022-12-14 11:42 ` Andy Shevchenko
@ 2022-12-14 13:43   ` Hawa, Hanna
  0 siblings, 0 replies; 3+ messages in thread
From: Hawa, Hanna @ 2022-12-14 13:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: jarkko.nikula, mika.westerberg, jsd, linux-i2c, linux-kernel,
	dwmw, benh, ronenk, talel, jonnyc, hanochu, farbere, itamark



On 12/14/2022 1:42 PM, Andy Shevchenko wrote:
> Can you explain, why pinctrl_bind_pins() is not enough?
> 
> (You may also refer to the ab78029ecc34 ("drivers/pinctrl: grab default handles
>   from device core") for more details.)

Thanks for your reviewing and pointing to this function.

No need to recall the devm_pinctrl_get() during the i2c probe, as the 
pinctrl_bind_pins() is enough to init the pinctrl struct. But still need 
to set the rinfo->pinctrl with dev->pins->p, will upload new patchset.

The change will look like:

@@ -832,6 +833,9 @@ static int i2c_dw_init_recovery_info(struct 
dw_i2c_dev *dev)
         struct i2c_adapter *adap = &dev->adapter;
         struct gpio_desc *gpio;

+       if (dev->dev->pins && dev->dev->pins->p)
+               rinfo->pinctrl = dev->dev->pins->p;
+
         gpio = devm_gpiod_get_optional(dev->dev, "scl", GPIOD_OUT_HIGH);
         if (IS_ERR_OR_NULL(gpio))
                 return PTR_ERR_OR_ZERO(gpio);

Thanks,
Hanna

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

end of thread, other threads:[~2022-12-14 13:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 10:27 [PATCH 1/1] i2c: designware: add pinctrl for recovery info as an option Hanna Hawa
2022-12-14 11:42 ` Andy Shevchenko
2022-12-14 13:43   ` Hawa, Hanna

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.