]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: dsa: microchip: Add PHY errata workarounds
authorRobert Hancock <hancock@sedsystems.ca>
Wed, 12 Jun 2019 20:49:05 +0000 (14:49 -0600)
committerDavid S. Miller <davem@davemloft.net>
Sat, 15 Jun 2019 02:11:53 +0000 (19:11 -0700)
The Silicon Errata and Data Sheet Clarification documents for the
KSZ9477 series of chips describe a number of otherwise undocumented PHY
register settings which are required to work around various chip errata.
Apply these settings when initializing the PHY ports on these chips.

Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/microchip/ksz9477.c
drivers/net/dsa/microchip/ksz_priv.h

index c026d15721f66bf3d03403b1f31d5362ec38bd9c..7be6d848b69f8d58faad279a40791281dcd56afc 100644 (file)
@@ -1165,6 +1165,62 @@ static phy_interface_t ksz9477_get_interface(struct ksz_device *dev, int port)
        return interface;
 }
 
+static void ksz9477_port_mmd_write(struct ksz_device *dev, int port,
+                                  u8 dev_addr, u16 reg_addr, u16 val)
+{
+       ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_SETUP,
+                    MMD_SETUP(PORT_MMD_OP_INDEX, dev_addr));
+       ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, reg_addr);
+       ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_SETUP,
+                    MMD_SETUP(PORT_MMD_OP_DATA_NO_INCR, dev_addr));
+       ksz_pwrite16(dev, port, REG_PORT_PHY_MMD_INDEX_DATA, val);
+}
+
+static void ksz9477_phy_errata_setup(struct ksz_device *dev, int port)
+{
+       /* Apply PHY settings to address errata listed in
+        * KSZ9477, KSZ9897, KSZ9896, KSZ9567, KSZ8565
+        * Silicon Errata and Data Sheet Clarification documents:
+        *
+        * Register settings are needed to improve PHY receive performance
+        */
+       ksz9477_port_mmd_write(dev, port, 0x01, 0x6f, 0xdd0b);
+       ksz9477_port_mmd_write(dev, port, 0x01, 0x8f, 0x6032);
+       ksz9477_port_mmd_write(dev, port, 0x01, 0x9d, 0x248c);
+       ksz9477_port_mmd_write(dev, port, 0x01, 0x75, 0x0060);
+       ksz9477_port_mmd_write(dev, port, 0x01, 0xd3, 0x7777);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x06, 0x3008);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x08, 0x2001);
+
+       /* Transmit waveform amplitude can be improved
+        * (1000BASE-T, 100BASE-TX, 10BASE-Te)
+        */
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x04, 0x00d0);
+
+       /* Energy Efficient Ethernet (EEE) feature select must
+        * be manually disabled (except on KSZ8565 which is 100Mbit)
+        */
+       if (dev->features & GBIT_SUPPORT)
+               ksz9477_port_mmd_write(dev, port, 0x07, 0x3c, 0x0000);
+
+       /* Register settings are required to meet data sheet
+        * supply current specifications
+        */
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x13, 0x6eff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x14, 0xe6ff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x15, 0x6eff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x16, 0xe6ff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x17, 0x00ff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x18, 0x43ff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x19, 0xc3ff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x1a, 0x6fff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x1b, 0x07ff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x1c, 0x0fff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x1d, 0xe7ff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x1e, 0xefff);
+       ksz9477_port_mmd_write(dev, port, 0x1c, 0x20, 0xeeee);
+}
+
 static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
 {
        u8 data8;
@@ -1203,6 +1259,8 @@ static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
                             PORT_FORCE_TX_FLOW_CTRL | PORT_FORCE_RX_FLOW_CTRL,
                             false);
 
+               if (dev->phy_errata_9477)
+                       ksz9477_phy_errata_setup(dev, port);
        } else {
                /* force flow control */
                ksz_port_cfg(dev, port, REG_PORT_CTRL_0,
@@ -1474,6 +1532,7 @@ struct ksz_chip_data {
        int num_statics;
        int cpu_ports;
        int port_cnt;
+       bool phy_errata_9477;
 };
 
 static const struct ksz_chip_data ksz9477_switch_chips[] = {
@@ -1485,6 +1544,7 @@ static const struct ksz_chip_data ksz9477_switch_chips[] = {
                .num_statics = 16,
                .cpu_ports = 0x7F,      /* can be configured as cpu port */
                .port_cnt = 7,          /* total physical port count */
+               .phy_errata_9477 = true,
        },
        {
                .chip_id = 0x00989700,
@@ -1494,6 +1554,7 @@ static const struct ksz_chip_data ksz9477_switch_chips[] = {
                .num_statics = 16,
                .cpu_ports = 0x7F,      /* can be configured as cpu port */
                .port_cnt = 7,          /* total physical port count */
+               .phy_errata_9477 = true,
        },
        {
                .chip_id = 0x00989300,
@@ -1522,6 +1583,7 @@ static int ksz9477_switch_init(struct ksz_device *dev)
                        dev->num_statics = chip->num_statics;
                        dev->port_cnt = chip->port_cnt;
                        dev->cpu_ports = chip->cpu_ports;
+                       dev->phy_errata_9477 = chip->phy_errata_9477;
 
                        break;
                }
index b52e5ca17ab4968c82c61939cae6c92eab2d924d..724301df91db4d8b0298da9f4d5d61db52bacdac 100644 (file)
@@ -77,6 +77,7 @@ struct ksz_device {
        int last_port;                  /* ports after that not used */
        phy_interface_t interface;
        u32 regs_size;
+       bool phy_errata_9477;
 
        struct vlan_table *vlan_cache;