Re: [RFC PATCH 06/10] net: ti: prueth: Adds HW timestamping support for PTP using PRU-ICSS IEP module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 10, 2025 at 2:01 PM Basharath Hussain Khaja
<basharath@xxxxxxxxxxx> wrote:
>
> From: Roger Quadros <rogerq@xxxxxx>
>
> PRU-ICSS IEP module, which is capable of timestamping RX and
> TX packets at HW level, is used for time synchronization by PTP4L.
>
> This change includes interaction between firmware and user space
> application (ptp4l) with required packet timestamps. The driver
> initializes the PRU firmware with appropriate mode and configuration
> flags. Firmware updates local registers with the flags set by driver
> and uses for further operation. RX SOF timestamp comes along with
> packet and firmware will rise interrupt with TX SOF timestamp after
> pushing the packet on to the wire.
>
> IEP driver is available in upstream and we are reusing for hardware
> configuration for ICSSM as well. On top of that we have extended it
> with the changes for AM57xx SoC.
>
> Extended ethtool for reading HW timestamping capability of the PRU
> interfaces.
>
> Currently ordinary clock (OC) configuration has been validated with
> Linux ptp4l.
>
> Signed-off-by: Roger Quadros <rogerq@xxxxxx>
> Signed-off-by: Andrew F. Davis <afd@xxxxxx>
> Signed-off-by: Parvathi Pudi <parvathi@xxxxxxxxxxx>
> Signed-off-by: Basharath Hussain Khaja <basharath@xxxxxxxxxxx>
> ---
>  drivers/net/ethernet/ti/icssg/icss_iep.c      |  42 ++
>  drivers/net/ethernet/ti/icssm/icssm_ethtool.c |  26 +
>  drivers/net/ethernet/ti/icssm/icssm_prueth.c  | 443 +++++++++++++++++-
>  drivers/net/ethernet/ti/icssm/icssm_prueth.h  |  11 +
>  .../net/ethernet/ti/icssm/icssm_prueth_ptp.h  |  85 ++++
>  5 files changed, 605 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/net/ethernet/ti/icssm/icssm_prueth_ptp.h
>
> diff --git a/drivers/net/ethernet/ti/icssg/icss_iep.c b/drivers/net/ethernet/ti/icssg/icss_iep.c
> index 768578c0d958..9a2ea13703d8 100644
> --- a/drivers/net/ethernet/ti/icssg/icss_iep.c
> +++ b/drivers/net/ethernet/ti/icssg/icss_iep.c
> @@ -937,11 +937,53 @@ static const struct icss_iep_plat_data am654_icss_iep_plat_data = {
>         .config = &am654_icss_iep_regmap_config,
>  };
>
> +static const struct icss_iep_plat_data am57xx_icss_iep_plat_data = {
> +       .flags = ICSS_IEP_64BIT_COUNTER_SUPPORT |
> +                ICSS_IEP_SLOW_COMPEN_REG_SUPPORT,
> +       .reg_offs = {
> +               [ICSS_IEP_GLOBAL_CFG_REG] = 0x00,
> +               [ICSS_IEP_COMPEN_REG] = 0x08,
> +               [ICSS_IEP_SLOW_COMPEN_REG] = 0x0C,
> +               [ICSS_IEP_COUNT_REG0] = 0x10,
> +               [ICSS_IEP_COUNT_REG1] = 0x14,
> +               [ICSS_IEP_CAPTURE_CFG_REG] = 0x18,
> +               [ICSS_IEP_CAPTURE_STAT_REG] = 0x1c,
> +
> +               [ICSS_IEP_CAP6_RISE_REG0] = 0x50,
> +               [ICSS_IEP_CAP6_RISE_REG1] = 0x54,
> +
> +               [ICSS_IEP_CAP7_RISE_REG0] = 0x60,
> +               [ICSS_IEP_CAP7_RISE_REG1] = 0x64,
> +
> +               [ICSS_IEP_CMP_CFG_REG] = 0x70,
> +               [ICSS_IEP_CMP_STAT_REG] = 0x74,
> +               [ICSS_IEP_CMP0_REG0] = 0x78,
> +               [ICSS_IEP_CMP0_REG1] = 0x7c,
> +               [ICSS_IEP_CMP1_REG0] = 0x80,
> +               [ICSS_IEP_CMP1_REG1] = 0x84,
> +
> +               [ICSS_IEP_CMP8_REG0] = 0xc0,
> +               [ICSS_IEP_CMP8_REG1] = 0xc4,
> +               [ICSS_IEP_SYNC_CTRL_REG] = 0x180,
> +               [ICSS_IEP_SYNC0_STAT_REG] = 0x188,
> +               [ICSS_IEP_SYNC1_STAT_REG] = 0x18c,
> +               [ICSS_IEP_SYNC_PWIDTH_REG] = 0x190,
> +               [ICSS_IEP_SYNC0_PERIOD_REG] = 0x194,
> +               [ICSS_IEP_SYNC1_DELAY_REG] = 0x198,
> +               [ICSS_IEP_SYNC_START_REG] = 0x19c,
> +       },
> +       .config = &am654_icss_iep_regmap_config,
> +};
> +
>  static const struct of_device_id icss_iep_of_match[] = {
>         {
>                 .compatible = "ti,am654-icss-iep",
>                 .data = &am654_icss_iep_plat_data,
>         },
> +       {
> +               .compatible = "ti,am5728-icss-iep",
> +               .data = &am57xx_icss_iep_plat_data,
> +       },
>         {},
>  };
>  MODULE_DEVICE_TABLE(of, icss_iep_of_match);
> diff --git a/drivers/net/ethernet/ti/icssm/icssm_ethtool.c b/drivers/net/ethernet/ti/icssm/icssm_ethtool.c
> index cce3276d5565..86d62d64dc4d 100644
> --- a/drivers/net/ethernet/ti/icssm/icssm_ethtool.c
> +++ b/drivers/net/ethernet/ti/icssm/icssm_ethtool.c
> @@ -7,6 +7,7 @@
>
>  #include <linux/if_bridge.h>
>  #include "icssm_prueth.h"
> +#include "../icssg/icss_iep.h"
>
>  #define PRUETH_MODULE_VERSION "0.2"
>  #define PRUETH_MODULE_DESCRIPTION "PRUSS Ethernet driver"
> @@ -189,12 +190,37 @@ static void icssm_emac_get_regs(struct net_device *ndev,
>         regs->version = PRUETH_REG_DUMP_GET_VER(prueth);
>  }
>
> +static int icssm_emac_get_ts_info(struct net_device *ndev,
> +                                 struct kernel_ethtool_ts_info *info)
> +{
> +       struct prueth_emac *emac = netdev_priv(ndev);
> +
> +       if ((PRUETH_IS_EMAC(emac->prueth) && !emac->emac_ptp_tx_irq))
> +               return ethtool_op_get_ts_info(ndev, info);
> +
> +       info->so_timestamping =
> +               SOF_TIMESTAMPING_TX_HARDWARE |
> +               SOF_TIMESTAMPING_TX_SOFTWARE |
> +               SOF_TIMESTAMPING_RX_HARDWARE |
> +               SOF_TIMESTAMPING_RX_SOFTWARE |
> +               SOF_TIMESTAMPING_SOFTWARE |
> +               SOF_TIMESTAMPING_RAW_HARDWARE;

In addtion to what Richard suggested, there is no need to re-mark the
following flags "SOF_TIMESTAMPING_RX_SOFTWARE" and
"SOF_TIMESTAMPING_SOFTWARE", please see __ethtool_get_ts_info().

Thanks,
Jason





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux