From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: linux-mips@vger.kernel.org
Cc: davem@davemloft.net, robh+dt@kernel.org, mark.rutland@arm.com,
axboe@kernel.dk, peppe.cavallaro@st.com, alexandre.torgue@st.com,
joabreu@synopsys.com, bhelgaas@google.com,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-ide@vger.kernel.org, linux-pci@vger.kernel.org,
Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC
Date: Wed, 30 Oct 2019 21:53:45 +0800 [thread overview]
Message-ID: <20191030135347.3636-4-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20191030135347.3636-1-jiaxun.yang@flygoat.com>
This device will be setup by parsing DeviceTree node
of pci device.
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_pci.c | 52 ++++++++++++++++++-
1 file changed, 50 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 292045f4581f..640a2a5b8d41 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -12,8 +12,11 @@
#include <linux/clk-provider.h>
#include <linux/pci.h>
#include <linux/dmi.h>
+#include <linux/of.h>
+#include <linux/of_irq.h>
#include "stmmac.h"
+#include "stmmac_platform.h"
/*
* This struct is used to associate PCI Function of MAC controller on a board,
@@ -33,6 +36,7 @@ struct stmmac_pci_dmi_data {
struct stmmac_pci_info {
int (*setup)(struct pci_dev *pdev, struct plat_stmmacenet_data *plat);
+ bool of_irq;
};
static int stmmac_pci_find_phy_addr(struct pci_dev *pdev,
@@ -444,6 +448,30 @@ static const struct stmmac_pci_info snps_gmac5_pci_info = {
.setup = snps_gmac5_default_data,
};
+static int loongson_pci_of_setup(struct pci_dev *pdev,
+ struct plat_stmmacenet_data *plat)
+{
+ struct device_node *np;
+ np = pci_device_to_OF_node(pdev);
+
+ if(!np) {
+ dev_err(&pdev->dev, "Unable to get OF node\n");
+ return -ENODEV;
+ }
+
+ if(!of_device_is_compatible(np, "loongson,pci-gmac")) {
+ dev_err(&pdev->dev, "Device compatible mismatch\n");
+ return -ENODEV;
+ }
+
+ return stmmac_parse_config_dt(np, plat);
+}
+
+static const struct stmmac_pci_info loongson_of_pci_info = {
+ .setup = loongson_pci_of_setup,
+ .of_irq = true,
+};
+
/**
* stmmac_pci_probe
*
@@ -508,8 +536,27 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
memset(&res, 0, sizeof(res));
res.addr = pcim_iomap_table(pdev)[i];
- res.wol_irq = pdev->irq;
- res.irq = pdev->irq;
+
+ if(info->of_irq) {
+ struct device_node *np;
+ np = pci_device_to_OF_node(pdev);
+
+ res.irq = of_irq_get_byname(np, "macirq");
+ if (res.irq < 0)
+ return res.irq;
+ res.wol_irq = of_irq_get_byname(np, "eth_wake_irq");
+ if (res.wol_irq < 0) {
+ if (res.wol_irq == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ res.wol_irq = res.irq;
+ }
+ res.lpi_irq = of_irq_get_byname(np, "eth_lpi");
+ if (res.lpi_irq == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ } else {
+ res.wol_irq = pdev->irq;
+ res.irq = pdev->irq;
+ }
return stmmac_dvr_probe(&pdev->dev, plat, &res);
}
@@ -602,6 +649,7 @@ static const struct pci_device_id stmmac_id_table[] = {
STMMAC_DEVICE(INTEL, STMMAC_EHL_SGMII1G_ID, ehl_sgmii1g_pci_info),
STMMAC_DEVICE(INTEL, STMMAC_TGL_SGMII1G_ID, tgl_sgmii1g_pci_info),
STMMAC_DEVICE(SYNOPSYS, STMMAC_GMAC5_ID, snps_gmac5_pci_info),
+ STMMAC_DEVICE(LOONGSON, PCI_DEVICE_ID_LOONGSON_GMAC, loongson_of_pci_info),
{}
};
--
2.23.0
next prev parent reply other threads:[~2019-10-30 13:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-30 13:53 [PATCH 0/5] PCI Devices for Loongson PCH Jiaxun Yang
2019-10-30 13:53 ` [PATCH 1/5] PCI: pci_ids: Add Loongson IDs Jiaxun Yang
2019-10-30 20:40 ` Bjorn Helgaas
2019-10-30 13:53 ` [PATCH 2/5] net: stmmac: Split devicetree parse Jiaxun Yang
2019-11-01 12:18 ` Andrew Murray
2019-11-01 22:43 ` kbuild test robot
2019-10-30 13:53 ` Jiaxun Yang [this message]
2019-10-30 20:36 ` [PATCH 3/5] net: stmmac: pci: Add Loongson GMAC Bjorn Helgaas
2019-10-30 13:53 ` [PATCH 4/5] dt-bindings: net: document loongson.pci-gmac Jiaxun Yang
2019-10-31 8:35 ` Simon Horman
2019-10-31 10:57 ` Jiaxun Yang
2019-10-31 20:42 ` Simon Horman
2019-10-30 13:53 ` [PATCH 5/5] libata/ahci: Apply non-standard BAR fix for Loongson Jiaxun Yang
2019-10-31 10:39 ` John Garry
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=20191030135347.3636-4-jiaxun.yang@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=alexandre.torgue@st.com \
--cc=axboe@kernel.dk \
--cc=bhelgaas@google.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=joabreu@synopsys.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
--cc=robh+dt@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).