Himax 10.36寸 incell觸控除錯

M-kobe發表於2024-09-28

觸控是帶筆的,資料比較大,用的是spi介面。

一、新增驅動:

  drivers/input/touchscreen/hxchipset

二、dts配置

&spi4 {
    status = "okay";
    pinctrl-0 = <&spi4m1_cs0 &spi4m1_cs1 &spi4m1_pins>;
    
    himax_touch@0 {
        compatible = "himax,hxcommon"; 
        reg = <0>;
        spi-max-frequency = <10000000>; 
        status = "okay";
        
        pinctrl-names = "default";
        pinctrl-0 = <&touch_int>;
        himax,irq-gpio =  <&gpio1 RK_PB5 IRQ_TYPE_LEVEL_LOW>;
        himax,rst-gpio = <&gpio1 RK_PB4 GPIO_ACTIVE_HIGH>;
        himax,panel-coords = <0 1200 0 2000>;
        himax,display-coords = <0 1200 0 2000>;
        report_type = <1>;
    };
};

三、新增韌體

diff --git a/device.mk b/device.mk
old mode 100644
new mode 100755
index b454e36..db1b079
--- a/device.mk
+++ b/device.mk
@@ -44,6 +44,8 @@ PRODUCT_COPY_FILES += \
 
 PRODUCT_COPY_FILES += \
     $(LOCAL_PATH)/init.rk3588.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.rk3588.rc \

+       $(LOCAL_PATH)/rk3588s_s/Himax_firmware.bin:$(TARGET_COPY_OUT_VENDOR)/etc/firmware/Himax_firmware.bin \
     $(LOCAL_PATH)/wake_lock_filter.xml:system/etc/wake_lock_filter.xml \

廠家提供正確驅動,驅動正常載入,提供的韌體正常載入(/vendor/etc/firmware/Himax_firmware.bin),如果時序正確,那這時候一般都有觸點了.
如果有觸點,但方向反了或者映象,那一般是韌體沒給對,需要提供正確對應的韌體。

四、除錯過程遇到的一些問題點

  1.觸控不穩定,偶爾休眠喚醒或者開機沒有觸控,那一般都是時序沒有調好,
    VCCD, VSP, VSN, LCM_RST, TP_RST這幾個訊號的時序要控制好:

VSP, VSN時序新增顯示驅動中

diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c
old mode 100644
new mode 100755
index 4e298108a62e..c4e5b96d61f7
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -143,6 +143,9 @@ struct panel_simple {
        struct gpio_desc *reset_gpio;
        struct gpio_desc *hpd_gpio;
 
+       struct gpio_desc *enn_gpio;
+       struct gpio_desc *enp_gpio;
+
        struct drm_display_mode override_mode;
 
        struct drm_dsc_picture_parameter_set *pps;
@@ -465,6 +468,9 @@ static int panel_simple_unprepare(struct drm_panel *panel)
        gpiod_direction_output(p->reset_gpio, 1);
        gpiod_direction_output(p->enable_gpio, 0);
 
+       gpiod_direction_output(p->enn_gpio, 0);
+       gpiod_direction_output(p->enp_gpio, 0);
+
        panel_simple_regulator_disable(p);
 
        if (p->desc->delay.unprepare)
@@ -518,6 +524,9 @@ static int panel_simple_prepare(struct drm_panel *panel)
 
        gpiod_direction_output(p->enable_gpio, 1);
 
+       gpiod_direction_output(p->enn_gpio, 1);
+       gpiod_direction_output(p->enp_gpio, 1);
+
        delay = p->desc->delay.prepare;
        if (p->no_hpd)
                delay += p->desc->delay.hpd_absent_delay;
@@ -810,6 +819,27 @@ static int panel_simple_probe(struct device *dev, const struct pane
l_desc *desc)
                return err;
        }
 
+       panel->enn_gpio = devm_gpiod_get_optional(dev, "enn", GPIOD_ASIS);
+       if (IS_ERR(panel->enn_gpio)) {
+               err = PTR_ERR(panel->enn_gpio);
+               if (err != -EPROBE_DEFER)
+                       dev_err(dev, "failed to get enn GPIO: %d\n", err);
+               return err;
+       }
+
+       panel->enp_gpio = devm_gpiod_get_optional(dev, "enp", GPIOD_ASIS);
+       if (IS_ERR(panel->enp_gpio)) {
+               err = PTR_ERR(panel->enp_gpio);
+               if (err != -EPROBE_DEFER)
+                       dev_err(dev, "failed to get enp GPIO: %d\n", err);
+               return err;
+       }
+
+       gpiod_direction_output(panel->enn_gpio, 1);
+       gpiod_direction_output(panel->enp_gpio, 1);
+
+       msleep(10);
+
        panel->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS);
        if (IS_ERR(panel->reset_gpio)) {
                err = PTR_ERR(panel->reset_gpio);

1.每次開機觸控不行,休眠喚醒後才有觸控。

  需要在u-boot裡面新增VSP, VSN訊號的控制:

diff --git a/drivers/video/drm/rockchip_panel.c b/drivers/video/drm/rockchip_panel.c
old mode 100644
new mode 100755
index de7e5e25c2..80eba26247
--- a/drivers/video/drm/rockchip_panel.c
+++ b/drivers/video/drm/rockchip_panel.c
@@ -67,6 +67,9 @@ struct rockchip_panel_priv {
        struct gpio_desc enable_gpio;
        struct gpio_desc reset_gpio;
 
+       struct gpio_desc enn_gpio;
+       struct gpio_desc enp_gpio;
+
        int cmd_type;
        struct gpio_desc spi_sdi_gpio;
        struct gpio_desc spi_scl_gpio;
@@ -285,6 +288,16 @@ static void panel_simple_prepare(struct rockchip_panel *panel)
        if (plat->delay.prepare)
                mdelay(plat->delay.prepare);
 
+               //wmc add
+       if (dm_gpio_is_valid(&priv->enn_gpio))
+               dm_gpio_set_value(&priv->enn_gpio, 1);
+
+       if (dm_gpio_is_valid(&priv->enp_gpio))
+               dm_gpio_set_value(&priv->enp_gpio, 1);
+
+++ b/drivers/video/drm/rockchip_panel.c
@@ -67,6 +67,9 @@ struct rockchip_panel_priv {
        struct gpio_desc enable_gpio;
        struct gpio_desc reset_gpio;
 
+       struct gpio_desc enn_gpio;
+       struct gpio_desc enp_gpio;
+
        int cmd_type;
        struct gpio_desc spi_sdi_gpio;
        struct gpio_desc spi_scl_gpio;
@@ -285,6 +288,16 @@ static void panel_simple_prepare(struct rockchip_panel *panel)
        if (plat->delay.prepare)
                mdelay(plat->delay.prepare);
 
+               //wmc add
+       if (dm_gpio_is_valid(&priv->enn_gpio))
+               dm_gpio_set_value(&priv->enn_gpio, 1);
+
+       if (dm_gpio_is_valid(&priv->enp_gpio))
+               dm_gpio_set_value(&priv->enp_gpio, 1);
+
+       mdelay(10);
+       /////////////
+
        if (dm_gpio_is_valid(&priv->reset_gpio))
                dm_gpio_set_value(&priv->reset_gpio, 1);
 
@@ -339,6 +352,14 @@ static void panel_simple_unprepare(struct rockchip_panel *panel)
        if (dm_gpio_is_valid(&priv->reset_gpio))
                dm_gpio_set_value(&priv->reset_gpio, 1);
 
+       //wmc add
+       if (dm_gpio_is_valid(&priv->enn_gpio))
+               dm_gpio_set_value(&priv->enn_gpio, 0);
+
+       if (dm_gpio_is_valid(&priv->enp_gpio))
+               dm_gpio_set_value(&priv->enp_gpio, 0);
+       /////////////
+
        if (dm_gpio_is_valid(&priv->enable_gpio))
                dm_gpio_set_value(&priv->enable_gpio, 0);
 
@@ -470,6 +491,20 @@ static int rockchip_panel_probe(struct udevice *dev)
                printf("%s: Cannot get reset GPIO: %d\n", __func__, ret);
                return ret;
        }
+       
+       ret = gpio_request_by_name(dev, "enn-gpios", 0,
+                                  &priv->enn_gpio, GPIOD_IS_OUT);
+       if (ret && ret != -ENOENT) {
+               printf("%s: Cannot get enn GPIO: %d\n", __func__, ret);
+               return ret;
+       }
+
+       ret = gpio_request_by_name(dev, "enp-gpios", 0,
+                                  &priv->enp_gpio, GPIOD_IS_OUT);
+       if (ret && ret != -ENOENT) {
+               printf("%s: Cannot get enp GPIO: %d\n", __func__, ret);
+               return ret;
+       }
 
        ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
                                           "backlight", &priv->backlight);

相關文章