Handle the PCF2127 RTC chip the same as PCF2129 when init'ing the chip.

This affects the detection of 24-hour vs AM/PM mode... the ampm bit is in a
different location on 2127 and 2129 chips compared to other nxp rtc chips.
I noticed the 2127 case wasn't being handled correctly when I accidentally
misconfiged my system by claiming my PCF2129 was a 2127.
This commit is contained in:
Ian Lepore 2019-07-18 01:30:56 +00:00
parent 5f34d83b8c
commit 634a2d26fd

View File

@ -351,9 +351,18 @@ pcf8523_start(struct nxprtc_softc *sc)
{
int err;
uint8_t cs1, cs3, clkout;
bool is2129;
bool is212x;
is2129 = (sc->chiptype == TYPE_PCA2129 || sc->chiptype == TYPE_PCF2129);
switch (sc->chiptype) {
case TYPE_PCF2127:
case TYPE_PCA2129:
case TYPE_PCF2129:
is212x = true;
break;
default:
is212x = true;
break;
}
/* Read and sanity-check the control registers. */
if ((err = read_reg(sc, PCF85xx_R_CS1, &cs1)) != 0) {
@ -389,7 +398,7 @@ pcf8523_start(struct nxprtc_softc *sc)
* to zero then back to 1, then wait 100ms for the refresh, and
* finally set the bit back to zero with the COF_HIGHZ write.
*/
if (is2129) {
if (is212x) {
clkout = PCF2129_B_CLKOUT_HIGHZ;
if ((err = write_reg(sc, PCF8523_R_TMR_CLKOUT,
clkout)) != 0) {
@ -429,7 +438,7 @@ pcf8523_start(struct nxprtc_softc *sc)
device_printf(sc->dev, "WARNING: RTC battery is low\n");
/* Remember whether we're running in AM/PM mode. */
if (is2129) {
if (is212x) {
if (cs1 & PCF2129_B_CS1_12HR)
sc->use_ampm = true;
} else {