Commit 8794ebfe authored by David S. Miller's avatar David S. Miller

Merge branch 'ksz9477-dsa-switch-driver-improvements'

Paul Barker says:

====================
ksz9477 dsa switch driver improvements

These changes were made while debugging the ksz9477 driver for use on a
custom board which uses the ksz9893 switch supported by this driver. The
patches have been runtime tested on top of Linux 5.8.4, I couldn't
runtime test them on top of 5.9-rc3 due to unrelated issues. They have
been build tested on top of net-next.

These changes can also be pulled from:

  https://gitlab.com/pbarker.dev/staging/linux.git
  tag: for-net-next/ksz-v3_2020-09-09

Changes from v2:

  * Fixed incorrect type in assignment error.
Reported-by: default avatarkernel test robot <lkp@intel.com>

Changes from v1:

  * Rebased onto net-next.

  * Dropped unnecessary `#include <linux/printk.h>`.

  * Instead of printing the phy mode in `ksz9477_port_setup()`, modify
    the existing print in `ksz9477_config_cpu_port()` to always produce
    output and to be more clear.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents d85427e3 5b797980
...@@ -1235,6 +1235,9 @@ static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port) ...@@ -1235,6 +1235,9 @@ static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
if (dev->interface == PHY_INTERFACE_MODE_RGMII_ID || if (dev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
dev->interface == PHY_INTERFACE_MODE_RGMII_TXID) dev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
data8 |= PORT_RGMII_ID_EG_ENABLE; data8 |= PORT_RGMII_ID_EG_ENABLE;
/* On KSZ9893, disable RGMII in-band status support */
if (dev->features & IS_9893)
data8 &= ~PORT_MII_MAC_MODE;
p->phydev.speed = SPEED_1000; p->phydev.speed = SPEED_1000;
break; break;
} }
...@@ -1265,6 +1268,8 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds) ...@@ -1265,6 +1268,8 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds)
for (i = 0; i < dev->port_cnt; i++) { for (i = 0; i < dev->port_cnt; i++) {
if (dsa_is_cpu_port(ds, i) && (dev->cpu_ports & (1 << i))) { if (dsa_is_cpu_port(ds, i) && (dev->cpu_ports & (1 << i))) {
phy_interface_t interface; phy_interface_t interface;
const char *prev_msg;
const char *prev_mode;
dev->cpu_port = i; dev->cpu_port = i;
dev->host_mask = (1 << dev->cpu_port); dev->host_mask = (1 << dev->cpu_port);
...@@ -1277,11 +1282,19 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds) ...@@ -1277,11 +1282,19 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds)
interface = ksz9477_get_interface(dev, i); interface = ksz9477_get_interface(dev, i);
if (!dev->interface) if (!dev->interface)
dev->interface = interface; dev->interface = interface;
if (interface && interface != dev->interface) if (interface && interface != dev->interface) {
prev_msg = " instead of ";
prev_mode = phy_modes(interface);
} else {
prev_msg = "";
prev_mode = "";
}
dev_info(dev->dev, dev_info(dev->dev,
"use %s instead of %s\n", "Port%d: using phy mode %s%s%s\n",
i,
phy_modes(dev->interface), phy_modes(dev->interface),
phy_modes(interface)); prev_msg,
prev_mode);
/* enable cpu port */ /* enable cpu port */
ksz9477_port_setup(dev, i, true); ksz9477_port_setup(dev, i, true);
...@@ -1426,10 +1439,12 @@ static int ksz9477_switch_detect(struct ksz_device *dev) ...@@ -1426,10 +1439,12 @@ static int ksz9477_switch_detect(struct ksz_device *dev)
/* Default capability is gigabit capable. */ /* Default capability is gigabit capable. */
dev->features = GBIT_SUPPORT; dev->features = GBIT_SUPPORT;
dev_dbg(dev->dev, "Switch detect: ID=%08x%02x\n", id32, data8);
id_hi = (u8)(id32 >> 16); id_hi = (u8)(id32 >> 16);
id_lo = (u8)(id32 >> 8); id_lo = (u8)(id32 >> 8);
if ((id_lo & 0xf) == 3) { if ((id_lo & 0xf) == 3) {
/* Chip is from KSZ9893 design. */ /* Chip is from KSZ9893 design. */
dev_info(dev->dev, "Found KSZ9893\n");
dev->features |= IS_9893; dev->features |= IS_9893;
/* Chip does not support gigabit. */ /* Chip does not support gigabit. */
...@@ -1438,6 +1453,7 @@ static int ksz9477_switch_detect(struct ksz_device *dev) ...@@ -1438,6 +1453,7 @@ static int ksz9477_switch_detect(struct ksz_device *dev)
dev->mib_port_cnt = 3; dev->mib_port_cnt = 3;
dev->phy_port_cnt = 2; dev->phy_port_cnt = 2;
} else { } else {
dev_info(dev->dev, "Found KSZ9477 or compatible\n");
/* Chip uses new XMII register definitions. */ /* Chip uses new XMII register definitions. */
dev->features |= NEW_XMII; dev->features |= NEW_XMII;
......
...@@ -400,8 +400,9 @@ int ksz_switch_register(struct ksz_device *dev, ...@@ -400,8 +400,9 @@ int ksz_switch_register(struct ksz_device *dev,
if (dev->reset_gpio) { if (dev->reset_gpio) {
gpiod_set_value_cansleep(dev->reset_gpio, 1); gpiod_set_value_cansleep(dev->reset_gpio, 1);
mdelay(10); usleep_range(10000, 12000);
gpiod_set_value_cansleep(dev->reset_gpio, 0); gpiod_set_value_cansleep(dev->reset_gpio, 0);
usleep_range(100, 1000);
} }
mutex_init(&dev->dev_mutex); mutex_init(&dev->dev_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment