// SPDX-License-Identifier: (GPL-2.0-or-later OR MIT)
/*
 * Copyright 2018-2022 TQ-Systems GmbH
 * Author: Markus Niebel <Markus.Niebel@tq-group.com>
 */

/*
 * Common for
 * - TQMa6ULx
 * - TQMa6ULxL
 * - TQMa6ULLx
 * - TQMa6ULLxL
 */

/ {
	memory@80000000 {
		device_type = "memory";
		reg = <0x80000000 0x10000000>;
	};
};

&i2c4 {
	clock-frequency = <100000>;
	pinctrl-names = "default", "gpio";
	pinctrl-0 = <&pinctrl_i2c4>;
	pinctrl-1 = <&pinctrl_i2c4_recovery>;
	scl-gpios = <&gpio1 20 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
	sda-gpios = <&gpio1 21 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
	status = "okay";

	pfuze3000: pmic@8 {
		compatible = "fsl,pfuze3000";
		reg = <0x08>;

		regulators {
			reg_sw1a: sw1a {
				regulator-min-microvolt = <700000>;
				regulator-max-microvolt = <3300000>;
				regulator-boot-on;
				regulator-ramp-delay = <6250>;
				/* not used */
			};

			reg_sw1b_core: sw1b {
				regulator-min-microvolt = <700000>;
				regulator-max-microvolt = <1475000>;
				regulator-boot-on;
				regulator-always-on;
				regulator-ramp-delay = <6250>;
			};

			reg_sw2: sw2 {
				regulator-min-microvolt = <2500000>;
				regulator-max-microvolt = <3300000>;
			};

			reg_sw3_ddr: sw3 {
				regulator-min-microvolt = <900000>;
				regulator-max-microvolt = <1650000>;
				regulator-boot-on;
				regulator-always-on;
			};

			reg_swbst: swbst {
				regulator-min-microvolt = <5000000>;
				regulator-max-microvolt = <5150000>;
				/* not used */
			};

			reg_snvs_3v0: vsnvs {
				regulator-min-microvolt = <1000000>;
				regulator-max-microvolt = <3000000>;
				regulator-boot-on;
				regulator-always-on;
			};

			reg_vrefddr: vrefddr {
				regulator-boot-on;
				regulator-always-on;
			};

			reg_vccsd: vccsd {
				regulator-min-microvolt = <2850000>;
				regulator-max-microvolt = <3300000>;
			};

			reg_v33_3v3: v33 {
				regulator-min-microvolt = <2850000>;
				regulator-max-microvolt = <3300000>;
				regulator-always-on;
			};

			reg_vldo1_3v3: vldo1 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <3300000>;
				/* not used */
			};

			reg_vldo2: vldo2 {
				regulator-min-microvolt = <800000>;
				regulator-max-microvolt = <1550000>;
				/* not used */
			};

			reg_vldo3: vldo3 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <3300000>;
				/* not used */
			};

			reg_vldo4: vldo4 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-always-on;
			};
		};
	};

	jc42_1a: eeprom-temperature@1a {
		compatible = "nxp,se97b", "jedec,jc-42.4-temp";
		reg = <0x1a>;
	};

	m24c64_50: eeprom@50 {
		compatible = "atmel,24c64";
		reg = <0x50>;
		pagesize = <32>;
	};

	m24c02_52: eeprom@52 {
		compatible = "nxp,se97b", "atmel,24c02";
		reg = <0x52>;
		pagesize = <16>;
		read-only;
	};

	rtc0: rtc@68 {
		compatible = "dallas,ds1339";
		reg = <0x68>;
	};
};

&gpio4 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_pmic>;

	/*
	 * PMIC & temperature sensor IRQ
	 * Both do currently not use IRQ
	 * potentially dangerous if used on baseboard
	 */
	pmic-int-hog {
		gpio-hog;
		gpios = <24 0>;
		input;
	};
};

&qspi {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_qspi>;
	status = "okay";

	flash0: flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		spi-max-frequency = <33000000>;
		spi-rx-bus-width = <4>;
		spi-tx-bus-width = <1>;
		reg = <0>;
	};
};

/* eMMC */
&usdhc2 {
	pinctrl-names = "default", "state_100mhz" , "state_200mhz";
	pinctrl-0 = <&pinctrl_usdhc2>;
	pinctrl-1 = <&pinctrl_usdhc2_100mhz>;
	pinctrl-2 = <&pinctrl_usdhc2_200mhz>;

	bus-width = <8>;
	disable-wp;
	non-removable;
	no-sdio;
	no-sd;
	status = "okay";
};

&iomuxc {
	pinctrl_i2c4: i2c4grp {
		fsl,pins = <
			MX6UL_PAD_UART2_TX_DATA__I2C4_SCL	0x4001b8b0
			MX6UL_PAD_UART2_RX_DATA__I2C4_SDA	0x4001b8b0
		>;
	};

	pinctrl_i2c4_recovery: i2c4recoverygrp {
		fsl,pins = <
			MX6UL_PAD_UART2_TX_DATA__GPIO1_IO20	0x4001b8b0
			MX6UL_PAD_UART2_RX_DATA__GPIO1_IO21	0x4001b8b0
		>;
	};

	pinctrl_pmic: pmic {
		fsl,pins = <
			/* PMIC irq */
			MX6UL_PAD_CSI_DATA03__GPIO4_IO24	0x1b099
		>;
	};
};