]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: dsa: mv88e6xxx: Add MDIO interrupts for internal PHYs
authorAndrew Lunn <andrew@lunn.ch>
Sat, 17 Mar 2018 19:32:05 +0000 (20:32 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 18 Mar 2018 20:52:59 +0000 (16:52 -0400)
When registering an MDIO bus, it is possible to pass an array of
interrupts, one per address on the bus. phylib will then associate the
interrupt to the PHY device, if no other interrupt is provided.

Some of the global2 interrupts are PHY interrupts. Place them into the
MDIO bus structure.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/global2.c
drivers/net/dsa/mv88e6xxx/global2.h

index a460673cf27e4bc66cc64e49352c6aa4af87fde9..fe46b40195fae1503fff871952d34370bf4053a6 100644 (file)
@@ -2293,12 +2293,19 @@ static int mv88e6xxx_mdio_register(struct mv88e6xxx_chip *chip,
        bus->write = mv88e6xxx_mdio_write;
        bus->parent = chip->dev;
 
+       if (!external) {
+               err = mv88e6xxx_g2_irq_mdio_setup(chip, bus);
+               if (err)
+                       return err;
+       }
+
        if (np)
                err = of_mdiobus_register(bus, np);
        else
                err = mdiobus_register(bus);
        if (err) {
                dev_err(chip->dev, "Cannot register MDIO bus (%d)\n", err);
+               mv88e6xxx_g2_irq_mdio_free(chip, bus);
                return err;
        }
 
@@ -2325,6 +2332,9 @@ static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip)
        list_for_each_entry(mdio_bus, &chip->mdios, list) {
                bus = mdio_bus->bus;
 
+               if (!mdio_bus->external)
+                       mv88e6xxx_g2_irq_mdio_free(chip, bus);
+
                mdiobus_unregister(bus);
        }
 }
index 5f370f1fc7c4e04326745b0b189de8a70ce766b8..6c620974fef37db47d0f9640842db1cac8483ae3 100644 (file)
@@ -1107,6 +1107,38 @@ out:
        return err;
 }
 
+int mv88e6xxx_g2_irq_mdio_setup(struct mv88e6xxx_chip *chip,
+                               struct mii_bus *bus)
+{
+       int phy, irq, err, err_phy;
+
+       for (phy = 0; phy < chip->info->num_internal_phys; phy++) {
+               irq = irq_find_mapping(chip->g2_irq.domain, phy);
+               if (irq < 0) {
+                       err = irq;
+                       goto out;
+               }
+               bus->irq[chip->info->port_base_addr + phy] = irq;
+       }
+       return 0;
+out:
+       err_phy = phy;
+
+       for (phy = 0; phy < err_phy; phy++)
+               irq_dispose_mapping(bus->irq[phy]);
+
+       return err;
+}
+
+void mv88e6xxx_g2_irq_mdio_free(struct mv88e6xxx_chip *chip,
+                               struct mii_bus *bus)
+{
+       int phy;
+
+       for (phy = 0; phy < chip->info->num_internal_phys; phy++)
+               irq_dispose_mapping(bus->irq[phy]);
+}
+
 int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip)
 {
        u16 reg;
index aa3f0a736966abfe316e84ff8dac8cf5dc8ecd4b..520ec70d32e84f304cf9246eb904bb5016474dd6 100644 (file)
@@ -317,6 +317,11 @@ int mv88e6xxx_g2_setup(struct mv88e6xxx_chip *chip);
 int mv88e6xxx_g2_irq_setup(struct mv88e6xxx_chip *chip);
 void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip);
 
+int mv88e6xxx_g2_irq_mdio_setup(struct mv88e6xxx_chip *chip,
+                               struct mii_bus *bus);
+void mv88e6xxx_g2_irq_mdio_free(struct mv88e6xxx_chip *chip,
+                               struct mii_bus *bus);
+
 int mv88e6185_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
 int mv88e6352_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip);
 
@@ -450,6 +455,17 @@ static inline void mv88e6xxx_g2_irq_free(struct mv88e6xxx_chip *chip)
 {
 }
 
+static inline int mv88e6xxx_g2_irq_mdio_setup(struct mv88e6xxx_chip *chip,
+                                             struct mii_bus *bus)
+{
+       return 0;
+}
+
+static inline void mv88e6xxx_g2_irq_mdio_free(struct mv88e6xxx_chip *chip,
+                                             struct mii_bus *bus)
+{
+}
+
 static inline int mv88e6185_g2_mgmt_rsvd2cpu(struct mv88e6xxx_chip *chip)
 {
        return -EOPNOTSUPP;