]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/net/dsa/mv88e6xxx/chip.c
net: dsa: mv88e6xxx: Add MDIO interrupts for internal PHYs
[mirror_ubuntu-jammy-kernel.git] / drivers / net / dsa / mv88e6xxx / chip.c
index cfd53632a655635882fe69b1cccf30cc6bd439d7..fe46b40195fae1503fff871952d34370bf4053a6 100644 (file)
@@ -360,7 +360,7 @@ static void mv88e6xxx_g1_irq_free_common(struct mv88e6xxx_chip *chip)
 
 static void mv88e6xxx_g1_irq_free(struct mv88e6xxx_chip *chip)
 {
-       mv88e6xxx_g1_irq_free(chip);
+       mv88e6xxx_g1_irq_free_common(chip);
 
        free_irq(chip->irq, chip);
 }
@@ -849,7 +849,9 @@ static void mv88e6xxx_get_stats(struct mv88e6xxx_chip *chip, int port,
 
        if (chip->info->ops->serdes_get_stats) {
                data += count;
+               mutex_lock(&chip->reg_lock);
                chip->info->ops->serdes_get_stats(chip, port, data);
+               mutex_unlock(&chip->reg_lock);
        }
 }
 
@@ -2291,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;
        }
 
@@ -2323,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);
        }
 }
@@ -3317,6 +3329,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6085",
                .num_databases = 4096,
                .num_ports = 10,
+               .num_internal_phys = 5,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3337,6 +3350,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6095/88E6095F",
                .num_databases = 256,
                .num_ports = 11,
+               .num_internal_phys = 0,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3355,6 +3369,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6097/88E6097F",
                .num_databases = 4096,
                .num_ports = 11,
+               .num_internal_phys = 8,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3375,6 +3390,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6123",
                .num_databases = 4096,
                .num_ports = 3,
+               .num_internal_phys = 5,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3395,6 +3411,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6131",
                .num_databases = 256,
                .num_ports = 8,
+               .num_internal_phys = 0,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3413,6 +3430,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6341",
                .num_databases = 4096,
                .num_ports = 6,
+               .num_internal_phys = 5,
                .num_gpio = 11,
                .max_vid = 4095,
                .port_base_addr = 0x10,
@@ -3420,6 +3438,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .global2_addr = 0x1c,
                .age_time_coeff = 3750,
                .atu_move_port_mask = 0x1f,
+               .g1_irqs = 9,
                .g2_irqs = 10,
                .pvt = true,
                .multi_chip = true,
@@ -3433,6 +3452,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6161",
                .num_databases = 4096,
                .num_ports = 6,
+               .num_internal_phys = 5,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3453,6 +3473,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6165",
                .num_databases = 4096,
                .num_ports = 6,
+               .num_internal_phys = 0,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3473,6 +3494,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6171",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3493,6 +3515,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6172",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .num_gpio = 15,
                .max_vid = 4095,
                .port_base_addr = 0x10,
@@ -3514,6 +3537,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6175",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3534,6 +3558,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6176",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .num_gpio = 15,
                .max_vid = 4095,
                .port_base_addr = 0x10,
@@ -3555,6 +3580,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6185",
                .num_databases = 256,
                .num_ports = 10,
+               .num_internal_phys = 0,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3573,6 +3599,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6190",
                .num_databases = 4096,
                .num_ports = 11,        /* 10 + Z80 */
+               .num_internal_phys = 11,
                .num_gpio = 16,
                .max_vid = 8191,
                .port_base_addr = 0x0,
@@ -3594,6 +3621,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6190X",
                .num_databases = 4096,
                .num_ports = 11,        /* 10 + Z80 */
+               .num_internal_phys = 11,
                .num_gpio = 16,
                .max_vid = 8191,
                .port_base_addr = 0x0,
@@ -3615,6 +3643,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6191",
                .num_databases = 4096,
                .num_ports = 11,        /* 10 + Z80 */
+               .num_internal_phys = 11,
                .max_vid = 8191,
                .port_base_addr = 0x0,
                .global1_addr = 0x1b,
@@ -3636,6 +3665,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6240",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .num_gpio = 15,
                .max_vid = 4095,
                .port_base_addr = 0x10,
@@ -3658,6 +3688,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6290",
                .num_databases = 4096,
                .num_ports = 11,        /* 10 + Z80 */
+               .num_internal_phys = 11,
                .num_gpio = 16,
                .max_vid = 8191,
                .port_base_addr = 0x0,
@@ -3680,6 +3711,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6320",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .num_gpio = 15,
                .max_vid = 4095,
                .port_base_addr = 0x10,
@@ -3687,6 +3719,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .global2_addr = 0x1c,
                .age_time_coeff = 15000,
                .g1_irqs = 8,
+               .g2_irqs = 10,
                .atu_move_port_mask = 0xf,
                .pvt = true,
                .multi_chip = true,
@@ -3701,6 +3734,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6321",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .num_gpio = 15,
                .max_vid = 4095,
                .port_base_addr = 0x10,
@@ -3708,6 +3742,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .global2_addr = 0x1c,
                .age_time_coeff = 15000,
                .g1_irqs = 8,
+               .g2_irqs = 10,
                .atu_move_port_mask = 0xf,
                .multi_chip = true,
                .tag_protocol = DSA_TAG_PROTO_EDSA,
@@ -3720,6 +3755,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .family = MV88E6XXX_FAMILY_6341,
                .name = "Marvell 88E6341",
                .num_databases = 4096,
+               .num_internal_phys = 5,
                .num_ports = 6,
                .num_gpio = 11,
                .max_vid = 4095,
@@ -3728,6 +3764,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .global2_addr = 0x1c,
                .age_time_coeff = 3750,
                .atu_move_port_mask = 0x1f,
+               .g1_irqs = 9,
                .g2_irqs = 10,
                .pvt = true,
                .multi_chip = true,
@@ -3742,6 +3779,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6350",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3762,6 +3800,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6351",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .max_vid = 4095,
                .port_base_addr = 0x10,
                .global1_addr = 0x1b,
@@ -3782,6 +3821,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6352",
                .num_databases = 4096,
                .num_ports = 7,
+               .num_internal_phys = 5,
                .num_gpio = 15,
                .max_vid = 4095,
                .port_base_addr = 0x10,
@@ -3803,6 +3843,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6390",
                .num_databases = 4096,
                .num_ports = 11,        /* 10 + Z80 */
+               .num_internal_phys = 11,
                .num_gpio = 16,
                .max_vid = 8191,
                .port_base_addr = 0x0,
@@ -3824,6 +3865,7 @@ static const struct mv88e6xxx_info mv88e6xxx_table[] = {
                .name = "Marvell 88E6390X",
                .num_databases = 4096,
                .num_ports = 11,        /* 10 + Z80 */
+               .num_internal_phys = 11,
                .num_gpio = 16,
                .max_vid = 8191,
                .port_base_addr = 0x0,
@@ -4204,15 +4246,18 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev)
        mv88e6xxx_unregister_switch(chip);
        mv88e6xxx_mdios_unregister(chip);
 
-       if (chip->irq > 0) {
-               mv88e6xxx_g1_vtu_prob_irq_free(chip);
-               mv88e6xxx_g1_atu_prob_irq_free(chip);
-               if (chip->info->g2_irqs > 0)
-                       mv88e6xxx_g2_irq_free(chip);
-               mutex_lock(&chip->reg_lock);
+       mv88e6xxx_g1_vtu_prob_irq_free(chip);
+       mv88e6xxx_g1_atu_prob_irq_free(chip);
+
+       if (chip->info->g2_irqs > 0)
+               mv88e6xxx_g2_irq_free(chip);
+
+       mutex_lock(&chip->reg_lock);
+       if (chip->irq > 0)
                mv88e6xxx_g1_irq_free(chip);
-               mutex_unlock(&chip->reg_lock);
-       }
+       else
+               mv88e6xxx_irq_poll_free(chip);
+       mutex_unlock(&chip->reg_lock);
 }
 
 static const struct of_device_id mv88e6xxx_of_match[] = {