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