Skip to content

Commit cf45ab8

Browse files
fogzotnashif
authored andcommitted
boards: opta: ethernet reorganization
This set of changes reorganize the ethernet configuration by removing the use a regulator to enable the PHY: the correct GPIO pin is set in code only if the network has been configured via CONFIG_NET_L2_ETHERNET. Signed-off-by: Federico Di Gregorio <[email protected]>
1 parent 516886b commit cf45ab8

File tree

7 files changed

+65
-49
lines changed

7 files changed

+65
-49
lines changed

boards/arduino/opta/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Copyright (c) 2021 STMicroelectronics
22
# SPDX-License-Identifier: Apache-2.0
33

4-
zephyr_sources(board_gpio_hse.c)
4+
zephyr_sources(board_gpio_init.c)

boards/arduino/opta/arduino_opta-common.dtsi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,7 @@
8787
&mailbox {
8888
status = "okay";
8989
};
90+
91+
&rng {
92+
status = "okay";
93+
};

boards/arduino/opta/arduino_opta_stm32h747xx_m7.dts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@
2424
zephyr,code-partition = &slot0_partition;
2525
};
2626

27-
ethernet_phy_en: ethernet_phy_en {
28-
compatible = "regulator-fixed";
29-
regulator-name = "ethernet-phy-reset-release";
30-
enable-gpios = <&gpioj 15 GPIO_ACTIVE_HIGH>;
31-
regulator-boot-on;
32-
status = "okay";
33-
};
34-
3527
sdram2: sdram@d0000000 {
3628
compatible = "zephyr,memory-region", "mmio-sram";
3729
device_type = "memory";
@@ -101,6 +93,7 @@ zephyr_udc0: &usbotg_fs {
10193
};
10294
};
10395

96+
/* Assign USB to M7 by default */
10497
&usbotg_fs {
10598
status = "okay";
10699
};
@@ -109,10 +102,7 @@ zephyr_udc0: &usbotg_fs {
109102
status = "disabled";
110103
};
111104

112-
&cdc_acm_uart0 {
113-
status = "okay";
114-
};
115-
105+
/* Assign ethernet to M7 by default */
116106
&mac {
117107
pinctrl-0 = <
118108
&eth_ref_clk_pa1
@@ -128,9 +118,9 @@ zephyr_udc0: &usbotg_fs {
128118
};
129119

130120
&mdio {
131-
status = "okay";
132121
pinctrl-0 = <&eth_mdio_pa2 &eth_mdc_pc1>;
133122
pinctrl-names = "default";
123+
status = "okay";
134124

135125
ethernet-phy@0 {
136126
compatible = "ethernet-phy";
@@ -139,6 +129,7 @@ zephyr_udc0: &usbotg_fs {
139129
};
140130
};
141131

142-
&rng {
132+
/* Assign USB serial (ACM) to M7 to have a working console out of the box */
133+
&cdc_acm_uart0 {
143134
status = "okay";
144135
};

boards/arduino/opta/arduino_opta_stm32h747xx_m7_defconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,3 @@ CONFIG_UART_LINE_CTRL=y
3131

3232
# Enable USB Stack (needed for the console to work)
3333
CONFIG_USB_DEVICE_STACK=y
34-
35-
# Enable regulator (needed to enable eth)
36-
CONFIG_REGULATOR=y
37-
CONFIG_REGULATOR_FIXED=y

boards/arduino/opta/board_gpio_hse.c

Lines changed: 0 additions & 30 deletions
This file was deleted.

boards/arduino/opta/board_gpio_init.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2024 DNDG srl
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/kernel.h>
7+
#include <zephyr/init.h>
8+
#include <stm32h7xx_ll_bus.h>
9+
#include <stm32h7xx_ll_gpio.h>
10+
11+
static int board_gpio_init(void)
12+
{
13+
/* The external oscillator that drives the HSE clock should be enabled
14+
* by setting the GPIOI1 pin. This function is registered at priority
15+
* RE_KERNEL_1 to be executed before the standard STM clock
16+
* setup code.
17+
*
18+
* Note that the HSE should be turned on by the M7 only because M4
19+
* is not booted by default on Opta and cannot configure the clocks
20+
* anyway.
21+
*/
22+
#ifdef CONFIG_BOARD_ARDUINO_OPTA_STM32H747XX_M7
23+
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOH);
24+
LL_GPIO_SetPinMode(GPIOH, LL_GPIO_PIN_1, LL_GPIO_MODE_OUTPUT);
25+
LL_GPIO_SetPinSpeed(GPIOH, LL_GPIO_PIN_1, LL_GPIO_SPEED_FREQ_LOW);
26+
LL_GPIO_SetPinOutputType(GPIOH, LL_GPIO_PIN_1, LL_GPIO_OUTPUT_PUSHPULL);
27+
LL_GPIO_SetPinPull(GPIOH, LL_GPIO_PIN_1, LL_GPIO_PULL_UP);
28+
LL_GPIO_SetOutputPin(GPIOH, LL_GPIO_PIN_1);
29+
#endif
30+
31+
/* The ethernet adapter is enabled by settig the GPIOJ15 pin to 1.
32+
* This is done only if the network has been explicitly configured
33+
*/
34+
#ifdef CONFIG_NET_L2_ETHERNET
35+
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOJ);
36+
LL_GPIO_SetPinMode(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_MODE_OUTPUT);
37+
LL_GPIO_SetPinSpeed(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_SPEED_FREQ_LOW);
38+
LL_GPIO_SetPinOutputType(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_OUTPUT_PUSHPULL);
39+
LL_GPIO_SetPinPull(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_PULL_UP);
40+
LL_GPIO_SetOutputPin(GPIOJ, LL_GPIO_PIN_15);
41+
#endif
42+
43+
return 0;
44+
}
45+
46+
SYS_INIT(board_gpio_init, PRE_KERNEL_1, 0);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright (c) 2024 DNDG srl
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&mac {
8+
status = "okay";
9+
};

0 commit comments

Comments
 (0)