[meta-freescale] [meta-fsl-arm-extra][PATCH] 2/3] qmx6-addons-gpio: Add gpio.sh configuration script

Alex de Cabo alejandro.de-cabo-garcia at congatec.com
Wed Jan 28 04:10:00 PST 2015


This patch adds the gpio.sh script to the rootfs, and the
needed links to make the listed GPIOs accesible via the
/sys/class/gpio interface.

The GPIOs [0..3] [5..7] are currently mapped as inputs, in
order to define them as output, uncomment the
"echo "out" ... direction" statement
underneath the related pin export statement

Pin mapping (Q7 GPIO vs. GPIO nr)

	Q7, GPIO 0 <--> gpio130
	Q7, GPIO 1 <--> gpio86 (disabled)
	Q7, GPIO 2 <--> gpio122
	Q7, GPIO 3 <--> gpio123
	Q7, GPIO 5 <--> gpio111
	Q7, GPIO 6 <--> gpio203
	Q7, GPIO 7 <--> gpio110

This patch needs the 4571a17 commit.

Signed-off-by: Alex de Cabo <alejandro.de-cabo-garcia at congatec.com>
---
 .../qmx6-addons/qmx6-addons-gpio-1.0/gpio.sh       | 88 ++++++++++++++++++++++
 recipes-bsp/qmx6-addons/qmx6-addons-gpio_1.0.bb    | 38 ++++++++++
 2 files changed, 126 insertions(+)
 create mode 100644 recipes-bsp/qmx6-addons/qmx6-addons-gpio-1.0/gpio.sh
 create mode 100644 recipes-bsp/qmx6-addons/qmx6-addons-gpio_1.0.bb

diff --git a/recipes-bsp/qmx6-addons/qmx6-addons-gpio-1.0/gpio.sh b/recipes-bsp/qmx6-addons/qmx6-addons-gpio-1.0/gpio.sh
new file mode 100644
index 0000000..91caab7
--- /dev/null
+++ b/recipes-bsp/qmx6-addons/qmx6-addons-gpio-1.0/gpio.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          gpios
+# Required-Start:    $local_fs mountvirtfs
+# Required-Stop:     $local_fs
+# Default-Start:     S
+# Default-Stop:      0 6
+# Short-Description: export of Q7 GPIOs
+### END INIT INFO
+
+# script for exporting the GPIOs defined by the Q7 standard
+#
+# the GPIOs [0..3]  [5..7] are currently mapped as inputs
+# in order to define them as output, uncomment the "echo "out" ... direction" statement underneath the related pin export statement 
+#
+# Pin mapping (Q7 GPIO vs. GPIO nr)
+#
+# Q7, GPIO 0	<-->	gpio130
+# Q7, GPIO 1	<-->	gpio86	(disabled)
+# Q7, GPIO 2	<-->	gpio122
+# Q7, GPIO 3	<-->	gpio123
+# Q7, GPIO 5	<-->	gpio111
+# Q7, GPIO 6	<-->	gpio203
+# Q7, GPIO 7	<-->	gpio110
+
+do_start() {
+	# Q7, Pin 185, GPIO 0
+	echo 130 > /sys/class/gpio/export
+	#echo "out" > /sys/class/gpio/gpio130/direction
+
+	# Q7, Pin 186, GPIO 1
+	# disabled, because this pin is shared with OTG_PWR functionality
+	# in order to enable the pin as GPIO, the kernel's device tree configuration has to be changed
+	#echo 86 > /sys/class/gpio/export
+	#echo "out" > /sys/class/gpio/gpio86/direction
+
+	# Q7, Pin 187, GPIO 2
+	echo 122 > /sys/class/gpio/export
+	#echo "out" > /sys/class/gpio/gpio122/direction
+
+	# Q7, Pin 188, GPIO 3
+	echo 123 > /sys/class/gpio/export
+	#echo "out" > /sys/class/gpio/gpio123/direction
+
+	# Q7, Pin 190, GPIO 5
+	# Attention: could lead to a conflict when specified as output and used along with a backplane which has a LPC device assembled
+	echo 111 > /sys/class/gpio/export
+	#echo "out" > /sys/class/gpio/gpio111/direction
+
+	# Q7, Pin 191 GPIO 6
+	# Attention: could lead to a conflict when specified as output and used along with a backplane which has a LPC device assembled
+	echo 203 > /sys/class/gpio/export
+	#echo "out" > /sys/class/gpio/gpio203/direction
+
+	# Q7, Pin 192, GPIO 7
+	# Attention: could lead to a conflict when specified as output and used along with a backplane which has a LPC device assembled
+	echo 110 > /sys/class/gpio/export
+	#echo "out" > /sys/class/gpio/gpio110/direction
+
+}
+
+do_stop() {
+	echo 110 > /sys/class/gpio/unexport
+	echo 203 > /sys/class/gpio/unexport
+	echo 111 > /sys/class/gpio/unexport
+	echo 123 > /sys/class/gpio/unexport
+	echo 122 > /sys/class/gpio/unexport
+	#echo 86 > /sys/class/gpio/unexport
+	echo 130 > /sys/class/gpio/unexport
+}
+
+case "$1" in
+	start)
+	do_start
+		;;
+	restart|reload|force-reload)
+		echo "Error: argument '$1' not supported" >&2
+		exit 3
+		;;
+	stop)
+	do_stop
+		;;
+	*)
+		echo "Usage: $0 start|stop" >&2
+		exit 3
+		;;
+esac
+
diff --git a/recipes-bsp/qmx6-addons/qmx6-addons-gpio_1.0.bb b/recipes-bsp/qmx6-addons/qmx6-addons-gpio_1.0.bb
new file mode 100644
index 0000000..000927e
--- /dev/null
+++ b/recipes-bsp/qmx6-addons/qmx6-addons-gpio_1.0.bb
@@ -0,0 +1,38 @@
+# Congatec QMX6 u-boot
+
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://gpio.sh;md5=06d9e2200bcd42ddefedbd26b72ce11c"
+
+SRC_URI_cgtqmx6 = " file://gpio.sh "
+S = "${WORKDIR}"
+
+
+do_configure() {
+        :
+}
+
+do_compile() {
+        :
+}
+
+do_install(){
+	install -d ${D}${sysconfdir}/init.d
+	install -m 0755 ${WORKDIR}/gpio.sh ${D}${sysconfdir}/init.d
+
+        install -d ${D}${sysconfdir}/rc2.d
+        install -d ${D}${sysconfdir}/rc3.d
+        install -d ${D}${sysconfdir}/rc5.d
+
+	update-rc.d -r ${D} gpio.sh start 99 2 3 5 .
+}
+
+FILES_${PN}_cgtqmx6 = "\
+                 /etc/init.d/gpio.sh \
+		 /etc/rc2.d/S99gpio.sh \
+		/etc/rc5.d/S99gpio.sh \
+		/etc/rc3.d/S99gpio.sh \
+"
+
+
+PACKAGE_ARCH_cgtqmx6 = "${MACHINE_ARCH}"
+COMPATIBLE_MACHINE = "(cgtqmx6)"
-- 
1.9.1



More information about the meta-freescale mailing list