From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 412E0CD13D3 for ; Thu, 30 Apr 2026 18:27:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wIW6D-0006Zq-Rq; Thu, 30 Apr 2026 14:27:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wIW5i-0006WE-Al for qemu-arm@nongnu.org; Thu, 30 Apr 2026 14:26:34 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wIW5e-0005U8-B5 for qemu-arm@nongnu.org; Thu, 30 Apr 2026 14:26:25 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-43cfce3a195so699210f8f.2 for ; Thu, 30 Apr 2026 11:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777573579; x=1778178379; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bVcTOSBzgf8YzSLv34DedErZlS0+u7paIqWok/bj8ko=; b=gUEHY34DjmcKm2A5uwQH1ENuQw6OhJSv4jjXKMIbK9LkbjoKIPotFD86wPdehmyfd/ z3pV9J1mWJ7Q/d+ZgTKzBeKl2j6nuHpVdHB3ZkH5nxrboe2uL1cCfs67UjpHudXGDM72 Fc91jl9w7mUrxHR3a4Vm7GAWeKXiTaP/25HQm0VQr21MkJlYtsnLGn8+L8lmlRtH1roc ASLu0lmaHrftDuOy7HQK/gvqdf/cqxLUr0sWaN2DKJJvJIGboLPMu7y8KxtK2Hvft3Lk VluXu8nYKP5egSELbHyGUv62zQ0PB6HjZN/z+khv4SvWqBV1NIibi3gAWoEnMMrB3F6c dTiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777573579; x=1778178379; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bVcTOSBzgf8YzSLv34DedErZlS0+u7paIqWok/bj8ko=; b=ZnpxTzSPqEtPviFatYKbIrneqsrkZQLfE6Om/MpkUi46W8/qqAutFeZpiaX821lRvj UJMB/1xWx+tsiuP0kjetSQHaJ/BiM2uMPU/Wt56zUMXc51KxoG1Kul0+HFkNSFEHA1Io vWOOKx404UZn5oRRAqGk5jZs8sRZcn/+Ilb3HUvUNFj5wKxq5A6XP8XNibUpOLsBah1w MI5nREQHmESdVEOurh78qJH80wTKBASEHmRTHwoiI7sy1GdHSNEkr4ldz15jW0rV/uVp VnwxHT18nGWFwbBZeAxGcDWmtCTcLuD6q4ePc9nF05R4E0eCozsEYqxI9bkNVoDd+Rn3 qbvg== X-Gm-Message-State: AOJu0Yxef2vD/Jj5CTow3e00hckG38vmkFpKcMQ1NwGaTdK56wHgwHPA KPZw4N2LLMxorygs9/XL0hT5ajxr9FcvlbsG+vBqFvx8AqryzLkoFmMC X-Gm-Gg: AeBDieum76MBdR9m+52F/MPFl2HpttphtJMnxLnvR4eNhdb4KK09CfsFVKNMELjjWRi jA1k3ZiCDOxMdDIlBV8uqZLD3vkiobcxBYmQESAT/XbXFgLUm9y5JJhJqqpYeXo7pW7fMbbJ7If KFpqRsa1OiAcXB7RgL9S5Gz3OzwmEEMz+Z1E0ReVwcP3ICfBStZK59aH6uNjHUK/OFt0s8TqNsE RAagMVeDODl0CwMih8qOQP7OhF2AuwAfY8LU32arYAyGX54GVwJJlqovHhlc06HNoCKfW84IJLD D2nRNtcunJ+PdxHSTRKkDbH2dj9mQTVmPxrXlAToNdpV5EVEg6vI0SFIEEiUD4kwcSyH47m7WvN y/nweNwORigewHaao00dHKaAn1KFX+c0HM9GYYqJJ/Dxe5O3h1qApYN6kMx3Sb0f8MPw/knqAOE qkCJTj491Hit8/3PXWLIRhRbrkN76arxwLRGiwJDZNtx8hl/MBx48DP2+IXO28AAJ1 X-Received: by 2002:a05:6000:2f8a:b0:441:1cf9:4f06 with SMTP id ffacd0b85a97d-4493fed64c0mr6949536f8f.31.1777573579066; Thu, 30 Apr 2026 11:26:19 -0700 (PDT) Received: from acidburn.pod.cvut.cz (acidburn.pod.cvut.cz. [147.32.90.2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-447b76e5c00sm14674925f8f.25.2026.04.30.11.26.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 11:26:18 -0700 (PDT) From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Bobek?= To: qemu-devel@nongnu.org, Matyas Bobek , Pavel Pisa , Bernhard Beschow Cc: qemu-arm@nongnu.org, Marc Kleine-Budde , Oliver Hartkopp , Nikita Ostrenkov , Peter Maydell , =?UTF-8?q?Maty=C3=A1=C5=A1=20Bobek?= Subject: [PATCH v3 0/7] hw/arm/sabrelite: Add FlexCAN support Date: Thu, 30 Apr 2026 20:26:02 +0200 Message-ID: X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=matyas.bobek@gmail.com; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org This series adds emulation of the FlexCAN CAN controller, version 2, found in NXP i.MX6 series SoCs. The controller is integrated into fsl-imx6 and the Sabrelite ARM board. The chip has two FlexCAN controllers, but the Linux Sabrelite device tree enables only one by default. Linux kernel with both controllers enabled has been tested to work properly (using a custom device tree). See docs/system/devices/can.rst for an example of QEMU command line invocation. More information about the implementation can be found in my bachelor thesis [1]. The headers (struct FlexcanRegs and flexcan_regs.h macros) were copied from the Linux kernel. Marc Kleine-Budde is the copyright holder. He has been kindly asked to provide consent, to confirm his approval for the inclusion of said header fragments into QEMU. The approval is still pending, hopefully it will be resolved soon. I will update the patchset on request if another wording/solution for the copyright statement is proposed/requested. Changes from v2: - moved variable declarations to the top-of-the-block - cleanup - removed redundant license boilerplate - rebased onto latest master - Link to v2: https://lore.kernel.org/qemu-devel/cover.1773866323.git.matyas.bobek@gmail.com/ Changes from v1 to v2: - removed DPRINTF (turned into traces or guest errors) - removed gotos and unnecessary continues - register memory region shortened to actual length w/o padding - make flexcan_* fns private - used DEVICE(s)->canonical_path instead of allocating new strings - changed DEVICE_NATIVE_ENDIAN to DEVICE_LITTLE_ENDIAN - removed ugly USE macro - used enums instead of define sequences in flexcan.c - fixed FlexCAN KConfig conf (fixes build on non-arm-softmmu) - fixed style and other issues from Bernhard's review - better wording in docs - rebased onto latest master - Link to v1: https://lore.kernel.org/qemu-devel/cover.1765826753.git.matyas.bobek@gmail.com Thanks Bernhard Beschow for the review and his patience. I borrowed some fixes from his flexcan branch at [2]. [1] http://dspace.cvut.cz/bitstream/handle/10467/122654/F3-BP-2025-Bobek-Matyas-BP_Bobek_FlexCAN_final_4.pdf [2] https://github.com/shentok/qemu/tree/flexcan Matyáš Bobek (7): hw/arm/sabrelite: Open code DEFINE_MACHINE_ARM hw/arm/sabrelite: Introduce class SabreliteMachineState hw/misc/imx6_ccm: Add PLL3 and CAN clock hw/net/can/flexcan: NXP FlexCAN core emulation hw/arm: Plug FlexCAN into FSL_IMX6 and Sabrelite tests: Add qtests for FlexCAN docs/arm/sabrelite: Mention FlexCAN support MAINTAINERS | 9 + docs/system/arm/sabrelite.rst | 1 + docs/system/devices/can.rst | 24 + hw/arm/Kconfig | 1 + hw/arm/fsl-imx6.c | 29 + hw/arm/sabrelite.c | 68 +- hw/misc/imx6_ccm.c | 24 + hw/misc/trace-events | 2 + hw/net/Kconfig | 5 + hw/net/can/flexcan.c | 1395 +++++++++++++++++++++++++++++++++ hw/net/can/flexcan_regs.h | 193 +++++ hw/net/can/meson.build | 1 + hw/net/can/trace-events | 18 + include/hw/arm/fsl-imx6.h | 6 + include/hw/misc/imx6_ccm.h | 4 + include/hw/misc/imx_ccm.h | 1 + include/hw/net/flexcan.h | 139 ++++ tests/qtest/flexcan-test.c | 421 ++++++++++ tests/qtest/meson.build | 1 + 19 files changed, 2332 insertions(+), 10 deletions(-) create mode 100644 hw/net/can/flexcan.c create mode 100644 hw/net/can/flexcan_regs.h create mode 100644 include/hw/net/flexcan.h create mode 100644 tests/qtest/flexcan-test.c -- 2.53.0