Skip to contentSkip to conversation

Add zynq-7000 rtdm gpio driver.

PATCH In review Greg Gallagher 2 participants 2 messages Dec 4, 2017 – Dec 5, 2017 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add zynq-7000 rtdm gpio driver.

From: Greg Gallagher <[email protected]>

---
For the zynq platform (and possibly others in the future) we need to modify gpio-core to request gpio pins before using them. The open() function will now request a gpio and fail if it's already reserved. This should make the pin request transparent to the user. The ability to request and release pins is also available in an ioctrl message. Tested on Microzed Zynq-7010 platform and the raspberry pi 2 board.

---
 include/rtdm/uapi/gpio.h            |  2 +
 kernel/drivers/gpio/Kconfig         |  8 ++++
 kernel/drivers/gpio/Makefile        |  1 +
 kernel/drivers/gpio/gpio-core.c     | 87 +++++++++++++++++++++++++++----------
 kernel/drivers/gpio/gpio-zynq7000.c | 40 +++++++++++++++++
 5 files changed, 116 insertions(+), 22 deletions(-)
 create mode 100644 kernel/drivers/gpio/gpio-zynq7000.c
include/rtdm/uapi/gpio.h +2 -0
index f846f48..b745f15 100644
@@ -22,6 +22,8 @@
 #define GPIO_RTIOC_DIR_IN		_IO(RTDM_CLASS_GPIO, 1)
 #define GPIO_RTIOC_IRQEN		_IOW(RTDM_CLASS_GPIO, 2, int) /* GPIO trigger */
 #define GPIO_RTIOC_IRQDIS		_IO(RTDM_CLASS_GPIO, 3)
+#define GPIO_RTIOC_REQS                _IO(RTDM_CLASS_GPIO, 4)
+#define GPIO_RTIOC_RELS                _IO(RTDM_CLASS_GPIO, 5)
 
 #define GPIO_TRIGGER_NONE		0x0 /* unspecified */
 #define GPIO_TRIGGER_EDGE_RISING	0x1
kernel/drivers/gpio/Kconfig +8 -0
index 869392f..81fc442 100644
@@ -33,6 +33,14 @@ config XENO_DRIVERS_GPIO_SUN8I_H3
 	Suitable for the GPIO controller available from Allwinner's H3
 	SoC, as found on the NanoPI boards.
 
+config XENO_DRIVERS_GPIO_ZYNQ7000
+	depends on ARCH_ZYNQ
+	bool "Support for Zynq7000 GPIOs"
+	help
+
+	Enables support for the GPIO controller available from
+	Xilinx's Zynq7000 SoC.
+
 config XENO_DRIVERS_GPIO_DEBUG
        bool "Enable GPIO core debugging features"
 
kernel/drivers/gpio/Makefile +1 -0
index 35ca52c..7f28403 100644
@@ -8,3 +8,4 @@ xeno_gpio-y := gpio-core.o
 xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_BCM2835) += gpio-bcm2835.o
 xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_MXC) += gpio-mxc.o
 xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_SUN8I_H3) += gpio-sun8i-h3.o
+xeno_gpio-$(CONFIG_XENO_DRIVERS_GPIO_ZYNQ7000) += gpio-zynq7000.o
kernel/drivers/gpio/gpio-core.c +65 -22

147 lines not on this page · raw message

kernel/drivers/gpio/gpio-zynq7000.c new file +40 -0
new file mode 100644
index 0000000..99b24a9
@@ -0,0 +1,40 @@
+/**
+ * @note Copyright (C) 2017 Greg Gallagher <[email protected]>
+ * 
+ * This driver is inspired by:
+ * gpio-bcm2835.c, please see original file for copyright information
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include <linux/module.h>
+#include "gpio-core.h"
+
+#define RTDM_SUBCLASS_ZYNQ7000  4
+
+static int __init zynq7000_gpio_init(void)
+{
+ 	return rtdm_gpiochip_scan_of(NULL, "xlnx,zynq-gpio-1.0", 
+                     RTDM_SUBCLASS_ZYNQ7000);
+}
+module_init(zynq7000_gpio_init);
+
+static void __exit zynq7000_gpio_exit(void)
+{
+	rtdm_gpiochip_remove_of(RTDM_SUBCLASS_ZYNQ7000);
+}
+module_exit(zynq7000_gpio_exit);
+
+MODULE_LICENSE("GPL");
+
Signature · 1 line
2.7.4
#1 lore raw
Quoted 10 lines · Greg Gallagher

From: Greg Gallagher <[email protected]>

---
For the zynq platform (and possibly others in the future) we need to modify gpio-core to request gpio pins before using them. The open() function will now request a gpio and fail if it's already reserved. This should make the pin request transparent to the user. The ability to request and release pins is also available in an ioctrl message. Tested on Microzed Zynq-7010 platform and the raspberry pi 2 board.

Thanks. Merged, as two separate commits, so that we can bisect through changes to generic code more easily.

commit 56f9dd3ff8b70880f4609a52c91372a27308c2ac (HEAD -> stable-3.0.x, origin/stable-3.0.x)

Author: Greg Gallagher <[email protected]>
Date:   Mon Dec 4 04:31:00 2017 +0100

drivers/gpio: Add zynq-7000 rtdm gpio driver

commit 70f9d8f15a3b4219cc86d49860e6b8b515954980

Author: Greg Gallagher <[email protected]>
Date:   Tue Dec 5 09:39:05 2017 +0100

drivers/gpio: Request gpio at open()

For the zynq platform (and possibly others in the future) we need to
modify
gpio-core to request gpio pins before using them. The open()
function will
now request a gpio and fail if it's already reserved. This should make the pin request transparent to the user. The ability to request and
release
pins is also available in an ioctrl message. Tested on Microzed
Zynq-7010
platform and the raspberry pi 2 board.

Signature · 1 line
Philippe.