All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrice Chotard <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/5] dm: gpio: Add get_alt_function ops
Date: Mon, 10 Sep 2018 18:11:06 +0200	[thread overview]
Message-ID: <1536595870-25111-2-git-send-email-patrice.chotard@st.com> (raw)
In-Reply-To: <1536595870-25111-1-git-send-email-patrice.chotard@st.com>

From: Patrick Delaunay <patrick.delaunay@st.com>

When a pin is not configured as a GPIO, it could
have several alternate function.

To be able to identify the alternate function,
add ops get_alt_function() to request the pin
alternate function index from the driver when pin is
not used as gpio.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

Changes in v3:
   - Rename get_alternate_function to get_alt_function
     in include/asm-generic/gpio.h

Changes in v2:
   - Rename get_function_number to get_alternate_function
     in include/asm-generic/gpio.h

 drivers/gpio/gpio-uclass.c |  6 ++++++
 include/asm-generic/gpio.h | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index da5e9ba6e524..27010a1ebf22 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -568,6 +568,12 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize)
 			 label ? label : "");
 	}
 
+	if (func == GPIOF_FUNC && ops->get_alt_function) {
+		ret = ops->get_alt_function(dev, offset);
+		if (ret >= 0)
+			snprintf(str + len, buffsize - len, ": %d", ret);
+	}
+
 	return 0;
 }
 
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d03602696f6d..dd3d77fafa98 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -266,6 +266,19 @@ struct dm_gpio_ops {
 	int (*get_function)(struct udevice *dev, unsigned offset);
 
 	/**
+	 * get_alt_function() Get the pins alternate function
+	 *
+	 * When a pin is not configured as GPIO, this pin can have several
+	 * alternate function. get_alt_function indicate the current
+	 * pin's alternate function index
+	 *
+	 * @dev:     Device to check
+	 * @offset:  GPIO offset within that device
+	 * @return current alternate function index
+	 */
+	int (*get_alt_function)(struct udevice *dev, unsigned int offset);
+
+	/**
 	 * xlate() - Translate phandle arguments into a GPIO description
 	 *
 	 * This function should set up the fields in desc according to the
-- 
1.9.1

  reply	other threads:[~2018-09-10 16:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 16:11 [U-Boot] [PATCH v3 0/5] Add get_alt_function ops Patrice Chotard
2018-09-10 16:11 ` Patrice Chotard [this message]
2018-09-10 16:11 ` [U-Boot] [PATCH v3 2/5] gpio: stm32f7: Add ops get_function Patrice Chotard
2018-09-10 16:11 ` [U-Boot] [PATCH v3 3/5] gpio: stm32f7: Add ops get_alt_function Patrice Chotard
2018-09-10 16:11 ` [U-Boot] [PATCH v3 4/5] gpio: sandbox: Rename GPIOF_(OUTPUT|HIGH|ODR) to SANDBOX_GPIO_(OUTPUT|HIGH|ODR) Patrice Chotard
2018-09-10 16:11 ` [U-Boot] [PATCH v3 5/5] test: dm: Add gpio get_alt_function ops test Patrice Chotard
2018-09-11  5:51 ` [U-Boot] [PATCH v3 0/5] Add get_alt_function ops Michal Simek
2018-09-11  7:31   ` Patrice CHOTARD
2018-09-11 10:24     ` Michal Simek
2018-09-11 11:12       ` Patrice CHOTARD
2018-09-11 12:17         ` Michal Simek
2018-09-11 13:31           ` [U-Boot] [Uboot-stm32] " Patrice CHOTARD
2018-09-11 13:45             ` Michal Simek
2018-09-11 17:03     ` [U-Boot] " Stephen Warren
2018-09-12  7:09       ` Patrice CHOTARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1536595870-25111-2-git-send-email-patrice.chotard@st.com \
    --to=patrice.chotard@st.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.