startup.inc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef STARTUP_INC_INCLUDED
  2. #define STARTUP_INC_INCLUDED
  3. #include <hwregs/asm/reg_map_asm.h>
  4. #include <hwregs/asm/gio_defs_asm.h>
  5. #include <hwregs/asm/pio_defs_asm.h>
  6. #include <hwregs/asm/clkgen_defs_asm.h>
  7. #include <hwregs/asm/pinmux_defs_asm.h>
  8. .macro GIO_SET_P BITS, OUTREG
  9. bmi 1f ; btstq: bit -> N flag
  10. nop
  11. or.d \BITS, \OUTREG
  12. 1:
  13. .endm
  14. .macro GIO_INIT
  15. move.d CONFIG_ETRAX_DEF_GIO_PA_OUT, $r0
  16. move.d REG_ADDR(gio, regi_gio, rw_pa_dout), $r1
  17. move.d $r0, [$r1]
  18. move.d CONFIG_ETRAX_DEF_GIO_PA_OE, $r0
  19. move.d REG_ADDR(gio, regi_gio, rw_pa_oe), $r1
  20. move.d $r0, [$r1]
  21. move.d CONFIG_ETRAX_DEF_GIO_PB_OUT, $r0
  22. move.d REG_ADDR(gio, regi_gio, rw_pb_dout), $r1
  23. move.d $r0, [$r1]
  24. move.d CONFIG_ETRAX_DEF_GIO_PB_OE, $r0
  25. move.d REG_ADDR(gio, regi_gio, rw_pb_oe), $r1
  26. move.d $r0, [$r1]
  27. move.d CONFIG_ETRAX_DEF_GIO_PC_OUT, $r0
  28. move.d REG_ADDR(gio, regi_gio, rw_pc_dout), $r1
  29. move.d $r0, [$r1]
  30. move.d CONFIG_ETRAX_DEF_GIO_PC_OE, $r0
  31. move.d REG_ADDR(gio, regi_gio, rw_pc_oe), $r1
  32. move.d $r0, [$r1]
  33. move.d 0xFFFFFFFF, $r0
  34. move.d REG_ADDR(pinmux, regi_pinmux, rw_gio_pa), $r1
  35. move.d $r0, [$r1]
  36. move.d REG_ADDR(pinmux, regi_pinmux, rw_gio_pc), $r1
  37. move.d $r0, [$r1]
  38. ;; If eth_mdio, eth, geth bits are set in hwprot, don't
  39. ;; set them to gpio, as this means they have been configured
  40. ;; earlier and shouldn't be changed.
  41. move.d 0xFC000000, $r2 ; pins 25..0 are eth_mdio, eth, geth
  42. move.d REG_ADDR(pinmux, regi_pinmux, rw_hwprot), $r1
  43. move.d [$r1], $r0
  44. btstq REG_BIT(pinmux, rw_hwprot, eth), $r0
  45. GIO_SET_P 0x00FFFF00, $r2 ;; pins 8..23 are eth
  46. btstq REG_BIT(pinmux, rw_hwprot, eth_mdio), $r0
  47. GIO_SET_P 0x03000000, $r2 ;; pins 24..25 are eth_mdio
  48. btstq REG_BIT(pinmux, rw_hwprot, geth), $r0
  49. GIO_SET_P 0x000000FF, $r2 ;; pins 0..7 are geth
  50. move.d REG_ADDR(pinmux, regi_pinmux, rw_gio_pb), $r1
  51. move.d $r2, [$r1]
  52. .endm
  53. .macro START_CLOCKS
  54. move.d REG_ADDR(clkgen, regi_clkgen, rw_clk_ctrl), $r1
  55. move.d [$r1], $r0
  56. or.d REG_STATE(clkgen, rw_clk_ctrl, cpu, yes) | \
  57. REG_STATE(clkgen, rw_clk_ctrl, ddr2, yes) | \
  58. REG_STATE(clkgen, rw_clk_ctrl, memarb_bar_ddr, yes), $r0
  59. move.d $r0, [$r1]
  60. .endm
  61. .macro SETUP_WAIT_STATES
  62. move.d REG_ADDR(pio, regi_pio, rw_ce0_cfg), $r0
  63. move.d CONFIG_ETRAX_PIO_CE0_CFG, $r1
  64. move.d $r1, [$r0]
  65. move.d REG_ADDR(pio, regi_pio, rw_ce1_cfg), $r0
  66. move.d CONFIG_ETRAX_PIO_CE1_CFG, $r1
  67. move.d $r1, [$r0]
  68. move.d REG_ADDR(pio, regi_pio, rw_ce2_cfg), $r0
  69. move.d CONFIG_ETRAX_PIO_CE2_CFG, $r1
  70. move.d $r1, [$r0]
  71. .endm
  72. #endif