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:01 UTC

[incubator-nuttx] branch master updated (08007dc -> b16eea4)

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 08007dc  ramtron:Remove errant code and definitions
     new e20becd  feature: charge: add add chipid ioctl api
     new b16eea4  feat: charger: add operation to get out voltage

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 drivers/power/battery_charger.c       | 20 ++++++++++++++++++++
 drivers/power/battery_gauge.c         | 10 ++++++++++
 drivers/power/battery_monitor.c       | 10 ++++++++++
 include/nuttx/power/battery_charger.h | 10 ++++++++++
 include/nuttx/power/battery_gauge.h   | 11 +++++++++++
 include/nuttx/power/battery_ioctl.h   |  2 ++
 include/nuttx/power/battery_monitor.h |  6 ++++++
 7 files changed, 69 insertions(+)

[incubator-nuttx] 02/02: feat: charger: add operation to get out voltage

Posted by ag...@apache.org.
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 b16eea4f14a50ff178baf6043a6f9d6d34f906b7
Author: zhangguoliang <zh...@xiaomi.com>
AuthorDate: Mon Nov 8 19:46:56 2021 +0800

    feat: charger: add operation to get out voltage
    
    Signed-off-by: zhangguoliang <zh...@xiaomi.com>
---
 drivers/power/battery_charger.c       | 10 ++++++++++
 include/nuttx/power/battery_charger.h |  4 ++++
 include/nuttx/power/battery_ioctl.h   |  1 +
 3 files changed, 15 insertions(+)

diff --git a/drivers/power/battery_charger.c b/drivers/power/battery_charger.c
index 35e883a..ea62a10 100644
--- a/drivers/power/battery_charger.c
+++ b/drivers/power/battery_charger.c
@@ -370,6 +370,16 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd,
         }
         break;
 
+      case BATIOC_GET_VOLTAGE:
+        {
+          FAR int *outvoltsp = (FAR int *)((uintptr_t)arg);
+          if (outvoltsp)
+            {
+              ret = dev->ops->get_voltage(dev, outvoltsp);
+            }
+        }
+        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 6829925..eee6348 100644
--- a/include/nuttx/power/battery_charger.h
+++ b/include/nuttx/power/battery_charger.h
@@ -122,6 +122,10 @@ struct battery_charger_operations_s
   /* Get chip id */
 
   int (*chipid)(struct battery_charger_dev_s *dev, unsigned int *value);
+
+  /* Get the actual output voltage for charging */
+
+  int (*get_voltage)(struct battery_charger_dev_s *dev, 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 6aa9b7d..90be461 100644
--- a/include/nuttx/power/battery_ioctl.h
+++ b/include/nuttx/power/battery_ioctl.h
@@ -55,6 +55,7 @@
 #define BATIOC_CLEARFAULTS   _BATIOC(0x000F)
 #define BATIOC_COULOMBS      _BATIOC(0x0010)
 #define BATIOC_CHIPID        _BATIOC(0x0011)
+#define BATIOC_GET_VOLTAGE   _BATIOC(0x0012)
 
 /* Special input values for BATIOC_INPUT_CURRENT that may optionally
  * be supported by lower-half driver:

[incubator-nuttx] 01/02: feature: charge: add add chipid ioctl api

Posted by ag...@apache.org.
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 */