fpga.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2002
  4. * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
  5. */
  6. #include <linux/types.h> /* for ulong typedef */
  7. #ifndef _FPGA_H_
  8. #define _FPGA_H_
  9. #ifndef CONFIG_MAX_FPGA_DEVICES
  10. #define CONFIG_MAX_FPGA_DEVICES 5
  11. #endif
  12. /* fpga_xxxx function return value definitions */
  13. #define FPGA_SUCCESS 0
  14. #define FPGA_FAIL 1
  15. /* device numbers must be non-negative */
  16. #define FPGA_INVALID_DEVICE -1
  17. #define FPGA_ENC_USR_KEY 1
  18. #define FPGA_NO_ENC_OR_NO_AUTH 2
  19. /* root data type defintions */
  20. typedef enum { /* typedef fpga_type */
  21. fpga_min_type, /* range check value */
  22. fpga_xilinx, /* Xilinx Family) */
  23. fpga_altera, /* unimplemented */
  24. fpga_lattice, /* Lattice family */
  25. fpga_undefined /* invalid range check value */
  26. } fpga_type; /* end, typedef fpga_type */
  27. typedef struct { /* typedef fpga_desc */
  28. fpga_type devtype; /* switch value to select sub-functions */
  29. void *devdesc; /* real device descriptor */
  30. } fpga_desc; /* end, typedef fpga_desc */
  31. typedef struct { /* typedef fpga_desc */
  32. unsigned int blocksize;
  33. char *interface;
  34. char *dev_part;
  35. const char *filename;
  36. int fstype;
  37. } fpga_fs_info;
  38. struct fpga_secure_info {
  39. u8 *userkey_addr;
  40. u8 authflag;
  41. u8 encflag;
  42. };
  43. typedef enum {
  44. BIT_FULL = 0,
  45. BIT_PARTIAL,
  46. BIT_NONE = 0xFF,
  47. } bitstream_type;
  48. /* root function definitions */
  49. void fpga_init(void);
  50. int fpga_add(fpga_type devtype, void *desc);
  51. int fpga_count(void);
  52. const fpga_desc *const fpga_get_desc(int devnum);
  53. int fpga_is_partial_data(int devnum, size_t img_len);
  54. int fpga_load(int devnum, const void *buf, size_t bsize,
  55. bitstream_type bstype);
  56. int fpga_fsload(int devnum, const void *buf, size_t size,
  57. fpga_fs_info *fpga_fsinfo);
  58. int fpga_loads(int devnum, const void *buf, size_t size,
  59. struct fpga_secure_info *fpga_sec_info);
  60. int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
  61. bitstream_type bstype);
  62. int fpga_dump(int devnum, const void *buf, size_t bsize);
  63. int fpga_info(int devnum);
  64. const fpga_desc *const fpga_validate(int devnum, const void *buf,
  65. size_t bsize, char *fn);
  66. #endif /* _FPGA_H_ */