From nobody Mon Oct 6 04:59:34 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9EE22EF9BD for ; Fri, 25 Jul 2025 15:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753458130; cv=none; b=LwcKVhp+3fKYErDY6fpiJIRbuYgQQ/8W2T+acbc2gt9GY4gJnGTc22/9Lmtu+pFvXAnaiYx3KbJIlzM0UADeTn1tdPuKOSZDeH6OKSa6T1zjyQUMwzDEExvmD6a0yd35KIATbh/28ywci66/8sVX7p7eqTlH7tIXxAP3we8P5z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753458130; c=relaxed/simple; bh=JcrZQg4NSQPxjI3ARjKhCDXAM0AmuH0YqWdBQlP7btI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dY56hcUqKrc4qhrQsGUlhqWp8VBu8BvXNvSZtCjrbS55p1AREw2gcLmGbqheITx2XbKupB19Q5BRhV6aVebAJU7gan6houV9SymBA0ClP48PkCqDfHtsesvagSSFVNn51rZeqsUZlmRpiZGjujwF5s/MX2XBMk0mGuNymTrJOZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AxQAc9Y1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AxQAc9Y1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753458127; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UiZnBTHWpWVPXm9lDPLsbMep0xLgG8NJHfff/JNQO4g=; b=AxQAc9Y1ua4DXaN00paeGm91WYW/FJOj19f3TX6I4anwy18M9WKhc++K7IETY6vGD3HBfh 63e+0Bvq2jWM8HIu7UmceS+bV5rzrKlnT1tyVha307XiHKDWRCCkcdiHRCh2TvgRvZdgJ3 w7xqZEpRAU0Vf+FbGnotiPe6Qzfa6Kw= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-v1wkj6HCPBu2zQNyZsLyyA-1; Fri, 25 Jul 2025 11:42:04 -0400 X-MC-Unique: v1wkj6HCPBu2zQNyZsLyyA-1 X-Mimecast-MFC-AGG-ID: v1wkj6HCPBu2zQNyZsLyyA_1753458122 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B2CAE180009F; Fri, 25 Jul 2025 15:42:02 +0000 (UTC) Received: from p16v.luc.cera.cz (unknown [10.45.224.176]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 37B081966665; Fri, 25 Jul 2025 15:41:59 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Prathosh Satish , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Schmidt , Petr Oros Subject: [PATCH net-next 5/5] dpll: zl3073x: Implement devlink flash callback Date: Fri, 25 Jul 2025 17:41:36 +0200 Message-ID: <20250725154136.1008132-6-ivecera@redhat.com> In-Reply-To: <20250725154136.1008132-1-ivecera@redhat.com> References: <20250725154136.1008132-1-ivecera@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Type: text/plain; charset="utf-8" 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 --- 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/n= etworking/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 +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 availab= le, +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" =20 /** @@ -141,11 +143,74 @@ void zl3073x_devlink_flash_notify(struct zl3073x_dev = *zldev, const char *msg, total); } =20 +/** + * 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 =3D devlink_priv(devlink); + struct zl3073x_fw_component *util; + struct zl3073x_fw *zlfw; + int rc =3D 0; + + /* Load firmware */ + zlfw =3D zl3073x_fw_load(zldev, params->fw->data, params->fw->size, + extack); + if (IS_ERR(zlfw)) + return PTR_ERR(zlfw); + + util =3D zlfw->component[ZL_FW_COMPONENT_UTIL]; + if (!util) { + zl3073x_devlink_flash_notify(zldev, + "Utility is missing in firmware", + NULL, 0, 0); + rc =3D -EOPNOTSUPP; + goto error; + } + + /* Stop normal operation during flash */ + zl3073x_dev_stop(zldev); + + /* Enter flashing mode */ + rc =3D zl3073x_flash_mode_enter(zldev, util->data, util->size, extack); + if (!rc) { + /* Flash the firmware */ + rc =3D zl3073x_fw_flash(zldev, zlfw, extack); + + /* Leave flashing mode */ + zl3073x_flash_mode_leave(zldev, extack); + } + + /* Restart normal operation */ + rc =3D 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 =3D { .info_get =3D zl3073x_devlink_info_get, .reload_actions =3D BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT), .reload_down =3D zl3073x_devlink_reload_down, .reload_up =3D zl3073x_devlink_reload_up, + .flash_update =3D zl3073x_devlink_flash_update, }; =20 static void --=20 2.49.1