// SPDX-License-Identifier: GPL-2.0
/*
 * dts file for Xilinx ZynqMP SC k24 RevA
 *
 * (C) Copyright 2025, Advanced Micro Devices, Inc.
 *
 * Michal Simek <michal.simek@amd.com>
 */

#include "include/dt-bindings/net/ti-dp83867.h"
#include "include/dt-bindings/phy/phy.h"
#include "zynqmp-sm-k24-reva.dtsi"

/delete-node/ &eeprom_cc;

/ {
	model = "ZynqMP SC K24 RevA";
	compatible = "xlnx,zynqmp-sc-k24-revA", "xlnx,zynqmp-sc-k24",
		     "xlnx,zynqmp";

	aliases {
		nvmem1 = &eeprom_cc;
	};

	sysctrl_gtr_clk2: sysctrl-gtr-clk2 {
		clock-frequency = <26000000>;
		#clock-cells = <0>;
		compatible = "fixed-clock";
	};
};

&pwm_fan {
	pwms = <&ttc0 0 40000 0>;
};

&gem1 { /* MDIO MIO50/51 */
	phy-mode = "sgmii";
	phy-handle = <&phy0>;

	mdio: mdio {
		#address-cells = <1>;
		#size-cells = <0>;

		phy0: ethernet-phy@1 {
			#phy-cells = <1>;
			compatible = "ethernet-phy-id2000.a231";
			reg = <1>;
			ti,dp83867-rxctrl-strap-quirk;
			reset-gpios = <&gpio 77 GPIO_ACTIVE_LOW>;
			reset-assert-us = <2500>;
			reset-deassert-us = <500>;
		};
	};
};

/* i2c via PL */
/* u192 0x10 SLG7XL46528 */
/* u195 0x69 SIT95211 */

&i2c1 {
	bootph-all;
	clock-frequency = <400000>;
	pinctrl-names = "default", "gpio";
	pinctrl-0 = <&pinctrl_i2c1_default>;
	pinctrl-1 = <&pinctrl_i2c1_gpio>;
	scl-gpios = <&gpio 24 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
	sda-gpios = <&gpio 25 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;

	slg7xl45106: gpio@11 { /* u169 - reset logic */
		compatible = "dlg,slg7xl45106";
		reg = <0x11>;
		label = "resetchip";
		gpio-controller;
		#gpio-cells = <2>;
		gpio-line-names = "USB_PHY_RESET_B", "SC_PS_RESET_OUT2",
				  "SC_PS_RESET_OUT3", "SC_PS_RESET_OUT4",
				  "SC_PS_RESET_OUT5",
				  "EEPROM_WC_B", "PS_ETH_RST_B";
	};
	i2c-arbitrator@72 { /* u161 */
		compatible = "nxp,pca9541";
		bootph-all;
		reg = <0x72>;

		i2c_arb: i2c-arb {
			#address-cells = <1>;
			#size-cells = <0>;

			eeprom_cc: eeprom@54 { /* u35 - required by spec - also at address 0x5C */
				compatible = "atmel,24c128";
				label = "eeprom_cc";
				reg = <0x54>;
				bootph-all;
			};
		};
	};
};

&gpio {
	gpio-line-names =
		/*   0 -   4 */ "QSPI_CLK", "QSPI_DQ1", "QSPI_DQ2", "QSPI_DQ3", "QSPI_DQ0",
		/*   5 -   9 */ "QSPI_CS_B", "SPI_CLK", "LED1", "LED2", "SPI_CS_B",
		/*  10 -  14 */ "SPI_MISO", "SPI_MOSI", "FWUEN", "EMMC_DAT0", "EMMC_DAT1",
		/*  15 -  19 */ "EMMC_DAT2", "EMMC_DAT3", "EMMC_DAT4", "EMMC_DAT5", "EMMC_DAT6",
		/*  20 -  24 */ "EMMC_DAT7", "EMMC_CMD", "EMMC_CLK", "EMMC_RST", "I2C1_SCL",
		/*  25 -  29 */ "I2C1_SDA", "SYSCTLR_JTAG_S0", "SYSCTLR_JTAG_S1", "VERSAL_ERROR_OUT_LS", "VERSAL_DONE",
		/*  30 -  34 */ "SYSCTLR_POR_B_LS", "SHUTDOWN", "FPD_PWR_EN", "PL_PWR_EN", "PS_PWR_EN",
		/*  35 -  39 */ "PMU_RST", "UART1_TXD", "UART1_RXD", "SYSCTLR_VERSAL_MODE0", "SYSCTLR_VERSAL_MODE1",
		/*  40 -  44 */ "SYSCTLR_VERSAL_MODE2", "SYSCTLR_VERSAL_MODE3", "SYSCTLR_VERSAL_MODE0_READBACK", "SYSCTLR_VERSAL_MODE1_READBACK", "SYSCTLR_VERSAL_MODE2_READBACK",
		/*  45 -  49 */ "SYSCTLR_VERSAL_MODE3_READBACK", "SYSCTLR_VERSAL_POR_B_READBACK", "FAN_PWM", "UART_MUXSEL0", "UART_MUXSEL1",
		/*  50 -  54 */ "GEM_MDC", "GEM_MDIO", "USB0_CLK", "USB0_DIR", "USB0_DATA2",
		/*  55 -  59 */ "USB0_NXT", "USB0_DATA0", "USB0_DATA1", "USB0_STP", "USB0_DATA3",
		/*  60 -  64 */ "USB0_DATA4", "USB0_DATA5", "USB0_DATA6", "USB0_DATA7", "",
		/*  65 -  69 */ "I2C0_SW_SEL", "I2C0_SCL", "I2C0_SDA", "I2C0_ALERT", "I2C1_ALERT",
		/*  70 -  74 */ "UART0_TXD", "UART0_RXD", "I2C1_SW_INT_B", "I2C0I2C1_SW_INT_BI2C1_SW_INT_B_SW_INT_B", "SYSCTLR_IIC_MUX0_RESET_B",
		/*  75 -  77 */ "SYSCTLR_IIC_MUX1_RESET_B", "USB_RESET_B", "ETH_RESET_B",
		/* MIO end and EMIO start */
		/*  78 -  79 */ "", "",
		/*  80 -  84 */ "", "", "", "", "",
		/*  85 -  89 */ "", "", "", "", "",
		/*  90 -  94 */ "", "", "", "", "",
		/*  95 -  99 */ "", "", "", "", "",
		/* 100 - 104 */ "", "", "", "", "",
		/* 105 - 109 */ "", "", "", "", "",
		/* 110 - 114 */ "", "", "", "", "",
		/* 115 - 119 */ "", "", "", "", "",
		/* 120 - 124 */ "", "", "", "", "",
		/* 125 - 129 */ "", "", "", "", "",
		/* 130 - 134 */ "", "", "", "", "",
		/* 135 - 139 */ "", "", "", "", "",
		/* 140 - 144 */ "", "", "", "", "",
		/* 145 - 149 */ "", "", "", "", "",
		/* 150 - 154 */ "", "", "", "", "",
		/* 155 - 159 */ "", "", "", "", "",
		/* 160 - 164 */ "", "", "", "", "",
		/* 165 - 169 */ "", "", "", "", "",
		/* 170 - 173 */ "", "", "", "";
};

&psgtr {
        status = "okay";
        clocks = <&sysctrl_gtr_clk2>;
        clock-names = "ref2";
};

&usb0 { /* mio52 - mio63 */
        reset-gpios = <&gpio 76 GPIO_ACTIVE_LOW>;
        phy-names = "usb3-phy";
        phys = <&psgtr 2 PHY_TYPE_USB3 0 2>;
};

&dwc3_0 {
        dr_mode = "host";
        snps,usb3_lpm_capable;
        maximum-speed = "super-speed";
};

&pinctrl0 {
	pinctrl_i2c1_default: i2c1-default {
		conf {
			groups = "i2c1_6_grp";
			bias-pull-up;
			slew-rate = <SLEW_RATE_SLOW>;
			power-source = <IO_STANDARD_LVCMOS18>;
		};

		mux {
			groups = "i2c1_6_grp";
			function = "i2c1";
		};
	};

	pinctrl_i2c1_gpio: i2c1-gpio-grp {
		conf {
			groups = "gpio0_24_grp", "gpio0_25_grp";
			slew-rate = <SLEW_RATE_SLOW>;
			power-source = <IO_STANDARD_LVCMOS18>;
		};

		mux {
			groups = "gpio0_24_grp", "gpio0_25_grp";
			function = "gpio0";
		};
	};
};
