From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459962; b=Il2+9vgeNX8oba5VlPrIrYpkPVSLm0ZUTIPgIsjR57kYlmq65wl39PxAEufbMXY99DKS eLkUW/FQqVhKunwoDRoNaQw/uAwsB90kgnMv4D/2ep1tYIgVEL5+gLPhVJDMUAjwLEDm6 hHFr5q44PN6aio2KoyRWhzuXK/Sv8TP+v9Jc+meMBcjrb8QfFWKOQTIqzP0292RVt28SP O3Po2Qt1kDOVZb2TxS7xhYY1NaCOfe9esfZXcbjPTr1QMW4v7EiHH6qImrvKR6702Z0lX aAcAsXpff8NN/qiNuMfEADZWJFKUEsq08Gy+SxcrldG0WOq8lb+Lrg7bMrV891rS/yg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796459962; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=dak2kl4kQ/dx7BN6+Q65T9u9CCLvXd4JlVmVK7pETlc=; b=A2DUpzzvikXvLtEl3/AiInuZPfix7B2kw2WO2axI/6XM2jdsBzUCvdHhHjJLiENTNIEF xnRkTCWnDjmuGPsL35Dsq9gmxGtQYwcNLGUH7bF9XOryaGKYbesbf5FzsbkFMyYHXMwE8 tD555KlsTZn9wtmeOz3E+lZTfhFqMycqexfq0yVM9etFzutiFX9Y3CtEelx9+5zHuqFUp a2ALhD2QpO6H4yyJm8ZVwXPGmedTZnXfmJYOGqVOxZMF89iqwai9IBcK0p9h2xtTkPbs8 BkkHoxIxEUHmMJnQHxcguu+xI9ZlGZIVvcZCzG31oGc5Jy0tVt5aCqgPfQs/DPdPagA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TlGYy7Wr; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01019606A330 for ; Sat, 5 Dec 2026 08:39:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 01019606A330 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.a=rsa-sha256 header.s=mimecast20190719 header.b=TlGYy7Wr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796459961; 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=dak2kl4kQ/dx7BN6+Q65T9u9CCLvXd4JlVmVK7pETlc=; b=TlGYy7WrkCoZaipAQI+GAGFScXRNPcz7/OH+HFoCGKp0W/M1n0dBkxTDyKBVs/7u+wi46O VWmGA97BNGNo4h+dSs+TT3EY5yonZKGPXB3f3LBxLo/nY7Qj9KK+23Sf1BfbT/5VtBwlpb EzWCAGvnu+35KHaS49+R2jHJxtmS1LE= Received: from mx-prod-mc-08.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 with 8BITMIME (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-QC8kQJ9_MAaoyA7l2Y7eWQ-1; Sat, 5 Dec 2026 08:39:14 +0000 X-MC-Unique: QC8kQJ9_MAaoyA7l2Y7eWQ-1 X-Mimecast-MFC-AGG-ID: QC8kQJ9_MAaoyA7l2Y7eWQ_1796459951 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 606271800540; Sat, 5 Dec 2026 08:39:11 +0000 (UTC) Received: from ivecera-thinkpadp16vgen1.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A4C51955E9C; Sat, 5 Dec 2026 08:39:07 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Jonathan Corbet , Shuah Khan , Randy Dunlap , Min Li , Vadim Fedorenko , Arkadiusz Kubalewski , linux-doc@vger.kernel.org Subject: [PATCH net-next v2 1/3] dpll: zl3073x: factor device CPU reset into a helper Date: Sat, 5 Dec 2026 09:38:58 +0100 Message-ID: <20261205083900.595822-2-ivecera@redhat.com> In-Reply-To: <20261205083900.595822-1-ivecera@redhat.com> References: <20261205083900.595822-1-ivecera@redhat.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 zl3073x_flash_mode_leave() resets the device CPU back to normal firmware processing via an open-coded HW register write sequence in flash.c. The same core reset is needed for a full device reset that reboots the firmware and reloads the configuration from flash, introduced later in this series. Factor it into a reusable helper, zl3073x_dev_hw_reset(), in core.c. Drop the 'wait' field from struct zl3073x_hwreg_seq_item and the HWREG_SEQ_ITEM() macro. zl3073x_write_hwreg_seq() tested seq->wait instead of seq[i].wait, so only the first item of a sequence was considered and, as that is zero in all the sequences, the 1000 ms waits requested by the flash mode enter sequences never took place. The flash update has worked without them, so drop them instead of fixing the test. zl3073x_flash_mode_leave() waits after the core reset with msleep() on its own, and that wait moves into the helper. Reviewed-by: Min Li Tested-by: Min Li Signed-off-by: Ivan Vecera --- Changes in v2: - Comment that the 500 ms wait after the core reset follows the datasheet RST_B timing (Sashiko) --- drivers/dpll/zl3073x/core.c | 61 ++++++++++++++++++++++++++-- drivers/dpll/zl3073x/core.h | 6 +-- drivers/dpll/zl3073x/flash.c | 79 ++++++++---------------------------- 3 files changed, 77 insertions(+), 69 deletions(-) diff --git a/drivers/dpll/zl3073x/core.c b/drivers/dpll/zl3073x/core.c index 230df08e27cd19..e833c62d064842 100644 --- a/drivers/dpll/zl3073x/core.c +++ b/drivers/dpll/zl3073x/core.c @@ -497,14 +497,69 @@ int zl3073x_write_hwreg_seq(struct zl3073x_dev *zldev, seq[i].value, seq[i].mask); if (rc) return rc; - - if (seq->wait) - msleep(seq->wait); } return rc; } +/** + * zl3073x_dev_hw_reset - Reset the device CPU and reload firmware and config + * @zldev: zl3073x device pointer + * + * Triggers a core reset that reboots the firmware and reloads the whole + * configuration from flash. The device is inaccessible on the control bus + * while the reset is in progress. + * + * Context: Process context. The caller must stop normal operation with + * zl3073x_dev_stop() first. + * + * Return: 0 on success, <0 on error + */ +int zl3073x_dev_hw_reset(struct zl3073x_dev *zldev) +{ + static const struct zl3073x_hwreg_seq_item hw_seq[] = { + HWREG_SEQ_ITEM(0x80000404, 1, BIT(0)), + HWREG_SEQ_ITEM(0x80000410, 1, BIT(0)), + }; + u8 reset_status; + int rc; + + /* Read reset status register */ + rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status); + if (rc) + return rc; + + /* Arm the reset detection flag */ + reset_status |= ZL_REG_RESET_STATUS_RESET; + rc = zl3073x_write_u8(zldev, ZL_REG_RESET_STATUS, reset_status); + if (rc) + return rc; + + /* Trigger the core reset. The last write typically errors out as + * the device CPU resets mid-transaction, so its return value is + * not checked. + */ + zl3073x_write_hwreg_seq(zldev, hw_seq, ARRAY_SIZE(hw_seq)); + + /* The core reset acts like a reset via the RST_B pin, device + * registers can be accessed 500 ms after it. + */ + msleep(500); + + /* Read again the reset status register */ + rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status); + if (rc) + return rc; + + /* Check the reset flag was cleared by the firmware */ + if (reset_status & ZL_REG_RESET_STATUS_RESET) { + dev_err(zldev->dev, "Device reset not confirmed\n"); + return -EINVAL; + } + + return 0; +} + static int zl3073x_dev_state_fetch(struct zl3073x_dev *zldev) { diff --git a/drivers/dpll/zl3073x/core.h b/drivers/dpll/zl3073x/core.h index 67c10e2595118c..4d979543500c4e 100644 --- a/drivers/dpll/zl3073x/core.h +++ b/drivers/dpll/zl3073x/core.h @@ -125,21 +125,18 @@ int zl3073x_dev_phase_avg_factor_set(struct zl3073x_dev *zldev, u8 factor); * @addr: HW register to be written * @value: value to be written to HW register * @mask: bitmask indicating bits to be updated - * @wait: number of ms to wait after register write */ struct zl3073x_hwreg_seq_item { u32 addr; u32 value; u32 mask; - u32 wait; }; -#define HWREG_SEQ_ITEM(_addr, _value, _mask, _wait) \ +#define HWREG_SEQ_ITEM(_addr, _value, _mask) \ { \ .addr = _addr, \ .value = FIELD_PREP_CONST(_mask, _value), \ .mask = _mask, \ - .wait = _wait, \ } int zl3073x_mb_op(struct zl3073x_dev *zldev, unsigned int op_reg, u8 op_val, @@ -161,6 +158,7 @@ int zl3073x_update_hwreg(struct zl3073x_dev *zldev, u32 addr, u32 value, int zl3073x_write_hwreg_seq(struct zl3073x_dev *zldev, const struct zl3073x_hwreg_seq_item *seq, size_t num_items); +int zl3073x_dev_hw_reset(struct zl3073x_dev *zldev); /***************** * Misc operations diff --git a/drivers/dpll/zl3073x/flash.c b/drivers/dpll/zl3073x/flash.c index f85535c8ad2469..306e7c857b2313 100644 --- a/drivers/dpll/zl3073x/flash.c +++ b/drivers/dpll/zl3073x/flash.c @@ -529,22 +529,22 @@ int zl3073x_flash_mode_enter(struct zl3073x_dev *zldev, const void *util_ptr, { /* Sequence to be written prior utility download */ static const struct zl3073x_hwreg_seq_item pre_seq[] = { - HWREG_SEQ_ITEM(0x80000400, 1, BIT(0), 0), - HWREG_SEQ_ITEM(0x80206340, 1, BIT(4), 0), - HWREG_SEQ_ITEM(0x10000000, 1, BIT(2), 0), - HWREG_SEQ_ITEM(0x10000024, 0x00000001, U32_MAX, 0), - HWREG_SEQ_ITEM(0x10000020, 0x00000001, U32_MAX, 0), - HWREG_SEQ_ITEM(0x10000000, 1, BIT(10), 1000), + HWREG_SEQ_ITEM(0x80000400, 1, BIT(0)), + HWREG_SEQ_ITEM(0x80206340, 1, BIT(4)), + HWREG_SEQ_ITEM(0x10000000, 1, BIT(2)), + HWREG_SEQ_ITEM(0x10000024, 0x00000001, U32_MAX), + HWREG_SEQ_ITEM(0x10000020, 0x00000001, U32_MAX), + HWREG_SEQ_ITEM(0x10000000, 1, BIT(10)), }; /* Sequence to be written after utility download */ static const struct zl3073x_hwreg_seq_item post_seq[] = { - HWREG_SEQ_ITEM(0x10400004, 0x000000C0, U32_MAX, 0), - HWREG_SEQ_ITEM(0x10400008, 0x00000000, U32_MAX, 0), - HWREG_SEQ_ITEM(0x10400010, 0x20000000, U32_MAX, 0), - HWREG_SEQ_ITEM(0x10400014, 0x20000004, U32_MAX, 0), - HWREG_SEQ_ITEM(0x10000000, 1, GENMASK(10, 9), 0), - HWREG_SEQ_ITEM(0x10000020, 0x00000000, U32_MAX, 0), - HWREG_SEQ_ITEM(0x10000000, 0, BIT(0), 1000), + HWREG_SEQ_ITEM(0x10400004, 0x000000C0, U32_MAX), + HWREG_SEQ_ITEM(0x10400008, 0x00000000, U32_MAX), + HWREG_SEQ_ITEM(0x10400010, 0x20000000, U32_MAX), + HWREG_SEQ_ITEM(0x10400014, 0x20000004, U32_MAX), + HWREG_SEQ_ITEM(0x10000000, 1, GENMASK(10, 9)), + HWREG_SEQ_ITEM(0x10000020, 0x00000000, U32_MAX), + HWREG_SEQ_ITEM(0x10000000, 0, BIT(0)), }; int rc; @@ -604,62 +604,17 @@ int zl3073x_flash_mode_enter(struct zl3073x_dev *zldev, const void *util_ptr, * @extack: netlink extack pointer to report errors * * The function instructs the device to leave the flash mode and - * to return back to normal operation. - * - * The procedure: - * 1) Set reset flag - * 2) Reset the device CPU by specific HW register sequence - * 3) Wait for the device to be ready - * 4) Check the reset flag was cleared + * to return back to normal operation by resetting the device CPU + * with zl3073x_dev_hw_reset(). * * Return: 0 on success, <0 on error */ int zl3073x_flash_mode_leave(struct zl3073x_dev *zldev, struct netlink_ext_ack *extack) { - /* Sequence to be written after flash */ - static const struct zl3073x_hwreg_seq_item fw_reset_seq[] = { - HWREG_SEQ_ITEM(0x80000404, 1, BIT(0), 0), - HWREG_SEQ_ITEM(0x80000410, 1, BIT(0), 0), - }; - u8 reset_status; - int rc; - zl3073x_devlink_flash_notify(zldev, "Leaving flash mode", "utility", 0, 0); - /* Read reset status register */ - rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status); - if (rc) - return rc; - - /* Set reset bit */ - reset_status |= ZL_REG_RESET_STATUS_RESET; - - /* Update reset status register */ - rc = zl3073x_write_u8(zldev, ZL_REG_RESET_STATUS, reset_status); - if (rc) - return rc; - - /* We do not check the return value here as the sequence resets - * the device CPU and the last write always return an error. - */ - zl3073x_write_hwreg_seq(zldev, fw_reset_seq, ARRAY_SIZE(fw_reset_seq)); - - /* Wait for the device to be ready */ - msleep(500); - - /* Read again the reset status register */ - rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status); - if (rc) - return rc; - - /* Check the reset bit was cleared */ - if (reset_status & ZL_REG_RESET_STATUS_RESET) { - dev_err(zldev->dev, - "Reset not confirmed after switch to normal mode\n"); - return -EINVAL; - } - - return 0; + /* Reset the device CPU to resume normal firmware processing */ + return zl3073x_dev_hw_reset(zldev); } -- 2.56.1