[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250725154136.1008132-6-ivecera@redhat.com>
Date: Fri, 25 Jul 2025 17:41:36 +0200
From: Ivan Vecera <ivecera@...hat.com>
To: netdev@...r.kernel.org
Cc: Jiri Pirko <jiri@...nulli.us>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>,
Jonathan Corbet <corbet@....net>,
Prathosh Satish <Prathosh.Satish@...rochip.com>,
linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org,
Michal Schmidt <mschmidt@...hat.com>,
Petr Oros <poros@...hat.com>
Subject: [PATCH net-next 5/5] dpll: zl3073x: Implement devlink flash callback
Use the introduced functionality to read firmware files and flash their
contents into the device's internal flash memory to implement the devlink
flash update callback.
Sample output on EDS2 development board:
# devlink -j dev info i2c/1-0070 | jq '.[][]["versions"]["running"]'
{
"fw": "6026"
}
# devlink dev flash i2c/1-0070 file firmware_fw2.hex
[utility] Prepare flash mode
[utility] Downloading image 100%
[utility] Flash mode enabled
[firmware1-part1] Downloading image 100%
[firmware1-part1] Flashing image
[firmware1-part2] Downloading image 100%
[firmware1-part2] Flashing image
[firmware1] Flashing done
[firmware2] Downloading image 100%
[firmware2] Flashing image 100%
[firmware2] Flashing done
[utility] Leaving flash mode
Flashing done
# devlink -j dev info i2c/1-0070 | jq '.[][]["versions"]["running"]'
{
"fw": "7006"
}
Signed-off-by: Ivan Vecera <ivecera@...hat.com>
---
Documentation/networking/devlink/zl3073x.rst | 14 +++++
drivers/dpll/zl3073x/devlink.c | 65 ++++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/Documentation/networking/devlink/zl3073x.rst b/Documentation/networking/devlink/zl3073x.rst
index 4b6cfaf386433..fc5a8dc272a77 100644
--- a/Documentation/networking/devlink/zl3073x.rst
+++ b/Documentation/networking/devlink/zl3073x.rst
@@ -49,3 +49,17 @@ The ``zl3073x`` driver reports the following versions
- running
- 1.3.0.1
- Device configuration version customized by OEM
+
+Flash Update
+============
+
+The ``zl3073x`` driver implements support for flash update using the
+``devlink-flash`` interface. It supports updating the device flash using a
+combined flash image ("bundle") that contains multiple components (firmware
+parts and configurations).
+
+During the flash procedure, the standard firmware interface is not available,
+so the driver unregisters all DPLLs and associated pins, and re-registers them
+once the flash procedure is complete.
+
+The driver does not support any overwrite mask flags.
diff --git a/drivers/dpll/zl3073x/devlink.c b/drivers/dpll/zl3073x/devlink.c
index d0f6d9cd4a68e..06962643c9363 100644
--- a/drivers/dpll/zl3073x/devlink.c
+++ b/drivers/dpll/zl3073x/devlink.c
@@ -9,6 +9,8 @@
#include "core.h"
#include "devlink.h"
#include "dpll.h"
+#include "flash.h"
+#include "fw.h"
#include "regs.h"
/**
@@ -141,11 +143,74 @@ void zl3073x_devlink_flash_notify(struct zl3073x_dev *zldev, const char *msg,
total);
}
+/**
+ * zl3073x_flash_update - Devlink flash update callback
+ * @devlink: devlink structure pointer
+ * @params: flashing parameters pointer
+ * @extack: netlink extack pointer to report errors
+ *
+ * Returns 0 in case of success or negative value otherwise
+ */
+static int
+zl3073x_devlink_flash_update(struct devlink *devlink,
+ struct devlink_flash_update_params *params,
+ struct netlink_ext_ack *extack)
+{
+ struct zl3073x_dev *zldev = devlink_priv(devlink);
+ struct zl3073x_fw_component *util;
+ struct zl3073x_fw *zlfw;
+ int rc = 0;
+
+ /* Load firmware */
+ zlfw = zl3073x_fw_load(zldev, params->fw->data, params->fw->size,
+ extack);
+ if (IS_ERR(zlfw))
+ return PTR_ERR(zlfw);
+
+ util = zlfw->component[ZL_FW_COMPONENT_UTIL];
+ if (!util) {
+ zl3073x_devlink_flash_notify(zldev,
+ "Utility is missing in firmware",
+ NULL, 0, 0);
+ rc = -EOPNOTSUPP;
+ goto error;
+ }
+
+ /* Stop normal operation during flash */
+ zl3073x_dev_stop(zldev);
+
+ /* Enter flashing mode */
+ rc = zl3073x_flash_mode_enter(zldev, util->data, util->size, extack);
+ if (!rc) {
+ /* Flash the firmware */
+ rc = zl3073x_fw_flash(zldev, zlfw, extack);
+
+ /* Leave flashing mode */
+ zl3073x_flash_mode_leave(zldev, extack);
+ }
+
+ /* Restart normal operation */
+ rc = zl3073x_dev_start(zldev, true);
+ if (rc)
+ dev_warn(zldev->dev, "Failed to re-start normal operation\n");
+
+error:
+ /* Free flash context */
+ zl3073x_fw_free(zlfw);
+
+ zl3073x_devlink_flash_notify(zldev,
+ rc ? "Flashing failed" : "Flashing done",
+ NULL, 0, 0);
+
+ return rc;
+}
+
static const struct devlink_ops zl3073x_devlink_ops = {
.info_get = zl3073x_devlink_info_get,
.reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT),
.reload_down = zl3073x_devlink_reload_down,
.reload_up = zl3073x_devlink_reload_up,
+ .flash_update = zl3073x_devlink_flash_update,
};
static void
--
2.49.1
Powered by blists - more mailing lists