31
31
#define NETNEXT_VERSION "11"
32
32
33
33
/* Information for net */
34
- #define NET_VERSION "10 "
34
+ #define NET_VERSION "11 "
35
35
36
36
#define DRIVER_VERSION "v1." NETNEXT_VERSION "." NET_VERSION
37
37
#define DRIVER_AUTHOR "Realtek linux nic maintainers <
[email protected] >"
68
68
#define PLA_LED_FEATURE 0xdd92
69
69
#define PLA_PHYAR 0xde00
70
70
#define PLA_BOOT_CTRL 0xe004
71
+ #define PLA_LWAKE_CTRL_REG 0xe007
71
72
#define PLA_GPHY_INTR_IMR 0xe022
72
73
#define PLA_EEE_CR 0xe040
73
74
#define PLA_EEEP_CR 0xe080
95
96
#define PLA_TALLYCNT 0xe890
96
97
#define PLA_SFF_STS_7 0xe8de
97
98
#define PLA_PHYSTATUS 0xe908
99
+ #define PLA_CONFIG6 0xe90a /* CONFIG6 */
98
100
#define PLA_BP_BA 0xfc26
99
101
#define PLA_BP_0 0xfc28
100
102
#define PLA_BP_1 0xfc2a
107
109
#define PLA_BP_EN 0xfc38
108
110
109
111
#define USB_USB2PHY 0xb41e
112
+ #define USB_SSPHYLINK1 0xb426
110
113
#define USB_SSPHYLINK2 0xb428
111
114
#define USB_U2P3_CTRL 0xb460
112
115
#define USB_CSR_DUMMY1 0xb464
300
303
#define LINK_ON_WAKE_EN 0x0010
301
304
#define LINK_OFF_WAKE_EN 0x0008
302
305
306
+ /* PLA_CONFIG6 */
307
+ #define LANWAKE_CLR_EN BIT(0)
308
+
303
309
/* PLA_CONFIG5 */
304
310
#define BWF_EN 0x0040
305
311
#define MWF_EN 0x0020
312
318
/* PLA_PHY_PWR */
313
319
#define TX_10M_IDLE_EN 0x0080
314
320
#define PFM_PWM_SWITCH 0x0040
321
+ #define TEST_IO_OFF BIT(4)
315
322
316
323
/* PLA_MAC_PWR_CTRL */
317
324
#define D3_CLK_GATED_EN 0x00004000
324
331
#define MAC_CLK_SPDWN_EN BIT(15)
325
332
326
333
/* PLA_MAC_PWR_CTRL3 */
334
+ #define PLA_MCU_SPDWN_EN BIT(14)
327
335
#define PKT_AVAIL_SPDWN_EN 0x0100
328
336
#define SUSPEND_SPDWN_EN 0x0004
329
337
#define U1U2_SPDWN_EN 0x0002
354
362
/* PLA_BOOT_CTRL */
355
363
#define AUTOLOAD_DONE 0x0002
356
364
365
+ /* PLA_LWAKE_CTRL_REG */
366
+ #define LANWAKE_PIN BIT(7)
367
+
357
368
/* PLA_SUSPEND_FLAG */
358
369
#define LINK_CHG_EVENT BIT(0)
359
370
365
376
#define DEBUG_LTSSM 0x0082
366
377
367
378
/* PLA_EXTRA_STATUS */
379
+ #define CUR_LINK_OK BIT(15)
368
380
#define U3P3_CHECK_EN BIT(7) /* RTL_VER_05 only */
369
381
#define LINK_CHANGE_FLAG BIT(8)
382
+ #define POLL_LINK_CHG BIT(0)
370
383
371
384
/* USB_USB2PHY */
372
385
#define USB2PHY_SUSPEND 0x0001
373
386
#define USB2PHY_L1 0x0002
374
387
388
+ /* USB_SSPHYLINK1 */
389
+ #define DELAY_PHY_PWR_CHG BIT(1)
390
+
375
391
/* USB_SSPHYLINK2 */
376
392
#define pwd_dn_scale_mask 0x3ffe
377
393
#define pwd_dn_scale (x ) ((x) << 1)
@@ -2863,6 +2879,17 @@ static int rtl8153_enable(struct r8152 *tp)
2863
2879
r8153_set_rx_early_timeout (tp );
2864
2880
r8153_set_rx_early_size (tp );
2865
2881
2882
+ if (tp -> version == RTL_VER_09 ) {
2883
+ u32 ocp_data ;
2884
+
2885
+ ocp_data = ocp_read_word (tp , MCU_TYPE_USB , USB_FW_TASK );
2886
+ ocp_data &= ~FC_PATCH_TASK ;
2887
+ ocp_write_word (tp , MCU_TYPE_USB , USB_FW_TASK , ocp_data );
2888
+ usleep_range (1000 , 2000 );
2889
+ ocp_data |= FC_PATCH_TASK ;
2890
+ ocp_write_word (tp , MCU_TYPE_USB , USB_FW_TASK , ocp_data );
2891
+ }
2892
+
2866
2893
return rtl_enable (tp );
2867
2894
}
2868
2895
@@ -3376,8 +3403,8 @@ static void rtl8153b_runtime_enable(struct r8152 *tp, bool enable)
3376
3403
r8153b_ups_en (tp , false);
3377
3404
r8153_queue_wake (tp , false);
3378
3405
rtl_runtime_suspend_enable (tp , false);
3379
- r8153_u2p3en (tp , true);
3380
- r8153b_u1u2en (tp , true);
3406
+ if (tp -> udev -> speed != USB_SPEED_HIGH )
3407
+ r8153b_u1u2en (tp , true);
3381
3408
}
3382
3409
}
3383
3410
@@ -4675,7 +4702,6 @@ static void r8153b_hw_phy_cfg(struct r8152 *tp)
4675
4702
4676
4703
r8153_aldps_en (tp , true);
4677
4704
r8152b_enable_fc (tp );
4678
- r8153_u2p3en (tp , true);
4679
4705
4680
4706
set_bit (PHY_RESET , & tp -> flags );
4681
4707
}
@@ -4954,13 +4980,28 @@ static void rtl8152_down(struct r8152 *tp)
4954
4980
4955
4981
static void rtl8153_up (struct r8152 * tp )
4956
4982
{
4983
+ u32 ocp_data ;
4984
+
4957
4985
if (test_bit (RTL8152_UNPLUG , & tp -> flags ))
4958
4986
return ;
4959
4987
4960
4988
r8153_u1u2en (tp , false);
4961
4989
r8153_u2p3en (tp , false);
4962
4990
r8153_aldps_en (tp , false);
4963
4991
r8153_first_init (tp );
4992
+
4993
+ ocp_data = ocp_read_byte (tp , MCU_TYPE_PLA , PLA_CONFIG6 );
4994
+ ocp_data |= LANWAKE_CLR_EN ;
4995
+ ocp_write_byte (tp , MCU_TYPE_PLA , PLA_CONFIG6 , ocp_data );
4996
+
4997
+ ocp_data = ocp_read_byte (tp , MCU_TYPE_PLA , PLA_LWAKE_CTRL_REG );
4998
+ ocp_data &= ~LANWAKE_PIN ;
4999
+ ocp_write_byte (tp , MCU_TYPE_PLA , PLA_LWAKE_CTRL_REG , ocp_data );
5000
+
5001
+ ocp_data = ocp_read_word (tp , MCU_TYPE_USB , USB_SSPHYLINK1 );
5002
+ ocp_data &= ~DELAY_PHY_PWR_CHG ;
5003
+ ocp_write_word (tp , MCU_TYPE_USB , USB_SSPHYLINK1 , ocp_data );
5004
+
4964
5005
r8153_aldps_en (tp , true);
4965
5006
4966
5007
switch (tp -> version ) {
@@ -4979,11 +5020,17 @@ static void rtl8153_up(struct r8152 *tp)
4979
5020
4980
5021
static void rtl8153_down (struct r8152 * tp )
4981
5022
{
5023
+ u32 ocp_data ;
5024
+
4982
5025
if (test_bit (RTL8152_UNPLUG , & tp -> flags )) {
4983
5026
rtl_drop_queued_tx (tp );
4984
5027
return ;
4985
5028
}
4986
5029
5030
+ ocp_data = ocp_read_byte (tp , MCU_TYPE_PLA , PLA_CONFIG6 );
5031
+ ocp_data &= ~LANWAKE_CLR_EN ;
5032
+ ocp_write_byte (tp , MCU_TYPE_PLA , PLA_CONFIG6 , ocp_data );
5033
+
4987
5034
r8153_u1u2en (tp , false);
4988
5035
r8153_u2p3en (tp , false);
4989
5036
r8153_power_cut_en (tp , false);
@@ -4994,6 +5041,8 @@ static void rtl8153_down(struct r8152 *tp)
4994
5041
4995
5042
static void rtl8153b_up (struct r8152 * tp )
4996
5043
{
5044
+ u32 ocp_data ;
5045
+
4997
5046
if (test_bit (RTL8152_UNPLUG , & tp -> flags ))
4998
5047
return ;
4999
5048
@@ -5004,18 +5053,29 @@ static void rtl8153b_up(struct r8152 *tp)
5004
5053
r8153_first_init (tp );
5005
5054
ocp_write_dword (tp , MCU_TYPE_USB , USB_RX_BUF_TH , RX_THR_B );
5006
5055
5056
+ ocp_data = ocp_read_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL3 );
5057
+ ocp_data &= ~PLA_MCU_SPDWN_EN ;
5058
+ ocp_write_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL3 , ocp_data );
5059
+
5007
5060
r8153_aldps_en (tp , true);
5008
- r8153_u2p3en (tp , true);
5009
- r8153b_u1u2en (tp , true);
5061
+
5062
+ if (tp -> udev -> speed != USB_SPEED_HIGH )
5063
+ r8153b_u1u2en (tp , true);
5010
5064
}
5011
5065
5012
5066
static void rtl8153b_down (struct r8152 * tp )
5013
5067
{
5068
+ u32 ocp_data ;
5069
+
5014
5070
if (test_bit (RTL8152_UNPLUG , & tp -> flags )) {
5015
5071
rtl_drop_queued_tx (tp );
5016
5072
return ;
5017
5073
}
5018
5074
5075
+ ocp_data = ocp_read_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL3 );
5076
+ ocp_data |= PLA_MCU_SPDWN_EN ;
5077
+ ocp_write_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL3 , ocp_data );
5078
+
5019
5079
r8153b_u1u2en (tp , false);
5020
5080
r8153_u2p3en (tp , false);
5021
5081
r8153b_power_cut_en (tp , false);
@@ -5387,6 +5447,16 @@ static void r8153_init(struct r8152 *tp)
5387
5447
else
5388
5448
ocp_data |= DYNAMIC_BURST ;
5389
5449
ocp_write_byte (tp , MCU_TYPE_USB , USB_CSR_DUMMY1 , ocp_data );
5450
+
5451
+ r8153_queue_wake (tp , false);
5452
+
5453
+ ocp_data = ocp_read_word (tp , MCU_TYPE_PLA , PLA_EXTRA_STATUS );
5454
+ if (rtl8152_get_speed (tp ) & LINK_STATUS )
5455
+ ocp_data |= CUR_LINK_OK ;
5456
+ else
5457
+ ocp_data &= ~CUR_LINK_OK ;
5458
+ ocp_data |= POLL_LINK_CHG ;
5459
+ ocp_write_word (tp , MCU_TYPE_PLA , PLA_EXTRA_STATUS , ocp_data );
5390
5460
}
5391
5461
5392
5462
ocp_data = ocp_read_byte (tp , MCU_TYPE_USB , USB_CSR_DUMMY2 );
@@ -5416,10 +5486,19 @@ static void r8153_init(struct r8152 *tp)
5416
5486
ocp_write_word (tp , MCU_TYPE_USB , USB_CONNECT_TIMER , 0x0001 );
5417
5487
5418
5488
r8153_power_cut_en (tp , false);
5489
+ rtl_runtime_suspend_enable (tp , false);
5419
5490
r8153_u1u2en (tp , true);
5420
5491
r8153_mac_clk_spd (tp , false);
5421
5492
usb_enable_lpm (tp -> udev );
5422
5493
5494
+ ocp_data = ocp_read_byte (tp , MCU_TYPE_PLA , PLA_CONFIG6 );
5495
+ ocp_data |= LANWAKE_CLR_EN ;
5496
+ ocp_write_byte (tp , MCU_TYPE_PLA , PLA_CONFIG6 , ocp_data );
5497
+
5498
+ ocp_data = ocp_read_byte (tp , MCU_TYPE_PLA , PLA_LWAKE_CTRL_REG );
5499
+ ocp_data &= ~LANWAKE_PIN ;
5500
+ ocp_write_byte (tp , MCU_TYPE_PLA , PLA_LWAKE_CTRL_REG , ocp_data );
5501
+
5423
5502
/* rx aggregation */
5424
5503
ocp_data = ocp_read_word (tp , MCU_TYPE_USB , USB_USB_CTRL );
5425
5504
ocp_data &= ~(RX_AGG_DISABLE | RX_ZERO_EN );
@@ -5484,14 +5563,37 @@ static void r8153b_init(struct r8152 *tp)
5484
5563
r8153b_ups_en (tp , false);
5485
5564
r8153_queue_wake (tp , false);
5486
5565
rtl_runtime_suspend_enable (tp , false);
5487
- r8153b_u1u2en (tp , true);
5566
+
5567
+ ocp_data = ocp_read_word (tp , MCU_TYPE_PLA , PLA_EXTRA_STATUS );
5568
+ if (rtl8152_get_speed (tp ) & LINK_STATUS )
5569
+ ocp_data |= CUR_LINK_OK ;
5570
+ else
5571
+ ocp_data &= ~CUR_LINK_OK ;
5572
+ ocp_data |= POLL_LINK_CHG ;
5573
+ ocp_write_word (tp , MCU_TYPE_PLA , PLA_EXTRA_STATUS , ocp_data );
5574
+
5575
+ if (tp -> udev -> speed != USB_SPEED_HIGH )
5576
+ r8153b_u1u2en (tp , true);
5488
5577
usb_enable_lpm (tp -> udev );
5489
5578
5490
5579
/* MAC clock speed down */
5491
5580
ocp_data = ocp_read_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL2 );
5492
5581
ocp_data |= MAC_CLK_SPDWN_EN ;
5493
5582
ocp_write_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL2 , ocp_data );
5494
5583
5584
+ ocp_data = ocp_read_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL3 );
5585
+ ocp_data &= ~PLA_MCU_SPDWN_EN ;
5586
+ ocp_write_word (tp , MCU_TYPE_PLA , PLA_MAC_PWR_CTRL3 , ocp_data );
5587
+
5588
+ if (tp -> version == RTL_VER_09 ) {
5589
+ /* Disable Test IO for 32QFN */
5590
+ if (ocp_read_byte (tp , MCU_TYPE_PLA , 0xdc00 ) & BIT (5 )) {
5591
+ ocp_data = ocp_read_word (tp , MCU_TYPE_PLA , PLA_PHY_PWR );
5592
+ ocp_data |= TEST_IO_OFF ;
5593
+ ocp_write_word (tp , MCU_TYPE_PLA , PLA_PHY_PWR , ocp_data );
5594
+ }
5595
+ }
5596
+
5495
5597
set_bit (GREEN_ETHERNET , & tp -> flags );
5496
5598
5497
5599
/* rx aggregation */
@@ -6707,6 +6809,11 @@ static int rtl8152_probe(struct usb_interface *intf,
6707
6809
6708
6810
intf -> needs_remote_wakeup = 1 ;
6709
6811
6812
+ if (!rtl_can_wakeup (tp ))
6813
+ __rtl_set_wol (tp , 0 );
6814
+ else
6815
+ tp -> saved_wolopts = __rtl_get_wol (tp );
6816
+
6710
6817
tp -> rtl_ops .init (tp );
6711
6818
#if IS_BUILTIN (CONFIG_USB_RTL8152 )
6712
6819
/* Retry in case request_firmware() is not ready yet. */
@@ -6724,10 +6831,6 @@ static int rtl8152_probe(struct usb_interface *intf,
6724
6831
goto out1 ;
6725
6832
}
6726
6833
6727
- if (!rtl_can_wakeup (tp ))
6728
- __rtl_set_wol (tp , 0 );
6729
-
6730
- tp -> saved_wolopts = __rtl_get_wol (tp );
6731
6834
if (tp -> saved_wolopts )
6732
6835
device_set_wakeup_enable (& udev -> dev , true);
6733
6836
else
0 commit comments