// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
/*
 * Copyright (C) Protonic Holland
 * Author: David Jander <david@protonic.nl>
 */
/dts-v1/;

#include "stm32mp153.dtsi"
#include "stm32mp15xc.dtsi"
#include "stm32mp15-pinctrl.dtsi"
#include "stm32mp15xxaa-pinctrl.dtsi"
#include "stm32mp15x-mecio1-io.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>

/ {
	model = "Protonic MECIO1r1";
	compatible = "prt,mecio1r1", "st,stm32mp153";

	led {
		compatible = "gpio-leds";

		led-0 {
			color = <LED_COLOR_ID_RED>;
			function = LED_FUNCTION_DEBUG;
			gpios = <&gpioa 13 GPIO_ACTIVE_LOW>;
		};

		led-1 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_DEBUG;
			gpios = <&gpioa 14 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "heartbeat";
		};
	};
};

&adc1 {
	channel@0 {
		reg = <0>;
		st,min-sample-time-ns = <20000>;
		label = "p24v_hpdcm";
	};

	channel@1 {
		reg = <1>;
		st,min-sample-time-ns = <20000>;
		label = "p24v_stp";
	};

	channel@3 {
		reg = <3>;
		st,min-sample-time-ns = <200000>;
		label = "phint1_ain";
	};

	channel@5 {
		reg = <5>;
		st,min-sample-time-ns = <20000>;
		label = "hpout1_i";
	};

	channel@9 {
		reg = <9>;
		st,min-sample-time-ns = <20000>;
		label = "hpout0_i";
	};

	channel@13 {
		reg = <13>;
		st,min-sample-time-ns = <20000>;
		label = "hpdcm0_i2";
	};

	channel@15 {
		reg = <15>;
		st,min-sample-time-ns = <20000>;
		label = "hpdcm1_i2";
	};

	channel@18 {
		reg = <18>;
		st,min-sample-time-ns = <20000>;
		label = "hpdcm0_i1";
	};
};

&clk_hse {
	clock-frequency = <24000000>;
};

&gpio0 {
	gpio-line-names = "HSIN0_BIAS", "HSIN1_BIAS", "HSIN2_BIAS", "HSIN3_BIAS",
			  "", "", "HSIN_VREF0_LVL", "HSIN_VREF1_LVL",
			  "HSIN4_BIAS", "HSIN5_BIAS", "HSIN6_BIAS", "HSIN7_BIAS",
			  "", "", "", "";
};

&gpio1 {
	gpio-line-names = "HSIN8_BIAS", "HSIN9_BIAS", "HSIN10_BIAS", "HSIN11_BIAS",
			  "", "", "HSIN_VREF2_LVL", "HSIN_VREF3_LVL",
			  "HSIN12_BIAS", "HSIN13_BIAS", "HSIN14_BIAS", "HSIN15_BIAS",
			  "", "", "LSIN8_BIAS", "LSIN9_BIAS";
};

&gpioa {
	gpio-line-names = "", "", "", "",
			  "", "", "", "",
			  "", "", "GPIO1_RESETN", "",
			  "", "", "", "LPOUT5";
};

&gpiob {
	gpio-line-names = "", "", "", "",
			  "LPOUT4_RESETN", "", "", "",
			  "", "LPOUT4_ALERTN", "", "",
			  "", "", "", "";
};

&gpioc {
	gpio-line-names = "", "", "", "",
			  "", "", "", "",
			  "", "LPOUT4", "", "",
			  "", "", "", "";
};

&gpiod {
	gpio-line-names = "LPOUT2", "", "LPOUT3_RESETN", "",
			  "LPOUT2_ALERTN", "", "MECIO_ADDR0", "",
			  "HPOUT1_ALERTN", "HPOUT1_RESETN", "", "",
			  "", "", "HPOUT0", "HPOUT1";
};

&gpioe {
	gpio-line-names = "LPOUT0_RESETN", "", "", "",
			  "", "LPOUT3", "LPOUT5_ALERTN", "",
			  "", "", "", "",
			  "", "", "", "HSIN_RESETN";
};

&gpiof {
	gpio-line-names = "LPOUT5_RESETN", "", "", "HPOUT0_ALERTN",
			  "", "LPOUT1", "", "",
			  "", "", "", "",
			  "", "", "", "";
};

&gpiog {
	gpio-line-names = "", "", "", "HPOUT0_RESETN",
			  "", "", "LPOUT3_ALERTN", "",
			  "", "", "GPIO0_RESETN", "",
			  "", "", "", "LPOUT2_RESETN";
};

&gpioh {
	gpio-line-names = "", "", "", "",
			  "", "", "", "",
			  "", "LPOUT0", "", "",
			  "", "LPOUT0_ALERTN", "STP_ENABLEN", "STP_RESETN";
};

&gpioi {
	gpio-line-names = "", "", "", "",
			  "", "", "", "",
			  "", "", "SPE_RESETN", "",
			  "HPDCM0_SLEEPN", "", "", "";
};

&gpioj {
	gpio-line-names = "", "", "", "",
			  "", "", "", "MECIO_ADDR1",
			  "", "", "", "",
			  "", "", "", "LPOUT1_RESETN";
};

&gpiok {
	gpio-line-names = "", "", "RTD_RESETN", "",
			  "", "LPOUT1_ALERTN", "", "";
};

&gpioz {
	gpio-line-names = "", "", "", "",
			  "HPDCM1_SLEEPN", "", "", "";
};

&m_can1 {
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&m_can1_pins_b>;
	pinctrl-1 = <&m_can1_sleep_pins_b>;
	status = "okay";
};