Skip to content

Commit 3ad5ceb

Browse files
Peter Chenvinodkoul
authored andcommitted
phy: cadence: salvo: add .set_mode API
For NXP platform design, the PHY can't know VBUS well, it causes the FSM in controller seeing the disconnection at L1 use case. With .set_mode API introduced, the controller driver could force PHY seeing B Session VALID when it is at the device mode (VBUS is there), and keep FSM working well. Signed-off-by: Peter Chen <[email protected]> Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent fe55166 commit 3ad5ceb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/phy/cadence/phy-cadence-salvo.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
/* USB2 PHY register definition */
9393
#define UTMI_REG15 0xaf
9494
#define UTMI_AFE_RX_REG5 0x12
95+
#define UTMI_AFE_BC_REG4 0x29
9596

9697
/* TB_ADDR_TX_RCVDETSC_CTRL */
9798
#define RXDET_IN_P3_32KHZ BIT(0)
@@ -105,6 +106,9 @@
105106
/* 0us, txvalid is ready just after HS/FS transmitters have powered up */
106107
#define TXVALID_GATE_THRESHOLD_HS_0US (BIT(4) | BIT(5))
107108

109+
#define SET_B_SESSION_VALID (BIT(6) | BIT(5))
110+
#define CLR_B_SESSION_VALID (BIT(6))
111+
108112
struct cdns_reg_pairs {
109113
u16 val;
110114
u32 off;
@@ -124,6 +128,13 @@ struct cdns_salvo_phy {
124128
};
125129

126130
static const struct of_device_id cdns_salvo_phy_of_match[];
131+
static const struct cdns_salvo_data cdns_nxp_salvo_data;
132+
133+
static bool cdns_is_nxp_phy(struct cdns_salvo_phy *salvo_phy)
134+
{
135+
return salvo_phy->data == &cdns_nxp_salvo_data;
136+
}
137+
127138
static u16 cdns_salvo_read(struct cdns_salvo_phy *salvo_phy, u32 offset, u32 reg)
128139
{
129140
return (u16)readl(salvo_phy->base + offset +
@@ -272,11 +283,29 @@ static int cdns_salvo_phy_power_off(struct phy *phy)
272283
return 0;
273284
}
274285

286+
static int cdns_salvo_set_mode(struct phy *phy, enum phy_mode mode, int submode)
287+
{
288+
struct cdns_salvo_phy *salvo_phy = phy_get_drvdata(phy);
289+
290+
if (!cdns_is_nxp_phy(salvo_phy))
291+
return 0;
292+
293+
if (mode == PHY_MODE_USB_DEVICE)
294+
cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_BC_REG4,
295+
SET_B_SESSION_VALID);
296+
else
297+
cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_BC_REG4,
298+
CLR_B_SESSION_VALID);
299+
300+
return 0;
301+
}
302+
275303
static const struct phy_ops cdns_salvo_phy_ops = {
276304
.init = cdns_salvo_phy_init,
277305
.power_on = cdns_salvo_phy_power_on,
278306
.power_off = cdns_salvo_phy_power_off,
279307
.owner = THIS_MODULE,
308+
.set_mode = cdns_salvo_set_mode,
280309
};
281310

282311
static int cdns_salvo_phy_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)