fpga.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /* fpga_xxxx function return value definitions */
  10. #define FPGA_SUCCESS 0
  11. #define FPGA_FAIL 1
  12. /* device numbers must be non-negative */
  13. #define FPGA_INVALID_DEVICE -1
  14. #define FPGA_ENC_DEV_KEY 0
  15. #define FPGA_ENC_USR_KEY 1
  16. #define FPGA_NO_ENC_OR_NO_AUTH 2
  17. /* root data type defintions */
  18. typedef enum { /* typedef fpga_type */
  19. fpga_min_type, /* range check value */
  20. fpga_xilinx, /* Xilinx Family) */
  21. fpga_altera, /* unimplemented */
  22. fpga_lattice, /* Lattice family */
  23. fpga_undefined /* invalid range check value */
  24. } fpga_type; /* end, typedef fpga_type */
  25. typedef struct { /* typedef fpga_desc */
  26. fpga_type devtype; /* switch value to select sub-functions */
  27. void *devdesc; /* real device descriptor */
  28. } fpga_desc; /* end, typedef fpga_desc */
  29. typedef struct { /* typedef fpga_desc */
  30. unsigned int blocksize;
  31. char *interface;
  32. char *dev_part;
  33. const char *filename;
  34. int fstype;
  35. } fpga_fs_info;
  36. struct fpga_secure_info {
  37. u8 *userkey_addr;
  38. u8 authflag;
  39. u8 encflag;
  40. };
  41. typedef enum {
  42. BIT_FULL = 0,
  43. BIT_PARTIAL,
  44. BIT_NONE = 0xFF,
  45. } bitstream_type;
  46. /* root function definitions */
  47. void fpga_init(void);
  48. int fpga_add(fpga_type devtype, void *desc);
  49. int fpga_count(void);
  50. const fpga_desc *const fpga_get_desc(int devnum);
  51. int fpga_is_partial_data(int devnum, size_t img_len);
  52. int fpga_load(int devnum, const void *buf, size_t bsize,
  53. bitstream_type bstype, int flags);
  54. int fpga_fsload(int devnum, const void *buf, size_t size,
  55. fpga_fs_info *fpga_fsinfo);
  56. int fpga_loads(int devnum, const void *buf, size_t size,
  57. struct fpga_secure_info *fpga_sec_info);
  58. int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
  59. bitstream_type bstype);
  60. int fpga_dump(int devnum, const void *buf, size_t bsize);
  61. int fpga_info(int devnum);
  62. const fpga_desc *const fpga_validate(int devnum, const void *buf,
  63. size_t bsize, char *fn);
  64. int fpga_compatible2flag(int devnum, const char *compatible);
  65. #endif /* _FPGA_H_ */