Message ID | 20220913160427.12749-2-arun.ramadoss@microchip.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: dsa: microchip: ksz9477: enable interrupt for internal phy link detection | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/cc_maintainers | success | CCed 11 of 11 maintainers |
netdev/build_clang | success | Errors and warnings before: 0 this patch: 0 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 86 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
Hi, Le 13/09/2022 à 18:04, Arun Ramadoss a écrit : > Currently the number of port irqs is hard coded for the lan937x switch > as 6. In order to make the generic interrupt handler for ksz switches, > number of port irq supported by the switch is added to the > ksz_chip_data. It is 4 for ksz9477, 2 for ksz9897 and 3 for ksz9567. The ksz9896 has been added recently and it's close to the ksz9897. So it should get ".port_nirqs = 2" too? IIUC, to get the number of port irqs you have to look at table "Port Interrupt Mask Register" in the datasheet. 4 port irqs for the ksz9477: SGMII, PTP, PHY and ACL. 2 port irqs for the ksz9897/ksz9896: PHY and ACL. 3 port irqs for the ksz9567: PTP, PHY and ACL. Best regards, Romain > > Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > --- > drivers/net/dsa/microchip/ksz_common.c | 9 +++++++++ > drivers/net/dsa/microchip/ksz_common.h | 1 + > drivers/net/dsa/microchip/lan937x_main.c | 4 +--- > 3 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c > index fcaa71f66322..b91089a483e7 100644 > --- a/drivers/net/dsa/microchip/ksz_common.c > +++ b/drivers/net/dsa/microchip/ksz_common.c > @@ -1168,6 +1168,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 16, > .cpu_ports = 0x7F, /* can be configured as cpu port */ > .port_cnt = 7, /* total physical port count */ > + .port_nirqs = 4, > .ops = &ksz9477_dev_ops, > .phy_errata_9477 = true, > .mib_names = ksz9477_mib_names, > @@ -1230,6 +1231,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 16, > .cpu_ports = 0x7F, /* can be configured as cpu port */ > .port_cnt = 7, /* total physical port count */ > + .port_nirqs = 2, > .ops = &ksz9477_dev_ops, > .phy_errata_9477 = true, > .mib_names = ksz9477_mib_names, > @@ -1259,6 +1261,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 16, > .cpu_ports = 0x07, /* can be configured as cpu port */ > .port_cnt = 3, /* total port count */ > + .port_nirqs = 2, > .ops = &ksz9477_dev_ops, > .mib_names = ksz9477_mib_names, > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > @@ -1283,6 +1286,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 16, > .cpu_ports = 0x7F, /* can be configured as cpu port */ > .port_cnt = 7, /* total physical port count */ > + .port_nirqs = 3, > .ops = &ksz9477_dev_ops, > .phy_errata_9477 = true, > .mib_names = ksz9477_mib_names, > @@ -1312,6 +1316,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 256, > .cpu_ports = 0x10, /* can be configured as cpu port */ > .port_cnt = 5, /* total physical port count */ > + .port_nirqs = 6, > .ops = &lan937x_dev_ops, > .mib_names = ksz9477_mib_names, > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > @@ -1335,6 +1340,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 256, > .cpu_ports = 0x30, /* can be configured as cpu port */ > .port_cnt = 6, /* total physical port count */ > + .port_nirqs = 6, > .ops = &lan937x_dev_ops, > .mib_names = ksz9477_mib_names, > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > @@ -1358,6 +1364,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 256, > .cpu_ports = 0x30, /* can be configured as cpu port */ > .port_cnt = 8, /* total physical port count */ > + .port_nirqs = 6, > .ops = &lan937x_dev_ops, > .mib_names = ksz9477_mib_names, > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > @@ -1385,6 +1392,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 256, > .cpu_ports = 0x38, /* can be configured as cpu port */ > .port_cnt = 5, /* total physical port count */ > + .port_nirqs = 6, > .ops = &lan937x_dev_ops, > .mib_names = ksz9477_mib_names, > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > @@ -1412,6 +1420,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { > .num_statics = 256, > .cpu_ports = 0x30, /* can be configured as cpu port */ > .port_cnt = 8, /* total physical port count */ > + .port_nirqs = 6, > .ops = &lan937x_dev_ops, > .mib_names = ksz9477_mib_names, > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h > index 6203dcd8c8f7..baa1e1bc1b7c 100644 > --- a/drivers/net/dsa/microchip/ksz_common.h > +++ b/drivers/net/dsa/microchip/ksz_common.h > @@ -45,6 +45,7 @@ struct ksz_chip_data { > int num_statics; > int cpu_ports; > int port_cnt; > + u8 port_nirqs; > const struct ksz_dev_ops *ops; > bool phy_errata_9477; > bool ksz87xx_eee_link_erratum; > diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c > index 9b6760b1e572..7136d9c55315 100644 > --- a/drivers/net/dsa/microchip/lan937x_main.c > +++ b/drivers/net/dsa/microchip/lan937x_main.c > @@ -20,8 +20,6 @@ > #include "ksz_common.h" > #include "lan937x.h" > > -#define LAN937x_PNIRQS 6 > - > static int lan937x_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set) > { > return regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0); > @@ -697,7 +695,7 @@ static int lan937x_pirq_setup(struct ksz_device *dev, u8 p) > int ret, irq; > int irq_num; > > - port->pirq.nirqs = LAN937x_PNIRQS; > + port->pirq.nirqs = dev->info->port_nirqs; > port->pirq.domain = irq_domain_add_simple(dev->dev->of_node, > port->pirq.nirqs, 0, > &lan937x_pirq_domain_ops,
Hi Romain, On Tue, 2022-09-13 at 22:11 +0200, Romain Naour wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you > know the content is safe > > Hi, > > Le 13/09/2022 à 18:04, Arun Ramadoss a écrit : > > Currently the number of port irqs is hard coded for the lan937x > > switch > > as 6. In order to make the generic interrupt handler for ksz > > switches, > > number of port irq supported by the switch is added to the > > ksz_chip_data. It is 4 for ksz9477, 2 for ksz9897 and 3 for > > ksz9567. > > The ksz9896 has been added recently and it's close to the ksz9897. > So it should get ".port_nirqs = 2" too? > > IIUC, to get the number of port irqs you have to look at table "Port > Interrupt > Mask Register" in the datasheet. > > 4 port irqs for the ksz9477: SGMII, PTP, PHY and ACL. > 2 port irqs for the ksz9897/ksz9896: PHY and ACL. > 3 port irqs for the ksz9567: PTP, PHY and ACL. Thanks for pointing it out. I will include .port_nirqs=2 for ksz9896 and send the v2 patch. > > Best regards, > Romain > > > > > Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > > --- > > drivers/net/dsa/microchip/ksz_common.c | 9 +++++++++ > > drivers/net/dsa/microchip/ksz_common.h | 1 + > > drivers/net/dsa/microchip/lan937x_main.c | 4 +--- > > 3 files changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/net/dsa/microchip/ksz_common.c > > b/drivers/net/dsa/microchip/ksz_common.c > > index fcaa71f66322..b91089a483e7 100644 > > --- a/drivers/net/dsa/microchip/ksz_common.c > > +++ b/drivers/net/dsa/microchip/ksz_common.c > > @@ -1168,6 +1168,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 16, > > .cpu_ports = 0x7F, /* can be configured as cpu > > port */ > > .port_cnt = 7, /* total physical port count > > */ > > + .port_nirqs = 4, > > .ops = &ksz9477_dev_ops, > > .phy_errata_9477 = true, > > .mib_names = ksz9477_mib_names, > > @@ -1230,6 +1231,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 16, > > .cpu_ports = 0x7F, /* can be configured as cpu > > port */ > > .port_cnt = 7, /* total physical port count > > */ > > + .port_nirqs = 2, > > .ops = &ksz9477_dev_ops, > > .phy_errata_9477 = true, > > .mib_names = ksz9477_mib_names, > > @@ -1259,6 +1261,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 16, > > .cpu_ports = 0x07, /* can be configured as cpu > > port */ > > .port_cnt = 3, /* total port count */ > > + .port_nirqs = 2, > > .ops = &ksz9477_dev_ops, > > .mib_names = ksz9477_mib_names, > > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > > @@ -1283,6 +1286,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 16, > > .cpu_ports = 0x7F, /* can be configured as cpu > > port */ > > .port_cnt = 7, /* total physical port count > > */ > > + .port_nirqs = 3, > > .ops = &ksz9477_dev_ops, > > .phy_errata_9477 = true, > > .mib_names = ksz9477_mib_names, > > @@ -1312,6 +1316,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 256, > > .cpu_ports = 0x10, /* can be configured as cpu > > port */ > > .port_cnt = 5, /* total physical port count > > */ > > + .port_nirqs = 6, > > .ops = &lan937x_dev_ops, > > .mib_names = ksz9477_mib_names, > > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > > @@ -1335,6 +1340,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 256, > > .cpu_ports = 0x30, /* can be configured as cpu > > port */ > > .port_cnt = 6, /* total physical port count > > */ > > + .port_nirqs = 6, > > .ops = &lan937x_dev_ops, > > .mib_names = ksz9477_mib_names, > > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > > @@ -1358,6 +1364,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 256, > > .cpu_ports = 0x30, /* can be configured as cpu > > port */ > > .port_cnt = 8, /* total physical port count > > */ > > + .port_nirqs = 6, > > .ops = &lan937x_dev_ops, > > .mib_names = ksz9477_mib_names, > > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > > @@ -1385,6 +1392,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 256, > > .cpu_ports = 0x38, /* can be configured as cpu > > port */ > > .port_cnt = 5, /* total physical port count > > */ > > + .port_nirqs = 6, > > .ops = &lan937x_dev_ops, > > .mib_names = ksz9477_mib_names, > > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > > @@ -1412,6 +1420,7 @@ const struct ksz_chip_data ksz_switch_chips[] > > = { > > .num_statics = 256, > > .cpu_ports = 0x30, /* can be configured as cpu > > port */ > > .port_cnt = 8, /* total physical port count > > */ > > + .port_nirqs = 6, > > .ops = &lan937x_dev_ops, > > .mib_names = ksz9477_mib_names, > > .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), > > diff --git a/drivers/net/dsa/microchip/ksz_common.h > > b/drivers/net/dsa/microchip/ksz_common.h > > index 6203dcd8c8f7..baa1e1bc1b7c 100644 > > --- a/drivers/net/dsa/microchip/ksz_common.h > > +++ b/drivers/net/dsa/microchip/ksz_common.h > > @@ -45,6 +45,7 @@ struct ksz_chip_data { > > int num_statics; > > int cpu_ports; > > int port_cnt; > > + u8 port_nirqs; > > const struct ksz_dev_ops *ops; > > bool phy_errata_9477; > > bool ksz87xx_eee_link_erratum; > > diff --git a/drivers/net/dsa/microchip/lan937x_main.c > > b/drivers/net/dsa/microchip/lan937x_main.c > > index 9b6760b1e572..7136d9c55315 100644 > > --- a/drivers/net/dsa/microchip/lan937x_main.c > > +++ b/drivers/net/dsa/microchip/lan937x_main.c > > @@ -20,8 +20,6 @@ > > #include "ksz_common.h" > > #include "lan937x.h" > > > > -#define LAN937x_PNIRQS 6 > > - > > static int lan937x_cfg(struct ksz_device *dev, u32 addr, u8 bits, > > bool set) > > { > > return regmap_update_bits(dev->regmap[0], addr, bits, set ? > > bits : 0); > > @@ -697,7 +695,7 @@ static int lan937x_pirq_setup(struct ksz_device > > *dev, u8 p) > > int ret, irq; > > int irq_num; > > > > - port->pirq.nirqs = LAN937x_PNIRQS; > > + port->pirq.nirqs = dev->info->port_nirqs; > > port->pirq.domain = irq_domain_add_simple(dev->dev->of_node, > > port->pirq.nirqs, > > 0, > > &lan937x_pirq_domai > > n_ops, > >
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index fcaa71f66322..b91089a483e7 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1168,6 +1168,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 16, .cpu_ports = 0x7F, /* can be configured as cpu port */ .port_cnt = 7, /* total physical port count */ + .port_nirqs = 4, .ops = &ksz9477_dev_ops, .phy_errata_9477 = true, .mib_names = ksz9477_mib_names, @@ -1230,6 +1231,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 16, .cpu_ports = 0x7F, /* can be configured as cpu port */ .port_cnt = 7, /* total physical port count */ + .port_nirqs = 2, .ops = &ksz9477_dev_ops, .phy_errata_9477 = true, .mib_names = ksz9477_mib_names, @@ -1259,6 +1261,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 16, .cpu_ports = 0x07, /* can be configured as cpu port */ .port_cnt = 3, /* total port count */ + .port_nirqs = 2, .ops = &ksz9477_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), @@ -1283,6 +1286,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 16, .cpu_ports = 0x7F, /* can be configured as cpu port */ .port_cnt = 7, /* total physical port count */ + .port_nirqs = 3, .ops = &ksz9477_dev_ops, .phy_errata_9477 = true, .mib_names = ksz9477_mib_names, @@ -1312,6 +1316,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x10, /* can be configured as cpu port */ .port_cnt = 5, /* total physical port count */ + .port_nirqs = 6, .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), @@ -1335,6 +1340,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 6, /* total physical port count */ + .port_nirqs = 6, .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), @@ -1358,6 +1364,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 8, /* total physical port count */ + .port_nirqs = 6, .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), @@ -1385,6 +1392,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x38, /* can be configured as cpu port */ .port_cnt = 5, /* total physical port count */ + .port_nirqs = 6, .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), @@ -1412,6 +1420,7 @@ const struct ksz_chip_data ksz_switch_chips[] = { .num_statics = 256, .cpu_ports = 0x30, /* can be configured as cpu port */ .port_cnt = 8, /* total physical port count */ + .port_nirqs = 6, .ops = &lan937x_dev_ops, .mib_names = ksz9477_mib_names, .mib_cnt = ARRAY_SIZE(ksz9477_mib_names), diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 6203dcd8c8f7..baa1e1bc1b7c 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -45,6 +45,7 @@ struct ksz_chip_data { int num_statics; int cpu_ports; int port_cnt; + u8 port_nirqs; const struct ksz_dev_ops *ops; bool phy_errata_9477; bool ksz87xx_eee_link_erratum; diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/microchip/lan937x_main.c index 9b6760b1e572..7136d9c55315 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -20,8 +20,6 @@ #include "ksz_common.h" #include "lan937x.h" -#define LAN937x_PNIRQS 6 - static int lan937x_cfg(struct ksz_device *dev, u32 addr, u8 bits, bool set) { return regmap_update_bits(dev->regmap[0], addr, bits, set ? bits : 0); @@ -697,7 +695,7 @@ static int lan937x_pirq_setup(struct ksz_device *dev, u8 p) int ret, irq; int irq_num; - port->pirq.nirqs = LAN937x_PNIRQS; + port->pirq.nirqs = dev->info->port_nirqs; port->pirq.domain = irq_domain_add_simple(dev->dev->of_node, port->pirq.nirqs, 0, &lan937x_pirq_domain_ops,