memsetup.S 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /*
  2. * Most of this taken from Redboot hal_platform_setup.h with cleanup
  3. *
  4. * NOTE: I haven't clean this up considerably, just enough to get it
  5. * running. See hal_platform_setup.h for the source. See
  6. * board/cradle/memsetup.S for another PXA250 setup that is
  7. * much cleaner.
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <config.h>
  28. #include <version.h>
  29. #include <asm/arch/pxa-regs.h>
  30. DRAM_SIZE: .long CFG_DRAM_SIZE
  31. /* wait for coprocessor write complete */
  32. .macro CPWAIT reg
  33. mrc p15,0,\reg,c2,c0,0
  34. mov \reg,\reg
  35. sub pc,pc,#4
  36. .endm
  37. .globl memsetup
  38. memsetup:
  39. mov r10, lr
  40. /* Set up GPIO pins first */
  41. ldr r0, =GPSR0
  42. ldr r1, =CFG_GPSR0_VAL
  43. str r1, [r0]
  44. ldr r0, =GPSR1
  45. ldr r1, =CFG_GPSR1_VAL
  46. str r1, [r0]
  47. ldr r0, =GPSR2
  48. ldr r1, =CFG_GPSR2_VAL
  49. str r1, [r0]
  50. ldr r0, =GPCR0
  51. ldr r1, =CFG_GPCR0_VAL
  52. str r1, [r0]
  53. ldr r0, =GPCR1
  54. ldr r1, =CFG_GPCR1_VAL
  55. str r1, [r0]
  56. ldr r0, =GPCR2
  57. ldr r1, =CFG_GPCR2_VAL
  58. str r1, [r0]
  59. ldr r0, =GPDR0
  60. ldr r1, =CFG_GPDR0_VAL
  61. str r1, [r0]
  62. ldr r0, =GPDR1
  63. ldr r1, =CFG_GPDR1_VAL
  64. str r1, [r0]
  65. ldr r0, =GPDR2
  66. ldr r1, =CFG_GPDR2_VAL
  67. str r1, [r0]
  68. ldr r0, =GAFR0_L
  69. ldr r1, =CFG_GAFR0_L_VAL
  70. str r1, [r0]
  71. ldr r0, =GAFR0_U
  72. ldr r1, =CFG_GAFR0_U_VAL
  73. str r1, [r0]
  74. ldr r0, =GAFR1_L
  75. ldr r1, =CFG_GAFR1_L_VAL
  76. str r1, [r0]
  77. ldr r0, =GAFR1_U
  78. ldr r1, =CFG_GAFR1_U_VAL
  79. str r1, [r0]
  80. ldr r0, =GAFR2_L
  81. ldr r1, =CFG_GAFR2_L_VAL
  82. str r1, [r0]
  83. ldr r0, =GAFR2_U
  84. ldr r1, =CFG_GAFR2_U_VAL
  85. str r1, [r0]
  86. /* enable GPIO pins */
  87. ldr r0, =PSSR
  88. ldr r1, =CFG_PSSR_VAL
  89. str r1, [r0]
  90. ldr r3, =MSC1 /* low - bank 2 Lubbock Registers / SRAM */
  91. ldr r2, =CFG_MSC1_VAL /* high - bank 3 Ethernet Controller */
  92. str r2, [r3] /* need to set MSC1 before trying to write to the HEX LEDs */
  93. ldr r2, [r3] /* need to read it back to make sure the value latches (see MSC section of manual) */
  94. ldr r1, =LED_BLANK
  95. mov r0, #0xFF
  96. str r0, [r1] /* turn on hex leds */
  97. loop:
  98. ldr r0, =0xB0070001
  99. ldr r1, =_LED
  100. str r0, [r1] /* hex display */
  101. /*********************************************************************
  102. Initlialize Memory Controller
  103. The sequence below is based on the recommended init steps detailed
  104. in the EAS, chapter 5 (Chapter 10, Operating Systems Developers Guide)
  105. pause for 200 uSecs- allow internal clocks to settle
  106. *Note: only need this if hard reset... doing it anyway for now
  107. */
  108. @ ---- Wait 200 usec
  109. ldr r3, =OSCR @ reset the OS Timer Count to zero
  110. mov r2, #0
  111. str r2, [r3]
  112. ldr r4, =0x300 @ really 0x2E1 is about 200usec, so 0x300 should be plenty
  113. 1:
  114. ldr r2, [r3]
  115. cmp r4, r2
  116. bgt 1b
  117. mem_init:
  118. @ get memory controller base address
  119. ldr r1, =MEMC_BASE
  120. @****************************************************************************
  121. @ Step 1
  122. @
  123. @ write msc0, read back to ensure data latches
  124. @
  125. ldr r2, =CFG_MSC0_VAL
  126. str r2, [r1, #MSC0_OFFSET]
  127. ldr r2, [r1, #MSC0_OFFSET]
  128. @ write msc1
  129. ldr r2, =CFG_MSC1_VAL
  130. str r2, [r1, #MSC1_OFFSET]
  131. ldr r2, [r1, #MSC1_OFFSET]
  132. @ write msc2
  133. ldr r2, =CFG_MSC2_VAL
  134. str r2, [r1, #MSC2_OFFSET]
  135. ldr r2, [r1, #MSC2_OFFSET]
  136. @ write mecr
  137. ldr r2, =CFG_MECR_VAL
  138. str r2, [r1, #MECR_OFFSET]
  139. @ write mcmem0
  140. ldr r2, =CFG_MCMEM0_VAL
  141. str r2, [r1, #MCMEM0_OFFSET]
  142. @ write mcmem1
  143. ldr r2, =CFG_MCMEM1_VAL
  144. str r2, [r1, #MCMEM1_OFFSET]
  145. @ write mcatt0
  146. ldr r2, =CFG_MCATT0_VAL
  147. str r2, [r1, #MCATT0_OFFSET]
  148. @ write mcatt1
  149. ldr r2, =CFG_MCATT1_VAL
  150. str r2, [r1, #MCATT1_OFFSET]
  151. @ write mcio0
  152. ldr r2, =CFG_MCIO0_VAL
  153. str r2, [r1, #MCIO0_OFFSET]
  154. @ write mcio1
  155. ldr r2, =CFG_MCIO1_VAL
  156. str r2, [r1, #MCIO1_OFFSET]
  157. @-------------------------------------------------------
  158. @ 3rd bullet, Step 1
  159. @
  160. @ get the mdrefr settings
  161. ldr r3, =CFG_MDREFR_VAL_100
  162. @ extract DRI field (we need a valid DRI field)
  163. @
  164. ldr r2, =0xFFF
  165. @ valid DRI field in r3
  166. @
  167. and r3, r3, r2
  168. @ get the reset state of MDREFR
  169. @
  170. ldr r4, [r1, #MDREFR_OFFSET]
  171. @ clear the DRI field
  172. @
  173. bic r4, r4, r2
  174. @ insert the valid DRI field loaded above
  175. @
  176. orr r4, r4, r3
  177. @ write back mdrefr
  178. @
  179. str r4, [r1, #MDREFR_OFFSET]
  180. @ *Note: preserve the mdrefr value in r4 *
  181. @****************************************************************************
  182. @ Step 2
  183. @
  184. /* This should be for SRAM, why is it commented out??? */
  185. @ fetch sxcnfg value
  186. @
  187. @ldr r2, =0
  188. @ write back sxcnfg
  189. @str r2, [r1, #SXCNFG_OFFSET]
  190. /* @if sxcnfg=0, don't program for synch-static memory */
  191. @cmp r2, #0
  192. @beq 1f
  193. @program sxmrs
  194. @ldr r2, =SXMRS_SETTINGS
  195. @str r2, [r1, #SXMRS_OFFSET]
  196. @****************************************************************************
  197. @ Step 3
  198. @
  199. @ Assumes previous mdrefr value in r4, if not then read current mdrefr
  200. @ clear the free-running clock bits
  201. @ (clear K0Free, K1Free, K2Free
  202. @
  203. bic r4, r4, #(0x00800000 | 0x01000000 | 0x02000000)
  204. @ set K1RUN if bank 0 installed
  205. @
  206. orr r4, r4, #0x00010000
  207. #ifdef THIS
  208. @<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<
  209. @<!<!<!<!<!<!<!<!<!<!<! Begin INSERT 1 <!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<
  210. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  211. @ Lubbock: Allow the user to select the {T/R/M} with predetermined
  212. @ SDCLK. Based on Table 3-1 in PXA250 and PXA210 Dev Man.
  213. @
  214. @ * = Must set MDREFR.K1DB2 to halve the MemClk for desired SDCLK[1]
  215. @
  216. @ S25, S26 used to provide all 400 MHz BIN values for Cotulla (0,0 - 1,3)
  217. @ S25, S26 used to provide all 200 MHz BIN values for Sabinal
  218. @
  219. @ S23: Force the halving of MemClk when deriving SDCLK[1]
  220. @ DOT: no override !DOT: halve (if not already forced half)
  221. /* @ *For certain MemClks, SDCLK's derivation is forced to be halved */
  222. @
  223. @ S24: Run/Turbo.
  224. @ DOT: Run mode !DOT: Turbo mode
  225. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  226. @
  227. @ Allow the user to control K1DB2 where applicable
  228. @
  229. @ Get the value of S23: @ 1 = DOT (unity), 0 = !DOT (halve it)
  230. @
  231. @ DOT: set K1DB2 (SDCLD = MemClk)
  232. @ !DOT: clear K1DB2 (SDCLK = MemClk/2)
  233. @
  234. @ldr r2, =FPGA_REGS_BASE_PHYSICAL
  235. bl GET_S23 @ r3, r2 @ get the value of S23 in R0, i put the base adx of fpga in r3
  236. cmp r3, #0x0 @ is !DOT?
  237. orreq r4, r4, #0x00020000 @ SDClk[1] = MemClk/2
  238. bicne r4, r4, #0x00020000 @ SDClk[1] = MemClk
  239. @
  240. @ Next, we need to look for S25,S26 selections that necessitate the
  241. @ halving of MemClk to derive SDCLK[1]: (S25,S26)={03-0C, 10-13}
  242. @ Override above S23-based selection accordingly.
  243. @
  244. ldr r2, =FPGA_REGS_BASE_PHYSICAL
  245. bl GET_S25 @ r0, r2
  246. @ get the value of S25 in R0, i put the base adx of fpga in r2
  247. ldr r2, =FPGA_REGS_BASE_PHYSICAL
  248. BL GET_S26 @ r3, r2
  249. @ get the value of S26 in R1, i put the base adx of fpga in r2
  250. orr r0, r0, r3 @ concatenate S25 & S26 vals
  251. and r0, r0, #0xFF
  252. @ Set K1DB2 for the frequencies that require it
  253. @
  254. cmp r0, #0x03
  255. cmpne r0, #0x04
  256. cmpne r0, #0x05
  257. cmpne r0, #0x06
  258. cmpne r0, #0x07
  259. cmpne r0, #0x08
  260. cmpne r0, #0x09
  261. cmpne r0, #0x0A
  262. cmpne r0, #0x0B
  263. cmpne r0, #0x0C
  264. cmpne r0, #0x10
  265. cmpne r0, #0x11
  266. cmpne r0, #0x12
  267. cmpne r0, #0x13
  268. orreq r4, r4, #0x00020000 @ SDCLK[1] = (MemClk)/2 for 03 - 0C @ 10 - 13
  269. @
  270. @ *Must make MSC0&1 adjustments now for MEMClks > 100MHz.
  271. @
  272. @ Adjust MSC0 for MemClks > 100 MHz
  273. @
  274. ldreq r0, [r1, #MSC0_OFFSET]
  275. ldreq r3, =0x7F007F00
  276. biceq r0, r0, r3 @ clear MSC0[14:12, 11:8] (RRR, RDN)
  277. ldreq r3, =0x46004600
  278. orreq r0, r0, r3 @ set MSC0[14, 10:9] (doubling RRR, RDN)
  279. streq r0, [r1, #MSC0_OFFSET]
  280. ldreq r0, [r1, #MSC0_OFFSET] @ read it back to ensure that the data latches
  281. @
  282. @ Adjust MSC1.LH for MemClks > 100 MHz
  283. @
  284. ldreq r0, [r1, #MSC1_OFFSET]
  285. ldreq r3, =0x7FF0
  286. biceq r0, r0, r3 @ clear MSC1[14:12, 11:8, 7:4] (RRR, RDN, RDF)
  287. ldreq r3, =0x4880
  288. orreq r0, r0, r3 @ set MSC1[14, 11, 7] (doubling RRR, RDN, RDF)
  289. streq r0, [r1, #MSC1_OFFSET]
  290. ldreq r0, [r1, #MSC1_OFFSET] @ read it back to ensure that the data latches
  291. @ @
  292. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  293. #endif
  294. @<!<!<!<!<!<!<!<!<!<!<! End INSERT 1 <!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<
  295. @<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<
  296. @ write back mdrefr
  297. @
  298. str r4, [r1, #MDREFR_OFFSET]
  299. ldr r4, [r1, #MDREFR_OFFSET]
  300. @ deassert SLFRSH
  301. @
  302. bic r4, r4, #0x00400000
  303. @ write back mdrefr
  304. @
  305. str r4, [r1, #MDREFR_OFFSET]
  306. @ assert E1PIN
  307. @
  308. orr r4, r4, #0x00008000
  309. @ write back mdrefr
  310. @
  311. str r4, [r1, #MDREFR_OFFSET]
  312. ldr r4, [r1, #MDREFR_OFFSET]
  313. nop
  314. nop
  315. @****************************************************************************
  316. @ Step 4
  317. @
  318. @ fetch platform value of mdcnfg
  319. @
  320. ldr r2, =CFG_MDCNFG_VAL
  321. @ disable all sdram banks
  322. @
  323. bic r2, r2, #(MDCNFG_DE0 | MDCNFG_DE1)
  324. bic r2, r2, #(MDCNFG_DE2 | MDCNFG_DE3)
  325. @ program banks 0/1 for bus width
  326. @
  327. bic r2, r2, #MDCNFG_DWID0 @0=32-bit
  328. @ write initial value of mdcnfg, w/o enabling sdram banks
  329. @
  330. str r2, [r1, #MDCNFG_OFFSET]
  331. @ ****************************************************************************
  332. @ Step 5
  333. @
  334. @ pause for 200 uSecs
  335. @
  336. ldr r3, =OSCR @reset the OS Timer Count to zero
  337. mov r2, #0
  338. str r2, [r3]
  339. ldr r4, =0x300 @really 0x2E1 is about 200usec, so 0x300 should be plenty
  340. 1:
  341. ldr r2, [r3]
  342. cmp r4, r2
  343. bgt 1b
  344. @****************************************************************************
  345. @ Step 6
  346. @
  347. mov r0, #0x78 @turn everything off
  348. mcr p15, 0, r0, c1, c0, 0 @(caches off, MMU off, etc.)
  349. @ ****************************************************************************
  350. @ Step 7
  351. @
  352. @ Access memory *not yet enabled* for CBR refresh cycles (8)
  353. @ - CBR is generated for all banks
  354. ldr r2, =CFG_DRAM_BASE
  355. str r2, [r2]
  356. str r2, [r2]
  357. str r2, [r2]
  358. str r2, [r2]
  359. str r2, [r2]
  360. str r2, [r2]
  361. str r2, [r2]
  362. str r2, [r2]
  363. @ ****************************************************************************
  364. @ Step 8: NOP (enable dcache if you wanna... we dont)
  365. @
  366. @ ****************************************************************************
  367. @ Step 9
  368. @
  369. @get memory controller base address
  370. @
  371. ldr r1, =MEMC_BASE
  372. @fetch current mdcnfg value
  373. @
  374. ldr r3, [r1, #MDCNFG_OFFSET]
  375. @enable sdram bank 0 if installed (must do for any populated bank)
  376. @
  377. orr r3, r3, #MDCNFG_DE0
  378. @write back mdcnfg, enabling the sdram bank(s)
  379. @
  380. str r3, [r1, #MDCNFG_OFFSET]
  381. @****************************************************************************
  382. @ Step 10
  383. @
  384. @ write mdmrs
  385. @
  386. ldr r2, =CFG_MDMRS_VAL
  387. str r2, [r1, #MDMRS_OFFSET]
  388. @****************************************************************************
  389. @ Step 11: Final Step
  390. @
  391. @INITINTC
  392. @********************************************************************
  393. @ Disable (mask) all interrupts at the interrupt controller
  394. @
  395. @ clear the interrupt level register (use IRQ, not FIQ)
  396. @
  397. mov r1, #0
  398. ldr r2, =ICLR
  399. str r1, [r2]
  400. @ mask all interrupts at the controller
  401. @
  402. ldr r2, =ICMR
  403. str r1, [r2]
  404. @INITCLKS
  405. @ ********************************************************************
  406. @ Disable the peripheral clocks, and set the core clock
  407. @ frequency (hard-coding at 398.12MHz for now).
  408. @
  409. @ Turn Off ALL on-chip peripheral clocks for re-configuration
  410. @ *Note: See label 'ENABLECLKS' for the re-enabling
  411. @
  412. ldr r1, =CKEN
  413. mov r2, #0
  414. str r2, [r1]
  415. @ default value in case no valid rotary switch setting is found
  416. ldr r2, =(CCCR_L27 | CCCR_M2 | CCCR_N10) @ DEFAULT: {200/200/100}
  417. @... and write the core clock config register
  418. @
  419. ldr r1, =CCCR
  420. str r2, [r1]
  421. /* @ enable the 32Khz oscillator for RTC and PowerManager
  422. @
  423. ldr r1, =OSCC
  424. mov r2, #OSCC_OON
  425. str r2, [r1]
  426. @ NOTE: spin here until OSCC.OOK get set,
  427. @ meaning the PLL has settled.
  428. @
  429. 60:
  430. ldr r2, [r1]
  431. ands r2, r2, #1
  432. beq 60b
  433. */
  434. @OSCC_OON_DONE
  435. #ifdef A0_COTULLA
  436. @****************************************************************************
  437. @ !!! Take care of A0 Errata Sighting #4 --
  438. @ after a frequency change, the memory controller must be restarted
  439. @
  440. @ get memory controller base address
  441. ldr r1, =MEMC_BASE
  442. @ get the current state of MDREFR
  443. @
  444. ldr r2, [r1, #MDREFR_OFFSET]
  445. @ clear E0PIN, E1PIN
  446. @
  447. bic r3, r2, #(MDREFR_E0PIN | MDREFR_E1PIN)
  448. @ write MDREFR with E0PIN, E1PIN cleared (disable sdclk[0,1])
  449. @
  450. str r3, [r1, #MDREFR_OFFSET]
  451. @ then write MDREFR with E0PIN, E1PIN set (enable sdclk[0,1])
  452. @
  453. str r2, [r1, #MDREFR_OFFSET]
  454. @ get the current state of MDCNFG
  455. @
  456. ldr r3, [r1, #MDCNFG_OFFSET]
  457. @ disable all SDRAM banks
  458. @
  459. bic r3, r3, #(MDCNFG_DE0 | MDCNFG_DE1)
  460. bic r3, r3, #(MDCNFG_DE2 | MDCNFG_DE3)
  461. @ write back MDCNFG
  462. @
  463. ldr r3, [r1, #MDCNFG_OFFSET]
  464. @ Access memory not yet enabled for CBR refresh cycles (8)
  465. @ - CBR is generated for *all* banks
  466. ldr r2, =CFG_DRAM_BASE
  467. str r2, [r2]
  468. str r2, [r2]
  469. str r2, [r2]
  470. str r2, [r2]
  471. str r2, [r2]
  472. str r2, [r2]
  473. str r2, [r2]
  474. str r2, [r2]
  475. @ fetch current mdcnfg value
  476. @
  477. ldr r3, [r1, #MDCNFG_OFFSET]
  478. @ enable sdram bank 0 if installed
  479. @
  480. orr r3, r3, #MDCNFG_DE0
  481. @ write back mdcnfg, enabling the sdram bank(s)
  482. @
  483. str r3, [r1, #MDCNFG_OFFSET]
  484. @ write mdmrs
  485. @
  486. ldr r2, =CFG_MDMRS_VAL
  487. str r2, [r1, #MDMRS_OFFSET]
  488. /* @ errata: don't enable auto power-down */
  489. @ get current value of mdrefr
  490. @ldr r3, [r1, #MDREFR_OFFSET]
  491. @ enable auto-power down
  492. @orr r3, r3, #MDREFR_APD
  493. @write back mdrefr
  494. @str r3, [r1, #MDREFR_OFFSET]
  495. #endif A0_Cotulla
  496. ldr r0, =0x000C0dE3
  497. ldr r1, =_LED
  498. str r0, [r1] /* hex display */
  499. @ ^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%
  500. @ ^%^%^%^%^%^%^%^%^% above could be replaced by prememLLI ^%^%^%^%^%^%^%^%^%
  501. @ ^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%
  502. /* Save SDRAM size */
  503. ldr r1, =DRAM_SIZE
  504. str r8, [r1]
  505. ldr r0, =0xC0DE0006
  506. ldr r1, =_LED
  507. str r0, [r1] /* hex display */
  508. /* Interrupt init */
  509. /* Mask all interrupts */
  510. ldr r0, =ICMR /* enable no sources */
  511. mov r1, #0
  512. str r1, [r0]
  513. #define NODEBUG
  514. #ifdef NODEBUG
  515. /*Disable software and data breakpoints */
  516. mov r0,#0
  517. mcr p15,0,r0,c14,c8,0 /* ibcr0 */
  518. mcr p15,0,r0,c14,c9,0 /* ibcr1 */
  519. mcr p15,0,r0,c14,c4,0 /* dbcon */
  520. /*Enable all debug functionality */
  521. mov r0,#0x80000000
  522. mcr p14,0,r0,c10,c0,0 /* dcsr */
  523. #endif
  524. ldr r0, =0xBEEF001D
  525. ldr r1, =_LED
  526. str r0, [r1] /* hex display */
  527. mov pc, r10
  528. @ End memsetup
  529. @ %%%%%%%%%%% Useful subroutines
  530. GET_S23:
  531. @ This macro will read S23 and return its value in r3
  532. @ r2 contains the base address of the Lubbock user registers
  533. ldr r2, =FPGA_REGS_BASE_PHYSICAL
  534. /*@ read S23's value */
  535. ldr r3, [r2, #USER_SWITCHES_OFFSET]
  536. @ mask out irrelevant bits
  537. and r3, r3, #0x200
  538. @ get bit into position 0
  539. mov r3, r3, LSR #9
  540. mov pc, lr
  541. @ End GET_S23
  542. GET_S24:
  543. @ This macro will read S24 and return its value in r0
  544. @ r2 contains the base address of the Lubbock user registers
  545. ldr r2, =FPGA_REGS_BASE_PHYSICAL
  546. /*@ read S24's value */
  547. ldr r0, [r2, #USER_SWITCHES_OFFSET]
  548. @ mask out irrelevant bits
  549. and r0, r0, #0x100
  550. @ get bit into position 0
  551. mov r0, r0, LSR #8
  552. mov pc, lr
  553. @ End GET_S23
  554. GET_S25:
  555. @ This macro will read rotary S25 and return its value in r0
  556. @ r2 contains the base address of the Lubbock user registers
  557. @ read the user switches register
  558. ldr r0, [r2, #USER_SWITCHES_OFFSET]
  559. @ mask out irrelevant bits
  560. and r0, r0, #0xF0
  561. mov pc, lr
  562. @ End subroutine
  563. GET_S26:
  564. @ This macro will read rotary S26 and return its value in r3
  565. @ r2 contains the base address of the Lubbock user registers
  566. @ read the user switches register
  567. ldr r3, [r2, #USER_SWITCHES_OFFSET]
  568. @ mask out irrelevant bits
  569. and r3, r3, #0x0F
  570. mov pc, lr
  571. @ End subroutine GET_S26