Skip to content

Commit

Permalink
Merge remote-tracking branch 'rk/next-dev'
Browse files Browse the repository at this point in the history
Change-Id: Ic05eebf9e16450c71aaa0f437e5c0ff2a6d14bf1
Signed-off-by: Jensen Huang <[email protected]>
  • Loading branch information
911gt3 committed Oct 13, 2022
2 parents 035b542 + 334b1f3 commit f2229e8
Show file tree
Hide file tree
Showing 144 changed files with 22,298 additions and 10,305 deletions.
2 changes: 1 addition & 1 deletion arch/arm/dts/rv1106-u-boot.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
};

&emmc {
mmc-ecsd = <0x3fe00>;
mmc-ecsd = <0x3F000>;
bus-width = <8>;
mmc-hs200-1_8v;
u-boot,dm-spl;
Expand Down
8 changes: 8 additions & 0 deletions arch/arm/include/asm/arch-rockchip/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,12 @@ int param_parse_pre_serial(int *flags);
*/
int param_parse_pubkey_fuse_programmed(void);

#ifdef CONFIG_PSTORE
/**
* param_parse_pstore() - Parse and Init pstore according to pre-loader atags.
*
* @return 0 on success, otherwise failed.
*/
int param_parse_pstore(void);
#endif
#endif
13 changes: 13 additions & 0 deletions arch/arm/include/asm/arch-rockchip/pstore.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2018 Rockchip Electronics Co., Ltd
*
*/

#ifndef __PSTORE_H_
#define __PSTORE_H_

void putc_to_ram(const char c);
void puts_to_ram(const char *str);

#endif
11 changes: 11 additions & 0 deletions arch/arm/include/asm/arch-rockchip/rk_atags.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define ATAG_PUB_KEY 0x54410056
#define ATAG_SOC_INFO 0x54410057
#define ATAG_BOOT1_PARAM 0x54410058
#define ATAG_PSTORE 0x54410059
#define ATAG_MAX 0x544100ff

/* Tag size and offset */
Expand Down Expand Up @@ -173,6 +174,15 @@ struct tag_boot1p {
u32 hash;
} __packed;

struct tag_pstore {
u32 version;
struct {
u32 addr;
u32 size;
} buf[16];
u32 hash;
} __packed;

struct tag_core {
u32 flags;
u32 pagesize;
Expand All @@ -198,6 +208,7 @@ struct tag {
struct tag_pub_key pub_key;
struct tag_soc_info soc;
struct tag_boot1p boot1p;
struct tag_pstore pstore;
} u;
} __aligned(4);

Expand Down
114 changes: 114 additions & 0 deletions arch/arm/include/asm/arch-rockchip/rk_meta.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2022 Rockchip Electronics Co., Ltd
*
*/

#ifndef _RK_CFG_H_
#define _RK_CFG_H_

/* META storage layout */
/***************************/ /* ----- ITEM start -----*/
/** META_HEAD **/
/***************************/
/** ITEM 1 **/
/***************************/
/** ITEM 2 **/
/***************************/
/** ITEM 3 **/
/***************************/
/** .... **/
/***************************/ /* --- ITEM backup start 32KB ---*/
/** ITEM 1 BACKUP **/
/***************************/
/** ITEM 2 BACKUP **/
/***************************/
/** ITEM 3 BACKUP **/
/***************************/
/** .... **/
/***************************/
/** META_END **/
/***************************/ /* ----- ITEM backup end -----*/
/** IQ FILE BIN **/ /* 320K sensor iq file bin */
/***************************/

/* META memory layout */
/***************************/ /* ----- ITEM start -----*/
/** META_HEAD **/
/***************************/
/** ITEM 1 **/
/***************************/
/** ITEM 2 **/
/***************************/
/** ITEM 3 **/
/***************************/
/** .... **/
/***************************/ /* --- ITEM backup start 32KB ---*/
/** ITEM 1 BACKUP **/
/***************************/
/** ITEM 2 BACKUP **/
/***************************/
/** ITEM 3 BACKUP **/
/***************************/
/** .... **/
/***************************/
/** META_END **/
/***************************/ /* ----- ITEM backup end -----*/
/** IQ FILE BIN **/ /* 320K sensor iq file bin */
/***************************/

#define RK_META 0x544d4b52
#define RK_META_END 0x55aabbcc
#define RK_CMDLINE 0x4c444d43

#define ITEM_SIZE (1 * 1024)
#define MAX_CMDLINE_LENGTH (1024 / 2)
#define MAX_HEAD_SIZE 4
#define MAX_META_SEGMENT_SIZE (16 * 1024)
#define BACKUP_META_SIZE (MAX_META_SEGMENT_SIZE / 2)
#define META_INFO_HEAD_OFFSET 0
#define META_INFO_SIZE ITEM_SIZE
#define PARAM_SHARE2KERNEL_OFFSET (META_INFO_HEAD_OFFSET + META_INFO_SIZE)
#define PARAM_SHARE2KERNEL_SIZE (ITEM_SIZE)
#define SENSOR_INIT_OFFSET (PARAM_SHARE2KERNEL_OFFSET + PARAM_SHARE2KERNEL_SIZE)
#define SENSOR_INIT_MAX_SIZE ITEM_SIZE
#define CMDLINE_OFFSET (SENSOR_INIT_OFFSET + SENSOR_INIT_MAX_SIZE)
#define CMDLINE_MAX_SIZE ITEM_SIZE
#define AE_TABLE_OFFSET (CMDLINE_OFFSET + CMDLINE_MAX_SIZE)
#define AE_TABLE_MAX_SIZE ITEM_SIZE

#define APP_PARAM_OFFSET (AE_TABLE_OFFSET + AE_TABLE_MAX_SIZE)
#define APP_PARAM_MAX_SIZE ITEM_SIZE

#define SENSOR_IQ_BIN_OFFSET (MAX_META_SEGMENT_SIZE)
#define SENSOR_IQ_BIN_MAX_SIZE (320 * 1024)
#define MAX_META_BIN_SIZE (MAX_META_SEGMENT_SIZE + SENSOR_IQ_BIN_MAX_SIZE)
#define META_SIZE MAX_META_BIN_SIZE

/* 512 - sizeof(tag/load/size/comp_type/comp_size/comp_off/crc32/meta_flags) */
#define META_HEAD_RESERVED_SIZE (120*4)
#define META_READ_DONE_FLAG (1 << 0)

#define AE_TABLE_SHARE2KERNEL_OFFSET (PARAM_SHARE2KERNEL_OFFSET)

#define META_COMPRESS_TYPE_GZ 0x1

struct meta_head {
uint32_t tag;
uint32_t load;
uint32_t size;
uint32_t comp_type;
uint32_t comp_size;
uint32_t comp_off;
uint8_t reserved[META_HEAD_RESERVED_SIZE];
uint32_t crc32;
uint32_t meta_flags;
};

struct cmdline_info {
uint32_t tag;
uint8_t data[MAX_CMDLINE_LENGTH];
uint32_t crc32;
};

#endif
28 changes: 28 additions & 0 deletions arch/arm/mach-rockchip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,13 @@ config ROCKCHIP_PRELOADER_ATAGS
tos, U-Boot, etc. It delivers boot and configure information, shared with pre-loaders
and finally ends with U-Boot.

config ROCKCHIP_META
bool "Rockchip Meta"
depends on SPL_KERNEL_BOOT && SPL_LIBDISK_SUPPORT
help
This support to load Rockchip meta data which like isp parameter, peripheral
parameters, etc.

config ROCKCHIP_PRELOADER_SERIAL
bool "Rockchip pre-loader serial"
default y if ROCKCHIP_PRELOADER_ATAGS
Expand Down Expand Up @@ -988,6 +995,27 @@ config TRUST_SHA_MODE
0: none; 1: sha1; 2: sha256 RK big endian; 3: sha256 little endian.
endif

config PSTORE
bool "Print log to linux pstore buffer"
default n
help
This enable Print uboot log to linux pstore buffer which address
is default 0x110000 for most soc.

config PERSISTENT_RAM_ADDR
hex "Linux pstore buffer address"
default 0x0
depends on PSTORE
help
This select linux pstore buffer address for uboot.

config PERSISTENT_RAM_SIZE
hex "Linux pstore buffer size"
default 0x0
depends on PSTORE
help
This select linux pstore buffer size for uboot.

config VENDOR_FRIENDLYELEC
bool
default n
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-rockchip/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ifndef CONFIG_TPL_BUILD
obj-$(CONFIG_$(SPL_)FIT) += fit_misc.o
ifdef CONFIG_SPL_BUILD
obj-y += spl_boot_mode.o
obj-$(CONFIG_ROCKCHIP_META) += rk_meta.o
endif
endif

Expand Down Expand Up @@ -87,3 +88,4 @@ obj-$(CONFIG_TPL_BUILD) += $(obj-tpl-y)

obj-$(CONFIG_ROCKCHIP_PRELOADER_ATAGS) += rk_atags.o
obj-$(CONFIG_SET_DFU_ALT_INFO) += dfu_alt_info.o
obj-$(CONFIG_PSTORE) += pstore.o
45 changes: 32 additions & 13 deletions arch/arm/mach-rockchip/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,17 @@ static int rockchip_set_serialno(void)
memset(serialno_str, 0, VENDOR_SN_MAX);

#ifdef CONFIG_ROCKCHIP_VENDOR_PARTITION
int j;

ret = vendor_storage_read(SN_ID, serialno_str, (VENDOR_SN_MAX-1));
if (ret > 0) {
i = strlen(serialno_str);
for (; i > 0; i--) {
j = strlen(serialno_str);
for (i = 0; i < j; i++) {
if ((serialno_str[i] >= 'a' && serialno_str[i] <= 'z') ||
(serialno_str[i] >= 'A' && serialno_str[i] <= 'Z') ||
(serialno_str[i] >= '0' && serialno_str[i] <= '9'))
continue;
else
break;
}

Expand Down Expand Up @@ -351,14 +355,26 @@ static void cmdline_handle(void)
return;

/*
* From rk356x, the sd/udisk update flag was moved from
* IDB to Android BCB.
* 1. From rk356x, the sd/udisk recovery update flag was moved from
* IDB to Android BCB.
*
* 2. Udisk is init at the late boot_from_udisk(), but
* rockchip_get_boot_mode() actually only read once,
* we need to update boot mode according to udisk BCB.
*/
if (get_bcb_recovery_msg() == BCB_MSG_RECOVERY_RK_FWUPDATE) {
if (dev_desc->if_type == IF_TYPE_MMC && dev_desc->devnum == 1)
env_update("bootargs", "sdfwupdate");
else if (dev_desc->if_type == IF_TYPE_USB && dev_desc->devnum == 0)
env_update("bootargs", "usbfwupdate");
if ((dev_desc->if_type == IF_TYPE_MMC && dev_desc->devnum == 1) ||
(dev_desc->if_type == IF_TYPE_USB && dev_desc->devnum == 0)) {
if (get_bcb_recovery_msg() == BCB_MSG_RECOVERY_RK_FWUPDATE) {
if (dev_desc->if_type == IF_TYPE_MMC && dev_desc->devnum == 1) {
env_update("bootargs", "sdfwupdate");
} else if (dev_desc->if_type == IF_TYPE_USB && dev_desc->devnum == 0) {
env_update("bootargs", "usbfwupdate");
env_set("reboot_mode", "recovery-usb");
}
} else {
if (dev_desc->if_type == IF_TYPE_USB && dev_desc->devnum == 0)
env_set("reboot_mode", "normal");
}
}
}

Expand All @@ -376,9 +392,7 @@ int board_late_init(void)
rockchip_set_serialno();
#endif
setup_download_mode();
#if (CONFIG_ROCKCHIP_BOOT_MODE_REG > 0)
setup_boot_mode();
#endif

#ifdef CONFIG_ROCKCHIP_USB_BOOT
boot_from_udisk();
#endif
Expand All @@ -390,6 +404,9 @@ int board_late_init(void)
#endif
#ifdef CONFIG_ROCKCHIP_EINK_DISPLAY
rockchip_eink_show_uboot_logo();
#endif
#if (CONFIG_ROCKCHIP_BOOT_MODE_REG > 0)
setup_boot_mode();
#endif
env_fixup();
soc_clk_dump();
Expand Down Expand Up @@ -693,7 +710,9 @@ int board_init_f_boot_flags(void)
int boot_flags = 0;

arch_fpga_init();

#ifdef CONFIG_PSTORE
param_parse_pstore();
#endif
param_parse_pre_serial(&boot_flags);

/* The highest priority to turn off (override) console */
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/mach-rockchip/boot_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ int rockchip_get_boot_mode(void)
} else if (!strcmp(env_reboot_mode, "fastboot")) {
printf("boot mode: fastboot\n");
return BOOT_MODE_BOOTLOADER;
} else if (!strcmp(env_reboot_mode, "normal")) {
printf("boot mode: normal(env)\n");
return BOOT_MODE_NORMAL;
}
}

Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-rockchip/kernel_dtb.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <dm/root.h>
#include <dm/uclass-internal.h>
#include <asm/arch/hotkey.h>
#include <asm/arch/resource_img.h>

DECLARE_GLOBAL_DATA_PTR;

Expand Down Expand Up @@ -317,6 +318,7 @@ int init_kernel_dtb(void)
}

if (IS_ENABLED(CONFIG_EMBED_KERNEL_DTB_ALWAYS)) {
resource_init_list();
printf("Always embed kernel dtb\n");
goto dtb_embed;
}
Expand Down
Loading

0 comments on commit f2229e8

Please sign in to comment.