mirror of
https://github.com/revyos/th1520-vendor-uboot.git
synced 2026-06-21 17:12:31 +02:00
Compare commits
7 Commits
20251124
...
Linux_SDK_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
316b169ffe | ||
|
|
d8c8b62185 | ||
|
|
ba628b63b3 | ||
|
|
60c2e85ba7 | ||
|
|
e14a461444 | ||
|
|
6c027f3c8e | ||
|
|
644f3eb8ff |
2
Kconfig
2
Kconfig
@@ -302,7 +302,7 @@ menu "Boot images"
|
||||
|
||||
config ANDROID_BOOT_IMAGE
|
||||
bool "Enable support for Android Boot Images"
|
||||
default y if FASTBOOT
|
||||
default n if FASTBOOT
|
||||
help
|
||||
This enables support for booting images which use the Android
|
||||
image format header.
|
||||
|
||||
8
Makefile
8
Makefile
@@ -219,7 +219,7 @@ endif
|
||||
|
||||
ifeq ($(KBUILD_SRC),)
|
||||
# building in the source tree
|
||||
srctree := .
|
||||
srctree := $(shell pwd)
|
||||
else
|
||||
ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
|
||||
# building in a subdirectory of the source tree
|
||||
@@ -726,6 +726,8 @@ UBOOTINCLUDE := \
|
||||
$(if $(CONFIG_HAS_THUMB2),, \
|
||||
-I$(srctree)/arch/$(ARCH)/thumb1/include),) \
|
||||
-I$(srctree)/arch/$(ARCH)/include \
|
||||
$(if $(CONFIG_TARGET_LIGHT_C910), -I$(srctree)/lib/sec_library/include) \
|
||||
$(if $(CONFIG_TARGET_LIGHT_C910), -I$(srctree)/lib/sec_library/include/soft_crypto) \
|
||||
-include $(srctree)/include/linux/kconfig.h
|
||||
|
||||
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
|
||||
@@ -756,6 +758,8 @@ libs-y += drivers/net/phy/
|
||||
libs-y += drivers/power/ \
|
||||
drivers/power/domain/ \
|
||||
drivers/power/fuel_gauge/ \
|
||||
drivers/power/charge/ \
|
||||
drivers/mcu/ \
|
||||
drivers/power/mfd/ \
|
||||
drivers/power/pmic/ \
|
||||
drivers/power/battery/ \
|
||||
@@ -811,7 +815,7 @@ PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`
|
||||
endif
|
||||
PLATFORM_LIBS += $(PLATFORM_LIBGCC)
|
||||
ifeq ($(CONFIG_TARGET_LIGHT_C910),y)
|
||||
PLATFORM_LIBS += -L $(shell pwd)/lib/sec_library -lsec_library
|
||||
PLATFORM_LIBS += -L $(srctree)/lib/sec_library -lsec_library
|
||||
endif
|
||||
|
||||
ifdef CONFIG_CC_COVERAGE
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
|
||||
obj-y += dram.o
|
||||
obj-y += cpu.o
|
||||
obj-y += feature.o
|
||||
|
||||
@@ -141,8 +141,9 @@ void dcache_enable(void)
|
||||
#ifdef CONFIG_SPL_RISCV_MMODE
|
||||
#ifdef CONFIG_TARGET_LIGHT_C910
|
||||
asm volatile (
|
||||
"li x29, 0x11ff\n\t"
|
||||
"csrw mhcr, x29\n\t"
|
||||
"csrr x29, mhcr\n\t"
|
||||
"ori x28, x29, 0x2\n\t"
|
||||
"csrw mhcr, x28\n\t"
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -14,9 +14,9 @@ DECLARE_GLOBAL_DATA_PTR;
|
||||
int dram_init(void)
|
||||
{
|
||||
#ifdef CONFIG_DDR_BOARD_CONFIG
|
||||
extern unsigned long get_ddr_density(void);
|
||||
// update ram_size from board config info
|
||||
gd->ram_size = get_ddr_density();
|
||||
// already setup during ddr initial flow
|
||||
gd->bd->bi_memsize = gd->ram_size;
|
||||
gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
|
||||
return 0;
|
||||
#else
|
||||
return fdtdec_setup_mem_size_base();
|
||||
|
||||
114
arch/riscv/cpu/c9xx/feature.c
Normal file
114
arch/riscv/cpu/c9xx/feature.c
Normal file
@@ -0,0 +1,114 @@
|
||||
#include <common.h>
|
||||
#include <asm/types.h>
|
||||
#include <asm/asm.h>
|
||||
#include <asm/csr.h>
|
||||
|
||||
void setup_features(void)
|
||||
{
|
||||
unsigned int i, cpu_type, cpu_ver;
|
||||
unsigned long version[8];
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
version[i] = csr_read(CSR_MCPUID);
|
||||
|
||||
cpu_type = (version[0] >> 18) & 0xf;
|
||||
cpu_ver = (version[1] >> 12) & 0xffff;
|
||||
|
||||
/*
|
||||
* Warning: CSR_MCCR2 contains an L2 cache latency setting,
|
||||
* you need to confirm it by your own soc design.
|
||||
*/
|
||||
switch (cpu_type) {
|
||||
case 0x3:
|
||||
if (cpu_ver >= 0x1080 && cpu_ver <= 0x10bf) { //1.2.0~1.2.x
|
||||
csr_write(CSR_MCCR2, 0xe0010009);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x6e30c);
|
||||
csr_write(CSR_MHCR, 0x1ff);
|
||||
} else if (cpu_ver == 0x10ca) { //1.3.10
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xe2490009);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x66e30c);
|
||||
csr_write(CSR_MHCR, 0x17f);
|
||||
csr_write(CSR_MHINT2, 0x420000);
|
||||
csr_write(CSR_MHINT4, 0x410);
|
||||
} else if (cpu_ver >= 0x1100 && cpu_ver <= 0x113f) { //1.4.0~1.4.x
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xe2490009);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x16e30c);
|
||||
csr_write(CSR_MHCR, 0x1ff);
|
||||
} else if (cpu_ver >= 0x1140 && cpu_ver <= 0x117f) { //1.5.0~1.5.x
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xe2490009);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0xe6e30c);
|
||||
csr_write(CSR_MHINT2, 0x180);
|
||||
csr_write(CSR_MHCR, 0x1ff);
|
||||
} else if (cpu_ver >= 0x1180 && cpu_ver <= 0x1183) { //1.6.0~1.6.3
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xe249000b);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x1ee30c);
|
||||
csr_write(CSR_MHINT2, 0x180);
|
||||
csr_write(CSR_MHCR, 0x1ff);
|
||||
} else if (cpu_ver >= 0x1184 && cpu_ver <= 0x123f) { //1.6.4~1.8.x
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xe249000b);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x1ee30c);
|
||||
csr_write(CSR_MHINT2, 0x180);
|
||||
csr_write(CSR_MHCR, 0x11ff);
|
||||
} else if (cpu_ver >= 0x2000 && cpu_ver <= 0xffff) { //2.0.0~
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xe249000b);
|
||||
csr_write(CSR_MXSTATUS, 0x438000);
|
||||
csr_write(CSR_MHINT, 0x31ea32c);
|
||||
csr_write(CSR_MHINT2, 0x180);
|
||||
csr_write(CSR_MHCR, 0x11ff);
|
||||
} else {
|
||||
while(1);
|
||||
}
|
||||
break;
|
||||
case 0x4:
|
||||
if (cpu_ver >= 0x1002 && cpu_ver <= 0xffff) {
|
||||
csr_write(CSR_MHCR, 0x17f);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x650c);
|
||||
} else {
|
||||
while(1);
|
||||
}
|
||||
break;
|
||||
case 0x5:
|
||||
if (cpu_ver >= 0x0000 && cpu_ver <= 0x0007) { //0.0.0~0.0.7
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xe0420008);
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x2c50c);
|
||||
csr_write(CSR_MHCR, 0x11ff);
|
||||
} else if (cpu_ver >= 0x0040 && cpu_ver <= 0xffff) { //0.1.0~
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xa042000a);
|
||||
csr_write(CSR_MXSTATUS, 0x438000);
|
||||
csr_write(CSR_MHINT, 0x21aa10c);
|
||||
csr_write(CSR_MHCR, 0x10011ff);
|
||||
} else {
|
||||
while(1);
|
||||
}
|
||||
break;
|
||||
case 0x6:
|
||||
if (cpu_ver >= 0x0) {
|
||||
csr_write(CSR_MSMPR, 0x1);
|
||||
csr_write(CSR_MCCR2, 0xA042000A);
|
||||
csr_write(CSR_MXSTATUS, 0x638001);
|
||||
csr_write(CSR_MHINT, 0x3A1AA10C);
|
||||
csr_write(CSR_MHCR, 0x10011BF);
|
||||
} else {
|
||||
while(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,15 @@ u32 hart_lottery __attribute__((section(".data"))) = 0;
|
||||
u32 available_harts_lock = 1;
|
||||
#endif
|
||||
|
||||
void arch_setup_gd(struct global_data *gd_ptr)
|
||||
{
|
||||
// sync specific info from spl
|
||||
gd_ptr->ram_size = gd->ram_size;
|
||||
|
||||
// setup gd ptr
|
||||
gd = gd_ptr;
|
||||
}
|
||||
|
||||
static inline bool supports_extension(char ext)
|
||||
{
|
||||
#ifdef CONFIG_CPU
|
||||
|
||||
@@ -104,3 +104,45 @@ trap_entry:
|
||||
LREG x2, 2 * REGBYTES(sp)
|
||||
addi sp, sp, 32 * REGBYTES
|
||||
MODE_PREFIX(ret)
|
||||
|
||||
/* trap secondary_entry */
|
||||
.align 10
|
||||
.global secondary_entry
|
||||
secondary_entry:
|
||||
/*
|
||||
* Clear L1 cache & BTB & BHT ...
|
||||
*/
|
||||
li t0, 0x70013
|
||||
csrw CSR_MCOR, t0
|
||||
|
||||
/*
|
||||
* Enable cache coherency
|
||||
*/
|
||||
li t0, 1
|
||||
csrw CSR_MSMPR, t0
|
||||
|
||||
/*
|
||||
*Prepare percpu stack
|
||||
*/
|
||||
csrr t0, mhartid
|
||||
li t1, 0x100
|
||||
mul t1, t1, t0
|
||||
lla sp, stacks
|
||||
add sp, sp, t1
|
||||
|
||||
/*
|
||||
* Call C routine
|
||||
*/
|
||||
call setup_features
|
||||
call next_stage
|
||||
|
||||
/*
|
||||
* Never get here, dead loop
|
||||
*/
|
||||
j .
|
||||
|
||||
.align 10
|
||||
stacks:
|
||||
.rept 0x1000
|
||||
.long
|
||||
.endr
|
||||
|
||||
@@ -41,6 +41,12 @@ secondary_harts_relocation_error:
|
||||
_start:
|
||||
|
||||
#if (defined CONFIG_SPL_BUILD) && (defined CONFIG_TARGET_LIGHT_C910)
|
||||
/* Disable indirect branch prediction once entering into uboot world */
|
||||
li t0, 0x117f
|
||||
csrw 0x7c1, t0
|
||||
/* Disable fence broadcase and HW TLB */
|
||||
li t0, 0x66e30c
|
||||
csrw 0x7c5, t0
|
||||
/* Enable cache ASAP as LIGHT's requirement */
|
||||
jal icache_enable
|
||||
jal dcache_enable
|
||||
@@ -98,12 +104,6 @@ call_board_init_f_0:
|
||||
mv a0, sp
|
||||
jal board_init_f_alloc_reserve
|
||||
|
||||
/*
|
||||
* Set global data pointer here for all harts, uninitialized at this
|
||||
* point.
|
||||
*/
|
||||
mv gp, a0
|
||||
|
||||
/* setup stack */
|
||||
#ifdef CONFIG_SMP
|
||||
/* tp: hart id */
|
||||
@@ -121,16 +121,34 @@ call_board_init_f_0:
|
||||
la t0, hart_lottery
|
||||
li s2, 1
|
||||
amoswap.w s2, t1, 0(t0)
|
||||
bnez s2, wait_for_gd_init
|
||||
beqz s2, call_board_init_f_1
|
||||
|
||||
/*
|
||||
* Set global data pointer here for secondary harts, uninitialized at this
|
||||
* point.
|
||||
*/
|
||||
mv gp, a0
|
||||
|
||||
jal wait_for_gd_init
|
||||
#else
|
||||
bnez tp, secondary_hart_loop
|
||||
beqz tp, call_board_init_f_1
|
||||
|
||||
/*
|
||||
* Set global data pointer here for secondary harts, uninitialized at this
|
||||
* point.
|
||||
*/
|
||||
mv gp, a0
|
||||
|
||||
jal secondary_hart_loop
|
||||
#endif
|
||||
|
||||
call_board_init_f_1:
|
||||
#ifdef CONFIG_OF_PRIOR_STAGE
|
||||
la t0, prior_stage_fdt_address
|
||||
SREG s1, 0(t0)
|
||||
#endif
|
||||
|
||||
/* Set global data pointer here for main hart */
|
||||
jal board_init_f_init_reserve
|
||||
|
||||
/* save the boot hart id to global_data */
|
||||
|
||||
@@ -5,7 +5,7 @@ dtb-$(CONFIG_TARGET_SIFIVE_FU540) += hifive-unleashed-a00.dtb
|
||||
dtb-$(CONFIG_TARGET_ICE_C910) += ice-c910.dtb
|
||||
dtb-$(CONFIG_TARGET_LIGHT_EVB_MPW_C910) += light-evb-mpw-c910.dtb
|
||||
dtb-$(CONFIG_TARGET_LIGHT_FPGA_FM_C910) += light-fpga-fm-c910.dtb
|
||||
dtb-$(CONFIG_TARGET_LIGHT_C910) += light-a-ref.dtb light-b-ref.dtb light-a-val.dtb light-b-product.dtb light-a-product.dtb light-ant-ref.dtb light-beagle.dtb light-b-power.dtb light-lpi4a.dtb
|
||||
dtb-$(CONFIG_TARGET_LIGHT_C910) += light-a-ref.dtb light-b-ref.dtb light-a-val.dtb light-b-product.dtb light-a-product.dtb light-ant-ref.dtb light-beagle.dtb light-b-power.dtb light-lpi4a.dtb th1520-rvbook.dtb
|
||||
|
||||
targets += $(dtb-y)
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/dts-v1/;
|
||||
|
||||
#include <dt-bindings/pmic/light_pmic.h>
|
||||
|
||||
/ {
|
||||
model = "T-HEAD c910 light";
|
||||
compatible = "thead,c910_light";
|
||||
@@ -306,10 +309,10 @@
|
||||
spi-max-frequency = <100000000>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
flash@0 {
|
||||
compatible = "jedec,spi-nor";
|
||||
tpm@0{
|
||||
compatible = "z32h330tc,z32h330tc-spi";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <40000000>;
|
||||
spi-max-frequency = <20000000>;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -359,6 +362,20 @@
|
||||
};
|
||||
};
|
||||
|
||||
usb: usb@ffe7040000 {
|
||||
compatible = "snps,dwc3";
|
||||
reg = <0xff 0xe7040000 0x0 0x10000>;
|
||||
interrupts = <68>;
|
||||
reg-shift = <2>;
|
||||
reg-io-width = <4>;
|
||||
maximum-speed = "super-speed";
|
||||
dr_mode = "host";
|
||||
dma-mask = <0xf 0xffffffff>;
|
||||
snps,usb3_lpm_capable;
|
||||
snps,usb_sofitpsync;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
pwm: pwm@ffec01c000 {
|
||||
compatible = "thead,pwm-light";
|
||||
reg = <0xff 0xec01c000 0x0 0x4000>;
|
||||
@@ -479,6 +496,429 @@
|
||||
lcd-en-gpios = <&pcal6408ahk_a 2 0>; /* active high */
|
||||
lcd-bias-en-gpios = <&pcal6408ahk_a 4 0>;/* active high */
|
||||
};
|
||||
|
||||
aon {
|
||||
compatible = "thead,light-aon";
|
||||
status = "okay";
|
||||
|
||||
wakeup-by-gpio-on;
|
||||
wakeup-by-rtc-on;
|
||||
|
||||
pd: light-aon-pd {
|
||||
compatible = "thead,light-aon-pd";
|
||||
#power-domain-cells = <1>;
|
||||
};
|
||||
|
||||
light-regu-reg {
|
||||
compatible = "thead,light-dialog-pmic";
|
||||
status = "okay";
|
||||
|
||||
soc_dvdd18_aon_reg: soc_dvdd18_aon {
|
||||
regulator-name = "soc_dvdd18_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd33_usb3_reg: soc_avdd33_usb3 {
|
||||
regulator-name = "soc_avdd33_usb3";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_aon_reg: soc_dvdd08_aon {
|
||||
regulator-name = "soc_dvdd08_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_apcpu_dvdd_dvddm_reg: soc_apcpu_dvdd_dvddm {
|
||||
regulator-name = "soc_apcpu_dvdd_dvddm";
|
||||
regulator-min-microvolt = <300000>;
|
||||
regulator-max-microvolt = <1570000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ddr_reg: soc_dvdd08_ddr {
|
||||
regulator-name = "soc_dvdd08_ddr";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v8_reg: soc_vdd_ddr_1v8 {
|
||||
regulator-name = "soc_vdd_ddr_1v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v1_reg: soc_vdd_ddr_1v1 {
|
||||
regulator-name = "soc_vdd_ddr_1v1";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_0v6_reg: soc_vdd_ddr_0v6 {
|
||||
regulator-name = "soc_vdd_ddr_0v6";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_ap_reg: soc_dvdd18_ap {
|
||||
regulator-name = "soc_dvdd18_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ap_reg: soc_dvdd08_ap {
|
||||
regulator-name = "soc_dvdd08_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd08_mipi_hdmi_reg: soc_avdd08_mipi_hdmi {
|
||||
regulator-name = "soc_avdd08_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd18_mipi_hdmi_reg: soc_avdd18_mipi_hdmi {
|
||||
regulator-name = "soc_avdd18_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd33_emmc_reg: soc_dvdd33_emmc {
|
||||
regulator-name = "soc_dvdd33_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_emmc_reg: soc_dvdd18_emmc {
|
||||
regulator-name = "soc_vdd18_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dovdd18_scan_reg: soc_dovdd18_scan {
|
||||
regulator-name = "soc_dovdd18_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
};
|
||||
soc_vext_2v8_reg: soc_vext_2v8 {
|
||||
regulator-name = "soc_vext_2v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dvdd12_scan_reg: soc_dvdd12_scan {
|
||||
regulator-name = "soc_dvdd12_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
};
|
||||
soc_avdd28_scan_en_reg: soc_avdd28_scan_en {
|
||||
regulator-name = "soc_avdd28_scan_en";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
};
|
||||
soc_avdd28_rgb_reg: soc_avdd28_rgb {
|
||||
regulator-name = "soc_avdd28_rgb";
|
||||
regulator-min-microvolt = <2200000>;
|
||||
regulator-max-microvolt = <3475000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dovdd18_rgb_reg: soc_dovdd18_rgb {
|
||||
regulator-name = "soc_dovdd18_rgb";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dvdd12_rgb_reg: soc_dvdd12_rgb {
|
||||
regulator-name = "soc_dvdd12_rgb";
|
||||
regulator-min-microvolt = <400000>;
|
||||
regulator-max-microvolt = <1675000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_avdd25_ir_reg: soc_avdd25_ir {
|
||||
regulator-name = "soc_avdd25_ir";
|
||||
regulator-min-microvolt = <2200000>;
|
||||
regulator-max-microvolt = <3475000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dovdd18_ir_reg: soc_dovdd18_ir {
|
||||
regulator-name = "soc_dovdd18_ir";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dvdd12_ir_reg: soc_dvdd12_ir {
|
||||
regulator-name = "soc_dvdd12_ir";
|
||||
regulator-min-microvolt = <400000>;
|
||||
regulator-max-microvolt = <1675000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
};
|
||||
|
||||
aon_pmic_config {
|
||||
compatible = "thead,light-pmic-conf";
|
||||
status = "okay";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
iic-config = <0 0 2>;
|
||||
pmic_dev_0: pmic-dev@0 {
|
||||
pmic-name = "dialog,da9063,v1";
|
||||
pmic-addr = <0x5a 0x5b>;
|
||||
pmic_wdt_on;
|
||||
errio_gpio = <0 14 3>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
pmic_dev_1: pmic-dev@1 {
|
||||
pmic-name = "dialog,da9121,v1";
|
||||
pmic-addr = <0x68>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
pmic_dev_2: pmic-dev@2 {
|
||||
pmic-name = "dialog,slg51000,v1";
|
||||
pmic-addr = <0x75>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
regu_config_0 {
|
||||
reg_info = <&soc_dvdd18_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO3>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_1 {
|
||||
reg_info = <&soc_avdd33_usb3_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO9>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_2 {
|
||||
reg_info = <&soc_dvdd08_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO2>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_3 {
|
||||
reg_info = <&soc_apcpu_dvdd_dvddm_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BCORE1>;
|
||||
auto_on_info = <0 0 800000>;
|
||||
};
|
||||
|
||||
regu_id@1 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BCORE2>;
|
||||
auto_on_info = <1 0 800000>;
|
||||
};
|
||||
|
||||
coupling_info@0 {
|
||||
negative-min;
|
||||
info = <0 1 5 30>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_4 {
|
||||
reg_info = <&soc_dvdd08_ddr_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKPERI>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_5 {
|
||||
reg_info = <&soc_vdd_ddr_1v8_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO4>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_6 {
|
||||
reg_info = <&soc_vdd_ddr_1v1_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKMEM>;
|
||||
};
|
||||
regu_id@1 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKIO>;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
regu_config_7 {
|
||||
reg_info = <&soc_vdd_ddr_0v6_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKPRO>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_8 {
|
||||
reg_info = <&soc_dvdd18_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO11>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_9 {
|
||||
reg_info = <&soc_avdd08_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_10 {
|
||||
reg_info = <&soc_avdd18_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO5>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_11 {
|
||||
reg_info = <&soc_dvdd33_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO10>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_12 {
|
||||
reg_info = <&soc_dovdd18_scan_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO6>;
|
||||
auto_on_info = <2 1 1800000>;
|
||||
auto_off_info = <7 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_13 {
|
||||
reg_info = <&soc_vext_2v8_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO7>;
|
||||
auto_on_info = <3 1 2800000>;
|
||||
auto_off_info = <8 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_14 {
|
||||
reg_info = <&soc_dvdd12_scan_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO8>;
|
||||
auto_on_info = <4 1 1200000>;
|
||||
auto_off_info = <9 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_15 {
|
||||
reg_info = <&soc_avdd28_scan_en_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_GPIO4>;
|
||||
auto_on_info = <5 1 2800000>;
|
||||
auto_off_info = <6 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_16 {
|
||||
reg_info = <&soc_dvdd08_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 DA9121_ID_BUCK1>;
|
||||
parent_pmic_dev = <&pmic_dev_0 2 0>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_17 {
|
||||
reg_info = <&soc_avdd28_rgb_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_2 SLG51000_ID_LDO1>;
|
||||
auto_on_info = <6 0 2800000>;
|
||||
auto_off_info = <0 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_18 {
|
||||
reg_info = <&soc_avdd25_ir_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_2 SLG51000_ID_LDO2>;
|
||||
auto_on_info = <7 0 2500000>;
|
||||
auto_off_info = <1 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_19 {
|
||||
reg_info = <&soc_dvdd18_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_2 SLG51000_ID_LDO3>;
|
||||
parent_pmic_dev = <&pmic_dev_0 7 0>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_20 {
|
||||
reg_info = <&soc_dovdd18_rgb_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_2 SLG51000_ID_LDO4>;
|
||||
auto_on_info = <8 0 1800000>;
|
||||
auto_off_info = <2 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_21 {
|
||||
reg_info = <&soc_dvdd12_rgb_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_2 SLG51000_ID_LDO5>;
|
||||
auto_on_info = <9 0 1200000>;
|
||||
auto_off_info = <3 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_22 {
|
||||
reg_info = <&soc_dvdd12_ir_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_2 SLG51000_ID_LDO6>;
|
||||
auto_on_info = <10 0 1200000>;
|
||||
auto_off_info = <4 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_23 {
|
||||
reg_info = <&soc_dovdd18_ir_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_2 SLG51000_ID_LDO7>;
|
||||
auto_on_info = <11 0 1800000>;
|
||||
auto_off_info = <5 1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
chosen {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/dts-v1/;
|
||||
|
||||
#include <dt-bindings/pmic/light_pmic.h>
|
||||
|
||||
/ {
|
||||
model = "T-HEAD c910 light";
|
||||
compatible = "thead,c910_light";
|
||||
@@ -469,6 +472,362 @@
|
||||
lcd-en-gpios = <&gpio1_porta 9 0>; /* active high */
|
||||
lcd-bias-en-gpios = <&gpio1_porta 10 0>;/* active high */
|
||||
};
|
||||
|
||||
aon {
|
||||
compatible = "thead,light-aon";
|
||||
status = "okay";
|
||||
|
||||
wakeup-by-gpio-on;
|
||||
wakeup-by-rtc-on;
|
||||
|
||||
pd: light-aon-pd {
|
||||
compatible = "thead,light-aon-pd";
|
||||
#power-domain-cells = <1>;
|
||||
};
|
||||
|
||||
light-regu-reg {
|
||||
compatible = "thead,light-dialog-pmic";
|
||||
status = "okay";
|
||||
|
||||
|
||||
|
||||
soc_dvdd18_aon_reg: soc_dvdd18_aon {
|
||||
regulator-name = "soc_dvdd18_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd33_usb3_reg: soc_avdd33_usb3 {
|
||||
regulator-name = "soc_avdd33_usb3";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_aon_reg: soc_dvdd08_aon {
|
||||
regulator-name = "soc_dvdd08_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_apcpu_dvdd_dvddm_reg: soc_apcpu_dvdd_dvddm {
|
||||
regulator-name = "soc_apcpu_dvdd_dvddm";
|
||||
regulator-min-microvolt = <300000>;
|
||||
regulator-max-microvolt = <1570000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ddr_reg: soc_dvdd08_ddr {
|
||||
regulator-name = "soc_dvdd08_ddr";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v8_reg: soc_vdd_ddr_1v8 {
|
||||
regulator-name = "soc_vdd_ddr_1v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v1_reg: soc_vdd_ddr_1v1 {
|
||||
regulator-name = "soc_vdd_ddr_1v1";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_0v6_reg: soc_vdd_ddr_0v6 {
|
||||
regulator-name = "soc_vdd_ddr_0v6";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_ap_reg: soc_dvdd18_ap {
|
||||
regulator-name = "soc_dvdd18_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ap_reg: soc_dvdd08_ap {
|
||||
regulator-name = "soc_dvdd08_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd08_mipi_hdmi_reg: soc_avdd08_mipi_hdmi {
|
||||
regulator-name = "soc_avdd08_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd18_mipi_hdmi_reg: soc_avdd18_mipi_hdmi {
|
||||
regulator-name = "soc_avdd18_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd33_emmc_reg: soc_dvdd33_emmc {
|
||||
regulator-name = "soc_dvdd33_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_emmc_reg: soc_dvdd18_emmc {
|
||||
regulator-name = "soc_vdd18_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dovdd18_scan_reg: soc_dovdd18_scan {
|
||||
regulator-name = "soc_dovdd18_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_vext_2v8_reg: soc_vext_2v8 {
|
||||
regulator-name = "soc_vext_2v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dvdd12_scan_reg: soc_dvdd12_scan {
|
||||
regulator-name = "soc_dvdd12_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_avdd28_scan_en_reg: soc_avdd28_scan_en {
|
||||
regulator-name = "soc_avdd28_scan_en";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_avdd28_rgb_reg: soc_avdd28_rgb {
|
||||
regulator-name = "soc_avdd28_rgb";
|
||||
regulator-min-microvolt = <2200000>;
|
||||
regulator-max-microvolt = <3475000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dovdd18_rgb_reg: soc_dovdd18_rgb {
|
||||
regulator-name = "soc_dovdd18_rgb";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dvdd12_rgb_reg: soc_dvdd12_rgb {
|
||||
regulator-name = "soc_dvdd12_rgb";
|
||||
regulator-min-microvolt = <400000>;
|
||||
regulator-max-microvolt = <1675000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_avdd25_ir_reg: soc_avdd25_ir {
|
||||
regulator-name = "soc_avdd25_ir";
|
||||
regulator-min-microvolt = <2200000>;
|
||||
regulator-max-microvolt = <3475000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dovdd18_ir_reg: soc_dovdd18_ir {
|
||||
regulator-name = "soc_dovdd18_ir";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dvdd12_ir_reg: soc_dvdd12_ir {
|
||||
regulator-name = "soc_dvdd12_ir";
|
||||
regulator-min-microvolt = <400000>;
|
||||
regulator-max-microvolt = <1675000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_adc_vref_reg: soc_adc_vref {
|
||||
regulator-name = "soc_adc_vref";
|
||||
};
|
||||
soc_lcd0_en_reg: soc_lcd0_en {
|
||||
regulator-name = "soc_lcd0_en";
|
||||
};
|
||||
soc_vext_1v8_reg: soc_vext_1v8 {
|
||||
regulator-name = "soc_vext_1v8";
|
||||
};
|
||||
};
|
||||
|
||||
aon_pmic_config {
|
||||
compatible = "thead,light-pmic-conf";
|
||||
status = "okay";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
iic-config = <0 0 2>;
|
||||
pmic_dev_0: pmic-dev@0 {
|
||||
pmic-name = "ricoh,rn5t567,v0";
|
||||
pmic-addr = <0x31>;
|
||||
pmic_wdt_on;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
pmic_dev_1: pmic-dev@1 {
|
||||
pmic-name = "ricoh,rn5t567,v1";
|
||||
pmic-addr = <0x32>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
regu_config_0 {
|
||||
reg_info = <&soc_dvdd18_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_LDO4>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_1 {
|
||||
reg_info = <&soc_avdd33_usb3_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_LDO1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_2 {
|
||||
reg_info = <&soc_dvdd08_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_LDO3>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_3 {
|
||||
reg_info = <&soc_apcpu_dvdd_dvddm_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_DC3>;
|
||||
auto_on_info = <2 0 800000>;
|
||||
};
|
||||
|
||||
regu_id@1 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_DC4>;
|
||||
auto_on_info = <3 0 800000>;
|
||||
};
|
||||
|
||||
coupling_info@0 {
|
||||
negative-min;
|
||||
info = <0 1 5 30>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_4 {
|
||||
reg_info = <&soc_dvdd08_ddr_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_DC1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_5 {
|
||||
reg_info = <&soc_vdd_ddr_1v8_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_LDO2>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_6 {
|
||||
reg_info = <&soc_vdd_ddr_1v1_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_DC2>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_7 {
|
||||
reg_info = <&soc_vdd_ddr_0v6_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_DC1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_8 {
|
||||
reg_info = <&soc_dvdd18_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_LDO2>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_9 {
|
||||
reg_info = <&soc_avdd08_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_LDO3>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_10 {
|
||||
reg_info = <&soc_avdd18_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_LDO4>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_11 {
|
||||
reg_info = <&soc_dvdd33_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_LDO1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_12 {
|
||||
reg_info = <&soc_dvdd08_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_GPIO3>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_13 {
|
||||
reg_info = <&soc_dvdd18_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_DC3>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_14 {
|
||||
reg_info = <&soc_adc_vref_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_LDO5>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_15 {
|
||||
reg_info = <&soc_lcd0_en_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 RICOH567_ID_LDO5>;
|
||||
auto_on_info = <0 0 1800000>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_16 {
|
||||
reg_info = <&soc_vext_1v8_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 RICOH567_ID_DC4>;
|
||||
auto_on_info = <1 0 1800000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
chosen {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
/dts-v1/;
|
||||
|
||||
#include <dt-bindings/pmic/light_pmic.h>
|
||||
|
||||
/ {
|
||||
model = "T-HEAD c910 light";
|
||||
compatible = "thead,c910_light";
|
||||
@@ -147,6 +150,13 @@
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
pcal6408ahk_d: gpio@20 {
|
||||
compatible = "nxp,pca9557";
|
||||
reg = <0x18>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
};
|
||||
|
||||
i2c4: i2c@ffe7f28000{
|
||||
@@ -157,13 +167,6 @@
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
pcal6408ahk_a: gpio@20 {
|
||||
compatible = "nxp,pca9554";
|
||||
reg = <0x20>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
};
|
||||
|
||||
i2c5: i2c@fff7f2c000{
|
||||
@@ -382,6 +385,20 @@
|
||||
reg = <0xff 0xef600000 0x0 0x100>;
|
||||
};
|
||||
|
||||
usb: usb@ffe7040000 {
|
||||
compatible = "snps,dwc3";
|
||||
reg = <0xff 0xe7040000 0x0 0x10000>;
|
||||
interrupts = <68>;
|
||||
reg-shift = <2>;
|
||||
reg-io-width = <4>;
|
||||
maximum-speed = "super-speed";
|
||||
dr_mode = "host";
|
||||
dma-mask = <0xf 0xffffffff>;
|
||||
snps,usb3_lpm_capable;
|
||||
snps,usb_sofitpsync;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
axiscr {
|
||||
compatible = "thead,axiscr";
|
||||
reg = <0xff 0xff004000 0x0 0x1000>;
|
||||
@@ -472,13 +489,376 @@
|
||||
default-brightness-level = <7>;
|
||||
};
|
||||
|
||||
ili9881c_panel {
|
||||
compatible = "ilitek,ili9881c";
|
||||
jadard_jd9365da {
|
||||
compatible = "jadard,jd9365da-h3";
|
||||
backlight = <&lcd_backlight>;
|
||||
reset-gpios = <&gpio1_porta 5 1>; /* active low */
|
||||
lcd-en-gpios = <&pcal6408ahk_a 2 0>; /* active high */
|
||||
lcd-bias-en-gpios = <&pcal6408ahk_a 4 0>;/* active high */
|
||||
reset-gpio = <&pcal6408ahk_d 7 0>;
|
||||
hsvcc-gpio = <&pcal6408ahk_d 6 1>;
|
||||
vspn3v3-gpio = <&pcal6408ahk_d 5 1>;
|
||||
};
|
||||
|
||||
aon {
|
||||
compatible = "thead,light-aon";
|
||||
status = "okay";
|
||||
|
||||
wakeup-by-gpio-on;
|
||||
wakeup-by-rtc-on;
|
||||
|
||||
pd: light-aon-pd {
|
||||
compatible = "thead,light-aon-pd";
|
||||
#power-domain-cells = <1>;
|
||||
};
|
||||
|
||||
light-regu-reg {
|
||||
compatible = "thead,light-dialog-pmic";
|
||||
status = "okay";
|
||||
|
||||
|
||||
|
||||
soc_dvdd18_aon_reg: soc_dvdd18_aon {
|
||||
regulator-name = "soc_dvdd18_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd33_usb3_reg: soc_avdd33_usb3 {
|
||||
regulator-name = "soc_avdd33_usb3";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_aon_reg: soc_dvdd08_aon {
|
||||
regulator-name = "soc_dvdd08_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_apcpu_dvdd_dvddm_reg: soc_apcpu_dvdd_dvddm {
|
||||
regulator-name = "soc_apcpu_dvdd_dvddm";
|
||||
regulator-min-microvolt = <300000>;
|
||||
regulator-max-microvolt = <1570000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ddr_reg: soc_dvdd08_ddr {
|
||||
regulator-name = "soc_dvdd08_ddr";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v8_reg: soc_vdd_ddr_1v8 {
|
||||
regulator-name = "soc_vdd_ddr_1v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v1_reg: soc_vdd_ddr_1v1 {
|
||||
regulator-name = "soc_vdd_ddr_1v1";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_0v6_reg: soc_vdd_ddr_0v6 {
|
||||
regulator-name = "soc_vdd_ddr_0v6";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_ap_reg: soc_dvdd18_ap {
|
||||
regulator-name = "soc_dvdd18_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ap_reg: soc_dvdd08_ap {
|
||||
regulator-name = "soc_dvdd08_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd08_mipi_hdmi_reg: soc_avdd08_mipi_hdmi {
|
||||
regulator-name = "soc_avdd08_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd18_mipi_hdmi_reg: soc_avdd18_mipi_hdmi {
|
||||
regulator-name = "soc_avdd18_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd33_emmc_reg: soc_dvdd33_emmc {
|
||||
regulator-name = "soc_dvdd33_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_emmc_reg: soc_dvdd18_emmc {
|
||||
regulator-name = "soc_vdd18_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dovdd18_scan_reg: soc_dovdd18_scan {
|
||||
regulator-name = "soc_dovdd18_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
};
|
||||
soc_vext_2v8_reg: soc_vext_2v8 {
|
||||
regulator-name = "soc_vext_2v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dvdd12_scan_reg: soc_dvdd12_scan {
|
||||
regulator-name = "soc_dvdd12_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
};
|
||||
soc_avdd28_scan_en_reg: soc_avdd28_scan_en {
|
||||
regulator-name = "soc_avdd28_scan_en";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
};
|
||||
soc_avdd28_rgb_reg: soc_avdd28_rgb {
|
||||
regulator-name = "soc_avdd28_rgb";
|
||||
regulator-min-microvolt = <2200000>;
|
||||
regulator-max-microvolt = <3475000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dovdd18_rgb_reg: soc_dovdd18_rgb {
|
||||
regulator-name = "soc_dovdd18_rgb";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dvdd12_rgb_reg: soc_dvdd12_rgb {
|
||||
regulator-name = "soc_dvdd12_rgb";
|
||||
regulator-min-microvolt = <400000>;
|
||||
regulator-max-microvolt = <1675000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_avdd25_ir_reg: soc_avdd25_ir {
|
||||
regulator-name = "soc_avdd25_ir";
|
||||
regulator-min-microvolt = <2200000>;
|
||||
regulator-max-microvolt = <3475000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dovdd18_ir_reg: soc_dovdd18_ir {
|
||||
regulator-name = "soc_dovdd18_ir";
|
||||
regulator-min-microvolt = <1200000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
soc_dvdd12_ir_reg: soc_dvdd12_ir {
|
||||
regulator-name = "soc_dvdd12_ir";
|
||||
regulator-min-microvolt = <400000>;
|
||||
regulator-max-microvolt = <1675000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
aon_pmic_config {
|
||||
compatible = "thead,light-pmic-conf";
|
||||
status = "okay";
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
iic-config = <0 0 2>;
|
||||
pmic_dev_0: pmic-dev@0 {
|
||||
pmic-name = "dialog,da9063,v1";
|
||||
pmic-addr = <0x5a 0x5b>;
|
||||
pmic_wdt_on;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
pmic_dev_1: pmic-dev@1 {
|
||||
pmic-name = "dialog,da9121,v1";
|
||||
pmic-addr = <0x68>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
regu_config_0 {
|
||||
reg_info = <&soc_dvdd18_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO3>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_1 {
|
||||
reg_info = <&soc_avdd33_usb3_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO9>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_2 {
|
||||
reg_info = <&soc_dvdd08_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO2>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_3 {
|
||||
reg_info = <&soc_apcpu_dvdd_dvddm_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BCORE1>;
|
||||
auto_on_info = <0 0 800000>;
|
||||
};
|
||||
|
||||
regu_id@1 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BCORE2>;
|
||||
auto_on_info = <1 0 800000>;
|
||||
};
|
||||
|
||||
regu_id@2 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKIO>;
|
||||
auto_on_info = <2 0 800000>;
|
||||
};
|
||||
|
||||
coupling_info@0 {
|
||||
negative-min;
|
||||
info = <0 2 5 30>;
|
||||
};
|
||||
|
||||
coupling_info@1 {
|
||||
negative-min;
|
||||
info = <1 2 5 30>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_4 {
|
||||
reg_info = <&soc_dvdd08_ddr_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKPERI>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_5 {
|
||||
reg_info = <&soc_vdd_ddr_1v8_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO4>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_6 {
|
||||
reg_info = <&soc_vdd_ddr_1v1_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKMEM>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_7 {
|
||||
reg_info = <&soc_vdd_ddr_0v6_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKPRO>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_8 {
|
||||
reg_info = <&soc_dvdd18_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO11>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_9 {
|
||||
reg_info = <&soc_avdd08_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_10 {
|
||||
reg_info = <&soc_avdd18_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO5>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_11 {
|
||||
reg_info = <&soc_dvdd33_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO10>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_12 {
|
||||
reg_info = <&soc_dovdd18_scan_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO6>;
|
||||
auto_on_info = <3 1 1800000>;
|
||||
auto_off_info = <1 1>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
regu_config_13 {
|
||||
reg_info = <&soc_dvdd12_scan_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO8>;
|
||||
auto_on_info = <4 1 1200000>;
|
||||
auto_off_info = <2 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_14 {
|
||||
reg_info = <&soc_avdd28_scan_en_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO7>;
|
||||
auto_on_info = <5 1 2800000>;
|
||||
auto_off_info = <0 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_15 {
|
||||
reg_info = <&soc_dvdd08_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 DA9121_ID_BUCK1>;
|
||||
parent_pmic_dev = <&pmic_dev_0 2 0>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_16 {
|
||||
reg_info = <&soc_dvdd18_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_GPIO7>;
|
||||
parent_pmic_dev = <&pmic_dev_0 7 0>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
chosen {
|
||||
|
||||
947
arch/riscv/dts/th1520-rvbook.dts
Normal file
947
arch/riscv/dts/th1520-rvbook.dts
Normal file
@@ -0,0 +1,947 @@
|
||||
/dts-v1/;
|
||||
#include <dt-bindings/usb/pd.h>
|
||||
#include <dt-bindings/pmic/light_pmic.h>
|
||||
|
||||
/ {
|
||||
model = "T-HEAD c910 light";
|
||||
compatible = "thead,c910_light";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
|
||||
charge-animation {
|
||||
compatible = "rockchip,uboot-charge";
|
||||
uboot-low-power-voltage = <7300>;
|
||||
powerkey-gpio= <&ao_gpio_porta 6 0>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
leds {
|
||||
status = "okay";
|
||||
compatible = "gpio-leds";
|
||||
red-led {
|
||||
gpios = <&gpio1_porta 14 0>; // GPIO_ACTIVE_HIGH: 0
|
||||
label = "battery_charging";
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
green-led {
|
||||
gpios = <&gpio1_porta 13 0>; // GPIO_ACTIVE_HIGH: 0
|
||||
label = "battery_full";
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
blue-led {
|
||||
gpios = <&gpio1_porta 15 0>; // GPIO_ACTIVE_HIGH: 0
|
||||
label = "battery_start";
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
|
||||
memory@0 {
|
||||
device_type = "memory";
|
||||
reg = <0x0 0xc0000000 0x0 0x40000000>;
|
||||
};
|
||||
|
||||
aliases {
|
||||
spi0 = &spi0;
|
||||
spi1 = &qspi0;
|
||||
spi2 = &qspi1;
|
||||
};
|
||||
|
||||
cpus {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
timebase-frequency = <3000000>;
|
||||
u-boot,dm-pre-reloc;
|
||||
cpu@0 {
|
||||
device_type = "cpu";
|
||||
reg = <0>;
|
||||
status = "okay";
|
||||
compatible = "riscv";
|
||||
riscv,isa = "rv64imafdcvsu";
|
||||
mmu-type = "riscv,sv39";
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
};
|
||||
|
||||
soc {
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
compatible = "simple-bus";
|
||||
ranges;
|
||||
u-boot,dm-pre-reloc;
|
||||
|
||||
intc: interrupt-controller@ffd8000000 {
|
||||
compatible = "riscv,plic0";
|
||||
reg = <0xff 0xd8000000 0x0 0x04000000>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
dummy_apb: apb-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <62500000>;
|
||||
clock-output-names = "dummy_apb";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
dummy_ahb: ahb-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <250000000>;
|
||||
clock-output-names = "core";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
dummy_spi: spi-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <396000000>;
|
||||
clock-output-names = "dummy_spi";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
dummy_qspi0: qspi0-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <792000000>;
|
||||
clock-output-names = "dummy_qspi0";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
dummy_uart_sclk: uart-sclk-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <100000000>;
|
||||
clock-output-names = "dummy_uart_sclk";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
dummy_i2c_icclk: i2c-icclk-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <50000000>;
|
||||
clock-output-names = "dummy_i2c_icclk";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
dummy_dpu_pixclk: dpu-pix-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <74250000>;
|
||||
clock-output-names = "dummy_dpu_pixclk";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
dummy_dphy_refclk: dphy-ref-clock {
|
||||
compatible = "fixed-clock";
|
||||
clock-frequency = <24000000>;
|
||||
clock-output-names = "dummy_dpu_refclk";
|
||||
#clock-cells = <0>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
i2c0: i2c@ffe7f20000 {
|
||||
compatible = "snps,designware-i2c";
|
||||
reg = <0xff 0xe7f20000 0x0 0x4000>;
|
||||
clocks = <&dummy_i2c_icclk>;
|
||||
clock-frequency = <100000>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
usbc0: husb311_0@4e {
|
||||
compatible = "hynetek,husb311";
|
||||
int-n-gpios = <&gpio3_porta 10 1>;
|
||||
reg = <0x4e>;
|
||||
status = "okay";
|
||||
|
||||
usb_con0: connector {
|
||||
compatible = "usb-c-connector";
|
||||
label = "USB-C";
|
||||
data-role = "dual";
|
||||
power-role = "dual";
|
||||
try-power-role = "sink";
|
||||
source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>;
|
||||
sink-pdos =
|
||||
<PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)
|
||||
PDO_FIXED(9000, 3000, PDO_FIXED_USB_COMM)
|
||||
PDO_FIXED(12000, 3000, PDO_FIXED_USB_COMM)>;
|
||||
op-sink-microwatt = <10000000>;
|
||||
};
|
||||
};
|
||||
|
||||
cw2015@62 {
|
||||
clock-frequency = <100000>;
|
||||
status = "okay";
|
||||
compatible = "cellwise,cw2015";
|
||||
reg = <0x62>;
|
||||
cellwise,battery-profile = /bits/ 8
|
||||
<0x17 0x67 0x66 0x65 0x64 0x63 0x61 0x5E
|
||||
0x52 0x6D 0x4D 0x58 0x5B 0x51 0x44 0x3B
|
||||
0x33 0x2C 0x26 0x23 0x24 0x29 0x34 0x42
|
||||
0x49 0x16 0x0E 0xB8 0x3D 0x5D 0x68 0x7D
|
||||
0x78 0x75 0x7B 0x7A 0x3F 0x18 0x82 0x48
|
||||
0x09 0x4A 0x1A 0x47 0x86 0x93 0x97 0x15
|
||||
0x49 0x71 0x9A 0xC3 0x80 0x41 0x4F 0xCB
|
||||
0x2F 0x00 0x64 0xA5 0xB5 0x0D 0xB8 0x91>;
|
||||
cellwise,monitor-interval-ms = <5000>;
|
||||
cellwise,dual-cell = <1>;
|
||||
};
|
||||
|
||||
bq25703: bq25703@6b {
|
||||
status = "okay";
|
||||
compatible = "ti,bq25703";
|
||||
reg = <0x6b>;
|
||||
typec0-enable-gpios = <&gpio3_porta 13 0>; //CHG_PATH_SEL0_180
|
||||
typec1-enable-gpios = <&gpio3_porta 12 0>; //CHG_PATH_SEL1_180
|
||||
ti,charge-current = <2500000>;
|
||||
ti,max-input-voltage = <5000000>;
|
||||
ti,input-current = <2000000>;
|
||||
};
|
||||
};
|
||||
|
||||
i2c1: i2c@ffe7f24000{
|
||||
compatible = "snps,designware-i2c";
|
||||
reg = <0xff 0xe7f24000 0x0 0x4000>;
|
||||
clocks = <&dummy_i2c_icclk>;
|
||||
clock-frequency = <100000>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
mcu_hc32fx:mcu-hc32fx@0x4c {
|
||||
status = "okay";
|
||||
compatible = "mcu_hc32fx";
|
||||
reg = <0x4c>;
|
||||
};
|
||||
|
||||
usbc1: husb311_1@4e {
|
||||
compatible = "hynetek,husb311";
|
||||
int-n-gpios = <&gpio1_porta 5 1>;
|
||||
reg = <0x4e>;
|
||||
status = "okay";
|
||||
|
||||
usb_con1: connector {
|
||||
compatible = "usb-c-connector";
|
||||
label = "USB-C";
|
||||
data-role = "dual";
|
||||
power-role = "dual";
|
||||
try-power-role = "sink";
|
||||
source-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_USB_COMM)>;
|
||||
sink-pdos =
|
||||
<PDO_FIXED(5000, 3000, PDO_FIXED_USB_COMM)
|
||||
PDO_FIXED(9000, 3000, PDO_FIXED_USB_COMM)
|
||||
PDO_FIXED(12000, 3000, PDO_FIXED_USB_COMM)>;
|
||||
op-sink-microwatt = <10000000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
i2c2: i2c@ffec00c000{
|
||||
compatible = "snps,designware-i2c";
|
||||
reg = <0xff 0xec00c000 0x0 0x4000>;
|
||||
clocks = <&dummy_i2c_icclk>;
|
||||
clock-frequency = <100000>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
};
|
||||
|
||||
i2c3: i2c@ffec014000{
|
||||
compatible = "snps,designware-i2c";
|
||||
reg = <0xff 0xec014000 0x0 0x4000>;
|
||||
clocks = <&dummy_i2c_icclk>;
|
||||
clock-frequency = <100000>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
};
|
||||
|
||||
i2c4: i2c@ffe7f28000{
|
||||
compatible = "snps,designware-i2c";
|
||||
reg = <0xff 0xe7f28000 0x0 0x4000>;
|
||||
clocks = <&dummy_i2c_icclk>;
|
||||
clock-frequency = <100000>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
pcal6408ahk_a: gpio@20 {
|
||||
compatible = "nxp,pca9554";
|
||||
reg = <0x20>;
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
};
|
||||
};
|
||||
|
||||
i2c5: i2c@fff7f2c000{
|
||||
compatible = "snps,designware-i2c";
|
||||
reg = <0xff 0xf7f2c000 0x0 0x4000>;
|
||||
clocks = <&dummy_i2c_icclk>;
|
||||
clock-frequency = <100000>;
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
};
|
||||
|
||||
serial@ffe7014000 {
|
||||
compatible = "snps,dw-apb-uart";
|
||||
reg = <0xff 0xe7014000 0x0 0x400>;
|
||||
clocks = <&dummy_uart_sclk>;
|
||||
clock-frequency = <100000000>;
|
||||
clock-names = "baudclk";
|
||||
reg-shift = <2>;
|
||||
reg-io-width = <4>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
gmac0: ethernet@ffe7070000 {
|
||||
compatible = "snps,dwmac";
|
||||
reg = <0xff 0xe7070000 0x0 0x2000>;
|
||||
clocks = <&dummy_apb>;
|
||||
clock-names = "stmmaceth";
|
||||
snps,pbl = <32>;
|
||||
snps,fixed-burst;
|
||||
|
||||
phy-mode = "rgmii-id";
|
||||
phy-handle = <&phy_88E1111_a>;
|
||||
status = "disabled";
|
||||
mdio0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
compatible = "snps,dwmac-mdio";
|
||||
|
||||
phy_88E1111_a: ethernet-phy@1 {
|
||||
reg = <0x1>;
|
||||
};
|
||||
|
||||
phy_88E1111_b: ethernet-phy@2 {
|
||||
reg = <0x2>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
gmac1: ethernet@ffe7060000 {
|
||||
compatible = "snps,dwmac";
|
||||
reg = <0xff 0xe7060000 0x0 0x2000>;
|
||||
clocks = <&dummy_apb>;
|
||||
clock-names = "stmmaceth";
|
||||
snps,pbl = <32>;
|
||||
snps,fixed-burst;
|
||||
phy-mode = "rgmii-id";
|
||||
phy-handle = <&phy_88E1111_b>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
emmc: sdhci@ffe7080000 {
|
||||
compatible = "snps,dwcmshc-sdhci";
|
||||
reg = <0xff 0xe7080000 0x0 0x10000>;
|
||||
index = <0x0>;
|
||||
clocks = <&dummy_ahb>;
|
||||
clock-frequency = <198000000>;
|
||||
clock-names = "core";
|
||||
max-frequency = <198000000>;
|
||||
sdhci-caps-mask = <0x0 0x1000000>;
|
||||
mmc-hs400-1_8v;
|
||||
non-removable;
|
||||
no-sdio;
|
||||
no-sd;
|
||||
bus-width = <8>;
|
||||
voltage= "1.8v";
|
||||
pull_up;
|
||||
io_fixed_1v8;
|
||||
fifo-mode;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
|
||||
sdhci0: sd@ffe7090000 {
|
||||
compatible = "snps,dwcmshc-sdhci";
|
||||
reg = <0xff 0xe7090000 0x0 0x10000>;
|
||||
index = <0x1>;
|
||||
clocks = <&dummy_ahb>;
|
||||
clock-frequency = <198000000>;
|
||||
max-frequency = <198000000>;
|
||||
sd-uhs-sdr104;
|
||||
pull_up;
|
||||
clock-names = "core";
|
||||
bus-width = <4>;
|
||||
voltage= "3.3v";
|
||||
};
|
||||
|
||||
qspi0: spi@ffea000000 {
|
||||
compatible = "snps,dw-apb-ssi-quad";
|
||||
reg = <0xff 0xea000000 0x0 0x1000>;
|
||||
clocks = <&dummy_qspi0>;
|
||||
num-cs = <1>;
|
||||
cs-gpio = <&gpio2_porta 3 0>; // GPIO_ACTIVE_HIGH: 0
|
||||
spi-max-frequency = <100000000>;
|
||||
#address-cells = <1>;
|
||||
#size-cells =<0>;
|
||||
spi-flash@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "spi-nand";
|
||||
spi-tx-bus-width = <4>;
|
||||
spi-rx-bus-width = <4>;
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
qspi1: spi@fff8000000 {
|
||||
compatible = "snps,dw-apb-ssi-quad";
|
||||
reg = <0xff 0xf8000000 0x0 0x1000>;
|
||||
clocks = <&dummy_spi>;
|
||||
num-cs = <1>;
|
||||
cs-gpio = <&gpio0_porta 1 0>; // GPIO_ACTIVE_HIGH: 0
|
||||
spi-max-frequency = <66000000>;
|
||||
#address-cells = <1>;
|
||||
#size-cells =<0>;
|
||||
spi-flash@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
compatible = "spi-nand";
|
||||
spi-tx-bus-width = <4>;
|
||||
spi-rx-bus-width = <4>;
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
spi0: spi@ffe700c000 {
|
||||
compatible = "snps,dw-apb-ssi";
|
||||
reg = <0xff 0xe700c000 0x0 0x1000>;
|
||||
clocks = <&dummy_spi>;
|
||||
cs-gpio = <&gpio2_porta 15 0>;
|
||||
spi-max-frequency = <100000000>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
tpm@0{
|
||||
compatible = "z32h330tc,z32h330tc-spi";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <22000000>;
|
||||
};
|
||||
};
|
||||
|
||||
gpio2: gpio@ffe7f34000 {
|
||||
compatible = "snps,dw-apb-gpio";
|
||||
reg = <0xff 0xe7f34000 0x0 0x1000>;
|
||||
clocks = <&dummy_apb>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
gpio2_porta: gpio-controller@0 {
|
||||
compatible = "snps,dw-apb-gpio-port";
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
snps,nr-gpios = <32>;
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
gpio3: gpio@ffe7f38000 {
|
||||
compatible = "snps,dw-apb-gpio";
|
||||
reg = <0xff 0xe7f38000 0x0 0x1000>;
|
||||
clocks = <&dummy_apb>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
gpio3_porta: gpio-controller@0 {
|
||||
compatible = "snps,dw-apb-gpio-port";
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
snps,nr-gpios = <32>;
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
gpio0: gpio@ffec005000 {
|
||||
compatible = "snps,dw-apb-gpio";
|
||||
reg = <0xff 0xec005000 0x0 0x1000>;
|
||||
clocks = <&dummy_apb>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
gpio0_porta: gpio-controller@0 {
|
||||
compatible = "snps,dw-apb-gpio-port";
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
snps,nr-gpios = <32>;
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
ao_gpio: gpio@fffff41000 {
|
||||
compatible = "snps,dw-apb-gpio";
|
||||
reg = <0xff 0xfff41000 0x0 0x1000>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
ao_gpio_porta: ao_gpio-controller@0 {
|
||||
compatible = "snps,dw-apb-gpio-port";
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
nr-gpios-snps = <32>;
|
||||
reg = <0>;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
gpio1: gpio@ffec006000 {
|
||||
compatible = "snps,dw-apb-gpio";
|
||||
reg = <0xff 0xec006000 0x0 0x1000>;
|
||||
clocks = <&dummy_apb>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
|
||||
gpio1_porta: gpio-controller@0 {
|
||||
compatible = "snps,dw-apb-gpio-port";
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
snps,nr-gpios = <32>;
|
||||
reg = <0>;
|
||||
};
|
||||
};
|
||||
|
||||
pwm: pwm@ffec01c000 {
|
||||
compatible = "thead,pwm-light";
|
||||
reg = <0xff 0xec01c000 0x0 0x4000>;
|
||||
#pwm-cells = <2>;
|
||||
};
|
||||
|
||||
dsi_regs: dsi-controller@ffef500000 {
|
||||
compatible = "thead,light-dsi-regs", "syscon";
|
||||
reg = <0xff 0xef500000 0x0 0x10000>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
vosys_regs: vosys@ffef528000 {
|
||||
compatible = "thead,light-vo-subsys", "syscon";
|
||||
reg = <0xff 0xef528000 0x0 0x1000>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
dpu: dc8200@ffef600000 {
|
||||
compatible = "verisilicon,dc8200";
|
||||
reg = <0xff 0xef600000 0x0 0x100>;
|
||||
};
|
||||
|
||||
axiscr {
|
||||
compatible = "thead,axiscr";
|
||||
reg = <0xff 0xff004000 0x0 0x1000>;
|
||||
lock-read = "okay";
|
||||
lock-write = "okay";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
u-boot,dm-pre-reloc;
|
||||
axiscr0: axisrc@0 {
|
||||
device_type = "axiscr";
|
||||
region = <0x00 0x00000000 0x00 0x80000000>; // 4KB align
|
||||
status = "disabled";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
axiscr1: axisrc@1 {
|
||||
device_type = "axiscr";
|
||||
region = <0x00 0x80000000 0x00 0x80000000>; // 4KB align
|
||||
status = "disabled";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
axiscr2: axisrc@2 {
|
||||
device_type = "axiscr";
|
||||
region = <0x01 0x00000000 0x00 0x80000000>; // 4KB align
|
||||
status = "disabled";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
};
|
||||
|
||||
axiparity {
|
||||
compatible = "thead,axiparity";
|
||||
reg = <0xff 0xff00c000 0x0 0x1000>;
|
||||
lock = "okay";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
u-boot,dm-pre-reloc;
|
||||
axiparity0: axiparity@0 {
|
||||
device_type = "axiparity";
|
||||
region = <0x00 0x00000000 0x01 0x0000000>; // 4KB align
|
||||
status = "disabled";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
axiparity1: axiparity@1 {
|
||||
device_type = "axiparity";
|
||||
region = <0x01 0x00000000 0x01 0x00000000>; // 4KB align
|
||||
status = "disabled";
|
||||
#address-cells = <2>;
|
||||
#size-cells = <2>;
|
||||
u-boot,dm-pre-reloc;
|
||||
};
|
||||
};
|
||||
|
||||
dsi_bridge: dsi-bridge {
|
||||
compatible = "thead,light-dsi-bridge";
|
||||
clocks = <&dummy_dpu_pixclk>;
|
||||
clock-names = "pix-clk";
|
||||
phys = <&dsi_dphy>;
|
||||
phy-names = "dphy";
|
||||
};
|
||||
|
||||
dsi_host: dsi-host {
|
||||
compatible = "synopsys,dw-mipi-dsi";
|
||||
regmap = <&dsi_regs>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
dsi_dphy: dsi-dphy {
|
||||
compatible = "synopsys,dw-dphy";
|
||||
regmap = <&dsi_regs>;
|
||||
vosys-regmap = <&vosys_regs>;
|
||||
clocks = <&dummy_dpu_pixclk>, <&dummy_dphy_refclk>;
|
||||
clock-names = "pix-clk", "ref-clk";
|
||||
#phy-cells = <0>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
lcd_backlight: pwm-backlight {
|
||||
compatible = "pwm-backlight";
|
||||
pwms = <&pwm 0 5000000>;
|
||||
brightness-levels = <0 4 8 16 32 64 128 255>;
|
||||
default-brightness-level = <7>;
|
||||
};
|
||||
|
||||
ili9881c_panel {
|
||||
status = "disabled";
|
||||
compatible = "ilitek,ili9881c";
|
||||
backlight = <&lcd_backlight>;
|
||||
reset-gpios = <&gpio1_porta 5 1>; /* active low */
|
||||
lcd-en-gpios = <&pcal6408ahk_a 2 0>; /* active high */
|
||||
lcd-bias-en-gpios = <&pcal6408ahk_a 4 0>;/* active high */
|
||||
};
|
||||
|
||||
aon {
|
||||
compatible = "thead,light-aon";
|
||||
status = "okay";
|
||||
|
||||
wakeup-by-gpio-on;
|
||||
wakeup-by-rtc-on;
|
||||
|
||||
pd: light-aon-pd {
|
||||
compatible = "thead,light-aon-pd";
|
||||
#power-domain-cells = <1>;
|
||||
};
|
||||
|
||||
light-regu-reg {
|
||||
compatible = "thead,light-dialog-pmic";
|
||||
status = "okay";
|
||||
|
||||
soc_dvdd18_aon_reg: soc_dvdd18_aon {
|
||||
regulator-name = "soc_dvdd18_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd33_usb3_reg: soc_avdd33_usb3 {
|
||||
regulator-name = "soc_avdd33_usb3";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_aon_reg: soc_dvdd08_aon {
|
||||
regulator-name = "soc_dvdd08_aon";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_apcpu_dvdd_dvddm_reg: soc_apcpu_dvdd_dvddm {
|
||||
regulator-name = "soc_apcpu_dvdd_dvddm";
|
||||
regulator-min-microvolt = <300000>;
|
||||
regulator-max-microvolt = <1570000>;
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ddr_reg: soc_dvdd08_ddr {
|
||||
regulator-name = "soc_dvdd08_ddr";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v8_reg: soc_vdd_ddr_1v8 {
|
||||
regulator-name = "soc_vdd_ddr_1v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_1v1_reg: soc_vdd_ddr_1v1 {
|
||||
regulator-name = "soc_vdd_ddr_1v1";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_vdd_ddr_0v6_reg: soc_vdd_ddr_0v6 {
|
||||
regulator-name = "soc_vdd_ddr_0v6";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_ap_reg: soc_dvdd18_ap {
|
||||
regulator-name = "soc_dvdd18_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd08_ap_reg: soc_dvdd08_ap {
|
||||
regulator-name = "soc_dvdd08_ap";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd08_mipi_hdmi_reg: soc_avdd08_mipi_hdmi {
|
||||
regulator-name = "soc_avdd08_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_avdd18_mipi_hdmi_reg: soc_avdd18_mipi_hdmi {
|
||||
regulator-name = "soc_avdd18_mipi_hdmi";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd33_emmc_reg: soc_dvdd33_emmc {
|
||||
regulator-name = "soc_dvdd33_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
|
||||
soc_dvdd18_emmc_reg: soc_dvdd18_emmc {
|
||||
regulator-name = "soc_vdd18_emmc";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dovdd18_scan_reg: soc_dovdd18_scan {
|
||||
regulator-name = "soc_dovdd18_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
};
|
||||
soc_vext_2v8_reg: soc_vext_2v8 {
|
||||
regulator-name = "soc_vext_2v8";
|
||||
regulator-boot-on;
|
||||
regulator-always-on;
|
||||
};
|
||||
soc_dvdd12_scan_reg: soc_dvdd12_scan {
|
||||
regulator-name = "soc_dvdd12_scan";
|
||||
regulator-min-microvolt = <900000>;
|
||||
regulator-max-microvolt = <3600000>;
|
||||
};
|
||||
soc_avdd28_scan_en_reg: soc_avdd28_scan_en {
|
||||
regulator-name = "soc_avdd28_scan_en";
|
||||
regulator-min-microvolt = <2800000>;
|
||||
regulator-max-microvolt = <2800000>;
|
||||
};
|
||||
};
|
||||
|
||||
aon_pmic_config {
|
||||
compatible = "thead,light-pmic-conf";
|
||||
status = "okay";
|
||||
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
iic-config = <0 0 2>;
|
||||
pmic_dev_0: pmic-dev@0 {
|
||||
pmic-name = "dialog,da9063,v1";
|
||||
pmic-addr = <0x5a 0x5b>;
|
||||
pmic_wdt_on;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
pmic_dev_1: pmic-dev@1 {
|
||||
pmic-name = "dialog,da9121,v1";
|
||||
pmic-addr = <0x68>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
regu_config_0 {
|
||||
reg_info = <&soc_dvdd18_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO3>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_1 {
|
||||
reg_info = <&soc_avdd33_usb3_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO9>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_2 {
|
||||
reg_info = <&soc_dvdd08_aon_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO2>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_3 {
|
||||
reg_info = <&soc_apcpu_dvdd_dvddm_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BCORE1>;
|
||||
auto_on_info = <0 0 800000>;
|
||||
};
|
||||
|
||||
regu_id@1 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BCORE2>;
|
||||
auto_on_info = <1 0 800000>;
|
||||
};
|
||||
|
||||
regu_id@2 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKIO>;
|
||||
auto_on_info = <2 0 800000>;
|
||||
};
|
||||
|
||||
coupling_info@0 {
|
||||
negative-min;
|
||||
info = <0 2 5 30>;
|
||||
};
|
||||
|
||||
coupling_info@1 {
|
||||
negative-min;
|
||||
info = <1 2 5 30>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_4 {
|
||||
reg_info = <&soc_dvdd08_ddr_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKPERI>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_5 {
|
||||
reg_info = <&soc_vdd_ddr_1v8_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO4>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_6 {
|
||||
reg_info = <&soc_vdd_ddr_1v1_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKMEM>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_7 {
|
||||
reg_info = <&soc_vdd_ddr_0v6_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_BUCKPRO>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_8 {
|
||||
reg_info = <&soc_dvdd18_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO11>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_9 {
|
||||
reg_info = <&soc_dvdd08_ap_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_1 DA9121_ID_BUCK1>;
|
||||
parent_pmic_dev = <&pmic_dev_0 2 0>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_10 {
|
||||
reg_info = <&soc_avdd08_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_11 {
|
||||
reg_info = <&soc_avdd18_mipi_hdmi_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO5>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_12 {
|
||||
reg_info = <&soc_dvdd33_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO10>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_13 {
|
||||
reg_info = <&soc_dvdd18_emmc_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_GPIO7>;
|
||||
parent_pmic_dev = <&pmic_dev_0 7 0>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_14 {
|
||||
reg_info = <&soc_dovdd18_scan_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO6>;
|
||||
auto_on_info = <2 1 1800000>;
|
||||
auto_off_info = <7 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_15 {
|
||||
reg_info = <&soc_vext_2v8_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO7>;
|
||||
auto_on_info = <3 1 2800000>;
|
||||
auto_off_info = <8 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_16 {
|
||||
reg_info = <&soc_dvdd12_scan_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_LDO8>;
|
||||
auto_on_info = <4 1 1200000>;
|
||||
auto_off_info = <9 1>;
|
||||
};
|
||||
};
|
||||
|
||||
regu_config_17 {
|
||||
reg_info = <&soc_avdd28_scan_en_reg>;
|
||||
status = "okay";
|
||||
regu_id@0 {
|
||||
pmic_dev = <&pmic_dev_0 DA9063_ID_GPIO4>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyS0,115200";
|
||||
stdout-path = "/soc/serial@ffe7014000:115200";
|
||||
};
|
||||
};
|
||||
@@ -34,7 +34,9 @@ typedef enum image_type {
|
||||
T_ROOTFS = 4,
|
||||
T_TF = 2,
|
||||
T_TEE = 5,
|
||||
T_UBOOT = 6
|
||||
T_UBOOT = 6,
|
||||
T_USER = 7,
|
||||
T_SBMETA = 8,
|
||||
} img_type_t;
|
||||
|
||||
static const char header_magic[4] = {'T', 'H', 'E', 'D'};
|
||||
|
||||
17
arch/riscv/include/asm/arch-thead/light-reset.h
Normal file
17
arch/riscv/include/asm/arch-thead/light-reset.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef __LIGHT_RESET_H__
|
||||
#define __LIGHT_RESET_H__
|
||||
|
||||
#define APSYS_RSTGEN_BASE 0xFFEF014000
|
||||
#define REG_C910_SWRST (APSYS_RSTGEN_BASE + 0x4)
|
||||
#define APSYS_REG_BASE 0xFFEF018000
|
||||
#define REG_C910_CORE0_RVBA_L (APSYS_REG_BASE + 0x50)
|
||||
#define REG_C910_CORE0_RVBA_H (APSYS_REG_BASE + 0x54)
|
||||
#define REG_C910_CORE1_RVBA_L (APSYS_REG_BASE + 0x58)
|
||||
#define REG_C910_CORE1_RVBA_H (APSYS_REG_BASE + 0x5C)
|
||||
#define REG_C910_CORE2_RVBA_L (APSYS_REG_BASE + 0x60)
|
||||
#define REG_C910_CORE2_RVBA_H (APSYS_REG_BASE + 0x64)
|
||||
#define REG_C910_CORE3_RVBA_L (APSYS_REG_BASE + 0x68)
|
||||
#define REG_C910_CORE3_RVBA_H (APSYS_REG_BASE + 0x6C)
|
||||
#define REG_PLIC_DELEGATE 0xffd81ffffc
|
||||
|
||||
#endif /* __LIGHT_RESET_H__ */
|
||||
53
arch/riscv/include/asm/atomic.h
Normal file
53
arch/riscv/include/asm/atomic.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef _ASM_RISCV_ATOMIC_H
|
||||
#define _ASM_RISCV_ATOMIC_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <asm/barrier.h>
|
||||
|
||||
typedef struct {
|
||||
volatile long counter;
|
||||
} atomic_t;
|
||||
|
||||
#define ATOMIC_INIT(_lptr, val) (_lptr)->counter = (val)
|
||||
|
||||
#define ATOMIC_INITIALIZER(val) \
|
||||
{ \
|
||||
.counter = (val), \
|
||||
}
|
||||
|
||||
long atomic_read(atomic_t *atom)
|
||||
{
|
||||
long ret = atom->counter;
|
||||
rmb();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void atomic_write(atomic_t *atom, long value)
|
||||
{
|
||||
atom->counter = value;
|
||||
wmb();
|
||||
}
|
||||
|
||||
long atomic_add_return(atomic_t *atom, long value)
|
||||
{
|
||||
long ret;
|
||||
#if __SIZEOF_LONG__ == 4
|
||||
__asm__ __volatile__(" amoadd.w.aqrl %1, %2, %0"
|
||||
: "+A"(atom->counter), "=r"(ret)
|
||||
: "r"(value)
|
||||
: "memory");
|
||||
#elif __SIZEOF_LONG__ == 8
|
||||
__asm__ __volatile__(" amoadd.d.aqrl %1, %2, %0"
|
||||
: "+A"(atom->counter), "=r"(ret)
|
||||
: "r"(value)
|
||||
: "memory");
|
||||
#endif
|
||||
return ret + value;
|
||||
}
|
||||
|
||||
long atomic_sub_return(atomic_t *atom, long value)
|
||||
{
|
||||
return atomic_add_return(atom, -value);
|
||||
}
|
||||
|
||||
#endif /* _ASM_RISCV_ATOMIC_H */
|
||||
@@ -104,15 +104,23 @@
|
||||
#define CSR_CYCLEH 0xc80
|
||||
#define CSR_TIMEH 0xc81
|
||||
#define CSR_INSTRETH 0xc82
|
||||
#define CSR_MVENDORID 0xf11
|
||||
#define CSR_MARCHID 0xf12
|
||||
#define CSR_MIMPID 0xf13
|
||||
#define CSR_MHARTID 0xf14
|
||||
#define CSR_MCPUID 0xfc0
|
||||
|
||||
#define CSR_SMPEN 0x7f3
|
||||
#define CSR_MTEE 0x7f4
|
||||
#define CSR_SMPEN 0x7f3
|
||||
#define CSR_MTEE 0x7f4
|
||||
#define CSR_MCOR 0x7c2
|
||||
#define CSR_MHCR 0x7c1
|
||||
#define CSR_MCCR2 0x7c3
|
||||
#define CSR_MHINT 0x7c5
|
||||
#define CSR_MHINT2 0x7cc
|
||||
#define CSR_MHINT3 0x7cd
|
||||
#define CSR_MHINT4 0x7ce
|
||||
#define CSR_MXSTATUS 0x7c0
|
||||
#define CSR_MSMPR 0x7f3
|
||||
#define CSR_PLIC_BASE 0xfc1
|
||||
|
||||
#define sync_is() asm volatile (".long 0x01b0000b")
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#define __ASM_RISCV_DMA_MAPPING_H
|
||||
|
||||
#include <linux/dma-direction.h>
|
||||
#include "common.h"
|
||||
|
||||
#define dma_mapping_error(x, y) 0
|
||||
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
#include <opensbi.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/csr.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/smp.h>
|
||||
#include <asm/barrier.h>
|
||||
#include <asm/atomic.h>
|
||||
#include <asm/arch-thead/light-reset.h>
|
||||
#include <dm/device.h>
|
||||
#include <dm/root.h>
|
||||
#include <u-boot/zlib.h>
|
||||
@@ -22,6 +26,12 @@
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
static struct fw_dynamic_info opensbi_info;
|
||||
static atomic_t _harts_count = ATOMIC_INITIALIZER(3);
|
||||
static ulong _load_start;
|
||||
static ulong _dtb_addr;
|
||||
static ulong _dyn_info_addr;
|
||||
|
||||
extern void secondary_entry();
|
||||
|
||||
__weak void board_quiesce_devices(void)
|
||||
{
|
||||
@@ -81,6 +91,58 @@ static void boot_prep_linux(bootm_headers_t *images)
|
||||
}
|
||||
}
|
||||
|
||||
void next_stage(void)
|
||||
{
|
||||
void (*next_entry)(unsigned long arg0,unsigned long arg1,unsigned long arg2);
|
||||
|
||||
next_entry = (void (*))(_load_start);
|
||||
ulong hartid = csr_read(CSR_MHARTID);
|
||||
|
||||
atomic_sub_return(&_harts_count, 1);
|
||||
/*
|
||||
* set $a0 = hartid
|
||||
* set $a1 = $dtb_addr
|
||||
* set $a2 = $dyn_info_addr
|
||||
*/
|
||||
next_entry(hartid, _dtb_addr , _dyn_info_addr);
|
||||
}
|
||||
|
||||
bool has_reset_sample(ulong dtb_addr)
|
||||
{
|
||||
int node_offset;
|
||||
node_offset = fdt_path_offset(dtb_addr, "/soc/reset-sample");
|
||||
if (node_offset < 0) {
|
||||
printf("## fdt has no reset_sample\n");
|
||||
return false;
|
||||
} else {
|
||||
printf("## fdt has reset_sample\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static void reset_sample(void)
|
||||
{
|
||||
ulong addr;
|
||||
uint addr_l, addr_h;
|
||||
|
||||
// RESET ADDR
|
||||
addr = (unsigned long)(void *)secondary_entry;
|
||||
addr_h = (uint)(addr >> 32);
|
||||
addr_l = (uint)(addr & 0xFFFFFFFF);
|
||||
// writel(addr_h, (volatile void *)REG_C910_CORE0_RVBA_H);
|
||||
// writel(addr_l, (volatile void *)REG_C910_CORE0_RVBA_L);
|
||||
writel(addr_h, (volatile void *)REG_C910_CORE1_RVBA_H);
|
||||
writel(addr_l, (volatile void *)REG_C910_CORE1_RVBA_L);
|
||||
writel(addr_h, (volatile void *)REG_C910_CORE2_RVBA_H);
|
||||
writel(addr_l, (volatile void *)REG_C910_CORE2_RVBA_L);
|
||||
writel(addr_h, (volatile void *)REG_C910_CORE3_RVBA_H);
|
||||
writel(addr_l, (volatile void *)REG_C910_CORE3_RVBA_L);
|
||||
|
||||
// RESET
|
||||
writel(0x1F, (volatile void *)REG_C910_SWRST);
|
||||
writel(0x1, (volatile void *)REG_PLIC_DELEGATE);
|
||||
}
|
||||
|
||||
static void boot_jump_linux(bootm_headers_t *images, int flag)
|
||||
{
|
||||
void (*kernel)(ulong hart, void *dtb, struct fw_dynamic_info *p);
|
||||
@@ -98,12 +160,25 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
|
||||
|
||||
announce_and_cleanup(fake);
|
||||
|
||||
opensbi_info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE;
|
||||
opensbi_info.version = 0x1;
|
||||
opensbi_info.next_addr = images->os.start;
|
||||
opensbi_info.next_mode = FW_DYNAMIC_INFO_NEXT_MODE_S;
|
||||
opensbi_info.options = 0;
|
||||
opensbi_info.boot_hart = 0;
|
||||
_load_start = kernel;
|
||||
_dtb_addr = images->ft_addr;
|
||||
_dyn_info_addr = (ulong)&opensbi_info;
|
||||
if (!has_reset_sample(_dtb_addr)) {
|
||||
opensbi_info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE;
|
||||
opensbi_info.version = 0x2;
|
||||
opensbi_info.next_addr = images->os.start;
|
||||
opensbi_info.next_mode = FW_DYNAMIC_INFO_NEXT_MODE_S;
|
||||
opensbi_info.options = 0;
|
||||
opensbi_info.boot_hart = 0;
|
||||
reset_sample();
|
||||
} else {
|
||||
opensbi_info.magic = FW_DYNAMIC_INFO_MAGIC_VALUE;
|
||||
opensbi_info.version = 0x1;
|
||||
opensbi_info.next_addr = images->os.start;
|
||||
opensbi_info.next_mode = FW_DYNAMIC_INFO_NEXT_MODE_S;
|
||||
opensbi_info.options = 0;
|
||||
opensbi_info.boot_hart = 0;
|
||||
}
|
||||
|
||||
if (!fake) {
|
||||
if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
|
||||
|
||||
@@ -34,19 +34,61 @@ config SYS_BOARD
|
||||
config SYS_CONFIG_NAME
|
||||
default "light-c910"
|
||||
|
||||
config LIGHT_BOOT_FORCE_SEQ
|
||||
bool "light boot force sequence"
|
||||
default n
|
||||
|
||||
config LIGHT_SEC_UPGRADE
|
||||
bool "light secure upgrade"
|
||||
default n
|
||||
|
||||
config LIGHT_ANDROID_BOOT_IMAGE_VAL_A
|
||||
bool "light board-a android image"
|
||||
default n
|
||||
|
||||
config AVB_USE_OEM_KEY
|
||||
bool "AVB signature with OEM key"
|
||||
default n
|
||||
|
||||
config AVB_ROLLBACK_ENABLE
|
||||
bool "AVB rollback index in RPMB"
|
||||
default n
|
||||
|
||||
config AVB_HW_ENGINE_ENABLE
|
||||
bool "AVB Hardware cryptographic engine enable"
|
||||
default n
|
||||
|
||||
config LIGHT_ANDROID_BOOT_IMAGE_VAL_B
|
||||
bool "light board-b android image"
|
||||
default n
|
||||
|
||||
config LIGHT_ANDROID_BOOT_IMAGE_VAL_LPI4A
|
||||
bool "light board-lpi4a android image"
|
||||
default n
|
||||
|
||||
config LIGHT_ANDROID_BOOT_IMAGE_ANT_REF
|
||||
bool "light board ant ref android image"
|
||||
default n
|
||||
|
||||
config LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A
|
||||
bool "light board-a security boot with verification"
|
||||
default n
|
||||
|
||||
config LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B
|
||||
bool "light board-b security boot with verification"
|
||||
bool "light board-b security boot with verification"
|
||||
default n
|
||||
|
||||
config LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF
|
||||
bool "light ant ref security boot with verification"
|
||||
bool "light ant ref security boot with verification"
|
||||
default n
|
||||
|
||||
config LIGHT_SEC_BOOT_WITH_VERIFY_LPI4A
|
||||
bool "light lpi4a security boot with verification"
|
||||
default n
|
||||
|
||||
config LIGHT_SEC_BOOT_WITH_VERIFY_RVBOOK
|
||||
bool "light lpi4a security boot with verification"
|
||||
default n
|
||||
|
||||
config TARGET_LIGHT_FPGA_FM_C910
|
||||
bool "light fullmask FPGA board"
|
||||
@@ -88,6 +130,10 @@ config TARGET_LIGHT_FM_C910_LPI4A
|
||||
bool "light fullmask for Lichee Pi 4A board "
|
||||
default n
|
||||
|
||||
config TARGET_LIGHT_FM_C910_RVBOOK
|
||||
bool "light fullmask for RVBOOK board "
|
||||
default n
|
||||
|
||||
config TARGET_LIGHT_FM_C910_B_POWER
|
||||
bool "light fullmask for light-b-power board "
|
||||
default n
|
||||
@@ -98,8 +144,7 @@ config SYS_TEXT_BASE
|
||||
|
||||
config SPL_TEXT_BASE
|
||||
hex
|
||||
default 0xffe0000800 if LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A || LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B || LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF
|
||||
default 0xffe0000000 if !(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A || LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B || LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF)
|
||||
default 0xffe0000800
|
||||
|
||||
config SPL_MAX_SIZE
|
||||
hex
|
||||
@@ -210,6 +255,17 @@ config DDR_LP4_2133_SINGLERANK
|
||||
help
|
||||
Enabling this will support lpddr4 2133 singlerank configuration.
|
||||
|
||||
config DDR_DDP
|
||||
bool "LPDDR4/4X Dual Die Package support"
|
||||
help
|
||||
Enabling this will support ddr Dual Die Package configuration.
|
||||
e.g. to support 8GB ddr device with 17-bit row address (16:0)
|
||||
|
||||
config FIXUP_MEMORY_REGION
|
||||
bool "self-adapt to query and fixup memory region"
|
||||
help
|
||||
Enabling this will support self-adapt to query and fixup memory region
|
||||
|
||||
config DDR_H32_MODE
|
||||
bool "LPDDR4/4X 32bit mode configuration"
|
||||
help
|
||||
|
||||
@@ -7,6 +7,10 @@ DDR_SRC_PATH=lpddr4/src
|
||||
DDR_REGU_SRC=lpddr-regu
|
||||
DDR_FW_PATH=$(DDR_SRC_PATH)/ddr_phy_fw
|
||||
|
||||
ifdef CONFIG_RV_BOOK
|
||||
obj-y += sys_clk.o
|
||||
endif
|
||||
|
||||
ifdef CONFIG_SPL_BUILD
|
||||
obj-y += spl.o
|
||||
obj-y += sys_clk.o
|
||||
@@ -23,6 +27,7 @@ obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/init_ddr.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/pinmux.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/waitfwdone.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/ddr_common_func.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/ddr_retention.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/common_lib.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/lpddr4_init.o
|
||||
ifdef CONFIG_DDR_DBI_OFF
|
||||
@@ -60,12 +65,15 @@ obj-$(CONFIG_THEAD_LIGHT_DIGITAL_SENSOR) += digital_sensor.o digital_sensor_test
|
||||
obj-y += clock_config.o
|
||||
obj-y += sec_check.o
|
||||
obj-y += boot.o
|
||||
obj-y += sbmeta/sbmeta.o
|
||||
ifndef CONFIG_TARGET_LIGHT_FPGA_FM_C910
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/ddr_common_func.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/ddr_retention.o
|
||||
obj-$(CONFIG_LPDDR) += $(DDR_SRC_PATH)/common_lib.o
|
||||
endif
|
||||
|
||||
obj-y += light-sv/pll_io_test.o
|
||||
obj-y += light-sv/adc_test.o
|
||||
obj-y += version_rollback.o
|
||||
obj-$(CONFIG_AVB_VERIFY) += secimg_load.o
|
||||
endif
|
||||
|
||||
@@ -8,11 +8,24 @@
|
||||
#include <asm/io.h>
|
||||
#include <dwc3-uboot.h>
|
||||
#include <usb.h>
|
||||
#include <usb/xhci.h>
|
||||
#include <cpu_func.h>
|
||||
#include <abuf.h>
|
||||
#include "sec_library.h"
|
||||
|
||||
#ifdef CONFIG_LIGHT_AON_CONF
|
||||
#include "../../../drivers/misc/light_regu.h"
|
||||
#include "dm/device.h"
|
||||
#include "dm/uclass.h"
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_DWC3
|
||||
static struct dwc3_device dwc3_device_data = {
|
||||
#ifdef CONFIG_RV_BOOK
|
||||
.maximum_speed = USB_SPEED_HIGH,
|
||||
#else
|
||||
.maximum_speed = USB_SPEED_SUPER,
|
||||
#endif
|
||||
.dr_mode = USB_DR_MODE_PERIPHERAL,
|
||||
.index = 0,
|
||||
};
|
||||
@@ -26,6 +39,13 @@ int usb_gadget_handle_interrupts(int index)
|
||||
int board_usb_init(int index, enum usb_init_type init)
|
||||
{
|
||||
dwc3_device_data.base = 0xFFE7040000UL;
|
||||
|
||||
if (init == USB_INIT_DEVICE) {
|
||||
dwc3_device_data.dr_mode = USB_DR_MODE_PERIPHERAL;
|
||||
} else {
|
||||
dwc3_device_data.dr_mode = USB_DR_MODE_HOST;
|
||||
}
|
||||
|
||||
return dwc3_uboot_init(&dwc3_device_data);
|
||||
}
|
||||
|
||||
@@ -35,6 +55,28 @@ int board_usb_cleanup(int index, enum usb_init_type init)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
|
||||
{
|
||||
|
||||
|
||||
int ret = board_usb_init(index, USB_INIT_HOST);
|
||||
if (ret != 0) {
|
||||
puts("Failed to initialize board for USB\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
*hccr = (struct xhci_hccr *)dwc3_device_data.base;
|
||||
*hcor = (struct xhci_hcor *)(dwc3_device_data.base +
|
||||
HC_LENGTH(xhci_readl(&(*hccr)->cr_capbase)));;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void xhci_hcd_stop(int index)
|
||||
{
|
||||
board_usb_cleanup(index, USB_INIT_HOST);
|
||||
}
|
||||
|
||||
int g_dnl_board_usb_cable_connected(void)
|
||||
{
|
||||
return 1;
|
||||
@@ -42,17 +84,24 @@ int g_dnl_board_usb_cable_connected(void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CMD_BOOT_SLAVE
|
||||
#ifdef CONFIG_LIGHT_AON_CONF
|
||||
#define E902_AON_CONFIG_SIZE 0xC00
|
||||
#else
|
||||
#define E902_AON_CONFIG_SIZE 0x000
|
||||
#endif
|
||||
#define E902_SYSREG_START 0xfffff48044
|
||||
#define E902_SYSREG_RESET 0xfffff44024
|
||||
#define E902_START_ADDRESS 0xFFEF8000
|
||||
#define E902_START_ADDRESS (0xFFEF8000 + E902_AON_CONFIG_SIZE)
|
||||
#define C910_E902_START_ADDRESS 0xFFFFEF8000
|
||||
#define E902_IOPMP_BASE 0xFFFFC21000
|
||||
|
||||
#define C906_RST_ADDR_L 0xfffff48048
|
||||
#define C906_RST_ADDR_H 0xfffff4804C
|
||||
#define C906_START_ADDRESS_L 0xc0000000
|
||||
#define C906_START_ADDRESS_H 0xff
|
||||
#define C910_C906_START_ADDRESS 0xffc0000000
|
||||
|
||||
#define C906_START_ADDRESS_L 0x32000000
|
||||
#define C906_START_ADDRESS_H 0x00
|
||||
#define C910_C906_START_ADDRESS 0x0032000000
|
||||
|
||||
#define C906_CPR_IPCG_ADDRESS 0xFFCB000010
|
||||
#define C906_IOCTL_GPIO_SEL_ADDRESS 0xFFCB01D000
|
||||
#define C906_IOCTL_AF_SELH_ADDRESS 0xFFCB01D008
|
||||
@@ -82,32 +131,164 @@ void set_c906_cpu_entry(phys_addr_t entry_h, phys_addr_t entry_l)
|
||||
|
||||
void boot_audio(void)
|
||||
{
|
||||
writel(0x37, (volatile void *)C906_RESET_REG);
|
||||
writel(0x37, (volatile void *)C906_RESET_REG);
|
||||
|
||||
set_c906_cpu_entry(C906_START_ADDRESS_H, C906_START_ADDRESS_L);
|
||||
flush_cache((uintptr_t)C910_C906_START_ADDRESS, 0x20000);
|
||||
set_c906_cpu_entry(C906_START_ADDRESS_H, C906_START_ADDRESS_L);
|
||||
flush_cache((uintptr_t)C910_C906_START_ADDRESS, 0x20000);
|
||||
|
||||
writel(0x7ffff1f, (volatile void *)C906_CPR_IPCG_ADDRESS);
|
||||
writel((1<<23) | (1<<24), (volatile void *)C906_IOCTL_GPIO_SEL_ADDRESS);
|
||||
writel(0, (volatile void *)C906_IOCTL_AF_SELH_ADDRESS);
|
||||
writel(0x7ffff1f, (volatile void *)C906_CPR_IPCG_ADDRESS);
|
||||
writel((1<<23) | (1<<24), (volatile void *)C906_IOCTL_GPIO_SEL_ADDRESS);
|
||||
writel(0, (volatile void *)C906_IOCTL_AF_SELH_ADDRESS);
|
||||
|
||||
writel(0x3f, (volatile void *)C906_RESET_REG);
|
||||
writel(0x3f, (volatile void *)C906_RESET_REG);
|
||||
}
|
||||
|
||||
void boot_aon(void)
|
||||
#ifdef CONFIG_LIGHT_AON_CONF
|
||||
|
||||
int get_and_set_aon_config_data(void)
|
||||
{
|
||||
int ret =0;
|
||||
struct udevice *dev;
|
||||
struct mic_regu_platdata *config_data =NULL;
|
||||
|
||||
ret = uclass_first_device_err(UCLASS_MISC, &dev);
|
||||
if(ret){
|
||||
printf("get light aon config faild %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
config_data = (struct mic_regu_platdata *)(dev->platdata);
|
||||
|
||||
volatile aon_config_t* read_config = (aon_config_t* )C910_E902_START_ADDRESS;
|
||||
if(strncmp((const char*)read_config->magic , AON_CONFIG_MAGIC, strlen(AON_CONFIG_MAGIC))) {
|
||||
printf("No aon config magic found in aon bin, please check the aon bin\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(strncmp((const char*)read_config->version, AON_CONFIG_VERSION, strlen(AON_CONFIG_VERSION))) {
|
||||
printf("Err aon config version, aon bin is:%s, u-boot is:%s\n", read_config->version, AON_CONFIG_VERSION);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(PMIC_MAX_HW_ID_NUM > read_config->max_hw_id_num) {
|
||||
printf("Invald max hw id num, aon bin support %d , u-boot is %d\n",read_config->max_hw_id_num, PMIC_MAX_HW_ID_NUM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*set pmic dev info */
|
||||
int pmic_dev_num = config_data->pmic_list.pmic_num;
|
||||
int pmic_dev_list_offset = sizeof(aon_config_t);
|
||||
uint64_t pmic_dev_start_addr = C910_E902_START_ADDRESS + pmic_dev_list_offset;
|
||||
|
||||
int regu_num = config_data->regu_id_list.regu_id_num;
|
||||
int regu_id_list_offset = pmic_dev_list_offset + pmic_dev_num * sizeof(pmic_dev_info_t);
|
||||
uint64_t regu_start_addr = C910_E902_START_ADDRESS + regu_id_list_offset;
|
||||
int aon_bin_size = regu_id_list_offset + regu_num* sizeof(csi_regu_id_t);
|
||||
if( aon_bin_size > read_config->aon_config_partition_size) {
|
||||
printf("Invalid aon partition size, aon bin support:%lld, u-boot is %d\n", read_config->aon_config_partition_size, aon_bin_size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("pmic_dev_num:%d offset:%d addr:%lld\n",pmic_dev_num, pmic_dev_list_offset, pmic_dev_start_addr);
|
||||
|
||||
memcpy((void*)pmic_dev_start_addr, config_data->pmic_list.pmic_list, pmic_dev_num * sizeof(pmic_dev_info_t));
|
||||
printf("regu_num:%d offset:%d addr:%lld\n",regu_num,regu_id_list_offset, regu_start_addr);
|
||||
|
||||
memcpy((void*)regu_start_addr, config_data->regu_id_list.regu_id_list, regu_num * sizeof(csi_regu_id_t));
|
||||
|
||||
read_config->wakeup_flag = config_data->wakeup_flag;
|
||||
read_config->aon_pmic.iic_config.iic_id = config_data->iic_config.iic_id;
|
||||
read_config->aon_pmic.iic_config.addr_mode = config_data->iic_config.addr_mode;
|
||||
read_config->aon_pmic.iic_config.speed = config_data->iic_config.speed;
|
||||
read_config->aon_pmic.pmic_dev_num = pmic_dev_num;
|
||||
read_config->aon_pmic.pmic_dev_list_offset = pmic_dev_list_offset;
|
||||
|
||||
/*set regu list info*/
|
||||
read_config->aon_pmic.regu_num = regu_num;
|
||||
read_config->aon_pmic.regu_id_list_offset = regu_id_list_offset;
|
||||
|
||||
memcpy((void*)read_config->uboot_set_magic, UBOOT_CONFIG_MAGIC, strlen(UBOOT_CONFIG_MAGIC));
|
||||
|
||||
flush_cache((uintptr_t)C910_E902_START_ADDRESS, aon_bin_size);
|
||||
|
||||
printf("-->pmic_dev_num:%d offset:%d\n",read_config->aon_pmic.pmic_dev_num, read_config->aon_pmic.pmic_dev_list_offset);
|
||||
printf("-->regu_num:%d offset:%d\n",read_config->aon_pmic.regu_num,read_config->aon_pmic.regu_id_list_offset);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int do_boot_aon(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
#ifdef CONFIG_LIGHT_AON_CONF
|
||||
int ret = 0;
|
||||
ret = get_and_set_aon_config_data();
|
||||
if(ret) {
|
||||
printf("aon config and set faild %d", ret);
|
||||
hang();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
writel(0xffffffff, (void *)(E902_IOPMP_BASE + 0xc0));
|
||||
disable_slave_cpu();
|
||||
set_slave_cpu_entry(E902_START_ADDRESS);
|
||||
flush_cache((uintptr_t)C910_E902_START_ADDRESS, 0x10000);
|
||||
enable_slave_cpu();
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
bootaon, CONFIG_SYS_MAXARGS, 0, do_boot_aon,
|
||||
"Boot aon from memory ",
|
||||
" "
|
||||
);
|
||||
|
||||
int do_bootslave(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
boot_aon();
|
||||
mdelay(100);
|
||||
boot_audio();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOARD_RNG_SEED
|
||||
const char pre_gen_seed[128] = {211, 134, 226, 116, 1, 13, 224, 196, 88, 213, 188, 219, 128, 41, 231, 228, 129, 123, 173, 234, 219, 79, 152, 154, 169, 27, 183, 166, 52, 21, 118, 7, 155, 89, 124, 156, 102, 92, 96, 190, 49, 28, 154, 177, 69, 129, 149, 199, 253, 66, 177, 216, 146, 73, 114, 59, 100, 41, 225, 152, 62, 88, 160, 217, 177, 28, 117, 23, 120, 213, 213, 169, 242, 111, 90, 55, 241, 239, 254, 238, 50, 175, 198, 196, 248, 56, 255, 92, 97, 224, 245, 160, 56, 149, 121, 233, 177, 239, 0, 41, 196, 214, 210, 182, 69, 44, 238, 54, 27, 236, 36, 77, 156, 234, 17, 148, 34, 16, 241, 132, 241, 230, 36, 41, 123, 157, 19, 44};
|
||||
/* Use hardware rng to seed Linux random. */
|
||||
int board_rng_seed(struct abuf *buf)
|
||||
{
|
||||
size_t len = 128;
|
||||
uint8_t *data = NULL;
|
||||
int sc_err = SC_FAIL;
|
||||
|
||||
/* abuf is working up in asynchronization mode, so the memory usage for random data storage must
|
||||
be allocated first. */
|
||||
data = malloc(len);
|
||||
if (!data) {
|
||||
printf("Fail to allocate memory, using pre-defined entropy\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_AVB_HW_ENGINE_ENABLE)
|
||||
/* We still use pre-define entropy data in case hardware random engine does not work */
|
||||
sc_err = csi_sec_library_init();
|
||||
if (sc_err != SC_OK) {
|
||||
printf("Fail to initialize sec library, using pre-defined entropy\n");
|
||||
goto _err;
|
||||
}
|
||||
|
||||
sc_err = sc_rng_get_random_bytes(data, len);
|
||||
if (sc_err != SC_OK) {
|
||||
printf("Fail to retrieve random data, using pre-defined entropy\n");
|
||||
goto _err;
|
||||
}
|
||||
|
||||
abuf_init_set(buf, data, len);
|
||||
return 0;
|
||||
|
||||
_err:
|
||||
#endif
|
||||
/* use pre-defined random data in case of the random engine is disable */
|
||||
memcpy(data, pre_gen_seed, len);
|
||||
abuf_init_set(buf, data, len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1146,6 +1146,7 @@ void ap_mipi_dsi1_clk_endisable(bool en)
|
||||
writel(cfg1, (void __iomem *)AP_DPU1_PLL_CFG1);
|
||||
}
|
||||
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_DISCRETE) || defined (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B)
|
||||
static void ap_multimedia_div_num_set(enum multimedia_div_type type, unsigned int div_num)
|
||||
{
|
||||
unsigned long div_reg;
|
||||
@@ -1209,6 +1210,7 @@ static void ap_multimedia_div_num_set(enum multimedia_div_type type, unsigned in
|
||||
div_cfg |= div_en;
|
||||
writel(div_cfg, (void __iomem *)div_reg);
|
||||
}
|
||||
#endif
|
||||
|
||||
int clk_config(void)
|
||||
{
|
||||
@@ -1218,7 +1220,7 @@ int clk_config(void)
|
||||
return -EINVAL;
|
||||
|
||||
printf("C910 CPU FREQ: %ldMHz\n", rate / 1000000);
|
||||
|
||||
#ifdef PERI_BUS_PLL_FREQ_PRINT
|
||||
rate = clk_light_get_rate("ahb2_cpusys_hclk", CLK_DEV_MUX);
|
||||
if (!rate)
|
||||
return -EINVAL;
|
||||
@@ -1260,6 +1262,7 @@ int clk_config(void)
|
||||
return -EINVAL;
|
||||
|
||||
printf("DPU1 PLL POSTDIV FREQ: %ldMHZ\n", rate / 1000000);
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_PLL_FREQ_PRINT
|
||||
rate = clk_light_get_rate("audio_pll_foutpostdiv", CLK_DEV_PLL);
|
||||
@@ -1302,9 +1305,9 @@ int clk_config(void)
|
||||
|
||||
/* The boards other than the LightA board perform the bus down-speed operation */
|
||||
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_DISCRETE) || defined (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B) || defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A)
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_DISCRETE) || defined (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B)
|
||||
ap_multimedia_div_num_set(VI_MIPI_CSI0_DIV, 12); /* Input frquency: 2376MHZ */
|
||||
ap_multimedia_div_num_set(VI_ISP0_CORE_DIV, 15); /* Input frquency: 2376MHZ */
|
||||
ap_multimedia_div_num_set(VI_ISP0_CORE_DIV, 12); /* Input frquency: 2376MHZ */
|
||||
ap_multimedia_div_num_set(VI_ISP1_CORE_DIV, 12); /* Input frquency: 2376MHZ */
|
||||
ap_multimedia_div_num_set(VI_ISP_RY_CORE_DIV, 12); /* Input frquency: 2376MHZ */
|
||||
ap_multimedia_div_num_set(VO_DPU_CORE_DIV, 4); /* Input frquency: 2376MHZ */
|
||||
|
||||
@@ -12,3 +12,17 @@ void init_ddr(void)
|
||||
{
|
||||
writel(0x1ff << 4, (void *)0xffff005000);
|
||||
}
|
||||
|
||||
int fixup_ddr_addrmap(unsigned long size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int query_ddr_boundary(unsigned long size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
unsigned long get_ddr_density(void)
|
||||
{
|
||||
return 0x100000000;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,15 @@
|
||||
#include <thead/clock_config.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <asm/arch-thead/light-iopmp.h>
|
||||
#include <memalign.h>
|
||||
#include <fdt_support.h>
|
||||
#include <fs.h>
|
||||
#include <asm/global_data.h>
|
||||
#ifdef CONFIG_RV_BOOK
|
||||
#include <memalign.h>
|
||||
#include <fdt_support.h>
|
||||
#include <fs.h>
|
||||
#endif
|
||||
|
||||
#define SOC_PIN_AP_RIGHT_TOP (0x0)
|
||||
#define SOC_PIN_AP_LEFT_TOP (0x1)
|
||||
@@ -31,6 +40,7 @@
|
||||
#define GMAC0_APB3S_BADDR 0xffec003000
|
||||
#define GMAC1_APB3S_BADDR 0xffec004000
|
||||
static uint64_t apb3s_baddr;
|
||||
extern int check_image_board_id(uint8_t *image_data);
|
||||
|
||||
typedef enum {
|
||||
UART0_TXD = PAD_GRP_BASE_SET(SOC_PIN_AP_RIGHT_TOP),
|
||||
@@ -338,6 +348,193 @@ static int light_pinmx_get_mux_base(pin_name_t pin_name, uint32_t** cfg_base)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FASTBOOT_FLASH_MMC
|
||||
/*
|
||||
* The SN data is stored in the first 512B of the NV partition. It should be read out
|
||||
* and updated. In the following situations, the update will fail:
|
||||
* a. The NV partition cannot be found
|
||||
* b. The length of the SN is out of range
|
||||
* c. The value of the SN contains unprintable characters
|
||||
*/
|
||||
#define MAX_SN_SIZE (64 + 2) /* extra two bytes is used for magic number */
|
||||
#define MAX_READ_SIZE 512
|
||||
#define NV_MAC_OFFSET 128
|
||||
#define NV_MAC_SIZE 20
|
||||
|
||||
static int is_env_setted(const char *env_name)
|
||||
{
|
||||
#ifdef U_BUILD_DEBUG
|
||||
return 0;
|
||||
#else
|
||||
const char *env = env_get(env_name);
|
||||
if(env && *env) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void update_sn(void)
|
||||
{
|
||||
struct blk_desc *dev_desc;
|
||||
struct disk_partition part_info;
|
||||
unsigned char buffer[MAX_READ_SIZE];
|
||||
int ret;
|
||||
ulong block_start;
|
||||
ulong block_count;
|
||||
ulong n;
|
||||
size_t length;
|
||||
unsigned int i;
|
||||
|
||||
ret = is_env_setted("serial#");
|
||||
if (ret) {
|
||||
printf("serial# has been setted,skip read from nv partition\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get mmc dev */
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (dev_desc == NULL) {
|
||||
printf("Failed to find MMC device\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* Get the nv partition infomation */
|
||||
ret = part_get_info_by_name(dev_desc, NV_PARTITION_NAME, &part_info);
|
||||
if (ret < 0) {
|
||||
printf("Failed to find '%s' partition\n", NV_PARTITION_NAME);
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* Read the first MAX_READ_SIZE from NV partition data */
|
||||
block_start = part_info.start;
|
||||
block_count = (MAX_READ_SIZE + dev_desc->blksz - 1) / dev_desc->blksz;
|
||||
n = blk_dread(dev_desc, block_start, block_count, buffer);
|
||||
if (n != block_count) {
|
||||
printf("Failed to read data from '%s' partition\n", NV_PARTITION_NAME);
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* Check the length of SN data */
|
||||
length = strnlen((char *)buffer, MAX_READ_SIZE);
|
||||
if ((length > MAX_SN_SIZE)) {
|
||||
printf("The size of SN data(%zu) is out of range \r\n", length);
|
||||
goto err_exit;
|
||||
}
|
||||
/* Check the magic number of NV */
|
||||
i = 0;
|
||||
if ((buffer[i++] != 'N') || (buffer[i++] != 'V')) {
|
||||
printf("The magic number of NV partition is invalid\r\n");
|
||||
goto err_exit;
|
||||
}
|
||||
/* Check the value of the SN data; the SN value should consist of printable characters*/
|
||||
for (; i < length; i++) {
|
||||
if ((buffer[i] < 33) || (buffer[i] > 126)) {
|
||||
printf("Unprintable character detected[0x%x] @%d \r\n", buffer[i], i);
|
||||
goto err_exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* The first two bytes are used for NV magic number */
|
||||
env_set("serial#", (char *)buffer + 2);
|
||||
printf("Success to read SN value, update SN: %s to env serial# \r\n", buffer + 2);
|
||||
|
||||
ret = run_command("env save",0);
|
||||
if(ret != 0) {
|
||||
printf("Failed to update SN to env\r\n");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
err_exit:
|
||||
printf("Failed to read the SN value; Using the default value instead\r\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void update_mac(void)
|
||||
{
|
||||
struct blk_desc *dev_desc;
|
||||
struct disk_partition part_info;
|
||||
unsigned char buffer[MAX_READ_SIZE];
|
||||
int ret;
|
||||
ulong block_start;
|
||||
ulong block_count;
|
||||
ulong n;
|
||||
size_t length;
|
||||
unsigned int i;
|
||||
|
||||
ret = is_env_setted("ethaddr");
|
||||
if (ret) {
|
||||
printf("ethaddr has been setted,skip read from nv partition\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get mmc dev */
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (dev_desc == NULL) {
|
||||
printf("Failed to find MMC device\n");
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* Get the nv partition infomation */
|
||||
ret = part_get_info_by_name(dev_desc, NV_PARTITION_NAME, &part_info);
|
||||
if (ret < 0) {
|
||||
printf("Failed to find '%s' partition\n", NV_PARTITION_NAME);
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* Read the first MAX_READ_SIZE from NV partition data */
|
||||
block_start = part_info.start;
|
||||
block_count = (MAX_READ_SIZE + dev_desc->blksz - 1) / dev_desc->blksz;
|
||||
n = blk_dread(dev_desc, block_start, block_count, buffer);
|
||||
if (n != block_count) {
|
||||
printf("Failed to read data from '%s' partition\n", NV_PARTITION_NAME);
|
||||
goto err_exit;
|
||||
}
|
||||
|
||||
/* Check the length of MAC data */
|
||||
length = strnlen((char *)buffer + NV_MAC_OFFSET, MAX_READ_SIZE);
|
||||
if (length != NV_MAC_SIZE) {
|
||||
printf("The size of MAC data(%zu) is out of range\r\n", length);
|
||||
goto err_exit;
|
||||
}
|
||||
/* Check the magic number of MAC */
|
||||
i = 0;
|
||||
if ((buffer[NV_MAC_OFFSET + i++] != 'M') || (buffer[NV_MAC_OFFSET + i++] != 'A') || (buffer[NV_MAC_OFFSET + i++] != 'C')) {
|
||||
printf("The magic number of NV partition is invalid\r\n");
|
||||
goto err_exit;
|
||||
}
|
||||
/* Check the value of the MAC data; the MAC value should consist of printable characters*/
|
||||
for (; i < length; i++) {
|
||||
if ((buffer[NV_MAC_OFFSET + i] < 33) || (buffer[i + NV_MAC_OFFSET] > 126)) {
|
||||
printf("Unprintable character detected\r\n");
|
||||
goto err_exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* The first two bytes are used for MAC magic number */
|
||||
env_set("ethaddr", (char *)buffer + 3 + NV_MAC_OFFSET);
|
||||
printf("Success to read MAC value, update MAC: %s to env ethaddr \r\n", buffer + 3 + NV_MAC_OFFSET);
|
||||
|
||||
return;
|
||||
|
||||
err_exit:
|
||||
printf("Failed to read the MAC value; Using the default value instead\r\n");
|
||||
|
||||
return;
|
||||
}
|
||||
#else
|
||||
static void update_sn(void)
|
||||
{
|
||||
}
|
||||
|
||||
static void update_mac(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* function: danica_ioreuse_inital
|
||||
*
|
||||
@@ -555,12 +752,14 @@ static void gmac_phy_rst(void)
|
||||
(void *)LIGHT_GPIO3_BADDR);
|
||||
writel(readl((void *)LIGHT_GPIO1_BADDR) & ~LIGHT_GPIO1_13,
|
||||
(void *)LIGHT_GPIO1_BADDR);
|
||||
wmb();
|
||||
/* At least 10ms */
|
||||
mdelay(12);
|
||||
mdelay(50);
|
||||
writel(readl((void *)LIGHT_GPIO3_BADDR) | LIGHT_GPIO3_21,
|
||||
(void *)LIGHT_GPIO3_BADDR);
|
||||
writel(readl((void *)LIGHT_GPIO1_BADDR) | LIGHT_GPIO1_13,
|
||||
(void *)LIGHT_GPIO1_BADDR);
|
||||
wmb();
|
||||
}
|
||||
|
||||
static void gmac_glue_init(uint64_t apb3s_baddr)
|
||||
@@ -910,14 +1109,14 @@ static void light_iopin_init(void)
|
||||
light_pin_cfg(GPIO1_2,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
light_pin_cfg(GPIO1_3,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
light_pin_cfg(GPIO1_4,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
#ifndef defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER)
|
||||
#if ! defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER)
|
||||
light_pin_cfg(GPIO1_9,PIN_SPEED_NORMAL,PIN_PN,2); //soc_vdd18_lcd0_en_reg --backup regulator
|
||||
#else
|
||||
light_pin_cfg(GPIO1_9,PIN_SPEED_NORMAL,PIN_PU,2); //soc_vdd18_lcd0_en_reg
|
||||
#endif
|
||||
light_pin_cfg(GPIO1_10,PIN_SPEED_NORMAL,PIN_PN,2);//soc_lcd0_bias_en_reg
|
||||
light_pin_cfg(GPIO1_11,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
#ifndef defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER)
|
||||
#if ! defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER)
|
||||
light_pin_cfg(GPIO1_12,PIN_SPEED_NORMAL,PIN_PN,2);//reg_tp_pwr_en --touch pannel
|
||||
#else
|
||||
light_pin_cfg(GPIO1_12,PIN_SPEED_NORMAL,PIN_PU,2);//reg_tp_pwr_en --touch pannel
|
||||
@@ -1406,7 +1605,7 @@ static void light_iopin_init(void)
|
||||
light_pin_cfg(GMAC0_RXD2, PIN_SPEED_NORMAL, PIN_PN, 0xF);
|
||||
light_pin_cfg(GMAC0_RXD3, PIN_SPEED_NORMAL, PIN_PN, 0xF);
|
||||
}
|
||||
#elif defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A)
|
||||
#elif defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A) || defined(CONFIG_TARGET_LIGHT_FM_C910_RVBOOK)
|
||||
static void light_iopin_init(void)
|
||||
{
|
||||
/* aon-padmux config */
|
||||
@@ -1419,7 +1618,10 @@ static void light_iopin_init(void)
|
||||
light_pin_cfg(CPU_JTG_TMS, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_mux(CPU_JTG_TDI, 3);
|
||||
light_pin_cfg(CPU_JTG_TDI, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
|
||||
#ifdef CONFIG_RV_BOOK
|
||||
light_pin_mux(CPU_JTG_TRST, 3);
|
||||
light_pin_cfg(CPU_JTG_TRST, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
#endif
|
||||
light_pin_mux(AOGPIO_7, 1);
|
||||
light_pin_mux(AOGPIO_8, 1);
|
||||
// light_pin_mux(AOGPIO_9, 0);
|
||||
@@ -1431,7 +1633,7 @@ static void light_iopin_init(void)
|
||||
// light_pin_mux(AOGPIO_15,0);
|
||||
light_pin_cfg(AOGPIO_7, PIN_SPEED_NORMAL, PIN_PN, 2); ///NC
|
||||
light_pin_cfg(AOGPIO_8, PIN_SPEED_NORMAL, PIN_PN, 2); ///NC
|
||||
// light_pin_cfg(AOGPIO_9,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
light_pin_cfg(AOGPIO_9,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
light_pin_cfg(AOGPIO_10, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_cfg(AOGPIO_11, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_cfg(AOGPIO_12, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
@@ -1465,6 +1667,7 @@ static void light_iopin_init(void)
|
||||
light_pin_cfg(AUDIO_PA29, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_mux(AUDIO_PA30, 0);
|
||||
light_pin_cfg(AUDIO_PA30, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_mux(AUDIO_PA30, 3);
|
||||
|
||||
// light_pin_mux(AUDIO_PA9,3); ///AUDIO-PA-RESET
|
||||
// light_pin_cfg(AUDIO_PA9,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
@@ -1568,7 +1771,7 @@ static void light_iopin_init(void)
|
||||
light_pin_mux(CLK_OUT_2, 0);
|
||||
light_pin_cfg(CLK_OUT_2, PIN_SPEED_NORMAL, PIN_PU, 2);
|
||||
light_pin_mux(CLK_OUT_3, 0);
|
||||
light_pin_cfg(CLK_OUT_3, PIN_SPEED_NORMAL, PIN_PU, 2);
|
||||
light_pin_cfg(CLK_OUT_3, PIN_SPEED_NORMAL, PIN_PU, 2);
|
||||
|
||||
// light_pin_mux(GPIO1_21,3);
|
||||
light_pin_mux(GPIO1_22, 3);
|
||||
@@ -1588,7 +1791,7 @@ static void light_iopin_init(void)
|
||||
light_pin_cfg(GPIO1_30, PIN_SPEED_NORMAL, PIN_PN, 2); ///<DBB2LEDDRIVER_EN
|
||||
|
||||
light_pin_cfg(UART0_TXD, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_cfg(UART0_RXD, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_cfg(UART0_RXD, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
|
||||
/*ap-pdmux on righ/top*/
|
||||
// light_pin_mux(QSPI0_SCLK,3); ///NC
|
||||
@@ -1681,16 +1884,19 @@ static void light_iopin_init(void)
|
||||
light_pin_cfg(GMAC0_CRS, PIN_SPEED_NORMAL, PIN_PU, 2);
|
||||
}
|
||||
#else
|
||||
|
||||
static void light_iopin_init(void)
|
||||
{
|
||||
light_pin_cfg(I2C_AON_SCL,PIN_SPEED_NORMAL,PIN_PN,4);
|
||||
light_pin_cfg(I2C_AON_SDA,PIN_SPEED_NORMAL,PIN_PN,4);
|
||||
light_pin_cfg(AOGPIO_8,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
light_pin_cfg(AOGPIO_9,PIN_SPEED_NORMAL,PIN_PN,2);
|
||||
light_pin_cfg(AOGPIO_14, PIN_SPEED_NORMAL, PIN_PN, 2);
|
||||
light_pin_mux(AOGPIO_10,1);
|
||||
light_pin_mux(AOGPIO_11,1);
|
||||
light_pin_mux(AOGPIO_12,1);
|
||||
light_pin_mux(AOGPIO_13,1);
|
||||
light_pin_mux(AOGPIO_14, 0);
|
||||
light_pin_mux(AUDIO_PA30,3);
|
||||
|
||||
/*qspi1 cs0 gpio0-1 pad strength and pin-pull mode*/
|
||||
@@ -1860,10 +2066,18 @@ static void light_usb_boot_check(void)
|
||||
uchar env_enetaddr[6]={0};
|
||||
uchar env_enet1addr[6]={0};
|
||||
int env_ethaddr_flag,env_eth1addr_flag;
|
||||
int ret = 0;
|
||||
|
||||
boot_mode = readl((void *)SOC_OM_ADDRBASE) & 0x7;
|
||||
if (boot_mode & BIT(2))
|
||||
return;
|
||||
|
||||
/*check board id of uboot image*/
|
||||
ret = check_image_board_id((uint8_t*)SRAM_BASE_ADDR);
|
||||
if (ret != 0) {
|
||||
while(1);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
||||
env_set("usb_fastboot", "yes");
|
||||
#endif
|
||||
@@ -1892,19 +2106,30 @@ static void light_usb_boot_check(void)
|
||||
run_command("fastboot usb 0", 0);
|
||||
}
|
||||
|
||||
|
||||
int board_late_init(void)
|
||||
{
|
||||
|
||||
light_usb_boot_check();
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_UPGRADE)
|
||||
extern void sec_upgrade_thread(void);
|
||||
extern void nonsec_upgrade_thread(void);
|
||||
extern void sec_firmware_version_dump(void);
|
||||
sec_upgrade_thread();
|
||||
nonsec_upgrade_thread();
|
||||
sec_firmware_version_dump();
|
||||
#endif
|
||||
|
||||
light_usb_boot_check();
|
||||
ap_peri_clk_disable();
|
||||
#ifdef CONFIG_MCU_HC32fX
|
||||
mcu_poweron();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DM_CHARGE_DISPLAY
|
||||
charge_display();
|
||||
#endif
|
||||
|
||||
update_sn();
|
||||
update_mac();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1934,3 +2159,244 @@ U_BOOT_CMD(
|
||||
"check ethaddrs in environment variables is valid",
|
||||
""
|
||||
);
|
||||
|
||||
|
||||
#define PAGE_SIZE 4096
|
||||
#define HIBERNATE_SIG "S1SUSPEND"
|
||||
#define HIBERNATE_SIG2 "S1SUSPEN2" //sign for 2nd time load image
|
||||
|
||||
static inline int fdt_disabled_node(void *blob,const char *path)
|
||||
{
|
||||
int offset;
|
||||
offset = fdt_path_offset(blob,path);
|
||||
if (offset < 0) {
|
||||
printf("ERROR:failed to find %s node in dtb (ret %d)\n",path,offset);
|
||||
return offset;
|
||||
}
|
||||
return fdt_status_disabled(blob,offset);
|
||||
}
|
||||
|
||||
/*First check if path1 exist, if not, alternate to path2*/
|
||||
static inline int fdt_disabled_node_alt(void *blob,const char *path1, const char *path2)
|
||||
{
|
||||
int offset;
|
||||
offset = fdt_path_offset(blob,path1);
|
||||
if (offset < 0) {
|
||||
offset = fdt_path_offset(blob,path2);
|
||||
if(offset < 0)
|
||||
{
|
||||
printf("ERROR:failed to find %s node or %s node in dtb (ret %d)\n",path1,path2,offset);
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
return fdt_status_disabled(blob,offset);
|
||||
}
|
||||
|
||||
/*First check if alias name *fisrt exist, if not, alternate to alias name *alt*/
|
||||
static inline int fdt_status_disabled_by_alias_alt(void *blob,const char *fisrt,const char* alt)
|
||||
{
|
||||
int ret;
|
||||
ret = fdt_status_disabled_by_alias(blob,fisrt);
|
||||
if(ret < 0)
|
||||
ret = fdt_status_disabled_by_alias(blob,alt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int do_board_check_hibernate(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||
char * const argv[])
|
||||
{
|
||||
int ret;
|
||||
char runcmd[128];
|
||||
ulong addr;
|
||||
void *blob = NULL;
|
||||
ulong mask = 0;
|
||||
int resume_part;
|
||||
bool fastresume = 0;
|
||||
#define ON_RET_ERROR(str) if(ret < 0) printf("set node %s status failed %d\n",str,ret)
|
||||
ALLOC_CACHE_ALIGN_BUFFER(u8,swsusp_header_buf,PAGE_SIZE);
|
||||
u8 *header = &swsusp_header_buf[0];
|
||||
struct blk_desc *dev_desc;
|
||||
struct disk_partition part_info;
|
||||
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (dev_desc == NULL) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
resume_part = part_get_info_by_name(dev_desc, "swap", &part_info);
|
||||
if (resume_part < 0) {
|
||||
printf("Failed to find swap partition\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if(argc >= 4) { // is user pass in ,use that
|
||||
sprintf(runcmd, "read %s %s %s 0 8",
|
||||
argv[1],argv[2],argv[3]);
|
||||
header = (u8 *)simple_strtoul(argv[3],NULL,16);
|
||||
if(argc >= 5)
|
||||
mask = simple_strtoul(argv[4],NULL,16);
|
||||
printf("read swsusp_header to %p,dtb disbale mask 0x%lx\n",header,mask);
|
||||
} else {
|
||||
sprintf(runcmd, "read mmc 0:%d 0x%lx 0 8",
|
||||
resume_part,(unsigned long)&header[0]);
|
||||
}
|
||||
|
||||
ret = run_command(runcmd, 0);
|
||||
if(ret != CMD_RET_SUCCESS)
|
||||
goto failed;
|
||||
if(!memcmp(HIBERNATE_SIG, &header[PAGE_SIZE-10], 10) ||
|
||||
!memcmp(HIBERNATE_SIG2, &header[PAGE_SIZE-10], 10) ) {
|
||||
printf("found sign\n");
|
||||
}
|
||||
else {
|
||||
sprintf(runcmd, "0:%s",env_get("mmcbootpart"));
|
||||
if(file_exists("mmc",runcmd,"no_fastresume",FS_TYPE_EXT)) {
|
||||
printf("do not fastresume\n");
|
||||
goto default_set;
|
||||
}
|
||||
|
||||
sprintf(runcmd, "read mmc 0:%d 0x%lx 0 8",
|
||||
resume_part+1,(unsigned long)&header[0]);
|
||||
ret = run_command(runcmd, 0);
|
||||
if(ret != CMD_RET_SUCCESS)
|
||||
goto failed;
|
||||
if(!memcmp(HIBERNATE_SIG, &header[PAGE_SIZE-10], 10) ||
|
||||
!memcmp(HIBERNATE_SIG2, &header[PAGE_SIZE-10], 10) ) {
|
||||
printf("found fastresume sign\n");
|
||||
resume_part = resume_part+1;
|
||||
fastresume = true;
|
||||
}
|
||||
else {
|
||||
printf(" not find hibernate sign\n");
|
||||
goto default_set;
|
||||
}
|
||||
}
|
||||
|
||||
/*get dtb address*/
|
||||
if(env_get("dtb_addr") == NULL)
|
||||
{
|
||||
printf("Cannot get dtb_addr,check flow !\n");
|
||||
goto failed;
|
||||
}
|
||||
addr = env_get_hex("dtb_addr",0);
|
||||
sprintf(runcmd, "fdt addr 0x%lx", env_get_hex("dtb_addr",0));
|
||||
ret = run_command(runcmd, 0);
|
||||
if(ret != CMD_RET_SUCCESS)
|
||||
goto failed;
|
||||
sprintf(runcmd, "fdt resize");
|
||||
ret = run_command(runcmd, 0);
|
||||
if(ret != CMD_RET_SUCCESS)
|
||||
goto failed;
|
||||
|
||||
/*set unneed devices node disabled for hibernate resume in kernel dtb*/
|
||||
blob = (void *)addr;
|
||||
ret = fdt_status_disabled_by_alias(blob,"i2c0");
|
||||
ON_RET_ERROR("i2c0");
|
||||
ret = fdt_status_disabled_by_alias(blob,"i2c1");
|
||||
ON_RET_ERROR("i2c1");
|
||||
ret = fdt_status_disabled_by_alias(blob,"i2c2");
|
||||
ON_RET_ERROR("i2c2");
|
||||
|
||||
ret = fdt_status_disabled_by_alias_alt(blob,"audio_i2c0","i2c5");
|
||||
ON_RET_ERROR("audio_i2c0 or i2c5");
|
||||
ret = fdt_status_disabled_by_alias_alt(blob,"audio_i2c1","i2c6");
|
||||
ON_RET_ERROR("audio_i2c1 or i2c6");
|
||||
ret = fdt_status_disabled_by_alias(blob,"ethernet0");
|
||||
ON_RET_ERROR("ethernet0");
|
||||
ret = fdt_status_disabled_by_alias(blob,"ethernet1");
|
||||
ON_RET_ERROR("ethernet1");
|
||||
ret = fdt_status_disabled_by_alias(blob,"spi0");
|
||||
ON_RET_ERROR("spi0");
|
||||
ret = fdt_status_disabled_by_alias(blob,"spi1");
|
||||
ON_RET_ERROR("spi1");
|
||||
ret = fdt_status_disabled_by_alias(blob,"spi2");
|
||||
ON_RET_ERROR("spi2");
|
||||
|
||||
ret = fdt_disabled_node(blob,"/soc/adc");
|
||||
ON_RET_ERROR("/soc/adc");
|
||||
|
||||
//default mask is 0, need set this node disbaled
|
||||
if(0 == (mask & 0x01)) {
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/light_i2s","/soc/ap-i2s");
|
||||
ON_RET_ERROR("/soc/light_i2s or /soc/ap-i2s");
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/audio_i2s0","/soc/audio-i2s0");
|
||||
ON_RET_ERROR("/soc/audio_i2s0 or /soc/audio-i2s0");
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/audio_i2s1","/soc/audio-i2s1");
|
||||
ON_RET_ERROR("/soc/audio_i2s1 or /soc/audio-i2s1");
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/audio_i2s2","/soc/audio-i2s2");
|
||||
ON_RET_ERROR("/soc/audio_i2s2 or /soc/audio-i2s2");
|
||||
}
|
||||
if(0 == (mask & 0x02)) {
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/audio_i2s_8ch_sd0","/soc/i2s-8ch-sd0");
|
||||
ON_RET_ERROR("/soc/audio_i2s_8ch_sd0 or /soc/i2s-8ch-sd0");
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/audio_i2s_8ch_sd1","/soc/i2s-8ch-sd1");
|
||||
ON_RET_ERROR("/soc/audio_i2s_8ch_sd1 or /soc/i2s-8ch-sd1");
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/audio_i2s_8ch_sd2","/soc/i2s-8ch-sd2");
|
||||
ON_RET_ERROR("/soc/audio_i2s_8ch_sd2 or /soc/i2s-8ch-sd2");
|
||||
ret = fdt_disabled_node_alt(blob,"/soc/audio_i2s_8ch_sd3","/soc/i2s-8ch-sd3");
|
||||
ON_RET_ERROR("/soc/audio_i2s_8ch_sd3 or /soc/i2s-8ch-sd3");
|
||||
}
|
||||
/*set resume_bootargs for kernel do fast bootup */
|
||||
sprintf(runcmd,"resume=/dev/mmcblk0p%d notrace noftrace nopty noclkdebug ",resume_part);
|
||||
env_set("resume_bootargs",runcmd);
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
|
||||
default_set:
|
||||
sprintf(runcmd,"resume=/dev/mmcblk0p%d",resume_part);
|
||||
env_set("resume_bootargs",runcmd);
|
||||
return CMD_RET_SUCCESS;
|
||||
|
||||
failed:
|
||||
printf("ERROR:runcmd %s failed!\n",runcmd);
|
||||
sprintf(runcmd,"resume=/dev/mmcblk0p%d",resume_part);
|
||||
env_set("resume_bootargs",runcmd);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
chk_hibernate, 6, 0, do_board_check_hibernate,
|
||||
"check hibernate image sign,if valid set dtb nodes and bootargs for fast boot resume",
|
||||
" [<interface> <dev[:part]>] [mask]"
|
||||
);
|
||||
|
||||
#ifdef CONFIG_FIXUP_MEMORY_REGION
|
||||
static int do_fixup_memory_region(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||
char * const argv[])
|
||||
{
|
||||
ulong addr;
|
||||
void *blob = NULL;
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
u64 base, size;
|
||||
|
||||
base = gd->ram_base;
|
||||
size = gd->ram_size;
|
||||
|
||||
/*get dtb address*/
|
||||
if(env_get("dtb_addr") == NULL)
|
||||
{
|
||||
printf("Cannot get dtb_addr,check flow !\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
addr = env_get_hex("dtb_addr",0);
|
||||
|
||||
/*set unneed devices node disabled for hibernate resume in kernel dtb*/
|
||||
blob = (void *)addr;
|
||||
fdtdec_setup_mem_size_base_fdt(blob);
|
||||
size -= gd->ram_base;
|
||||
|
||||
if (size != gd->ram_size) {
|
||||
printf("fixup memory region from [0x%09lx ~ 0x%09lx] to [0x%09lx ~ 0x%09lx]\n",
|
||||
gd->ram_base, gd->ram_base+gd->ram_size, gd->ram_base, gd->ram_base+size);
|
||||
gd->ram_size = size;
|
||||
fdt_fixup_memory(blob, gd->ram_base, gd->ram_size);
|
||||
}
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
U_BOOT_CMD(
|
||||
fixup_memory_region, 2, 0, do_fixup_memory_region,
|
||||
"modify linux memory region via gd->ram_size",
|
||||
""
|
||||
);
|
||||
#endif
|
||||
|
||||
@@ -136,7 +136,7 @@ static const struct regulator_t g_apcpu_regu_id_list[] = {
|
||||
REGU_ID_DEF(IIC_IDX_AONIIC,APCPU_REGU_VDDM,0x31,0x39,0,1,800000,600000,3500000,12500,1),
|
||||
},
|
||||
};
|
||||
#elif defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_A_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF) || (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A)
|
||||
#elif defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_A_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF) || (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A) || defined(CONFIG_TARGET_LIGHT_FM_C910_RVBOOK)
|
||||
/**
|
||||
* board for ant-ref
|
||||
*
|
||||
@@ -165,6 +165,7 @@ static const struct regulator_t g_apcpu_regu_id_list[] = {
|
||||
}
|
||||
};
|
||||
#else
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B)
|
||||
/**
|
||||
* board for EB064A10/EB064A11
|
||||
*
|
||||
@@ -183,6 +184,7 @@ static const struct regulator_t g_regu_id_list[] = {
|
||||
REGU_ID_DEF(IIC_IDX_AONIIC,DDR_VDD_REGU_1V1,0x5A,0xA7,0,1,CONFIG_DDR_REGU_1V1,800000,1500000,20000,0),
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
static const struct regulator_t g_apcpu_regu_id_list[] = {
|
||||
{
|
||||
@@ -236,7 +238,7 @@ static int wait_iic_receive(dw_iic_regs_t *iic_base, uint32_t wait_data_num, uin
|
||||
}
|
||||
|
||||
|
||||
unsigned long soc_get_iic_freq(uint32_t idx)
|
||||
static unsigned long soc_get_iic_freq(uint32_t idx)
|
||||
{
|
||||
if (idx == IIC_IDX_AONIIC){
|
||||
return 49152000U;
|
||||
@@ -651,6 +653,7 @@ int32_t csi_iic_mem_receive_sr(csi_iic_t *iic, uint32_t devaddr, uint16_t memadd
|
||||
return read_count;
|
||||
}
|
||||
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_A) ||defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B)
|
||||
static int pmic_read_reg_sr(csi_iic_t *iic_handle,uint16_t dev_addr,uint32_t offset, uint32_t *val)
|
||||
{
|
||||
int32_t num;
|
||||
@@ -662,6 +665,7 @@ static int pmic_read_reg_sr(csi_iic_t *iic_handle,uint16_t dev_addr,uint32_t off
|
||||
*val = temp[0];
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int pmic_write_reg(csi_iic_t *iic_handle,uint16_t dev_addr,uint32_t offset, uint32_t val)
|
||||
{
|
||||
@@ -688,6 +692,7 @@ static int pmic_write_reg(csi_iic_t *iic_handle,uint16_t dev_addr,uint32_t offse
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if !defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_A) && !defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B)
|
||||
static int pmic_read_reg(csi_iic_t *iic_handle,uint16_t dev_addr,uint32_t offset, uint32_t *val)
|
||||
{
|
||||
int32_t num;
|
||||
@@ -716,6 +721,7 @@ static int pmic_read_reg(csi_iic_t *iic_handle,uint16_t dev_addr,uint32_t offset
|
||||
*val = temp[0];
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int _pmic_ddr_regu_init(uint32_t idx)
|
||||
{
|
||||
@@ -788,7 +794,7 @@ static void light_iopmp_config(void)
|
||||
}
|
||||
}
|
||||
|
||||
int pmic_ddr_regu_init(void)
|
||||
int aon_local_init(void)
|
||||
{
|
||||
#define AON_PADMUX_BASE (0xfffff4a000)
|
||||
int ret;
|
||||
@@ -818,13 +824,14 @@ int pmic_ddr_regu_init(void)
|
||||
int pmic_ddr_set_voltage(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#if 0 //currently,no need to modify ddr regulator voltage
|
||||
uint32_t val = 0;
|
||||
uint32_t regu_num = ARRAY_SIZE(g_regu_id_list);
|
||||
uint32_t i;
|
||||
struct regulator_t *pregu;
|
||||
csi_iic_t *dev_handle;
|
||||
|
||||
#if 0 //currently,no need to modify ddr regulator voltage
|
||||
pregu = (struct regulator_t*)g_regu_id_list;
|
||||
for (i = 0; i < regu_num; i++, pregu++) {
|
||||
if (pregu->regu_vol_target < pregu->regu_vol_min || pregu->regu_vol_target > pregu->regu_vol_max)
|
||||
@@ -838,6 +845,10 @@ int pmic_ddr_set_voltage(void)
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B)
|
||||
uint32_t val = 0;
|
||||
struct regulator_t *pregu;
|
||||
csi_iic_t *dev_handle;
|
||||
|
||||
/*enable lcd0_en ldo*/
|
||||
pregu = (struct regulator_t*)&g_regu_id_list[LCD0_EN];
|
||||
dev_handle = pmic_get_iic_handle(pregu->iic_id);
|
||||
@@ -944,7 +955,7 @@ int pmic_reset_apcpu_voltage(void)
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
#elif defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_A_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF)|| (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A)
|
||||
#elif defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_A_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF)|| (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A) || defined(CONFIG_TARGET_LIGHT_FM_C910_RVBOOK)
|
||||
int pmic_reset_apcpu_voltage(void)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
#define __DDR_REGU_H__
|
||||
|
||||
int pmic_ddr_set_voltage(void);
|
||||
int pmic_ddr_regu_init(void);
|
||||
int aon_local_init(void);
|
||||
#endif
|
||||
|
||||
218
board/thead/light-c910/lpddr4/include/aonsys_reg_define.h
Normal file
218
board/thead/light-c910/lpddr4/include/aonsys_reg_define.h
Normal file
@@ -0,0 +1,218 @@
|
||||
//------------------------------------------------------------
|
||||
// DONOT MODIFY THIS FILE
|
||||
// generated by JISHENGJU automatically
|
||||
//------------------------------------------------------------
|
||||
|
||||
#ifndef AONSYS_SYSREG_REG_OFFSET_DEFINE_H
|
||||
#define AONSYS_SYSREG_REG_OFFSET_DEFINE_H
|
||||
|
||||
#define AONSYS_REG_BASE 0xFFFFF48000
|
||||
|
||||
#define REG_AON_CPU_LP_MODE (AONSYS_REG_BASE + 0x0 )
|
||||
#define REG_AON_CHIP_LP_MODE (AONSYS_REG_BASE + 0x4 )
|
||||
#define REG_AON_AO_SERAM_TRN (AONSYS_REG_BASE + 0x10 )
|
||||
#define REG_AON_AO_SERAM_INT (AONSYS_REG_BASE + 0x14 )
|
||||
#define REG_AON_STR_SERAM_TRN (AONSYS_REG_BASE + 0x18 )
|
||||
#define REG_AON_STR_SERAM_INT (AONSYS_REG_BASE + 0x1c )
|
||||
#define REG_AON_STR_INDICATOR_0 (AONSYS_REG_BASE + 0x20 )
|
||||
#define REG_AON_STR_INDICATOR_1 (AONSYS_REG_BASE + 0x24 )
|
||||
#define REG_AON_STR_INDICATOR_2 (AONSYS_REG_BASE + 0x28 )
|
||||
#define REG_AON_STR_INDICATOR_3 (AONSYS_REG_BASE + 0x2c )
|
||||
#define REG_AON_PVTC_WR_LOCK (AONSYS_REG_BASE + 0x30 )
|
||||
#define REG_AON_PVTC_TS_ALARM (AONSYS_REG_BASE + 0x34 )
|
||||
#define REG_AON_PVTC_VM_ALARM (AONSYS_REG_BASE + 0x38 )
|
||||
#define REG_AON_PVTC_PD_ALARM (AONSYS_REG_BASE + 0x3c )
|
||||
#define REG_AON_E902_CNT_CLR (AONSYS_REG_BASE + 0x40 )
|
||||
#define REG_AON_E902_RST_ADDR (AONSYS_REG_BASE + 0x44 )
|
||||
#define REG_AON_C906_RST_ADDR_L (AONSYS_REG_BASE + 0x48 )
|
||||
#define REG_AON_C906_RST_ADDR_H (AONSYS_REG_BASE + 0x4c )
|
||||
#define REG_AON_RESERVED_REG_0 (AONSYS_REG_BASE + 0x50 )
|
||||
#define REG_AON_RESERVED_REG_1 (AONSYS_REG_BASE + 0x54 )
|
||||
#define REG_AON_RESERVED_REG_2 (AONSYS_REG_BASE + 0x58 )
|
||||
#define REG_AON_RESERVED_REG_3 (AONSYS_REG_BASE + 0x5c )
|
||||
#define REG_AON_AON_AHB_ADEXT (AONSYS_REG_BASE + 0x60 )
|
||||
#define REG_AON_RC_EN (AONSYS_REG_BASE + 0x70 )
|
||||
#define REG_AON_RC_FCAL (AONSYS_REG_BASE + 0x74 )
|
||||
#define REG_AON_RC_MODE (AONSYS_REG_BASE + 0x78 )
|
||||
#define REG_AON_RC_READY (AONSYS_REG_BASE + 0x7c )
|
||||
#define REG_AON_ISO_CFG (AONSYS_REG_BASE + 0x80 )
|
||||
#define REG_AON_OCRAM_ERR (AONSYS_REG_BASE + 0x90 )
|
||||
#define REG_AON_TIMER_LINK (AONSYS_REG_BASE + 0x100)
|
||||
#define REG_AON_PD_REQ (AONSYS_REG_BASE + 0x110)
|
||||
#define REG_AON_PD_ISO_EN_SET (AONSYS_REG_BASE + 0x114)
|
||||
#define REG_AON_PD_ISO_EN_CLR (AONSYS_REG_BASE + 0x118)
|
||||
#define REG_AON_PD_SW_EN_SET (AONSYS_REG_BASE + 0x11c)
|
||||
#define REG_AON_PD_SW_EN_CLR (AONSYS_REG_BASE + 0x120)
|
||||
#define REG_AON_PD_SW_ACK (AONSYS_REG_BASE + 0x124)
|
||||
#define REG_AON_PD_SW_CNT_EN (AONSYS_REG_BASE + 0x128)
|
||||
#define REG_AON_PD_FSM_RST (AONSYS_REG_BASE + 0x12c)
|
||||
#define REG_AON_PD_INT_MASK (AONSYS_REG_BASE + 0x130)
|
||||
#define REG_AON_PD_FSM_STS_L (AONSYS_REG_BASE + 0x134)
|
||||
#define REG_AON_PD_FSM_STS_H (AONSYS_REG_BASE + 0x138)
|
||||
#define REG_AON_PD_INT_STS (AONSYS_REG_BASE + 0x13c)
|
||||
#define REG_AON_PD_INT_CLR (AONSYS_REG_BASE + 0x140)
|
||||
#define REG_AON_PD_BLK0_SW_CNT (AONSYS_REG_BASE + 0x144)
|
||||
#define REG_AON_PD_BLK1_SW_CNT (AONSYS_REG_BASE + 0x148)
|
||||
#define REG_AON_PD_BLK2_SW_CNT (AONSYS_REG_BASE + 0x14c)
|
||||
#define REG_AON_PD_BLK3_SW_CNT (AONSYS_REG_BASE + 0x150)
|
||||
#define REG_AON_PD_BLK4_SW_CNT (AONSYS_REG_BASE + 0x154)
|
||||
#define REG_AON_PD_BLK5_SW_CNT (AONSYS_REG_BASE + 0x158)
|
||||
#define REG_AON_PD_BLK6_SW_CNT (AONSYS_REG_BASE + 0x15c)
|
||||
#define REG_AON_PD_BLK7_SW_CNT (AONSYS_REG_BASE + 0x160)
|
||||
#define REG_AON_PD_BLK8_SW_CNT (AONSYS_REG_BASE + 0x164)
|
||||
#define REG_AON_PD_BLK9_SW_CNT (AONSYS_REG_BASE + 0x168)
|
||||
#define REG_AON_PD_BLK10_SW_CNT (AONSYS_REG_BASE + 0x16c)
|
||||
#define REG_AON_PD_BLK0_INTV_CNT (AONSYS_REG_BASE + 0x180)
|
||||
#define REG_AON_PD_BLK1_INTV_CNT (AONSYS_REG_BASE + 0x184)
|
||||
#define REG_AON_PD_BLK2_INTV_CNT (AONSYS_REG_BASE + 0x188)
|
||||
#define REG_AON_PD_BLK3_INTV_CNT (AONSYS_REG_BASE + 0x18c)
|
||||
#define REG_AON_PD_BLK4_INTV_CNT (AONSYS_REG_BASE + 0x190)
|
||||
#define REG_AON_PD_BLK5_INTV_CNT (AONSYS_REG_BASE + 0x194)
|
||||
#define REG_AON_PD_BLK6_INTV_CNT (AONSYS_REG_BASE + 0x198)
|
||||
#define REG_AON_PD_BLK7_INTV_CNT (AONSYS_REG_BASE + 0x19c)
|
||||
#define REG_AON_PD_BLK8_INTV_CNT (AONSYS_REG_BASE + 0x1a0)
|
||||
#define REG_AON_PD_BLK9_INTV_CNT (AONSYS_REG_BASE + 0x1a4)
|
||||
#define REG_AON_PD_BLK10_INTV_CNT (AONSYS_REG_BASE + 0x1a8)
|
||||
#define REG_AON_AUDIO_PMU_REQ (AONSYS_REG_BASE + 0x1f8)
|
||||
#define REG_AON_AUDIO_PMU_STS (AONSYS_REG_BASE + 0x1fc)
|
||||
#define REG_AON_AUDIO_PMU_INTR (AONSYS_REG_BASE + 0x204)
|
||||
#define REG_AON_PMU_AUDIO_REQ (AONSYS_REG_BASE + 0x208)
|
||||
#define REG_AON_PMU_AUDIO_STS (AONSYS_REG_BASE + 0x20c)
|
||||
#define REG_AON_MEM_LP_MODE (AONSYS_REG_BASE + 0x210)
|
||||
#define REG_AON_C910_DBG_MASK (AONSYS_REG_BASE + 0x214)
|
||||
#define REG_AON_C910_L2CACHE (AONSYS_REG_BASE + 0x218)
|
||||
#define REG_AON_BISR_CTRL (AONSYS_REG_BASE + 0x220)
|
||||
#define REG_AON_EFUSE_PRELOAD_DONE (AONSYS_REG_BASE + 0x224)
|
||||
#define REG_AON_GPIO_RTE (AONSYS_REG_BASE + 0x228)
|
||||
#define REG_AON_PLL_DSKEW_LOCK (AONSYS_REG_BASE + 0x22c)
|
||||
#define REG_AON_SRAM_AXI_CFG (AONSYS_REG_BASE + 0x230)
|
||||
#define REG_AON_SRAM_AXI_ST (AONSYS_REG_BASE + 0x234)
|
||||
#define REG_AON_SRAM_AXI_ERR_STS_0 (AONSYS_REG_BASE + 0x238)
|
||||
#define REG_AON_SRAM_AXI_ERR_STS_1 (AONSYS_REG_BASE + 0x23c)
|
||||
#define REG_AON_SRAM_AXI_ERR_STS_2 (AONSYS_REG_BASE + 0x240)
|
||||
#define REG_AON_SRAM_AXI_ERR_STS_3 (AONSYS_REG_BASE + 0x244)
|
||||
#define REG_AON_SRAM_AXI_ERR_STS_4 (AONSYS_REG_BASE + 0x248)
|
||||
#define REG_AON_SE_MUX_LOCK (AONSYS_REG_BASE + 0x24c)
|
||||
#define REG_AON_CPU_DBG_DIS_LOCK (AONSYS_REG_BASE + 0x270)
|
||||
#define REG_AON_RESERVED_REG_4 (AONSYS_REG_BASE + 0x300)
|
||||
#define REG_AON_RESERVED_REG_5 (AONSYS_REG_BASE + 0x304)
|
||||
#define REG_AON_RESERVED_REG_6 (AONSYS_REG_BASE + 0x308)
|
||||
#define REG_AON_RESERVED_REG_7 (AONSYS_REG_BASE + 0x30c)
|
||||
#define REG_AON_RESERVED_REG_8 (AONSYS_REG_BASE + 0x400)
|
||||
#define REG_AON_RESERVED_REG_9 (AONSYS_REG_BASE + 0x404)
|
||||
#define REG_AON_RESERVED_REG_10 (AONSYS_REG_BASE + 0x408)
|
||||
#define REG_AON_RESERVED_REG_11 (AONSYS_REG_BASE + 0x40c)
|
||||
#define REG_AON_RESERVED_REG_12 (AONSYS_REG_BASE + 0x500)
|
||||
#define REG_AON_RESERVED_REG_13 (AONSYS_REG_BASE + 0x504)
|
||||
#define REG_AON_RESERVED_REG_14 (AONSYS_REG_BASE + 0x508)
|
||||
#define REG_AON_RESERVED_REG_15 (AONSYS_REG_BASE + 0x50c)
|
||||
#define REG_AON_RESERVED_REG_16 (AONSYS_REG_BASE + 0x600)
|
||||
#define REG_AON_RESERVED_REG_17 (AONSYS_REG_BASE + 0x604)
|
||||
#define REG_AON_RESERVED_REG_18 (AONSYS_REG_BASE + 0x608)
|
||||
#define REG_AON_RESERVED_REG_19 (AONSYS_REG_BASE + 0x60c)
|
||||
|
||||
#define CPU_LP_MODE_DFLT_VAL 0x3ff
|
||||
#define CHIP_LP_MODE_DFLT_VAL 0x0
|
||||
#define AO_SERAM_TRN_DFLT_VAL 0x0
|
||||
#define AO_SERAM_INT_DFLT_VAL 0x0
|
||||
#define STR_SERAM_TRN_DFLT_VAL 0x0
|
||||
#define STR_SERAM_INT_DFLT_VAL 0x0
|
||||
#define STR_INDICATOR_0_DFLT_VAL 0x0
|
||||
#define STR_INDICATOR_1_DFLT_VAL 0x0
|
||||
#define STR_INDICATOR_2_DFLT_VAL 0x0
|
||||
#define STR_INDICATOR_3_DFLT_VAL 0x0
|
||||
#define PVTC_WR_LOCK_DFLT_VAL 0x0
|
||||
#define PVTC_TS_ALARM_DFLT_VAL 0x0
|
||||
#define PVTC_VM_ALARM_DFLT_VAL 0x0
|
||||
#define PVTC_PD_ALARM_DFLT_VAL 0x0
|
||||
#define E902_CNT_CLR_DFLT_VAL 0x0
|
||||
#define E902_RST_ADDR_DFLT_VAL 0xffef8000
|
||||
#define C906_RST_ADDR_L_DFLT_VAL 0xc0000000
|
||||
#define C906_RST_ADDR_H_DFLT_VAL 0xff
|
||||
#define RESERVED_REG_0_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_1_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_2_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_3_DFLT_VAL 0x0
|
||||
#define AON_AHB_ADEXT_DFLT_VAL 0x0
|
||||
#define RC_EN_DFLT_VAL 0x1
|
||||
#define RC_FCAL_DFLT_VAL 0x77f
|
||||
#define RC_MODE_DFLT_VAL 0x1
|
||||
#define RC_READY_DFLT_VAL 0x0
|
||||
#define ISO_CFG_DFLT_VAL 0x0
|
||||
#define OCRAM_ERR_DFLT_VAL 0x0
|
||||
#define TIMER_LINK_DFLT_VAL 0x0
|
||||
#define PD_REQ_DFLT_VAL 0x0
|
||||
#define PD_ISO_EN_SET_DFLT_VAL 0x0
|
||||
#define PD_ISO_EN_CLR_DFLT_VAL 0x0
|
||||
#define PD_SW_EN_SET_DFLT_VAL 0x0
|
||||
#define PD_SW_EN_CLR_DFLT_VAL 0x0
|
||||
#define PD_SW_ACK_DFLT_VAL 0x3fffff
|
||||
#define PD_SW_CNT_EN_DFLT_VAL 0x0
|
||||
#define PD_FSM_RST_DFLT_VAL 0x0
|
||||
#define PD_INT_MASK_DFLT_VAL 0x3fffff
|
||||
#define PD_FSM_STS_L_DFLT_VAL 0x0
|
||||
#define PD_FSM_STS_H_DFLT_VAL 0x0
|
||||
#define PD_INT_STS_DFLT_VAL 0x0
|
||||
#define PD_INT_CLR_DFLT_VAL 0x0
|
||||
#define PD_BLK0_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK1_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK2_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK3_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK4_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK5_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK6_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK7_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK8_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK9_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK10_SW_CNT_DFLT_VAL 0xff00ff
|
||||
#define PD_BLK0_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK1_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK2_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK3_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK4_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK5_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK6_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK7_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK8_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK9_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define PD_BLK10_INTV_CNT_DFLT_VAL 0xff0ffff
|
||||
#define AUDIO_PMU_REQ_DFLT_VAL 0x0
|
||||
#define AUDIO_PMU_STS_DFLT_VAL 0x0
|
||||
#define AUDIO_PMU_INTR_DFLT_VAL 0x0
|
||||
#define PMU_AUDIO_REQ_DFLT_VAL 0x0
|
||||
#define PMU_AUDIO_STS_DFLT_VAL 0x0
|
||||
#define MEM_LP_MODE_DFLT_VAL 0x0
|
||||
#define C910_DBG_MASK_DFLT_VAL 0x0
|
||||
#define C910_L2CACHE_DFLT_VAL 0x0
|
||||
#define BISR_CTRL_DFLT_VAL 0x0
|
||||
#define EFUSE_PRELOAD_DONE_DFLT_VAL 0x0
|
||||
#define GPIO_RTE_DFLT_VAL 0x0
|
||||
#define PLL_DSKEW_LOCK_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_CFG_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_ST_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_ERR_STS_0_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_ERR_STS_1_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_ERR_STS_2_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_ERR_STS_3_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_ERR_STS_4_DFLT_VAL 0x0
|
||||
#define SE_MUX_LOCK_DFLT_VAL 0x0
|
||||
#define CPU_DBG_DIS_LOCK_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_4_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_5_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_6_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_7_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_8_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_9_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_10_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_11_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_12_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_13_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_14_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_15_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_16_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_17_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_18_DFLT_VAL 0x0
|
||||
#define RESERVED_REG_19_DFLT_VAL 0x0
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
//------------------------------------------------------------
|
||||
// DONOT MODIFY THIS FILE
|
||||
// generated by JISHENGJU automatically
|
||||
//------------------------------------------------------------
|
||||
|
||||
#ifndef AONSYS_RSTGEN_REG_OFFSET_DEFINE_H
|
||||
#define AONSYS_RSTGEN_REG_OFFSET_DEFINE_H
|
||||
|
||||
#define AONSYS_RSTGEN_REG_BASE 0xFFFFF44000
|
||||
|
||||
#define REG_AON_RST_CNT (AONSYS_RSTGEN_REG_BASE + 0x0 )
|
||||
#define REG_AON_SYS_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x10 )
|
||||
#define REG_AON_RTC_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x14 )
|
||||
#define REG_AON_AOGPIO_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x18 )
|
||||
#define REG_AON_AOI2C_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x1c )
|
||||
#define REG_AON_PVTC_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x20 )
|
||||
#define REG_AON_E902_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x24 )
|
||||
#define REG_AON_AOTIMER_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x28 )
|
||||
#define REG_AON_AOWDT_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x2c )
|
||||
#define REG_AON_APSYS_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x30 )
|
||||
#define REG_AON_NPUSYS_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x34 )
|
||||
#define REG_AON_DDRSYS_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x38 )
|
||||
#define REG_AON_AUDIO_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x3c )
|
||||
#define REG_AON_BISR_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x50 )
|
||||
#define REG_AON_DSP0_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x54 )
|
||||
#define REG_AON_DSP1_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x58 )
|
||||
#define REG_AON_GPU_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x5c )
|
||||
#define REG_AON_VDEC_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x60 )
|
||||
#define REG_AON_VENC_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x64 )
|
||||
#define REG_AON_ADC_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x70 )
|
||||
#define REG_AON_AUDGPIO_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x74 )
|
||||
#define REG_AON_AOUART_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x78 )
|
||||
#define REG_AON_RST_CLR_0 (AONSYS_RSTGEN_REG_BASE + 0x100 )
|
||||
#define REG_AON_RST_CLR_1 (AONSYS_RSTGEN_REG_BASE + 0x104 )
|
||||
#define REG_AON_RST_CLR_2 (AONSYS_RSTGEN_REG_BASE + 0x108 )
|
||||
#define REG_AON_RST_CLR_3 (AONSYS_RSTGEN_REG_BASE + 0x10c )
|
||||
#define REG_AON_RST_CLR_4 (AONSYS_RSTGEN_REG_BASE + 0x110 )
|
||||
#define REG_AON_RST_STS_0 (AONSYS_RSTGEN_REG_BASE + 0x120 )
|
||||
#define REG_AON_RST_STS_1 (AONSYS_RSTGEN_REG_BASE + 0x124 )
|
||||
#define REG_AON_RST_STS_2 (AONSYS_RSTGEN_REG_BASE + 0x128 )
|
||||
#define REG_AON_RST_STS_3 (AONSYS_RSTGEN_REG_BASE + 0x12c )
|
||||
#define REG_AON_RST_STS_4 (AONSYS_RSTGEN_REG_BASE + 0x130 )
|
||||
#define REG_AON_RST_REQ_EN_0 (AONSYS_RSTGEN_REG_BASE + 0x140 )
|
||||
#define REG_AON_RST_REQ_EN_1 (AONSYS_RSTGEN_REG_BASE + 0x144 )
|
||||
#define REG_AON_RST_REQ_EN_2 (AONSYS_RSTGEN_REG_BASE + 0x148 )
|
||||
#define REG_AON_RST_REQ_EN_3 (AONSYS_RSTGEN_REG_BASE + 0x14c )
|
||||
#define REG_AON_SRAM_AXI_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x11f4)
|
||||
#define REG_AON_SE_RST_CFG (AONSYS_RSTGEN_REG_BASE + 0x160 )
|
||||
|
||||
#define RST_CNT_DFLT_VAL 0xf0f
|
||||
#define SYS_RST_CFG_DFLT_VAL 0x0
|
||||
#define RTC_RST_CFG_DFLT_VAL 0x3
|
||||
#define AOGPIO_RST_CFG_DFLT_VAL 0x3
|
||||
#define AOI2C_RST_CFG_DFLT_VAL 0x1
|
||||
#define PVTC_RST_CFG_DFLT_VAL 0x1
|
||||
#define E902_RST_CFG_DFLT_VAL 0x2
|
||||
#define AOTIMER_RST_CFG_DFLT_VAL 0x3
|
||||
#define AOWDT_RST_CFG_DFLT_VAL 0x1
|
||||
#define APSYS_RST_CFG_DFLT_VAL 0x1
|
||||
#define NPUSYS_RST_CFG_DFLT_VAL 0x1
|
||||
#define DDRSYS_RST_CFG_DFLT_VAL 0x1
|
||||
#define AUDIO_RST_CFG_DFLT_VAL 0x0
|
||||
#define BISR_RST_CFG_DFLT_VAL 0x3
|
||||
#define DSP0_RST_CFG_DFLT_VAL 0x1
|
||||
#define DSP1_RST_CFG_DFLT_VAL 0x1
|
||||
#define GPU_RST_CFG_DFLT_VAL 0x1
|
||||
#define VDEC_RST_GEN_RST_CFG_DFLT_VAL 0x1
|
||||
#define VENC_RST_CFG_DFLT_VAL 0x1
|
||||
#define ADC_RST_CFG_DFLT_VAL 0x1
|
||||
#define AUDGPIO_RST_CFG_DFLT_VAL 0x3
|
||||
#define AOUART_RST_CFG_DFLT_VAL 0x3
|
||||
#define RST_CLR_0_DFLT_VAL 0x0
|
||||
#define RST_CLR_1_DFLT_VAL 0x0
|
||||
#define RST_CLR_2_DFLT_VAL 0x0
|
||||
#define RST_CLR_3_DFLT_VAL 0x0
|
||||
#define RST_CLR_4_DFLT_VAL 0x0
|
||||
#define RST_STS_0_DFLT_VAL 0x0
|
||||
#define RST_STS_1_DFLT_VAL 0x0
|
||||
#define RST_STS_2_DFLT_VAL 0x0
|
||||
#define RST_STS_3_DFLT_VAL 0x0
|
||||
#define RST_STS_4_DFLT_VAL 0x0
|
||||
#define RST_REQ_EN_0_DFLT_VAL 0x11100
|
||||
#define RST_REQ_EN_1_DFLT_VAL 0xbb000000
|
||||
#define RST_REQ_EN_2_DFLT_VAL 0x0
|
||||
#define RST_REQ_EN_3_DFLT_VAL 0x0
|
||||
#define SRAM_AXI_RST_CFG_DFLT_VAL 0x5f
|
||||
#define SE_RST_CFG_DFLT_VAL 0x1
|
||||
|
||||
|
||||
#endif
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "ddr_reg_define.h"
|
||||
#include "ddr_sysreg_registers_struct.h"
|
||||
#include "ddr_sysreg_registers.h"
|
||||
#include "aonsys_reg_define.h"
|
||||
#include "aonsys_rstget_reg_define.h"
|
||||
#include "define_ddr.h"
|
||||
#include "DWC_ddr_umctl2_c_struct.h"
|
||||
#include "DWC_ddr_umctl2_header.h"
|
||||
|
||||
@@ -15,6 +15,9 @@ enum DDR_BITWIDTH {
|
||||
|
||||
unsigned long get_ddr_density(void);
|
||||
enum DDR_TYPE get_ddr_type(void);
|
||||
int get_ddr_rank_number(void);
|
||||
int get_ddr_freq(void);
|
||||
enum DDR_BITWIDTH get_ddr_bitwidth(void);
|
||||
void ddr_sysreg_wr(unsigned long int addr,unsigned int wr_data);
|
||||
unsigned int ddr_sysreg_rd(unsigned long int addr);
|
||||
|
||||
@@ -48,5 +51,9 @@ void ctrl_init(int rank_num, int speed);
|
||||
void addrmap(int rank_num, enum DDR_BITWIDTH bits);
|
||||
void ctrl_en(enum DDR_BITWIDTH bits);
|
||||
void enable_auto_refresh(void);
|
||||
|
||||
void lpddr4_auto_selref(void);
|
||||
int lpddr4_query_boundary(enum DDR_TYPE type, int rank_num, int speed,
|
||||
enum DDR_BITWIDTH bits, unsigned long size);
|
||||
int lpddr4_reinit_ctrl(enum DDR_TYPE type, int rank_num, int speed,
|
||||
enum DDR_BITWIDTH bits, unsigned long size);
|
||||
#endif // DDR_COMMON_FUNCE_H
|
||||
|
||||
38
board/thead/light-c910/lpddr4/include/ddr_retention.h
Normal file
38
board/thead/light-c910/lpddr4/include/ddr_retention.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef DDR_RETENTION_H
|
||||
#define DDR_RETENTION_H
|
||||
|
||||
///data structure to store ddr misc register address, value
|
||||
typedef struct Reg_Misc_Addr_Val {
|
||||
uint32_t Address; ///< register address
|
||||
uint32_t Value; ///< register value
|
||||
} Reg_Misc_Addr_Val_t;
|
||||
|
||||
///data structure to store register address, value pairs
|
||||
typedef struct Reg_Phy_Addr_Val {
|
||||
uint32_t Address; ///< register address
|
||||
uint16_t Value0; ///< register value phy0
|
||||
uint16_t Value1; ///< register value phy1
|
||||
} Reg_Phy_Addr_Val_t;
|
||||
|
||||
/// enumeration of instructions for PhyInit Register Interface
|
||||
typedef enum {
|
||||
saveRegs, ///< save(read) tracked register values
|
||||
restoreRegs, ///< restore (write) saved register values
|
||||
} regInstr;
|
||||
|
||||
// typedef struct Reg_Addr_Value {
|
||||
// uint32_t reg_num;
|
||||
// Reg_Addr_Val_t reg[0];
|
||||
// } Reg_Addr_Value_t;
|
||||
|
||||
typedef struct Ddr_Reg_Config {
|
||||
uint32_t misc_reg_num;
|
||||
uint32_t phy_reg_num;
|
||||
uint8_t ddr_rank;
|
||||
uint8_t reserve[55];
|
||||
} Ddr_Reg_Config_t;
|
||||
|
||||
int dwc_ddrphy_phyinit_regInterface(regInstr myRegInstr);
|
||||
void dwc_ddr_misc_regu_save(void);
|
||||
|
||||
#endif
|
||||
@@ -2,9 +2,14 @@
|
||||
#include <linux/sizes.h>
|
||||
#include "../include/common_lib.h"
|
||||
#include "../include/ddr_common_func.h"
|
||||
#include "../include/ddr_retention.h"
|
||||
|
||||
DDR_SYSREG_REG_SW_REG_S ddr_sysreg;
|
||||
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
#define DDR_DEBUG(x) printf(x)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_DDR_RANK_SIZE
|
||||
#define CONFIG_DDR_RANK_SIZE SZ_4G
|
||||
#endif
|
||||
@@ -14,6 +19,9 @@ unsigned long get_ddr_density() {
|
||||
#ifdef CONFIG_DDR_DUAL_RANK
|
||||
mul = 2;
|
||||
#endif
|
||||
#ifdef CONFIG_DDR_DDP
|
||||
mul *= 2;
|
||||
#endif
|
||||
#ifdef CONFIG_DDR_H32_MODE
|
||||
div = 2;
|
||||
#endif
|
||||
@@ -31,6 +39,44 @@ enum DDR_TYPE get_ddr_type() {
|
||||
#endif // #ifdef CONFIG_LPDDR4X
|
||||
}
|
||||
|
||||
int get_ddr_rank_number() {
|
||||
#ifdef CONFIG_DDR_SINGLE_RANK
|
||||
return 1;
|
||||
#elif defined CONFIG_DDR_DUAL_RANK
|
||||
return 2;
|
||||
#else
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
DDR_DEBUG("unsupported ddr rank type!!!\n");
|
||||
#endif
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
int get_ddr_freq() {
|
||||
#ifdef CONFIG_DDR_4266
|
||||
return 4266;
|
||||
#elif CONFIG_DDR_3733
|
||||
return 3733;
|
||||
#elif CONFIG_DDR_3200
|
||||
return 3200;
|
||||
#elif CONFIG_DDR_2133
|
||||
return 2133;
|
||||
#else
|
||||
printf("unsupport lpddr4 freq!!!\n");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
enum DDR_BITWIDTH get_ddr_bitwidth() {
|
||||
#ifdef CONFIG_DDR_H32_MODE
|
||||
return DDR_BITWIDTH_32;
|
||||
#elif CONFIG_DDR_H16_MODE
|
||||
return DDR_BITWIDTH_16;
|
||||
#else
|
||||
return DDR_BITWIDTH_64;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ddr_sysreg_wr(unsigned long int addr,unsigned int wr_data) {
|
||||
wr(addr+DDR_SYSREG_BADDR,wr_data);
|
||||
}
|
||||
@@ -101,75 +147,114 @@ unsigned int ddr_phy_reg_rd(unsigned long int addr) {
|
||||
|
||||
void lp4_mrw(int addr, int wdata,int dch,int rank) {
|
||||
DWC_DDR_UMCTL2_C_STRUCT_REG_S umctl2_reg;
|
||||
uint32_t val_t0,val_t1;
|
||||
if(dch==0) {
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 0;//write
|
||||
wr(MRCTRL0,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
while ((rd(MRSTAT) & 0x1) == 0x1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 0;//write
|
||||
wr(MRCTRL0, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = (addr<<8) | (wdata&0xFF);
|
||||
wr(MRCTRL1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = (addr << 8) | (wdata & 0xFF);
|
||||
wr(MRCTRL1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = (addr << 8) | (wdata & 0xFF);
|
||||
wr(MRCTRL1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
//udelay(10);
|
||||
//delay 5us
|
||||
val_t0=rd(0xFFF4D004);
|
||||
val_t1=rd(0xFFF4D004);
|
||||
while((val_t0-val_t1)<200){val_t1=rd(0xFFF4D004);};
|
||||
|
||||
while ((rd(MRSTAT) & 0x1) == 0x1);
|
||||
}
|
||||
else {
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 0;//write
|
||||
wr(MRCTRL0_DCH1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
while ((rd(MRSTAT_DCH1) & 0x1) == 0x1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 0;//write
|
||||
wr(MRCTRL0_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = (addr<<8) | (wdata&0xFF);
|
||||
wr(MRCTRL1_DCH1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0_DCH1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
}
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = (addr << 8) | (wdata & 0xFF);
|
||||
wr(MRCTRL1_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = (addr << 8) | (wdata & 0xFF);
|
||||
wr(MRCTRL1_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
//udelay(10);
|
||||
//delay 5us
|
||||
val_t0=rd(0xFFF4D004);
|
||||
val_t1=rd(0xFFF4D004);
|
||||
while((val_t0-val_t1)<200){val_t1=rd(0xFFF4D004);};
|
||||
while ((rd(MRSTAT_DCH1) & 0x1) == 0x1);
|
||||
}
|
||||
}
|
||||
|
||||
int lp4_mrr(int addr,int dch,int rank) {
|
||||
DWC_DDR_UMCTL2_C_STRUCT_REG_S umctl2_reg;
|
||||
if(dch==0) {
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 1;//read
|
||||
wr(MRCTRL0,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 1;//read
|
||||
wr(MRCTRL0, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = addr<<8;
|
||||
wr(MRCTRL1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = addr << 8;
|
||||
wr(MRCTRL1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1);
|
||||
return (umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data & 0xFF);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = addr << 8;
|
||||
wr(MRCTRL1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
udelay(20);
|
||||
while ((rd(MRSTAT) & 0x1) == 0x1);
|
||||
return ddr_sysreg_rd(MRR_STS_CH0);
|
||||
}
|
||||
else {
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 1;//read
|
||||
wr(MRCTRL0_DCH1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
//umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_addr = addr; //do not care for lp4
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_rank = rank;//rank0 only
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_type = 1;//read
|
||||
wr(MRCTRL0_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = addr<<8;
|
||||
wr(MRCTRL1_DCH1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0_DCH1,umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = addr << 8;
|
||||
wr(MRCTRL1_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1_DCH1);
|
||||
return (umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data & 0xFF);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32 = rd(MRCTRL1_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.mr_data = addr << 8;
|
||||
wr(MRCTRL1_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl1.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32 = rd(MRCTRL0_DCH1);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.mr_wr = 1;//trigger wr/rd
|
||||
wr(MRCTRL0_DCH1, umctl2_reg.dwc_ddr_umctl2_c_struct_mrctrl0.u32);
|
||||
|
||||
udelay(20);
|
||||
while ((rd(MRSTAT_DCH1) & 0x1) == 0x1);
|
||||
return ddr_sysreg_rd(MRR_STS_CH1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,15 +318,15 @@ unsigned int ddr_phy_reg_rd(unsigned long int addr) {
|
||||
if(port & 0x4) wr(PCTRL_2,0);
|
||||
if(port & 0x8) wr(PCTRL_3,0);
|
||||
if(port & 0x10) wr(PCTRL_4,0);
|
||||
if(port & 0x1F) { //at least one port is not disabled
|
||||
wr(DBG1,0);
|
||||
wr(DBG1_DCH1,0);
|
||||
while (rd(PSTAT) != 0x0);
|
||||
if ((port & 0x1F) == 0x1F) { //all ports are disabled
|
||||
wr(DBG1, 2);
|
||||
wr(DBG1_DCH1, 2);
|
||||
}
|
||||
else { //all ports are disabled
|
||||
wr(DBG1,3);
|
||||
wr(DBG1_DCH1,3);
|
||||
else { //at least one port is not disabled
|
||||
wr(DBG1, 0);
|
||||
wr(DBG1_DCH1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void enable_axi_port(int port) {
|
||||
@@ -454,7 +539,7 @@ if(bits==64) {
|
||||
wr(DFITMG0,0x05a3820e);//[28:24] dft_t_ctrl_delay [22:16] dfi_t_rddate_en=RL-5
|
||||
#endif
|
||||
wr(DFITMG1,0x000c0303);
|
||||
wr(DFILPCFG0,0x0351a001);
|
||||
wr(DFILPCFG0,0x0351a101); //[8]=1: enable dfi lp mode during selfref
|
||||
//wr(DFIUPD0,0x00400018); //[31:30]=0 use ctrlupd enable
|
||||
//wr(DFIUPD1,0x00b700c4);
|
||||
//wr(DFIUPD2,0x00000000);//[31]=0 disable phy ctrlupdate
|
||||
@@ -554,7 +639,7 @@ if(bits==64) {
|
||||
wr(DFITMG0,0x059f820c);//[28:24] dfi_t_ctrl_delay
|
||||
#endif
|
||||
wr(DFITMG1,0x000c0303);//dfi_t_wrdata_delay=tctrl+6+BL/2+trainedTdqsdly=24, may need take care cmd pipe
|
||||
wr(DFILPCFG0,0x0351a001);
|
||||
wr(DFILPCFG0,0x0351a101); //[8]=1: enable dfi lp mode during selfref
|
||||
//wr(DFIUPD0,0xc0400018);
|
||||
//wr(DFIUPD1,0x00b700c4);
|
||||
//wr(DFIUPD2,0x80000000);
|
||||
@@ -642,7 +727,7 @@ if(bits==64) {
|
||||
wr(DFITMG0,0x059b820a); //[22:16] dfi_t_rddate_en=RL-5
|
||||
#endif
|
||||
wr(DFITMG1,0x000b0303);
|
||||
wr(DFILPCFG0,0x0351a001);
|
||||
wr(DFILPCFG0,0x0351a101); //[8]=1: enable dfi lp mode during selfref
|
||||
//wr(DFIUPD0,0xc0400018);
|
||||
//wr(DFIUPD1,0x00b700c4);
|
||||
//wr(DFIUPD2,0x80000000);
|
||||
@@ -727,7 +812,7 @@ if(bits==64) {
|
||||
wr(ZQCTL2,0x00000000);
|
||||
wr(DFITMG0,0x048f8206);
|
||||
wr(DFITMG1,0x000b0303);
|
||||
wr(DFILPCFG0,0x0351a001);
|
||||
wr(DFILPCFG0,0x0351a101); //[8]=1: enable dfi lp mode during selfref
|
||||
//wr(DFIUPD0,0xc0400018);
|
||||
//wr(DFIUPD1,0x00b700c4);
|
||||
//wr(DFIUPD2,0x80000000);
|
||||
@@ -853,17 +938,28 @@ if(bits==64) {
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
printf("DDR 32bit mode\n");
|
||||
#endif
|
||||
wr(ADDRMAP0,0x001f001f); //
|
||||
if(rank_num==2) {
|
||||
wr(ADDRMAP0,0x001f0017);//4GB
|
||||
#ifdef CONFIG_DDR_DDP
|
||||
wr(ADDRMAP0,0x001f0018);//max 8GB
|
||||
#else
|
||||
wr(ADDRMAP0,0x001f0017); //4GB
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
wr(ADDRMAP0,0x001f001f); //cs_bit0: NULL
|
||||
}
|
||||
wr(ADDRMAP1,0x00080808); //bank +2
|
||||
wr(ADDRMAP2,0x00000000); //col b5+5 ~ col b2 +2
|
||||
wr(ADDRMAP3,0x00000000); //col b9 ~ col b6
|
||||
wr(ADDRMAP4,0x00001f1f); //col b11~ col b10
|
||||
wr(ADDRMAP5,0x070f0707); //row_b11 row b2_10 row b1 row b0 +6
|
||||
wr(ADDRMAP6,0x07070707); //max row 15
|
||||
wr(ADDRMAP7,0x00000f0f);
|
||||
wr(ADDRMAP6,0x07070707); //row 15
|
||||
wr(ADDRMAP7,0x00000f0f); //row16: NULL
|
||||
#ifdef CONFIG_DDR_DDP
|
||||
if(rank_num==2) {
|
||||
wr(ADDRMAP7,0x00000f07); //max row16
|
||||
}
|
||||
#endif
|
||||
wr(ADDRMAP9,0x07070707);
|
||||
wr(ADDRMAP10,0x07070707);
|
||||
wr(ADDRMAP11,0x00000007);
|
||||
@@ -871,17 +967,25 @@ if(bits==64) {
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
printf("DDR 64bit mode, 256B interleaving\n");
|
||||
#endif
|
||||
wr(ADDRMAP0,0x0004001f); // +2
|
||||
wr(ADDRMAP0,0x0004001f); //cs_bit0: NULL
|
||||
if(rank_num==2) {
|
||||
wr(ADDRMAP0,0x00040018);//8GB
|
||||
#ifdef CONFIG_DDR_DDP
|
||||
wr(ADDRMAP0,0x00040019);//max 16GB
|
||||
#else
|
||||
wr(ADDRMAP0,0x00040018);//8GB
|
||||
#endif
|
||||
}
|
||||
wr(ADDRMAP1,0x00090909); //bank +2
|
||||
wr(ADDRMAP2,0x00000000); //col b5+5 ~ col b2 +2
|
||||
wr(ADDRMAP3,0x01010101); //col b9 ~ col b6
|
||||
wr(ADDRMAP4,0x00001f1f); //col b11~ col b10
|
||||
wr(ADDRMAP5,0x080f0808); //row_b11 row b2_10 row b1 row b0 +6
|
||||
wr(ADDRMAP6,0x08080808);
|
||||
wr(ADDRMAP7,0x00000f0f);
|
||||
wr(ADDRMAP6,0x08080808); //row15
|
||||
#ifdef CONFIG_DDR_DDP
|
||||
wr(ADDRMAP7,0x00000f08); //row16
|
||||
#else
|
||||
wr(ADDRMAP7,0x00000f0f); //row16: NULL
|
||||
#endif
|
||||
wr(ADDRMAP9,0x08080808);
|
||||
wr(ADDRMAP10,0x08080808);
|
||||
wr(ADDRMAP11,0x00000008);
|
||||
@@ -890,6 +994,156 @@ if(bits==64) {
|
||||
}
|
||||
}
|
||||
|
||||
#define MEMSIZE_MIN_MB (1*1024)
|
||||
#define MEMSIZE_MAX_MB (16*1024)
|
||||
#define UNIT_MB (1024*1024)
|
||||
int lpddr4_query_boundary(enum DDR_TYPE type, int rank_num, int speed,
|
||||
enum DDR_BITWIDTH bits, unsigned long size)
|
||||
{
|
||||
if ((size < (unsigned long)MEMSIZE_MIN_MB*UNIT_MB) ||
|
||||
(size > (unsigned long)MEMSIZE_MAX_MB*UNIT_MB))
|
||||
goto err_ret;
|
||||
|
||||
if (bits == DDR_BITWIDTH_32) {// only phy0
|
||||
if (rank_num == 2) {
|
||||
if (size == 0x80000000) //2GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x100000000) //4GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x200000000) //8GB
|
||||
goto ret_ok;
|
||||
else
|
||||
goto err_ret;
|
||||
}
|
||||
else { // single rank
|
||||
if (size == 0x40000000) //1GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x80000000) //2GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x100000000) //4GB
|
||||
goto ret_ok;
|
||||
else
|
||||
goto err_ret;
|
||||
}
|
||||
}
|
||||
else if (bits == DDR_BITWIDTH_64) { // phy0+phy1
|
||||
if (rank_num == 2) {
|
||||
if (size == 0x100000000) //4GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x200000000) //8GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x400000000) //16GB
|
||||
goto ret_ok;
|
||||
else
|
||||
goto err_ret;
|
||||
}
|
||||
else { // single rank
|
||||
if (size == 0x80000000) //2GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x100000000) //4GB
|
||||
goto ret_ok;
|
||||
else if (size == 0x200000000) //8GB
|
||||
goto ret_ok;
|
||||
else
|
||||
goto err_ret;
|
||||
}
|
||||
}
|
||||
else {
|
||||
goto err_ret;
|
||||
}
|
||||
|
||||
ret_ok:
|
||||
return 0;
|
||||
|
||||
err_ret:
|
||||
return -1;
|
||||
}
|
||||
|
||||
int adjust_ddr_addrmap(enum DDR_TYPE type, int rank_num, int speed,
|
||||
enum DDR_BITWIDTH bits, unsigned long size)
|
||||
{
|
||||
if (lpddr4_query_boundary(type, rank_num, speed, bits, size) < 0)
|
||||
goto err_ret;
|
||||
|
||||
if (bits == DDR_BITWIDTH_32) {// only phy0
|
||||
if (rank_num == 2) {
|
||||
if (size == 0x80000000) {//2GB
|
||||
wr(ADDRMAP0,0x001f0016); // cs_bit0: HIF[28]
|
||||
wr(ADDRMAP6,0x0f070707); // row15: NULL
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x100000000) {//4GB
|
||||
wr(ADDRMAP0,0x001f0017); // cs_bit0: HIF[29]
|
||||
wr(ADDRMAP6,0x07070707); // row15: HIF[28]
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x200000000) {//8GB
|
||||
wr(ADDRMAP0,0x001f0018); // cs_bit0: HIF[30]
|
||||
wr(ADDRMAP6,0x07070707); // row15: HIF[28]
|
||||
wr(ADDRMAP7,0x00000f07); // row16: HIF[29]
|
||||
}
|
||||
}
|
||||
else { // single rank
|
||||
wr(ADDRMAP0,0x001f001f); // cs_bit0: NULL
|
||||
if (size == 0x40000000) {//1GB
|
||||
wr(ADDRMAP6,0x0f070707); // row15: NULL
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x80000000) {//2GB
|
||||
wr(ADDRMAP6,0x07070707); // row15: HIF[28]
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x100000000) {//4GB
|
||||
wr(ADDRMAP6,0x07070707); // row15: HIF[28]
|
||||
wr(ADDRMAP7,0x00000f07); // row16: HIF[29]
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (bits == DDR_BITWIDTH_64) { // phy0+phy1
|
||||
if (rank_num == 2) {
|
||||
if (size == 0x100000000) {//4GB
|
||||
wr(ADDRMAP0,0x00040017); // cs_bit0: HIF[29]
|
||||
wr(ADDRMAP6,0x0f080808); // row15: NULL
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x200000000) {//8GB
|
||||
wr(ADDRMAP0,0x00040018); // cs_bit0: HIF[30]
|
||||
wr(ADDRMAP6,0x08080808); // row15: HIF[29]
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x400000000) {//16GB
|
||||
wr(ADDRMAP0,0x00040019); // cs_bit0: HIF[31]
|
||||
wr(ADDRMAP6,0x08080808); // row15: HIF[29]
|
||||
wr(ADDRMAP7,0x00000f08); // row16: HIF[30]
|
||||
}
|
||||
}
|
||||
else { // single rank
|
||||
wr(ADDRMAP0,0x0004001f); // cs_bit0: NULL
|
||||
if (size == 0x80000000) {//2GB
|
||||
wr(ADDRMAP6,0x0f080808); // row15: NULL
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x100000000) {//4GB
|
||||
wr(ADDRMAP6,0x08080808); // row15: HIF[29]
|
||||
wr(ADDRMAP7,0x00000f0f); // row16: NULL
|
||||
}
|
||||
else if (size == 0x200000000) {//8GB
|
||||
wr(ADDRMAP6,0x08080808); // row15: HIF[29]
|
||||
wr(ADDRMAP7,0x00000f08); // row16: HIF[30]
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// nothing
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_ret:
|
||||
printf("unsupport memsize %ld\n", size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void quasi_reg_write(unsigned long int reg,int wdata) {
|
||||
DWC_DDR_UMCTL2_C_STRUCT_REG_S umctl2_reg;
|
||||
|
||||
@@ -1004,11 +1258,11 @@ void lpddr4_enter_selfrefresh(int pwdn_en,int dis_dram_clk,int mode) {
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_stat.u32 = rd(STAT_DCH1);
|
||||
if(pwdn_en) {
|
||||
while( umctl2_reg.dwc_ddr_umctl2_c_struct_stat.selfref_state != 2) //wait sdram enter selfrefresh-powerdown state
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_stat.u32 = rd(STAT);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_stat.u32 = rd(STAT_DCH1);
|
||||
}
|
||||
else {
|
||||
while( umctl2_reg.dwc_ddr_umctl2_c_struct_stat.selfref_state != 1) //wait sdram enter selfrefresh state
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_stat.u32 = rd(STAT);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_stat.u32 = rd(STAT_DCH1);
|
||||
}
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
printf("[lpddr4_enter_selfrefresh]: CH1 STAT is :%x after enter selfrefresh state\n",umctl2_reg.dwc_ddr_umctl2_c_struct_stat.u32);
|
||||
@@ -1044,7 +1298,8 @@ void lpddr4_auto_ps_en(int pwdn_en,int selfref_en,int clock_auto_disable ) {
|
||||
//ddr_sysreg_wr(DDR_CFG0,0x1ff0);
|
||||
//ddr_sysreg_wr(DDR_CFG0,0x1ff0);
|
||||
ddr_sysreg.ddr_sysreg_registers_struct_ddr_cfg0.u32 = ddr_sysreg_rd(DDR_CFG0);
|
||||
ddr_sysreg.ddr_sysreg_registers_struct_ddr_cfg0.rg_ctl_ddr_usw_rst_reg |= 0x1F2;
|
||||
//ddr_sysreg.ddr_sysreg_registers_struct_ddr_cfg0.rg_ctl_ddr_usw_rst_reg |= 0x1F2;
|
||||
ddr_sysreg.ddr_sysreg_registers_struct_ddr_cfg0.rg_ctl_ddr_usw_rst_reg |= 0x1FA;
|
||||
ddr_sysreg_wr(DDR_CFG0,ddr_sysreg.ddr_sysreg_registers_struct_ddr_cfg0.u32);
|
||||
}
|
||||
|
||||
@@ -1064,7 +1319,7 @@ void dfi_freq_change(int dfi_freq,int skip_dram_init) {
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
printf("[dfi_freq_change]: start dfi_freq_change, target dfi_freq is %x \n",dfi_freq);
|
||||
#endif
|
||||
wr(DBG1,3);
|
||||
//wr(DBG1,3);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.u32 = rd(SWCTL);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.sw_done = 0;
|
||||
wr(SWCTL,umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.u32);
|
||||
@@ -1075,7 +1330,6 @@ void dfi_freq_change(int dfi_freq,int skip_dram_init) {
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.u32 = rd(DFIMISC);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.dfi_frequency = dfi_freq;
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.dfi_init_start = 0x1;
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.dfi_init_complete_en = 0;
|
||||
wr(DFIMISC,umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.u32);
|
||||
|
||||
@@ -1086,15 +1340,28 @@ void dfi_freq_change(int dfi_freq,int skip_dram_init) {
|
||||
while( umctl2_reg.dwc_ddr_umctl2_c_struct_swstat.sw_done_ack == 0)
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.u32 = rd(SWSTAT);
|
||||
|
||||
wr(SWCTL,0x0);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.u32 = rd(DFIMISC);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.dfi_init_start = 0x1;
|
||||
wr(DFIMISC,umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.u32);
|
||||
wr(SWCTL,0x1);
|
||||
while(rd(SWSTAT)!=0x00000001);
|
||||
rdata = rd(DFISTAT);
|
||||
while ((rdata & 0x1) != 0) //wait dfi_init_complete = 0
|
||||
rdata = rd(DFISTAT);
|
||||
|
||||
#ifndef CONFIG_DDR_H32_MODE
|
||||
rdata = rd(DCH1_DFISTAT);
|
||||
while((rdata & 0x1) != 0) //wait dfi_init_complete = 0
|
||||
rdata = rd(DFISTAT);
|
||||
rdata = rd(DCH1_DFISTAT);
|
||||
#endif
|
||||
|
||||
//change dfi clk freq here
|
||||
//pull down dfi_init_start
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.u32 = rd(SWCTL);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.sw_done = 0;
|
||||
wr(SWCTL,umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.u32);
|
||||
|
||||
wr(SWCTL, umctl2_reg.dwc_ddr_umctl2_c_struct_swctl.u32);
|
||||
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.u32 = rd(DFIMISC);
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.dfi_init_start = 0;
|
||||
wr(DFIMISC,umctl2_reg.dwc_ddr_umctl2_c_struct_dfimisc.u32);
|
||||
@@ -1108,9 +1375,17 @@ void dfi_freq_change(int dfi_freq,int skip_dram_init) {
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfistat.u32 = rd(DFISTAT);
|
||||
while(umctl2_reg.dwc_ddr_umctl2_c_struct_dfistat.dfi_init_complete == 0)
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfistat.u32 = rd(DFISTAT);
|
||||
wr(DBG1,0);
|
||||
|
||||
//wait dfi_init_complete = 1
|
||||
#ifndef CONFIG_DDR_H32_MODE
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfistat.u32 = rd(DCH1_DFISTAT);
|
||||
while(umctl2_reg.dwc_ddr_umctl2_c_struct_dfistat.dfi_init_complete == 0)
|
||||
umctl2_reg.dwc_ddr_umctl2_c_struct_dfistat.u32 = rd(DCH1_DFISTAT);
|
||||
#endif
|
||||
|
||||
//wr(DBG1,0);
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
printf("[dfi_freq_change]: dfi_freq_change, end \n",dfi_freq);
|
||||
printf("[dfi_freq_change]: dfi_freq_change, end \n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1121,7 +1396,7 @@ void ddr_soc_pll_disable () {
|
||||
printf("DDR SOC PLL PowerDown \n");
|
||||
#endif
|
||||
}
|
||||
void lpddr4_auto_selref()
|
||||
void lpddr4_auto_selref(void)
|
||||
{
|
||||
ddr_sysreg_wr(DDR_CFG1,0xa0000); //remove core clock after xx
|
||||
wr(SWCTL,0);
|
||||
@@ -1135,3 +1410,168 @@ void lpddr4_auto_selref()
|
||||
wr(PWRCTL,0x0000000b); //[3] dfi_dram_clk_disable [1] powerdown_en [0]serref_en
|
||||
wr(DCH1_PWRCTL,0x0000000b);
|
||||
}
|
||||
|
||||
void ctrl_en_lp3_exit(enum DDR_BITWIDTH bits) {
|
||||
//skip DRAM init, because this has done
|
||||
wr(SWCTL,0x00000000);
|
||||
wr(INIT0,0xc0020002);
|
||||
wr(SWCTL,0x00000001);
|
||||
while(rd(SWSTAT)!=0x00000001);
|
||||
|
||||
//dfi frequency change proto ,to PS0
|
||||
wr(SWCTL,0x00000000);
|
||||
wr(DFIMISC,0x00000000);// [5]dfi_freq=0x0
|
||||
wr(SWCTL,0x00000001);
|
||||
while(rd(SWSTAT)!=0x00000001);
|
||||
|
||||
wr(SWCTL,0x00000000);
|
||||
wr(DFIMISC,0x00000020);// [5]dfi_init_start=0x1
|
||||
wr(SWCTL,0x00000001);
|
||||
while(rd(SWSTAT)!=0x00000001);
|
||||
|
||||
|
||||
while(rd(DFISTAT)!=0x00000001); //polling dfi_init_complete
|
||||
if(bits==64) {
|
||||
while(rd(DCH1_DFISTAT)!=0x00000001);
|
||||
}
|
||||
wr(SWCTL,0x00000000);
|
||||
wr(DFIMISC,0x00000000);
|
||||
wr(SWCTL,0x00000001);
|
||||
while(rd(SWSTAT)!=0x00000001);
|
||||
|
||||
|
||||
wr(SWCTL,0x00000000);
|
||||
wr(DFIMISC,0x00000001);
|
||||
wr(SWCTL,0x00000001);
|
||||
while(rd(SWSTAT)!=0x00000001);
|
||||
|
||||
//for low power,
|
||||
wr(SWCTL,0x00000000);
|
||||
wr(PWRCTL,0x0000000a); //[3] dfi_dram_clk_disable [1] powerdown_en
|
||||
wr(DCH1_PWRCTL,0x0000000a);
|
||||
wr(SWCTL,0x00000001);
|
||||
while (rd(SWSTAT) != 0x00000001);
|
||||
//detect until umctrl into normal state
|
||||
while (rd(STAT) != 0x00000001);
|
||||
if(bits==64) {
|
||||
while(rd(DCH1_STAT) != 0x00000001);
|
||||
}
|
||||
|
||||
//en phy master proto
|
||||
wr(DFIPHYMSTR,0x14000001);
|
||||
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
DDR_DEBUG("DFIPHYMSTR is %0x \n", rd(DFIPHYMSTR));
|
||||
DDR_DEBUG("DFIUPD0 is %0x \n", rd(DFIUPD0));
|
||||
DDR_DEBUG("DFIUPD1 is %0x \n", rd(DFIUPD1));
|
||||
DDR_DEBUG("ZQCTL0 is %0x \n", rd(ZQCTL0));
|
||||
DDR_DEBUG("ADDRMAP0 is %0x \n", rd(ADDRMAP0));
|
||||
DDR_DEBUG("ADDRMAP1 is %0x \n", rd(ADDRMAP1));
|
||||
#endif
|
||||
}
|
||||
|
||||
int lpddr4_reinit_ctrl(enum DDR_TYPE type, int rank_num, int speed,
|
||||
enum DDR_BITWIDTH bits, unsigned long size)
|
||||
{
|
||||
int ret;
|
||||
unsigned int rdata;
|
||||
|
||||
//a.
|
||||
ddr_sysreg_wr(DDR_CFG1, 0xa000011f); //remove core clock after xx
|
||||
wr(PWRCTL, 0x00000000); //[3] dfi_dram_clk_disable [1] powerdown_en [0]serref_en
|
||||
wr(DCH1_PWRCTL, 0x00000000);
|
||||
|
||||
// use phy value stored in spl
|
||||
//dwc_ddrphy_phyinit_regInterface(saveRegs);
|
||||
|
||||
//b.dis axi port
|
||||
disable_axi_port(0x1f);
|
||||
while (rd(PSTAT) != 0x0);
|
||||
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
DDR_DEBUG("Axi prot idle\n");
|
||||
#endif
|
||||
wr(DFIPHYMSTR, 0x14000000);
|
||||
//check status.
|
||||
while ((rd(STAT) & 0x3) == 0x03);
|
||||
|
||||
#ifndef CONFIG_DDR_H32_MODE
|
||||
while ((rd(STAT_DCH1) & 0x3) == 0x03);
|
||||
#endif
|
||||
//c.poll cam empty flag
|
||||
while ((rd(DBGCAM) & 0x36000000) != 0x36000000);
|
||||
//d.save phy regs
|
||||
//e.SRE
|
||||
lpddr4_enter_selfrefresh(1, 0, 0);
|
||||
//f.LP3 enter
|
||||
dfi_freq_change(0x1f, 0x3);
|
||||
//g.PwrOk disassert
|
||||
rdata = ddr_sysreg_rd(DDR_CFG0);
|
||||
rdata &= ~(0x1 << 6);
|
||||
ddr_sysreg_wr(DDR_CFG0, rdata); //Pwrokin dessert
|
||||
|
||||
//p.phy reset
|
||||
rdata = ddr_sysreg_rd(DDR_CFG0);
|
||||
rdata &= ~(0x1 << 7);
|
||||
rdata &= 0x0;
|
||||
ddr_sysreg_wr(DDR_CFG0, rdata); //Phy reset .DDR_CFG0 ALL reset
|
||||
|
||||
//r.ddr core reset
|
||||
rdata = ddr_sysreg_rd(DDR_CFG0);
|
||||
rdata &= ~(0x1 << 5);
|
||||
ddr_sysreg_wr(DDR_CFG0, rdata); //ctrl sw reset
|
||||
|
||||
//s.pwr ok assert
|
||||
rdata = ddr_sysreg_rd(DDR_CFG0);
|
||||
rdata |= (0x1 << 6);
|
||||
ddr_sysreg_wr(DDR_CFG0, rdata); //Pwrokin dessert
|
||||
|
||||
//t.ctrl init
|
||||
//dwc_umctl_init_skip_traing(type, rank_num, speed, bits);
|
||||
ddr_sysreg_wr(DDR_CFG0, 0x50); // release apb presetn
|
||||
ddr_sysreg_wr(DDR_CFG0, 0x50);
|
||||
ddr_sysreg_wr(DDR_CFG0, 0x50);
|
||||
if (bits == 32) {
|
||||
ddr_sysreg_wr(DDR_CFG0, 0x52);
|
||||
}
|
||||
ctrl_init(rank_num, speed);
|
||||
addrmap(rank_num, bits);
|
||||
ret = adjust_ddr_addrmap(type, rank_num, speed, bits, size);
|
||||
|
||||
// msic regu restore for str
|
||||
dwc_ddr_misc_regu_save();
|
||||
|
||||
de_assert_other_reset_ddr(); //after this step, only PwrOk is staill low
|
||||
|
||||
dq_pinmux(bits);
|
||||
|
||||
//u.phy restor
|
||||
dwc_ddrphy_phyinit_regInterface(restoreRegs);
|
||||
|
||||
//v.ctrl en ,hs
|
||||
ctrl_en_lp3_exit(bits);
|
||||
|
||||
//w.SRE
|
||||
lpddr4_selfrefresh_exit(0);
|
||||
|
||||
//y.en auto refresh
|
||||
enable_auto_refresh();
|
||||
|
||||
//x.en axi port
|
||||
enable_axi_port(0x1f);
|
||||
wr(DFIPHYMSTR, 0x14000001);
|
||||
lpddr4_auto_selref();
|
||||
|
||||
if(rd(PSTAT))
|
||||
{
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
DDR_DEBUG("***** DDR busy in LP3 Mode *****\n");
|
||||
#endif
|
||||
}else{
|
||||
#ifdef CONFIG_DDR_MSG
|
||||
DDR_DEBUG("***** AXI port idle *****\n");
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
1080
board/thead/light-c910/lpddr4/src/ddr_retention.c
Normal file
1080
board/thead/light-c910/lpddr4/src/ddr_retention.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
#include "../include/common_lib.h"
|
||||
#include "../include/pinmux.h"
|
||||
#include "../include/ddr_common_func.h"
|
||||
#include "../include/ddr_retention.h"
|
||||
#include "../include/lpddr4_init.h"
|
||||
|
||||
extern void lp4_phy_train1d2d(enum DDR_TYPE type, int speed, enum DDR_BITWIDTH bits);
|
||||
@@ -26,11 +27,34 @@ void lpddr4_init(enum DDR_TYPE type, int rank_num, int speed, enum DDR_BITWIDTH
|
||||
|
||||
lp4_phy_train1d2d(type, speed, bits);
|
||||
|
||||
dwc_ddrphy_phyinit_regInterface(saveRegs);
|
||||
|
||||
ctrl_en(bits);
|
||||
|
||||
enable_axi_port(0x1f);
|
||||
|
||||
|
||||
enable_auto_refresh();
|
||||
|
||||
lpddr4_auto_selref();
|
||||
}
|
||||
|
||||
int fixup_ddr_addrmap(unsigned long size)
|
||||
{
|
||||
enum DDR_TYPE type = get_ddr_type();
|
||||
int rank_num = get_ddr_rank_number();
|
||||
int speed = get_ddr_freq();
|
||||
enum DDR_BITWIDTH bits = get_ddr_bitwidth();
|
||||
|
||||
return lpddr4_reinit_ctrl(type, rank_num, speed, bits, size);
|
||||
}
|
||||
|
||||
int query_ddr_boundary(unsigned long size)
|
||||
{
|
||||
enum DDR_TYPE type = get_ddr_type();
|
||||
int rank_num = get_ddr_rank_number();
|
||||
int speed = get_ddr_freq();
|
||||
enum DDR_BITWIDTH bits = get_ddr_bitwidth();
|
||||
|
||||
return lpddr4_query_boundary(type, rank_num, speed, bits, size);
|
||||
}
|
||||
|
||||
|
||||
446
board/thead/light-c910/sbmeta/sbmeta.c
Normal file
446
board/thead/light-c910/sbmeta/sbmeta.c
Normal file
@@ -0,0 +1,446 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2021 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#include "sbmeta.h"
|
||||
#include "sec_crypto_sha.h"
|
||||
|
||||
#define LOGLEVEL_ERROR 1
|
||||
#define LOGLEVEL_INFO 2
|
||||
#define LOGLEVEL_DEBUG 3
|
||||
#define SBMETA_LOGLEVEL 1
|
||||
#define trace_printer(level, fmt,...) printf("%s"fmt, level, ##__VA_ARGS__)
|
||||
#if (SBMETA_LOGLEVEL < 1)
|
||||
#define EMSG(...)
|
||||
#else
|
||||
#define EMSG(fmt, args...) trace_printer("error: ", fmt, ##args)
|
||||
#endif
|
||||
|
||||
#if (SBMETA_LOGLEVEL < 2)
|
||||
#define IMSG(...)
|
||||
#else
|
||||
#define IMSG(fmt, args...) trace_printer("info: ", fmt, ##args)
|
||||
#endif
|
||||
|
||||
#if (SBMETA_LOGLEVEL < 3)
|
||||
#define DMSG(...)
|
||||
#else
|
||||
#define DMSG(fmt, args...) trace_printer("", fmt, ##args)
|
||||
#endif
|
||||
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_LPI4A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_RVBOOK)
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_UPGRADE)
|
||||
/* digest_size corresponding to digest_scheme specified in sbmeta_info_t */
|
||||
static const int digest_size[] = {0, 20, 16, 28, 32, 48, 64, 32};
|
||||
static const char* image_name_s[] = {
|
||||
"dtb", "kernel", "tf", "aon", "rootfs", "tee", "uboot", "user"
|
||||
};
|
||||
/* index to get sc_sha_mode_t value */
|
||||
static const int sha_idx2ctl[] = {0, 1, 8, 3, 2, 5, 4, 9};
|
||||
|
||||
static const unsigned long image_addrs[] = {
|
||||
LIGHT_DTB_ADDR,
|
||||
LIGHT_KERNEL_ADDR,
|
||||
LIGHT_TF_FW_TMP_ADDR,
|
||||
LIGHT_AON_FW_ADDR,
|
||||
LIGHT_ROOTFS_ADDR,
|
||||
LIGHT_TEE_FW_ADDR,
|
||||
CONFIG_SYS_TEXT_BASE,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int magiccode;
|
||||
uint8_t dev;
|
||||
uint8_t part;
|
||||
uint8_t image_type;
|
||||
uint8_t digest_scheme;
|
||||
uint8_t sign_scheme;
|
||||
uint8_t isencrypted;
|
||||
uint8_t medium_type;
|
||||
uint8_t checksum_scheme;
|
||||
char filename[MAX_NAME_SIZE];
|
||||
uint8_t digest[MAX_DIGEST_SIZE];
|
||||
uint32_t relocated_addr;
|
||||
uint8_t security_level;
|
||||
uint8_t reserved[15];
|
||||
} sbmeta_info_t;
|
||||
|
||||
static int is_sbmeta_info(uint32_t entry_src_addr)
|
||||
{
|
||||
uint32_t *buffer = (uint32_t *)(uintptr_t)entry_src_addr;
|
||||
|
||||
/* sbmeta_info_t entry should start with magic code 'S''B''M''T' */
|
||||
if (*buffer != SBMETA_MAGIC) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dump_sbmeta_info(sbmeta_info_t *sbmeta_info)
|
||||
{
|
||||
if (sbmeta_info == NULL) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
/* only support emmc now */
|
||||
if (sbmeta_info->medium_type != 0) {
|
||||
EMSG("medium type %d is not supported now\r\n", sbmeta_info->medium_type);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
/* only support dtb, krlimg/tf, sbi, aon, rootfs, tee, uboot and user-defined type */
|
||||
if (sbmeta_info->image_type > IMAGE_TYPE_NUM || sbmeta_info->image_type < 0) {
|
||||
EMSG("image type is out of range\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
/* only support none, sha1, md5, sha224, sha256, sha384, sha512, sm3 and reserved scheme */
|
||||
if (sbmeta_info->digest_scheme > DIGEST_TYPE_NUM || sbmeta_info->digest_scheme < 0) {
|
||||
EMSG("digest type is out of range\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
/* only support none, rsa1024, rsa2048, ecc256, ecc160, sm2 and reserved scheme */
|
||||
if (sbmeta_info->sign_scheme > SIGN_TYPE_NUM || sbmeta_info->sign_scheme < 0) {
|
||||
EMSG("signature type is out of range\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
/* DTB, TF, TEE, Kernel will be loaded from default partitions specified in env */
|
||||
if (sbmeta_info->image_type != T_ROOTFS && sbmeta_info->image_type != T_USER) {
|
||||
IMSG("Image has been loaded\r\n");
|
||||
}
|
||||
|
||||
if (sbmeta_info->security_level > SBMETA_SECURITY_LEVEL_SIGN || sbmeta_info->security_level < SBMETA_SECURITY_LEVEL_NONE) {
|
||||
EMSG("security level is invalid\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
/* dump sbmeta_info_t */
|
||||
DMSG("image medium type: %d\n", sbmeta_info->medium_type);
|
||||
DMSG("image load part: mmc %d:%d\n", sbmeta_info->dev, sbmeta_info->part);
|
||||
DMSG("image type: %d \n", sbmeta_info->image_type);
|
||||
DMSG("image digest scheme: %d\n", sbmeta_info->digest_scheme);
|
||||
DMSG("image sign scheme: %d\n", sbmeta_info->sign_scheme);
|
||||
DMSG("image enable encryption: %s\n", sbmeta_info->isencrypted ? "en" : "dis");
|
||||
DMSG("image file name: %s\n", sbmeta_info->filename);
|
||||
DMSG("image digest:");
|
||||
for (int i = 0; i < digest_size[sbmeta_info->digest_scheme]; i++) {
|
||||
DMSG("%02X", sbmeta_info->digest[i]);
|
||||
}
|
||||
DMSG("\r\n");
|
||||
DMSG("\n\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sbmeta_field_verify(sbmeta_info_t *sbmeta_info, unsigned long img_src_addr)
|
||||
{
|
||||
uint8_t digest_scheme = 0;
|
||||
uint8_t sign_scheme = 0;
|
||||
uint8_t is_encrypted = 0;
|
||||
img_header_t *phead = NULL;
|
||||
|
||||
if (sbmeta_info == NULL) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if (sbmeta_info->security_level < SBMETA_SECURITY_LEVEL_SIGN) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if image has secure header, check with sbmeta field */
|
||||
if (image_have_head(img_src_addr)) {
|
||||
phead = (img_header_t *)img_src_addr;
|
||||
digest_scheme = phead->digest_scheme;
|
||||
sign_scheme = phead->signature_scheme;
|
||||
is_encrypted = (phead->option_flag & 0x2) >> 1;
|
||||
}
|
||||
|
||||
if (sbmeta_info->digest_scheme != digest_scheme) {
|
||||
EMSG("digest type %d is not expected: %d\r\n", digest_scheme, sbmeta_info->digest_scheme);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
/* only support none, rsa1024, rsa2048, ecc256, ecc160, sm2 and reserved scheme */
|
||||
if (sbmeta_info->sign_scheme != sign_scheme) {
|
||||
EMSG("signature type %d is not expected: %d\r\n", sign_scheme, sbmeta_info->sign_scheme);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if (sbmeta_info->isencrypted != is_encrypted) {
|
||||
EMSG("encryption %d is not expected: %d\r\n", is_encrypted, sbmeta_info->isencrypted);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_digest(uint8_t *buffer, uint32_t buffer_size, uint8_t digest_scheme, uint8_t *digest)
|
||||
{
|
||||
uint32_t len = 0;
|
||||
uint8_t sum[64];
|
||||
sc_sha_t sha;
|
||||
sc_sha_context_t ctx;
|
||||
int mode = 0;
|
||||
|
||||
if (!buffer || digest_scheme > DIGEST_TYPE_NUM) {
|
||||
EMSG("wrong parameter\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if (digest_scheme == 0) {
|
||||
return 0;
|
||||
}
|
||||
mode = sha_idx2ctl[digest_scheme];
|
||||
|
||||
if (sc_sha_init(&sha, 0) != 0) {
|
||||
EMSG("sha initialize failed\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if (sc_sha_start(&sha, &ctx, mode) != 0) {
|
||||
EMSG("sha start failed\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if (sc_sha_update(&sha, &ctx, buffer, buffer_size) != 0) {
|
||||
EMSG("sha update failed\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
if (sc_sha_finish(&sha, &ctx, sum, &len) != 0) {
|
||||
EMSG("sha finish failed\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
sc_sha_uninit(&sha);
|
||||
|
||||
/* check digest value */
|
||||
if (memcmp(digest, sum, len) != 0) {
|
||||
EMSG("check digest failed\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Verify image specified in sbmeta_info_t. The image has been loaded to memory before */
|
||||
static int sbmeta_verify_image(uint32_t image_load_addr, sbmeta_info_t *sbmeta_info)
|
||||
{
|
||||
uint32_t image_size = 0;
|
||||
const char *image_name;
|
||||
uint8_t image_type = sbmeta_info->image_type;
|
||||
uint8_t checksum_scheme = sbmeta_info->checksum_scheme;
|
||||
uint8_t *digest = sbmeta_info->digest;
|
||||
uint8_t is_encrypted = sbmeta_info->isencrypted;
|
||||
uint32_t security_level = sbmeta_info->security_level;
|
||||
uint32_t filesize = 0;
|
||||
char buf[64] = {0};
|
||||
|
||||
/* check image_type to avoid array index out of bounds */
|
||||
if (image_type > IMAGE_TYPE_NUM || image_type < 0) {
|
||||
EMSG("image type is out of range\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
image_name = image_name_s[image_type];
|
||||
|
||||
/* check tee/tf version if needed */
|
||||
#ifdef LIGHT_IMG_VERSION_CHECK_IN_BOOT
|
||||
if (image_have_head(image_load_addr) == 1) {
|
||||
if (image_type == T_TF) {
|
||||
IMSG("check TF version in boot \n");
|
||||
if (check_tf_version_in_boot(LIGHT_TF_FW_TMP_ADDR) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (image_type == T_TEE) {
|
||||
IMSG("check TEE version in boot \n");
|
||||
if (check_tee_version_in_boot(LIGHT_TEE_FW_ADDR) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* start verifying images */
|
||||
IMSG("Process %s image verification ...\n", image_name);
|
||||
if (security_level == SBMETA_SECURITY_LEVEL_SIGN || is_encrypted != 0) {
|
||||
if (verify_customer_image(image_type, image_load_addr) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
} else if (security_level == SBMETA_SECURITY_LEVEL_HASH) {
|
||||
if (memcmp(digest, buf, 64) == 0) {
|
||||
EMSG("sbmeta info doesn't specify digest value in security level 2\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "ext4size mmc %x:%x %s", sbmeta_info->dev, sbmeta_info->part, sbmeta_info->filename);
|
||||
if (run_command(buf, 0) != 0) {
|
||||
EMSG("get file size error\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
filesize = env_get_hex("filesize", 0);
|
||||
if (check_digest((uint8_t *)(uintptr_t)image_load_addr, filesize, checksum_scheme, digest) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* move image headers always */
|
||||
if (image_have_head(image_load_addr) == 1) {
|
||||
image_size = get_image_size(image_load_addr);
|
||||
IMSG("%s image size: %d\n", image_name, image_size);
|
||||
if (image_size < 0) {
|
||||
EMSG("GET %s image size error\n", image_name);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
if (image_type == T_TF) {
|
||||
memmove((void *)(uintptr_t)LIGHT_TF_FW_ADDR, (const void *)(uintptr_t)(image_load_addr + HEADER_SIZE), image_size);
|
||||
} else {
|
||||
memmove((void *)(uintptr_t)image_load_addr, (const void *)(uintptr_t)(image_load_addr + HEADER_SIZE), image_size);
|
||||
}
|
||||
} else {
|
||||
/* TF should be moved to LIGHT_TF_FW_ADDR all the cases*/
|
||||
if (image_type == T_TF) {
|
||||
/* while image_size is unknown, reload the image */
|
||||
run_command("ext4load mmc 0:3 0x0 trust_firmware.bin", 0);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int light_sbmetaboot(int argc, char *const argv[])
|
||||
{
|
||||
int count = 0;
|
||||
uint32_t sbmeta_size = 0;
|
||||
uint32_t info_addr = 0;
|
||||
uint32_t image_load_addr = 0;
|
||||
char cmd[64] = {0};
|
||||
sbmeta_info_t *sbmeta_info = NULL;
|
||||
|
||||
/* Load sbmeta image to memory */
|
||||
snprintf(cmd, sizeof(cmd), "ext4load mmc ${mmcdev}:${mmcsbmetapart} 0x%x %s", (void *)(uintptr_t)LIGHT_SBMETA_ADDR, SBMETA_FILENAME);
|
||||
printf("%s\n",cmd);
|
||||
if (run_command(cmd, 0) != 0) {
|
||||
/* if sbmeta doesn't exist, do secboot by default */
|
||||
IMSG("SBMETA doesn't exist, go to verify tf/tee\r\n");
|
||||
|
||||
/*
|
||||
* Verify tf and tee by command secboot.
|
||||
* Note that tf and tee has been loaded in "run bootcmd_load"
|
||||
*/
|
||||
if (run_command("secboot", 0) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* initialize crypto algorithm interfaces */
|
||||
if (csi_sec_init() != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
/* Check and verify sbmeta image */
|
||||
if (image_have_head(LIGHT_SBMETA_ADDR) == 1) {
|
||||
#ifdef LIGHT_IMG_VERSION_CHECK_IN_BOOT
|
||||
IMSG("check SBMETA version in boot \n");
|
||||
ret = check_sbmeta_version_in_boot(LIGHT_SBMETA_ADDR);
|
||||
if (ret != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
#endif
|
||||
IMSG("Process SBMETA image verification...\r\n");
|
||||
if (verify_customer_image(T_SBMETA, LIGHT_SBMETA_ADDR) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
sbmeta_size = get_image_size(LIGHT_SBMETA_ADDR);
|
||||
IMSG("sbmeta_size:%d\r\n", sbmeta_size);
|
||||
if (sbmeta_size != SBMETA_SIZE) {
|
||||
EMSG("SBMETA header is wrong! Size must equal to %d bytes!\r\n", SBMETA_SIZE);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
/* move image headers always */
|
||||
memmove((void *)LIGHT_SBMETA_ADDR, (const void *)(LIGHT_SBMETA_ADDR + HEADER_SIZE), sbmeta_size);
|
||||
} else {
|
||||
/* if sbmeta image is not secure, reset */
|
||||
IMSG("SBMETA image must be with signature\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
/* Parse sbmeta_info_t in image sbmeta, then load and verify specified images */
|
||||
info_addr = LIGHT_SBMETA_ADDR;
|
||||
for (count = 0; count < MAX_ENTRY_NUM; count++) {
|
||||
if (is_sbmeta_info(info_addr) == 0) {
|
||||
/* Dump and check sbmeta info */
|
||||
sbmeta_info = (sbmeta_info_t *)(uintptr_t)info_addr;
|
||||
if (dump_sbmeta_info(sbmeta_info) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
info_addr += ENTRY_SIZE;
|
||||
|
||||
/*
|
||||
* If image_type != T_USER, load to address specified in light-c910.h;
|
||||
* otherwise, load to user-specified address.
|
||||
*/
|
||||
if (sbmeta_info->image_type != T_USER) {
|
||||
image_load_addr = image_addrs[sbmeta_info->image_type];
|
||||
} else {
|
||||
image_load_addr = sbmeta_info->relocated_addr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load image specified in sbmeta info
|
||||
* Note: only load images don't exist in env "bootcmd_load"
|
||||
*/
|
||||
if (sbmeta_info->image_type == T_ROOTFS || sbmeta_info->image_type == T_USER) {
|
||||
snprintf(cmd, sizeof(cmd), "ext4load mmc %x:%x %p %s", sbmeta_info->dev,
|
||||
sbmeta_info->part, \
|
||||
(void *)(uintptr_t)image_load_addr, sbmeta_info->filename);
|
||||
if (run_command(cmd, 0) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (sbmeta_field_verify(sbmeta_info, image_load_addr) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
/* Check and verify user-specified image */
|
||||
if (sbmeta_verify_image(image_load_addr, sbmeta_info) != 0) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if sbmeta didn't specify images, reset */
|
||||
if (count == 0) {
|
||||
EMSG("SBMETA doesn't specify any images!\r\n");
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
/* Clear sbmeta buffer in memory */
|
||||
memset((void *)LIGHT_SBMETA_ADDR, 0, PLAIN_SBMETA_TEXT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_sbmetaboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||
{
|
||||
if (light_sbmetaboot(argc, argv) != 0) {
|
||||
EMSG("sbmetaboot failed\r\n");
|
||||
while (1);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
sbmetaboot, CONFIG_SYS_MAXARGS, 1, do_sbmetaboot,
|
||||
"load and verify image sbmeta, then verify image files specified in sbmeta",
|
||||
""
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
33
board/thead/light-c910/sbmeta/sbmeta.h
Normal file
33
board/thead/light-c910/sbmeta/sbmeta.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2021 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef _LIGHT_SBMETA_H
|
||||
#define _LIGHT_SBMETA_H
|
||||
|
||||
#include "common.h"
|
||||
#include "command.h"
|
||||
#include <asm/arch-thead/boot_mode.h>
|
||||
|
||||
#define MAX_NAME_SIZE 32
|
||||
#define MAX_DIGEST_SIZE 64
|
||||
#define SBMETA_MAGIC 0x544D4253 /* = {'S', 'B', 'M', 'T'} */
|
||||
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_LPI4A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_RVBOOK)
|
||||
#define LIGHT_SBMETA_ADDR 0x10000000
|
||||
#endif
|
||||
#define ENTRY_SIZE 128
|
||||
#define PLAIN_SBMETA_TEXT 4096
|
||||
#define SBMETA_SIZE 4736 /* 4K SMBETA image + 640 footer */
|
||||
#define MAX_ENTRY_NUM PLAIN_SBMETA_TEXT / ENTRY_SIZE /* 4K/128=32 */
|
||||
#define IMAGE_TYPE_NUM 7
|
||||
#define DIGEST_TYPE_NUM 8
|
||||
#define SIGN_TYPE_NUM 6
|
||||
#define SBMETA_FILENAME "sbmeta.bin"
|
||||
|
||||
#define SBMETA_SECURITY_LEVEL_SIGN 3 /* verify signature and hash */
|
||||
#define SBMETA_SECURITY_LEVEL_HASH 2 /* verify checksum */
|
||||
#define SBMETA_SECURITY_LEVEL_NONE 1 /* no verification */
|
||||
|
||||
#endif
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <asm/arch-thead/boot_mode.h>
|
||||
#include "../../../lib/sec_library/include/csi_sec_img_verify.h"
|
||||
|
||||
extern int csi_efuse_api_int(void);
|
||||
extern int csi_efuse_api_init(void);
|
||||
extern int csi_efuse_api_unint(void);
|
||||
extern int csi_efuse_read_raw(uint32_t addr, void *data, uint32_t cnt);
|
||||
extern int csi_efuse_write_raw(uint32_t addr, const void *data, uint32_t cnt);
|
||||
@@ -35,7 +35,7 @@ int csi_sec_init(void)
|
||||
char *version;
|
||||
|
||||
/* Initialize eFuse module */
|
||||
ret = csi_efuse_api_int();
|
||||
ret = csi_efuse_api_init();
|
||||
if (ret) {
|
||||
printf("efuse init faild[%d]\n", ret);
|
||||
goto exit;
|
||||
@@ -62,7 +62,7 @@ void designware_get_mac_from_fuse(unsigned char *mac)
|
||||
int ret;
|
||||
|
||||
/* Initialize eFuse module */
|
||||
ret = csi_efuse_api_int();
|
||||
ret = csi_efuse_api_init();
|
||||
if (ret) {
|
||||
printf("efuse init faild[%d]\n", ret);
|
||||
return;
|
||||
@@ -75,6 +75,89 @@ void designware_get_mac_from_fuse(unsigned char *mac)
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_LPI4A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_RVBOOK)
|
||||
/* Secure function for image verificaiton here */
|
||||
int get_image_version(unsigned long img_src_addr)
|
||||
{
|
||||
img_header_t *img = (img_header_t *)img_src_addr;
|
||||
uint8_t magiccode[4] = {0};
|
||||
|
||||
magiccode[3] = img->magic_num & 0xff;
|
||||
magiccode[2] = (img->magic_num & 0xff00) >> 8;
|
||||
magiccode[1] = (img->magic_num & 0xff0000) >> 16;
|
||||
magiccode[0] = (img->magic_num & 0xff000000) >> 24;
|
||||
if (memcmp(header_magic, magiccode, 4) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return img->image_version;
|
||||
}
|
||||
|
||||
int get_image_size(unsigned long img_src_addr)
|
||||
{
|
||||
img_header_t *img = (img_header_t *)img_src_addr;
|
||||
uint8_t magiccode[4] = {0};
|
||||
|
||||
magiccode[3] = img->magic_num & 0xff;
|
||||
magiccode[2] = (img->magic_num & 0xff00) >> 8;
|
||||
magiccode[1] = (img->magic_num & 0xff0000) >> 16;
|
||||
magiccode[0] = (img->magic_num & 0xff000000) >> 24;
|
||||
if (memcmp(header_magic, magiccode, 4) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return img->image_size;
|
||||
}
|
||||
|
||||
void dump_image_header_info(long addr)
|
||||
{
|
||||
img_header_t *phead = (img_header_t *)addr;
|
||||
|
||||
printf("\n---------------------------------------------\n");
|
||||
printf("entry point: 0x%x\n", phead->entry_point);
|
||||
printf("image size: %d Bytes\n", phead->image_size);
|
||||
printf("head version: 0x%x\n", phead->head_version);
|
||||
printf("image version: 0x%x\n", phead->image_version);
|
||||
printf("image checksum: 0x%x\n", phead->image_checksum);
|
||||
printf("image run addr: 0x%llx\n", phead->image_run_addr);
|
||||
printf("image offset: 0x%x\n", phead->image_offset);
|
||||
printf("image digest scheme: %d\n", phead->digest_scheme);
|
||||
printf("image sign scheme: %d\n", phead->signature_scheme);
|
||||
printf("image encrypt type: %d\n", phead->encrypt_type);
|
||||
printf("\n---------------------------------------------\n");
|
||||
}
|
||||
|
||||
int verify_customer_image(img_type_t type, long addr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Double check image number */
|
||||
if (image_have_head(addr) == 0) {
|
||||
printf("error: image has no secure header\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Dump image header information here */
|
||||
dump_image_header_info(addr);
|
||||
|
||||
/* Call customer image verification function */
|
||||
if ((type == T_TF) || (type == T_TEE) || (type == T_KRLIMG) || (type == T_DTB) || (type == T_SBMETA)) {
|
||||
ret = csi_sec_custom_image_verify(addr, UBOOT_STAGE_ADDR);
|
||||
if (ret) {
|
||||
printf("Image(%d) is verified fail, Please go to check!\n\n", type);
|
||||
return ret;
|
||||
}
|
||||
} else if (type == T_UBOOT) {
|
||||
ret = csi_sec_uboot_image_verify(addr, addr - PUBKEY_HEADER_SIZE);
|
||||
if (ret) {
|
||||
printf("Image(%s) is verified fail, Please go to check!\n\n", "uboot");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
static int strtou32(const char *str, unsigned int base, u32 *result)
|
||||
{
|
||||
char *ep;
|
||||
@@ -110,7 +193,7 @@ static int do_fuse(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
|
||||
int ret, i;
|
||||
|
||||
/* Initialize eFuse module */
|
||||
ret = csi_efuse_api_int();
|
||||
ret = csi_efuse_api_init();
|
||||
if (ret) {
|
||||
printf("efuse init faild[%d]\n", ret);
|
||||
goto err;
|
||||
@@ -180,88 +263,6 @@ err:
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF)
|
||||
/* Secure function for image verificaiton here */
|
||||
int get_image_version(unsigned long img_src_addr)
|
||||
{
|
||||
img_header_t *img = (img_header_t *)img_src_addr;
|
||||
uint8_t magiccode[4] = {0};
|
||||
|
||||
magiccode[3] = img->magic_num & 0xff;
|
||||
magiccode[2] = (img->magic_num & 0xff00) >> 8;
|
||||
magiccode[1] = (img->magic_num & 0xff0000) >> 16;
|
||||
magiccode[0] = (img->magic_num & 0xff000000) >> 24;
|
||||
if (memcmp(header_magic, magiccode, 4) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return img->image_version;
|
||||
}
|
||||
|
||||
int get_image_size(unsigned long img_src_addr)
|
||||
{
|
||||
img_header_t *img = (img_header_t *)img_src_addr;
|
||||
uint8_t magiccode[4] = {0};
|
||||
|
||||
magiccode[3] = img->magic_num & 0xff;
|
||||
magiccode[2] = (img->magic_num & 0xff00) >> 8;
|
||||
magiccode[1] = (img->magic_num & 0xff0000) >> 16;
|
||||
magiccode[0] = (img->magic_num & 0xff000000) >> 24;
|
||||
if (memcmp(header_magic, magiccode, 4) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return img->image_size;
|
||||
}
|
||||
|
||||
void dump_image_header_info(long addr)
|
||||
{
|
||||
img_header_t *phead = (img_header_t *)addr;
|
||||
|
||||
printf("\n---------------------------------------------\n");
|
||||
printf("entry point: 0x%x\n", phead->entry_point);
|
||||
printf("image size: %d Bytes\n", phead->image_size);
|
||||
printf("head version: 0x%x\n", phead->head_version);
|
||||
printf("image version: 0x%x\n", phead->image_version);
|
||||
printf("image checksum: 0x%x\n", phead->image_checksum);
|
||||
printf("image run addr: 0x%llx\n", phead->image_run_addr);
|
||||
printf("image offset: 0x%x\n", phead->image_offset);
|
||||
printf("image digest scheme: %d\n", phead->digest_scheme);
|
||||
printf("image sign scheme: %d\n", phead->signature_scheme);
|
||||
printf("image encrypt type: %d\n", phead->encrypt_type);
|
||||
printf("\n---------------------------------------------\n");
|
||||
}
|
||||
|
||||
int verify_customer_image(img_type_t type, long addr)
|
||||
{
|
||||
int ret;
|
||||
const char *image_name = "";
|
||||
|
||||
/* Double check image number */
|
||||
if (image_have_head(addr) == 0)
|
||||
return -1;
|
||||
|
||||
/* Dump image header information here */
|
||||
dump_image_header_info(addr);
|
||||
|
||||
/* Call customer image verification function */
|
||||
if ((type == T_TF) || (type == T_TEE) || (type == T_KRLIMG)) {
|
||||
ret = csi_sec_custom_image_verify(addr, UBOOT_STAGE_ADDR);
|
||||
if (ret) {
|
||||
printf("Image(%d) is verified fail, Please go to check!\n\n", type);
|
||||
return ret;
|
||||
}
|
||||
} else if (type == T_UBOOT) {
|
||||
ret = csi_sec_uboot_image_verify(addr, addr - PUBKEY_HEADER_SIZE);
|
||||
if (ret) {
|
||||
printf("Image(%s) is verified fail, Please go to check!\n\n", "uboot");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
U_BOOT_CMD(
|
||||
efuse, CONFIG_SYS_MAXARGS, 0, do_fuse,
|
||||
"eFuse sub-system",
|
||||
|
||||
239
board/thead/light-c910/secimg_load.c
Normal file
239
board/thead/light-c910/secimg_load.c
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* (C) Copyright 2018, Linaro Limited
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
#include <command.h>
|
||||
#include <env.h>
|
||||
#include <configs/light-c910.h>
|
||||
#include <asm/arch-thead/boot_mode.h>
|
||||
#include "sec_library.h"
|
||||
|
||||
#define ENV_SECIMG_LOAD "sec_m_load"
|
||||
#define VAL_SECIMG_LOAD "ext4load mmc ${mmcdev}:${mmcteepart} $tf_addr trust_firmware.bin; ext4load mmc ${mmcdev}:${mmcteepart} $tee_addr tee.bin\0"
|
||||
|
||||
#define RPMB_BLOCK_SIZE 256
|
||||
#define RPMB_ROLLBACK_BLOCK_START 1
|
||||
|
||||
#ifndef LIGHT_KDF_RPMB_KEY
|
||||
static const unsigned char emmc_rpmb_key_sample[32] = {0x33, 0x22, 0x11, 0x00, 0x77, 0x66, 0x55, 0x44, \
|
||||
0xbb, 0xaa, 0x99, 0x88, 0xff, 0xee, 0xdd, 0xcc, \
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
#endif
|
||||
|
||||
extern int sprintf(char *buf, const char *fmt, ...);
|
||||
extern char * get_slot_name_suffix(void);
|
||||
|
||||
static int get_rpmb_key(uint8_t key[32])
|
||||
{
|
||||
#ifndef LIGHT_KDF_RPMB_KEY
|
||||
memcpy(key, emmc_rpmb_key_sample, sizeof(emmc_rpmb_key_sample));
|
||||
|
||||
return 0;
|
||||
#else
|
||||
uint32_t kdf_rpmb_key_length = 0;
|
||||
int ret = 0;
|
||||
ret = csi_kdf_gen_hmac_key(key, &kdf_rpmb_key_length);
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int get_image_file_size(unsigned long img_src_addr)
|
||||
{
|
||||
img_header_t *img = (img_header_t *)img_src_addr;
|
||||
uint8_t magiccode[4] = {0};
|
||||
|
||||
magiccode[3] = img->magic_num & 0xff;
|
||||
magiccode[2] = (img->magic_num & 0xff00) >> 8;
|
||||
magiccode[1] = (img->magic_num & 0xff0000) >> 16;
|
||||
magiccode[0] = (img->magic_num & 0xff000000) >> 24;
|
||||
if (memcmp(header_magic, magiccode, 4) == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return img->image_size;
|
||||
}
|
||||
|
||||
static int verify_and_load_image(unsigned long image_addr_src, unsigned long image_addr_dst)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned int image_size = 0;
|
||||
|
||||
if (image_have_head(image_addr_src) == 1) {
|
||||
ret = csi_sec_init();
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = csi_sec_custom_image_verify(image_addr_src, UBOOT_STAGE_ADDR);
|
||||
if (ret != 0) {
|
||||
printf("image verify error\r\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
image_size = get_image_file_size(image_addr_src);
|
||||
if (image_size < 0) {
|
||||
printf("image get size error\r\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
memmove((void *)image_addr_dst, (const void *)(image_addr_src + HEADER_SIZE), image_size);
|
||||
} else {
|
||||
printf("in secure mode but image has no header\r\n");
|
||||
return -4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int verify_and_load_tee_tf_image(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = verify_and_load_image(LIGHT_TF_FW_TMP_ADDR, LIGHT_TF_FW_ADDR);
|
||||
if (ret != 0) {
|
||||
printf("verify tf image failed\r\n");
|
||||
return ret;
|
||||
}
|
||||
printf("verify trust firmware image success\r\n");
|
||||
|
||||
ret = verify_and_load_image(LIGHT_TEE_FW_ADDR, LIGHT_TEE_FW_ADDR);
|
||||
if (ret != 0) {
|
||||
printf("verify tee image failed\r\n");
|
||||
return ret;
|
||||
}
|
||||
printf("verify tee image success\r\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* In order to use common bootloader for both secure boot and non-secure boot,
|
||||
we only know the boot type through reading the sec_boot field in efuse. Due to
|
||||
the efuse is only accessed in lifecycle(DEV/OEM/PRO/RMP), we ensure it must be
|
||||
non-secure boot in lifecycle(INIT) */
|
||||
bool get_system_boot_type(void)
|
||||
{
|
||||
bool btype = true; /* false: non-secure boot | true: secure boot */
|
||||
#if 0
|
||||
int lc = 0;
|
||||
sboot_st_t sb_flag = SECURE_BOOT_DIS;
|
||||
int ret = 0;
|
||||
#endif
|
||||
int sb_emulater = 0;
|
||||
|
||||
sb_emulater = env_get_ulong("sb_emulater", 10, 0);
|
||||
if (sb_emulater == 0) {
|
||||
btype = false;
|
||||
}
|
||||
# if 0
|
||||
ret = csi_efuse_get_lc(&lc);
|
||||
/* 0: LC_INIT, 1: LC_DEV, 2: LC_OEM, 3: LC_PRO */
|
||||
if ((ret == 0) && (lc != 0)) {
|
||||
csi_efuse_api_init();
|
||||
|
||||
/* Check platform secure boot enable ? */
|
||||
ret = csi_efuse_get_secure_boot_st(&sb_flag);
|
||||
if ((ret == 0) && (sb_flag == SECURE_BOOT_EN))
|
||||
btype = true;
|
||||
|
||||
csi_efuse_api_uninit();
|
||||
}
|
||||
#endif
|
||||
return btype;
|
||||
}
|
||||
|
||||
int sec_read_rollback_index(size_t rollback_index_slot, uint64_t *out_rollback_index)
|
||||
{
|
||||
char runcmd[64] = {0};
|
||||
unsigned char blkdata[RPMB_BLOCK_SIZE];
|
||||
size_t rpmb_block = (rollback_index_slot * sizeof(uint64_t)) / RPMB_BLOCK_SIZE + RPMB_ROLLBACK_BLOCK_START;
|
||||
size_t rpmb_offset = (rollback_index_slot * sizeof(uint64_t)) % RPMB_BLOCK_SIZE;
|
||||
|
||||
sprintf(runcmd, "mmc rpmb read 0x%lx %ld 1", (unsigned long)blkdata, rpmb_block);
|
||||
if(run_command(runcmd, 0)) {
|
||||
printf("read_rollback_index failed, mmc read error\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*out_rollback_index = *(uint64_t*)(blkdata + rpmb_offset);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sec_write_rollback_index(size_t rollback_index_slot, uint64_t rollback_index)
|
||||
{
|
||||
char runcmd[64] = {0};
|
||||
unsigned char blkdata[RPMB_BLOCK_SIZE];
|
||||
size_t rpmb_block = (rollback_index_slot * sizeof(uint64_t)) / RPMB_BLOCK_SIZE + RPMB_ROLLBACK_BLOCK_START;
|
||||
size_t rpmb_offset = (rollback_index_slot * sizeof(uint64_t)) % RPMB_BLOCK_SIZE;
|
||||
uint8_t rpmb_key[32];
|
||||
|
||||
sprintf(runcmd, "mmc rpmb read 0x%lx %ld 1", (unsigned long)blkdata, rpmb_block);
|
||||
if(run_command(runcmd, 0)) {
|
||||
printf("read_rollback_index failed, mmc read error\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*(uint64_t*)(blkdata + rpmb_offset) = rollback_index;
|
||||
|
||||
if (get_rpmb_key(rpmb_key) != 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
sprintf(runcmd, "mmc rpmb write 0x%lx %ld 1 0x%lx", (unsigned long)blkdata, rpmb_block, (unsigned long)rpmb_key);
|
||||
if(run_command(runcmd, 0)) {
|
||||
printf("read_rollback_index failed, mmc write error\r\n");
|
||||
return -3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_secimg_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
bool sb_enable = false;
|
||||
const char *secimgs_load_str = VAL_SECIMG_LOAD;
|
||||
int ret = -1;
|
||||
int teepart = 0;
|
||||
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
char *slot_suffix = get_slot_name_suffix();
|
||||
teepart = env_get_ulong("mmcteepart", 10, 8);
|
||||
if ((strcmp(slot_suffix, "_a") == 0) && (teepart != 8)) {
|
||||
/* Switch mmcbootpart to "_b" */
|
||||
env_set_ulong("mmcbootpart", 2);
|
||||
/* Switch mmcteepart to "_b" */
|
||||
env_set_ulong("mmcteepart", 8);
|
||||
} else if ((strcmp(slot_suffix, "_b") == 0) && (teepart != 9)){
|
||||
/* Switch mmcbootpart to "_b" */
|
||||
env_set_ulong("mmcbootpart", 3);
|
||||
/* Switch mmcteepart to "_b" */
|
||||
env_set_ulong("mmcteepart", 9);
|
||||
}
|
||||
#endif
|
||||
|
||||
sb_enable = get_system_boot_type();
|
||||
if (sb_enable) {
|
||||
/* By default, the value for ENV-SEC-M-LOAD is always to load opensbi image.
|
||||
* if secure boot is enable, we force to change the value to load tee image.
|
||||
* but Never to save it in volatile-RAM
|
||||
*/
|
||||
ret = env_set(ENV_SECIMG_LOAD, secimgs_load_str);
|
||||
if (ret != 0) {
|
||||
printf("Rewrite ENV (%s) fails\n", ENV_SECIMG_LOAD);
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
secimg_load, 1, 1, do_secimg_load,
|
||||
"Runtime-load secure image if secure system is enable",
|
||||
NULL
|
||||
);
|
||||
@@ -26,6 +26,11 @@
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
extern void init_ddr(void);
|
||||
#ifdef CONFIG_FIXUP_MEMORY_REGION
|
||||
extern int fixup_ddr_addrmap(unsigned long size);
|
||||
extern int query_ddr_boundary(unsigned long size);
|
||||
#endif
|
||||
extern unsigned long get_ddr_density(void);
|
||||
extern void cpu_clk_config(int cpu_freq);
|
||||
extern void sys_clk_config(void);
|
||||
extern void ddr_clk_config(int ddr_freq);
|
||||
@@ -48,6 +53,7 @@ static struct light_reset_list light_post_reset_lists[] = {
|
||||
{0x00000002, 0xFFEF528000}, /* VO sys_reg: GPU rst */
|
||||
{0x00000003, 0xFFEF528000}, /* VO sys_reg: GPU rst */
|
||||
{0x00000007, 0xFFFF529004}, /* VO sys_reg: DPU rst */
|
||||
{0x07FFFF18, 0xFFCB000014}, /* Audio sys_reg: DMA rst */
|
||||
};
|
||||
|
||||
static void light_pre_reset_config(void)
|
||||
@@ -92,6 +98,25 @@ void setup_ddr_pmp(void)
|
||||
sync_is();
|
||||
}
|
||||
|
||||
void clear_ddr_pmp(void)
|
||||
{
|
||||
/* restore pmp entry0,entry1 setting in bootrom */
|
||||
writel(0x0400000000 >> 12, (void *)(PMP_BASE_ADDR + 0x104));
|
||||
writel(0x0 >> 12, (void *)(PMP_BASE_ADDR + 0x100));
|
||||
writel(0xffe1000000 >> 12, (void *)(PMP_BASE_ADDR + 0x10c));
|
||||
writel(0xffe0180000 >> 12, (void *)(PMP_BASE_ADDR + 0x108));
|
||||
|
||||
writel(0x4040, (void *)(PMP_BASE_ADDR + 0x000));
|
||||
|
||||
sync_is();
|
||||
}
|
||||
|
||||
static inline void _l2cache_ciall(void)
|
||||
{
|
||||
asm volatile (".long 0x0170000b");
|
||||
}
|
||||
|
||||
|
||||
int get_rng(unsigned int *rng, int cnt)
|
||||
{
|
||||
int i;
|
||||
@@ -296,17 +321,113 @@ void setup_ddr_parity(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FIXUP_MEMORY_REGION
|
||||
|
||||
#define MAGIC_DATA (0xF4240)
|
||||
#define MAGIC_DATA2 (0x5AA5)
|
||||
#define MAGIC_DATA3 (0x3C3C)
|
||||
#define MAGIC_DATA4 (0xF0F0)
|
||||
|
||||
/*
|
||||
return: 0: found boundary;
|
||||
*/
|
||||
int boundary_verify(unsigned long boundary) {
|
||||
phys_addr_t verify_addr = (phys_addr_t)CONFIG_SYS_SDRAM_BASE;
|
||||
phys_addr_t verify_addr2 = ((phys_addr_t)boundary + CONFIG_SYS_SDRAM_BASE)/4;
|
||||
phys_addr_t verify_addr3 = ((phys_addr_t)boundary + CONFIG_SYS_SDRAM_BASE)/2;
|
||||
phys_addr_t verify_addr4 = (phys_addr_t)boundary + CONFIG_SYS_SDRAM_BASE;
|
||||
|
||||
// verify data accessing result firstly
|
||||
writel(MAGIC_DATA2, verify_addr);
|
||||
invalidate_dcache_range(verify_addr, verify_addr + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if (readl(verify_addr) != MAGIC_DATA2) {
|
||||
printf("ddr rw test failed\n");
|
||||
return -1;
|
||||
}
|
||||
writel(MAGIC_DATA, verify_addr); // writing at beginning
|
||||
invalidate_dcache_range(verify_addr, verify_addr + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if (readl(verify_addr) != MAGIC_DATA) {
|
||||
printf("ddr rw test failed\n");
|
||||
return -1;
|
||||
}
|
||||
writel(MAGIC_DATA2, verify_addr2); // writing at one-quarter addr
|
||||
writel(MAGIC_DATA3, verify_addr3); // writing at half addr
|
||||
invalidate_dcache_range(verify_addr, verify_addr + CONFIG_SYS_CACHELINE_SIZE);
|
||||
invalidate_dcache_range(verify_addr2, verify_addr2 + CONFIG_SYS_CACHELINE_SIZE);
|
||||
invalidate_dcache_range(verify_addr3, verify_addr3 + CONFIG_SYS_CACHELINE_SIZE);
|
||||
|
||||
if (boundary == (unsigned long)MAXIMAL_DDR_DENSITY_MB * UNIT_MB) { // boundary by design
|
||||
if ((readl(verify_addr) == MAGIC_DATA) &&
|
||||
(readl(verify_addr2) == MAGIC_DATA2) &&
|
||||
(readl(verify_addr3) == MAGIC_DATA3))
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
writel(MAGIC_DATA4, verify_addr4); // writing out of boundary
|
||||
invalidate_dcache_range(verify_addr4, verify_addr4 + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if ((readl(verify_addr) == MAGIC_DATA4) && // overwrite by verify_addr4
|
||||
(readl(verify_addr2) == MAGIC_DATA2) &&
|
||||
(readl(verify_addr3) == MAGIC_DATA3) &&
|
||||
(readl(verify_addr4) == MAGIC_DATA4))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int setup_ddr_addrmap(void)
|
||||
{
|
||||
unsigned long boundary = (unsigned long)MAXIMAL_DDR_DENSITY_MB * UNIT_MB;
|
||||
|
||||
// verify data accessing result firstly
|
||||
writel(MAGIC_DATA, (phys_addr_t)CONFIG_SYS_SDRAM_BASE);
|
||||
invalidate_dcache_range(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if (readl((phys_addr_t)CONFIG_SYS_SDRAM_BASE) != MAGIC_DATA) {
|
||||
printf("ddr rw test failed\n");
|
||||
goto addrmap_err;
|
||||
}
|
||||
writel(MAGIC_DATA2, (phys_addr_t)CONFIG_SYS_SDRAM_BASE);
|
||||
invalidate_dcache_range(CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_SDRAM_BASE + CONFIG_SYS_CACHELINE_SIZE);
|
||||
if (readl((phys_addr_t)CONFIG_SYS_SDRAM_BASE) != MAGIC_DATA2) {
|
||||
printf("ddr rw test failed\n");
|
||||
goto addrmap_err;
|
||||
}
|
||||
|
||||
// try to find memory boundary
|
||||
while (boundary >= (unsigned long)MINIMAL_DDR_DENSITY_MB * UNIT_MB) {
|
||||
if (query_ddr_boundary(boundary) == 0) {
|
||||
clear_ddr_pmp();
|
||||
fixup_ddr_addrmap(boundary);
|
||||
setup_ddr_pmp();
|
||||
if (boundary_verify(boundary) == 0) {
|
||||
gd->ram_size = boundary;
|
||||
printf("found ddr boundary <0x%lx>\n", boundary);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
boundary = boundary >> 1;
|
||||
}
|
||||
|
||||
gd->ram_size = get_ddr_density();
|
||||
addrmap_err:
|
||||
printf("failed to setup ddr addrmap\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void cpu_performance_enable(void)
|
||||
{
|
||||
#define CSR_MHINT2_E 0x7cc
|
||||
#define CSR_MHINT4 0x7ce
|
||||
csr_write(CSR_SMPEN, 0x1);
|
||||
csr_write(CSR_MHINT2_E, csr_read(CSR_MHINT2_E) | 0x20000);
|
||||
csr_write(CSR_MHINT4, csr_read(CSR_MHINT4) | 0x410);
|
||||
csr_write(CSR_MCCR2, 0xe2490009);
|
||||
csr_write(CSR_MHCR, 0x117f); // clear bit7 to disable indirect brantch prediction
|
||||
csr_write(CSR_MXSTATUS, 0x638000);
|
||||
csr_write(CSR_MHINT, 0x6e30c | (1<<21) | (1<<22)); // set bit21 & bit 22 to close tlb & fence broadcast
|
||||
// FIXME: Clear bit[12] to disable L0BTB.
|
||||
csr_write(CSR_MHCR, 0x17f); // clear bit7 to disable indirect brantch prediction
|
||||
// FIXME set mhint2[22] to enable core icg en
|
||||
csr_write(CSR_MHINT2_E, csr_read(CSR_MHINT2_E) | 0x420000);
|
||||
csr_write(CSR_MHINT4, csr_read(CSR_MHINT4) | 0x410);
|
||||
}
|
||||
|
||||
static int bl1_img_have_head(unsigned long img_src_addr)
|
||||
@@ -368,9 +489,9 @@ void board_init_f(ulong dummy)
|
||||
preloader_console_init();
|
||||
|
||||
#ifdef CONFIG_PMIC_VOL_INIT
|
||||
ret = pmic_ddr_regu_init();
|
||||
ret = aon_local_init();
|
||||
if (ret) {
|
||||
printf("%s pmic init failed %d \n",__func__,ret);
|
||||
printf("%s aon local init failed %d \n",__func__,ret);
|
||||
hang();
|
||||
}
|
||||
|
||||
@@ -385,23 +506,43 @@ void board_init_f(ulong dummy)
|
||||
printf("%s set apcpu voltage failed \n",__func__);
|
||||
hang();
|
||||
}
|
||||
|
||||
#endif
|
||||
ddr_clk_config(0);
|
||||
#ifdef CONFIG_RV_BOOK
|
||||
cpu_clk_config(750000000);
|
||||
#else
|
||||
cpu_clk_config(0);
|
||||
#endif
|
||||
|
||||
init_ddr();
|
||||
setup_ddr_scramble();
|
||||
setup_ddr_parity();
|
||||
setup_ddr_pmp();
|
||||
#ifdef CONFIG_FIXUP_MEMORY_REGION
|
||||
setup_ddr_addrmap();
|
||||
#else
|
||||
// update ram_size from board config
|
||||
gd->ram_size = get_ddr_density();
|
||||
#endif
|
||||
|
||||
printf("ddr initialized, jump to uboot\n");
|
||||
light_board_init_r(NULL, 0);
|
||||
}
|
||||
|
||||
static uint32_t get_custom_boot_seq(void)
|
||||
{
|
||||
/* boot media definition */
|
||||
/* BOOT_DEVICE_MMC1 - boot from eMMC or SD card */
|
||||
/* BOOT_DEVICE_NAND - boot from nand flash */
|
||||
/* BOOT_DEVICE_SPI - boot from spi flash */
|
||||
/* TODO: user can decide the boot media according their own configuration */
|
||||
return BOOT_DEVICE_MMC1;
|
||||
}
|
||||
|
||||
void board_boot_order(u32 *spl_boot_list)
|
||||
{
|
||||
#define SOC_OM_ADDRBASE 0xffef018010
|
||||
#if CONFIG_IS_ENABLED(LIGHT_BOOT_FORCE_SEQ)
|
||||
switch (readl((void *)SOC_OM_ADDRBASE) & 0x7) {
|
||||
case 0:
|
||||
case 1:
|
||||
@@ -428,6 +569,8 @@ void board_boot_order(u32 *spl_boot_list)
|
||||
default:
|
||||
spl_boot_list[0] = BOOT_DEVICE_NONE;
|
||||
}
|
||||
|
||||
#else
|
||||
spl_boot_list[0] = get_custom_boot_seq();
|
||||
#endif
|
||||
cpu_performance_enable();
|
||||
}
|
||||
|
||||
@@ -20,12 +20,106 @@
|
||||
#define LIGHT_APSYS_RSTGEN_ADDRBASE 0xffff015000
|
||||
#define LIGHT_DPU_CLOCK_GATING_CTRL0 0xffef601A28
|
||||
#define LIGHT_DPU_CLOCK_GATING_CTRL1 0xffef601A2C
|
||||
#ifdef CONFIG_RV_BOOK
|
||||
#define LIGHT_CPU_PLL_IDX(x) (x)
|
||||
#endif
|
||||
|
||||
void show_sys_clk(void)
|
||||
{
|
||||
/* Do nothing for FPGA */
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RV_BOOK
|
||||
|
||||
static int _light_get_pllid(void)
|
||||
{
|
||||
unsigned int val;
|
||||
int ret;
|
||||
val = readl((void *)LIGHT_APCLK_ADDRBASE + 0x100);
|
||||
if(val & 0x1)
|
||||
ret = LIGHT_CPU_PLL_IDX(1);
|
||||
else
|
||||
ret = LIGHT_CPU_PLL_IDX(0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void update_cpu_freq(uint32_t val)
|
||||
{
|
||||
if(_light_get_pllid() == LIGHT_CPU_PLL_IDX(0))
|
||||
{
|
||||
/* update cpupll1*/
|
||||
writel(0x20000000, (void *)LIGHT_APCLK_ADDRBASE + 0x14);
|
||||
writel(val, (void *)LIGHT_APCLK_ADDRBASE + 0x10);
|
||||
writel(0x23000000, (void *)LIGHT_APCLK_ADDRBASE + 0x14);
|
||||
udelay(3);
|
||||
writel(0x03000000, (void *)LIGHT_APCLK_ADDRBASE + 0x14);
|
||||
readl((void *)LIGHT_APCLK_ADDRBASE + 0x80);
|
||||
readl((void *)LIGHT_APCLK_ADDRBASE + 0x80);
|
||||
while(!(readl((void *)LIGHT_APCLK_ADDRBASE + 0x80) & 0x10));
|
||||
udelay(11);
|
||||
}else{
|
||||
/* update cpupll0*/
|
||||
writel(0x20000000, (void *)LIGHT_APCLK_ADDRBASE + 0x04);
|
||||
writel(val, (void *)LIGHT_APCLK_ADDRBASE + 0x00);
|
||||
writel(0x23000000, (void *)LIGHT_APCLK_ADDRBASE + 0x04);
|
||||
udelay(3);
|
||||
writel(0x03000000, (void *)LIGHT_APCLK_ADDRBASE + 0x04);
|
||||
readl((void *)LIGHT_APCLK_ADDRBASE + 0x80);
|
||||
readl((void *)LIGHT_APCLK_ADDRBASE + 0x80);
|
||||
while(!(readl((void *)LIGHT_APCLK_ADDRBASE + 0x80) & 0x02));
|
||||
udelay(11);
|
||||
}
|
||||
}
|
||||
|
||||
void cpu_clk_config(int32_t cpu_freq)
|
||||
{
|
||||
#ifndef CONFIG_TARGET_LIGHT_FPGA_FM_C910 /* for sillicon */
|
||||
unsigned int tmp;
|
||||
|
||||
switch(cpu_freq){
|
||||
case 750000000:
|
||||
{
|
||||
/* 4. update c910_cclk to 750Mhz */
|
||||
update_cpu_freq(0x1407d01);
|
||||
/* config bus: cpu clk ratio to 1:1 */
|
||||
writel((readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) & (~(0x7<<8))) | (0x0<<8), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // ratio=0
|
||||
writel(readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) & (~(0x1<<11)), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=0
|
||||
writel(readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) | (0x1<<11), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=1
|
||||
printf("cpu frequency to 750\n");
|
||||
}
|
||||
break;
|
||||
case 1500000000:
|
||||
{
|
||||
/* 4. update c910_cclk to 1.5Ghz */
|
||||
update_cpu_freq(0x01207d01);
|
||||
/* config bus: cpu clk ratio to 1:2 */
|
||||
writel((readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) & (~(0x7<<8))) | (0x1<<8), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // ratio=0
|
||||
writel(readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) & (~(0x1<<11)), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=0
|
||||
writel(readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) | (0x1<<11), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=1
|
||||
printf("cpu frequency to 1500\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if(_light_get_pllid() == LIGHT_CPU_PLL_IDX(0))
|
||||
{
|
||||
/* switch c910_cclk to cpu_pll1_foutpostdiv */
|
||||
tmp = readl((void *)LIGHT_APCLK_ADDRBASE + 0x100);
|
||||
tmp |= 0x1;
|
||||
writel(tmp, (void *)LIGHT_APCLK_ADDRBASE + 0x100);
|
||||
}else
|
||||
{
|
||||
/* switch c910_cclk to cpu_pll0_foutpostdiv */
|
||||
tmp = readl((void *)LIGHT_APCLK_ADDRBASE + 0x100);
|
||||
tmp &= ~0x1;
|
||||
writel(tmp, (void *)LIGHT_APCLK_ADDRBASE + 0x100);
|
||||
}
|
||||
udelay(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
void cpu_clk_config(uint32_t cpu_freq)
|
||||
{
|
||||
#ifndef CONFIG_TARGET_LIGHT_FPGA_FM_C910 /* for sillicon */
|
||||
@@ -43,9 +137,9 @@ void cpu_clk_config(uint32_t cpu_freq)
|
||||
udelay(11);
|
||||
|
||||
/* config bus: cpu clk ratio to 1:1 */
|
||||
writel((readl(LIGHT_APCLK_ADDRBASE + 0x100) & (~(0x7<<8))) | (0x0<<8), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // ratio=0
|
||||
writel(readl(LIGHT_APCLK_ADDRBASE + 0x100) & (~(0x1<<11)), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=0
|
||||
writel(readl(LIGHT_APCLK_ADDRBASE + 0x100) | (0x1<<11), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=1
|
||||
writel((readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) & (~(0x7<<8))) | (0x0<<8), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // ratio=0
|
||||
writel(readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) & (~(0x1<<11)), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=0
|
||||
writel(readl((const volatile void __iomem *)(LIGHT_APCLK_ADDRBASE + 0x100)) | (0x1<<11), (void *)(LIGHT_APCLK_ADDRBASE + 0x100)); // sync=1
|
||||
|
||||
/* switch c910_cclk to cpu_pll1_foutpostdiv */
|
||||
tmp = readl((void *)LIGHT_APCLK_ADDRBASE + 0x100);
|
||||
@@ -54,6 +148,7 @@ void cpu_clk_config(uint32_t cpu_freq)
|
||||
udelay(1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void sys_clk_config(void)
|
||||
{
|
||||
@@ -290,7 +385,7 @@ void sys_clk_config(void)
|
||||
|
||||
/* The boards other than the LightA board perform the bus down-speed operation */
|
||||
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_DISCRETE) || defined (CONFIG_TARGET_LIGHT_FM_C910_BEAGLE) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B) || defined (CONFIG_TARGET_LIGHT_FM_C910_LPI4A)
|
||||
#if defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_DISCRETE) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF) || defined (CONFIG_TARGET_LIGHT_FM_C910_B_POWER) || defined (CONFIG_TARGET_LIGHT_FM_C910_VAL_B)
|
||||
/* axi_sram_clk: 812.8512MHz -> 688.128MHz */
|
||||
tmp = readl((void *)LIGHT_AONCLK_ADDRBASE + 0x104);
|
||||
tmp |= 0x2000;
|
||||
@@ -336,6 +431,24 @@ void sys_clk_config(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
static int cpu_switch_freq(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||
char * const argv[])
|
||||
{
|
||||
cpu_clk_config(1500000000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
cpufreq_switch,
|
||||
2,
|
||||
0,
|
||||
cpu_switch_freq,
|
||||
"switch cpu freq to highest",
|
||||
""
|
||||
);
|
||||
#endif
|
||||
|
||||
void ddr_clk_config(int ddr_freq)
|
||||
{
|
||||
/* Do nothing for FPGA */
|
||||
|
||||
@@ -263,6 +263,12 @@ config CMD_BOOTI
|
||||
help
|
||||
Boot an AArch64 Linux Kernel image from memory.
|
||||
|
||||
config CMD_BOOTANDROID
|
||||
bool "bootandroid"
|
||||
default n
|
||||
help
|
||||
Boot an android image from mmc.
|
||||
|
||||
config BOOTM_LINUX
|
||||
bool "Support booting Linux OS images"
|
||||
depends on CMD_BOOTM || CMD_BOOTZ || CMD_BOOTI
|
||||
|
||||
@@ -137,6 +137,7 @@ obj-$(CONFIG_CMD_TPM) += tpm-common.o
|
||||
obj-$(CONFIG_CMD_TPM_V1) += tpm-v1.o
|
||||
obj-$(CONFIG_CMD_TPM_TEST) += tpm_test.o
|
||||
obj-$(CONFIG_CMD_TPM_V2) += tpm-v2.o
|
||||
obj-$(CONFIG_CMD_MEASURED_BOOT) += mboot.o
|
||||
obj-$(CONFIG_CMD_CROS_EC) += cros_ec.o
|
||||
obj-$(CONFIG_CMD_TSI148) += tsi148.o
|
||||
obj-$(CONFIG_CMD_UBI) += ubi.o
|
||||
@@ -175,6 +176,7 @@ obj-$(CONFIG_CMD_REGULATOR) += regulator.o
|
||||
obj-$(CONFIG_CMD_BLOB) += blob.o
|
||||
|
||||
# Android Verified Boot 2.0
|
||||
obj-$(CONFIG_CMD_BOOTANDROID) += bootandroid.o
|
||||
obj-$(CONFIG_CMD_AVB) += avb.o
|
||||
|
||||
obj-$(CONFIG_DDR_SCAN) += ddrscan.o
|
||||
|
||||
@@ -312,6 +312,10 @@ int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag,
|
||||
printf("Unknown error occurred\n");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
if (out_data)
|
||||
avb_slot_verify_data_free(out_data);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
572
cmd/bootandroid.c
Normal file
572
cmd/bootandroid.c
Normal file
@@ -0,0 +1,572 @@
|
||||
/*
|
||||
* (C) Copyright 2018, Linaro Limited
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <avb_verify.h>
|
||||
#include <command.h>
|
||||
#include <env.h>
|
||||
#include <image.h>
|
||||
#include <malloc.h>
|
||||
#include <mmc.h>
|
||||
#include <android_image.h>
|
||||
#include <android_bootloader_message.h>
|
||||
#include <xbc.h>
|
||||
|
||||
#define ENV_KERNEL_ADDR "kernel_addr"
|
||||
#define ENV_RAMDISK_ADDR "ramdisk_addr"
|
||||
#define ENV_DTB_ADDR "dtb_addr"
|
||||
#define DEFAULT_KERNEL_ADDR 0x00200800
|
||||
#define DEFAULT_RAMDISK_ADDR LIGHT_ROOTFS_ADDR
|
||||
#define DEFAULT_DTB_ADDR LIGHT_DTB_ADDR
|
||||
#define ENV_RAMDISK_SIZE "ramdisk_size"
|
||||
#define MISC_PARTITION "misc"
|
||||
#define RECOVERY_PARTITION "recovery"
|
||||
#define BOOT_PARTITION "boot"
|
||||
#define VENDOR_BOOT_PARTITION "vendor_boot"
|
||||
|
||||
#define BOOTDEV_DEFAULT 0
|
||||
#define BCB_BOOTONCE "bootonce-bootloader"
|
||||
#define BCB_BOOTRECOVERY "boot-recovery"
|
||||
|
||||
|
||||
/*
|
||||
* Knowing secure boot is enable or disable dependents on
|
||||
* special data field in efuse and efuse control register.
|
||||
*/
|
||||
extern bool get_system_boot_type(void);
|
||||
/*
|
||||
* The suffix for partition name is from the value of ENV_BOOTAB
|
||||
*/
|
||||
static const char *slot_name_suffix = NULL;
|
||||
|
||||
/*
|
||||
* BOOT IMAGE HEADER V3/V4 PAGESIZE
|
||||
* Source code:system/tools/mkbootimg/unpack_bootimg.py
|
||||
*/
|
||||
#define BOOT_IMAGE_HEADER_V3_PAGESIZE 4096
|
||||
|
||||
static struct AvbOps *avb_ops = NULL;
|
||||
static struct bootloader_message_ab *s_bcb = NULL;
|
||||
static struct bootloader_control *boot_ctl = NULL;
|
||||
|
||||
static char *get_boot_partition_name_suffix(void)
|
||||
{
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
if (boot_ctl != NULL) {
|
||||
/* index 0 is _a, index 1 is _b*/
|
||||
if(boot_ctl->slot_info[0].priority < boot_ctl->slot_info[1].priority) {
|
||||
strcpy(boot_ctl->slot_suffix, "_b");
|
||||
} else {
|
||||
strcpy(boot_ctl->slot_suffix, "_a");
|
||||
}
|
||||
} else {
|
||||
printf("get_slot_suffix boot_ctl is null return _a");
|
||||
return "_a";
|
||||
}
|
||||
printf("get_slot_suffix boot_ctl->slot_suffix %s\r\n", boot_ctl->slot_suffix);
|
||||
return boot_ctl->slot_suffix;
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
static void get_partition_name(const char *partion, char *partion_name)
|
||||
{
|
||||
strcpy(partion_name, partion);
|
||||
strcat(partion_name, get_boot_partition_name_suffix());
|
||||
}
|
||||
|
||||
/*
|
||||
*format 4 chars/bytes to a int number
|
||||
*/
|
||||
static int byteToInt(uint8_t* data,int offset)
|
||||
{
|
||||
return data[offset+0] + (data[offset+1] << 8) + (data[offset+2] << 16) + (data[offset+3] << 24);
|
||||
}
|
||||
|
||||
static int get_number_of_pages(int image_size, int page_size)
|
||||
{
|
||||
return (image_size + page_size - 1) / page_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* header_version >=3,get dtb data from vendor_boot.img ,else boot.img.
|
||||
*
|
||||
* header_version = 4,get bootconfig data from vendor_boot.img ,
|
||||
* and append bootconfig to the end of ramdisk(initrd)
|
||||
* doc:https://www.kernel.org/doc/html/next/translations/zh_CN/admin-guide/bootconfig.html#initrd
|
||||
*/
|
||||
static int prepare_data_from_vendor_boot(struct andr_img_hdr *hdr, int dtb_start, uint8_t** buf_bootconfig, int* vendor_bootconfig_size, bool isRecovery)
|
||||
{
|
||||
int ret;
|
||||
disk_partition_t part_info;
|
||||
uint8_t* vendor_boot_data = NULL;
|
||||
struct blk_desc *dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
char vb_part_name[32] = {0};
|
||||
|
||||
if (hdr == NULL) {
|
||||
printf("invalid hdr\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* if the vendor boot partition name is beyond 32B, arise error */
|
||||
if ((32 - strlen(VENDOR_BOOT_PARTITION)) < 2)
|
||||
return -1;
|
||||
|
||||
get_partition_name(VENDOR_BOOT_PARTITION, vb_part_name);
|
||||
|
||||
printf("blk_get_dev %s\n", vb_part_name);
|
||||
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
|
||||
printf("MMC err: invalid mmc device\n");
|
||||
return -1;
|
||||
}
|
||||
/* Get boot partition info */
|
||||
ret = part_get_info_by_name(dev_desc, vb_part_name, &part_info);
|
||||
if (ret < 0) {
|
||||
printf("MMC err: cannot find %s partition\n", vb_part_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (part_info.size * part_info.blksz > CONFIG_FASTBOOT_BUF_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
//vendor_boot_data = (uint8_t*)CONFIG_FASTBOOT_BUF_ADDR;
|
||||
|
||||
printf("vendor_boot_data part_info.size = %ld, part_info.blksz = %lu", part_info.size, part_info.blksz);
|
||||
// reuse kernel start address to load vendor boot data
|
||||
// because av_malloc(32M) failed in 2G devices
|
||||
// TODO: why av_malloc failed
|
||||
// ATTATION: If the vendor_boot partition size > boot partition size, it is error.
|
||||
// avb_malloc(part_info.size * part_info.blksz);
|
||||
vendor_boot_data = (uint8_t*)env_get_hex(ENV_KERNEL_ADDR, DEFAULT_KERNEL_ADDR);
|
||||
|
||||
ret = blk_dread(dev_desc, part_info.start, part_info.size, vendor_boot_data);
|
||||
// vendor_boot.img
|
||||
//* +------------------------+
|
||||
//* | vendor boot header | o pages
|
||||
//* +------------------------+
|
||||
//* | vendor ramdisk section | p pages
|
||||
//* +------------------------+
|
||||
//* | dtb | q pages
|
||||
//* +------------------------+
|
||||
//* | vendor ramdisk table | r pages
|
||||
//* +------------------------+
|
||||
//* | bootconfig | s pages
|
||||
//* +------------------------+
|
||||
//* o = (2124 + page_size - 1) / page_size
|
||||
//* p = (vendor_ramdisk_size + page_size - 1) / page_size
|
||||
//* q = (dtb_size + page_size - 1) / page_size
|
||||
//* r = (vendor_ramdisk_table_size + page_size - 1) / page_size
|
||||
//* s = (vendor_bootconfig_size + page_size - 1) / page_size
|
||||
|
||||
// see system/tools/mkbootimg/unpack_bootimg.py
|
||||
// info.boot_magic = unpack('8s', args.boot_img.read(8))[0].decode()
|
||||
// info.header_version = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.page_size = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.kernel_load_address = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.ramdisk_load_address = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.vendor_ramdisk_size = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.cmdline = cstr(unpack('2048s', args.boot_img.read(2048))[0].decode())
|
||||
// info.tags_load_address = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.product_name = cstr(unpack('16s', args.boot_img.read(16))[0].decode())
|
||||
// info.header_size = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.dtb_size = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.dtb_load_address = unpack('Q', args.boot_img.read(8))[0]
|
||||
// info.vendor_ramdisk_table_size = unpack('I', args.boot_img.read(4))[0]
|
||||
// vendor_ramdisk_table_entry_num = unpack('I', args.boot_img.read(4))[0]
|
||||
// vendor_ramdisk_table_entry_size = unpack('I', args.boot_img.read(4))[0]
|
||||
// info.vendor_bootconfig_size = unpack('I', args.boot_img.read(4))[0]
|
||||
// num_vendor_ramdisk_table_pages = get_number_of_pages(
|
||||
// info.vendor_ramdisk_table_size, page_size)
|
||||
// vendor_ramdisk_table_offset = page_size * (
|
||||
// num_boot_header_pages + num_boot_ramdisk_pages + num_boot_dtb_pages)
|
||||
// bootconfig_offset = page_size * (num_boot_header_pages
|
||||
// + num_boot_ramdisk_pages + num_boot_dtb_pages
|
||||
// + num_vendor_ramdisk_table_pages)
|
||||
|
||||
int vendor_boot_pagesize = byteToInt(vendor_boot_data,12);//offset 12
|
||||
int vendor_ramdisk_size = byteToInt(vendor_boot_data,24);//offset 24
|
||||
int dtb_size = byteToInt(vendor_boot_data,2100);//offset 2100
|
||||
int o = (2124 + vendor_boot_pagesize - 1) / vendor_boot_pagesize;
|
||||
int p = (vendor_ramdisk_size + vendor_boot_pagesize - 1) / vendor_boot_pagesize;
|
||||
int dtb_offset = vendor_boot_pagesize * (o + p);
|
||||
|
||||
hdr->dtb_size= dtb_size;
|
||||
memcpy((void *)(uint64_t)dtb_start, vendor_boot_data + dtb_offset, hdr->dtb_size);
|
||||
|
||||
int q=(hdr->dtb_size + vendor_boot_pagesize - 1) / vendor_boot_pagesize;
|
||||
int vendor_ramdisk_table_size=byteToInt(vendor_boot_data,2112);//offset 2112
|
||||
|
||||
int r=(vendor_ramdisk_table_size + vendor_boot_pagesize - 1) / vendor_boot_pagesize;
|
||||
*vendor_bootconfig_size=byteToInt(vendor_boot_data,2124);//offset 2124
|
||||
|
||||
*buf_bootconfig = avb_malloc(*vendor_bootconfig_size);
|
||||
if (*buf_bootconfig == NULL) {
|
||||
printf("vendor bootconfig malloc fail\n");
|
||||
return -1;
|
||||
}
|
||||
int bootconfig_offset=vendor_boot_pagesize * (o + p + q + r);
|
||||
memcpy(*buf_bootconfig, vendor_boot_data + bootconfig_offset, *vendor_bootconfig_size);
|
||||
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
char *find_str = NULL;
|
||||
char *slot_suffix = get_boot_partition_name_suffix();
|
||||
char *slot_suffx_pre = "androidboot.slot_suffix=";
|
||||
printf("prepare_data_from_vendor_boot slot_suffix:%s\n", slot_suffix);
|
||||
printf("prepare_data_from_vendor_boot slot_suffx_pre:%s\n", slot_suffx_pre);
|
||||
|
||||
find_str = strstr((char *)*buf_bootconfig, slot_suffx_pre);
|
||||
if (find_str != NULL) {
|
||||
memcpy(find_str + strlen(slot_suffx_pre), slot_suffix, strlen(slot_suffix));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (isRecovery) {
|
||||
int i = 0;
|
||||
struct vendor_ramdisk_table_entry *ramdisk_entry = NULL;
|
||||
int vendor_ramdisk_table_offset = vendor_boot_pagesize * (o + p + q);
|
||||
int vendor_ramdisk_table_entry_num = byteToInt(vendor_boot_data,2116);//offset 2116
|
||||
printf("vendor_boot vendor_ramdisk_table_entry_num:%d\n",vendor_ramdisk_table_entry_num);
|
||||
int vendor_ramdisk_table_entry_size = byteToInt(vendor_boot_data,2120);//offset 2116
|
||||
printf("vendor_boot vendor_ramdisk_table_entry_size:%d\n",vendor_ramdisk_table_entry_size);
|
||||
for (i = 0; i < vendor_ramdisk_table_entry_num; i++) {
|
||||
ramdisk_entry = (struct vendor_ramdisk_table_entry*)(vendor_boot_data + vendor_ramdisk_table_offset
|
||||
+ ( i * vendor_ramdisk_table_entry_size ));
|
||||
if (ramdisk_entry->ramdisk_type != VENDOR_RAMDISK_TYPE_RECOVERY) {
|
||||
continue;
|
||||
}
|
||||
printf("find recovery from ramdisk table.\n");
|
||||
int ramdisk_start = env_get_hex(ENV_RAMDISK_ADDR, DEFAULT_RAMDISK_ADDR);
|
||||
int recovery_ramdisk_offset = vendor_boot_pagesize * o + ramdisk_entry->ramdisk_offset;
|
||||
|
||||
printf("ramdisk_start:%x, ramdisk_size:%x, dtb_start:%x\n", ramdisk_start, ramdisk_entry->ramdisk_size, dtb_start);
|
||||
if (ramdisk_start + ramdisk_entry->ramdisk_size > dtb_start) {
|
||||
printf("ramdisk space are overlaped !!!\n");
|
||||
}
|
||||
|
||||
memcpy((void *)(uint64_t)ramdisk_start, vendor_boot_data + recovery_ramdisk_offset,
|
||||
ramdisk_entry->ramdisk_size);//ramdisk
|
||||
//get bootconfig form vendor_boot.img and append bootconfig to ramdisk
|
||||
char* bootconfig_params = (char*)*buf_bootconfig;
|
||||
int ret = addBootConfigParameters(bootconfig_params, *vendor_bootconfig_size,
|
||||
ramdisk_start + ramdisk_entry->ramdisk_size , 0);
|
||||
if (ret == -1) {
|
||||
printf("\nadd BootConfig Parameters error!!!\n");
|
||||
} else {
|
||||
printf("\nramdisk size is changed,new value is:%d\n",ramdisk_entry->ramdisk_size + ret);
|
||||
//set ramdisk size for bootm
|
||||
env_set_hex(ENV_RAMDISK_SIZE, ramdisk_entry->ramdisk_size + ret);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void prepare_loaded_parttion_data(const uint8_t* data, bool isRecovery)
|
||||
{
|
||||
struct andr_img_hdr *hdr = (struct andr_img_hdr *)map_sysmem((phys_addr_t)data, 0);
|
||||
|
||||
if (IMAGE_FORMAT_ANDROID == genimg_get_format(hdr)) {
|
||||
int dtb_start = env_get_hex(ENV_DTB_ADDR, DEFAULT_DTB_ADDR);
|
||||
uint8_t* buf_bootconfig = NULL;
|
||||
int size_bootconfig=0;
|
||||
|
||||
printf("Boot image header_version:%d\n", hdr->header_version);
|
||||
if (hdr->header_version >= 3) {
|
||||
// see system/tools/mkbootimg/unpack_bootimg.py
|
||||
hdr->kernel_size = byteToInt((uint8_t *)data, 8);
|
||||
hdr->ramdisk_size = byteToInt((uint8_t *)data, 12);
|
||||
hdr->page_size = BOOT_IMAGE_HEADER_V3_PAGESIZE;
|
||||
prepare_data_from_vendor_boot(hdr,dtb_start,&buf_bootconfig,&size_bootconfig,isRecovery);
|
||||
}
|
||||
|
||||
int kernel_start = env_get_hex(ENV_KERNEL_ADDR, DEFAULT_KERNEL_ADDR);
|
||||
int ramdisk_start = env_get_hex(ENV_RAMDISK_ADDR, DEFAULT_RAMDISK_ADDR);
|
||||
// see system/tools/mkbootimg/unpack_bootimg.py
|
||||
int page_size = hdr->page_size;
|
||||
int num_header_pages = 1;
|
||||
int num_kernel_pages = get_number_of_pages(hdr->kernel_size, page_size);
|
||||
int num_ramdisk_pages = get_number_of_pages(hdr->ramdisk_size, page_size);
|
||||
int kernel_offset = page_size * num_header_pages;
|
||||
int ramdisk_offset = page_size * (num_header_pages + num_kernel_pages);
|
||||
int dtb_offset = page_size * (num_header_pages + num_kernel_pages + num_ramdisk_pages);
|
||||
|
||||
printf("Boot image kernel_start:%x, kernel_offset:%x, kernel_size:%d\n", kernel_start, kernel_offset, hdr->kernel_size);
|
||||
printf("Boot image ramdisk_start:%x, ramdisk_offset:%x, ramdisk_size:%d\n", ramdisk_start, ramdisk_offset, hdr->ramdisk_size);
|
||||
printf("Boot image page_size:%d\n", hdr->page_size);
|
||||
printf("dtb_start:%x, dtb_offset:%x, dtb_size:%d\n", dtb_start, dtb_offset, hdr->dtb_size);
|
||||
|
||||
if (kernel_start + hdr->kernel_size > ramdisk_start || kernel_start + hdr->kernel_size > dtb_start || ramdisk_start + hdr->ramdisk_size > dtb_start) {
|
||||
printf("boot.img kernel space and ramdisk space are overlaped !!!\n");
|
||||
} else {
|
||||
memcpy((void *)(uint64_t)kernel_start, data + kernel_offset, hdr->kernel_size);
|
||||
if (!isRecovery) {
|
||||
memcpy((void *)(uint64_t)ramdisk_start, data + ramdisk_offset, hdr->ramdisk_size);
|
||||
}
|
||||
|
||||
if( hdr->header_version < 3) {
|
||||
//set ramdisk size for bootm
|
||||
env_set_hex(ENV_RAMDISK_SIZE, hdr->ramdisk_size);
|
||||
memcpy((void *)(uint64_t)dtb_start, data + dtb_offset, hdr->dtb_size);
|
||||
} else if (!isRecovery) {
|
||||
//get bootconfig form vendor_boot.img and append bootconfig to ramdisk
|
||||
char* bootconfig_params=(char*)buf_bootconfig;
|
||||
int ret = addBootConfigParameters(bootconfig_params, size_bootconfig,
|
||||
ramdisk_start + hdr->ramdisk_size , 0);
|
||||
if (ret == -1) {
|
||||
printf("Bootconfig Err: add BootConfig Parameters error!!!\n");
|
||||
} else {
|
||||
printf("ramdisk size is updated to new value is:%d\n",hdr->ramdisk_size + ret);
|
||||
//set ramdisk size for bootm
|
||||
env_set_hex(ENV_RAMDISK_SIZE, hdr->ramdisk_size + ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (buf_bootconfig != NULL) {
|
||||
avb_free(buf_bootconfig);
|
||||
}
|
||||
}
|
||||
unmap_sysmem(hdr);
|
||||
}
|
||||
|
||||
static int prepare_boot_data(const AvbSlotVerifyData *out_data, bool isRecovery)
|
||||
{
|
||||
int res = CMD_RET_FAILURE;
|
||||
int i = 0;
|
||||
int num_loaded_partition = out_data->num_loaded_partitions;
|
||||
|
||||
printf("@@@@ prepare loaded partition (%d) data start\n", num_loaded_partition);
|
||||
for (i = 0; i < num_loaded_partition; i++) {
|
||||
const AvbPartitionData *loaded_partition = &out_data->loaded_partitions[i];
|
||||
|
||||
if (loaded_partition->partition_name != NULL) {
|
||||
printf("partition_name=%s, data_size=%ld\n", \
|
||||
loaded_partition->partition_name, loaded_partition->data_size);
|
||||
prepare_loaded_parttion_data(loaded_partition->data, isRecovery);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void prepare_partition_data(const char *name, bool isRecovery)
|
||||
{
|
||||
int ret = 0;
|
||||
disk_partition_t part_info;
|
||||
struct blk_desc *dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
uint8_t *data = NULL;
|
||||
|
||||
printf("prepare_partition_data %s\n", name);
|
||||
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
|
||||
printf("MMC err: invalid mmc device\n");
|
||||
return;
|
||||
}
|
||||
/* Get boot partition info */
|
||||
ret = part_get_info_by_name(dev_desc, name, &part_info);
|
||||
if (ret < 0) {
|
||||
printf("MMC err: cannot find %s partition\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
data = avb_malloc(part_info.size * part_info.blksz);
|
||||
if (data == NULL) {
|
||||
printf("avb malloc(%ldKB) fails\n", part_info.size * part_info.blksz / 1024);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = blk_dread(dev_desc, part_info.start, part_info.size, data);
|
||||
prepare_loaded_parttion_data(data, isRecovery);
|
||||
|
||||
printf("prepare_partition_data %s, read=%d, start:%lx, size:%ld, blksize:%lx\n", \
|
||||
name, ret, part_info.start, part_info.size, part_info.blksz);
|
||||
|
||||
avb_free(data);
|
||||
}
|
||||
|
||||
static void clear_bcb(void)
|
||||
{
|
||||
int ret;
|
||||
disk_partition_t part_info;
|
||||
struct blk_desc *dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
|
||||
//bcb clear and store
|
||||
memset(s_bcb, 0, sizeof(struct bootloader_message_ab));
|
||||
|
||||
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
|
||||
printf("BootAndriod bcb err: invalid mmc device\n");
|
||||
return;
|
||||
}
|
||||
/* Get boot partition info */
|
||||
ret = part_get_info_by_name(dev_desc, MISC_PARTITION, &part_info);
|
||||
if (ret < 0) {
|
||||
printf("BootAndriod bcb err: cannot find misc partition\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = blk_dwrite(dev_desc, part_info.start, part_info.size, s_bcb);
|
||||
printf("BootAndriod bcb info :clear_bcb write=%d, %ld,%ld,%ld\n", ret, part_info.start, part_info.size, part_info.blksz);
|
||||
}
|
||||
|
||||
static int do_andriod_bcb_business(int *boot_recovery)
|
||||
{
|
||||
AvbIOResult ret = AVB_IO_RESULT_OK;
|
||||
size_t bytes_read = 0;
|
||||
int res = CMD_RET_FAILURE;
|
||||
|
||||
#ifdef CONFIG_ANDROID_AB
|
||||
char *slot_suffix = "_a";
|
||||
#else
|
||||
char *slot_suffix = "";
|
||||
#endif
|
||||
|
||||
if (avb_ops != NULL) {
|
||||
avb_ops_free(avb_ops);
|
||||
avb_ops = NULL;
|
||||
}
|
||||
|
||||
avb_ops = avb_ops_alloc(BOOTDEV_DEFAULT);
|
||||
if (avb_ops == NULL) {
|
||||
goto _bcb_err;
|
||||
}
|
||||
|
||||
if (s_bcb != NULL) {
|
||||
avb_free(s_bcb);
|
||||
s_bcb = NULL;
|
||||
}
|
||||
|
||||
s_bcb = avb_malloc(sizeof(struct bootloader_message_ab));
|
||||
if (s_bcb == NULL) {
|
||||
goto _bcb_err;
|
||||
}
|
||||
|
||||
if (boot_ctl != NULL) {
|
||||
avb_free(boot_ctl);
|
||||
boot_ctl = NULL;
|
||||
}
|
||||
|
||||
boot_ctl = malloc(sizeof(struct bootloader_control));
|
||||
if (boot_ctl == NULL)
|
||||
{
|
||||
ret = -2;
|
||||
goto _bcb_err;
|
||||
}
|
||||
|
||||
ret = avb_ops->read_from_partition(avb_ops,
|
||||
MISC_PARTITION,
|
||||
0,
|
||||
sizeof(struct bootloader_message_ab),
|
||||
s_bcb,
|
||||
&bytes_read);
|
||||
if (ret != AVB_IO_RESULT_OK) {
|
||||
printf("BootAndriod Err: Bcb read failed\n");
|
||||
goto _bcb_err;
|
||||
}
|
||||
|
||||
/* Enter into fastboot mode if bcb string is bootonce or bootrecovery */
|
||||
if (0 == strncmp(s_bcb->message.command, "bootonce-bootloader", strlen("bootonce-bootloader")))
|
||||
{
|
||||
printf("BootAndriod Info: Bcb read %ld bytes, %s\n", bytes_read, s_bcb->message.command);
|
||||
printf("BootAndriod Info: Enter fastboot mode\n");
|
||||
clear_bcb();
|
||||
run_command("fastboot usb 0", 0);
|
||||
}
|
||||
else if (0 == strncmp(s_bcb->message.command, "boot-recovery", strlen("boot-recovery")))
|
||||
{
|
||||
printf("recovery slot_suffix = %s\n", slot_suffix);
|
||||
*boot_recovery = 1;
|
||||
}
|
||||
|
||||
memset(boot_ctl, 0, sizeof(struct bootloader_control));
|
||||
memcpy(boot_ctl, (struct bootloader_control*)s_bcb->slot_suffix, sizeof(struct bootloader_control));
|
||||
|
||||
res = CMD_RET_SUCCESS;
|
||||
|
||||
_bcb_err:
|
||||
if (res != CMD_RET_SUCCESS) {
|
||||
if (avb_ops != NULL) {
|
||||
avb_ops_free(avb_ops);
|
||||
avb_ops = NULL;
|
||||
}
|
||||
|
||||
if (boot_ctl != NULL) {
|
||||
avb_free(boot_ctl);
|
||||
boot_ctl = NULL;
|
||||
}
|
||||
|
||||
if (s_bcb != NULL) {
|
||||
avb_free(s_bcb);
|
||||
s_bcb = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int do_bootandroid(struct cmd_tbl_s *cmdtp, int flag, int argc,
|
||||
char * const argv[]) {
|
||||
|
||||
const char * const requested_partitions[] = {"vbmeta", "boot", "vbmeta_system", NULL};
|
||||
AvbSlotVerifyResult slot_result = AVB_SLOT_VERIFY_RESULT_OK;
|
||||
AvbSlotVerifyData *slot_data = NULL;
|
||||
AvbIOResult ret = AVB_IO_RESULT_OK;
|
||||
AvbSlotVerifyFlags slotflags = AVB_SLOT_VERIFY_FLAGS_NONE;
|
||||
AvbHashtreeErrorMode htflags = AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE;
|
||||
int res = CMD_RET_FAILURE;
|
||||
char bp_name[32] = {0};
|
||||
int boot_recovery = 0;
|
||||
|
||||
res = do_andriod_bcb_business(&boot_recovery);
|
||||
if (res != CMD_RET_SUCCESS) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Retieve boot partition 's name suffix */
|
||||
slot_name_suffix = get_boot_partition_name_suffix();
|
||||
|
||||
/* Start with slot verification in secure boot */
|
||||
if (get_system_boot_type()) {
|
||||
/* Verify boot partition requested in vbmeta.img */
|
||||
slot_result = avb_slot_verify(avb_ops,
|
||||
requested_partitions,
|
||||
slot_name_suffix,
|
||||
slotflags,
|
||||
htflags,
|
||||
&slot_data);
|
||||
|
||||
if (slot_result == AVB_SLOT_VERIFY_RESULT_OK) {
|
||||
printf("BootAndriod Info: Request Partition are verified successfully\n");
|
||||
printf("BootAndriod cmdline: slot_data.cmdline:%s\n", slot_data->cmdline);
|
||||
prepare_boot_data(slot_data, boot_recovery ? true:false);
|
||||
if (ret == 0) {
|
||||
if (slot_data != NULL)
|
||||
avb_slot_verify_data_free(slot_data);
|
||||
}
|
||||
} else {
|
||||
/* In case of avb slot verification failure, Force system reset */
|
||||
run_command("reset", 0);
|
||||
}
|
||||
} else {
|
||||
/* Go to load BOOT partition directly in non-secure boot */
|
||||
get_partition_name(BOOT_PARTITION, bp_name);
|
||||
prepare_partition_data(bp_name, boot_recovery ? true:false);
|
||||
}
|
||||
|
||||
exit:
|
||||
return res;
|
||||
}
|
||||
|
||||
const char * get_slot_name_suffix(void)
|
||||
{
|
||||
return slot_name_suffix;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
bootandroid, 2, 1, do_bootandroid,
|
||||
"bootandroid - boot android bootimg from device\n",
|
||||
"mmc0 | mmc1 | mmc2 | mmcX]\n "
|
||||
"- boot application image stored in storage device like mmc\n"
|
||||
);
|
||||
|
||||
98
cmd/booti.c
98
cmd/booti.c
@@ -67,7 +67,6 @@ static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||
int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Consume 'booti' */
|
||||
argc--; argv++;
|
||||
|
||||
@@ -119,23 +118,110 @@ U_BOOT_CMD(
|
||||
|
||||
#endif
|
||||
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF)
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_VAL_B) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_LPI4A) || CONFIG_IS_ENABLED(LIGHT_SEC_BOOT_WITH_VERIFY_RVBOOK)
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_UPGRADE)
|
||||
extern int light_secboot(int argc, char * const argv[]);
|
||||
#endif
|
||||
int do_secboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_UPGRADE)
|
||||
if (light_secboot(argc, argv) != 0) {
|
||||
run_command("reset", 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
U_BOOT_CMD(
|
||||
secboot, CONFIG_SYS_MAXARGS, 1, do_secboot,
|
||||
"verify image file with known pubkey which reside in father image or itself!",
|
||||
secboot, CONFIG_SYS_MAXARGS, 1, do_secboot,
|
||||
"verify image file with known pubkey which reside in father image or itself!",
|
||||
"vimage addr imgname[[tee/tf] - verify specifed image resides in addr\n"
|
||||
);
|
||||
|
||||
/* check whether partition numbers are consistent with the slot suffix */
|
||||
static int do_light_bootab(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
|
||||
char *slot_suffix = env_get("slot_suffix");
|
||||
int teepart = env_get_hex("mmcteepart", 3);
|
||||
|
||||
struct disk_partition part_info;
|
||||
struct blk_desc *dev_desc;
|
||||
int part = 0;
|
||||
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (dev_desc == NULL) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((strcmp(slot_suffix, "a") == 0) && (teepart != 3)) {
|
||||
part = part_get_info_by_name(dev_desc, "boot_a", &part_info);
|
||||
if (part < 0) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return 1;
|
||||
}
|
||||
env_set_hex("mmcbootpart", part);
|
||||
|
||||
part = part_get_info_by_name(dev_desc, "tee_a", &part_info);
|
||||
if (part < 0) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return 1;
|
||||
}
|
||||
env_set_hex("mmcteepart", part);
|
||||
|
||||
part = part_get_info_by_name(dev_desc, "sbmeta_a", &part_info);
|
||||
if (part < 0) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return 1;
|
||||
}
|
||||
env_set_hex("mmcsbmetapart", part);
|
||||
|
||||
part = part_get_info_by_name(dev_desc, "root_a", &part_info);
|
||||
if (part < 0) {
|
||||
printf("root AB partition is not enabled\n");
|
||||
} else {
|
||||
env_set_hex("mmcpart", part);
|
||||
}
|
||||
|
||||
run_command("env save", 0);
|
||||
} else if ((strcmp(slot_suffix, "b") == 0) && (teepart != 10)) {
|
||||
part = part_get_info_by_name(dev_desc, "boot_b", &part_info);
|
||||
if (part < 0) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return 1;
|
||||
}
|
||||
env_set_hex("mmcbootpart", part);
|
||||
|
||||
part = part_get_info_by_name(dev_desc, "tee_b", &part_info);
|
||||
if (part < 0) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return 1;
|
||||
}
|
||||
env_set_hex("mmcteepart", part);
|
||||
|
||||
part = part_get_info_by_name(dev_desc, "sbmeta_b", &part_info);
|
||||
if (part < 0) {
|
||||
printf("Failed to find MMC device\n");
|
||||
return 1;
|
||||
}
|
||||
env_set_hex("mmcsbmetapart", part);
|
||||
|
||||
part = part_get_info_by_name(dev_desc, "root_b", &part_info);
|
||||
if (part < 0) {
|
||||
printf("root AB partition is not enabled\n");
|
||||
} else {
|
||||
env_set_hex("mmcpart", part);
|
||||
}
|
||||
run_command("env save", 0);
|
||||
}
|
||||
printf("current active slot is:%s\n", slot_suffix);
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
light_bootab, CONFIG_SYS_MAXARGS, 1, do_light_bootab,
|
||||
"Light A/B updates",
|
||||
NULL
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
122
cmd/mboot.c
Normal file
122
cmd/mboot.c
Normal file
@@ -0,0 +1,122 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright (c) 2018 Bootlin
|
||||
* Author: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <log.h>
|
||||
#include <mapmem.h>
|
||||
#include <tpm-common.h>
|
||||
#include <tpm-v2.h>
|
||||
#include <env.h>
|
||||
#include <env_internal.h>
|
||||
#include "tpm-user-utils.h"
|
||||
#include "sec_library.h"
|
||||
|
||||
enum mboot_type {
|
||||
UBOOT_IMAGE = 0,
|
||||
KERNEL_IMAGE,
|
||||
PARTITIONS_STR,
|
||||
MBOOT_TYPE_MAX,
|
||||
};
|
||||
enum pcr_index {
|
||||
PCR_0 = 0,
|
||||
PCR_1,
|
||||
PCR_2,
|
||||
PCR_3,
|
||||
PCR_4,
|
||||
PCR_5,
|
||||
PCR_6,
|
||||
PCR_7,
|
||||
};
|
||||
static uint8_t image_digest[32] __attribute__((aligned(64))) = { 0 };
|
||||
|
||||
#define CHECK_RET_WITH_RET(x, ret) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
return ret; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static uint32_t hash_image_sha256(long image_addr, size_t size, void *digest, uint32_t *digest_len)
|
||||
{
|
||||
uint32_t ret;
|
||||
sc_sha_t sha;
|
||||
sc_sha_context_t ctx;
|
||||
|
||||
CHECK_RET_WITH_RET(ret = csi_sec_library_init(), ret);
|
||||
CHECK_RET_WITH_RET(ret = sc_sha_init(&sha, 0), ret);
|
||||
CHECK_RET_WITH_RET(ret = sc_sha_start(&sha, &ctx, SC_SHA_MODE_256), ret);
|
||||
CHECK_RET_WITH_RET(ret = sc_sha_trans_config(&sha, &ctx, SC_SHA_DMA_MODE), ret);
|
||||
CHECK_RET_WITH_RET(ret = sc_sha_update(&sha, &ctx, (void *)image_addr, size), ret);
|
||||
CHECK_RET_WITH_RET(ret = sc_sha_finish(&sha, &ctx, digest, digest_len), ret);
|
||||
|
||||
return SC_OK;
|
||||
}
|
||||
|
||||
static int do_measured_boot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
struct udevice *dev;
|
||||
struct tpm_chip_priv *priv;
|
||||
uint32_t index, type;
|
||||
uint32_t rc;
|
||||
int ret;
|
||||
long image_addr = 0;
|
||||
size_t image_size = 0;
|
||||
uint32_t image_digest_len = 0;
|
||||
char *partitions_str = NULL;
|
||||
|
||||
if (argc != 1)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
ret = get_tpm(&dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
tpm_init(dev); /* Initialization TPM2 chip */
|
||||
rc = tpm2_startup(dev, TPM2_SU_CLEAR); /* Startup TPM2 chip with mode TPM_ST_CLEAR*/
|
||||
if (rc)
|
||||
report_return_code(rc);
|
||||
|
||||
priv = dev_get_uclass_priv(dev);
|
||||
if (!priv)
|
||||
return -EINVAL;
|
||||
|
||||
for (type = UBOOT_IMAGE; type < MBOOT_TYPE_MAX; type++) {
|
||||
if (type == UBOOT_IMAGE) { /*U-BOOT Image */
|
||||
index = PCR_0;
|
||||
image_addr = CONFIG_SPL_TEXT_BASE;
|
||||
image_size = CONFIG_SPL_MAX_SIZE+CONFIG_SYS_MONITOR_LEN;
|
||||
} else if (type == KERNEL_IMAGE) { /* KERNEL Image */
|
||||
index = PCR_0;
|
||||
image_addr = 0x00200000;
|
||||
if (fs_set_blk_dev("mmc", "0:2", 2))
|
||||
return -EINVAL;
|
||||
if (fs_size("Image", &image_size) < 0)
|
||||
return -EINVAL;
|
||||
} else if (type == PARTITIONS_STR) { /* PARTITIONS */
|
||||
index = PCR_5;
|
||||
partitions_str = env_get("partitions");
|
||||
image_addr = (long)partitions_str;
|
||||
image_size = strlen(partitions_str);
|
||||
}
|
||||
|
||||
rc = hash_image_sha256(image_addr, image_size, image_digest, &image_digest_len);
|
||||
if (rc)
|
||||
return -EINVAL;
|
||||
|
||||
rc = tpm2_pcr_extend(dev, index, image_digest);
|
||||
if (rc)
|
||||
break;
|
||||
}
|
||||
|
||||
return report_return_code(rc);
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
measured_boot, CONFIG_SYS_MAXARGS, 1, do_measured_boot,
|
||||
"extend hash(u-boot), hash(kernel), hash(partitions str) to pcr0 and pcr5",
|
||||
""
|
||||
);
|
||||
36
cmd/mmc.c
36
cmd/mmc.c
@@ -574,6 +574,7 @@ static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag,
|
||||
}
|
||||
|
||||
extern volatile uint32_t DELAY_LANE;
|
||||
extern volatile int manual_set_delay ;
|
||||
static int do_mmc_set_delay_lane(cmd_tbl_t *cmdtp, int flag,
|
||||
int argc, char * const argv[])
|
||||
{
|
||||
@@ -587,17 +588,22 @@ static int do_mmc_set_delay_lane(cmd_tbl_t *cmdtp, int flag,
|
||||
mmc = find_mmc_device(curr_device);
|
||||
if (!mmc) {
|
||||
printf("no mmc device at slot %x\n", curr_device);
|
||||
return CMD_RET_FAILURE;
|
||||
goto RET_FAILURE;
|
||||
}
|
||||
|
||||
manual_set_delay = 1;
|
||||
if (0 != snps_mmc_init(mmc))
|
||||
return CMD_RET_FAILURE;
|
||||
goto RET_FAILURE;
|
||||
|
||||
mmc = init_mmc_device(curr_device, true);
|
||||
if (!mmc)
|
||||
return CMD_RET_FAILURE;
|
||||
|
||||
goto RET_FAILURE;
|
||||
|
||||
manual_set_delay = 0;
|
||||
return CMD_RET_SUCCESS;
|
||||
|
||||
RET_FAILURE:
|
||||
manual_set_delay = 0;
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
static int do_mmc_turning(cmd_tbl_t *cmdtp, int flag,
|
||||
@@ -605,6 +611,10 @@ static int do_mmc_turning(cmd_tbl_t *cmdtp, int flag,
|
||||
{
|
||||
struct mmc *mmc;
|
||||
int i = 0, n;
|
||||
int stop_on_ok = 1;
|
||||
if(argc > 1 && (!strncmp(argv[1],"cont",4))){
|
||||
stop_on_ok = 0;
|
||||
}
|
||||
for(i = 0; i <= 128; i++) {
|
||||
DELAY_LANE = i;
|
||||
printf("set DELAY_LANE = %d\n", DELAY_LANE);
|
||||
@@ -616,8 +626,10 @@ static int do_mmc_turning(cmd_tbl_t *cmdtp, int flag,
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
manual_set_delay = 1;
|
||||
if (0 != snps_mmc_init(mmc)) {
|
||||
printf("Error: mmc init error!\n");
|
||||
manual_set_delay = 0;
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
@@ -628,18 +640,21 @@ static int do_mmc_turning(cmd_tbl_t *cmdtp, int flag,
|
||||
|
||||
if (mmc_getwp(mmc) == 1) {
|
||||
printf("Error: card is write protected!\n");
|
||||
manual_set_delay = 0;
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
|
||||
n = blk_dwrite(mmc_get_blk_desc(mmc), 0, 1, 0);
|
||||
if (n == 1) {
|
||||
printf("blocks written: %s\n", "OK" );
|
||||
return CMD_RET_SUCCESS;
|
||||
manual_set_delay = 0;
|
||||
if(stop_on_ok)
|
||||
return CMD_RET_SUCCESS;
|
||||
} else {
|
||||
printf("written: %s\n", "error");
|
||||
}
|
||||
}
|
||||
|
||||
manual_set_delay = 0;
|
||||
if (i > 128) {
|
||||
return CMD_RET_FAILURE;
|
||||
}
|
||||
@@ -1239,9 +1254,10 @@ U_BOOT_CMD(
|
||||
#endif
|
||||
"mmc erase blk# cnt\n"
|
||||
"mmc rescan\n"
|
||||
"mmc set_delay # val\n"
|
||||
"mmc turning\n"
|
||||
"mmc memset addr # lenght\n"
|
||||
"mmc set_delay # val - set clk out delay mannaul,reinit host and rescan dev\n"
|
||||
"mmc turning [continue] - loop test for clk delay form 0 to 128, reinit host and rescan dev\n"
|
||||
" - without arg [continue] exit once init and write ok\n"
|
||||
"mmc memset addr # length - set mem addr 0xff with length '# length' \n"
|
||||
"mmc part - lists available partition on current mmc device\n"
|
||||
"mmc dev [dev] [part] - show or set current mmc device [partition]\n"
|
||||
"mmc list - lists available devices\n"
|
||||
|
||||
19
cmd/net.c
19
cmd/net.c
@@ -458,3 +458,22 @@ U_BOOT_CMD(
|
||||
);
|
||||
|
||||
#endif /* CONFIG_CMD_LINK_LOCAL */
|
||||
|
||||
/* moved from board_init_r sequence here to save normal boot time */
|
||||
static int do_eth_init(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||
char * const argv[])
|
||||
{
|
||||
puts("Net: ");
|
||||
eth_initialize();
|
||||
#if defined(CONFIG_RESET_PHY_R)
|
||||
debug("Reset Ethernet PHY\n");
|
||||
reset_phy();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_BOOT_CMD(
|
||||
eth, 6, 1, do_eth_init,
|
||||
"eth initialize",
|
||||
""
|
||||
);
|
||||
|
||||
@@ -962,6 +962,20 @@ config TPL_HASH
|
||||
and the algorithms it supports are defined in common/hash.c. See
|
||||
also CMD_HASH for command-line access.
|
||||
|
||||
config BOARD_RNG_SEED
|
||||
bool "Provide /chosen/rng-seed property to the linux kernel"
|
||||
help
|
||||
Selecting this option requires the board to define a
|
||||
board_rng_seed() function, which should return a buffer
|
||||
which will be used to populate the /chosen/rng-seed property
|
||||
in the device tree for the OS being booted.
|
||||
|
||||
It is up to the board code (and more generally the whole
|
||||
BSP) where and how to store (or generate) such a seed, how
|
||||
to ensure a given seed is only used once, how to create a
|
||||
new seed for use on subsequent boots, and whether or not the
|
||||
kernel should account any entropy from the given seed.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Update support"
|
||||
|
||||
@@ -14,6 +14,48 @@
|
||||
#include <tee.h>
|
||||
#include <tee/optee_ta_avb.h>
|
||||
|
||||
#ifdef CONFIG_AVB_ROLLBACK_ENABLE
|
||||
extern int sec_write_rollback_index(size_t rollback_index_slot, uint64_t rollback_index);
|
||||
extern int sec_read_rollback_index(size_t rollback_index_slot, uint64_t *out_rollback_index);
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_AVB_USE_OEM_KEY)
|
||||
static const unsigned char avb_root_oem_pub[520] = {
|
||||
0x00,0x00,0x08,0x00,0x11,0x70,0xEA,0xC9,0xC2,0xAD,0x66,0x2A,0x57,0x2A,0x89,0x68,
|
||||
0x8B,0x40,0x33,0xF2,0xEA,0x22,0xD7,0x3E,0x31,0x5F,0x9D,0xB8,0xD1,0x16,0x5C,0x22,
|
||||
0xC3,0xFE,0xE6,0x35,0x3F,0x96,0x6D,0xD8,0x1A,0x11,0xE9,0x53,0x90,0x88,0xA9,0xCE,
|
||||
0xA7,0x33,0xB2,0x16,0x60,0x18,0xBE,0x23,0xCC,0x5C,0xAB,0x29,0x0E,0x7B,0x35,0x16,
|
||||
0xB0,0x59,0x3A,0x2F,0x62,0xF1,0x9B,0x39,0x0A,0x21,0x00,0xFE,0x75,0xEB,0x00,0xDF,
|
||||
0x17,0xAF,0x44,0x11,0x42,0x4E,0x4C,0x7C,0xA6,0xDC,0xC5,0xAD,0xB3,0x7C,0xC3,0xB1,
|
||||
0x52,0xAD,0x0C,0xEF,0x73,0x69,0x7E,0xFC,0xF9,0x12,0xA7,0x5C,0x60,0x47,0xEF,0x8F,
|
||||
0xC7,0x9D,0xD9,0x62,0xF5,0x0E,0x62,0xBB,0x3E,0x80,0x23,0xFA,0x19,0x4C,0x0A,0xD6,
|
||||
0xE0,0xA7,0x0E,0x65,0xEA,0xD5,0xB8,0xA9,0xF2,0xA3,0xDA,0x18,0xBE,0x5D,0x4B,0x37,
|
||||
0x91,0xBA,0xDB,0x0D,0x50,0x7E,0xEE,0x52,0xDF,0x90,0xE6,0xFC,0x8F,0xB8,0x24,0x2A,
|
||||
0x2B,0xBE,0xA6,0xC9,0x5B,0x89,0x3E,0xE8,0x24,0xBD,0x6A,0x03,0x31,0x6C,0xFC,0x4A,
|
||||
0xBA,0x6B,0xEE,0x08,0xAE,0x33,0x6E,0xC0,0x64,0x87,0xC1,0x35,0x65,0x42,0x34,0xE5,
|
||||
0xF8,0x3B,0x82,0x36,0xE9,0xFA,0x23,0xD7,0x12,0xC5,0x7B,0x27,0x16,0xB0,0xC7,0x40,
|
||||
0x5A,0xA4,0x8A,0x56,0xA4,0x54,0x0F,0xD9,0xA7,0x25,0x25,0xE3,0x7F,0x72,0x6E,0x4B,
|
||||
0x63,0x1B,0x05,0xFE,0x4E,0x1F,0x1D,0x05,0xDD,0x91,0xA7,0xBF,0xA4,0x90,0xDA,0x7D,
|
||||
0x0F,0xB6,0xFC,0x5D,0x8E,0xFB,0xE2,0xF7,0x5F,0x76,0xFA,0xD5,0x12,0xEC,0x87,0xD6,
|
||||
0x07,0xA0,0xAC,0xB6,0xE6,0xBA,0xB0,0x87,0xBA,0x51,0xD7,0x6C,0x19,0xC0,0x2C,0xA5,
|
||||
0x2C,0x08,0x52,0x2A,0x63,0x18,0x10,0x94,0xEA,0x5C,0x13,0xBF,0x42,0x8E,0x12,0xB6,
|
||||
0x7D,0x34,0xD9,0x1C,0x42,0xBC,0xCE,0x44,0x8A,0x13,0x5B,0x93,0x6F,0x34,0x41,0xA1,
|
||||
0xA3,0xD3,0x2E,0xF4,0xD3,0x28,0xAD,0x8F,0x8B,0x89,0x9D,0x42,0x43,0xD6,0xBF,0xDE,
|
||||
0x9F,0xBD,0x32,0x06,0xE3,0x67,0xD3,0x14,0x2F,0x4C,0xE7,0x6B,0x9A,0xD9,0x04,0xFA,
|
||||
0x4B,0x46,0x88,0xE7,0x04,0xAA,0x56,0xFF,0xBF,0x89,0x1D,0xFD,0x32,0xDF,0x47,0xC0,
|
||||
0x34,0x0D,0x25,0x8C,0xF6,0xE1,0x5E,0xA9,0x3C,0x30,0x3A,0x53,0x0C,0xDB,0xAD,0x8E,
|
||||
0x01,0xCB,0x46,0xE0,0xF5,0x97,0x2D,0xB8,0xF8,0x29,0xC3,0x19,0x4C,0x05,0x8B,0x74,
|
||||
0xE0,0xA6,0x3B,0x3C,0x96,0x4F,0x91,0x74,0x62,0xAA,0x50,0x0F,0x11,0x30,0x59,0xAE,
|
||||
0x7A,0x80,0xD3,0xAC,0xB3,0xDB,0x24,0x3A,0x79,0xD4,0xDB,0x79,0x10,0x63,0x27,0xD0,
|
||||
0x6B,0xF9,0xA3,0xF4,0x27,0x24,0x89,0x0C,0xAC,0x31,0x15,0x08,0x10,0x59,0x08,0x2D,
|
||||
0x00,0x3D,0xD8,0xD6,0x3B,0x91,0xC8,0x55,0xCF,0x28,0x3A,0xFB,0xD7,0xF7,0xF7,0x9D,
|
||||
0x41,0xBD,0x3E,0xD1,0x77,0xA3,0xF6,0xFA,0x33,0x05,0x5A,0x36,0xCE,0xB9,0x02,0x12,
|
||||
0x10,0xEB,0xCA,0xA7,0x3C,0xC8,0x5D,0xCD,0x33,0xD9,0xFA,0x16,0xD4,0x52,0x12,0xB6,
|
||||
0x35,0xD5,0x84,0x53,0xC4,0x21,0xDC,0x72,0x2F,0xF9,0x1E,0x59,0x0A,0xCD,0x7D,0x89,
|
||||
0xD4,0xCF,0x8E,0x2E,0x09,0x36,0xF5,0x12,0x35,0x43,0x64,0x6C,0xD1,0x70,0xBF,0x67,
|
||||
0x3A,0x54,0x72,0x84,0xF3,0xF1,0x4A,0x6A
|
||||
};
|
||||
#else
|
||||
static const unsigned char avb_root_pub[1032] = {
|
||||
0x0, 0x0, 0x10, 0x0, 0x55, 0xd9, 0x4, 0xad, 0xd8, 0x4,
|
||||
0xaf, 0xe3, 0xd3, 0x84, 0x6c, 0x7e, 0xd, 0x89, 0x3d, 0xc2,
|
||||
@@ -120,7 +162,7 @@ static const unsigned char avb_root_pub[1032] = {
|
||||
0xe1, 0x74, 0xa1, 0xa3, 0x99, 0xa0, 0x85, 0x9e, 0xf1, 0xac,
|
||||
0xd8, 0x7e,
|
||||
};
|
||||
|
||||
#endif
|
||||
/**
|
||||
* ============================================================================
|
||||
* Boot states support (GREEN, YELLOW, ORANGE, RED) and dm_verity
|
||||
@@ -590,6 +632,19 @@ static AvbIOResult validate_vbmeta_public_key(AvbOps *ops,
|
||||
public_key_metadata_length,
|
||||
bool *out_key_is_trusted)
|
||||
{
|
||||
#if defined (CONFIG_AVB_USE_OEM_KEY)
|
||||
if (!public_key_length || !public_key_data || !out_key_is_trusted)
|
||||
return AVB_IO_RESULT_ERROR_IO;
|
||||
|
||||
*out_key_is_trusted = false;
|
||||
if (public_key_length != sizeof(avb_root_oem_pub))
|
||||
return AVB_IO_RESULT_ERROR_IO;
|
||||
|
||||
if (memcmp(avb_root_oem_pub, public_key_data, public_key_length) == 0)
|
||||
*out_key_is_trusted = true;
|
||||
|
||||
return AVB_IO_RESULT_OK;
|
||||
#else
|
||||
if (!public_key_length || !public_key_data || !out_key_is_trusted)
|
||||
return AVB_IO_RESULT_ERROR_IO;
|
||||
|
||||
@@ -601,6 +656,7 @@ static AvbIOResult validate_vbmeta_public_key(AvbOps *ops,
|
||||
*out_key_is_trusted = true;
|
||||
|
||||
return AVB_IO_RESULT_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_OPTEE_TA_AVB
|
||||
@@ -681,8 +737,15 @@ static AvbIOResult read_rollback_index(AvbOps *ops,
|
||||
size_t rollback_index_slot,
|
||||
u64 *out_rollback_index)
|
||||
{
|
||||
#ifdef CONFIG_AVB_ROLLBACK_ENABLE
|
||||
if (sec_read_rollback_index(rollback_index_slot, out_rollback_index) != 0) {
|
||||
return AVB_IO_RESULT_ERROR_IO;
|
||||
}
|
||||
|
||||
return AVB_IO_RESULT_OK;
|
||||
#else
|
||||
#ifndef CONFIG_OPTEE_TA_AVB
|
||||
/* For now we always return 0 as the stored rollback index. */
|
||||
/* For now we always return 0 as the stored rollback index. */
|
||||
printf("%s not supported yet\n", __func__);
|
||||
|
||||
if (out_rollback_index)
|
||||
@@ -708,8 +771,10 @@ static AvbIOResult read_rollback_index(AvbOps *ops,
|
||||
|
||||
*out_rollback_index = (u64)param[1].u.value.a << 32 |
|
||||
(u32)param[1].u.value.b;
|
||||
|
||||
return AVB_IO_RESULT_OK;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -727,6 +792,13 @@ static AvbIOResult write_rollback_index(AvbOps *ops,
|
||||
size_t rollback_index_slot,
|
||||
u64 rollback_index)
|
||||
{
|
||||
#ifdef CONFIG_AVB_ROLLBACK_ENABLE
|
||||
if (sec_write_rollback_index(rollback_index_slot, rollback_index) != 0) {
|
||||
return AVB_IO_RESULT_ERROR_IO;
|
||||
}
|
||||
|
||||
return AVB_IO_RESULT_OK;
|
||||
#else
|
||||
#ifndef CONFIG_OPTEE_TA_AVB
|
||||
/* For now this is a no-op. */
|
||||
printf("%s not supported yet\n", __func__);
|
||||
@@ -748,6 +820,7 @@ static AvbIOResult write_rollback_index(AvbOps *ops,
|
||||
return invoke_func(ops->user_data, TA_AVB_CMD_WRITE_ROLLBACK_INDEX,
|
||||
ARRAY_SIZE(param), param);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <abuf.h>
|
||||
#include <env.h>
|
||||
#include <mapmem.h>
|
||||
#include <stdio_dev.h>
|
||||
@@ -274,6 +275,7 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end)
|
||||
|
||||
int fdt_chosen(void *fdt)
|
||||
{
|
||||
struct abuf buf = {};
|
||||
int nodeoffset;
|
||||
int err;
|
||||
char *str; /* used to set string properties */
|
||||
@@ -289,6 +291,17 @@ int fdt_chosen(void *fdt)
|
||||
if (nodeoffset < 0)
|
||||
return nodeoffset;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BOARD_RNG_SEED) && !board_rng_seed(&buf)) {
|
||||
err = fdt_setprop(fdt, nodeoffset, "rng-seed",
|
||||
abuf_data(&buf), abuf_size(&buf));
|
||||
abuf_uninit(&buf);
|
||||
if (err < 0) {
|
||||
printf("WARNING: could not set rng-seed %s.\n",
|
||||
fdt_strerror(err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
str = env_get("bootargs");
|
||||
if (str) {
|
||||
err = fdt_setprop(fdt, nodeoffset, "bootargs", str,
|
||||
|
||||
@@ -416,7 +416,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
|
||||
* FDT blob
|
||||
*/
|
||||
debug("* fdt: raw FDT blob\n");
|
||||
printf("## Flattened Device Tree blob at %08lx\n",
|
||||
debug("## Flattened Device Tree blob at %08lx\n",
|
||||
(long)fdt_addr);
|
||||
}
|
||||
break;
|
||||
@@ -425,7 +425,7 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
|
||||
goto no_fdt;
|
||||
}
|
||||
|
||||
printf(" Booting using the fdt blob at %#08lx\n", fdt_addr);
|
||||
debug(" Booting using the fdt blob at %#08lx\n", fdt_addr);
|
||||
fdt_blob = map_sysmem(fdt_addr, 0);
|
||||
} else if (images->legacy_hdr_valid &&
|
||||
image_check_type(&images->legacy_hdr_os_copy,
|
||||
|
||||
@@ -71,7 +71,7 @@ static int splash_video_logo_load(void)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
memcpy((void *)bmp_load_addr, bmp_logo_bitmap,
|
||||
memcpy((void *)(u64)bmp_load_addr, bmp_logo_bitmap,
|
||||
ARRAY_SIZE(bmp_logo_bitmap));
|
||||
|
||||
return 0;
|
||||
|
||||
118
configs/light_a_val_android_defconfig
Normal file
118
configs/light_a_val_android_defconfig
Normal file
@@ -0,0 +1,118 @@
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_SINGLERANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=n
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="light-a-val"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A=y
|
||||
# CONFIG_LIGHT_SEC_UPGRADE=y
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_SPL_TEXT_BASE=0xffe0000800
|
||||
CONFIG_LIGHT_ANDROID_BOOT_IMAGE_VAL_A=y
|
||||
CONFIG_AVB_USE_OEM_KEY=y
|
||||
# CONFIG_AVB_ROLLBACK_ENABLE is not set
|
||||
CONFIG_AVB_HW_ENGINE_ENABLE=y
|
||||
CONFIG_ANDROID_BOOT_IMAGE=y
|
||||
CONFIG_LIBAVB=y
|
||||
CONFIG_AVB_VERIFY=y
|
||||
CONFIG_CMD_AVB=y
|
||||
CONFIG_CMD_BOOTANDROID=y
|
||||
CONFIG_ANDROID_AB=y
|
||||
CONFIG_CMD_AB_SELECT=y
|
||||
CONFIG_XBC=y
|
||||
CONFIG_BOARD_RNG_SEED=y
|
||||
@@ -21,17 +21,18 @@ CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_SINGLERANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_USB=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
@@ -76,6 +77,9 @@ CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_DM_USB=y
|
||||
CONFIG_USB_XHCI_HCD=y
|
||||
CONFIG_USB_XHCI_DWC3=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
@@ -83,7 +87,7 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
# CONFIG_LIGHT_BOOT_FORCE_SEQ is not set
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
@@ -103,3 +107,5 @@ CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
|
||||
@@ -18,6 +18,14 @@ CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_SINGLERANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
# CONFIG_TPM is not set
|
||||
# CONFIG_TPM_Z32H330TC_SPI is not set
|
||||
# CONFIG_TPM_V2 is not set
|
||||
# CONFIG_CMD_TPM_V2 is not set
|
||||
# CONFIG_CMD_TPM is not set
|
||||
# CONFIG_CMD_TPM_TEST is not set
|
||||
# CONFIG_CMD_MEASURED_BOOT is not set
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
@@ -28,7 +36,6 @@ CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
@@ -73,6 +80,9 @@ CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_DM_USB=y
|
||||
CONFIG_USB_XHCI_HCD=y
|
||||
CONFIG_USB_XHCI_DWC3=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
@@ -82,6 +92,7 @@ CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
CONFIG_LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A=y
|
||||
CONFIG_LIGHT_SEC_UPGRADE=y
|
||||
# CONFIG_LIGHT_BOOT_FORCE_SEQ is not set
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
@@ -89,6 +100,7 @@ CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_CMD_USB=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
@@ -101,3 +113,7 @@ CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
# CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION is not set
|
||||
# CONFIG_FASTBOOT_ECIES_AUTH is not set
|
||||
|
||||
120
configs/light_ant_ref_android_defconfig
Normal file
120
configs/light_ant_ref_android_defconfig
Normal file
@@ -0,0 +1,120 @@
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
CONFIG_TARGET_LIGHT_FM_C910_VAL_ANT_REF=y
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3200_SINGLERANK=y
|
||||
CONFIG_DDR_H32_MODE=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=n
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="light-ant-ref"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_UPGRADE is not set
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_SYS_TEXT_BASE=0x7b000000
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_SPL_TEXT_BASE=0xffe0000800
|
||||
CONFIG_LIGHT_ANDROID_BOOT_IMAGE_ANT_REF=y
|
||||
CONFIG_AVB_USE_OEM_KEY=y
|
||||
# CONFIG_AVB_ROLLBACK_ENABLE is not set
|
||||
CONFIG_AVB_HW_ENGINE_ENABLE=y
|
||||
CONFIG_ANDROID_BOOT_IMAGE=y
|
||||
CONFIG_LIBAVB=y
|
||||
CONFIG_AVB_VERIFY=y
|
||||
CONFIG_CMD_AVB=y
|
||||
CONFIG_CMD_BOOTANDROID=y
|
||||
CONFIG_ANDROID_AB=y
|
||||
CONFIG_CMD_AB_SELECT=y
|
||||
CONFIG_XBC=y
|
||||
CONFIG_BOARD_RNG_SEED=y
|
||||
@@ -20,6 +20,7 @@ CONFIG_DDR_LP4X_3200_SINGLERANK=y
|
||||
CONFIG_DDR_H32_MODE=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
@@ -82,7 +83,8 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_LIGHT_SEC_BOOT_WITH_VERIFY_ANT_REF=y
|
||||
CONFIG_LIGHT_SEC_UPGRADE=y
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
|
||||
@@ -20,6 +20,7 @@ CONFIG_DDR_LP4X_3200_SINGLERANK=y
|
||||
CONFIG_DDR_H32_MODE=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
|
||||
122
configs/light_b_product_android_defconfig
Normal file
122
configs/light_b_product_android_defconfig
Normal file
@@ -0,0 +1,122 @@
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
CONFIG_TARGET_LIGHT_FM_C910_VAL_B=y
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3200_SINGLERANK=y
|
||||
CONFIG_DDR_H32_MODE=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=n
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_CMD_TIME=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="light-b-product"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT_WITH_VERIFY_VAL_A=y
|
||||
# CONFIG_LIGHT_SEC_UPGRADE=y
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_SYS_TEXT_BASE=0x7b000000
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_SPL_TEXT_BASE=0xffe0000800
|
||||
CONFIG_LIGHT_ANDROID_BOOT_IMAGE_VAL_B=y
|
||||
CONFIG_AVB_USE_OEM_KEY=y
|
||||
# CONFIG_AVB_ROLLBACK_ENABLE is not set
|
||||
CONFIG_AVB_HW_ENGINE_ENABLE=y
|
||||
CONFIG_ANDROID_BOOT_IMAGE=y
|
||||
CONFIG_LIBAVB=y
|
||||
CONFIG_AVB_VERIFY=y
|
||||
CONFIG_CMD_AVB=y
|
||||
CONFIG_CMD_BOOTANDROID=y
|
||||
CONFIG_ANDROID_AB=y
|
||||
CONFIG_CMD_AB_SELECT=y
|
||||
CONFIG_XBC=y
|
||||
CONFIG_BOARD_RNG_SEED=y
|
||||
@@ -20,6 +20,7 @@ CONFIG_DDR_LP4X_3200_SINGLERANK=y
|
||||
CONFIG_DDR_H32_MODE=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
@@ -104,3 +105,5 @@ CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
|
||||
@@ -20,6 +20,7 @@ CONFIG_DDR_LP4X_3200_SINGLERANK=y
|
||||
CONFIG_DDR_H32_MODE=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
@@ -104,3 +105,7 @@ CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
# CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION is not set
|
||||
# CONFIG_FASTBOOT_ECIES_AUTH is not set
|
||||
|
||||
118
configs/light_beagle_android_defconfig
Normal file
118
configs/light_beagle_android_defconfig
Normal file
@@ -0,0 +1,118 @@
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
CONFIG_TARGET_LIGHT_FM_C910_BEAGLE=y
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_SINGLERANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=n
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="light-a-val"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_LIGHT_ANDROID_BOOT_IMAGE_VAL_BEAGLE=y
|
||||
CONFIG_AVB_USE_OEM_KEY=y
|
||||
# CONFIG_AVB_ROLLBACK_ENABLE is not set
|
||||
CONFIG_AVB_HW_ENGINE_ENABLE=y
|
||||
CONFIG_ANDROID_BOOT_IMAGE=y
|
||||
CONFIG_LIBAVB=y
|
||||
CONFIG_AVB_VERIFY=y
|
||||
CONFIG_CMD_AVB=y
|
||||
CONFIG_CMD_BOOTANDROID=y
|
||||
CONFIG_ANDROID_AB=y
|
||||
CONFIG_CMD_AB_SELECT=y
|
||||
CONFIG_XBC=y
|
||||
CONFIG_BOARD_RNG_SEED=y
|
||||
CONFIG_SPL_TEXT_BASE=0xffe0000800
|
||||
118
configs/light_lpi4a_android_defconfig
Normal file
118
configs/light_lpi4a_android_defconfig
Normal file
@@ -0,0 +1,118 @@
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
CONFIG_TARGET_LIGHT_FM_C910_LPI4A=y
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_DUALRANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="light-lpi4a"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_JD9365DA=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_SPL_TEXT_BASE=0xffe0000800
|
||||
CONFIG_LIGHT_ANDROID_BOOT_IMAGE_VAL_LPI4A=y
|
||||
CONFIG_AVB_USE_OEM_KEY=y
|
||||
# CONFIG_AVB_ROLLBACK_ENABLE is not set
|
||||
CONFIG_AVB_HW_ENGINE_ENABLE=y
|
||||
CONFIG_ANDROID_BOOT_IMAGE=y
|
||||
CONFIG_LIBAVB=y
|
||||
CONFIG_AVB_VERIFY=y
|
||||
CONFIG_CMD_AVB=y
|
||||
CONFIG_CMD_BOOTANDROID=y
|
||||
CONFIG_ANDROID_AB=y
|
||||
CONFIG_CMD_AB_SELECT=y
|
||||
CONFIG_XBC=y
|
||||
CONFIG_BOARD_RNG_SEED=y
|
||||
@@ -22,6 +22,7 @@ CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_DUALRANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
@@ -32,7 +33,6 @@ CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
@@ -77,6 +77,9 @@ CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_DM_USB=y
|
||||
CONFIG_USB_XHCI_HCD=y
|
||||
CONFIG_USB_XHCI_DWC3=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
@@ -92,10 +95,13 @@ CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_CMD_USB=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=n
|
||||
CONFIG_VIDEO_LCD_JD9365DA=y
|
||||
CONFIG_VIDEO_LCD_CUSTOM_LOGO=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
@@ -104,3 +110,6 @@ CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
|
||||
|
||||
117
configs/light_lpi4a_sec_defconfig
Normal file
117
configs/light_lpi4a_sec_defconfig
Normal file
@@ -0,0 +1,117 @@
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
CONFIG_TARGET_LIGHT_FM_C910_LPI4A=y
|
||||
# CONFIG_THEAD_PLIC is not set
|
||||
# CONFIG_THEAD_LIGHT_TIMER is not set
|
||||
# CONFIG_THEAD_LIGHT_DIGITAL_SENSOR is not set
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_DUALRANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="light-lpi4a"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_DM_USB=y
|
||||
CONFIG_USB_XHCI_HCD=y
|
||||
CONFIG_USB_XHCI_DWC3=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
CONFIG_LIGHT_SEC_BOOT_WITH_VERIFY_LPI4A=y
|
||||
CONFIG_LIGHT_SEC_UPGRADE=y
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_CMD_USB=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=n
|
||||
CONFIG_VIDEO_LCD_JD9365DA=y
|
||||
CONFIG_VIDEO_LCD_CUSTOM_LOGO=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
# CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION is not set
|
||||
# CONFIG_FASTBOOT_ECIES_AUTH is not set
|
||||
130
configs/light_rvbook_defconfig
Normal file
130
configs/light_rvbook_defconfig
Normal file
@@ -0,0 +1,130 @@
|
||||
CONFIG_RV_BOOK=y
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
CONFIG_TARGET_LIGHT_FM_C910_RVBOOK=y
|
||||
# CONFIG_THEAD_PLIC is not set
|
||||
# CONFIG_THEAD_LIGHT_TIMER is not set
|
||||
# CONFIG_THEAD_LIGHT_DIGITAL_SENSOR is not set
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_DUALRANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="th1520-rvbook"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
# CONFIG_LIGHT_SEC_BOOT is not set
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=y
|
||||
CONFIG_VIDEO_LCD_CUSTOM_LOGO=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_TPM=y
|
||||
CONFIG_TPM_V2=y
|
||||
CONFIG_TPM_Z32H330TC_SPI=y
|
||||
CONFIG_CMD_TPM=y
|
||||
CONFIG_CMD_TPM_V2=y
|
||||
CONFIG_CMD_TPM_TEST=y
|
||||
CONFIG_DM_CHARGE_DISPLAY=y
|
||||
CONFIG_CHARGE_ANIMATION=y
|
||||
CONFIG_DM_FUEL_GAUGE=y
|
||||
CONFIG_POWER_FG_CW201X=y
|
||||
CONFIG_CHARGER_BQ25700=y
|
||||
CONFIG_LED=y
|
||||
CONFIG_LED_GPIO=y
|
||||
CONFIG_DM_MCU=y
|
||||
CONFIG_MCU_HC32fX=y
|
||||
CONFIG_DM_POWER_DELIVERY=y
|
||||
CONFIG_TYPEC_TCPM=y
|
||||
CONFIG_TYPEC_TCPCI=y
|
||||
CONFIG_TYPEC_HUSB311=y
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
132
configs/light_rvbook_sec_defconfig
Normal file
132
configs/light_rvbook_sec_defconfig
Normal file
@@ -0,0 +1,132 @@
|
||||
CONFIG_RV_BOOK=y
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_SPL_MMC_SUPPORT=y
|
||||
CONFIG_ENV_SIZE=0x20000
|
||||
CONFIG_ENV_OFFSET=0xe0000
|
||||
CONFIG_NR_DRAM_BANKS=8
|
||||
CONFIG_SPL=y
|
||||
CONFIG_SMP=y
|
||||
CONFIG_TARGET_LIGHT_C910=y
|
||||
# CONFIG_THEAD_PLIC is not set
|
||||
# CONFIG_THEAD_LIGHT_TIMER is not set
|
||||
# CONFIG_THEAD_LIGHT_DIGITAL_SENSOR is not set
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_BUILD_TARGET="u-boot-with-spl.bin"
|
||||
CONFIG_DISPLAY_CPUINFO=y
|
||||
CONFIG_DISPLAY_BOARDINFO=y
|
||||
# CONFIG_SPL_LEGACY_IMAGE_SUPPORT is not set
|
||||
CONFIG_SPL_RAM_SUPPORT=y
|
||||
CONFIG_SPL_RAM_DEVICE=y
|
||||
CONFIG_SYS_PROMPT="C910 Light# "
|
||||
CONFIG_DDR_LP4X_3733_DUALRANK=y
|
||||
# CONFIG_DDR_LP4_3733_DUALRANK is not set
|
||||
CONFIG_DDR_BOARD_CONFIG=y
|
||||
CONFIG_FIXUP_MEMORY_REGION=y
|
||||
CONFIG_CMD_BOOT_SLAVE=y
|
||||
CONFIG_CMD_ERASEENV=y
|
||||
CONFIG_CMD_GPT=y
|
||||
CONFIG_CMD_MTD=y
|
||||
CONFIG_CMD_EXT4_WRITE=y
|
||||
CONFIG_CMD_SPI=y
|
||||
CONFIG_CMD_I2C=y
|
||||
CONFIG_CMD_MEMTEST=y
|
||||
CONFIG_DDR_SCAN=y
|
||||
CONFIG_DDR_PRBS_TEST=n
|
||||
# CONFIG_DOS_PARTITION is not set
|
||||
# CONFIG_ISO_PARTITION is not set
|
||||
CONFIG_PARTITION_TYPE_GUID=y
|
||||
CONFIG_OF_EMBED=y
|
||||
CONFIG_DEFAULT_DEVICE_TREE="th1520-rvbook"
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
|
||||
CONFIG_SPL_CLK=y
|
||||
CONFIG_USB_FUNCTION_FASTBOOT=y
|
||||
CONFIG_UDP_FUNCTION_FASTBOOT=y
|
||||
CONFIG_FASTBOOT_BUF_ADDR=0x10000000
|
||||
CONFIG_FASTBOOT_FLASH=y
|
||||
CONFIG_FASTBOOT_FLASH_MMC_DEV=0
|
||||
CONFIG_FASTBOOT_CMD_OEM_FORMAT=y
|
||||
CONFIG_DM_GPIO=y
|
||||
CONFIG_DM_I2C=y
|
||||
CONFIG_SYS_I2C_DW=y
|
||||
CONFIG_DWAPB_GPIO=y
|
||||
# CONFIG_MMC_SPI is not set
|
||||
CONFIG_MMC_VERBOSE=y
|
||||
CONFIG_SUPPORT_EMMC_BOOT=y
|
||||
CONFIG_MMC_IO_VOLTAGE=y
|
||||
CONFIG_MMC_UHS_SUPPORT=y
|
||||
CONFIG_MMC_HS400_SUPPORT=y
|
||||
CONFIG_MMC_DW=y
|
||||
CONFIG_MMC_DW_SNPS=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_SNPS=y
|
||||
CONFIG_MMC_SDHCI_SDMA=y
|
||||
CONFIG_CMD_MMC=y
|
||||
CONFIG_CMD_MMC_RPMB=y
|
||||
CONFIG_SUPPORT_EMMC_RPMB=y
|
||||
CONFIG_DM_MTD=y
|
||||
CONFIG_MTD_SPI_NAND=y
|
||||
CONFIG_SPI_FLASH_WINBOND=y
|
||||
CONFIG_ETH_DESIGNWARE=y
|
||||
CONFIG_PHY_REALTEK=y
|
||||
CONFIG_RTL8211E_PINE64_GIGABIT_FIX=y
|
||||
CONFIG_RTL8211X_PHY_FORCE_MASTER=y
|
||||
CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON=y
|
||||
CONFIG_SYS_NS16550=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_DESIGNWARE_SPI=y
|
||||
CONFIG_DESIGNWARE_QSPI=y
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_DWC3=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_GADGET_MANUFACTURER="U-Boot-THEAD"
|
||||
CONFIG_USB_GADGET_VENDOR_NUM=0x1234
|
||||
CONFIG_USB_GADGET_PRODUCT_NUM=0x8888
|
||||
# CONFIG_SPL_USE_TINY_PRINTF is not set
|
||||
# CONFIG_EFI_LOADER is not set
|
||||
|
||||
CONFIG_LIGHT_SEC_BOOT_WITH_VERIFY_RVBOOK=y
|
||||
CONFIG_LIGHT_SEC_UPGRADE=y
|
||||
CONFIG_BOARD_LATE_INIT=y
|
||||
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
|
||||
CONFIG_DM_VIDEO=y
|
||||
CONFIG_PHY=y
|
||||
CONFIG_REGMAP=y
|
||||
CONFIG_SYSCON=y
|
||||
CONFIG_CMD_BMP=y
|
||||
CONFIG_VIDEO_BRIDGE=y
|
||||
CONFIG_DM_PCA953X=y
|
||||
CONFIG_VIDEO_VS_DPU=y
|
||||
CONFIG_VIDEO_LCD_ILITEK_ILI9881C=y
|
||||
CONFIG_VIDEO_LCD_CUSTOM_LOGO=y
|
||||
CONFIG_VIDEO_DW_DSI_LIGHT=y
|
||||
CONFIG_VIDEO_DW_DPHY=y
|
||||
CONFIG_VIDEO_DW_DSI_HOST=y
|
||||
CONFIG_SYS_WHITE_ON_BLACK=y
|
||||
CONFIG_PMIC_VOL_INIT=y
|
||||
CONFIG_DDR_REGU_0V6=600000
|
||||
CONFIG_DDR_REGU_0V8=800000
|
||||
CONFIG_DDR_REGU_1V1=1100000
|
||||
CONFIG_TPM=y
|
||||
CONFIG_TPM_V2=y
|
||||
CONFIG_TPM_Z32H330TC_SPI=y
|
||||
CONFIG_CMD_TPM=y
|
||||
CONFIG_CMD_TPM_V2=y
|
||||
CONFIG_CMD_TPM_TEST=y
|
||||
CONFIG_DM_CHARGE_DISPLAY=y
|
||||
CONFIG_CHARGE_ANIMATION=y
|
||||
CONFIG_DM_FUEL_GAUGE=y
|
||||
CONFIG_POWER_FG_CW201X=y
|
||||
CONFIG_CHARGER_BQ25700=y
|
||||
CONFIG_LED=y
|
||||
CONFIG_LED_GPIO=y
|
||||
CONFIG_DM_MCU=y
|
||||
CONFIG_MCU_HC32fX=y
|
||||
CONFIG_DM_POWER_DELIVERY=y
|
||||
CONFIG_TYPEC_TCPM=y
|
||||
CONFIG_TYPEC_TCPCI=y
|
||||
CONFIG_TYPEC_HUSB311=y
|
||||
CONFIG_MISC=y
|
||||
CONFIG_LIGHT_AON_CONF=y
|
||||
CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION=y
|
||||
@@ -130,6 +130,8 @@ source "drivers/w1-eeprom/Kconfig"
|
||||
|
||||
source "drivers/watchdog/Kconfig"
|
||||
|
||||
source "drivers/mcu/Kconfig"
|
||||
|
||||
config PHYS_TO_BUS
|
||||
bool "Custom physical to bus address mapping"
|
||||
help
|
||||
|
||||
@@ -85,6 +85,9 @@ obj-y += misc/
|
||||
obj-$(CONFIG_MMC) += mmc/
|
||||
obj-$(CONFIG_NVME) += nvme/
|
||||
obj-$(CONFIG_PCI_ENDPOINT) += pci_endpoint/
|
||||
ifdef CONFIG_RV_BOOK
|
||||
obj-$(CONFIG_DM_POWER_DELIVERY) += power/power_delivery/
|
||||
endif
|
||||
obj-y += dfu/
|
||||
obj-$(CONFIG_PCH) += pch/
|
||||
obj-y += phy/allwinner/
|
||||
|
||||
@@ -2,7 +2,7 @@ menu "Fastboot support"
|
||||
|
||||
config FASTBOOT
|
||||
bool
|
||||
imply ANDROID_BOOT_IMAGE
|
||||
# imply ANDROID_BOOT_IMAGE
|
||||
imply CMD_FASTBOOT
|
||||
|
||||
config USB_FUNCTION_FASTBOOT
|
||||
@@ -135,6 +135,14 @@ config FASTBOOT_CMD_OEM_FORMAT
|
||||
relies on the env variable partitions to contain the list of
|
||||
partitions as required by the gpt command.
|
||||
|
||||
config FASTBOOT_CMD_OEM_NV_OPERATION
|
||||
bool "Enable the 'oem nv get/set' command"
|
||||
help
|
||||
Add support for the "oem get/set" command from a client.
|
||||
|
||||
config FASTBOOT_ECIES_AUTH
|
||||
bool "Enabled ecies fastboot auth"
|
||||
|
||||
endif # FASTBOOT
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -3,5 +3,7 @@
|
||||
obj-y += fb_common.o
|
||||
obj-y += fb_getvar.o
|
||||
obj-y += fb_command.o
|
||||
obj-$(CONFIG_FASTBOOT_ECIES_AUTH) += fb_ecies.o
|
||||
obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fb_mmc.o
|
||||
obj-$(CONFIG_FASTBOOT_FLASH_NAND) += fb_nand.o
|
||||
obj-$(CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION) += fb_nv_operation.o
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#define BLOCK_SIZE 512
|
||||
#define BOARD_ID_OFFSET 0x26
|
||||
|
||||
/**
|
||||
* image_size - final fastboot image size
|
||||
@@ -42,6 +43,20 @@ static void reboot_bootloader(char *, char *);
|
||||
static void oem_format(char *, char *);
|
||||
#endif
|
||||
static void oem_command(char *, char *);
|
||||
int image_have_head(unsigned long img_src_addr);
|
||||
|
||||
#if CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION
|
||||
void oem_nv_get_proccess(char *cmd_parameter, char *response);
|
||||
void oem_nv_set_proccess(char *cmd_parameter, char *response);
|
||||
void oem_nv_factory_recovery_process(char *cmd_parameter, char *response);
|
||||
static void oem_nv_get(char *cmd_parameter, char *response);
|
||||
static void oem_nv_set(char *cmd_parameter, char *response);
|
||||
static void oem_fcty(char *cmd_parameter, char *response);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FASTBOOT_ECIES_AUTH
|
||||
int ecies_process_data(uint8_t * data, int data_size,char *response);
|
||||
#endif
|
||||
|
||||
static const struct {
|
||||
const char *command;
|
||||
@@ -95,6 +110,20 @@ static const struct {
|
||||
.command = "oem command",
|
||||
.dispatch = oem_command,
|
||||
},
|
||||
#if CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION
|
||||
[FASTBOOT_COMMAND_OEM_NV_GET] = {
|
||||
.command = "oem nv get",
|
||||
.dispatch = oem_nv_get,
|
||||
},
|
||||
[FASTBOOT_COMMAND_OEM_NV_SET] = {
|
||||
.command = "oem nv set",
|
||||
.dispatch = oem_nv_set,
|
||||
},
|
||||
[FASTBOOT_COMMAND_OEM_FCTY] = {
|
||||
.command = "oem fcty",
|
||||
.dispatch = oem_fcty,
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -263,7 +292,119 @@ void fastboot_data_complete(char *response)
|
||||
fastboot_bytes_received = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* check_image_board_id() - check if board id in image matched with board id in env
|
||||
*
|
||||
* @image_data: Image data
|
||||
*
|
||||
* 0 if success otherwise failed
|
||||
*/
|
||||
int check_image_board_id(uint8_t *image_data)
|
||||
{
|
||||
char *env_board_id = NULL;
|
||||
char board_id[3] = {0};
|
||||
env_board_id = env_get("board#");
|
||||
/*if current board id is null or image has no header,skip check*/
|
||||
if (env_board_id == NULL || env_board_id[0] == 0 || image_have_head((unsigned long)image_data) == 0) {
|
||||
return 0;
|
||||
}
|
||||
memcpy(board_id, image_data + BOARD_ID_OFFSET,sizeof(uint16_t));
|
||||
/*if image board id is null,skip check*/
|
||||
if (*(uint16_t*)board_id == 0) {
|
||||
return 0;
|
||||
}
|
||||
/*check if current board id match with board id in image*/
|
||||
if (strncmp(env_board_id, board_id, sizeof(board_id)) != 0) {
|
||||
printf("U-BOOT image download via fastboot is interrupted due to the U-BOOT for board %s does not work in the board %s\r\n",board_id,env_board_id);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hibernate_image_cleaned_flag = 0;
|
||||
void clean_hibernate_image_header(char *response)
|
||||
{
|
||||
struct blk_desc *dev_desc;
|
||||
disk_partition_t info;
|
||||
if(0x03 == hibernate_image_cleaned_flag) //already erased all
|
||||
{
|
||||
return;
|
||||
}
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
|
||||
fastboot_fail("invalid mmc device", response);
|
||||
return;
|
||||
}
|
||||
char * buf = memalign(CONFIG_SYS_CACHELINE_SIZE,4096);
|
||||
if(!buf) {
|
||||
printf(" mem alloc for hibernate partition header failed!\n");
|
||||
return;
|
||||
}
|
||||
/* if fastresume partition exists, earse the old image header */
|
||||
if(part_get_info_by_name(dev_desc, "fastresume", &info)) {
|
||||
printf(" find fastresume partition , erase the header:\n");
|
||||
memset(buf,0xff,4096);
|
||||
if(blk_dwrite(dev_desc, info.start, 4096/info.blksz, buf) != 4096/info.blksz)
|
||||
{
|
||||
printf(" fastresume header write failed!\n");
|
||||
hibernate_image_cleaned_flag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
hibernate_image_cleaned_flag |= 0x1;
|
||||
}
|
||||
}
|
||||
/* if swap partition exists, earse the old image header */
|
||||
if(part_get_info_by_name(dev_desc, "swap", &info)) {
|
||||
printf(" find swap partition , erase the header:\n");
|
||||
memset(buf,0xff,4096);
|
||||
if(blk_dwrite(dev_desc, info.start, 4096/info.blksz, buf) != 4096/info.blksz)
|
||||
{
|
||||
printf(" swap header write failed!\n");
|
||||
hibernate_image_cleaned_flag = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
hibernate_image_cleaned_flag |= 0x2;
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
|
||||
void fasboot_uboot_write_process(void *buf, char *response)
|
||||
{
|
||||
char cmdbuf[32];
|
||||
u32 block_cnt;
|
||||
struct blk_desc *dev_desc;
|
||||
int ret = 0;
|
||||
disk_partition_t info;
|
||||
|
||||
ret = check_image_board_id(buf);
|
||||
if (ret != 0) {
|
||||
fastboot_fail("U-BOOT image does not match the type of BOARD", response);
|
||||
return;
|
||||
}
|
||||
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
|
||||
fastboot_fail("invalid mmc device", response);
|
||||
return;
|
||||
}
|
||||
|
||||
run_command("mmc partconf 0 1 0 1", 0);
|
||||
|
||||
block_cnt = image_size / BLOCK_SIZE;
|
||||
if (image_size % BLOCK_SIZE) {
|
||||
block_cnt = block_cnt +1;
|
||||
}
|
||||
|
||||
sprintf(cmdbuf, "mmc write 0x%p 0 %x", buf, block_cnt);
|
||||
|
||||
run_command(cmdbuf, 0);
|
||||
run_command("mmc partconf 0 1 0 0", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* flash() - write the downloaded image to the indicated partition.
|
||||
*
|
||||
@@ -277,28 +418,10 @@ static void flash(char *cmd_parameter, char *response)
|
||||
{
|
||||
#ifdef THEAD_LIGHT_FASTBOOT
|
||||
char cmdbuf[32];
|
||||
u32 block_cnt;
|
||||
struct blk_desc *dev_desc;
|
||||
|
||||
disk_partition_t info;
|
||||
if (strcmp(cmd_parameter, "uboot") == 0) {
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
|
||||
fastboot_fail("invalid mmc device", response);
|
||||
return;
|
||||
}
|
||||
|
||||
run_command("mmc partconf 0 1 0 1", 0);
|
||||
|
||||
block_cnt = image_size / BLOCK_SIZE;
|
||||
if (image_size % BLOCK_SIZE) {
|
||||
block_cnt = block_cnt +1;
|
||||
}
|
||||
|
||||
sprintf(cmdbuf, "mmc write 0x%p 0 %x", fastboot_buf_addr, block_cnt);
|
||||
|
||||
run_command(cmdbuf, 0);
|
||||
run_command("mmc partconf 0 1 0 0", 0);
|
||||
|
||||
fasboot_uboot_write_process(fastboot_buf_addr, response);
|
||||
} else if ((strcmp(cmd_parameter, "fw") == 0)) {
|
||||
memcpy((void *)LIGHT_FW_ADDR, fastboot_buf_addr, image_size);
|
||||
} else if ((strcmp(cmd_parameter, "uImage") == 0)) {
|
||||
@@ -313,7 +436,42 @@ static void flash(char *cmd_parameter, char *response)
|
||||
memcpy((void *)LIGHT_TF_FW_ADDR, fastboot_buf_addr, image_size);
|
||||
} else if ((strcmp(cmd_parameter, TEE_PART_NAME) == 0)) {
|
||||
memcpy((void *)LIGHT_TEE_FW_ADDR, fastboot_buf_addr, image_size);
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_RV_BOOK
|
||||
else if ((strcmp(cmd_parameter, "boot") == 0)) {
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
|
||||
fastboot_fail("invalid mmc device", response);
|
||||
return;
|
||||
}
|
||||
/* if fastresume partition exists, earse the old image header */
|
||||
if(part_get_info_by_name(dev_desc, "fastresume", &info)) {
|
||||
printf(" find fastresume partition , erase the header:\n");
|
||||
char * buf = memalign(CONFIG_SYS_CACHELINE_SIZE,4096);
|
||||
if(!buf) {
|
||||
printf(" fastresume partition header mem alloc failed\n");
|
||||
return;
|
||||
}
|
||||
memset(buf,0xff,4096);
|
||||
blk_dwrite(dev_desc, info.start, 4096/info.blksz, buf);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FASTBOOT_ECIES_AUTH
|
||||
else if ((strcmp(cmd_parameter, "ecies") == 0)) {
|
||||
ecies_process_data(fastboot_buf_addr, image_size,response);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
//If version is updated, hibernate image may not compatible with current,erase it.
|
||||
if ((strcmp(cmd_parameter, "boot") == 0)
|
||||
|| (strcmp(cmd_parameter, "uboot") == 0)
|
||||
|| (strcmp(cmd_parameter, "root") == 0)) {
|
||||
|
||||
clean_hibernate_image_header(response);
|
||||
}
|
||||
|
||||
if(strcmp(cmd_parameter, "uboot") == 0 || (strcmp(cmd_parameter, "fw") == 0) ||
|
||||
(strcmp(cmd_parameter, "uImage") == 0) || (strcmp(cmd_parameter, "dtb") == 0) ||
|
||||
@@ -324,38 +482,7 @@ static void flash(char *cmd_parameter, char *response)
|
||||
#endif
|
||||
|
||||
#if CONFIG_IS_ENABLED(LIGHT_SEC_UPGRADE)
|
||||
if(strcmp(cmd_parameter, TF_IMG_UPD_NAME) == 0) {
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
/* tee/tf/uboot image must be written into stash partition */
|
||||
sprintf(cmdbuf, "%s", STASH_PART_NAME);
|
||||
fastboot_mmc_flash_write(cmdbuf, fastboot_buf_addr, image_size, response);
|
||||
#endif
|
||||
/* Send ACK to host */
|
||||
fastboot_okay(NULL, response);
|
||||
|
||||
/* set secure upgrade flag to indicate it is TF image upgrade*/
|
||||
sprintf(cmdbuf,"env set sec_upgrade_mode 0x%x", TF_SEC_UPGRADE_FLAG);
|
||||
run_command(cmdbuf, 0);
|
||||
run_command("saveenv", 0);
|
||||
run_command("reset", 0);
|
||||
return;
|
||||
} else if (strcmp(cmd_parameter, TEE_IMG_UPD_NAME) == 0) {
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
/* tee/tf/uboot image must be written into stash partition */
|
||||
sprintf(cmdbuf, "%s", STASH_PART_NAME);
|
||||
fastboot_mmc_flash_write(cmdbuf, fastboot_buf_addr, image_size, response);
|
||||
#endif
|
||||
|
||||
/* Send ACK to host */
|
||||
fastboot_okay(NULL, response);
|
||||
|
||||
/* set secure upgrade flag to indicate it is TEE image upgrade*/
|
||||
sprintf(cmdbuf,"env set sec_upgrade_mode 0x%x", TEE_SEC_UPGRADE_FLAG);
|
||||
run_command(cmdbuf, 0);
|
||||
run_command("saveenv", 0);
|
||||
run_command("reset", 0);
|
||||
return;
|
||||
} else if (strcmp(cmd_parameter, UBOOT_IMG_UPD_NAME) == 0) {
|
||||
if (strcmp(cmd_parameter, UBOOT_IMG_UPD_NAME) == 0) {
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
|
||||
env_set_hex("ubootupdsize", image_size);
|
||||
@@ -366,14 +493,14 @@ static void flash(char *cmd_parameter, char *response)
|
||||
|
||||
/* Send ACK to host */
|
||||
fastboot_okay(NULL, response);
|
||||
|
||||
|
||||
/* set secure upgrade flag to indicate it is UBOOT image upgrade*/
|
||||
sprintf(cmdbuf,"env set sec_upgrade_mode 0x%x", UBOOT_SEC_UPGRADE_FLAG);
|
||||
run_command(cmdbuf, 0);
|
||||
run_command("saveenv", 0);
|
||||
run_command("reset", 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
@@ -458,3 +585,38 @@ static void oem_command(char *cmd_parameter, char *response)
|
||||
else
|
||||
fastboot_okay(NULL, response);
|
||||
}
|
||||
|
||||
#if CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION
|
||||
/**
|
||||
* oem_nv_get() - Execute the OEM NV GET command
|
||||
*
|
||||
* @cmd_parameter: Pointer to command parameter
|
||||
* @response: Pointer to fastboot response buffer
|
||||
*/
|
||||
static void oem_nv_get(char *cmd_parameter, char *response)
|
||||
{
|
||||
oem_nv_get_proccess(cmd_parameter,response);
|
||||
}
|
||||
|
||||
/**
|
||||
* oem_nv_set() - Execute the OEM NV Set command
|
||||
*
|
||||
* @cmd_parameter: Pointer to command parameter
|
||||
* @response: Pointer to fastboot response buffer
|
||||
*/
|
||||
static void oem_nv_set(char *cmd_parameter, char *response)
|
||||
{
|
||||
oem_nv_set_proccess(cmd_parameter,response);
|
||||
}
|
||||
|
||||
/**
|
||||
* oem_fcty() - Execute the OEM fcty command
|
||||
*
|
||||
* @cmd_parameter: Pointer to command parameter
|
||||
* @response: Pointer to fastboot response buffer
|
||||
*/
|
||||
static void oem_fcty(char *cmd_parameter, char *response)
|
||||
{
|
||||
oem_nv_factory_recovery_process(cmd_parameter,response);
|
||||
}
|
||||
#endif
|
||||
@@ -118,7 +118,11 @@ void fastboot_boot(void)
|
||||
#ifdef THEAD_LIGHT_FASTBOOT
|
||||
char cmdbuf[32];
|
||||
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
sprintf(cmdbuf, "run bootcmd");
|
||||
#else
|
||||
sprintf(cmdbuf, "bootslave; run set_bootargs; booti %s - %s", LIGHT_KERNEL_ADDR_CMD, LIGHT_DTB_ADDR_CMD);
|
||||
#endif
|
||||
printf("fastboot bootcmd %s\n", cmdbuf);
|
||||
run_command(cmdbuf, 0);
|
||||
|
||||
|
||||
198
drivers/fastboot/fb_ecies.c
Normal file
198
drivers/fastboot/fb_ecies.c
Normal file
@@ -0,0 +1,198 @@
|
||||
#include <sec_ecies_session.h>
|
||||
#include <common.h>
|
||||
#include <command.h>
|
||||
#include <env.h>
|
||||
#include <fastboot.h>
|
||||
#include <fastboot-internal.h>
|
||||
#include <fb_mmc.h>
|
||||
#include <fb_nand.h>
|
||||
#include <part.h>
|
||||
#include <stdlib.h>
|
||||
#include <csi_sec_img_verify.h>
|
||||
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
|
||||
extern void fasboot_uboot_write_process(void *buf, char *response);
|
||||
#define MAX_ECIES_IMAGE_SIZE (9*1024*1024)
|
||||
#define ECIES_MALLOC_START (MAX_ECIES_IMAGE_SIZE * 2)
|
||||
|
||||
typedef struct {
|
||||
uint32_t magic;
|
||||
uint32_t file_size;
|
||||
char partition_name[64];
|
||||
} __attribute__((__packed__)) send_file_info_t;
|
||||
|
||||
static uint32_t ecies_file_pos = 0;
|
||||
static int slave_init = 0;
|
||||
|
||||
static int current_pos = 0;
|
||||
|
||||
void *csi_ecies_malloc(uint32_t size)
|
||||
{
|
||||
void * ptr = NULL;
|
||||
|
||||
if (current_pos + size >= CONFIG_FASTBOOT_BUF_SIZE) {
|
||||
current_pos = 0;
|
||||
}
|
||||
|
||||
ptr = (void *)(long)(CONFIG_FASTBOOT_BUF_ADDR + ECIES_MALLOC_START + current_pos);
|
||||
current_pos += size;
|
||||
return ptr;
|
||||
};
|
||||
|
||||
void csi_ecies_free(void *buffer)
|
||||
{
|
||||
return;
|
||||
};
|
||||
|
||||
static int ecies_data_write(uint8_t *buf,uint8_t *data,int data_len)
|
||||
{
|
||||
char response[FASTBOOT_RESPONSE_LEN];
|
||||
|
||||
if (data_len == 0 || buf == NULL || data == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(buf + ecies_file_pos,data,data_len);
|
||||
ecies_file_pos += data_len;
|
||||
if (ecies_file_pos == sizeof(send_file_info_t) + ((send_file_info_t *)buf)->file_size) {
|
||||
if (strcmp(((send_file_info_t *)buf)->partition_name, TEE_PART_NAME) == 0) {
|
||||
memcpy((void *)LIGHT_TEE_FW_ADDR, buf + sizeof(send_file_info_t), ((send_file_info_t *)buf)->file_size);
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
fastboot_mmc_flash_write(((send_file_info_t *)buf)->partition_name, buf + sizeof(send_file_info_t), ((send_file_info_t *)buf)->file_size,
|
||||
response);
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
|
||||
fastboot_nand_flash_write(((send_file_info_t *)buf)->partition_name, buf + sizeof(send_file_info_t), ((send_file_info_t *)buf)->file_size,
|
||||
response);
|
||||
#endif
|
||||
} else if (strcmp(((send_file_info_t *)buf)->partition_name, UBOOT_PART_NAME) == 0) {
|
||||
fasboot_uboot_write_process(buf + sizeof(send_file_info_t),response);
|
||||
} else {
|
||||
printf("unknown partition name\n");
|
||||
return -2;
|
||||
}
|
||||
|
||||
ecies_file_pos = 0;
|
||||
} else if(ecies_file_pos > sizeof(send_file_info_t) + ((send_file_info_t *)buf)->file_size) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hex_to_str(char *dest, const uint8_t *src, int len)
|
||||
{
|
||||
char ddl = 0;
|
||||
char ddh = 0;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
ddh = 48 + src[i] / 16;
|
||||
ddl = 48 + src[i] % 16;
|
||||
|
||||
if (ddh > 57) {
|
||||
ddh = ddh + 7;
|
||||
}
|
||||
|
||||
if (ddl > 57) {
|
||||
ddl = ddl + 7;
|
||||
}
|
||||
|
||||
dest[i * 2] = ddh;
|
||||
dest[i * 2 + 1] = ddl;
|
||||
}
|
||||
|
||||
dest[len * 2] = '\0';
|
||||
}
|
||||
|
||||
int ecies_process_data(uint8_t * data, int data_size,char *response)
|
||||
{
|
||||
static ecies_session_t ss_slave;
|
||||
char apduResponse[ECIES_INIT_RESPONSE_LEN] = {0};
|
||||
uint8_t *plaintext = csi_ecies_malloc(MAX_ECIES_IMAGE_SIZE);
|
||||
uint32_t plaintextLen = 0;
|
||||
uint32_t apduResponseLen = 0;
|
||||
int ret = 0;
|
||||
uint8_t cla = 0;
|
||||
uint8_t errcode = 0;
|
||||
|
||||
if (plaintext == NULL) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (!slave_init) {
|
||||
csi_sec_library_init();
|
||||
ret = hal_ecies_slave_init(&ss_slave);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"hal_ecies_slave_init ERROR");
|
||||
ret = -2;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
ret = hal_ecies_slave_session_comm(&ss_slave, data, data_size, (uint8_t *)apduResponse, &apduResponseLen, plaintext, &plaintextLen);
|
||||
if (ret != 0) {
|
||||
ret = hal_ecies_status_get((uint8_t *)apduResponse, apduResponseLen, &cla, &errcode);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"hal_ecies_errcode_get ERROR");
|
||||
ret = -3;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (cla == ECIES_CLA_INITIALIZE_UPDATE_RESPONSE && errcode == ECIES_RESPONSE_SESSION_OPENED_ERROR) {
|
||||
slave_init = 0;
|
||||
ecies_file_pos = 0;
|
||||
hal_ecies_slave_uninit(&ss_slave);
|
||||
ret = hal_ecies_slave_init(&ss_slave);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"hal_ecies_slave_init ERROR");
|
||||
ret = -4;
|
||||
goto end;
|
||||
}
|
||||
ret = hal_ecies_slave_session_comm(&ss_slave, data, data_size, (uint8_t*)apduResponse, &apduResponseLen, plaintext, &plaintextLen);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"hal_ecies_slave_session_comm ERROR");
|
||||
ret = -5;
|
||||
goto end;
|
||||
}
|
||||
} else if(errcode != ECIES_RESPONSE_OK) {
|
||||
if (errcode == ECIES_CLA_SDATA_SEND_RESPONSE) {
|
||||
strcpy(response,"ECIES_CLA_SDATA_SEND_RESPONSE ERROR");
|
||||
ret = -6;
|
||||
goto end;
|
||||
} else if (errcode == ECIES_CLA_SESSION_CLOSE) {
|
||||
strcpy(response,"ECIES_CLA_SESSION_CLOSE ERROR");
|
||||
ret = -7;
|
||||
goto end;
|
||||
} else if (errcode == ECIES_CLA_INITIALIZE_UPDATE) {
|
||||
strcpy(response,"ECIES_CLA_INITIALIZE_UPDATE ERROR");
|
||||
ret = -8;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slave_init && plaintextLen) {
|
||||
ret = ecies_data_write((uint8_t*)(long)(CONFIG_FASTBOOT_BUF_ADDR + MAX_ECIES_IMAGE_SIZE),plaintext,plaintextLen);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"ecies_data_write ERROR");
|
||||
ret = -8;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
slave_init = 1;
|
||||
|
||||
strcpy(response,"SUCCESS:");
|
||||
hex_to_str(response + strlen(response),(uint8_t*)apduResponse,apduResponseLen);
|
||||
ret = 0;
|
||||
end:
|
||||
if (plaintext) {
|
||||
csi_ecies_free(plaintext);
|
||||
plaintext = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <version.h>
|
||||
|
||||
static void getvar_version(char *var_parameter, char *response);
|
||||
static void getvar_dynamic_partition(char *var_parameter, char *response);
|
||||
static void getvar_version_bootloader(char *var_parameter, char *response);
|
||||
static void getvar_downloadsize(char *var_parameter, char *response);
|
||||
static void getvar_serialno(char *var_parameter, char *response);
|
||||
@@ -41,6 +42,9 @@ static const struct {
|
||||
}, {
|
||||
.variable = "version-bootloader",
|
||||
.dispatch = getvar_version_bootloader
|
||||
}, {
|
||||
.variable = "dynamic-partition",
|
||||
.dispatch = getvar_dynamic_partition
|
||||
}, {
|
||||
.variable = "downloadsize",
|
||||
.dispatch = getvar_downloadsize
|
||||
@@ -134,6 +138,17 @@ static void getvar_version_bootloader(char *var_parameter, char *response)
|
||||
fastboot_okay(U_BOOT_VERSION, response);
|
||||
}
|
||||
|
||||
static void getvar_dynamic_partition(char *var_parameter, char *response)
|
||||
{
|
||||
char *part_name="super";
|
||||
|
||||
int r = getvar_get_part_info(part_name, response, NULL);
|
||||
if (r >= 0)
|
||||
fastboot_okay("true", response); /* part exists */
|
||||
else
|
||||
fastboot_okay("false", response);
|
||||
}
|
||||
|
||||
static void getvar_downloadsize(char *var_parameter, char *response)
|
||||
{
|
||||
fastboot_response("OKAY", response, "0x%08x", fastboot_buf_size);
|
||||
@@ -247,7 +262,11 @@ static void getvar_partition_size(char *part_name, char *response)
|
||||
|
||||
static void getvar_is_userspace(char *var_parameter, char *response)
|
||||
{
|
||||
#ifdef CONFIG_ANDROID_BOOT_IMAGE
|
||||
fastboot_okay("yes", response);
|
||||
#else
|
||||
fastboot_okay("no", response);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
342
drivers/fastboot/fb_nv_operation.c
Normal file
342
drivers/fastboot/fb_nv_operation.c
Normal file
@@ -0,0 +1,342 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <fb_mmc.h>
|
||||
#include <command.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/types.h>
|
||||
#include <configs/light-c910.h>
|
||||
#include <thead/clock_config.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <asm/arch-thead/light-iopmp.h>
|
||||
#include "../lib/sec_library/include/soc.h"
|
||||
|
||||
#define MAX_NV_NUMBER_SIZE 32
|
||||
#define MAX_NV_DATA_SIZE 128
|
||||
#define NV_BLOCK_SIZE 512
|
||||
|
||||
extern int32_t wj_efuse_get_lc(long unsigned int, int *lc);
|
||||
|
||||
typedef enum {
|
||||
FB_SYS_ACTION_FACTORY_RECOVER,
|
||||
FB_SYS_ACTION_READ_EFUSE,
|
||||
} fb_sys_action_t;
|
||||
|
||||
static int nv_get(uint8_t *data,int offset,int data_len)
|
||||
{
|
||||
struct blk_desc *dev_desc;
|
||||
struct disk_partition part_info;
|
||||
ulong block_start;
|
||||
uint8_t data_nv[NV_BLOCK_SIZE] = {0};
|
||||
int ret;
|
||||
int n;
|
||||
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (dev_desc == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = part_get_info_by_name(dev_desc, NV_PARTITION_NAME, &part_info);
|
||||
if (ret < 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if(NV_BLOCK_SIZE != dev_desc->blksz) {
|
||||
return -4;
|
||||
}
|
||||
|
||||
block_start = part_info.start + offset / dev_desc->blksz;
|
||||
n = blk_dread(dev_desc, block_start, 1, data_nv);
|
||||
if (n != 1) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
memcpy(data,data_nv + offset % NV_BLOCK_SIZE,data_len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nv_set(uint8_t *data,int offset,int data_len)
|
||||
{
|
||||
struct blk_desc *dev_desc;
|
||||
struct disk_partition part_info;
|
||||
ulong block_start;
|
||||
uint8_t data_nv[NV_BLOCK_SIZE] = {0};
|
||||
int ret;
|
||||
int n;
|
||||
|
||||
|
||||
dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
|
||||
if (dev_desc == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = part_get_info_by_name(dev_desc, NV_PARTITION_NAME, &part_info);
|
||||
if (ret < 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (NV_BLOCK_SIZE != dev_desc->blksz) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
block_start = part_info.start + offset / dev_desc->blksz;
|
||||
|
||||
n = blk_dread(dev_desc, block_start, 1, data_nv);
|
||||
if (n != 1) {
|
||||
return -4;
|
||||
}
|
||||
memcpy(data_nv + offset % NV_BLOCK_SIZE,data,data_len);
|
||||
n = blk_dwrite(dev_desc, block_start, 1, data_nv);
|
||||
if (n != 1) {
|
||||
return -5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int factory_recovery(char *response)
|
||||
{
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC)
|
||||
fastboot_mmc_erase("metadata", response);
|
||||
if (strcmp(response, "OKAY") != 0) {
|
||||
return -1;
|
||||
}
|
||||
fastboot_mmc_erase("misc", response);
|
||||
if (strcmp(response, "OKAY") != 0) {
|
||||
return -2;
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_NAND)
|
||||
fastboot_nand_erase("metadata", response);
|
||||
if (strcmp(response, "OKAY") != 0) {
|
||||
return -3;
|
||||
}
|
||||
fastboot_nand_erase("misc", response);
|
||||
if (strcmp(response, "OKAY") != 0) {
|
||||
return -4;
|
||||
}
|
||||
#endif
|
||||
|
||||
strcpy(response,"OKAY");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_efuse_status(char *response)
|
||||
{
|
||||
int ret;
|
||||
int lc = 0;
|
||||
ret = wj_efuse_get_lc(WJ_EFUSE_BASE, &lc);
|
||||
if (ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(lc == 0) {
|
||||
strcpy(response,"LC_INIT");
|
||||
} else {
|
||||
strcpy(response,"LC_BLOWNED");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static int sys_action(int flag,char *response)
|
||||
{
|
||||
if (flag == FB_SYS_ACTION_FACTORY_RECOVER) {
|
||||
return factory_recovery(response);
|
||||
} else if (flag == FB_SYS_ACTION_READ_EFUSE) {
|
||||
return read_efuse_status(response);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int toupper(int c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
return c - 32;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static void str_to_hex(uint8_t *dest, const char *src, int len)
|
||||
{
|
||||
char h1, h2;
|
||||
unsigned char s1, s2;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
h1 = src[2 * i];
|
||||
h2 = src[2 * i + 1];
|
||||
s1 = toupper(h1) - 48;
|
||||
s2 = toupper(h2) - 48;
|
||||
if (s1 > 9) {
|
||||
s1 = s1 - 7;
|
||||
}
|
||||
|
||||
if (s2 > 9) {
|
||||
s2 = s2 - 7;
|
||||
}
|
||||
|
||||
dest[i] = s1 * 16 + s2;
|
||||
}
|
||||
}
|
||||
|
||||
static void hex_to_str(char *dest, const uint8_t *src, int len)
|
||||
{
|
||||
char ddl = 0;
|
||||
char ddh = 0;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
ddh = 48 + src[i] / 16;
|
||||
ddl = 48 + src[i] % 16;
|
||||
|
||||
if (ddh > 57) {
|
||||
ddh = ddh + 7;
|
||||
}
|
||||
|
||||
if (ddl > 57) {
|
||||
ddl = ddl + 7;
|
||||
}
|
||||
|
||||
dest[i * 2] = ddh;
|
||||
dest[i * 2 + 1] = ddl;
|
||||
}
|
||||
|
||||
dest[len * 2] = '\0';
|
||||
}
|
||||
|
||||
static int char_to_int(char *data,int *out)
|
||||
{
|
||||
*out = 0;
|
||||
while(*data) {
|
||||
if(*data < '0' || *data > '9')
|
||||
return -1;
|
||||
|
||||
*out = *out * 10 + (*data - '0');
|
||||
++data;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#if CONFIG_FASTBOOT_CMD_OEM_NV_OPERATION
|
||||
void oem_nv_factory_recovery_process(char *cmd_parameter, char *response)
|
||||
{
|
||||
int ret = 0;
|
||||
int flag = 0;
|
||||
|
||||
ret = char_to_int(cmd_parameter,&flag);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"ERROR FLAG INVALID");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = sys_action(flag,response);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"ERROR SYS ACTION FAILED");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void oem_nv_get_proccess(char *cmd_parameter, char *response)
|
||||
{
|
||||
char *sep = NULL;
|
||||
char offset[MAX_NV_NUMBER_SIZE] = {0};
|
||||
char len[MAX_NV_NUMBER_SIZE] = {0};
|
||||
int sep_pos = 0;
|
||||
uint8_t nv_data[MAX_NV_DATA_SIZE + 32] = {0};
|
||||
char nv_data_str[MAX_NV_DATA_SIZE * 2 + 1] = {0};
|
||||
int ret;
|
||||
int offset_int = 0;
|
||||
int len_int = 0;
|
||||
|
||||
sep = strstr(cmd_parameter, ":");
|
||||
if (sep == NULL) {
|
||||
strcpy(response,"ERROR INVALID PARAM");
|
||||
return;
|
||||
}
|
||||
|
||||
sep_pos = sep - cmd_parameter;
|
||||
memcpy(offset,cmd_parameter,sep - cmd_parameter);
|
||||
memcpy(len,cmd_parameter + (sep - cmd_parameter) + 1,strlen(cmd_parameter) - sep_pos - 1);
|
||||
|
||||
ret = char_to_int(offset,&offset_int);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"ERROR OFFSET INVALID");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = char_to_int(len,&len_int);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"ERROR LEN INVALID");
|
||||
return;
|
||||
}
|
||||
|
||||
if (len_int > MAX_NV_DATA_SIZE) {
|
||||
strcpy(response,"ERROR NV SIZE TOO LARGE");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = nv_get(nv_data, offset_int, len_int);
|
||||
if (ret != 0) {
|
||||
printf("nv_get failed:%d\n",ret);
|
||||
strcpy(response,"ERROR NV GET FAILED");
|
||||
return;
|
||||
}
|
||||
|
||||
hex_to_str(nv_data_str,nv_data,len_int);
|
||||
strcpy(response,"SUCCESS:");
|
||||
strcat(response,nv_data_str);
|
||||
}
|
||||
|
||||
void oem_nv_set_proccess(char *cmd_parameter, char *response)
|
||||
{
|
||||
char *sep = NULL;
|
||||
char offset[MAX_NV_NUMBER_SIZE] = {0};
|
||||
uint8_t nv_data[MAX_NV_DATA_SIZE + 32] = {0};
|
||||
char *nv_data_str;
|
||||
int data_len;
|
||||
int ret;
|
||||
int offset_int = 0;
|
||||
|
||||
sep = strstr(cmd_parameter, ":");
|
||||
if (sep == NULL) {
|
||||
strcpy(response,"ERROR INVALID PARAM");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(offset,cmd_parameter,sep - cmd_parameter);
|
||||
nv_data_str = cmd_parameter + (sep - cmd_parameter) + 1;
|
||||
|
||||
data_len = strlen(nv_data_str) / 2;
|
||||
|
||||
ret = char_to_int(offset,&offset_int);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"ERROR OFFSET INVALID");
|
||||
return;
|
||||
}
|
||||
|
||||
if (data_len > MAX_NV_DATA_SIZE) {
|
||||
strcpy(response,"ERROR NV SIZE TOO LARGE");
|
||||
return;
|
||||
}
|
||||
|
||||
str_to_hex(nv_data,nv_data_str,data_len);
|
||||
|
||||
ret = nv_set(nv_data, offset_int, data_len);
|
||||
if (ret != 0) {
|
||||
strcpy(response,"ERROR NV SET FAILED");
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(response,"OKAY");
|
||||
}
|
||||
#endif
|
||||
15
drivers/mcu/Kconfig
Executable file
15
drivers/mcu/Kconfig
Executable file
@@ -0,0 +1,15 @@
|
||||
menu "MCU Support"
|
||||
|
||||
config DM_MCU
|
||||
bool "Enable driver model for mcu device support"
|
||||
depends on DM
|
||||
help
|
||||
This adds a simple uclass for mcu device.
|
||||
|
||||
config MCU_HC32fX
|
||||
bool "Enable HC32fX MCU support"
|
||||
depends on DM_MCU
|
||||
help
|
||||
This adds a driver for the HC32fX MCU support.
|
||||
|
||||
endmenu
|
||||
9
drivers/mcu/Makefile
Executable file
9
drivers/mcu/Makefile
Executable file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Copyright (c) 2015 Google, Inc
|
||||
# Written by Simon Glass <sjg@chromium.org>
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
|
||||
obj-$(CONFIG_DM_MCU) += mcu-uclass.o
|
||||
obj-$(CONFIG_MCU_HC32fX) += mcu_hc32fx.o
|
||||
65
drivers/mcu/mcu-uclass.c
Executable file
65
drivers/mcu/mcu-uclass.c
Executable file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Google, Inc
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <mcu/mcu-uclass.h>
|
||||
#include <dm/root.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
|
||||
int _mcu_shutdown(struct udevice *dev)
|
||||
{
|
||||
struct mcu_ops *ops = dev_get_driver_ops(dev);
|
||||
|
||||
if (!ops->shutdown)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->shutdown(dev);
|
||||
}
|
||||
|
||||
int _mcu_poweron(struct udevice *dev)
|
||||
{
|
||||
struct mcu_ops *ops = dev_get_driver_ops(dev);
|
||||
|
||||
if (!ops->poweron)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->poweron(dev);
|
||||
}
|
||||
|
||||
int mcu_poweron(void)
|
||||
{
|
||||
struct udevice *mcu;
|
||||
int ret;
|
||||
|
||||
ret = uclass_get_device(UCLASS_MCU, 0, &mcu);
|
||||
if (ret) {
|
||||
printf("Get UCLASS_MCU failed, ret=%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return _mcu_poweron(mcu);
|
||||
}
|
||||
|
||||
int mcu_shutdown(void)
|
||||
{
|
||||
struct udevice *mcu;
|
||||
int ret;
|
||||
|
||||
ret = uclass_get_device(UCLASS_MCU, 0, &mcu);
|
||||
if (ret) {
|
||||
printf("Get charge display failed, ret=%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return _mcu_shutdown(mcu);
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(mcu) = {
|
||||
.id = UCLASS_MCU,
|
||||
.name = "mcu",
|
||||
};
|
||||
97
drivers/mcu/mcu_hc32fx.c
Executable file
97
drivers/mcu/mcu_hc32fx.c
Executable file
@@ -0,0 +1,97 @@
|
||||
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <mcu/mcu-uclass.h>
|
||||
#include <dm/lists.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#define HC32FX_POWEROFF_20 0x20
|
||||
#define HC32FX_POWERON_30 0x30
|
||||
#define POWER_OFF 0x55
|
||||
#define POWER_ON 0x01
|
||||
|
||||
struct hc32fx_info {
|
||||
struct udevice *dev;
|
||||
};
|
||||
|
||||
static u8 hc32fx_read(struct hc32fx_info *hc32fx, u8 reg)
|
||||
{
|
||||
u8 val;
|
||||
int ret;
|
||||
|
||||
ret = dm_i2c_read(hc32fx->dev, reg, &val, 1);
|
||||
if (ret) {
|
||||
printf("write error to device: %p register: %#x!",
|
||||
hc32fx->dev, reg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static int hc32fx_write(struct hc32fx_info *hc32fx, u8 reg, u8 val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = dm_i2c_write(hc32fx->dev, reg, &val, 1);
|
||||
if (ret) {
|
||||
printf("write error to device: %p register: %#x!",
|
||||
hc32fx->dev, reg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcu_hc32fx_poweron(struct udevice *dev)
|
||||
{
|
||||
struct hc32fx_info *hc32fx = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
ret = hc32fx_write(hc32fx, HC32FX_POWERON_30, POWER_ON);
|
||||
if(ret)
|
||||
printf("set mcu POWERON fail\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mcu_hc32fx_shutdown(struct udevice *dev)
|
||||
{
|
||||
struct hc32fx_info *hc32fx = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
ret = hc32fx_write(hc32fx, HC32FX_POWEROFF_20, POWER_OFF);
|
||||
if(ret)
|
||||
printf("set mcu POWEROFF fail\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mcu_gpio_probe(struct udevice *dev)
|
||||
{
|
||||
struct hc32fx_info *priv = dev_get_priv(dev);
|
||||
priv->dev = dev;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct mcu_ops mcu_hc32fx_ops = {
|
||||
.poweron = mcu_hc32fx_poweron,
|
||||
.shutdown = mcu_hc32fx_shutdown,
|
||||
};
|
||||
|
||||
static const struct udevice_id hc32fx_ops_ids[] = {
|
||||
{ .compatible = "mcu_hc32fx" },
|
||||
{ }
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(mcu_gpio) = {
|
||||
.name = "hc32fx-mcu",
|
||||
.id = UCLASS_MCU,
|
||||
.of_match = hc32fx_ops_ids,
|
||||
.ops = &mcu_hc32fx_ops,
|
||||
.priv_auto_alloc_size = sizeof(struct hc32fx_info),
|
||||
.probe = mcu_gpio_probe,
|
||||
};
|
||||
@@ -439,4 +439,10 @@ config K3_AVS0
|
||||
optimized voltage from the efuse, so that it can be programmed
|
||||
to the PMIC on board.
|
||||
|
||||
config LIGHT_AON_CONF
|
||||
bool "Light aon config support"
|
||||
depends on MISC
|
||||
help
|
||||
Select this to enable aon config by dts.
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -68,3 +68,4 @@ obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
|
||||
obj-$(CONFIG_JZ4780_EFUSE) += jz4780_efuse.o
|
||||
obj-$(CONFIG_MICROCHIP_FLEXCOM) += microchip_flexcom.o
|
||||
obj-$(CONFIG_K3_AVS0) += k3_avs.o
|
||||
obj-$(CONFIG_LIGHT_AON_CONF) += light_regu.o
|
||||
|
||||
1161
drivers/misc/light_regu.c
Normal file
1161
drivers/misc/light_regu.c
Normal file
File diff suppressed because it is too large
Load Diff
271
drivers/misc/light_regu.h
Normal file
271
drivers/misc/light_regu.h
Normal file
@@ -0,0 +1,271 @@
|
||||
#ifndef __LIGHT_REGU_H__
|
||||
#define __LIGHT_REGU_H__
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SOC_DVDD18_AON, /*da9063: ldo-3 */
|
||||
SOC_AVDD33_USB3, /*da9063: ldo-9 */
|
||||
SOC_DVDD08_AON, /*da9063: ldo-2 */
|
||||
SOC_APCPU_DVDD_DVDDM, /*da9063: vbcore1 & vbcore2*/
|
||||
SOC_DVDD08_DDR, /*da9063: buckperi */
|
||||
SOC_VDD_DDR_1V8, /*da9063: ldo-4 */
|
||||
SOC_VDD_DDR_1V1, /*da9063: buckmem & buckio */
|
||||
SOC_VDD_DDR_0V6, /*da9063: buckpro */
|
||||
SOC_DVDD18_AP, /*da9063: ldo-11 */
|
||||
SOC_DVDD08_AP, /*da9121: da9121_ex */
|
||||
SOC_AVDD08_MIPI_HDMI, /*da9063: ldo-1 */
|
||||
SOC_AVDD18_MIPI_HDMI, /*da9063: ldo-5 */
|
||||
SOC_DVDD33_EMMC, /*da9063: ldo-10 */
|
||||
SOC_DVDD18_EMMC, /*slg51000:ldo-3 */
|
||||
SOC_DOVDD18_SCAN, /*da9063: ldo-6 */
|
||||
SOC_VEXT_2V8, /*da9063: ldo-7 */
|
||||
SOC_DVDD12_SCAN, /*da9063: ldo-8 */
|
||||
SOC_AVDD28_SCAN_EN, /*da9063: gpio-4,SGM2019-ADJ */
|
||||
SOC_AVDD28_RGB, /*slg51000:ldo-1 */
|
||||
SOC_DOVDD18_RGB, /*slg51000:ldo-4 */
|
||||
SOC_DVDD12_RGB, /*slg51000:ldo-5 */
|
||||
SOC_AVDD25_IR, /*slg51000:ldo-2 */
|
||||
SOC_DOVDD18_IR, /*slg51000:ldo-7 */
|
||||
SOC_DVDD12_IR, /*slg51000:ldo-6 */
|
||||
SOC_ADC_VREF,
|
||||
SOC_LCD0_EN,
|
||||
SOC_VEXT_1V8,
|
||||
|
||||
SOC_REGU_INVALID = 0xFF
|
||||
} soc_virtual_id_en;
|
||||
|
||||
#define REGU_DTS_NAME "light-regu-reg"
|
||||
#define AON_CONF_NAME "aon_pmic_config"
|
||||
#define PMIC_DEV_DTS_NAME "pmic-dev"
|
||||
#define PMIC_PARENT_CTRL_NAME "pmic_ctrl_info"
|
||||
#define REGU_ID_CONF_NAME "regu_config"
|
||||
#define REGU_ID_NAME "regu_id"
|
||||
#define COUPLING_ID_INFO_NAME "coupling_info"
|
||||
|
||||
#define PMIC_DEV_ENABLE_WDT (1U << 0)
|
||||
#define PMIC_DEV_ENABLE_ERR_IO (1U << 1)
|
||||
#define PMIC_DEV_ENABLE_LPM_IO (1U << 2)
|
||||
|
||||
#define HW_ID_NO_SOFT_AUTO_ON (0xff)
|
||||
#define HW_ID_NO_SOFT_AUTO_OFF (0xff)
|
||||
#define HW_ID_INVALID (0xff)
|
||||
#define PMIC_ID_INVALID (0xff)
|
||||
#define REGU_SUB_ID_INVALID (0xff)
|
||||
|
||||
#define REGU_EXT_ID_NAME_LEN 30
|
||||
#define PMIC_DEV_NAME_LEN 20
|
||||
#define PMIC_DEV_VERSION_LEN 20
|
||||
|
||||
#define PMIC_MAX_HW_ID_NUM 3
|
||||
#define PMIC_MAX_COUPLING_NUM 3
|
||||
|
||||
#define AON_WAKEUP_BY_GPIO (1 << 0)
|
||||
#define AON_WAKEUP_BY_RTC (1 << 1)
|
||||
|
||||
#define AON_CONFIG_MAGIC "AON_CONFIG"
|
||||
#define UBOOT_CONFIG_MAGIC "UBOOT_SET"
|
||||
#define AON_CONFIG_VERSION "1.0.0"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HW_ID_ACTIVATE_HIGH = 0U,
|
||||
HW_ID_ACTIVATE_LOW = 1U,
|
||||
} hw_activate_status_en;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t pmic_id;
|
||||
uint8_t io_hw_id;
|
||||
uint8_t activate_status;
|
||||
} pmic_parent_hw_io_ctrl_info_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t on_order;
|
||||
uint8_t on_delay_ms;
|
||||
uint32_t init_target_uv;
|
||||
} regu_soft_power_ctrl_on_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t off_order;
|
||||
uint8_t off_delay_ms;
|
||||
} regu_soft_power_ctrl_off_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
regu_soft_power_ctrl_on_t on_info;
|
||||
regu_soft_power_ctrl_off_t off_info;
|
||||
} regu_soft_power_ctrl_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t id0;
|
||||
uint8_t id1;
|
||||
int8_t max_spread; // mv/10
|
||||
int8_t min_spread; // mv/10
|
||||
} coupling_desc_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPIO_IRQ_MODE_RISING_EDGE = 0, ///< Interrupt mode for rising edge
|
||||
GPIO_IRQ_MODE_FALLING_EDGE, ///< Interrupt mode for falling edge
|
||||
GPIO_IRQ_MODE_BOTH_EDGE, ///< Interrupt mode for both edge
|
||||
GPIO_IRQ_MODE_LOW_LEVEL, ///< Interrupt mode for low level
|
||||
GPIO_IRQ_MODE_HIGH_LEVEL, ///< Interrupt mode for high level
|
||||
} csi_gpio_irq_mode_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IIC_ADDRESS_7BIT = 0U, ///< 7-bit address mode
|
||||
IIC_ADDRESS_10BIT ///< 10-bit address mode
|
||||
} csi_iic_addr_mode_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IIC_BUS_SPEED_STANDARD = 0U, ///< Standard Speed (<=100kHz)
|
||||
IIC_BUS_SPEED_FAST, ///< Fast Speed (<=400kHz)
|
||||
IIC_BUS_SPEED_FAST_PLUS, ///< Fast plus Speed (<= 1MHz)
|
||||
IIC_BUS_SPEED_HIGH ///< High Speed (<=3.4MHz)
|
||||
} csi_iic_speed_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t pmic_id;
|
||||
uint8_t hw_id;
|
||||
uint8_t benable;
|
||||
pmic_parent_hw_io_ctrl_info_t parent_hw_info;
|
||||
regu_soft_power_ctrl_t soft_power_ctrl_info;
|
||||
} pmic_hw_info_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
coupling_desc_t coupling_list[PMIC_MAX_COUPLING_NUM];
|
||||
pmic_hw_info_t id[PMIC_MAX_HW_ID_NUM]; ///< sub id1 for single-rail or first src of dual-rail
|
||||
} pmic_hw_id_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t regu_ext_id; ///< virtual global regulator id
|
||||
char regu_ext_id_name[REGU_EXT_ID_NAME_LEN]; ///< vitual regu-id name
|
||||
pmic_hw_id_t sub; ///< sub id set for dual-rail/single-rail regulator
|
||||
} csi_regu_id_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PMIC_CTRL_BY_AON_GPIO = 0U,
|
||||
PMIC_CTRL_BY_PMIC_GPIO = 1U,
|
||||
PMIC_CTRL_BY_NOTHINTG = 0xFF,
|
||||
} pmic_ctrl_info_en;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t gpio_port;
|
||||
uint8_t pin;
|
||||
uint8_t activate_status;
|
||||
} pmic_ctrl_by_aon_info_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t pmic_id;
|
||||
uint8_t io_hw_id;
|
||||
uint8_t activate_status;
|
||||
} pmic_ctrl_by_pmic_info_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t pmic_ctrl_type;
|
||||
union
|
||||
{
|
||||
pmic_ctrl_by_aon_info_t aon_io;
|
||||
pmic_ctrl_by_pmic_info_t pmic_io;
|
||||
} info;
|
||||
} pmic_parent_ctrl_info_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t gpio_port;
|
||||
uint8_t pin;
|
||||
uint8_t trigger_mode;
|
||||
} pmic_interrupt_io_info_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
char device_name[PMIC_DEV_NAME_LEN];
|
||||
char version_name[PMIC_DEV_VERSION_LEN];
|
||||
uint8_t pmic_id;
|
||||
uint8_t addr1;
|
||||
uint8_t addr2;
|
||||
uint8_t flag; /*support wdt|errio| lpm io*/
|
||||
uint8_t slew_rate;
|
||||
uint32_t wdt_len;
|
||||
pmic_interrupt_io_info_t err_io_info;
|
||||
pmic_interrupt_io_info_t lpm_io_info;
|
||||
pmic_parent_ctrl_info_t ctrl_info;
|
||||
} pmic_dev_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
soc_virtual_id_en id;
|
||||
char virtual_id_name[REGU_EXT_ID_NAME_LEN];
|
||||
int min_uv;
|
||||
int max_uv;
|
||||
} soc_virtual_id_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int regu_num;
|
||||
soc_virtual_id_t *regu_list;
|
||||
} virtual_regu_list_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int pmic_num;
|
||||
pmic_dev_info_t *pmic_list;
|
||||
} pmic_dev_list_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int regu_id_num;
|
||||
csi_regu_id_t *regu_id_list;
|
||||
} regu_id_list_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
uint8_t iic_id; ///< iic id
|
||||
uint8_t addr_mode; ///< iic addr_mode ---> csi_iic_addr_mode_t
|
||||
uint8_t speed; ///< iic speed type ---> csi_iic_speed_t
|
||||
uint8_t reserved[1];
|
||||
} csi_pmic_if_config_t;
|
||||
|
||||
struct mic_regu_platdata
|
||||
{
|
||||
const char *name;
|
||||
uint32_t wakeup_flag;
|
||||
csi_pmic_if_config_t iic_config;
|
||||
virtual_regu_list_t regu_list;
|
||||
pmic_dev_list_t pmic_list;
|
||||
regu_id_list_t regu_id_list;
|
||||
};
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
csi_pmic_if_config_t iic_config;
|
||||
uint8_t pmic_dev_num;
|
||||
uint8_t regu_num;
|
||||
uint32_t pmic_dev_list_offset;
|
||||
uint32_t regu_id_list_offset;
|
||||
} aon_pmic_config_t;
|
||||
|
||||
typedef struct __packed
|
||||
{
|
||||
const char magic[11];
|
||||
const char version[11];
|
||||
const char uboot_set_magic[11];
|
||||
uint8_t max_hw_id_num;
|
||||
uint64_t aon_config_partition_size;
|
||||
uint32_t wakeup_flag;
|
||||
aon_pmic_config_t aon_pmic;
|
||||
} aon_config_t;
|
||||
|
||||
#endif
|
||||
@@ -13,7 +13,6 @@
|
||||
* general classes. A set of generic read, write and ioctl methods may
|
||||
* be used to access the device.
|
||||
*/
|
||||
|
||||
int misc_read(struct udevice *dev, int offset, void *buf, int size)
|
||||
{
|
||||
const struct misc_ops *ops = device_get_ops(dev);
|
||||
|
||||
@@ -38,9 +38,7 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)
|
||||
timeout--;
|
||||
udelay(1000);
|
||||
}
|
||||
#ifdef CONFIG_TARGET_LIGHT_C910
|
||||
mdelay(50);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void sdhci_cmd_done(struct sdhci_host *host, struct mmc_cmd *cmd)
|
||||
@@ -136,9 +134,9 @@ static void sdhci_prepare_dma(struct sdhci_host *host, struct mmc_data *data,
|
||||
unsigned char ctrl;
|
||||
|
||||
if (data->flags == MMC_DATA_READ)
|
||||
host->start_addr = (dma_addr_t)data->dest;
|
||||
host->start_addr = (dma_addr_t)(u64)data->dest;
|
||||
else
|
||||
host->start_addr = (dma_addr_t)data->src;
|
||||
host->start_addr = (dma_addr_t)(u64)data->src;
|
||||
|
||||
ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
|
||||
ctrl &= ~SDHCI_CTRL_DMA_MASK;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define HS400_DELAY_LANE 24
|
||||
|
||||
volatile int DELAY_LANE = 50;
|
||||
volatile int manual_set_delay = 0; //flag for cmd manual setted DELAY_LANE,non-zero is setted. auto clear in cmd
|
||||
|
||||
static void sdhci_phy_1_8v_init_no_pull(struct sdhci_host *host)
|
||||
{
|
||||
@@ -154,10 +155,14 @@ void snps_set_uhs_timing(struct sdhci_host *host)
|
||||
{
|
||||
struct mmc *mmc = (struct mmc *)host->mmc;
|
||||
u32 reg;
|
||||
|
||||
int restore_delay;
|
||||
reg = sdhci_readw(host, SDHCI_HOST_CONTROL2);
|
||||
reg &= ~SDHCI_CTRL_UHS_MASK;
|
||||
|
||||
|
||||
if(manual_set_delay){
|
||||
DELAY_LANE = DELAY_LANE & 0x7f; /*limit bit[0:6]*/
|
||||
printf("%s: manual set delay (%d) active \n",host->name,DELAY_LANE);
|
||||
}
|
||||
switch (mmc->selected_mode) {
|
||||
case UHS_SDR50:
|
||||
case MMC_HS_52:
|
||||
@@ -175,9 +180,13 @@ void snps_set_uhs_timing(struct sdhci_host *host)
|
||||
reg |= SDHCI_CTRL_UHS_SDR104;
|
||||
break;
|
||||
case MMC_HS_400:
|
||||
DELAY_LANE = HS400_DELAY_LANE;
|
||||
restore_delay = DELAY_LANE;
|
||||
if(!manual_set_delay){ /*default not set manual in cmd,when set in cmd,use DELAY_LANE set in cmd*/
|
||||
DELAY_LANE = HS400_DELAY_LANE;
|
||||
}
|
||||
sdhci_phy_1_8v_init(host);
|
||||
reg |= SNPS_SDHCI_CTRL_HS400;
|
||||
DELAY_LANE = restore_delay; /*restore for other modes*/
|
||||
break;
|
||||
default:
|
||||
sdhci_phy_3_3v_init(host);
|
||||
@@ -345,7 +354,10 @@ static int snps_sdhci_probe(struct udevice *dev)
|
||||
ret = max_clk;
|
||||
goto err;
|
||||
}
|
||||
|
||||
//get Maximum Base Clock frequency from dts clock-frequency
|
||||
if(0 == dev_read_u32(dev, "clock-frequency", &max_clk)){
|
||||
host->max_clk = max_clk;
|
||||
}
|
||||
host->mmc = &plat->mmc;
|
||||
host->mmc->dev = dev;
|
||||
host->mmc->priv = host;
|
||||
|
||||
@@ -508,7 +508,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
|
||||
{
|
||||
struct phy_device *phydev;
|
||||
int phy_addr = -1, ret;
|
||||
|
||||
|
||||
#ifdef CONFIG_PHY_ADDR
|
||||
phy_addr = CONFIG_PHY_ADDR;
|
||||
#endif
|
||||
@@ -801,13 +801,16 @@ int designware_eth_probe(struct udevice *dev)
|
||||
err = ret;
|
||||
goto mdio_err;
|
||||
}
|
||||
|
||||
#ifdef GMAC_USE_FIRST_MII_BUS
|
||||
if (!g_mii_bus) {
|
||||
priv->bus = miiphy_get_dev_by_name(dev->name);
|
||||
g_mii_bus = priv->bus;
|
||||
} else {
|
||||
priv->bus = g_mii_bus;
|
||||
}
|
||||
#else
|
||||
priv->bus = miiphy_get_dev_by_name(dev->name);
|
||||
#endif
|
||||
ret = dw_phy_init(priv, dev);
|
||||
debug("%s, ret=%d\n", __func__, ret);
|
||||
if (!ret)
|
||||
@@ -815,8 +818,18 @@ int designware_eth_probe(struct udevice *dev)
|
||||
|
||||
/* continue here for cleanup if no PHY found */
|
||||
err = ret;
|
||||
#ifdef GMAC_USE_FIRST_MII_BUS
|
||||
struct mii_dev *t_mii = NULL;
|
||||
t_mii = miiphy_get_dev_by_name(dev->name);
|
||||
if((g_mii_bus != t_mii) && (t_mii != NULL) ){
|
||||
printf("free mdio bus %s\n",t_mii->name);
|
||||
mdio_unregister(t_mii);
|
||||
mdio_free(t_mii);
|
||||
}
|
||||
#else
|
||||
mdio_unregister(priv->bus);
|
||||
mdio_free(priv->bus);
|
||||
#endif
|
||||
mdio_err:
|
||||
|
||||
#ifdef CONFIG_CLK
|
||||
|
||||
@@ -2,10 +2,22 @@ menu "Power"
|
||||
|
||||
source "drivers/power/domain/Kconfig"
|
||||
|
||||
source "drivers/power/fuel_gauge/Kconfig"
|
||||
|
||||
source "drivers/power/pmic/Kconfig"
|
||||
|
||||
source "drivers/power/regulator/Kconfig"
|
||||
|
||||
source "drivers/power/charge/Kconfig"
|
||||
|
||||
source "drivers/power/power_delivery/Kconfig"
|
||||
|
||||
config DM_CHARGE_DISPLAY
|
||||
bool "Enable driver model for charge display support"
|
||||
depends on DM
|
||||
help
|
||||
This adds a simple uclass for charge display.
|
||||
|
||||
choice
|
||||
prompt "Select Sunxi PMIC Variant"
|
||||
depends on ARCH_SUNXI
|
||||
@@ -72,6 +84,13 @@ config SY8106A_POWER
|
||||
|
||||
endchoice
|
||||
|
||||
config CHARGE_ANIMATION
|
||||
bool "Enable charge animation"
|
||||
depends on DM_CHARGE_DISPLAY && DM_FUEL_GAUGE
|
||||
select ARM_CPU_SUSPEND
|
||||
help
|
||||
This adds a simple function for charge animation display.
|
||||
|
||||
config AXP_DCDC1_VOLT
|
||||
int "axp pmic dcdc1 voltage"
|
||||
depends on AXP221_POWER || AXP809_POWER || AXP818_POWER
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
# Copyright (c) 2009 Wind River Systems, Inc.
|
||||
# Tom Rix <Tom.Rix at windriver.com>
|
||||
|
||||
obj-$(CONFIG_DM_CHARGE_DISPLAY) += charge-display-uclass.o
|
||||
obj-$(CONFIG_AXP152_POWER) += axp152.o
|
||||
obj-$(CONFIG_AXP209_POWER) += axp209.o
|
||||
obj-$(CONFIG_AXP221_POWER) += axp221.o
|
||||
obj-$(CONFIG_AXP809_POWER) += axp809.o
|
||||
obj-$(CONFIG_AXP818_POWER) += axp818.o
|
||||
obj-$(CONFIG_CHARGE_ANIMATION) += charge_animation.o
|
||||
obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o
|
||||
obj-$(CONFIG_FTPMU010_POWER) += ftpmu010.o
|
||||
obj-$(CONFIG_SY8106A_POWER) += sy8106a.o
|
||||
|
||||
40
drivers/power/charge-display-uclass.c
Executable file
40
drivers/power/charge-display-uclass.c
Executable file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* (C) Copyright 2017 Rockchip Electronics Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <command.h>
|
||||
#include <common.h>
|
||||
#include <dm.h>
|
||||
#include <power/charge_display.h>
|
||||
|
||||
int charge_display_show(struct udevice *dev)
|
||||
{
|
||||
const struct dm_charge_display_ops *ops = dev_get_driver_ops(dev);
|
||||
|
||||
if (!ops || !ops->show)
|
||||
return -ENOSYS;
|
||||
|
||||
return ops->show(dev);
|
||||
}
|
||||
|
||||
int charge_display(void)
|
||||
{
|
||||
struct udevice *dev;
|
||||
struct udevice *fg_dev;
|
||||
int ret;
|
||||
|
||||
ret = uclass_get_device(UCLASS_CHARGE_DISPLAY, 0, &dev);
|
||||
if (ret) {
|
||||
debug("Get charge display failed, ret=%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return charge_display_show(dev);
|
||||
}
|
||||
|
||||
UCLASS_DRIVER(charge_display) = {
|
||||
.id = UCLASS_CHARGE_DISPLAY,
|
||||
.name = "charge_display",
|
||||
};
|
||||
5
drivers/power/charge/Kconfig
Executable file
5
drivers/power/charge/Kconfig
Executable file
@@ -0,0 +1,5 @@
|
||||
config CHARGER_BQ25700
|
||||
bool "BQ25700 charger support"
|
||||
depends on DM_FUEL_GAUGE
|
||||
help
|
||||
This adds support for BQ25700 charger support.
|
||||
7
drivers/power/charge/Makefile
Executable file
7
drivers/power/charge/Makefile
Executable file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# Copyright (c) 2019 Fuzhou Rockchip Electronics Co., Ltd
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0+
|
||||
#
|
||||
|
||||
obj-$(CONFIG_CHARGER_BQ25700) += bq25700_charger.o
|
||||
334
drivers/power/charge/bq25700_charger.c
Executable file
334
drivers/power/charge/bq25700_charger.c
Executable file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* (C) Copyright 2019 Fuzhou Rockchip Electronics Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <common.h>
|
||||
#include <asm/gpio.h>
|
||||
#include <dm/device.h>
|
||||
#include <dm/uclass.h>
|
||||
#include <power/fuel_gauge.h>
|
||||
#include <power/pmic.h>
|
||||
#include <power/power_delivery/power_delivery.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#define BQ25700_ID 0x25700
|
||||
#define BQ25703_ID 0x25703
|
||||
|
||||
#define COMPAT_BQ25700 "ti,bq25700"
|
||||
#define COMPAT_BQ25703 "ti,bq25703"
|
||||
|
||||
#define BQ25700_I2C_SPEED 100000
|
||||
#define BQ25700_CHARGE_CURRENT_1500MA 0x5C0
|
||||
#define BQ25700_SDP_INPUT_CURRENT_500MA 0xA00
|
||||
#define BQ25700_DCP_INPUT_CURRENT_1500MA 0x1E00
|
||||
#define BQ25700_DCP_INPUT_CURRENT_2000MA 0x2800
|
||||
#define BQ25700_DCP_INPUT_CURRENT_3000MA 0x3C00
|
||||
|
||||
#define WATCHDOG_ENSABLE (0x03 << 13)
|
||||
|
||||
#define BQ25700_CHARGEOPTION0_REG 0x12
|
||||
#define BQ25700_CHARGECURREN_REG 0x14
|
||||
#define BQ25700_CHARGERSTAUS_REG 0x20
|
||||
#define BQ25700_INPUTVOLTAGE_REG 0x3D
|
||||
#define BQ25700_INPUTCURREN_REG 0x3F
|
||||
|
||||
#define BQ25703_CHARGEOPTION0_REG 0x00
|
||||
#define BQ25703_CHARGECURREN_REG 0x02
|
||||
#define BQ25703_CHARGERSTAUS_REG 0x20
|
||||
#define BQ25703_INPUTVOLTAGE_REG 0x0A
|
||||
#define BQ25703_INPUTCURREN_REG 0x0E
|
||||
#define PD_MUN 2
|
||||
#define TYPEC0_I2C "i2c@ffe7f20000"
|
||||
#define TYPEC1_I2C "i2c@ffe7f24000"
|
||||
|
||||
enum bq25700_table_ids {
|
||||
/* range tables */
|
||||
TBL_ICHG,
|
||||
TBL_CHGMAX,
|
||||
TBL_INPUTVOL,
|
||||
TBL_INPUTCUR,
|
||||
TBL_SYSVMIN,
|
||||
TBL_OTGVOL,
|
||||
TBL_OTGCUR,
|
||||
TBL_EXTCON,
|
||||
};
|
||||
|
||||
struct bq25700 {
|
||||
struct udevice *dev;
|
||||
u32 ichg;
|
||||
u32 chip_id;
|
||||
struct udevice *pd[PD_MUN];
|
||||
};
|
||||
|
||||
struct bq25700_range {
|
||||
u32 min;
|
||||
u32 max;
|
||||
u32 step;
|
||||
};
|
||||
|
||||
static int bq25700_read(struct bq25700 *charger, uint reg)
|
||||
{
|
||||
u16 val;
|
||||
int ret;
|
||||
|
||||
ret = dm_i2c_read(charger->dev, reg, (u8 *)&val, 2);
|
||||
if (ret) {
|
||||
printf("write error to device: %p register: %#x!",
|
||||
charger->dev, reg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static int bq25700_write(struct bq25700 *charger, uint reg, u16 val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = dm_i2c_write(charger->dev, reg, (u8 *)&val, 2);
|
||||
if (ret) {
|
||||
printf("write error to device: %p register: %#x!",
|
||||
charger->dev, reg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const union {
|
||||
struct bq25700_range rt;
|
||||
} bq25700_tables[] = {
|
||||
/* range tables */
|
||||
[TBL_ICHG] = {.rt = {0, 8128000, 64000}},
|
||||
/* uV */
|
||||
[TBL_CHGMAX] = {.rt = {0, 19200000, 16000}},
|
||||
/* uV max charge voltage*/
|
||||
[TBL_INPUTVOL] = {.rt = {3200000, 19520000, 64000}},
|
||||
/* uV input charge voltage*/
|
||||
[TBL_INPUTCUR] = {.rt = {0, 6350000, 50000}},
|
||||
/*uA input current*/
|
||||
[TBL_SYSVMIN] = {.rt = {1024000, 16182000, 256000}},
|
||||
/* uV min system voltage*/
|
||||
[TBL_OTGVOL] = {.rt = {4480000, 20800000, 64000}},
|
||||
/*uV OTG volage*/
|
||||
[TBL_OTGCUR] = {.rt = {0, 6350000, 50000}},
|
||||
};
|
||||
|
||||
static u32 bq25700_find_idx(u32 value, enum bq25700_table_ids id)
|
||||
{
|
||||
const struct bq25700_range *rtbl = &bq25700_tables[id].rt;
|
||||
u32 rtbl_size;
|
||||
u32 idx;
|
||||
|
||||
rtbl_size = (rtbl->max - rtbl->min) / rtbl->step + 1;
|
||||
|
||||
for (idx = 1;
|
||||
idx < rtbl_size && (idx * rtbl->step + rtbl->min <= value);
|
||||
idx++)
|
||||
;
|
||||
|
||||
return idx - 1;
|
||||
}
|
||||
|
||||
static bool bq25700_charger_status(struct bq25700 *charger)
|
||||
{
|
||||
int state_of_charger;
|
||||
u16 value;
|
||||
|
||||
value = bq25700_read(charger, BQ25700_CHARGERSTAUS_REG);
|
||||
state_of_charger = value >> 15;
|
||||
|
||||
return state_of_charger;
|
||||
}
|
||||
|
||||
static bool bq25703_charger_status(struct bq25700 *charger)
|
||||
{
|
||||
int state_of_charger;
|
||||
u16 value;
|
||||
|
||||
value = bq25700_read(charger, BQ25703_CHARGERSTAUS_REG);
|
||||
state_of_charger = value >> 15;
|
||||
|
||||
return state_of_charger;
|
||||
}
|
||||
|
||||
static bool bq257xx_charger_status(struct udevice *dev)
|
||||
{
|
||||
struct bq25700 *charger = dev_get_priv(dev);
|
||||
|
||||
if (charger->chip_id == BQ25700_ID)
|
||||
return bq25700_charger_status(charger);
|
||||
else
|
||||
return bq25703_charger_status(charger);
|
||||
}
|
||||
|
||||
static int bq25700_charger_capability(struct udevice *dev)
|
||||
{
|
||||
return FG_CAP_CHARGER;
|
||||
}
|
||||
|
||||
static int bq25700_get_usb_type(void)
|
||||
{
|
||||
#ifdef CONFIG_PHY_ROCKCHIP_INNO_USB2
|
||||
return rockchip_chg_get_type();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int bq25700_get_pd_output_val(struct bq25700 *charger,
|
||||
int *vol, int *cur)
|
||||
{
|
||||
struct power_delivery_data pd_data;
|
||||
int ret;
|
||||
|
||||
if (!charger->pd[0] && !charger->pd[1]) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memset(&pd_data, 0, sizeof(pd_data));
|
||||
int i = 0;
|
||||
for (i = 0; i < PD_MUN; i++) {
|
||||
if (!charger->pd[i]) {
|
||||
continue;
|
||||
}
|
||||
ret = power_delivery_get_data(charger->pd[i], &pd_data);
|
||||
if (ret) {
|
||||
continue;
|
||||
}
|
||||
if (!pd_data.online || !pd_data.voltage || !pd_data.current) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*vol = pd_data.voltage;
|
||||
*cur = pd_data.current;
|
||||
printf("voltage is %d current is %d\n", *vol, *cur);
|
||||
goto end;
|
||||
}
|
||||
return -EINVAL;
|
||||
|
||||
end:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bq25703_charger_current_init(struct bq25700 *charger)
|
||||
{
|
||||
u16 charge_current = BQ25700_CHARGE_CURRENT_1500MA;
|
||||
u16 sdp_inputcurrent = BQ25700_SDP_INPUT_CURRENT_500MA;
|
||||
u16 dcp_inputcurrent = BQ25700_DCP_INPUT_CURRENT_1500MA;
|
||||
int pd_inputvol, pd_inputcurrent;
|
||||
u16 vol_idx = 0, cur_idx;
|
||||
u16 temp;
|
||||
|
||||
temp = bq25700_read(charger, BQ25703_CHARGEOPTION0_REG);
|
||||
temp &= (~WATCHDOG_ENSABLE);
|
||||
bq25700_write(charger, BQ25703_CHARGEOPTION0_REG, temp);
|
||||
|
||||
if (!bq25700_get_pd_output_val(charger, &pd_inputvol,
|
||||
&pd_inputcurrent)) {
|
||||
if (pd_inputvol > 5000000) {
|
||||
vol_idx = bq25700_find_idx(pd_inputvol - 1280000 - 3200000,
|
||||
TBL_INPUTVOL);
|
||||
vol_idx = vol_idx << 6;
|
||||
}
|
||||
cur_idx = bq25700_find_idx(pd_inputcurrent,
|
||||
TBL_INPUTCUR);
|
||||
cur_idx = cur_idx << 8;
|
||||
if (pd_inputcurrent != 0)
|
||||
{
|
||||
bq25700_write(charger, BQ25703_INPUTCURREN_REG,
|
||||
cur_idx);
|
||||
if (vol_idx)
|
||||
bq25700_write(charger, BQ25703_INPUTVOLTAGE_REG,
|
||||
vol_idx);
|
||||
charge_current = bq25700_find_idx(pd_inputcurrent,
|
||||
TBL_ICHG);
|
||||
charge_current = charge_current << 6;
|
||||
}
|
||||
} else {
|
||||
bq25700_write(charger, BQ25703_INPUTCURREN_REG,
|
||||
dcp_inputcurrent);
|
||||
}
|
||||
|
||||
if (bq25703_charger_status(charger)) {
|
||||
bq25700_write(charger, BQ25703_CHARGECURREN_REG,
|
||||
charge_current);
|
||||
}
|
||||
}
|
||||
|
||||
static int bq25700_ofdata_to_platdata(struct udevice *dev)
|
||||
{
|
||||
struct bq25700 *charger = dev_get_priv(dev);
|
||||
const void *blob = gd->fdt_blob;
|
||||
int node, node1;
|
||||
|
||||
charger->dev = dev;
|
||||
|
||||
node = fdt_node_offset_by_compatible(blob, 0, COMPAT_BQ25700);
|
||||
node1 = fdt_node_offset_by_compatible(blob, 0, COMPAT_BQ25703);
|
||||
if ((node < 0) && (node1 < 0)) {
|
||||
printf("Can't find dts node for charger bq25700\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (node < 0) {
|
||||
node = node1;
|
||||
charger->chip_id = BQ25703_ID;
|
||||
} else {
|
||||
charger->chip_id = BQ25700_ID;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bq25700_probe(struct udevice *dev)
|
||||
{
|
||||
struct bq25700 *charger = dev_get_priv(dev);
|
||||
int ret;
|
||||
|
||||
struct udevice *pd_tmp;
|
||||
struct udevice *dev_tmp;
|
||||
|
||||
for (uclass_first_device(UCLASS_PD, &pd_tmp);
|
||||
pd_tmp;
|
||||
uclass_next_device(&pd_tmp))
|
||||
{
|
||||
dev_tmp = dev_get_parent(pd_tmp);
|
||||
if (!strncmp(TYPEC0_I2C, dev_tmp->name, strlen(TYPEC0_I2C))) { // Ensure that typec0 has the highest priority
|
||||
charger->pd[0] = pd_tmp;
|
||||
} else if (!strncmp(TYPEC1_I2C, dev_tmp->name, strlen(TYPEC1_I2C))) {
|
||||
charger->pd[1] = pd_tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if (charger->chip_id == BQ25703_ID) {
|
||||
bq25703_charger_current_init(charger);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct udevice_id charger_ids[] = {
|
||||
{.compatible = "ti,bq25700"},
|
||||
{.compatible = "ti,bq25703"},
|
||||
{},
|
||||
{ },
|
||||
};
|
||||
|
||||
static struct dm_fuel_gauge_ops charger_ops = {
|
||||
.get_chrg_online = bq257xx_charger_status,
|
||||
.capability = bq25700_charger_capability,
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(bq25700_charger) = {
|
||||
.name = "bq25700_charger",
|
||||
.id = UCLASS_FG,
|
||||
.probe = bq25700_probe,
|
||||
.of_match = charger_ids,
|
||||
.ops = &charger_ops,
|
||||
.ofdata_to_platdata = bq25700_ofdata_to_platdata,
|
||||
.priv_auto_alloc_size = sizeof(struct bq25700),
|
||||
};
|
||||
366
drivers/power/charge_animation.c
Executable file
366
drivers/power/charge_animation.c
Executable file
@@ -0,0 +1,366 @@
|
||||
/*
|
||||
* (C) Copyright 2017 Rockchip Electronics Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include <asm/io.h>
|
||||
#include <asm/gpio.h>
|
||||
#include <common.h>
|
||||
#include <console.h>
|
||||
#include <dm.h>
|
||||
#include <errno.h>
|
||||
#include <led.h>
|
||||
#include <rtc.h>
|
||||
#include <pwm.h>
|
||||
#include <power/charge_display.h>
|
||||
#include <power/charge_animation.h>
|
||||
#include <power/fuel_gauge.h>
|
||||
#include <power/pmic.h>
|
||||
#include <mcu/mcu-uclass.h>
|
||||
#ifdef CONFIG_IRQ
|
||||
#include <irq-generic.h>
|
||||
#include <rk_timer_irq.h>
|
||||
#endif
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#define IMAGE_RECALC_IDX -1
|
||||
#define IMAGE_SOC_100_IDX(n) ((n) - 2)
|
||||
#define IMAGE_LOWPOWER_IDX(n) ((n) - 1)
|
||||
#define SYSTEM_SUSPEND_DELAY_MS 5000
|
||||
#define FUEL_GAUGE_POLL_MS 1000
|
||||
|
||||
#define LED_CHARGING_NAME "battery_charging"
|
||||
#define LED_CHARGING_FULL_NAME "battery_full"
|
||||
#define LED_CHARGING_START_NAME "battery_start"
|
||||
|
||||
struct charge_image {
|
||||
const char *name;
|
||||
int soc;
|
||||
int period; /* ms */
|
||||
};
|
||||
|
||||
struct charge_animation_priv {
|
||||
struct udevice *fg;
|
||||
struct udevice *charger;
|
||||
struct udevice *mcu;
|
||||
#ifdef CONFIG_LED
|
||||
struct udevice *led_charging;
|
||||
struct udevice *led_full;
|
||||
struct udevice *led_start;
|
||||
#endif
|
||||
const struct charge_image *image;
|
||||
int image_num;
|
||||
|
||||
int auto_wakeup_key_state;
|
||||
ulong auto_screen_off_timeout; /* ms */
|
||||
ulong suspend_delay_timeout; /* ms */
|
||||
};
|
||||
|
||||
struct gpio_desc powerkey_gpio;
|
||||
static int leds_switch = 0;
|
||||
|
||||
#ifdef CONFIG_LED
|
||||
static int leds_update(struct udevice *dev, int soc)
|
||||
{
|
||||
struct charge_animation_priv *priv = dev_get_priv(dev);
|
||||
static int old_soc = -1;
|
||||
int ret, ledst;
|
||||
|
||||
if (old_soc == soc)
|
||||
return 0;
|
||||
|
||||
old_soc = soc;
|
||||
if (priv->led_charging) {
|
||||
ledst = (soc < 100) ? LEDST_ON : LEDST_OFF;
|
||||
ret = led_set_state(priv->led_charging, ledst);
|
||||
if (ret) {
|
||||
printf("set charging led %s failed, ret=%d\n",
|
||||
(ledst == LEDST_ON) ? "ON" : "OFF", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (priv->led_full) {
|
||||
ledst = (soc == 100) ? LEDST_ON : LEDST_OFF;
|
||||
ret = led_set_state(priv->led_full, ledst);
|
||||
if (ret) {
|
||||
printf("set charging full led %s failed, ret=%d\n",
|
||||
ledst == LEDST_ON ? "ON" : "OFF", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int leds_charge_on(struct udevice *dev, int soc)
|
||||
{
|
||||
struct charge_animation_priv *priv = dev_get_priv(dev);
|
||||
int ret, ledst;
|
||||
|
||||
ledst = LEDST_ON;
|
||||
ret = led_set_state(priv->led_full, ledst);
|
||||
if (ret) {
|
||||
printf("set charging full led %s failed, ret=%d\n",
|
||||
ledst == LEDST_ON ? "ON" : "OFF", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int leds_charge_off(struct udevice *dev, int soc)
|
||||
{
|
||||
struct charge_animation_priv *priv = dev_get_priv(dev);
|
||||
int ret, ledst;
|
||||
ledst = LEDST_OFF;
|
||||
ret = led_set_state(priv->led_charging, ledst);
|
||||
if (ret) {
|
||||
printf("set charging full led %s failed, ret=%d\n",
|
||||
ledst == LEDST_ON ? "ON" : "OFF", ret);
|
||||
return ret;
|
||||
}
|
||||
ret = led_set_state(priv->led_full, ledst);
|
||||
if (ret) {
|
||||
printf("set charging full led %s failed, ret=%d\n",
|
||||
ledst == LEDST_ON ? "ON" : "OFF", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int leds_charge_update(struct udevice *dev, int soc)
|
||||
{
|
||||
struct charge_animation_priv *priv = dev_get_priv(dev);
|
||||
int ret, ledst;
|
||||
if (leds_switch > 5){
|
||||
leds_charge_on(dev, soc);
|
||||
} else {
|
||||
leds_charge_off(dev, soc);
|
||||
}
|
||||
leds_switch++;
|
||||
if (leds_switch > 10)
|
||||
leds_switch = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
static int leds_update(struct udevice *dev, int soc) { return 0; }
|
||||
|
||||
static int leds_charge_on(struct udevice *dev, int soc) { return 0; }
|
||||
|
||||
static int leds_charge_off(struct udevice *dev, int soc) { return 0; }
|
||||
|
||||
static int leds_charge_update(struct udevice *dev, int soc) { return 0; }
|
||||
#endif
|
||||
|
||||
static int charge_animation_ofdata_to_platdata(struct udevice *dev)
|
||||
{
|
||||
struct charge_animation_pdata *pdata = dev_get_platdata(dev);
|
||||
pdata->low_power_voltage =
|
||||
dev_read_u32_default(dev, "uboot-low-power-voltage", 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fg_charger_get_chrg_online(struct udevice *dev)
|
||||
{
|
||||
struct charge_animation_priv *priv = dev_get_priv(dev);
|
||||
struct udevice *charger;
|
||||
|
||||
charger = priv->charger ? : priv->fg;
|
||||
|
||||
return fuel_gauge_get_chrg_online(charger);
|
||||
}
|
||||
|
||||
static int get_reboot_state(void){
|
||||
const char *var_name = "battery_charge";
|
||||
char *value = env_get(var_name);
|
||||
if (value)
|
||||
if (strcmp(value, "0") == 0) {
|
||||
env_set(var_name, "1");
|
||||
env_save();
|
||||
return 0;
|
||||
}
|
||||
|
||||
env_set(var_name, "1");
|
||||
env_save();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int charge_animation_show(struct udevice *dev)
|
||||
{
|
||||
int soc, voltage, ret, charging = 0;
|
||||
struct charge_animation_priv *priv = dev_get_priv(dev);
|
||||
struct charge_animation_pdata *pdata = dev_get_platdata(dev);
|
||||
struct udevice *fg = priv->fg;
|
||||
struct udevice *mcu = priv->mcu;
|
||||
|
||||
voltage = fuel_gauge_get_voltage(fg);
|
||||
if (voltage < 0)
|
||||
return -EINVAL;
|
||||
|
||||
while (voltage < pdata->low_power_voltage + 50) {
|
||||
soc = fuel_gauge_update_get_soc(fg);
|
||||
if (soc < 0 || soc > 100) {
|
||||
printf("get soc failed: %d\n", soc);
|
||||
continue;
|
||||
} else if (soc >= 1) {
|
||||
printf("soc is: %d\n", soc);
|
||||
break;
|
||||
}
|
||||
|
||||
voltage = fuel_gauge_get_voltage(fg);
|
||||
if (voltage < 0) {
|
||||
printf("get voltage failed: %d\n", voltage);
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = leds_update(dev, soc);
|
||||
if (ret)
|
||||
printf("update led failed: %d\n", ret);
|
||||
|
||||
printf("soc is: %d voltage is :%d\n", soc, voltage);
|
||||
|
||||
charging = fg_charger_get_chrg_online(dev);
|
||||
if (charging <= 0) {
|
||||
mcu_shutdown(); // shutdown system power
|
||||
}
|
||||
mdelay(100);
|
||||
};
|
||||
leds_charge_off(dev, soc);
|
||||
|
||||
ret = get_reboot_state();
|
||||
|
||||
charging = fg_charger_get_chrg_online(dev);
|
||||
|
||||
if (!(charging <= 0) && ret != 0)
|
||||
while(1){
|
||||
ret = dm_gpio_get_value(&powerkey_gpio);
|
||||
if (ret == 0){
|
||||
break;
|
||||
}
|
||||
|
||||
charging = fg_charger_get_chrg_online(dev);
|
||||
if (charging <= 0) {
|
||||
mcu_shutdown(); // shutdown system power
|
||||
}
|
||||
|
||||
soc = fuel_gauge_update_get_soc(fg);
|
||||
if (soc == 100){
|
||||
leds_charge_on(dev, soc);
|
||||
}else if (soc < 100){
|
||||
leds_charge_update(dev, soc);
|
||||
}
|
||||
mdelay(300);
|
||||
}
|
||||
|
||||
leds_charge_off(dev, soc);
|
||||
|
||||
ret = led_set_state(priv->led_start, LEDST_ON);
|
||||
if (!ret)
|
||||
printf("Found Charging-Start LED\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fg_charger_get_device(struct udevice **fuel_gauge,
|
||||
struct udevice **charger)
|
||||
{
|
||||
struct udevice *dev;
|
||||
struct uclass *uc;
|
||||
int ret, cap;
|
||||
|
||||
*fuel_gauge = NULL,
|
||||
*charger = NULL;
|
||||
|
||||
ret = uclass_get(UCLASS_FG, &uc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
for (uclass_first_device(UCLASS_FG, &dev);
|
||||
dev;
|
||||
uclass_next_device(&dev)) {
|
||||
cap = fuel_gauge_capability(dev);
|
||||
if (cap == (FG_CAP_CHARGER | FG_CAP_FUEL_GAUGE)) {
|
||||
*fuel_gauge = dev;
|
||||
*charger = NULL;
|
||||
} else if (cap == FG_CAP_FUEL_GAUGE) {
|
||||
*fuel_gauge = dev;
|
||||
} else if (cap == FG_CAP_CHARGER) {
|
||||
*charger = dev;
|
||||
}
|
||||
}
|
||||
|
||||
return (*fuel_gauge) ? 0 : -ENODEV;
|
||||
}
|
||||
|
||||
static const struct dm_charge_display_ops charge_animation_ops = {
|
||||
.show = charge_animation_show,
|
||||
};
|
||||
|
||||
static int charge_animation_probe(struct udevice *dev)
|
||||
{
|
||||
struct charge_animation_priv *priv = dev_get_priv(dev);
|
||||
int ret, soc;
|
||||
/* Get PMIC: used for power off system */
|
||||
ret = uclass_get_device(UCLASS_MCU, 0, &priv->mcu);
|
||||
if (ret) {
|
||||
if (ret == -ENODEV)
|
||||
printf("Can't find MCU\n");
|
||||
else
|
||||
printf("Get UCLASS MCU failed: %d\n", ret);
|
||||
}
|
||||
|
||||
/* Get fuel gauge and charger(If need) */
|
||||
ret = fg_charger_get_device(&priv->fg, &priv->charger);
|
||||
if (ret) {
|
||||
if (ret == -ENODEV)
|
||||
debug("Can't find FG\n");
|
||||
else
|
||||
debug("Get UCLASS FG failed: %d\n", ret);
|
||||
// return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_LED
|
||||
ret = led_get_by_label(LED_CHARGING_NAME, &priv->led_charging);
|
||||
if (!ret)
|
||||
printf("Found Charging LED \n");
|
||||
|
||||
ret = led_get_by_label(LED_CHARGING_FULL_NAME, &priv->led_full);
|
||||
if (!ret)
|
||||
printf("Found Charging-Full LED\n");
|
||||
|
||||
ret = led_get_by_label(LED_CHARGING_START_NAME, &priv->led_start);
|
||||
if (!ret)
|
||||
printf("Found Charging-Start LED\n");
|
||||
#endif
|
||||
ret = gpio_request_by_name(dev, "powerkey-gpio", 0, &powerkey_gpio, 0);
|
||||
if (dm_gpio_is_valid(&powerkey_gpio)) {
|
||||
dm_gpio_set_dir_flags(&powerkey_gpio, GPIOD_IS_IN);
|
||||
}
|
||||
|
||||
printf("Enable charge animation display\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct udevice_id charge_animation_ids[] = {
|
||||
{ .compatible = "rockchip,uboot-charge" },
|
||||
{ },
|
||||
};
|
||||
|
||||
U_BOOT_DRIVER(charge_animation) = {
|
||||
.name = "charge-animation",
|
||||
.id = UCLASS_CHARGE_DISPLAY,
|
||||
.probe = charge_animation_probe,
|
||||
.of_match = charge_animation_ids,
|
||||
.ops = &charge_animation_ops,
|
||||
.ofdata_to_platdata = charge_animation_ofdata_to_platdata,
|
||||
.platdata_auto_alloc_size = sizeof(struct charge_animation_pdata),
|
||||
.priv_auto_alloc_size = sizeof(struct charge_animation_priv),
|
||||
};
|
||||
11
drivers/power/fuel_gauge/Kconfig
Executable file
11
drivers/power/fuel_gauge/Kconfig
Executable file
@@ -0,0 +1,11 @@
|
||||
config DM_FUEL_GAUGE
|
||||
bool "Enable driver model fuel gauge support"
|
||||
depends on DM
|
||||
help
|
||||
This adds a simple uclass for fuel gauge.
|
||||
|
||||
config POWER_FG_CW201X
|
||||
bool "CW201X Fuel gauge support"
|
||||
depends on DM_FUEL_GAUGE
|
||||
help
|
||||
This adds support for CW201X fuel gauge support.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user