Tom Rini | 8b0c8a1 | 2018-05-06 18:27:01 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2018, STMicroelectronics - All Rights Reserved |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 4 | */ |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 5 | |
| 6 | #define LOG_CATEGORY LOGC_BOARD |
| 7 | |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 8 | #include <common.h> |
| 9 | #include <adc.h> |
Patrick Delaunay | 500401f | 2019-06-21 15:26:40 +0200 | [diff] [blame] | 10 | #include <bootm.h> |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 11 | #include <clk.h> |
Patrick Delaunay | 266bf10 | 2019-07-30 19:16:44 +0200 | [diff] [blame] | 12 | #include <config.h> |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 13 | #include <dm.h> |
Simon Glass | db22961 | 2019-08-01 09:46:42 -0600 | [diff] [blame] | 14 | #include <env.h> |
Simon Glass | 9d1f619 | 2019-08-02 09:44:25 -0600 | [diff] [blame] | 15 | #include <env_internal.h> |
Simon Glass | 2dc9c34 | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 16 | #include <fdt_support.h> |
Patrick Delaunay | 58bc0cd | 2019-03-29 15:42:23 +0100 | [diff] [blame] | 17 | #include <g_dnl.h> |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 18 | #include <generic-phy.h> |
Simon Glass | f11478f | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 19 | #include <hang.h> |
Patrick Delaunay | 7f3384d | 2019-03-29 15:42:24 +0100 | [diff] [blame] | 20 | #include <i2c.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 21 | #include <init.h> |
Patrick Delaunay | 92dc102 | 2019-02-12 11:44:41 +0100 | [diff] [blame] | 22 | #include <led.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 23 | #include <log.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 24 | #include <malloc.h> |
Patrick Delaunay | 92dc102 | 2019-02-12 11:44:41 +0100 | [diff] [blame] | 25 | #include <misc.h> |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 26 | #include <mtd_node.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 27 | #include <net.h> |
Patrick Delaunay | bff66f9 | 2019-08-01 11:29:03 +0200 | [diff] [blame] | 28 | #include <netdev.h> |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 29 | #include <phy.h> |
Patrick Delaunay | c17d725 | 2019-08-02 15:07:20 +0200 | [diff] [blame] | 30 | #include <remoteproc.h> |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 31 | #include <reset.h> |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 32 | #include <syscon.h> |
Patrick Delaunay | 7f3384d | 2019-03-29 15:42:24 +0100 | [diff] [blame] | 33 | #include <usb.h> |
Patrick Delaunay | ae0931d0 | 2019-07-30 19:16:39 +0200 | [diff] [blame] | 34 | #include <watchdog.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 35 | #include <asm/global_data.h> |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 36 | #include <asm/io.h> |
Patrick Delaunay | f2a7b87 | 2019-02-27 17:01:18 +0100 | [diff] [blame] | 37 | #include <asm/gpio.h> |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 38 | #include <asm/arch/stm32.h> |
Patrice Chotard | dad97bf | 2019-05-02 18:36:01 +0200 | [diff] [blame] | 39 | #include <asm/arch/sys_proto.h> |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 40 | #include <jffs2/load_kernel.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 41 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 42 | #include <linux/delay.h> |
Simon Glass | d66c5f7 | 2020-02-03 07:36:15 -0700 | [diff] [blame] | 43 | #include <linux/err.h> |
Patrick Delaunay | 181298e | 2020-04-22 14:29:16 +0200 | [diff] [blame] | 44 | #include <linux/iopoll.h> |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 45 | #include <power/regulator.h> |
Patrick Delaunay | 7f3384d | 2019-03-29 15:42:24 +0100 | [diff] [blame] | 46 | #include <usb/dwc2_udc.h> |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 47 | |
Patrick Delaunay | fcb6b0b | 2020-06-29 10:34:06 +0200 | [diff] [blame] | 48 | #include "../../st/common/stusb160x.h" |
| 49 | |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 50 | /* SYSCFG registers */ |
| 51 | #define SYSCFG_BOOTR 0x00 |
| 52 | #define SYSCFG_PMCSETR 0x04 |
| 53 | #define SYSCFG_IOCTRLSETR 0x18 |
| 54 | #define SYSCFG_ICNR 0x1C |
| 55 | #define SYSCFG_CMPCR 0x20 |
| 56 | #define SYSCFG_CMPENSETR 0x24 |
| 57 | #define SYSCFG_PMCCLRR 0x44 |
| 58 | |
| 59 | #define SYSCFG_BOOTR_BOOT_MASK GENMASK(2, 0) |
| 60 | #define SYSCFG_BOOTR_BOOTPD_SHIFT 4 |
| 61 | |
| 62 | #define SYSCFG_IOCTRLSETR_HSLVEN_TRACE BIT(0) |
| 63 | #define SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI BIT(1) |
| 64 | #define SYSCFG_IOCTRLSETR_HSLVEN_ETH BIT(2) |
| 65 | #define SYSCFG_IOCTRLSETR_HSLVEN_SDMMC BIT(3) |
| 66 | #define SYSCFG_IOCTRLSETR_HSLVEN_SPI BIT(4) |
| 67 | |
| 68 | #define SYSCFG_CMPCR_SW_CTRL BIT(1) |
| 69 | #define SYSCFG_CMPCR_READY BIT(8) |
| 70 | |
| 71 | #define SYSCFG_CMPENSETR_MPU_EN BIT(0) |
| 72 | |
| 73 | #define SYSCFG_PMCSETR_ETH_CLK_SEL BIT(16) |
| 74 | #define SYSCFG_PMCSETR_ETH_REF_CLK_SEL BIT(17) |
| 75 | |
| 76 | #define SYSCFG_PMCSETR_ETH_SELMII BIT(20) |
| 77 | |
| 78 | #define SYSCFG_PMCSETR_ETH_SEL_MASK GENMASK(23, 21) |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 79 | #define SYSCFG_PMCSETR_ETH_SEL_GMII_MII 0 |
| 80 | #define SYSCFG_PMCSETR_ETH_SEL_RGMII BIT(21) |
| 81 | #define SYSCFG_PMCSETR_ETH_SEL_RMII BIT(23) |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 82 | |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 83 | /* |
| 84 | * Get a global data pointer |
| 85 | */ |
| 86 | DECLARE_GLOBAL_DATA_PTR; |
| 87 | |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 88 | #define USB_LOW_THRESHOLD_UV 200000 |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 89 | #define USB_WARNING_LOW_THRESHOLD_UV 660000 |
| 90 | #define USB_START_LOW_THRESHOLD_UV 1230000 |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 91 | #define USB_START_HIGH_THRESHOLD_UV 2150000 |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 92 | |
Patrick Delaunay | f2f25c3 | 2020-05-25 12:19:46 +0200 | [diff] [blame] | 93 | int board_early_init_f(void) |
| 94 | { |
| 95 | /* nothing to do, only used in SPL */ |
| 96 | return 0; |
| 97 | } |
| 98 | |
Patrick Delaunay | 92dc102 | 2019-02-12 11:44:41 +0100 | [diff] [blame] | 99 | int checkboard(void) |
| 100 | { |
| 101 | int ret; |
| 102 | char *mode; |
| 103 | u32 otp; |
| 104 | struct udevice *dev; |
| 105 | const char *fdt_compat; |
| 106 | int fdt_compat_len; |
| 107 | |
Patrick Delaunay | 472407a | 2020-03-18 09:22:49 +0100 | [diff] [blame] | 108 | if (IS_ENABLED(CONFIG_TFABOOT)) |
Patrick Delaunay | 92dc102 | 2019-02-12 11:44:41 +0100 | [diff] [blame] | 109 | mode = "trusted"; |
| 110 | else |
| 111 | mode = "basic"; |
| 112 | |
Patrick Delaunay | 92dc102 | 2019-02-12 11:44:41 +0100 | [diff] [blame] | 113 | fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible", |
| 114 | &fdt_compat_len); |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 115 | |
| 116 | log_info("Board: stm32mp1 in %s mode (%s)\n", mode, |
| 117 | fdt_compat && fdt_compat_len ? fdt_compat : ""); |
Patrick Delaunay | 92dc102 | 2019-02-12 11:44:41 +0100 | [diff] [blame] | 118 | |
Patrick Delaunay | 52163d9 | 2020-03-24 09:05:00 +0100 | [diff] [blame] | 119 | /* display the STMicroelectronics board identification */ |
Patrick Delaunay | 0885c23 | 2020-02-12 19:37:42 +0100 | [diff] [blame] | 120 | if (CONFIG_IS_ENABLED(CMD_STBOARD)) { |
| 121 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 122 | DM_DRIVER_GET(stm32mp_bsec), |
Patrick Delaunay | 0885c23 | 2020-02-12 19:37:42 +0100 | [diff] [blame] | 123 | &dev); |
| 124 | if (!ret) |
| 125 | ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), |
| 126 | &otp, sizeof(otp)); |
| 127 | if (ret > 0 && otp) |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 128 | log_info("Board: MB%04x Var%d.%d Rev.%c-%02d\n", |
| 129 | otp >> 16, |
| 130 | (otp >> 12) & 0xF, |
| 131 | (otp >> 4) & 0xF, |
| 132 | ((otp >> 8) & 0xF) - 1 + 'A', |
| 133 | otp & 0xF); |
Patrick Delaunay | 92dc102 | 2019-02-12 11:44:41 +0100 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | return 0; |
| 137 | } |
| 138 | |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 139 | static void board_key_check(void) |
| 140 | { |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 141 | ofnode node; |
| 142 | struct gpio_desc gpio; |
| 143 | enum forced_boot_mode boot_mode = BOOT_NORMAL; |
| 144 | |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 145 | if (!IS_ENABLED(CONFIG_FASTBOOT) && !IS_ENABLED(CONFIG_CMD_STM32PROG)) |
| 146 | return; |
| 147 | |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 148 | node = ofnode_path("/config"); |
| 149 | if (!ofnode_valid(node)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 150 | log_debug("no /config node?\n"); |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 151 | return; |
| 152 | } |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 153 | if (IS_ENABLED(CONFIG_FASTBOOT)) { |
| 154 | if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0, |
| 155 | &gpio, GPIOD_IS_IN)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 156 | log_debug("could not find a /config/st,fastboot-gpios\n"); |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 157 | } else { |
| 158 | if (dm_gpio_get_value(&gpio)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 159 | log_notice("Fastboot key pressed, "); |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 160 | boot_mode = BOOT_FASTBOOT; |
| 161 | } |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 162 | |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 163 | dm_gpio_free(NULL, &gpio); |
| 164 | } |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 165 | } |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 166 | if (IS_ENABLED(CONFIG_CMD_STM32PROG)) { |
| 167 | if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0, |
| 168 | &gpio, GPIOD_IS_IN)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 169 | log_debug("could not find a /config/st,stm32prog-gpios\n"); |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 170 | } else { |
| 171 | if (dm_gpio_get_value(&gpio)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 172 | log_notice("STM32Programmer key pressed, "); |
Patrick Delaunay | f660485 | 2020-07-31 16:31:42 +0200 | [diff] [blame] | 173 | boot_mode = BOOT_STM32PROG; |
| 174 | } |
| 175 | dm_gpio_free(NULL, &gpio); |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 176 | } |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 177 | } |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 178 | if (boot_mode != BOOT_NORMAL) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 179 | log_notice("entering download mode...\n"); |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 180 | clrsetbits_le32(TAMP_BOOT_CONTEXT, |
| 181 | TAMP_BOOT_FORCED_MASK, |
| 182 | boot_mode); |
| 183 | } |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 184 | } |
| 185 | |
Patrick Delaunay | 58bc0cd | 2019-03-29 15:42:23 +0100 | [diff] [blame] | 186 | int g_dnl_board_usb_cable_connected(void) |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 187 | { |
Patrick Delaunay | 58bc0cd | 2019-03-29 15:42:23 +0100 | [diff] [blame] | 188 | struct udevice *dwc2_udc_otg; |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 189 | int ret; |
| 190 | |
Patrick Delaunay | a1d5f20 | 2020-07-31 16:31:43 +0200 | [diff] [blame] | 191 | if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG)) |
| 192 | return -ENODEV; |
| 193 | |
Patrick Delaunay | fcb6b0b | 2020-06-29 10:34:06 +0200 | [diff] [blame] | 194 | /* if typec stusb160x is present, means DK1 or DK2 board */ |
| 195 | ret = stusb160x_cable_connected(); |
| 196 | if (ret >= 0) |
| 197 | return ret; |
Patrick Delaunay | 7f3384d | 2019-03-29 15:42:24 +0100 | [diff] [blame] | 198 | |
Patrick Delaunay | 58bc0cd | 2019-03-29 15:42:23 +0100 | [diff] [blame] | 199 | ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 200 | DM_DRIVER_GET(dwc2_udc_otg), |
Patrick Delaunay | 58bc0cd | 2019-03-29 15:42:23 +0100 | [diff] [blame] | 201 | &dwc2_udc_otg); |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 202 | if (ret) { |
| 203 | log_debug("dwc2_udc_otg init failed\n"); |
| 204 | return ret; |
| 205 | } |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 206 | |
Patrick Delaunay | 58bc0cd | 2019-03-29 15:42:23 +0100 | [diff] [blame] | 207 | return dwc2_udc_B_session_valid(dwc2_udc_otg); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 208 | } |
Patrick Delaunay | 0aafce6 | 2019-09-13 15:24:17 +0200 | [diff] [blame] | 209 | |
Patrick Delaunay | a1d5f20 | 2020-07-31 16:31:43 +0200 | [diff] [blame] | 210 | #ifdef CONFIG_USB_GADGET_DOWNLOAD |
Patrick Delaunay | 0aafce6 | 2019-09-13 15:24:17 +0200 | [diff] [blame] | 211 | #define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11 |
| 212 | #define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb |
| 213 | |
| 214 | int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) |
| 215 | { |
Patrick Delaunay | a1d5f20 | 2020-07-31 16:31:43 +0200 | [diff] [blame] | 216 | if (IS_ENABLED(CONFIG_DFU_OVER_USB) && |
| 217 | !strcmp(name, "usb_dnl_dfu")) |
Patrick Delaunay | 0aafce6 | 2019-09-13 15:24:17 +0200 | [diff] [blame] | 218 | put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct); |
Patrick Delaunay | a1d5f20 | 2020-07-31 16:31:43 +0200 | [diff] [blame] | 219 | else if (IS_ENABLED(CONFIG_FASTBOOT) && |
| 220 | !strcmp(name, "usb_dnl_fastboot")) |
Patrick Delaunay | 0aafce6 | 2019-09-13 15:24:17 +0200 | [diff] [blame] | 221 | put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM, |
| 222 | &dev->idProduct); |
| 223 | else |
| 224 | put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, &dev->idProduct); |
| 225 | |
| 226 | return 0; |
| 227 | } |
Patrick Delaunay | a1d5f20 | 2020-07-31 16:31:43 +0200 | [diff] [blame] | 228 | #endif /* CONFIG_USB_GADGET_DOWNLOAD */ |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 229 | |
| 230 | static int get_led(struct udevice **dev, char *led_string) |
| 231 | { |
| 232 | char *led_name; |
| 233 | int ret; |
| 234 | |
| 235 | led_name = fdtdec_get_config_string(gd->fdt_blob, led_string); |
| 236 | if (!led_name) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 237 | log_debug("could not find %s config string\n", led_string); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 238 | return -ENOENT; |
| 239 | } |
| 240 | ret = led_get_by_label(led_name, dev); |
| 241 | if (ret) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 242 | log_debug("get=%d\n", ret); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 243 | return ret; |
| 244 | } |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | static int setup_led(enum led_state_t cmd) |
| 250 | { |
| 251 | struct udevice *dev; |
| 252 | int ret; |
| 253 | |
Patrick Delaunay | 8ae05cf | 2020-04-22 14:29:12 +0200 | [diff] [blame] | 254 | if (!CONFIG_IS_ENABLED(LED)) |
| 255 | return 0; |
| 256 | |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 257 | ret = get_led(&dev, "u-boot,boot-led"); |
| 258 | if (ret) |
| 259 | return ret; |
| 260 | |
| 261 | ret = led_set_state(dev, cmd); |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 262 | return ret; |
| 263 | } |
Patrick Delaunay | ae0931d0 | 2019-07-30 19:16:39 +0200 | [diff] [blame] | 264 | |
| 265 | static void __maybe_unused led_error_blink(u32 nb_blink) |
| 266 | { |
Patrick Delaunay | ae0931d0 | 2019-07-30 19:16:39 +0200 | [diff] [blame] | 267 | int ret; |
| 268 | struct udevice *led; |
| 269 | u32 i; |
Patrick Delaunay | ae0931d0 | 2019-07-30 19:16:39 +0200 | [diff] [blame] | 270 | |
| 271 | if (!nb_blink) |
| 272 | return; |
| 273 | |
Patrick Delaunay | 8ae05cf | 2020-04-22 14:29:12 +0200 | [diff] [blame] | 274 | if (CONFIG_IS_ENABLED(LED)) { |
| 275 | ret = get_led(&led, "u-boot,error-led"); |
| 276 | if (!ret) { |
| 277 | /* make u-boot,error-led blinking */ |
| 278 | /* if U32_MAX and 125ms interval, for 17.02 years */ |
| 279 | for (i = 0; i < 2 * nb_blink; i++) { |
| 280 | led_set_state(led, LEDST_TOGGLE); |
| 281 | mdelay(125); |
| 282 | WATCHDOG_RESET(); |
| 283 | } |
| 284 | led_set_state(led, LEDST_ON); |
Patrick Delaunay | ae0931d0 | 2019-07-30 19:16:39 +0200 | [diff] [blame] | 285 | } |
| 286 | } |
Patrick Delaunay | ae0931d0 | 2019-07-30 19:16:39 +0200 | [diff] [blame] | 287 | |
| 288 | /* infinite: the boot process must be stopped */ |
| 289 | if (nb_blink == U32_MAX) |
| 290 | hang(); |
| 291 | } |
Patrice Chotard | 204079b | 2018-08-10 17:12:14 +0200 | [diff] [blame] | 292 | |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 293 | static int adc_measurement(ofnode node, int adc_count, int *min_uV, int *max_uV) |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 294 | { |
| 295 | struct ofnode_phandle_args adc_args; |
| 296 | struct udevice *adc; |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 297 | unsigned int raw; |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 298 | int ret, uV; |
| 299 | int i; |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 300 | |
| 301 | for (i = 0; i < adc_count; i++) { |
| 302 | if (ofnode_parse_phandle_with_args(node, "st,adc_usb_pd", |
| 303 | "#io-channel-cells", 0, i, |
| 304 | &adc_args)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 305 | log_debug("can't find /config/st,adc_usb_pd\n"); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | ret = uclass_get_device_by_ofnode(UCLASS_ADC, adc_args.node, |
| 310 | &adc); |
| 311 | |
| 312 | if (ret) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 313 | log_err("Can't get adc device(%d)\n", ret); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 314 | return ret; |
| 315 | } |
| 316 | |
| 317 | ret = adc_channel_single_shot(adc->name, adc_args.args[0], |
| 318 | &raw); |
| 319 | if (ret) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 320 | log_err("single shot failed for %s[%d]!\n", |
| 321 | adc->name, adc_args.args[0]); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 322 | return ret; |
| 323 | } |
| 324 | /* Convert to uV */ |
| 325 | if (!adc_raw_to_uV(adc, raw, &uV)) { |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 326 | if (uV > *max_uV) |
| 327 | *max_uV = uV; |
| 328 | if (uV < *min_uV) |
| 329 | *min_uV = uV; |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 330 | log_debug("%s[%02d] = %u, %d uV\n", |
| 331 | adc->name, adc_args.args[0], raw, uV); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 332 | } else { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 333 | log_err("Can't get uV value for %s[%d]\n", |
| 334 | adc->name, adc_args.args[0]); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 335 | } |
| 336 | } |
| 337 | |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 338 | return 0; |
| 339 | } |
| 340 | |
| 341 | static int board_check_usb_power(void) |
| 342 | { |
| 343 | ofnode node; |
| 344 | int max_uV = 0; |
| 345 | int min_uV = USB_START_HIGH_THRESHOLD_UV; |
| 346 | int adc_count, ret; |
| 347 | u32 nb_blink; |
| 348 | u8 i; |
| 349 | |
| 350 | node = ofnode_path("/config"); |
| 351 | if (!ofnode_valid(node)) { |
| 352 | log_debug("no /config node?\n"); |
| 353 | return -ENOENT; |
| 354 | } |
| 355 | |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 356 | /* |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 357 | * Retrieve the ADC channels devices and get measurement |
| 358 | * for each of them |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 359 | */ |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 360 | adc_count = ofnode_count_phandle_with_args(node, "st,adc_usb_pd", |
| 361 | "#io-channel-cells", 0); |
| 362 | if (adc_count < 0) { |
| 363 | if (adc_count == -ENOENT) |
| 364 | return 0; |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 365 | |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 366 | log_err("Can't find adc channel (%d)\n", adc_count); |
| 367 | |
| 368 | return adc_count; |
| 369 | } |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 370 | |
Patrice Chotard | 7dfa797 | 2020-10-16 09:28:59 +0200 | [diff] [blame] | 371 | /* perform maximum of 2 ADC measurements to detect power supply current */ |
| 372 | for (i = 0; i < 2; i++) { |
| 373 | if (IS_ENABLED(CONFIG_ADC)) |
| 374 | ret = adc_measurement(node, adc_count, &min_uV, &max_uV); |
| 375 | else |
| 376 | ret = -ENODEV; |
| 377 | |
| 378 | if (ret) |
| 379 | return ret; |
| 380 | |
| 381 | /* |
| 382 | * If highest value is inside 1.23 Volts and 2.10 Volts, that means |
| 383 | * board is plugged on an USB-C 3A power supply and boot process can |
| 384 | * continue. |
| 385 | */ |
| 386 | if (max_uV > USB_START_LOW_THRESHOLD_UV && |
| 387 | max_uV <= USB_START_HIGH_THRESHOLD_UV && |
| 388 | min_uV <= USB_LOW_THRESHOLD_UV) |
| 389 | return 0; |
| 390 | |
| 391 | if (i == 0) { |
| 392 | log_err("Previous ADC measurements was not the one expected, retry in 20ms\n"); |
| 393 | mdelay(20); /* equal to max tPDDebounce duration (min 10ms - max 20ms) */ |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | log_notice("****************************************************\n"); |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 398 | /* |
| 399 | * If highest and lowest value are either both below |
| 400 | * USB_LOW_THRESHOLD_UV or both above USB_LOW_THRESHOLD_UV, that |
| 401 | * means USB TYPE-C is in unattached mode, this is an issue, make |
| 402 | * u-boot,error-led blinking and stop boot process. |
| 403 | */ |
| 404 | if ((max_uV > USB_LOW_THRESHOLD_UV && |
| 405 | min_uV > USB_LOW_THRESHOLD_UV) || |
| 406 | (max_uV <= USB_LOW_THRESHOLD_UV && |
| 407 | min_uV <= USB_LOW_THRESHOLD_UV)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 408 | log_notice("* ERROR USB TYPE-C connection in unattached mode *\n"); |
| 409 | log_notice("* Check that USB TYPE-C cable is correctly plugged *\n"); |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 410 | /* with 125ms interval, led will blink for 17.02 years ....*/ |
| 411 | nb_blink = U32_MAX; |
| 412 | } |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 413 | |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 414 | if (max_uV > USB_LOW_THRESHOLD_UV && |
| 415 | max_uV <= USB_WARNING_LOW_THRESHOLD_UV && |
| 416 | min_uV <= USB_LOW_THRESHOLD_UV) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 417 | log_notice("* WARNING 500mA power supply detected *\n"); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 418 | nb_blink = 2; |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 419 | } |
| 420 | |
| 421 | if (max_uV > USB_WARNING_LOW_THRESHOLD_UV && |
| 422 | max_uV <= USB_START_LOW_THRESHOLD_UV && |
| 423 | min_uV <= USB_LOW_THRESHOLD_UV) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 424 | log_notice("* WARNING 1.5A power supply detected *\n"); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 425 | nb_blink = 3; |
| 426 | } |
| 427 | |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 428 | /* |
| 429 | * If highest value is above 2.15 Volts that means that the USB TypeC |
| 430 | * supplies more than 3 Amp, this is not compliant with TypeC specification |
| 431 | */ |
| 432 | if (max_uV > USB_START_HIGH_THRESHOLD_UV) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 433 | log_notice("* USB TYPE-C charger not compliant with *\n"); |
| 434 | log_notice("* specification *\n"); |
| 435 | log_notice("****************************************************\n\n"); |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 436 | /* with 125ms interval, led will blink for 17.02 years ....*/ |
| 437 | nb_blink = U32_MAX; |
| 438 | } else { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 439 | log_notice("* Current too low, use a 3A power supply! *\n"); |
| 440 | log_notice("****************************************************\n\n"); |
Patrice Chotard | cded32f | 2019-04-30 18:09:38 +0200 | [diff] [blame] | 441 | } |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 442 | |
Patrick Delaunay | ae0931d0 | 2019-07-30 19:16:39 +0200 | [diff] [blame] | 443 | led_error_blink(nb_blink); |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 444 | |
| 445 | return 0; |
| 446 | } |
| 447 | |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 448 | static void sysconf_init(void) |
| 449 | { |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 450 | u8 *syscfg; |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 451 | struct udevice *pwr_dev; |
| 452 | struct udevice *pwr_reg; |
| 453 | struct udevice *dev; |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 454 | u32 otp = 0; |
Patrick Delaunay | 181298e | 2020-04-22 14:29:16 +0200 | [diff] [blame] | 455 | int ret; |
| 456 | u32 bootr, val; |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 457 | |
| 458 | syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG); |
| 459 | |
| 460 | /* interconnect update : select master using the port 1 */ |
| 461 | /* LTDC = AXI_M9 */ |
| 462 | /* GPU = AXI_M8 */ |
| 463 | /* today information is hardcoded in U-Boot */ |
| 464 | writel(BIT(9), syscfg + SYSCFG_ICNR); |
| 465 | |
| 466 | /* disable Pull-Down for boot pin connected to VDD */ |
| 467 | bootr = readl(syscfg + SYSCFG_BOOTR); |
| 468 | bootr &= ~(SYSCFG_BOOTR_BOOT_MASK << SYSCFG_BOOTR_BOOTPD_SHIFT); |
| 469 | bootr |= (bootr & SYSCFG_BOOTR_BOOT_MASK) << SYSCFG_BOOTR_BOOTPD_SHIFT; |
| 470 | writel(bootr, syscfg + SYSCFG_BOOTR); |
| 471 | |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 472 | /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI |
| 473 | * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection. |
| 474 | * The customer will have to disable this for low frequencies |
| 475 | * or if AFMUX is selected but the function not used, typically for |
| 476 | * TRACE. Otherwise, impact on power consumption. |
| 477 | * |
| 478 | * WARNING: |
| 479 | * enabling High Speed mode while VDD>2.7V |
| 480 | * with the OTP product_below_2v5 (OTP 18, BIT 13) |
| 481 | * erroneously set to 1 can damage the IC! |
| 482 | * => U-Boot set the register only if VDD < 2.7V (in DT) |
| 483 | * but this value need to be consistent with board design |
| 484 | */ |
Patrick Delaunay | 6b2baa0 | 2019-07-30 19:16:42 +0200 | [diff] [blame] | 485 | ret = uclass_get_device_by_driver(UCLASS_PMIC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 486 | DM_DRIVER_GET(stm32mp_pwr_pmic), |
Patrick Delaunay | 6b2baa0 | 2019-07-30 19:16:42 +0200 | [diff] [blame] | 487 | &pwr_dev); |
Patrick Delaunay | 4b2bfd6 | 2020-07-31 16:31:45 +0200 | [diff] [blame] | 488 | if (!ret && IS_ENABLED(CONFIG_DM_REGULATOR)) { |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 489 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 490 | DM_DRIVER_GET(stm32mp_bsec), |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 491 | &dev); |
| 492 | if (ret) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 493 | log_err("Can't find stm32mp_bsec driver\n"); |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 494 | return; |
| 495 | } |
| 496 | |
| 497 | ret = misc_read(dev, STM32_BSEC_SHADOW(18), &otp, 4); |
Patrick Delaunay | ceb82e3 | 2019-08-02 13:08:06 +0200 | [diff] [blame] | 498 | if (ret > 0) |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 499 | otp = otp & BIT(13); |
| 500 | |
Patrick Delaunay | 6b2baa0 | 2019-07-30 19:16:42 +0200 | [diff] [blame] | 501 | /* get VDD = vdd-supply */ |
| 502 | ret = device_get_supply_regulator(pwr_dev, "vdd-supply", |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 503 | &pwr_reg); |
| 504 | |
| 505 | /* check if VDD is Low Voltage */ |
| 506 | if (!ret) { |
| 507 | if (regulator_get_value(pwr_reg) < 2700000) { |
| 508 | writel(SYSCFG_IOCTRLSETR_HSLVEN_TRACE | |
| 509 | SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI | |
| 510 | SYSCFG_IOCTRLSETR_HSLVEN_ETH | |
| 511 | SYSCFG_IOCTRLSETR_HSLVEN_SDMMC | |
| 512 | SYSCFG_IOCTRLSETR_HSLVEN_SPI, |
| 513 | syscfg + SYSCFG_IOCTRLSETR); |
| 514 | |
| 515 | if (!otp) |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 516 | log_err("product_below_2v5=0: HSLVEN protected by HW\n"); |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 517 | } else { |
| 518 | if (otp) |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 519 | log_err("product_below_2v5=1: HSLVEN update is destructive, no update as VDD>2.7V\n"); |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 520 | } |
| 521 | } else { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 522 | log_debug("VDD unknown"); |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 523 | } |
| 524 | } |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 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 | |
Patrick Delaunay | 181298e | 2020-04-22 14:29:16 +0200 | [diff] [blame] | 531 | /* poll until ready (1s timeout) */ |
| 532 | ret = readl_poll_timeout(syscfg + SYSCFG_CMPCR, val, |
| 533 | val & SYSCFG_CMPCR_READY, |
| 534 | 1000000); |
| 535 | if (ret) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 536 | log_err("SYSCFG: I/O compensation failed, timeout.\n"); |
Patrick Delaunay | 181298e | 2020-04-22 14:29:16 +0200 | [diff] [blame] | 537 | led_error_blink(10); |
| 538 | } |
| 539 | |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 540 | clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL); |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 541 | } |
| 542 | |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 543 | /* Fix to make I2C1 usable on DK2 for touchscreen usage in kernel */ |
| 544 | static int dk2_i2c1_fix(void) |
| 545 | { |
| 546 | ofnode node; |
| 547 | struct gpio_desc hdmi, audio; |
| 548 | int ret = 0; |
| 549 | |
Patrick Delaunay | c75bc6a | 2020-07-31 16:31:47 +0200 | [diff] [blame] | 550 | if (!IS_ENABLED(CONFIG_DM_REGULATOR)) |
| 551 | return -ENODEV; |
| 552 | |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 553 | node = ofnode_path("/soc/i2c@40012000/hdmi-transmitter@39"); |
| 554 | if (!ofnode_valid(node)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 555 | log_debug("no hdmi-transmitter@39 ?\n"); |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 556 | return -ENOENT; |
| 557 | } |
| 558 | |
| 559 | if (gpio_request_by_name_nodev(node, "reset-gpios", 0, |
| 560 | &hdmi, GPIOD_IS_OUT)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 561 | log_debug("could not find reset-gpios\n"); |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 562 | return -ENOENT; |
| 563 | } |
| 564 | |
| 565 | node = ofnode_path("/soc/i2c@40012000/cs42l51@4a"); |
| 566 | if (!ofnode_valid(node)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 567 | log_debug("no cs42l51@4a ?\n"); |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 568 | return -ENOENT; |
| 569 | } |
| 570 | |
| 571 | if (gpio_request_by_name_nodev(node, "reset-gpios", 0, |
| 572 | &audio, GPIOD_IS_OUT)) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 573 | log_debug("could not find reset-gpios\n"); |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 574 | return -ENOENT; |
| 575 | } |
| 576 | |
| 577 | /* before power up, insure that HDMI and AUDIO IC is under reset */ |
| 578 | ret = dm_gpio_set_value(&hdmi, 1); |
| 579 | if (ret) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 580 | log_err("can't set_value for hdmi_nrst gpio"); |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 581 | goto error; |
| 582 | } |
| 583 | ret = dm_gpio_set_value(&audio, 1); |
| 584 | if (ret) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 585 | log_err("can't set_value for audio_nrst gpio"); |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 586 | goto error; |
| 587 | } |
| 588 | |
| 589 | /* power-up audio IC */ |
| 590 | regulator_autoset_by_name("v1v8_audio", NULL); |
| 591 | |
| 592 | /* power-up HDMI IC */ |
| 593 | regulator_autoset_by_name("v1v2_hdmi", NULL); |
| 594 | regulator_autoset_by_name("v3v3_hdmi", NULL); |
| 595 | |
| 596 | error: |
| 597 | return ret; |
| 598 | } |
| 599 | |
| 600 | static bool board_is_dk2(void) |
| 601 | { |
Patrick Delaunay | 310aa8a | 2020-01-13 15:17:42 +0100 | [diff] [blame] | 602 | if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) && |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 603 | of_machine_is_compatible("st,stm32mp157c-dk2")) |
| 604 | return true; |
| 605 | |
| 606 | return false; |
| 607 | } |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 608 | |
Patrick Delaunay | 486ae96 | 2020-04-22 14:29:13 +0200 | [diff] [blame] | 609 | static bool board_is_ev1(void) |
| 610 | { |
| 611 | if (CONFIG_IS_ENABLED(TARGET_ST_STM32MP15x) && |
| 612 | (of_machine_is_compatible("st,stm32mp157a-ev1") || |
| 613 | of_machine_is_compatible("st,stm32mp157c-ev1") || |
| 614 | of_machine_is_compatible("st,stm32mp157d-ev1") || |
| 615 | of_machine_is_compatible("st,stm32mp157f-ev1"))) |
| 616 | return true; |
| 617 | |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | /* touchscreen driver: only used for pincontrol configuration */ |
| 622 | static const struct udevice_id goodix_ids[] = { |
| 623 | { .compatible = "goodix,gt9147", }, |
| 624 | { } |
| 625 | }; |
| 626 | |
| 627 | U_BOOT_DRIVER(goodix) = { |
| 628 | .name = "goodix", |
| 629 | .id = UCLASS_NOP, |
| 630 | .of_match = goodix_ids, |
| 631 | }; |
| 632 | |
| 633 | static void board_ev1_init(void) |
| 634 | { |
| 635 | struct udevice *dev; |
| 636 | |
| 637 | /* configure IRQ line on EV1 for touchscreen before LCD reset */ |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 638 | uclass_get_device_by_driver(UCLASS_NOP, DM_DRIVER_GET(goodix), &dev); |
Patrick Delaunay | 486ae96 | 2020-04-22 14:29:13 +0200 | [diff] [blame] | 639 | } |
| 640 | |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 641 | /* board dependent setup after realloc */ |
| 642 | int board_init(void) |
| 643 | { |
| 644 | /* address of boot parameters */ |
| 645 | gd->bd->bi_boot_params = STM32_DDR_BASE + 0x100; |
| 646 | |
Patrick Delaunay | 9789640 | 2020-06-04 14:30:24 +0200 | [diff] [blame] | 647 | if (CONFIG_IS_ENABLED(DM_GPIO_HOG)) |
| 648 | gpio_hog_probe_all(); |
Patrice Chotard | 972723a | 2019-03-11 11:13:17 +0100 | [diff] [blame] | 649 | |
Patrick Delaunay | 008d3c3 | 2019-02-27 17:01:20 +0100 | [diff] [blame] | 650 | board_key_check(); |
| 651 | |
Patrick Delaunay | 486ae96 | 2020-04-22 14:29:13 +0200 | [diff] [blame] | 652 | if (board_is_ev1()) |
| 653 | board_ev1_init(); |
| 654 | |
Patrick Delaunay | 9f76fdf | 2019-07-30 19:16:38 +0200 | [diff] [blame] | 655 | if (board_is_dk2()) |
| 656 | dk2_i2c1_fix(); |
| 657 | |
Patrick Delaunay | c75bc6a | 2020-07-31 16:31:47 +0200 | [diff] [blame] | 658 | if (IS_ENABLED(CONFIG_DM_REGULATOR)) |
| 659 | regulators_enable_boot_on(_DEBUG); |
Patrick Delaunay | 6519e44 | 2019-07-05 17:20:09 +0200 | [diff] [blame] | 660 | |
Patrick Delaunay | 4b2bfd6 | 2020-07-31 16:31:45 +0200 | [diff] [blame] | 661 | if (!IS_ENABLED(CONFIG_TFABOOT)) |
| 662 | sysconf_init(); |
Patrick Delaunay | 4ace1d1 | 2019-02-27 17:01:24 +0100 | [diff] [blame] | 663 | |
Patrick Delaunay | 78f68f2 | 2020-04-10 19:14:01 +0200 | [diff] [blame] | 664 | if (CONFIG_IS_ENABLED(LED)) |
Patrick Delaunay | 36e3d11 | 2018-07-27 16:37:08 +0200 | [diff] [blame] | 665 | led_default_state(); |
| 666 | |
Patrick Delaunay | 8ae05cf | 2020-04-22 14:29:12 +0200 | [diff] [blame] | 667 | setup_led(LEDST_ON); |
| 668 | |
Patrick Delaunay | 8eb3b1e | 2018-03-12 10:46:18 +0100 | [diff] [blame] | 669 | return 0; |
| 670 | } |
Patrick Delaunay | d70e3f8 | 2019-02-27 17:01:11 +0100 | [diff] [blame] | 671 | |
| 672 | int board_late_init(void) |
| 673 | { |
Patrick Delaunay | d70e3f8 | 2019-02-27 17:01:11 +0100 | [diff] [blame] | 674 | const void *fdt_compat; |
| 675 | int fdt_compat_len; |
Patrick Delaunay | e8566ec | 2019-07-30 19:16:37 +0200 | [diff] [blame] | 676 | int ret; |
| 677 | u32 otp; |
| 678 | struct udevice *dev; |
| 679 | char buf[10]; |
Patrick Delaunay | f118e4a | 2020-07-31 16:31:48 +0200 | [diff] [blame] | 680 | char dtb_name[256]; |
| 681 | int buf_len; |
Patrick Delaunay | d70e3f8 | 2019-02-27 17:01:11 +0100 | [diff] [blame] | 682 | |
Patrick Delaunay | f118e4a | 2020-07-31 16:31:48 +0200 | [diff] [blame] | 683 | if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) { |
| 684 | fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible", |
| 685 | &fdt_compat_len); |
| 686 | if (fdt_compat && fdt_compat_len) { |
| 687 | if (strncmp(fdt_compat, "st,", 3) != 0) { |
| 688 | env_set("board_name", fdt_compat); |
| 689 | } else { |
| 690 | env_set("board_name", fdt_compat + 3); |
Patrick Delaunay | 4533a2c | 2020-04-22 14:29:14 +0200 | [diff] [blame] | 691 | |
Patrick Delaunay | f118e4a | 2020-07-31 16:31:48 +0200 | [diff] [blame] | 692 | buf_len = sizeof(dtb_name); |
| 693 | strncpy(dtb_name, fdt_compat + 3, buf_len); |
| 694 | buf_len -= strlen(fdt_compat + 3); |
| 695 | strncat(dtb_name, ".dtb", buf_len); |
| 696 | env_set("fdtfile", dtb_name); |
| 697 | } |
Patrick Delaunay | 4533a2c | 2020-04-22 14:29:14 +0200 | [diff] [blame] | 698 | } |
Patrick Delaunay | f118e4a | 2020-07-31 16:31:48 +0200 | [diff] [blame] | 699 | ret = uclass_get_device_by_driver(UCLASS_MISC, |
Simon Glass | 65130cd | 2020-12-28 20:34:56 -0700 | [diff] [blame] | 700 | DM_DRIVER_GET(stm32mp_bsec), |
Patrick Delaunay | f118e4a | 2020-07-31 16:31:48 +0200 | [diff] [blame] | 701 | &dev); |
Patrick Delaunay | e8566ec | 2019-07-30 19:16:37 +0200 | [diff] [blame] | 702 | |
Patrick Delaunay | f118e4a | 2020-07-31 16:31:48 +0200 | [diff] [blame] | 703 | if (!ret) |
| 704 | ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), |
| 705 | &otp, sizeof(otp)); |
| 706 | if (ret > 0 && otp) { |
| 707 | snprintf(buf, sizeof(buf), "0x%04x", otp >> 16); |
| 708 | env_set("board_id", buf); |
Patrick Delaunay | e8566ec | 2019-07-30 19:16:37 +0200 | [diff] [blame] | 709 | |
Patrick Delaunay | f118e4a | 2020-07-31 16:31:48 +0200 | [diff] [blame] | 710 | snprintf(buf, sizeof(buf), "0x%04x", |
| 711 | ((otp >> 8) & 0xF) - 1 + 0xA); |
| 712 | env_set("board_rev", buf); |
| 713 | } |
Patrick Delaunay | e8566ec | 2019-07-30 19:16:37 +0200 | [diff] [blame] | 714 | } |
Patrick Delaunay | d70e3f8 | 2019-02-27 17:01:11 +0100 | [diff] [blame] | 715 | |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 716 | /* for DK1/DK2 boards */ |
| 717 | board_check_usb_power(); |
| 718 | |
Patrick Delaunay | d70e3f8 | 2019-02-27 17:01:11 +0100 | [diff] [blame] | 719 | return 0; |
| 720 | } |
Patrice Chotard | 879cde5 | 2019-02-12 16:50:40 +0100 | [diff] [blame] | 721 | |
| 722 | void board_quiesce_devices(void) |
| 723 | { |
| 724 | setup_led(LEDST_OFF); |
| 725 | } |
Patrice Chotard | 41443cf | 2019-05-02 18:07:14 +0200 | [diff] [blame] | 726 | |
Patrick Delaunay | bff66f9 | 2019-08-01 11:29:03 +0200 | [diff] [blame] | 727 | /* eth init function : weak called in eqos driver */ |
| 728 | int board_interface_eth_init(struct udevice *dev, |
| 729 | phy_interface_t interface_type) |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 730 | { |
| 731 | u8 *syscfg; |
| 732 | u32 value; |
Patrick Delaunay | bff66f9 | 2019-08-01 11:29:03 +0200 | [diff] [blame] | 733 | bool eth_clk_sel_reg = false; |
| 734 | bool eth_ref_clk_sel_reg = false; |
| 735 | |
| 736 | /* Gigabit Ethernet 125MHz clock selection. */ |
| 737 | eth_clk_sel_reg = dev_read_bool(dev, "st,eth_clk_sel"); |
| 738 | |
| 739 | /* Ethernet 50Mhz RMII clock selection */ |
| 740 | eth_ref_clk_sel_reg = |
| 741 | dev_read_bool(dev, "st,eth_ref_clk_sel"); |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 742 | |
| 743 | syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG); |
| 744 | |
| 745 | if (!syscfg) |
| 746 | return -ENODEV; |
| 747 | |
| 748 | switch (interface_type) { |
| 749 | case PHY_INTERFACE_MODE_MII: |
| 750 | value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII | |
| 751 | SYSCFG_PMCSETR_ETH_REF_CLK_SEL; |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 752 | log_debug("PHY_INTERFACE_MODE_MII\n"); |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 753 | break; |
| 754 | case PHY_INTERFACE_MODE_GMII: |
| 755 | if (eth_clk_sel_reg) |
| 756 | value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII | |
| 757 | SYSCFG_PMCSETR_ETH_CLK_SEL; |
| 758 | else |
| 759 | value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII; |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 760 | log_debug("PHY_INTERFACE_MODE_GMII\n"); |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 761 | break; |
| 762 | case PHY_INTERFACE_MODE_RMII: |
| 763 | if (eth_ref_clk_sel_reg) |
| 764 | value = SYSCFG_PMCSETR_ETH_SEL_RMII | |
| 765 | SYSCFG_PMCSETR_ETH_REF_CLK_SEL; |
| 766 | else |
| 767 | value = SYSCFG_PMCSETR_ETH_SEL_RMII; |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 768 | log_debug("PHY_INTERFACE_MODE_RMII\n"); |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 769 | break; |
| 770 | case PHY_INTERFACE_MODE_RGMII: |
| 771 | case PHY_INTERFACE_MODE_RGMII_ID: |
| 772 | case PHY_INTERFACE_MODE_RGMII_RXID: |
| 773 | case PHY_INTERFACE_MODE_RGMII_TXID: |
| 774 | if (eth_clk_sel_reg) |
| 775 | value = SYSCFG_PMCSETR_ETH_SEL_RGMII | |
| 776 | SYSCFG_PMCSETR_ETH_CLK_SEL; |
| 777 | else |
| 778 | value = SYSCFG_PMCSETR_ETH_SEL_RGMII; |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 779 | log_debug("PHY_INTERFACE_MODE_RGMII\n"); |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 780 | break; |
| 781 | default: |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 782 | log_debug("Do not manage %d interface\n", |
| 783 | interface_type); |
Christophe Roullier | 69ac3f5 | 2019-05-17 15:08:43 +0200 | [diff] [blame] | 784 | /* Do not manage others interfaces */ |
| 785 | return -EINVAL; |
| 786 | } |
| 787 | |
| 788 | /* clear and set ETH configuration bits */ |
| 789 | writel(SYSCFG_PMCSETR_ETH_SEL_MASK | SYSCFG_PMCSETR_ETH_SELMII | |
| 790 | SYSCFG_PMCSETR_ETH_REF_CLK_SEL | SYSCFG_PMCSETR_ETH_CLK_SEL, |
| 791 | syscfg + SYSCFG_PMCCLRR); |
| 792 | writel(value, syscfg + SYSCFG_PMCSETR); |
| 793 | |
| 794 | return 0; |
| 795 | } |
| 796 | |
Patrice Chotard | 3432037 | 2019-05-02 18:28:05 +0200 | [diff] [blame] | 797 | enum env_location env_get_location(enum env_operation op, int prio) |
| 798 | { |
| 799 | u32 bootmode = get_bootmode(); |
| 800 | |
| 801 | if (prio) |
| 802 | return ENVL_UNKNOWN; |
| 803 | |
| 804 | switch (bootmode & TAMP_BOOT_DEVICE_MASK) { |
Patrick Delaunay | 455b065 | 2020-06-15 11:18:22 +0200 | [diff] [blame] | 805 | case BOOT_FLASH_SD: |
| 806 | case BOOT_FLASH_EMMC: |
Patrick Delaunay | 821a9ba | 2020-07-31 16:31:49 +0200 | [diff] [blame] | 807 | if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC)) |
| 808 | return ENVL_MMC; |
| 809 | else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4)) |
| 810 | return ENVL_EXT4; |
| 811 | else |
| 812 | return ENVL_NOWHERE; |
| 813 | |
Patrice Chotard | 3432037 | 2019-05-02 18:28:05 +0200 | [diff] [blame] | 814 | case BOOT_FLASH_NAND: |
Patrick Delaunay | b5a7ca2 | 2020-03-18 09:22:52 +0100 | [diff] [blame] | 815 | case BOOT_FLASH_SPINAND: |
Patrick Delaunay | 821a9ba | 2020-07-31 16:31:49 +0200 | [diff] [blame] | 816 | if (CONFIG_IS_ENABLED(ENV_IS_IN_UBI)) |
| 817 | return ENVL_UBI; |
| 818 | else |
| 819 | return ENVL_NOWHERE; |
| 820 | |
Patrice Chotard | 2c461ec | 2019-05-09 14:25:36 +0200 | [diff] [blame] | 821 | case BOOT_FLASH_NOR: |
Patrick Delaunay | 821a9ba | 2020-07-31 16:31:49 +0200 | [diff] [blame] | 822 | if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH)) |
| 823 | return ENVL_SPI_FLASH; |
| 824 | else |
| 825 | return ENVL_NOWHERE; |
| 826 | |
Patrice Chotard | 3432037 | 2019-05-02 18:28:05 +0200 | [diff] [blame] | 827 | default: |
| 828 | return ENVL_NOWHERE; |
| 829 | } |
| 830 | } |
| 831 | |
Patrice Chotard | dad97bf | 2019-05-02 18:36:01 +0200 | [diff] [blame] | 832 | const char *env_ext4_get_intf(void) |
| 833 | { |
| 834 | u32 bootmode = get_bootmode(); |
| 835 | |
| 836 | switch (bootmode & TAMP_BOOT_DEVICE_MASK) { |
| 837 | case BOOT_FLASH_SD: |
| 838 | case BOOT_FLASH_EMMC: |
| 839 | return "mmc"; |
| 840 | default: |
| 841 | return ""; |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | const char *env_ext4_get_dev_part(void) |
| 846 | { |
Manuel Reis | be9d3e2 | 2020-11-25 10:16:20 +0000 | [diff] [blame] | 847 | static char *const env_dev_part = |
| 848 | #ifdef CONFIG_ENV_EXT4_DEVICE_AND_PART |
| 849 | CONFIG_ENV_EXT4_DEVICE_AND_PART; |
| 850 | #else |
| 851 | ""; |
| 852 | #endif |
Patrice Chotard | dad97bf | 2019-05-02 18:36:01 +0200 | [diff] [blame] | 853 | static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"}; |
Manuel Reis | be9d3e2 | 2020-11-25 10:16:20 +0000 | [diff] [blame] | 854 | |
| 855 | if (strlen(env_dev_part) > 0) |
| 856 | return env_dev_part; |
| 857 | |
Patrice Chotard | dad97bf | 2019-05-02 18:36:01 +0200 | [diff] [blame] | 858 | u32 bootmode = get_bootmode(); |
| 859 | |
| 860 | return dev_part[(bootmode & TAMP_BOOT_INSTANCE_MASK) - 1]; |
| 861 | } |
Manuel Reis | be9d3e2 | 2020-11-25 10:16:20 +0000 | [diff] [blame] | 862 | |
Patrick Delaunay | 455b065 | 2020-06-15 11:18:22 +0200 | [diff] [blame] | 863 | int mmc_get_env_dev(void) |
| 864 | { |
| 865 | u32 bootmode = get_bootmode(); |
| 866 | |
| 867 | return (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1; |
| 868 | } |
Patrick Delaunay | 455b065 | 2020-06-15 11:18:22 +0200 | [diff] [blame] | 869 | |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 870 | #if defined(CONFIG_OF_BOARD_SETUP) |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 871 | int ft_board_setup(void *blob, struct bd_info *bd) |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 872 | { |
Patrick Delaunay | a8a67ed | 2020-07-29 13:24:52 +0200 | [diff] [blame] | 873 | static const struct node_info nodes[] = { |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 874 | { "st,stm32f469-qspi", MTD_DEV_TYPE_NOR, }, |
Patrick Delaunay | b5a7ca2 | 2020-03-18 09:22:52 +0100 | [diff] [blame] | 875 | { "st,stm32f469-qspi", MTD_DEV_TYPE_SPINAND}, |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 876 | { "st,stm32mp15-fmc2", MTD_DEV_TYPE_NAND, }, |
Christophe Kerello | 15359e4 | 2020-07-31 09:53:42 +0200 | [diff] [blame] | 877 | { "st,stm32mp1-fmc2-nfc", MTD_DEV_TYPE_NAND, }, |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 878 | }; |
Patrick Delaunay | 1b5cd0b | 2020-10-15 14:52:30 +0200 | [diff] [blame] | 879 | char *boot_device; |
Patrick Delaunay | 9d96e90 | 2020-07-31 16:31:50 +0200 | [diff] [blame] | 880 | |
Patrick Delaunay | 1b5cd0b | 2020-10-15 14:52:30 +0200 | [diff] [blame] | 881 | /* Check the boot-source and don't update MTD for serial or usb boot */ |
| 882 | boot_device = env_get("boot_device"); |
| 883 | if (!boot_device || |
| 884 | (strcmp(boot_device, "serial") && strcmp(boot_device, "usb"))) |
| 885 | if (IS_ENABLED(CONFIG_FDT_FIXUP_PARTITIONS)) |
| 886 | fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); |
Patrick Delaunay | de98cbf | 2019-07-02 13:26:07 +0200 | [diff] [blame] | 887 | |
| 888 | return 0; |
| 889 | } |
| 890 | #endif |
Patrick Delaunay | c17d725 | 2019-08-02 15:07:20 +0200 | [diff] [blame] | 891 | |
| 892 | static void board_copro_image_process(ulong fw_image, size_t fw_size) |
| 893 | { |
| 894 | int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */ |
| 895 | |
| 896 | if (!rproc_is_initialized()) |
| 897 | if (rproc_init()) { |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 898 | log_err("Remote Processor %d initialization failed\n", |
| 899 | id); |
Patrick Delaunay | c17d725 | 2019-08-02 15:07:20 +0200 | [diff] [blame] | 900 | return; |
| 901 | } |
| 902 | |
| 903 | ret = rproc_load(id, fw_image, fw_size); |
Patrick Delaunay | f7b2a84 | 2020-11-06 19:01:59 +0100 | [diff] [blame] | 904 | log_err("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n", |
| 905 | id, fw_image, fw_size, ret ? " Failed!" : " Success!"); |
Patrick Delaunay | c17d725 | 2019-08-02 15:07:20 +0200 | [diff] [blame] | 906 | |
Fabien Dessenne | ad6cc94 | 2019-10-30 14:38:32 +0100 | [diff] [blame] | 907 | if (!ret) |
Patrick Delaunay | c17d725 | 2019-08-02 15:07:20 +0200 | [diff] [blame] | 908 | rproc_start(id); |
Patrick Delaunay | c17d725 | 2019-08-02 15:07:20 +0200 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process); |