You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/12/04 15:52:36 UTC

[GitHub] kasjer closed pull request #1541: adp5061: Make charge_control dependency optional

kasjer closed pull request #1541: adp5061: Make charge_control dependency optional
URL: https://github.com/apache/mynewt-core/pull/1541
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/drivers/chg_ctrl/adp5061/include/adp5061/adp5061.h b/hw/drivers/chg_ctrl/adp5061/include/adp5061/adp5061.h
index 242ed0cf1b..f70a8d6b86 100644
--- a/hw/drivers/chg_ctrl/adp5061/include/adp5061/adp5061.h
+++ b/hw/drivers/chg_ctrl/adp5061/include/adp5061/adp5061.h
@@ -24,7 +24,9 @@
 #include "os/os_dev.h"
 #include "syscfg/syscfg.h"
 #include "os/os_time.h"
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
 #include "charge-control/charge_control.h"
+#endif
 #if MYNEWT_VAL(BUS_DRIVER_PRESENT)
 #include "bus/bus_driver.h"
 #include "bus/i2c.h"
@@ -49,10 +51,13 @@ struct adp5061_config {
 struct adp5061_dev {
 #if MYNEWT_VAL(BUS_DRIVER_PRESENT)
     struct bus_i2c_node     a_node;
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
+    struct charge_control   a_chg_ctrl;
+#endif
 #else
     struct os_dev           a_dev;
-#endif
     struct charge_control   a_chg_ctrl;
+#endif
     struct adp5061_config   a_cfg;
     os_time_t               a_last_read_time;
 };
diff --git a/hw/drivers/chg_ctrl/adp5061/pkg.yml b/hw/drivers/chg_ctrl/adp5061/pkg.yml
index 6c4ba79e63..90590de0f7 100644
--- a/hw/drivers/chg_ctrl/adp5061/pkg.yml
+++ b/hw/drivers/chg_ctrl/adp5061/pkg.yml
@@ -27,9 +27,11 @@ pkg.keywords:
 pkg.deps:
     - "@apache-mynewt-core/kernel/os"
     - '@apache-mynewt-core/hw/hal'
-    - '@apache-mynewt-core/hw/charge-control'
     - '@apache-mynewt-core/hw/util/i2cn'
 
+pkg.deps.!BUS_DRIVER_PRESENT||ADP5061_USE_CHARGE_CONTROL:
+    - '@apache-mynewt-core/hw/charge-control'
+
 pkg.deps.ADP5061_CLI:
     - '@apache-mynewt-core/sys/shell'
     - '@apache-mynewt-core/util/parse'
diff --git a/hw/drivers/chg_ctrl/adp5061/src/adp5061.c b/hw/drivers/chg_ctrl/adp5061/src/adp5061.c
index 8175070535..c081f1ebec 100644
--- a/hw/drivers/chg_ctrl/adp5061/src/adp5061.c
+++ b/hw/drivers/chg_ctrl/adp5061/src/adp5061.c
@@ -34,7 +34,9 @@
 #endif
 #include <adp5061/adp5061.h>
 #include <bsp/bsp.h>
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
 #include <charge-control/charge_control.h>
+#endif
 #include "adp5061_priv.h"
 
 /**
@@ -63,6 +65,7 @@ static const struct adp5061_config default_config = {
     .iend = 0x01,
 };
 
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
 #if MYNEWT_VAL(ADP5061_INT_PIN) >= 0
 /**
 * ADP5061 interrupt handler CB
@@ -99,6 +102,7 @@ adp5061_isr(void *arg){
     os_eventq_put(os_eventq_dflt_get(), &interrupt_handler);
 }
 #endif
+#endif
 
 static int
 adp5061_write_configuration(struct adp5061_dev *dev)
@@ -427,6 +431,7 @@ adp5061_enable_int(struct adp5061_dev *dev, uint8_t mask)
     return adp5061_set_reg(dev, REG_INT_EN, mask);
 }
 
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
 static int
 adp5061_chg_ctrl_read(struct charge_control *cc, charge_control_type_t type,
         charge_control_data_func_t data_func, void *data_arg, uint32_t timeout)
@@ -602,12 +607,15 @@ static const struct charge_control_driver g_adp5061_chg_ctrl_driver = {
     .ccd_enable = adp5061_chg_ctrl_enable,
     .ccd_disable = adp5061_chg_ctrl_disable,
 };
+#endif /* ADP5061_USE_CHARGE_CONTROL */
 
 int
 adp5061_init(struct os_dev *dev, void *arg)
 {
     struct adp5061_dev *adp5061 = (struct adp5061_dev *)dev;
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
     struct charge_control *cc;
+#endif
     const struct adp5061_config *cfg;
     uint8_t device_id;
     int rc;
@@ -617,6 +625,7 @@ adp5061_init(struct os_dev *dev, void *arg)
         goto err;
     }
 
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
     cc = &adp5061->a_chg_ctrl;
 
     rc = charge_control_init(cc, dev);
@@ -637,6 +646,7 @@ adp5061_init(struct os_dev *dev, void *arg)
 
     charge_control_set_type_mask(cc,
             CHARGE_CONTROL_TYPE_STATUS | CHARGE_CONTROL_TYPE_FAULT);
+#endif /* ADP5061_USE_CHARGE_CONTROL */
 
     cfg = &default_config;
 
@@ -659,10 +669,13 @@ adp5061_init(struct os_dev *dev, void *arg)
         goto err;
     }
 
+#if MYNEWT_VAL(ADP5061_USE_CHARGE_CONTROL)
     rc = charge_control_mgr_register(cc);
     if (rc) {
         goto err;
     }
+#endif /* ADP5061_USE_CHARGE_CONTROL */
+
 #if MYNEWT_VAL(ADP5061_CLI)
     adp5061_shell_init(adp5061);
 #endif
diff --git a/hw/drivers/chg_ctrl/adp5061/syscfg.yml b/hw/drivers/chg_ctrl/adp5061/syscfg.yml
index feb16e4ef8..0f8e75c5f9 100644
--- a/hw/drivers/chg_ctrl/adp5061/syscfg.yml
+++ b/hw/drivers/chg_ctrl/adp5061/syscfg.yml
@@ -39,3 +39,6 @@ syscfg.defs:
     ADP5061_CLI_DECODE:
         description: 'Decode registere fields in shell'
         value: 0
+    ADP5061_USE_CHARGE_CONTROL:
+        description: 'Enable charge control integration'
+        value: 1


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services