From: Andrew Lunn <andrew@lunn.ch>
To: Hanyuan Zhao <hanyuan-z@qq.com>
Cc: davem@davemloft.net, kuba@kernel.org, andrew+netdev@lunn.ch,
edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] net: enc28j60: support getting irq number from gpio phandle in the device tree
Date: Sun, 9 Mar 2025 16:41:53 +0100 [thread overview]
Message-ID: <2b09bea7-2a61-4697-a9c1-6a42cf8570c4@lunn.ch> (raw)
In-Reply-To: <tencent_0A154BBE38E000228C01BE742CB73681FE09@qq.com>
On Sun, Mar 09, 2025 at 03:47:08PM +0800, Hanyuan Zhao wrote:
> This patch allows the kernel to automatically requests the pin, configures
> it as an input, and converts it to an IRQ number, according to a GPIO
> phandle specified in device tree. This simplifies the process by
> eliminating the need to manually define pinctrl and interrupt nodes.
> Additionally, it is necessary for platforms that do not support pin
> configuration and properties via the device tree.
>
> Signed-off-by: Hanyuan Zhao <hanyuan-z@qq.com>
> ---
> drivers/net/ethernet/microchip/enc28j60.c | 25 ++++++++++++++++++-----
> 1 file changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/enc28j60.c b/drivers/net/ethernet/microchip/enc28j60.c
> index d6c9491537e4..b3613e45c900 100644
> --- a/drivers/net/ethernet/microchip/enc28j60.c
> +++ b/drivers/net/ethernet/microchip/enc28j60.c
> @@ -24,6 +24,7 @@
> #include <linux/skbuff.h>
> #include <linux/delay.h>
> #include <linux/spi/spi.h>
> +#include <linux/of_gpio.h>
>
> #include "enc28j60_hw.h"
>
> @@ -1526,6 +1527,7 @@ static int enc28j60_probe(struct spi_device *spi)
> struct net_device *dev;
> struct enc28j60_net *priv;
> int ret = 0;
> + unsigned long irq_flags = IRQF_ONESHOT;
>
> if (netif_msg_drv(&debug))
> dev_info(&spi->dev, "Ethernet driver %s loaded\n", DRV_VERSION);
> @@ -1558,20 +1560,33 @@ static int enc28j60_probe(struct spi_device *spi)
> eth_hw_addr_random(dev);
> enc28j60_set_hw_macaddr(dev);
>
> + if (spi->irq > 0) {
> + dev->irq = spi->irq;
> + } else {
> + /* Try loading device tree property irq-gpios */
> + struct gpio_desc *irq_gpio_desc = devm_fwnode_gpiod_get_index(&spi->dev,
> + of_fwnode_handle(spi->dev.of_node), "irq", 0, GPIOD_IN, NULL);
> + if (IS_ERR(irq_gpio_desc)) {
> + dev_err(&spi->dev, "unable to get a valid irq gpio\n");
> + goto error_irq;
> + }
> + dev->irq = gpiod_to_irq(irq_gpio_desc);
My understanding is that you should not need most of this. The IRQ
core will handle converting a GPIO to an interrupt, if you just list
is as an interrupt source in the normal way.
> + irq_flags |= IRQF_TRIGGER_FALLING;
You say:
> Additionally, it is necessary for platforms that do not support pin
> configuration and properties via the device tree.
Are you talking about ACPI?
Andrew
next prev parent reply other threads:[~2025-03-09 15:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-09 7:47 Hanyuan Zhao
2025-03-09 15:41 ` Andrew Lunn [this message]
[not found] ` <tencent_BE0060E3A7AF384BAF4DA37FD2121B8E1D07@qq.com>
2025-03-10 12:06 ` [PATCH 1/2] net: enc28j60: support getting irq number from gpiophandle " Andrew Lunn
2025-03-10 2:40 [PATCH 1/2] net: enc28j60: support getting irq number from gpio phandle " hanyuan
2025-03-10 12:18 ` Andrew Lunn
2025-03-10 12:25 ` hanyuan
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=2b09bea7-2a61-4697-a9c1-6a42cf8570c4@lunn.ch \
--to=andrew@lunn.ch \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hanyuan-z@qq.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®