From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Ilya Chichkov <i.chichkov@yadro.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH] hw/rtc: Add RTC PCF8563 module
Date: Fri, 21 Feb 2025 11:43:35 +0100 [thread overview]
Message-ID: <925aedb5-6cb5-47eb-980f-d72841f6fa86@linaro.org> (raw)
In-Reply-To: <20250221073444.15257-1-i.chichkov@yadro.com>
Hi Ilya,
On 21/2/25 08:34, Ilya Chichkov wrote:
> Add PCF8563 a real-time clock with calendar and I2C interface.
> This commit adds support for interfacing with it and implements
> functionality of setting timer, alarm, reading and writing time.
>
> Datasheet: https://www.micros.com.pl/mediaserver/UZPCF8563ts5_0001.pdf
>
> Signed-off-by: Ilya Chichkov <i.chichkov@yadro.com>
> ---
> hw/rtc/Kconfig | 5 +
> hw/rtc/meson.build | 1 +
> hw/rtc/pcf8563_rtc.c | 638 +++++++++++++++++++++++++++++++++++++++++++
> hw/rtc/trace-events | 11 +
> 4 files changed, 655 insertions(+)
> create mode 100644 hw/rtc/pcf8563_rtc.c
> +static void pcf8563_realize(DeviceState *dev, Error **errp)
> +{
> + I2CSlave *i2c = I2C_SLAVE(dev);
> + Pcf8563State *s = PCF8563(i2c);
> +
> + s->alarm_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &alarm_timer_cb, s);
> + s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &timer_cb, s);
> + s->irq_gen_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &irq_gen_timer_cb, s);
> +
> + pcf8563_reset(i2c);
Calling pcf8563_reset() here, the device will only be reset once
(cold reset), not when a guest VM resets (hot reset).
See below to register a reset handler called when guest resets.
> +}
> +static void pcf8563_class_init(ObjectClass *klass, void *data)
> +{
> + DeviceClass *dc = DEVICE_CLASS(klass);
> + I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
ResettableClass *rc = RESETTABLE_CLASS(klass);
> +
> + k->event = pcf8563_event;
> + k->recv = pcf8563_rx;
> + k->send = pcf8563_tx;
> + dc->realize = pcf8563_realize;
> + dc->vmsd = &vmstate_pcf8563;
rc->phases.hold = pcf8563_reset_hold;
> +
> + trace_pcf8563_rtc_init();
This trace event is wrong, this isn't the device init but the
registration of its model.
> +}
Your device is missing testing coverage. Our QTest framework seems
well adapted for it.
You can use some examples as template:
$ git grep -l i2c tests/qtest/*.c
tests/qtest/adm1266-test.c
tests/qtest/adm1272-test.c
tests/qtest/bcm2835-i2c-test.c
tests/qtest/ds1338-test.c
tests/qtest/emc141x-test.c
tests/qtest/isl_pmbus_vr-test.c
tests/qtest/lsm303dlhc-mag-test.c
tests/qtest/max34451-test.c
tests/qtest/microbit-test.c
tests/qtest/npcm7xx_smbus-test.c
tests/qtest/pca9552-test.c
tests/qtest/pnv-host-i2c-test.c
tests/qtest/qtest_aspeed.c
tests/qtest/tmp105-test.c
tests/qtest/tpm-tis-i2c-test.c
Regards,
Phil.
next prev parent reply other threads:[~2025-02-21 10:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 7:34 [PATCH] hw/rtc: Add RTC PCF8563 module Ilya Chichkov
2025-02-21 10:43 ` Philippe Mathieu-Daudé [this message]
2025-02-21 18:35 ` Bernhard Beschow
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=925aedb5-6cb5-47eb-980f-d72841f6fa86@linaro.org \
--to=philmd@linaro.org \
--cc=i.chichkov@yadro.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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).