Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2021 Gateworks Corporation |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <cpu_func.h> |
| 8 | #include <hang.h> |
| 9 | #include <i2c.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 10 | #include <init.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 11 | #include <spl.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 12 | #include <asm/mach-imx/gpio.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 13 | #include <asm/arch/clock.h> |
| 14 | #include <asm/arch/imx8mm_pins.h> |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 15 | #include <asm/arch/imx8mn_pins.h> |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 16 | #include <asm/arch/imx8mp_pins.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 17 | #include <asm/arch/sys_proto.h> |
| 18 | #include <asm/mach-imx/boot_mode.h> |
| 19 | #include <asm/arch/ddr.h> |
| 20 | #include <asm-generic/gpio.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 21 | #include <dm/uclass.h> |
| 22 | #include <dm/device.h> |
Tim Harvey | d4daeaa | 2022-04-13 08:56:40 -0700 | [diff] [blame] | 23 | #include <linux/delay.h> |
Tim Harvey | 1b7fbf6 | 2021-06-30 16:50:02 -0700 | [diff] [blame] | 24 | #include <power/bd71837.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 25 | #include <power/mp5416.h> |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 26 | #include <power/pca9450.h> |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 27 | |
Tim Harvey | d4daeaa | 2022-04-13 08:56:40 -0700 | [diff] [blame] | 28 | #include "eeprom.h" |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 29 | #include "lpddr4_timing.h" |
| 30 | |
| 31 | #define PCIE_RSTN IMX_GPIO_NR(4, 6) |
| 32 | |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 33 | static void spl_dram_init(int size) |
| 34 | { |
| 35 | struct dram_timing_info *dram_timing; |
| 36 | |
| 37 | switch (size) { |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 38 | #ifdef CONFIG_IMX8MM |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 39 | case 512: |
| 40 | dram_timing = &dram_timing_512mb; |
| 41 | break; |
| 42 | case 1024: |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 43 | dram_timing = &dram_timing_1gb; |
| 44 | break; |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 45 | case 2048: |
Tim Harvey | 6603b5e | 2021-07-27 15:19:41 -0700 | [diff] [blame] | 46 | dram_timing = &dram_timing_2gb; |
| 47 | break; |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 48 | case 4096: |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 49 | dram_timing = &dram_timing_4gb; |
| 50 | break; |
| 51 | default: |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 52 | printf("Unknown DDR configuration: %d MiB\n", size); |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 53 | dram_timing = &dram_timing_1gb; |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 54 | size = 1024; |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 55 | #elif CONFIG_IMX8MN |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 56 | case 1024: |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 57 | dram_timing = &dram_timing_1gb_single_die; |
| 58 | break; |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 59 | case 2048: |
Tim Harvey | d4daeaa | 2022-04-13 08:56:40 -0700 | [diff] [blame] | 60 | if (!strcmp(eeprom_get_model(), "GW7902-SP466-A") || |
| 61 | !strcmp(eeprom_get_model(), "GW7902-SP466-B")) { |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 62 | dram_timing = &dram_timing_2gb_dual_die; |
| 63 | } else { |
| 64 | dram_timing = &dram_timing_2gb_single_die; |
| 65 | } |
| 66 | break; |
| 67 | default: |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 68 | printf("Unknown DDR configuration: %d MiB\n", size); |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 69 | dram_timing = &dram_timing_2gb_dual_die; |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 70 | size = 2048; |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 71 | #elif CONFIG_IMX8MP |
| 72 | case 4096: |
| 73 | dram_timing = &dram_timing_4gb_dual_die; |
| 74 | break; |
| 75 | default: |
| 76 | printf("Unknown DDR configuration: %d GiB\n", size); |
| 77 | dram_timing = &dram_timing_4gb_dual_die; |
| 78 | size = 4096; |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 79 | #endif |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 80 | } |
| 81 | |
Tim Harvey | 5cc5e19 | 2022-02-18 15:19:33 -0800 | [diff] [blame] | 82 | printf("DRAM : LPDDR4 "); |
| 83 | if (size > 512) |
| 84 | printf("%d GiB\n", size / 1024); |
| 85 | else |
| 86 | printf("%d MiB\n", size); |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 87 | ddr_init(dram_timing); |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | #define UART_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_FSEL1) |
| 91 | #define WDOG_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE) |
| 92 | |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 93 | #ifdef CONFIG_IMX8MM |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 94 | static iomux_v3_cfg_t const uart_pads[] = { |
| 95 | IMX8MM_PAD_UART2_RXD_UART2_RX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 96 | IMX8MM_PAD_UART2_TXD_UART2_TX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 97 | }; |
| 98 | |
| 99 | static iomux_v3_cfg_t const wdog_pads[] = { |
| 100 | IMX8MM_PAD_GPIO1_IO02_WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL), |
| 101 | }; |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 102 | #elif CONFIG_IMX8MN |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 103 | static const iomux_v3_cfg_t uart_pads[] = { |
| 104 | IMX8MN_PAD_UART2_RXD__UART2_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 105 | IMX8MN_PAD_UART2_TXD__UART2_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 106 | }; |
| 107 | |
| 108 | static const iomux_v3_cfg_t wdog_pads[] = { |
| 109 | IMX8MN_PAD_GPIO1_IO02__WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL), |
| 110 | }; |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 111 | #elif CONFIG_IMX8MP |
| 112 | static const iomux_v3_cfg_t uart_pads[] = { |
| 113 | MX8MP_PAD_UART2_RXD__UART2_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 114 | MX8MP_PAD_UART2_TXD__UART2_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL), |
| 115 | }; |
| 116 | |
| 117 | static const iomux_v3_cfg_t wdog_pads[] = { |
| 118 | MX8MP_PAD_GPIO1_IO02__WDOG1_WDOG_B | MUX_PAD_CTRL(WDOG_PAD_CTRL), |
| 119 | }; |
| 120 | |
Tim Harvey | 1a50e74 | 2022-02-11 10:48:56 -0800 | [diff] [blame] | 121 | #endif |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 122 | |
| 123 | int board_early_init_f(void) |
| 124 | { |
| 125 | struct wdog_regs *wdog = (struct wdog_regs *)WDOG1_BASE_ADDR; |
| 126 | |
| 127 | imx_iomux_v3_setup_multiple_pads(wdog_pads, ARRAY_SIZE(wdog_pads)); |
| 128 | |
| 129 | set_wdog_reset(wdog); |
| 130 | |
| 131 | imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads)); |
| 132 | |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Model specific PMIC adjustments necessary prior to DRAM init |
| 138 | * |
| 139 | * Note that we can not use pmic dm drivers here as we have a generic |
| 140 | * venice dt that does not have board-specific pmic's defined. |
| 141 | * |
Tim Harvey | 1b7fbf6 | 2021-06-30 16:50:02 -0700 | [diff] [blame] | 142 | * Instead we must use dm_i2c so we a helpers to give us |
| 143 | * clrsetbit functions we would otherwise have if we could use PMIC dm |
| 144 | * drivers. |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 145 | */ |
Tim Harvey | 1b7fbf6 | 2021-06-30 16:50:02 -0700 | [diff] [blame] | 146 | static int dm_i2c_clrsetbits(struct udevice *dev, uint reg, uint clr, uint set) |
| 147 | { |
| 148 | int ret; |
| 149 | u8 val; |
| 150 | |
| 151 | ret = dm_i2c_read(dev, reg, &val, 1); |
| 152 | if (ret) |
| 153 | return ret; |
| 154 | val = (val & ~clr) | set; |
| 155 | |
| 156 | return dm_i2c_write(dev, reg, &val, 1); |
| 157 | } |
| 158 | |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 159 | static int power_init_board(void) |
| 160 | { |
Tim Harvey | d4daeaa | 2022-04-13 08:56:40 -0700 | [diff] [blame] | 161 | const char *model = eeprom_get_model(); |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 162 | struct udevice *bus; |
| 163 | struct udevice *dev; |
| 164 | int ret; |
| 165 | |
| 166 | if ((!strncmp(model, "GW71", 4)) || |
| 167 | (!strncmp(model, "GW72", 4)) || |
| 168 | (!strncmp(model, "GW73", 4))) { |
Tim Harvey | d541927 | 2021-07-27 15:19:38 -0700 | [diff] [blame] | 169 | ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &bus); |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 170 | if (ret) { |
| 171 | printf("PMIC : failed I2C1 probe: %d\n", ret); |
| 172 | return ret; |
| 173 | } |
| 174 | ret = dm_i2c_probe(bus, 0x69, 0, &dev); |
| 175 | if (ret) { |
| 176 | printf("PMIC : failed probe: %d\n", ret); |
| 177 | return ret; |
| 178 | } |
| 179 | puts("PMIC : MP5416\n"); |
| 180 | |
| 181 | /* set VDD_ARM SW3 to 0.92V for 1.6GHz */ |
| 182 | dm_i2c_reg_write(dev, MP5416_VSET_SW3, |
| 183 | BIT(7) | MP5416_VSET_SW3_SVAL(920000)); |
| 184 | } |
| 185 | |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 186 | else if (!strncmp(model, "GW74", 4)) { |
| 187 | ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &bus); |
| 188 | if (ret) { |
| 189 | printf("PMIC : failed I2C1 probe: %d\n", ret); |
| 190 | return ret; |
| 191 | } |
| 192 | ret = dm_i2c_probe(bus, 0x25, 0, &dev); |
| 193 | if (ret) { |
| 194 | printf("PMIC : failed probe: %d\n", ret); |
| 195 | return ret; |
| 196 | } |
| 197 | puts("PMIC : PCA9450\n"); |
| 198 | |
| 199 | /* BUCKxOUT_DVS0/1 control BUCK123 output */ |
| 200 | dm_i2c_reg_write(dev, PCA9450_BUCK123_DVS, 0x29); |
| 201 | |
| 202 | /* Buck 1 DVS control through PMIC_STBY_REQ */ |
| 203 | dm_i2c_reg_write(dev, PCA9450_BUCK1CTRL, 0x59); |
| 204 | |
| 205 | /* Set DVS1 to 0.8v for suspend */ |
| 206 | dm_i2c_reg_write(dev, PCA9450_BUCK1OUT_DVS1, 0x10); |
| 207 | |
| 208 | /* increase VDD_DRAM to 0.95v for 3Ghz DDR */ |
| 209 | dm_i2c_reg_write(dev, PCA9450_BUCK3OUT_DVS0, 0x1C); |
| 210 | |
| 211 | /* VDD_DRAM off in suspend: B1_ENMODE=10 */ |
| 212 | dm_i2c_reg_write(dev, PCA9450_BUCK3CTRL, 0x4a); |
| 213 | |
| 214 | /* set VDD_SNVS_0V8 from default 0.85V */ |
| 215 | dm_i2c_reg_write(dev, PCA9450_LDO2CTRL, 0xC0); |
| 216 | |
| 217 | /* set WDOG_B_CFG to cold reset */ |
| 218 | dm_i2c_reg_write(dev, PCA9450_RESET_CTRL, 0xA1); |
| 219 | } |
| 220 | |
Tim Harvey | 6603b5e | 2021-07-27 15:19:41 -0700 | [diff] [blame] | 221 | else if ((!strncmp(model, "GW7901", 6)) || |
| 222 | (!strncmp(model, "GW7902", 6))) { |
| 223 | if (!strncmp(model, "GW7901", 6)) |
| 224 | ret = uclass_get_device_by_seq(UCLASS_I2C, 1, &bus); |
| 225 | else |
| 226 | ret = uclass_get_device_by_seq(UCLASS_I2C, 0, &bus); |
Tim Harvey | 1b7fbf6 | 2021-06-30 16:50:02 -0700 | [diff] [blame] | 227 | if (ret) { |
| 228 | printf("PMIC : failed I2C2 probe: %d\n", ret); |
| 229 | return ret; |
| 230 | } |
| 231 | ret = dm_i2c_probe(bus, 0x4b, 0, &dev); |
| 232 | if (ret) { |
| 233 | printf("PMIC : failed probe: %d\n", ret); |
| 234 | return ret; |
| 235 | } |
| 236 | puts("PMIC : BD71847\n"); |
| 237 | |
| 238 | /* unlock the PMIC regs */ |
| 239 | dm_i2c_reg_write(dev, BD718XX_REGLOCK, 0x1); |
| 240 | |
| 241 | /* set switchers to forced PWM mode */ |
| 242 | dm_i2c_clrsetbits(dev, BD718XX_BUCK1_CTRL, 0, 0x8); |
| 243 | dm_i2c_clrsetbits(dev, BD718XX_BUCK2_CTRL, 0, 0x8); |
| 244 | dm_i2c_clrsetbits(dev, BD718XX_1ST_NODVS_BUCK_CTRL, 0, 0x8); |
| 245 | dm_i2c_clrsetbits(dev, BD718XX_2ND_NODVS_BUCK_CTRL, 0, 0x8); |
| 246 | dm_i2c_clrsetbits(dev, BD718XX_3RD_NODVS_BUCK_CTRL, 0, 0x8); |
| 247 | dm_i2c_clrsetbits(dev, BD718XX_4TH_NODVS_BUCK_CTRL, 0, 0x8); |
| 248 | |
| 249 | /* increase VDD_0P95 (VDD_GPU/VPU/DRAM) to 0.975v for 1.5Ghz DDR */ |
| 250 | dm_i2c_reg_write(dev, BD718XX_1ST_NODVS_BUCK_VOLT, 0x83); |
| 251 | |
| 252 | /* increase VDD_SOC to 0.85v before first DRAM access */ |
| 253 | dm_i2c_reg_write(dev, BD718XX_BUCK1_VOLT_RUN, 0x0f); |
| 254 | |
| 255 | /* increase VDD_ARM to 0.92v for 800 and 1600Mhz */ |
| 256 | dm_i2c_reg_write(dev, BD718XX_BUCK2_VOLT_RUN, 0x16); |
| 257 | |
| 258 | /* Lock the PMIC regs */ |
| 259 | dm_i2c_reg_write(dev, BD718XX_REGLOCK, 0x11); |
| 260 | } |
| 261 | |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | void board_init_f(ulong dummy) |
| 266 | { |
| 267 | struct udevice *dev; |
| 268 | int ret; |
| 269 | int dram_sz; |
| 270 | |
| 271 | arch_cpu_init(); |
| 272 | |
| 273 | init_uart_clk(1); |
| 274 | |
| 275 | board_early_init_f(); |
| 276 | |
| 277 | timer_init(); |
| 278 | |
| 279 | preloader_console_init(); |
| 280 | |
| 281 | /* Clear the BSS. */ |
| 282 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 283 | |
| 284 | ret = spl_early_init(); |
| 285 | if (ret) { |
| 286 | debug("spl_early_init() failed: %d\n", ret); |
| 287 | hang(); |
| 288 | } |
| 289 | |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 290 | enable_tzc380(); |
| 291 | |
| 292 | /* need to hold PCIe switch in reset otherwise it can lock i2c bus EEPROM is on */ |
| 293 | gpio_request(PCIE_RSTN, "perst#"); |
| 294 | gpio_direction_output(PCIE_RSTN, 0); |
| 295 | |
Tim Harvey | d4daeaa | 2022-04-13 08:56:40 -0700 | [diff] [blame] | 296 | /* |
| 297 | * probe GSC device |
| 298 | * |
| 299 | * On a board with a missing/depleted backup battery for GSC, the |
| 300 | * board may be ready to probe the GSC before its firmware is |
| 301 | * running. We will wait here indefinately for the GSC EEPROM. |
| 302 | */ |
| 303 | #ifdef CONFIG_IMX8MN |
| 304 | /* |
| 305 | * IMX8MN boots quicker than IMX8MM and exposes issue |
| 306 | * where because GSC I2C state machine isn't running and its |
| 307 | * SCL/SDA are driven low the I2C driver spams 'Arbitration lost' |
| 308 | * I2C errors. |
| 309 | * |
| 310 | * TODO: Put a loop here that somehow waits for I2C CLK/DAT to be high |
| 311 | */ |
| 312 | mdelay(50); |
| 313 | #endif |
| 314 | while (1) { |
| 315 | if (!uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(gsc), &dev)) |
| 316 | break; |
| 317 | mdelay(1); |
| 318 | } |
| 319 | dram_sz = eeprom_init(0); |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 320 | |
| 321 | /* PMIC */ |
| 322 | power_init_board(); |
| 323 | |
| 324 | /* DDR initialization */ |
| 325 | spl_dram_init(dram_sz); |
| 326 | |
| 327 | board_init_r(NULL, 0); |
| 328 | } |
| 329 | |
| 330 | /* determine prioritized order of boot devices to load U-Boot from */ |
| 331 | void board_boot_order(u32 *spl_boot_list) |
| 332 | { |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 333 | int i = 0; |
| 334 | |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 335 | /* |
| 336 | * If the SPL was loaded via serial loader, we try to get |
| 337 | * U-Boot proper via USB SDP. |
| 338 | */ |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 339 | if (spl_boot_device() == BOOT_DEVICE_BOARD) { |
| 340 | #ifdef CONFIG_IMX8MM |
| 341 | spl_boot_list[i++] = BOOT_DEVICE_BOARD; |
| 342 | #else |
| 343 | spl_boot_list[i++] = BOOT_DEVICE_BOOTROM; |
| 344 | #endif |
| 345 | } |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 346 | |
| 347 | /* we have only eMMC in default venice dt */ |
Tim Harvey | 0f5717f | 2022-04-13 11:31:09 -0700 | [diff] [blame] | 348 | spl_boot_list[i++] = BOOT_DEVICE_MMC1; |
Tim Harvey | 256dba0 | 2021-03-02 14:00:21 -0800 | [diff] [blame] | 349 | } |
| 350 | |
| 351 | /* return boot device based on where the SPL was loaded from */ |
| 352 | int spl_board_boot_device(enum boot_device boot_dev_spl) |
| 353 | { |
| 354 | switch (boot_dev_spl) { |
| 355 | case USB_BOOT: |
| 356 | return BOOT_DEVICE_BOARD; |
| 357 | /* SDHC2 */ |
| 358 | case SD2_BOOT: |
| 359 | case MMC2_BOOT: |
| 360 | return BOOT_DEVICE_MMC1; |
| 361 | /* SDHC3 */ |
| 362 | case SD3_BOOT: |
| 363 | case MMC3_BOOT: |
| 364 | return BOOT_DEVICE_MMC2; |
| 365 | default: |
| 366 | return BOOT_DEVICE_NONE; |
| 367 | } |
| 368 | } |
Tim Harvey | 724d10a | 2022-03-08 10:45:39 -0800 | [diff] [blame] | 369 | |
| 370 | const char *spl_board_loader_name(u32 boot_device) |
| 371 | { |
| 372 | switch (boot_device) { |
| 373 | /* SDHC2 */ |
| 374 | case BOOT_DEVICE_MMC1: |
| 375 | return "eMMC"; |
| 376 | /* SDHC3 */ |
| 377 | case BOOT_DEVICE_MMC2: |
| 378 | return "SD card"; |
| 379 | default: |
| 380 | return NULL; |
| 381 | } |
| 382 | } |