aboutsummaryrefslogtreecommitdiffstats
path: root/board/dhelectronics
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2024-06-06 15:01:48 +0200
committerPatrice Chotard <patrice.chotard@foss.st.com>2024-06-18 08:55:52 +0200
commitf4a565104425032be537aef14cd2617c274e7bdf (patch)
tree35dfe0435b9e7ab2e7da44b37cb96bd252a54a4a /board/dhelectronics
parentff51ef85d66467a6b89d28f7ec3f9b418d2cf5d7 (diff)
downloadu-boot-f4a565104425032be537aef14cd2617c274e7bdf.tar.gz
ARM: dts: stm32: Auto-detect second MAC on STM32MP15xx DH electronics DHCOM
Test whether this system is compatible with STM32MP15xx DHCOM SoM, if so, test whether R292 pull up is populated on pin PC3, which is an indication that the second MAC chip, KS8851-16MLL, is populated. Use this information to patch 'status' DT property into the second ethernet MAC DT node and enable/disable the MAC on systems where the chip is/isn't populated respectively. Use spl_perform_fixups() to patch the U-Boot proper DT from SPL and ft_board_setup() to patch Linux DT from U-Boot proper. This way both software components are configured the same way. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Diffstat (limited to 'board/dhelectronics')
-rw-r--r--board/dhelectronics/dh_stm32mp1/board.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index 20c9d70737e..ebd45f9053f 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -37,6 +37,7 @@
#include <power/regulator.h>
#include <remoteproc.h>
#include <reset.h>
+#include <spl.h>
#include <syscon.h>
#include <usb.h>
#include <usb/dwc2_udc.h>
@@ -672,12 +673,69 @@ void board_quiesce_devices(void)
#endif
}
+static void dh_stm32_ks8851_fixup(void *blob)
+{
+ struct gpio_desc ks8851intrn;
+ bool compatible = false;
+ int ks8851intrn_value;
+ const char *prop;
+ ofnode node;
+ int idx = 0;
+ int offset;
+ int ret;
+
+ /* Do nothing if not STM32MP15xx DHCOM SoM */
+ while ((prop = fdt_stringlist_get(blob, 0, "compatible", idx++, NULL))) {
+ if (!strstr(prop, "dhcom-som"))
+ continue;
+ compatible = true;
+ break;
+ }
+
+ if (!compatible)
+ return;
+
+ /*
+ * Read state of INTRN pull up resistor, if this pull up is populated,
+ * KS8851-16MLL is populated as well and should be enabled, otherwise
+ * it should be disabled.
+ */
+ node = ofnode_path("/config");
+ if (!ofnode_valid(node))
+ return;
+
+ ret = gpio_request_by_name_nodev(node, "dh,mac-coding-gpios", 0,
+ &ks8851intrn, GPIOD_IS_IN);
+ if (ret)
+ return;
+
+ ks8851intrn_value = dm_gpio_get_value(&ks8851intrn);
+
+ dm_gpio_free(NULL, &ks8851intrn);
+
+ /* Set the 'status' property into KS8851-16MLL DT node. */
+ offset = fdt_path_offset(blob, "ethernet1");
+ ret = fdt_node_check_compatible(blob, offset, "micrel,ks8851-mll");
+ if (ret) /* Not compatible */
+ return;
+
+ /* Add a bit of extra space for new 'status' property */
+ ret = fdt_shrink_to_minimum(blob, 4096);
+ if (!ret)
+ return;
+
+ fdt_setprop_string(blob, offset, "status",
+ ks8851intrn_value ? "okay" : "disabled");
+}
+
#if defined(CONFIG_OF_BOARD_SETUP)
int ft_board_setup(void *blob, struct bd_info *bd)
{
const char *buck3path = "/soc/i2c@5c002000/stpmic@33/regulators/buck3";
int buck3off, ret, uv;
+ dh_stm32_ks8851_fixup(blob);
+
ret = board_get_regulator_buck3_nvm_uv_av96(&uv);
if (ret) /* Not Avenger96 board, do not patch Buck3 in DT. */
return 0;
@@ -698,6 +756,13 @@ int ft_board_setup(void *blob, struct bd_info *bd)
}
#endif
+#if defined(CONFIG_SPL_BUILD)
+void spl_perform_fixups(struct spl_image_info *spl_image)
+{
+ dh_stm32_ks8851_fixup(spl_image_fdt_addr(spl_image));
+}
+#endif
+
static void board_copro_image_process(ulong fw_image, size_t fw_size)
{
int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */