Commit 03a4a540 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: dsa: mv88e6xxx: Rename _phy_ to _mdio_

The switch implements a generic MDIO bus, which could host more than
PHYs. It is conventional to use _mdio_ or _mii_ in the function name,
so rename them. Also postfix make the historically first read/write
function with _direct, to help distinguish it from _indirect and _ppu.

While touching these functions, remove some of the _ prefixes, which
we are deprecating.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e755e49e
...@@ -238,16 +238,16 @@ int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr) ...@@ -238,16 +238,16 @@ int mv88e6xxx_set_addr(struct dsa_switch *ds, u8 *addr)
return mv88e6xxx_set_addr_direct(ds, addr); return mv88e6xxx_set_addr_direct(ds, addr);
} }
static int _mv88e6xxx_phy_read(struct mv88e6xxx_priv_state *ps, int addr, static int mv88e6xxx_mdio_read_direct(struct mv88e6xxx_priv_state *ps,
int regnum) int addr, int regnum)
{ {
if (addr >= 0) if (addr >= 0)
return _mv88e6xxx_reg_read(ps, addr, regnum); return _mv88e6xxx_reg_read(ps, addr, regnum);
return 0xffff; return 0xffff;
} }
static int _mv88e6xxx_phy_write(struct mv88e6xxx_priv_state *ps, int addr, static int mv88e6xxx_mdio_write_direct(struct mv88e6xxx_priv_state *ps,
int regnum, u16 val) int addr, int regnum, u16 val)
{ {
if (addr >= 0) if (addr >= 0)
return _mv88e6xxx_reg_write(ps, addr, regnum, val); return _mv88e6xxx_reg_write(ps, addr, regnum, val);
...@@ -378,8 +378,8 @@ void mv88e6xxx_ppu_state_init(struct mv88e6xxx_priv_state *ps) ...@@ -378,8 +378,8 @@ void mv88e6xxx_ppu_state_init(struct mv88e6xxx_priv_state *ps)
ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer; ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer;
} }
static int mv88e6xxx_phy_read_ppu(struct mv88e6xxx_priv_state *ps, int addr, static int mv88e6xxx_mdio_read_ppu(struct mv88e6xxx_priv_state *ps, int addr,
int regnum) int regnum)
{ {
int ret; int ret;
...@@ -392,8 +392,8 @@ static int mv88e6xxx_phy_read_ppu(struct mv88e6xxx_priv_state *ps, int addr, ...@@ -392,8 +392,8 @@ static int mv88e6xxx_phy_read_ppu(struct mv88e6xxx_priv_state *ps, int addr,
return ret; return ret;
} }
static int mv88e6xxx_phy_write_ppu(struct mv88e6xxx_priv_state *ps, int addr, static int mv88e6xxx_mdio_write_ppu(struct mv88e6xxx_priv_state *ps, int addr,
int regnum, u16 val) int regnum, u16 val)
{ {
int ret; int ret;
...@@ -829,7 +829,7 @@ static int mv88e6xxx_wait(struct mv88e6xxx_priv_state *ps, int reg, ...@@ -829,7 +829,7 @@ static int mv88e6xxx_wait(struct mv88e6xxx_priv_state *ps, int reg,
return ret; return ret;
} }
static int _mv88e6xxx_phy_wait(struct mv88e6xxx_priv_state *ps) static int mv88e6xxx_mdio_wait(struct mv88e6xxx_priv_state *ps)
{ {
return _mv88e6xxx_wait(ps, REG_GLOBAL2, GLOBAL2_SMI_OP, return _mv88e6xxx_wait(ps, REG_GLOBAL2, GLOBAL2_SMI_OP,
GLOBAL2_SMI_OP_BUSY); GLOBAL2_SMI_OP_BUSY);
...@@ -1076,7 +1076,7 @@ static int _mv88e6xxx_atu_wait(struct mv88e6xxx_priv_state *ps) ...@@ -1076,7 +1076,7 @@ static int _mv88e6xxx_atu_wait(struct mv88e6xxx_priv_state *ps)
GLOBAL_ATU_OP_BUSY); GLOBAL_ATU_OP_BUSY);
} }
static int _mv88e6xxx_phy_read_indirect(struct mv88e6xxx_priv_state *ps, static int mv88e6xxx_mdio_read_indirect(struct mv88e6xxx_priv_state *ps,
int addr, int regnum) int addr, int regnum)
{ {
int ret; int ret;
...@@ -1087,7 +1087,7 @@ static int _mv88e6xxx_phy_read_indirect(struct mv88e6xxx_priv_state *ps, ...@@ -1087,7 +1087,7 @@ static int _mv88e6xxx_phy_read_indirect(struct mv88e6xxx_priv_state *ps,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = _mv88e6xxx_phy_wait(ps); ret = mv88e6xxx_mdio_wait(ps);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1096,7 +1096,7 @@ static int _mv88e6xxx_phy_read_indirect(struct mv88e6xxx_priv_state *ps, ...@@ -1096,7 +1096,7 @@ static int _mv88e6xxx_phy_read_indirect(struct mv88e6xxx_priv_state *ps,
return ret; return ret;
} }
static int _mv88e6xxx_phy_write_indirect(struct mv88e6xxx_priv_state *ps, static int mv88e6xxx_mdio_write_indirect(struct mv88e6xxx_priv_state *ps,
int addr, int regnum, u16 val) int addr, int regnum, u16 val)
{ {
int ret; int ret;
...@@ -1109,7 +1109,7 @@ static int _mv88e6xxx_phy_write_indirect(struct mv88e6xxx_priv_state *ps, ...@@ -1109,7 +1109,7 @@ static int _mv88e6xxx_phy_write_indirect(struct mv88e6xxx_priv_state *ps,
GLOBAL2_SMI_OP_22_WRITE | (addr << 5) | GLOBAL2_SMI_OP_22_WRITE | (addr << 5) |
regnum); regnum);
return _mv88e6xxx_phy_wait(ps); return mv88e6xxx_mdio_wait(ps);
} }
static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port,
...@@ -1123,7 +1123,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, ...@@ -1123,7 +1123,7 @@ static int mv88e6xxx_get_eee(struct dsa_switch *ds, int port,
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
reg = _mv88e6xxx_phy_read_indirect(ps, port, 16); reg = mv88e6xxx_mdio_read_indirect(ps, port, 16);
if (reg < 0) if (reg < 0)
goto out; goto out;
...@@ -1154,7 +1154,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, ...@@ -1154,7 +1154,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
ret = _mv88e6xxx_phy_read_indirect(ps, port, 16); ret = mv88e6xxx_mdio_read_indirect(ps, port, 16);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -1164,7 +1164,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, ...@@ -1164,7 +1164,7 @@ static int mv88e6xxx_set_eee(struct dsa_switch *ds, int port,
if (e->tx_lpi_enabled) if (e->tx_lpi_enabled)
reg |= 0x0100; reg |= 0x0100;
ret = _mv88e6xxx_phy_write_indirect(ps, port, 16, reg); ret = mv88e6xxx_mdio_write_indirect(ps, port, 16, reg);
out: out:
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->smi_mutex);
...@@ -2547,34 +2547,34 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port) ...@@ -2547,34 +2547,34 @@ static void mv88e6xxx_port_bridge_leave(struct dsa_switch *ds, int port)
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->smi_mutex);
} }
static int _mv88e6xxx_phy_page_write(struct mv88e6xxx_priv_state *ps, static int _mv88e6xxx_mdio_page_write(struct mv88e6xxx_priv_state *ps,
int port, int page, int reg, int val) int port, int page, int reg, int val)
{ {
int ret; int ret;
ret = _mv88e6xxx_phy_write_indirect(ps, port, 0x16, page); ret = mv88e6xxx_mdio_write_indirect(ps, port, 0x16, page);
if (ret < 0) if (ret < 0)
goto restore_page_0; goto restore_page_0;
ret = _mv88e6xxx_phy_write_indirect(ps, port, reg, val); ret = mv88e6xxx_mdio_write_indirect(ps, port, reg, val);
restore_page_0: restore_page_0:
_mv88e6xxx_phy_write_indirect(ps, port, 0x16, 0x0); mv88e6xxx_mdio_write_indirect(ps, port, 0x16, 0x0);
return ret; return ret;
} }
static int _mv88e6xxx_phy_page_read(struct mv88e6xxx_priv_state *ps, static int _mv88e6xxx_mdio_page_read(struct mv88e6xxx_priv_state *ps,
int port, int page, int reg) int port, int page, int reg)
{ {
int ret; int ret;
ret = _mv88e6xxx_phy_write_indirect(ps, port, 0x16, page); ret = mv88e6xxx_mdio_write_indirect(ps, port, 0x16, page);
if (ret < 0) if (ret < 0)
goto restore_page_0; goto restore_page_0;
ret = _mv88e6xxx_phy_read_indirect(ps, port, reg); ret = mv88e6xxx_mdio_read_indirect(ps, port, reg);
restore_page_0: restore_page_0:
_mv88e6xxx_phy_write_indirect(ps, port, 0x16, 0x0); mv88e6xxx_mdio_write_indirect(ps, port, 0x16, 0x0);
return ret; return ret;
} }
...@@ -2645,16 +2645,16 @@ static int mv88e6xxx_power_on_serdes(struct mv88e6xxx_priv_state *ps) ...@@ -2645,16 +2645,16 @@ static int mv88e6xxx_power_on_serdes(struct mv88e6xxx_priv_state *ps)
{ {
int ret; int ret;
ret = _mv88e6xxx_phy_page_read(ps, REG_FIBER_SERDES, PAGE_FIBER_SERDES, ret = _mv88e6xxx_mdio_page_read(ps, REG_FIBER_SERDES,
MII_BMCR); PAGE_FIBER_SERDES, MII_BMCR);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret & BMCR_PDOWN) { if (ret & BMCR_PDOWN) {
ret &= ~BMCR_PDOWN; ret &= ~BMCR_PDOWN;
ret = _mv88e6xxx_phy_page_write(ps, REG_FIBER_SERDES, ret = _mv88e6xxx_mdio_page_write(ps, REG_FIBER_SERDES,
PAGE_FIBER_SERDES, MII_BMCR, PAGE_FIBER_SERDES, MII_BMCR,
ret); ret);
} }
return ret; return ret;
...@@ -3159,43 +3159,43 @@ static int mv88e6xxx_setup(struct dsa_switch *ds) ...@@ -3159,43 +3159,43 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
return err; return err;
} }
int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page, int reg) int mv88e6xxx_mdio_page_read(struct dsa_switch *ds, int port, int page, int reg)
{ {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret; int ret;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
ret = _mv88e6xxx_phy_page_read(ps, port, page, reg); ret = _mv88e6xxx_mdio_page_read(ps, port, page, reg);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->smi_mutex);
return ret; return ret;
} }
int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page, int mv88e6xxx_mdio_page_write(struct dsa_switch *ds, int port, int page,
int reg, int val) int reg, int val)
{ {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int ret; int ret;
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
ret = _mv88e6xxx_phy_page_write(ps, port, page, reg, val); ret = _mv88e6xxx_mdio_page_write(ps, port, page, reg, val);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->smi_mutex);
return ret; return ret;
} }
static int mv88e6xxx_port_to_phy_addr(struct mv88e6xxx_priv_state *ps, static int mv88e6xxx_port_to_mdio_addr(struct mv88e6xxx_priv_state *ps,
int port) int port)
{ {
if (port >= 0 && port < ps->info->num_ports) if (port >= 0 && port < ps->info->num_ports)
return port; return port;
return -EINVAL; return -EINVAL;
} }
static int mv88e6xxx_phy_read(struct dsa_switch *ds, int port, int regnum) static int mv88e6xxx_mdio_read(struct dsa_switch *ds, int port, int regnum)
{ {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int addr = mv88e6xxx_port_to_phy_addr(ps, port); int addr = mv88e6xxx_port_to_mdio_addr(ps, port);
int ret; int ret;
if (addr < 0) if (addr < 0)
...@@ -3204,21 +3204,21 @@ static int mv88e6xxx_phy_read(struct dsa_switch *ds, int port, int regnum) ...@@ -3204,21 +3204,21 @@ static int mv88e6xxx_phy_read(struct dsa_switch *ds, int port, int regnum)
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU))
ret = mv88e6xxx_phy_read_ppu(ps, addr, regnum); ret = mv88e6xxx_mdio_read_ppu(ps, addr, regnum);
else if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_SMI_PHY)) else if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_SMI_PHY))
ret = _mv88e6xxx_phy_read_indirect(ps, addr, regnum); ret = mv88e6xxx_mdio_read_indirect(ps, addr, regnum);
else else
ret = _mv88e6xxx_phy_read(ps, addr, regnum); ret = mv88e6xxx_mdio_read_direct(ps, addr, regnum);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->smi_mutex);
return ret; return ret;
} }
static int mv88e6xxx_phy_write(struct dsa_switch *ds, int port, int regnum, static int mv88e6xxx_mdio_write(struct dsa_switch *ds, int port, int regnum,
u16 val) u16 val)
{ {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int addr = mv88e6xxx_port_to_phy_addr(ps, port); int addr = mv88e6xxx_port_to_mdio_addr(ps, port);
int ret; int ret;
if (addr < 0) if (addr < 0)
...@@ -3227,11 +3227,11 @@ static int mv88e6xxx_phy_write(struct dsa_switch *ds, int port, int regnum, ...@@ -3227,11 +3227,11 @@ static int mv88e6xxx_phy_write(struct dsa_switch *ds, int port, int regnum,
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU)) if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_PPU))
ret = mv88e6xxx_phy_write_ppu(ps, addr, regnum, val); ret = mv88e6xxx_mdio_write_ppu(ps, addr, regnum, val);
else if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_SMI_PHY)) else if (mv88e6xxx_has(ps, MV88E6XXX_FLAG_SMI_PHY))
ret = _mv88e6xxx_phy_write_indirect(ps, addr, regnum, val); ret = mv88e6xxx_mdio_write_indirect(ps, addr, regnum, val);
else else
ret = _mv88e6xxx_phy_write(ps, addr, regnum, val); ret = mv88e6xxx_mdio_write_direct(ps, addr, regnum, val);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->smi_mutex);
return ret; return ret;
...@@ -3249,37 +3249,37 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp) ...@@ -3249,37 +3249,37 @@ static int mv88e61xx_get_temp(struct dsa_switch *ds, int *temp)
mutex_lock(&ps->smi_mutex); mutex_lock(&ps->smi_mutex);
ret = _mv88e6xxx_phy_write(ps, 0x0, 0x16, 0x6); ret = mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x6);
if (ret < 0) if (ret < 0)
goto error; goto error;
/* Enable temperature sensor */ /* Enable temperature sensor */
ret = _mv88e6xxx_phy_read(ps, 0x0, 0x1a); ret = mv88e6xxx_mdio_read_direct(ps, 0x0, 0x1a);
if (ret < 0) if (ret < 0)
goto error; goto error;
ret = _mv88e6xxx_phy_write(ps, 0x0, 0x1a, ret | (1 << 5)); ret = mv88e6xxx_mdio_write_direct(ps, 0x0, 0x1a, ret | (1 << 5));
if (ret < 0) if (ret < 0)
goto error; goto error;
/* Wait for temperature to stabilize */ /* Wait for temperature to stabilize */
usleep_range(10000, 12000); usleep_range(10000, 12000);
val = _mv88e6xxx_phy_read(ps, 0x0, 0x1a); val = mv88e6xxx_mdio_read_direct(ps, 0x0, 0x1a);
if (val < 0) { if (val < 0) {
ret = val; ret = val;
goto error; goto error;
} }
/* Disable temperature sensor */ /* Disable temperature sensor */
ret = _mv88e6xxx_phy_write(ps, 0x0, 0x1a, ret & ~(1 << 5)); ret = mv88e6xxx_mdio_write_direct(ps, 0x0, 0x1a, ret & ~(1 << 5));
if (ret < 0) if (ret < 0)
goto error; goto error;
*temp = ((val & 0x1f) - 5) * 5; *temp = ((val & 0x1f) - 5) * 5;
error: error:
_mv88e6xxx_phy_write(ps, 0x0, 0x16, 0x0); mv88e6xxx_mdio_write_direct(ps, 0x0, 0x16, 0x0);
mutex_unlock(&ps->smi_mutex); mutex_unlock(&ps->smi_mutex);
return ret; return ret;
} }
...@@ -3292,7 +3292,7 @@ static int mv88e63xx_get_temp(struct dsa_switch *ds, int *temp) ...@@ -3292,7 +3292,7 @@ static int mv88e63xx_get_temp(struct dsa_switch *ds, int *temp)
*temp = 0; *temp = 0;
ret = mv88e6xxx_phy_page_read(ds, phy, 6, 27); ret = mv88e6xxx_mdio_page_read(ds, phy, 6, 27);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -3325,7 +3325,7 @@ static int mv88e6xxx_get_temp_limit(struct dsa_switch *ds, int *temp) ...@@ -3325,7 +3325,7 @@ static int mv88e6xxx_get_temp_limit(struct dsa_switch *ds, int *temp)
*temp = 0; *temp = 0;
ret = mv88e6xxx_phy_page_read(ds, phy, 6, 26); ret = mv88e6xxx_mdio_page_read(ds, phy, 6, 26);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -3343,12 +3343,12 @@ static int mv88e6xxx_set_temp_limit(struct dsa_switch *ds, int temp) ...@@ -3343,12 +3343,12 @@ static int mv88e6xxx_set_temp_limit(struct dsa_switch *ds, int temp)
if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_TEMP_LIMIT)) if (!mv88e6xxx_has(ps, MV88E6XXX_FLAG_TEMP_LIMIT))
return -EOPNOTSUPP; return -EOPNOTSUPP;
ret = mv88e6xxx_phy_page_read(ds, phy, 6, 26); ret = mv88e6xxx_mdio_page_read(ds, phy, 6, 26);
if (ret < 0) if (ret < 0)
return ret; return ret;
temp = clamp_val(DIV_ROUND_CLOSEST(temp, 5) + 5, 0, 0x1f); temp = clamp_val(DIV_ROUND_CLOSEST(temp, 5) + 5, 0, 0x1f);
return mv88e6xxx_phy_page_write(ds, phy, 6, 26, return mv88e6xxx_mdio_page_write(ds, phy, 6, 26,
(ret & 0xe0ff) | (temp << 8)); (ret & 0xe0ff) | (temp << 8));
} }
static int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm) static int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
...@@ -3362,7 +3362,7 @@ static int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm) ...@@ -3362,7 +3362,7 @@ static int mv88e6xxx_get_temp_alarm(struct dsa_switch *ds, bool *alarm)
*alarm = false; *alarm = false;
ret = mv88e6xxx_phy_page_read(ds, phy, 6, 26); ret = mv88e6xxx_mdio_page_read(ds, phy, 6, 26);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -3590,8 +3590,8 @@ struct dsa_switch_driver mv88e6xxx_switch_driver = { ...@@ -3590,8 +3590,8 @@ struct dsa_switch_driver mv88e6xxx_switch_driver = {
.probe = mv88e6xxx_drv_probe, .probe = mv88e6xxx_drv_probe,
.setup = mv88e6xxx_setup, .setup = mv88e6xxx_setup,
.set_addr = mv88e6xxx_set_addr, .set_addr = mv88e6xxx_set_addr,
.phy_read = mv88e6xxx_phy_read, .phy_read = mv88e6xxx_mdio_read,
.phy_write = mv88e6xxx_phy_write, .phy_write = mv88e6xxx_mdio_write,
.adjust_link = mv88e6xxx_adjust_link, .adjust_link = mv88e6xxx_adjust_link,
.get_strings = mv88e6xxx_get_strings, .get_strings = mv88e6xxx_get_strings,
.get_ethtool_stats = mv88e6xxx_get_ethtool_stats, .get_ethtool_stats = mv88e6xxx_get_ethtool_stats,
......
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