From d24ae71981c221b2918310466c388696cb720689 Mon Sep 17 00:00:00 2001
From: Otto Urpelainen <oturpe@iki.fi>
Date: Sat, 26 Sep 2020 11:57:28 +0300
Subject: [PATCH] Include cust.dtsi created by DrvGen instead of running DrvGen
 during build

DrvGen is a MediaTek proprietary tool that automatically generates device
tree files. Getting the tool to run in postmarketOS build environment is quite
challenging, as the tool has been built using glibc, but postmarketOS uses
musl. Disabling the tool execution here, instead the generated file is directly
in the source tree.
---
 arch/arm64/Makefile           |   2 +-
 arch/arm64/boot/dts/cust.dtsi | 351 ++++++++++++++++++++++++++++++++++
 2 files changed, 352 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/boot/dts/cust.dtsi

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index e312f18b..a3022dad 100755
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -76,7 +76,7 @@ all:	$(KBUILD_IMAGE) $(KBUILD_DTBS)
 MTK_PLATFORM := $(CONFIG_MTK_PLATFORM:"%"=%)
 MTK_PROJECT := $(CONFIG_ARCH_MTK_PROJECT:"%"=%)
 export MTK_PLATFORM MTK_PROJECT MTK_TARGET_PROJECT
--include $(srctree)/scripts/drvgen/drvgen.mk
+#-include $(srctree)/scripts/drvgen/drvgen.mk
 archprepare: $(DRVGEN_FILE_LIST)
 dtbs: $(DRVGEN_FILE_LIST)
 
diff --git a/arch/arm64/boot/dts/cust.dtsi b/arch/arm64/boot/dts/cust.dtsi
new file mode 100644
index 00000000..4c405ce8
--- /dev/null
+++ b/arch/arm64/boot/dts/cust.dtsi
@@ -0,0 +1,351 @@
+/*
+ * Generated by MTK SP Drv_CodeGen Version 03.13.6  for MT6755. Copyright MediaTek Inc. (C) 2013.
+ * Sat Sep 26 13:21:12 2020
+ * Do Not Modify the File.
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+/*************************
+ * EINT DTSI File
+*************************/
+
+&ext_buck_oc {
+	interrupt-parent = <&eintc>;
+	interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
+	debounce = <0 0>;
+	status = "okay";
+};
+&touch {
+	interrupt-parent = <&eintc>;
+	interrupts = <1 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <1 0>;
+	status = "okay";
+};
+&accdet {
+	interrupt-parent = <&eintc>;
+	interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <2 256000>;
+	status = "okay";
+};
+&msdc1_ins {
+	interrupt-parent = <&eintc>;
+	interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <3 1000>;
+	status = "okay";
+};
+&gyro {
+	interrupt-parent = <&eintc>;
+	interrupts = <4 IRQ_TYPE_LEVEL_HIGH>;
+	debounce = <4 0>;
+	status = "okay";
+};
+&mse {
+	interrupt-parent = <&eintc>;
+	interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
+	debounce = <5 0>;
+	status = "okay";
+};
+&als {
+	interrupt-parent = <&eintc>;
+	interrupts = <6 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <6 0>;
+	status = "okay";
+};
+&mrdump_ext_rst {
+	interrupt-parent = <&eintc>;
+	interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <7 512000>;
+	status = "okay";
+};
+&irq_nfc {
+	interrupt-parent = <&eintc>;
+	interrupts = <26 IRQ_TYPE_LEVEL_HIGH>;
+	debounce = <26 0>;
+	status = "okay";
+};
+&dsi_te {
+	interrupt-parent = <&eintc>;
+	interrupts = <44 IRQ_TYPE_EDGE_RISING>;
+	debounce = <44 0>;
+	status = "okay";
+};
+&cei_camera_capture {
+	interrupt-parent = <&eintc>;
+	interrupts = <62 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <62 0>;
+	status = "okay";
+};
+&cei_camera_focus {
+	interrupt-parent = <&eintc>;
+	interrupts = <79 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <79 0>;
+	status = "okay";
+};
+&cei_hall_out {
+	interrupt-parent = <&eintc>;
+	interrupts = <107 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <107 0>;
+	status = "okay";
+};
+
+
+/********************
+ * GPIO USAGE MAPPING DTSI File
+****************/
+
+&gpio_usage_mapping {
+	GPIO_SIM2_SIO = <36>;
+	GPIO_SIM2_SRST = <37>;
+	GPIO_SIM2_SCLK = <38>;
+	GPIO_SIM1_SCLK = <39>;
+	GPIO_SIM1_SRST = <40>;
+	GPIO_SIM1_SIO = <41>;
+	GPIO_FDD_BAND_SUPPORT_DETECT_1ST_PIN = <89>;
+	GPIO_FDD_BAND_SUPPORT_DETECT_2ND_PIN = <90>;
+};
+
+
+&eintc {
+	MD1_SIM1_HOT_PLUG_EINT@0 {
+		compatible = "mediatek,MD1_SIM1_HOT_PLUG_EINT-eint";
+		interrupts = <0 4>;
+		debounce = <0 100000>;
+		dedicated = <0 0>;
+		src_pin = <0 1>;
+		sockettype=<0 0>;
+		status = "okay";
+	};
+};
+
+
+/*************************
+ * PMIC DTSI File
+*************************/
+
+&mt_pmic_vcama_ldo_reg {
+	regulator-name = "vcama";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vsim1_ldo_reg {
+	regulator-name = "vsim1";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vsim2_ldo_reg {
+	regulator-name = "vsim2";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vldo28_ldo_reg {
+	regulator-name = "vldo28";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vgp3_ldo_reg {
+	regulator-name = "vgp3";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vibr_ldo_reg {
+	regulator-name = "vibr";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vcamd_ldo_reg {
+	regulator-name = "vcamd";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vcamio_ldo_reg {
+	regulator-name = "vcamio";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+
+&kd_camera_hw1 {
+	vcama-supply = <&mt_pmic_vcama_ldo_reg>;
+	vcama_main2-supply = <&mt_pmic_vcama_ldo_reg>;
+	vcama_sub-supply = <&mt_pmic_vcama_ldo_reg>;
+
+	vcamaf-supply = <&mt_pmic_vldo28_ldo_reg>;
+	vcamaf_main2-supply = <&mt_pmic_vldo28_ldo_reg>;
+	vcamaf_sub-supply = <&mt_pmic_vldo28_ldo_reg>;
+
+	vcamd_main2-supply = <&mt_pmic_vgp3_ldo_reg>;
+	vcamd_sub-supply = <&mt_pmic_vgp3_ldo_reg>;
+
+	vcamd-supply = <&mt_pmic_vcamd_ldo_reg>;
+
+	vcamio-supply = <&mt_pmic_vcamio_ldo_reg>;
+	vcamio_main2-supply = <&mt_pmic_vcamio_ldo_reg>;
+	vcamio_sub-supply = <&mt_pmic_vcamio_ldo_reg>;
+
+	status = "okay";
+};
+
+&touch {
+	vtouch-supply = <&mt_pmic_vldo28_ldo_reg>;
+	status = "okay";
+};
+
+
+/********************************************
+ *ADC DTSI File
+********************************************/
+
+&auxadc {
+	adc_channel@ {
+		compatible = "mediatek,adc_channel";
+		mediatek,temperature0 = <0>;
+		mediatek,temperature1 = <1>;
+		mediatek,adc_fdd_rf_params_dynamic_custom_ch = <12>;
+		status = "okay";
+	};
+};
+
+
+/**********************************************
+ *CLK_BUF DTSI File
+********************************************/
+
+&rf_clock_buffer_ctrl {
+	mediatek,clkbuf-quantity = <4>;
+	mediatek,clkbuf-config = <2 0 1 1>;
+	mediatek,clkbuf-driving-current = <2 2 2 2>;
+	status = "okay";
+};
+
+&pmic_clock_buffer_ctrl {
+	mediatek,clkbuf-quantity = <4>;
+	mediatek,clkbuf-config = <2 1 1 2>;
+	mediatek,clkbuf-driving-current = <2 2 2 2>;
+	status = "okay";
+};
+
+
+/**********************************************
+ *Keypad DTSI File
+********************************************/
+
+&keypad{
+	mediatek,kpd-key-debounce = <1024>;
+	mediatek,kpd-sw-pwrkey = <116>;
+	mediatek,kpd-hw-pwrkey = <8>;
+	mediatek,kpd-sw-rstkey  = <115>;
+	mediatek,kpd-hw-rstkey = <17>;
+	mediatek,kpd-use-extend-type = <0>;
+	/*HW Keycode [0~71] -> Linux Keycode*/
+	mediatek,kpd-hw-map-num = <72>;
+	mediatek,kpd-hw-init-map = <0 114 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+				0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
+				0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >;
+	mediatek,kpd-pwrkey-eint-gpio = <0>;
+	mediatek,kpd-pwkey-gpio-din  = <0>;
+	mediatek,kpd-hw-dl-key0 = <17>;
+	mediatek,kpd-hw-dl-key1 = <1>;
+	mediatek,kpd-hw-dl-key2 = <8>;
+	mediatek,kpd-hw-recovery-key = <17>;
+	mediatek,kpd-hw-factory-key = <1>;
+	status = "okay";
+};
+
+
+/*************************
+ * I2C DTSI File
+*************************/
+
+&i2c0 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	cap_touch@10 {
+		compatible = "mediatek,cap_touch";
+		reg = <0x10>;
+		status = "okay";
+	};
+	i2c_lcd_bias@3e {
+		compatible = "mediatek,i2c_lcd_bias";
+		reg = <0x3e>;
+		status = "okay";
+	};
+};
+
+&i2c1 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	ext_vbat_boost@75 {
+		compatible = "mediatek,ext_vbat_boost";
+		reg = <0x75>;
+		status = "okay";
+	};
+	swithing_charger@6b {
+		compatible = "mediatek,swithing_charger";
+		reg = <0x6b>;
+		status = "okay";
+	};
+	msensor@2e {
+		compatible = "mediatek,msensor";
+		reg = <0x2e>;
+		status = "okay";
+	};
+	gyro@68 {
+		compatible = "mediatek,gyro";
+		reg = <0x68>;
+		status = "okay";
+	};
+	pressure@77 {
+		compatible = "mediatek,pressure";
+		reg = <0x77>;
+		status = "okay";
+	};
+	alsps@48 {
+		compatible = "mediatek,alsps";
+		reg = <0x48>;
+		status = "okay";
+	};
+	strobe_main@63 {
+		compatible = "mediatek,strobe_main";
+		reg = <0x63>;
+		status = "okay";
+	};
+};
+
+&i2c2 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	camera_main@10 {
+		compatible = "mediatek,camera_main";
+		reg = <0x10>;
+		status = "okay";
+	};
+	camera_main_af@0c {
+		compatible = "mediatek,camera_main_af";
+		reg = <0x0c>;
+		status = "okay";
+	};
+};
+
+&i2c3 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	camera_sub@10 {
+		compatible = "mediatek,camera_sub";
+		reg = <0x10>;
+		status = "okay";
+	};
+	camera_sub_af@0c {
+		compatible = "mediatek,camera_sub_af";
+		reg = <0x0c>;
+		status = "okay";
+	};
+	nfc@28 {
+		compatible = "mediatek,nfc";
+		reg = <0x28>;
+		status = "okay";
+	};
+};
+
+
+
-- 
2.26.2

