From 5016607e4b1ec9a3de1957c3f756c02c69d10389 Mon Sep 17 00:00:00 2001
From: Oliver Smith <ollieparanoid@postmarketos.org>
Date: Sun, 9 Oct 2022 02:29:46 +0200
Subject: [PATCH] Include cust.dtsi, don't run python2 drvgen

Instead of running mediatek's python2 drvgen script to generate the
cust.dtsi file, include the generated file. I've tried to forward port
the tool to python3 first, but it is not trivial and the existing
patches we have that do forward port it don't apply on this particular
version. Just including the short generated file is the sane choice
here, it's not like we are going to modify it anyway.

Related: https://wiki.postmarketos.org/wiki/Porting_to_a_new_device#Removing_python2_dependency
---
 arch/arm/Makefile           |   2 +-
 arch/arm/boot/dts/cust.dtsi | 391 ++++++++++++++++++++++++++++++++++++
 2 files changed, 392 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/cust.dtsi

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 2fe43bea..845dcd16 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -300,7 +300,7 @@ MTK_PROJECT := $(CONFIG_ARCH_MTK_PROJECT:"%"=%)
 export MTK_PLATFORM MTK_PROJECT MTK_TARGET_PROJECT
 KBUILD_CPPFLAGS += -I$(srctree)/drivers/misc/mediatek/include/mt-plat/$(MTK_PLATFORM)/include
 KBUILD_CPPFLAGS += -I$(srctree)/arch/arm/mach-mediatek/include/
--include $(srctree)/scripts/drvgen/drvgen.mk
+#-include $(srctree)/scripts/drvgen/drvgen.mk
 archprepare: $(DRVGEN_FILE_LIST)
 dtbs: $(DRVGEN_FILE_LIST)
 
diff --git a/arch/arm/boot/dts/cust.dtsi b/arch/arm/boot/dts/cust.dtsi
new file mode 100644
index 00000000..20b919c2
--- /dev/null
+++ b/arch/arm/boot/dts/cust.dtsi
@@ -0,0 +1,391 @@
+/*
+ * Generated by MTK SP DrvGen Version: 3.5.160809 for MT6580.
+ * 2022-10-09 00:27:19
+ * Do Not Modify The File.
+ * Copyright Mediatek Inc. (c) 2016.
+*/
+
+/*************************
+ * ADC DTSI File
+*************************/
+
+&auxadc {
+	adc_channel@ {
+		compatible = "mediatek,adc_channel";
+		mediatek,temperature0 = <0>;
+		mediatek,temperature1 = <1>;
+		status = "okay";
+	};
+};
+
+
+/*************************
+ * CLK_BUF DTSI File
+*************************/
+
+&rf_clock_buffer_ctrl {
+	mediatek,clkbuf-quantity = <4>;
+	mediatek,clkbuf-config = <>;
+	status = "okay";
+};
+
+
+/*************************
+ * I2C DTSI File
+*************************/
+
+&i2c0 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	clock-frequency = <400000>;
+	mediatek,use-open-drain;
+	camera_main@10 {
+		compatible = "mediatek,camera_main";
+		reg = <0x10>;
+		status = "okay";
+	};
+
+	camera_sub@36 {
+		compatible = "mediatek,camera_sub";
+		reg = <0x36>;
+		status = "okay";
+	};
+
+	camera_main_af@74 {
+		compatible = "mediatek,camera_main_af";
+		reg = <0x74>;
+		status = "okay";
+	};
+
+};
+
+&i2c1 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	clock-frequency = <400000>;
+	mediatek,use-open-drain;
+	cap_touch@70 {
+		compatible = "mediatek,cap_touch";
+		reg = <0x70>;
+		status = "okay";
+	};
+
+};
+
+&i2c2 {
+	#address-cells = <1>;
+	#size-cells = <0>;
+	clock-frequency = <400000>;
+	mediatek,use-open-drain;
+	gsensor@18 {
+		compatible = "mediatek,gsensor";
+		reg = <0x18>;
+		status = "okay";
+	};
+
+};
+
+
+
+/*************************
+ * GPIO DTSI File
+*************************/
+
+&gpio_usage_mapping {
+	GPIO_SIM1_SCLK = <22>;
+	GPIO_SIM1_SIO = <23>;
+	GPIO_SIM2_SIO = <24>;
+	GPIO_SIM2_SCLK = <25>;
+};
+
+
+/*************************
+ * EINT DTSI File
+*************************/
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+&eintc {
+	mediatek,mapping_table_entry = <26>;
+			/* <gpio_pin, eint_pin> */
+	mediatek,mapping_table = <0 0>,
+					<1 1>,
+					<2 2>,
+					<3 3>,
+					<4 4>,
+					<5 5>,
+					<6 6>,
+					<7 7>,
+					<8 8>,
+					<9 9>,
+					<10 10>,
+					<11 11>,
+					<12 12>,
+					<13 13>,
+					<14 14>,
+					<15 15>,
+					<16 16>,
+					<17 17>,
+					<18 18>,
+					<19 19>,
+					<20 20>,
+					<21 21>,
+					<22 22>,
+					<23 23>,
+					<24 24>,
+					<25 25>,
+					<26 26>,
+					<27 27>,
+					<28 28>,
+					<29 29>,
+					<30 30>,
+					<31 31>,
+					<32 32>,
+					<33 33>,
+					<34 34>,
+					<35 35>,
+					<36 36>,
+					<37 37>,
+					<38 38>,
+					<39 39>,
+					<40 40>,
+					<41 41>,
+					<42 42>,
+					<43 43>,
+					<44 44>,
+					<45 45>,
+					<46 46>,
+					<47 47>,
+					<48 48>,
+					<49 49>,
+					<50 50>,
+					<51 51>,
+					<52 52>,
+					<53 53>,
+					<54 54>,
+					<55 55>,
+					<56 56>,
+					<57 57>,
+					<58 58>,
+					<59 59>,
+					<60 60>,
+					<61 61>,
+					<62 62>,
+					<63 63>,
+					<64 64>,
+					<65 65>,
+					<66 66>,
+					<67 67>,
+					<68 68>,
+					<69 69>,
+					<70 70>,
+					<71 71>,
+					<72 72>,
+					<73 73>,
+					<74 74>,
+					<75 75>,
+					<76 76>,
+					<77 77>,
+					<78 78>,
+					<79 79>,
+					<80 80>,
+					<81 81>,
+					<82 82>,
+					<83 83>,
+					<84 84>,
+					<85 85>,
+					<86 86>,
+					<87 87>,
+					<88 88>,
+					<89 89>,
+					<90 90>,
+					<91 91>,
+					<92 92>;
+	mediatek,builtin_entry = <0>;
+};
+
+&msdc1_ins {
+	interrupt-parent = <&eintc>;
+	interrupts = <3 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <3 1000>;
+	status = "okay";
+};
+
+&touch {
+	interrupt-parent = <&eintc>;
+	interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
+	debounce = <5 0>;
+	status = "okay";
+};
+
+&accdet {
+	interrupt-parent = <&eintc>;
+	interrupts = <9 IRQ_TYPE_LEVEL_LOW>;
+	debounce = <9 256000>;
+	status = "okay";
+};
+
+&eint_dtv {
+	interrupt-parent = <&eintc>;
+	interrupts = <14 IRQ_TYPE_EDGE_FALLING>;
+	debounce = <14 0>;
+	status = "okay";
+};
+
+
+
+/*************************
+ * MD1_EINT DTSI File
+*************************/
+
+&eintc {
+};
+
+
+/*************************
+ * PMIC DTSI File
+*************************/
+
+&mt_pmic_vmc_ldo_reg {
+	regulator-name = "vmc";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vmch_ldo_reg {
+	regulator-name = "vmch";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vemc_3v3_ldo_reg {
+	regulator-name = "vemc3v3";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vgp1_ldo_reg {
+	regulator-name = "vgp1";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vgp2_ldo_reg {
+	regulator-name = "vgp2";
+	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_vcn_1v8_ldo_reg {
+	regulator-name = "vcn1v8";
+	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_vcamaf_ldo_reg {
+	regulator-name = "vcamaf";
+	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_vm_ldo_reg {
+	regulator-name = "vm";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vrf18_ldo_reg {
+	regulator-name = "vrf18";
+	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";
+};
+&mt_pmic_vcama_ldo_reg {
+	regulator-name = "vcama";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vcn33_wifi_ldo_reg {
+	regulator-name = "vcn33wifi";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+&mt_pmic_vcn28_ldo_reg {
+	regulator-name = "vcn28";
+	regulator-default-on = <0>; /* 0:skip, 1: off, 2:on */
+	status = "okay";
+};
+
+&kd_camera_hw1 {
+	vcamaf-supply = <&mt_pmic_vcamaf_ldo_reg>;
+	vcamaf_main2-supply = <&mt_pmic_vcamaf_ldo_reg>;
+	vcamaf_sub-supply = <&mt_pmic_vcamaf_ldo_reg>;
+	vcamd-supply = <&mt_pmic_vcamd_ldo_reg>;
+	vcamd_main2-supply = <&mt_pmic_vcamd_ldo_reg>;
+	vcamd_sub-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>;
+	vcama-supply = <&mt_pmic_vcama_ldo_reg>;
+	vcama_main2-supply = <&mt_pmic_vcama_ldo_reg>;
+	vcama_sub-supply = <&mt_pmic_vcama_ldo_reg>;
+	status = "okay";
+};
+
+&touch {
+	vtouch-supply = <&mt_pmic_vgp1_ldo_reg>;
+	status = "okay";
+};
+
+
+/*************************
+ * POWER DTSI File
+*************************/
+
+
+
+/*************************
+ * KPD DTSI File
+*************************/
+
+&keypad {
+	mediatek,kpd-key-debounce = <1024>;
+	mediatek,kpd-sw-pwrkey = <116>;
+	mediatek,kpd-hw-pwrkey = <8>;
+	mediatek,kpd-use-extend-type = <0>;
+	/*HW Keycode [0~71] -> Linux Keycode*/
+	mediatek,kpd-hw-map-num = <72>;
+	mediatek,kpd-hw-init-map = <115 0 0 0 0 0 0 0 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 >;
+	mediatek,kpd-pwrkey-eint-gpio = <0>;
+	mediatek,kpd-pwkey-gpio-din  = <0>;
+	mediatek,kpd-hw-dl-key0 = <9>;
+	mediatek,kpd-hw-dl-key1 = <0>;
+	mediatek,kpd-hw-dl-key2 = <8>;
+	mediatek,kpd-hw-recovery-key = <0>;
+	mediatek,kpd-hw-factory-key = <9>;
+	status = "okay";
+};
+
+
-- 
2.34.1

