hs.tcl 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright (C) 2015, 2020 Synopsys, Inc.
  2. # Anton Kolesov <anton.kolesov@synopsys.com>
  3. # Didin Evgeniy <didin@synopsys.com>
  4. #
  5. # SPDX-License-Identifier: GPL-2.0-or-later
  6. source [find cpu/arc/v2.tcl]
  7. proc arc_hs_examine_target { target } {
  8. # Will set current target for us.
  9. arc_v2_examine_target $target
  10. }
  11. proc arc_hs_init_regs { } {
  12. arc_v2_init_regs
  13. [target current] configure \
  14. -event examine-end "arc_hs_examine_target [target current]"
  15. }
  16. # Scripts in "target" folder should call this function instead of direct
  17. # invocation of arc_common_reset.
  18. proc arc_hs_reset { {target ""} } {
  19. arc_v2_reset $target
  20. # Invalidate L2 cache if there is one.
  21. set l2_config [$target arc jtag get-aux-reg 0x901]
  22. # Will return 0, if cache is not present and register doesn't exist.
  23. set l2_ctrl [$target arc jtag get-aux-reg 0x903]
  24. if { ($l2_config != 0) && (($l2_ctrl & 1) == 0) } {
  25. puts "L2 cache is present and not disabled"
  26. # Wait until BUSY bit is 0.
  27. puts "Invalidating L2 cache..."
  28. $target arc jtag set-aux-reg 0x905 1
  29. # Dummy read of SLC_AUX_CACHE_CTRL bit, as described in:
  30. # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/arch/arc?id=c70c473396cbdec1168a6eff60e13029c0916854
  31. set l2_ctrl [$target arc jtag get-aux-reg 0x903]
  32. set l2_ctrl [$target arc jtag get-aux-reg 0x903]
  33. while { ($l2_ctrl & 0x100) != 0 } {
  34. set l2_ctrl [$target arc jtag get-aux-reg 0x903]
  35. }
  36. # Flush cache if needed. If SLC_AUX_CACHE_CTRL.IM is 1, then invalidate
  37. # operation already flushed everything.
  38. if { ($l2_ctrl & 0x40) == 0 } {
  39. puts "Flushing L2 cache..."
  40. $target arc jtag set-aux-reg 0x904 1
  41. set l2_ctrl [$target arc jtag get-aux-reg 0x903]
  42. set l2_ctrl [$target arc jtag get-aux-reg 0x903]
  43. while { [expr {$l2_ctrl & 0x100}] != 0 } {
  44. set l2_ctrl [$target arc jtag get-aux-reg 0x903]
  45. }
  46. }
  47. puts "L2 cache has been flushed and invalidated."
  48. }
  49. }