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=1796321207; b=TC5I5NDQZ46A8+pq44BbP9g2G8bm8K4DubEplfoOHD0b47sv/fifQNigoifK/FESn6xK yf56xmQtM26VzYKc0yKB3U2wGoXygRF+JQIRbfvB0ifjizIbX90xGjh9GPHn7rwop44wn SYqyClndXU7lURgfPhnhclyqSmsI71VhCQLTyIY3T0dh5UlnJdfSNwgt6Q7K5r0sqUj4Y Oc+JBKGWi5DLNQy+Swjgu6qVEtO8g4L0tSDKLUwAxHcUppGjC50Ny36ZQB+BJuBmmOeOa lyf9l9u197czaqirE5D/Sm3DtGqO9QuPtnbr9pRRoyxsU7ENgeuJRrsMB6wt1So0+Sw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796321207; 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=MSc9GI+o4HciX7koy9k7beue7Ox5Y1RT6Zlx4CPAaBs=; b=Nu4YHBPniPRr9g8nPZGKAoOUe1lyAXqS/Ffy9LIXLzt+9nfa3pY1pSo9y5diTWs9/XGV E5c2ImoTR1zTvM7Yu4rk/CfXICgSxgikHfeeqVVlf8g5bDkaRxPG9yaXh0OVNOoBBVn0z W2UZ7TgKxTJNsDHAj6nwpQ2bhA+3JG7JpLycMVcef2Ir4gA4w+NKawq9EyioOLw8ZTJKp m1K7PDPMdA7lc+iVnxAL62cfnEa8b2No46MPEVj8ZxtYDcia09p7tIHUiHSqqP0QIeWmi 2AMtdgvmGNlWdJBlkhyWNVUv7g+WBnr9VqGmR2MVCGp0E+ubX9WTfjgnJT6S6tVyV5A== 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=SOBTQY7u; 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 226B3606A322 for ; Thu, 3 Dec 2026 18:06:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 226B3606A322 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=SOBTQY7u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796321207; 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=MSc9GI+o4HciX7koy9k7beue7Ox5Y1RT6Zlx4CPAaBs=; b=SOBTQY7uJnNlhYr/2dOBGZkxLJwAogWZcaxp0dh9Iv8rS9I8EhbAXPgSeWAk8DUN/78SAR OozzrpLpQ26XP1Y9XfmoZVH3Gcs9MwBJoXHj+vZS0pPDW+bFr5MRZAT6eEqKvTvVibjlE/ oQxS/3wL19b664phdS0sGG0DWfrWdt8= 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 (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-428-BGwAJVXsMQ-r9hikn8JnWQ-1; Thu, 3 Dec 2026 18:06:41 +0000 X-MC-Unique: BGwAJVXsMQ-r9hikn8JnWQ-1 X-Mimecast-MFC-AGG-ID: BGwAJVXsMQ-r9hikn8JnWQ_1796321199 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 3C0CE18B50E8; Thu, 3 Dec 2026 18:06:38 +0000 (UTC) Received: from ivecera-thinkpadp16vgen1.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2104D3002D19; Thu, 3 Dec 2026 18:06:33 +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 , Shuah Khan , Randy Dunlap , Min Li , Vadim Fedorenko , Arkadiusz Kubalewski , linux-doc@vger.kernel.org Subject: [PATCH net-next 1/3] dpll: zl3073x: factor device CPU reset into a helper Date: Thu, 3 Dec 2026 19:06:25 +0100 Message-ID: <20261203180627.215256-2-ivecera@redhat.com> In-Reply-To: <20261203180627.215256-1-ivecera@redhat.com> References: <20261203180627.215256-1-ivecera@redhat.com> X-Mailing-List: linux-doc@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.4.1 on 10.30.177.4 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 --- drivers/dpll/zl3073x/core.c | 58 ++++++++++++++++++++++++-- drivers/dpll/zl3073x/core.h | 6 +-- drivers/dpll/zl3073x/flash.c | 79 ++++++++---------------------------- 3 files changed, 74 insertions(+), 69 deletions(-) diff --git a/drivers/dpll/zl3073x/core.c b/drivers/dpll/zl3073x/core.c index 230df08e27cd19..27a55d810d5b05 100644 --- a/drivers/dpll/zl3073x/core.c +++ b/drivers/dpll/zl3073x/core.c @@ -497,14 +497,66 @@ 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)); + + 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