2
1

0002-Add-OSD32MP1-BRK-build-config.patch 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881
  1. From cbe33390a338428d74a4549cb28e25af42d7f7d9 Mon Sep 17 00:00:00 2001
  2. From: "neeraj.dantu" <dantuguf14105@gmail.com>
  3. Date: Sun, 21 Nov 2021 23:31:02 -0600
  4. Subject: [PATCH 2/2] Add OSD32MP1-BRK build config
  5. Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
  6. ---
  7. arch/arm/mach-stm32mp/Kconfig | 10 +-
  8. board/octavo/osd32mp1-brk/Kconfig | 13 +
  9. board/octavo/osd32mp1-brk/MAINTAINERS | 8 +
  10. board/octavo/osd32mp1-brk/Makefile | 9 +
  11. board/octavo/osd32mp1-brk/board.c | 631 +++++++++++++++++++++++++
  12. configs/osd32mp1_brk_trusted_defconfig | 141 ++++++
  13. 6 files changed, 811 insertions(+), 1 deletion(-)
  14. create mode 100644 board/octavo/osd32mp1-brk/Kconfig
  15. create mode 100644 board/octavo/osd32mp1-brk/MAINTAINERS
  16. create mode 100644 board/octavo/osd32mp1-brk/Makefile
  17. create mode 100644 board/octavo/osd32mp1-brk/board.c
  18. create mode 100644 configs/osd32mp1_brk_trusted_defconfig
  19. diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig
  20. index 44bfac9000..006855acad 100644
  21. --- a/arch/arm/mach-stm32mp/Kconfig
  22. +++ b/arch/arm/mach-stm32mp/Kconfig
  23. @@ -92,6 +92,14 @@ config TARGET_DH_STM32MP1_PDK2
  24. help
  25. Target the DH PDK2 development kit with STM32MP15x SoM.
  26. +config TARGET_OCTAVO_OSD32MP1_BRK
  27. + bool "Octavo OSD32MP1 BRK"
  28. + select STM32MP15x
  29. + imply BOOTCOUNT_LIMIT
  30. + imply CMD_BOOTCOUNT
  31. + help
  32. + Target the Octavo BRK board based on OSD32MP1 SiP.
  33. +
  34. endchoice
  35. config SYS_TEXT_BASE
  36. @@ -172,5 +180,5 @@ endif
  37. source "arch/arm/mach-stm32mp/cmd_stm32prog/Kconfig"
  38. source "board/st/stm32mp1/Kconfig"
  39. source "board/dhelectronics/dh_stm32mp1/Kconfig"
  40. -
  41. +source "board/octavo/osd32mp1-brk/Kconfig"
  42. endif
  43. diff --git a/board/octavo/osd32mp1-brk/Kconfig b/board/octavo/osd32mp1-brk/Kconfig
  44. new file mode 100644
  45. index 0000000000..907a09c170
  46. --- /dev/null
  47. +++ b/board/octavo/osd32mp1-brk/Kconfig
  48. @@ -0,0 +1,13 @@
  49. +if TARGET_OCTAVO_OSD32MP1_BRK
  50. +
  51. +config SYS_BOARD
  52. + default "osd32mp1-brk"
  53. +
  54. +config SYS_VENDOR
  55. + default "octavo"
  56. +
  57. +config SYS_CONFIG_NAME
  58. + default "stm32mp1"
  59. +
  60. +source "board/st/common/Kconfig"
  61. +endif
  62. diff --git a/board/octavo/osd32mp1-brk/MAINTAINERS b/board/octavo/osd32mp1-brk/MAINTAINERS
  63. new file mode 100644
  64. index 0000000000..9c0addbc21
  65. --- /dev/null
  66. +++ b/board/octavo/osd32mp1-brk/MAINTAINERS
  67. @@ -0,0 +1,8 @@
  68. +OCTAVO osd32mp1-brk BOARD
  69. +M: Martin Lesniak <martin.lesniak@st.com>
  70. +M: Neeraj Dantu <neeraj.dantu@octavosystems.com>
  71. +S: Maintained
  72. +F: arch/arm/dts/stm32mp157c-osd32mp1-brk*
  73. +F: board/Octavo/osd32mp1-brk/
  74. +F: configs/osd32mp1_brk_trusted_defconfig
  75. +F: include/configs/stm32mp1.h
  76. diff --git a/board/octavo/osd32mp1-brk/Makefile b/board/octavo/osd32mp1-brk/Makefile
  77. new file mode 100644
  78. index 0000000000..b368b396a4
  79. --- /dev/null
  80. +++ b/board/octavo/osd32mp1-brk/Makefile
  81. @@ -0,0 +1,9 @@
  82. +# SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  83. +#
  84. +# Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  85. +#
  86. +
  87. +obj-y += ../../st/common/stpmic1.o board.o
  88. +
  89. +obj-$(CONFIG_SYS_MTDPARTS_RUNTIME) += ../../st/common/stm32mp_mtdparts.o
  90. +obj-$(CONFIG_SET_DFU_ALT_INFO) += ../../st/common/stm32mp_dfu.o
  91. diff --git a/board/octavo/osd32mp1-brk/board.c b/board/octavo/osd32mp1-brk/board.c
  92. new file mode 100644
  93. index 0000000000..fd97c9a390
  94. --- /dev/null
  95. +++ b/board/octavo/osd32mp1-brk/board.c
  96. @@ -0,0 +1,631 @@
  97. +// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  98. +/*
  99. + * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
  100. + */
  101. +#include <common.h>
  102. +#include <adc.h>
  103. +#include <bootm.h>
  104. +#include <clk.h>
  105. +#include <config.h>
  106. +#include <dm.h>
  107. +#include <env.h>
  108. +#include <env_internal.h>
  109. +#include <fdt_support.h>
  110. +#include <g_dnl.h>
  111. +#include <generic-phy.h>
  112. +#include <hang.h>
  113. +#include <i2c.h>
  114. +#include <i2c_eeprom.h>
  115. +#include <init.h>
  116. +#include <led.h>
  117. +#include <log.h>
  118. +#include <malloc.h>
  119. +#include <misc.h>
  120. +#include <mtd_node.h>
  121. +#include <net.h>
  122. +#include <netdev.h>
  123. +#include <phy.h>
  124. +#include <remoteproc.h>
  125. +#include <reset.h>
  126. +#include <syscon.h>
  127. +#include <usb.h>
  128. +#include <watchdog.h>
  129. +#include <asm/io.h>
  130. +#include <asm/gpio.h>
  131. +#include <asm/arch/stm32.h>
  132. +#include <asm/arch/sys_proto.h>
  133. +#include <jffs2/load_kernel.h>
  134. +#include <linux/bitops.h>
  135. +#include <linux/delay.h>
  136. +#include <linux/err.h>
  137. +#include <linux/iopoll.h>
  138. +#include <power/regulator.h>
  139. +#include <usb/dwc2_udc.h>
  140. +
  141. +/* SYSCFG registers */
  142. +#define SYSCFG_BOOTR 0x00
  143. +#define SYSCFG_PMCSETR 0x04
  144. +#define SYSCFG_IOCTRLSETR 0x18
  145. +#define SYSCFG_ICNR 0x1C
  146. +#define SYSCFG_CMPCR 0x20
  147. +#define SYSCFG_CMPENSETR 0x24
  148. +#define SYSCFG_PMCCLRR 0x44
  149. +
  150. +#define SYSCFG_BOOTR_BOOT_MASK GENMASK(2, 0)
  151. +#define SYSCFG_BOOTR_BOOTPD_SHIFT 4
  152. +
  153. +#define SYSCFG_IOCTRLSETR_HSLVEN_TRACE BIT(0)
  154. +#define SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI BIT(1)
  155. +#define SYSCFG_IOCTRLSETR_HSLVEN_ETH BIT(2)
  156. +#define SYSCFG_IOCTRLSETR_HSLVEN_SDMMC BIT(3)
  157. +#define SYSCFG_IOCTRLSETR_HSLVEN_SPI BIT(4)
  158. +
  159. +#define SYSCFG_CMPCR_SW_CTRL BIT(1)
  160. +#define SYSCFG_CMPCR_READY BIT(8)
  161. +
  162. +#define SYSCFG_CMPENSETR_MPU_EN BIT(0)
  163. +
  164. +#define SYSCFG_PMCSETR_ETH_CLK_SEL BIT(16)
  165. +#define SYSCFG_PMCSETR_ETH_REF_CLK_SEL BIT(17)
  166. +
  167. +#define SYSCFG_PMCSETR_ETH_SELMII BIT(20)
  168. +
  169. +#define SYSCFG_PMCSETR_ETH_SEL_MASK GENMASK(23, 21)
  170. +#define SYSCFG_PMCSETR_ETH_SEL_GMII_MII 0
  171. +#define SYSCFG_PMCSETR_ETH_SEL_RGMII BIT(21)
  172. +#define SYSCFG_PMCSETR_ETH_SEL_RMII BIT(23)
  173. +
  174. +/*
  175. + * Get a global data pointer
  176. + */
  177. +DECLARE_GLOBAL_DATA_PTR;
  178. +
  179. +int setup_mac_address(void)
  180. +{
  181. + struct udevice *dev;
  182. + ofnode eeprom;
  183. + unsigned char enetaddr[6];
  184. + int ret;
  185. +
  186. + ret = eth_env_get_enetaddr("ethaddr", enetaddr);
  187. + if (ret) /* ethaddr is already set */
  188. + return 0;
  189. +
  190. + eeprom = ofnode_path("/soc/i2c@5c002000/eeprom@50");
  191. + if (!ofnode_valid(eeprom)) {
  192. + printf("Invalid hardware path to EEPROM!\n");
  193. + return -ENODEV;
  194. + }
  195. +
  196. + ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev);
  197. + if (ret) {
  198. + printf("Cannot find EEPROM!\n");
  199. + return ret;
  200. + }
  201. +
  202. + ret = i2c_eeprom_read(dev, 0xfa, enetaddr, 0x6);
  203. + if (ret) {
  204. + printf("Error reading configuration EEPROM!\n");
  205. + return ret;
  206. + }
  207. +
  208. + if (is_valid_ethaddr(enetaddr))
  209. + eth_env_set_enetaddr("ethaddr", enetaddr);
  210. +
  211. + return 0;
  212. +}
  213. +
  214. +int checkboard(void)
  215. +{
  216. + char *mode;
  217. + const char *fdt_compat;
  218. + int fdt_compat_len;
  219. +
  220. + if (IS_ENABLED(CONFIG_STM32MP15x_STM32IMAGE))
  221. + mode = "trusted - stm32image";
  222. + else if (IS_ENABLED(CONFIG_TFABOOT))
  223. + mode = "trusted";
  224. + else
  225. + mode = "basic";
  226. +
  227. + printf("Board: stm32mp1 in %s mode", mode);
  228. + fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
  229. + &fdt_compat_len);
  230. + if (fdt_compat && fdt_compat_len)
  231. + printf(" (%s)", fdt_compat);
  232. + puts("\n");
  233. +
  234. + return 0;
  235. +}
  236. +
  237. +static void board_key_check(void)
  238. +{
  239. + ofnode node;
  240. + struct gpio_desc gpio;
  241. + enum forced_boot_mode boot_mode = BOOT_NORMAL;
  242. +
  243. + if (!IS_ENABLED(CONFIG_FASTBOOT) && !IS_ENABLED(CONFIG_CMD_STM32PROG))
  244. + return;
  245. +
  246. + node = ofnode_path("/config");
  247. + if (!ofnode_valid(node)) {
  248. + debug("%s: no /config node?\n", __func__);
  249. + return;
  250. + }
  251. + if (IS_ENABLED(CONFIG_FASTBOOT)) {
  252. + if (gpio_request_by_name_nodev(node, "st,fastboot-gpios", 0,
  253. + &gpio, GPIOD_IS_IN)) {
  254. + debug("%s: could not find a /config/st,fastboot-gpios\n",
  255. + __func__);
  256. + } else {
  257. + if (dm_gpio_get_value(&gpio)) {
  258. + puts("Fastboot key pressed, ");
  259. + boot_mode = BOOT_FASTBOOT;
  260. + }
  261. +
  262. + dm_gpio_free(NULL, &gpio);
  263. + }
  264. + }
  265. + if (IS_ENABLED(CONFIG_CMD_STM32PROG)) {
  266. + if (gpio_request_by_name_nodev(node, "st,stm32prog-gpios", 0,
  267. + &gpio, GPIOD_IS_IN)) {
  268. + debug("%s: could not find a /config/st,stm32prog-gpios\n",
  269. + __func__);
  270. + } else {
  271. + if (dm_gpio_get_value(&gpio)) {
  272. + puts("STM32Programmer key pressed, ");
  273. + boot_mode = BOOT_STM32PROG;
  274. + }
  275. + dm_gpio_free(NULL, &gpio);
  276. + }
  277. + }
  278. + if (boot_mode != BOOT_NORMAL) {
  279. + puts("entering download mode...\n");
  280. + clrsetbits_le32(TAMP_BOOT_CONTEXT,
  281. + TAMP_BOOT_FORCED_MASK,
  282. + boot_mode);
  283. + }
  284. +}
  285. +
  286. +int g_dnl_board_usb_cable_connected(void)
  287. +{
  288. + struct udevice *dwc2_udc_otg;
  289. + int ret;
  290. +
  291. + if (!IS_ENABLED(CONFIG_USB_GADGET_DWC2_OTG))
  292. + return -ENODEV;
  293. + ret = uclass_get_device_by_driver(UCLASS_USB_GADGET_GENERIC,
  294. + DM_GET_DRIVER(dwc2_udc_otg),
  295. + &dwc2_udc_otg);
  296. + if (!ret)
  297. + debug("dwc2_udc_otg init failed\n");
  298. +
  299. + return dwc2_udc_B_session_valid(dwc2_udc_otg);
  300. +}
  301. +
  302. +#ifdef CONFIG_USB_GADGET_DOWNLOAD
  303. +#define STM32MP1_G_DNL_DFU_PRODUCT_NUM 0xdf11
  304. +#define STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM 0x0afb
  305. +
  306. +int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
  307. +{
  308. + if (IS_ENABLED(CONFIG_DFU_OVER_USB) &&
  309. + !strcmp(name, "usb_dnl_dfu"))
  310. + put_unaligned(STM32MP1_G_DNL_DFU_PRODUCT_NUM, &dev->idProduct);
  311. + else if (IS_ENABLED(CONFIG_FASTBOOT) &&
  312. + !strcmp(name, "usb_dnl_fastboot"))
  313. + put_unaligned(STM32MP1_G_DNL_FASTBOOT_PRODUCT_NUM,
  314. + &dev->idProduct);
  315. + else
  316. + put_unaligned(CONFIG_USB_GADGET_PRODUCT_NUM, &dev->idProduct);
  317. +
  318. + return 0;
  319. +}
  320. +#endif /* CONFIG_USB_GADGET_DOWNLOAD */
  321. +
  322. +static int get_led(struct udevice **dev, char *led_string)
  323. +{
  324. + char *led_name;
  325. + int ret;
  326. +
  327. + led_name = fdtdec_get_config_string(gd->fdt_blob, led_string);
  328. + if (!led_name) {
  329. + pr_debug("%s: could not find %s config string\n",
  330. + __func__, led_string);
  331. + return -ENOENT;
  332. + }
  333. + ret = led_get_by_label(led_name, dev);
  334. + if (ret) {
  335. + debug("%s: get=%d\n", __func__, ret);
  336. + return ret;
  337. + }
  338. +
  339. + return 0;
  340. +}
  341. +
  342. +static int setup_led(enum led_state_t cmd)
  343. +{
  344. + struct udevice *dev;
  345. + int ret;
  346. +
  347. + if (!CONFIG_IS_ENABLED(LED))
  348. + return 0;
  349. +
  350. + ret = get_led(&dev, "u-boot,boot-led");
  351. + if (ret)
  352. + return ret;
  353. +
  354. + ret = led_set_state(dev, cmd);
  355. + return ret;
  356. +}
  357. +
  358. +static void __maybe_unused led_error_blink(u32 nb_blink)
  359. +{
  360. + int ret;
  361. + struct udevice *led;
  362. + u32 i;
  363. +
  364. + if (!nb_blink)
  365. + return;
  366. +
  367. + if (CONFIG_IS_ENABLED(LED)) {
  368. + ret = get_led(&led, "u-boot,error-led");
  369. + if (!ret) {
  370. + /* make u-boot,error-led blinking */
  371. + /* if U32_MAX and 125ms interval, for 17.02 years */
  372. + for (i = 0; i < 2 * nb_blink; i++) {
  373. + led_set_state(led, LEDST_TOGGLE);
  374. + mdelay(125);
  375. + WATCHDOG_RESET();
  376. + }
  377. + led_set_state(led, LEDST_ON);
  378. + }
  379. + }
  380. +
  381. + /* infinite: the boot process must be stopped */
  382. + if (nb_blink == U32_MAX)
  383. + hang();
  384. +}
  385. +
  386. +static void sysconf_init(void)
  387. +{
  388. + u8 *syscfg;
  389. + struct udevice *pwr_dev;
  390. + struct udevice *pwr_reg;
  391. + struct udevice *dev;
  392. + u32 otp = 0;
  393. + int ret;
  394. + u32 bootr, val;
  395. +
  396. + syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
  397. +
  398. + /* interconnect update : select master using the port 1 */
  399. + /* LTDC = AXI_M9 */
  400. + /* GPU = AXI_M8 */
  401. + /* today information is hardcoded in U-Boot */
  402. + writel(BIT(9), syscfg + SYSCFG_ICNR);
  403. +
  404. + /* disable Pull-Down for boot pin connected to VDD */
  405. + bootr = readl(syscfg + SYSCFG_BOOTR);
  406. + bootr &= ~(SYSCFG_BOOTR_BOOT_MASK << SYSCFG_BOOTR_BOOTPD_SHIFT);
  407. + bootr |= (bootr & SYSCFG_BOOTR_BOOT_MASK) << SYSCFG_BOOTR_BOOTPD_SHIFT;
  408. + writel(bootr, syscfg + SYSCFG_BOOTR);
  409. +
  410. + /* High Speed Low Voltage Pad mode Enable for SPI, SDMMC, ETH, QSPI
  411. + * and TRACE. Needed above ~50MHz and conditioned by AFMUX selection.
  412. + * The customer will have to disable this for low frequencies
  413. + * or if AFMUX is selected but the function not used, typically for
  414. + * TRACE. Otherwise, impact on power consumption.
  415. + *
  416. + * WARNING:
  417. + * enabling High Speed mode while VDD>2.7V
  418. + * with the OTP product_below_2v5 (OTP 18, BIT 13)
  419. + * erroneously set to 1 can damage the IC!
  420. + * => U-Boot set the register only if VDD < 2.7V (in DT)
  421. + * but this value need to be consistent with board design
  422. + */
  423. + ret = uclass_get_device_by_driver(UCLASS_PMIC,
  424. + DM_GET_DRIVER(stm32mp_pwr_pmic),
  425. + &pwr_dev);
  426. + if (!ret && IS_ENABLED(CONFIG_DM_REGULATOR)) {
  427. + ret = uclass_get_device_by_driver(UCLASS_MISC,
  428. + DM_GET_DRIVER(stm32mp_bsec),
  429. + &dev);
  430. + if (ret) {
  431. + pr_err("Can't find stm32mp_bsec driver\n");
  432. + return;
  433. + }
  434. +
  435. + ret = misc_read(dev, STM32_BSEC_SHADOW(18), &otp, 4);
  436. + if (ret > 0)
  437. + otp = otp & BIT(13);
  438. +
  439. + /* get VDD = vdd-supply */
  440. + ret = device_get_supply_regulator(pwr_dev, "vdd-supply",
  441. + &pwr_reg);
  442. +
  443. + /* check if VDD is Low Voltage */
  444. + if (!ret) {
  445. + if (regulator_get_value(pwr_reg) < 2700000) {
  446. + writel(SYSCFG_IOCTRLSETR_HSLVEN_TRACE |
  447. + SYSCFG_IOCTRLSETR_HSLVEN_QUADSPI |
  448. + SYSCFG_IOCTRLSETR_HSLVEN_ETH |
  449. + SYSCFG_IOCTRLSETR_HSLVEN_SDMMC |
  450. + SYSCFG_IOCTRLSETR_HSLVEN_SPI,
  451. + syscfg + SYSCFG_IOCTRLSETR);
  452. +
  453. + if (!otp)
  454. + pr_err("product_below_2v5=0: HSLVEN protected by HW\n");
  455. + } else {
  456. + if (otp)
  457. + pr_err("product_below_2v5=1: HSLVEN update is destructive, no update as VDD>2.7V\n");
  458. + }
  459. + } else {
  460. + debug("VDD unknown");
  461. + }
  462. + }
  463. +
  464. + /* activate automatic I/O compensation
  465. + * warning: need to ensure CSI enabled and ready in clock driver
  466. + */
  467. + writel(SYSCFG_CMPENSETR_MPU_EN, syscfg + SYSCFG_CMPENSETR);
  468. +
  469. + /* poll until ready (1s timeout) */
  470. + ret = readl_poll_timeout(syscfg + SYSCFG_CMPCR, val,
  471. + val & SYSCFG_CMPCR_READY,
  472. + 1000000);
  473. + if (ret) {
  474. + pr_err("SYSCFG: I/O compensation failed, timeout.\n");
  475. + led_error_blink(10);
  476. + }
  477. +
  478. + clrbits_le32(syscfg + SYSCFG_CMPCR, SYSCFG_CMPCR_SW_CTRL);
  479. +}
  480. +
  481. +/* board dependent setup after realloc */
  482. +int board_init(void)
  483. +{
  484. + /* address of boot parameters */
  485. + gd->bd->bi_boot_params = STM32_DDR_BASE + 0x100;
  486. +
  487. + if (CONFIG_IS_ENABLED(DM_GPIO_HOG))
  488. + gpio_hog_probe_all();
  489. +
  490. + board_key_check();
  491. +
  492. + if (IS_ENABLED(CONFIG_DM_REGULATOR))
  493. + regulators_enable_boot_on(_DEBUG);
  494. +
  495. + if (!IS_ENABLED(CONFIG_TFABOOT))
  496. + sysconf_init();
  497. +
  498. + if (CONFIG_IS_ENABLED(LED))
  499. + led_default_state();
  500. +
  501. + return 0;
  502. +}
  503. +
  504. +int board_late_init(void)
  505. +{
  506. + char *boot_device;
  507. + const void *fdt_compat;
  508. + int fdt_compat_len;
  509. + int ret;
  510. + u32 otp;
  511. + struct udevice *dev;
  512. + char buf[10];
  513. + char dtb_name[256];
  514. + int buf_len;
  515. +
  516. + if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
  517. + fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
  518. + &fdt_compat_len);
  519. + if (fdt_compat && fdt_compat_len) {
  520. + if (strncmp(fdt_compat, "st,", 3) != 0) {
  521. + env_set("board_name", fdt_compat);
  522. + } else {
  523. + env_set("board_name", fdt_compat + 3);
  524. +
  525. + buf_len = sizeof(dtb_name);
  526. + strncpy(dtb_name, fdt_compat + 3, buf_len);
  527. + buf_len -= strlen(fdt_compat + 3);
  528. + strncat(dtb_name, ".dtb", buf_len);
  529. + env_set("fdtfile", dtb_name);
  530. + }
  531. + }
  532. + ret = uclass_get_device_by_driver(UCLASS_MISC,
  533. + DM_GET_DRIVER(stm32mp_bsec),
  534. + &dev);
  535. +
  536. + if (!ret)
  537. + ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
  538. + &otp, sizeof(otp));
  539. + if (ret > 0 && otp) {
  540. + snprintf(buf, sizeof(buf), "0x%04x", otp >> 16);
  541. + env_set("board_id", buf);
  542. +
  543. + snprintf(buf, sizeof(buf), "0x%04x",
  544. + ((otp >> 8) & 0xF) - 1 + 0xA);
  545. + env_set("board_rev", buf);
  546. + }
  547. + }
  548. +
  549. + /* Check the boot-source to disable bootdelay */
  550. + boot_device = env_get("boot_device");
  551. + if (!strcmp(boot_device, "serial") || !strcmp(boot_device, "usb"))
  552. + env_set("bootdelay", "0");
  553. +
  554. + return 0;
  555. +}
  556. +
  557. +void board_quiesce_devices(void)
  558. +{
  559. + setup_led(LEDST_OFF);
  560. +}
  561. +
  562. +/* eth init function : weak called in eqos driver */
  563. +int board_interface_eth_init(struct udevice *dev,
  564. + phy_interface_t interface_type, ulong rate)
  565. +{
  566. + u8 *syscfg;
  567. + u32 value;
  568. + bool eth_clk_sel_reg = false;
  569. + bool eth_ref_clk_sel_reg = false;
  570. +
  571. + /* Gigabit Ethernet 125MHz clock selection. */
  572. + eth_clk_sel_reg = dev_read_bool(dev, "st,eth_clk_sel");
  573. +
  574. + /* Ethernet 50Mhz RMII clock selection */
  575. + eth_ref_clk_sel_reg =
  576. + dev_read_bool(dev, "st,eth_ref_clk_sel");
  577. +
  578. + syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
  579. +
  580. + if (!syscfg)
  581. + return -ENODEV;
  582. +
  583. + switch (interface_type) {
  584. + case PHY_INTERFACE_MODE_MII:
  585. + value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
  586. + SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
  587. + debug("%s: PHY_INTERFACE_MODE_MII\n", __func__);
  588. + break;
  589. + case PHY_INTERFACE_MODE_GMII:
  590. + if (eth_clk_sel_reg)
  591. + value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII |
  592. + SYSCFG_PMCSETR_ETH_CLK_SEL;
  593. + else
  594. + value = SYSCFG_PMCSETR_ETH_SEL_GMII_MII;
  595. + debug("%s: PHY_INTERFACE_MODE_GMII\n", __func__);
  596. + break;
  597. + case PHY_INTERFACE_MODE_RMII:
  598. + if (eth_ref_clk_sel_reg)
  599. + value = SYSCFG_PMCSETR_ETH_SEL_RMII |
  600. + SYSCFG_PMCSETR_ETH_REF_CLK_SEL;
  601. + else
  602. + value = SYSCFG_PMCSETR_ETH_SEL_RMII;
  603. + debug("%s: PHY_INTERFACE_MODE_RMII\n", __func__);
  604. + break;
  605. + case PHY_INTERFACE_MODE_RGMII:
  606. + case PHY_INTERFACE_MODE_RGMII_ID:
  607. + case PHY_INTERFACE_MODE_RGMII_RXID:
  608. + case PHY_INTERFACE_MODE_RGMII_TXID:
  609. + if (eth_clk_sel_reg)
  610. + value = SYSCFG_PMCSETR_ETH_SEL_RGMII |
  611. + SYSCFG_PMCSETR_ETH_CLK_SEL;
  612. + else
  613. + value = SYSCFG_PMCSETR_ETH_SEL_RGMII;
  614. + debug("%s: PHY_INTERFACE_MODE_RGMII\n", __func__);
  615. + break;
  616. + default:
  617. + debug("%s: Do not manage %d interface\n",
  618. + __func__, interface_type);
  619. + /* Do not manage others interfaces */
  620. + return -EINVAL;
  621. + }
  622. +
  623. + /* clear and set ETH configuration bits */
  624. + writel(SYSCFG_PMCSETR_ETH_SEL_MASK | SYSCFG_PMCSETR_ETH_SELMII |
  625. + SYSCFG_PMCSETR_ETH_REF_CLK_SEL | SYSCFG_PMCSETR_ETH_CLK_SEL,
  626. + syscfg + SYSCFG_PMCCLRR);
  627. + writel(value, syscfg + SYSCFG_PMCSETR);
  628. +
  629. + return 0;
  630. +}
  631. +
  632. +enum env_location env_get_location(enum env_operation op, int prio)
  633. +{
  634. + u32 bootmode = get_bootmode();
  635. +
  636. + if (prio)
  637. + return ENVL_UNKNOWN;
  638. +
  639. + switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
  640. + case BOOT_FLASH_SD:
  641. + case BOOT_FLASH_EMMC:
  642. + if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
  643. + return ENVL_MMC;
  644. + else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
  645. + return ENVL_EXT4;
  646. + else
  647. + return ENVL_NOWHERE;
  648. +
  649. + case BOOT_FLASH_NAND:
  650. + case BOOT_FLASH_SPINAND:
  651. + if (CONFIG_IS_ENABLED(ENV_IS_IN_UBI))
  652. + return ENVL_UBI;
  653. + else
  654. + return ENVL_NOWHERE;
  655. +
  656. + case BOOT_FLASH_NOR:
  657. + if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
  658. + return ENVL_SPI_FLASH;
  659. + else
  660. + return ENVL_NOWHERE;
  661. +
  662. + default:
  663. + return ENVL_NOWHERE;
  664. + }
  665. +}
  666. +
  667. +const char *env_ext4_get_intf(void)
  668. +{
  669. + u32 bootmode = get_bootmode();
  670. +
  671. + switch (bootmode & TAMP_BOOT_DEVICE_MASK) {
  672. + case BOOT_FLASH_SD:
  673. + case BOOT_FLASH_EMMC:
  674. + return "mmc";
  675. + default:
  676. + return "";
  677. + }
  678. +}
  679. +
  680. +const char *env_ext4_get_dev_part(void)
  681. +{
  682. + static char *const dev_part[] = {"0:auto", "1:auto", "2:auto"};
  683. + u32 bootmode = get_bootmode();
  684. +
  685. + return dev_part[(bootmode & TAMP_BOOT_INSTANCE_MASK) - 1];
  686. +}
  687. +
  688. +int mmc_get_env_dev(void)
  689. +{
  690. + u32 bootmode;
  691. +
  692. + if (CONFIG_SYS_MMC_ENV_DEV >= 0)
  693. + return CONFIG_SYS_MMC_ENV_DEV;
  694. +
  695. + bootmode = get_bootmode();
  696. +
  697. + /* use boot instance to select the correct mmc device identifier */
  698. + return (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1;
  699. +}
  700. +
  701. +#if defined(CONFIG_OF_BOARD_SETUP)
  702. +int ft_board_setup(void *blob, struct bd_info *bd)
  703. +{
  704. + return 0;
  705. +}
  706. +#endif
  707. +
  708. +static void board_copro_image_process(ulong fw_image, size_t fw_size)
  709. +{
  710. + int ret, id = 0; /* Copro id fixed to 0 as only one coproc on mp1 */
  711. +
  712. + if (!rproc_is_initialized())
  713. + if (rproc_init()) {
  714. + printf("Remote Processor %d initialization failed\n",
  715. + id);
  716. + return;
  717. + }
  718. +
  719. + ret = rproc_load(id, fw_image, fw_size);
  720. + printf("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n",
  721. + id, fw_image, fw_size, ret ? " Failed!" : " Success!");
  722. +
  723. + if (!ret)
  724. + rproc_start(id);
  725. +}
  726. +
  727. +U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_COPRO, board_copro_image_process);
  728. diff --git a/configs/osd32mp1_brk_trusted_defconfig b/configs/osd32mp1_brk_trusted_defconfig
  729. new file mode 100644
  730. index 0000000000..6d41af8886
  731. --- /dev/null
  732. +++ b/configs/osd32mp1_brk_trusted_defconfig
  733. @@ -0,0 +1,141 @@
  734. +CONFIG_ARM=y
  735. +CONFIG_ARCH_STM32MP=y
  736. +CONFIG_TFABOOT=y
  737. +CONFIG_SYS_MALLOC_F_LEN=0x3000
  738. +CONFIG_ENV_OFFSET=0x480000
  739. +CONFIG_ENV_SECT_SIZE=0x40000
  740. +# CONFIG_TARGET_ST_STM32MP15x=y
  741. +CONFIG_TARGET_OCTAVO_OSD32MP1_BRK=y
  742. +CONFIG_CMD_STM32PROG=y
  743. +CONFIG_ENV_OFFSET_REDUND=0x4C0000
  744. +CONFIG_DEFAULT_DEVICE_TREE="stm32mp157c-osd32mp1-brk"
  745. +CONFIG_DISTRO_DEFAULTS=y
  746. +CONFIG_FIT=y
  747. +CONFIG_BOOTDELAY=1
  748. +CONFIG_BOOTCOMMAND="run bootcmd_stm32mp"
  749. +CONFIG_SYS_PROMPT="OSD32MP> "
  750. +# CONFIG_CMD_BOOTD is not set
  751. +CONFIG_CMD_ADTIMG=y
  752. +# CONFIG_CMD_ELF is not set
  753. +CONFIG_CMD_EEPROM=y
  754. +CONFIG_CMD_ERASEENV=y
  755. +CONFIG_CMD_MEMINFO=y
  756. +CONFIG_CMD_MEMTEST=y
  757. +CONFIG_SYS_MEMTEST_START=0xc0000000
  758. +CONFIG_SYS_MEMTEST_END=0xc4000000
  759. +CONFIG_CMD_ADC=y
  760. +CONFIG_CMD_CLK=y
  761. +CONFIG_CMD_DFU=y
  762. +CONFIG_CMD_FUSE=y
  763. +CONFIG_CMD_GPIO=y
  764. +CONFIG_CMD_I2C=y
  765. +CONFIG_CMD_MMC=y
  766. +CONFIG_CMD_REMOTEPROC=y
  767. +CONFIG_CMD_SPI=y
  768. +CONFIG_CMD_USB=y
  769. +CONFIG_CMD_USB_MASS_STORAGE=y
  770. +CONFIG_CMD_BMP=y
  771. +CONFIG_CMD_CACHE=y
  772. +CONFIG_CMD_TIME=y
  773. +CONFIG_CMD_TIMER=y
  774. +CONFIG_CMD_PMIC=y
  775. +CONFIG_CMD_REGULATOR=y
  776. +CONFIG_CMD_EXT4_WRITE=y
  777. +CONFIG_CMD_MTDPARTS=y
  778. +CONFIG_CMD_UBI=y
  779. +CONFIG_ENV_IS_NOWHERE=y
  780. +CONFIG_ENV_IS_IN_MMC=y
  781. +CONFIG_ENV_IS_IN_UBI=y
  782. +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
  783. +CONFIG_ENV_UBI_PART="UBI"
  784. +CONFIG_ENV_UBI_VOLUME="uboot_config"
  785. +CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
  786. +CONFIG_SYS_RELOC_GD_ENV_ADDR=y
  787. +CONFIG_SYS_MMC_ENV_DEV=-1
  788. +CONFIG_STM32_ADC=y
  789. +CONFIG_CLK_SCMI=y
  790. +CONFIG_SET_DFU_ALT_INFO=y
  791. +CONFIG_USB_FUNCTION_FASTBOOT=y
  792. +CONFIG_FASTBOOT_BUF_ADDR=0xC0000000
  793. +CONFIG_FASTBOOT_BUF_SIZE=0x02000000
  794. +CONFIG_FASTBOOT_USB_DEV=1
  795. +CONFIG_FASTBOOT_FLASH=y
  796. +CONFIG_FASTBOOT_FLASH_MMC_DEV=1
  797. +CONFIG_GPIO_HOG=y
  798. +CONFIG_DM_HWSPINLOCK=y
  799. +CONFIG_HWSPINLOCK_STM32=y
  800. +CONFIG_DM_I2C=y
  801. +CONFIG_SYS_I2C_STM32F7=y
  802. +CONFIG_LED=y
  803. +CONFIG_LED_GPIO=y
  804. +CONFIG_DM_MAILBOX=y
  805. +CONFIG_STM32_IPCC=y
  806. +CONFIG_STM32_FMC2_EBI=y
  807. +CONFIG_I2C_EEPROM=y
  808. +CONFIG_DM_MMC=y
  809. +CONFIG_SUPPORT_EMMC_BOOT=y
  810. +CONFIG_STM32_SDMMC2=y
  811. +CONFIG_MTD=y
  812. +CONFIG_DM_MTD=y
  813. +CONFIG_SYS_MTDPARTS_RUNTIME=y
  814. +CONFIG_MTD_RAW_NAND=y
  815. +CONFIG_NAND_STM32_FMC2=y
  816. +CONFIG_MTD_SPI_NAND=y
  817. +CONFIG_DM_SPI_FLASH=y
  818. +CONFIG_SPI_FLASH_MACRONIX=y
  819. +CONFIG_SPI_FLASH_SPANSION=y
  820. +CONFIG_SPI_FLASH_STMICRO=y
  821. +CONFIG_SPI_FLASH_WINBOND=y
  822. +# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
  823. +CONFIG_SPI_FLASH_MTD=y
  824. +CONFIG_PHY_REALTEK=y
  825. +CONFIG_DM_ETH=y
  826. +CONFIG_DWC_ETH_QOS=y
  827. +CONFIG_PHY=y
  828. +CONFIG_PHY_STM32_USBPHYC=y
  829. +CONFIG_PINCONF=y
  830. +CONFIG_PINCTRL_STMFX=y
  831. +CONFIG_DM_PMIC=y
  832. +CONFIG_PMIC_STPMIC1=y
  833. +CONFIG_DM_REGULATOR=y
  834. +CONFIG_DM_REGULATOR_FIXED=y
  835. +CONFIG_DM_REGULATOR_GPIO=y
  836. +CONFIG_DM_REGULATOR_STM32_VREFBUF=y
  837. +CONFIG_DM_REGULATOR_STPMIC1=y
  838. +CONFIG_REMOTEPROC_STM32_COPRO=y
  839. +CONFIG_RESET_SCMI=y
  840. +CONFIG_DM_RNG=y
  841. +CONFIG_RNG_STM32MP1=y
  842. +CONFIG_DM_RTC=y
  843. +CONFIG_RTC_STM32=y
  844. +CONFIG_SERIAL_RX_BUFFER=y
  845. +CONFIG_SPI=y
  846. +CONFIG_DM_SPI=y
  847. +CONFIG_STM32_QSPI=y
  848. +CONFIG_STM32_SPI=y
  849. +CONFIG_TEE=y
  850. +CONFIG_OPTEE=y
  851. +# CONFIG_OPTEE_TA_AVB is not set
  852. +CONFIG_USB=y
  853. +CONFIG_DM_USB=y
  854. +CONFIG_DM_USB_GADGET=y
  855. +CONFIG_USB_EHCI_HCD=y
  856. +CONFIG_USB_EHCI_GENERIC=y
  857. +CONFIG_USB_GADGET=y
  858. +CONFIG_USB_GADGET_MANUFACTURER="STMicroelectronics"
  859. +CONFIG_USB_GADGET_VENDOR_NUM=0x0483
  860. +CONFIG_USB_GADGET_PRODUCT_NUM=0x5720
  861. +CONFIG_USB_GADGET_DWC2_OTG=y
  862. +CONFIG_DM_VIDEO=y
  863. +CONFIG_BACKLIGHT_GPIO=y
  864. +CONFIG_VIDEO_LCD_ORISETECH_OTM8009A=y
  865. +CONFIG_VIDEO_LCD_RAYDIUM_RM68200=y
  866. +CONFIG_VIDEO_STM32=y
  867. +CONFIG_VIDEO_STM32_DSI=y
  868. +CONFIG_VIDEO_STM32_MAX_XRES=1280
  869. +CONFIG_VIDEO_STM32_MAX_YRES=800
  870. +CONFIG_WDT=y
  871. +CONFIG_WDT_STM32MP=y
  872. +CONFIG_ERRNO_STR=y
  873. +CONFIG_FDT_FIXUP_PARTITIONS=y
  874. +CONFIG_LMB_RESERVED_REGIONS=16
  875. --
  876. 2.25.1