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

#include "stm32mp151.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 MECIO1r0";
	compatible = "prt,mecio1r0", "st,stm32mp151";

	led {
		compatible = "gpio-leds";

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

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

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

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

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

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

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

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

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

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

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

&ethernet0 {
	assigned-clocks = <&rcc ETHCK_K>, <&rcc PLL3_Q>;
	assigned-clock-parents = <&rcc PLL3_Q>;
	assigned-clock-rates = <125000000>; /* Clock PLL3 to 625Mhz in tf-a. */
	st,eth-clk-sel;
};

&gpio0 {
	gpio-line-names = "HSIN0_BIAS", "HSIN1_BIAS", "HSIN2_BIAS", "HSIN3_BIAS",
			  "HSIN4_BIAS", "", "STP_VREF0_LVL", "HSIN_VREF0_LVL",
			  "STP0_FB_BIAS", "STP1_FB_BIAS", "STP2_FB_BIAS", "STP3_FB_BIAS",
			  "", "", "", "";
};

&gpio1 {
	gpio-line-names = "HSIN5_BIAS", "HSIN6_BIAS", "HSIN7_BIAS", "HSIN8_BIAS",
			  "HSIN9_BIAS", "", "STP_VREF1_LVL", "HSIN_VREF1_LVL",
			  "STP4_FB_BIAS", "STP5_FB_BIAS", "STP6_FB_BIAS", "",
			  "", "", "LSIN8_BIAS", "LSIN9_BIAS";
};

&gpiod {
	gpio-line-names = "", "", "", "",
			  "", "", "", "",
			  "", "", "", "",
			  "STP_RESETN", "STP_ENABLEN", "HPOUT0", "HPOUT0_ALERTN";
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_hog_d_mecsbc>;
};

&gpioe {
	gpio-line-names = "HPOUT0_RESETN", "HPOUT1", "HPOUT1_ALERTN", "",
			  "", "", "HPOUT1_RESETN",
			  "LPOUT0", "LPOUT0_ALERTN", "LPOUT0_RESETN",
			  "LPOUT1", "LPOUT1_ALERTN", "LPOUT1_RESETN",
			  "LPOUT2", "LPOUT2_ALERTN", "LPOUT2_RESETN";
};

&gpiof {
	gpio-line-names = "LPOUT3", "LPOUT3_ALERTN", "LPOUT3_RESETN",
			  "LPOUT4", "LPOUT4_ALERTN", "LPOUT4_RESETN",
			  "", "",
			  "", "", "", "",
			  "", "", "", "";
};

&gpiog {
	gpio-line-names = "LPOUT5", "LPOUT5_ALERTN", "", "LPOUT5_RESETN",
			  "", "", "", "",
			  "", "", "", "",
			  "", "", "", "";
};

&gpioh {
	gpio-line-names = "", "", "", "",
			  "", "", "", "",
			  "GPIO0_RESETN", "", "", "",
			  "", "", "", "";
};

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

&gpioj {
	gpio-line-names = "HSIN10", "HSIN11", "HSIN12", "HSIN13",
			  "HSIN14", "HSIN15", "", "",
			  "", "", "", "",
			  "", "RTD_RESETN", "", "";
};

&gpiok {
	gpio-line-names = "", "", "HSIN0", "HSIN1",
			  "HSIN2", "HSIN3", "HSIN4", "HSIN5";
};

&gpioz {
	gpio-line-names = "", "", "", "HSIN6",
			  "HSIN7", "HSIN8", "HSIN9", "";
};