// SPDX-License-Identifier: GPL-2.0
/*
 * at91-kizbox3-hs.dts - Device Tree file for Overkiz KIZBOX3-HS board
 *
 * Copyright (C) 2018 Overkiz SAS
 *
 * Authors: Dorian Rocipon <d.rocipon@overkiz.com>
 *          Kevin Carli <k.carli@overkiz.com>
 *          Mickael Gardet <m.gardet@overkiz.com>
 */
/dts-v1/;
#include "at91-kizbox3_common.dtsi"

/ {
	model = "Overkiz KIZBOX3-HS";
	compatible = "overkiz,kizbox3-hs", "atmel,sama5d2", "atmel,sama5";

	led-controller-1 {
		status = "okay";

		led-1 {
			status = "okay";
		};

		led-2 {
			status = "okay";
		};

		led-3 {
			status = "okay";
		};

		led-4 {
			status = "okay";
		};
	};

	led-controller-2  {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_led_red
			     &pinctrl_led_white>;
		status = "okay";

		led-5 {
			label = "pio:red:user";
			gpios = <&pioA PIN_PB1 GPIO_ACTIVE_HIGH>;
			default-state = "off";
		};

		led-6 {
			label = "pio:white:user";
			gpios = <&pioA PIN_PB8 GPIO_ACTIVE_HIGH>;
			default-state = "off";
		};
	};

	gpio-keys {
		compatible = "gpio-keys";
		pinctrl-names = "default" , "default", "default",
				"default", "default" ;
		pinctrl-0 = <&pinctrl_key_gpio_default>;
		pinctrl-1 = <&pinctrl_pio_rf &pinctrl_pio_wifi>;
		pinctrl-2 = <&pinctrl_pio_io_boot
			     &pinctrl_pio_io_reset
			     &pinctrl_pio_io_test_radio>;
		pinctrl-3 = <&pinctrl_pio_zbe_test_radio
			     &pinctrl_pio_zbe_rst>;
		pinctrl-4 = <&pinctrl_pio_input>;

		switch-1 {
			label = "SW1";
			gpios = <&pioA PIN_PA29 GPIO_ACTIVE_LOW>;
			linux,code = <0x101>;
			wakeup-source;
		};

		switch-2 {
			label = "SW2";
			gpios = <&pioA PIN_PA18 GPIO_ACTIVE_LOW>;
			linux,code = <0x102>;
			wakeup-source;
		};

		switch-3 {
			label = "SW3";
			gpios = <&pioA PIN_PA22 GPIO_ACTIVE_LOW>;
			linux,code = <0x103>;
			wakeup-source;
		};

		switch-7 {
			label = "SW7";
			gpios = <&pioA PIN_PA26 GPIO_ACTIVE_LOW>;
			linux,code = <0x107>;
			wakeup-source;
		};

		switch-8 {
			label = "SW8";
			gpios = <&pioA PIN_PA24 GPIO_ACTIVE_LOW>;
			linux,code = <0x108>;
			wakeup-source;
		};
	};

	gpios {
		compatible = "gpio";
		status = "okay";

		rf_on {
			label = "rf on";
			gpio = <&pioA PIN_PC19 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		wifi_on {
			label = "wifi on";
			gpio = <&pioA PIN_PC20 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		zbe_test_radio {
			label = "zbe test radio";
			gpio = <&pioA PIN_PB21 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		zbe_rst {
			label = "zbe rst";
			gpio = <&pioA PIN_PB25 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		io_reset {
			label = "io reset";
			gpio = <&pioA PIN_PB30 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		io_test_radio {
			label = "io test radio";
			gpio = <&pioA PIN_PC9 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		io_boot_0 {
			label = "io boot 0";
			gpio = <&pioA PIN_PC11 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		io_boot_1 {
			label = "io boot 1";
			gpio = <&pioA PIN_PC17 GPIO_ACTIVE_HIGH>;
			output;
			init-low;
		};

		verbose_bootloader {
			label = "verbose bootloader";
			gpio = <&pioA PIN_PB11 GPIO_ACTIVE_HIGH>;
			input;
		};

		 nail_bed_detection  {
			label = "nail bed detection";
			gpio = <&pioA PIN_PB12 GPIO_ACTIVE_HIGH>;
			input;
		};

		 id_usba {
			label = "id usba";
			gpio = <&pioA PIN_PC0 GPIO_ACTIVE_LOW>;
			input;
		};
	};
};

&pioA {
	pinctrl_key_gpio_default: key_gpio_default {
		pinmux = <PIN_PA22__GPIO>,
		<PIN_PA24__GPIO>,
		<PIN_PA26__GPIO>,
		<PIN_PA29__GPIO>,
		<PIN_PA18__GPIO>;
		bias-disable;
		};

	pinctrl_gpio {
		pinctrl_pio_rf: gpio_rf {
			pinmux = <PIN_PC19__GPIO>;
			bias-disable;
		};
		pinctrl_pio_wifi: gpio_wifi {
			pinmux = <PIN_PC20__GPIO>;
			bias-disable;
		};
		pinctrl_pio_io_boot: gpio_io_boot {
			pinmux =
			<PIN_PC11__GPIO>,
			<PIN_PC17__GPIO>;
			bias-disable;
		};
		pinctrl_pio_io_test_radio: gpio_io_test_radio {
			pinmux = <PIN_PC9__GPIO>;
			bias-disable;
		};
		pinctrl_pio_zbe_test_radio: gpio_zbe_test_radio {
			pinmux = <PIN_PB21__GPIO>;
			bias-disable;
		};
		pinctrl_pio_zbe_rst: gpio_zbe_rst {
			pinmux = <PIN_PB25__GPIO>;
			bias-disable;
		};
		/* stm32 reset must be open drain (internal pull up) */
		pinctrl_pio_io_reset: gpio_io_reset {
			pinmux = <PIN_PB30__GPIO>;
			bias-disable;
			drive-open-drain;
			output-low;
		};
		pinctrl_pio_input: gpio_input {
			pinmux =
			<PIN_PB11__GPIO>,
			<PIN_PB12__GPIO>,
			<PIN_PC0__GPIO>;
			bias-disable;
		};
	};

	pinctrl_leds {
		pinctrl_led_red: led_red {
			pinmux = <PIN_PB1__GPIO>;
			bias-disable;
		};
		pinctrl_led_white: led_white {
			pinmux = <PIN_PB8__GPIO>;
			bias-disable;
		};
	};
};

&adc {
	status = "okay";
};

&uart0 {
	status = "okay";
};

&uart1 {
	status = "okay";
};

&uart2 {
	status = "okay";
};

&uart3 {
	status = "okay";
};

&uart4 {
	status = "okay";
};

&flx0 {
	status = "okay";

	uart5: serial@200  {
			status = "okay";
	};
};

&flx3 {
	status = "okay";
	uart8: serial@200 {
		status = "okay";
	};
};

&flx4 {
	status = "okay";

	i2c6: i2c@600 {
		status = "okay";
	};
};

&usb0 {
	status = "okay";
};

&usb1 {
	status = "okay";
};

&usb2 {
	status = "okay";
};