// SPDX-License-Identifier: (GPL-2.0+ OR MIT)

/*
 * Author: Christian Hewitt <christianshewitt@gmail.com>
 */

/dts-v1/;

#include "meson-gxm.dtsi"
#include "meson-gx-p23x-q20x.dtsi"
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>

/ {
	compatible = "videostrong,gxm-kiii-pro", "amlogic,s912", "amlogic,meson-gxm";
	model = "MeCool KIII Pro";

	memory@0 {
		device_type = "memory";
		reg = <0x0 0x0 0x0 0xC0000000>;
	};

	adc-keys {
		compatible = "adc-keys";
		io-channels = <&saradc 0>;
		io-channel-names = "buttons";
		keyup-threshold-microvolt = <1710000>;

		button-function {
			label = "Update";
			linux,code = <KEY_VENDOR>;
			press-threshold-microvolt = <10000>;
		};
	};

	gpio-keys-polled {
		compatible = "gpio-keys-polled";
		poll-interval = <100>;

		button {
			label = "power";
			linux,code = <KEY_POWER>;
			gpios = <&gpio_ao GPIOAO_2 GPIO_ACTIVE_LOW>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led-blue {
			color = <LED_COLOR_ID_BLUE>;
			function = LED_FUNCTION_POWER;
			gpios = <&gpio GPIODV_24 GPIO_ACTIVE_HIGH>;
			default-state = "on";
			panic-indicator;
		};
	};
};

&ethmac {
	pinctrl-0 = <&eth_pins>;
	pinctrl-names = "default";

	phy-handle = <&external_phy>;

	amlogic,tx-delay-ns = <2>;

	phy-mode = "rgmii";
};

&external_mdio {
	external_phy: ethernet-phy@0 {
		/* Realtek RTL8211F (0x001cc916) */
		reg = <0>;
		max-speed = <1000>;

		reset-assert-us = <10000>;
		reset-deassert-us = <80000>;
		reset-gpios = <&gpio GPIOZ_14 GPIO_ACTIVE_LOW>;

		interrupt-parent = <&gpio_intc>;
		/* MAC_INTR on GPIOZ_15 */
		interrupts = <25 IRQ_TYPE_LEVEL_LOW>;
	};
};

&ir {
	linux,rc-map-name = "rc-mecool-kiii-pro";
};

&sd_emmc_a {
	brcmf: wifi@1 {
		reg = <1>;
		compatible = "brcm,bcm4329-fmac";
	};
};

&uart_A {
	status = "okay";
	pinctrl-0 = <&uart_a_pins>, <&uart_a_cts_rts_pins>;
	pinctrl-names = "default";
	uart-has-rtscts;

	bluetooth {
		compatible = "brcm,bcm43438-bt";
		shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
		max-speed = <2000000>;
		clocks = <&wifi32k>;
		clock-names = "lpo";
	};
};
