浏览代码

添加vbat

monkeylqd 2 天之前
父节点
当前提交
c560f0a939
共有 1 个文件被更改,包括 23 次插入0 次删除
  1. 23 0
      fan.c

+ 23 - 0
fan.c

@@ -4142,6 +4142,25 @@ static ssize_t voltage_vcore_store(struct kobject *kobj, struct kobj_attribute *
 }
 
 
+static ssize_t voltage_vbat_show(struct kobject *kobj, struct kobj_attribute *attr,
+                         char *buf)
+{
+	int vlotage = 0;
+    uint8_t raw;
+	raw = hwm_read_reg_retry(IT8786_HWM_BASE_DEFAULT, 0x28);
+
+	vlotage = vin_raw_to_volt(raw, 10, 10);
+
+	return sprintf(buf, "%d", vlotage);
+}
+
+static ssize_t voltage_vbat_store(struct kobject *kobj, struct kobj_attribute *attr,
+                                 const char *buf, size_t count)
+{
+    return -EINVAL;
+}
+
+
 static ssize_t voltage_5v_show(struct kobject *kobj, struct kobj_attribute *attr,
                          char *buf)
 {
@@ -4183,6 +4202,9 @@ static ssize_t voltage_12v_store(struct kobject *kobj, struct kobj_attribute *at
     return -EINVAL;
 }
 
+static struct kobj_attribute voltage_vbat =
+    __ATTR(voltage_vbat, 0644, voltage_vbat_show, voltage_vbat_store);
+
 static struct kobj_attribute voltage_vcore =
     __ATTR(voltage_vcore, 0644, voltage_vcore_show, voltage_vcore_store);
 
@@ -4236,6 +4258,7 @@ static struct attribute *fan_attrs[] = {
     &power_flag.attr,
     &ac_power.attr,
     &voltage_vcore.attr,
+	&voltage_vbat.attr,
     &voltage_5v.attr,
     &voltage_12v.attr,
     NULL,