Skip to content

Commit 7b6e623

Browse files
oleremkuba-moo
authored andcommitted
net: dsa: microchip: ksz8795: handle eee specif erratum
According to erratum described in DS80000687C[1]: "Module 2: Link drops with some EEE link partners.", we need to "Disable the EEE next page exchange in EEE Global Register 2" 1 - https://ww1.microchip.com/downloads/en/DeviceDoc/KSZ87xx-Errata-DS80000687C.pdf Signed-off-by: Oleksij Rempel <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 82e94d4 commit 7b6e623

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

drivers/net/dsa/microchip/ksz8.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum ksz_regs {
1616
REG_IND_DATA_HI,
1717
REG_IND_DATA_LO,
1818
REG_IND_MIB_CHECK,
19+
REG_IND_BYTE,
1920
P_FORCE_CTRL,
2021
P_LINK_STATUS,
2122
P_LOCAL_CTRL,

drivers/net/dsa/microchip/ksz8795.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static const u8 ksz8795_regs[] = {
3333
[REG_IND_DATA_HI] = 0x71,
3434
[REG_IND_DATA_LO] = 0x75,
3535
[REG_IND_MIB_CHECK] = 0x74,
36+
[REG_IND_BYTE] = 0xA0,
3637
[P_FORCE_CTRL] = 0x0C,
3738
[P_LINK_STATUS] = 0x0E,
3839
[P_LOCAL_CTRL] = 0x07,
@@ -222,6 +223,25 @@ static void ksz_port_cfg(struct ksz_device *dev, int port, int offset, u8 bits,
222223
bits, set ? bits : 0);
223224
}
224225

226+
static int ksz8_ind_write8(struct ksz_device *dev, u8 table, u16 addr, u8 data)
227+
{
228+
struct ksz8 *ksz8 = dev->priv;
229+
const u8 *regs = ksz8->regs;
230+
u16 ctrl_addr;
231+
int ret = 0;
232+
233+
mutex_lock(&dev->alu_mutex);
234+
235+
ctrl_addr = IND_ACC_TABLE(table) | addr;
236+
ret = ksz_write8(dev, regs[REG_IND_BYTE], data);
237+
if (!ret)
238+
ret = ksz_write16(dev, regs[REG_IND_CTRL_0], ctrl_addr);
239+
240+
mutex_unlock(&dev->alu_mutex);
241+
242+
return ret;
243+
}
244+
225245
static int ksz8_reset_switch(struct ksz_device *dev)
226246
{
227247
if (ksz_is_ksz88x3(dev)) {
@@ -1391,6 +1411,23 @@ static void ksz8_config_cpu_port(struct dsa_switch *ds)
13911411
}
13921412
}
13931413

1414+
static int ksz8_handle_global_errata(struct dsa_switch *ds)
1415+
{
1416+
struct ksz_device *dev = ds->priv;
1417+
int ret = 0;
1418+
1419+
/* KSZ87xx Errata DS80000687C.
1420+
* Module 2: Link drops with some EEE link partners.
1421+
* An issue with the EEE next page exchange between the
1422+
* KSZ879x/KSZ877x/KSZ876x and some EEE link partners may result in
1423+
* the link dropping.
1424+
*/
1425+
if (dev->ksz87xx_eee_link_erratum)
1426+
ret = ksz8_ind_write8(dev, TABLE_EEE, REG_IND_EEE_GLOB2_HI, 0);
1427+
1428+
return ret;
1429+
}
1430+
13941431
static int ksz8_setup(struct dsa_switch *ds)
13951432
{
13961433
struct ksz_device *dev = ds->priv;
@@ -1458,7 +1495,7 @@ static int ksz8_setup(struct dsa_switch *ds)
14581495

14591496
ds->configure_vlan_while_not_filtering = false;
14601497

1461-
return 0;
1498+
return ksz8_handle_global_errata(ds);
14621499
}
14631500

14641501
static void ksz8_get_caps(struct dsa_switch *ds, int port,
@@ -1575,6 +1612,7 @@ struct ksz_chip_data {
15751612
int num_statics;
15761613
int cpu_ports;
15771614
int port_cnt;
1615+
bool ksz87xx_eee_link_erratum;
15781616
};
15791617

15801618
static const struct ksz_chip_data ksz8_switch_chips[] = {
@@ -1586,6 +1624,7 @@ static const struct ksz_chip_data ksz8_switch_chips[] = {
15861624
.num_statics = 8,
15871625
.cpu_ports = 0x10, /* can be configured as cpu port */
15881626
.port_cnt = 5, /* total cpu and user ports */
1627+
.ksz87xx_eee_link_erratum = true,
15891628
},
15901629
{
15911630
/*
@@ -1609,6 +1648,7 @@ static const struct ksz_chip_data ksz8_switch_chips[] = {
16091648
.num_statics = 8,
16101649
.cpu_ports = 0x10, /* can be configured as cpu port */
16111650
.port_cnt = 4, /* total cpu and user ports */
1651+
.ksz87xx_eee_link_erratum = true,
16121652
},
16131653
{
16141654
.chip_id = 0x8765,
@@ -1618,6 +1658,7 @@ static const struct ksz_chip_data ksz8_switch_chips[] = {
16181658
.num_statics = 8,
16191659
.cpu_ports = 0x10, /* can be configured as cpu port */
16201660
.port_cnt = 5, /* total cpu and user ports */
1661+
.ksz87xx_eee_link_erratum = true,
16211662
},
16221663
{
16231664
.chip_id = 0x8830,
@@ -1652,6 +1693,8 @@ static int ksz8_switch_init(struct ksz_device *dev)
16521693
dev->host_mask = chip->cpu_ports;
16531694
dev->port_mask = (BIT(dev->phy_port_cnt) - 1) |
16541695
chip->cpu_ports;
1696+
dev->ksz87xx_eee_link_erratum =
1697+
chip->ksz87xx_eee_link_erratum;
16551698
break;
16561699
}
16571700
}

drivers/net/dsa/microchip/ksz8795_reg.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,10 @@
812812

813813
#define IND_ACC_TABLE(table) ((table) << 8)
814814

815+
/* */
816+
#define REG_IND_EEE_GLOB2_LO 0x34
817+
#define REG_IND_EEE_GLOB2_HI 0x35
818+
815819
/* Driver set switch broadcast storm protection at 10% rate. */
816820
#define BROADCAST_STORM_PROT_RATE 10
817821

drivers/net/dsa/microchip/ksz_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct ksz_device {
7777
phy_interface_t compat_interface;
7878
u32 regs_size;
7979
bool phy_errata_9477;
80+
bool ksz87xx_eee_link_erratum;
8081
bool synclko_125;
8182
bool synclko_disable;
8283

0 commit comments

Comments
 (0)