Skip to content

Commit e8c3336

Browse files
nxpfranklivinodkoul
authored andcommitted
phy: cadence: salvo: Add cdns,usb2-disconnect-threshold-microvolt property
Add cdns,usb2-disconnect-threshold-microvolt property to address fake USB disconnection issue during enumeration or suspend state for difference platform. Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 3ad5ceb commit e8c3336

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
@@ -6,6 +6,7 @@
66
* Copyright (c) 2019-2020 NXP
77
*/
88

9+
#include <linux/bitfield.h>
910
#include <linux/clk.h>
1011
#include <linux/io.h>
1112
#include <linux/module.h>
@@ -91,9 +92,19 @@
9192

9293
/* USB2 PHY register definition */
9394
#define UTMI_REG15 0xaf
95+
#define UTMI_AFE_RX_REG0 0x0d
9496
#define UTMI_AFE_RX_REG5 0x12
9597
#define UTMI_AFE_BC_REG4 0x29
9698

99+
/* Align UTMI_AFE_RX_REG0 bit[7:6] define */
100+
enum usb2_disconn_threshold {
101+
USB2_DISCONN_THRESHOLD_575 = 0x0,
102+
USB2_DISCONN_THRESHOLD_610 = 0x1,
103+
USB2_DISCONN_THRESHOLD_645 = 0x3,
104+
};
105+
106+
#define RX_USB2_DISCONN_MASK GENMASK(7, 6)
107+
97108
/* TB_ADDR_TX_RCVDETSC_CTRL */
98109
#define RXDET_IN_P3_32KHZ BIT(0)
99110
/*
@@ -125,6 +136,7 @@ struct cdns_salvo_phy {
125136
struct clk *clk;
126137
void __iomem *base;
127138
struct cdns_salvo_data *data;
139+
enum usb2_disconn_threshold usb2_disconn;
128140
};
129141

130142
static const struct of_device_id cdns_salvo_phy_of_match[];
@@ -260,6 +272,12 @@ static int cdns_salvo_phy_init(struct phy *phy)
260272
value | TXVALID_GATE_THRESHOLD_HS_0US);
261273

262274
cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG5, 0x5);
275+
276+
value = cdns_salvo_read(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG0);
277+
value &= ~RX_USB2_DISCONN_MASK;
278+
value = FIELD_PREP(RX_USB2_DISCONN_MASK, salvo_phy->usb2_disconn);
279+
cdns_salvo_write(salvo_phy, USB2_PHY_OFFSET, UTMI_AFE_RX_REG0, value);
280+
263281
udelay(10);
264282

265283
clk_disable_unprepare(salvo_phy->clk);
@@ -314,6 +332,7 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
314332
struct device *dev = &pdev->dev;
315333
struct cdns_salvo_phy *salvo_phy;
316334
struct cdns_salvo_data *data;
335+
u32 val;
317336

318337
data = (struct cdns_salvo_data *)of_device_get_match_data(dev);
319338
salvo_phy = devm_kzalloc(dev, sizeof(*salvo_phy), GFP_KERNEL);
@@ -325,6 +344,16 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
325344
if (IS_ERR(salvo_phy->clk))
326345
return PTR_ERR(salvo_phy->clk);
327346

347+
if (of_property_read_u32(dev->of_node, "cdns,usb2-disconnect-threshold-microvolt", &val))
348+
val = 575;
349+
350+
if (val < 610)
351+
salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_575;
352+
else if (val < 645)
353+
salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_610;
354+
else
355+
salvo_phy->usb2_disconn = USB2_DISCONN_THRESHOLD_645;
356+
328357
salvo_phy->base = devm_platform_ioremap_resource(pdev, 0);
329358
if (IS_ERR(salvo_phy->base))
330359
return PTR_ERR(salvo_phy->base);

0 commit comments

Comments
 (0)