ARM: imx: Add OCRAM_S into iMX8M MMU tables
Subsystems (3)
PATCH 1/1 ARM: imx: Add OCRAM_S into iMX8M MMU tables
The OCRAM_S is regular memory, just like the OCRAM, add it to the MMU tables so it can be used and cached.
--- arch/arm/mach-imx/imx8m/soc.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/mach-imx/imx8m/soc.c +7 -0
@@ -104,6 +104,13 @@ static struct mm_region imx8m_mem_map[] = { .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | PTE_BLOCK_NON_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN + }, { +/* OCRAM_S */ + .virt = 0x180000UL, + .phys = 0x180000UL, + .size = 0x8000UL, + .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | + PTE_BLOCK_OUTER_SHARE }, {/* TCM */ .virt = 0x7C0000UL,
Signature · 1 line
2.30.0
PATCH 1/1 ARM: imx: Add OCRAM_S into iMX8M MMU tables
Hi Marek,
Quoted 26 lines · Marek Vasut
Caution: EXT Email
The
OCRAM_Sis regular memory, just like the OCRAM, add it to the MMU tables so it can be used and cached.Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>---
?arch/arm/mach-imx/imx8m/soc.c | 7 +++++++
?1 file changed, 7 insertions(+)arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0
-0
imx/imx8m/soc.c
index5456c10fb17..225e4e12500100644arch/arm/mach-imx/imx8m/soc.c +0
-0@@ -104,6 +104,13 @@ static struct mm_region imx8m_mem_map[] = {????????????????.attrs =
PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE)| ?????????????????????????PTE_BLOCK_NON_SHARE | ?????????????????????????PTE_BLOCK_PXN |PTE_BLOCK_UXN+???????}, {
+???????????????/*OCRAM_S*/
+???????????????.virt =0x180000UL, +???????????????.phys =0x180000UL,
Quoted 9 lines
+???????????????.size =
0x8000UL, +???????????????.attrs =PTE_BLOCK_MEMTYPE(MT_NORMAL)| +????????????????????????PTE_BLOCK_OUTER_SHARE ????????}, {
????????????????/* TCM */ ????????????????.virt =0x7C0000UL,
--
2.30.0
OCRAM_S is used by ATF and SPL to pass DDR CSR data. It is better not? use it in u-boot to avoid any DDR issue.
And this?imx8m_mem_map will be modified at runtime to get rid of optee memory. When OCRAM_S is added, the index used in?enable_caches and dram_init need update as well.
Best regards,
Ye Li
PATCH 1/1 ARM: imx: Add OCRAM_S into iMX8M MMU tables
Quoted 31 lines · Ye Li
Hi Marek,
Quoted 28 lines · Marek Vasut
Caution: EXT Email
The
OCRAM_Sis regular memory, just like the OCRAM, add it to the MMU tables so it can be used and cached.Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>--- ?arch/arm/mach-imx/imx8m/soc.c | 7 +++++++?1 file changed, 7 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0
-0
imx/imx8m/soc.c
index5456c10fb17..225e4e12500100644arch/arm/mach-imx/imx8m/soc.c +6
-0@@ -104,6 +104,13 @@ static struct mm_region imx8m_mem_map[] = { ????????????????.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | ?????????????????????????PTE_BLOCK_NON_SHARE | ?????????????????????????PTE_BLOCK_PXN | PTE_BLOCK_UXN +???????}, { +???????????????/* OCRAM_S */ +???????????????.virt = 0x180000UL, +???????????????.phys = 0x180000UL, +???????????????.size = 0x8000UL, +???????????????.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-imx/imx8m/soc.c +1
-1+????????????????????????PTE_BLOCK_OUTER_SHARE ????????}, { ????????????????/* TCM */ ????????????????.virt = 0x7C0000UL, --2.30.0
OCRAM_Sis used by ATF and SPL to pass DDR CSR data.
Where is this implemented ?
Quoted 2 lines
It is better not
use it in u-boot to avoid any DDR issue.
The MMU table entry does not trigger any IO to the OCRAM_S , it merely makes it cacheable .
Quoted 3 lines
And this?imx8m_mem_map will be modified at runtime to get rid of optee memory. When
OCRAM_Sis added, the index used in?enable_caches anddram_initneed update as well.
I'm not sure I understand this. What kind of modification are you talking about ? The DRAM entry offset should be determined automatically, so there shouldn't be any need to hand-tune ad-hoc offsets.
PATCH 1/1 ARM: imx: Add OCRAM_S into iMX8M MMU tables
Hi Marek,
Quoted 45 lines · Marek Vasut
Caution: EXT Email
Quoted 34 lines · Ye Li
Hi Marek,
Quoted 30 lines · Marek Vasut
Caution: EXT Email
The
OCRAM_Sis regular memory, just like the OCRAM, add it to the MMU
tables so it can be used and cached.Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>---
?arch/arm/mach-imx/imx8m/soc.c| 7 +++++++ ? 1 file changed, 7 insertions(+)arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0
-0
imx/imx8m/soc.c
index5456c10fb17..225e4e12500100644arch/arm/mach-imx/imx8m/soc.c +0
-0@@ -104,6 +104,13 @@ static struct mm_region imx8m_mem_map[] = {?????????????????.attrs =
PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE)| ??????????????????????????PTE_BLOCK_NON_SHARE | ??????????????????????????PTE_BLOCK_PXN |PTE_BLOCK_UXN+???????}, {
+???????????????/*OCRAM_S*/
+???????????????.virt =0x180000UL, +???????????????.phys =0x180000UL, +???????????????.size =0x8000UL, +???????????????.attrs =PTE_BLOCK_MEMTYPE(MT_NORMAL)|Quoted 8 lines
Quoted 7 lines
+????????????????????????PTE_BLOCK_OUTER_SHARE ?????????}, {
?????????????????/* TCM */ ?????????????????.virt =0x7C0000UL,
--
2.30.0
OCRAM_Sis used by ATF and SPL to pass DDR CSR data.
Quoted 1 line
Where is this implemented ?
See below definition in?drivers/ddr/imx/imx8m/Kconfig
config SAVED_DRAM_TIMING_BASE
hex "Define the base address for saved dram timing" help
??after DRAM is trained, need to save the dram related timming ??info into memory for low power use. OCRAM_S is used for this ??purpose on i.MX8MM.
default 0x180000
Quoted 8 lines
Quoted 4 lines
It is better not
use it in u-boot to avoid any DDR issue.The MMU table entry does not trigger any IO to the
OCRAM_S, it merely
makes it cacheable .
That's fine to add a map, just remind to use it carefully since it already used by ATF.
Quoted 9 lines
Quoted 5 lines
And this
imx8m_mem_mapwill be modified at runtime to get rid of optee
memory. WhenOCRAM_Sis added, the index used inenable_cachesanddram_initneed update as well.I'm not sure I understand this. What kind of modification are you talking about ? The DRAM entry offset should be determined automatically, so there shouldn't be any need to hand-tune ad-hoc offsets.
You also need below change, the index for DRAM1 is used in codes to help remove the OPTEE space from MMU table.
arch/arm/mach-imx/imx8m/soc.c +0 -0
@@ -167,10 +167,10 @@ void enable_caches(void)
?????????????????* please make sure that entry initial value matches ?????????????????* imx8m_mem_map for DRAM1 ?????????????????*/
-???????????????int entry = 5;
+???????????????int entry = 6;
????????????????u64 attrs = imx8m_mem_map[entry].attrs;
?
-???????????????while (i < CONFIG_NR_DRAM_BANKS && entry < 8) { +???????????????while (i < CONFIG_NR_DRAM_BANKS && entry < 9) { ????????????????????????if (gd->bd->bi_dram[i].start == 0) ????????????????????????????????break; ????????????????????????imx8m_mem_map[entry].phys = gd->bd-
Quoted 1 line
bi_dram[i].start;
@@ -212,7 +212,7 @@ int dram_init(void) ????????????????gd->ram_size = sdram_size;
?
????????/* also update the SDRAM size in the mem_map used externally */ -???????imx8m_mem_map[5].size = sdram_size; +???????imx8m_mem_map[6].size = sdram_size;
?
?#ifdef PHYS_SDRAM_2_SIZE
????????gd->ram_size += PHYS_SDRAM_2_SIZE;
Best regards,
Ye Li
PATCH 1/1 ARM: imx: Add OCRAM_S into iMX8M MMU tables
Quoted 1 line · Ye Li
Hi Marek,
Hi,
[...]
Quoted 27 lines
Quoted 23 lines
Quoted 15 lines
Quoted 15 lines
arch/arm/mach- renamed from arch/arm/mach-imx/imx8m/soc.c +0
-0
imx/imx8m/soc.c
index5456c10fb17..225e4e12500100644arch/arm/mach-imx/imx8m/soc.c +6
-0@@ -104,6 +104,13 @@ static struct mm_region imx8m_mem_map[] = { ?????????????????.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | ??????????????????????????PTE_BLOCK_NON_SHARE | ??????????????????????????PTE_BLOCK_PXN | PTE_BLOCK_UXN +???????}, { +???????????????/* OCRAM_S */ +???????????????.virt = 0x180000UL, +???????????????.phys = 0x180000UL, +???????????????.size = 0x8000UL, +???????????????.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |Quoted 8 lines
Quoted 7 lines
arch/arm/mach-imx/imx8m/soc.c +1
-1+????????????????????????PTE_BLOCK_OUTER_SHARE ?????????}, { ?????????????????/* TCM */ ?????????????????.virt = 0x7C0000UL, --2.30.0
OCRAM_Sis used by ATF and SPL to pass DDR CSR data.Quoted 1 line
Where is this implemented ?
See below definition in?drivers/ddr/imx/imx8m/Kconfig
Quoted 7 lines
config
SAVED_DRAM_TIMING_BASE
hex "Define the base address for saved dram timing" help
??after DRAM is trained, need to save the dram related timming ??info into memory for low power use.OCRAM_Sis used for this ??purpose on i.MX8MM.
default0x180000
So, this just defines some sort of value. Note that some boards do override this value to NOT point into OCRAM_S .
I think what you wanted to point me to is drivers/ddr/imx/imx8m/ddr_init.c:
248 dram_config_save(dram_timing, CONFIG_SAVED_DRAM_TIMING_BASE);
which writes regular memory. And that regular memory can very well be cacheable.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
It is better not
use it in u-boot to avoid any DDR issue.The MMU table entry does not trigger any IO to the
OCRAM_S, it merely
makes it cacheable .That's fine to add a map, just remind to use it carefully since it already used by ATF.
Not necessarily, use git grep SAVED_DRAM_TIMING_BASE configs/ and see how some boards change the default in configs/ .
Quoted 15 lines
Quoted 8 lines
Quoted 4 lines
And this
imx8m_mem_mapwill be modified at runtime to get rid of optee
memory. WhenOCRAM_Sis added, the index used inenable_cachesanddram_initneed update as well.I'm not sure I understand this. What kind of modification are you talking about ? The DRAM entry offset should be determined automatically, so there shouldn't be any need to hand-tune ad-hoc offsets.
You also need below change, the index for DRAM1 is used in codes to help remove the OPTEE space from MMU table.
arch/arm/mach-imx/imx8m/soc.c void enable_caches(void) · line 170
Quoted 5 lines
arch/arm/mach-imx/imx8m/soc.c +1
-1@@ -167,10 +167,10 @@ void enable_caches(void)?????????????????* please make sure that entry initial value matches ?????????????????* imx8m_mem_map for DRAM1 ?????????????????*/ -???????????????int entry = 5; +???????????????int entry = 6;
OK, then this hard-coding of random offset is nasty and should be fixed. For example iterate over imx8m_mem_map[] and detect entry which has PA
Quoted 19 lines
=
0x40000000, that's your DRAM.????????????????u64 attrs = imx8m_mem_map[entry].attrs;
-???????????????while (i <
CONFIG_NR_DRAM_BANKS&& entry < 8) { +???????????????while (i <CONFIG_NR_DRAM_BANKS&& entry < 9) {
????????????????????????if (gd->bd->bi_dram[i].start == 0) ????????????????????????????????break; ????????????????????????imx8m_mem_map[entry].phys = gd->bd-Quoted 1 line
bi_dram[i].start;
arch/arm/mach-imx/imx8m/soc.c +1
-1@@ -212,7 +212,7 @@ int dram_init(void) ????????????????gd->ram_size = sdram_size; ????????/* also update the SDRAM size in the mem_map used externally */ -???????imx8m_mem_map[5].size = sdram_size; +???????imx8m_mem_map[6].size = sdram_size; ?#ifdef PHYS_SDRAM_2_SIZE ????????gd->ram_size += PHYS_SDRAM_2_SIZE;
[...]
PATCH 1/1 ARM: imx: Add OCRAM_S into iMX8M MMU tables
In reply to Marek VasutQuoted 6 lines
The
OCRAM_Sis regular memory, just like the OCRAM, add it to the MMU tables so it can be used and cached.Signed-off-by Marek Vasut <[email protected]>Cc Fabio Estevam <[email protected]>Cc Peng Fan <[email protected]>Cc Stefano Babic <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================