fpga.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /* 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. char *filename;
  34. int fstype;
  35. } fpga_fs_info;
  36. typedef enum {
  37. BIT_FULL = 0,
  38. BIT_PARTIAL,
  39. BIT_NONE = 0xFF,
  40. } bitstream_type;
  41. /* root function definitions */
  42. void fpga_init(void);
  43. int fpga_add(fpga_type devtype, void *desc);
  44. int fpga_count(void);
  45. const fpga_desc *const fpga_get_desc(int devnum);
  46. int fpga_is_partial_data(int devnum, size_t img_len);
  47. int fpga_load(int devnum, const void *buf, size_t bsize,
  48. bitstream_type bstype);
  49. int fpga_fsload(int devnum, const void *buf, size_t size,
  50. fpga_fs_info *fpga_fsinfo);
  51. int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
  52. bitstream_type bstype);
  53. int fpga_dump(int devnum, const void *buf, size_t bsize);
  54. int fpga_info(int devnum);
  55. const fpga_desc *const fpga_validate(int devnum, const void *buf,
  56. size_t bsize, char *fn);
  57. #endif /* _FPGA_H_ */