Skip to content

Commit f3cb3c7

Browse files
kmaincentPaolo Abeni
authored andcommitted
net: pse-pd: tps23881: Add missing configuration register after disable
When setting the PWOFF register, the controller resets multiple configuration registers. This patch ensures these registers are reconfigured as needed following a disable operation. Acked-by: Oleksij Rempel <[email protected]> Signed-off-by: Kory Maincent <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4c2bab5 commit f3cb3c7

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

drivers/net/pse-pd/tps23881.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
130130
struct i2c_client *client = priv->client;
131131
u8 chan;
132132
u16 val;
133+
int ret;
133134

134135
if (id >= TPS23881_MAX_CHANS)
135136
return -ERANGE;
@@ -143,7 +144,34 @@ static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
143144
BIT(chan % 4));
144145
}
145146

146-
return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
147+
ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
148+
if (ret)
149+
return ret;
150+
151+
/* PWOFF command resets lots of register which need to be
152+
* configured again. According to the datasheet "It may take upwards
153+
* of 5ms after PWOFFn command for all register values to be updated"
154+
*/
155+
mdelay(5);
156+
157+
/* Enable detection and classification */
158+
ret = i2c_smbus_read_word_data(client, TPS23881_REG_DET_CLA_EN);
159+
if (ret < 0)
160+
return ret;
161+
162+
chan = priv->port[id].chan[0];
163+
val = tps23881_set_val(ret, chan, 0, BIT(chan % 4), BIT(chan % 4));
164+
val = tps23881_set_val(val, chan, 4, BIT(chan % 4), BIT(chan % 4));
165+
166+
if (priv->port[id].is_4p) {
167+
chan = priv->port[id].chan[1];
168+
val = tps23881_set_val(ret, chan, 0, BIT(chan % 4),
169+
BIT(chan % 4));
170+
val = tps23881_set_val(val, chan, 4, BIT(chan % 4),
171+
BIT(chan % 4));
172+
}
173+
174+
return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val);
147175
}
148176

149177
static int tps23881_pi_is_enabled(struct pse_controller_dev *pcdev, int id)

0 commit comments

Comments
 (0)