From: "Thomas Perrot (Schneider Electric)" <thomas.perrot@bootlin.com>
To: "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Bartosz Golaszewski" <brgl@kernel.org>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Jérémie Dautheribes" <jeremie.dautheribes@bootlin.com>,
"Wim Van Sebroeck" <wim@linux-watchdog.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"Lee Jones" <lee@kernel.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-watchdog@vger.kernel.org,
"Thomas Perrot (Schneider Electric)" <thomas.perrot@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [PATCH 5/8] mfd: aaeon: Add SRG-IMX8PL MCU driver
Date: Fri, 12 Dec 2025 08:41:08 +0100 [thread overview]
Message-ID: <20251212-dev-b4-aaeon-mcu-driver-v1-5-6bd65bc8ef12@bootlin.com> (raw)
In-Reply-To: <20251212-dev-b4-aaeon-mcu-driver-v1-0-6bd65bc8ef12@bootlin.com>
Add Multi-Function Device (MFD) driver for the Aaeon SRG-IMX8PL
embedded controller. This driver provides the core I2C communication
interface and registers child devices (GPIO and watchdog controllers).
The MCU firmware version is queried during probe and logged for
diagnostic purposes. All I2C transactions are serialized using a mutex
to ensure proper communication with the microcontroller.
Co-developed-by: Jérémie Dautheribes (Schneider Electric) <jeremie.dautheribes@bootlin.com>
Signed-off-by: Jérémie Dautheribes (Schneider Electric) <jeremie.dautheribes@bootlin.com>
Signed-off-by: Thomas Perrot (Schneider Electric) <thomas.perrot@bootlin.com>
---
drivers/mfd/Kconfig | 10 ++++
drivers/mfd/aaeon-mcu.c | 133 ++++++++++++++++++++++++++++++++++++++++++
include/linux/mfd/aaeon-mcu.h | 30 ++++++++++
3 files changed, 173 insertions(+)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index aace5766b38aa5e46e32a8a7b42eea238159fbcf..9195115c7bcd619439cb9ff71d70e46629291867 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1574,6 +1574,16 @@ config AB8500_CORE
the irq_chip parts for handling the Mixed Signal chip events.
This chip embeds various other multimedia functionalities as well.
+config MFD_AAEON_MCU
+ tristate "Aaeon SRG-IMX8PL MCU Driver"
+ depends on I2C
+ select MFD_CORE
+ help
+ Select this option to enable support for the Aaeon SRG-IMX8PL
+ onboard microcontroller (MCU). This driver provides the core
+ functionality to communicate with the MCU over I2C. The MCU
+ provides various sub-devices including GPIO and watchdog controllers.
+
config MFD_DB8500_PRCMU
bool "ST-Ericsson DB8500 Power Reset Control Management Unit"
depends on UX500_SOC_DB8500
diff --git a/drivers/mfd/aaeon-mcu.c b/drivers/mfd/aaeon-mcu.c
new file mode 100644
index 0000000000000000000000000000000000000000..472d44d5e8627f46806015599542753a5bda4526
--- /dev/null
+++ b/drivers/mfd/aaeon-mcu.c
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Aaeon MCU MFD driver
+ *
+ * Copyright (C) 2025 Bootlin
+ * Author: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com>
+ * Author: Thomas Perrot <thomas.perrot@bootlin.com>
+ */
+
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/aaeon-mcu.h>
+
+#define AAEON_MCU_GET_FW_VERSION 0x76
+
+static struct mfd_cell aaeon_mcu_devs[] = {
+ {
+ .name = "aaeon-mcu-wdt",
+ .of_compatible = "aaeon,srg-imx8pl-wdt",
+ },
+ {
+ .name = "aaeon-mcu-gpio",
+ .of_compatible = "aaeon,srg-imx8pl-gpio",
+ },
+};
+
+static int aaeon_mcu_print_fw_version(struct i2c_client *client)
+{
+ u8 cmd[3], version[2];
+ int ret;
+
+ /* Major version number */
+ cmd[0] = AAEON_MCU_GET_FW_VERSION;
+ cmd[1] = 0x00;
+ cmd[2] = 0x00;
+
+ ret = aaeon_mcu_i2c_xfer(client, cmd, 3, &version[0], 1);
+ if (ret < 0)
+ return ret;
+
+ /* Minor version number */
+ cmd[0] = AAEON_MCU_GET_FW_VERSION;
+ cmd[1] = 0x01;
+ /* cmd[2] = 0x00; */
+
+ ret = aaeon_mcu_i2c_xfer(client, cmd, 3, &version[1], 1);
+ if (ret < 0)
+ return ret;
+
+ dev_info(&client->dev, "firmware version: v%d.%d\n",
+ version[0], version[1]);
+
+ return 0;
+}
+
+static int aaeon_mcu_probe(struct i2c_client *client)
+{
+ struct aaeon_mcu_dev *mcu;
+ int ret;
+
+ mcu = devm_kzalloc(&client->dev, sizeof(*mcu), GFP_KERNEL);
+ if (!mcu)
+ return -ENOMEM;
+
+ i2c_set_clientdata(client, mcu);
+ mcu->dev = &client->dev;
+ mcu->i2c_client = client;
+ mutex_init(&mcu->i2c_lock);
+
+ ret = aaeon_mcu_print_fw_version(client);
+ if (ret) {
+ dev_err(&client->dev, "unable to read firmware version\n");
+ return ret;
+ }
+
+ return devm_mfd_add_devices(mcu->dev, PLATFORM_DEVID_NONE, aaeon_mcu_devs,
+ ARRAY_SIZE(aaeon_mcu_devs), NULL, 0, NULL);
+}
+
+int aaeon_mcu_i2c_xfer(struct i2c_client *client,
+ const u8 *cmd, int cmd_len,
+ u8 *rsp, int rsp_len)
+{
+ struct aaeon_mcu_dev *mcu = i2c_get_clientdata(client);
+ int ret;
+
+ mutex_lock(&mcu->i2c_lock);
+
+ ret = i2c_master_send(client, cmd, cmd_len);
+ if (ret < 0)
+ goto unlock;
+
+ ret = i2c_master_recv(client, rsp, rsp_len);
+ if (ret < 0)
+ goto unlock;
+
+ if (ret != rsp_len) {
+ dev_err(&client->dev,
+ "i2c recv count error (expected: %d, actual: %d)\n",
+ rsp_len, ret);
+ ret = -EIO;
+ goto unlock;
+ }
+
+ ret = 0;
+
+unlock:
+ mutex_unlock(&mcu->i2c_lock);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(aaeon_mcu_i2c_xfer);
+
+static const struct of_device_id aaeon_mcu_of_match[] = {
+ { .compatible = "aaeon,srg-imx8pl-mcu" },
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, aaeon_mcu_of_match);
+
+static struct i2c_driver aaeon_mcu_driver = {
+ .driver = {
+ .name = "aaeon_mcu",
+ .of_match_table = aaeon_mcu_of_match,
+ },
+ .probe = aaeon_mcu_probe,
+};
+
+module_i2c_driver(aaeon_mcu_driver);
+
+MODULE_DESCRIPTION("Aaeon MCU MFD Driver");
+MODULE_AUTHOR("Jérémie Dautheribes");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/aaeon-mcu.h b/include/linux/mfd/aaeon-mcu.h
new file mode 100644
index 0000000000000000000000000000000000000000..89632cb46bc6c9518755dc43afb87faa94acb6f5
--- /dev/null
+++ b/include/linux/mfd/aaeon-mcu.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Aaeon MCU driver definitions
+ *
+ * Copyright (C) 2025 Bootlin
+ * Author: Jérémie Dautheribes <jeremie.dautheribes@bootlin.com>
+ * Author: Thomas Perrot <thomas.perrot@bootlin.com>
+ */
+
+#ifndef __LINUX_MFD_AAEON_MCU_H
+#define __LINUX_MFD_AAEON_MCU_H
+
+/**
+ * struct aaeon_mcu_dev - Internal representation of the Aaeon MCU
+ * @dev: Pointer to kernel device structure
+ * @i2c_client: Pointer to the Aaeon MCU I2C client
+ * @i2c_lock: Mutex to serialize I2C bus access
+ */
+
+struct aaeon_mcu_dev {
+ struct device *dev;
+ struct i2c_client *i2c_client;
+ struct mutex i2c_lock;
+};
+
+int aaeon_mcu_i2c_xfer(struct i2c_client *client,
+ const u8 *cmd, int cmd_len,
+ u8 *rsp, int rsp_len);
+
+#endif /* __LINUX_MFD_AAEON_MCU_H */
--
2.52.0
next prev parent reply other threads:[~2025-12-12 7:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-12 7:41 [PATCH 0/8] Add support for AAEON SRG-IMX8PL MCU Thomas Perrot (Schneider Electric)
2025-12-12 7:41 ` [PATCH 1/8] dt-bindings: vendor-prefixes: Add AAEON vendor prefix Thomas Perrot (Schneider Electric)
2025-12-12 7:41 ` [PATCH 2/8] dt-bindings: gpio: Add AAEON embedded controller GPIO binding Thomas Perrot (Schneider Electric)
2025-12-12 8:19 ` Krzysztof Kozlowski
2025-12-12 7:41 ` [PATCH 3/8] dt-bindings: watchdog: Add AAEON embedded controller watchdog binding Thomas Perrot (Schneider Electric)
2025-12-12 8:20 ` Krzysztof Kozlowski
2025-12-12 11:46 ` Guenter Roeck
2025-12-13 3:05 ` Krzysztof Kozlowski
2025-12-12 7:41 ` [PATCH 4/8] dt-bindings: mfd: Add AAEON embedded controller binding Thomas Perrot (Schneider Electric)
2025-12-12 8:22 ` Krzysztof Kozlowski
2025-12-12 7:41 ` Thomas Perrot (Schneider Electric) [this message]
2025-12-12 7:41 ` [PATCH 6/8] gpio: aaeon: Add GPIO driver for SRG-IMX8PL MCU Thomas Perrot (Schneider Electric)
2025-12-12 10:11 ` Bartosz Golaszewski
2025-12-13 6:22 ` kernel test robot
2025-12-13 22:38 ` kernel test robot
2025-12-12 7:41 ` [PATCH 7/8] watchdog: aaeon: Add watchdog " Thomas Perrot (Schneider Electric)
2025-12-12 11:44 ` Guenter Roeck
2025-12-12 7:41 ` [PATCH 8/8] MAINTAINERS: Add entry for AAEON SRG-IMX8PL MCU driver Thomas Perrot (Schneider Electric)
2025-12-12 8:23 ` Krzysztof Kozlowski
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=20251212-dev-b4-aaeon-mcu-driver-v1-5-6bd65bc8ef12@bootlin.com \
--to=thomas.perrot@bootlin.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jeremie.dautheribes@bootlin.com \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wim@linux-watchdog.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).