openharmony hdf框架gt911触摸驱动移植

openharmony提供了hdf的驱动框架,今天以gt911触摸驱动的例子记录一下。首先hdf要加载进Linux的driver中,在Linux源码/driver/hdf目录有如下文件。

 framwork和khdf两个软链接文件一定要链接成功。

在hdf的设备树中加入gt911的文件信息

/home/xu/openharmony/vendor/hihope/rk3568/hdf_config/khdf/device_info/device_info.hcs
 device_touch_chip :: device {
                device0 :: deviceNode {
                    policy = 0;
                    priority = 130;
                    preload = 0;
                    permission = 0660;
                    moduleName = "HDF_TOUCH_GT911";
                    serviceName = "hdf_touch_gt911_service";
                    deviceMatchAttr = "zsj_gt911_5p5";
                }

然后加入针对触摸板硬件连接的信息。

/home/xu/openharmony/vendor/hihope/rk3568/hdf_config/khdf/input/input_config.hcs
root {
    input_config {
        touchConfig {
            touch0 {
                boardConfig {
                    match_attr = "touch_device1";
                    inputAttr {
                        /* 0:touch 1:key 2:keyboard 3:mouse 4:button 5:crown 6:encoder */
                        inputType = 0;
                        solutionX = 1024;
                        solutionY = 600;
                        devName = "main_touch";
                    }

// Hi3516DV300-Runhe  gt911--5p5 & 4p0
                    busConfig {
                        // 0:i2c 1:spi
                        busType = 0;
                        busNum = 1;
                        clkGpio = 11;
                        dataGpio = 12;
                        i2cClkIomux = [0xfdd60000, 0x100];
                        i2cDataIomux = [0xfdd60000, 0x100];
                    }

                    pinConfig {
                        rstGpio = 20;
                        intGpio = 13;
                        rstRegCfg = [0xfdd60000, 0x100];
                        intRegCfg = [0xfdd60000, 0x100];
                    }


                    powerConfig {
                        /* 0:unused 1:ldo 2:gpio 3:pmic */
                        vccType = 2;
                        vccNum = 20;    // gpio20
                        vccValue = 1800;
                        vciType = 1;
                        vciNum = 12;    // ldo12
                        vciValue = 3300;
                    }

                    featureConfig {
                        capacitanceTest = 0;
                        gestureMode = 0;
                        gloverMOde = 0;
                        coverMode = 0;
                        chargerMode = 0;
                        knuckleMode = 0;
                    }
                }

                chipConfig {
                    template touchChip {
                        match_attr = "";
                        chipName = "gt911";
                        vendorName = "zsj";
                        chipInfo = "AAAA11222";  // 4-ProjectName, 2-TP IC, 3-TP Module
                        /* 0:i2c 1:spi*/
                        busType = 0;
                        deviceAddr = 0x5D;
                        /* 0:None 1:Rising 2:Failing 4:High-level 8:Low-level */
                        irqFlag = 2;
                        maxSpeed = 400;
                        chipVersion = 0; //parse Coord TypeA
                        powerSequence {
                            /* [type, status, dir , delay]
                                 0:none 1:vcc-1.8v 2:vci-3.3v 3:reset 4:int
                                 0:off or low  1:on or high  2:no ops
                                 0:input  1:output  2:no ops
                                 meanings delay xms, 20: delay 20ms
                             */
                            powerOnSeq = [4, 0, 1, 5,
                                         3, 0, 1, 10,
                                         3, 1, 1, 60,
                                         4, 2, 0, 50];
                            suspendSeq = [3, 0, 2, 10];
                            resumeSeq = [3, 1, 2, 10];
                            powerOffSeq = [3, 0, 2, 10,
                                           1, 0, 2, 20];
                        }
                    }

                    chip0 :: touchChip {
                        match_attr = "zsj_gt911_5p5";
                        chipInfo = "ZIDN45100";  // 4-ProjectName, 2-TP IC, 3-TP Module
                        chipVersion = 0; //parse point by TypeA
                    }
}

hdf中关于触摸的kconfig和Makefile文件。

/home/xu/openharmony/drivers/adapter/khdf/linux/model/input

hdf触摸驱动源文件。

/home/xu/openharmony/drivers/framework/model/input/driver/touchscreen

之后就是驱动的移植了,和Linux很类似,只是架构中调用的函数不同。也可以在以上目录中添加自己的驱动。

你可能感兴趣的:(openharmony,linux,运维,服务器)