Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts
26513 views
// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
 * Copyright (C) 2022 Sophgo Technology Inc. All rights reserved.
 */

#include "sg2042.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
	model = "Milk-V Pioneer";
	compatible = "milkv,pioneer", "sophgo,sg2042";

	chosen {
		stdout-path = "serial0";
	};

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

		key-power {
			label = "Power Key";
			linux,code = <KEY_POWER>;
			gpios = <&port0a 22 GPIO_ACTIVE_HIGH>;
			linux,input-type = <EV_KEY>;
			debounce-interval = <100>;
		};
	};
};

&cgi_main {
	clock-frequency = <25000000>;
};

&cgi_dpll0 {
	clock-frequency = <25000000>;
};

&cgi_dpll1 {
	clock-frequency = <25000000>;
};

&emmc {
	pinctrl-0 = <&emmc_cfg>;
	pinctrl-names = "default";
	bus-width = <4>;
	no-sdio;
	no-sd;
	non-removable;
	wp-inverted;
	status = "okay";
};

&i2c1 {
	pinctrl-0 = <&i2c1_cfg>;
	pinctrl-names = "default";
	status = "okay";

	mcu: syscon@17 {
		compatible = "sophgo,sg2042-hwmon-mcu";
		reg = <0x17>;
		#thermal-sensor-cells = <1>;
	};
};

&pinctrl {
	emmc_cfg: sdhci-emmc-cfg {
		sdhci-emmc-wp-pins {
			pinmux = <PINMUX(PIN_EMMC_WP, 0)>;
			bias-disable;
			drive-strength-microamp = <26800>;
			input-schmitt-disable;
		};

		sdhci-emmc-cd-pins {
			pinmux = <PINMUX(PIN_EMMC_CD, 0)>;
			bias-pull-up;
			drive-strength-microamp = <26800>;
			input-schmitt-enable;
		};

		sdhci-emmc-rst-pwr-pins {
			pinmux = <PINMUX(PIN_EMMC_RST, 0)>,
				 <PINMUX(PIN_EMMC_PWR_EN, 0)>;
			bias-disable;
			drive-strength-microamp = <26800>;
			input-schmitt-disable;
		};
	};

	i2c1_cfg: i2c1-cfg {
		i2c1-pins {
			pinmux = <PINMUX(PIN_IIC1_SDA, 0)>,
				 <PINMUX(PIN_IIC1_SCL, 0)>;
			bias-pull-up;
			drive-strength-microamp = <26800>;
			input-schmitt-enable;
		};
	};

	sd_cfg: sdhci-sd-cfg {
		sdhci-sd-cd-wp-pins {
			pinmux = <PINMUX(PIN_SDIO_CD, 0)>,
				 <PINMUX(PIN_SDIO_WP, 0)>;
			bias-pull-up;
			drive-strength-microamp = <26800>;
			input-schmitt-enable;
		};

		sdhci-sd-rst-pwr-pins {
			pinmux = <PINMUX(PIN_SDIO_RST, 0)>,
				 <PINMUX(PIN_SDIO_PWR_EN, 0)>;
			bias-disable;
			drive-strength-microamp = <26800>;
			input-schmitt-disable;
		};
	};

	uart0_cfg: uart0-cfg {
		uart0-rx-pins {
			pinmux = <PINMUX(PIN_UART0_TX, 0)>,
				 <PINMUX(PIN_UART0_RX, 0)>;
			bias-pull-up;
			drive-strength-microamp = <26800>;
			input-schmitt-enable;
		};
	};
};

&sd {
	pinctrl-0 = <&sd_cfg>;
	pinctrl-names = "default";
	bus-width = <4>;
	no-sdio;
	no-mmc;
	wp-inverted;
	status = "okay";
};

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

/ {
	pwmfan: pwm-fan {
		compatible = "pwm-fan";
		cooling-levels = <103 128 179 230 255>;
		pwms = <&pwm 0 40000 0>;
		#cooling-cells = <2>;
	};

	thermal-zones {
		soc-thermal {
			polling-delay-passive = <1000>;
			polling-delay = <1000>;
			thermal-sensors = <&mcu 0>;

			trips {
				soc_active1: soc-active1 {
					temperature = <30000>;
					hysteresis = <8000>;
					type = "active";
				};

				soc_active2: soc-active2 {
					temperature = <58000>;
					hysteresis = <12000>;
					type = "active";
				};

				soc_active3: soc-active3 {
					temperature = <70000>;
					hysteresis = <10000>;
					type = "active";
				};

				soc_hot: soc-hot {
					temperature = <80000>;
					hysteresis = <5000>;
					type = "hot";
				};
			};

			cooling-maps {
				map0 {
					trip = <&soc_active1>;
					cooling-device = <&pwmfan 0 1>;
				};

				map1 {
					trip = <&soc_active2>;
					cooling-device = <&pwmfan 1 2>;
				};

				map2 {
					trip = <&soc_active3>;
					cooling-device = <&pwmfan 2 3>;
				};

				map3 {
					trip = <&soc_hot>;
					cooling-device = <&pwmfan 3 4>;
				};
			};
		};

		board-thermal {
			polling-delay-passive = <1000>;
			polling-delay = <1000>;
			thermal-sensors = <&mcu 1>;

			trips {
				board_active: board-active {
					temperature = <75000>;
					hysteresis = <8000>;
					type = "active";
				};
			};

			cooling-maps {
				map4 {
					trip = <&board_active>;
					cooling-device = <&pwmfan 3 4>;
				};
			};
		};
	};
};