From 812ded0d8d6800728c4c11abed7546d735449123 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Wed, 15 Feb 2023 09:14:04 +0000
Subject: [PATCH] add rk809 spk hp

---
 kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi |    2 
 kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi   |   46 +++++++++------
 kernel/drivers/misc/nkio/nkio.h                     |    6 +-
 kernel/drivers/misc/nkio/nk_io_core.c               |   71 ++++++++++++++++-------
 4 files changed, 83 insertions(+), 42 deletions(-)

diff --git a/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi b/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi
index 2c59a55..2342060 100755
--- a/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi
+++ b/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi
@@ -17,7 +17,7 @@
 
 	rk_headset: rk-headset {
 		compatible = "rockchip_headset";
-		headset_gpio = <&gpio3 RK_PC2 GPIO_ACTIVE_LOW>;
+		headset_gpio = <&gpio0 RK_PD5 GPIO_ACTIVE_LOW>;
 		pinctrl-names = "default";
 		pinctrl-0 = <&hp_det>;
 	};
@@ -32,15 +32,6 @@
 		vin-supply = <&vcc3v3_sys>;
 	};
 
-	vcc3v3_vga: vcc3v3-vga {
-		compatible = "regulator-fixed";
-		regulator-name = "vcc3v3_vga";
-		regulator-always-on;
-		regulator-boot-on;
-		gpio = <&gpio0 RK_PD5 GPIO_ACTIVE_HIGH>;
-		enable-active-high;
-		vin-supply = <&vcc3v3_sys>;
-	};
 
 	pcie30_avdd0v9: pcie30-avdd0v9 {
 		compatible = "regulator-fixed";
@@ -97,7 +88,7 @@
 
 	    nk_io_init {
                 compatible = "nk_io_control";
-				usb_en_oc_gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;  //USB_EN_OC_GPIO0_A5
+//				usb_en_oc_gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;  //USB_EN_OC_GPIO0_A5
 				lcd_bk_en_gpio = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>; //LCD0_BKLT_EN_3V3
 				lcd_pwblk_gpio = <&gpio0 RK_PB7 GPIO_ACTIVE_HIGH>;  //LCD0_BKLT_EN_3V3
 				vcc3_io_en_gpio = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>; //VCC3_IO_EN_GPIO0_C4_3V3
@@ -110,12 +101,14 @@
                 reset_4g_gpio = <&gpio1 RK_PB2 GPIO_ACTIVE_HIGH>; //4G_RST_GPIO01_B2_3V3
                 air_mode_4g_gpio = <&gpio1 RK_PB0 GPIO_ACTIVE_HIGH>; //4G_AIR_MODE_GPIO01_B0_3V3
                 wake_4g_gpio = <&gpio1 RK_PB1 GPIO_ACTIVE_HIGH>; //4G_WAKEUP_GPIO01_B1_3V3
-                
+				hp_en_gpio = <&gpio3 RK_PA6 GPIO_ACTIVE_HIGH>;//HP_EN_GPIO3_A6_3V3
+                spk_out_gpio = <&gpio4 RK_PC2 GPIO_ACTIVE_HIGH>;//AMP_SD_GPIO4_C2_3V3
+				
 				edp_enable_gpio = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>;
-                edp_gpio0 = <&gpio3 RK_PD2 GPIO_ACTIVE_LOW>; //7511_GPIO0-GPIO3_D2
-				edp_gpio1 = <&gpio3 RK_PD3 GPIO_ACTIVE_LOW>; //7511_GPIO1-GPIO3_D3
-				edp_gpio2 = <&gpio3 RK_PD4 GPIO_ACTIVE_LOW>; //7511_GPIO2-GPIO3_D4
-				edp_gpio3 = <&gpio3 RK_PD5 GPIO_ACTIVE_LOW>; //7511_GPIO3-GPIO3_D5
+                edp_gpio0 = <&gpio3 RK_PD2 GPIO_ACTIVE_HIGH>; //7511_GPIO0-GPIO3_D2
+				edp_gpio1 = <&gpio3 RK_PD3 GPIO_ACTIVE_HIGH>; //7511_GPIO1-GPIO3_D3
+				edp_gpio2 = <&gpio3 RK_PD4 GPIO_ACTIVE_HIGH>; //7511_GPIO2-GPIO3_D4
+				edp_gpio3 = <&gpio3 RK_PD5 GPIO_ACTIVE_HIGH>; //7511_GPIO3-GPIO3_D5
                 edp_reset = <&gpio3 RK_PD1 GPIO_ACTIVE_LOW>; //7511_RST_GPIO3_D1
 //              tp_reset = <&gpio3 RK_PA7 GPIO_ACTIVE_HIGH>;
 //              vddio_mipi = <&gpio1 RK_PA4 GPIO_ACTIVE_HIGH>;
@@ -434,7 +427,7 @@
 //	};
 	headphone {
 		hp_det: hp-det {
-			rockchip,pins = <3 RK_PC2 RK_FUNC_GPIO &pcfg_pull_down>;
+			rockchip,pins = <0 RK_PD5 RK_FUNC_GPIO &pcfg_pull_down>;
 		};
 	};
 
@@ -451,7 +444,24 @@
 	};
 	nk_io_init{
 		nk_io_gpio: nk-io-gpio{
-            rockchip,pins = <0 RK_PC6 RK_FUNC_GPIO &pcfg_pull_up>;
+			rockchip,pins = <0 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
+							<0 RK_PB7 RK_FUNC_GPIO &pcfg_pull_none>,
+							<0 RK_PC4 RK_FUNC_GPIO &pcfg_pull_none>,
+							<4 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>,
+							<4 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>,
+							<1 RK_PA4 RK_FUNC_GPIO &pcfg_pull_none>,
+							<0 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>,
+							<1 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>,
+							<1 RK_PB0 RK_FUNC_GPIO &pcfg_pull_none>,
+							<1 RK_PB1 RK_FUNC_GPIO &pcfg_pull_none>,
+							<3 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>,
+							<4 RK_PC2 RK_FUNC_GPIO &pcfg_pull_none>,
+							<3 RK_PD2 RK_FUNC_GPIO &pcfg_pull_none>,
+							<3 RK_PD3 RK_FUNC_GPIO &pcfg_pull_none>,
+							<3 RK_PD4 RK_FUNC_GPIO &pcfg_pull_none>,
+							<3 RK_PD5 RK_FUNC_GPIO &pcfg_pull_none>,
+							<3 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>,
+							<0 RK_PC6 RK_FUNC_GPIO &pcfg_pull_none>;
 		};
 	};
 };
diff --git a/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi b/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
index 83cde4b..dec6b3a 100755
--- a/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
+++ b/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
@@ -273,6 +273,8 @@
 	vcc5v0_otg: vcc5v0-otg-regulator {
 		compatible = "regulator-fixed";
 		regulator-name = "vcc5v0_otg";
+		egulator-boot-on;
+		regulator-always-on;
 		regulator-min-microvolt = <5000000>;
 		regulator-max-microvolt = <5000000>;
 		enable-active-high;
diff --git a/kernel/drivers/misc/nkio/nk_io_core.c b/kernel/drivers/misc/nkio/nk_io_core.c
index 46e2120..4193df9 100755
--- a/kernel/drivers/misc/nkio/nk_io_core.c
+++ b/kernel/drivers/misc/nkio/nk_io_core.c
@@ -139,27 +139,6 @@
         }
 
 
-	//usb_en_oc_gpio
-	ret = of_get_named_gpio_flags(node, "usb_en_oc_gpio", 0, &flags);
-	if (ret < 0) {
-		printk("%s() Can not read property usb_en_oc_gpio\n", __FUNCTION__);
-		goto err;
-	} else {
-		pdata->usb_en_oc_gpio = ret;
-		gpio_free(ret);
-		ret = devm_gpio_request(&pdev->dev, pdata->usb_en_oc_gpio, "usb_en_oc_gpio");
-		if (ret < 0){
-			printk("%s() devm_gpio_request usb_en_oc_gpio request ERROR\n", __FUNCTION__);
-			goto err;
-		}
-
-		ret = gpio_direction_output(pdata->usb_en_oc_gpio,1); 
-		if(ret < 0){
-			printk("%s() gpio_direction_input usb_en_oc_gpio set ERROR\n", __FUNCTION__);
-			goto err;
-		}
-	}
-
 	//hub_host2_5V_rest_gpio
 	ret = of_get_named_gpio_flags(node, "hub_host2_5V_rest_gpio", 0, &flags);
 	if (ret < 0) {
@@ -292,7 +271,57 @@
 	           }
 	   }
 
+	   //hp_en_gpio
+	   ret = of_get_named_gpio_flags(node, "hp_en_gpio", 0, &flags);
+	   if (ret < 0) {
+	           printk("%s() Can not read property hp_en_gpio\n", __FUNCTION__);
+	   } else {
+	           pdata->hp_en_gpio = ret;
 
+	           ret = devm_gpio_request(&pdev->dev, pdata->hp_en_gpio, "hp_en_gpio");
+	           if(ret < 0){
+	                   printk("%s() devm_gpio_request hp_en_gpio request ERROR\n", __FUNCTION__);
+	           }
+	           ret = gpio_direction_output(pdata->hp_en_gpio,1);
+	           if(ret < 0){
+	                   printk("%s() gpio_direction_output hp_en_gpio set ERROR\n", __FUNCTION__);
+	           }
+	   }
+	   
+	      //wifi_power_en_gpio
+	   ret = of_get_named_gpio_flags(node, "wifi_power_en_gpio", 0, &flags);
+	   if (ret < 0) {
+	           printk("%s() Can not read property wifi_power_en_gpio\n", __FUNCTION__);
+	   } else {
+	           pdata->wifi_power_en_gpio = ret;
+
+	           ret = devm_gpio_request(&pdev->dev, pdata->wifi_power_en_gpio, "wifi_power_en_gpio");
+	           if(ret < 0){
+	                   printk("%s() devm_gpio_request wifi_power_en_gpio request ERROR\n", __FUNCTION__);
+	           }
+	           ret = gpio_direction_output(pdata->wifi_power_en_gpio,1);
+	           if(ret < 0){
+	                   printk("%s() gpio_direction_output wifi_power_en_gpio set ERROR\n", __FUNCTION__);
+	           }
+	   }
+
+
+	      //spk_out_gpio
+	   ret = of_get_named_gpio_flags(node, "spk_out_gpio", 0, &flags);
+	   if (ret < 0) {
+	           printk("%s() Can not read property spk_out_gpio\n", __FUNCTION__);
+	   } else {
+	           pdata->spk_out_gpio = ret;
+
+	           ret = devm_gpio_request(&pdev->dev, pdata->spk_out_gpio, "spk_out_gpio");
+	           if(ret < 0){
+	                   printk("%s() devm_gpio_request spk_out_gpio request ERROR\n", __FUNCTION__);
+	           }
+	           ret = gpio_direction_output(pdata->spk_out_gpio,0);
+	           if(ret < 0){
+	                   printk("%s() gpio_direction_output spk_out_gpio set ERROR\n", __FUNCTION__);
+	           }
+	   }
 	   //air_mode_4g_gpio
 	   ret = of_get_named_gpio_flags(node, "air_mode_4g_gpio", 0, &flags);
 	   if (ret < 0) {
diff --git a/kernel/drivers/misc/nkio/nkio.h b/kernel/drivers/misc/nkio/nkio.h
index e94e17f..1693957 100755
--- a/kernel/drivers/misc/nkio/nkio.h
+++ b/kernel/drivers/misc/nkio/nkio.h
@@ -7,8 +7,8 @@
 	unsigned int vcc_3_3v_io;
 	unsigned int vcc_12v_io;
 	unsigned int usb_5v_gpio;
-	//unsigned int hub_5V_rest_gpio;
-	//unsigned int hub_5V_gpio;
+	unsigned int wifi_power_en_gpio;
+	unsigned int hp_en_gpio;
 	unsigned int led_gpio;
 	unsigned int mic_switch_gpio;
 	unsigned int audio_switch_gpio;
@@ -27,7 +27,7 @@
 	unsigned int hub_host3_5v_gpio; 
 	unsigned int edp_power_supply_gpio;
 	unsigned int edp_enable_gpio;
-   	unsigned int tp_enable;
+   	unsigned int spk_out_gpio;
 	unsigned int vddio_mipi;
 //    unsigned int tp_reset;
 };

--
Gitblit v1.6.2