wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Rich Ireland, Enterasys Networks, rireland@enterasys.com. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 8 | #include <linux/types.h> /* for ulong typedef */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 9 | |
| 10 | #ifndef _FPGA_H_ |
| 11 | #define _FPGA_H_ |
| 12 | |
| 13 | #ifndef CONFIG_MAX_FPGA_DEVICES |
| 14 | #define CONFIG_MAX_FPGA_DEVICES 5 |
| 15 | #endif |
| 16 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 17 | /* fpga_xxxx function return value definitions */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 18 | #define FPGA_SUCCESS 0 |
| 19 | #define FPGA_FAIL -1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 20 | |
| 21 | /* device numbers must be non-negative */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 22 | #define FPGA_INVALID_DEVICE -1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 23 | |
| 24 | /* root data type defintions */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 25 | typedef enum { /* typedef fpga_type */ |
| 26 | fpga_min_type, /* range check value */ |
| 27 | fpga_xilinx, /* Xilinx Family) */ |
| 28 | fpga_altera, /* unimplemented */ |
Stefano Babic | ec65c59 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 29 | fpga_lattice, /* Lattice family */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 30 | fpga_undefined /* invalid range check value */ |
| 31 | } fpga_type; /* end, typedef fpga_type */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 32 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 33 | typedef struct { /* typedef fpga_desc */ |
| 34 | fpga_type devtype; /* switch value to select sub-functions */ |
| 35 | void *devdesc; /* real device descriptor */ |
| 36 | } fpga_desc; /* end, typedef fpga_desc */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 37 | |
Siva Durga Prasad Paladugu | 9112b4c | 2014-03-14 16:35:37 +0530 | [diff] [blame] | 38 | typedef struct { /* typedef fpga_desc */ |
| 39 | unsigned int blocksize; |
| 40 | char *interface; |
| 41 | char *dev_part; |
| 42 | char *filename; |
| 43 | int fstype; |
| 44 | } fpga_fs_info; |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 45 | |
Michal Simek | 1466365 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 46 | typedef enum { |
| 47 | BIT_FULL = 0, |
Michal Simek | 64c7098 | 2014-05-02 13:43:39 +0200 | [diff] [blame] | 48 | BIT_PARTIAL, |
Michal Simek | 1466365 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 49 | } bitstream_type; |
| 50 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 51 | /* root function definitions */ |
Wolfgang Denk | 74f9b38 | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 52 | extern void fpga_init(void); |
| 53 | extern int fpga_add(fpga_type devtype, void *desc); |
| 54 | extern int fpga_count(void); |
Michal Simek | 1466365 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 55 | extern int fpga_load(int devnum, const void *buf, size_t bsize, |
| 56 | bitstream_type bstype); |
Siva Durga Prasad Paladugu | 9112b4c | 2014-03-14 16:35:37 +0530 | [diff] [blame] | 57 | extern int fpga_fsload(int devnum, const void *buf, size_t size, |
| 58 | fpga_fs_info *fpga_fsinfo); |
Michal Simek | 1466365 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 59 | extern int fpga_loadbitstream(int devnum, char *fpgadata, size_t size, |
| 60 | bitstream_type bstype); |
Wolfgang Denk | 74f9b38 | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 61 | extern int fpga_dump(int devnum, const void *buf, size_t bsize); |
| 62 | extern int fpga_info(int devnum); |
Michal Simek | 6ff890d | 2013-04-26 15:04:48 +0200 | [diff] [blame] | 63 | extern const fpga_desc *const fpga_validate(int devnum, const void *buf, |
| 64 | size_t bsize, char *fn); |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 65 | |
| 66 | #endif /* _FPGA_H_ */ |