From: Yangbo Lu <yangbo.lu@nxp.com>
To: netdev@vger.kernel.org
Cc: Yangbo Lu <yangbo.lu@nxp.com>,
"David S . Miller" <davem@davemloft.net>,
Richard Cochran <richardcochran@gmail.com>,
Claudiu Manoil <claudiu.manoil@nxp.com>,
Jakub Kicinski <kuba@kernel.org>
Subject: [net-next, v2, 6/7] enetc: store ptp device pointer
Date: Fri, 21 May 2021 12:36:18 +0800 [thread overview]
Message-ID: <20210521043619.44694-7-yangbo.lu@nxp.com> (raw)
In-Reply-To: <20210521043619.44694-1-yangbo.lu@nxp.com>
Store ptp device pointer which will be used for ptp domain
timestamp conversion.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v2:
- Made sure ptp device was got.
- Update copyright.
---
drivers/net/ethernet/freescale/enetc/enetc.h | 3 ++-
drivers/net/ethernet/freescale/enetc/enetc_pf.c | 14 +++++++++++++-
drivers/net/ethernet/freescale/enetc/enetc_vf.c | 14 +++++++++++++-
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
index 08b283347d9c..925f2a96e375 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc.h
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
-/* Copyright 2017-2019 NXP */
+/* Copyright 2017-2021 NXP */
#include <linux/timer.h>
#include <linux/pci.h>
@@ -351,6 +351,7 @@ struct enetc_ndev_priv {
struct work_struct tx_onestep_tstamp;
struct sk_buff_head tx_skbs;
+ struct device *ptp_dev;
};
/* Messaging */
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
index 31274325159a..994a4d3b715e 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
-/* Copyright 2017-2019 NXP */
+/* Copyright 2017-2021 NXP */
#include <linux/mdio.h>
#include <linux/module.h>
@@ -1201,6 +1201,7 @@ static int enetc_pf_probe(struct pci_dev *pdev,
{
struct device_node *node = pdev->dev.of_node;
struct enetc_ndev_priv *priv;
+ struct pci_dev *ptp_pdev;
struct net_device *ndev;
struct enetc_si *si;
struct enetc_pf *pf;
@@ -1293,6 +1294,16 @@ static int enetc_pf_probe(struct pci_dev *pdev,
goto err_alloc_msix;
}
+ ptp_pdev = pci_get_device(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_PTP,
+ NULL);
+ if (!ptp_pdev) {
+ dev_err(&pdev->dev, "no PTP device found\n");
+ err = -ENODEV;
+ goto err_get_ptp;
+ }
+
+ priv->ptp_dev = &ptp_pdev->dev;
+
if (!of_get_phy_mode(node, &pf->if_mode)) {
err = enetc_mdiobus_create(pf, node);
if (err)
@@ -1310,6 +1321,7 @@ static int enetc_pf_probe(struct pci_dev *pdev,
return 0;
err_reg_netdev:
+err_get_ptp:
enetc_phylink_destroy(priv);
err_phylink_create:
enetc_mdiobus_destroy(pf);
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
index 03090ba7e226..ca1deb7d4dcb 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
-/* Copyright 2017-2019 NXP */
+/* Copyright 2017-2021 NXP */
#include <linux/module.h>
#include "enetc.h"
@@ -138,6 +138,7 @@ static int enetc_vf_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct enetc_ndev_priv *priv;
+ struct pci_dev *ptp_pdev;
struct net_device *ndev;
struct enetc_si *si;
int err;
@@ -188,6 +189,16 @@ static int enetc_vf_probe(struct pci_dev *pdev,
goto err_alloc_msix;
}
+ ptp_pdev = pci_get_device(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_PTP,
+ NULL);
+ if (!ptp_pdev) {
+ dev_err(&pdev->dev, "no PTP device found\n");
+ err = -ENODEV;
+ goto err_get_ptp;
+ }
+
+ priv->ptp_dev = &ptp_pdev->dev;
+
err = register_netdev(ndev);
if (err)
goto err_reg_netdev;
@@ -197,6 +208,7 @@ static int enetc_vf_probe(struct pci_dev *pdev,
return 0;
err_reg_netdev:
+err_get_ptp:
enetc_free_msix(priv);
err_config_si:
err_alloc_msix:
--
2.25.1
next prev parent reply other threads:[~2021-05-21 4:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-21 4:36 [net-next, v2, 0/7] ptp: support virtual clocks for multiple Yangbo Lu
2021-05-21 4:36 ` [net-next, v2, 1/7] ptp: add ptp virtual clock driver framework Yangbo Lu
2021-05-23 21:24 ` Richard Cochran
2021-05-31 10:38 ` Y.b. Lu
2021-05-21 4:36 ` [net-next, v2, 2/7] ptp: support ptp physical/virtual clocks conversion Yangbo Lu
2021-05-25 11:33 ` Richard Cochran
2021-05-31 10:39 ` Y.b. Lu
2021-05-25 12:28 ` Richard Cochran
2021-05-31 10:40 ` Y.b. Lu
2021-05-21 4:36 ` [net-next, v2, 3/7] ptp: support domains and timestamp conversion Yangbo Lu
2021-05-21 4:36 ` [net-next, v2, 4/7] ptp_qoriq: export ptp clock reading function for cyclecounter Yangbo Lu
2021-05-21 4:36 ` [net-next, v2, 5/7] enetc_ptp: support ptp virtual clock Yangbo Lu
2021-05-21 4:36 ` Yangbo Lu [this message]
2021-05-21 4:36 ` [net-next, v2, 7/7] enetc: support PTP domain timestamp conversion Yangbo Lu
2021-05-22 20:46 ` Claudiu Manoil
2021-05-25 12:37 ` Richard Cochran
2021-05-25 12:48 ` Richard Cochran
2021-05-31 11:26 ` Y.b. Lu
2021-05-31 13:49 ` Richard Cochran
2021-06-15 9:44 ` Y.b. Lu
2021-05-31 10:51 ` Y.b. Lu
2021-05-31 11:31 ` Y.b. Lu
2021-05-31 13:54 ` Richard Cochran
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=20210521043619.44694-7-yangbo.lu@nxp.com \
--to=yangbo.lu@nxp.com \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.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;
as well as URLs for NNTP newsgroup(s).