--- /dev/null
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <ynezz@true.cz>
+Date: Thu, 11 Nov 2021 16:32:46 +0100
+Subject: [PATCH] ARM: dts: imx: add support for Gaben FlexiSBC
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+!!! TODO !!!
+
+Gaben FlexiSBC is custom carrier board utilizing Toradex Apalis i.MX6
+family of modules. It's being developed, sold and supported by gaben.cz.
+
+Features:
+
+* 1x ADV7180
+* 1x CAN (terminator)
+* 1x galvanically isolated RS485/RS232 (terminator, protection diodes)
+* 1x RS232 with DB9 connector with all signals (missing RI)
+* 4x digital inputs, optically isolated, surge protection
+* 4x digital outputs, using Omron G5V2 relays with max. 2A switching current
+* microSD card slot, 4-bit SDIO, GPIO for card detect
+* LVDS (3x data and clock pairs), usually not populated
+* MCP9800 thermometer on I2C1
+* 4x buttons, RGB LED
+* Secondary watchdog using external MCU
+* Dog128 LCD connected to SPI1 with PWM backlight
+* 4x extension slots using miniPCIe connector format:
+ - GSM&GPS, including SIM card slot for standard sized SIMs
+ - user controllable power source VCC-GSM (GPIO expander)
+ - UART3 signals shared with RFID (jumper select)
+ - PCIe standard slot usually used for WiFi cards
+ - 3x Rx,Tx,CLK diff pairs, WAKE, RESET (PRsT), USB, I2C signals
+ - user controllable power source VCC-PCIE (GPIO expander)
+ - CUSTOM with CAN2, UART4, SPI2, USB, I2C3, 3x GPIO
+ - user controllable power source VCC-CUSTOM (GPIO expander)
+ - RFID with USB, UART3, and WAKEUP/RESET GPIOs
+ - UART3 signals shared with GSM&GPS (jumper select)
+
+Signed-off-by: Petr Štetiar <ynezz@true.cz>
+---
+ arch/arm/boot/dts/Makefile | 1 +
+ .../boot/dts/imx6q-apalis-gaben-flexisbc.dts | 431 ++++++++++++++++++
+ 2 files changed, 432 insertions(+)
+ create mode 100644 arch/arm/boot/dts/imx6q-apalis-gaben-flexisbc.dts
+
+diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
+index 2ea850a50f60..6cd3c308398e 100644
+--- a/arch/arm/boot/dts/Makefile
++++ b/arch/arm/boot/dts/Makefile
+@@ -488,6 +488,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
+ imx6dl-yapp4-hydra.dtb \
+ imx6dl-yapp4-orion.dtb \
+ imx6dl-yapp4-ursa.dtb \
++ imx6q-apalis-gaben-flexisbc.dtb \
+ imx6q-apalis-eval.dtb \
+ imx6q-apalis-ixora.dtb \
+ imx6q-apalis-ixora-v1.1.dtb \
+diff --git a/arch/arm/boot/dts/imx6q-apalis-gaben-flexisbc.dts b/arch/arm/boot/dts/imx6q-apalis-gaben-flexisbc.dts
+new file mode 100644
+index 000000000000..4c4460a8b241
+--- /dev/null
++++ b/arch/arm/boot/dts/imx6q-apalis-gaben-flexisbc.dts
+@@ -0,0 +1,431 @@
++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
++
++/dts-v1/;
++
++#include <dt-bindings/input/input.h>
++#include <dt-bindings/interrupt-controller/irq.h>
++#include "imx6q.dtsi"
++#include "imx6qdl-apalis.dtsi"
++
++/ {
++ model = "Toradex Apalis iMX6Q/D Module on Gaben Flexi SBC";
++ compatible = "gaben,flexisbc", "toradex,apalis_imx6q", "fsl,imx6q";
++
++ aliases {
++ i2c1 = &i2c1;
++ i2c2 = &i2c2;
++ i2c3 = &i2c3;
++
++ rtc0 = &mcp_rtc;
++ rtc1 = &snvs_rtc;
++
++ led-boot = &led_system;
++ led-failsafe = &led_system;
++ led-upgrade = &led_system;
++ };
++
++ keys {
++ compatible = "gpio-keys";
++ pinctrl-names = "default";
++ pinctrl-0 = <&pinctrl_gpio_buttons &pinctrl_gpio_keys>;
++
++ /* S1-S4 buttons on top board under LCD */
++ s1 {
++ label = "button-s1";
++ gpios = <&gpio1 20 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_A>;
++ debounce-interval = <10>;
++ };
++
++ s2 {
++ label = "button-s2";
++ gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_B>;
++ debounce-interval = <10>;
++ };
++
++ s3 {
++ label = "button-s3";
++ gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_C>;
++ debounce-interval = <10>;
++ };
++
++ s4 {
++ label = "button-s4";
++ gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_X>;
++ debounce-interval = <10>;
++ };
++
++ /* IN0-IN3 digital inputs */
++ in0 {
++ label = "dio-in0";
++ gpios = <&gpio7 9 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_0>;
++ debounce-interval = <10>;
++ };
++
++ in1 {
++ label = "dio-in1";
++ gpios = <&gpio6 8 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_1>;
++ debounce-interval = <10>;
++ };
++
++ in2 {
++ label = "dio-in2";
++ gpios = <&gpio7 10 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_2>;
++ debounce-interval = <10>;
++ };
++
++ in3 {
++ label = "dio-in3";
++ gpios = <&gpio6 11 GPIO_ACTIVE_LOW>;
++ linux,code = <BTN_3>;
++ debounce-interval = <10>;
++ };
++
++ /* Wake-up signal from miniPCIe/GSM slot */
++ wakeup {
++ label = "wake-up";
++ gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
++ linux,code = <KEY_WAKEUP>;
++ debounce-interval = <10>;
++ wakeup-source;
++ };
++ };
++
++ leds {
++ compatible = "gpio-leds";
++ pinctrl-names = "default";
++ pinctrl-0 = <&pinctrl_gpio_leds>;
++
++ heartbeat {
++ label = "heartbeat";
++ gpios = <&gpio3 22 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "heartbeat";
++ };
++
++ led_system: rgb-red {
++ label = "rgb-red";
++ gpios = <&gpio4 18 GPIO_ACTIVE_LOW>;
++ };
++
++ rgb-green {
++ label = "rgb-green";
++ gpios = <&gpio4 19 GPIO_ACTIVE_LOW>;
++ };
++
++ rgb-blue {
++ label = "rgb-blue";
++ gpios = <&gpio1 17 GPIO_ACTIVE_LOW>;
++ };
++
++ led-in0 {
++ label = "in0";
++ gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
++ };
++
++ led-in1 {
++ label = "in1";
++ gpios = <&gpio6 16 GPIO_ACTIVE_HIGH>;
++ };
++
++ led-in2 {
++ label = "in2";
++ gpios = <&gpio2 8 GPIO_ACTIVE_HIGH>;
++ };
++
++ led-in3 {
++ label = "in3";
++ gpios = <&gpio2 11 GPIO_ACTIVE_HIGH>;
++ };
++
++ /*
++ * TODO: For nodes bellow we're currently abusing LEDs, but we
++ * should fix it correctly with libgpiod
++ */
++
++ relay-rfid-power {
++ label = "relay-rfid-power";
++ gpios = <&gpio3 31 GPIO_ACTIVE_LOW>;
++ linux,default-trigger = "default-on";
++ };
++
++ relay0 {
++ label = "relay0";
++ gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>;
++ };
++
++ relay1 {
++ label = "relay1";
++ gpios = <&gpio5 11 GPIO_ACTIVE_HIGH>;
++ };
++
++ relay2 {
++ label = "relay2";
++ gpios = <&gpio2 27 GPIO_ACTIVE_HIGH>;
++ };
++
++ relay3 {
++ label = "relay3";
++ gpios = <&gpio5 10 GPIO_ACTIVE_HIGH>;
++ };
++
++ /* USB HUB CY7C65632 reset, not connected currently */
++ reset-usb-hub2 {
++ label = "reset-usb-hub2";
++ gpios = <&gpio6 15 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "default-on";
++ };
++
++ /* adv7180@i2c3 reset */
++ reset-adv7180 {
++ label = "reset-adv7180";
++ gpios = <&gpio7 12 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "default-on";
++ };
++
++ rfid-wakeup {
++ label = "rfid-wakeup";
++ gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>;
++ };
++
++ rfid-reset {
++ label = "rfid-reset";
++ gpios = <&gpio2 31 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "default-on";
++ };
++ };
++
++ pwm-beeper {
++ compatible = "pwm-beeper";
++ pwms = <&pwm2 0 1000 0>;
++ beeper-hz = <900>;
++ };
++
++ dog8-backlight {
++ status = "okay";
++ compatible = "pwm-backlight";
++ pwms = <&pwm1 0 50000 0 >;
++ brightness-levels = <0 10 20 30 40
++ 50 60 70 80 90
++ 100 110 120 127 255
++ >;
++ default-brightness-level = <0>;
++ };
++
++ lvds-backlight {
++ compatible = "pwm-backlight";
++ pwms = <&pwm3 0 50000 0>;
++ brightness-levels = <0 10 20 30 40
++ 50 60 70 80 90
++ 100 110 120 127 255
++ >;
++ default-brightness-level = <0>;
++ };
++};
++
++&can1 {
++ status = "okay";
++};
++
++&gpio3 {
++ /* mcp23009@i2c3 reset */
++ expander-reset {
++ gpio-hog;
++ gpios = <29 GPIO_ACTIVE_HIGH>;
++ output-high;
++ line-name = "expander-reset";
++ };
++};
++
++&i2c1 {
++ status = "okay";
++
++ sensor: lm75@48 {
++ compatible = "national,lm75";
++ reg = <0x48>;
++ };
++};
++
++&i2c3 {
++ status = "okay";
++
++ gpio_expander: mcp23009@20 {
++ compatible = "microchip,mcp23008";
++ gpio-controller;
++ #gpio-cells = <2>;
++ reg = <0x20>;
++ };
++
++ adv7180: adv7180@21 {
++ compatible = "adv,adv7180";
++ reg = <0x21>;
++ pinctrl-names = "default";
++ pinctrl-0 = <&pinctrl_ipu1_csi0>;
++ clocks = <&clks 200>;
++ clock-names = "csi_mclk";
++ csi_id = <0>;
++ mclk = <24000000>;
++ mclk_source = <1>;
++ cvbs = <1>;
++ status = "okay";
++ };
++
++ mcp_rtc: mcp7941x@6f {
++ compatible = "microchip,mcp7941x";
++ reg = <0x6f>;
++ };
++};
++
++&iomuxc {
++ pinctrl-names = "default";
++ pinctrl-0 = <&pinctrl_apalis_gpio1 &pinctrl_apalis_gpio2
++ &pinctrl_apalis_gpio3 &pinctrl_apalis_gpio4
++ &pinctrl_apalis_gpio5 &pinctrl_apalis_gpio6
++ &pinctrl_apalis_gpio7 &pinctrl_apalis_gpio8
++ &pinctrl_rs485_dr &pinctrl_misc_gpio &pinctrl_revision>;
++
++ /*
++ * BTN0 is in pinctrl_misc_gpio, because we need to init it ASAP. BTN0
++ * is being used as reset via IC11/ATTiny if being held down for more
++ * then 8 seconds. If the gpio-keys is compiled as module and we boot
++ * over NFS, then it can take more then 8 seconds to init the GPIO and
++ * the board would get stuck in the reboot loop forever.
++ */
++ pinctrl_gpio_buttons: gpio-buttons {
++ fsl,pins = <
++ MX6QDL_PAD_NANDF_D2__GPIO2_IO02 0x1b0b0 /* BTN1 */
++ MX6QDL_PAD_NANDF_D3__GPIO2_IO03 0x1b0b0 /* BTN2 */
++ MX6QDL_PAD_SD1_DAT0__GPIO1_IO16 0x1b0b0 /* BTN3 */
++ >;
++ };
++
++ pinctrl_rs485_dr: rs485dr {
++ fsl,pins = <
++ MX6QDL_PAD_EIM_WAIT__GPIO5_IO00 0x130b0 /* 485-DR */
++ >;
++ };
++
++ pinctrl_misc_gpio: misc-gpio {
++ fsl,pins = <
++ MX6QDL_PAD_SD1_CLK__GPIO1_IO20 0x1b0b0 /* BTN0 */
++ MX6QDL_PAD_EIM_DA14__GPIO3_IO14 0x130b0 /* LVDS-BLK_PWM */
++ MX6QDL_PAD_SD1_DAT2__GPIO1_IO19 0x130b0 /* CS_PCIE / RFID_WAKEUP */
++ MX6QDL_PAD_SD1_DAT3__GPIO1_IO21 0x130b0 /* RING */
++ MX6QDL_PAD_NANDF_D0__GPIO2_IO00 0x130b0 /* WDIS */
++ MX6QDL_PAD_SD1_CMD__GPIO1_IO18 0x130b0 /* PERST */
++ MX6QDL_PAD_NANDF_CS2__GPIO6_IO15 0x130b0 /* RHUB */
++ MX6QDL_PAD_EIM_EB3__GPIO2_IO31 0x1b0b1 /* RFID_RESET */
++ >;
++ };
++
++ pinctrl_revision: revision {
++ fsl,pins = <
++ MX6QDL_PAD_EIM_A21__GPIO2_IO17 0 /* SJ2 bit0 */
++ MX6QDL_PAD_EIM_A22__GPIO2_IO16 0 /* SJ3 bit1 */
++ MX6QDL_PAD_EIM_A23__GPIO6_IO06 0 /* SJ4 bit2 */
++ MX6QDL_PAD_EIM_A24__GPIO5_IO04 0 /* SJ5 bit3 */
++ >;
++ };
++
++ pinctrl_gpio_leds: gpio-leds {
++ fsl,pins = <
++ MX6QDL_PAD_EIM_D22__GPIO3_IO22 0x130b0 /* Heartbeat LED */
++
++ MX6QDL_PAD_DI0_PIN2__GPIO4_IO18 0x1b0b0 /* RGB-R */
++ MX6QDL_PAD_DI0_PIN3__GPIO4_IO19 0x1b0b0 /* RGB-G */
++ MX6QDL_PAD_SD1_DAT1__GPIO1_IO17 0x1b0b0 /* RGB-B */
++
++ MX6QDL_PAD_NANDF_CLE__GPIO6_IO07 0x130b0 /* LED-IN0 */
++ MX6QDL_PAD_NANDF_CS3__GPIO6_IO16 0x130b0 /* LED-IN1 */
++ MX6QDL_PAD_SD4_DAT0__GPIO2_IO08 0x130b0 /* LED-IN2 */
++ MX6QDL_PAD_SD4_DAT3__GPIO2_IO11 0x130b0 /* LED-IN3 */
++
++ MX6QDL_PAD_GPIO_19__GPIO4_IO05 0x130b0 /* RELAY0 */
++ MX6QDL_PAD_DISP0_DAT17__GPIO5_IO11 0x130b0 /* RELAY1 */
++ MX6QDL_PAD_EIM_LBA__GPIO2_IO27 0x130b0 /* RELAY2 */
++ MX6QDL_PAD_DISP0_DAT16__GPIO5_IO10 0x130b0 /* RELAY3 */
++ MX6QDL_PAD_EIM_D31__GPIO3_IO31 0x1b0b0 /* RFID_PWR_RELAY */
++ >;
++ };
++};
++
++&ldb {
++ status = "disabled";
++};
++
++&sata {
++ status = "disabled";
++};
++
++&pcie {
++ /* active-high meaning opposite of regular PERST# active-low polarity */
++ reset-gpio = <&gpio1 28 GPIO_ACTIVE_HIGH>;
++ reset-gpio-active-high;
++ status = "okay";
++};
++
++&pwm1 {
++ status = "okay";
++};
++
++&pwm2 {
++ status = "okay";
++};
++
++&pwm3 {
++ status = "okay";
++};
++
++&pwm4 {
++ status = "okay";
++};
++
++&uart1 {
++ status = "okay";
++};
++
++&uart2 {
++ status = "okay";
++};
++
++&uart4 {
++ status = "okay";
++};
++
++&uart5 {
++ status = "okay";
++};
++
++&usbotg {
++ status = "okay";
++};
++
++®_usb_host_vbus {
++ status = "okay";
++};
++
++&usbh1 {
++ vbus-supply = <®_usb_host_vbus>;
++ status = "okay";
++};
++
++/* SD1 */
++&usdhc2 {
++ status = "okay";
++};
++
++&ecspi1 {
++ status = "okay";
++
++ /* dogm128 LCD */
++ spidev0: spi@0 {
++ compatible = "spidev";
++ reg = <0>;
++ spi-max-frequency = <50000000>;
++ };
++};