From: "Jernej Škrabec" <jernej.skrabec@gmail.com>
To: Chen-Yu Tsai <wens@csie.org>,
Alessandro Zummo <a.zummo@towertech.it>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Samuel Holland <samuel@sholland.org>
Cc: Samuel Holland <samuel@sholland.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org,
linux-sunxi@lists.linux.dev
Subject: Re: [PATCH] rtc: sun6i: Add NVMEM provider
Date: Fri, 15 Apr 2022 20:26:43 +0200 [thread overview]
Message-ID: <10062096.nUPlyArG6x@jernej-laptop> (raw)
In-Reply-To: <20220413231731.56709-1-samuel@sholland.org>
Dne četrtek, 14. april 2022 ob 01:17:30 CEST je Samuel Holland napisal(a):
> The sun6i RTC provides 32 bytes of general-purpose data registers.
> They can be used to save data in the always-on RTC power domain.
> The registers are writable via 32-bit MMIO accesses only.
>
> Expose them with a NVMEM provider so they can be used by other drivers.
>
> Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Best regards,
Jernej
> ---
>
> drivers/rtc/rtc-sun6i.c | 42 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
> index 5b3e4da63406..755aeb82a285 100644
> --- a/drivers/rtc/rtc-sun6i.c
> +++ b/drivers/rtc/rtc-sun6i.c
> @@ -71,6 +71,10 @@
> #define SUN6I_LOSC_OUT_GATING 0x0060
> #define SUN6I_LOSC_OUT_GATING_EN_OFFSET 0
>
> +/* General-purpose data */
> +#define SUN6I_GP_DATA 0x0100
> +#define SUN6I_GP_DATA_SIZE 0x20
> +
> /*
> * Get date values
> */
> @@ -662,6 +666,39 @@ static const struct rtc_class_ops sun6i_rtc_ops = {
> .alarm_irq_enable = sun6i_rtc_alarm_irq_enable
> };
>
> +static int sun6i_rtc_nvmem_read(void *priv, unsigned int offset, void
> *_val, size_t bytes) +{
> + struct sun6i_rtc_dev *chip = priv;
> + u32 *val = _val;
> + int i;
> +
> + for (i = 0; i < bytes / 4; ++i)
> + val[i] = readl(chip->base + SUN6I_GP_DATA + offset + 4 *
i);
> +
> + return 0;
> +}
> +
> +static int sun6i_rtc_nvmem_write(void *priv, unsigned int offset, void
> *_val, size_t bytes) +{
> + struct sun6i_rtc_dev *chip = priv;
> + u32 *val = _val;
> + int i;
> +
> + for (i = 0; i < bytes / 4; ++i)
> + writel(val[i], chip->base + SUN6I_GP_DATA + offset + 4 *
i);
> +
> + return 0;
> +}
> +
> +static struct nvmem_config sun6i_rtc_nvmem_cfg = {
> + .type = NVMEM_TYPE_BATTERY_BACKED,
> + .reg_read = sun6i_rtc_nvmem_read,
> + .reg_write = sun6i_rtc_nvmem_write,
> + .size = SUN6I_GP_DATA_SIZE,
> + .word_size = 4,
> + .stride = 4,
> +};
> +
> #ifdef CONFIG_PM_SLEEP
> /* Enable IRQ wake on suspend, to wake up from RTC. */
> static int sun6i_rtc_suspend(struct device *dev)
> @@ -795,6 +832,11 @@ static int sun6i_rtc_probe(struct platform_device
> *pdev) if (ret)
> return ret;
>
> + sun6i_rtc_nvmem_cfg.priv = chip;
> + ret = devm_rtc_nvmem_register(chip->rtc, &sun6i_rtc_nvmem_cfg);
> + if (ret)
> + return ret;
> +
> dev_info(&pdev->dev, "RTC enabled\n");
>
> return 0;
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-04-15 18:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 23:17 [PATCH] rtc: sun6i: Add NVMEM provider Samuel Holland
2022-04-15 18:26 ` Jernej Škrabec [this message]
2022-05-17 20:49 ` alexandre.belloni
-- strict thread matches above, loose matches on Subject: below --
2021-04-19 1:45 Samuel Holland
2021-04-30 9:02 ` Maxime Ripard
2021-05-04 15:33 ` Alexandre Belloni
2021-05-10 3:39 ` Samuel Holland
2021-05-10 8:00 ` Alexandre Belloni
2021-05-25 8:24 ` Maxime Ripard
2021-05-27 4:09 ` Samuel Holland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=10062096.nUPlyArG6x@jernej-laptop \
--to=jernej.skrabec@gmail.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=samuel@sholland.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).