All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/3] add support for cherryview gpio controller driver
@ 2021-08-31  5:07 Hongzhan Chen
  2021-08-31  5:07 ` [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation Hongzhan Chen
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Hongzhan Chen @ 2021-08-31  5:07 UTC (permalink / raw)
  To: xenomai

1. move out of OF config conditional compilation so that non-OF platform
  call same API to remove rtdm gpio chip device and remove _of for api
  name.
2. Introduce helper to find gpiochip as referring to pair of 
   rtdm_gpiochip_scan_of and rtdm_gpiochip_scan_array_of. 
3. Add Intel Cherryview pinctrl driver based on on 1 and 2.

I also did following tests with this patchset:
1. run /usr/lib/xenomai/testsuite/gpiobench -i 334 -i 335 -c INT33FF:02
   to validate patch 9afea5ff2d7ba97db96b22a005a9a7fcf5f2d892 when
   setting GPIO_RTIOC_TS
2. apply following patch, and rerun 1.

index f83d7689f..50afbd418 100644
--- a/testsuite/gpiobench/gpiobench.c
+++ b/testsuite/gpiobench/gpiobench.c
@@ -619,7 +619,7 @@ int main(int argc, char **argv)
                        goto out;
                }

-               ret = ioctl(ti.fd_dev_intr, GPIO_RTIOC_TS, &value);
+               ret = ioctl(ti.fd_dev_intr, GPIO_RTIOC_TS_MONO, &value);
                if (ret) {
                        printf("ioctl gpio port ts, failed\n");
                        goto out;

3. test result for inner related output:
   REALTIME clock:
	# Total: 000999999
	# Min Latencies: 00013
	# Avg Latencies: 16.879997
	# Max Latencies: 00043

   MONO clock:
	# Total: 000083988
	# Min Latencies: 00012
	# Avg Latencies: 2814377.000000
	# Max Latencies: 00041

Hardware env:
1. Rock PI X V1.4.
2. GPIO loopback connection between GPIO 334 and 335.

Hongzhan Chen (3):
  drivers/gpio: core: Move out of OF config conditional compilation
  drivers/gpio: core: Introduce helper to find gpiochip
  driver/gpio: Add Intel Cherryview pinctrl driver

 include/cobalt/kernel/rtdm/gpio.h     | 12 +++++--
 kernel/drivers/gpio/Kconfig           |  7 ++++
 kernel/drivers/gpio/Makefile          |  2 ++
 kernel/drivers/gpio/gpio-bcm2835.c    |  2 +-
 kernel/drivers/gpio/gpio-cherryview.c | 42 ++++++++++++++++++++++
 kernel/drivers/gpio/gpio-core.c       | 50 ++++++++++++++++++++++++---
 kernel/drivers/gpio/gpio-mxc.c        |  2 +-
 kernel/drivers/gpio/gpio-omap.c       |  2 +-
 kernel/drivers/gpio/gpio-sun8i-h3.c   |  2 +-
 kernel/drivers/gpio/gpio-xilinx.c     |  2 +-
 kernel/drivers/gpio/gpio-zynq7000.c   |  2 +-
 11 files changed, 112 insertions(+), 13 deletions(-)
 create mode 100644 kernel/drivers/gpio/gpio-cherryview.c

-- 
2.17.1



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

* [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation
  2021-08-31  5:07 [PATCH V2 0/3] add support for cherryview gpio controller driver Hongzhan Chen
@ 2021-08-31  5:07 ` Hongzhan Chen
  2021-08-31 13:05   ` Jan Kiszka
  2021-08-31  5:07 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Hongzhan Chen @ 2021-08-31  5:07 UTC (permalink / raw)
  To: xenomai

Rename interface name because it is undependent of OF platform and
non-OF platform would also call it to remove rtdm gpio chip device.

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
---
 include/cobalt/kernel/rtdm/gpio.h   | 5 ++---
 kernel/drivers/gpio/gpio-bcm2835.c  | 2 +-
 kernel/drivers/gpio/gpio-core.c     | 8 ++++----
 kernel/drivers/gpio/gpio-mxc.c      | 2 +-
 kernel/drivers/gpio/gpio-omap.c     | 2 +-
 kernel/drivers/gpio/gpio-sun8i-h3.c | 2 +-
 kernel/drivers/gpio/gpio-xilinx.c   | 2 +-
 kernel/drivers/gpio/gpio-zynq7000.c | 2 +-
 8 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
index 72cc3a035..29f26d6c6 100644
--- a/include/cobalt/kernel/rtdm/gpio.h
+++ b/include/cobalt/kernel/rtdm/gpio.h
@@ -70,9 +70,8 @@ int rtdm_gpiochip_scan_of(struct device_node *from,
 int rtdm_gpiochip_scan_array_of(struct device_node *from,
 				const char *compat[],
 				int nentries, int type);
-
-void rtdm_gpiochip_remove_of(int type);
-
 #endif
 
+void rtdm_gpiochip_remove(int type);
+
 #endif /* !_COBALT_RTDM_GPIO_H */
diff --git a/kernel/drivers/gpio/gpio-bcm2835.c b/kernel/drivers/gpio/gpio-bcm2835.c
index f30d6b591..a0c17f875 100644
--- a/kernel/drivers/gpio/gpio-bcm2835.c
+++ b/kernel/drivers/gpio/gpio-bcm2835.c
@@ -29,7 +29,7 @@ module_init(bcm2835_gpio_init);
 
 static void __exit bcm2835_gpio_exit(void)
 {
-	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_BCM2835);
+	rtdm_gpiochip_remove(RTDM_SUBCLASS_BCM2835);
 }
 module_exit(bcm2835_gpio_exit);
 
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 06a19b33a..ccda67bd1 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -626,7 +626,9 @@ int rtdm_gpiochip_scan_array_of(struct device_node *from,
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_array_of);
 
-void rtdm_gpiochip_remove_of(int type)
+#endif /* CONFIG_OF */
+
+void rtdm_gpiochip_remove(int type)
 {
 	struct rtdm_gpio_chip *rgc, *n;
 
@@ -643,6 +645,4 @@ void rtdm_gpiochip_remove_of(int type)
 
 	mutex_unlock(&chip_lock);
 }
-EXPORT_SYMBOL_GPL(rtdm_gpiochip_remove_of);
-
-#endif /* CONFIG_OF */
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_remove);
diff --git a/kernel/drivers/gpio/gpio-mxc.c b/kernel/drivers/gpio/gpio-mxc.c
index 7b28111f6..99162e5f8 100644
--- a/kernel/drivers/gpio/gpio-mxc.c
+++ b/kernel/drivers/gpio/gpio-mxc.c
@@ -35,7 +35,7 @@ module_init(mxc_gpio_init);
 
 static void __exit mxc_gpio_exit(void)
 {
-	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_MXC);
+	rtdm_gpiochip_remove(RTDM_SUBCLASS_MXC);
 }
 module_exit(mxc_gpio_exit);
 
diff --git a/kernel/drivers/gpio/gpio-omap.c b/kernel/drivers/gpio/gpio-omap.c
index 5f10278f3..848d84694 100644
--- a/kernel/drivers/gpio/gpio-omap.c
+++ b/kernel/drivers/gpio/gpio-omap.c
@@ -36,7 +36,7 @@ module_init(omap_gpio_init);
 
 static void __exit omap_gpio_exit(void)
 {
-	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_OMAP);
+	rtdm_gpiochip_remove(RTDM_SUBCLASS_OMAP);
 }
 module_exit(omap_gpio_exit);
 
diff --git a/kernel/drivers/gpio/gpio-sun8i-h3.c b/kernel/drivers/gpio/gpio-sun8i-h3.c
index 94303dd00..0dcfe8c00 100644
--- a/kernel/drivers/gpio/gpio-sun8i-h3.c
+++ b/kernel/drivers/gpio/gpio-sun8i-h3.c
@@ -36,7 +36,7 @@ module_init(h3_gpio_init);
 
 static void __exit h3_gpio_exit(void)
 {
-	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_H3);
+	rtdm_gpiochip_remove(RTDM_SUBCLASS_H3);
 }
 module_exit(h3_gpio_exit);
 
diff --git a/kernel/drivers/gpio/gpio-xilinx.c b/kernel/drivers/gpio/gpio-xilinx.c
index e982f5fa4..05bf870df 100644
--- a/kernel/drivers/gpio/gpio-xilinx.c
+++ b/kernel/drivers/gpio/gpio-xilinx.c
@@ -32,7 +32,7 @@ module_init(xilinx_gpio_init);
 
 static void __exit xilinx_gpio_exit(void)
 {
-	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_XILINX);
+	rtdm_gpiochip_remove(RTDM_SUBCLASS_XILINX);
 }
 module_exit(xilinx_gpio_exit);
 
diff --git a/kernel/drivers/gpio/gpio-zynq7000.c b/kernel/drivers/gpio/gpio-zynq7000.c
index 070db3fe4..5a6f2b83d 100644
--- a/kernel/drivers/gpio/gpio-zynq7000.c
+++ b/kernel/drivers/gpio/gpio-zynq7000.c
@@ -32,7 +32,7 @@ module_init(zynq7000_gpio_init);
 
 static void __exit zynq7000_gpio_exit(void)
 {
-	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_ZYNQ7000);
+	rtdm_gpiochip_remove(RTDM_SUBCLASS_ZYNQ7000);
 }
 module_exit(zynq7000_gpio_exit);
 
-- 
2.17.1



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

* [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
  2021-08-31  5:07 [PATCH V2 0/3] add support for cherryview gpio controller driver Hongzhan Chen
  2021-08-31  5:07 ` [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation Hongzhan Chen
@ 2021-08-31  5:07 ` Hongzhan Chen
  2021-08-31  6:47   ` Jan Kiszka
  2021-08-31  5:07 ` [PATCH 3/3] driver/gpio: Add Intel Cherryview pinctrl driver Hongzhan Chen
  2021-08-31  7:15 ` [PATCH V2 0/3] add support for cherryview gpio controller driver Jan Kiszka
  3 siblings, 1 reply; 13+ messages in thread
From: Hongzhan Chen @ 2021-08-31  5:07 UTC (permalink / raw)
  To: xenomai

To find gpiochip for non-OF platforms like x86

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
---
 include/cobalt/kernel/rtdm/gpio.h |  7 ++++++
 kernel/drivers/gpio/gpio-core.c   | 42 +++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
index 29f26d6c6..98279e242 100644
--- a/include/cobalt/kernel/rtdm/gpio.h
+++ b/include/cobalt/kernel/rtdm/gpio.h
@@ -62,6 +62,13 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
 			     unsigned int offset);
 
+int rtdm_gpiochip_find(struct device_node *from,
+			  const char *label, int type);
+
+int rtdm_gpiochip_array_find(struct device_node *from,
+				const char *compat[],
+				int nentries, int type);
+
 #ifdef CONFIG_OF
 
 int rtdm_gpiochip_scan_of(struct device_node *from,
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index ccda67bd1..ce80e8d73 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -528,6 +528,48 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
 
+int rtdm_gpiochip_find(struct device_node *from, const char *label,
+			  int type)
+{
+	struct rtdm_gpio_chip *rgc;
+	struct gpio_chip *chip;
+	int ret = -ENODEV;
+
+	if (!rtdm_available())
+		return -ENOSYS;
+
+	chip = find_chip_by_name(label);
+	if (chip == NULL)
+		return ret;
+
+	ret = 0;
+	rgc = rtdm_gpiochip_alloc(chip, type);
+	if (IS_ERR(rgc))
+		ret = PTR_ERR(rgc);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
+
+int rtdm_gpiochip_array_find(struct device_node *from,
+				const char *compat[],
+				int nentries, int type)
+{
+	int ret = -ENODEV, _ret, n;
+
+	for (n = 0; n < nentries; n++) {
+		_ret = rtdm_gpiochip_find(from, compat[n], type);
+		if (_ret) {
+			if (_ret != -ENODEV)
+				return _ret;
+		} else
+			ret = 0;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_array_find);
+
 #ifdef CONFIG_OF
 
 #include <linux/of_platform.h>
-- 
2.17.1



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

* [PATCH 3/3] driver/gpio: Add Intel Cherryview pinctrl driver
  2021-08-31  5:07 [PATCH V2 0/3] add support for cherryview gpio controller driver Hongzhan Chen
  2021-08-31  5:07 ` [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation Hongzhan Chen
  2021-08-31  5:07 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
@ 2021-08-31  5:07 ` Hongzhan Chen
  2021-08-31  6:51   ` Jan Kiszka
  2021-08-31  7:15 ` [PATCH V2 0/3] add support for cherryview gpio controller driver Jan Kiszka
  3 siblings, 1 reply; 13+ messages in thread
From: Hongzhan Chen @ 2021-08-31  5:07 UTC (permalink / raw)
  To: xenomai

Add support for Intel Cherryview pin controller driver

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
---
 kernel/drivers/gpio/Kconfig           |  7 +++++
 kernel/drivers/gpio/Makefile          |  2 ++
 kernel/drivers/gpio/gpio-cherryview.c | 42 +++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 kernel/drivers/gpio/gpio-cherryview.c

diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
index 44f41688c..c257444f0 100644
--- a/kernel/drivers/gpio/Kconfig
+++ b/kernel/drivers/gpio/Kconfig
@@ -57,6 +57,13 @@ config XENO_DRIVERS_GPIO_OMAP
 	Enables support for the GPIO controller available from
 	OMAP family SOC.
 
+config XENO_DRIVERS_GPIO_CHERRYVIEW
+	depends on PINCTRL_CHERRYVIEW
+	tristate "Support for Cherryview GPIOs"
+	help
+
+	Enables support for the Intel Cherryview GPIO controller
+
 config XENO_DRIVERS_GPIO_DEBUG
        bool "Enable GPIO core debugging features"
 
diff --git a/kernel/drivers/gpio/Makefile b/kernel/drivers/gpio/Makefile
index 7bcf59949..e534eab93 100644
--- a/kernel/drivers/gpio/Makefile
+++ b/kernel/drivers/gpio/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_XENO_DRIVERS_GPIO_SUN8I_H3) += xeno-gpio-sun8i-h3.o
 obj-$(CONFIG_XENO_DRIVERS_GPIO_ZYNQ7000) += xeno-gpio-zynq7000.o
 obj-$(CONFIG_XENO_DRIVERS_GPIO_XILINX) += xeno-gpio-xilinx.o
 obj-$(CONFIG_XENO_DRIVERS_GPIO_OMAP) += xeno-gpio-omap.o
+obj-$(CONFIG_XENO_DRIVERS_GPIO_CHERRYVIEW) += xeno-gpio-cherryview.o
 obj-$(CONFIG_XENO_DRIVERS_GPIO) += gpio-core.o
 
 xeno-gpio-bcm2835-y := gpio-bcm2835.o
@@ -14,3 +15,4 @@ xeno-gpio-sun8i-h3-y := gpio-sun8i-h3.o
 xeno-gpio-zynq7000-y := gpio-zynq7000.o
 xeno-gpio-xilinx-y := gpio-xilinx.o
 xeno-gpio-omap-y := gpio-omap.o
+xeno-gpio-cherryview-y := gpio-cherryview.o
diff --git a/kernel/drivers/gpio/gpio-cherryview.c b/kernel/drivers/gpio/gpio-cherryview.c
new file mode 100644
index 000000000..524199fe9
--- /dev/null
+++ b/kernel/drivers/gpio/gpio-cherryview.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * @note Copyright (C) 2021 Hongzhan Chen <hongzhan.chen@intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <linux/module.h>
+#include <rtdm/gpio.h>
+
+#define RTDM_SUBCLASS_CHERRYVIEW  7
+
+static const char *compat_array[] = {
+	"INT33FF:00",
+	"INT33FF:01",
+	"INT33FF:02",
+	"INT33FF:03",
+};
+
+static int __init cherryview_gpio_init(void)
+{
+	return rtdm_gpiochip_array_find(NULL, compat_array,
+					ARRAY_SIZE(compat_array),
+					RTDM_SUBCLASS_CHERRYVIEW);
+}
+module_init(cherryview_gpio_init);
+
+static void __exit cherryview_gpio_exit(void)
+{
+	rtdm_gpiochip_remove(RTDM_SUBCLASS_CHERRYVIEW);
+}
+module_exit(cherryview_gpio_exit);
+
+MODULE_LICENSE("GPL");
-- 
2.17.1



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

* Re: [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
  2021-08-31  5:07 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
@ 2021-08-31  6:47   ` Jan Kiszka
  2021-08-31  7:07     ` Chen, Hongzhan
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2021-08-31  6:47 UTC (permalink / raw)
  To: Hongzhan Chen, xenomai

On 31.08.21 07:07, Hongzhan Chen via Xenomai wrote:
> To find gpiochip for non-OF platforms like x86
> 
> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
> ---
>  include/cobalt/kernel/rtdm/gpio.h |  7 ++++++
>  kernel/drivers/gpio/gpio-core.c   | 42 +++++++++++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
> 
> diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
> index 29f26d6c6..98279e242 100644
> --- a/include/cobalt/kernel/rtdm/gpio.h
> +++ b/include/cobalt/kernel/rtdm/gpio.h
> @@ -62,6 +62,13 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
>  int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
>  			     unsigned int offset);
>  
> +int rtdm_gpiochip_find(struct device_node *from,
> +			  const char *label, int type);
> +
> +int rtdm_gpiochip_array_find(struct device_node *from,
> +				const char *compat[],
> +				int nentries, int type);
> +
>  #ifdef CONFIG_OF
>  
>  int rtdm_gpiochip_scan_of(struct device_node *from,
> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
> index ccda67bd1..ce80e8d73 100644
> --- a/kernel/drivers/gpio/gpio-core.c
> +++ b/kernel/drivers/gpio/gpio-core.c
> @@ -528,6 +528,48 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
>  }
>  EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
>  
> +int rtdm_gpiochip_find(struct device_node *from, const char *label,
> +			  int type)
> +{
> +	struct rtdm_gpio_chip *rgc;
> +	struct gpio_chip *chip;
> +	int ret = -ENODEV;
> +
> +	if (!rtdm_available())
> +		return -ENOSYS;
> +
> +	chip = find_chip_by_name(label);
> +	if (chip == NULL)
> +		return ret;
> +
> +	ret = 0;
> +	rgc = rtdm_gpiochip_alloc(chip, type);
> +	if (IS_ERR(rgc))
> +		ret = PTR_ERR(rgc);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
> +
> +int rtdm_gpiochip_array_find(struct device_node *from,
> +				const char *compat[],

Is "compat" the right argument name here? We are searching by name
(label), no?

Jan

> +				int nentries, int type)
> +{
> +	int ret = -ENODEV, _ret, n;
> +
> +	for (n = 0; n < nentries; n++) {
> +		_ret = rtdm_gpiochip_find(from, compat[n], type);
> +		if (_ret) {
> +			if (_ret != -ENODEV)
> +				return _ret;
> +		} else
> +			ret = 0;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_array_find);
> +
>  #ifdef CONFIG_OF
>  
>  #include <linux/of_platform.h>
> 

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

* Re: [PATCH 3/3] driver/gpio: Add Intel Cherryview pinctrl driver
  2021-08-31  5:07 ` [PATCH 3/3] driver/gpio: Add Intel Cherryview pinctrl driver Hongzhan Chen
@ 2021-08-31  6:51   ` Jan Kiszka
  0 siblings, 0 replies; 13+ messages in thread
From: Jan Kiszka @ 2021-08-31  6:51 UTC (permalink / raw)
  To: Hongzhan Chen, xenomai

On 31.08.21 07:07, Hongzhan Chen via Xenomai wrote:
> Add support for Intel Cherryview pin controller driver
> 
> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
> ---
>  kernel/drivers/gpio/Kconfig           |  7 +++++
>  kernel/drivers/gpio/Makefile          |  2 ++
>  kernel/drivers/gpio/gpio-cherryview.c | 42 +++++++++++++++++++++++++++
>  3 files changed, 51 insertions(+)
>  create mode 100644 kernel/drivers/gpio/gpio-cherryview.c
> 
> diff --git a/kernel/drivers/gpio/Kconfig b/kernel/drivers/gpio/Kconfig
> index 44f41688c..c257444f0 100644
> --- a/kernel/drivers/gpio/Kconfig
> +++ b/kernel/drivers/gpio/Kconfig
> @@ -57,6 +57,13 @@ config XENO_DRIVERS_GPIO_OMAP
>  	Enables support for the GPIO controller available from
>  	OMAP family SOC.
>  
> +config XENO_DRIVERS_GPIO_CHERRYVIEW
> +	depends on PINCTRL_CHERRYVIEW
> +	tristate "Support for Cherryview GPIOs"
> +	help
> +
> +	Enables support for the Intel Cherryview GPIO controller
> +
>  config XENO_DRIVERS_GPIO_DEBUG
>         bool "Enable GPIO core debugging features"
>  
> diff --git a/kernel/drivers/gpio/Makefile b/kernel/drivers/gpio/Makefile
> index 7bcf59949..e534eab93 100644
> --- a/kernel/drivers/gpio/Makefile
> +++ b/kernel/drivers/gpio/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_XENO_DRIVERS_GPIO_SUN8I_H3) += xeno-gpio-sun8i-h3.o
>  obj-$(CONFIG_XENO_DRIVERS_GPIO_ZYNQ7000) += xeno-gpio-zynq7000.o
>  obj-$(CONFIG_XENO_DRIVERS_GPIO_XILINX) += xeno-gpio-xilinx.o
>  obj-$(CONFIG_XENO_DRIVERS_GPIO_OMAP) += xeno-gpio-omap.o
> +obj-$(CONFIG_XENO_DRIVERS_GPIO_CHERRYVIEW) += xeno-gpio-cherryview.o
>  obj-$(CONFIG_XENO_DRIVERS_GPIO) += gpio-core.o
>  
>  xeno-gpio-bcm2835-y := gpio-bcm2835.o
> @@ -14,3 +15,4 @@ xeno-gpio-sun8i-h3-y := gpio-sun8i-h3.o
>  xeno-gpio-zynq7000-y := gpio-zynq7000.o
>  xeno-gpio-xilinx-y := gpio-xilinx.o
>  xeno-gpio-omap-y := gpio-omap.o
> +xeno-gpio-cherryview-y := gpio-cherryview.o
> diff --git a/kernel/drivers/gpio/gpio-cherryview.c b/kernel/drivers/gpio/gpio-cherryview.c
> new file mode 100644
> index 000000000..524199fe9
> --- /dev/null
> +++ b/kernel/drivers/gpio/gpio-cherryview.c
> @@ -0,0 +1,42 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * @note Copyright (C) 2021 Hongzhan Chen <hongzhan.chen@intel.com>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of the
> + * License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + */
> +#include <linux/module.h>
> +#include <rtdm/gpio.h>
> +
> +#define RTDM_SUBCLASS_CHERRYVIEW  7
> +
> +static const char *compat_array[] = {

Again naming: 'compat'? Or rather 'label'?

> +	"INT33FF:00",
> +	"INT33FF:01",
> +	"INT33FF:02",
> +	"INT33FF:03",
> +};
> +
> +static int __init cherryview_gpio_init(void)
> +{
> +	return rtdm_gpiochip_array_find(NULL, compat_array,
> +					ARRAY_SIZE(compat_array),
> +					RTDM_SUBCLASS_CHERRYVIEW);
> +}
> +module_init(cherryview_gpio_init);
> +
> +static void __exit cherryview_gpio_exit(void)
> +{
> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_CHERRYVIEW);
> +}
> +module_exit(cherryview_gpio_exit);
> +
> +MODULE_LICENSE("GPL");
> 

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

* RE: [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
  2021-08-31  6:47   ` Jan Kiszka
@ 2021-08-31  7:07     ` Chen, Hongzhan
  2021-08-31  7:14       ` Jan Kiszka
  0 siblings, 1 reply; 13+ messages in thread
From: Chen, Hongzhan @ 2021-08-31  7:07 UTC (permalink / raw)
  To: Jan Kiszka, xenomai



 -----Original Message-----
>From: Jan Kiszka <jan.kiszka@siemens.com> 
>Sent: Tuesday, August 31, 2021 2:48 PM
>To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>Subject: Re: [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
>
>On 31.08.21 07:07, Hongzhan Chen via Xenomai wrote:
>> To find gpiochip for non-OF platforms like x86
>> 
>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>> ---
>>  include/cobalt/kernel/rtdm/gpio.h |  7 ++++++
>>  kernel/drivers/gpio/gpio-core.c   | 42 +++++++++++++++++++++++++++++++
>>  2 files changed, 49 insertions(+)
>> 
>> diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
>> index 29f26d6c6..98279e242 100644
>> --- a/include/cobalt/kernel/rtdm/gpio.h
>> +++ b/include/cobalt/kernel/rtdm/gpio.h
>> @@ -62,6 +62,13 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
>>  int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
>>  			     unsigned int offset);
>>  
>> +int rtdm_gpiochip_find(struct device_node *from,
>> +			  const char *label, int type);
>> +
>> +int rtdm_gpiochip_array_find(struct device_node *from,
>> +				const char *compat[],
>> +				int nentries, int type);
>> +
>>  #ifdef CONFIG_OF
>>  
>>  int rtdm_gpiochip_scan_of(struct device_node *from,
>> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
>> index ccda67bd1..ce80e8d73 100644
>> --- a/kernel/drivers/gpio/gpio-core.c
>> +++ b/kernel/drivers/gpio/gpio-core.c
>> @@ -528,6 +528,48 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
>>  }
>>  EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
>>  
>> +int rtdm_gpiochip_find(struct device_node *from, const char *label,
>> +			  int type)
>> +{
>> +	struct rtdm_gpio_chip *rgc;
>> +	struct gpio_chip *chip;
>> +	int ret = -ENODEV;
>> +
>> +	if (!rtdm_available())
>> +		return -ENOSYS;
>> +
>> +	chip = find_chip_by_name(label);
>> +	if (chip == NULL)
>> +		return ret;
>> +
>> +	ret = 0;
>> +	rgc = rtdm_gpiochip_alloc(chip, type);
>> +	if (IS_ERR(rgc))
>> +		ret = PTR_ERR(rgc);
>> +
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
>> +
>> +int rtdm_gpiochip_array_find(struct device_node *from,
>> +				const char *compat[],
>
>Is "compat" the right argument name here? We are searching by name
>(label), no?

Yes , it is label. Let me modify it. So patch 1/3 is accepted ?

Regards

Hongzhan chen
>
>Jan
>
>> +				int nentries, int type)
>> +{
>> +	int ret = -ENODEV, _ret, n;
>> +
>> +	for (n = 0; n < nentries; n++) {
>> +		_ret = rtdm_gpiochip_find(from, compat[n], type);
>> +		if (_ret) {
>> +			if (_ret != -ENODEV)
>> +				return _ret;
>> +		} else
>> +			ret = 0;
>> +	}
>> +
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_array_find);
>> +
>>  #ifdef CONFIG_OF
>>  
>>  #include <linux/of_platform.h>
>> 
>
>-- 
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux
>
>

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

* Re: [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
  2021-08-31  7:07     ` Chen, Hongzhan
@ 2021-08-31  7:14       ` Jan Kiszka
  0 siblings, 0 replies; 13+ messages in thread
From: Jan Kiszka @ 2021-08-31  7:14 UTC (permalink / raw)
  To: Chen, Hongzhan, xenomai

On 31.08.21 09:07, Chen, Hongzhan wrote:
> 
> 
>  -----Original Message-----
>> From: Jan Kiszka <jan.kiszka@siemens.com> 
>> Sent: Tuesday, August 31, 2021 2:48 PM
>> To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org
>> Subject: Re: [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
>>
>> On 31.08.21 07:07, Hongzhan Chen via Xenomai wrote:
>>> To find gpiochip for non-OF platforms like x86
>>>
>>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
>>> ---
>>>  include/cobalt/kernel/rtdm/gpio.h |  7 ++++++
>>>  kernel/drivers/gpio/gpio-core.c   | 42 +++++++++++++++++++++++++++++++
>>>  2 files changed, 49 insertions(+)
>>>
>>> diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
>>> index 29f26d6c6..98279e242 100644
>>> --- a/include/cobalt/kernel/rtdm/gpio.h
>>> +++ b/include/cobalt/kernel/rtdm/gpio.h
>>> @@ -62,6 +62,13 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
>>>  int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
>>>  			     unsigned int offset);
>>>  
>>> +int rtdm_gpiochip_find(struct device_node *from,
>>> +			  const char *label, int type);
>>> +
>>> +int rtdm_gpiochip_array_find(struct device_node *from,
>>> +				const char *compat[],
>>> +				int nentries, int type);
>>> +
>>>  #ifdef CONFIG_OF
>>>  
>>>  int rtdm_gpiochip_scan_of(struct device_node *from,
>>> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
>>> index ccda67bd1..ce80e8d73 100644
>>> --- a/kernel/drivers/gpio/gpio-core.c
>>> +++ b/kernel/drivers/gpio/gpio-core.c
>>> @@ -528,6 +528,48 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
>>>  }
>>>  EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
>>>  
>>> +int rtdm_gpiochip_find(struct device_node *from, const char *label,
>>> +			  int type)
>>> +{
>>> +	struct rtdm_gpio_chip *rgc;
>>> +	struct gpio_chip *chip;
>>> +	int ret = -ENODEV;
>>> +
>>> +	if (!rtdm_available())
>>> +		return -ENOSYS;
>>> +
>>> +	chip = find_chip_by_name(label);
>>> +	if (chip == NULL)
>>> +		return ret;
>>> +
>>> +	ret = 0;
>>> +	rgc = rtdm_gpiochip_alloc(chip, type);
>>> +	if (IS_ERR(rgc))
>>> +		ret = PTR_ERR(rgc);
>>> +
>>> +	return ret;
>>> +}
>>> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
>>> +
>>> +int rtdm_gpiochip_array_find(struct device_node *from,
>>> +				const char *compat[],
>>
>> Is "compat" the right argument name here? We are searching by name
>> (label), no?
> 
> Yes , it is label. Let me modify it. So patch 1/3 is accepted ?
> 

Already done that locally while merging. Also just renamed compat_array
to label_array in patch 3. Let me push this then.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

* Re: [PATCH V2 0/3] add support for cherryview gpio controller driver
  2021-08-31  5:07 [PATCH V2 0/3] add support for cherryview gpio controller driver Hongzhan Chen
                   ` (2 preceding siblings ...)
  2021-08-31  5:07 ` [PATCH 3/3] driver/gpio: Add Intel Cherryview pinctrl driver Hongzhan Chen
@ 2021-08-31  7:15 ` Jan Kiszka
  3 siblings, 0 replies; 13+ messages in thread
From: Jan Kiszka @ 2021-08-31  7:15 UTC (permalink / raw)
  To: Hongzhan Chen, xenomai

On 31.08.21 07:07, Hongzhan Chen via Xenomai wrote:
> 1. move out of OF config conditional compilation so that non-OF platform
>   call same API to remove rtdm gpio chip device and remove _of for api
>   name.
> 2. Introduce helper to find gpiochip as referring to pair of 
>    rtdm_gpiochip_scan_of and rtdm_gpiochip_scan_array_of. 
> 3. Add Intel Cherryview pinctrl driver based on on 1 and 2.
> 
> I also did following tests with this patchset:
> 1. run /usr/lib/xenomai/testsuite/gpiobench -i 334 -i 335 -c INT33FF:02
>    to validate patch 9afea5ff2d7ba97db96b22a005a9a7fcf5f2d892 when
>    setting GPIO_RTIOC_TS
> 2. apply following patch, and rerun 1.
> 
> index f83d7689f..50afbd418 100644
> --- a/testsuite/gpiobench/gpiobench.c
> +++ b/testsuite/gpiobench/gpiobench.c
> @@ -619,7 +619,7 @@ int main(int argc, char **argv)
>                         goto out;
>                 }
> 
> -               ret = ioctl(ti.fd_dev_intr, GPIO_RTIOC_TS, &value);
> +               ret = ioctl(ti.fd_dev_intr, GPIO_RTIOC_TS_MONO, &value);
>                 if (ret) {
>                         printf("ioctl gpio port ts, failed\n");
>                         goto out;
> 
> 3. test result for inner related output:
>    REALTIME clock:
> 	# Total: 000999999
> 	# Min Latencies: 00013
> 	# Avg Latencies: 16.879997
> 	# Max Latencies: 00043
> 
>    MONO clock:
> 	# Total: 000083988
> 	# Min Latencies: 00012
> 	# Avg Latencies: 2814377.000000
> 	# Max Latencies: 00041
> 
> Hardware env:
> 1. Rock PI X V1.4.
> 2. GPIO loopback connection between GPIO 334 and 335.
> 
> Hongzhan Chen (3):
>   drivers/gpio: core: Move out of OF config conditional compilation
>   drivers/gpio: core: Introduce helper to find gpiochip
>   driver/gpio: Add Intel Cherryview pinctrl driver
> 
>  include/cobalt/kernel/rtdm/gpio.h     | 12 +++++--
>  kernel/drivers/gpio/Kconfig           |  7 ++++
>  kernel/drivers/gpio/Makefile          |  2 ++
>  kernel/drivers/gpio/gpio-bcm2835.c    |  2 +-
>  kernel/drivers/gpio/gpio-cherryview.c | 42 ++++++++++++++++++++++
>  kernel/drivers/gpio/gpio-core.c       | 50 ++++++++++++++++++++++++---
>  kernel/drivers/gpio/gpio-mxc.c        |  2 +-
>  kernel/drivers/gpio/gpio-omap.c       |  2 +-
>  kernel/drivers/gpio/gpio-sun8i-h3.c   |  2 +-
>  kernel/drivers/gpio/gpio-xilinx.c     |  2 +-
>  kernel/drivers/gpio/gpio-zynq7000.c   |  2 +-
>  11 files changed, 112 insertions(+), 13 deletions(-)
>  create mode 100644 kernel/drivers/gpio/gpio-cherryview.c
> 

All three merged, with slight modifications as discussed.

Thanks,
Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

* Re: [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation
  2021-08-31  5:07 ` [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation Hongzhan Chen
@ 2021-08-31 13:05   ` Jan Kiszka
  2021-09-01  1:16     ` Chen, Hongzhan
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2021-08-31 13:05 UTC (permalink / raw)
  To: Hongzhan Chen, xenomai

On 31.08.21 07:07, Hongzhan Chen via Xenomai wrote:
> Rename interface name because it is undependent of OF platform and
> non-OF platform would also call it to remove rtdm gpio chip device.
> 
> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
> ---
>  include/cobalt/kernel/rtdm/gpio.h   | 5 ++---
>  kernel/drivers/gpio/gpio-bcm2835.c  | 2 +-
>  kernel/drivers/gpio/gpio-core.c     | 8 ++++----
>  kernel/drivers/gpio/gpio-mxc.c      | 2 +-
>  kernel/drivers/gpio/gpio-omap.c     | 2 +-
>  kernel/drivers/gpio/gpio-sun8i-h3.c | 2 +-
>  kernel/drivers/gpio/gpio-xilinx.c   | 2 +-
>  kernel/drivers/gpio/gpio-zynq7000.c | 2 +-
>  8 files changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
> index 72cc3a035..29f26d6c6 100644
> --- a/include/cobalt/kernel/rtdm/gpio.h
> +++ b/include/cobalt/kernel/rtdm/gpio.h
> @@ -70,9 +70,8 @@ int rtdm_gpiochip_scan_of(struct device_node *from,
>  int rtdm_gpiochip_scan_array_of(struct device_node *from,
>  				const char *compat[],
>  				int nentries, int type);
> -
> -void rtdm_gpiochip_remove_of(int type);
> -
>  #endif
>  
> +void rtdm_gpiochip_remove(int type);
> +
>  #endif /* !_COBALT_RTDM_GPIO_H */
> diff --git a/kernel/drivers/gpio/gpio-bcm2835.c b/kernel/drivers/gpio/gpio-bcm2835.c
> index f30d6b591..a0c17f875 100644
> --- a/kernel/drivers/gpio/gpio-bcm2835.c
> +++ b/kernel/drivers/gpio/gpio-bcm2835.c
> @@ -29,7 +29,7 @@ module_init(bcm2835_gpio_init);
>  
>  static void __exit bcm2835_gpio_exit(void)
>  {
> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_BCM2835);
> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_BCM2835);
>  }
>  module_exit(bcm2835_gpio_exit);
>  
> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
> index 06a19b33a..ccda67bd1 100644
> --- a/kernel/drivers/gpio/gpio-core.c
> +++ b/kernel/drivers/gpio/gpio-core.c
> @@ -626,7 +626,9 @@ int rtdm_gpiochip_scan_array_of(struct device_node *from,
>  }
>  EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_array_of);
>  
> -void rtdm_gpiochip_remove_of(int type)
> +#endif /* CONFIG_OF */
> +
> +void rtdm_gpiochip_remove(int type)
>  {
>  	struct rtdm_gpio_chip *rgc, *n;
>  
> @@ -643,6 +645,4 @@ void rtdm_gpiochip_remove_of(int type)
>  
>  	mutex_unlock(&chip_lock);
>  }
> -EXPORT_SYMBOL_GPL(rtdm_gpiochip_remove_of);
> -
> -#endif /* CONFIG_OF */
> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_remove);
> diff --git a/kernel/drivers/gpio/gpio-mxc.c b/kernel/drivers/gpio/gpio-mxc.c
> index 7b28111f6..99162e5f8 100644
> --- a/kernel/drivers/gpio/gpio-mxc.c
> +++ b/kernel/drivers/gpio/gpio-mxc.c
> @@ -35,7 +35,7 @@ module_init(mxc_gpio_init);
>  
>  static void __exit mxc_gpio_exit(void)
>  {
> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_MXC);
> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_MXC);
>  }
>  module_exit(mxc_gpio_exit);
>  
> diff --git a/kernel/drivers/gpio/gpio-omap.c b/kernel/drivers/gpio/gpio-omap.c
> index 5f10278f3..848d84694 100644
> --- a/kernel/drivers/gpio/gpio-omap.c
> +++ b/kernel/drivers/gpio/gpio-omap.c
> @@ -36,7 +36,7 @@ module_init(omap_gpio_init);
>  
>  static void __exit omap_gpio_exit(void)
>  {
> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_OMAP);
> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_OMAP);
>  }
>  module_exit(omap_gpio_exit);
>  
> diff --git a/kernel/drivers/gpio/gpio-sun8i-h3.c b/kernel/drivers/gpio/gpio-sun8i-h3.c
> index 94303dd00..0dcfe8c00 100644
> --- a/kernel/drivers/gpio/gpio-sun8i-h3.c
> +++ b/kernel/drivers/gpio/gpio-sun8i-h3.c
> @@ -36,7 +36,7 @@ module_init(h3_gpio_init);
>  
>  static void __exit h3_gpio_exit(void)
>  {
> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_H3);
> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_H3);
>  }
>  module_exit(h3_gpio_exit);
>  
> diff --git a/kernel/drivers/gpio/gpio-xilinx.c b/kernel/drivers/gpio/gpio-xilinx.c
> index e982f5fa4..05bf870df 100644
> --- a/kernel/drivers/gpio/gpio-xilinx.c
> +++ b/kernel/drivers/gpio/gpio-xilinx.c
> @@ -32,7 +32,7 @@ module_init(xilinx_gpio_init);
>  
>  static void __exit xilinx_gpio_exit(void)
>  {
> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_XILINX);
> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_XILINX);
>  }
>  module_exit(xilinx_gpio_exit);
>  
> diff --git a/kernel/drivers/gpio/gpio-zynq7000.c b/kernel/drivers/gpio/gpio-zynq7000.c
> index 070db3fe4..5a6f2b83d 100644
> --- a/kernel/drivers/gpio/gpio-zynq7000.c
> +++ b/kernel/drivers/gpio/gpio-zynq7000.c
> @@ -32,7 +32,7 @@ module_init(zynq7000_gpio_init);
>  
>  static void __exit zynq7000_gpio_exit(void)
>  {
> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_ZYNQ7000);
> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_ZYNQ7000);
>  }
>  module_exit(zynq7000_gpio_exit);
>  
> 

Oops, we already had a rtdm_gpiochip_remove. Renaming this one to
rtdm_gpiochip_remove_by_type".

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

* RE: [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation
  2021-08-31 13:05   ` Jan Kiszka
@ 2021-09-01  1:16     ` Chen, Hongzhan
  0 siblings, 0 replies; 13+ messages in thread
From: Chen, Hongzhan @ 2021-09-01  1:16 UTC (permalink / raw)
  To: Jan Kiszka, xenomai

                                                                                          
                                                                                          
>-----Original Message-----                                                                
>From: Jan Kiszka <jan.kiszka@siemens.com>                                                 
>Sent: Tuesday, August 31, 2021 9:06 PM                                                    
>To: Chen, Hongzhan <hongzhan.chen@intel.com>; xenomai@xenomai.org                         
>Subject: Re: [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation
>                                                                                          
>On 31.08.21 07:07, Hongzhan Chen via Xenomai wrote:                                       
>> Rename interface name because it is undependent of OF platform and                      
>> non-OF platform would also call it to remove rtdm gpio chip device.                     
>>                                                                                         
>> Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>                                  
>> ---                                                                                     
>>  include/cobalt/kernel/rtdm/gpio.h   | 5 ++---                                          
>>  kernel/drivers/gpio/gpio-bcm2835.c  | 2 +-                                             
>>  kernel/drivers/gpio/gpio-core.c     | 8 ++++----                                       
>>  kernel/drivers/gpio/gpio-mxc.c      | 2 +-                                             
>>  kernel/drivers/gpio/gpio-omap.c     | 2 +-                                             
>>  kernel/drivers/gpio/gpio-sun8i-h3.c | 2 +-                                             
>>  kernel/drivers/gpio/gpio-xilinx.c   | 2 +-                                             
>>  kernel/drivers/gpio/gpio-zynq7000.c | 2 +-                                             
>>  8 files changed, 12 insertions(+), 13 deletions(-)                                     
>>                                                                                         
>> diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h      
>> index 72cc3a035..29f26d6c6 100644                                                       
>> --- a/include/cobalt/kernel/rtdm/gpio.h                                                 
>> +++ b/include/cobalt/kernel/rtdm/gpio.h                                                 
>> @@ -70,9 +70,8 @@ int rtdm_gpiochip_scan_of(struct device_node *from,                   
>>  int rtdm_gpiochip_scan_array_of(struct device_node *from,                              
>>  				const char *compat[],                                                           
>>  				int nentries, int type);                                                        
>> -                                                                                       
>> -void rtdm_gpiochip_remove_of(int type);                                                
>> -                                                                                       
>>  #endif                                                                                 
>>                                                                                         
>> +void rtdm_gpiochip_remove(int type);                                                   
>> +                                                                                       
>>  #endif /* !_COBALT_RTDM_GPIO_H */                                                      
>> diff --git a/kernel/drivers/gpio/gpio-bcm2835.c b/kernel/drivers/gpio/gpio-bcm2835.c    
>> index f30d6b591..a0c17f875 100644                                                       
>> --- a/kernel/drivers/gpio/gpio-bcm2835.c                                                
>> +++ b/kernel/drivers/gpio/gpio-bcm2835.c                                                
>> @@ -29,7 +29,7 @@ module_init(bcm2835_gpio_init);                                       
>>                                                                                         
>>  static void __exit bcm2835_gpio_exit(void)                                             
>>  {                                                                                      
>> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_BCM2835);                                       
>> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_BCM2835);                                          
>>  }                                                                                      
>>  module_exit(bcm2835_gpio_exit);                                                        
>>                                                                                         
>> diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c          
>> index 06a19b33a..ccda67bd1 100644                                                       
>> --- a/kernel/drivers/gpio/gpio-core.c                                                   
>> +++ b/kernel/drivers/gpio/gpio-core.c                                                   
>> @@ -626,7 +626,9 @@ int rtdm_gpiochip_scan_array_of(struct device_node *from,           
>>  }                                                                                      
>>  EXPORT_SYMBOL_GPL(rtdm_gpiochip_scan_array_of);                                        
>>                                                                                         
>> -void rtdm_gpiochip_remove_of(int type)                                                 
>> +#endif /* CONFIG_OF */                                                                 
>> +                                                                                       
>> +void rtdm_gpiochip_remove(int type)                                                    
>>  {                                                                                      
>>  	struct rtdm_gpio_chip *rgc, *n;                                                       
>>                                                                                         
>> @@ -643,6 +645,4 @@ void rtdm_gpiochip_remove_of(int type)                              
>>                                                                                         
>>  	mutex_unlock(&chip_lock);                                                             
>>  }                                                                                      
>> -EXPORT_SYMBOL_GPL(rtdm_gpiochip_remove_of);                                            
>> -                                                                                       
>> -#endif /* CONFIG_OF */                                                                 
>> +EXPORT_SYMBOL_GPL(rtdm_gpiochip_remove);                                               
>> diff --git a/kernel/drivers/gpio/gpio-mxc.c b/kernel/drivers/gpio/gpio-mxc.c            
>> index 7b28111f6..99162e5f8 100644                                                       
>> --- a/kernel/drivers/gpio/gpio-mxc.c                                                    
>> +++ b/kernel/drivers/gpio/gpio-mxc.c                                                    
>> @@ -35,7 +35,7 @@ module_init(mxc_gpio_init);                                           
>>                                                                                         
>>  static void __exit mxc_gpio_exit(void)                                                 
>>  {                                                                                      
>> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_MXC);                                           
>> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_MXC);                                              
>>  }                                                                                      
>>  module_exit(mxc_gpio_exit);                                                            
>>                                                                                         
>> diff --git a/kernel/drivers/gpio/gpio-omap.c b/kernel/drivers/gpio/gpio-omap.c          
>> index 5f10278f3..848d84694 100644                                                       
>> --- a/kernel/drivers/gpio/gpio-omap.c                                                   
>> +++ b/kernel/drivers/gpio/gpio-omap.c                                                   
>> @@ -36,7 +36,7 @@ module_init(omap_gpio_init);                                          
>>                                                                                         
>>  static void __exit omap_gpio_exit(void)                                                
>>  {                                                                                      
>> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_OMAP);                                          
>> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_OMAP);                                             
>>  }                                                                                      
>>  module_exit(omap_gpio_exit);                                                           
>>                                                                                         
>> diff --git a/kernel/drivers/gpio/gpio-sun8i-h3.c b/kernel/drivers/gpio/gpio-sun8i-h3.c  
>> index 94303dd00..0dcfe8c00 100644                                                       
>> --- a/kernel/drivers/gpio/gpio-sun8i-h3.c                                               
>> +++ b/kernel/drivers/gpio/gpio-sun8i-h3.c                                               
>> @@ -36,7 +36,7 @@ module_init(h3_gpio_init);                                            
>>                                                                                         
>>  static void __exit h3_gpio_exit(void)                                                  
>>  {                                                                                      
>> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_H3);                                            
>> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_H3);                                               
>>  }                                                                                      
>>  module_exit(h3_gpio_exit);                                                             
>>                                                                                         
>> diff --git a/kernel/drivers/gpio/gpio-xilinx.c b/kernel/drivers/gpio/gpio-xilinx.c      
>> index e982f5fa4..05bf870df 100644                                                       
>> --- a/kernel/drivers/gpio/gpio-xilinx.c                                                 
>> +++ b/kernel/drivers/gpio/gpio-xilinx.c                                                 
>> @@ -32,7 +32,7 @@ module_init(xilinx_gpio_init);                                        
>>                                                                                         
>>  static void __exit xilinx_gpio_exit(void)                                              
>>  {                                                                                      
>> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_XILINX);                                        
>> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_XILINX);                                           
>>  }                                                                                      
>>  module_exit(xilinx_gpio_exit);                                                         
>>                                                                                         
>> diff --git a/kernel/drivers/gpio/gpio-zynq7000.c b/kernel/drivers/gpio/gpio-zynq7000.c  
>> index 070db3fe4..5a6f2b83d 100644                                                       
>> --- a/kernel/drivers/gpio/gpio-zynq7000.c                                               
>> +++ b/kernel/drivers/gpio/gpio-zynq7000.c                                               
>> @@ -32,7 +32,7 @@ module_init(zynq7000_gpio_init);                                      
>>                                                                                         
>>  static void __exit zynq7000_gpio_exit(void)                                            
>>  {                                                                                      
>> -	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_ZYNQ7000);                                      
>> +	rtdm_gpiochip_remove(RTDM_SUBCLASS_ZYNQ7000);                                         
>>  }                                                                                      
>>  module_exit(zynq7000_gpio_exit);                                                       
>>                                                                                         
>>                                                                                         
>                                                                                          
>Oops, we already had a rtdm_gpiochip_remove. Renaming this one to                         
>rtdm_gpiochip_remove_by_type".          

Thanks for your finding it out and correcting it. I just noticed it. 
                                                  
>                                                                                          
>Jan                                                                                       
>                                                                                          
>--                                                                                        
>Siemens AG, T RDA IOT                                                                     
>Corporate Competence Center Embedded Linux                                                

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

* [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip
  2021-08-30  6:45 [PATCH " Hongzhan Chen
@ 2021-08-30  6:45 ` Hongzhan Chen
  0 siblings, 0 replies; 13+ messages in thread
From: Hongzhan Chen @ 2021-08-30  6:45 UTC (permalink / raw)
  To: xenomai

To find gpiochip for non-OF platforms like x86

Signed-off-by: Hongzhan Chen <hongzhan.chen@intel.com>
---
 include/cobalt/kernel/rtdm/gpio.h |  7 ++++++
 kernel/drivers/gpio/gpio-core.c   | 42 +++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
index c307b1572..07093e0be 100644
--- a/include/cobalt/kernel/rtdm/gpio.h
+++ b/include/cobalt/kernel/rtdm/gpio.h
@@ -62,6 +62,13 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
 			     unsigned int offset);
 
+int rtdm_gpiochip_find(struct device_node *from,
+			  const char *label, int type);
+
+int rtdm_gpiochip_array_find(struct device_node *from,
+				const char *compat[],
+				int nentries, int type);
+
 #ifdef CONFIG_OF
 
 int rtdm_gpiochip_scan_of(struct device_node *from,
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index ddda62b24..6bcf04ea3 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -528,6 +528,48 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
 
+int rtdm_gpiochip_find(struct device_node *from, const char *label,
+			  int type)
+{
+	struct rtdm_gpio_chip *rgc;
+	struct gpio_chip *chip;
+	int ret = -ENODEV;
+
+	if (!rtdm_available())
+		return -ENOSYS;
+
+	chip = find_chip_by_name(label);
+	if (chip == NULL)
+		return ret;
+
+	ret = 0;
+	rgc = rtdm_gpiochip_alloc(chip, type);
+	if (IS_ERR(rgc))
+		ret = PTR_ERR(rgc);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
+
+int rtdm_gpiochip_array_find(struct device_node *from,
+				const char *compat[],
+				int nentries, int type)
+{
+	int ret = -ENODEV, _ret, n;
+
+	for (n = 0; n < nentries; n++) {
+		_ret = rtdm_gpiochip_find(from, compat[n], type);
+		if (_ret) {
+			if (_ret != -ENODEV)
+				return _ret;
+		} else
+			ret = 0;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_array_find);
+
 #ifdef CONFIG_OF
 
 #include <linux/of_platform.h>
-- 
2.17.1



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

* [PATCH 2/3] drivers/gpio: core: introduce helper to find gpiochip
  2021-04-14  2:16 [PATCH 1/3] rtdm/testing: latmus: introduce latmus driver hongzha1
@ 2021-04-14  2:16 ` hongzha1
  0 siblings, 0 replies; 13+ messages in thread
From: hongzha1 @ 2021-04-14  2:16 UTC (permalink / raw)
  To: xenomai

To find gpiochip for non-OF platforms like x86

Signed-off-by: hongzha1 <hongzhan.chen@intel.com>

diff --git a/include/cobalt/kernel/rtdm/gpio.h b/include/cobalt/kernel/rtdm/gpio.h
index 00055ec0a..c5fb20f25 100644
--- a/include/cobalt/kernel/rtdm/gpio.h
+++ b/include/cobalt/kernel/rtdm/gpio.h
@@ -61,6 +61,9 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 int rtdm_gpiochip_post_event(struct rtdm_gpio_chip *rgc,
 			     unsigned int offset);
 
+int rtdm_gpiochip_find(struct device_node *from,
+			  const char *label, int type);
+
 #ifdef CONFIG_OF
 
 int rtdm_gpiochip_scan_of(struct device_node *from,
diff --git a/kernel/drivers/gpio/gpio-core.c b/kernel/drivers/gpio/gpio-core.c
index 600ef9789..b3d801fa1 100644
--- a/kernel/drivers/gpio/gpio-core.c
+++ b/kernel/drivers/gpio/gpio-core.c
@@ -520,6 +520,29 @@ int rtdm_gpiochip_add_by_name(struct rtdm_gpio_chip *rgc,
 }
 EXPORT_SYMBOL_GPL(rtdm_gpiochip_add_by_name);
 
+int rtdm_gpiochip_find(struct device_node *from, const char *label,
+			  int type)
+{
+	struct rtdm_gpio_chip *rgc;
+	struct gpio_chip *chip;
+	int ret = -ENODEV;
+
+	if (!rtdm_available())
+		return -ENOSYS;
+
+	chip = find_chip_by_name(label);
+	if (chip == NULL)
+		return ret;
+
+	ret = 0;
+	rgc = rtdm_gpiochip_alloc(chip, type);
+	if (IS_ERR(rgc))
+		ret = PTR_ERR(rgc);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(rtdm_gpiochip_find);
+
 #ifdef CONFIG_OF
 
 #include <linux/of_platform.h>
-- 
2.17.1



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

end of thread, other threads:[~2021-09-01  1:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31  5:07 [PATCH V2 0/3] add support for cherryview gpio controller driver Hongzhan Chen
2021-08-31  5:07 ` [PATCH 1/3] drivers/gpio: core: Move out of OF config conditional compilation Hongzhan Chen
2021-08-31 13:05   ` Jan Kiszka
2021-09-01  1:16     ` Chen, Hongzhan
2021-08-31  5:07 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
2021-08-31  6:47   ` Jan Kiszka
2021-08-31  7:07     ` Chen, Hongzhan
2021-08-31  7:14       ` Jan Kiszka
2021-08-31  5:07 ` [PATCH 3/3] driver/gpio: Add Intel Cherryview pinctrl driver Hongzhan Chen
2021-08-31  6:51   ` Jan Kiszka
2021-08-31  7:15 ` [PATCH V2 0/3] add support for cherryview gpio controller driver Jan Kiszka
  -- strict thread matches above, loose matches on Subject: below --
2021-08-30  6:45 [PATCH " Hongzhan Chen
2021-08-30  6:45 ` [PATCH 2/3] drivers/gpio: core: Introduce helper to find gpiochip Hongzhan Chen
2021-04-14  2:16 [PATCH 1/3] rtdm/testing: latmus: introduce latmus driver hongzha1
2021-04-14  2:16 ` [PATCH 2/3] drivers/gpio: core: introduce helper to find gpiochip hongzha1

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.