From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Cc: "Alessandro Zummo" <a.zummo@towertech.it>,
rw-r-r-0644 <r.r.qwertyuiop.r.r@gmail.com>,
"Ash Logan" <ash@heyquark.com>,
"Jonathan Neuschäfer" <j.ne@posteo.net>,
"Rob Herring" <robh+dt@kernel.org>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"Paul Mackerras" <paulus@samba.org>,
linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 2/5] rtc: gamecube: Report low battery as invalid data
Date: Tue, 30 Nov 2021 23:45:18 +0100 [thread overview]
Message-ID: <YaapfmykL0BOHHhF@piout.net> (raw)
In-Reply-To: <20211027223516.2031-3-linkmauve@linkmauve.fr>
Hello,
On 28/10/2021 00:35:12+0200, Emmanuel Gil Peyrot wrote:
> I haven’t been able to test this patch as all of my consoles have a
> working RTC battery, but according to the documentation it should work
> like that.
>
> Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
> ---
> drivers/rtc/rtc-gamecube.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/rtc/rtc-gamecube.c b/drivers/rtc/rtc-gamecube.c
> index e8260c82c07d..1932c6fe1301 100644
> --- a/drivers/rtc/rtc-gamecube.c
> +++ b/drivers/rtc/rtc-gamecube.c
> @@ -83,6 +83,10 @@
> #define RTC_CONTROL0 0x21000c
> #define RTC_CONTROL1 0x21000d
>
> +/* RTC flags */
> +#define RTC_CONTROL0_UNSTABLE_POWER 0x00000800
> +#define RTC_CONTROL0_LOW_BATTERY 0x00000200
> +
> struct priv {
> struct regmap *regmap;
> void __iomem *iob;
> @@ -182,9 +186,35 @@ static int gamecube_rtc_set_time(struct device *dev, struct rtc_time *t)
> return regmap_write(d->regmap, RTC_COUNTER, timestamp - d->rtc_bias);
> }
>
> +static int gamecube_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
> +{
> + struct priv *d = dev_get_drvdata(dev);
> + int value;
> + int control0;
> + int ret;
> +
> + switch (cmd) {
> + case RTC_VL_READ:
> + ret = regmap_read(d->regmap, RTC_CONTROL0, &control0);
> + if (ret)
> + return ret;
> +
> + value = 0;
> + if (control0 & RTC_CONTROL0_UNSTABLE_POWER)
> + value |= RTC_VL_DATA_INVALID;
> + if (control0 & RTC_CONTROL0_LOW_BATTERY)
> + value |= RTC_VL_DATA_INVALID;
Shouldn't that one be RTC_VL_BACKUP_LOW?
Else, the driver is great, I'm ready to apply it.
> + return put_user(value, (unsigned int __user *)arg);
> +
> + default:
> + return -ENOIOCTLCMD;
> + }
> +}
> +
> static const struct rtc_class_ops gamecube_rtc_ops = {
> .read_time = gamecube_rtc_read_time,
> .set_time = gamecube_rtc_set_time,
> + .ioctl = gamecube_rtc_ioctl,
> };
>
> static int gamecube_rtc_read_offset_from_sram(struct priv *d)
> --
> 2.33.1
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2021-11-30 22:45 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 22:05 [PATCH] rtc: nintendo: Add a RTC driver for the GameCube, Wii and Wii U Emmanuel Gil Peyrot
2021-10-27 16:45 ` Alexandre Belloni
2021-10-27 17:05 ` Emmanuel Gil Peyrot
2021-10-27 17:09 ` Emmanuel Gil Peyrot
2021-10-27 20:32 ` Alexandre Belloni
2021-10-28 20:32 ` Jonathan Neuschäfer
2021-10-28 21:34 ` Emmanuel Gil Peyrot
2021-10-29 11:06 ` Jonathan Neuschäfer
2021-10-27 22:35 ` [PATCH v2 0/5] " Emmanuel Gil Peyrot
2021-10-27 22:35 ` [PATCH v2 1/5] rtc: gamecube: " Emmanuel Gil Peyrot
2021-10-27 22:35 ` [PATCH v2 2/5] rtc: gamecube: Report low battery as invalid data Emmanuel Gil Peyrot
2021-11-30 22:45 ` Alexandre Belloni [this message]
2021-12-15 17:52 ` Emmanuel Gil Peyrot
2021-10-27 22:35 ` [PATCH v2 3/5] powerpc: wii.dts: Expose HW_SRNPROT on this platform Emmanuel Gil Peyrot
2021-10-27 22:35 ` [PATCH v2 4/5] powerpc: gamecube_defconfig: Enable the RTC driver Emmanuel Gil Peyrot
2021-10-27 22:35 ` [PATCH v2 5/5] powerpc: wii_defconfig: " Emmanuel Gil Peyrot
2021-12-15 17:54 ` [PATCH v3 0/5] rtc: nintendo: Add a RTC driver for the GameCube, Wii and Wii U Emmanuel Gil Peyrot
2021-12-15 17:54 ` [PATCH v3 1/5] rtc: gamecube: " Emmanuel Gil Peyrot
2021-12-15 17:54 ` [PATCH v3 2/5] rtc: gamecube: Report low battery as invalid data Emmanuel Gil Peyrot
2021-12-15 17:54 ` [PATCH v3 3/5] powerpc: wii.dts: Expose HW_SRNPROT on this platform Emmanuel Gil Peyrot
2021-12-15 17:55 ` [PATCH v3 4/5] powerpc: gamecube_defconfig: Enable the RTC driver Emmanuel Gil Peyrot
2021-12-15 17:55 ` [PATCH v3 5/5] powerpc: wii_defconfig: " Emmanuel Gil Peyrot
2021-12-16 4:52 ` [PATCH v3 0/5] rtc: nintendo: Add a RTC driver for the GameCube, Wii and Wii U Michael Ellerman
2021-12-16 9:50 ` Alexandre Belloni
2021-12-16 9:49 ` Alexandre Belloni
2021-12-16 20:22 ` Emmanuel Gil Peyrot
2021-12-16 20:56 ` Alexandre Belloni
2021-12-16 20:58 ` Emmanuel Gil Peyrot
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=YaapfmykL0BOHHhF@piout.net \
--to=alexandre.belloni@bootlin.com \
--cc=a.zummo@towertech.it \
--cc=ash@heyquark.com \
--cc=benh@kernel.crashing.org \
--cc=devicetree@vger.kernel.org \
--cc=j.ne@posteo.net \
--cc=linkmauve@linkmauve.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
--cc=r.r.qwertyuiop.r.r@gmail.com \
--cc=robh+dt@kernel.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).