6
6
* Copyright (c) 2019-2020 NXP
7
7
*/
8
8
9
+ #include <linux/bitfield.h>
9
10
#include <linux/clk.h>
10
11
#include <linux/io.h>
11
12
#include <linux/module.h>
91
92
92
93
/* USB2 PHY register definition */
93
94
#define UTMI_REG15 0xaf
95
+ #define UTMI_AFE_RX_REG0 0x0d
94
96
#define UTMI_AFE_RX_REG5 0x12
95
97
#define UTMI_AFE_BC_REG4 0x29
96
98
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
+
97
108
/* TB_ADDR_TX_RCVDETSC_CTRL */
98
109
#define RXDET_IN_P3_32KHZ BIT(0)
99
110
/*
@@ -125,6 +136,7 @@ struct cdns_salvo_phy {
125
136
struct clk * clk ;
126
137
void __iomem * base ;
127
138
struct cdns_salvo_data * data ;
139
+ enum usb2_disconn_threshold usb2_disconn ;
128
140
};
129
141
130
142
static const struct of_device_id cdns_salvo_phy_of_match [];
@@ -260,6 +272,12 @@ static int cdns_salvo_phy_init(struct phy *phy)
260
272
value | TXVALID_GATE_THRESHOLD_HS_0US );
261
273
262
274
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
+
263
281
udelay (10 );
264
282
265
283
clk_disable_unprepare (salvo_phy -> clk );
@@ -314,6 +332,7 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
314
332
struct device * dev = & pdev -> dev ;
315
333
struct cdns_salvo_phy * salvo_phy ;
316
334
struct cdns_salvo_data * data ;
335
+ u32 val ;
317
336
318
337
data = (struct cdns_salvo_data * )of_device_get_match_data (dev );
319
338
salvo_phy = devm_kzalloc (dev , sizeof (* salvo_phy ), GFP_KERNEL );
@@ -325,6 +344,16 @@ static int cdns_salvo_phy_probe(struct platform_device *pdev)
325
344
if (IS_ERR (salvo_phy -> clk ))
326
345
return PTR_ERR (salvo_phy -> clk );
327
346
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
+
328
357
salvo_phy -> base = devm_platform_ioremap_resource (pdev , 0 );
329
358
if (IS_ERR (salvo_phy -> base ))
330
359
return PTR_ERR (salvo_phy -> base );
0 commit comments