// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2019 André Hentschel <nerv@dawncrow.de>
 */
/dts-v1/;

#include "dm3725.dtsi"

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

/ {
	model = "Amazon Echo (first generation)";
	compatible = "amazon,omap3-echo", "ti,omap3630", "ti,omap3";

	cpus {
		cpu@0 {
			cpu0-supply = <&vdd1_reg>;
		};
	};

	memory@80000000 {
		device_type = "memory";
		reg = <0x80000000 0xc600000>; /* 198 MB */
	};

	vcc5v: fixedregulator0 {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-boot-on;
		regulator-always-on;
	};

	vcc3v3: fixedregulator1 {
		compatible = "regulator-fixed";
		regulator-name = "vcc3v3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		regulator-always-on;
	};

	vcc1v8: fixedregulator2 {
		compatible = "regulator-fixed";
		regulator-name = "vcc1v8";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		regulator-boot-on;
		regulator-always-on;
	};

	sdio_pwrseq: sdio-pwrseq {
		compatible = "mmc-pwrseq-simple";
		reset-gpios = <&gpio1 21 GPIO_ACTIVE_LOW>;
		post-power-on-delay-ms = <40>;
	};

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

		pinctrl-names = "default";
		pinctrl-0 = <&button_pins>;

		mute-button {
			label = "mute";
			linux,code = <KEY_MUTE>;
			gpios = <&gpio3 6 GPIO_ACTIVE_LOW>;	/* GPIO_70 */
			wakeup-source;
		};

		help-button {
			label = "help";
			linux,code = <KEY_HELP>;
			gpios = <&gpio3 8 GPIO_ACTIVE_LOW>;	/* GPIO_72 */
			wakeup-source;
		};
	};

	rotary: rotary-encoder {
		compatible = "rotary-encoder";
		gpios = <
			&gpio3  5 GPIO_ACTIVE_HIGH /* GPIO_69 */
			&gpio3 12 GPIO_ACTIVE_HIGH /* GPIO_76 */
		>;
		linux,axis = <REL_X>;
		rotary-encoder,relative-axis;
	};

	speaker_amp: speaker-amplifier {
		compatible = "simple-audio-amplifier";
		enable-gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;	/* gpio_129 */
		sound-name-prefix = "Speaker Amp";
		VCC-supply = <&vcc1v8>;
	};

	sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "Misto Speaker";
		simple-audio-card,widgets =
			"Speaker", "Speaker";
		simple-audio-card,routing =
			"Speaker Amp INL", "HPL",
			"Speaker Amp INR", "HPR",
			"Speaker", "Speaker Amp OUTL",
			"Speaker", "Speaker Amp OUTR";
		simple-audio-card,format = "i2s";
		simple-audio-card,bitclock-master = <&sound_master>;
		simple-audio-card,frame-master = <&sound_master>;
		simple-audio-card,aux-devs = <&speaker_amp>;

		simple-audio-card,cpu {
			sound-dai = <&mcbsp2>;
		};

		sound_master: simple-audio-card,codec {
			sound-dai = <&codec0>;
			system-clock-frequency = <19200000>;
		};
	};
};

&i2c1 {
	clock-frequency = <400000>;

	tps: tps@2d {
		reg = <0x2d>;
	};
};

&mcbsp2 {
	status = "okay";
	#sound-dai-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&mcbsp2_pins>;
};

&i2c2 {
	clock-frequency = <400000>;

	lp5523A: lp5523A@32 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "national,lp5523";
		label = "q1";
		reg = <0x32>;
		clock-mode = /bits/ 8 <0>; /* LP55XX_CLOCK_AUTO */
		enable-gpios = <&gpio4 13 GPIO_ACTIVE_HIGH>; /* GPIO_109 */

		multi-led@0 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x0>;
			color = <LED_COLOR_ID_RGB>;

			led@0 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x0>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@1 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x1>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@6 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x6>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@1 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x1>;
			color = <LED_COLOR_ID_RGB>;

			led@2 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x2>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@3 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x3>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@7 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x7>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@2 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x2>;
			color = <LED_COLOR_ID_RGB>;

			led@4 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x4>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@5 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x5>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@8 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x8>;
				color = <LED_COLOR_ID_RED>;
			};
		};
	};

	lp5523B: lp5523B@33 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "national,lp5523";
		label = "q3";
		reg = <0x33>;
		clock-mode = /bits/ 8 <0>; /* LP55XX_CLOCK_AUTO */

		multi-led@0 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x0>;
			color = <LED_COLOR_ID_RGB>;

			led@0 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x0>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@1 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x1>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@6 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x6>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@1 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x1>;
			color = <LED_COLOR_ID_RGB>;

			led@2 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x2>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@3 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x3>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@7 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x7>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@2 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x2>;
			color = <LED_COLOR_ID_RGB>;

			led@4 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x4>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@5 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x5>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@8 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x8>;
				color = <LED_COLOR_ID_RED>;
			};
		};
	};

	lp5523C: lp5523C@34 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "national,lp5523";
		label = "q4";
		reg = <0x34>;
		clock-mode = /bits/ 8 <0>; /* LP55XX_CLOCK_AUTO */

		multi-led@0 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x0>;
			color = <LED_COLOR_ID_RGB>;

			led@0 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x0>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@1 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x1>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@6 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x6>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@1 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x1>;
			color = <LED_COLOR_ID_RGB>;

			led@2 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x2>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@3 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x3>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@7 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x7>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@2 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x2>;
			color = <LED_COLOR_ID_RGB>;

			led@4 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x4>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@5 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x5>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@8 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x8>;
				color = <LED_COLOR_ID_RED>;
			};
		};
	};

	lp5523D: lp552D@35 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "national,lp5523";
		label = "q2";
		reg = <0x35>;
		clock-mode = /bits/ 8 <0>; /* LP55XX_CLOCK_AUTO */

		multi-led@0 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x0>;
			color = <LED_COLOR_ID_RGB>;

			led@0 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x0>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@1 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x1>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@6 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x6>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@1 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x1>;
			color = <LED_COLOR_ID_RGB>;

			led@2 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x2>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@3 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x3>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@7 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x7>;
				color = <LED_COLOR_ID_RED>;
			};
		};
		multi-led@2 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0x2>;
			color = <LED_COLOR_ID_RGB>;

			led@4 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x4>;
				color = <LED_COLOR_ID_GREEN>;
			};

			led@5 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x5>;
				color = <LED_COLOR_ID_BLUE>;
			};

			led@8 {
				led-cur = /bits/ 8 <12>;
				max-cur = /bits/ 8 <15>;
				reg = <0x8>;
				color = <LED_COLOR_ID_RED>;
			};
		};
	};
};

&i2c3 {
	clock-frequency = <400000>;

	codec0: codec@18 {
		#sound-dai-cells = <0>;
		compatible = "ti,tlv320aic32x4";
		reg = <0x18>;
		clocks = <&sys_clkout1>;
		clock-names = "mclk";
		ldoin-supply = <&vcc1v8>;
		iov-supply = <&vcc1v8>;
		reset-gpios = <&gpio3 10 GPIO_ACTIVE_LOW>;	/* gpio_74 */
	};
};


#include "../../tps65910.dtsi"

&omap3_pmx_core {
	tps_pins: tps-pins {
		pinctrl-single,pins = <
			OMAP3_CORE1_IOPAD(0x21e0, PIN_INPUT_PULLUP | PIN_OFF_INPUT_PULLUP | PIN_OFF_OUTPUT_LOW | PIN_OFF_WAKEUPENABLE | MUX_MODE0) /* sys_nirq.sys_nirq */
		>;
	};

	button_pins: button-pins {
		pinctrl-single,pins = <
			OMAP3_CORE1_IOPAD(0x20dc, PIN_INPUT | MUX_MODE4)	/* dss_data0.gpio_70 */
			OMAP3_CORE1_IOPAD(0x20e0, PIN_INPUT | MUX_MODE4)	/* dss_data2.gpio_72 */
			OMAP3_CORE1_IOPAD(0x20e4, PIN_OUTPUT | MUX_MODE4)	/* dss_data4.gpio_74 */
			OMAP3_CORE1_IOPAD(0x20fa, PIN_OUTPUT_PULLDOWN | MUX_MODE4)	/* dss_data15.gpio_85 */
			OMAP3_CORE1_IOPAD(0x2a1a, PIN_OUTPUT | MUX_MODE0)	/* sys_clkout1.sys_clkout1 */
		>;
	};

	mmc1_pins: mmc1-pins {
		pinctrl-single,pins = <
			OMAP3_CORE1_IOPAD(0x2144, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc1_clk.sdmmc1_clk */
			OMAP3_CORE1_IOPAD(0x2146, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc1_cmd.sdmmc1_cmd */
			OMAP3_CORE1_IOPAD(0x2148, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc1_dat0.sdmmc1_dat0 */
			OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc1_dat1.sdmmc1_dat1 */
			OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc1_dat2.sdmmc1_dat2 */
			OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc1_dat3.sdmmc1_dat3 */
		>;
	};

	mmc2_pins: mmc2-pins {
		pinctrl-single,pins = <
			OMAP3_CORE1_IOPAD(0x2158, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_clk.sdmmc2_clk */
			OMAP3_CORE1_IOPAD(0x215a, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_cmd.sdmmc2_cmd */
			OMAP3_CORE1_IOPAD(0x215c, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat0.sdmmc2_dat0 */
			OMAP3_CORE1_IOPAD(0x215e, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat1.sdmmc2_dat1 */
			OMAP3_CORE1_IOPAD(0x2160, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat2.sdmmc2_dat2 */
			OMAP3_CORE1_IOPAD(0x2162, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat3.sdmmc2_dat3 */
			OMAP3_CORE1_IOPAD(0x2164, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat4.sdmmc2_dat4 */
			OMAP3_CORE1_IOPAD(0x2166, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat5.sdmmc2_dat5 */
			OMAP3_CORE1_IOPAD(0x2168, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat6.sdmmc2_dat6 */
			OMAP3_CORE1_IOPAD(0x216a, PIN_INPUT_PULLUP | MUX_MODE0)		/* sdmmc2_dat7.sdmmc2_dat7 */
		>;
	};

	mcbsp2_pins: mcbsp2-pins {
		pinctrl-single,pins = <
			OMAP3_CORE1_IOPAD(0x213c, PIN_INPUT | MUX_MODE0)	/* mcbsp2_fsx.mcbsp2_fsx */
			OMAP3_CORE1_IOPAD(0x213e, PIN_INPUT | MUX_MODE0)	/* mcbsp2_clkx.mcbsp2_clkx */
			OMAP3_CORE1_IOPAD(0x2140, PIN_INPUT | MUX_MODE0)	/* mcbsp2_dr.mcbsp2.dr */
			OMAP3_CORE1_IOPAD(0x2142, PIN_OUTPUT | MUX_MODE0)	/* mcbsp2_dx.mcbsp2_dx */
		>;
	};
};

&omap3_pmx_core2 {
	mmc3_pins: mmc3-pins {
		pinctrl-single,pins = <
			OMAP3630_CORE2_IOPAD(0x25d8, PIN_INPUT_PULLUP | MUX_MODE2)	/* etk_clk.sdmmc3_clk */
			OMAP3630_CORE2_IOPAD(0x25da, PIN_INPUT_PULLUP | MUX_MODE2)	/* etk_ctl.sdmmc3_cmd */
			OMAP3630_CORE2_IOPAD(0x25e2, PIN_INPUT_PULLUP | MUX_MODE2)	/* etk_d3.sdmmc3_dat3 */
			OMAP3630_CORE2_IOPAD(0x25e4, PIN_INPUT_PULLUP | MUX_MODE2)	/* etk_d4.sdmmc3_dat0 */
			OMAP3630_CORE2_IOPAD(0x25e6, PIN_INPUT_PULLUP | MUX_MODE2)	/* etk_d5.sdmmc3_dat1 */
			OMAP3630_CORE2_IOPAD(0x25e8, PIN_INPUT_PULLUP | MUX_MODE2)	/* etk_d6.sdmmc3_dat2 */
		>;
	};
};

&mmc1 {
	status = "okay";
	bus-width = <4>;
	pinctrl-names = "default";
	pinctrl-0 = <&mmc1_pins>;
	vmmc-supply = <&vmmc_reg>;
};

&mmc2 {
	status = "okay";
	bus-width = <8>;
	pinctrl-names = "default";
	pinctrl-0 = <&mmc2_pins>;
	vmmc-supply = <&vmmc_reg>;
};

&mmc3 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";
	bus-width = <4>;
	pinctrl-names = "default";
	pinctrl-0 = <&mmc3_pins>;
	non-removable;
	disable-wp;
	mmc-pwrseq = <&sdio_pwrseq>;
	vmmc-supply = <&vcc3v3>;
	vqmmc-supply = <&vcc1v8>;
	atheros@0 {
		compatible = "atheros,ath6kl";
		reg = <0>;
		bus-width = <4>;
	};
};

&tps {
	pinctrl-names = "default";
	pinctrl-0 = <&tps_pins>;

	interrupts = <7>; /* SYS_NIRQ cascaded to intc */
	interrupt-parent = <&intc>;

	ti,en-ck32k-xtal;
	ti,system-power-controller;

	vcc1-supply = <&vcc5v>;
	vcc2-supply = <&vcc5v>;
	vcc3-supply = <&vcc5v>;
	vcc4-supply = <&vcc5v>;
	vcc5-supply = <&vcc5v>;
	vcc6-supply = <&vcc5v>;
	vcc7-supply = <&vcc5v>;
	vccio-supply = <&vcc5v>;

	regulators {

		vio_reg: regulator@1 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-always-on;
		};

		vdd1_reg: regulator@2 {
			regulator-name = "vdd_mpu";
			regulator-min-microvolt = <600000>;
			regulator-max-microvolt = <1500000>;
			regulator-boot-on;
			regulator-always-on;
		};

		vdd2_reg: regulator@3 {
			regulator-name = "vdd_dsp";
			regulator-min-microvolt = <600000>;
			regulator-max-microvolt = <1500000>;
			regulator-always-on;
		};

		vdd3_reg: regulator@4 {
			regulator-name = "vdd_core";
			regulator-min-microvolt = <5000000>;
			regulator-max-microvolt = <5000000>;
			regulator-always-on;
		};

		vdig1_reg: regulator@5 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <2700000>;
			regulator-always-on;
		};

		vdig2_reg: regulator@6 {
			regulator-min-microvolt = <1000000>;
			regulator-max-microvolt = <1800000>;
			regulator-always-on;
		};

		vpll_reg: regulator@7 {
			regulator-min-microvolt = <1000000>;
			regulator-max-microvolt = <2500000>;
			regulator-always-on;
		};

		vdac_reg: regulator@8 {
			regulator-min-microvolt = <1100000>;
			regulator-max-microvolt = <3300000>;
			regulator-always-on;
		};

		vaux1_reg: regulator@9 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2850000>;
			regulator-always-on;
		};

		vaux2_reg: regulator@10 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <3300000>;
			regulator-always-on;
		};

		vaux33_reg: regulator@11 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <3300000>;
			regulator-always-on;
		};

		vmmc_reg: regulator@12 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <3000000>;
			regulator-always-on;
		};
	};
};