// SPDX-License-Identifier: GPL-2.0

#include <dt-bindings/input/input.h>

#include "tegra30.dtsi"

/ {
	chosen {
		stdout-path = &uartd;
	};

	aliases {
		i2c0 = &pwr_i2c;
		i2c1 = &gen2_i2c;

		mmc0 = &sdmmc4;	/* eMMC */

		rtc0 = &pmic;
		rtc1 = "/rtc@7000e000";

		spi0 = &dsi_spi;

		usb0 = &micro_usb;
	};

	memory {
		device_type = "memory";
		reg = <0x80000000 0x40000000>;
	};

	host1x@50000000 {
		dc@54200000 {
			rgb {
				status = "okay";

				nvidia,panel = <&bridge>;
			};
		};
	};

	uartd: serial@70006300 {
		status = "okay";
	};

	gen2_i2c: i2c@7000c400 {
		status = "okay";
		clock-frequency = <400000>;

		backlight: lm3533@36 {
			compatible = "ti,lm3533";
			reg = <0x36>;

			enable-gpios = <&gpio TEGRA_GPIO(N, 6) GPIO_ACTIVE_HIGH>;
			default-brightness-level = <128>;
		};

		muic@44 {
			compatible = "maxim,max14526-muic";
			reg = <0x44>;

			maxim,ap-usb;

			usif-gpios = <&gpio TEGRA_GPIO(Y, 3) GPIO_ACTIVE_HIGH>;
			dp2t-gpios = <&gpio TEGRA_GPIO(CC, 2) GPIO_ACTIVE_HIGH>;
		};
	};

	pwr_i2c: i2c@7000d000 {
		status = "okay";
		clock-frequency = <400000>;

		pmic: max77663@1c {
			compatible = "maxim,max77663";
			reg = <0x1c>;

			interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
			#interrupt-cells = <2>;
			interrupt-controller;

			#gpio-cells = <2>;
			gpio-controller;

			system-power-controller;

			regulators {
				vdd_1v8_vio: sd2 {
					regulator-name = "vdd_1v8_gen";
					regulator-min-microvolt = <1800000>;
					regulator-max-microvolt = <1800000>;
					regulator-always-on;
					regulator-boot-on;
				};

				vdd_usd: ldo3 {
					regulator-name = "vdd_sdmmc3";
					regulator-min-microvolt = <3000000>;
					regulator-max-microvolt = <3000000>;
					regulator-always-on;
					regulator-boot-on;
				};

				vcore_emmc: ldo5 {
					regulator-name = "vdd_ddr_rx";
					regulator-min-microvolt = <2850000>;
					regulator-max-microvolt = <2850000>;
					regulator-always-on;
					regulator-boot-on;
				};
			};
		};
	};

	dsi_spi: spi@7000dc00 {
		status = "okay";
		spi-max-frequency = <25000000>;

		bridge: bridge-spi@2 {
			compatible = "solomon,ssd2825";
			reg = <2>;

			spi-cpol;
			spi-cpha;

			spi-max-frequency = <1000000>;

			power-gpios = <&gpio TEGRA_GPIO(B, 1) GPIO_ACTIVE_HIGH>;
			reset-gpios = <&gpio TEGRA_GPIO(O, 2) GPIO_ACTIVE_HIGH>;

			clocks = <&ssd2825_refclk>;
			clock-names = "tx_clk";

			panel = <&panel>;
		};
	};

	sdmmc4: sdhci@78000600 {
		status = "okay";
		bus-width = <8>;
		non-removable;

		vmmc-supply = <&vcore_emmc>;
		vqmmc-supply = <&vdd_1v8_vio>;
	};

	micro_usb: usb@7d000000 {
		status = "okay";
		dr_mode = "otg";
	};

	/* PMIC has a built-in 32KHz oscillator which is used by PMC */
	clk32k_in: clock-32k {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <32768>;
		clock-output-names = "pmic-oscillator";
	};

	ssd2825_refclk: clock-ssd2825 {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <24000000>;
		clock-output-names = "ssd2825-refclk";
	};

	gpio-keys {
		compatible = "gpio-keys";

		key-power {
			label = "Power";
			gpios = <&gpio TEGRA_GPIO(C, 7) GPIO_ACTIVE_LOW>;
			linux,code = <KEY_ENTER>;
		};

		key-volume-down {
			label = "Volume Down";
			gpios = <&gpio TEGRA_GPIO(O, 4) GPIO_ACTIVE_LOW>;
			linux,code = <KEY_DOWN>;
		};
	};
};