lkml.org 
[lkml]   [2023]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 16/24] rtc: pm8xxx: add support for nvmem offset
From


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@kernel.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;
> +}
> +

\
 
 \ /
  Last update: 2023-03-26 23:58    [W:0.329 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site