-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Rockchip rk3588 #7059
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
/* | ||
* Copyright (C) 2019, Theobroma Systems Design und Consulting GmbH | ||
* Copyright (c) 2024, Rockchip, Inc. All rights reserved. | ||
* | ||
*/ | ||
|
||
#include <common.h> | ||
#include <io.h> | ||
#include <kernel/panic.h> | ||
#include <mm/core_memprot.h> | ||
#include <platform.h> | ||
#include <platform_config.h> | ||
|
||
#define FIREWALL_DDR_RGN(i) ((i) * 0x4) | ||
#define FIREWALL_DDR_CON 0xf0 | ||
#define FIREWALL_DSU_RGN(i) ((i) * 0x4) | ||
#define FIREWALL_DSU_CON(i) (0xf0 + ((i) * 0x4)) | ||
|
||
#define RG_MAP_SECURE(top, base) \ | ||
(((((top) - 1) & 0x7fff) << 16) | ((base) & 0x7fff)) | ||
|
||
#define DDR_CHN_CNT 4 | ||
|
||
register_phys_mem_pgdir(MEM_AREA_IO_SEC, FIREWALL_DDR_BASE, FIREWALL_DDR_SIZE); | ||
register_phys_mem_pgdir(MEM_AREA_IO_SEC, FIREWALL_DSU_BASE, FIREWALL_DSU_SIZE); | ||
|
||
int platform_secure_ddr_region(int rgn, paddr_t st, size_t sz) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How have you been able to find out how to set MMU configuration for this SoC? I cannot find any exact MMU register mappings in SoC's TRM. Actually, this file seems like a platform_rk3399.c copy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many different hardware blocks have their own MMUs. Most are the same type, but not always. These tend to be something different than the ARM SMMU type (these also exist, protecting PCIE and PHP blocks). They are documented in the TRMs in each block's respective chapter, although it is mostly in the register sections. |
||
{ | ||
vaddr_t fw_ddr_base = (vaddr_t)phys_to_virt_io(FIREWALL_DDR_BASE, FIREWALL_DDR_SIZE); | ||
vaddr_t fw_dsu_base = (vaddr_t)phys_to_virt_io(FIREWALL_DSU_BASE, FIREWALL_DSU_SIZE); | ||
paddr_t ed = st + sz; | ||
uint32_t st_mb = st / SIZE_M(1); | ||
uint32_t ed_mb = ed / SIZE_M(1); | ||
uint32_t i; | ||
|
||
if (!fw_ddr_base || !fw_dsu_base) | ||
panic(); | ||
|
||
assert(rgn <= 7); | ||
assert(st < ed); | ||
|
||
/* Check aligned 1MB */ | ||
assert(st % SIZE_M(1) == 0); | ||
assert(ed % SIZE_M(1) == 0); | ||
|
||
DMSG("protecting region %d: 0x%lx-0x%lx", rgn, st, ed); | ||
|
||
/* Map secure region in DDR */ | ||
io_write32(fw_ddr_base + FIREWALL_DDR_RGN(rgn), RG_MAP_SECURE(ed_mb, st_mb)); | ||
|
||
/* Map secure region in each DSU channel and enable */ | ||
for (i = 0; i < DDR_CHN_CNT; i++) { | ||
io_write32(fw_dsu_base + FIREWALL_DSU_RGN(i), RG_MAP_SECURE(ed_mb, st_mb)); | ||
io_setbits32(fw_dsu_base + FIREWALL_DSU_CON(i), BIT(rgn)); | ||
} | ||
|
||
/* Enable secure region for DDR */ | ||
io_setbits32(fw_ddr_base + FIREWALL_DDR_CON, BIT(rgn)); | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see rk3588 has two firewalls: FIREWALL_DDR with base address 0xFE030000 and FIREWALL_SYSMEM with base address 0xFE038000 have you been able to find out the difference? I guess the FIREWALL_DDR hold MMU registers, and FIREWALL_SYSMEM holds SMMU registers, but I cannot confirm this.