Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Jan 2020 21:19:27 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r356806 - in head: share/man/man9 sys/dev/fdt
Message-ID:  <202001162119.00GLJR56039362@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Thu Jan 16 21:19:27 2020
New Revision: 356806
URL: https://svnweb.freebsd.org/changeset/base/356806

Log:
  fdt_pinctrl: Add new methods for gpios
  
  Most of the gpio controller cannot configure or get the configuration
  of the pin muxing as it's usually handled in the pinctrl driver.
  But they can know what is the pinmuxing driver either because they are
  child of it or via the gpio-range property.
  Add some new methods to fdt_pinctrl that a pin controller can implement.
  Some methods are :
  fdt_pinctrl_is_gpio: Use to know if the pin in the gpio mode
  fdt_pinctrl_set_flags: Set the flags of the pin (pullup/pulldown etc ...)
  fdt_pinctrl_get_flags: Get the flags of the pin (pullup/pulldown etc ...)
  
  The defaults method returns EOPNOTSUPP.
  
  Reviewed by:	ian, bcr (manpages)
  MFC after:	1 month
  Differential Revision:	https://reviews.freebsd.org/D23093

Modified:
  head/share/man/man9/fdt_pinctrl.9
  head/sys/dev/fdt/fdt_pinctrl_if.m

Modified: head/share/man/man9/fdt_pinctrl.9
==============================================================================
--- head/share/man/man9/fdt_pinctrl.9	Thu Jan 16 20:57:29 2020	(r356805)
+++ head/share/man/man9/fdt_pinctrl.9	Thu Jan 16 21:19:27 2020	(r356806)
@@ -125,6 +125,36 @@ foo_configure_pins(device_t dev, phandle_t cfgxref)
 }
 
 static int
+foo_is_gpio(device_t dev, device_t gpiodev, bool *is_gpio)
+{
+	return (foo_is_pin_func_gpio(is_gpio));
+}
+
+static int
+foo_set_flags(device_t dev, device_t gpiodev, uint32_t pin, uint32_t flags)
+{
+	int rv;
+
+	rv = foo_is_pin_func_gpio(is_gpio);
+	if (rv != 0)
+		return (rv);
+	foo_set_flags(pin, flags);
+	return (0);
+}
+
+static int
+foo_get_flags(device_t dev, device_t gpiodev, uint32_t pin, uint32_t *flags)
+{
+	int rv;
+
+	rv = foo_is_pin_func_gpio(is_gpio);
+	if (rv != 0)
+		return (rv);
+	foo_get_flags(pin, flags);
+	return (0);
+}
+
+static int
 foo_attach(device_t dev)
 {
 	...
@@ -144,6 +174,9 @@ static device_method_t foo_methods[] = {
 
 	/* fdt_pinctrl interface */
 	DEVMETHOD(fdt_pinctrl_configure, foo_configure_pins),
+	DEVMETHOD(fdt_pinctrl_is_gpio, foo_is_gpio),
+	DEVMETHOD(fdt_pinctrl_set_flags, foo_set_flags),
+	DEVMETHOD(fdt_pinctrl_get_flags, foo_get_flags),
 
 	/* Terminate method list */
 	DEVMETHOD_END

Modified: head/sys/dev/fdt/fdt_pinctrl_if.m
==============================================================================
--- head/sys/dev/fdt/fdt_pinctrl_if.m	Thu Jan 16 20:57:29 2020	(r356805)
+++ head/sys/dev/fdt/fdt_pinctrl_if.m	Thu Jan 16 21:19:27 2020	(r356806)
@@ -36,6 +36,31 @@
 
 INTERFACE fdt_pinctrl;
 
+CODE {
+	static int
+	fdt_pinctrl_default_is_gpio(device_t pinctrl, device_t gpio, bool *is_gpio)
+	{
+
+		return (EOPNOTSUPP);
+	}
+
+	static int
+	fdt_pinctrl_default_set_flags(device_t pinctrl, device_t gpio, uint32_t pin,
+	    uint32_t flags)
+	{
+
+		return (EOPNOTSUPP);
+	}
+
+	static int
+	fdt_pinctrl_default_get_flags(device_t pinctrl, device_t gpio, uint32_t pin,
+	    uint32_t *flags)
+	{
+
+		return (EOPNOTSUPP);
+	}
+};
+
 # Needed for timestamping device probe/attach calls
 HEADER {
 	#include <sys/tslog.h>
@@ -57,3 +82,36 @@ METHOD int configure {
 	phandle_t	cfgxref;
 };
 
+
+#
+# Test if the pin is in gpio mode
+# Called from a gpio device
+#
+METHOD int is_gpio {
+	device_t pinctrl;
+	device_t gpio;
+	uint32_t pin;
+	bool *is_gpio;
+} DEFAULT fdt_pinctrl_default_is_gpio;
+
+#
+# Set the flags of a pin
+# Called from a gpio device
+#
+METHOD int set_flags {
+	device_t pinctrl;
+	device_t gpio;
+	uint32_t pin;
+	uint32_t flags;
+} DEFAULT fdt_pinctrl_default_set_flags;
+
+#
+# Get the flags of a pin
+# Called from a gpio device
+#
+METHOD int get_flags {
+	device_t pinctrl;
+	device_t gpio;
+	uint32_t pin;
+	uint32_t *flags;
+} DEFAULT fdt_pinctrl_default_get_flags;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001162119.00GLJR56039362>