Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2002 |
| 4 | * Rich Ireland, Enterasys Networks, rireland@enterasys.com. |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 7 | #include <linux/types.h> /* for ulong typedef */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 8 | |
| 9 | #ifndef _FPGA_H_ |
| 10 | #define _FPGA_H_ |
| 11 | |
| 12 | #ifndef CONFIG_MAX_FPGA_DEVICES |
| 13 | #define CONFIG_MAX_FPGA_DEVICES 5 |
| 14 | #endif |
| 15 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 16 | /* fpga_xxxx function return value definitions */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 17 | #define FPGA_SUCCESS 0 |
| 18 | #define FPGA_FAIL -1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 19 | |
| 20 | /* device numbers must be non-negative */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 21 | #define FPGA_INVALID_DEVICE -1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 22 | |
Siva Durga Prasad Paladugu | cedd48e | 2018-05-31 15:10:22 +0530 | [diff] [blame] | 23 | #define FPGA_ENC_USR_KEY 1 |
| 24 | #define FPGA_NO_ENC_OR_NO_AUTH 2 |
| 25 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 26 | /* root data type defintions */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 27 | typedef enum { /* typedef fpga_type */ |
| 28 | fpga_min_type, /* range check value */ |
| 29 | fpga_xilinx, /* Xilinx Family) */ |
| 30 | fpga_altera, /* unimplemented */ |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 31 | fpga_lattice, /* Lattice family */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 32 | fpga_undefined /* invalid range check value */ |
| 33 | } fpga_type; /* end, typedef fpga_type */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 34 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 35 | typedef struct { /* typedef fpga_desc */ |
| 36 | fpga_type devtype; /* switch value to select sub-functions */ |
| 37 | void *devdesc; /* real device descriptor */ |
| 38 | } fpga_desc; /* end, typedef fpga_desc */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 39 | |
Siva Durga Prasad Paladugu | 1a89766 | 2014-03-14 16:35:37 +0530 | [diff] [blame] | 40 | typedef struct { /* typedef fpga_desc */ |
| 41 | unsigned int blocksize; |
| 42 | char *interface; |
| 43 | char *dev_part; |
| 44 | char *filename; |
| 45 | int fstype; |
| 46 | } fpga_fs_info; |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 47 | |
Siva Durga Prasad Paladugu | cedd48e | 2018-05-31 15:10:22 +0530 | [diff] [blame] | 48 | struct fpga_secure_info { |
| 49 | u8 *userkey_addr; |
| 50 | u8 authflag; |
| 51 | u8 encflag; |
| 52 | }; |
| 53 | |
Michal Simek | 7a78bd2 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 54 | typedef enum { |
| 55 | BIT_FULL = 0, |
Michal Simek | 6719386 | 2014-05-02 13:43:39 +0200 | [diff] [blame] | 56 | BIT_PARTIAL, |
Siva Durga Prasad Paladugu | ddbcf8f | 2015-12-09 18:46:42 +0530 | [diff] [blame] | 57 | BIT_NONE = 0xFF, |
Michal Simek | 7a78bd2 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 58 | } bitstream_type; |
| 59 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 60 | /* root function definitions */ |
Michal Simek | 6583505 | 2015-01-14 09:59:00 +0100 | [diff] [blame] | 61 | void fpga_init(void); |
| 62 | int fpga_add(fpga_type devtype, void *desc); |
| 63 | int fpga_count(void); |
Michal Simek | ebd322d | 2015-01-13 16:09:53 +0100 | [diff] [blame] | 64 | const fpga_desc *const fpga_get_desc(int devnum); |
Goldschmidt Simon | 8b93a92 | 2017-11-10 14:17:41 +0000 | [diff] [blame] | 65 | int fpga_is_partial_data(int devnum, size_t img_len); |
Michal Simek | 6583505 | 2015-01-14 09:59:00 +0100 | [diff] [blame] | 66 | int fpga_load(int devnum, const void *buf, size_t bsize, |
| 67 | bitstream_type bstype); |
| 68 | int fpga_fsload(int devnum, const void *buf, size_t size, |
| 69 | fpga_fs_info *fpga_fsinfo); |
Siva Durga Prasad Paladugu | cedd48e | 2018-05-31 15:10:22 +0530 | [diff] [blame] | 70 | int fpga_loads(int devnum, const void *buf, size_t size, |
| 71 | struct fpga_secure_info *fpga_sec_info); |
Michal Simek | 6583505 | 2015-01-14 09:59:00 +0100 | [diff] [blame] | 72 | int fpga_loadbitstream(int devnum, char *fpgadata, size_t size, |
| 73 | bitstream_type bstype); |
| 74 | int fpga_dump(int devnum, const void *buf, size_t bsize); |
| 75 | int fpga_info(int devnum); |
| 76 | const fpga_desc *const fpga_validate(int devnum, const void *buf, |
| 77 | size_t bsize, char *fn); |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 78 | |
| 79 | #endif /* _FPGA_H_ */ |