From: <Tristram.Ha@microchip.com>
To: Woojung Huh <woojung.huh@microchip.com>,
<UNGLinuxDriver@microchip.com>, <devicetree@vger.kernel.org>,
Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Marek Vasut <marex@denx.de>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Tristram Ha <tristram.ha@microchip.com>
Subject: [PATCH net-next 2/4] net: dsa: microchip: support global switch interrupt in KSZ DSA driver
Date: Fri, 9 Aug 2024 16:38:38 -0700 [thread overview]
Message-ID: <20240809233840.59953-3-Tristram.Ha@microchip.com> (raw)
In-Reply-To: <20240809233840.59953-1-Tristram.Ha@microchip.com>
From: Tristram Ha <tristram.ha@microchip.com>
The KSZ9477 DSA driver outsources interrupt handling to other drivers
such as PHY, but the switch driver still needs to handle some interrupts
itself. This patch prepares the common code to allow specific switch
drivers to handle all switch interrupts.
The port interrupt handling uses the same function as used by the global
switch interrupt, so the port variable is used to differentiate that.
Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
---
drivers/net/dsa/microchip/ksz_common.c | 15 ++++++++++++++-
drivers/net/dsa/microchip/ksz_common.h | 5 ++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 1491099528be..f328c97f27d1 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -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);
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 5f0a628b9849..a2547646026f 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -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);
--
2.34.1
next prev parent reply other threads:[~2024-08-09 23:38 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 23:38 [PATCH net-next 0/4] net: dsa: microchip: add SGMII port support to KSZ9477 switch Tristram.Ha
2024-08-09 23:38 ` [PATCH net-next 1/4] dt-bindings: " Tristram.Ha
2024-08-10 0:20 ` Rob Herring (Arm)
2024-08-10 11:48 ` Krzysztof Kozlowski
2024-08-13 23:09 ` Tristram.Ha
2024-08-14 6:12 ` Krzysztof Kozlowski
2024-08-14 22:32 ` Tristram.Ha
2024-08-10 17:26 ` Andrew Lunn
2024-08-13 21:14 ` Tristram.Ha
2024-08-13 21:32 ` Andrew Lunn
2024-08-13 22:17 ` Tristram.Ha
2024-08-14 13:50 ` Andrew Lunn
2024-08-14 22:30 ` Tristram.Ha
2024-08-14 22:40 ` Andrew Lunn
2024-08-15 21:54 ` Tristram.Ha
2024-08-15 22:50 ` Andrew Lunn
2024-08-09 23:38 ` Tristram.Ha [this message]
2024-08-09 23:38 ` [PATCH net-next 3/4] net: dsa: microchip: handle most interrupts in KSZ9477/KSZ9893 switch families Tristram.Ha
2024-08-10 17:43 ` Sai Krishna Gajula
2024-08-10 17:44 ` Andrew Lunn
2024-08-13 22:24 ` Tristram.Ha
2024-08-14 13:55 ` Andrew Lunn
2024-08-09 23:38 ` [PATCH net-next 4/4] net: dsa: microchip: add SGMII port support to KSZ9477 switch Tristram.Ha
2024-08-10 17:52 ` Andrew Lunn
2024-08-13 20:59 ` Tristram.Ha
2024-08-11 16:32 ` Andrew Lunn
2024-08-13 20:54 ` Tristram.Ha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240809233840.59953-3-Tristram.Ha@microchip.com \
--to=tristram.ha@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marex@denx.de \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox