fpga.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * (C) Copyright 2002
  3. * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. */
  24. #include <linux/types.h> /* for ulong typedef */
  25. #ifndef _FPGA_H_
  26. #define _FPGA_H_
  27. #ifndef CONFIG_MAX_FPGA_DEVICES
  28. #define CONFIG_MAX_FPGA_DEVICES 5
  29. #endif
  30. /* CONFIG_FPGA bit assignments */
  31. #define CONFIG_SYS_FPGA_MAN(x) (x)
  32. #define CONFIG_SYS_FPGA_DEV(x) ((x) << 8 )
  33. #define CONFIG_SYS_FPGA_IF(x) ((x) << 16 )
  34. /* FPGA Manufacturer bits in CONFIG_FPGA */
  35. #define CONFIG_SYS_FPGA_XILINX CONFIG_SYS_FPGA_MAN( 0x1 )
  36. #define CONFIG_SYS_FPGA_ALTERA CONFIG_SYS_FPGA_MAN( 0x2 )
  37. /* fpga_xxxx function return value definitions */
  38. #define FPGA_SUCCESS 0
  39. #define FPGA_FAIL -1
  40. /* device numbers must be non-negative */
  41. #define FPGA_INVALID_DEVICE -1
  42. /* root data type defintions */
  43. typedef enum { /* typedef fpga_type */
  44. fpga_min_type, /* range check value */
  45. fpga_xilinx, /* Xilinx Family) */
  46. fpga_altera, /* unimplemented */
  47. fpga_lattice, /* Lattice family */
  48. fpga_undefined /* invalid range check value */
  49. } fpga_type; /* end, typedef fpga_type */
  50. typedef struct { /* typedef fpga_desc */
  51. fpga_type devtype; /* switch value to select sub-functions */
  52. void *devdesc; /* real device descriptor */
  53. } fpga_desc; /* end, typedef fpga_desc */
  54. /* root function definitions */
  55. extern void fpga_init(void);
  56. extern int fpga_add(fpga_type devtype, void *desc);
  57. extern int fpga_count(void);
  58. extern int fpga_load(int devnum, const void *buf, size_t bsize);
  59. extern int fpga_loadbitstream(unsigned long dev, char *fpgadata, size_t size);
  60. extern int fpga_dump(int devnum, const void *buf, size_t bsize);
  61. extern int fpga_info(int devnum);
  62. #endif /* _FPGA_H_ */