@@ -2,7 +2,7 @@
/*
* Microchip switch driver main logic
*
- * Copyright (C) 2017-2019 Microchip Technology Inc.
+ * Copyright (C) 2017-2024 Microchip Technology Inc.
*/
#include <linux/delay.h>
@@ -2257,6 +2257,12 @@ static irqreturn_t ksz_irq_thread_fn(int irq, void *dev_id)
if (ret)
goto out;
+ if (dev->dev_ops->handle_irq) {
+ ret = dev->dev_ops->handle_irq(dev, kirq->port, &data);
+ if (ret == IRQ_HANDLED)
+ ++nhandled;
+ }
+
for (n = 0; n < kirq->nirqs; ++n) {
if (data & BIT(n)) {
sub_irq = irq_find_mapping(kirq->domain, n);
@@ -2300,6 +2306,7 @@ static int ksz_girq_setup(struct ksz_device *dev)
{
struct ksz_irq *girq = &dev->girq;
+ girq->port = 0;
girq->nirqs = dev->info->port_cnt;
girq->reg_mask = REG_SW_PORT_INT_MASK__1;
girq->reg_status = REG_SW_PORT_INT_STATUS__1;
@@ -2314,6 +2321,7 @@ static int ksz_pirq_setup(struct ksz_device *dev, u8 p)
{
struct ksz_irq *pirq = &dev->ports[p].pirq;
+ pirq->port = p + 1;
pirq->nirqs = dev->info->port_nirqs;
pirq->reg_mask = dev->dev_ops->get_port_addr(p, REG_PORT_INT_MASK);
pirq->reg_status = dev->dev_ops->get_port_addr(p, REG_PORT_INT_STATUS);
@@ -2419,6 +2427,11 @@ static int ksz_setup(struct dsa_switch *ds)
if (ret)
goto out_ptp_clock_unregister;
+ if (dev->irq > 0) {
+ if (dev->dev_ops->enable_irq)
+ dev->dev_ops->enable_irq(dev);
+ }
+
/* start switch */
regmap_update_bits(ksz_regmap_8(dev), regs[S_START_CTRL],
SW_START, SW_START);
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* Microchip switch driver common header
*
- * Copyright (C) 2017-2019 Microchip Technology Inc.
+ * Copyright (C) 2017-2024 Microchip Technology Inc.
*/
#ifndef __KSZ_COMMON_H
@@ -99,6 +99,7 @@ struct ksz_irq {
int irq_num;
char name[16];
struct ksz_device *dev;
+ u8 port;
};
struct ksz_ptp_irq {
@@ -373,6 +374,8 @@ struct ksz_dev_ops {
int (*reset)(struct ksz_device *dev);
int (*init)(struct ksz_device *dev);
void (*exit)(struct ksz_device *dev);
+ void (*enable_irq)(struct ksz_device *dev);
+ irqreturn_t (*handle_irq)(struct ksz_device *dev, u8 port, u8 *data);
};
struct ksz_device *ksz_switch_alloc(struct device *base, void *priv);