[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <85481368-b32e-61aa-f83a-fb42d58c351a@linaro.org>
Date: Fri, 27 Jan 2023 14:13:21 +0000
From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To: Johan Hovold <johan+linaro@...nel.org>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
Bjorn Andersson <andersson@...nel.org>
Cc: Andy Gross <agross@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>,
Alessandro Zummo <a.zummo@...ertech.it>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Maximilian Luz <luzmaximilian@...il.com>,
linux-arm-msm@...r.kernel.org, linux-rtc@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 16/24] rtc: pm8xxx: add support for nvmem offset
On 26/01/2023 14:20, 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
> 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@...nel.org>
> ---
> drivers/rtc/rtc-pm8xxx.c | 134 +++++++++++++++++++++++++++++++++++----
> 1 file changed, 123 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c
> index 922aef0f0241..09816b9f6282 100644
> --- a/drivers/rtc/rtc-pm8xxx.c
> +++ b/drivers/rtc/rtc-pm8xxx.c
> @@ -3,6 +3,7 @@
> */
> +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_err(rtc_dd->dev, "failed to read nvmem offset: %d\n", rc);
> + return rc;
> + }
> +
> + if (len != sizeof(u32)) {
> + dev_err(rtc_dd->dev, "unexpected nvmem cell size %zu\n", len);
> + kfree(buf);
> + return -EINVAL;
> + }
how about us nvmem_cell_read_u32()
> +
> + rtc_dd->offset = get_unaligned_le32(buf);
> +
> + kfree(buf);
> +
> + return 0;
> +}
> +
Powered by blists - more mailing lists