// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2025 Arm Ltd.
 * Copyright (c) 2026 Alexander Sverdlin <alexander.sverdlin@gmail.com>
 */

/dts-v1/;

#include "sun50i-a133-helperboard-core.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/linux-event-codes.h>
#include <dt-bindings/leds/common.h>

/{
	model = "Baijie HelperBoard A133";
	compatible = "baijie,helperboard-a133",
		     "baijie,helperboard-a133-core",
		     "allwinner,sun50i-a100";

	aliases {
		serial0 = &uart0;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

	leds {
		compatible = "gpio-leds";

		led {
			function = LED_FUNCTION_INDICATOR;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&pio 7 13 GPIO_ACTIVE_LOW>;	/* PH13 */
		};
	};

	reg_vdd5v: vdd5v {
		/* board wide 5V supply from a 12V->5V regulator */
		compatible = "regulator-fixed";
		regulator-name = "vdd-5v";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-always-on;
	};
};

&ehci1 {
	status = "okay";
};

&emac0 {
	pinctrl-names = "default";
	pinctrl-0 = <&rgmii0_pins>;
	phy-handle = <&rgmii_phy>;
	phy-mode = "rgmii-id";
	allwinner,rx-delay-ps = <200>;
	allwinner,tx-delay-ps = <200>;
	status = "okay";
};

&lradc {
	wakeup-source;
	status = "okay";

	button-115 {
		label = "K1";
		linux,code = <KEY_1>;
		channel = <0>;
		voltage = <114607>;
	};

	button-235 {
		label = "K2";
		linux,code = <KEY_2>;
		channel = <0>;
		voltage = <234783>;
	};

	button-360 {
		label = "K3";
		linux,code = <KEY_3>;
		channel = <0>;
		voltage = <360000>;
	};

	button-476 {
		label = "K4";
		linux,code = <KEY_4>;
		channel = <0>;
		voltage = <476471>;
	};

	button-592 {
		label = "K5";
		linux,code = <KEY_5>;
		channel = <0>;
		voltage = <591946>;
	};
};

&mdio0 {
	reset-gpios = <&pio 7 11 GPIO_ACTIVE_LOW>;	/* PH11 */
	reset-delay-us = <10000>;
	reset-post-delay-us = <150000>;

	rgmii_phy: ethernet-phy@1 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <1>;
	};
};

&mmc0 {
	vmmc-supply = <&reg_dcdc1>;
	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>;	/* PF6 */
	bus-width = <4>;
	disable-wp;
	status = "okay";
};

&ohci1 {
	status = "okay";
};

&rgmii0_pins {
	drive-strength = <30>;
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_pb_pins>;
	status = "okay";
};

&usb_otg {
	/*
	 * Connected to a downstream port of an onboard hub, therefore only
	 * "peripheral" mode will work here.
	 */
	dr_mode = "peripheral";
	status = "okay";
};

&usbphy {
	usb1_vbus-supply = <&reg_vdd5v>;
	status = "okay";
};