diff options
author | Pali Rohár <pali@kernel.org> | 2022-03-02 12:47:55 +0100 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2022-05-02 07:28:25 +0200 |
commit | 1da19dcf3b08db266043960f721d34d13ccc221c (patch) | |
tree | 7d82492bec11a50c81519e5008b89f170f2b4acd /board/CZ.NIC/turris_omnia/turris_omnia.c | |
parent | 8ead243ecc2c5073cff3bd9dfb4c4fcab8c2a94a (diff) | |
download | u-boot-1da19dcf3b08db266043960f721d34d13ccc221c.tar.gz u-boot-1da19dcf3b08db266043960f721d34d13ccc221c.tar.bz2 u-boot-1da19dcf3b08db266043960f721d34d13ccc221c.zip |
arm: mvebu: turris_omnia: Allow to configure mSATA slot via env variable
Some PCIe-based MiniPCIe cards are broken and they do not ground PIN 43
which is required by PCIe mini CEM specs. Such broken cards are incorrectly
detected as mSATA cards because SATA specs requires that PIN 43 on mSATA
cards has to be disconnected.
PIN 43 on Turris Omnia is used only for MiniPCIe/mSATA card detection by
software in U-Boot SPL. Allow to override that U-Boot SPL detection by a
new "omnia_msata_slot" env variable (to value "pcie" or "sata") so broken
MiniPCIe cards can be used in combo mSATA/MiniPCIe slot too.
As configuration of PCIe vs SATA functionality is done in U-Boot SPL,
it is required to change env variable in permanent storage and reset the
board to take effect.
To force PCIe mode for broken MiniPCIe cards, call U-Boot commands:
=> setenv omnia_msata_slot pcie
=> saveenv
=> reset
Signed-off-by: Pali Rohár <pali@kernel.org>
Diffstat (limited to 'board/CZ.NIC/turris_omnia/turris_omnia.c')
-rw-r--r-- | board/CZ.NIC/turris_omnia/turris_omnia.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c index 25902742e3..4753f9b2c8 100644 --- a/board/CZ.NIC/turris_omnia/turris_omnia.c +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c @@ -200,13 +200,25 @@ static bool disable_mcu_watchdog(void) return true; } -static bool omnia_detect_sata(void) +static bool omnia_detect_sata(const char *msata_slot) { int ret; u16 stsword; puts("MiniPCIe/mSATA card detection... "); + if (msata_slot) { + if (strcmp(msata_slot, "pcie") == 0) { + puts("forced to MiniPCIe via env\n"); + return false; + } else if (strcmp(msata_slot, "sata") == 0) { + puts("forced to mSATA via env\n"); + return true; + } else if (strcmp(msata_slot, "auto") != 0) { + printf("unsupported env value '%s', fallback to... ", msata_slot); + } + } + ret = omnia_mcu_read(CMD_GET_STATUS_WORD, &stsword, sizeof(stsword)); if (ret) { printf("omnia_mcu_read failed: %i, defaulting to MiniPCIe card\n", @@ -239,7 +251,18 @@ void *env_sf_get_env_addr(void) int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count) { - if (omnia_detect_sata()) { +#ifdef CONFIG_SPL_ENV_SUPPORT + /* Do not use env_load() as malloc() pool is too small at this stage */ + bool has_env = (env_init() == 0); +#endif + const char *env_value = NULL; + +#ifdef CONFIG_SPL_ENV_SUPPORT + /* beware that env_get() returns static allocated memory */ + env_value = has_env ? env_get("omnia_msata_slot") : NULL; +#endif + + if (omnia_detect_sata(env_value)) { /* Change SerDes for first mPCIe port (mSATA) from PCIe to SATA */ board_serdes_map[0].serdes_type = SATA0; board_serdes_map[0].serdes_speed = SERDES_SPEED_6_GBPS; |