From cf45ab85d2d60b65f4a05fca509be09eabd28ade Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Fri, 18 Oct 2024 17:51:14 +0200 Subject: [PATCH] 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 --- boards/arduino/opta/CMakeLists.txt | 2 +- boards/arduino/opta/arduino_opta-common.dtsi | 4 ++ .../opta/arduino_opta_stm32h747xx_m7.dts | 19 ++------ .../arduino_opta_stm32h747xx_m7_defconfig | 4 -- boards/arduino/opta/board_gpio_hse.c | 30 ------------ boards/arduino/opta/board_gpio_init.c | 46 +++++++++++++++++++ .../arduino_opta_stm32h747xx_m7.overlay | 9 ++++ 7 files changed, 65 insertions(+), 49 deletions(-) delete mode 100644 boards/arduino/opta/board_gpio_hse.c create mode 100644 boards/arduino/opta/board_gpio_init.c create mode 100644 samples/net/telnet/boards/arduino_opta_stm32h747xx_m7.overlay diff --git a/boards/arduino/opta/CMakeLists.txt b/boards/arduino/opta/CMakeLists.txt index c4483abeb70..07d2bfea9bc 100644 --- a/boards/arduino/opta/CMakeLists.txt +++ b/boards/arduino/opta/CMakeLists.txt @@ -1,4 +1,4 @@ # Copyright (c) 2021 STMicroelectronics # SPDX-License-Identifier: Apache-2.0 -zephyr_sources(board_gpio_hse.c) +zephyr_sources(board_gpio_init.c) diff --git a/boards/arduino/opta/arduino_opta-common.dtsi b/boards/arduino/opta/arduino_opta-common.dtsi index dcf957265c4..add572d6cbc 100644 --- a/boards/arduino/opta/arduino_opta-common.dtsi +++ b/boards/arduino/opta/arduino_opta-common.dtsi @@ -87,3 +87,7 @@ &mailbox { status = "okay"; }; + +&rng { + status = "okay"; +}; diff --git a/boards/arduino/opta/arduino_opta_stm32h747xx_m7.dts b/boards/arduino/opta/arduino_opta_stm32h747xx_m7.dts index e26a16c7858..7ddf514eff5 100644 --- a/boards/arduino/opta/arduino_opta_stm32h747xx_m7.dts +++ b/boards/arduino/opta/arduino_opta_stm32h747xx_m7.dts @@ -24,14 +24,6 @@ zephyr,code-partition = &slot0_partition; }; - ethernet_phy_en: ethernet_phy_en { - compatible = "regulator-fixed"; - regulator-name = "ethernet-phy-reset-release"; - enable-gpios = <&gpioj 15 GPIO_ACTIVE_HIGH>; - regulator-boot-on; - status = "okay"; - }; - sdram2: sdram@d0000000 { compatible = "zephyr,memory-region", "mmio-sram"; device_type = "memory"; @@ -101,6 +93,7 @@ zephyr_udc0: &usbotg_fs { }; }; +/* Assign USB to M7 by default */ &usbotg_fs { status = "okay"; }; @@ -109,10 +102,7 @@ zephyr_udc0: &usbotg_fs { status = "disabled"; }; -&cdc_acm_uart0 { - status = "okay"; -}; - +/* Assign ethernet to M7 by default */ &mac { pinctrl-0 = < ð_ref_clk_pa1 @@ -128,9 +118,9 @@ zephyr_udc0: &usbotg_fs { }; &mdio { - status = "okay"; pinctrl-0 = <ð_mdio_pa2 ð_mdc_pc1>; pinctrl-names = "default"; + status = "okay"; ethernet-phy@0 { compatible = "ethernet-phy"; @@ -139,6 +129,7 @@ zephyr_udc0: &usbotg_fs { }; }; -&rng { +/* Assign USB serial (ACM) to M7 to have a working console out of the box */ +&cdc_acm_uart0 { status = "okay"; }; diff --git a/boards/arduino/opta/arduino_opta_stm32h747xx_m7_defconfig b/boards/arduino/opta/arduino_opta_stm32h747xx_m7_defconfig index a0dd727422e..dcb6d1edc87 100644 --- a/boards/arduino/opta/arduino_opta_stm32h747xx_m7_defconfig +++ b/boards/arduino/opta/arduino_opta_stm32h747xx_m7_defconfig @@ -31,7 +31,3 @@ CONFIG_UART_LINE_CTRL=y # Enable USB Stack (needed for the console to work) CONFIG_USB_DEVICE_STACK=y - -# Enable regulator (needed to enable eth) -CONFIG_REGULATOR=y -CONFIG_REGULATOR_FIXED=y diff --git a/boards/arduino/opta/board_gpio_hse.c b/boards/arduino/opta/board_gpio_hse.c deleted file mode 100644 index 2ee45f52dad..00000000000 --- a/boards/arduino/opta/board_gpio_hse.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2024 DNDG srl - * SPDX-License-Identifier: Apache-2.0 - */ - -#include -#include -#include -#include - -static int board_gpio_hse(void) -{ - /* The external oscillator that drives the HSE clock should be enabled - * by setting the GPIOI1 pin. This function is registered at priority - * RE_KERNEL_1 to be executed before the standard STM clock - * setup code. - */ - - LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOH); - - LL_GPIO_SetPinMode(GPIOH, LL_GPIO_PIN_1, LL_GPIO_MODE_OUTPUT); - LL_GPIO_SetPinSpeed(GPIOH, LL_GPIO_PIN_1, LL_GPIO_SPEED_FREQ_LOW); - LL_GPIO_SetPinOutputType(GPIOH, LL_GPIO_PIN_1, LL_GPIO_OUTPUT_PUSHPULL); - LL_GPIO_SetPinPull(GPIOH, LL_GPIO_PIN_1, LL_GPIO_PULL_UP); - LL_GPIO_SetOutputPin(GPIOH, LL_GPIO_PIN_1); - - return 0; -} - -SYS_INIT(board_gpio_hse, PRE_KERNEL_1, 0); diff --git a/boards/arduino/opta/board_gpio_init.c b/boards/arduino/opta/board_gpio_init.c new file mode 100644 index 00000000000..fcf8f6872a6 --- /dev/null +++ b/boards/arduino/opta/board_gpio_init.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 DNDG srl + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include + +static int board_gpio_init(void) +{ + /* The external oscillator that drives the HSE clock should be enabled + * by setting the GPIOI1 pin. This function is registered at priority + * RE_KERNEL_1 to be executed before the standard STM clock + * setup code. + * + * Note that the HSE should be turned on by the M7 only because M4 + * is not booted by default on Opta and cannot configure the clocks + * anyway. + */ +#ifdef CONFIG_BOARD_ARDUINO_OPTA_STM32H747XX_M7 + LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOH); + LL_GPIO_SetPinMode(GPIOH, LL_GPIO_PIN_1, LL_GPIO_MODE_OUTPUT); + LL_GPIO_SetPinSpeed(GPIOH, LL_GPIO_PIN_1, LL_GPIO_SPEED_FREQ_LOW); + LL_GPIO_SetPinOutputType(GPIOH, LL_GPIO_PIN_1, LL_GPIO_OUTPUT_PUSHPULL); + LL_GPIO_SetPinPull(GPIOH, LL_GPIO_PIN_1, LL_GPIO_PULL_UP); + LL_GPIO_SetOutputPin(GPIOH, LL_GPIO_PIN_1); +#endif + + /* The ethernet adapter is enabled by settig the GPIOJ15 pin to 1. + * This is done only if the network has been explicitly configured + */ +#ifdef CONFIG_NET_L2_ETHERNET + LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOJ); + LL_GPIO_SetPinMode(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_MODE_OUTPUT); + LL_GPIO_SetPinSpeed(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_SPEED_FREQ_LOW); + LL_GPIO_SetPinOutputType(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_OUTPUT_PUSHPULL); + LL_GPIO_SetPinPull(GPIOJ, LL_GPIO_PIN_15, LL_GPIO_PULL_UP); + LL_GPIO_SetOutputPin(GPIOJ, LL_GPIO_PIN_15); +#endif + + return 0; +} + +SYS_INIT(board_gpio_init, PRE_KERNEL_1, 0); diff --git a/samples/net/telnet/boards/arduino_opta_stm32h747xx_m7.overlay b/samples/net/telnet/boards/arduino_opta_stm32h747xx_m7.overlay new file mode 100644 index 00000000000..189db2ea3e4 --- /dev/null +++ b/samples/net/telnet/boards/arduino_opta_stm32h747xx_m7.overlay @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024 DNDG srl + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&mac { + status = "okay"; +};