// SPDX-License-Identifier: GPL-2.0

#include <dt-bindings/input/input.h>
#include "tegra20.dtsi"

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

	aliases {
		i2c0 = &pwr_i2c;

		mmc0 = &sdmmc4; /* eMMC */
		mmc1 = &sdmmc3; /* uSD slot */

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

		usb0 = &micro_usb;
	};

	memory {
		device_type = "memory";
		reg = <0x00000000 0x40000000>; /* 1 GB */
	};

	pinmux@70000014 {
		pinctrl-names = "default";
		pinctrl-0 = <&state_default>;

		state_default: pinmux {
			ata {
				nvidia,pins = "ata", "atc", "atd", "ate",
					      "gmb", "gmd", "irrx", "irtx",
					      "spid", "spie";
				nvidia,function = "gmi";
			};

			atb {
				nvidia,pins = "atb", "gma", "gme";
				nvidia,function = "sdio4";
			};

			cdev1 {
				nvidia,pins = "cdev1";
				nvidia,function = "plla_out";
			};

			cdev2 {
				nvidia,pins = "cdev2";
				nvidia,function = "pllp_out4";
			};

			crtp {
				nvidia,pins = "crtp";
				nvidia,function = "crt";
			};

			csus {
				nvidia,pins = "csus";
				nvidia,function = "vi_sensor_clk";
			};

			dap1 {
				nvidia,pins = "dap1";
				nvidia,function = "dap1";
			};

			dap2 {
				nvidia,pins = "dap2";
				nvidia,function = "dap2";
			};

			dap3 {
				nvidia,pins = "dap3";
				nvidia,function = "dap3";
			};

			dap4 {
				nvidia,pins = "dap4";
				nvidia,function = "dap4";
			};

			ddc {
				nvidia,pins = "ddc";
				nvidia,function = "rsvd4";
			};

			pta {
				nvidia,pins = "pta";
				nvidia,function = "i2c2";
			};

			spif {
				nvidia,pins = "spif", "uac";
				nvidia,function = "rsvd4";
			};

			dta {
				nvidia,pins = "dta", "dtb", "dtc", "dtd", "dte";
				nvidia,function = "vi";
			};

			dtf {
				nvidia,pins = "dtf";
				nvidia,function = "i2c3";
			};

			gmc {
				nvidia,pins = "gmc";
				nvidia,function = "uartd";
			};

			gpu {
				nvidia,pins = "gpu", "uaa", "uab";
				nvidia,function = "uarta";
			};

			gpu7 {
				nvidia,pins = "gpu7";
				nvidia,function = "rtck";
			};

			gpv {
				nvidia,pins = "gpv", "slxa", "slxk";
				nvidia,function = "pcie";
			};

			hdint {
				nvidia,pins = "hdint", "spdi", "spdo";
				nvidia,function = "rsvd2";
			};

			i2cp {
				nvidia,pins = "i2cp";
				nvidia,function = "i2cp";
			};

			kbca {
				nvidia,pins = "kbca", "kbcb", "kbcc", "kbcd",
					      "kbce", "kbcf";
				nvidia,function = "kbc";
			};

			lcsn {
				nvidia,pins = "lcsn", "lsck", "lsda", "lsdi";
				nvidia,function = "spi3";
			};

			ld0 {
				nvidia,pins = "ld0", "ld1", "ld2", "ld3", "ld4",
					      "ld5", "ld6", "ld7", "ld8", "ld9",
					      "ld10", "ld11", "ld12", "ld13", "ld14",
					      "ld15", "ld16", "ld17", "ldc", "ldi",
					      "lhp0", "lhp1", "lhp2", "lhs", "lm0",
					      "lm1", "lpp", "lpw0", "lpw1", "lpw2",
					      "lsc0", "lsc1", "lspi", "lvp0", "lvp1",
					      "lvs";
				nvidia,function = "displaya";
			};

			owc {
				nvidia,pins = "owc";
				nvidia,function = "owr";
			};

			pmc {
				nvidia,pins = "pmc";
				nvidia,function = "pwr_on";
			};

			rm {
				nvidia,pins = "rm";
				nvidia,function = "i2c1";
			};

			sdb {
				nvidia,pins = "sdb", "sdc", "sdd";
				nvidia,function = "sdio3";
			};

			sdio1 {
				nvidia,pins = "sdio1";
				nvidia,function = "sdio1";
			};

			slxc {
				nvidia,pins = "slxc", "slxd";
				nvidia,function = "spi4";
			};

			spig {
				nvidia,pins = "spig", "spih";
				nvidia,function = "spi2_alt";
			};

			uad {
				nvidia,pins = "uad";
				nvidia,function = "irda";
			};

			uca {
				nvidia,pins = "uca", "ucb";
				nvidia,function = "uartc";
			};

			uda {
				nvidia,pins = "uda";
				nvidia,function = "spi1";
			};

			spia {
				nvidia,pins = "spia", "spib", "spic";
				nvidia,function = "spi2";
			};

			conf-cdev1 {
				nvidia,pins = "cdev1", "cdev2", "dap1", "dap2",
					      "dap3", "dap4", "ddc", "dte", "gma",
					      "gmc", "gmd", "gme", "gpu7", "hdint",
					      "i2cp", "lcsn", "lhs", "lm0", "lm1",
					      "lpw1", "lsc0", "lsck", "lsda", "lsdi",
					      "lspi", "lvs", "pmc", "pta", "rm",
					      "sdb", "sdio1", "uac", "uda", "ck32",
					      "ddrc", "pmca", "pmcb", "pmcc", "pmcd",
					      "xm2c", "xm2d";
				nvidia,pull = <TEGRA_PIN_PULL_NONE>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
			};

			conf-crtp {
				nvidia,pins = "crtp", "lvp0";
				nvidia,pull = <TEGRA_PIN_PULL_NONE>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
			};

			conf-csus {
				nvidia,pins = "csus", "spid";
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
			};

			conf-ata {
				nvidia,pins = "ata", "atb", "atc", "ate",
					      "gmb", "gpu", "irrx", "irtx",
					      "kbca", "kbcc", "kbce", "kbcf",
					      "ldc", "lpw0", "lpw2", "lsc1", "sdc",
					      "sdd", "spig", "uaa", "uab",
					      "uad", "uca", "ucb", "pmce";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
			};

			conf-owc {
				nvidia,pins = "owc";
				nvidia,pull = <TEGRA_PIN_PULL_UP>;
				nvidia,tristate = <TEGRA_PIN_ENABLE>;
			};

			conf-atd {
				nvidia,pins = "atd", "dta", "dtb", "dtc", "dtd",
					      "kbcb", "ld0", "ld1", "ld10", "ld11",
					      "ld12", "ld13", "ld14", "ld15", "ld16",
					      "ld17", "ld2", "ld3", "ld4", "ld5",
					      "ld6", "ld7", "ld8", "ld9", "ldi",
					      "lhp0", "lhp1", "lhp2", "lpp", "lvp1",
					      "slxa", "slxc", "slxd", "slxk", "spdo",
					      "spia", "spic", "spie", "spif";
				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
				nvidia,tristate = <TEGRA_PIN_DISABLE>;
			};

			drive-ao1 {
				nvidia,pins = "drive_ao1", "drive_at1", "drive_dbg",
					      "drive_vi1", "drive_vi2";
				nvidia,high-speed-mode = <TEGRA_PIN_DISABLE>;
				nvidia,schmitt = <TEGRA_PIN_ENABLE>;
				nvidia,low-power-mode = <TEGRA_PIN_LP_DRIVE_DIV_1>;
				nvidia,pull-down-strength = <31>;
				nvidia,pull-up-strength = <31>;
				nvidia,slew-rate-rising = <TEGRA_PIN_SLEW_RATE_SLOWEST>;
				nvidia,slew-rate-falling = <TEGRA_PIN_SLEW_RATE_SLOWEST>;
			};

			drive-sdio1 {
				nvidia,pins = "drive_sdio1";
				nvidia,high-speed-mode = <TEGRA_PIN_DISABLE>;
				nvidia,schmitt = <TEGRA_PIN_ENABLE>;
				nvidia,low-power-mode = <TEGRA_PIN_LP_DRIVE_DIV_1>;
				nvidia,pull-down-strength = <31>;
				nvidia,pull-up-strength = <31>;
				nvidia,slew-rate-rising = <TEGRA_PIN_SLEW_RATE_SLOWEST>;
				nvidia,slew-rate-falling = <TEGRA_PIN_SLEW_RATE_SLOWEST>;
			};

			drive-ddc {
				nvidia,pins = "drive_ddc";
				nvidia,high-speed-mode = <TEGRA_PIN_DISABLE>;
				nvidia,schmitt = <TEGRA_PIN_ENABLE>;
				nvidia,low-power-mode = <TEGRA_PIN_LP_DRIVE_DIV_1>;
				nvidia,pull-down-strength = <31>;
				nvidia,pull-up-strength = <31>;
				nvidia,slew-rate-rising = <TEGRA_PIN_SLEW_RATE_FASTEST>;
				nvidia,slew-rate-falling = <TEGRA_PIN_SLEW_RATE_FASTEST>;
			};
		};
	};

	uartb: serial@70006040 {
		clocks = <&tegra_car 7>;
		status = "okay";
	};

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

		pmic: max8907@3c {
			compatible = "maxim,max8907";
			reg = <0x3c>;

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

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

			maxim,system-power-controller;

			regulators {
				vlcd_1v8_reg: ldo3 {
					regulator-name = "vlcd_1v8";
					regulator-min-microvolt = <1800000>;
					regulator-max-microvolt = <1800000>;
					regulator-always-on;
					regulator-boot-on;
				};

				usb_phy_reg: ldo4 {
					regulator-name = "vap_usb_3v3";
					regulator-min-microvolt = <3300000>;
					regulator-max-microvolt = <3300000>;
					regulator-always-on;
					regulator-boot-on;
				};

				vlcd_3v0_reg: ldo12 {
					regulator-name = "vlcd_3v0";
					regulator-min-microvolt = <3000000>;
					regulator-max-microvolt = <3000000>;
				};

				vmmc_usd_reg: ldo16 {
					regulator-name = "vmmc_usd";
					regulator-min-microvolt = <3300000>;
					regulator-max-microvolt = <3300000>;
				};
			};
		};
	};

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

	usb-phy@c5000000 {
		status = "okay";
		vbus-supply = <&usb_phy_reg>;
	};

	sdmmc3: sdhci@c8000400 {
		status = "okay";
		bus-width = <4>;

		vmmc-supply = <&vmmc_usd_reg>;
		vqmmc-supply = <&vdd_3v3_sys>;
	};

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

		vmmc-supply = <&vdd_3v3_sys>;
		vqmmc-supply = <&vdd_3v3_sys>;
	};

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

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

		key-power {
			label = "Power";
			gpios = <&gpio TEGRA_GPIO(U, 5) GPIO_ACTIVE_HIGH>;
			linux,code = <KEY_ENTER>;
		};

		key-volume-up {
			label = "Volume Up";
			gpios = <&gpio TEGRA_GPIO(Q, 1) GPIO_ACTIVE_LOW>;
			linux,code = <KEY_UP>;
		};

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

	vdd_3v3_sys: regulator-3v3 {
		compatible = "regulator-fixed";
		regulator-name = "vdd_3v3_vs";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
	};
};
