altera.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2002
  4. * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
  5. */
  6. #include <fpga.h>
  7. #ifndef _ALTERA_H_
  8. #define _ALTERA_H_
  9. /*
  10. * For the StratixV FPGA programming via SPI, the following
  11. * information is coded in the 32bit cookie:
  12. * Bit 31 ... Bit 0
  13. * SPI-Bus | SPI-Dev | Config-Pin | Done-Pin
  14. */
  15. #define FPGA_COOKIE(bus, dev, config, done) \
  16. (((bus) << 24) | ((dev) << 16) | ((config) << 8) | (done))
  17. #define COOKIE2SPI_BUS(c) (((c) >> 24) & 0xff)
  18. #define COOKIE2SPI_DEV(c) (((c) >> 16) & 0xff)
  19. #define COOKIE2CONFIG(c) (((c) >> 8) & 0xff)
  20. #define COOKIE2DONE(c) ((c) & 0xff)
  21. enum altera_iface {
  22. /* insert all new types after this */
  23. min_altera_iface_type,
  24. /* serial data and external clock */
  25. passive_serial,
  26. /* parallel data */
  27. passive_parallel_synchronous,
  28. /* parallel data */
  29. passive_parallel_asynchronous,
  30. /* serial data w/ internal clock (not used) */
  31. passive_serial_asynchronous,
  32. /* jtag/tap serial (not used ) */
  33. altera_jtag_mode,
  34. /* fast passive parallel (FPP) */
  35. fast_passive_parallel,
  36. /* fast passive parallel with security (FPPS) */
  37. fast_passive_parallel_security,
  38. /* secure device manager (SDM) mailbox */
  39. secure_device_manager_mailbox,
  40. /* insert all new types before this */
  41. max_altera_iface_type,
  42. };
  43. enum altera_family {
  44. /* insert all new types after this */
  45. min_altera_type,
  46. /* ACEX1K Family */
  47. Altera_ACEX1K,
  48. /* CYCLONII Family */
  49. Altera_CYC2,
  50. /* StratixII Family */
  51. Altera_StratixII,
  52. /* StratixV Family */
  53. Altera_StratixV,
  54. /* Stratix10 Family */
  55. Intel_FPGA_Stratix10,
  56. /* SoCFPGA Family */
  57. Altera_SoCFPGA,
  58. /* Add new models here */
  59. /* insert all new types before this */
  60. max_altera_type,
  61. };
  62. typedef struct {
  63. /* part type */
  64. enum altera_family family;
  65. /* interface type */
  66. enum altera_iface iface;
  67. /* bytes of data part can accept */
  68. size_t size;
  69. /* interface function table */
  70. void *iface_fns;
  71. /* base interface address */
  72. void *base;
  73. /* implementation specific cookie */
  74. int cookie;
  75. } Altera_desc;
  76. /* Generic Altera Functions
  77. *********************************************************************/
  78. extern int altera_load(Altera_desc *desc, const void *image, size_t size);
  79. extern int altera_dump(Altera_desc *desc, const void *buf, size_t bsize);
  80. extern int altera_info(Altera_desc *desc);
  81. /* Board specific implementation specific function types
  82. *********************************************************************/
  83. typedef int (*Altera_pre_fn)( int cookie );
  84. typedef int (*Altera_config_fn)( int assert_config, int flush, int cookie );
  85. typedef int (*Altera_status_fn)( int cookie );
  86. typedef int (*Altera_done_fn)( int cookie );
  87. typedef int (*Altera_clk_fn)( int assert_clk, int flush, int cookie );
  88. typedef int (*Altera_data_fn)( int assert_data, int flush, int cookie );
  89. typedef int(*Altera_write_fn)(const void *buf, size_t len, int flush, int cookie);
  90. typedef int (*Altera_abort_fn)( int cookie );
  91. typedef int (*Altera_post_fn)( int cookie );
  92. typedef struct {
  93. Altera_pre_fn pre;
  94. Altera_config_fn config;
  95. Altera_status_fn status;
  96. Altera_done_fn done;
  97. Altera_clk_fn clk;
  98. Altera_data_fn data;
  99. Altera_write_fn write;
  100. Altera_abort_fn abort;
  101. Altera_post_fn post;
  102. } altera_board_specific_func;
  103. #ifdef CONFIG_FPGA_SOCFPGA
  104. int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size);
  105. #endif
  106. #ifdef CONFIG_FPGA_STRATIX_V
  107. int stratixv_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size);
  108. #endif
  109. #ifdef CONFIG_FPGA_STRATIX10
  110. int stratix10_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size);
  111. #endif
  112. #endif /* _ALTERA_H_ */