altera.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /* insert all new types before this */
  39. max_altera_iface_type,
  40. };
  41. enum altera_family {
  42. /* insert all new types after this */
  43. min_altera_type,
  44. /* ACEX1K Family */
  45. Altera_ACEX1K,
  46. /* CYCLONII Family */
  47. Altera_CYC2,
  48. /* StratixII Family */
  49. Altera_StratixII,
  50. /* StratixV Family */
  51. Altera_StratixV,
  52. /* SoCFPGA Family */
  53. Altera_SoCFPGA,
  54. /* Add new models here */
  55. /* insert all new types before this */
  56. max_altera_type,
  57. };
  58. typedef struct {
  59. /* part type */
  60. enum altera_family family;
  61. /* interface type */
  62. enum altera_iface iface;
  63. /* bytes of data part can accept */
  64. size_t size;
  65. /* interface function table */
  66. void *iface_fns;
  67. /* base interface address */
  68. void *base;
  69. /* implementation specific cookie */
  70. int cookie;
  71. } Altera_desc;
  72. /* Generic Altera Functions
  73. *********************************************************************/
  74. extern int altera_load(Altera_desc *desc, const void *image, size_t size);
  75. extern int altera_dump(Altera_desc *desc, const void *buf, size_t bsize);
  76. extern int altera_info(Altera_desc *desc);
  77. /* Board specific implementation specific function types
  78. *********************************************************************/
  79. typedef int (*Altera_pre_fn)( int cookie );
  80. typedef int (*Altera_config_fn)( int assert_config, int flush, int cookie );
  81. typedef int (*Altera_status_fn)( int cookie );
  82. typedef int (*Altera_done_fn)( int cookie );
  83. typedef int (*Altera_clk_fn)( int assert_clk, int flush, int cookie );
  84. typedef int (*Altera_data_fn)( int assert_data, int flush, int cookie );
  85. typedef int(*Altera_write_fn)(const void *buf, size_t len, int flush, int cookie);
  86. typedef int (*Altera_abort_fn)( int cookie );
  87. typedef int (*Altera_post_fn)( int cookie );
  88. typedef struct {
  89. Altera_pre_fn pre;
  90. Altera_config_fn config;
  91. Altera_status_fn status;
  92. Altera_done_fn done;
  93. Altera_clk_fn clk;
  94. Altera_data_fn data;
  95. Altera_write_fn write;
  96. Altera_abort_fn abort;
  97. Altera_post_fn post;
  98. } altera_board_specific_func;
  99. #ifdef CONFIG_FPGA_SOCFPGA
  100. int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size);
  101. #endif
  102. #ifdef CONFIG_FPGA_STRATIX_V
  103. int stratixv_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size);
  104. #endif
  105. #endif /* _ALTERA_H_ */