Skip to content

Commit c242be4

Browse files
committed
drivers: ethernet: imx_netc: add MMIO memory mapping
Added MMIO memory mapping support in nxim_imx_netc driver as need to do MMU mapping for Cortex-A Core, but the update is also feasible for Cortex-M Core. Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
1 parent 7e9ed2b commit c242be4

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

drivers/ethernet/nxp_imx_netc/eth_nxp_imx_netc.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6+
#define DT_DRV_COMPAT nxp_imx_netc
67

78
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL
89
#include <zephyr/logging/log.h>
@@ -32,6 +33,17 @@ LOG_MODULE_REGISTER(nxp_imx_eth);
3233
#define NETC_HAS_NO_SWITCH_TAG_SUPPORT 1
3334
#endif
3435

36+
#define DEV_CFG(_dev) ((const struct eth_nxp_imx_netc_ecam_config *)(_dev)->config)
37+
#define DEV_DATA(_dev) ((struct eth_nxp_imx_netc_ecam_data *)(_dev)->data)
38+
39+
struct eth_nxp_imx_netc_ecam_config {
40+
DEVICE_MMIO_NAMED_ROM(base);
41+
};
42+
43+
struct eth_nxp_imx_netc_ecam_data {
44+
DEVICE_MMIO_NAMED_RAM(base);
45+
};
46+
3547
const struct device *netc_dev_list[NETC_DRV_MAX_INST_SUPPORT];
3648

3749
#ifdef CONFIG_PTP_CLOCK_NXP_NETC
@@ -529,3 +541,22 @@ int netc_eth_set_config(const struct device *dev, enum ethernet_config_type type
529541

530542
return ret;
531543
}
544+
545+
static int eth_nxp_imx_netc_ecam_init(const struct device *dev)
546+
{
547+
DEVICE_MMIO_NAMED_MAP(dev, base, K_MEM_CACHE_NONE | K_MEM_DIRECT_MAP);
548+
549+
return 0;
550+
}
551+
552+
#define ETH_NXP_IMX_NETC_ECAM_INIT(inst) \
553+
static struct eth_nxp_imx_netc_ecam_data eth_nxp_imx_netc_ecam_data_##inst; \
554+
static const struct eth_nxp_imx_netc_ecam_config eth_nxp_imx_netc_ecam_config_##inst = { \
555+
DEVICE_MMIO_NAMED_ROM_INIT(base, DT_DRV_INST(inst)), \
556+
}; \
557+
DEVICE_DT_INST_DEFINE(inst, eth_nxp_imx_netc_ecam_init, NULL, \
558+
&eth_nxp_imx_netc_ecam_data_##inst, \
559+
&eth_nxp_imx_netc_ecam_config_##inst, POST_KERNEL, \
560+
CONFIG_ETH_INIT_PRIORITY, NULL);
561+
562+
DT_INST_FOREACH_STATUS_OKAY(ETH_NXP_IMX_NETC_ECAM_INIT)

drivers/ethernet/nxp_imx_netc/eth_nxp_imx_netc_priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
}
8787

8888
struct netc_eth_config {
89+
DEVICE_MMIO_NAMED_ROM(base);
8990
uint16_t si_idx;
9091
const struct device *phy_dev;
9192
netc_hw_mii_mode_t phy_mode;
@@ -109,6 +110,7 @@ struct netc_eth_config {
109110
typedef uint8_t rx_buffer_t[NETC_RX_RING_BUF_SIZE_ALIGN];
110111

111112
struct netc_eth_data {
113+
DEVICE_MMIO_NAMED_RAM(base);
112114
ep_handle_t handle;
113115
struct net_if *iface;
114116
uint8_t mac_addr[6];

0 commit comments

Comments
 (0)