gp326xxxa.cfg 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # SPDX-License-Identifier: GPL-2.0-or-later
  2. #
  3. # Support for General Plus GP326XXXA chips
  4. #
  5. if { [info exists CHIPNAME] } {
  6. set _CHIPNAME $CHIPNAME
  7. } else {
  8. set _CHIPNAME gp326xxxa
  9. }
  10. if { [info exists ENDIAN] } {
  11. set _ENDIAN $ENDIAN
  12. } else {
  13. set _ENDIAN little
  14. }
  15. if { [info exists CPUTAPID] } {
  16. set _CPUTAPID $CPUTAPID
  17. } else {
  18. set _CPUTAPID 0x4f1f0f0f
  19. }
  20. jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
  21. set _TARGETNAME $_CHIPNAME.cpu
  22. target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME
  23. # Use internal SRAM as a work area
  24. $_TARGETNAME configure -work-area-phys 0xf8000000 -work-area-size 0x8000 -work-area-backup 0
  25. # The chip has both lines connected together
  26. reset_config trst_and_srst srst_pulls_trst
  27. # This delay is needed otherwise communication with the target would
  28. # be unreliable
  29. adapter srst delay 100
  30. # Set the adapter speed ridiculously low just in case we are
  31. # running off of a 32kHz clock
  32. adapter speed 2
  33. proc gp32xxxa_halt_and_reset_control_registers {} {
  34. # System control registers
  35. set P_SYSTEM_CTRL_NEW 0xD0000008
  36. set P_SYSTEM_CTRL 0xD000000C
  37. set P_SYSTEM_CLK_EN0 0xD0000010
  38. set P_SYSTEM_CLK_EN1 0xD0000014
  39. set P_SYSTEM_RESET_FLAG 0xD0000018
  40. set P_SYSTEM_CLK_CTRL 0xD000001C
  41. set P_SYSTEM_LVR_CTRL 0xD0000020
  42. set P_SYSTEM_WATCHDOG_CTRL 0xD0000024
  43. set P_SYSTEM_PLLEN 0xD000005C
  44. # Since we can't use SRST without pulling TRST
  45. # we can't assume the state of the clock configuration
  46. # or watchdog settings. So reset them before porceeding
  47. # Set the adapter speed ridiculously low just in case we are
  48. # running off of a 32kHz clock
  49. adapter speed 2
  50. # Disable any advanced features at this stage
  51. arm7_9 dcc_downloads disable
  52. arm7_9 fast_memory_access disable
  53. # Do a "soft reset"
  54. soft_reset_halt
  55. # Reset all system control registers to their default "after-reset" values
  56. mwh $P_SYSTEM_WATCHDOG_CTRL 0x0000
  57. mwh $P_SYSTEM_LVR_CTRL 0x0000
  58. mwh $P_SYSTEM_CTRL_NEW 0x0001
  59. mwh $P_SYSTEM_CTRL 0x0001
  60. # Clear all reset flags by writing 1's
  61. mwh $P_SYSTEM_RESET_FLAG 0x001C
  62. mwh $P_SYSTEM_CLK_CTRL 0x8000
  63. mwh $P_SYSTEM_CLK_EN0 0xFFFF
  64. mwh $P_SYSTEM_CLK_EN1 0xFFFF
  65. mwh $P_SYSTEM_PLLEN 0x0010
  66. # Unfortunately there's no register that would allow us to
  67. # know if PLL is locked. So just wait for 100ms in hopes that
  68. # it would be enough.
  69. sleep 100
  70. # Now that we know that we are running at 48Mhz
  71. # Increase JTAG speed and enable speed optimization features
  72. adapter speed 5000
  73. arm7_9 dcc_downloads enable
  74. arm7_9 fast_memory_access enable
  75. }
  76. $_TARGETNAME configure -event reset-end { gp32xxxa_halt_and_reset_control_registers }