From 557c24d082b6ecb9bfe5407b77ae43fa7650a5dc Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 17 Feb 2023 11:02:20 +0000
Subject: [PATCH] add eDP LVDS PCIE WIFI6
---
lcdparamservice/lcd_parameters/LVDS/21.5_LVDS_1920x1080 | 25
lcdparamservice/lcd_parameters/eDP/12.5_eDP_1366x768 | 25
kernel/arch/arm64/boot/dts/rockchip/rk3568.dtsi | 10
lcdparamservice/lcd_parameters/LVDS/12.1_LVDS_1024x768 | 25
lcdparamservice/lcdparamservice | 0
kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi | 176 ++++-
lcdparamservice/lcd_parameters/LVDS/18.5_LVDS_1366x768 | 25
lcdparamservice/lcd_parameters/LVDS/17_LVDS_1280x1024 | 25
lcdparamservice/lcd_parameters/LVDS/23.8_LVDS_1920x1080 | 25
lcdparamservice/lcd_parameters/eDP/12.5_eDP_1920x1080 | 25
lcdparamservice/lcdparamservice.c | 547 +++++++++++++++++
lcdparamservice/lcd_parameters/LVDS/15_LVDS_1024X768 | 25
kernel/drivers/misc/nkio/nk_io_core.c | 102 +-
kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi | 28
lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080_NV156FHM | 25
lcdparamservice/lcd_parameters/eDP/13.3_eDP_1920x1080 | 25
lcdparamservice/lcd_parameters/LVDS/19_LVDS_1280x1024 | 25
kernel/drivers/misc/nkio/nkio.h | 2
rtl8852be | 0
lcdparamservice/lcd_parameters/LVDS/21.8_LVDS_1920x1080 | 25
u-boot/arch/arm/mach-rockchip/kernel_dtb.c | 497 +++++++++++++++
lcdparamservice/lcd_parameters/LVDS/10.1_LVDS_1280x800 | 25
lcdparamservice/lcd_parameters/LVDS/19_LVDS_1400x900 | 25
lcdparamservice/lcd_parameters/LVDS/8_LVDS_800x600 | 25
u-boot/drivers/video/drm/rockchip_panel.c | 99 ++
lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080 | 25
lcdparamservice/chglcd.sh | 28
27 files changed, 1,759 insertions(+), 130 deletions(-)
diff --git a/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi b/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi
index 9424547..69afddb 100755
--- a/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi
+++ b/kernel/arch/arm64/boot/dts/rockchip/NK-R36S0.dtsi
@@ -8,6 +8,7 @@
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>
+#include <dt-bindings/display/media-bus-format.h>
#include "rk3568.dtsi"
#include "rk3568-evb.dtsi"
@@ -58,7 +59,9 @@
regulator-name = "vcc3v3_pcie";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
+ regulator-always-on;
enable-active-high;
+ regulator-boot-on;
gpio = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>;
startup-delay-us = <5000>;
vin-supply = <&dc_12v>;
@@ -88,13 +91,9 @@
nk_io_init {
compatible = "nk_io_control";
-// 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
hub_host2_5V_rest_gpio = <&gpio4 RK_PD2 GPIO_ACTIVE_HIGH>; //HUB_RST_GPIO4_D2_3V3
hub_host3_5v_gpio = <&gpio4 RK_PB2 GPIO_ACTIVE_HIGH>; //HOST3_EN_GPIO4_B2_1V8
-// hub_host3_5V_rest_gpio = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>;
vcc_5v_io = <&gpio1 RK_PA4 GPIO_ACTIVE_HIGH>; //VCC5_IO_EN_GPIO1_A4_3V3
vcc_12v_io = <&gpio0 RK_PC7 GPIO_ACTIVE_HIGH>; //VCC12_IO_EN_GPIO0_C7_3V3
en_4g_gpio = <&gpio0 RK_PC6 GPIO_ACTIVE_HIGH>; //4G_PWREN_H_GPIO0_C6
@@ -102,23 +101,55 @@
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_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>;
-
+ spk_out_gpio = <&gpio4 RK_PC2 GPIO_ACTIVE_HIGH>;//AMP_SD_GPIO4_C2_3V3
wifi_power_en_gpio = <&gpio3 RK_PC6 GPIO_ACTIVE_HIGH>; //WIFI_PWREN_GPIO3_C6_1V8
-
+// pcie_power_en_gpio = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>;//PCIE_PWREN_H_GPIO0_D4
pinctrl-names = "default";
- pinctrl-0 = <&nk_io_gpio>;
- nodka_lvds = <9>;
+ pinctrl-0 = <&nk_io_gpio>;
};
+
+ panel: panel {
+ compatible = "simple-panel";
+ backlight = <&backlight>;
+ power-supply = <&vcc3v3_lcd0_n>;
+ enable-gpios = <&gpio2 RK_PD4 GPIO_ACTIVE_HIGH>; //LCD0_VDD_H_GPIO2_D4
+ reset-gpios = <&gpio3 RK_PD1 GPIO_ACTIVE_LOW>; //7511_RST_GPIO3_D1
+ edp-bl-gpios = <&gpio0 RK_PB7 GPIO_ACTIVE_HIGH>; //LCD0_BKLT_EN_3V3
+ edp-bl-en = <&gpio0 RK_PB0 GPIO_ACTIVE_HIGH>; //LCD0_BKLT_EN_3V3
+ bus-format = <MEDIA_BUS_FMT_RGB888_1X24>;
+ bpc = <8>;
+ prepare-delay-ms = <200>;
+ enable-delay-ms = <20>;
+ lvds-gpio0 = <&gpio3 RK_PD2 GPIO_ACTIVE_HIGH>; //7511_GPIO0-GPIO3_D2
+ lvds-gpio1 = <&gpio3 RK_PD3 GPIO_ACTIVE_HIGH>; //7511_GPIO1-GPIO3_D3
+ lvds-gpio2 = <&gpio3 RK_PD4 GPIO_ACTIVE_HIGH>; //7511_GPIO2-GPIO3_D4
+ lvds-gpio3 = <&gpio3 RK_PD5 GPIO_ACTIVE_HIGH>; //7511_GPIO3-GPIO3_D5
+ nodka-lvds = <9>;
+
+ display-timings {
+ native-mode = <&timing0>;
+ timing0: timing0 {
+ clock-frequency = <142300000>;
+ hactive = <1920>;
+ vactive = <1080>;
+ hfront-porch = <48>;
+ hsync-len = <32>;
+ hback-porch = <100>;
+ vfront-porch = <7>;
+ vsync-len = <20>;
+ vback-porch = <23>;
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <0>;
+ pixelclk-active = <0>;
+ };
+ };
+ ports {
+ panel_in: endpoint {
+ remote-endpoint = <&edp_out>;
+ };
+ };
+ };
};
&combphy0_us {
@@ -134,11 +165,11 @@
};
&csi2_dphy_hw {
- status = "okay";
+ status = "disabled";
};
&csi2_dphy0 {
- status = "okay";
+ status = "disabled";
ports {
#address-cells = <1>;
@@ -181,8 +212,12 @@
* video_phy0 needs to be enabled
* when dsi0 is enabled
*/
+&video_phy0 {
+ status = "disabled";
+};
+
&dsi0 {
- status = "okay";
+ status = "disabled";
};
&dsi0_in_vp0 {
@@ -190,7 +225,7 @@
};
&dsi0_in_vp1 {
- status = "okay";
+ status = "disabled";
};
&dsi0_panel {
@@ -201,6 +236,10 @@
* video_phy1 needs to be enabled
* when dsi1 is enabled
*/
+
+&video_phy1 {
+ status = "disabled";
+};
&dsi1 {
status = "disabled";
};
@@ -217,22 +256,82 @@
power-supply = <&vcc3v3_lcd1_n>;
};
+/*
+* edp_start
+*/
+
&edp {
- hpd-gpios = <&gpio0 RK_PC2 GPIO_ACTIVE_HIGH>;
- status = "okay";
+ force-hpd;
+ status = "okay";
+ ports {
+ port@1 {
+ reg = <1>;
+ edp_out: endpoint {
+ remote-endpoint = <&panel_in>;
+ };
+ };
+ };
};
&edp_phy {
- status = "okay";
+ status = "okay";
};
&edp_in_vp0 {
- status = "okay";
+ status = "disabled";
};
&edp_in_vp1 {
+ status = "okay";
+};
+
+&route_edp {
+ status = "okay";
+ connect = <&vp1_out_edp>;
+};
+
+&route_edp {
+ status = "okay";
+};
+/*
+* edp_end
+*/
+
+/*
+* Hdmi_start
+*/
+
+&hdmi {
+ status = "okay";
+ rockchip,phy-table =
+ <92812500 0x8009 0x0000 0x0270>,
+ <165000000 0x800b 0x0000 0x026d>,
+ <185625000 0x800b 0x0000 0x01ed>,
+ <297000000 0x800b 0x0000 0x01ad>,
+ <594000000 0x8029 0x0000 0x0088>,
+ <000000000 0x0000 0x0000 0x0000>;
+};
+
+&route_hdmi {
+ status = "okay";
+ connect = <&vp0_out_hdmi>;
+};
+
+&hdmi_in_vp0 {
+ status = "okay";
+};
+
+&hdmi_in_vp1 {
status = "disabled";
};
+
+&hdmi_sound {
+ status = "okay";
+};
+
+/*
+ * Hdmi_END
+*/
&gmac0 {
phy-mode = "rgmii";
@@ -409,20 +508,14 @@
};
};
-&video_phy0 {
- status = "okay";
-};
-&video_phy1 {
- status = "disabled";
-};
&pcie30phy {
status = "okay";
};
-&pcie3x2 {
- reset-gpios = <&gpio2 RK_PD6 GPIO_ACTIVE_HIGH>;
+&pcie2x1 {
+ reset-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_HIGH>;
vpcie3v3-supply = <&vcc3v3_pcie>;
status = "okay";
};
@@ -477,15 +570,15 @@
};
&rkisp {
- status = "okay";
+ status = "disabled";
};
&rkisp_mmu {
- status = "okay";
+ status = "disabled";
};
&rkisp_vir0 {
- status = "okay";
+ status = "disabled";
port {
#address-cells = <1>;
@@ -499,14 +592,11 @@
};
&route_dsi0 {
- status = "okay";
+ status = "disabled";
connect = <&vp1_out_dsi0>;
};
-&route_edp {
- status = "okay";
- connect = <&vp0_out_edp>;
-};
+
&sata2 {
status = "okay";
@@ -545,7 +635,7 @@
};
&vcc3v3_lcd0_n {
- gpio = <&gpio2 RK_PD4 GPIO_ACTIVE_HIGH>;
+ gpio = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>;
enable-active-high;
};
diff --git a/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi b/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
index 4b2aae0..ea2fb31 100755
--- a/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
+++ b/kernel/arch/arm64/boot/dts/rockchip/rk3568-evb.dtsi
@@ -291,7 +291,7 @@
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
enable-active-high;
- gpio = <&gpio2 RK_PD4 GPIO_ACTIVE_HIGH>;
+ gpio = <&gpio0 RK_PC4 GPIO_ACTIVE_HIGH>; //VCC3_IO_EN_GPIO0_C4_3V3
vin-supply = <&vcc3v3_sys>;
regulator-state-mem {
@@ -1070,28 +1070,7 @@
status = "okay";
};
-&hdmi {
- status = "okay";
- rockchip,phy-table =
- <92812500 0x8009 0x0000 0x0270>,
- <165000000 0x800b 0x0000 0x026d>,
- <185625000 0x800b 0x0000 0x01ed>,
- <297000000 0x800b 0x0000 0x01ad>,
- <594000000 0x8029 0x0000 0x0088>,
- <000000000 0x0000 0x0000 0x0000>;
-};
-&hdmi_in_vp0 {
- status = "okay";
-};
-
-&hdmi_in_vp1 {
- status = "disabled";
-};
-
-&hdmi_sound {
- status = "okay";
-};
&i2c0 {
status = "okay";
@@ -1691,10 +1670,7 @@
status = "okay";
};
-&route_hdmi {
- status = "okay";
- connect = <&vp0_out_hdmi>;
-};
+
&saradc {
status = "okay";
diff --git a/kernel/arch/arm64/boot/dts/rockchip/rk3568.dtsi b/kernel/arch/arm64/boot/dts/rockchip/rk3568.dtsi
index bd07a1e..90c1e53 100755
--- a/kernel/arch/arm64/boot/dts/rockchip/rk3568.dtsi
+++ b/kernel/arch/arm64/boot/dts/rockchip/rk3568.dtsi
@@ -256,20 +256,20 @@
connect = <&vp0_out_dsi1>;
};
route_edp: route-edp {
- status = "disabled";
+ status = "okay";
logo,uboot = "logo.bmp";
logo,kernel = "logo_kernel.bmp";
logo,mode = "center";
charge_logo,mode = "center";
- connect = <&vp0_out_edp>;
+ connect = <&vp1_out_edp>;
};
route_hdmi: route-hdmi {
- status = "disabled";
+ status = "okay";
logo,uboot = "logo.bmp";
logo,kernel = "logo_kernel.bmp";
logo,mode = "center";
charge_logo,mode = "center";
- connect = <&vp1_out_hdmi>;
+ connect = <&vp0_out_hdmi>;
};
route_lvds: route-lvds {
status = "disabled";
@@ -2397,7 +2397,7 @@
reg-names = "pcie-dbi", "pcie-apb";
resets = <&cru SRST_PCIE20_POWERUP>;
reset-names = "pipe";
- status = "disabled";
+ status = "okay";
pcie2x1_intc: legacy-interrupt-controller {
interrupt-controller;
diff --git a/kernel/drivers/misc/nkio/nk_io_core.c b/kernel/drivers/misc/nkio/nk_io_core.c
index e084fb3..b9db2bd 100755
--- a/kernel/drivers/misc/nkio/nk_io_core.c
+++ b/kernel/drivers/misc/nkio/nk_io_core.c
@@ -61,11 +61,8 @@
{
struct device_node *node = pdev->dev.of_node;
struct nk_io_pdata *pdata;
- int gpio0, gpio1, gpio2, gpio3, reset_pin, ch342_reset;
int ret;
- int lvds_index;
- int i=0;
- static int lvds_gpio[4] ;
+
enum of_gpio_flags flags;
@@ -97,7 +94,7 @@
goto err;
}
}
-
+#if 0
//vcc3_io_en_gpio
ret = of_get_named_gpio_flags(node, "vcc3_io_en_gpio", 0, &flags);
if (ret < 0) {
@@ -117,7 +114,7 @@
goto err;
}
}
-
+#endif
//vcc_12v_io
ret = of_get_named_gpio_flags(node, "vcc_12v_io", 0, &flags);
if (ret < 0) {
@@ -287,7 +284,24 @@
printk("%s() gpio_direction_output hp_en_gpio set ERROR\n", __FUNCTION__);
}
}
-
+#if 0
+ //pcie_power_en_gpio
+ ret = of_get_named_gpio_flags(node, "pcie_power_en_gpio", 0, &flags);
+ if (ret < 0) {
+ printk("%s() Can not read property pcie_power_en_gpio\n", __FUNCTION__);
+ } else {
+ pdata->pcie_power_en_gpio = ret;
+
+ ret = devm_gpio_request(&pdev->dev, pdata->pcie_power_en_gpio, "pcie_power_en_gpio");
+ if(ret < 0){
+ printk("%s() devm_gpio_request pcie_power_en_gpio request ERROR\n", __FUNCTION__);
+ }
+ ret = gpio_direction_output(pdata->pcie_power_en_gpio,1);
+ if(ret < 0){
+ printk("%s() gpio_direction_output pcie_power_en_gpio set ERROR\n", __FUNCTION__);
+ }
+ }
+#endif
//wifi_power_en_gpio
ret = of_get_named_gpio_flags(node, "wifi_power_en_gpio", 0, &flags);
if (ret < 0) {
@@ -377,24 +391,42 @@
}
}
- //ch342_enable-gpio;
- ret = of_get_named_gpio_flags(node, "ch342_power", 0, &flags);
+ //lcd_bk_en_gpio;
+ ret = of_get_named_gpio_flags(node, "lcd_bk_en_gpio", 0, &flags);
if (ret < 0) {
- printk("%s() Can not read property ch342_gpio\n", __FUNCTION__);
+ printk("%s() Can not read property lcd_bk_en_gpio\n", __FUNCTION__);
} else {
- pdata->ch342_power = ret;
+ pdata->lcd_bk_en_gpio = ret;
- ret = devm_gpio_request(&pdev->dev, pdata->ch342_power, "ch342_power");
+ ret = devm_gpio_request(&pdev->dev, pdata->lcd_bk_en_gpio, "lcd_bk_en_gpio");
if(ret < 0){
- printk("%s() devm_gpio_request ch342_power request ERROR\n", __FUNCTION__);
+ printk("%s() devm_gpio_request lcd_bk_en_gpio request ERROR\n", __FUNCTION__);
}
- ret = gpio_direction_output(pdata->ch342_power,1);
+ ret = gpio_direction_output(pdata->lcd_bk_en_gpio,1);
if(ret < 0){
- printk("%s() gpio_direction_input ch342_power set ERROR\n", __FUNCTION__);
+ printk("%s() gpio_direction_output lcd_bk_en_gpio set ERROR\n", __FUNCTION__);
}
}
-*/
+
+ //lcd_pwblk_gpio;
+ ret = of_get_named_gpio_flags(node, "lcd_pwblk_gpio", 0, &flags);
+ if (ret < 0) {
+ printk("%s() Can not read property lcd_pwblk_gpio\n", __FUNCTION__);
+ } else {
+ pdata->lcd_pwblk_gpio = ret;
+
+ ret = devm_gpio_request(&pdev->dev, pdata->lcd_pwblk_gpio, "lcd_pwblk_gpio");
+ if(ret < 0){
+ printk("%s() devm_gpio_request lcd_pwblk_gpio request ERROR\n", __FUNCTION__);
+ }
+
+ ret = gpio_direction_output(pdata->lcd_pwblk_gpio,1);
+ if(ret < 0){
+ printk("%s() gpio_direction_output lcd_pwblk_gpio set ERROR\n", __FUNCTION__);
+ }
+ }
+
//edp_set_pixel-s
ret = of_get_named_gpio_flags(node, "edp_reset", 0, &flags);
@@ -498,6 +530,12 @@
gpio_direction_output(gpio2, lvds_gpio[2]);
gpio_direction_output(gpio3, lvds_gpio[3]);
+
+ gpio_direction_output(reset_pin, 0);
+ usleep_range(80000, 100000);
+ gpio_direction_output(reset_pin, 1);
+ usleep_range(80000, 100000);
+*/
printk(" #######nk_io_control_probe end####### \n");
return 0;
@@ -542,38 +580,6 @@
static int nk_io_control_resume(struct platform_device *pdev)
{
- int ret,reset_pin;
- printk("nk_io resume !!!!\n");
- ret = gpio_get_value(120);
-
-#if 0
- gpio_set_value(8,1);
- ret = gpio_get_value(8);
- printk("vcc12v gpio value : %d\n",ret);
-#endif
-#if 0
- gpio_set_value(15,1);
- ret = gpio_get_value(15);
- printk("edp_en gpio value : %d\n",ret);
- gpio_set_value(21,1);
- ret = gpio_get_value(21);
- printk("hub_host3_5v_gpio value : %d\n",ret);
-#endif
-#if 0
- usleep_range(80000, 100000);
- gpio_set_value(120,0);
-// gpio_direction_output(120, 0);
- usleep_range(80000, 100000);
- ret = gpio_get_value(120);
- printk("edp_reset gpio value : %d\n",ret);
-// gpio_direction_output(120, 1);
- gpio_set_value(120,1);
- usleep_range(80000, 100000);
- ret = gpio_get_value(120);
- printk("edp_reset gpio value : %d\n",ret);
-#endif
- //enable = 1;
- //LED_SET(11);
return 0;
}
diff --git a/kernel/drivers/misc/nkio/nkio.h b/kernel/drivers/misc/nkio/nkio.h
index 1693957..b4c9557 100755
--- a/kernel/drivers/misc/nkio/nkio.h
+++ b/kernel/drivers/misc/nkio/nkio.h
@@ -28,7 +28,7 @@
unsigned int edp_power_supply_gpio;
unsigned int edp_enable_gpio;
unsigned int spk_out_gpio;
- unsigned int vddio_mipi;
+ unsigned int pcie_power_en_gpio;
// unsigned int tp_reset;
};
diff --git a/lcdparamservice/chglcd.sh b/lcdparamservice/chglcd.sh
new file mode 100755
index 0000000..99d7fea
--- /dev/null
+++ b/lcdparamservice/chglcd.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+CONFIG_PATH="/root/.config/nodka_lcd/lcd.config"
+EDP_PARMFILE_PATH="/nodka_test/lcd_parameters/eDP/"
+LVDS_PARMFILE_PATH="/nodka_test/lcd_parameters/LVDS/"
+
+choose_button=$(grep choose_button $CONFIG_PATH)
+choose_button=${choose_button:14}
+echo $choose_button
+
+edp_type=$(grep edp_type $CONFIG_PATH)
+edp_type=${edp_type:9}
+echo $edp_type
+
+lvds_type=$(grep lvds_type $CONFIG_PATH)
+lvds_type=${lvds_type:10}
+echo $lvds_type
+
+if [[ $choose_button = "button_eDP" ]];then
+ cp $EDP_PARMFILE_PATH$edp_type /nodka_test/nodka_lcd
+else
+ cp $LVDS_PARMFILE_PATH$lvds_type /nodka_test/nodka_lcd
+fi
+sync
+
+
+lcdparamservice
+
+
diff --git a/lcdparamservice/lcd_parameters/LVDS/10.1_LVDS_1280x800 b/lcdparamservice/lcd_parameters/LVDS/10.1_LVDS_1280x800
new file mode 100755
index 0000000..d9e58d1
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/10.1_LVDS_1280x800
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 72500000;
+hactive = 1280;
+hfront-porch = 70;
+hsync-len = 72;
+hback-porch = 160;
+vactive = 800;
+vfront-porch = 4;
+vsync-len = 21;
+vback-porch = 42;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 15;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/12.1_LVDS_1024x768 b/lcdparamservice/lcd_parameters/LVDS/12.1_LVDS_1024x768
new file mode 100755
index 0000000..4140687
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/12.1_LVDS_1024x768
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 70000000;
+hactive = 1024;
+hfront-porch = 58;
+hsync-len = 320;
+hback-porch = 44;
+vactive = 768;
+vfront-porch = 3;
+vsync-len = 15;
+vback-porch = 38;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 13;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/15_LVDS_1024X768 b/lcdparamservice/lcd_parameters/LVDS/15_LVDS_1024X768
new file mode 100755
index 0000000..4a68b67
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/15_LVDS_1024X768
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 70000000;
+hactive = 1024;
+hfront-porch = 48;
+hsync-len = 320;
+hback-porch = 44;
+vactive = 768;
+vfront-porch = 3;
+vsync-len = 15;
+vback-porch = 38;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 13;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/17_LVDS_1280x1024 b/lcdparamservice/lcd_parameters/LVDS/17_LVDS_1280x1024
new file mode 100755
index 0000000..3d3f70c
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/17_LVDS_1280x1024
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 107900000;
+hactive = 1280;
+hfront-porch = 96;
+hsync-len = 160;
+hback-porch = 408;
+vactive = 1024;
+vfront-porch = 7;
+vsync-len = 19;
+vback-porch = 42;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 12;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/18.5_LVDS_1366x768 b/lcdparamservice/lcd_parameters/LVDS/18.5_LVDS_1366x768
new file mode 100755
index 0000000..19c716c
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/18.5_LVDS_1366x768
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 78000000;
+hactive = 1366;
+hfront-porch = 28;
+hsync-len = 40;
+hback-porch = 240;
+vactive = 768;
+vfront-porch = 3;
+vsync-len = 17;
+vback-porch = 40;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 11;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/19_LVDS_1280x1024 b/lcdparamservice/lcd_parameters/LVDS/19_LVDS_1280x1024
new file mode 100755
index 0000000..3d3f70c
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/19_LVDS_1280x1024
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 107900000;
+hactive = 1280;
+hfront-porch = 96;
+hsync-len = 160;
+hback-porch = 408;
+vactive = 1024;
+vfront-porch = 7;
+vsync-len = 19;
+vback-porch = 42;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 12;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/19_LVDS_1400x900 b/lcdparamservice/lcd_parameters/LVDS/19_LVDS_1400x900
new file mode 100755
index 0000000..89b9488
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/19_LVDS_1400x900
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 91000000;
+hactive = 1440;
+hfront-porch = 20;
+hsync-len = 60;
+hback-porch = 160;
+vactive = 900;
+vfront-porch = 6;
+vsync-len = 16;
+vback-porch = 48;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 7;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/21.5_LVDS_1920x1080 b/lcdparamservice/lcd_parameters/LVDS/21.5_LVDS_1920x1080
new file mode 100755
index 0000000..9890330
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/21.5_LVDS_1920x1080
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 142300000;
+hactive = 1980;
+hfront-porch = 48;
+hsync-len = 80;
+hback-porch = 180;
+vactive = 1080;
+vfront-porch = 7;
+vsync-len = 27;
+vback-porch = 50;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 9;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/21.8_LVDS_1920x1080 b/lcdparamservice/lcd_parameters/LVDS/21.8_LVDS_1920x1080
new file mode 100755
index 0000000..9890330
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/21.8_LVDS_1920x1080
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 142300000;
+hactive = 1980;
+hfront-porch = 48;
+hsync-len = 80;
+hback-porch = 180;
+vactive = 1080;
+vfront-porch = 7;
+vsync-len = 27;
+vback-porch = 50;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 9;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/23.8_LVDS_1920x1080 b/lcdparamservice/lcd_parameters/LVDS/23.8_LVDS_1920x1080
new file mode 100755
index 0000000..9890330
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/23.8_LVDS_1920x1080
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 142300000;
+hactive = 1980;
+hfront-porch = 48;
+hsync-len = 80;
+hback-porch = 180;
+vactive = 1080;
+vfront-porch = 7;
+vsync-len = 27;
+vback-porch = 50;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 9;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/LVDS/8_LVDS_800x600 b/lcdparamservice/lcd_parameters/LVDS/8_LVDS_800x600
new file mode 100755
index 0000000..c2e09dc
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/LVDS/8_LVDS_800x600
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 40000000;
+hactive = 800;
+hfront-porch = 4;
+hsync-len = 214;
+hback-porch = 260;
+vactive = 600;
+vfront-porch = 4;
+vsync-len = 16;
+vback-porch = 39;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 6;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/eDP/12.5_eDP_1366x768 b/lcdparamservice/lcd_parameters/eDP/12.5_eDP_1366x768
new file mode 100755
index 0000000..29a546f
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/eDP/12.5_eDP_1366x768
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 78000000;
+hactive = 1366;
+hfront-porch = 28;
+hsync-len = 40;
+hback-porch = 140;
+vactive = 768;
+vfront-porch = 3;
+vsync-len = 17;
+vback-porch = 40;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 11;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/eDP/12.5_eDP_1920x1080 b/lcdparamservice/lcd_parameters/eDP/12.5_eDP_1920x1080
new file mode 100755
index 0000000..9890330
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/eDP/12.5_eDP_1920x1080
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 142300000;
+hactive = 1980;
+hfront-porch = 48;
+hsync-len = 80;
+hback-porch = 180;
+vactive = 1080;
+vfront-porch = 7;
+vsync-len = 27;
+vback-porch = 50;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 9;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/eDP/13.3_eDP_1920x1080 b/lcdparamservice/lcd_parameters/eDP/13.3_eDP_1920x1080
new file mode 100755
index 0000000..9890330
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/eDP/13.3_eDP_1920x1080
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 142300000;
+hactive = 1980;
+hfront-porch = 48;
+hsync-len = 80;
+hback-porch = 180;
+vactive = 1080;
+vfront-porch = 7;
+vsync-len = 27;
+vback-porch = 50;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 9;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080 b/lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080
new file mode 100755
index 0000000..9890330
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 142300000;
+hactive = 1980;
+hfront-porch = 48;
+hsync-len = 80;
+hback-porch = 180;
+vactive = 1080;
+vfront-porch = 7;
+vsync-len = 27;
+vback-porch = 50;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 9;
\ No newline at end of file
diff --git a/lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080_NV156FHM b/lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080_NV156FHM
new file mode 100755
index 0000000..4b51aba
--- /dev/null
+++ b/lcdparamservice/lcd_parameters/eDP/15.6_eDP_1920x1080_NV156FHM
@@ -0,0 +1,25 @@
+panel-type = 1;
+
+unprepare-delay-ms = 100;
+enable-delay-ms = 100;
+disable-delay-ms = 0;
+prepare-delay-ms = 100;
+reset-delay-ms = 100;
+init-delay-ms = 100;
+width-mm = 240;
+height-mm = 300;
+
+clock-frequency = 141400000;
+hactive = 1980;
+hfront-porch = 48;
+hsync-len = 80;
+hback-porch = 220;
+vactive = 1080;
+vfront-porch = 7;
+vsync-len = 9;
+vback-porch = 22;
+hsync-active = 0;
+vsync-activee = 0;
+de-active = 0;
+pixelclk-active = 0;
+nodka_lvds = 9;
\ No newline at end of file
diff --git a/lcdparamservice/lcdparamservice b/lcdparamservice/lcdparamservice
new file mode 100755
index 0000000..61f93fe
--- /dev/null
+++ b/lcdparamservice/lcdparamservice
Binary files differ
diff --git a/lcdparamservice/lcdparamservice.c b/lcdparamservice/lcdparamservice.c
new file mode 100755
index 0000000..3c8ca80
--- /dev/null
+++ b/lcdparamservice/lcdparamservice.c
@@ -0,0 +1,547 @@
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <termio.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+//#include <cutils/properties.h>
+#include <sys/utsname.h>
+//#include <cutils/list.h>
+//#include <cutils/log.h>
+//#include <cutils/sockets.h>
+#include <sys/reboot.h>
+//#include <cutils/iosched_policy.h>
+
+#undef LOG_TAG
+#define LOG_TAG "LcdParamService"
+
+typedef unsigned short uint16;
+typedef unsigned long uint32;
+typedef unsigned char uint8;
+
+
+#define LCD_PARAMETE_FILE_UPATH "find /media/demo/usb0 -name nodka_lcd"
+#define LCD_PARAMETE_FILE_SDPATH "find /nodka_test -name nodka_lcd"
+//#define OEM_PARTITIOM_NODE_PATH "/dev/block/by-name/lcdparam"
+//#define BASEPARAMETER_PATH "dev/block/platform/fe330000.sdhci/by-name/baseparameter"
+#define BASEPARAMETER_PATH "/dev/block/by-name/baseparameter"
+/*#define OEM_PARTITIOM_NODE_PATH "data/oem"*/
+
+/*#define RKNAND_GET_VENDOR_SECTOR0 _IOW('v', 16, unsigned int)*/
+/*#define RKNAND_STORE_VENDOR_SECTOR0 _IOW('v', 17, unsigned int)*/
+
+
+#define RKNAND_SYS_STORGAE_DATA_LEN 512 //oem size
+/*#define VENDOR_SECTOR_OP_TAG 0x444E4556 // "VEND"*/
+
+#define POLY 0xEDB88320L //CRC stand
+#define CONFIG_NUM 27
+#define BASE_OFFSET 256 * 1024
+
+char *key[CONFIG_NUM] =
+{
+ "panel-type",
+
+ "unprepare-delay-ms",
+ "enable-delay-ms",
+ "disable-delay-ms",
+ "prepare-delay-ms",
+ "reset-delay-ms",
+ "init-delay-ms",
+ "width-mm",
+ "height-mm",
+
+ "clock-frequency",
+ "hactive",
+ "hfront-porch",
+ "hsync-len",
+ "hback-porch",
+ "vactive",
+ "vfront-porch",
+ "vsync-len",
+ "vback-porch",
+ "hsync-active",
+ "vsync-active",
+ "de-active",
+ "pixelclk-active",
+
+ "dsi,flags",
+ "dsi,format",
+ "dsi,lanes",
+ "panel-init-sequence",
+
+ "nodka_lvds"
+};
+
+typedef struct tagRKNAND_SYS_STORGAE
+{
+ /*unsigned long tag;*/
+ /*unsigned long len;*/
+ unsigned char data[RKNAND_SYS_STORGAE_DATA_LEN];
+}RKNAND_SYS_STORGAE;
+
+
+static uint32 crc32_tab[256];
+static uint32 nand_crc = 0;
+
+char *strreplace(char *s, char old, char new)
+{
+ for (; *s; ++s)
+ if (*s == old)
+ *s = new;
+ return s;
+}
+
+void rknand_print_hex_data(uint8 *s,uint32 * buf,uint32 len)
+{
+ uint32 i;
+ printf("%s\n",s);
+ for(i=0;i<len;i+=4)
+ {
+ printf("%lx %lx %lx %lx\n",buf[i],buf[i+1],buf[i+2],buf[i+3]);
+ }
+}
+
+
+void init_crc32_tab(void)
+{
+ int i = 0;
+ int j = 0;
+ uint32 crc = 0;
+
+ for(i = 0; i < 256; i++)
+ {
+ crc = (uint32)i;
+ for(j = 0; j < 8; j++)
+ {
+ if(crc & 0x00000001L)
+ crc = (crc >> 1) ^ POLY;
+ else
+ crc = crc >> 1;
+ }
+ crc32_tab[i] = crc;
+ }
+
+}
+
+uint32 get_crc32(uint32 crc_init, uint8 *crc_buf, uint32 buf_size)
+{
+ uint32 crc = crc_init ^ 0xffffffff;
+
+ init_crc32_tab();
+ while(buf_size--)
+ crc = (crc >> 8) ^ crc32_tab[(crc & 0xff) ^ *crc_buf++];
+ return crc ^ 0xfffffff;
+}
+
+uint32 getfile_crc(FILE *fp)
+{
+ uint32 size = 4 *1024;
+ uint8 crc_buf[size];
+ uint32 readln = 0;
+ uint crc = 0;
+
+ while((readln = fread(crc_buf, sizeof(uint8), size, fp)) > 0)
+ crc = get_crc32(crc, crc_buf, readln);
+
+ return crc;
+
+}
+
+/*
+ *去除字符串左端空格
+ */
+char *strtriml(char *pstr)
+{
+ int i = 0,j;
+ j = strlen(pstr) - 1;
+ while (isspace(pstr[i]) && (i <= j))
+ i++;
+ if (0<i)
+ strcpy(pstr, &pstr[i]);
+ return pstr;
+}
+
+/*
+ *去除字符串右端空格
+ */
+char *strtrimr(char *pstr)
+{
+ int i;
+ i = strlen(pstr) - 1;
+ while (isspace(pstr[i]) && (i >= 0))
+ pstr[i--] = '\0';
+ return pstr;
+}
+
+/*
+ *去除字符串两端空格
+ */
+char *strtrim(char *pstr)
+{
+ char *p;
+ p = strtrimr(pstr);
+ return strtriml(p);
+}
+
+
+char *strdelchr(char *pstr, int chr)
+{
+ int i = 0;
+ int l = 0;
+ int ll = 0;
+ ll = l = strlen(pstr);
+
+ while(i < l)
+ {
+ if(pstr[i] == chr)
+ {
+ memmove((pstr + i), (pstr + i + 1), (ll - i -1));
+ pstr[ll - 1] = '\0';
+ ll--;
+ }
+ i++;
+ }
+ /* for(i = 0; i < l; i++) */
+ /* { */
+ /* if(pstr[i] == chr) */
+ /* { */
+ /* memmove((pstr + i), (pstr + i + 1), (l - i -1)); */
+ /* pstr[l - 1] = '\0'; */
+ /* break; */
+ /* } */
+ /* } */
+ return pstr;
+}
+
+
+void strrmspace(char * str)
+{
+ char *p1, *p2;
+ char ch;
+ p1 = str; //first pointer
+ p2 = str; // second pointer to the remaining string
+ if (p1==NULL) return;
+ while (*p1)
+ {
+ if (*p1 != ' ')
+ {
+ ch = *p1;
+ *p2 = ch;
+ p1++;
+ p2++;
+ }
+ else
+ {
+ p1++;
+ }
+ }
+ *p2 = '\0';
+}
+uint32 getfile_crc_from_nand(void)
+{
+ int ret = 0;
+ uint32 crc = 0;
+
+ RKNAND_SYS_STORGAE sysData;
+
+ int sys_fd;
+
+ if (0 != access(BASEPARAMETER_PATH, R_OK | W_OK)){
+ printf("access fail!!!\n");
+ return -1;
+ }
+
+ memset(sysData.data, '\0', sizeof(sysData.data));
+ /*sysData.tag = VENDOR_SECTOR_OP_TAG;*/
+ /*sysData.len = RKNAND_SYS_STORGAE_DATA_LEN-8;*/
+ /*sys_fd = fopen(OEM_PARTITIOM_NODE_PATH, "r");*/
+ /*[>sys_fd = open("/dev/rknand_sys_storage",O_RDWR,0);<]*/
+ /*if(sys_fd == NULL)*/
+ /*{*/
+ /*printf("fopen err %s err=%d\n",OEM_PARTITIOM_NODE_PATH, sys_fd);*/
+ /*return -1;*/
+ /*}*/
+
+ sys_fd = open(BASEPARAMETER_PATH, O_RDONLY);
+
+ if (sys_fd < 0)
+ {
+ printf("fopen err %s sys_fd=,%d\n",BASEPARAMETER_PATH, sys_fd);
+ return -1;
+ }
+ lseek(sys_fd, BASE_OFFSET, SEEK_SET);
+ ret = read (sys_fd, (void*)&sysData, sizeof(sysData));
+ if (ret < 0)
+ {
+ printf("read err %s sys_fd=,%d\n",BASEPARAMETER_PATH, sys_fd );
+ return -1;
+ }
+
+ /*ret = ioctl(sys_fd, RKNAND_GET_VENDOR_SECTOR0, &sysData);*/
+ /*fread((void*)&sysData,sizeof(sysData),1,sys_fd);*/
+ /* rknand_print_hex_data("getfile_crc_from_nand data:",(uint32*)sysData.data,32); */
+ /* crc = sysData.data[24 * 4]; */
+ /* crc = (crc << 8) + sysData.data[24 * 4 + 1]; */
+ /* crc = (crc << 8) + sysData.data[24 * 4 + 2]; */
+ /* crc = (crc << 8) + sysData.data[24 * 4 + 3]; */
+ /* printf("-luoxt- crc data = 0x%02x%02x%02x%02x", sysData.data[24 * 4], */
+ /* sysData.data[24 * 4 + 1], */
+ /* sysData.data[24 * 4 + 2], */
+ /* sysData.data[24 * 4 + 3]); */
+
+ for(int i = 0; i < CONFIG_NUM+1; i++){
+ crc = sysData.data[i * 4];
+ crc = (crc << 8) + sysData.data[i * 4 + 1];
+ crc = (crc << 8) + sysData.data[i * 4 + 2];
+ crc = (crc << 8) + sysData.data[i * 4 + 3];
+ printf("-luoxt- %d nand crc data = 0X%02X%02X%02X%02X\n", i, sysData.data[i * 4],
+ sysData.data[i * 4 + 1],
+ sysData.data[i * 4 + 2],
+ sysData.data[i * 4 + 3]);
+ }
+
+
+ crc = sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-4];
+ crc = (crc << 8) + sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-3];
+ crc = (crc << 8) + sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-2];
+ crc = (crc << 8) + sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-1];
+ printf("-luoxt- nand crc data = 0X%02X%02X%02X%02X\n", sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-4],
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-3],
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-2],
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-1]);
+ close(sys_fd);
+
+ return crc;
+}
+
+int rk_update_lcd_parameters_from_sdcard(void)
+{
+
+ int ret = 0;
+ FILE *fp = 0;
+ char line[1024] = {0};
+ int i = 0;
+ RKNAND_SYS_STORGAE sysData;
+ int sys_fd = 0;
+ static uint32 file_crc = 0; //file lcdparameter crc data
+ static int updated = 0; // had store the param into the nand
+ static char got_crc = 0; //get file crc flag
+ char lcdparameter_buf[128];
+ FILE *stream;
+
+ memset( lcdparameter_buf, '\0', sizeof(lcdparameter_buf) );
+ memset(sysData.data, '\0', sizeof(sysData.data));
+ if((access(LCD_PARAMETE_FILE_UPATH,F_OK))!=-1)
+ {
+ printf("update form udisk\n");
+ stream = popen(LCD_PARAMETE_FILE_UPATH, "r");
+ }
+ else
+ {
+ printf("update form emmc\n");
+ stream = popen(LCD_PARAMETE_FILE_SDPATH, "r");
+ }
+ fread( lcdparameter_buf, sizeof(char), sizeof(lcdparameter_buf), stream);
+ strreplace(lcdparameter_buf,'\n','\0');
+ pclose(stream);
+
+ /*
+ while(access(lcdparameter_buf, 0))
+ {
+ if(updated)
+ updated = 0;
+ if(got_crc)
+ got_crc = 0;
+ return -1;
+ }
+ */
+
+ if(!updated)
+ {
+ if (!got_crc)
+ {
+ fp = fopen(lcdparameter_buf, "r");
+ //fp = fopen("/root/rk_lcd_parameters", "rb");
+ printf("---XYP_DEBUG--- ======== %s %d ========\n", __func__, __LINE__);
+ if(fp == NULL)
+ {
+ printf("open %s failed\n", lcdparameter_buf);
+ return -1;
+ }
+ else
+ {
+ printf("success open file %s \n", lcdparameter_buf);
+ }
+
+ file_crc = getfile_crc(fp);
+ got_crc = 1;
+ printf(" file crc is 0X%08lX nand_crc is 0X%08lX \n", file_crc, nand_crc );
+ fclose(fp);
+ }
+
+ /*sysData.tag = VENDOR_SECTOR_OP_TAG;*/
+ /*sysData.len = RKNAND_SYS_STORGAE_DATA_LEN - 8;*/
+
+ if((nand_crc != file_crc))
+ {
+ fp = fopen(lcdparameter_buf, "r");
+ if(fp == NULL)
+ {
+ printf("open %s failed\n", lcdparameter_buf);
+ return -1;
+ }
+ else
+ {
+ printf("success open file %s\n", lcdparameter_buf);
+ }
+
+
+ while(fgets(line, 1023, fp))
+ {
+ char *p = strtrim(line);
+ int len = strlen(p);
+ if(len <= 0)
+ {
+ continue;
+ }
+ else if(p[0]=='#')
+ {
+ continue;
+ }
+ else if( (!(strstr(p, "="))) && (!(strstr(p, ";"))) && (!(strstr(p, "screen_"))))
+ {
+ continue;
+ }
+ else
+ {
+ // get key and value string like "screen_lvds_format = 1" spilt by ";"
+ char *key_val_str = strtok(p, ";");
+ char *value = strchr(key_val_str, '=');
+ char cmd[4] = {'\0'};
+ if(value == NULL)
+ continue;
+ for(i = 0; i < CONFIG_NUM; i++)
+ {
+ if(strstr(p, key[i]))
+ {
+ char *val = strdelchr(value, '=');
+ strrmspace(val);
+ uint32 config1 = atoi(val);
+
+ if (strstr(p, "panel-init-sequence"))
+ {
+ int count=0;
+ int cmdlen=strlen(val)/2;
+
+ sysData.data[i * 4] =(uint8) (cmdlen >> 24);
+ sysData.data[i * 4 + 1] =(uint8) (cmdlen >> 16);
+ sysData.data[i * 4 + 2] =(uint8) (cmdlen >> 8);
+ sysData.data[i * 4 + 3] =(uint8) (cmdlen >> 0);
+ printf("-luoxt- %s=%lu val %s\n", key[i], config1, val);
+ i ++;
+ while(1)
+ {
+ cmd [0] = '0';
+ cmd [1] = 'x';
+ cmd [2] = *val;
+ cmd [3] = *(++val);
+ uint8 cmdu8 = strtol(cmd,NULL,16);
+ sysData.data[i * 4 + count++] = cmdu8;
+
+ printf("v1-luoxt- cmd=%d count=%d total=%d\n", cmdu8, count, cmdlen);
+ if (count < cmdlen)
+ ++val; //next cmd
+ else
+ break;
+ }
+
+ }
+ else{
+ sysData.data[i * 4] =(uint8) (config1 >> 24);
+ sysData.data[i * 4 + 1] =(uint8) (config1 >> 16);
+ sysData.data[i * 4 + 2] =(uint8) (config1 >> 8);
+ sysData.data[i * 4 + 3] =(uint8) (config1 >> 0);
+ printf("-luoxt- %s=%lu val %s\n", key[i], config1, val);
+ }
+ break;
+ }
+ }
+
+ }
+
+ }
+ // file crc data
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-4] = (uint8) (file_crc >> 24);
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-3] = (uint8) (file_crc >> 16);
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-2] = (uint8) (file_crc >> 8);
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-1] = (uint8) (file_crc >> 0);
+ printf("-luoxt- crc32 = 0X%02X%02X%02X%02X\n", sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-4],
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-3],
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-2],
+ sysData.data[RKNAND_SYS_STORGAE_DATA_LEN-1]);
+
+ /* rknand_print_hex_data("lcd paramters save:",(uint32*)sysData.data,32); */
+ /*ret = ioctl(sys_fd, RKNAND_STORE_VENDOR_SECTOR0, &sysData);*/
+
+ if (0 == access(BASEPARAMETER_PATH, 0))
+ {
+ sys_fd = open(BASEPARAMETER_PATH, O_WRONLY);
+
+ if (sys_fd < 0)
+ {
+ printf("open err %s err=%d\n",BASEPARAMETER_PATH, sys_fd);
+ return -1;
+ }
+
+ lseek(sys_fd, BASE_OFFSET, SEEK_SET);
+ ret = write (sys_fd, (void*)&sysData.data[0], RKNAND_SYS_STORGAE_DATA_LEN);
+ if (ret < 0)
+ {
+ printf("read err %s err=%d\n",BASEPARAMETER_PATH, sys_fd);
+ return -1;
+ }
+ }
+
+ close(sys_fd);
+ if(ret==-1){
+ printf("save lcdparam error\n");
+ }
+ else
+ {
+ updated = 1;
+ nand_crc = file_crc;
+ fclose(fp);
+ sync();
+ reboot(RB_AUTOBOOT);
+ }
+ fclose(fp);
+ return ret;
+ }
+ }
+ return ret;
+}
+
+int main(void)
+{
+ char command[128];
+ strcpy( command, "dd if=/dev/zero of=/dev/block/by-name/baseparameter" );
+ printf("CLEAN PARAMETERS\n");
+ system(command);
+ nand_crc = getfile_crc_from_nand();
+ while(1)
+ {
+
+ rk_update_lcd_parameters_from_sdcard();
+ //gettimeofday(&tv,NULL);
+ //fprintf(stderr, "[%ld] rk_update_lcd_parameters_from_sdcard sleep....\n", tv.tv_usec);
+ //usleep(100000);
+ sleep(5);
+ }
+ return 0;
+}
+
diff --git a/rtl8852be b/rtl8852be
new file mode 160000
index 0000000..68212c1
--- /dev/null
+++ b/rtl8852be
+Subproject commit 68212c16b229080742280f954b3ffde173e63fcc
diff --git a/u-boot/arch/arm/mach-rockchip/kernel_dtb.c b/u-boot/arch/arm/mach-rockchip/kernel_dtb.c
old mode 100644
new mode 100755
index 2f24cfa..3d3aa6a
--- a/u-boot/arch/arm/mach-rockchip/kernel_dtb.c
+++ b/u-boot/arch/arm/mach-rockchip/kernel_dtb.c
@@ -16,6 +16,500 @@
DECLARE_GLOBAL_DATA_PTR;
+
+#if 1
+struct display_fixup_data {
+ int type;
+
+ int delay_prepare;
+ int delay_enable;
+ int delay_disable;
+ int delay_unprepare;
+ int delay_reset;
+ int delay_init;
+ int size_width;
+ int size_height;
+
+ int clock_frequency;
+ int hactive;
+ int hfront_porch;
+ int hsync_len;
+ int hback_porch;
+ int vactive;
+ int vfront_porch;
+ int vsync_len;
+ int vback_porch;
+ int hsync_active;
+ int vsync_active;
+ int de_active;
+ int pixelclk_active;
+
+ /* for DSI Panel */
+ int flags;
+ int format;
+ int lanes;
+ int init_cmd_length;
+ u8 *init_cmd;
+
+ int nodka_lvds;
+};
+enum {
+ PANEL_TYPE_DSI,
+ PANEL_TYPE_EDP,
+ PANEL_TYPE_LVDS,
+};
+
+#define CUSTOM_PARTITION_NAME "baseparameter"
+#define LCD_PARAM_MAX_COUNT 27
+
+int lcdParam[LCD_PARAM_MAX_COUNT];
+char param_buf_temp[4*1024] = {0};
+
+void set_lcdparam_test_edp(struct display_fixup_data *data)
+{
+
+ data->type = PANEL_TYPE_DSI;
+ data->delay_prepare = 100;
+ data->delay_enable = 100;
+ data->delay_disable = 100;
+ data->delay_unprepare = 100;
+ data->delay_reset = 100;
+ data->delay_init = 100;
+ data->size_width = 240;
+ data->size_height = 300;
+ data->clock_frequency = 60000000;
+ data->hactive = 1024;
+ data->hfront_porch = 12;
+ data->hsync_len = 16;
+ data->hback_porch = 48;
+ data->vactive = 600;
+ data->vfront_porch = 8;
+ data->vsync_len = 4;
+ data->vback_porch = 8;
+ data->hsync_active = 0;
+ data->vsync_active = 0;
+ data->de_active = 0;
+ data->pixelclk_active = 0;
+ data->flags = 0;
+ data->format = 0;
+ data->lanes = 4;
+ *(data->init_cmd + 0) = 0x05;
+ *(data->init_cmd + 1) = 0x00;
+ *(data->init_cmd + 2) = 0x01;
+ *(data->init_cmd + 3) = 0x01;
+
+ *(data->init_cmd + 4) = 0x05;
+ *(data->init_cmd + 5) = 0x00;
+ *(data->init_cmd + 6) = 0x01;
+ *(data->init_cmd + 7) = 0x02;
+
+ *(data->init_cmd + 8) = 0x05;
+ *(data->init_cmd + 9) = 0x00;
+ *(data->init_cmd + 10) = 0x01;
+ *(data->init_cmd + 11) = 0x03;
+
+ *(data->init_cmd + 12) = 0x05;
+ *(data->init_cmd + 13) = 0x00;
+ *(data->init_cmd + 14) = 0x01;
+ *(data->init_cmd + 15) = 0x05;
+
+}
+
+int get_lcdparam_info_from_custom_partition(struct display_fixup_data *data)
+{
+
+ struct blk_desc *dev_desc;
+ disk_partition_t part_info;
+ char *boot_partname = CUSTOM_PARTITION_NAME;
+ int ret,i;
+
+ dev_desc = rockchip_get_bootdev();
+ if (!dev_desc) {
+ printf("%s: dev_desc is NULL!\n", __func__);
+ return -ENODEV;
+ }
+
+ ret = part_get_info_by_name(dev_desc, boot_partname, &part_info);
+ if (ret < 0) {
+ printf("%s: failed to get %s part, ret=%d\n",
+ __func__, boot_partname, ret);
+ /* RKIMG can support part table without 'boot' */
+ return -1;
+ }
+
+ printf("block num: %lu, name %s ,type %s,block size :%lu\n",part_info.size,part_info.name,part_info.type,part_info.blksz);
+
+ ret = blk_dread(dev_desc, part_info.start + 512, 1, param_buf_temp);
+ if (ret != 1) {
+ printf("%s: failed to read screen parameter, ret=%d\n",
+ __func__, ret);
+ return -1;
+ }
+
+ for (i = 0; i < LCD_PARAM_MAX_COUNT; i++) {
+ lcdParam[i] = param_buf_temp[i * 4];
+ lcdParam[i] = (lcdParam[i] << 8) + param_buf_temp[i * 4 + 1];
+ lcdParam[i] = (lcdParam[i] << 8) + param_buf_temp[i * 4 + 2];
+ lcdParam[i] = (lcdParam[i] << 8) + param_buf_temp[i * 4 + 3];
+ if(lcdParam[i] < 0){
+ lcdParam[i] = -lcdParam[i];
+ }
+ if(lcdParam[i] > 100000 && i != 9){
+ lcdParam[i] = 0;
+ }
+ printf("--get-- lcd_param %d\n",lcdParam[i]);
+ }
+
+ if(lcdParam[14] == 0 || lcdParam[10] == 0){
+ return -1;
+ }
+ printf("-get- crc32 = 0X%02X%02X%02X%02X\n",
+ param_buf_temp[LCD_PARAM_MAX_COUNT * 4], param_buf_temp[LCD_PARAM_MAX_COUNT * 4 + 1],
+ param_buf_temp[LCD_PARAM_MAX_COUNT * 4 + 2], param_buf_temp[LCD_PARAM_MAX_COUNT * 4 + 3]);
+
+ data->type = lcdParam[0];
+ data->delay_prepare = lcdParam[4];
+ data->delay_enable = lcdParam[2];
+ data->delay_disable = lcdParam[3];
+ data->delay_unprepare = lcdParam[1];
+ data->delay_reset = lcdParam[5];
+ data->delay_init = lcdParam[6];
+ data->size_width = lcdParam[7];
+ data->size_height = lcdParam[8];
+ data->clock_frequency = lcdParam[9];
+ data->hactive = lcdParam[10];
+ data->hfront_porch = lcdParam[11];
+ data->hsync_len = lcdParam[12];
+ data->hback_porch = lcdParam[13];
+ data->vactive = lcdParam[14];
+ data->vfront_porch = lcdParam[15];
+ data->vsync_len = lcdParam[16];
+ data->vback_porch = lcdParam[17];
+ data->hsync_active = lcdParam[18];
+ data->vsync_active = lcdParam[19];
+ data->de_active = lcdParam[20];
+ data->pixelclk_active = lcdParam[21];
+ data->flags = lcdParam[22];
+ data->format = lcdParam[23];
+ data->lanes = lcdParam[24];
+ data->init_cmd_length = lcdParam[25] = 16;
+ data->nodka_lvds = lcdParam[26];
+ data->init_cmd = malloc(sizeof(*(data->init_cmd)) * data->init_cmd_length);
+ for(i = 0; i < data->init_cmd_length; i++){
+ *(data->init_cmd + i) = param_buf_temp[100 + i];
+ // printf("init cmd = %x\n",param_buf_temp[100 + i]);
+
+ }
+
+// set_lcdparam_test_edp(data);
+
+ return 0;
+}
+
+#endif
+
+
+static int find_connector_node(const void *blob, int node)
+{
+ int phandle, remote;
+ int nodedepth;
+
+ phandle = fdt_getprop_u32_default_node(blob, node, 0,
+ "remote-endpoint", -1);
+ remote = fdt_node_offset_by_phandle(blob, phandle);
+ nodedepth = fdt_node_depth(blob, remote);
+
+ return fdt_supernode_atdepth_offset(blob, remote,
+ nodedepth - 3, NULL);
+}
+
+static int get_panel_node(const void *blob, int conn_node)
+{
+ int panel, ports, port, ep, remote, ph, nodedepth;
+
+ panel = fdt_subnode_offset(blob, conn_node, "panel");
+ printf("panel_1=%d\n",panel);
+ if (panel > 0) {
+ return panel;
+ }
+
+ ports = fdt_subnode_offset(blob, conn_node, "ports");
+ if (ports < 0)
+ {
+ return -ENODEV;
+ }
+
+ fdt_for_each_subnode(port, blob, ports) {
+ fdt_for_each_subnode(ep, blob, port) {
+ ph = fdt_getprop_u32_default_node(blob, ep, 0,
+ "remote-endpoint", 0);
+ if (!ph)
+ continue;
+
+ remote = fdt_node_offset_by_phandle(blob, ph);
+
+ nodedepth = fdt_node_depth(blob, remote);
+ if (nodedepth < 2)
+ continue;
+
+ panel = fdt_supernode_atdepth_offset(blob, remote,
+ nodedepth - 2,
+ NULL);
+ break;
+ }
+ }
+ printf("panel_2=%d\n",panel);
+ return panel;
+}
+
+static int fdt_fixup_node_status(void *blob, int node, enum fdt_status status)
+{
+ int ret;
+
+// printf("My fixup %s %d\n", fdt_get_name(blob, node, NULL), status);
+
+set_status:
+ ret = fdt_set_node_status(blob, node, status, 0);
+ if (ret == -FDT_ERR_NOSPACE) {
+ ret = fdt_increase_size(blob, 512);
+ if (!ret)
+ goto set_status;
+ else
+ goto err_size;
+ } else if (ret < 0) {
+ printf("Can't set node status: %s\n", fdt_strerror(ret));
+ return ret;
+ }
+
+ return 0;
+
+err_size:
+ printf("Can't increase blob size: %s\n", fdt_strerror(ret));
+ return ret;
+}
+
+static int fdt_fixup_panel_init_sequence(void *fdt, int node,const struct display_fixup_data *data)
+{
+ #if 0
+ u8 init_buf[] = {0x05, 0x00, 0x01, 0x78, 0x15, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x01, 0x14,0x39, 0x01, 0x03, 0x02, 0x29, 0x11};
+ u8 exit_buf[] = {0x05, 0x64, 0x01, 0x29, 0x05, 0x64, 0x01, 0x11};
+ #endif
+ int ret;
+
+add_seq:
+ ret = fdt_setprop(fdt, node, "panel-init-sequence", data->init_cmd, data->init_cmd_length);
+ if (ret == -FDT_ERR_NOSPACE) {
+ printf(" init sequence FDT_ERR_NOSPACE\n");
+ ret = fdt_increase_size(fdt, data->init_cmd_length * 4);//gln the length needs precision
+ if (!ret)
+ goto add_seq;
+ else
+ goto err_size;
+ } else if (ret < 0) {
+ printf("Can't add property: %s\n", fdt_strerror(ret));
+ return ret;
+ }
+
+#if 0
+add_init_seq:
+ ret = fdt_setprop(fdt, node, "panel-init-sequence", init_buf, sizeof(init_buf));
+ if (ret == -FDT_ERR_NOSPACE) {
+ printf(" init sequence FDT_ERR_NOSPACE\n");
+ ret = fdt_increase_size(fdt, 512);//gln the length needs precision
+ if (!ret)
+ goto add_init_seq;
+ else
+ goto err_size;
+ } else if (ret < 0) {
+ printf("Can't add property: %s\n", fdt_strerror(ret));
+ return ret;
+ }
+add_exit_seq:
+ ret = fdt_setprop(fdt, node, "panel-exit-sequence", exit_buf, sizeof(exit_buf));
+ if (ret == -FDT_ERR_NOSPACE) {
+ printf(" init sequence FDT_ERR_NOSPACE\n");
+ ret = fdt_increase_size(fdt, 512);//gln the length needs precision
+ if (!ret)
+ goto add_exit_seq;
+ else
+ goto err_size;
+ } else if (ret < 0) {
+ printf("Can't add property: %s\n", fdt_strerror(ret));
+ return ret;
+ }
+#endif
+
+ return 0;
+
+err_size:
+ printf("Can't increase blob size: %s\n", fdt_strerror(ret));
+ return ret;
+}
+
+static int fdt_fixup_setprop_u32(void *fdt, int node, const char *name, u32 data)
+{
+ int ret;
+
+set_prop:
+ ret = fdt_setprop_u32(fdt, node, name, data);
+ if (ret == -FDT_ERR_NOSPACE) {
+ ret = fdt_increase_size(fdt, 512);
+ if (!ret)
+ goto set_prop;
+ else
+ goto err_size;
+ } else if (ret < 0) {
+ printf("Can't add property: %s\n", fdt_strerror(ret));
+ return ret;
+ }
+
+ return 0;
+
+err_size:
+ printf("Can't increase blob size: %s\n", fdt_strerror(ret));
+ return ret;
+}
+
+static void fdt_fixup_display_timing(void *blob, int node,
+ const struct display_fixup_data *data)
+{
+ fdt_fixup_setprop_u32(blob, node, "clock-frequency", data->clock_frequency);
+ fdt_fixup_setprop_u32(blob, node, "hactive", data->hactive);
+ fdt_fixup_setprop_u32(blob, node, "hfront-porch", data->hfront_porch);
+ fdt_fixup_setprop_u32(blob, node, "hsync-len", data->hsync_len);
+ fdt_fixup_setprop_u32(blob, node, "hback-porch", data->hback_porch);
+ fdt_fixup_setprop_u32(blob, node, "vactive", data->vactive);
+ fdt_fixup_setprop_u32(blob, node, "vfront-porch", data->vfront_porch);
+ fdt_fixup_setprop_u32(blob, node, "vsync-len", data->vsync_len);
+ fdt_fixup_setprop_u32(blob, node, "vback-porch", data->vback_porch);
+ fdt_fixup_setprop_u32(blob, node, "hsync-active", data->hsync_active);
+ fdt_fixup_setprop_u32(blob, node, "vsync-active", data->vsync_active);
+ fdt_fixup_setprop_u32(blob, node, "de-active", data->de_active);
+ fdt_fixup_setprop_u32(blob, node, "pixelclk-active", data->pixelclk_active);
+}
+
+static void fdt_fixup_panel_node(void *blob, int node, const char *name,
+ const struct display_fixup_data *data)
+{
+ if (!strcmp(name, "dsi")) {
+ fdt_setprop_u32(blob, node, "dsi,flags", data->flags);
+ fdt_setprop_u32(blob, node, "dsi,format", data->format);
+ fdt_setprop_u32(blob, node, "dsi,lanes", data->lanes);
+ fdt_fixup_panel_init_sequence(blob, node,data);
+ }
+ fdt_fixup_setprop_u32(blob, node, "prepare-delay-ms", data->delay_prepare);
+ fdt_fixup_setprop_u32(blob, node, "enable-delay-ms", data->delay_enable);
+ fdt_fixup_setprop_u32(blob, node, "disable-delay-ms", data->delay_disable);
+ fdt_fixup_setprop_u32(blob, node, "unprepare-delay-ms", data->delay_unprepare);
+ fdt_fixup_setprop_u32(blob, node, "reset-delay-ms", data->delay_reset);
+ fdt_fixup_setprop_u32(blob, node, "init-delay-ms", data->delay_init);
+ fdt_fixup_setprop_u32(blob, node, "width-mm", data->size_width);
+ fdt_fixup_setprop_u32(blob, node, "height-mm", data->size_height);
+
+}
+static void fdt_fixup_nodka_lvds(void *blob, int node,
+ const struct display_fixup_data *data)
+{
+ if ( data->nodka_lvds != 0 )
+ fdt_fixup_setprop_u32(blob, node, "nodka-lvds", data->nodka_lvds);
+}
+
+
+static int fdt_fixup_display_sub_route(void *blob, const char *name,
+ enum fdt_status status,
+ const struct display_fixup_data *data)
+{
+ int route, phandle, connect, connector, panel, dt, timing, route_lvds;
+ char path[64];
+ char path_lvds[16] = "/panel";
+ int ret;
+ sprintf(path, "/display-subsystem/route/route-%s", name);
+
+
+ route = fdt_path_offset(blob, path);
+ printf("route : %d \n",route);
+ if (route < 0)
+ return route;
+
+ route_lvds = fdt_path_offset(blob, path_lvds);
+ if (route_lvds < 0)
+ {
+ printf("can not get route_lvds = %d\n",route_lvds);
+ return route_lvds;
+ }
+ /* fixup lvds gpio channel*/
+ fdt_fixup_nodka_lvds(blob, route_lvds, data);
+
+ /* fixup route status */
+ ret = fdt_fixup_node_status(blob, route, status);
+ if (ret < 0)
+ return ret;
+ phandle = fdt_getprop_u32_default_node(blob, route, 0, "connect", -1);
+ if (phandle < 0)
+ return phandle;
+ connect = fdt_node_offset_by_phandle(blob, phandle);
+ if (connect < 0)
+ return connect;
+ connector = find_connector_node(blob, connect);
+ if (connector < 0)
+ return connector;
+ /* fixup connector status */
+ ret = fdt_fixup_node_status(blob, connector, status);
+ if (ret < 0)
+ return ret;
+ if (status != FDT_STATUS_OKAY) {
+ return 0;
+ }
+ panel = get_panel_node(blob, connector);
+ if (panel < 0)
+ return panel;
+ /* fixup panel info */
+ fdt_fixup_panel_node(blob, panel, name, data);
+ dt = fdt_subnode_offset(blob, panel, "display-timings");
+ if (dt < 0) {
+ return dt;
+ }
+ timing = fdt_subnode_offset(blob, dt, "timing");
+ if (timing < 0) {
+ phandle = fdt_getprop_u32_default_node(blob, dt, 0, "native-mode", -1);
+ if (phandle < 0)
+ return phandle;
+
+ timing = fdt_node_offset_by_phandle(blob, phandle);
+ if (timing < 0)
+ return timing;
+ }
+
+ /* fixup panel display timing */
+ fdt_fixup_display_timing(blob, timing, data);
+ return 0;
+}
+
+static void fdt_fixup_display_route(void *blob, const struct display_fixup_data *data)
+{
+ if (data->type == PANEL_TYPE_DSI) {
+ fdt_fixup_display_sub_route(blob, "dsi", FDT_STATUS_OKAY, data);
+ fdt_fixup_display_sub_route(blob, "edp", FDT_STATUS_DISABLED, data);
+ fdt_fixup_display_sub_route(blob, "lvds", FDT_STATUS_DISABLED, data);
+ } else if (data->type == PANEL_TYPE_EDP) {
+ fdt_fixup_display_sub_route(blob, "dsi", FDT_STATUS_DISABLED, data);
+ fdt_fixup_display_sub_route(blob, "edp", FDT_STATUS_OKAY, data);
+ fdt_fixup_display_sub_route(blob, "lvds", FDT_STATUS_DISABLED, data);
+ } else if (data->type == PANEL_TYPE_LVDS) {
+ fdt_fixup_display_sub_route(blob, "lvds", FDT_STATUS_OKAY, data);
+ fdt_fixup_display_sub_route(blob, "dsi", FDT_STATUS_DISABLED, data);
+ fdt_fixup_display_sub_route(blob, "edp", FDT_STATUS_DISABLED, data);
+ }
+}
+
+
+
+
+
+
+
+
+
#ifdef CONFIG_USING_KERNEL_DTB_V2
static int dm_rm_kernel_dev(void)
{
@@ -301,6 +795,7 @@
#endif
ulong fdt_addr = 0;
int ret = -ENODEV;
+ struct display_fixup_data fix_data;
printf("DM: v%d\n", IS_ENABLED(CONFIG_USING_KERNEL_DTB_V2) ? 2 : 1);
@@ -372,6 +867,8 @@
phandles_fixup_cru((void *)gd->fdt_blob);
phandles_fixup_gpio((void *)gd->fdt_blob, (void *)ufdt_blob);
#endif
+ if (!get_lcdparam_info_from_custom_partition(&fix_data))
+ fdt_fixup_display_route((void *)fdt_addr, &fix_data);
gd->flags |= GD_FLG_KDTB_READY;
gd->of_root_f = gd->of_root;
diff --git a/u-boot/drivers/video/drm/rockchip_panel.c b/u-boot/drivers/video/drm/rockchip_panel.c
old mode 100644
new mode 100755
index de7e5e2..652e748
--- a/u-boot/drivers/video/drm/rockchip_panel.c
+++ b/u-boot/drivers/video/drm/rockchip_panel.c
@@ -45,6 +45,7 @@
bool power_invert;
u32 bus_format;
unsigned int bpc;
+ unsigned int lvds_index;
struct {
unsigned int prepare;
@@ -66,6 +67,13 @@
struct udevice *backlight;
struct gpio_desc enable_gpio;
struct gpio_desc reset_gpio;
+ struct gpio_desc edp_bl_on;
+ struct gpio_desc edp_bl_en;
+
+ struct gpio_desc lvds_gpio0;
+ struct gpio_desc lvds_gpio1;
+ struct gpio_desc lvds_gpio2;
+ struct gpio_desc lvds_gpio3;
int cmd_type;
struct gpio_desc spi_sdi_gpio;
@@ -275,24 +283,58 @@
if (priv->prepared)
return;
+
+ /*7511 LVDS IO Control start*/
+ printk("nodka_lvds_index = %d\n",plat->lvds_index);
+
+ ret = plat->lvds_index & 1;
+ if (dm_gpio_is_valid(&priv->lvds_gpio0))
+ dm_gpio_set_value(&priv->lvds_gpio0, ret);
+ ret = dm_gpio_get_value(&priv->lvds_gpio0);
+ printf("lvds_gpio0 : %d\n",ret);
+
+ ret = plat->lvds_index >> 1 & 1;
+ if (dm_gpio_is_valid(&priv->lvds_gpio1))
+ dm_gpio_set_value(&priv->lvds_gpio1, ret);
+ ret = dm_gpio_get_value(&priv->lvds_gpio1);
+ printf("lvds_gpio1 : %d\n",ret);
+
+ ret = plat->lvds_index >> 2 & 1;
+ if (dm_gpio_is_valid(&priv->lvds_gpio2))
+ dm_gpio_set_value(&priv->lvds_gpio2, ret);
+ ret = dm_gpio_get_value(&priv->lvds_gpio2);
+ printf("lvds_gpio2 : %d\n",ret);
+
+ ret = plat->lvds_index >> 3 & 1;
+ if (dm_gpio_is_valid(&priv->lvds_gpio3))
+ dm_gpio_set_value(&priv->lvds_gpio3, ret);
+ ret = dm_gpio_get_value(&priv->lvds_gpio3);
+ printf("lvds_gpio3 : %d\n",ret);
+ mdelay(100);
+/*7511 LVDS IO Control end*/
if (priv->power_supply)
regulator_set_enable(priv->power_supply, !plat->power_invert);
-
+
+ if (dm_gpio_is_valid(&priv->edp_bl_on))
+ dm_gpio_set_value(&priv->edp_bl_on, 1);
+
+ if (dm_gpio_is_valid(&priv->edp_bl_en))
+ dm_gpio_set_value(&priv->edp_bl_en, 1);
+
if (dm_gpio_is_valid(&priv->enable_gpio))
dm_gpio_set_value(&priv->enable_gpio, 1);
-
+
if (plat->delay.prepare)
mdelay(plat->delay.prepare);
-
+
if (dm_gpio_is_valid(&priv->reset_gpio))
dm_gpio_set_value(&priv->reset_gpio, 1);
-
- if (plat->delay.reset)
- mdelay(plat->delay.reset);
-
+ mdelay(50);
if (dm_gpio_is_valid(&priv->reset_gpio))
dm_gpio_set_value(&priv->reset_gpio, 0);
+
+ mdelay(200);
if (plat->delay.init)
mdelay(plat->delay.init);
@@ -407,6 +449,7 @@
plat->delay.disable = dev_read_u32_default(dev, "disable-delay-ms", 0);
plat->delay.init = dev_read_u32_default(dev, "init-delay-ms", 0);
plat->delay.reset = dev_read_u32_default(dev, "reset-delay-ms", 0);
+ plat->lvds_index = dev_read_u32_default(dev, "nodka-lvds", 0);
plat->bus_format = dev_read_u32_default(dev, "bus-format",
MEDIA_BUS_FMT_RBG888_1X24);
@@ -457,6 +500,20 @@
int ret;
const char *cmd_type;
+ ret = gpio_request_by_name(dev, "edp-bl-gpios", 0,
+ &priv->edp_bl_on, GPIOD_IS_OUT);
+ if (ret && ret != -ENOENT) {
+ printf("%s: Cannot get enable GPIO: %d\n", __func__, ret);
+ return ret;
+ }
+
+ ret = gpio_request_by_name(dev, "edp-bl-en", 0,
+ &priv->edp_bl_en, GPIOD_IS_OUT);
+ if (ret && ret != -ENOENT) {
+ printf("%s: Cannot get enable GPIO: %d\n", __func__, ret);
+ return ret;
+ }
+
ret = gpio_request_by_name(dev, "enable-gpios", 0,
&priv->enable_gpio, GPIOD_IS_OUT);
if (ret && ret != -ENOENT) {
@@ -471,6 +528,34 @@
return ret;
}
+ ret = gpio_request_by_name(dev, "lvds-gpio0", 0,
+ &priv->lvds_gpio0, GPIOD_IS_OUT);
+ if (ret && ret != -ENOENT) {
+ printf("%s: Cannot get lvds-gpio0: %d\n", __func__, ret);
+ return ret;
+ }
+
+ ret = gpio_request_by_name(dev, "lvds-gpio1", 0,
+ &priv->lvds_gpio1, GPIOD_IS_OUT);
+ if (ret && ret != -ENOENT) {
+ printf("%s: Cannot get lvds-gpio1: %d\n", __func__, ret);
+ return ret;
+ }
+
+ ret = gpio_request_by_name(dev, "lvds-gpio2", 0,
+ &priv->lvds_gpio2, GPIOD_IS_OUT);
+ if (ret && ret != -ENOENT) {
+ printf("%s: Cannot get lvds-gpio2: %d\n", __func__, ret);
+ return ret;
+ }
+
+ ret = gpio_request_by_name(dev, "lvds-gpio3", 0,
+ &priv->lvds_gpio3, GPIOD_IS_OUT);
+ if (ret && ret != -ENOENT) {
+ printf("%s: Cannot get lvds-gpio3: %d\n", __func__, ret);
+ return ret;
+ }
+
ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
"backlight", &priv->backlight);
if (ret && ret != -ENOENT) {
--
Gitblit v1.6.2