hc
2023-11-06 9df731a176aab8e03b984b681b1bea01ccff6644
u-boot/arch/arm/mach-rockchip/vendor.c
....@@ -10,6 +10,7 @@
1010 #include <boot_rkimg.h>
1111 #include <nand.h>
1212 #include <part.h>
13
+#include <fdt_support.h>
1314
1415 /* tag for vendor check */
1516 #define VENDOR_TAG 0x524B5644
....@@ -20,6 +21,9 @@
2021 /* align to 64 bytes */
2122 #define VENDOR_BTYE_ALIGN 0x3F
2223 #define VENDOR_BLOCK_SIZE 512
24
+
25
+#define PAGE_ALGIN_SIZE (4096uL)
26
+#define PAGE_ALGIN_MASK (~(PAGE_ALGIN_SIZE - 1))
2327
2428 /* --- Emmc define --- */
2529 /* Starting address of the Vendor in memory. */
....@@ -493,13 +497,14 @@
493497 /* Initialize */
494498 bootdev_type = dev_desc->if_type;
495499
496
- /* Always use, no need to release */
497
- buffer = (u8 *)malloc(size);
500
+ /* Always use, no need to release, align to page size for kerenl reserved memory */
501
+ buffer = (u8 *)memalign(PAGE_ALGIN_SIZE, size);
498502 if (!buffer) {
499503 printf("[Vendor ERROR]:Malloc failed!\n");
500504 ret = -ENOMEM;
501505 goto out;
502506 }
507
+
503508 /* Pointer initialization */
504509 vendor_info.hdr = (struct vendor_hdr *)buffer;
505510 vendor_info.item = (struct vendor_item *)(buffer + sizeof(struct vendor_hdr));
....@@ -566,6 +571,29 @@
566571 return ret;
567572 }
568573
574
+void vendor_storage_fixup(void *blob)
575
+{
576
+ unsigned long size;
577
+ unsigned long start;
578
+ ulong offset;
579
+
580
+ /* init vendor storage */
581
+ if (!bootdev_type) {
582
+ if (vendor_storage_init() < 0)
583
+ return;
584
+ }
585
+
586
+ offset = fdt_node_offset_by_compatible(blob, 0, "rockchip,vendor-storage-rm");
587
+ if (offset >= 0) {
588
+ start = (unsigned long)vendor_info.hdr;
589
+ size = (unsigned long)((void *)vendor_info.version2 - (void *)vendor_info.hdr);
590
+ size += 4;
591
+ fdt_update_reserved_memory(blob, "rockchip,vendor-storage-rm",
592
+ (u64)start,
593
+ (u64)size);
594
+ }
595
+}
596
+
569597 /*
570598 * @id: item id, first 4 id is occupied:
571599 * VENDOR_SN_ID