You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

116 lines
3.0 KiB

  1. #
  2. # Copyright (C) 2011 by Karl Kurbjun
  3. # Copyright (C) 2009 by David Brownell
  4. #
  5. # Utilities for TI ICEpick-C ... used in DaVinci, OMAP3, and more.
  6. # Details about the ICEPickC are available in the AM/DM37x document SPRUGN4M
  7. # create "constants"
  8. proc CONST { key } {
  9. array set constant {
  10. # define ICEPick instructions
  11. IR_BYPASS 0x00
  12. IR_ROUTER 0x02
  13. IR_CONNECT 0x07
  14. IF_BYPASS 0x3F
  15. }
  16. return $constant($key)
  17. }
  18. # Instruction to connect to the icepick module
  19. proc icepick_c_connect {jrc} {
  20. # Send CONNECT instruction in IR state
  21. irscan $jrc [CONST IR_CONNECT] -endstate IRPAUSE
  22. # Send write and connect key
  23. drscan $jrc 8 0x89 -endstate DRPAUSE
  24. }
  25. # Instruction to disconnect to the icepick module
  26. proc icepick_c_disconnect {jrc} {
  27. # Send CONNECT instruction in IR state
  28. irscan $jrc [CONST IR_CONNECT] -endstate IRPAUSE
  29. # Send write and connect key
  30. drscan $jrc 8 0x86 -endstate DRPAUSE
  31. }
  32. #
  33. # icepick_c_router:
  34. # this function is for sending router commands
  35. # arguments are:
  36. # jrc: TAP name for the ICEpick
  37. # rw: read/write (0 for read, 1 for write)
  38. # block: icepick or DAP
  39. # register: which register to read/write
  40. # payload: value to read/write
  41. # this function is for sending router commands
  42. #
  43. proc icepick_c_router {jrc rw block register payload} {
  44. set new_dr_value \
  45. [expr ( ($rw & 0x1) << 31) | ( ($block & 0x7) << 28) | \
  46. ( ($register & 0xF) << 24) | ( $payload & 0xFFFFFF ) ]
  47. # echo "\tNew router value:\t0x[format %x $new_dr_value]"
  48. # select router
  49. irscan $jrc [CONST IR_ROUTER] -endstate IRPAUSE
  50. # ROUTER instructions are 32 bits wide
  51. set old_dr_value [drscan $jrc 32 $new_dr_value -endstate DRPAUSE]
  52. }
  53. # Configure the icepick control register
  54. proc icepick_c_setup {jrc} {
  55. # send a router write, block is 0, register is 1, value is 0x2100
  56. icepick_c_router $jrc 1 0x0 0x1 0x001000
  57. }
  58. # jrc == TAP name for the ICEpick
  59. # port == a port number, 0..15
  60. proc icepick_c_tapenable {jrc port} {
  61. # First CONNECT to the ICEPick
  62. # echo "Connecting to ICEPick"
  63. icepick_c_connect $jrc
  64. # echo "Configuring the ICEpick"
  65. icepick_c_setup $jrc
  66. # NOTE: it's important not to enter RUN/IDLE state until
  67. # done sending these instructions and data to the ICEpick.
  68. # And never to enter RESET, which will disable the TAPs.
  69. # first enable power and clock for TAP
  70. icepick_c_router $jrc 1 0x2 $port 0x100048
  71. # TRM states that the register should be read back here, skipped for now
  72. # enable debug "default" mode
  73. icepick_c_router $jrc 1 0x2 $port 0x102048
  74. # TRM states that debug enable and debug mode should be read back and
  75. # confirmed - skipped for now
  76. # Finally select the tap
  77. icepick_c_router $jrc 1 0x2 $port 0x102148
  78. # Enter the bypass state
  79. irscan $jrc [CONST IR_BYPASS] -endstate RUN/IDLE
  80. runtest 10
  81. }
  82. # This function uses the ICEPick to send a warm system reset
  83. proc icepick_c_wreset {jrc} {
  84. # send a router write, block is 0, register is 1, value is 0x2100
  85. icepick_c_router $jrc 1 0x0 0x1 0x002101
  86. }