Skip to content

Commit 8f3d044

Browse files
kmaincentkuba-moo
authored andcommitted
net: pse-pd: pd692x0: Preserve PSE configuration across reboots
Detect when PSE hardware is already configured (user byte == 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 <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/20251013-feature_pd692x0_reboot_keep_conf-v2-3-68ab082a93dd@bootlin.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 6fa1f8b commit 8f3d044

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

drivers/net/pse-pd/pd692x0.c

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#define PD692X0_FW_MIN_VER 5
3131
#define PD692X0_FW_PATCH_VER 5
3232

33+
#define PD692X0_USER_BYTE 42
34+
3335
enum pd692x0_fw_state {
3436
PD692X0_FW_UNKNOWN,
3537
PD692X0_FW_OK,
@@ -80,6 +82,7 @@ enum {
8082
PD692X0_MSG_GET_PORT_PARAM,
8183
PD692X0_MSG_GET_POWER_BANK,
8284
PD692X0_MSG_SET_POWER_BANK,
85+
PD692X0_MSG_SET_USER_BYTE,
8386

8487
/* add new message above here */
8588
PD692X0_MSG_CNT
@@ -103,6 +106,7 @@ struct pd692x0_priv {
103106
bool last_cmd_key;
104107
unsigned long last_cmd_key_time;
105108

109+
bool cfg_saved;
106110
enum ethtool_c33_pse_admin_state admin_state[PD692X0_MAX_PIS];
107111
struct regulator_dev *manager_reg[PD692X0_MAX_MANAGERS];
108112
int manager_pw_budget[PD692X0_MAX_MANAGERS];
@@ -193,6 +197,12 @@ static const struct pd692x0_msg pd692x0_msg_template_list[PD692X0_MSG_CNT] = {
193197
.key = PD692X0_KEY_CMD,
194198
.sub = {0x07, 0x0b, 0x57},
195199
},
200+
[PD692X0_MSG_SET_USER_BYTE] = {
201+
.key = PD692X0_KEY_PRG,
202+
.sub = {0x41, PD692X0_USER_BYTE},
203+
.data = {0x4e, 0x4e, 0x4e, 0x4e,
204+
0x4e, 0x4e, 0x4e, 0x4e},
205+
},
196206
};
197207

198208
static u8 pd692x0_build_msg(struct pd692x0_msg *msg, u8 echo)
@@ -1233,6 +1243,15 @@ static void pd692x0_managers_free_pw_budget(struct pd692x0_priv *priv)
12331243
}
12341244
}
12351245

1246+
static int
1247+
pd692x0_save_user_byte(struct pd692x0_priv *priv)
1248+
{
1249+
struct pd692x0_msg msg, buf;
1250+
1251+
msg = pd692x0_msg_template_list[PD692X0_MSG_SET_USER_BYTE];
1252+
return pd692x0_sendrecv_msg(priv, &msg, &buf);
1253+
}
1254+
12361255
static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev)
12371256
{
12381257
struct pd692x0_priv *priv = to_pd692x0_priv(pcdev);
@@ -1268,9 +1287,16 @@ static int pd692x0_setup_pi_matrix(struct pse_controller_dev *pcdev)
12681287
if (ret)
12691288
goto err_managers_req_pw;
12701289

1271-
ret = pd692x0_hw_conf_init(priv);
1272-
if (ret)
1273-
goto err_managers_req_pw;
1290+
/* Do not init the conf if it is already saved */
1291+
if (!priv->cfg_saved) {
1292+
ret = pd692x0_hw_conf_init(priv);
1293+
if (ret)
1294+
goto err_managers_req_pw;
1295+
1296+
ret = pd692x0_save_user_byte(priv);
1297+
if (ret)
1298+
goto err_managers_req_pw;
1299+
}
12741300

12751301
pd692x0_of_put_managers(priv, manager);
12761302
kfree(manager);
@@ -1793,6 +1819,9 @@ static int pd692x0_i2c_probe(struct i2c_client *client)
17931819
}
17941820
}
17951821

1822+
if (buf.data[2] == PD692X0_USER_BYTE)
1823+
priv->cfg_saved = true;
1824+
17961825
priv->np = dev->of_node;
17971826
priv->pcdev.nr_lines = PD692X0_MAX_PIS;
17981827
priv->pcdev.owner = THIS_MODULE;

0 commit comments

Comments
 (0)