[PATCH v1 23/32] net/ntnic: add nt400d13 PRM module init
Serhii Iliushyk
sil-plv at napatech.com
Thu Feb 20 23:03:47 CET 2025
From: Danylo Vodopianov <dvo-plv at napatech.com>
Initialize RAB0 and create PRM for FPGA.
Signed-off-by: Danylo Vodopianov <dvo-plv at napatech.com>
---
drivers/net/ntnic/meson.build | 1 +
.../nthw/core/include/nthw_prm_nt400dxx.h | 30 +++++++++++++
.../nt400dxx/reset/nthw_fpga_rst_nt400dxx.c | 11 +++++
.../net/ntnic/nthw/core/nthw_prm_nt400dxx.c | 43 +++++++++++++++++++
drivers/net/ntnic/nthw/nthw_drv.h | 2 +
5 files changed, 87 insertions(+)
create mode 100644 drivers/net/ntnic/nthw/core/include/nthw_prm_nt400dxx.h
create mode 100644 drivers/net/ntnic/nthw/core/nthw_prm_nt400dxx.c
diff --git a/drivers/net/ntnic/meson.build b/drivers/net/ntnic/meson.build
index b9ac069bcc..9885d4efbf 100644
--- a/drivers/net/ntnic/meson.build
+++ b/drivers/net/ntnic/meson.build
@@ -63,6 +63,7 @@ sources = files(
'nthw/core/nthw_pcal6416a.c',
'nthw/core/nthw_pcm_nt400dxx.c',
'nthw/core/nthw_phy_tile.c',
+ 'nthw/core/nthw_prm_nt400dxx.c',
'nthw/core/nthw_si5332_si5156.c',
'nthw/core/nthw_rpf.c',
'nthw/core/nthw_rmc.c',
diff --git a/drivers/net/ntnic/nthw/core/include/nthw_prm_nt400dxx.h b/drivers/net/ntnic/nthw/core/include/nthw_prm_nt400dxx.h
new file mode 100644
index 0000000000..09bfd79249
--- /dev/null
+++ b/drivers/net/ntnic/nthw/core/include/nthw_prm_nt400dxx.h
@@ -0,0 +1,30 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#ifndef NTHW_PRM_NT400DXX_H_
+#define NTHW_PRM_NT400DXX_H_
+
+#include <stdint.h>
+
+#include "nthw_fpga_model.h"
+
+struct nt_prm_nt400dxx {
+ nthw_fpga_t *mp_fpga;
+ nthw_module_t *mp_mod_prm;
+
+ int mn_instance;
+
+ nthw_register_t *mp_reg_rst;
+ nthw_field_t *mp_fld_rst_periph;
+ nthw_field_t *mp_fld_rst_platform;
+};
+
+typedef struct nt_prm_nt400dxx nthw_prm_nt400dxx_t;
+typedef struct nt_prm_nt400dxx nt_prm_nt400dxx;
+
+nthw_prm_nt400dxx_t *nthw_prm_nt400dxx_new(void);
+int nthw_prm_nt400dxx_init(nthw_prm_nt400dxx_t *p, nthw_fpga_t *p_fpga, int n_instance);
+
+#endif /* NTHW_PRM_NT400DXX_H_ */
diff --git a/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c b/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c
index 60e7714283..4d74db88de 100644
--- a/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c
+++ b/drivers/net/ntnic/nthw/core/nt400dxx/reset/nthw_fpga_rst_nt400dxx.c
@@ -44,6 +44,17 @@ static int nthw_fpga_rst_nt400dxx_init(struct fpga_info_s *p_fpga_info)
nthw_hif_delete(p_nthw_hif);
+ /* (b) Init RAB0 */
+ nthw_rac_rab_init(p_fpga_info->mp_nthw_rac, 0x7);
+ nthw_rac_rab_init(p_fpga_info->mp_nthw_rac, 0x6);
+
+ /* Create PRM */
+ p_fpga_info->mp_nthw_agx.p_prm = nthw_prm_nt400dxx_new();
+ res = nthw_prm_nt400dxx_init(p_fpga_info->mp_nthw_agx.p_prm, p_fpga, 0);
+
+ if (res != 0)
+ return res;
+
/* Create PCM */
p_fpga_info->mp_nthw_agx.p_pcm = nthw_pcm_nt400dxx_new();
res = nthw_pcm_nt400dxx_init(p_fpga_info->mp_nthw_agx.p_pcm, p_fpga, 0);
diff --git a/drivers/net/ntnic/nthw/core/nthw_prm_nt400dxx.c b/drivers/net/ntnic/nthw/core/nthw_prm_nt400dxx.c
new file mode 100644
index 0000000000..b1910fdbd5
--- /dev/null
+++ b/drivers/net/ntnic/nthw/core/nthw_prm_nt400dxx.c
@@ -0,0 +1,43 @@
+/*
+ * SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2023 Napatech A/S
+ */
+
+#include "ntlog.h"
+#include "nthw_drv.h"
+#include "nthw_register.h"
+#include "nthw_prm_nt400dxx.h"
+
+nthw_prm_nt400dxx_t *nthw_prm_nt400dxx_new(void)
+{
+ nthw_prm_nt400dxx_t *p = malloc(sizeof(nthw_prm_nt400dxx_t));
+
+ if (p)
+ memset(p, 0, sizeof(nthw_prm_nt400dxx_t));
+
+ return p;
+}
+
+int nthw_prm_nt400dxx_init(nthw_prm_nt400dxx_t *p, nthw_fpga_t *p_fpga, int n_instance)
+{
+ nthw_module_t *p_mod = nthw_fpga_query_module(p_fpga, MOD_PRM_NT400DXX, n_instance);
+
+ if (p == NULL)
+ return p_mod == NULL ? -1 : 0;
+
+ if (p_mod == NULL) {
+ NT_LOG(ERR, NTHW, "%s: PRM_NT400DXX %d: no such instance",
+ p->mp_fpga->p_fpga_info->mp_adapter_id_str, p->mn_instance);
+ return -1;
+ }
+
+ p->mp_mod_prm = p_mod;
+
+ p->mp_fpga = p_fpga;
+ p->mn_instance = n_instance;
+
+ p->mp_reg_rst = nthw_module_get_register(p->mp_mod_prm, PRM_NT400DXX_RST);
+ p->mp_fld_rst_periph = nthw_register_get_field(p->mp_reg_rst, PRM_NT400DXX_RST_PERIPH);
+ p->mp_fld_rst_platform = nthw_register_get_field(p->mp_reg_rst, PRM_NT400DXX_RST_PLATFORM);
+ return 0;
+}
diff --git a/drivers/net/ntnic/nthw/nthw_drv.h b/drivers/net/ntnic/nthw/nthw_drv.h
index 955d0a37b0..ecd3bb9cc4 100644
--- a/drivers/net/ntnic/nthw/nthw_drv.h
+++ b/drivers/net/ntnic/nthw/nthw_drv.h
@@ -15,6 +15,7 @@
#include "nthw_rpf.h"
#include "nthw_pcm_nt400dxx.h"
#include "nthw_phy_tile.h"
+#include "nthw_prm_nt400dxx.h"
#include "nthw_pcm_nt400dxx.h"
/*
@@ -27,6 +28,7 @@ typedef struct nthw_agx_s {
nthw_pca9532_t *p_pca9532_led;
nthw_si5332_t *p_si5332;
nthw_si5156_t *p_si5156;
+ nthw_prm_nt400dxx_t *p_prm;
nthw_pcm_nt400dxx_t *p_pcm;
nthw_phy_tile_t *p_phy_tile;
nthw_rpf_t *p_rpf;
--
2.45.0
More information about the dev
mailing list