diff mbox series

[7/9] ravb: Add support for RZ/V2M

Message ID 20220504145454.71287-8-phil.edworthy@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series Add Renesas RZ/V2M Ethernet support | expand

Commit Message

Phil Edworthy May 4, 2022, 2:54 p.m. UTC
RZ/V2M Ethernet is very similar to R-Car Gen3 Ethernet-AVB, though
some small parts are the same as R-Car Gen2.
Other differences are:
* It has separate data (DI), error (Line 1) and management (Line 2) irqs
  rather than one irq for all three.
* Instead of using the High-speed peripheral bus clock for gPTP, it has a
  separate gPTP reference clock.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Note: gPTP was tested using an RZ/V2M EVK and an R-Car M3N Salvator-XS
board, connected with a Summit X440 AVB switch, using ptp4l.
---
 drivers/net/ethernet/renesas/ravb_main.c | 27 ++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Sergey Shtylyov May 5, 2022, 8:18 p.m. UTC | #1
On 5/4/22 5:54 PM, Phil Edworthy wrote:

> RZ/V2M Ethernet is very similar to R-Car Gen3 Ethernet-AVB, though
> some small parts are the same as R-Car Gen2.

   You mean the absence of the interrupt enable/disable registers?

> Other differences are:

   Differences to gen3, you mean?

> * It has separate data (DI), error (Line 1) and management (Line 2) irqs
>   rather than one irq for all three.
> * Instead of using the High-speed peripheral bus clock for gPTP, it has a
>   separate gPTP reference clock.
> 
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> Note: gPTP was tested using an RZ/V2M EVK and an R-Car M3N Salvator-XS
> board, connected with a Summit X440 AVB switch, using ptp4l.

   Oh, that's good! :-)

> ---
>  drivers/net/ethernet/renesas/ravb_main.c | 27 ++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index ded87cb51650..03b127faf52f 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -2461,6 +2461,32 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
>  	.magic_pkt = 1,
>  };
>  
> +static const struct ravb_hw_info ravb_rzv2m_hw_info = {
> +	.rx_ring_free = ravb_rx_ring_free_rcar,
> +	.rx_ring_format = ravb_rx_ring_format_rcar,
> +	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
> +	.receive = ravb_rx_rcar,
> +	.set_rate = ravb_set_rate_rcar,
> +	.set_feature = ravb_set_features_rcar,
> +	.dmac_init = ravb_dmac_init_rcar,
> +	.emac_init = ravb_emac_init_rcar,
> +	.gstrings_stats = ravb_gstrings_stats,
> +	.gstrings_size = sizeof(ravb_gstrings_stats),
> +	.net_hw_features = NETIF_F_RXCSUM,
> +	.net_features = NETIF_F_RXCSUM,
> +	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
> +	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
> +	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
> +	.rx_max_buf_size = SZ_2K,

   What about .internal_delay and .tx_counters?

> +	.multi_irqs = 1,
> +	.err_mgmt_irqs = 1,
> +	.gptp = 1,

   Not .ccc_gac?

[...]

MBR. Sergey
Phil Edworthy May 9, 2022, 7:01 a.m. UTC | #2
Hi Sergey,

On 05 May 2022 21:18 Sergey Shtylyov wrote:
> On 5/4/22 5:54 PM, Phil Edworthy wrote:
> 
> > RZ/V2M Ethernet is very similar to R-Car Gen3 Ethernet-AVB, though
> > some small parts are the same as R-Car Gen2.
> 
>    You mean the absence of the interrupt enable/disable registers?
> 
> > Other differences are:
> 
>    Differences to gen3, you mean?
Differences to both gen3 and gen2.

 
> > * It has separate data (DI), error (Line 1) and management (Line 2) irqs
> >   rather than one irq for all three.
> > * Instead of using the High-speed peripheral bus clock for gPTP, it has
> a
> >   separate gPTP reference clock.
> >
> > Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> > Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > Note: gPTP was tested using an RZ/V2M EVK and an R-Car M3N Salvator-XS
> > board, connected with a Summit X440 AVB switch, using ptp4l.
> 
>    Oh, that's good! :-)
btw, you should be able to test gPTP without an AVB switch if you connect
the boards directly. I haven't tried it as I'm using rootfs over NFS on
the rz/v2m board.

For ptp4l, I had to create a config file that increases tx_timestamp_timeout
on the rzv2m board:
  echo "[global]" > ptp.cfg
  echo "tx_timestamp_timeout    100" >> ptp.cfg
This increases the timeout waiting for the tx time stamp to 100ms, which is
excessive and it would likely work with 2ms. The default is 1ms.

Rcar gen3 didn’t need this config file, but it has a more powerful processor.
Though whilst familiarising myself with ptp4l I had some debug code in the
driver and that was enough for rcar to also need this config change.

Then just run ptp4l on both sides:
  ptp4l -i eth0 -m -f ./ptp.cfg


> > ---
> >  drivers/net/ethernet/renesas/ravb_main.c | 27 ++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> >
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> b/drivers/net/ethernet/renesas/ravb_main.c
> > index ded87cb51650..03b127faf52f 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > @@ -2461,6 +2461,32 @@ static const struct ravb_hw_info
> ravb_gen2_hw_info = {
> >  	.magic_pkt = 1,
> >  };
> >
> > +static const struct ravb_hw_info ravb_rzv2m_hw_info = {
> > +	.rx_ring_free = ravb_rx_ring_free_rcar,
> > +	.rx_ring_format = ravb_rx_ring_format_rcar,
> > +	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
> > +	.receive = ravb_rx_rcar,
> > +	.set_rate = ravb_set_rate_rcar,
> > +	.set_feature = ravb_set_features_rcar,
> > +	.dmac_init = ravb_dmac_init_rcar,
> > +	.emac_init = ravb_emac_init_rcar,
> > +	.gstrings_stats = ravb_gstrings_stats,
> > +	.gstrings_size = sizeof(ravb_gstrings_stats),
> > +	.net_hw_features = NETIF_F_RXCSUM,
> > +	.net_features = NETIF_F_RXCSUM,
> > +	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
> > +	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
> > +	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
> > +	.rx_max_buf_size = SZ_2K,
> 
>    What about .internal_delay and .tx_counters?
rz/v2m doesn't have the APSR reg, so .internal_delay = 0, and doesn't
have the TROCR reg, so .tx_counters = 0


> > +	.multi_irqs = 1,
> > +	.err_mgmt_irqs = 1,
> > +	.gptp = 1,
> 
>    Not .ccc_gac?
Nope, not on this device.

Thanks
Phil
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index ded87cb51650..03b127faf52f 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2461,6 +2461,32 @@  static const struct ravb_hw_info ravb_gen2_hw_info = {
 	.magic_pkt = 1,
 };
 
+static const struct ravb_hw_info ravb_rzv2m_hw_info = {
+	.rx_ring_free = ravb_rx_ring_free_rcar,
+	.rx_ring_format = ravb_rx_ring_format_rcar,
+	.alloc_rx_desc = ravb_alloc_rx_desc_rcar,
+	.receive = ravb_rx_rcar,
+	.set_rate = ravb_set_rate_rcar,
+	.set_feature = ravb_set_features_rcar,
+	.dmac_init = ravb_dmac_init_rcar,
+	.emac_init = ravb_emac_init_rcar,
+	.gstrings_stats = ravb_gstrings_stats,
+	.gstrings_size = sizeof(ravb_gstrings_stats),
+	.net_hw_features = NETIF_F_RXCSUM,
+	.net_features = NETIF_F_RXCSUM,
+	.stats_len = ARRAY_SIZE(ravb_gstrings_stats),
+	.max_rx_len = RX_BUF_SZ + RAVB_ALIGN - 1,
+	.tccr_mask = TCCR_TSRQ0 | TCCR_TSRQ1 | TCCR_TSRQ2 | TCCR_TSRQ3,
+	.rx_max_buf_size = SZ_2K,
+	.multi_irqs = 1,
+	.err_mgmt_irqs = 1,
+	.gptp = 1,
+	.gptp_ptm_gic = 1,
+	.gptp_ref_clk = 1,
+	.nc_queues = 1,
+	.magic_pkt = 1,
+};
+
 static const struct ravb_hw_info gbeth_hw_info = {
 	.rx_ring_free = ravb_rx_ring_free_gbeth,
 	.rx_ring_format = ravb_rx_ring_format_gbeth,
@@ -2488,6 +2514,7 @@  static const struct of_device_id ravb_match_table[] = {
 	{ .compatible = "renesas,etheravb-rcar-gen2", .data = &ravb_gen2_hw_info },
 	{ .compatible = "renesas,etheravb-r8a7795", .data = &ravb_gen3_hw_info },
 	{ .compatible = "renesas,etheravb-rcar-gen3", .data = &ravb_gen3_hw_info },
+	{ .compatible = "renesas,etheravb-rzv2m", .data = &ravb_rzv2m_hw_info },
 	{ .compatible = "renesas,rzg2l-gbeth", .data = &gbeth_hw_info },
 	{ }
 };