All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
	Sergey Shtylyov <s.shtylyov@omp.ru>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Sergei Shtylyov <sergei.shtylyov@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Adam Ford <aford173@gmail.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>
Subject: [PATCH net-next 03/13] ravb: Add no_ptp_cfg_active to struct ravb_hw_info
Date: Wed, 25 Aug 2021 08:01:44 +0100	[thread overview]
Message-ID: <20210825070154.14336-4-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20210825070154.14336-1-biju.das.jz@bp.renesas.com>

There are some H/W differences for the gPTP feature between
R-Car Gen3, R-Car Gen2, and RZ/G2L as below.

1) On R-Car Gen2, gPTP support is not active in config mode.
2) On R-Car Gen3, gPTP support is active in config mode.
3) RZ/G2L does not support the gPTP feature.

Add a no_ptp_cfg_active hw feature bit to struct ravb_hw_info for
handling gPTP for R-Car Gen2.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  1 +
 drivers/net/ethernet/renesas/ravb_main.c | 20 ++++++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index da486e06b322..9ecf1a8c3ca8 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -998,6 +998,7 @@ struct ravb_hw_info {
 	unsigned internal_delay:1;	/* AVB-DMAC has internal delays */
 	unsigned tx_counters:1;		/* E-MAC has TX counters */
 	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
+	unsigned no_ptp_cfg_active:1;	/* AVB-DMAC does not support gPTP active in config mode */
 };
 
 struct ravb_private {
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 28b8dcae57a8..e33b836218f0 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1205,6 +1205,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
 			      struct ethtool_ringparam *ring)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 	int error;
 
 	if (ring->tx_pending > BE_TX_RING_MAX ||
@@ -1218,7 +1219,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
 	if (netif_running(ndev)) {
 		netif_device_detach(ndev);
 		/* Stop PTP Clock driver */
-		if (priv->chip_id == RCAR_GEN2)
+		if (info->no_ptp_cfg_active)
 			ravb_ptp_stop(ndev);
 		/* Wait for DMA stopping */
 		error = ravb_stop_dma(ndev);
@@ -1250,7 +1251,7 @@ static int ravb_set_ringparam(struct net_device *ndev,
 		ravb_emac_init(ndev);
 
 		/* Initialise PTP Clock driver */
-		if (priv->chip_id == RCAR_GEN2)
+		if (info->no_ptp_cfg_active)
 			ravb_ptp_init(ndev, priv->pdev);
 
 		netif_device_attach(ndev);
@@ -1390,7 +1391,7 @@ static int ravb_open(struct net_device *ndev)
 	ravb_emac_init(ndev);
 
 	/* Initialise PTP Clock driver */
-	if (priv->chip_id == RCAR_GEN2)
+	if (info->no_ptp_cfg_active)
 		ravb_ptp_init(ndev, priv->pdev);
 
 	netif_tx_start_all_queues(ndev);
@@ -1404,7 +1405,7 @@ static int ravb_open(struct net_device *ndev)
 
 out_ptp_stop:
 	/* Stop PTP Clock driver */
-	if (priv->chip_id == RCAR_GEN2)
+	if (info->no_ptp_cfg_active)
 		ravb_ptp_stop(ndev);
 out_free_irq_nc_tx:
 	if (!info->multi_irqs)
@@ -1445,13 +1446,14 @@ static void ravb_tx_timeout_work(struct work_struct *work)
 {
 	struct ravb_private *priv = container_of(work, struct ravb_private,
 						 work);
+	const struct ravb_hw_info *info = priv->info;
 	struct net_device *ndev = priv->ndev;
 	int error;
 
 	netif_tx_stop_all_queues(ndev);
 
 	/* Stop PTP Clock driver */
-	if (priv->chip_id == RCAR_GEN2)
+	if (info->no_ptp_cfg_active)
 		ravb_ptp_stop(ndev);
 
 	/* Wait for DMA stopping */
@@ -1486,7 +1488,7 @@ static void ravb_tx_timeout_work(struct work_struct *work)
 
 out:
 	/* Initialise PTP Clock driver */
-	if (priv->chip_id == RCAR_GEN2)
+	if (info->no_ptp_cfg_active)
 		ravb_ptp_init(ndev, priv->pdev);
 
 	netif_tx_start_all_queues(ndev);
@@ -1695,7 +1697,7 @@ static int ravb_close(struct net_device *ndev)
 	ravb_write(ndev, 0, TIC);
 
 	/* Stop PTP Clock driver */
-	if (priv->chip_id == RCAR_GEN2)
+	if (info->no_ptp_cfg_active)
 		ravb_ptp_stop(ndev);
 
 	/* Set the config mode to stop the AVB-DMAC's processes */
@@ -1956,6 +1958,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
 	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
 	.aligned_tx = 1,
+	.no_ptp_cfg_active = 1,
 };
 
 static const struct of_device_id ravb_match_table[] = {
@@ -1996,8 +1999,9 @@ static int ravb_set_gti(struct net_device *ndev)
 static void ravb_set_config_mode(struct net_device *ndev)
 {
 	struct ravb_private *priv = netdev_priv(ndev);
+	const struct ravb_hw_info *info = priv->info;
 
-	if (priv->chip_id == RCAR_GEN2) {
+	if (info->no_ptp_cfg_active) {
 		ravb_modify(ndev, CCC, CCC_OPC, CCC_OPC_CONFIG);
 		/* Set CSEL value */
 		ravb_modify(ndev, CCC, CCC_CSEL, CCC_CSEL_HPB);
-- 
2.17.1


  parent reply	other threads:[~2021-08-25  7:02 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25  7:01 [PATCH net-next 00/13] Add Factorisation code to support Gigabit Ethernet driver Biju Das
2021-08-25  7:01 ` [PATCH net-next 01/13] ravb: Remove the macros NUM_TX_DESC_GEN[23] Biju Das
2021-08-25 14:30   ` Sergey Shtylyov
2021-08-25  7:01 ` [PATCH net-next 02/13] ravb: Add multi_irq to struct ravb_hw_info Biju Das
2021-08-25 18:49   ` Sergey Shtylyov
2021-08-25 19:10     ` Sergey Shtylyov
2021-08-25  7:01 ` Biju Das [this message]
2021-08-25 20:17   ` [PATCH net-next 03/13] ravb: Add no_ptp_cfg_active " Sergey Shtylyov
2021-08-25  7:01 ` [PATCH net-next 04/13] ravb: Add ptp_cfg_active " Biju Das
2021-08-25 20:38   ` Sergey Shtylyov
2021-08-26  6:20     ` Biju Das
2021-08-26 10:29       ` Sergey Shtylyov
2021-08-26 10:34         ` Biju Das
2021-08-26 10:42           ` Sergey Shtylyov
2021-08-26 10:52             ` Biju Das
2021-08-26 18:06               ` Sergei Shtylyov
2021-08-26 18:57                 ` Andrew Lunn
2021-08-26 19:02                   ` Sergey Shtylyov
2021-08-26 19:09                     ` Andrew Lunn
2021-08-26 19:37                       ` Biju Das
2021-08-26 20:03                         ` Sergey Shtylyov
2021-08-27  6:36                           ` Biju Das
2021-08-27 15:48                             ` Sergey Shtylyov
2021-08-27 15:55                               ` Biju Das
2021-08-25  7:01 ` [PATCH net-next 05/13] ravb: Factorise ravb_ring_free function Biju Das
2021-08-25 20:53   ` Sergey Shtylyov
2021-08-25  7:01 ` [PATCH net-next 06/13] ravb: Factorise ravb_ring_format function Biju Das
2021-08-26 18:54   ` Sergey Shtylyov
2021-08-26 19:34     ` Biju Das
2021-08-25  7:01 ` [PATCH net-next 07/13] ravb: Factorise ravb_ring_init function Biju Das
2021-08-26 20:27   ` Sergey Shtylyov
2021-08-25  7:01 ` [PATCH net-next 08/13] ravb: Factorise ravb_rx function Biju Das
2021-08-26 20:41   ` Sergey Shtylyov
2021-08-27  6:28     ` Biju Das
2021-08-25  7:01 ` [PATCH net-next 09/13] ravb: Factorise ravb_adjust_link function Biju Das
2021-08-25  7:01 ` [PATCH net-next 10/13] ravb: Factorise ravb_set_features Biju Das
2021-08-27 19:16   ` Sergey Shtylyov
2021-08-28  9:20     ` Biju Das
2021-08-28 11:35       ` Sergey Shtylyov
2021-08-28 12:45         ` Biju Das
2021-08-25  7:01 ` [PATCH net-next 11/13] ravb: Factorise ravb_dmac_init function Biju Das
2021-08-27 19:36   ` Sergey Shtylyov
2021-08-28  9:28     ` Biju Das
2021-08-25  7:01 ` [PATCH net-next 12/13] ravb: Factorise ravb_emac_init function Biju Das
2021-08-27 19:52   ` Sergey Shtylyov
2021-08-28  9:34     ` Biju Das
2021-08-25  7:01 ` [PATCH net-next 13/13] ravb: Add reset support Biju Das
2021-08-27 20:17   ` Sergey Shtylyov
2021-08-28  9:41     ` Biju Das
2021-08-25 10:30 ` [PATCH net-next 00/13] Add Factorisation code to support Gigabit Ethernet driver patchwork-bot+netdevbpf
2021-08-25 10:57   ` Sergey Shtylyov
2021-08-25 13:46     ` Andrew Lunn
2021-08-25 14:06       ` Sergey Shtylyov

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=20210825070154.14336-4-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=aford173@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=biju.das@bp.renesas.com \
    --cc=davem@davemloft.net \
    --cc=geert+renesas@glider.be \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=s.shtylyov@omp.ru \
    --cc=sergei.shtylyov@gmail.com \
    --cc=yoshihiro.shimoda.uh@renesas.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.