[Feature][T106][task-view-1364][ADC] add sys node query ADC modification
Only Configure:No
Affected branch:master
Affected module:ADC
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update:Yes
Change-Id: I997a6742b467e8f8e78087a6aac4b6131a64058f
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-adc.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-adc.c
index 830630d..f79c485 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-adc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-adc.c
@@ -17,6 +17,9 @@
//#include <linux/wakelock.h>
#include <linux/pm_wakeup.h>
+u32 adc_query_count = 3;
+EXPORT_SYMBOL(adc_query_count);
+
#define ZX234290_VBAT_ADC_COMPENDATE_VALUE 50
typedef enum adc_channel
{
@@ -352,7 +355,7 @@
**************************************************************************/
uint get_battery_voltage(void)
{
- int counter = 3;
+ int counter = adc_query_count;
int index=0;
int tmpValue=0,totalValue=0;
uint avgValue;
@@ -381,7 +384,7 @@
**************************************************************************/
uint get_adc1_voltage(void)
{
- int counter = 3;
+ int counter = adc_query_count;
int index=0;
int tmpValue=0,totalValue=0;
uint avgValue;
@@ -411,7 +414,7 @@
//extern struct wake_lock adc_wake_lock;
uint get_adc2_voltage(void)
{
- int counter = 3;
+ int counter = adc_query_count;
int index=0;
int tmpValue=0,totalValue=0;
uint avgValue;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-core.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-core.c
index 6da76d2..172c551 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-core.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mfd/zx234290-core.c
@@ -30,6 +30,7 @@
#include <dma_cfg.h>
#include <linux/reboot.h>
+extern u32 adc_query_count;
#define USER_RST_TO_NORMAL 1
@@ -536,6 +537,23 @@
DEFINE_SIMPLE_ATTRIBUTE(fops_adc_ro, debugfs_adc_get, NULL, "%llumV\n");
+static int debugfs_adc_count_set(void *data, u64 val)
+{
+ if (val > 0 && val <= 3) {
+ adc_query_count = (u32)val;
+ return 0;
+ }
+ return -EINVAL;
+}
+
+static int debugfs_adc_count_get(void *data, u64 *val)
+{
+ *val = adc_query_count;
+ return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(fops_adc_count, debugfs_adc_count_get, debugfs_adc_count_set, "%llu\n");
+
static struct dentry *g_pmu_root;
extern u32 int_irq_times;
@@ -579,6 +597,18 @@
dev_err(zx234290->dev, "debugfs_create_dir err=%d\n", IS_ERR(node));
goto err;
}
+ // Add node to set ADC query count
+ node = debugfs_create_file("set_adc_count", S_IRUGO | S_IWUGO, root, NULL, &fops_adc_count);
+ if (!node){
+ dev_err(zx234290->dev, "debugfs_create_dir err=%d\n", IS_ERR(node));
+ goto err;
+ }
+ // Add node to get ADC query count
+ node = debugfs_create_file("get_adc_count", S_IRUGO, root, NULL, &fops_adc_count);
+ if (!node){
+ dev_err(zx234290->dev, "debugfs_create_dir err=%d\n", IS_ERR(node));
+ goto err;
+ }
//print u32
debugfs_create_u32("irq_cnt", S_IRUGO, root, &int_irq_times);