mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
UPSTREAM: pcf8523: Fix wrong initialization of several registers
In the case where the RTC is initialized after the battery is completely drained the bits for power_mode and cof_selection are set up with wrongly applied masks. In the case where the RTC is re-initialized again with no power-loss after the last initialization the bits for cap_sel, power_mode and cof_selection are not shifted to the right position. Both errors lead to a wrong initialization of the RTC and in turn to a way larger current consumption (instead of 120 nA the RTC current rises to over 2 A). This patch fixes both errors and the current consumption is in the right range again. TEST=booted mc_bdx1 and verified current consumption of RTC BUG=None BRANCH=None Signed-off-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-on: https://review.coreboot.org/17829 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Martin Roth <martinroth@google.com> Change-Id: I8594f6ac121a175844393952db2169dbc5cbd2b2 Reviewed-on: https://chromium-review.googlesource.com/420842 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
parent
dc2140664d
commit
dc75b6a1d5
1 changed files with 5 additions and 5 deletions
|
@ -63,15 +63,15 @@ static void pcf8523_init(struct device *dev)
|
||||||
* corrupted and OS bit was not set. */
|
* corrupted and OS bit was not set. */
|
||||||
reg = smbus_read_byte(dev, CTRL_REG_1);
|
reg = smbus_read_byte(dev, CTRL_REG_1);
|
||||||
reg &= ~(STOP_BIT | CAP_SEL);
|
reg &= ~(STOP_BIT | CAP_SEL);
|
||||||
reg |= config->cap_sel;
|
reg |= ((!!config->cap_sel) << 7);
|
||||||
smbus_write_byte(dev, CTRL_REG_1, reg);
|
smbus_write_byte(dev, CTRL_REG_1, reg);
|
||||||
reg = smbus_read_byte(dev, CTRL_REG_3);
|
reg = smbus_read_byte(dev, CTRL_REG_3);
|
||||||
reg &= ~PM_MASK;
|
reg &= ~PM_MASK;
|
||||||
reg |= config->power_mode;
|
reg |= ((config->power_mode & 0x07) << 5);
|
||||||
smbus_write_byte(dev, CTRL_REG_3, reg);
|
smbus_write_byte(dev, CTRL_REG_3, reg);
|
||||||
reg = smbus_read_byte(dev, TMR_CLKOUT_REG);
|
reg = smbus_read_byte(dev, TMR_CLKOUT_REG);
|
||||||
reg &= ~COF_MASK;
|
reg &= ~COF_MASK;
|
||||||
reg |= config->cof_selection;
|
reg |= ((config->cof_selection & 0x07) << 3);
|
||||||
smbus_write_byte(dev, TMR_CLKOUT_REG, reg);
|
smbus_write_byte(dev, TMR_CLKOUT_REG, reg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ static void pcf8523_init(struct device *dev)
|
||||||
((!!config->tmrA_int_en) << 1) |
|
((!!config->tmrA_int_en) << 1) |
|
||||||
(!!config->tmrB_int_en));
|
(!!config->tmrB_int_en));
|
||||||
|
|
||||||
smbus_write_byte(dev, CTRL_REG_3, ((config->power_mode & 0x03) << 5) |
|
smbus_write_byte(dev, CTRL_REG_3, ((config->power_mode & 0x07) << 5) |
|
||||||
((!!config->bat_switch_int_en) << 1) |
|
((!!config->bat_switch_int_en) << 1) |
|
||||||
(!!config->bat_low_int_en));
|
(!!config->bat_low_int_en));
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ static void pcf8523_init(struct device *dev)
|
||||||
|
|
||||||
smbus_write_byte(dev, TMR_CLKOUT_REG, ((!!config->tmrA_int_mode) << 7) |
|
smbus_write_byte(dev, TMR_CLKOUT_REG, ((!!config->tmrA_int_mode) << 7) |
|
||||||
((!!config->tmrB_int_mode) << 6) |
|
((!!config->tmrB_int_mode) << 6) |
|
||||||
((config->cof_selection & 0x38) << 3) |
|
((config->cof_selection & 0x07) << 3) |
|
||||||
((config->tmrA_mode & 0x03) << 1) |
|
((config->tmrA_mode & 0x03) << 1) |
|
||||||
(!!config->tmrB_mode));
|
(!!config->tmrB_mode));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue