Jagan Teki | c0f218b | 2021-03-16 21:52:03 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
| 4 | * Copyright (C) 2020 Engicam S.r.l. |
| 5 | * Copyright (C) 2020 Amarula Solutions(India) |
| 6 | * Author: Jagan Teki <jagan@amarulasolutions.com> |
| 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <env.h> |
| 11 | #include <env_internal.h> |
| 12 | #include <syscon.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <asm/arch/sys_proto.h> |
| 15 | #include <power/regulator.h> |
| 16 | |
Jagan Teki | c0f218b | 2021-03-16 21:52:03 +0530 | [diff] [blame] | 17 | int checkboard(void) |
| 18 | { |
| 19 | char *mode; |
| 20 | const char *fdt_compat; |
| 21 | int fdt_compat_len; |
| 22 | |
| 23 | if (IS_ENABLED(CONFIG_TFABOOT)) |
| 24 | mode = "trusted"; |
| 25 | else |
| 26 | mode = "basic"; |
| 27 | |
| 28 | printf("Board: stm32mp1 in %s mode", mode); |
Patrick Delaunay | fbb0715 | 2022-05-19 09:07:30 +0200 | [diff] [blame] | 29 | fdt_compat = ofnode_get_property(ofnode_root(), "compatible", |
| 30 | &fdt_compat_len); |
Jagan Teki | c0f218b | 2021-03-16 21:52:03 +0530 | [diff] [blame] | 31 | if (fdt_compat && fdt_compat_len) |
| 32 | printf(" (%s)", fdt_compat); |
| 33 | puts("\n"); |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | /* board dependent setup after realloc */ |
| 39 | int board_init(void) |
| 40 | { |
Jagan Teki | c0f218b | 2021-03-16 21:52:03 +0530 | [diff] [blame] | 41 | if (IS_ENABLED(CONFIG_DM_REGULATOR)) |
| 42 | regulators_enable_boot_on(_DEBUG); |
| 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | int board_late_init(void) |
| 48 | { |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | enum env_location env_get_location(enum env_operation op, int prio) |
| 53 | { |
| 54 | u32 bootmode = get_bootmode(); |
| 55 | |
| 56 | if (prio) |
| 57 | return ENVL_UNKNOWN; |
| 58 | |
| 59 | switch (bootmode & TAMP_BOOT_DEVICE_MASK) { |
| 60 | case BOOT_FLASH_SD: |
| 61 | case BOOT_FLASH_EMMC: |
| 62 | if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC)) |
| 63 | return ENVL_MMC; |
| 64 | else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4)) |
| 65 | return ENVL_EXT4; |
| 66 | else |
| 67 | return ENVL_NOWHERE; |
| 68 | |
| 69 | case BOOT_FLASH_NAND: |
| 70 | case BOOT_FLASH_SPINAND: |
Simon Glass | bd3ebf6 | 2023-02-05 15:39:48 -0700 | [diff] [blame] | 71 | if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI)) |
Jagan Teki | c0f218b | 2021-03-16 21:52:03 +0530 | [diff] [blame] | 72 | return ENVL_UBI; |
| 73 | else |
| 74 | return ENVL_NOWHERE; |
| 75 | |
| 76 | case BOOT_FLASH_NOR: |
| 77 | if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH)) |
| 78 | return ENVL_SPI_FLASH; |
| 79 | else |
| 80 | return ENVL_NOWHERE; |
| 81 | |
| 82 | default: |
| 83 | return ENVL_NOWHERE; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | const char *env_ext4_get_intf(void) |
| 88 | { |
| 89 | u32 bootmode = get_bootmode(); |
| 90 | |
| 91 | switch (bootmode & TAMP_BOOT_DEVICE_MASK) { |
| 92 | case BOOT_FLASH_SD: |
| 93 | case BOOT_FLASH_EMMC: |
| 94 | return "mmc"; |
| 95 | default: |
| 96 | return ""; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | const char *env_ext4_get_dev_part(void) |
| 101 | { |
| 102 | static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"}; |
| 103 | u32 bootmode = get_bootmode(); |
| 104 | |
| 105 | return dev_part[(bootmode & TAMP_BOOT_INSTANCE_MASK) - 1]; |
| 106 | } |
| 107 | |
| 108 | int mmc_get_env_dev(void) |
| 109 | { |
| 110 | u32 bootmode = get_bootmode(); |
| 111 | |
| 112 | return (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1; |
| 113 | } |
| 114 | |
| 115 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 116 | int ft_board_setup(void *blob, struct bd_info *bd) |
| 117 | { |
| 118 | return 0; |
| 119 | } |
| 120 | #endif |