summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/imx233/powermgmt-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 17:16:48 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 18:21:43 +0200
commit7c5b65b9d234f819447195e3f852d9b59a225813 (patch)
treeb49f4741fe792b07456bfc7ad4e71a7edbb01c0d /firmware/target/arm/imx233/powermgmt-imx233.c
parentb73fda3a05f78a3ce78708e319f2eb719fd55719 (diff)
downloadrockbox-7c5b65b9d234f819447195e3f852d9b59a225813.tar.gz
rockbox-7c5b65b9d234f819447195e3f852d9b59a225813.tar.bz2
rockbox-7c5b65b9d234f819447195e3f852d9b59a225813.zip
imx233: rewrite power using new registers
Change-Id: Ifbee91161220419f4d1750672b5c4ae3537cefca
Diffstat (limited to 'firmware/target/arm/imx233/powermgmt-imx233.c')
-rw-r--r--firmware/target/arm/imx233/powermgmt-imx233.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c
index 31f9ac7659..b155b5fcb8 100644
--- a/firmware/target/arm/imx233/powermgmt-imx233.c
+++ b/firmware/target/arm/imx233/powermgmt-imx233.c
@@ -41,7 +41,7 @@ static int timeout_4p2_ilimit_increase; /* timeout before increasing 4p2 ilimit
int _battery_voltage(void)
{
/* battery value is in 8mV LSB */
- return __XTRACT(HW_POWER_BATTMONITOR, BATT_VAL) * 8;
+ return BF_RD(POWER_BATTMONITOR, BATT_VAL) * 8;
}
void powermgmt_init_target(void)
@@ -49,12 +49,12 @@ void powermgmt_init_target(void)
imx233_power_set_charge_current(IMX233_CHARGE_CURRENT);
imx233_power_set_stop_current(IMX233_STOP_CURRENT);
/* assume that adc_init was called and battery monitoring via LRADC setup */
- __REG_SET(HW_POWER_BATTMONITOR) = HW_POWER_BATTMONITOR__ENBATADJ;
+ BF_WR(POWER_BATTMONITOR, EN_BATADJ, 1);
/* make sure we are in a known state: disable charger and 4p2 */
- __REG_SET(HW_POWER_CHARGE) = HW_POWER_CHARGE__PWD_BATTCHRG;
- __REG_CLR(HW_POWER_DCDC4P2) = HW_POWER_DCDC4P2__ENABLE_DCDC |
- HW_POWER_DCDC4P2__ENABLE_4P2;
- __REG_SET(HW_POWER_5VCTRL) = HW_POWER_5VCTRL__PWD_CHARGE_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);
charge_state = DISCHARGING;
}
@@ -68,10 +68,10 @@ void charging_algorithm_step(void)
logf("pwrmgmt: * -> discharging");
logf("pwrmgmt: disable charger and 4p2");
/* 5V has been lost: disable 4p2 power rail */
- __REG_SET(HW_POWER_CHARGE) = HW_POWER_CHARGE__PWD_BATTCHRG;
- __REG_CLR(HW_POWER_DCDC4P2) = HW_POWER_DCDC4P2__ENABLE_DCDC |
- HW_POWER_DCDC4P2__ENABLE_4P2;
- __REG_SET(HW_POWER_5VCTRL) = HW_POWER_5VCTRL__PWD_CHARGE_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);
charge_state = DISCHARGING;
}
/* battery -> 5v transition */
@@ -80,11 +80,11 @@ void charging_algorithm_step(void)
logf("pwrmgmt: discharging -> trickle");
logf("pwrmgmt: begin charging 4p2");
/* 5V has been detected: prepare 4.2V power rail for activation */
- __REG_SET(HW_POWER_DCDC4P2) = HW_POWER_DCDC4P2__ENABLE_4P2;
- __REG_SET(HW_POWER_CHARGE) = HW_POWER_CHARGE__ENABLE_LOAD;
- __FIELD_SET(HW_POWER_5VCTRL, CHARGE_4P2_ILIMIT, 1);
- __REG_CLR(HW_POWER_5VCTRL) = HW_POWER_5VCTRL__PWD_CHARGE_4P2;// FIXME: manual error ?
- __REG_SET(HW_POWER_DCDC4P2) = HW_POWER_DCDC4P2__ENABLE_DCDC;
+ BF_WR(POWER_DCDC4P2, ENABLE_4P2, 1);
+ BF_SET(POWER_CHARGE, ENABLE_LOAD);
+ BF_WR(POWER_5VCTRL, CHARGE_4P2_ILIMIT, 1);
+ BF_CLR(POWER_5VCTRL, PWD_CHARGE_4P2);// FIXME: manual error ?
+ BF_WR(POWER_DCDC4P2, ENABLE_DCDC, 1);
timeout_4p2_ilimit_increase = current_tick + HZ / 100;
charge_state = TRICKLE;
}
@@ -92,10 +92,10 @@ void charging_algorithm_step(void)
{
/* if 4.2V current limit has not reached 780mA, increase it slowly to
* charge the 4.2V capacitance */
- if(__XTRACT(HW_POWER_5VCTRL, CHARGE_4P2_ILIMIT) != 0x3f)
+ if(BF_RD(POWER_5VCTRL, CHARGE_4P2_ILIMIT) != 0x3f)
{
//logf("pwrmgmt: incr 4.2 ilimit");
- HW_POWER_5VCTRL += 1 << HW_POWER_5VCTRL__CHARGE_4P2_ILIMIT_BP;
+ HW_POWER_5VCTRL += BF_POWER_5VCTRL_CHARGE_4P2_ILIMIT(1);
timeout_4p2_ilimit_increase = current_tick + HZ / 100;
}
/* we've reached the maximum, take action */
@@ -104,12 +104,12 @@ void charging_algorithm_step(void)
logf("pwrmgmt: enable dcdc and charger");
logf("pwrmgmt: trickle -> charging");
/* adjust arbitration between 4.2 and battery */
- __FIELD_SET(HW_POWER_DCDC4P2, CMPTRIP, 0); /* 85% */
- __FIELD_SET(HW_POWER_DCDC4P2, DROPOUT_CTRL, 0xe); /* select greater, 200 mV drop */
- __REG_CLR(HW_POWER_5VCTRL) = HW_POWER_5VCTRL__DCDC_XFER;
- __REG_SET(HW_POWER_5VCTRL) = HW_POWER_5VCTRL__ENABLE_DCDC;
+ 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 */
- __REG_CLR(HW_POWER_CHARGE) = HW_POWER_CHARGE__PWD_BATTCHRG;
+ BF_CLR(POWER_CHARGE, PWD_BATTCHRG);
charge_state = CHARGING;
timeout_charging = current_tick + IMX233_CHARGING_TIMEOUT;
}
@@ -120,11 +120,11 @@ void charging_algorithm_step(void)
logf("pwrmgmt: charging timeout exceeded!");
logf("pwrmgmt: charging -> error");
/* stop charging */
- __REG_SET(HW_POWER_5VCTRL) = HW_POWER_5VCTRL__PWD_CHARGE_4P2;
+ BF_SET(POWER_5VCTRL, PWD_CHARGE_4P2);
/* goto error state */
charge_state = CHARGE_STATE_ERROR;
}
- else if(charge_state == CHARGING && !(HW_POWER_STS & HW_POWER_STS__CHRGSTS))
+ else if(charge_state == CHARGING && !BF_RD(POWER_STS, CHRGSTS))
{
logf("pwrmgmt: topping off");
logf("pwrmgmt: charging -> topoff");
@@ -136,7 +136,7 @@ void charging_algorithm_step(void)
logf("pwrmgmt: charging finished");
logf("pwrmgmt: topoff -> disabled");
/* stop charging */
- __REG_SET(HW_POWER_CHARGE) = HW_POWER_CHARGE__PWD_BATTCHRG;
+ BF_SET(POWER_CHARGE, PWD_BATTCHRG);
charge_state = CHARGE_STATE_DISABLED;
}
}