// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2019 FriendlyElec Computer Tech. Co., Ltd.
 * (http://www.friendlyarm.com)
 */

/dts-v1/;
#include <dt-bindings/input/linux-event-codes.h>
#include "rk3328-nanopi-r2s.dts"

/ {
	model = "FriendlyElec NanoPi R2S";
	compatible = "friendlyelec,nanopi-r2", "rockchip,rk3328";

	gpio-keys {
		compatible = "gpio-keys";
		#address-cells = <1>;
		#size-cells = <0>;
		autorepeat;

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

		button@0 {
			gpios = <&gpio0 RK_PA0 GPIO_ACTIVE_LOW>;
			label = "reset";
			linux,code = <BTN_1>;
			linux,input-type = <1>;
			gpio-key,wakeup = <1>;
			debounce-interval = <100>;
		};
	};

	vcc_rtl8153: vcc-rtl8153-regulator {
		compatible = "regulator-fixed";
		gpio = <&gpio2 RK_PC6 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&usb30_en_drv>;
		regulator-always-on;
		regulator-name = "vcc_rtl8153";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		off-on-delay-us = <5000>;
		enable-active-high;
	};
};

&mach {
	hwrev = <0>;
	model = "NanoPi R2S";
};

&emmc {
	status = "disabled";
};

&i2c0 {
	status = "okay";
};

&leds {
	status = "okay";

	led@2 {
		gpios = <&gpio2 RK_PB7 GPIO_ACTIVE_HIGH>;
		label = "lan_led";
	};

	led@3 {
		gpios = <&gpio2 RK_PC2 GPIO_ACTIVE_HIGH>;
		label = "wan_led";
	};
};

&rk805 {
	interrupt-parent = <&gpio1>;
	interrupts = <RK_PD0 IRQ_TYPE_LEVEL_LOW>;
};

&vccio_sd {
	status = "okay";
};

&io_domains {
	vccio3-supply = <&vccio_sd>;
};

&sdmmc {
	vqmmc-supply = <&vccio_sd>;
	max-frequency = <150000000>;
	sd-uhs-sdr50;
	sd-uhs-sdr104;
	status = "okay";
};

&sdmmc_ext {
	status = "disabled";
};

&sdio_pwrseq {
	status = "disabled";
};

&pinctrl {
	pmic {
		pmic_int_l: pmic-int-l {
			rockchip,pins = <1 RK_PD0 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	rockchip-key {
		gpio_key1: gpio-key1 {
			rockchip,pins = <0 RK_PA0 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};

	usb {
		otg_vbus_drv: otg-vbus-drv {
			rockchip,pins = <1 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		usb30_en_drv: usb30-en-drv {
			rockchip,pins = <2 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};
