net: dsa: mv88e6xxx: introduce .serdes_irq_enable
Introduce a new .serdes_irq_enable operation to prepare the abstraction of IRQ enabling from the SERDES IRQ setup code. Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
dc272f600e
Коммит
61a46b4147
|
@ -2934,6 +2934,7 @@ static const struct mv88e6xxx_ops mv88e6141_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6341_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3184,6 +3185,7 @@ static const struct mv88e6xxx_ops mv88e6176_ops = {
|
|||
.serdes_get_lane = mv88e6352_serdes_get_lane,
|
||||
.serdes_power = mv88e6352_serdes_power,
|
||||
.serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6352_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6352_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6352_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3268,6 +3270,7 @@ static const struct mv88e6xxx_ops mv88e6190_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6390_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3316,6 +3319,7 @@ static const struct mv88e6xxx_ops mv88e6190x_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6390x_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3364,6 +3368,7 @@ static const struct mv88e6xxx_ops mv88e6191_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6390_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.avb_ops = &mv88e6390_avb_ops,
|
||||
|
@ -3414,6 +3419,7 @@ static const struct mv88e6xxx_ops mv88e6240_ops = {
|
|||
.serdes_get_lane = mv88e6352_serdes_get_lane,
|
||||
.serdes_power = mv88e6352_serdes_power,
|
||||
.serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6352_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6352_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6352_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3504,6 +3510,7 @@ static const struct mv88e6xxx_ops mv88e6290_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6390_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3642,6 +3649,7 @@ static const struct mv88e6xxx_ops mv88e6341_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6341_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3775,6 +3783,7 @@ static const struct mv88e6xxx_ops mv88e6352_ops = {
|
|||
.serdes_get_lane = mv88e6352_serdes_get_lane,
|
||||
.serdes_power = mv88e6352_serdes_power,
|
||||
.serdes_irq_mapping = mv88e6352_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6352_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6352_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6352_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3830,6 +3839,7 @@ static const struct mv88e6xxx_ops mv88e6390_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6390_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
@ -3882,6 +3892,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = {
|
|||
.serdes_power = mv88e6390_serdes_power,
|
||||
.serdes_get_lane = mv88e6390x_serdes_get_lane,
|
||||
.serdes_irq_mapping = mv88e6390_serdes_irq_mapping,
|
||||
.serdes_irq_enable = mv88e6390_serdes_irq_enable,
|
||||
.serdes_irq_setup = mv88e6390_serdes_irq_setup,
|
||||
.serdes_irq_free = mv88e6390_serdes_irq_free,
|
||||
.gpio_ops = &mv88e6352_gpio_ops,
|
||||
|
|
|
@ -452,6 +452,8 @@ struct mv88e6xxx_ops {
|
|||
int port);
|
||||
int (*serdes_irq_setup)(struct mv88e6xxx_chip *chip, int port);
|
||||
void (*serdes_irq_free)(struct mv88e6xxx_chip *chip, int port);
|
||||
int (*serdes_irq_enable)(struct mv88e6xxx_chip *chip, int port, u8 lane,
|
||||
bool enable);
|
||||
|
||||
/* Statistics from the SERDES interface */
|
||||
int (*serdes_get_sset_count)(struct mv88e6xxx_chip *chip, int port);
|
||||
|
|
|
@ -434,7 +434,7 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
|
|||
lane = mv88e6xxx_serdes_get_lane(chip, port);
|
||||
if (lane) {
|
||||
if (chip->ports[port].serdes_irq) {
|
||||
err = mv88e6390_serdes_irq_disable(chip, port, lane);
|
||||
err = mv88e6xxx_serdes_irq_disable(chip, port, lane);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
|
|||
return err;
|
||||
|
||||
if (chip->ports[port].serdes_irq) {
|
||||
err = mv88e6390_serdes_irq_enable(chip, port, lane);
|
||||
err = mv88e6xxx_serdes_irq_enable(chip, port, lane);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -226,15 +226,15 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int mv88e6352_serdes_irq_enable(struct mv88e6xxx_chip *chip)
|
||||
int mv88e6352_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, u8 lane,
|
||||
bool enable)
|
||||
{
|
||||
return mv88e6352_serdes_write(chip, MV88E6352_SERDES_INT_ENABLE,
|
||||
MV88E6352_SERDES_INT_LINK_CHANGE);
|
||||
}
|
||||
u16 val = 0;
|
||||
|
||||
static int mv88e6352_serdes_irq_disable(struct mv88e6xxx_chip *chip)
|
||||
{
|
||||
return mv88e6352_serdes_write(chip, MV88E6352_SERDES_INT_ENABLE, 0);
|
||||
if (enable)
|
||||
val |= MV88E6352_SERDES_INT_LINK_CHANGE;
|
||||
|
||||
return mv88e6352_serdes_write(chip, MV88E6352_SERDES_INT_ENABLE, val);
|
||||
}
|
||||
|
||||
unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip, int port)
|
||||
|
@ -245,9 +245,11 @@ unsigned int mv88e6352_serdes_irq_mapping(struct mv88e6xxx_chip *chip, int port)
|
|||
int mv88e6352_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port)
|
||||
{
|
||||
unsigned int irq;
|
||||
u8 lane;
|
||||
int err;
|
||||
|
||||
if (!mv88e6352_port_has_serdes(chip, port))
|
||||
lane = mv88e6xxx_serdes_get_lane(chip, port);
|
||||
if (!lane)
|
||||
return 0;
|
||||
|
||||
irq = mv88e6xxx_serdes_irq_mapping(chip, port);
|
||||
|
@ -272,15 +274,18 @@ int mv88e6352_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port)
|
|||
return err;
|
||||
}
|
||||
|
||||
return mv88e6352_serdes_irq_enable(chip);
|
||||
return mv88e6xxx_serdes_irq_enable(chip, port, lane);
|
||||
}
|
||||
|
||||
void mv88e6352_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)
|
||||
{
|
||||
if (!mv88e6352_port_has_serdes(chip, port))
|
||||
u8 lane;
|
||||
|
||||
lane = mv88e6xxx_serdes_get_lane(chip, port);
|
||||
if (!lane)
|
||||
return;
|
||||
|
||||
mv88e6352_serdes_irq_disable(chip);
|
||||
mv88e6xxx_serdes_irq_disable(chip, port, lane);
|
||||
|
||||
/* Freeing the IRQ will trigger irq callbacks. So we cannot
|
||||
* hold the reg_lock.
|
||||
|
@ -546,51 +551,31 @@ static void mv88e6390_serdes_irq_link_sgmii(struct mv88e6xxx_chip *chip,
|
|||
}
|
||||
|
||||
static int mv88e6390_serdes_irq_enable_sgmii(struct mv88e6xxx_chip *chip,
|
||||
u8 lane)
|
||||
u8 lane, bool enable)
|
||||
{
|
||||
u16 val = 0;
|
||||
|
||||
if (enable)
|
||||
val |= MV88E6390_SGMII_INT_LINK_DOWN |
|
||||
MV88E6390_SGMII_INT_LINK_UP;
|
||||
|
||||
return mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
|
||||
MV88E6390_SGMII_INT_ENABLE,
|
||||
MV88E6390_SGMII_INT_LINK_DOWN |
|
||||
MV88E6390_SGMII_INT_LINK_UP);
|
||||
MV88E6390_SGMII_INT_ENABLE, val);
|
||||
}
|
||||
|
||||
static int mv88e6390_serdes_irq_disable_sgmii(struct mv88e6xxx_chip *chip,
|
||||
u8 lane)
|
||||
{
|
||||
return mv88e6390_serdes_write(chip, lane, MDIO_MMD_PHYXS,
|
||||
MV88E6390_SGMII_INT_ENABLE, 0);
|
||||
}
|
||||
|
||||
int mv88e6390_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port,
|
||||
u8 lane)
|
||||
int mv88e6390_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, u8 lane,
|
||||
bool enable)
|
||||
{
|
||||
u8 cmode = chip->ports[port].cmode;
|
||||
int err = 0;
|
||||
|
||||
switch (cmode) {
|
||||
case MV88E6XXX_PORT_STS_CMODE_SGMII:
|
||||
case MV88E6XXX_PORT_STS_CMODE_1000BASEX:
|
||||
case MV88E6XXX_PORT_STS_CMODE_2500BASEX:
|
||||
err = mv88e6390_serdes_irq_enable_sgmii(chip, lane);
|
||||
return mv88e6390_serdes_irq_enable_sgmii(chip, lane, enable);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int mv88e6390_serdes_irq_disable(struct mv88e6xxx_chip *chip, int port,
|
||||
u8 lane)
|
||||
{
|
||||
u8 cmode = chip->ports[port].cmode;
|
||||
int err = 0;
|
||||
|
||||
switch (cmode) {
|
||||
case MV88E6XXX_PORT_STS_CMODE_SGMII:
|
||||
case MV88E6XXX_PORT_STS_CMODE_1000BASEX:
|
||||
case MV88E6XXX_PORT_STS_CMODE_2500BASEX:
|
||||
err = mv88e6390_serdes_irq_disable_sgmii(chip, lane);
|
||||
}
|
||||
|
||||
return err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mv88e6390_serdes_irq_status_sgmii(struct mv88e6xxx_chip *chip,
|
||||
|
@ -676,7 +661,7 @@ int mv88e6390_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port)
|
|||
return err;
|
||||
}
|
||||
|
||||
return mv88e6390_serdes_irq_enable(chip, port, lane);
|
||||
return mv88e6xxx_serdes_irq_enable(chip, port, lane);
|
||||
}
|
||||
|
||||
void mv88e6390_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)
|
||||
|
@ -687,7 +672,7 @@ void mv88e6390_serdes_irq_free(struct mv88e6xxx_chip *chip, int port)
|
|||
if (!lane)
|
||||
return;
|
||||
|
||||
mv88e6390_serdes_irq_disable(chip, port, lane);
|
||||
mv88e6xxx_serdes_irq_disable(chip, port, lane);
|
||||
|
||||
/* Freeing the IRQ will trigger irq callbacks. So we cannot
|
||||
* hold the reg_lock.
|
||||
|
|
|
@ -88,15 +88,15 @@ int mv88e6390_serdes_power(struct mv88e6xxx_chip *chip, int port, u8 lane,
|
|||
bool on);
|
||||
int mv88e6390_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port);
|
||||
void mv88e6390_serdes_irq_free(struct mv88e6xxx_chip *chip, int port);
|
||||
int mv88e6352_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, u8 lane,
|
||||
bool enable);
|
||||
int mv88e6390_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port, u8 lane,
|
||||
bool enable);
|
||||
int mv88e6352_serdes_get_sset_count(struct mv88e6xxx_chip *chip, int port);
|
||||
int mv88e6352_serdes_get_strings(struct mv88e6xxx_chip *chip,
|
||||
int port, uint8_t *data);
|
||||
int mv88e6352_serdes_get_stats(struct mv88e6xxx_chip *chip, int port,
|
||||
uint64_t *data);
|
||||
int mv88e6390_serdes_irq_enable(struct mv88e6xxx_chip *chip, int port,
|
||||
u8 lane);
|
||||
int mv88e6390_serdes_irq_disable(struct mv88e6xxx_chip *chip, int port,
|
||||
u8 lane);
|
||||
int mv88e6352_serdes_irq_setup(struct mv88e6xxx_chip *chip, int port);
|
||||
void mv88e6352_serdes_irq_free(struct mv88e6xxx_chip *chip, int port);
|
||||
|
||||
|
@ -137,4 +137,22 @@ mv88e6xxx_serdes_irq_mapping(struct mv88e6xxx_chip *chip, int port)
|
|||
return chip->info->ops->serdes_irq_mapping(chip, port);
|
||||
}
|
||||
|
||||
static inline int mv88e6xxx_serdes_irq_enable(struct mv88e6xxx_chip *chip,
|
||||
int port, u8 lane)
|
||||
{
|
||||
if (!chip->info->ops->serdes_irq_enable)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return chip->info->ops->serdes_irq_enable(chip, port, lane, true);
|
||||
}
|
||||
|
||||
static inline int mv88e6xxx_serdes_irq_disable(struct mv88e6xxx_chip *chip,
|
||||
int port, u8 lane)
|
||||
{
|
||||
if (!chip->info->ops->serdes_irq_enable)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
return chip->info->ops->serdes_irq_enable(chip, port, lane, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче