From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: Gaurav Sharma <gaurav.sharma_7@nxp.com>,
Bernhard Beschow <shentey@gmail.com>,
Pavel Pisa <pisa@cmp.felk.cvut.cz>,
Jason Wang <jasowang@redhat.com>,
Francisco Iglesias <francisco.iglesias@amd.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, Matyas Bobek <matyas.bobek@gmail.com>,
Jean-Christophe Dubois <jcd@tribudubois.net>,
Vikram Garhwal <vikram.garhwal@bytedance.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Subject: [PATCH 1/4] hw/net/can/flexcan: Subclass TYPE_CAN_FLEXCAN
Date: Thu, 2 Jul 2026 00:46:09 +0200 [thread overview]
Message-ID: <20260701224612.48342-2-shentey@gmail.com> (raw)
In-Reply-To: <20260701224612.48342-1-shentey@gmail.com>
Subclass TYPE_CAN_FLEXCAN, yielding TYPE_CAN_FLEXCAN2 and TYPE_CAN_FLEXCAN3.
Since TYPE_CAN_FLEXCAN is now abstract, TYPE_FSL_IMX6 needs to use
TYPE_CAN_FLEXCAN2. TYPE_CAN_FLEXCAN3 will be used in TYPE_FSL_IMX8MP.
Note that Linux performs 8 byte accesses on the i.MX8M Plus, therefore
.max_access_size has to be adjusted. Otherwise this results in bus errors.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
include/hw/net/flexcan.h | 4 ++-
hw/arm/fsl-imx6.c | 2 +-
hw/net/can/flexcan.c | 61 +++++++++++++++++++++++++++++++---------
3 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/include/hw/net/flexcan.h b/include/hw/net/flexcan.h
index 153afc1e03..32de7b904a 100644
--- a/include/hw/net/flexcan.h
+++ b/include/hw/net/flexcan.h
@@ -139,7 +139,9 @@ typedef struct FlexcanState {
} FlexcanState;
#define TYPE_CAN_FLEXCAN "flexcan"
-
OBJECT_DECLARE_SIMPLE_TYPE(FlexcanState, CAN_FLEXCAN);
+#define TYPE_CAN_FLEXCAN2 "flexcan2"
+#define TYPE_CAN_FLEXCAN3 "flexcan3"
+
#endif
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index bf106a9063..57cdde971c 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -92,7 +92,7 @@ static void fsl_imx6_init(Object *obj)
}
for (i = 0; i < FSL_IMX6_NUM_CANS; i++) {
snprintf(name, NAME_SIZE, "flexcan%d", i + 1);
- object_initialize_child(obj, name, &s->flexcan[i], TYPE_CAN_FLEXCAN);
+ object_initialize_child(obj, name, &s->flexcan[i], TYPE_CAN_FLEXCAN2);
}
for (i = 0; i < FSL_IMX6_NUM_WDTS; i++) {
snprintf(name, NAME_SIZE, "wdt%d", i);
diff --git a/hw/net/can/flexcan.c b/hw/net/can/flexcan.c
index 1ea459d9f6..d6a76c28ab 100644
--- a/hw/net/can/flexcan.c
+++ b/hw/net/can/flexcan.c
@@ -1298,7 +1298,7 @@ static const struct MemoryRegionOps flexcan_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
.valid = {
.min_access_size = 1,
- .max_access_size = 4,
+ .max_access_size = 8,
.unaligned = true,
.accepts = flexcan_mem_accepts
},
@@ -1324,16 +1324,26 @@ static int flexcan_connect_to_bus(FlexcanState *s, CanBusState *bus)
return 0;
}
-static void flexcan_init(Object *obj)
+static void flexcan2_init(Object *obj)
{
FlexcanState *s = CAN_FLEXCAN(obj);
memory_region_init_io(
- &s->iomem, obj, &flexcan_ops, s, TYPE_CAN_FLEXCAN,
+ &s->iomem, obj, &flexcan_ops, s, TYPE_CAN_FLEXCAN2,
offsetof(FlexcanRegs, _reserved6)
);
}
+static void flexcan3_init(Object *obj)
+{
+ FlexcanState *s = CAN_FLEXCAN(obj);
+
+ memory_region_init_io(
+ &s->iomem, obj, &flexcan_ops, s, TYPE_CAN_FLEXCAN3,
+ sizeof(FlexcanRegs)
+ );
+}
+
static void flexcan_realize(DeviceState *dev, Error **errp)
{
FlexcanState *s = CAN_FLEXCAN(dev);
@@ -1378,19 +1388,42 @@ static void flexcan_class_init(ObjectClass *klass, const void *data)
dc->realize = flexcan_realize;
device_class_set_props(dc, flexcan_properties);
dc->vmsd = &vmstate_can;
- dc->desc = "i.MX FLEXCAN Controller";
}
-static const TypeInfo flexcan_info = {
- .name = TYPE_CAN_FLEXCAN,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(FlexcanState),
- .class_init = flexcan_class_init,
- .instance_init = flexcan_init,
-};
+static void flexcan2_class_init(ObjectClass *klass, const void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
-static void can_register_types(void)
+ dc->desc = "i.MX FlexCAN 2 Controller";
+}
+
+static void flexcan3_class_init(ObjectClass *klass, const void *data)
{
- type_register_static(&flexcan_info);
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->desc = "i.MX FlexCAN 3 Controller";
}
-type_init(can_register_types)
+
+static const TypeInfo flexcan_types[] = {
+ {
+ .name = TYPE_CAN_FLEXCAN,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(FlexcanState),
+ .class_init = flexcan_class_init,
+ .abstract = true,
+ },
+ {
+ .name = TYPE_CAN_FLEXCAN2,
+ .parent = TYPE_CAN_FLEXCAN,
+ .class_init = flexcan2_class_init,
+ .instance_init = flexcan2_init,
+ },
+ {
+ .name = TYPE_CAN_FLEXCAN3,
+ .parent = TYPE_CAN_FLEXCAN,
+ .class_init = flexcan3_class_init,
+ .instance_init = flexcan3_init,
+ },
+};
+
+DEFINE_TYPES(flexcan_types)
--
2.54.0
next prev parent reply other threads:[~2026-07-01 22:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 22:46 [PATCH 0/4] hw/arm/fsl-imx8mp: Add inital FlexCAN support Bernhard Beschow
2026-07-01 22:46 ` Bernhard Beschow [this message]
2026-07-02 12:45 ` [PATCH 1/4] hw/net/can/flexcan: Subclass TYPE_CAN_FLEXCAN Philippe Mathieu-Daudé
2026-07-02 16:58 ` Bernhard Beschow
2026-07-01 22:46 ` [PATCH 2/4] hw/arm/imx8mp-evk: Open code DEFINE_MACHINE_AARCH64 Bernhard Beschow
2026-07-02 12:23 ` Philippe Mathieu-Daudé
2026-07-01 22:46 ` [PATCH 3/4] hw/arm/imx8mp-evk: Introduce FslImx8mpEvkState Bernhard Beschow
2026-07-02 12:23 ` Philippe Mathieu-Daudé
2026-07-01 22:46 ` [PATCH 4/4] hw/arm: Add basic FlexCAN3 support to TYPE_FSL_IMX8MP and imx8mp-evk Bernhard Beschow
2026-07-02 12:41 ` Philippe Mathieu-Daudé
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=20260701224612.48342-2-shentey@gmail.com \
--to=shentey@gmail.com \
--cc=francisco.iglesias@amd.com \
--cc=gaurav.sharma_7@nxp.com \
--cc=jasowang@redhat.com \
--cc=jcd@tribudubois.net \
--cc=matyas.bobek@gmail.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=pisa@cmp.felk.cvut.cz \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vikram.garhwal@bytedance.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.