head.S 20 KB

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