diff options
author | Tom Rini <trini@konsulko.com> | 2022-01-20 12:40:20 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-01-20 12:40:20 -0500 |
commit | 2d7a463e82daeba4f6a7fb59bac0fe94d6f6d3a2 (patch) | |
tree | 96e28ce689933dd4ebd120309a9caa2e02897d48 /board | |
parent | 3918376e91dac7711cf04bd06f8de80e797edfea (diff) | |
parent | 8f880c3d89432e9988b23bb7099d6360c14a206f (diff) | |
download | u-boot-2d7a463e82daeba4f6a7fb59bac0fe94d6f6d3a2.tar.gz |
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell
- fdt_support: Add fdt_for_each_node_by_compatible() helper macro
(Marek)
- turris_omnia: Fixup SATA or PCIe nodes at runtime in DT blob (Pali)
- pci_mvebu: Add support for Kirkwood PCIe controllers (Pali)
- SPL: More verifications for kwbimage in SPL (Pali)
- mvebu: Remove comphy_update_map() (Pali)
- Minor misc stuff
Diffstat (limited to 'board')
-rw-r--r-- | board/CZ.NIC/turris_mox/turris_mox.c | 48 | ||||
-rw-r--r-- | board/CZ.NIC/turris_omnia/turris_omnia.c | 91 | ||||
-rw-r--r-- | board/Marvell/octeon_ebb7304/board.c | 9 | ||||
-rw-r--r-- | board/congatec/cgtqmx8/spl.c | 8 | ||||
-rw-r--r-- | board/freescale/lx2160a/lx2160a.c | 5 |
5 files changed, 111 insertions, 50 deletions
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 3eb5cb4256..f0c5aa6a52 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -21,7 +21,6 @@ #include <linux/libfdt.h> #include <linux/string.h> #include <miiphy.h> -#include <mvebu/comphy.h> #include <spi.h> #include "mox_sp.h" @@ -49,6 +48,7 @@ int board_fix_fdt(void *blob) enum fdt_status status_pcie, status_eth1; u8 topology[MAX_MOX_MODULES]; int i, size, ret; + bool eth1_sgmii; /* * SPI driver is not loaded in driver model yet, but we have to find out @@ -69,6 +69,7 @@ int board_fix_fdt(void *blob) status_pcie = FDT_STATUS_DISABLED; status_eth1 = FDT_STATUS_DISABLED; + eth1_sgmii = false; for (i = 0; i < MAX_MOX_MODULES; ++i) { writel(0x0, ARMADA_37XX_SPI_DOUT); @@ -82,6 +83,10 @@ int board_fix_fdt(void *blob) topology[i] &= 0xf; + if (topology[i] == MOX_MODULE_SFP && + status_pcie == FDT_STATUS_DISABLED) + eth1_sgmii = true; + if (topology[i] == MOX_MODULE_SFP || topology[i] == MOX_MODULE_TOPAZ || topology[i] == MOX_MODULE_PERIDOT) @@ -98,6 +103,15 @@ int board_fix_fdt(void *blob) printf("Cannot set status for eth1 in U-Boot's device tree: %s!\n", fdt_strerror(ret)); + if (eth1_sgmii) { + ret = fdt_path_offset(blob, "ethernet1"); + if (ret >= 0) + ret = fdt_setprop_string(blob, ret, "phy-mode", "sgmii"); + if (ret < 0) + printf("Cannot set phy-mode for eth1 to sgmii in U-Boot device tree: %s!\n", + fdt_strerror(ret)); + } + if (size > 1 && (topology[1] == MOX_MODULE_PCI || topology[1] == MOX_MODULE_USB3 || topology[1] == MOX_MODULE_PASSPCI)) @@ -199,38 +213,6 @@ static int mox_get_topology(const u8 **ptopology, int *psize, int *pis_sd) return 0; } -int comphy_update_map(struct comphy_map *serdes_map, int count) -{ - int ret, i, size, sfpindex = -1, swindex = -1; - const u8 *topology; - - ret = mox_get_topology(&topology, &size, NULL); - if (ret) - return ret; - - for (i = 0; i < size; ++i) { - if (topology[i] == MOX_MODULE_SFP && sfpindex == -1) - sfpindex = i; - else if ((topology[i] == MOX_MODULE_TOPAZ || - topology[i] == MOX_MODULE_PERIDOT) && - swindex == -1) - swindex = i; - } - - if (sfpindex >= 0 && swindex >= 0) { - if (sfpindex < swindex) - serdes_map[0].speed = COMPHY_SPEED_1_25G; - else - serdes_map[0].speed = COMPHY_SPEED_3_125G; - } else if (sfpindex >= 0) { - serdes_map[0].speed = COMPHY_SPEED_1_25G; - } else if (swindex >= 0) { - serdes_map[0].speed = COMPHY_SPEED_3_125G; - } - - return 0; -} - #define SW_SMI_CMD_R(d, r) (0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) #define SW_SMI_CMD_W(d, r) (0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index ae24d14b76..33cec6587e 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -490,6 +490,86 @@ void spl_board_init(void) } } +#if IS_ENABLED(CONFIG_OF_BOARD_FIXUP) || IS_ENABLED(CONFIG_OF_BOARD_SETUP) + +static void fixup_serdes_0_nodes(void *blob) +{ + bool mode_sata; + int node; + + /* + * Determine if SerDes 0 is configured to SATA mode. + * We do this instead of calling omnia_detect_sata() to avoid another + * call to the MCU. By this time the common PHYs are initialized (it is + * done in SPL), so we can read this common PHY register. + */ + mode_sata = (readl(MVEBU_REGISTER(0x183fc)) & GENMASK(3, 0)) == 2; + + /* + * We're either adding status = "disabled" property, or changing + * status = "okay" to status = "disabled". In both cases we'll need more + * space. Increase the size a little. + */ + if (fdt_increase_size(blob, 32) < 0) { + printf("Cannot increase FDT size!\n"); + return; + } + + /* If mSATA card is not present, disable SATA DT node */ + if (!mode_sata) { + fdt_for_each_node_by_compatible(node, blob, -1, + "marvell,armada-380-ahci") { + if (!fdtdec_get_is_enabled(blob, node)) + continue; + + if (fdt_status_disabled(blob, node) < 0) + printf("Cannot disable SATA DT node!\n"); + else + debug("Disabled SATA DT node\n"); + + break; + } + + return; + } + + /* Otherwise disable PCIe port 0 DT node (MiniPCIe / mSATA port) */ + fdt_for_each_node_by_compatible(node, blob, -1, + "marvell,armada-370-pcie") { + int port; + + if (!fdtdec_get_is_enabled(blob, node)) + continue; + + fdt_for_each_subnode (port, blob, node) { + if (!fdtdec_get_is_enabled(blob, port)) + continue; + + if (fdtdec_get_int(blob, port, "marvell,pcie-port", + -1) != 0) + continue; + + if (fdt_status_disabled(blob, port) < 0) + printf("Cannot disable PCIe port 0 DT node!\n"); + else + debug("Disabled PCIe port 0 DT node\n"); + + return; + } + } +} + +#endif + +#if IS_ENABLED(CONFIG_OF_BOARD_FIXUP) +int board_fix_fdt(void *blob) +{ + fixup_serdes_0_nodes(blob); + + return 0; +} +#endif + int board_init(void) { /* address of boot parameters */ @@ -694,7 +774,7 @@ static bool fixup_mtd_partitions(void *blob, int offset, struct mtd_info *mtd) return true; } -int ft_board_setup(void *blob, struct bd_info *bd) +static void fixup_spi_nor_partitions(void *blob) { struct mtd_info *mtd; int node; @@ -711,12 +791,19 @@ int ft_board_setup(void *blob, struct bd_info *bd) goto fail; put_mtd_device(mtd); - return 0; + return; fail: printf("Failed fixing SPI NOR partitions!\n"); if (!IS_ERR_OR_NULL(mtd)) put_mtd_device(mtd); +} + +int ft_board_setup(void *blob, struct bd_info *bd) +{ + fixup_spi_nor_partitions(blob); + fixup_serdes_0_nodes(blob); + return 0; } #endif diff --git a/board/Marvell/octeon_ebb7304/board.c b/board/Marvell/octeon_ebb7304/board.c index c6c7c13483..5fd84b260b 100644 --- a/board/Marvell/octeon_ebb7304/board.c +++ b/board/Marvell/octeon_ebb7304/board.c @@ -103,9 +103,7 @@ static int get_lmac_fdt_node(const void *fdt, int search_node, int search_bgx, i int parent; /* Iterate through all bgx ports */ - node = -1; - while ((node = fdt_node_offset_by_compatible((void *)fdt, node, - compat)) >= 0) { + fdt_for_each_node_by_compatible(node, (void *)fdt, -1, compat) { /* Get the node and bgx from the physical address */ parent = fdt_parent_offset(fdt, node); reg = fdt_getprop(fdt, parent, "reg", &len); @@ -146,9 +144,8 @@ static int get_mix_fdt_node(const void *fdt, int search_node, int search_index) int node; /* Iterate through all the mix fdt nodes */ - node = -1; - while ((node = fdt_node_offset_by_compatible((void *)fdt, node, - "cavium,octeon-7890-mix")) >= 0) { + fdt_for_each_node_by_compatible(node, (void *)fdt, -1, + "cavium,octeon-7890-mix") { int parent; int len; const char *name; diff --git a/board/congatec/cgtqmx8/spl.c b/board/congatec/cgtqmx8/spl.c index 37b7221c52..dea34e4dc6 100644 --- a/board/congatec/cgtqmx8/spl.c +++ b/board/congatec/cgtqmx8/spl.c @@ -6,6 +6,7 @@ #include <common.h> #include <dm.h> +#include <fdt_support.h> #include <init.h> #include <log.h> #include <spl.h> @@ -29,13 +30,10 @@ void spl_board_init(void) continue; } - offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "nxp,imx8-pd"); - while (offset != -FDT_ERR_NOTFOUND) { + fdt_for_each_node_by_compatible(offset, gd->fdt_blob, -1, + "nxp,imx8-pd") lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset), NULL, NULL, true); - offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset, - "nxp,imx8-pd"); - } uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev); diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c index bda665624d..c9835f9299 100644 --- a/board/freescale/lx2160a/lx2160a.c +++ b/board/freescale/lx2160a/lx2160a.c @@ -123,8 +123,7 @@ int board_fix_fdt(void *fdt) if (IS_SVR_REV(get_svr(), 1, 0)) return 0; - off = fdt_node_offset_by_compatible(fdt, -1, "fsl,lx2160a-pcie"); - while (off != -FDT_ERR_NOTFOUND) { + fdt_for_each_node_by_compatible(off, fdt, -1, "fsl,lx2160a-pcie") { fdt_setprop(fdt, off, "compatible", "fsl,ls-pcie", strlen("fsl,ls-pcie") + 1); @@ -166,8 +165,6 @@ int board_fix_fdt(void *fdt) } fdt_setprop(fdt, off, "reg-names", reg_names, names_len); - off = fdt_node_offset_by_compatible(fdt, off, - "fsl,lx2160a-pcie"); } return 0; |