]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: microchip: Use dynamic irq offset
authorBastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Mon, 5 Jan 2026 13:08:01 +0000 (14:08 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 8 Jan 2026 12:01:16 +0000 (13:01 +0100)
The PTP irq_chip operations use an hardcoded IRQ offset in the bit
logic. This IRQ offset isn't the same on KSZ8463 than on others switches
so it can't use the irq_chip operations.

Convey the interrupt bit offset through a new attribute in struct ksz_irq

Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
Link: https://patch.msgid.link/20260105-ksz-rework-v1-2-a68df7f57375@bootlin.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/dsa/microchip/ksz_common.h
drivers/net/dsa/microchip/ksz_ptp.c

index c65188cd3c0a0ed8dd75ee195cebbe47b3a01ada..3add190e686260bb1807ba03b4b153abeead223e 100644 (file)
@@ -108,6 +108,7 @@ struct ksz_irq {
        int irq_num;
        char name[16];
        struct ksz_device *dev;
+       u16 irq0_offset;
 };
 
 struct ksz_ptp_irq {
index 997e4a76d0a68448b0ebc76169150687bbc79673..0ac2865ba9c000fa58b974647c9c88287164cd1c 100644 (file)
@@ -1008,7 +1008,7 @@ static irqreturn_t ksz_ptp_irq_thread_fn(int irq, void *dev_id)
                return IRQ_NONE;
 
        for (n = 0; n < ptpirq->nirqs; ++n) {
-               if (data & BIT(n + KSZ_PTP_INT_START)) {
+               if (data & BIT(n + ptpirq->irq0_offset)) {
                        sub_irq = irq_find_mapping(ptpirq->domain, n);
                        handle_nested_irq(sub_irq);
                        ++nhandled;
@@ -1023,14 +1023,14 @@ static void ksz_ptp_irq_mask(struct irq_data *d)
 {
        struct ksz_irq *kirq = irq_data_get_irq_chip_data(d);
 
-       kirq->masked &= ~BIT(d->hwirq + KSZ_PTP_INT_START);
+       kirq->masked &= ~BIT(d->hwirq + kirq->irq0_offset);
 }
 
 static void ksz_ptp_irq_unmask(struct irq_data *d)
 {
        struct ksz_irq *kirq = irq_data_get_irq_chip_data(d);
 
-       kirq->masked |= BIT(d->hwirq + KSZ_PTP_INT_START);
+       kirq->masked |= BIT(d->hwirq + kirq->irq0_offset);
 }
 
 static void ksz_ptp_irq_bus_lock(struct irq_data *d)
@@ -1126,6 +1126,8 @@ int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p)
        ptpirq->reg_mask = ops->get_port_addr(p, REG_PTP_PORT_TX_INT_ENABLE__2);
        ptpirq->reg_status = ops->get_port_addr(p,
                                                REG_PTP_PORT_TX_INT_STATUS__2);
+       ptpirq->irq0_offset = KSZ_PTP_INT_START;
+
        snprintf(ptpirq->name, sizeof(ptpirq->name), "ptp-irq-%d", p);
 
        init_completion(&port->tstamp_msg_comp);