head.S 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. /*
  2. * Head of the kernel - alter with care
  3. *
  4. * Copyright (C) 2000, 2001 Axis Communications AB
  5. *
  6. * Authors: Bjorn Wesen (bjornw@axis.com)
  7. *
  8. */
  9. #define ASSEMBLER_MACROS_ONLY
  10. /* The IO_* macros use the ## token concatenation operator, so
  11. -traditional must not be used when assembling this file. */
  12. #include <arch/sv_addr_ag.h>
  13. #define CRAMFS_MAGIC 0x28cd3d45
  14. #define RAM_INIT_MAGIC 0x56902387
  15. #define COMMAND_LINE_MAGIC 0x87109563
  16. #define START_ETHERNET_CLOCK IO_STATE(R_NETWORK_GEN_CONFIG, enable, on) |\
  17. IO_STATE(R_NETWORK_GEN_CONFIG, phy, mii_clk)
  18. ;; exported symbols
  19. .globl etrax_irv
  20. .globl romfs_start
  21. .globl romfs_length
  22. .globl romfs_in_flash
  23. .globl swapper_pg_dir
  24. .text
  25. ;; This is the entry point of the kernel. We are in supervisor mode.
  26. ;; 0x00000000 if Flash, 0x40004000 if DRAM
  27. ;; since etrax actually starts at address 2 when booting from flash, we
  28. ;; put a nop (2 bytes) here first so we dont accidentally skip the di
  29. ;;
  30. ;; NOTICE! The registers r8 and r9 are used as parameters carrying
  31. ;; information from the decompressor (if the kernel was compressed).
  32. ;; They should not be used in the code below until read.
  33. nop
  34. di
  35. ;; First setup the kseg_c mapping from where the kernel is linked
  36. ;; to 0x40000000 (where the actual DRAM resides) otherwise
  37. ;; we cannot do very much! See arch/cris/README.mm
  38. ;;
  39. ;; Notice that since we're potentially running at 0x00 or 0x40 right now,
  40. ;; we will get a fault as soon as we enable the MMU if we dont
  41. ;; temporarily map those segments linearily.
  42. ;;
  43. ;; Due to a bug in Etrax-100 LX version 1 we need to map the memory
  44. ;; slightly different. The bug is that you can't remap bit 31 of
  45. ;; an address. Though we can check the version register for
  46. ;; whether the bug is present, some constants would then have to
  47. ;; be variables, so we don't. The drawback is that you can "only" map
  48. ;; 1G per process with CONFIG_CRIS_LOW_MAP.
  49. #ifdef CONFIG_CRIS_LOW_MAP
  50. ; kseg mappings, temporary map of 0xc0->0x40
  51. move.d IO_FIELD (R_MMU_KBASE_HI, base_c, 4) \
  52. | IO_FIELD (R_MMU_KBASE_HI, base_b, 0xb) \
  53. | IO_FIELD (R_MMU_KBASE_HI, base_9, 9) \
  54. | IO_FIELD (R_MMU_KBASE_HI, base_8, 8), $r0
  55. move.d $r0, [R_MMU_KBASE_HI]
  56. ; temporary map of 0x40->0x40 and 0x60->0x40
  57. move.d IO_FIELD (R_MMU_KBASE_LO, base_6, 4) \
  58. | IO_FIELD (R_MMU_KBASE_LO, base_4, 4), $r0
  59. move.d $r0, [R_MMU_KBASE_LO]
  60. ; mmu enable, segs e,c,b,a,6,5,4,0 segment mapped
  61. move.d IO_STATE (R_MMU_CONFIG, mmu_enable, enable) \
  62. | IO_STATE (R_MMU_CONFIG, inv_excp, enable) \
  63. | IO_STATE (R_MMU_CONFIG, acc_excp, enable) \
  64. | IO_STATE (R_MMU_CONFIG, we_excp, enable) \
  65. | IO_STATE (R_MMU_CONFIG, seg_f, page) \
  66. | IO_STATE (R_MMU_CONFIG, seg_e, seg) \
  67. | IO_STATE (R_MMU_CONFIG, seg_d, page) \
  68. | IO_STATE (R_MMU_CONFIG, seg_c, seg) \
  69. | IO_STATE (R_MMU_CONFIG, seg_b, seg) \
  70. | IO_STATE (R_MMU_CONFIG, seg_a, seg) \
  71. | IO_STATE (R_MMU_CONFIG, seg_9, page) \
  72. | IO_STATE (R_MMU_CONFIG, seg_8, page) \
  73. | IO_STATE (R_MMU_CONFIG, seg_7, page) \
  74. | IO_STATE (R_MMU_CONFIG, seg_6, seg) \
  75. | IO_STATE (R_MMU_CONFIG, seg_5, seg) \
  76. | IO_STATE (R_MMU_CONFIG, seg_4, seg) \
  77. | IO_STATE (R_MMU_CONFIG, seg_3, page) \
  78. | IO_STATE (R_MMU_CONFIG, seg_2, page) \
  79. | IO_STATE (R_MMU_CONFIG, seg_1, page) \
  80. | IO_STATE (R_MMU_CONFIG, seg_0, seg), $r0
  81. move.d $r0, [R_MMU_CONFIG]
  82. #else
  83. ; kseg mappings
  84. move.d IO_FIELD (R_MMU_KBASE_HI, base_e, 8) \
  85. | IO_FIELD (R_MMU_KBASE_HI, base_c, 4) \
  86. | IO_FIELD (R_MMU_KBASE_HI, base_b, 0xb), $r0
  87. move.d $r0, [R_MMU_KBASE_HI]
  88. ; temporary map of 0x40->0x40 and 0x00->0x00
  89. move.d IO_FIELD (R_MMU_KBASE_LO, base_4, 4), $r0
  90. move.d $r0, [R_MMU_KBASE_LO]
  91. ; mmu enable, segs f,e,c,b,4,0 segment mapped
  92. move.d IO_STATE (R_MMU_CONFIG, mmu_enable, enable) \
  93. | IO_STATE (R_MMU_CONFIG, inv_excp, enable) \
  94. | IO_STATE (R_MMU_CONFIG, acc_excp, enable) \
  95. | IO_STATE (R_MMU_CONFIG, we_excp, enable) \
  96. | IO_STATE (R_MMU_CONFIG, seg_f, seg) \
  97. | IO_STATE (R_MMU_CONFIG, seg_e, seg) \
  98. | IO_STATE (R_MMU_CONFIG, seg_d, page) \
  99. | IO_STATE (R_MMU_CONFIG, seg_c, seg) \
  100. | IO_STATE (R_MMU_CONFIG, seg_b, seg) \
  101. | IO_STATE (R_MMU_CONFIG, seg_a, page) \
  102. | IO_STATE (R_MMU_CONFIG, seg_9, page) \
  103. | IO_STATE (R_MMU_CONFIG, seg_8, page) \
  104. | IO_STATE (R_MMU_CONFIG, seg_7, page) \
  105. | IO_STATE (R_MMU_CONFIG, seg_6, page) \
  106. | IO_STATE (R_MMU_CONFIG, seg_5, page) \
  107. | IO_STATE (R_MMU_CONFIG, seg_4, seg) \
  108. | IO_STATE (R_MMU_CONFIG, seg_3, page) \
  109. | IO_STATE (R_MMU_CONFIG, seg_2, page) \
  110. | IO_STATE (R_MMU_CONFIG, seg_1, page) \
  111. | IO_STATE (R_MMU_CONFIG, seg_0, seg), $r0
  112. move.d $r0, [R_MMU_CONFIG]
  113. #endif
  114. ;; Now we need to sort out the segments and their locations in RAM or
  115. ;; Flash. The image in the Flash (or in DRAM) consists of 3 pieces:
  116. ;; 1) kernel text, 2) kernel data, 3) ROM filesystem image
  117. ;; But the linker has linked the kernel to expect this layout in
  118. ;; DRAM memory:
  119. ;; 1) kernel text, 2) kernel data, 3) kernel BSS
  120. ;; (the location of the ROM filesystem is determined by the krom driver)
  121. ;; If we boot this from Flash, we want to keep the ROM filesystem in
  122. ;; the flash, we want to copy the text and need to copy the data to DRAM.
  123. ;; But if we boot from DRAM, we need to move the ROMFS image
  124. ;; from its position after kernel data, to after kernel BSS, BEFORE the
  125. ;; kernel starts using the BSS area (since its "overlayed" with the ROMFS)
  126. ;;
  127. ;; In both cases, we start in un-cached mode, and need to jump into a
  128. ;; cached PC after we're done fiddling around with the segments.
  129. ;;
  130. ;; arch/etrax100/etrax100.ld sets some symbols that define the start
  131. ;; and end of each segment.
  132. ;; Check if we start from DRAM or FLASH by testing PC
  133. move.d $pc,$r0
  134. and.d 0x7fffffff,$r0 ; get rid of the non-cache bit
  135. cmp.d 0x10000,$r0 ; arbitrary... just something above this code
  136. blo _inflash0
  137. nop
  138. jump _inram ; enter cached ram
  139. ;; Jumpgate for branches.
  140. _inflash0:
  141. jump _inflash
  142. ;; Put this in a suitable section where we can reclaim storage
  143. ;; after init.
  144. .section ".init.text", "ax"
  145. _inflash:
  146. #ifdef CONFIG_ETRAX_ETHERNET
  147. ;; Start MII clock to make sure it is running when tranceiver is reset
  148. move.d START_ETHERNET_CLOCK, $r0
  149. move.d $r0, [R_NETWORK_GEN_CONFIG]
  150. #endif
  151. ;; Set up waitstates etc according to kernel configuration.
  152. #ifndef CONFIG_SVINTO_SIM
  153. move.d CONFIG_ETRAX_DEF_R_WAITSTATES, $r0
  154. move.d $r0, [R_WAITSTATES]
  155. move.d CONFIG_ETRAX_DEF_R_BUS_CONFIG, $r0
  156. move.d $r0, [R_BUS_CONFIG]
  157. #endif
  158. ;; We need to initialze DRAM registers before we start using the DRAM
  159. cmp.d RAM_INIT_MAGIC, $r8 ; Already initialized?
  160. beq _dram_init_finished
  161. nop
  162. #include "../lib/dram_init.S"
  163. _dram_init_finished:
  164. ;; Copy text+data to DRAM
  165. ;; This is fragile - the calculation of r4 as the image size depends
  166. ;; on that the labels below actually are the first and last positions
  167. ;; in the linker-script.
  168. ;;
  169. ;; Then the locating of the cramfs image depends on the aforementioned
  170. ;; image being located in the flash at 0. This is most often not true,
  171. ;; thus the following does not work (normally there is a rescue-block
  172. ;; between the physical start of the flash and the flash-image start,
  173. ;; and when run with compression, the kernel is actually unpacked to
  174. ;; DRAM and we never get here in the first place :))
  175. moveq 0, $r0 ; source
  176. move.d text_start, $r1 ; destination
  177. move.d __vmlinux_end, $r2 ; end destination
  178. move.d $r2, $r4
  179. sub.d $r1, $r4 ; r4=__vmlinux_end in flash, used below
  180. 1: move.w [$r0+], $r3
  181. move.w $r3, [$r1+]
  182. cmp.d $r2, $r1
  183. blo 1b
  184. nop
  185. ;; We keep the cramfs in the flash.
  186. ;; There might be none, but that does not matter because
  187. ;; we don't do anything than read some bytes here.
  188. moveq 0, $r0
  189. move.d $r0, [romfs_length] ; default if there is no cramfs
  190. move.d [$r4], $r0 ; cramfs_super.magic
  191. cmp.d CRAMFS_MAGIC, $r0
  192. bne 1f
  193. nop
  194. move.d [$r4 + 4], $r0 ; cramfs_super.size
  195. move.d $r0, [romfs_length]
  196. #ifdef CONFIG_CRIS_LOW_MAP
  197. add.d 0x50000000, $r4 ; add flash start in virtual memory (cached)
  198. #else
  199. add.d 0xf0000000, $r4 ; add flash start in virtual memory (cached)
  200. #endif
  201. move.d $r4, [romfs_start]
  202. 1:
  203. moveq 1, $r0
  204. move.d $r0, [romfs_in_flash]
  205. jump _start_it ; enter code, cached this time
  206. _inram:
  207. ;; Move the ROM fs to after BSS end. This assumes that the cramfs
  208. ;; second longword contains the length of the cramfs
  209. moveq 0, $r0
  210. move.d $r0, [romfs_length] ; default if there is no cramfs
  211. ;; The kernel could have been unpacked to DRAM by the loader, but
  212. ;; the cramfs image could still be in the Flash directly after the
  213. ;; compressed kernel image. The loader passes the address of the
  214. ;; byte succeeding the last compressed byte in the flash in the
  215. ;; register r9 when starting the kernel. Check if r9 points to a
  216. ;; decent cramfs image!
  217. ;; (Notice that if this is not booted from the loader, r9 will be
  218. ;; garbage but we do sanity checks on it, the chance that it points
  219. ;; to a cramfs magic is small.. )
  220. cmp.d 0x0ffffff8, $r9
  221. bhs _no_romfs_in_flash ; r9 points outside the flash area
  222. nop
  223. move.d [$r9], $r0 ; cramfs_super.magic
  224. cmp.d CRAMFS_MAGIC, $r0
  225. bne _no_romfs_in_flash
  226. nop
  227. move.d [$r9+4], $r0 ; cramfs_super.length
  228. move.d $r0, [romfs_length]
  229. #ifdef CONFIG_CRIS_LOW_MAP
  230. add.d 0x50000000, $r9 ; add flash start in virtual memory (cached)
  231. #else
  232. add.d 0xf0000000, $r9 ; add flash start in virtual memory (cached)
  233. #endif
  234. move.d $r9, [romfs_start]
  235. moveq 1, $r0
  236. move.d $r0, [romfs_in_flash]
  237. jump _start_it ; enter code, cached this time
  238. _no_romfs_in_flash:
  239. ;; Check if there is a cramfs (magic value).
  240. ;; Notice that we check for cramfs magic value - which is
  241. ;; the "rom fs" we'll possibly use in 2.4 if not JFFS (which does
  242. ;; not need this mechanism anyway)
  243. move.d __init_end, $r0; the image will be after the end of init
  244. move.d [$r0], $r1 ; cramfs assumes same endian on host/target
  245. cmp.d CRAMFS_MAGIC, $r1; magic value in cramfs superblock
  246. bne 2f
  247. nop
  248. ;; Ok. What is its size ?
  249. move.d [$r0 + 4], $r2 ; cramfs_super.size (again, no need to swapwb)
  250. ;; We want to copy it to the end of the BSS
  251. move.d _end, $r1
  252. ;; Remember values so cramfs and setup can find this info
  253. move.d $r1, [romfs_start] ; new romfs location
  254. move.d $r2, [romfs_length]
  255. ;; We need to copy it backwards, since they can be overlapping
  256. add.d $r2, $r0
  257. add.d $r2, $r1
  258. ;; Go ahead. Make my loop.
  259. lsrq 1, $r2 ; size is in bytes, we copy words
  260. 1: move.w [$r0=$r0-2],$r3
  261. move.w $r3,[$r1=$r1-2]
  262. subq 1, $r2
  263. bne 1b
  264. nop
  265. 2:
  266. ;; Dont worry that the BSS is tainted. It will be cleared later.
  267. moveq 0, $r0
  268. move.d $r0, [romfs_in_flash]
  269. jump _start_it ; better skip the additional cramfs check below
  270. _start_it:
  271. ;; Check if kernel command line is supplied
  272. cmp.d COMMAND_LINE_MAGIC, $r10
  273. bne no_command_line
  274. nop
  275. move.d 256, $r13
  276. move.d cris_command_line, $r10
  277. or.d 0x80000000, $r11 ; Make it virtual
  278. 1:
  279. move.b [$r11+], $r12
  280. move.b $r12, [$r10+]
  281. subq 1, $r13
  282. bne 1b
  283. nop
  284. no_command_line:
  285. ;; the kernel stack is overlayed with the task structure for each
  286. ;; task. thus the initial kernel stack is in the same page as the
  287. ;; init_task (but starts in the top of the page, size 8192)
  288. move.d init_thread_union + 8192, $sp
  289. move.d ibr_start,$r0 ; this symbol is set by the linker script
  290. move $r0,$ibr
  291. move.d $r0,[etrax_irv] ; set the interrupt base register and pointer
  292. ;; Clear BSS region, from _bss_start to _end
  293. move.d __bss_start, $r0
  294. move.d _end, $r1
  295. 1: clear.d [$r0+]
  296. cmp.d $r1, $r0
  297. blo 1b
  298. nop
  299. #ifdef CONFIG_BLK_DEV_ETRAXIDE
  300. ;; disable ATA before enabling it in genconfig below
  301. moveq 0,$r0
  302. move.d $r0,[R_ATA_CTRL_DATA]
  303. move.d $r0,[R_ATA_TRANSFER_CNT]
  304. move.d $r0,[R_ATA_CONFIG]
  305. #if 0
  306. move.d R_PORT_G_DATA, $r1
  307. move.d $r0, [$r1]; assert ATA bus-reset
  308. nop
  309. nop
  310. nop
  311. nop
  312. nop
  313. nop
  314. move.d 0x08000000,$r0
  315. move.d $r0,[$r1]
  316. #endif
  317. #endif
  318. #ifdef CONFIG_JULIETTE
  319. ;; configure external DMA channel 0 before enabling it in genconfig
  320. moveq 0,$r0
  321. move.d $r0,[R_EXT_DMA_0_ADDR]
  322. ; cnt enable, word size, output, stop, size 0
  323. move.d IO_STATE (R_EXT_DMA_0_CMD, cnt, enable) \
  324. | IO_STATE (R_EXT_DMA_0_CMD, rqpol, ahigh) \
  325. | IO_STATE (R_EXT_DMA_0_CMD, apol, ahigh) \
  326. | IO_STATE (R_EXT_DMA_0_CMD, rq_ack, burst) \
  327. | IO_STATE (R_EXT_DMA_0_CMD, wid, word) \
  328. | IO_STATE (R_EXT_DMA_0_CMD, dir, output) \
  329. | IO_STATE (R_EXT_DMA_0_CMD, run, stop) \
  330. | IO_FIELD (R_EXT_DMA_0_CMD, trf_count, 0),$r0
  331. move.d $r0,[R_EXT_DMA_0_CMD]
  332. ;; reset dma4 and wait for completion
  333. moveq IO_STATE (R_DMA_CH4_CMD, cmd, reset),$r0
  334. move.b $r0,[R_DMA_CH4_CMD]
  335. 1: move.b [R_DMA_CH4_CMD],$r0
  336. and.b IO_MASK (R_DMA_CH4_CMD, cmd),$r0
  337. cmp.b IO_STATE (R_DMA_CH4_CMD, cmd, reset),$r0
  338. beq 1b
  339. nop
  340. ;; reset dma5 and wait for completion
  341. moveq IO_STATE (R_DMA_CH5_CMD, cmd, reset),$r0
  342. move.b $r0,[R_DMA_CH5_CMD]
  343. 1: move.b [R_DMA_CH5_CMD],$r0
  344. and.b IO_MASK (R_DMA_CH5_CMD, cmd),$r0
  345. cmp.b IO_STATE (R_DMA_CH5_CMD, cmd, reset),$r0
  346. beq 1b
  347. nop
  348. #endif
  349. ;; Etrax product HW genconfig setup
  350. moveq 0,$r0
  351. ;; Select or disable serial port 2
  352. #ifdef CONFIG_ETRAX_SERIAL_PORT2
  353. or.d IO_STATE (R_GEN_CONFIG, ser2, select),$r0
  354. #else
  355. or.d IO_STATE (R_GEN_CONFIG, ser2, disable),$r0
  356. #endif
  357. ;; Init interfaces (disable them).
  358. or.d IO_STATE (R_GEN_CONFIG, scsi0, disable) \
  359. | IO_STATE (R_GEN_CONFIG, ata, disable) \
  360. | IO_STATE (R_GEN_CONFIG, par0, disable) \
  361. | IO_STATE (R_GEN_CONFIG, mio, disable) \
  362. | IO_STATE (R_GEN_CONFIG, scsi1, disable) \
  363. | IO_STATE (R_GEN_CONFIG, scsi0w, disable) \
  364. | IO_STATE (R_GEN_CONFIG, par1, disable) \
  365. | IO_STATE (R_GEN_CONFIG, ser3, disable) \
  366. | IO_STATE (R_GEN_CONFIG, mio_w, disable) \
  367. | IO_STATE (R_GEN_CONFIG, usb1, disable) \
  368. | IO_STATE (R_GEN_CONFIG, usb2, disable) \
  369. | IO_STATE (R_GEN_CONFIG, par_w, disable),$r0
  370. ;; Init DMA channel muxing (set to unused clients).
  371. or.d IO_STATE (R_GEN_CONFIG, dma2, ata) \
  372. | IO_STATE (R_GEN_CONFIG, dma3, ata) \
  373. | IO_STATE (R_GEN_CONFIG, dma4, scsi1) \
  374. | IO_STATE (R_GEN_CONFIG, dma5, scsi1) \
  375. | IO_STATE (R_GEN_CONFIG, dma6, unused) \
  376. | IO_STATE (R_GEN_CONFIG, dma7, unused) \
  377. | IO_STATE (R_GEN_CONFIG, dma8, usb) \
  378. | IO_STATE (R_GEN_CONFIG, dma9, usb),$r0
  379. #if defined(CONFIG_ETRAX_DEF_R_PORT_G0_DIR_OUT)
  380. or.d IO_STATE (R_GEN_CONFIG, g0dir, out),$r0
  381. #endif
  382. #if defined(CONFIG_ETRAX_DEF_R_PORT_G8_15_DIR_OUT)
  383. or.d IO_STATE (R_GEN_CONFIG, g8_15dir, out),$r0
  384. #endif
  385. #if defined(CONFIG_ETRAX_DEF_R_PORT_G16_23_DIR_OUT)
  386. or.d IO_STATE (R_GEN_CONFIG, g16_23dir, out),$r0
  387. #endif
  388. #if defined(CONFIG_ETRAX_DEF_R_PORT_G24_DIR_OUT)
  389. or.d IO_STATE (R_GEN_CONFIG, g24dir, out),$r0
  390. #endif
  391. move.d $r0,[genconfig_shadow] ; init a shadow register of R_GEN_CONFIG
  392. #ifndef CONFIG_SVINTO_SIM
  393. move.d $r0,[R_GEN_CONFIG]
  394. #if 0
  395. moveq 4,$r0
  396. move.b $r0,[R_DMA_CH6_CMD] ; reset (ser0 dma out)
  397. move.b $r0,[R_DMA_CH7_CMD] ; reset (ser0 dma in)
  398. 1: move.b [R_DMA_CH6_CMD],$r0 ; wait for reset cycle to finish
  399. and.b 7,$r0
  400. cmp.b 4,$r0
  401. beq 1b
  402. nop
  403. 1: move.b [R_DMA_CH7_CMD],$r0 ; wait for reset cycle to finish
  404. and.b 7,$r0
  405. cmp.b 4,$r0
  406. beq 1b
  407. nop
  408. #endif
  409. moveq IO_STATE (R_DMA_CH8_CMD, cmd, reset),$r0
  410. move.b $r0,[R_DMA_CH8_CMD] ; reset (ser1 dma out)
  411. move.b $r0,[R_DMA_CH9_CMD] ; reset (ser1 dma in)
  412. 1: move.b [R_DMA_CH8_CMD],$r0 ; wait for reset cycle to finish
  413. andq IO_MASK (R_DMA_CH8_CMD, cmd),$r0
  414. cmpq IO_STATE (R_DMA_CH8_CMD, cmd, reset),$r0
  415. beq 1b
  416. nop
  417. 1: move.b [R_DMA_CH9_CMD],$r0 ; wait for reset cycle to finish
  418. andq IO_MASK (R_DMA_CH9_CMD, cmd),$r0
  419. cmpq IO_STATE (R_DMA_CH9_CMD, cmd, reset),$r0
  420. beq 1b
  421. nop
  422. ;; setup port PA and PB default initial directions and data
  423. ;; including their shadow registers
  424. move.b CONFIG_ETRAX_DEF_R_PORT_PA_DIR,$r0
  425. #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PA7)
  426. or.b IO_STATE (R_PORT_PA_DIR, dir7, output),$r0
  427. #endif
  428. move.b $r0,[port_pa_dir_shadow]
  429. move.b $r0,[R_PORT_PA_DIR]
  430. move.b CONFIG_ETRAX_DEF_R_PORT_PA_DATA,$r0
  431. #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PA7)
  432. #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
  433. and.b ~(1 << 7),$r0
  434. #else
  435. or.b (1 << 7),$r0
  436. #endif
  437. #endif
  438. move.b $r0,[port_pa_data_shadow]
  439. move.b $r0,[R_PORT_PA_DATA]
  440. move.b CONFIG_ETRAX_DEF_R_PORT_PB_CONFIG,$r0
  441. move.b $r0,[port_pb_config_shadow]
  442. move.b $r0,[R_PORT_PB_CONFIG]
  443. move.b CONFIG_ETRAX_DEF_R_PORT_PB_DIR,$r0
  444. #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PB5)
  445. or.b IO_STATE (R_PORT_PB_DIR, dir5, output),$r0
  446. #endif
  447. move.b $r0,[port_pb_dir_shadow]
  448. move.b $r0,[R_PORT_PB_DIR]
  449. move.b CONFIG_ETRAX_DEF_R_PORT_PB_DATA,$r0
  450. #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_PB5)
  451. #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
  452. and.b ~(1 << 5),$r0
  453. #else
  454. or.b (1 << 5),$r0
  455. #endif
  456. #endif
  457. move.b $r0,[port_pb_data_shadow]
  458. move.b $r0,[R_PORT_PB_DATA]
  459. moveq 0, $r0
  460. move.d $r0,[port_pb_i2c_shadow]
  461. move.d $r0, [R_PORT_PB_I2C]
  462. moveq 0,$r0
  463. #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_G10)
  464. #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
  465. and.d ~(1 << 10),$r0
  466. #else
  467. or.d (1 << 10),$r0
  468. #endif
  469. #endif
  470. #if defined(CONFIG_BLUETOOTH) && defined(CONFIG_BLUETOOTH_RESET_G11)
  471. #if defined(CONFIG_BLUETOOTH_RESET_ACTIVE_HIGH)
  472. and.d ~(1 << 11),$r0
  473. #else
  474. or.d (1 << 11),$r0
  475. #endif
  476. #endif
  477. move.d $r0,[port_g_data_shadow]
  478. move.d $r0,[R_PORT_G_DATA]
  479. ;; setup the serial port 0 at 115200 baud for debug purposes
  480. moveq IO_STATE (R_SERIAL0_XOFF, tx_stop, enable) \
  481. | IO_STATE (R_SERIAL0_XOFF, auto_xoff, disable) \
  482. | IO_FIELD (R_SERIAL0_XOFF, xoff_char, 0),$r0
  483. move.d $r0,[R_SERIAL0_XOFF]
  484. ; 115.2kbaud for both transmit and receive
  485. move.b IO_STATE (R_SERIAL0_BAUD, tr_baud, c115k2Hz) \
  486. | IO_STATE (R_SERIAL0_BAUD, rec_baud, c115k2Hz),$r0
  487. move.b $r0,[R_SERIAL0_BAUD]
  488. ; Set up and enable the serial0 receiver.
  489. move.b IO_STATE (R_SERIAL0_REC_CTRL, dma_err, stop) \
  490. | IO_STATE (R_SERIAL0_REC_CTRL, rec_enable, enable) \
  491. | IO_STATE (R_SERIAL0_REC_CTRL, rts_, active) \
  492. | IO_STATE (R_SERIAL0_REC_CTRL, sampling, middle) \
  493. | IO_STATE (R_SERIAL0_REC_CTRL, rec_stick_par, normal) \
  494. | IO_STATE (R_SERIAL0_REC_CTRL, rec_par, even) \
  495. | IO_STATE (R_SERIAL0_REC_CTRL, rec_par_en, disable) \
  496. | IO_STATE (R_SERIAL0_REC_CTRL, rec_bitnr, rec_8bit),$r0
  497. move.b $r0,[R_SERIAL0_REC_CTRL]
  498. ; Set up and enable the serial0 transmitter.
  499. move.b IO_FIELD (R_SERIAL0_TR_CTRL, txd, 0) \
  500. | IO_STATE (R_SERIAL0_TR_CTRL, tr_enable, enable) \
  501. | IO_STATE (R_SERIAL0_TR_CTRL, auto_cts, disabled) \
  502. | IO_STATE (R_SERIAL0_TR_CTRL, stop_bits, one_bit) \
  503. | IO_STATE (R_SERIAL0_TR_CTRL, tr_stick_par, normal) \
  504. | IO_STATE (R_SERIAL0_TR_CTRL, tr_par, even) \
  505. | IO_STATE (R_SERIAL0_TR_CTRL, tr_par_en, disable) \
  506. | IO_STATE (R_SERIAL0_TR_CTRL, tr_bitnr, tr_8bit),$r0
  507. move.b $r0,[R_SERIAL0_TR_CTRL]
  508. ;; setup the serial port 1 at 115200 baud for debug purposes
  509. moveq IO_STATE (R_SERIAL1_XOFF, tx_stop, enable) \
  510. | IO_STATE (R_SERIAL1_XOFF, auto_xoff, disable) \
  511. | IO_FIELD (R_SERIAL1_XOFF, xoff_char, 0),$r0
  512. move.d $r0,[R_SERIAL1_XOFF]
  513. ; 115.2kbaud for both transmit and receive
  514. move.b IO_STATE (R_SERIAL1_BAUD, tr_baud, c115k2Hz) \
  515. | IO_STATE (R_SERIAL1_BAUD, rec_baud, c115k2Hz),$r0
  516. move.b $r0,[R_SERIAL1_BAUD]
  517. ; Set up and enable the serial1 receiver.
  518. move.b IO_STATE (R_SERIAL1_REC_CTRL, dma_err, stop) \
  519. | IO_STATE (R_SERIAL1_REC_CTRL, rec_enable, enable) \
  520. | IO_STATE (R_SERIAL1_REC_CTRL, rts_, active) \
  521. | IO_STATE (R_SERIAL1_REC_CTRL, sampling, middle) \
  522. | IO_STATE (R_SERIAL1_REC_CTRL, rec_stick_par, normal) \
  523. | IO_STATE (R_SERIAL1_REC_CTRL, rec_par, even) \
  524. | IO_STATE (R_SERIAL1_REC_CTRL, rec_par_en, disable) \
  525. | IO_STATE (R_SERIAL1_REC_CTRL, rec_bitnr, rec_8bit),$r0
  526. move.b $r0,[R_SERIAL1_REC_CTRL]
  527. ; Set up and enable the serial1 transmitter.
  528. move.b IO_FIELD (R_SERIAL1_TR_CTRL, txd, 0) \
  529. | IO_STATE (R_SERIAL1_TR_CTRL, tr_enable, enable) \
  530. | IO_STATE (R_SERIAL1_TR_CTRL, auto_cts, disabled) \
  531. | IO_STATE (R_SERIAL1_TR_CTRL, stop_bits, one_bit) \
  532. | IO_STATE (R_SERIAL1_TR_CTRL, tr_stick_par, normal) \
  533. | IO_STATE (R_SERIAL1_TR_CTRL, tr_par, even) \
  534. | IO_STATE (R_SERIAL1_TR_CTRL, tr_par_en, disable) \
  535. | IO_STATE (R_SERIAL1_TR_CTRL, tr_bitnr, tr_8bit),$r0
  536. move.b $r0,[R_SERIAL1_TR_CTRL]
  537. #ifdef CONFIG_ETRAX_SERIAL_PORT2
  538. ;; setup the serial port 2 at 115200 baud for debug purposes
  539. moveq IO_STATE (R_SERIAL2_XOFF, tx_stop, enable) \
  540. | IO_STATE (R_SERIAL2_XOFF, auto_xoff, disable) \
  541. | IO_FIELD (R_SERIAL2_XOFF, xoff_char, 0),$r0
  542. move.d $r0,[R_SERIAL2_XOFF]
  543. ; 115.2kbaud for both transmit and receive
  544. move.b IO_STATE (R_SERIAL2_BAUD, tr_baud, c115k2Hz) \
  545. | IO_STATE (R_SERIAL2_BAUD, rec_baud, c115k2Hz),$r0
  546. move.b $r0,[R_SERIAL2_BAUD]
  547. ; Set up and enable the serial2 receiver.
  548. move.b IO_STATE (R_SERIAL2_REC_CTRL, dma_err, stop) \
  549. | IO_STATE (R_SERIAL2_REC_CTRL, rec_enable, enable) \
  550. | IO_STATE (R_SERIAL2_REC_CTRL, rts_, active) \
  551. | IO_STATE (R_SERIAL2_REC_CTRL, sampling, middle) \
  552. | IO_STATE (R_SERIAL2_REC_CTRL, rec_stick_par, normal) \
  553. | IO_STATE (R_SERIAL2_REC_CTRL, rec_par, even) \
  554. | IO_STATE (R_SERIAL2_REC_CTRL, rec_par_en, disable) \
  555. | IO_STATE (R_SERIAL2_REC_CTRL, rec_bitnr, rec_8bit),$r0
  556. move.b $r0,[R_SERIAL2_REC_CTRL]
  557. ; Set up and enable the serial2 transmitter.
  558. move.b IO_FIELD (R_SERIAL2_TR_CTRL, txd, 0) \
  559. | IO_STATE (R_SERIAL2_TR_CTRL, tr_enable, enable) \
  560. | IO_STATE (R_SERIAL2_TR_CTRL, auto_cts, disabled) \
  561. | IO_STATE (R_SERIAL2_TR_CTRL, stop_bits, one_bit) \
  562. | IO_STATE (R_SERIAL2_TR_CTRL, tr_stick_par, normal) \
  563. | IO_STATE (R_SERIAL2_TR_CTRL, tr_par, even) \
  564. | IO_STATE (R_SERIAL2_TR_CTRL, tr_par_en, disable) \
  565. | IO_STATE (R_SERIAL2_TR_CTRL, tr_bitnr, tr_8bit),$r0
  566. move.b $r0,[R_SERIAL2_TR_CTRL]
  567. #endif
  568. #ifdef CONFIG_ETRAX_SERIAL_PORT3
  569. ;; setup the serial port 3 at 115200 baud for debug purposes
  570. moveq IO_STATE (R_SERIAL3_XOFF, tx_stop, enable) \
  571. | IO_STATE (R_SERIAL3_XOFF, auto_xoff, disable) \
  572. | IO_FIELD (R_SERIAL3_XOFF, xoff_char, 0),$r0
  573. move.d $r0,[R_SERIAL3_XOFF]
  574. ; 115.2kbaud for both transmit and receive
  575. move.b IO_STATE (R_SERIAL3_BAUD, tr_baud, c115k2Hz) \
  576. | IO_STATE (R_SERIAL3_BAUD, rec_baud, c115k2Hz),$r0
  577. move.b $r0,[R_SERIAL3_BAUD]
  578. ; Set up and enable the serial3 receiver.
  579. move.b IO_STATE (R_SERIAL3_REC_CTRL, dma_err, stop) \
  580. | IO_STATE (R_SERIAL3_REC_CTRL, rec_enable, enable) \
  581. | IO_STATE (R_SERIAL3_REC_CTRL, rts_, active) \
  582. | IO_STATE (R_SERIAL3_REC_CTRL, sampling, middle) \
  583. | IO_STATE (R_SERIAL3_REC_CTRL, rec_stick_par, normal) \
  584. | IO_STATE (R_SERIAL3_REC_CTRL, rec_par, even) \
  585. | IO_STATE (R_SERIAL3_REC_CTRL, rec_par_en, disable) \
  586. | IO_STATE (R_SERIAL3_REC_CTRL, rec_bitnr, rec_8bit),$r0
  587. move.b $r0,[R_SERIAL3_REC_CTRL]
  588. ; Set up and enable the serial3 transmitter.
  589. move.b IO_FIELD (R_SERIAL3_TR_CTRL, txd, 0) \
  590. | IO_STATE (R_SERIAL3_TR_CTRL, tr_enable, enable) \
  591. | IO_STATE (R_SERIAL3_TR_CTRL, auto_cts, disabled) \
  592. | IO_STATE (R_SERIAL3_TR_CTRL, stop_bits, one_bit) \
  593. | IO_STATE (R_SERIAL3_TR_CTRL, tr_stick_par, normal) \
  594. | IO_STATE (R_SERIAL3_TR_CTRL, tr_par, even) \
  595. | IO_STATE (R_SERIAL3_TR_CTRL, tr_par_en, disable) \
  596. | IO_STATE (R_SERIAL3_TR_CTRL, tr_bitnr, tr_8bit),$r0
  597. move.b $r0,[R_SERIAL3_TR_CTRL]
  598. #endif
  599. #endif /* CONFIG_SVINTO_SIM */
  600. jump start_kernel ; jump into the C-function start_kernel in init/main.c
  601. .data
  602. etrax_irv:
  603. .dword 0
  604. romfs_start:
  605. .dword 0
  606. romfs_length:
  607. .dword 0
  608. romfs_in_flash:
  609. .dword 0
  610. ;; put some special pages at the beginning of the kernel aligned
  611. ;; to page boundaries - the kernel cannot start until after this
  612. #ifdef CONFIG_CRIS_LOW_MAP
  613. swapper_pg_dir = 0x60002000
  614. #else
  615. swapper_pg_dir = 0xc0002000
  616. #endif
  617. .section ".init.data", "aw"
  618. #include "../lib/hw_settings.S"