linux/Documentation/arm/tcm.txt
<<
3.9.3.9.3.p/spa 3.pspa class="lxr_search">3.9. ="+search" method="post" onsubmit="return do_search(this);">3.9.3.9.3.9.Search3.9.3.p/spa 9. ="ajax+*" method="post" onsubmit="return false;">3.pinput typ"v3hidden" nam"v3ajax_lookup" idv3ajax_lookup" lue="v3">39.
o o1p/a>ARM TCM (Tightly-Coupled Memory) handling in Linux o o2p/a>---- o o3p/a>Written by Linus Walleij <linus.walleij@stericsson.com> o o4p/a>3o o5p/a>Some ARM SoC:s have a so-called TCM (Tightly-Coupled Memory).3o o6p/a>This is usually just a few (4-64) KiB of RAM inside the ARM3o o7p/a>processor.3o o8p/a>3o o9p/a>Due to being embedded inside the CPU The TCM has a3o 8.12a>Harvard-architecture, so there is a ITCM (instrucon> TCM)3o 11p/a>and a DTCM (data TCM). The DTCM ca not contain any3o 12p/a>instrucon> s, but the ITCM ca acoually contain data.3o 13p/a>The size of DTCM or ITCM is minimum 4KiB so the typical3o 14p/a>minimum configuraon> is 4KiB ITCM and 4KiB DTCM.3o 15p/a>3o 16p/a>ARM CPU:s have special registers to read out staous, physical3o 17p/a>locaon> and size of TCM memories. arch/arm/include/asm/cputyp".h3o 18p/a>defines a CPUID_TCM register that you ca read out from the3o 19p/a>system control coprocessor. Documentaon> from ARM ca be found o 2.12a>at http://infocenter.arm.com, search for "TCM Staous Register"p/a>3o 21p/a>to see documents for all CPUs. Reading this register you ca 3o 22p/a>determine if ITCM (bits 1-0) and/or DTCM (bit 17-16) is present3o 23p/a>in the machine.3o 24p/a>3o 25p/a>There is further a TCM region register (search for "TCM Region3o 26p/a>Registers" at the ARM site) that ca report and modify the locaon> 3o 27p/a>size of TCM memories at runtime. This is used to read out and modify3o 28p/a>TCM locaon> and size. Notice that this is not a MMU table: you3o 29p/a>acoually move the physical locaon> of the TCM around. At the3o 3.12a>place you put it, it will mask any underlying RAM from the3o 31p/a>CPU so it is usually wise not to overlap any physical RAM with3o 32p/a>the TCM.3o 33p/a>3o 34p/a>The TCM memory ca the be remapped to another address again using3o 35p/a>the MMU, but notice that the TCM if often used in situaon> s where3o 36p/a>the MMU is turned off. To avoid confusion the current Linux o 37p/a>implementaon> will map the TCM 1 to 1 from physical to viroual o 38p/a>memory in the locaon> specified by the kernel. Currently Linux o 39p/a>will map ITCM to 0xfffe0000 and on, and DTCM to 0xfffe8000 and o 4.12a>on, supporting a maximum of 32KiB of ITCM and 32KiB of DTCM.3o 41p/a>3o 42p/a>Newer versn> s of the region registers also support dividing these3o 43p/a>TCMs in two separaoe banks, so for example a 8KiB ITCM is divided o 44p/a>into two 4KiB banks with its own control registers. The idea is to o 45p/a>be able to lock and hide one of the banks for use by the secure3o 46p/a>world (TrustZone).3o 47p/a>3o 48p/a>TCM is used for a few things:3o 49p/a>3o 5.12a>- FIQ and other interrupt handlers that need deterministic3o 51p/a> timing and ca not wait for cache misses.3o 52p/a>3o 5312a>- Idle loops where all external RAM is set to self-refresh3o 54p/a> retention mode, so only on-chip RAM is accessible by3o 55p/a> the CPU and the we hang inside ITCM waiting for a 3o 56p/a> interrupt.3o 57p/a>3o 5812a>- Other operaon> s which implies shutting off or reconfiguring3o 59p/a> the external RAM controller.3o 60p/a>3o 61p/a>There is a interface for using TCM on the ARM architecture3o 62p/a>in <asm/tcm.h>. Using this interface it is possible to:3ry ca thline" nam"v, supportimum of 32KiB of ITCM and 32KiB of DTCM.3<6 href="D6cumentaon> /arm/tcm.txt6L55" 6dv3L15" class="line" nam"v3L15">o 15p/a>3<6a href="DDocumentaon> /arm/tcm.txL56" 66v3L58"Taandunss="li classm"vmpilbut nclaImum of 32KiB of ITCM and 32KiB of DTCM.3<6 href="D6cumentaon> /arm/tcm.txt6L57" 6dv3L57" class="line" nam"v3L57">o 57p/a>3<6 href="D6cumentaon> /arm/tcm.txt6L58" 68v3L58"Taanne" n"line"litae" nclassm"v3 nama>The D supportImum of 32KiB of ITCM and 32KiB of DTCM.3<6 href="D6cumentaon> /arm/tcm.txt6L59" 6dv3L49" class="line" nam"v3L49">o 49p/a>3<7 href="D7cumentaon> /arm/tcm.txt7L60" 7dv3L50"Haine" nao 34int61p/a>T namanam"vhe T" nam"v39" class="line" nam"v3L49">o 49p/a>3<7 href="D7cumentaon> /arm/tcm.txt7L61" 7dv3L51""v3 nam="lipoo tv3L44gen_poo _creama(o 22p4gen_poo _ana(o there is a ITCM (instrucon> TCM)3<7 href="D7cumentaon> /arm/tcm.txt7L62" 72v3L51""2p4provnam"vcm_"v3 n(o 22p4vcm_ ala(o L61" 62p there is a ITCM (instrucon> TCM)3<7 href="D7cumentaon> /arm/tcm.txt7L63" 73v3L51"8" cla. SuL58heress=tcmgream L61" 62">o likhidav implies shutting off or reconfiguring3<7 href="D7cumentaon> /arm/tcm.txt7L54" 7dv3L54"devnam"haveene" n2a>- Other opedevnam"po clado34ining and ca not wait for cache misses.3<7 href="D7cumentaon> /arm/tcm.txt7L55" 7dv3L15" class="line" nam"v3L15">o 15p/a>3<7a href="7Documentaon> /arm/tcm.t7L56" 7dv3L16ss="line>- FIQng elass="line"sh"v3Lv31o 15p/a>3<7a href="DDocumentaon> /arm/tcm.txL57" 7dv3L5locaon> K s whi L61"">o wh. Code>- FIQ and nclalocknam"sh"v35" class="line" nam"v3L15">o 15p/a>3<7 href="D7cumentaon> /arm/tcm.txt7L58" 78v3L5#and siz class="line" nam"5" class="line" nam"v3L15">o 15p/a>3<7 href="D7cumentaon> /arm/tcm.txt7L59" 7dv3L49" class="line" nam"v3L49">o 49p/a>3<8 href="D8cumentaon> /arm/tcm.txt8L60" 8dv3L5Funss="li clagot nclai 49coprocestaggm"vlikhi 62png this interface it is possible to:3<8 href="D8cumentaon> /arm/tcm.txt8L61" 81v3L44" __bleduns L6o(4" bar)"5" class="line" nam"v3L15">o 15p/a>3<8 href="D8cumentaon> /arm/tcm.txt8L62" 8dv3L52" class="line" nam"v3L52">o 52p/a>3<8 href="D8cumentaon> /arm/tcm.txt8L63" 83v3L5Sandeion re inass=rkm"vhe b> smass=ng_">o thlinss="mayhe 0) and/or DTCM (bit 17-16) is present3<8 href="D8cumentaon> /arm/tcm.txt8L54" 84v3L21" line"dunss="li ">o o5p3 naam"v3L9">o o9p/ the3L4ou) and/or DTCM (bit 17-16) is present3<8 href="D8cumentaon> /arm/tcm.txt8L55" 8dv3L1wasOthersplt;,0">o 8.12a>lze of D__ble3 naaduns cm.tix>- FI and/or DTCM (bit 17-16) is present3<8a href="8Documentaon> /arm/tcm.t8L56" 86v3L39" clasko o9p/naamao l17-ve" nam"v3L23">o 23p/a>in the machine.3<8a href="8Documentaon> /arm/tcm.t8L57" 8dv3L57" class="line" nam"v3L57">o 57p/a>3<8a href="DDocumentaon> /arm/tcm.txL58" 88v3L5Variclasi clagot nclad 49coprocestaggm"vlikhi 62png this interface it is possible to:3<8 href="D8cumentaon> /arm/tcm.txt8L59" 89v3L44" __blene" nL6o"5" class="line" nam"v3L15">o 15p/a>3<9 href="D9cumentaon> /arm/tcm.txt9L60" 9dv3L60" class="line" nam"v3L60">o 60p/a>3<9 href="D9cumentaon> /arm/tcm.txt9L61" 9dv3L31"litae" noprocestaggm"vlikhi 62png this interface it is possible to:3<9 href="D9cumentaon> /arm/tcm.txt9L62" 92v3L44" __blee"litnL6o"5" class="line" nam"v3L15">o 15p/a>3<9 href="D9cumentaon> /arm/tcm.txt9L63" 9dv3L6ef="Documentaon> /arm/tfRAMfv3L38" c19 href="D9cumentaon> /arm/tcm.txt9L54" 9dv3L34o"linetaoemlasrt ncla th nam"uregisters also support dividing these3<9 href="D9cumentaon> /arm/tcm.txt9L55" 9dv3L1.seecture"line".g theext"line" 61".seecture"line".g thne" "line"gisters also support dividing these3<9a href="9Documentaon> /arm/tcm.t9L56" 96v3L3ca peectvely" nam"v3L23">o 23p/a>in the machine.3<9a href="9Documentaon> /arm/tcm.t9L57" 9dv3L57" class="line" nam"v3L57">o 57p/a>3<9a href="9Documentaon> /arm/tcm.t9L58" 98v3L5ECMs in codeng this interface it is possible to:3<9a href="DDocumentaon> /arm/tcm.txL59" 9dv3L49" class="line" nam"v3L49">o 49p/a>3<10 href="Doccumentaon> /arm/tcm.txt#LL60"#LLv3L5#and siz class="line" nam"5" class="line" nam"v3L15">o 15p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0160"#Ldv3L41" class="line" nam"v3L41">o 41p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0260"#L2v3L4/* Unt6it"v3iznd oe" n*/1" class="line" nam"v3L41">o 41p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0360"#Ldv3L6 /arm/ u32 __blene" nblevar"5" class="line" nam"v3L15">o 15p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0460"#L4v3L4/* I6it"v3iznd oe" n*/1" class="line" nam"v3L41">o 41p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0560"#L5v3L6 /arm/ u32 __blene" nbletaoig" na= 0x2BADBABEU"5" class="line" nam"v3L15">o 15p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0660"#L6v3L4/* 1"litae"n*/1" class="line" nam"v3L41">o 41p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0760"#L7v3L6 /arm/ e"litnu32 __blee"litnblee"litn= 0xCAFEBABEU"5" class="line" nam"v3L15">o 15p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0860"#L idv3L8" class="line" nam"v3L8">o o8p/a>3<10 href="Do0cumentaon> /arm/tcm.txt#0960"#L9v3L6 /arm/ o 36p__ble3 naaduns vcm_to_ble(o 36o there is a ITCM (instrucon> TCM)3 TCM)3o 15p/a>3<1a href="Doocumentaon> /arm/tcm.txt##L12"112v3L51"""""""L61"(in= 0; i clas"#LL; i++o there is a ITCM (instrucon> TCM)3o 15p/a>3<1a href="Doocumentaon> /arm/tcm.txt##L14"1idv3L1}5" class="line" nam"v3L15">o 15p/a>3<1a href="Doocumentaon> /arm/tcm.txt##L15"1idv3L15" class="line" nam"v3L15">o 15p/a>3 TCM)3 TCM)3- FIQrunclass, sup*/1" class="line" nam"v3L41">o 41p/a>3<1a href="Doocumentaon> /arm/tcm.txt##L19"119v3L51"""""""4" i"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L20"1idv3L21"""""""L61"(in= 0; i clas"#LL; i++o { there is a ITCM (instrucon> TCM)3o 15p/a>3<12 href="Doccumentaon> /arm/tcm.txt#LL12"122v3L51"""""""}5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L23"123v3L51"""""""vcm_to_ble()"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L24"12dv3L1}5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L25"12dv3L15" class="line" nam"v3L15">o 15p/a>3 TCM)3 TCM)3 em"5" class="line" nam"v3L15">o 15p/a>3<1a href="Doocumentaon> /arm/tcm.txt1#L29"129v3L51"""""""4" i"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L30"13dv3L60" class="line" nam"v3L60">o 60p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L31"131v3L51"""""""hello_ble()"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L32"132v3L51"""""""pr4" k("line"Helloa thexecuma>TementI/a>T na\n"line")"5" class="line" nam"v3L15">o 15p/a>3<1a href="Doccumentaon> /arm/tcm.txt#LL23"1idv3L33" class="line" nam"v3L33">o 33p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L34"134v3L51"""""""pr4" k("line"/a>Tvariclasit, it e clan: %u @ %p\n"line","blevar, &Ms ;blevar)"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L35"135v3L51"""""""vcmvar = 0xDEADBEEFU"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L36"136v3L51"""""""pr4" k("line"/a>Tvariclas: 0x%x @ %p\n"line","blevar, &Ms ;blevar)"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L37"13dv3L57" class="line" nam"v3L57">o 57p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L38"138v3L51"""""""pr4" k("line"/a>Ttaoig" navariclas: 0x%x @ %p\n"line","bletaoig" n, &Ms ;bletaoig" n)"5" class="line" nam"v3L15">o 15p/a>3<1a href="Doocumentaon> /arm/tcm.txt1#L39"13dv3L49" class="line" nam"v3L49">o 49p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L40"140v3L51"""""""pr4" k("line"/a>Te"litae": 0x%x @ %p\n"line","blee"lit, &Ms ;blee"lit)"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L41"1idv3L41" class="line" nam"v3L41">o 41p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L42"142v3L1""""""""/* Av3 nama s5" class="line"t, it wiipoo t*/1" class="line" nam"v3L41">o 41p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L43"143v3L51"""""""vcmem = vcm_"v3 n(20)"5" class="line" nam"v3L15">o 15p/a>3<1a href="Doccumentaon> /arm/tcm.txt#LL34"144v3L51"""""""if (vcmemo { there is a ITCM (instrucon> TCM)3TAv3 nama>T20 by e lass="li@ %p\n"line","bleemo"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L46"146v3L51"""""""""""""""bleem[0] = 0xDEADBEEFU"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L47"1idv3L41"""""""""""""""bleem[1]a= 0x2BADBABEU"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L48"148v3L41"""""""""""""""bleem[2]n= 0xCAFEBABEU"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L49"149v3L41"""""""""""""""bleem[3] = 0xDEADBEEFU"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L50"150v3L41"""""""""""""""bleem[4]a= 0x2BADBABEU"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L51"151v3L51"""""""""""""""L61"(in= 0; i clas"5; i++o there is a ITCM (instrucon> TCM)3Tbleem[%d]a= %08x\n"line","i,"bleem[i]o"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L53"153v3L51"""""""""""""""ble_ ala(bleem, 20)"5" class="line" nam"v3L15">o 15p/a>3<1a href="D1ocumentaon> /arm/tcm.txt1#L54"154v3L51"""""""}5" class="line" nam"v3L15">o 15p/a>3<1a href="D1