From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Gustavo Romero" <gustavo.romero@linaro.org>,
qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v2 2/4] hw/arm/stellaris: Convert I2C controller to Resettable interface
Date: Tue, 13 Feb 2024 16:52:12 +0100 [thread overview]
Message-ID: <20240213155214.13619-3-philmd@linaro.org> (raw)
In-Reply-To: <20240213155214.13619-1-philmd@linaro.org>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/arm/stellaris.c | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index 4fa857970b..d3a12fe51c 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -462,7 +462,10 @@ static void stellaris_sys_instance_init(Object *obj)
s->sysclk = qdev_init_clock_out(DEVICE(s), "SYSCLK");
}
-/* I2C controller. */
+/*
+ * I2C controller.
+ * ??? For now we only implement the master interface.
+ */
#define TYPE_STELLARIS_I2C "stellaris-i2c"
OBJECT_DECLARE_SIMPLE_TYPE(stellaris_i2c_state, STELLARIS_I2C)
@@ -607,10 +610,17 @@ static void stellaris_i2c_write(void *opaque, hwaddr offset,
stellaris_i2c_update(s);
}
-static void stellaris_i2c_reset(stellaris_i2c_state *s)
+static void stellaris_i2c_reset_enter(Object *obj, ResetType type)
{
+ stellaris_i2c_state *s = STELLARIS_I2C(obj);
+
if (s->mcs & STELLARIS_I2C_MCS_BUSBSY)
i2c_end_transfer(s->bus);
+}
+
+static void stellaris_i2c_reset_hold(Object *obj)
+{
+ stellaris_i2c_state *s = STELLARIS_I2C(obj);
s->msa = 0;
s->mcs = 0;
@@ -619,6 +629,12 @@ static void stellaris_i2c_reset(stellaris_i2c_state *s)
s->mimr = 0;
s->mris = 0;
s->mcr = 0;
+}
+
+static void stellaris_i2c_reset_exit(Object *obj)
+{
+ stellaris_i2c_state *s = STELLARIS_I2C(obj);
+
stellaris_i2c_update(s);
}
@@ -658,8 +674,6 @@ static void stellaris_i2c_init(Object *obj)
memory_region_init_io(&s->iomem, obj, &stellaris_i2c_ops, s,
"i2c", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
- /* ??? For now we only implement the master interface. */
- stellaris_i2c_reset(s);
}
/* Analogue to Digital Converter. This is only partially implemented,
@@ -1396,7 +1410,11 @@ type_init(stellaris_machine_init)
static void stellaris_i2c_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
+ rc->phases.enter = stellaris_i2c_reset_enter;
+ rc->phases.hold = stellaris_i2c_reset_hold;
+ rc->phases.exit = stellaris_i2c_reset_exit;
dc->vmsd = &vmstate_stellaris_i2c;
}
--
2.41.0
next prev parent reply other threads:[~2024-02-13 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 15:52 [PATCH v2 0/4] hw/arm/stellaris: QOM/QDev cleanups Philippe Mathieu-Daudé
2024-02-13 15:52 ` [PATCH v2 1/4] hw/arm/stellaris: Convert ADC controller to Resettable interface Philippe Mathieu-Daudé
2024-02-13 15:52 ` Philippe Mathieu-Daudé [this message]
2024-02-13 15:52 ` [PATCH v2 3/4] hw/arm/stellaris: Add missing QOM 'machine' parent Philippe Mathieu-Daudé
2024-02-13 15:52 ` [PATCH v2 4/4] hw/arm/stellaris: Add missing QOM 'SoC' parent Philippe Mathieu-Daudé
2024-02-15 13:50 ` [PATCH v2 0/4] hw/arm/stellaris: QOM/QDev cleanups Peter Maydell
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=20240213155214.13619-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=gustavo.romero@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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).