From nobody Wed Dec 17 14:10:54 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 D79C0255F5E for ; Mon, 13 Oct 2025 14:06:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760364368; cv=none; b=f4JbCb7MEAlVMP2X4z66QEAu5S74l1D8vfGwOxq35oAxKD6YzAUztQWj6V2VXACw6d4D/2QHLyO3GrO/L9AJKrAe34SBPHOtpz/Qa00+Akcd/VZdxl6A58q8YkGtn0jkV+ojWPnnsKDs2ucEZJSSKNS1lqqhrd2bVOpXp6eMM7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760364368; c=relaxed/simple; bh=RXiNSsaLBFvnwtGUyw4I9dI1476goIIzvGRvfaz60TY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YP1l2/ABtz9MeYrcmZ23OHMZww2YnUvKZGaoF3MIPir0sSqCymq8TGV7tF5iEC8vodDJy9VjHHXRRjT2+8Pv8a2BF0qia4Lmjpxx2R79qOTnXhF5wtC8sA5uF13LLbObdLumZnb1pERm2qfUXuv64zaQ4iEU9zqY+QIgkkigRNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dslZM7Jt; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dslZM7Jt" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 2F3764E4106D; Mon, 13 Oct 2025 14:06:05 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 05FE7606C6; Mon, 13 Oct 2025 14:06:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 226F5102F226C; Mon, 13 Oct 2025 16:06:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760364364; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=IAlSFBW3wt+5q5wx1Fjlx3+q6drrWVIVS7BvJiZpmkM=; b=dslZM7Jtcup6liLgBz8gGb//d6JIfevUXzkVaHDshosSxLehuvZVGdAZCp7X1eUtMnfO9T K8cOfsWVdSzIqEXZif7AGJ8G0h6uaFN58FTpUakuFAC6F6n7MkGgv9EUZkMDSiguVJn+6b BU/ftJwksrZVTd97hybzAM7yuOLMx+mYRsfStDFLvfOaMAww/G1z95YwwJA+OHAw+idu1p M5buwSFSnye1c7/tEYpWjNw0gh3XaRuMK6ZTW0xbWn1C9u+FaCHtFyp4QGdalHvZaHhoN8 XCUxiJw/OwF/00RZU/a8uZ4nlyYYiimW0FsE5dFU8Oo6gGOkpOsLfXf9SP3gaA== From: Kory Maincent Date: Mon, 13 Oct 2025 16:05:33 +0200 Subject: [PATCH net-next v2 3/3] net: pse-pd: pd692x0: Preserve PSE configuration across reboots Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251013-feature_pd692x0_reboot_keep_conf-v2-3-68ab082a93dd@bootlin.com> References: <20251013-feature_pd692x0_reboot_keep_conf-v2-0-68ab082a93dd@bootlin.com> In-Reply-To: <20251013-feature_pd692x0_reboot_keep_conf-v2-0-68ab082a93dd@bootlin.com> To: Oleksij Rempel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Thomas Petazzoni , kernel@pengutronix.de, Dent Project , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kory Maincent X-Mailer: b4 0.15-dev-8cb71 X-Last-TLS-Session-Version: TLSv1.3 From: Kory Maincent (Dent Project) Detect when PSE hardware is already configured (user byte =3D=3D 42) and skip hardware initialization to prevent power interruption to connected devices during system reboots. Previously, the driver would always reconfigure the PSE hardware on probe, causing a port matrix reflash that resulted in temporary power loss to all connected devices. This change maintains power continuity by preserving existing configuration when the PSE has been previously initialized. Signed-off-by: Kory Maincent Reviewed-by: Simon Horman --- drivers/net/pse-pd/pd692x0.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/net/pse-pd/pd692x0.c b/drivers/net/pse-pd/pd692x0.c index 782b1abf94cb..134435e90073 100644 --- a/drivers/net/pse-pd/pd692x0.c +++ b/drivers/net/pse-pd/pd692x0.c @@ -30,6 +30,8 @@ #define PD692X0_FW_MIN_VER 5 #define PD692X0_FW_PATCH_VER 5 =20 +#define PD692X0_USER_BYTE 42 + enum pd692x0_fw_state { PD692X0_FW_UNKNOWN, PD692X0_FW_OK, @@ -80,6 +82,7 @@ enum { PD692X0_MSG_GET_PORT_PARAM, PD692X0_MSG_GET_POWER_BANK, PD692X0_MSG_SET_POWER_BANK, + PD692X0_MSG_SET_USER_BYTE, =20 /* add new message above here */ PD692X0_MSG_CNT @@ -103,6 +106,7 @@ struct pd692x0_priv { bool last_cmd_key; unsigned long last_cmd_key_time; =20 + bool cfg_saved; enum ethtool_c33_pse_admin_state admin_state[PD692X0_MAX_PIS]; struct regulator_dev *manager_reg[PD692X0_MAX_MANAGERS]; int manager_pw_budget[PD692X0_MAX_MANAGERS]; @@ -193,6 +197,12 @@ static const struct pd692x0_msg pd692x0_msg_template_l= ist[PD692X0_MSG_CNT] =3D { .key =3D PD692X0_KEY_CMD, .sub =3D {0x07, 0x0b, 0x57}, }, + [PD692X0_MSG_SET_USER_BYTE] =3D { + .key =3D PD692X0_KEY_PRG, + .sub =3D {0x41, PD692X0_USER_BYTE}, + .data =3D {0x4e, 0x4e, 0x4e, 0x4e, + 0x4e, 0x4e, 0x4e, 0x4e}, + }, }; =20 static u8 pd692x0_build_msg(struct pd692x0_msg *msg, u8 echo) @@ -1233,6 +1243,15 @@ static void pd692x0_managers_free_pw_budget(struct p= d692x0_priv *priv) } } =20 +static int +pd692x0_save_user_byte(struct pd692x0_priv *priv) +{ + struct pd692x0_msg msg, buf; + + msg =3D pd692x0_msg_template_list[PD692X0_MSG_SET_USER_BYTE]; + return pd692x0_sendrecv_msg(priv, &msg, &buf); +} + static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev) { struct pd692x0_priv *priv =3D to_pd692x0_priv(pcdev); @@ -1268,9 +1287,16 @@ static int pd692x0_setup_pi_matrix(struct pse_contro= ller_dev *pcdev) if (ret) goto err_managers_req_pw; =20 - ret =3D pd692x0_hw_conf_init(priv); - if (ret) - goto err_managers_req_pw; + /* Do not init the conf if it is already saved */ + if (!priv->cfg_saved) { + ret =3D pd692x0_hw_conf_init(priv); + if (ret) + goto err_managers_req_pw; + + ret =3D pd692x0_save_user_byte(priv); + if (ret) + goto err_managers_req_pw; + } =20 pd692x0_of_put_managers(priv, manager); kfree(manager); @@ -1793,6 +1819,9 @@ static int pd692x0_i2c_probe(struct i2c_client *clien= t) } } =20 + if (buf.data[2] =3D=3D PD692X0_USER_BYTE) + priv->cfg_saved =3D true; + priv->np =3D dev->of_node; priv->pcdev.nr_lines =3D PD692X0_MAX_PIS; priv->pcdev.owner =3D THIS_MODULE; --=20 2.43.0