Skip to content

Commit b6b9453

Browse files
danieldegrassenashif
authored andcommitted
boards: mimxrt1160_evk: Enable ENET
Enable 10/100M Ethernet for RT1160 EVK Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 0fddb3e commit b6b9453

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

boards/arm/mimxrt1160_evk/Kconfig.defconfig

+7
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ endchoice
3434

3535
endif #FLASH
3636

37+
if NETWORKING
38+
39+
config NET_L2_ETHERNET
40+
default y if CPU_CORTEX_M7 # No cache memory support is required for driver
41+
42+
endif # NETWORKING
43+
3744
endif # BOARD_MIMXRT1160_EVK_CM7 || BOARD_MIMXRT1160_EVK_CM4

boards/arm/mimxrt1160_evk/mimxrt1160_evk_cm7.dts

+7
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,10 @@
114114
&edma0 {
115115
status = "okay";
116116
};
117+
118+
&enet {
119+
status = "okay";
120+
ptp {
121+
status = "okay";
122+
};
123+
};

boards/arm/mimxrt1160_evk/mimxrt1160_evk_cm7.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ supported:
2323
- i2c
2424
- pwm
2525
- dma
26+
- netif:eth

boards/arm/mimxrt1160_evk/pinmux.c

+64
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212

1313
LOG_MODULE_REGISTER(mimxrt1160_evk, LOG_LEVEL_INF);
1414

15+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET
16+
static gpio_pin_config_t enet_gpio_config = {
17+
.direction = kGPIO_DigitalOutput,
18+
.outputLogic = 0,
19+
.interruptMode = kGPIO_NoIntmode
20+
};
21+
#endif
22+
1523
static int mimxrt1160_evk_init(const struct device *dev)
1624
{
1725
ARG_UNUSED(dev);
@@ -94,7 +102,63 @@ static int mimxrt1160_evk_init(const struct device *dev)
94102
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B2_10_FLEXSPI1_A_DATA02, 0x0AU);
95103
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B2_11_FLEXSPI1_A_DATA03, 0x0AU);
96104
#endif
105+
106+
107+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET
108+
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_12_GPIO9_IO11, 0U);
109+
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_32_ENET_MDC, 0U);
110+
IOMUXC_SetPinMux(IOMUXC_GPIO_AD_33_ENET_MDIO, 0U);
111+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_02_ENET_TX_DATA00, 0U);
112+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_03_ENET_TX_DATA01, 0U);
113+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_04_ENET_TX_EN, 0U);
114+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_05_ENET_REF_CLK, 1U);
115+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_06_ENET_RX_DATA00, 1U);
116+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_07_ENET_RX_DATA01, 1U);
117+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_08_ENET_RX_EN, 0U);
118+
IOMUXC_SetPinMux(IOMUXC_GPIO_DISP_B2_09_ENET_RX_ER, 0U);
119+
IOMUXC_GPR->GPR4 = ((IOMUXC_GPR->GPR4 &
120+
(~(IOMUXC_GPR_GPR4_ENET_REF_CLK_DIR_MASK))) |
121+
IOMUXC_GPR_GPR4_ENET_REF_CLK_DIR(0x01U));
122+
IOMUXC_SetPinMux(IOMUXC_GPIO_LPSR_12_GPIO12_IO12, 0U);
123+
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_12_GPIO9_IO11, 0x06U);
124+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_02_ENET_TX_DATA00, 0x02U);
125+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_03_ENET_TX_DATA01, 0x02U);
126+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_04_ENET_TX_EN, 0x02U);
127+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_05_ENET_REF_CLK, 0x03U);
128+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_06_ENET_RX_DATA00, 0x06U);
129+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_07_ENET_RX_DATA01, 0x06U);
130+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_08_ENET_RX_EN, 0x06U);
131+
IOMUXC_SetPinConfig(IOMUXC_GPIO_DISP_B2_09_ENET_RX_ER, 0x06U);
132+
IOMUXC_SetPinConfig(IOMUXC_GPIO_LPSR_12_GPIO12_IO12, 0x0EU);
133+
134+
/* Initialize ENET_INT GPIO */
135+
GPIO_PinInit(GPIO9, 11, &enet_gpio_config);
136+
GPIO_PinInit(GPIO12, 12, &enet_gpio_config);
137+
138+
/* pull up the ENET_INT before RESET. */
139+
GPIO_WritePinOutput(GPIO9, 11, 1);
140+
GPIO_WritePinOutput(GPIO12, 12, 0);
141+
142+
/* 50M ENET_REF_CLOCK output to PHY and ENET module. */
143+
IOMUXC_GPR->GPR4 |= 0x3;
144+
#endif
145+
97146
return 0;
98147
}
99148

149+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET
150+
static int mimxrt1170_evk_phy_reset(const struct device *dev)
151+
{
152+
/* RESET PHY chip. */
153+
k_busy_wait(USEC_PER_MSEC * 10U);
154+
GPIO_WritePinOutput(GPIO12, 12, 1);
155+
156+
return 0;
157+
}
158+
#endif
159+
100160
SYS_INIT(mimxrt1160_evk_init, PRE_KERNEL_1, 0);
161+
162+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(enet), okay) && CONFIG_NET_L2_ETHERNET
163+
SYS_INIT(mimxrt1170_evk_phy_reset, POST_KERNEL, CONFIG_PHY_INIT_PRIORITY);
164+
#endif

dts/arm/nxp/nxp_rt1160_cm7.dtsi

+2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
itcm: itcm@0 {
3030
compatible = "nxp,imx-itcm";
3131
reg = <0x00000000 DT_SIZE_K(256)>;
32+
zephyr,memory-region = "ITCM";
3233
};
3334

3435
dtcm: dtcm@20000000 {
3536
compatible = "nxp,imx-dtcm";
3637
reg = <0x20000000 DT_SIZE_K(256)>;
38+
zephyr,memory-region = "DTCM";
3739
};
3840
};
3941

0 commit comments

Comments
 (0)