On 2/2/23 07:54, Johan Hovold wrote: > On many Qualcomm platforms the PMIC RTC control and time registers are > read-only so that the RTC time can not be updated. Instead an offset s/can not/cannot/ > needs be stored in some machine-specific non-volatile memory, which the > driver can take into account. > > Add support for storing a 32-bit offset from the Epoch in an nvmem cell > so that the RTC time can be set on such platforms. > > Signed-off-by: Johan Hovold <johan+linaro@xxxxxxxxxx> > --- > drivers/rtc/rtc-pm8xxx.c | 141 +++++++++++++++++++++++++++++++++++---- > 1 file changed, 129 insertions(+), 12 deletions(-) > > diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c > index eff2782beeed..372494e82f40 100644 > --- a/drivers/rtc/rtc-pm8xxx.c > +++ b/drivers/rtc/rtc-pm8xxx.c > @@ -1,8 +1,13 @@ > // SPDX-License-Identifier: GPL-2.0-only > -/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. > +/* > + * pm8xxx RTC driver > + * > + * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. > + * Copyright (c) 2023, Linaro Limited > */ > #include <linux/of.h> > #include <linux/module.h> > +#include <linux/nvmem-consumer.h> > #include <linux/init.h> > #include <linux/rtc.h> > #include <linux/platform_device.h> > @@ -49,6 +54,8 @@ struct pm8xxx_rtc_regs { > * @alarm_irq: alarm irq number > * @regs: register description > * @dev: device structure > + * @nvmem_cell: nvmem cell for offset > + * @offset: offset from epoch in seconds > */ > struct pm8xxx_rtc { > struct rtc_device *rtc; > @@ -57,8 +64,60 @@ struct pm8xxx_rtc { > int alarm_irq; > const struct pm8xxx_rtc_regs *regs; > struct device *dev; > + struct nvmem_cell *nvmem_cell; > + u32 offset; > }; > > +static int pm8xxx_rtc_read_nvmem_offset(struct pm8xxx_rtc *rtc_dd) > +{ > + size_t len; > + void *buf; > + int rc; > + > + buf = nvmem_cell_read(rtc_dd->nvmem_cell, &len); > + if (IS_ERR(buf)) { > + rc = PTR_ERR(buf); > + dev_dbg(rtc_dd->dev, "failed to read nvmem offset: %d\n", rc); Why is dev_dbg() used instead of dev_err() for newly added error messages? Also, why do these conditions warrant error logging when some of the previous patches in this series removed older error logging? Thanks, David