stm32mp1: update package information in device tree
[oweals/u-boot.git] / arch / arm / mach-stm32mp / fdt.c
1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 /*
3  * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
4  */
5
6 #include <common.h>
7 #include <fdt_support.h>
8 #include <asm/arch/sys_proto.h>
9 #include <dt-bindings/pinctrl/stm32-pinfunc.h>
10
11 /*
12  * This function is called right before the kernel is booted. "blob" is the
13  * device tree that will be passed to the kernel.
14  */
15 int ft_system_setup(void *blob, bd_t *bd)
16 {
17         int ret = 0;
18         u32 pkg;
19
20         switch (get_cpu_package()) {
21         case PKG_AA_LBGA448:
22                 pkg = STM32MP_PKG_AA;
23                 break;
24         case PKG_AB_LBGA354:
25                 pkg = STM32MP_PKG_AB;
26                 break;
27         case PKG_AC_TFBGA361:
28                 pkg = STM32MP_PKG_AC;
29                 break;
30         case PKG_AD_TFBGA257:
31                 pkg = STM32MP_PKG_AD;
32                 break;
33         default:
34                 pkg = 0;
35                 break;
36         }
37         if (pkg) {
38                 do_fixup_by_compat_u32(blob, "st,stm32mp157-pinctrl",
39                                        "st,package", pkg, false);
40                 do_fixup_by_compat_u32(blob, "st,stm32mp157-z-pinctrl",
41                                        "st,package", pkg, false);
42         }
43
44         return ret;
45 }