@@ -414,83 +414,57 @@ mt753x_preferred_default_local_cpu_port(struct dsa_switch *ds)
414
414
}
415
415
416
416
/* Setup port 6 interface mode and TRGMII TX circuit */
417
- static int
418
- mt7530_pad_clk_setup (struct dsa_switch * ds , phy_interface_t interface )
417
+ static void
418
+ mt7530_setup_port6 (struct dsa_switch * ds , phy_interface_t interface )
419
419
{
420
420
struct mt7530_priv * priv = ds -> priv ;
421
- u32 ncpo1 , ssc_delta , trgint , xtal ;
422
-
423
- xtal = mt7530_read (priv , MT7530_MHWTRAP ) & HWTRAP_XTAL_MASK ;
421
+ u32 ncpo1 , ssc_delta , xtal ;
424
422
425
- if (xtal == HWTRAP_XTAL_20MHZ ) {
426
- dev_err (priv -> dev ,
427
- "%s: MT7530 with a 20MHz XTAL is not supported!\n" ,
428
- __func__ );
429
- return - EINVAL ;
430
- }
423
+ /* Disable the MT7530 TRGMII clocks */
424
+ core_clear (priv , CORE_TRGMII_GSW_CLK_CG , REG_TRGMIICK_EN );
431
425
432
- switch (interface ) {
433
- case PHY_INTERFACE_MODE_RGMII :
434
- trgint = 0 ;
435
- break ;
436
- case PHY_INTERFACE_MODE_TRGMII :
437
- trgint = 1 ;
438
- if (xtal == HWTRAP_XTAL_25MHZ )
439
- ssc_delta = 0x57 ;
440
- else
441
- ssc_delta = 0x87 ;
442
- if (priv -> id == ID_MT7621 ) {
443
- /* PLL frequency: 125MHz: 1.0GBit */
444
- if (xtal == HWTRAP_XTAL_40MHZ )
445
- ncpo1 = 0x0640 ;
446
- if (xtal == HWTRAP_XTAL_25MHZ )
447
- ncpo1 = 0x0a00 ;
448
- } else { /* PLL frequency: 250MHz: 2.0Gbit */
449
- if (xtal == HWTRAP_XTAL_40MHZ )
450
- ncpo1 = 0x0c80 ;
451
- if (xtal == HWTRAP_XTAL_25MHZ )
452
- ncpo1 = 0x1400 ;
453
- }
454
- break ;
455
- default :
456
- dev_err (priv -> dev , "xMII interface %d not supported\n" ,
457
- interface );
458
- return - EINVAL ;
426
+ if (interface == PHY_INTERFACE_MODE_RGMII ) {
427
+ mt7530_rmw (priv , MT7530_P6ECR , P6_INTF_MODE_MASK ,
428
+ P6_INTF_MODE (0 ));
429
+ return ;
459
430
}
460
431
461
- mt7530_rmw (priv , MT7530_P6ECR , P6_INTF_MODE_MASK ,
462
- P6_INTF_MODE (trgint ));
432
+ mt7530_rmw (priv , MT7530_P6ECR , P6_INTF_MODE_MASK , P6_INTF_MODE (1 ));
463
433
464
- if (trgint ) {
465
- /* Disable the MT7530 TRGMII clocks */
466
- core_clear (priv , CORE_TRGMII_GSW_CLK_CG , REG_TRGMIICK_EN );
434
+ xtal = mt7530_read (priv , MT7530_MHWTRAP ) & HWTRAP_XTAL_MASK ;
467
435
468
- /* Setup the MT7530 TRGMII Tx Clock */
469
- core_write (priv , CORE_PLL_GROUP5 , RG_LCDDS_PCW_NCPO1 (ncpo1 ));
470
- core_write (priv , CORE_PLL_GROUP6 , RG_LCDDS_PCW_NCPO0 (0 ));
471
- core_write (priv , CORE_PLL_GROUP10 , RG_LCDDS_SSC_DELTA (ssc_delta ));
472
- core_write (priv , CORE_PLL_GROUP11 , RG_LCDDS_SSC_DELTA1 (ssc_delta ));
473
- core_write (priv , CORE_PLL_GROUP4 ,
474
- RG_SYSPLL_DDSFBK_EN | RG_SYSPLL_BIAS_EN |
475
- RG_SYSPLL_BIAS_LPF_EN );
476
- core_write (priv , CORE_PLL_GROUP2 ,
477
- RG_SYSPLL_EN_NORMAL | RG_SYSPLL_VODEN |
478
- RG_SYSPLL_POSDIV (1 ));
479
- core_write (priv , CORE_PLL_GROUP7 ,
480
- RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C (3 ) |
481
- RG_LCDDS_PWDB | RG_LCDDS_ISO_EN );
436
+ if (xtal == HWTRAP_XTAL_25MHZ )
437
+ ssc_delta = 0x57 ;
438
+ else
439
+ ssc_delta = 0x87 ;
482
440
483
- /* Enable the MT7530 TRGMII clocks */
484
- core_set (priv , CORE_TRGMII_GSW_CLK_CG , REG_TRGMIICK_EN );
441
+ if (priv -> id == ID_MT7621 ) {
442
+ /* PLL frequency: 125MHz: 1.0GBit */
443
+ if (xtal == HWTRAP_XTAL_40MHZ )
444
+ ncpo1 = 0x0640 ;
445
+ if (xtal == HWTRAP_XTAL_25MHZ )
446
+ ncpo1 = 0x0a00 ;
447
+ } else { /* PLL frequency: 250MHz: 2.0Gbit */
448
+ if (xtal == HWTRAP_XTAL_40MHZ )
449
+ ncpo1 = 0x0c80 ;
450
+ if (xtal == HWTRAP_XTAL_25MHZ )
451
+ ncpo1 = 0x1400 ;
485
452
}
486
453
487
- return 0 ;
488
- }
454
+ /* Setup the MT7530 TRGMII Tx Clock */
455
+ core_write (priv , CORE_PLL_GROUP5 , RG_LCDDS_PCW_NCPO1 (ncpo1 ));
456
+ core_write (priv , CORE_PLL_GROUP6 , RG_LCDDS_PCW_NCPO0 (0 ));
457
+ core_write (priv , CORE_PLL_GROUP10 , RG_LCDDS_SSC_DELTA (ssc_delta ));
458
+ core_write (priv , CORE_PLL_GROUP11 , RG_LCDDS_SSC_DELTA1 (ssc_delta ));
459
+ core_write (priv , CORE_PLL_GROUP4 , RG_SYSPLL_DDSFBK_EN |
460
+ RG_SYSPLL_BIAS_EN | RG_SYSPLL_BIAS_LPF_EN );
461
+ core_write (priv , CORE_PLL_GROUP2 , RG_SYSPLL_EN_NORMAL |
462
+ RG_SYSPLL_VODEN | RG_SYSPLL_POSDIV (1 ));
463
+ core_write (priv , CORE_PLL_GROUP7 , RG_LCDDS_PCW_NCPO_CHG |
464
+ RG_LCCDS_C (3 ) | RG_LCDDS_PWDB | RG_LCDDS_ISO_EN );
489
465
490
- static int
491
- mt7531_pad_setup (struct dsa_switch * ds , phy_interface_t interface )
492
- {
493
- return 0 ;
466
+ /* Enable the MT7530 TRGMII clocks */
467
+ core_set (priv , CORE_TRGMII_GSW_CLK_CG , REG_TRGMIICK_EN );
494
468
}
495
469
496
470
static void
@@ -943,9 +917,7 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
943
917
val &= ~MHWTRAP_P5_DIS ;
944
918
break ;
945
919
default :
946
- dev_err (ds -> dev , "Unsupported p5_intf_sel %d\n" ,
947
- priv -> p5_intf_sel );
948
- goto unlock_exit ;
920
+ break ;
949
921
}
950
922
951
923
/* Setup RGMII settings */
@@ -975,7 +947,6 @@ static void mt7530_setup_port5(struct dsa_switch *ds, phy_interface_t interface)
975
947
dev_dbg (ds -> dev , "Setup P5, HWTRAP=0x%x, intf_sel=%s, phy-mode=%s\n" ,
976
948
val , p5_intf_modes (priv -> p5_intf_sel ), phy_modes (interface ));
977
949
978
- unlock_exit :
979
950
mutex_unlock (& priv -> reg_mutex );
980
951
}
981
952
@@ -2262,6 +2233,12 @@ mt7530_setup(struct dsa_switch *ds)
2262
2233
return - ENODEV ;
2263
2234
}
2264
2235
2236
+ if ((val & HWTRAP_XTAL_MASK ) == HWTRAP_XTAL_20MHZ ) {
2237
+ dev_err (priv -> dev ,
2238
+ "MT7530 with a 20MHz XTAL is not supported!\n" );
2239
+ return - EINVAL ;
2240
+ }
2241
+
2265
2242
/* Reset the switch through internal reset */
2266
2243
mt7530_write (priv , MT7530_SYS_CTRL ,
2267
2244
SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
@@ -2596,11 +2573,9 @@ static void mt7531_mac_port_get_caps(struct dsa_switch *ds, int port,
2596
2573
static void mt7988_mac_port_get_caps (struct dsa_switch * ds , int port ,
2597
2574
struct phylink_config * config )
2598
2575
{
2599
- phy_interface_zero (config -> supported_interfaces );
2600
-
2601
2576
switch (port ) {
2602
2577
/* Ports which are connected to switch PHYs. There is no MII pinout. */
2603
- case 0 ... 4 :
2578
+ case 0 ... 3 :
2604
2579
__set_bit (PHY_INTERFACE_MODE_INTERNAL ,
2605
2580
config -> supported_interfaces );
2606
2581
break ;
@@ -2614,25 +2589,16 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port,
2614
2589
}
2615
2590
}
2616
2591
2617
- static int
2618
- mt753x_pad_setup (struct dsa_switch * ds , const struct phylink_link_state * state )
2619
- {
2620
- struct mt7530_priv * priv = ds -> priv ;
2621
-
2622
- return priv -> info -> pad_setup (ds , state -> interface );
2623
- }
2624
-
2625
2592
static int
2626
2593
mt7530_mac_config (struct dsa_switch * ds , int port , unsigned int mode ,
2627
2594
phy_interface_t interface )
2628
2595
{
2629
2596
struct mt7530_priv * priv = ds -> priv ;
2630
2597
2631
- /* Only need to setup port5. */
2632
- if (port != 5 )
2633
- return 0 ;
2634
-
2635
- mt7530_setup_port5 (priv -> ds , interface );
2598
+ if (port == 5 )
2599
+ mt7530_setup_port5 (priv -> ds , interface );
2600
+ else if (port == 6 )
2601
+ mt7530_setup_port6 (priv -> ds , interface );
2636
2602
2637
2603
return 0 ;
2638
2604
}
@@ -2788,8 +2754,6 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
2788
2754
if (priv -> p6_interface == state -> interface )
2789
2755
break ;
2790
2756
2791
- mt753x_pad_setup (ds , state );
2792
-
2793
2757
if (mt753x_mac_config (ds , port , mode , state ) < 0 )
2794
2758
goto unsupported ;
2795
2759
@@ -3106,11 +3070,6 @@ mt753x_conduit_state_change(struct dsa_switch *ds,
3106
3070
mt7530_rmw (priv , MT7530_MFC , CPU_EN | CPU_PORT_MASK , val );
3107
3071
}
3108
3072
3109
- static int mt7988_pad_setup (struct dsa_switch * ds , phy_interface_t interface )
3110
- {
3111
- return 0 ;
3112
- }
3113
-
3114
3073
static int mt7988_setup (struct dsa_switch * ds )
3115
3074
{
3116
3075
struct mt7530_priv * priv = ds -> priv ;
@@ -3174,7 +3133,6 @@ const struct mt753x_info mt753x_table[] = {
3174
3133
.phy_write_c22 = mt7530_phy_write_c22 ,
3175
3134
.phy_read_c45 = mt7530_phy_read_c45 ,
3176
3135
.phy_write_c45 = mt7530_phy_write_c45 ,
3177
- .pad_setup = mt7530_pad_clk_setup ,
3178
3136
.mac_port_get_caps = mt7530_mac_port_get_caps ,
3179
3137
.mac_port_config = mt7530_mac_config ,
3180
3138
},
@@ -3186,7 +3144,6 @@ const struct mt753x_info mt753x_table[] = {
3186
3144
.phy_write_c22 = mt7530_phy_write_c22 ,
3187
3145
.phy_read_c45 = mt7530_phy_read_c45 ,
3188
3146
.phy_write_c45 = mt7530_phy_write_c45 ,
3189
- .pad_setup = mt7530_pad_clk_setup ,
3190
3147
.mac_port_get_caps = mt7530_mac_port_get_caps ,
3191
3148
.mac_port_config = mt7530_mac_config ,
3192
3149
},
@@ -3198,7 +3155,6 @@ const struct mt753x_info mt753x_table[] = {
3198
3155
.phy_write_c22 = mt7531_ind_c22_phy_write ,
3199
3156
.phy_read_c45 = mt7531_ind_c45_phy_read ,
3200
3157
.phy_write_c45 = mt7531_ind_c45_phy_write ,
3201
- .pad_setup = mt7531_pad_setup ,
3202
3158
.cpu_port_config = mt7531_cpu_port_config ,
3203
3159
.mac_port_get_caps = mt7531_mac_port_get_caps ,
3204
3160
.mac_port_config = mt7531_mac_config ,
@@ -3211,7 +3167,6 @@ const struct mt753x_info mt753x_table[] = {
3211
3167
.phy_write_c22 = mt7531_ind_c22_phy_write ,
3212
3168
.phy_read_c45 = mt7531_ind_c45_phy_read ,
3213
3169
.phy_write_c45 = mt7531_ind_c45_phy_write ,
3214
- .pad_setup = mt7988_pad_setup ,
3215
3170
.cpu_port_config = mt7988_cpu_port_config ,
3216
3171
.mac_port_get_caps = mt7988_mac_port_get_caps ,
3217
3172
.mac_port_config = mt7988_mac_config ,
@@ -3241,9 +3196,8 @@ mt7530_probe_common(struct mt7530_priv *priv)
3241
3196
/* Sanity check if these required device operations are filled
3242
3197
* properly.
3243
3198
*/
3244
- if (!priv -> info -> sw_setup || !priv -> info -> pad_setup ||
3245
- !priv -> info -> phy_read_c22 || !priv -> info -> phy_write_c22 ||
3246
- !priv -> info -> mac_port_get_caps ||
3199
+ if (!priv -> info -> sw_setup || !priv -> info -> phy_read_c22 ||
3200
+ !priv -> info -> phy_write_c22 || !priv -> info -> mac_port_get_caps ||
3247
3201
!priv -> info -> mac_port_config )
3248
3202
return - EINVAL ;
3249
3203
0 commit comments