You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2021/11/26 10:17:02 UTC
[incubator-nuttx] 01/02: feature: charge: add add chipid ioctl api
This is an automated email from the ASF dual-hosted git repository.
aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit e20becd91b5e9207783b431e23848e623db4a2e3
Author: weizhifang <we...@xiaomi.com>
AuthorDate: Wed Oct 27 14:39:20 2021 +0800
feature: charge: add add chipid ioctl api
1.add chipid ioctl api to battery monitor code
2.add chipid itctl api to battery charger code
3.add chipid itctl api to battery gauge code
Signed-off-by: weizhifang <we...@xiaomi.com>
---
drivers/power/battery_charger.c | 10 ++++++++++
drivers/power/battery_gauge.c | 10 ++++++++++
drivers/power/battery_monitor.c | 10 ++++++++++
include/nuttx/power/battery_charger.h | 6 ++++++
include/nuttx/power/battery_gauge.h | 11 +++++++++++
include/nuttx/power/battery_ioctl.h | 1 +
include/nuttx/power/battery_monitor.h | 6 ++++++
7 files changed, 54 insertions(+)
diff --git a/drivers/power/battery_charger.c b/drivers/power/battery_charger.c
index 173176a..35e883a 100644
--- a/drivers/power/battery_charger.c
+++ b/drivers/power/battery_charger.c
@@ -360,6 +360,16 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd,
}
break;
+ case BATIOC_CHIPID:
+ {
+ FAR unsigned int *ptr = (FAR unsigned int *)((uintptr_t)arg);
+ if (ptr)
+ {
+ ret = dev->ops->chipid(dev, ptr);
+ }
+ }
+ break;
+
default:
_err("ERROR: Unrecognized cmd: %d\n", cmd);
ret = -ENOTTY;
diff --git a/drivers/power/battery_gauge.c b/drivers/power/battery_gauge.c
index 2f6ea83..69377ae 100644
--- a/drivers/power/battery_gauge.c
+++ b/drivers/power/battery_gauge.c
@@ -348,6 +348,16 @@ static int bat_gauge_ioctl(FAR struct file *filep,
}
break;
+ case BATIOC_CHIPID:
+ {
+ FAR unsigned int *ptr = (FAR unsigned int *)((uintptr_t)arg);
+ if (ptr)
+ {
+ ret = dev->ops->chipid(dev, ptr);
+ }
+ }
+ break;
+
default:
_err("ERROR: Unrecognized cmd: %d\n", cmd);
ret = -ENOTTY;
diff --git a/drivers/power/battery_monitor.c b/drivers/power/battery_monitor.c
index a4cacad..31eec41 100644
--- a/drivers/power/battery_monitor.c
+++ b/drivers/power/battery_monitor.c
@@ -427,6 +427,16 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd,
}
break;
+ case BATIOC_CHIPID:
+ {
+ FAR unsigned int *ptr = (FAR unsigned int *)((uintptr_t)arg);
+ if (ptr)
+ {
+ ret = dev->ops->chipid(dev, ptr);
+ }
+ }
+ break;
+
default:
_err("ERROR: Unrecognized cmd: %d\n", cmd);
ret = -ENOTTY;
diff --git a/include/nuttx/power/battery_charger.h b/include/nuttx/power/battery_charger.h
index 5ad01c1..6829925 100644
--- a/include/nuttx/power/battery_charger.h
+++ b/include/nuttx/power/battery_charger.h
@@ -78,6 +78,8 @@
* BATIOC_OPERATE - Perform miscellaneous, device-specific charger operation.
* Input value: An uintptr_t that can hold a pointer to struct
* batio_operate_msg_s.
+ * BATIOC_CHIPID -Get the charger chip id.
+ * Input value: A pointer to type unsigned int.
*/
/****************************************************************************
@@ -116,6 +118,10 @@ struct battery_charger_operations_s
/* Do device specific operation */
int (*operate)(struct battery_charger_dev_s *dev, uintptr_t param);
+
+ /* Get chip id */
+
+ int (*chipid)(struct battery_charger_dev_s *dev, unsigned int *value);
};
/* This structure defines the battery driver state structure */
diff --git a/include/nuttx/power/battery_gauge.h b/include/nuttx/power/battery_gauge.h
index 5fa2fd4..29fea0f 100644
--- a/include/nuttx/power/battery_gauge.h
+++ b/include/nuttx/power/battery_gauge.h
@@ -73,6 +73,13 @@
* (SoC). The returned value is a fixed precision percentage of the
* batteries full capacity.
* Input value: A pointer to type b16_t.
+ * BATIOC_CURRENT - Return the current of the battery . The returned value
+ * is a fixed precision number in units of ma.
+ * Input value: A pointer to type b16_t.
+ * BATIOC_TEMPERATURE- Return the current temperature of the battery.
+ * Input value: A pointer to type b8_t.
+ * BATIOC_CHIPID- Return the chip id of the gauge.
+ * Input value: A pointer to type unsigned int.
*/
/****************************************************************************
@@ -107,6 +114,10 @@ struct battery_gauge_operations_s
/* Battery temp */
int (*temp)(struct battery_gauge_dev_s *dev, b8_t *value);
+
+ /* Battery chipid */
+
+ int (*chipid)(struct battery_gauge_dev_s *dev, unsigned int *value);
};
/* This structure defines the battery driver state structure */
diff --git a/include/nuttx/power/battery_ioctl.h b/include/nuttx/power/battery_ioctl.h
index df08456..6aa9b7d 100644
--- a/include/nuttx/power/battery_ioctl.h
+++ b/include/nuttx/power/battery_ioctl.h
@@ -54,6 +54,7 @@
#define BATIOC_CHGDSG _BATIOC(0x000E)
#define BATIOC_CLEARFAULTS _BATIOC(0x000F)
#define BATIOC_COULOMBS _BATIOC(0x0010)
+#define BATIOC_CHIPID _BATIOC(0x0011)
/* Special input values for BATIOC_INPUT_CURRENT that may optionally
* be supported by lower-half driver:
diff --git a/include/nuttx/power/battery_monitor.h b/include/nuttx/power/battery_monitor.h
index 6f14740..0c1e260 100644
--- a/include/nuttx/power/battery_monitor.h
+++ b/include/nuttx/power/battery_monitor.h
@@ -100,6 +100,8 @@
* BATIOC_OPERATE - Perform miscellaneous, device-specific charger operation.
* Input value: An uintptr_t that can hold a pointer to struct
* batio_operate_msg_s.
+ * BATIOC_CHIPID -Get the chip id.
+ * Input value: A pointer to type unsigned int.
*/
/****************************************************************************
@@ -286,6 +288,10 @@ struct battery_monitor_operations_s
/* Do device specific operation */
int (*operate)(struct battery_monitor_dev_s *dev, uintptr_t param);
+
+ /* Get chip id */
+
+ int (*chipid)(struct battery_charger_dev_s *dev, unsigned int *value);
};
/* This structure defines the battery driver state structure */