scan_manager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2013 Altera Corporation <www.altera.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _SCAN_MANAGER_H_
  7. #define _SCAN_MANAGER_H_
  8. struct socfpga_scan_manager {
  9. u32 stat;
  10. u32 en;
  11. u32 padding[2];
  12. u32 fifo_single_byte;
  13. u32 fifo_double_byte;
  14. u32 fifo_triple_byte;
  15. u32 fifo_quad_byte;
  16. };
  17. /*
  18. * Shift count to get number of IO scan chain data in granularity
  19. * of 128-bit ( N / 128 )
  20. */
  21. #define IO_SCAN_CHAIN_128BIT_SHIFT 7
  22. /*
  23. * Mask to get residual IO scan chain data in
  24. * granularity of 128-bit ( N mod 128 )
  25. */
  26. #define IO_SCAN_CHAIN_128BIT_MASK 0x7F
  27. /*
  28. * Shift count to get number of IO scan chain
  29. * data in granularity of 32-bit ( N / 32 )
  30. */
  31. #define IO_SCAN_CHAIN_32BIT_SHIFT 5
  32. /*
  33. * Mask to get residual IO scan chain data in
  34. * granularity of 32-bit ( N mod 32 )
  35. */
  36. #define IO_SCAN_CHAIN_32BIT_MASK 0x1F
  37. /* Byte mask */
  38. #define IO_SCAN_CHAIN_BYTE_MASK 0xFF
  39. /* 24-bits (3 bytes) IO scan chain payload definition */
  40. #define IO_SCAN_CHAIN_PAYLOAD_24BIT 24
  41. /*
  42. * Maximum length of TDI_TDO packet payload is 128 bits,
  43. * represented by (length - 1) in TDI_TDO header
  44. */
  45. #define TDI_TDO_MAX_PAYLOAD 127
  46. /* TDI_TDO packet header for IO scan chain program */
  47. #define TDI_TDO_HEADER_FIRST_BYTE 0x80
  48. /* Position of second command byte for TDI_TDO packet */
  49. #define TDI_TDO_HEADER_SECOND_BYTE_SHIFT 8
  50. /*
  51. * Maximum polling loop to wait for IO scan chain engine
  52. * becomes idle to prevent infinite loop
  53. */
  54. #define SCAN_MAX_DELAY 100
  55. #define SCANMGR_STAT_ACTIVE_GET(x) (((x) & 0x80000000) >> 31)
  56. #define SCANMGR_STAT_WFIFOCNT_GET(x) (((x) & 0x70000000) >> 28)
  57. /*
  58. * Program HPS IO Scan Chain
  59. * io_scan_chain_id - IO scan chain ID
  60. * io_scan_chain_len_in_bits - IO scan chain length in bits
  61. * iocsr_scan_chain - IO scan chain table
  62. */
  63. uint32_t scan_mgr_io_scan_chain_prg(
  64. uint32_t io_scan_chain_id,
  65. uint32_t io_scan_chain_len_in_bits,
  66. const uint32_t *iocsr_scan_chain);
  67. extern const uint32_t iocsr_scan_chain0_table[
  68. ((CONFIG_HPS_IOCSR_SCANCHAIN0_LENGTH / 32) + 1)];
  69. extern const uint32_t iocsr_scan_chain1_table[
  70. ((CONFIG_HPS_IOCSR_SCANCHAIN1_LENGTH / 32) + 1)];
  71. extern const uint32_t iocsr_scan_chain2_table[
  72. ((CONFIG_HPS_IOCSR_SCANCHAIN2_LENGTH / 32) + 1)];
  73. extern const uint32_t iocsr_scan_chain3_table[
  74. ((CONFIG_HPS_IOCSR_SCANCHAIN3_LENGTH / 32) + 1)];
  75. int scan_mgr_configure_iocsr(void);
  76. #endif /* _SCAN_MANAGER_H_ */