u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] pinctrl single: GPIO support
@ 2021-08-24 10:16 Bharat Kumar Reddy Gooty
  2021-08-24 10:16 ` [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt Bharat Kumar Reddy Gooty
  2021-08-24 10:16 ` [PATCH v1 2/2] pinctrl: single: Add request() api Bharat Kumar Reddy Gooty
  0 siblings, 2 replies; 9+ messages in thread
From: Bharat Kumar Reddy Gooty @ 2021-08-24 10:16 UTC (permalink / raw)
  To: Dario Binacchi, Simon Glass, Pratyush Yadav, Rayagonda Kokatanur,
	Vignesh Raghavendra, u-boot
  Cc: Bharat Gooty

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

From: Bharat Gooty <bharat.gooty@broadcom.com>

pinctrl-single:-
Add support to parse "pinctrl-single,gpio-range" and 
"#pinctrl-single,gpio-range-cells" DT properties

Add pinctrl_ops request()

Bharat Gooty (2):
  pinctrl: single: Parse gpio details from dt
  pinctrl: single: Add request() api

 drivers/pinctrl/pinctrl-single.c | 86 ++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)

-- 
2.17.1


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt
  2021-08-24 10:16 [PATCH v1 0/2] pinctrl single: GPIO support Bharat Kumar Reddy Gooty
@ 2021-08-24 10:16 ` Bharat Kumar Reddy Gooty
  2021-09-13  6:40   ` Rayagonda Kokatanur
                     ` (2 more replies)
  2021-08-24 10:16 ` [PATCH v1 2/2] pinctrl: single: Add request() api Bharat Kumar Reddy Gooty
  1 sibling, 3 replies; 9+ messages in thread
From: Bharat Kumar Reddy Gooty @ 2021-08-24 10:16 UTC (permalink / raw)
  To: Dario Binacchi, Simon Glass, Pratyush Yadav, Rayagonda Kokatanur,
	Vignesh Raghavendra, u-boot
  Cc: Bharat Gooty

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

From: Bharat Gooty <bharat.gooty@broadcom.com>

Parse different gpio properties from dt as part of probe
function. This detail is required to enable pinctrl pad
later when gpio lines are requested.

Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
---
 drivers/pinctrl/pinctrl-single.c | 52 ++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index cf9ad3670f..0f96cd5870 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -8,6 +8,7 @@
 #include <dm.h>
 #include <dm/device_compat.h>
 #include <dm/devres.h>
+#include <dm/of_access.h>
 #include <dm/pinctrl.h>
 #include <linux/libfdt.h>
 #include <linux/list.h>
@@ -44,11 +45,27 @@ struct single_func {
 	unsigned int *pins;
 };
 
+/**
+ * struct single_gpiofunc_range - pin ranges with same mux value of gpio fun
+ * @offset: offset base of pins
+ * @npins: number pins with the same mux value of gpio function
+ * @gpiofunc: mux value of gpio function
+ * @node: list node
+ */
+struct single_gpiofunc_range {
+	u32 offset;
+	u32 npins;
+	u32 gpiofunc;
+	struct list_head node;
+};
+
 /**
  * struct single_priv - private data
  * @bits_per_pin: number of bits per pin
  * @npins: number of selectable pins
  * @pin_name: temporary buffer to store the pin name
+ * @functions: list pin functions
+ * @gpiofuncs: list gpio functions
  */
 struct single_priv {
 #if (IS_ENABLED(CONFIG_SANDBOX))
@@ -58,6 +75,7 @@ struct single_priv {
 	unsigned int npins;
 	char pin_name[PINNAME_SIZE];
 	struct list_head functions;
+	struct list_head gpiofuncs;
 };
 
 /**
@@ -454,6 +472,36 @@ static int single_get_pins_count(struct udevice *dev)
 	return priv->npins;
 }
 
+static int single_add_gpio_func(struct udevice *dev)
+{
+	struct single_priv *priv = dev_get_priv(dev);
+	const char *propname = "pinctrl-single,gpio-range";
+	const char *cellname = "#pinctrl-single,gpio-range-cells";
+	struct single_gpiofunc_range *range;
+	struct ofnode_phandle_args gpiospec;
+	int ret, i;
+
+	for (i = 0; ; i++) {
+		ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), propname,
+						     cellname, 0, i, &gpiospec);
+		/* Do not treat it as error. Only treat it as end condition. */
+		if (ret) {
+			ret = 0;
+			break;
+		}
+		range = devm_kzalloc(dev, sizeof(*range), GFP_KERNEL);
+		if (!range) {
+			ret = -ENOMEM;
+			break;
+		}
+		range->offset = gpiospec.args[0];
+		range->npins = gpiospec.args[1];
+		range->gpiofunc = gpiospec.args[2];
+		list_add_tail(&range->node, &priv->gpiofuncs);
+	}
+	return ret;
+}
+
 static int single_probe(struct udevice *dev)
 {
 	struct single_pdata *pdata = dev_get_plat(dev);
@@ -461,6 +509,7 @@ static int single_probe(struct udevice *dev)
 	u32 size;
 
 	INIT_LIST_HEAD(&priv->functions);
+	INIT_LIST_HEAD(&priv->gpiofuncs);
 
 	size = pdata->offset + pdata->width / BITS_PER_BYTE;
 	#if (CONFIG_IS_ENABLED(SANDBOX))
@@ -483,6 +532,9 @@ static int single_probe(struct udevice *dev)
 		priv->npins *= (pdata->width / priv->bits_per_pin);
 	}
 
+	if (single_add_gpio_func(dev))
+		dev_dbg(dev, "gpio functions are not added\n");
+
 	dev_dbg(dev, "%d pins\n", priv->npins);
 	return 0;
 }
-- 
2.17.1


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* [PATCH v1 2/2] pinctrl: single: Add request() api
  2021-08-24 10:16 [PATCH v1 0/2] pinctrl single: GPIO support Bharat Kumar Reddy Gooty
  2021-08-24 10:16 ` [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt Bharat Kumar Reddy Gooty
@ 2021-08-24 10:16 ` Bharat Kumar Reddy Gooty
  2021-09-13  6:39   ` Rayagonda Kokatanur
  2021-10-05 22:02   ` Tom Rini
  1 sibling, 2 replies; 9+ messages in thread
From: Bharat Kumar Reddy Gooty @ 2021-08-24 10:16 UTC (permalink / raw)
  To: Dario Binacchi, Simon Glass, Pratyush Yadav, Rayagonda Kokatanur,
	Vignesh Raghavendra, u-boot
  Cc: Bharat Gooty

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

From: Bharat Gooty <bharat.gooty@broadcom.com>

Add pinctrl_ops->request api to configure pctrl
pad register in gpio mode.

Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
---
 drivers/pinctrl/pinctrl-single.c | 34 ++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 0f96cd5870..8fc07e3498 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -250,6 +250,39 @@ static int single_get_pin_muxing(struct udevice *dev, unsigned int pin,
 	return 0;
 }
 
+static int single_request(struct udevice *dev, int pin, int flags)
+{
+	struct single_priv *priv = dev_get_priv(dev);
+	struct single_pdata *pdata = dev_get_plat(dev);
+	struct single_gpiofunc_range *frange = NULL;
+	struct list_head *pos, *tmp;
+	phys_addr_t reg;
+	int mux_bytes = 0;
+	u32 data;
+
+	/* If function mask is null, needn't enable it. */
+	if (!pdata->mask)
+		return -ENOTSUPP;
+
+	list_for_each_safe(pos, tmp, &priv->gpiofuncs) {
+		frange = list_entry(pos, struct single_gpiofunc_range, node);
+		if ((pin >= frange->offset + frange->npins) ||
+		    pin < frange->offset)
+			continue;
+
+		mux_bytes = pdata->width / BITS_PER_BYTE;
+		reg = pdata->base + pin * mux_bytes;
+
+		data = single_read(dev, reg);
+		data &= ~pdata->mask;
+		data |= frange->gpiofunc;
+		single_write(dev, data, reg);
+		break;
+	}
+
+	return 0;
+}
+
 static struct single_func *single_allocate_function(struct udevice *dev,
 						    unsigned int group_pins)
 {
@@ -587,6 +620,7 @@ const struct pinctrl_ops single_pinctrl_ops = {
 	.get_pin_name = single_get_pin_name,
 	.set_state = single_set_state,
 	.get_pin_muxing	= single_get_pin_muxing,
+	.request = single_request,
 };
 
 static const struct udevice_id single_pinctrl_match[] = {
-- 
2.17.1


-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]

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

* Re: [PATCH v1 2/2] pinctrl: single: Add request() api
  2021-08-24 10:16 ` [PATCH v1 2/2] pinctrl: single: Add request() api Bharat Kumar Reddy Gooty
@ 2021-09-13  6:39   ` Rayagonda Kokatanur
  2021-09-30  4:09     ` Simon Glass
  2021-10-05 22:02   ` Tom Rini
  1 sibling, 1 reply; 9+ messages in thread
From: Rayagonda Kokatanur @ 2021-09-13  6:39 UTC (permalink / raw)
  To: Bharat Kumar Reddy Gooty
  Cc: Dario Binacchi, Simon Glass, Pratyush Yadav, Vignesh Raghavendra,
	U-Boot Mailing List

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

On Tue, Aug 24, 2021 at 3:46 PM Bharat Kumar Reddy Gooty
<bharat.gooty@broadcom.com> wrote:
>
> From: Bharat Gooty <bharat.gooty@broadcom.com>
>
> Add pinctrl_ops->request api to configure pctrl
> pad register in gpio mode.
>
> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
> ---
>  drivers/pinctrl/pinctrl-single.c | 34 ++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index 0f96cd5870..8fc07e3498 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -250,6 +250,39 @@ static int single_get_pin_muxing(struct udevice *dev, unsigned int pin,
>         return 0;
>  }
>
> +static int single_request(struct udevice *dev, int pin, int flags)
> +{
> +       struct single_priv *priv = dev_get_priv(dev);
> +       struct single_pdata *pdata = dev_get_plat(dev);
> +       struct single_gpiofunc_range *frange = NULL;
> +       struct list_head *pos, *tmp;
> +       phys_addr_t reg;
> +       int mux_bytes = 0;
> +       u32 data;
> +
> +       /* If function mask is null, needn't enable it. */
> +       if (!pdata->mask)
> +               return -ENOTSUPP;
> +
> +       list_for_each_safe(pos, tmp, &priv->gpiofuncs) {
> +               frange = list_entry(pos, struct single_gpiofunc_range, node);
> +               if ((pin >= frange->offset + frange->npins) ||
> +                   pin < frange->offset)
> +                       continue;
> +
> +               mux_bytes = pdata->width / BITS_PER_BYTE;
> +               reg = pdata->base + pin * mux_bytes;
> +
> +               data = single_read(dev, reg);
> +               data &= ~pdata->mask;
> +               data |= frange->gpiofunc;
> +               single_write(dev, data, reg);
> +               break;
> +       }
> +
> +       return 0;
> +}
> +
>  static struct single_func *single_allocate_function(struct udevice *dev,
>                                                     unsigned int group_pins)
>  {
> @@ -587,6 +620,7 @@ const struct pinctrl_ops single_pinctrl_ops = {
>         .get_pin_name = single_get_pin_name,
>         .set_state = single_set_state,
>         .get_pin_muxing = single_get_pin_muxing,
> +       .request = single_request,
>  };
>
>  static const struct udevice_id single_pinctrl_match[] = {
> --
> 2.17.1
>

Acked-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4230 bytes --]

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

* Re: [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt
  2021-08-24 10:16 ` [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt Bharat Kumar Reddy Gooty
@ 2021-09-13  6:40   ` Rayagonda Kokatanur
  2021-09-30  4:09   ` Simon Glass
  2021-10-05 22:02   ` Tom Rini
  2 siblings, 0 replies; 9+ messages in thread
From: Rayagonda Kokatanur @ 2021-09-13  6:40 UTC (permalink / raw)
  To: Bharat Kumar Reddy Gooty
  Cc: Dario Binacchi, Simon Glass, Pratyush Yadav, Vignesh Raghavendra,
	U-Boot Mailing List

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

On Tue, Aug 24, 2021 at 3:46 PM Bharat Kumar Reddy Gooty
<bharat.gooty@broadcom.com> wrote:
>
> From: Bharat Gooty <bharat.gooty@broadcom.com>
>
> Parse different gpio properties from dt as part of probe
> function. This detail is required to enable pinctrl pad
> later when gpio lines are requested.
>
> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
> ---
>  drivers/pinctrl/pinctrl-single.c | 52 ++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index cf9ad3670f..0f96cd5870 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -8,6 +8,7 @@
>  #include <dm.h>
>  #include <dm/device_compat.h>
>  #include <dm/devres.h>
> +#include <dm/of_access.h>
>  #include <dm/pinctrl.h>
>  #include <linux/libfdt.h>
>  #include <linux/list.h>
> @@ -44,11 +45,27 @@ struct single_func {
>         unsigned int *pins;
>  };
>
> +/**
> + * struct single_gpiofunc_range - pin ranges with same mux value of gpio fun
> + * @offset: offset base of pins
> + * @npins: number pins with the same mux value of gpio function
> + * @gpiofunc: mux value of gpio function
> + * @node: list node
> + */
> +struct single_gpiofunc_range {
> +       u32 offset;
> +       u32 npins;
> +       u32 gpiofunc;
> +       struct list_head node;
> +};
> +
>  /**
>   * struct single_priv - private data
>   * @bits_per_pin: number of bits per pin
>   * @npins: number of selectable pins
>   * @pin_name: temporary buffer to store the pin name
> + * @functions: list pin functions
> + * @gpiofuncs: list gpio functions
>   */
>  struct single_priv {
>  #if (IS_ENABLED(CONFIG_SANDBOX))
> @@ -58,6 +75,7 @@ struct single_priv {
>         unsigned int npins;
>         char pin_name[PINNAME_SIZE];
>         struct list_head functions;
> +       struct list_head gpiofuncs;
>  };
>
>  /**
> @@ -454,6 +472,36 @@ static int single_get_pins_count(struct udevice *dev)
>         return priv->npins;
>  }
>
> +static int single_add_gpio_func(struct udevice *dev)
> +{
> +       struct single_priv *priv = dev_get_priv(dev);
> +       const char *propname = "pinctrl-single,gpio-range";
> +       const char *cellname = "#pinctrl-single,gpio-range-cells";
> +       struct single_gpiofunc_range *range;
> +       struct ofnode_phandle_args gpiospec;
> +       int ret, i;
> +
> +       for (i = 0; ; i++) {
> +               ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), propname,
> +                                                    cellname, 0, i, &gpiospec);
> +               /* Do not treat it as error. Only treat it as end condition. */
> +               if (ret) {
> +                       ret = 0;
> +                       break;
> +               }
> +               range = devm_kzalloc(dev, sizeof(*range), GFP_KERNEL);
> +               if (!range) {
> +                       ret = -ENOMEM;
> +                       break;
> +               }
> +               range->offset = gpiospec.args[0];
> +               range->npins = gpiospec.args[1];
> +               range->gpiofunc = gpiospec.args[2];
> +               list_add_tail(&range->node, &priv->gpiofuncs);
> +       }
> +       return ret;
> +}
> +
>  static int single_probe(struct udevice *dev)
>  {
>         struct single_pdata *pdata = dev_get_plat(dev);
> @@ -461,6 +509,7 @@ static int single_probe(struct udevice *dev)
>         u32 size;
>
>         INIT_LIST_HEAD(&priv->functions);
> +       INIT_LIST_HEAD(&priv->gpiofuncs);
>
>         size = pdata->offset + pdata->width / BITS_PER_BYTE;
>         #if (CONFIG_IS_ENABLED(SANDBOX))
> @@ -483,6 +532,9 @@ static int single_probe(struct udevice *dev)
>                 priv->npins *= (pdata->width / priv->bits_per_pin);
>         }
>
> +       if (single_add_gpio_func(dev))
> +               dev_dbg(dev, "gpio functions are not added\n");
> +
>         dev_dbg(dev, "%d pins\n", priv->npins);
>         return 0;
>  }
> --
> 2.17.1
>

Acked-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4230 bytes --]

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

* Re: [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt
  2021-08-24 10:16 ` [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt Bharat Kumar Reddy Gooty
  2021-09-13  6:40   ` Rayagonda Kokatanur
@ 2021-09-30  4:09   ` Simon Glass
  2021-10-05 22:02   ` Tom Rini
  2 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2021-09-30  4:09 UTC (permalink / raw)
  To: Bharat Kumar Reddy Gooty
  Cc: Dario Binacchi, Pratyush Yadav, Rayagonda Kokatanur,
	Vignesh Raghavendra, U-Boot Mailing List

Hi Bharat,

On Tue, 24 Aug 2021 at 04:16, Bharat Kumar Reddy Gooty
<bharat.gooty@broadcom.com> wrote:
>
> From: Bharat Gooty <bharat.gooty@broadcom.com>
>
> Parse different gpio properties from dt as part of probe
> function. This detail is required to enable pinctrl pad
> later when gpio lines are requested.
>
> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
> ---
>  drivers/pinctrl/pinctrl-single.c | 52 ++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)

Looks OK but please update the pinctrl.c test. Also please see below.

>
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index cf9ad3670f..0f96cd5870 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -8,6 +8,7 @@
>  #include <dm.h>
>  #include <dm/device_compat.h>
>  #include <dm/devres.h>
> +#include <dm/of_access.h>
>  #include <dm/pinctrl.h>
>  #include <linux/libfdt.h>
>  #include <linux/list.h>
> @@ -44,11 +45,27 @@ struct single_func {
>         unsigned int *pins;
>  };
>
> +/**
> + * struct single_gpiofunc_range - pin ranges with same mux value of gpio fun

fun?

> + * @offset: offset base of pins
> + * @npins: number pins with the same mux value of gpio function
> + * @gpiofunc: mux value of gpio function
> + * @node: list node
> + */
> +struct single_gpiofunc_range {
> +       u32 offset;
> +       u32 npins;
> +       u32 gpiofunc;
> +       struct list_head node;
> +};
> +
>  /**
>   * struct single_priv - private data
>   * @bits_per_pin: number of bits per pin
>   * @npins: number of selectable pins
>   * @pin_name: temporary buffer to store the pin name
> + * @functions: list pin functions
> + * @gpiofuncs: list gpio functions
>   */
>  struct single_priv {
>  #if (IS_ENABLED(CONFIG_SANDBOX))
> @@ -58,6 +75,7 @@ struct single_priv {
>         unsigned int npins;
>         char pin_name[PINNAME_SIZE];
>         struct list_head functions;
> +       struct list_head gpiofuncs;
>  };
>
>  /**
> @@ -454,6 +472,36 @@ static int single_get_pins_count(struct udevice *dev)
>         return priv->npins;
>  }
>
> +static int single_add_gpio_func(struct udevice *dev)
> +{
> +       struct single_priv *priv = dev_get_priv(dev);
> +       const char *propname = "pinctrl-single,gpio-range";

Can you please add the binding for this to U-Boot?

> +       const char *cellname = "#pinctrl-single,gpio-range-cells";
> +       struct single_gpiofunc_range *range;
> +       struct ofnode_phandle_args gpiospec;
> +       int ret, i;
> +
> +       for (i = 0; ; i++) {
> +               ret = ofnode_parse_phandle_with_args(dev_ofnode(dev), propname,
> +                                                    cellname, 0, i, &gpiospec);
> +               /* Do not treat it as error. Only treat it as end condition. */
> +               if (ret) {
> +                       ret = 0;
> +                       break;
> +               }
> +               range = devm_kzalloc(dev, sizeof(*range), GFP_KERNEL);
> +               if (!range) {
> +                       ret = -ENOMEM;
> +                       break;
> +               }
> +               range->offset = gpiospec.args[0];
> +               range->npins = gpiospec.args[1];
> +               range->gpiofunc = gpiospec.args[2];
> +               list_add_tail(&range->node, &priv->gpiofuncs);
> +       }
> +       return ret;
> +}
> +
>  static int single_probe(struct udevice *dev)
>  {
>         struct single_pdata *pdata = dev_get_plat(dev);
> @@ -461,6 +509,7 @@ static int single_probe(struct udevice *dev)
>         u32 size;
>
>         INIT_LIST_HEAD(&priv->functions);
> +       INIT_LIST_HEAD(&priv->gpiofuncs);
>
>         size = pdata->offset + pdata->width / BITS_PER_BYTE;
>         #if (CONFIG_IS_ENABLED(SANDBOX))
> @@ -483,6 +532,9 @@ static int single_probe(struct udevice *dev)
>                 priv->npins *= (pdata->width / priv->bits_per_pin);
>         }
>
> +       if (single_add_gpio_func(dev))
> +               dev_dbg(dev, "gpio functions are not added\n");

return the error here

> +
>         dev_dbg(dev, "%d pins\n", priv->npins);
>         return 0;
>  }
> --
> 2.17.1
>
>
> --
> This electronic communication and the information and any files transmitted
> with it, or attached to it, are confidential and are intended solely for
> the use of the individual or entity to whom it is addressed and may contain
> information that is confidential, legally privileged, protected by privacy
> laws, or otherwise restricted from disclosure to anyone else. If you are
> not the intended recipient or the person responsible for delivering the
> e-mail to the intended recipient, you are hereby notified that any use,
> copying, distributing, dissemination, forwarding, printing, or copying of
> this e-mail is strictly prohibited. If you received this e-mail in error,
> please return the e-mail to the sender, delete it from your computer, and
> destroy any printed copy of it.

Plesew drop this

Regards,
Simon

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

* Re: [PATCH v1 2/2] pinctrl: single: Add request() api
  2021-09-13  6:39   ` Rayagonda Kokatanur
@ 2021-09-30  4:09     ` Simon Glass
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Glass @ 2021-09-30  4:09 UTC (permalink / raw)
  To: Rayagonda Kokatanur
  Cc: Bharat Kumar Reddy Gooty, Dario Binacchi, Pratyush Yadav,
	Vignesh Raghavendra, U-Boot Mailing List

On Mon, 13 Sept 2021 at 00:39, Rayagonda Kokatanur
<rayagonda.kokatanur@broadcom.com> wrote:
>
> On Tue, Aug 24, 2021 at 3:46 PM Bharat Kumar Reddy Gooty
> <bharat.gooty@broadcom.com> wrote:
> >
> > From: Bharat Gooty <bharat.gooty@broadcom.com>
> >
> > Add pinctrl_ops->request api to configure pctrl
> > pad register in gpio mode.
> >
> > Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> > Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
> > ---
> >  drivers/pinctrl/pinctrl-single.c | 34 ++++++++++++++++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> >

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt
  2021-08-24 10:16 ` [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt Bharat Kumar Reddy Gooty
  2021-09-13  6:40   ` Rayagonda Kokatanur
  2021-09-30  4:09   ` Simon Glass
@ 2021-10-05 22:02   ` Tom Rini
  2 siblings, 0 replies; 9+ messages in thread
From: Tom Rini @ 2021-10-05 22:02 UTC (permalink / raw)
  To: Bharat Kumar Reddy Gooty
  Cc: Dario Binacchi, Simon Glass, Pratyush Yadav, Rayagonda Kokatanur,
	Vignesh Raghavendra, u-boot

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

On Tue, Aug 24, 2021 at 03:46:31PM +0530, Bharat Kumar Reddy Gooty wrote:

> From: Bharat Gooty <bharat.gooty@broadcom.com>
> 
> Parse different gpio properties from dt as part of probe
> function. This detail is required to enable pinctrl pad
> later when gpio lines are requested.
> 
> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
> Acked-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH v1 2/2] pinctrl: single: Add request() api
  2021-08-24 10:16 ` [PATCH v1 2/2] pinctrl: single: Add request() api Bharat Kumar Reddy Gooty
  2021-09-13  6:39   ` Rayagonda Kokatanur
@ 2021-10-05 22:02   ` Tom Rini
  1 sibling, 0 replies; 9+ messages in thread
From: Tom Rini @ 2021-10-05 22:02 UTC (permalink / raw)
  To: Bharat Kumar Reddy Gooty
  Cc: Dario Binacchi, Simon Glass, Pratyush Yadav, Rayagonda Kokatanur,
	Vignesh Raghavendra, u-boot

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

On Tue, Aug 24, 2021 at 03:46:32PM +0530, Bharat Kumar Reddy Gooty wrote:

> From: Bharat Gooty <bharat.gooty@broadcom.com>
> 
> Add pinctrl_ops->request api to configure pctrl
> pad register in gpio mode.
> 
> Signed-off-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> Signed-off-by: Bharat Gooty <bharat.gooty@broadcom.com>
> Acked-by: Rayagonda Kokatanur <rayagonda.kokatanur@broadcom.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2021-10-05 22:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 10:16 [PATCH v1 0/2] pinctrl single: GPIO support Bharat Kumar Reddy Gooty
2021-08-24 10:16 ` [PATCH v1 1/2] pinctrl: single: Parse gpio details from dt Bharat Kumar Reddy Gooty
2021-09-13  6:40   ` Rayagonda Kokatanur
2021-09-30  4:09   ` Simon Glass
2021-10-05 22:02   ` Tom Rini
2021-08-24 10:16 ` [PATCH v1 2/2] pinctrl: single: Add request() api Bharat Kumar Reddy Gooty
2021-09-13  6:39   ` Rayagonda Kokatanur
2021-09-30  4:09     ` Simon Glass
2021-10-05 22:02   ` Tom Rini

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