hikey: fix to load FIP by partition table.
authorHaojian Zhuang <haojian.zhuang@linaro.org>
Sat, 14 Sep 2019 11:18:01 +0000 (19:18 +0800)
committerHaojian Zhuang <haojian.zhuang@linaro.org>
Wed, 18 Sep 2019 10:18:57 +0000 (18:18 +0800)
Avoid to load FIP by hacking address. Load it by partition table instead.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
Change-Id: I0283fc2e6e459bff14de19d92db4158e05106ee4

plat/hisilicon/hikey/hikey_bl2_setup.c
plat/hisilicon/hikey/hikey_io_storage.c
plat/hisilicon/hikey/hikey_private.h
plat/hisilicon/hikey/include/hikey_def.h
plat/hisilicon/hikey/platform.mk

index 2f96efcdb3853591201005facc5ecaf4c25d6970..96136ec126f0f822df1dc684d6c3dc17b0edf74e 100644 (file)
@@ -114,6 +114,11 @@ uint32_t hikey_get_spsr_for_bl33_entry(void)
 }
 #endif /* __aarch64__ */
 
+int bl2_plat_handle_pre_image_load(unsigned int image_id)
+{
+       return hikey_set_fip_addr(image_id, "fastboot");
+}
+
 int hikey_bl2_handle_post_image_load(unsigned int image_id)
 {
        int err = 0;
index 11dd97334c4e54022b8a7214cf75a7932b9e0063..fd610d8c0c667a24451bbbcc8b164aa8e89875f7 100644 (file)
@@ -18,6 +18,7 @@
 #include <drivers/io/io_memmap.h>
 #include <drivers/io/io_storage.h>
 #include <drivers/mmc.h>
+#include <drivers/partition/partition.h>
 #include <lib/mmio.h>
 #include <lib/semihosting.h>
 #include <tools_share/firmware_image_package.h>
@@ -43,9 +44,12 @@ static uintptr_t fip_dev_handle;
 static int check_emmc(const uintptr_t spec);
 static int check_fip(const uintptr_t spec);
 
-static const io_block_spec_t emmc_fip_spec = {
-       .offset         = HIKEY_FIP_BASE,
-       .length         = HIKEY_FIP_MAX_SIZE,
+static io_block_spec_t emmc_fip_spec;
+
+static const io_block_spec_t emmc_gpt_spec = {
+       .offset         = 0,
+       .length         = PLAT_PARTITION_BLOCK_SIZE *
+                         (PLAT_PARTITION_MAX_ENTRIES / 4 + 2),
 };
 
 static const io_block_dev_spec_t emmc_dev_spec = {
@@ -213,6 +217,11 @@ static const struct plat_io_policy policies[] = {
                check_fip
        },
 #endif /* TRUSTED_BOARD_BOOT */
+       [GPT_IMAGE_ID] = {
+               &emmc_dev_handle,
+               (uintptr_t)&emmc_gpt_spec,
+               check_emmc
+       },
 };
 
 static int check_emmc(const uintptr_t spec)
@@ -267,6 +276,23 @@ void hikey_io_setup(void)
        (void)result;
 }
 
+int hikey_set_fip_addr(unsigned int image_id, const char *name)
+{
+       const partition_entry_t *entry;
+
+       if (emmc_fip_spec.length == 0) {
+               partition_init(GPT_IMAGE_ID);
+               entry = get_partition_entry(name);
+               if (entry == NULL) {
+                       ERROR("Could NOT find the %s partition!\n", name);
+                       return -ENOENT;
+               }
+               emmc_fip_spec.offset = entry->start;
+               emmc_fip_spec.length = entry->length;
+       }
+       return 0;
+}
+
 /* Return an IO device handle and specification which can be used to access
  * an image. Use this to enforce platform load policy
  */
index d82a0794a0c5d6e850a74a89ede6cd9bbc6b022c..b75bc723d7f3cb95fd2eb3572728fd9e68ba32b5 100644 (file)
@@ -72,4 +72,6 @@ int hikey_write_serialno(struct random_serial_num *serialno);
 
 void init_acpu_dvfs(void);
 
+int hikey_set_fip_addr(unsigned int image_id, const char *name);
+
 #endif /* HIKEY_PRIVATE_H */
index 4fb3e56a17b01636111023ffa19e3bad91365d85..590700daf91540400826e2757bded6dcf631a966 100644 (file)
@@ -84,8 +84,6 @@
 #define HIKEY_BL1_MMC_DATA_SIZE                0x0000B000
 
 #define EMMC_BASE                      0
-#define HIKEY_FIP_BASE                 (EMMC_BASE + (4 << 20))
-#define HIKEY_FIP_MAX_SIZE             (8 << 20)
 #define HIKEY_EMMC_RPMB_BASE           (EMMC_BASE + 0)
 #define HIKEY_EMMC_RPMB_MAX_SIZE       (128 << 10)
 #define HIKEY_EMMC_USERDATA_BASE       (EMMC_BASE + 0)
index 7fd897cdab134be222c6e9d54de27d0e6b7e6be6..fbf743292753b478cf4c348f415b971d87a2813d 100644 (file)
@@ -76,6 +76,8 @@ BL2_SOURCES           +=      common/desc_image_load.c                \
                                drivers/io/io_fip.c                     \
                                drivers/io/io_storage.c                 \
                                drivers/mmc/mmc.c                       \
+                               drivers/partition/gpt.c                 \
+                               drivers/partition/partition.c           \
                                drivers/synopsys/emmc/dw_mmc.c          \
                                lib/cpus/aarch64/cortex_a53.S           \
                                plat/hisilicon/hikey/aarch64/hikey_helpers.S \