24
24
#define MDIO_MMD_AN_MV_STAT2_100BT1 0x2000
25
25
#define MDIO_MMD_AN_MV_STAT2_1000BT1 0x4000
26
26
27
+ #define MDIO_MMD_PCS_MV_INT_EN 32784
28
+ #define MDIO_MMD_PCS_MV_INT_EN_LINK_UP 0x0040
29
+ #define MDIO_MMD_PCS_MV_INT_EN_LINK_DOWN 0x0080
30
+ #define MDIO_MMD_PCS_MV_INT_EN_100BT1 0x1000
31
+
32
+ #define MDIO_MMD_PCS_MV_GPIO_INT_STAT 32785
33
+ #define MDIO_MMD_PCS_MV_GPIO_INT_STAT_LINK_UP 0x0040
34
+ #define MDIO_MMD_PCS_MV_GPIO_INT_STAT_LINK_DOWN 0x0080
35
+ #define MDIO_MMD_PCS_MV_GPIO_INT_STAT_100BT1_GEN 0x1000
36
+
37
+ #define MDIO_MMD_PCS_MV_GPIO_INT_CTRL 32787
38
+ #define MDIO_MMD_PCS_MV_GPIO_INT_CTRL_TRI_DIS 0x0800
39
+
27
40
#define MDIO_MMD_PCS_MV_100BT1_STAT1 33032
28
41
#define MDIO_MMD_PCS_MV_100BT1_STAT1_IDLE_ERROR 0x00ff
29
42
#define MDIO_MMD_PCS_MV_100BT1_STAT1_JABBER 0x0100
38
51
#define MDIO_MMD_PCS_MV_100BT1_STAT2_LINK 0x0004
39
52
#define MDIO_MMD_PCS_MV_100BT1_STAT2_ANGE 0x0008
40
53
54
+ #define MDIO_MMD_PCS_MV_100BT1_INT_EN 33042
55
+ #define MDIO_MMD_PCS_MV_100BT1_INT_EN_LINKEVENT 0x0400
56
+
57
+ #define MDIO_MMD_PCS_MV_COPPER_INT_STAT 33043
58
+ #define MDIO_MMD_PCS_MV_COPPER_INT_STAT_LINKEVENT 0x0400
59
+
41
60
#define MDIO_MMD_PCS_MV_RX_STAT 33328
42
61
43
62
struct mmd_val {
@@ -99,13 +118,15 @@ static int mv88q2xxx_read_link_gbit(struct phy_device *phydev)
99
118
100
119
/* Read vendor specific Auto-Negotiation status register to get local
101
120
* and remote receiver status according to software initialization
102
- * guide.
121
+ * guide. However, when not in polling mode the local and remote
122
+ * receiver status are not evaluated due to the Marvell 88Q2xxx APIs.
103
123
*/
104
124
ret = phy_read_mmd (phydev , MDIO_MMD_AN , MDIO_MMD_AN_MV_STAT );
105
125
if (ret < 0 ) {
106
126
return ret ;
107
- } else if ((ret & MDIO_MMD_AN_MV_STAT_LOCAL_RX ) &&
108
- (ret & MDIO_MMD_AN_MV_STAT_REMOTE_RX )) {
127
+ } else if (((ret & MDIO_MMD_AN_MV_STAT_LOCAL_RX ) &&
128
+ (ret & MDIO_MMD_AN_MV_STAT_REMOTE_RX )) ||
129
+ !phy_polling_mode (phydev )) {
109
130
/* The link state is latched low so that momentary link
110
131
* drops can be detected. Do not double-read the status
111
132
* in polling mode to detect such short link drops except
@@ -145,7 +166,18 @@ static int mv88q2xxx_read_link_100m(struct phy_device *phydev)
145
166
* the link was already down. In case we are not polling,
146
167
* we always read the realtime status.
147
168
*/
148
- if (!phy_polling_mode (phydev ) || !phydev -> link ) {
169
+ if (!phy_polling_mode (phydev )) {
170
+ phydev -> link = false;
171
+ ret = phy_read_mmd (phydev , MDIO_MMD_PCS ,
172
+ MDIO_MMD_PCS_MV_100BT1_STAT2 );
173
+ if (ret < 0 )
174
+ return ret ;
175
+
176
+ if (ret & MDIO_MMD_PCS_MV_100BT1_STAT2_LINK )
177
+ phydev -> link = true;
178
+
179
+ return 0 ;
180
+ } else if (!phydev -> link ) {
149
181
ret = phy_read_mmd (phydev , MDIO_MMD_PCS ,
150
182
MDIO_MMD_PCS_MV_100BT1_STAT1 );
151
183
if (ret < 0 )
@@ -356,6 +388,79 @@ static int mv88q2xxx_get_sqi_max(struct phy_device *phydev)
356
388
return 15 ;
357
389
}
358
390
391
+ static int mv88q2xxx_config_intr (struct phy_device * phydev )
392
+ {
393
+ int ret ;
394
+
395
+ if (phydev -> interrupts == PHY_INTERRUPT_ENABLED ) {
396
+ /* Enable interrupts for 1000BASE-T1 link up and down events
397
+ * and enable general interrupts for 100BASE-T1.
398
+ */
399
+ ret = phy_write_mmd (phydev , MDIO_MMD_PCS ,
400
+ MDIO_MMD_PCS_MV_INT_EN ,
401
+ MDIO_MMD_PCS_MV_INT_EN_LINK_UP |
402
+ MDIO_MMD_PCS_MV_INT_EN_LINK_DOWN |
403
+ MDIO_MMD_PCS_MV_INT_EN_100BT1 );
404
+ if (ret < 0 )
405
+ return ret ;
406
+
407
+ /* Enable interrupts for 100BASE-T1 link events */
408
+ return phy_write_mmd (phydev , MDIO_MMD_PCS ,
409
+ MDIO_MMD_PCS_MV_100BT1_INT_EN ,
410
+ MDIO_MMD_PCS_MV_100BT1_INT_EN_LINKEVENT );
411
+ } else {
412
+ ret = phy_write_mmd (phydev , MDIO_MMD_PCS ,
413
+ MDIO_MMD_PCS_MV_INT_EN , 0 );
414
+ if (ret < 0 )
415
+ return ret ;
416
+
417
+ return phy_write_mmd (phydev , MDIO_MMD_PCS ,
418
+ MDIO_MMD_PCS_MV_100BT1_INT_EN , 0 );
419
+ }
420
+ }
421
+
422
+ static irqreturn_t mv88q2xxx_handle_interrupt (struct phy_device * phydev )
423
+ {
424
+ bool trigger_machine = false;
425
+ int irq ;
426
+
427
+ /* Before we can acknowledge the 100BT1 general interrupt, that is in
428
+ * the 1000BT1 interrupt status register, we have to acknowledge any
429
+ * interrupts that are related to it. Therefore we read first the 100BT1
430
+ * interrupt status register, followed by reading the 1000BT1 interrupt
431
+ * status register.
432
+ */
433
+
434
+ irq = phy_read_mmd (phydev , MDIO_MMD_PCS ,
435
+ MDIO_MMD_PCS_MV_COPPER_INT_STAT );
436
+ if (irq < 0 ) {
437
+ phy_error (phydev );
438
+ return IRQ_NONE ;
439
+ }
440
+
441
+ /* Check link status for 100BT1 */
442
+ if (irq & MDIO_MMD_PCS_MV_COPPER_INT_STAT_LINKEVENT )
443
+ trigger_machine = true;
444
+
445
+ irq = phy_read_mmd (phydev , MDIO_MMD_PCS , MDIO_MMD_PCS_MV_GPIO_INT_STAT );
446
+ if (irq < 0 ) {
447
+ phy_error (phydev );
448
+ return IRQ_NONE ;
449
+ }
450
+
451
+ /* Check link status for 1000BT1 */
452
+ if ((irq & MDIO_MMD_PCS_MV_GPIO_INT_STAT_LINK_UP ) ||
453
+ (irq & MDIO_MMD_PCS_MV_GPIO_INT_STAT_LINK_DOWN ))
454
+ trigger_machine = true;
455
+
456
+ if (!trigger_machine )
457
+ return IRQ_NONE ;
458
+
459
+ phy_trigger_machine (phydev );
460
+
461
+ return IRQ_HANDLED ;
462
+ }
463
+
359
464
static int mv88q222x_soft_reset (struct phy_device * phydev )
360
465
{
361
466
int ret ;
@@ -422,6 +527,14 @@ static int mv88q222x_revb0_config_init(struct phy_device *phydev)
422
527
*/
423
528
phydev -> pma_extable = MDIO_PMA_EXTABLE_BT1 ;
424
529
530
+ /* Configure interrupt with default settings, output is driven low for
531
+ * active interrupt and high for inactive.
532
+ */
533
+ if (phy_interrupt_is_valid (phydev ))
534
+ return phy_set_bits_mmd (phydev , MDIO_MMD_PCS ,
535
+ MDIO_MMD_PCS_MV_GPIO_INT_CTRL ,
536
+ MDIO_MMD_PCS_MV_GPIO_INT_CTRL_TRI_DIS );
537
+
425
538
return 0 ;
426
539
}
427
540
@@ -448,6 +561,8 @@ static struct phy_driver mv88q2xxx_driver[] = {
448
561
.config_init = mv88q222x_revb0_config_init ,
449
562
.read_status = mv88q2xxx_read_status ,
450
563
.soft_reset = mv88q222x_soft_reset ,
564
+ .config_intr = mv88q2xxx_config_intr ,
565
+ .handle_interrupt = mv88q2xxx_handle_interrupt ,
451
566
.set_loopback = genphy_c45_loopback ,
452
567
.get_sqi = mv88q2xxx_get_sqi ,
453
568
.get_sqi_max = mv88q2xxx_get_sqi_max ,
0 commit comments