Ravi kumar has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot.
two different modem regions wifi and lte to be handled in QC_SEC and modem
Change-Id: Iebce62f89312aa1e40555b637a9ced5d6498d14e Signed-off-by: Manideep Kurumella mkurumel@codeaurora.org
Change-Id: Ib4592ca66d3d0db4c4768be4cd27422fe9f786b8 --- M src/soc/qualcomm/common/include/soc/mmu_common.h M src/soc/qualcomm/common/mmu.c M src/soc/qualcomm/sc7180/Makefile.inc A src/soc/qualcomm/sc7180/carve_out.c M src/soc/qualcomm/sc7180/include/soc/symbols.h M src/soc/qualcomm/sc7180/memlayout.ld M src/soc/qualcomm/sc7180/soc.c 7 files changed, 47 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46661/1
diff --git a/src/soc/qualcomm/common/include/soc/mmu_common.h b/src/soc/qualcomm/common/include/soc/mmu_common.h index a38196f..b6c8aab 100644 --- a/src/soc/qualcomm/common/include/soc/mmu_common.h +++ b/src/soc/qualcomm/common/include/soc/mmu_common.h @@ -14,5 +14,6 @@
void soc_mmu_dram_config_post_dram_init(void); void qc_mmu_dram_config_post_dram_init(void *ddr_base, size_t ddr_size); +bool soc_modem_carve_out(void **start, void **end);
#endif /* _SOC_QUALCOMM_MMU_COMMON_H_ */ diff --git a/src/soc/qualcomm/common/mmu.c b/src/soc/qualcomm/common/mmu.c index 4f606be..ba1173e 100644 --- a/src/soc/qualcomm/common/mmu.c +++ b/src/soc/qualcomm/common/mmu.c @@ -4,10 +4,19 @@ #include <soc/mmu.h> #include <soc/mmu_common.h>
+__weak bool soc_modem_carve_out(void **start, void **end) { return false; } __weak void soc_mmu_dram_config_post_dram_init(void) { /* no-op */ }
void qc_mmu_dram_config_post_dram_init(void *ddr_base, size_t ddr_size) { - mmu_config_range((void *)ddr_base, ddr_size, CACHED_RAM); + void *start = NULL; + void *end = NULL; + + if (!soc_modem_carve_out(&start, &end)) { + mmu_config_range((void *)ddr_base, ddr_size, CACHED_RAM); + } else { + mmu_config_range(ddr_base, start - ddr_base, CACHED_RAM); + mmu_config_range(end, ddr_base + ddr_size - end, CACHED_RAM); + } soc_mmu_dram_config_post_dram_init(); } diff --git a/src/soc/qualcomm/sc7180/Makefile.inc b/src/soc/qualcomm/sc7180/Makefile.inc index 7f52a9a..07d2652 100644 --- a/src/soc/qualcomm/sc7180/Makefile.inc +++ b/src/soc/qualcomm/sc7180/Makefile.inc @@ -45,6 +45,7 @@ romstage-y += gpio.c romstage-y += qupv3_i2c.c romstage-y += clock.c +romstage-y += carve_out.c romstage-$(CONFIG_SC7180_QSPI) += qspi.c romstage-y += qcom_qup_se.c romstage-y += qupv3_config.c @@ -52,6 +53,7 @@
################################################################################ ramstage-y += soc.c +ramstage-y += carve_out.c ramstage-y += timer.c ramstage-y += spi.c ramstage-y += qupv3_spi.c diff --git a/src/soc/qualcomm/sc7180/carve_out.c b/src/soc/qualcomm/sc7180/carve_out.c new file mode 100644 index 0000000..0f0bdd5 --- /dev/null +++ b/src/soc/qualcomm/sc7180/carve_out.c @@ -0,0 +1,26 @@ +#include <arch/stages.h> +#include <soc/mmu_common.h> +#include <soc/symbols.h> +#include <device/mmio.h> + +#define MODEM_ID_ADDR (void *)0x146ABC00 +#define MODEM_ID_LTE 0x004c5445 +#define MODEM_ID_WIFI 0x57494649 +#define MODEM_ID_WIFI_END (void *)0x88000000 + +bool soc_modem_carve_out(void **start, void **end) +{ + uint32_t modem_id = read32(MODEM_ID_ADDR); + switch (modem_id) { + case MODEM_ID_LTE: + *start = _dram_modem; + *end = _edram_modem; + return true; + case MODEM_ID_WIFI: + *start = _dram_modem; + *end = MODEM_ID_WIFI_END; + return true; + default: + return false; + } +} diff --git a/src/soc/qualcomm/sc7180/include/soc/symbols.h b/src/soc/qualcomm/sc7180/include/soc/symbols.h index f15a8bb..b369d55 100644 --- a/src/soc/qualcomm/sc7180/include/soc/symbols.h +++ b/src/soc/qualcomm/sc7180/include/soc/symbols.h @@ -9,6 +9,7 @@ DECLARE_REGION(bsram) DECLARE_REGION(dram_aop) DECLARE_REGION(dram_soc) +DECLARE_REGION(dram_modem) DECLARE_REGION(dcb) DECLARE_REGION(pmic) DECLARE_REGION(limits_cfg) diff --git a/src/soc/qualcomm/sc7180/memlayout.ld b/src/soc/qualcomm/sc7180/memlayout.ld index ce08478..e450c33 100644 --- a/src/soc/qualcomm/sc7180/memlayout.ld +++ b/src/soc/qualcomm/sc7180/memlayout.ld @@ -51,6 +51,7 @@ REGION(dram_aop, 0x80800000, 0x040000, 0x1000) REGION(dram_soc, 0x80900000, 0x200000, 0x1000) BL31(0x80B00000, 1M) + REGION(dram_modem, 0x86000000, 0x8C00000, 0x1000) POSTRAM_CBFS_CACHE(0x9F800000, 16M) RAMSTAGE(0xA0800000, 16M) } diff --git a/src/soc/qualcomm/sc7180/soc.c b/src/soc/qualcomm/sc7180/soc.c index 74f0868..9037c45 100644 --- a/src/soc/qualcomm/sc7180/soc.c +++ b/src/soc/qualcomm/sc7180/soc.c @@ -9,12 +9,18 @@
static void soc_read_resources(struct device *dev) { + void *start = NULL; + void *end = NULL; + ram_resource(dev, 0, (uintptr_t)ddr_region->offset / KiB, ddr_region->size / KiB); reserved_ram_resource(dev, 1, (uintptr_t)_dram_aop / KiB, REGION_SIZE(dram_aop) / KiB); reserved_ram_resource(dev, 2, (uintptr_t)_dram_soc / KiB, REGION_SIZE(dram_soc) / KiB); + if (soc_modem_carve_out(&start, &end)) { + reserved_ram_resource(dev, 3, (uintptr_t)start / KiB, (end - start) / KiB); + } }
static void soc_init(struct device *dev)
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 1:
(4 comments)
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... PS1, Line 6: #define MODEM_ID_ADDR (void *)0x146ABC00 Macros with complex values should be enclosed in parentheses
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... PS1, Line 9: #define MODEM_ID_WIFI_END (void *)0x88000000 Macros with complex values should be enclosed in parentheses
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... PS1, Line 14: switch (modem_id) { switch and case should be at the same indent
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/soc... File src/soc/qualcomm/sc7180/soc.c:
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/soc... PS1, Line 21: if (soc_modem_carve_out(&start, &end)) { braces {} are not necessary for single statement blocks
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
PS1: needs a SPDX license header
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 1:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... PS1, Line 6: #define MODEM_ID_ADDR (void *)0x146ABC00 This should be declared as a 4-byte region in memlayout.ld instead.
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... PS1, Line 9: #define MODEM_ID_WIFI_END (void *)0x88000000 Rather than declaring that here, let's split the memlayout region in two (e.g. REGION(dram_modem_wifi_only, 0x86000000, 32M, 4) and REGION(dram_modem_extra, 0x88000000, 108M, 4)). Then just use the bounds _dram_modem_wifi_only and _edram_modem_extra for the LTE case.
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Julius Werner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46661
to look at the new patch set (#2).
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot.
two different modem regions wifi and lte to be handled in QC_SEC and modem
Change-Id: Ib4592ca66d3d0db4c4768be4cd27422fe9f786b8 Signed-off-by: Ravi Kumar Bokka rbokka@codeaurora.org --- M src/soc/qualcomm/common/include/soc/mmu_common.h M src/soc/qualcomm/common/mmu.c M src/soc/qualcomm/sc7180/Makefile.inc A src/soc/qualcomm/sc7180/carve_out.c M src/soc/qualcomm/sc7180/include/soc/symbols.h M src/soc/qualcomm/sc7180/memlayout.ld M src/soc/qualcomm/sc7180/soc.c 7 files changed, 55 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46661/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 2:
(4 comments)
https://review.coreboot.org/c/coreboot/+/46661/2/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/2/src/soc/qualcomm/sc7180/car... PS2, Line 15: memset(_modem_id, 0, REGION_SIZE(modem_id)); code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/46661/2/src/soc/qualcomm/sc7180/car... PS2, Line 15: memset(_modem_id, 0, REGION_SIZE(modem_id)); please, no spaces at the start of a line
https://review.coreboot.org/c/coreboot/+/46661/2/src/soc/qualcomm/sc7180/car... PS2, Line 18: switch (modem_id) { switch and case should be at the same indent
https://review.coreboot.org/c/coreboot/+/46661/2/src/soc/qualcomm/sc7180/soc... File src/soc/qualcomm/sc7180/soc.c:
https://review.coreboot.org/c/coreboot/+/46661/2/src/soc/qualcomm/sc7180/soc... PS2, Line 21: if (soc_modem_carve_out(&start, &end)) { braces {} are not necessary for single statement blocks
Ravi Kumar Bokka has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... PS1, Line 6: #define MODEM_ID_ADDR (void *)0x146ABC00
This should be declared as a 4-byte region in memlayout.ld instead.
Done
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... PS1, Line 9: #define MODEM_ID_WIFI_END (void *)0x88000000
Rather than declaring that here, let's split the memlayout region in two (e.g. […]
Done
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Julius Werner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46661
to look at the new patch set (#3).
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot.
two different modem regions wifi and lte to be handled in QC_SEC and modem
Change-Id: Ib4592ca66d3d0db4c4768be4cd27422fe9f786b8 Signed-off-by: Ravi Kumar Bokka rbokka@codeaurora.org --- M src/soc/qualcomm/common/include/soc/mmu_common.h M src/soc/qualcomm/common/mmu.c M src/soc/qualcomm/sc7180/Makefile.inc A src/soc/qualcomm/sc7180/carve_out.c M src/soc/qualcomm/sc7180/include/soc/symbols.h M src/soc/qualcomm/sc7180/memlayout.ld M src/soc/qualcomm/sc7180/soc.c 7 files changed, 55 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46661/3
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/car... PS3, Line 18: switch (modem_id) { switch and case should be at the same indent
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/soc... File src/soc/qualcomm/sc7180/soc.c:
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/soc... PS3, Line 21: if (soc_modem_carve_out(&start, &end)) { braces {} are not necessary for single statement blocks
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/car... PS3, Line 16: uint32_t modem_id = read32(_modem_id); How do you expect this to work? You're literally reading the value right after you set it to zero!
This function is called twice by coreboot, so you can't set it to zero after reading either. If you want this to get explicitly zeroed on cold boot, that needs to be done by QC-SEC.
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Julius Werner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46661
to look at the new patch set (#4).
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot.
two different modem regions wifi and lte to be handled in QC_SEC and modem
Change-Id: Ib4592ca66d3d0db4c4768be4cd27422fe9f786b8 Signed-off-by: Ravi Kumar Bokka rbokka@codeaurora.org --- M src/soc/qualcomm/common/include/soc/mmu_common.h M src/soc/qualcomm/common/mmu.c M src/soc/qualcomm/sc7180/Makefile.inc A src/soc/qualcomm/sc7180/carve_out.c M src/soc/qualcomm/sc7180/include/soc/symbols.h M src/soc/qualcomm/sc7180/memlayout.ld M src/soc/qualcomm/sc7180/soc.c 7 files changed, 54 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46661/4
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 4:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46661/4/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/4/src/soc/qualcomm/sc7180/car... PS4, Line 16: switch (modem_id) that open brace { should be on the previous line
https://review.coreboot.org/c/coreboot/+/46661/4/src/soc/qualcomm/sc7180/soc... File src/soc/qualcomm/sc7180/soc.c:
https://review.coreboot.org/c/coreboot/+/46661/4/src/soc/qualcomm/sc7180/soc... PS4, Line 21: if (soc_modem_carve_out(&start, &end)) { braces {} are not necessary for single statement blocks
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Julius Werner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46661
to look at the new patch set (#5).
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot.
two different modem regions wifi and lte to be handled in QC_SEC and modem
Change-Id: Ib4592ca66d3d0db4c4768be4cd27422fe9f786b8 Signed-off-by: Ravi Kumar Bokka rbokka@codeaurora.org --- M src/soc/qualcomm/common/include/soc/mmu_common.h M src/soc/qualcomm/common/mmu.c M src/soc/qualcomm/sc7180/Makefile.inc A src/soc/qualcomm/sc7180/carve_out.c M src/soc/qualcomm/sc7180/include/soc/symbols.h M src/soc/qualcomm/sc7180/memlayout.ld M src/soc/qualcomm/sc7180/soc.c 7 files changed, 52 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46661/5
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 5: Code-Review+2
Okay, this patch looks good now, but I still can't merge it because of the weird dependency chain you built here. We don't want to merge the herobrine patches yet, or that HACK patch, and CB:45418 is basically just an earlier version of this patch that should just be squashed into it.
So please squash this patch and CB:45418 together and rearrange them so that the resulting patch stands at the bottom of the dependency chain, so I can merge it.
Hello build bot (Jenkins), Patrick Georgi, Martin Roth, Julius Werner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46661
to look at the new patch set (#6).
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot.
two different modem regions wifi and lte to be handled in QC_SEC and modem
Change-Id: Ib4592ca66d3d0db4c4768be4cd27422fe9f786b8 Signed-off-by: Ravi Kumar Bokka rbokka@codeaurora.org --- M src/soc/qualcomm/common/include/soc/mmu_common.h M src/soc/qualcomm/common/mmu.c M src/soc/qualcomm/sc7180/Makefile.inc A src/soc/qualcomm/sc7180/carve_out.c M src/soc/qualcomm/sc7180/include/soc/symbols.h M src/soc/qualcomm/sc7180/memlayout.ld M src/soc/qualcomm/sc7180/soc.c 7 files changed, 52 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46661/6
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 6:
Duplicate of https://review.coreboot.org/c/coreboot/+/45418?
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 6: Code-Review+2
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
Patch Set 6:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46661/1/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
PS1:
needs a SPDX license header
Done
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/car... File src/soc/qualcomm/sc7180/carve_out.c:
https://review.coreboot.org/c/coreboot/+/46661/3/src/soc/qualcomm/sc7180/car... PS3, Line 16: uint32_t modem_id = read32(_modem_id);
How do you expect this to work? You're literally reading the value right after you set it to zero! […]
Done
Julius Werner has submitted this change. ( https://review.coreboot.org/c/coreboot/+/46661 )
Change subject: sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot. ......................................................................
sc7180: Add Modem region in memlayout to avoid modem cleanup in Secboot reboot.
two different modem regions wifi and lte to be handled in QC_SEC and modem
Change-Id: Ib4592ca66d3d0db4c4768be4cd27422fe9f786b8 Signed-off-by: Ravi Kumar Bokka rbokka@codeaurora.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/46661 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Julius Werner jwerner@chromium.org --- M src/soc/qualcomm/common/include/soc/mmu_common.h M src/soc/qualcomm/common/mmu.c M src/soc/qualcomm/sc7180/Makefile.inc A src/soc/qualcomm/sc7180/carve_out.c M src/soc/qualcomm/sc7180/include/soc/symbols.h M src/soc/qualcomm/sc7180/memlayout.ld M src/soc/qualcomm/sc7180/soc.c 7 files changed, 52 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved
diff --git a/src/soc/qualcomm/common/include/soc/mmu_common.h b/src/soc/qualcomm/common/include/soc/mmu_common.h index a38196f..b6c8aab 100644 --- a/src/soc/qualcomm/common/include/soc/mmu_common.h +++ b/src/soc/qualcomm/common/include/soc/mmu_common.h @@ -14,5 +14,6 @@
void soc_mmu_dram_config_post_dram_init(void); void qc_mmu_dram_config_post_dram_init(void *ddr_base, size_t ddr_size); +bool soc_modem_carve_out(void **start, void **end);
#endif /* _SOC_QUALCOMM_MMU_COMMON_H_ */ diff --git a/src/soc/qualcomm/common/mmu.c b/src/soc/qualcomm/common/mmu.c index 4f606be..ba1173e 100644 --- a/src/soc/qualcomm/common/mmu.c +++ b/src/soc/qualcomm/common/mmu.c @@ -4,10 +4,19 @@ #include <soc/mmu.h> #include <soc/mmu_common.h>
+__weak bool soc_modem_carve_out(void **start, void **end) { return false; } __weak void soc_mmu_dram_config_post_dram_init(void) { /* no-op */ }
void qc_mmu_dram_config_post_dram_init(void *ddr_base, size_t ddr_size) { - mmu_config_range((void *)ddr_base, ddr_size, CACHED_RAM); + void *start = NULL; + void *end = NULL; + + if (!soc_modem_carve_out(&start, &end)) { + mmu_config_range((void *)ddr_base, ddr_size, CACHED_RAM); + } else { + mmu_config_range(ddr_base, start - ddr_base, CACHED_RAM); + mmu_config_range(end, ddr_base + ddr_size - end, CACHED_RAM); + } soc_mmu_dram_config_post_dram_init(); } diff --git a/src/soc/qualcomm/sc7180/Makefile.inc b/src/soc/qualcomm/sc7180/Makefile.inc index 7f52a9a..07d2652 100644 --- a/src/soc/qualcomm/sc7180/Makefile.inc +++ b/src/soc/qualcomm/sc7180/Makefile.inc @@ -45,6 +45,7 @@ romstage-y += gpio.c romstage-y += qupv3_i2c.c romstage-y += clock.c +romstage-y += carve_out.c romstage-$(CONFIG_SC7180_QSPI) += qspi.c romstage-y += qcom_qup_se.c romstage-y += qupv3_config.c @@ -52,6 +53,7 @@
################################################################################ ramstage-y += soc.c +ramstage-y += carve_out.c ramstage-y += timer.c ramstage-y += spi.c ramstage-y += qupv3_spi.c diff --git a/src/soc/qualcomm/sc7180/carve_out.c b/src/soc/qualcomm/sc7180/carve_out.c new file mode 100644 index 0000000..960b923 --- /dev/null +++ b/src/soc/qualcomm/sc7180/carve_out.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <arch/stages.h> +#include <soc/mmu_common.h> +#include <soc/symbols.h> +#include <device/mmio.h> +#include <string.h> + +#define MODEM_ID_LTE 0x004c5445 +#define MODEM_ID_WIFI 0x57494649 + +bool soc_modem_carve_out(void **start, void **end) +{ + uint32_t modem_id = read32(_modem_id); + + switch (modem_id) { + case MODEM_ID_LTE: + *start = _dram_modem_wifi_only; + *end = _edram_modem_extra; + return true; + case MODEM_ID_WIFI: + *start = _dram_modem_wifi_only; + *end = _edram_modem_wifi_only; + return true; + default: + return false; + } +} diff --git a/src/soc/qualcomm/sc7180/include/soc/symbols.h b/src/soc/qualcomm/sc7180/include/soc/symbols.h index f15a8bb..207bc43 100644 --- a/src/soc/qualcomm/sc7180/include/soc/symbols.h +++ b/src/soc/qualcomm/sc7180/include/soc/symbols.h @@ -9,9 +9,12 @@ DECLARE_REGION(bsram) DECLARE_REGION(dram_aop) DECLARE_REGION(dram_soc) +DECLARE_REGION(dram_modem_wifi_only) +DECLARE_REGION(dram_modem_extra) DECLARE_REGION(dcb) DECLARE_REGION(pmic) DECLARE_REGION(limits_cfg) DECLARE_REGION(aop) +DECLARE_REGION(modem_id)
#endif /* _SOC_QUALCOMM_SC7180_SYMBOLS_H_ */ diff --git a/src/soc/qualcomm/sc7180/memlayout.ld b/src/soc/qualcomm/sc7180/memlayout.ld index ce08478..65e50d1 100644 --- a/src/soc/qualcomm/sc7180/memlayout.ld +++ b/src/soc/qualcomm/sc7180/memlayout.ld @@ -24,6 +24,7 @@ SSRAM_START(0x14680000) OVERLAP_DECOMPRESSOR_VERSTAGE_ROMSTAGE(0x14680000, 100K) REGION(qcsdi, 0x14699000, 52K, 4K) + REGION(modem_id, 0x146ABD00, 4, 4) SSRAM_END(0x146AE000)
BSRAM_START(0x14800000) @@ -51,6 +52,8 @@ REGION(dram_aop, 0x80800000, 0x040000, 0x1000) REGION(dram_soc, 0x80900000, 0x200000, 0x1000) BL31(0x80B00000, 1M) + REGION(dram_modem_wifi_only, 0x86000000, 32M, 4) + REGION(dram_modem_extra, 0x88000000, 108M, 4) POSTRAM_CBFS_CACHE(0x9F800000, 16M) RAMSTAGE(0xA0800000, 16M) } diff --git a/src/soc/qualcomm/sc7180/soc.c b/src/soc/qualcomm/sc7180/soc.c index 74f0868..d8cade4 100644 --- a/src/soc/qualcomm/sc7180/soc.c +++ b/src/soc/qualcomm/sc7180/soc.c @@ -9,12 +9,17 @@
static void soc_read_resources(struct device *dev) { + void *start = NULL; + void *end = NULL; + ram_resource(dev, 0, (uintptr_t)ddr_region->offset / KiB, ddr_region->size / KiB); reserved_ram_resource(dev, 1, (uintptr_t)_dram_aop / KiB, REGION_SIZE(dram_aop) / KiB); reserved_ram_resource(dev, 2, (uintptr_t)_dram_soc / KiB, REGION_SIZE(dram_soc) / KiB); + if (soc_modem_carve_out(&start, &end)) + reserved_ram_resource(dev, 3, (uintptr_t)start / KiB, (end - start) / KiB); }
static void soc_init(struct device *dev)