summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/imx233/kernel-imx233.c1
-rw-r--r--firmware/target/arm/imx233/power-imx233.c21
-rw-r--r--firmware/target/arm/imx233/powermgmt-imx233.c34
-rw-r--r--firmware/target/arm/imx233/powermgmt-imx233.h1
-rw-r--r--firmware/target/arm/imx233/system-imx233.c2
5 files changed, 32 insertions, 27 deletions
diff --git a/firmware/target/arm/imx233/kernel-imx233.c b/firmware/target/arm/imx233/kernel-imx233.c
index b3760a4..c3ee2e8 100644
--- a/firmware/target/arm/imx233/kernel-imx233.c
+++ b/firmware/target/arm/imx233/kernel-imx233.c
@@ -37,7 +37,6 @@ void tick_start(unsigned int interval_in_ms)
false, &tick_timer);
}
-
void arbiter_init(struct channel_arbiter_t *a, unsigned count)
{
mutex_init(&a->mutex);
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c
index 5041c3b..ccbd12b 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -146,27 +146,6 @@ void imx233_power_init(void)
BF_SET(POWER_CTRL, ENIRQ_VDD5V_GT_VDDIO);
#endif
imx233_icoll_enable_interrupt(INT_SRC_VDD5V, true);
- /* setup linear regulator offsets to 25 mV below to prevent contention between
- * linear regulators and DCDC */
-#if IMX233_SUBTARGET >= 3700
- BF_WR(POWER_VDDDCTRL, LINREG_OFFSET, 2);
- BF_WR(POWER_VDDACTRL, LINREG_OFFSET, 2);
- BF_WR(POWER_VDDIOCTRL, LINREG_OFFSET, 2);
- /* enable DCDC (more efficient) */
- BF_SET(POWER_5VCTRL, ENABLE_DCDC);
-#else
- BF_SET(POWER_5VCTRL, LINREG_OFFSET);
- BF_SET(POWER_5VCTRL, EN_DCDC1);
- BF_SET(POWER_5VCTRL, EN_DCDC2);
-#endif
-
-#if IMX233_SUBTARGET >= 3780
- /* enable a few bits controlling the DC-DC as recommended by Freescale */
- BF_SET(POWER_LOOPCTRL, TOGGLE_DIF);
- BF_SET(POWER_LOOPCTRL, EN_CM_HYST);
- BF_CLR(POWER_LOOPCTRL, EN_RCSCALE);
- BF_SETV(POWER_LOOPCTRL, EN_RCSCALE, 1);
-#endif
}
void power_init(void)
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c
index 8980124..9819406 100644
--- a/firmware/target/arm/imx233/powermgmt-imx233.c
+++ b/firmware/target/arm/imx233/powermgmt-imx233.c
@@ -44,19 +44,46 @@ int _battery_voltage(void)
return BF_RD(POWER_BATTMONITOR, BATT_VAL) * 8;
}
-void powermgmt_init_target(void)
+void imx233_powermgmt_init(void)
{
imx233_power_set_charge_current(IMX233_CHARGE_CURRENT);
imx233_power_set_stop_current(IMX233_STOP_CURRENT);
-#if IMX233_SUBTARGET >= 3780
/* assume that adc_init was called and battery monitoring via LRADC setup */
BF_WR(POWER_BATTMONITOR, EN_BATADJ, 1);
+#if IMX233_SUBTARGET >= 3700
+ /* setup linear regulator offsets to 25 mV below to prevent contention between
+ * linear regulators and DCDC */
+ BF_WR(POWER_VDDDCTRL, LINREG_OFFSET, 2);
+ BF_WR(POWER_VDDACTRL, LINREG_OFFSET, 2);
+ BF_WR(POWER_VDDIOCTRL, LINREG_OFFSET, 2);
+ /* enable DCDC (more efficient) */
+ BF_SET(POWER_5VCTRL, ENABLE_DCDC);
+ BF_CLR(POWER_5VCTRL, DCDC_XFER);
+#else
+ BF_SET(POWER_5VCTRL, LINREG_OFFSET);
+ BF_SET(POWER_5VCTRL, EN_DCDC1);
+ BF_SET(POWER_5VCTRL, EN_DCDC2);
+#endif
+
+#if IMX233_SUBTARGET >= 3780
+ /* enable a few bits controlling the DC-DC as recommended by Freescale */
+ BF_SET(POWER_LOOPCTRL, TOGGLE_DIF);
+ BF_SET(POWER_LOOPCTRL, EN_CM_HYST);
+ BF_CLR(POWER_LOOPCTRL, EN_RCSCALE);
+ BF_SETV(POWER_LOOPCTRL, EN_RCSCALE, 1);
+ /* adjust arbitration between 4.2 and battery */
+ BF_WR(POWER_DCDC4P2, CMPTRIP, 0); /* 85% */
+ BF_WR(POWER_DCDC4P2, DROPOUT_CTRL, 0xe); /* select greater, 200 mV drop */
/* make sure we are in a known state: disable charger and 4p2 */
BF_SET(POWER_CHARGE, PWD_BATTCHRG);
BF_WR(POWER_DCDC4P2, ENABLE_DCDC, 0);
BF_WR(POWER_DCDC4P2, ENABLE_4P2, 0);
BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2);
#endif
+}
+
+void powermgmt_init_target(void)
+{
charge_state = DISCHARGING;
}
@@ -106,9 +133,6 @@ void charging_algorithm_step(void)
{
logf("pwrmgmt: enable dcdc and charger");
logf("pwrmgmt: trickle -> charging");
- /* adjust arbitration between 4.2 and battery */
- BF_WR(POWER_DCDC4P2, CMPTRIP, 0); /* 85% */
- BF_WR(POWER_DCDC4P2, DROPOUT_CTRL, 0xe); /* select greater, 200 mV drop */
BF_CLR(POWER_5VCTRL, DCDC_XFER);
BF_SET(POWER_5VCTRL, ENABLE_DCDC);
/* enable battery charging */
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.h b/firmware/target/arm/imx233/powermgmt-imx233.h
index 8876a2d..07634ec 100644
--- a/firmware/target/arm/imx233/powermgmt-imx233.h
+++ b/firmware/target/arm/imx233/powermgmt-imx233.h
@@ -24,6 +24,7 @@
#include "config.h"
#include "powermgmt.h"
+void imx233_powermgmt_init(void);
void powermgmt_init_target(void);
void charging_algorithm_step(void);
void charging_algorithm_close(void);
diff --git a/firmware/target/arm/imx233/system-imx233.c b/firmware/target/arm/imx233/system-imx233.c
index aa1c216..d1f2cfb 100644
--- a/firmware/target/arm/imx233/system-imx233.c
+++ b/firmware/target/arm/imx233/system-imx233.c
@@ -43,6 +43,7 @@
#include "backlight-target.h"
#include "button.h"
#include "fmradio_i2c.h"
+#include "powermgmt.h"
void imx233_chip_reset(void)
{
@@ -132,6 +133,7 @@ void system_init(void)
imx233_lradc_init();
imx233_power_init();
imx233_i2c_init();
+ imx233_powermgmt_init();
/* make sure auto-slow is disable now, we don't know at which frequency we
* are running and auto-slow could violate constraints on {xbus,hbus} */