android TP驱动中 生产节点

本文主要介绍

在android系统的TP驱动中,生成device节点,,,

通过cat 节点来获取TP的FW版本


主要函数

device_create_file(dev,&ft5626_attrs[t]);

static struct device_attribute  ft5626_attrs[] = {
    __ATTR(touch_version, S_IRWXU| S_IRWXG| S_IRWXO, ft5626_version_show, ft5626_version_store),
  
static ssize_t ft5626_version_show(struct device *dev, struct device_attribute *attr, char *buf)

static ssize_t ft5626_version_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t _count)




#define FACTORY_DEBUG            1


#ifdef FACTORY_DEBUG
unsigned char uc_reg_value;
unsigned char uc_reg_addr;
#define FTS_REG_FW_VER                        0xA6
#endif


#ifdef FACTORY_DEBUG
static ssize_t ft5626_version_show(struct device *dev, struct device_attribute *attr, char *buf)
{
    int err;    

    uc_reg_addr = FTS_REG_FW_VER;
    
    err = fts_i2c_read(fts_i2c_client, &uc_reg_addr, 1, &uc_reg_value, 1);
    if (err < 0) {
        printk("[FTS]    get FW version failed.\n");
        uc_reg_value = 0;
    }

    return sprintf(buf, "%x\n", uc_reg_value);
}

static ssize_t ft5626_version_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t _count)
{
    return _count;
}

static struct device_attribute  ft5626_attrs[] = {
    __ATTR(touch_version, S_IRWXU| S_IRWXG| S_IRWXO, ft5626_version_show, ft5626_version_store),
   
};

static int  ft5626_create_sysfs(struct device *dev)
{
    int r;
    int t;
    for (t = 0; t < ARRAY_SIZE(ft5626_attrs); t++)
    {
        r = device_create_file(dev,&ft5626_attrs[t]);
        if (r)
        {
            dev_err(dev, "%s: failed to create sysfs file, error = %d\n", __func__, r);
            return r;
        }
    }
    return 0;
}#endif


//probe函数

#ifdef FACTORY_DEBUG
    err = ft5626_create_sysfs(&client->dev);
    if(err) {
        dev_err(&client->dev, "failed to create FACTORY_DEBUG\n");
    }
#endif


生成路径
/sys/devices/pci0000:00/808622C1:05/i2c-5/i2c-FTTH5506:00/touch_versio

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值