Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
| 4 | */ |
| 5 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 6 | #include <adc.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 7 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 8 | #include <net.h> |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 9 | #include <asm/arch/stm32.h> |
| 10 | #include <asm/arch/sys_proto.h> |
| 11 | #include <asm/gpio.h> |
| 12 | #include <asm/io.h> |
| 13 | #include <bootm.h> |
| 14 | #include <clk.h> |
| 15 | #include <config.h> |
| 16 | #include <dm.h> |
| 17 | #include <dm/device.h> |
| 18 | #include <dm/uclass.h> |
| 19 | #include <env.h> |
| 20 | #include <env_internal.h> |
| 21 | #include <g_dnl.h> |
| 22 | #include <generic-phy.h> |
| 23 | #include <hang.h> |
| 24 | #include <i2c.h> |
| 25 | #include <i2c_eeprom.h> |
| 26 | #include <init.h> |
| 27 | #include <led.h> |
| 28 | #include <memalign.h> |
| 29 | #include <misc.h> |
| 30 | #include <mtd.h> |
| 31 | #include <mtd_node.h> |
| 32 | #include <netdev.h> |
| 33 | #include <phy.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 34 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 35 | #include <linux/delay.h> |
Simon Glass | bdd5f81 | 2023-09-14 18:21:46 -0600 | [diff] [blame] | 36 | #include <linux/printk.h> |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 37 | #include <power/regulator.h> |
| 38 | #include <remoteproc.h> |
| 39 | #include <reset.h> |
Marek Vasut | 3551654 | 2024-06-06 15:01:48 +0200 | [diff] [blame] | 40 | #include <spl.h> |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 41 | #include <syscon.h> |
| 42 | #include <usb.h> |
| 43 | #include <usb/dwc2_udc.h> |
| 44 | #include <watchdog.h> |
Simon Glass | 0034d96 | 2021-08-07 07:24:01 -0600 | [diff] [blame] | 45 | #include <dm/ofnode.h> |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 46 | #include "../common/dh_common.h" |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 47 | #include "../../st/common/stpmic1.h" |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 48 | |
| 49 | /* SYSCFG registers */ |
| 50 | #define SYSCFG_BOOTR 0x00 |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 51 | #define SYSCFG_IOCTRLSETR 0x18 |
| 52 | #define SYSCFG_ICNR 0x1C |
| 53 | #define SYSCFG_CMPCR 0x20 |
| 54 | #define SYSCFG_CMPENSETR 0x24 |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 55 | |
| 56 | #define SYSCFG_BOOTR_BOOT_MASK GENMASK(2, 0) |
| 57 | #define SYSCFG_BOOTR_BOOTPD_SHIFT 4 |
| 58 | |
| 59 | #define SYSCFG_IOCTRLSETR_HSLVEN_TRACE BIT(0) |
| 60 | #define SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI BIT(1) |
| 61 | #define SYSCFG_IOCTRLSETR_HSLVEN_ETH BIT(2) |
| 62 | #define SYSCFG_IOCTRLSETR_HSLVEN_SDMMC BIT(3) |
| 63 | #define SYSCFG_IOCTRLSETR_HSLVEN_SPI BIT(4) |
| 64 | |
| 65 | #define SYSCFG_CMPCR_SW_CTRL BIT(1) |
| 66 | #define SYSCFG_CMPCR_READY BIT(8) |
| 67 | |
| 68 | #define SYSCFG_CMPENSETR_MPU_EN BIT(0) |
| 69 | |
Marek Vasut | 145a876 | 2020-10-08 15:14:58 +0200 | [diff] [blame] | 70 | #define KS_CCR 0x08 |
| 71 | #define KS_CCR_EEPROM BIT(9) |
| 72 | #define KS_BE0 BIT(12) |
| 73 | #define KS_BE1 BIT(13) |
Marek Vasut | b2b31c1 | 2021-05-03 13:31:39 +0200 | [diff] [blame] | 74 | #define KS_CIDER 0xC0 |
| 75 | #define CIDER_ID 0x8870 |
Marek Vasut | 145a876 | 2020-10-08 15:14:58 +0200 | [diff] [blame] | 76 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 77 | static bool dh_stm32_mac_is_in_ks8851(void) |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 78 | { |
Marek Vasut | f441184 | 2024-06-06 15:02:46 +0200 | [diff] [blame] | 79 | struct udevice *udev; |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 80 | u32 reg, cider, ccr; |
Marek Vasut | f441184 | 2024-06-06 15:02:46 +0200 | [diff] [blame] | 81 | char path[256]; |
| 82 | ofnode node; |
| 83 | int ret; |
Marek Vasut | b0a2a49 | 2020-07-31 01:34:50 +0200 | [diff] [blame] | 84 | |
Patrick Delaunay | 280949c | 2022-06-06 16:04:15 +0200 | [diff] [blame] | 85 | node = ofnode_path("ethernet1"); |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 86 | if (!ofnode_valid(node)) |
| 87 | return false; |
Marek Vasut | 145a876 | 2020-10-08 15:14:58 +0200 | [diff] [blame] | 88 | |
Marek Vasut | f441184 | 2024-06-06 15:02:46 +0200 | [diff] [blame] | 89 | ret = ofnode_get_path(node, path, sizeof(path)); |
| 90 | if (ret) |
| 91 | return false; |
| 92 | |
| 93 | ret = uclass_get_device_by_of_path(UCLASS_ETH, path, &udev); |
| 94 | if (ret) |
| 95 | return false; |
| 96 | |
| 97 | if (!ofnode_device_is_compatible(node, "micrel,ks8851-mll")) |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 98 | return false; |
Marek Vasut | 145a876 | 2020-10-08 15:14:58 +0200 | [diff] [blame] | 99 | |
| 100 | /* |
| 101 | * KS8851 with EEPROM may use custom MAC from EEPROM, read |
| 102 | * out the KS8851 CCR register to determine whether EEPROM |
| 103 | * is present. If EEPROM is present, it must contain valid |
| 104 | * MAC address. |
| 105 | */ |
Patrick Delaunay | 280949c | 2022-06-06 16:04:15 +0200 | [diff] [blame] | 106 | reg = ofnode_get_addr(node); |
Marek Vasut | 145a876 | 2020-10-08 15:14:58 +0200 | [diff] [blame] | 107 | if (!reg) |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 108 | return false; |
Marek Vasut | 145a876 | 2020-10-08 15:14:58 +0200 | [diff] [blame] | 109 | |
Marek Vasut | b2b31c1 | 2021-05-03 13:31:39 +0200 | [diff] [blame] | 110 | writew(KS_BE0 | KS_BE1 | KS_CIDER, reg + 2); |
| 111 | cider = readw(reg); |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 112 | if ((cider & 0xfff0) != CIDER_ID) |
| 113 | return true; |
Marek Vasut | b2b31c1 | 2021-05-03 13:31:39 +0200 | [diff] [blame] | 114 | |
Marek Vasut | 145a876 | 2020-10-08 15:14:58 +0200 | [diff] [blame] | 115 | writew(KS_BE0 | KS_BE1 | KS_CCR, reg + 2); |
| 116 | ccr = readw(reg); |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 117 | if (ccr & KS_CCR_EEPROM) |
| 118 | return true; |
| 119 | |
| 120 | return false; |
| 121 | } |
Marek Vasut | b0a2a49 | 2020-07-31 01:34:50 +0200 | [diff] [blame] | 122 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 123 | static int dh_stm32_setup_ethaddr(void) |
| 124 | { |
| 125 | unsigned char enetaddr[6]; |
| 126 | |
| 127 | if (dh_mac_is_in_env("ethaddr")) |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 128 | return 0; |
| 129 | |
Marek Vasut | 29ab1a9 | 2024-03-12 22:15:58 +0100 | [diff] [blame] | 130 | if (dh_get_mac_is_enabled("ethernet0")) |
| 131 | return 0; |
| 132 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 133 | if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0")) |
| 134 | return eth_env_set_enetaddr("ethaddr", enetaddr); |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 135 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 136 | return -ENXIO; |
| 137 | } |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 138 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 139 | static int dh_stm32_setup_eth1addr(void) |
| 140 | { |
| 141 | unsigned char enetaddr[6]; |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 142 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 143 | if (dh_mac_is_in_env("eth1addr")) |
| 144 | return 0; |
Marek Vasut | b0a2a49 | 2020-07-31 01:34:50 +0200 | [diff] [blame] | 145 | |
Marek Vasut | 29ab1a9 | 2024-03-12 22:15:58 +0100 | [diff] [blame] | 146 | if (dh_get_mac_is_enabled("ethernet1")) |
| 147 | return 0; |
| 148 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 149 | if (dh_stm32_mac_is_in_ks8851()) |
| 150 | return 0; |
| 151 | |
| 152 | if (!dh_get_mac_from_eeprom(enetaddr, "eeprom0")) { |
Marek Vasut | b0a2a49 | 2020-07-31 01:34:50 +0200 | [diff] [blame] | 153 | enetaddr[5]++; |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 154 | return eth_env_set_enetaddr("eth1addr", enetaddr); |
Marek Vasut | b0a2a49 | 2020-07-31 01:34:50 +0200 | [diff] [blame] | 155 | } |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 156 | |
Philip Oberfichtner | 78fa6b9 | 2022-07-26 15:04:53 +0200 | [diff] [blame] | 157 | return -ENXIO; |
| 158 | } |
| 159 | |
| 160 | int setup_mac_address(void) |
| 161 | { |
| 162 | if (dh_stm32_setup_ethaddr()) |
| 163 | log_err("%s: Unable to setup ethaddr!\n", __func__); |
| 164 | |
| 165 | if (dh_stm32_setup_eth1addr()) |
| 166 | log_err("%s: Unable to setup eth1addr!\n", __func__); |
| 167 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | int checkboard(void) |
| 172 | { |
| 173 | char *mode; |
| 174 | const char *fdt_compat; |
| 175 | int fdt_compat_len; |
| 176 | |
Patrick Delaunay | 472407a | 2020-03-18 09:22:49 +0100 | [diff] [blame] | 177 | if (IS_ENABLED(CONFIG_TFABOOT)) |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 178 | mode = "trusted"; |
| 179 | else |
| 180 | mode = "basic"; |
| 181 | |
| 182 | printf("Board: stm32mp1 in %s mode", mode); |
Patrick Delaunay | 280949c | 2022-06-06 16:04:15 +0200 | [diff] [blame] | 183 | fdt_compat = ofnode_get_property(ofnode_root(), "compatible", |
| 184 | &fdt_compat_len); |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 185 | if (fdt_compat && fdt_compat_len) |
| 186 | printf(" (%s)", fdt_compat); |
| 187 | puts("\n"); |
| 188 | |
| 189 | return 0; |
| 190 | } |
| 191 | |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 192 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
Marek Vasut | e5905ee | 2023-05-04 21:52:08 +0200 | [diff] [blame] | 193 | static u8 brdcode __section(".data"); |
| 194 | static u8 ddr3code __section(".data"); |
| 195 | static u8 somcode __section(".data"); |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 196 | static u32 opp_voltage_mv __section(".data"); |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 197 | |
| 198 | static void board_get_coding_straps(void) |
| 199 | { |
| 200 | struct gpio_desc gpio[4]; |
| 201 | ofnode node; |
| 202 | int i, ret; |
| 203 | |
Marek Vasut | 4bd7a5a | 2021-11-13 03:26:39 +0100 | [diff] [blame] | 204 | brdcode = 0; |
| 205 | ddr3code = 0; |
| 206 | somcode = 0; |
| 207 | |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 208 | node = ofnode_path("/config"); |
| 209 | if (!ofnode_valid(node)) { |
| 210 | printf("%s: no /config node?\n", __func__); |
| 211 | return; |
| 212 | } |
| 213 | |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 214 | ret = gpio_request_list_by_name_nodev(node, "dh,som-coding-gpios", |
| 215 | gpio, ARRAY_SIZE(gpio), |
| 216 | GPIOD_IS_IN); |
| 217 | for (i = 0; i < ret; i++) |
| 218 | somcode |= !!dm_gpio_get_value(&(gpio[i])) << i; |
| 219 | |
Marek Vasut | 4bd7a5a | 2021-11-13 03:26:39 +0100 | [diff] [blame] | 220 | gpio_free_list_nodev(gpio, ret); |
| 221 | |
Marek Vasut | 39221b5 | 2020-04-22 13:18:14 +0200 | [diff] [blame] | 222 | ret = gpio_request_list_by_name_nodev(node, "dh,ddr3-coding-gpios", |
| 223 | gpio, ARRAY_SIZE(gpio), |
| 224 | GPIOD_IS_IN); |
| 225 | for (i = 0; i < ret; i++) |
| 226 | ddr3code |= !!dm_gpio_get_value(&(gpio[i])) << i; |
| 227 | |
Marek Vasut | 4bd7a5a | 2021-11-13 03:26:39 +0100 | [diff] [blame] | 228 | gpio_free_list_nodev(gpio, ret); |
| 229 | |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 230 | ret = gpio_request_list_by_name_nodev(node, "dh,board-coding-gpios", |
| 231 | gpio, ARRAY_SIZE(gpio), |
| 232 | GPIOD_IS_IN); |
| 233 | for (i = 0; i < ret; i++) |
| 234 | brdcode |= !!dm_gpio_get_value(&(gpio[i])) << i; |
| 235 | |
Marek Vasut | 4bd7a5a | 2021-11-13 03:26:39 +0100 | [diff] [blame] | 236 | gpio_free_list_nodev(gpio, ret); |
| 237 | |
Harald Seiler | 1768f5d | 2023-09-27 14:46:25 +0200 | [diff] [blame] | 238 | if (CONFIG_IS_ENABLED(DISPLAY_PRINT)) |
| 239 | printf("Code: SoM:rev=%d,ddr3=%d Board:rev=%d\n", |
| 240 | somcode, ddr3code, brdcode); |
Marek Vasut | 39221b5 | 2020-04-22 13:18:14 +0200 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | int board_stm32mp1_ddr_config_name_match(struct udevice *dev, |
| 244 | const char *name) |
| 245 | { |
Marek Vasut | 272198e | 2020-04-29 15:08:38 +0200 | [diff] [blame] | 246 | if (ddr3code == 1 && |
| 247 | !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x1gb-533mhz")) |
| 248 | return 0; |
| 249 | |
Marek Vasut | 39221b5 | 2020-04-22 13:18:14 +0200 | [diff] [blame] | 250 | if (ddr3code == 2 && |
Marek Vasut | 272198e | 2020-04-29 15:08:38 +0200 | [diff] [blame] | 251 | !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x2gb-533mhz")) |
Marek Vasut | 39221b5 | 2020-04-22 13:18:14 +0200 | [diff] [blame] | 252 | return 0; |
| 253 | |
| 254 | if (ddr3code == 3 && |
Marek Vasut | 272198e | 2020-04-29 15:08:38 +0200 | [diff] [blame] | 255 | !strcmp(name, "st,ddr3l-dhsom-1066-888-bin-g-2x4gb-533mhz")) |
Marek Vasut | 39221b5 | 2020-04-22 13:18:14 +0200 | [diff] [blame] | 256 | return 0; |
| 257 | |
| 258 | return -EINVAL; |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 259 | } |
| 260 | |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 261 | void board_vddcore_init(u32 voltage_mv) |
| 262 | { |
Simon Glass | 49c24a8 | 2024-09-29 19:49:47 -0600 | [diff] [blame^] | 263 | if (IS_ENABLED(CONFIG_XPL_BUILD)) |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 264 | opp_voltage_mv = voltage_mv; |
| 265 | } |
| 266 | |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 267 | int board_early_init_f(void) |
| 268 | { |
Simon Glass | 49c24a8 | 2024-09-29 19:49:47 -0600 | [diff] [blame^] | 269 | if (IS_ENABLED(CONFIG_XPL_BUILD)) |
Patrick Delaunay | 08c891a | 2020-05-25 12:19:47 +0200 | [diff] [blame] | 270 | stpmic1_init(opp_voltage_mv); |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 271 | board_get_coding_straps(); |
| 272 | |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | #ifdef CONFIG_SPL_LOAD_FIT |
| 277 | int board_fit_config_name_match(const char *name) |
| 278 | { |
Marek Vasut | 060cb12 | 2020-07-31 01:35:33 +0200 | [diff] [blame] | 279 | const char *compat; |
| 280 | char test[128]; |
| 281 | |
Patrick Delaunay | 280949c | 2022-06-06 16:04:15 +0200 | [diff] [blame] | 282 | compat = ofnode_get_property(ofnode_root(), "compatible", NULL); |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 283 | |
Marek Vasut | 060cb12 | 2020-07-31 01:35:33 +0200 | [diff] [blame] | 284 | snprintf(test, sizeof(test), "%s_somrev%d_boardrev%d", |
| 285 | compat, somcode, brdcode); |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 286 | |
| 287 | if (!strcmp(name, test)) |
| 288 | return 0; |
| 289 | |
| 290 | return -EINVAL; |
| 291 | } |
| 292 | #endif |
| 293 | #endif |
| 294 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 295 | static void board_key_check(void) |
| 296 | { |
| 297 | #if defined(CONFIG_FASTBOOT) || defined(CONFIG_CMD_STM32PROG) |
| 298 | ofnode node; |
| 299 | struct gpio_desc gpio; |
| 300 | enum forced_boot_mode boot_mode = BOOT_NORMAL; |
| 301 | |
| 302 | node = ofnode_path("/config"); |
| 303 | if (!ofnode_valid(node)) { |
| 304 | debug("%s: no /config node?\n", __func__); |
| 305 | return; |
| 306 | } |
| 307 | #ifdef CONFIG_FASTBOOT |
| 308 | if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0, |
| 309 | &gpio, GPIOD_IS_IN)) { |
| 310 | debug("%s: could not find a /config/st,fastboot-gpios\n", |
| 311 | __func__); |
| 312 | } else { |
| 313 | if (dm_gpio_get_value(&gpio)) { |
| 314 | puts("Fastboot key pressed, "); |
| 315 | boot_mode = BOOT_FASTBOOT; |
| 316 | } |
| 317 | |
| 318 | dm_gpio_free(NULL, &gpio); |
| 319 | } |
| 320 | #endif |
| 321 | #ifdef CONFIG_CMD_STM32PROG |
| 322 | if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0, |
| 323 | &gpio, GPIOD_IS_IN)) { |
| 324 | debug("%s: could not find a /config/st,stm32prog-gpios\n", |
| 325 | __func__); |
| 326 | } else { |
| 327 | if (dm_gpio_get_value(&gpio)) { |
| 328 | puts("STM32Programmer key pressed, "); |
| 329 | boot_mode = BOOT_STM32PROG; |
| 330 | } |
| 331 | dm_gpio_free(NULL, &gpio); |
| 332 | } |
| 333 | #endif |
| 334 | |
| 335 | if (boot_mode != BOOT_NORMAL) { |
| 336 | puts("entering download mode...\n"); |
| 337 | clrsetbits_le32(TAMP_BOOT_CONTEXT, |
| 338 | TAMP_BOOT_FORCED_MASK, |
| 339 | boot_mode); |
| 340 | } |
| 341 | #endif |
| 342 | } |
| 343 | |
| 344 | #if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) |
| 345 | |
| 346 | #include <usb/dwc2_udc.h> |
| 347 | int g_dnl_board_usb_cable_connected(void) |
| 348 | { |
| 349 | struct udevice *dwc2_udc_otg; |
| 350 | int ret; |
| 351 | |
| 352 | ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 353 | DM_DRIVER_GET(dwc2_udc_otg), |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 354 | &dwc2_udc_otg); |
| 355 | if (!ret) |
| 356 | debug("dwc2_udc_otg init failed\n"); |
| 357 | |
| 358 | return dwc2_udc_B_session_valid(dwc2_udc_otg); |
| 359 | } |
| 360 | |
| 361 | #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11 |
| 362 | #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb |
| 363 | |
| 364 | int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) |
| 365 | { |
| 366 | if (!strcmp(name, "usb_dnl_dfu")) |
| 367 | put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct); |
| 368 | else if (!strcmp(name, "usb_dnl_fastboot")) |
| 369 | put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM, |
| 370 | &dev->idProduct); |
| 371 | else |
| 372 | put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, &dev->idProduct); |
| 373 | |
| 374 | return 0; |
| 375 | } |
| 376 | |
| 377 | #endif /* CONFIG_USB_GADGET */ |
| 378 | |
| 379 | #ifdef CONFIG_LED |
| 380 | static int get_led(struct udevice **dev, char *led_string) |
| 381 | { |
Simon Glass | 0034d96 | 2021-08-07 07:24:01 -0600 | [diff] [blame] | 382 | const char *led_name; |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 383 | int ret; |
| 384 | |
Simon Glass | 0034d96 | 2021-08-07 07:24:01 -0600 | [diff] [blame] | 385 | led_name = ofnode_conf_read_str(led_string); |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 386 | if (!led_name) { |
| 387 | pr_debug("%s: could not find %s config string\n", |
| 388 | __func__, led_string); |
| 389 | return -ENOENT; |
| 390 | } |
| 391 | ret = led_get_by_label(led_name, dev); |
| 392 | if (ret) { |
| 393 | debug("%s: get=%d\n", __func__, ret); |
| 394 | return ret; |
| 395 | } |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | static int setup_led(enum led_state_t cmd) |
| 401 | { |
| 402 | struct udevice *dev; |
| 403 | int ret; |
| 404 | |
| 405 | ret = get_led(&dev, "u-boot,boot-led"); |
| 406 | if (ret) |
| 407 | return ret; |
| 408 | |
| 409 | ret = led_set_state(dev, cmd); |
| 410 | return ret; |
| 411 | } |
| 412 | #endif |
| 413 | |
| 414 | static void __maybe_unused led_error_blink(u32 nb_blink) |
| 415 | { |
| 416 | #ifdef CONFIG_LED |
| 417 | int ret; |
| 418 | struct udevice *led; |
| 419 | u32 i; |
| 420 | #endif |
| 421 | |
| 422 | if (!nb_blink) |
| 423 | return; |
| 424 | |
| 425 | #ifdef CONFIG_LED |
| 426 | ret = get_led(&led, "u-boot,error-led"); |
| 427 | if (!ret) { |
| 428 | /* make u-boot,error-led blinking */ |
| 429 | /* if U32_MAX and 125ms interval, for 17.02 years */ |
| 430 | for (i = 0; i < 2 * nb_blink; i++) { |
| 431 | led_set_state(led, LEDST_TOGGLE); |
| 432 | mdelay(125); |
Stefan Roese | 80877fa | 2022-09-02 14:10:46 +0200 | [diff] [blame] | 433 | schedule(); |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 434 | } |
| 435 | } |
| 436 | #endif |
| 437 | |
| 438 | /* infinite: the boot process must be stopped */ |
| 439 | if (nb_blink == U32_MAX) |
| 440 | hang(); |
| 441 | } |
| 442 | |
| 443 | static void sysconf_init(void) |
| 444 | { |
Patrick Delaunay | f8fe21d | 2020-04-01 09:07:33 +0200 | [diff] [blame] | 445 | #ifndef CONFIG_TFABOOT |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 446 | u8 *syscfg; |
| 447 | #ifdef CONFIG_DM_REGULATOR |
| 448 | struct udevice *pwr_dev; |
| 449 | struct udevice *pwr_reg; |
| 450 | struct udevice *dev; |
| 451 | int ret; |
| 452 | u32 otp = 0; |
| 453 | #endif |
| 454 | u32 bootr; |
| 455 | |
| 456 | syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG); |
| 457 | |
| 458 | /* interconnect update : select master using the port 1 */ |
| 459 | /* LTDC = AXI_M9 */ |
| 460 | /* GPU = AXI_M8 */ |
| 461 | /* today information is hardcoded in U-Boot */ |
| 462 | writel(BIT(9), syscfg + SYSCFG_ICNR); |
| 463 | |
| 464 | /* disable Pull-Down for boot pin connected to VDD */ |
| 465 | bootr = readl(syscfg + SYSCFG_BOOTR); |
| 466 | bootr &= ~(SYSCFG_BOOTR_BOOT_MASK << SYSCFG_BOOTR_BOOTPD_SHIFT); |
| 467 | bootr |= (bootr & SYSCFG_BOOTR_BOOT_MASK) << SYSCFG_BOOTR_BOOTPD_SHIFT; |
| 468 | writel(bootr, syscfg + SYSCFG_BOOTR); |
| 469 | |
| 470 | #ifdef CONFIG_DM_REGULATOR |
| 471 | /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI |
| 472 | * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection. |
| 473 | * The customer will have to disable this for low frequencies |
| 474 | * or if AFMUX is selected but the function not used, typically for |
| 475 | * TRACE. Otherwise, impact on power consumption. |
| 476 | * |
| 477 | * WARNING: |
| 478 | * enabling High Speed mode while VDD>2.7V |
| 479 | * with the OTP product_below_2v5 (OTP 18, BIT 13) |
| 480 | * erroneously set to 1 can damage the IC! |
| 481 | * => U-Boot set the register only if VDD < 2.7V (in DT) |
| 482 | * but this value need to be consistent with board design |
| 483 | */ |
| 484 | ret = uclass_get_device_by_driver(UCLASS_PMIC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 485 | DM_DRIVER_GET(stm32mp_pwr_pmic), |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 486 | &pwr_dev); |
| 487 | if (!ret) { |
| 488 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 489 | DM_DRIVER_GET(stm32mp_bsec), |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 490 | &dev); |
| 491 | if (ret) { |
| 492 | pr_err("Can't find stm32mp_bsec driver\n"); |
| 493 | return; |
| 494 | } |
| 495 | |
| 496 | ret = misc_read(dev, STM32_BSEC_SHADOW(18), &otp, 4); |
| 497 | if (ret > 0) |
| 498 | otp = otp & BIT(13); |
| 499 | |
| 500 | /* get VDD = vdd-supply */ |
| 501 | ret = device_get_supply_regulator(pwr_dev, "vdd-supply", |
| 502 | &pwr_reg); |
| 503 | |
| 504 | /* check if VDD is Low Voltage */ |
| 505 | if (!ret) { |
| 506 | if (regulator_get_value(pwr_reg) < 2700000) { |
| 507 | writel(SYSCFG_IOCTRLSETR_HSLVEN_TRACE | |
| 508 | SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI | |
| 509 | SYSCFG_IOCTRLSETR_HSLVEN_ETH | |
| 510 | SYSCFG_IOCTRLSETR_HSLVEN_SDMMC | |
| 511 | SYSCFG_IOCTRLSETR_HSLVEN_SPI, |
| 512 | syscfg + SYSCFG_IOCTRLSETR); |
| 513 | |
| 514 | if (!otp) |
| 515 | pr_err("product_below_2v5=0: HSLVEN protected by HW\n"); |
| 516 | } else { |
| 517 | if (otp) |
| 518 | pr_err("product_below_2v5=1: HSLVEN update is destructive, no update as VDD>2.7V\n"); |
| 519 | } |
| 520 | } else { |
| 521 | debug("VDD unknown"); |
| 522 | } |
| 523 | } |
| 524 | #endif |
| 525 | |
| 526 | /* activate automatic I/O compensation |
| 527 | * warning: need to ensure CSI enabled and ready in clock driver |
| 528 | */ |
| 529 | writel(SYSCFG_CMPENSETR_MPU_EN, syscfg + SYSCFG_CMPENSETR); |
| 530 | |
| 531 | while (!(readl(syscfg + SYSCFG_CMPCR) & SYSCFG_CMPCR_READY)) |
| 532 | ; |
| 533 | clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL); |
| 534 | #endif |
| 535 | } |
| 536 | |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 537 | #ifdef CONFIG_DM_REGULATOR |
| 538 | #define STPMIC_NVM_BUCKS_VOUT_SHR 0xfc |
| 539 | #define STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_1V2 0 |
| 540 | #define STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_1V8 1 |
| 541 | #define STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_3V0 2 |
| 542 | #define STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_3V3 3 |
| 543 | #define STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_MASK GENMASK(1, 0) |
| 544 | #define STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_OFFSET(n) ((((n) - 1) & 3) * 2) |
| 545 | static int board_get_regulator_buck3_nvm_uv_av96(int *uv) |
| 546 | { |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 547 | struct udevice *dev; |
| 548 | u8 bucks_vout = 0; |
| 549 | const char *prop; |
| 550 | int len, ret; |
| 551 | |
| 552 | /* Check whether this is Avenger96 board. */ |
Patrick Delaunay | 280949c | 2022-06-06 16:04:15 +0200 | [diff] [blame] | 553 | prop = ofnode_get_property(ofnode_root(), "compatible", &len); |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 554 | if (!prop || !len) |
| 555 | return -ENODEV; |
| 556 | |
Marek Vasut | 5278494 | 2022-09-26 18:50:00 +0200 | [diff] [blame] | 557 | if (!strstr(prop, "avenger96") && !strstr(prop, "dhcor-testbench")) |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 558 | return -EINVAL; |
| 559 | |
| 560 | /* Read out STPMIC1 NVM and determine default Buck3 voltage. */ |
| 561 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
| 562 | DM_DRIVER_GET(stpmic1_nvm), |
| 563 | &dev); |
| 564 | if (ret) |
| 565 | return ret; |
| 566 | |
| 567 | ret = misc_read(dev, STPMIC_NVM_BUCKS_VOUT_SHR, &bucks_vout, 1); |
| 568 | if (ret != 1) |
| 569 | return -EINVAL; |
| 570 | |
| 571 | bucks_vout >>= STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_OFFSET(3); |
| 572 | bucks_vout &= STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_MASK; |
| 573 | |
Marek Vasut | 5278494 | 2022-09-26 18:50:00 +0200 | [diff] [blame] | 574 | if (strstr(prop, "avenger96")) { |
| 575 | /* |
| 576 | * Avenger96 board comes in multiple regulator configurations: |
| 577 | * - rev.100 or rev.200 have Buck3 preconfigured to |
| 578 | * 3V3 operation on boot and contains extra Enpirion |
| 579 | * EP53A8LQI DCDC converter which supplies the IO. |
| 580 | * Reduce Buck3 voltage to 2V9 to not waste power. |
| 581 | * - rev.200L have Buck3 preconfigured to 1V8 operation |
| 582 | * and have no Enpirion EP53A8LQI DCDC anymore, the |
| 583 | * IO is supplied from Buck3. |
| 584 | */ |
| 585 | if (bucks_vout == STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_3V3) |
| 586 | *uv = 2900000; |
| 587 | else |
| 588 | *uv = 1800000; |
| 589 | } else { |
| 590 | /* Testbench always respects Buck3 NVM settings */ |
| 591 | if (bucks_vout == STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_3V3) |
| 592 | *uv = 3300000; |
| 593 | else if (bucks_vout == STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_3V0) |
| 594 | *uv = 3000000; |
| 595 | else if (bucks_vout == STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_1V8) |
| 596 | *uv = 1800000; |
| 597 | else /* STPMIC_NVM_BUCKS_VOUT_SHR_BUCK_1V2 */ |
| 598 | *uv = 1200000; |
| 599 | } |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 600 | |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | static void board_init_regulator_av96(void) |
| 605 | { |
| 606 | struct udevice *rdev; |
| 607 | int ret, uv; |
| 608 | |
| 609 | ret = board_get_regulator_buck3_nvm_uv_av96(&uv); |
| 610 | if (ret) /* Not Avenger96 board. */ |
| 611 | return; |
| 612 | |
| 613 | ret = regulator_get_by_devname("buck3", &rdev); |
| 614 | if (ret) |
| 615 | return; |
| 616 | |
| 617 | /* Adjust Buck3 per preconfigured PMIC voltage from NVM. */ |
| 618 | regulator_set_value(rdev, uv); |
Marek Vasut | 69e8995 | 2022-09-23 03:31:22 +0200 | [diff] [blame] | 619 | regulator_set_enable(rdev, true); |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | static void board_init_regulator(void) |
| 623 | { |
| 624 | board_init_regulator_av96(); |
| 625 | |
| 626 | regulators_enable_boot_on(_DEBUG); |
| 627 | } |
| 628 | #else |
| 629 | static inline int board_get_regulator_buck3_nvm_uv_av96(int *uv) |
| 630 | { |
| 631 | return -EINVAL; |
| 632 | } |
| 633 | |
| 634 | static inline void board_init_regulator(void) {} |
| 635 | #endif |
| 636 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 637 | /* board dependent setup after realloc */ |
| 638 | int board_init(void) |
| 639 | { |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 640 | board_key_check(); |
| 641 | |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 642 | board_init_regulator(); |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 643 | |
| 644 | sysconf_init(); |
| 645 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 646 | return 0; |
| 647 | } |
| 648 | |
| 649 | int board_late_init(void) |
| 650 | { |
| 651 | char *boot_device; |
| 652 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 653 | const void *fdt_compat; |
| 654 | int fdt_compat_len; |
| 655 | |
Patrick Delaunay | 280949c | 2022-06-06 16:04:15 +0200 | [diff] [blame] | 656 | fdt_compat = ofnode_get_property(ofnode_root(), "compatible", |
| 657 | &fdt_compat_len); |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 658 | if (fdt_compat && fdt_compat_len) { |
| 659 | if (strncmp(fdt_compat, "st,", 3) != 0) |
| 660 | env_set("board_name", fdt_compat); |
| 661 | else |
| 662 | env_set("board_name", fdt_compat + 3); |
| 663 | } |
| 664 | #endif |
| 665 | |
| 666 | /* Check the boot-source to disable bootdelay */ |
| 667 | boot_device = env_get("boot_device"); |
| 668 | if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb")) |
| 669 | env_set("bootdelay", "0"); |
| 670 | |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 671 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 672 | env_set_ulong("dh_som_rev", somcode); |
| 673 | env_set_ulong("dh_board_rev", brdcode); |
Marek Vasut | 39221b5 | 2020-04-22 13:18:14 +0200 | [diff] [blame] | 674 | env_set_ulong("dh_ddr3_code", ddr3code); |
Marek Vasut | 47b98ba | 2020-04-22 13:18:11 +0200 | [diff] [blame] | 675 | #endif |
| 676 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 677 | return 0; |
| 678 | } |
| 679 | |
| 680 | void board_quiesce_devices(void) |
| 681 | { |
| 682 | #ifdef CONFIG_LED |
| 683 | setup_led(LEDST_OFF); |
| 684 | #endif |
| 685 | } |
| 686 | |
Marek Vasut | 3551654 | 2024-06-06 15:01:48 +0200 | [diff] [blame] | 687 | static void dh_stm32_ks8851_fixup(void *blob) |
| 688 | { |
| 689 | struct gpio_desc ks8851intrn; |
| 690 | bool compatible = false; |
| 691 | int ks8851intrn_value; |
| 692 | const char *prop; |
| 693 | ofnode node; |
| 694 | int idx = 0; |
| 695 | int offset; |
| 696 | int ret; |
| 697 | |
| 698 | /* Do nothing if not STM32MP15xx DHCOM SoM */ |
| 699 | while ((prop = fdt_stringlist_get(blob, 0, "compatible", idx++, NULL))) { |
| 700 | if (!strstr(prop, "dhcom-som")) |
| 701 | continue; |
| 702 | compatible = true; |
| 703 | break; |
| 704 | } |
| 705 | |
| 706 | if (!compatible) |
| 707 | return; |
| 708 | |
| 709 | /* |
| 710 | * Read state of INTRN pull up resistor, if this pull up is populated, |
| 711 | * KS8851-16MLL is populated as well and should be enabled, otherwise |
| 712 | * it should be disabled. |
| 713 | */ |
| 714 | node = ofnode_path("/config"); |
| 715 | if (!ofnode_valid(node)) |
| 716 | return; |
| 717 | |
| 718 | ret = gpio_request_by_name_nodev(node, "dh,mac-coding-gpios", 0, |
| 719 | &ks8851intrn, GPIOD_IS_IN); |
| 720 | if (ret) |
| 721 | return; |
| 722 | |
| 723 | ks8851intrn_value = dm_gpio_get_value(&ks8851intrn); |
| 724 | |
| 725 | dm_gpio_free(NULL, &ks8851intrn); |
| 726 | |
| 727 | /* Set the 'status' property into KS8851-16MLL DT node. */ |
| 728 | offset = fdt_path_offset(blob, "ethernet1"); |
| 729 | ret = fdt_node_check_compatible(blob, offset, "micrel,ks8851-mll"); |
| 730 | if (ret) /* Not compatible */ |
| 731 | return; |
| 732 | |
| 733 | /* Add a bit of extra space for new 'status' property */ |
| 734 | ret = fdt_shrink_to_minimum(blob, 4096); |
| 735 | if (!ret) |
| 736 | return; |
| 737 | |
| 738 | fdt_setprop_string(blob, offset, "status", |
| 739 | ks8851intrn_value ? "okay" : "disabled"); |
| 740 | } |
| 741 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 742 | #if defined(CONFIG_OF_BOARD_SETUP) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 743 | int ft_board_setup(void *blob, struct bd_info *bd) |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 744 | { |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 745 | const char *buck3path = "/soc/i2c@5c002000/stpmic@33/regulators/buck3"; |
| 746 | int buck3off, ret, uv; |
| 747 | |
Marek Vasut | 3551654 | 2024-06-06 15:01:48 +0200 | [diff] [blame] | 748 | dh_stm32_ks8851_fixup(blob); |
| 749 | |
Marek Vasut | 7f809fe | 2022-05-11 23:09:33 +0200 | [diff] [blame] | 750 | ret = board_get_regulator_buck3_nvm_uv_av96(&uv); |
| 751 | if (ret) /* Not Avenger96 board, do not patch Buck3 in DT. */ |
| 752 | return 0; |
| 753 | |
| 754 | buck3off = fdt_path_offset(blob, buck3path); |
| 755 | if (buck3off < 0) /* No Buck3 regulator found. */ |
| 756 | return 0; |
| 757 | |
| 758 | ret = fdt_setprop_u32(blob, buck3off, "regulator-min-microvolt", uv); |
| 759 | if (ret < 0) |
| 760 | return ret; |
| 761 | |
| 762 | ret = fdt_setprop_u32(blob, buck3off, "regulator-max-microvolt", uv); |
| 763 | if (ret < 0) |
| 764 | return ret; |
| 765 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 766 | return 0; |
| 767 | } |
| 768 | #endif |
| 769 | |
Simon Glass | 49c24a8 | 2024-09-29 19:49:47 -0600 | [diff] [blame^] | 770 | #if defined(CONFIG_XPL_BUILD) |
Marek Vasut | 3551654 | 2024-06-06 15:01:48 +0200 | [diff] [blame] | 771 | void spl_perform_fixups(struct spl_image_info *spl_image) |
| 772 | { |
| 773 | dh_stm32_ks8851_fixup(spl_image_fdt_addr(spl_image)); |
| 774 | } |
| 775 | #endif |
| 776 | |
Marek Vasut | 5ff0529 | 2020-01-24 18:39:16 +0100 | [diff] [blame] | 777 | static void board_copro_image_process(ulong fw_image, size_t fw_size) |
| 778 | { |
| 779 | int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */ |
| 780 | |
| 781 | if (!rproc_is_initialized()) |
| 782 | if (rproc_init()) { |
| 783 | printf("Remote Processor %d initialization failed\n", |
| 784 | id); |
| 785 | return; |
| 786 | } |
| 787 | |
| 788 | ret = rproc_load(id, fw_image, fw_size); |
| 789 | printf("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n", |
| 790 | id, fw_image, fw_size, ret ? " Failed!" : " Success!"); |
| 791 | |
| 792 | if (!ret) { |
| 793 | rproc_start(id); |
| 794 | env_set("copro_state", "booted"); |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process); |