altera.h 3.3 KB

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