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 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 12 | /* fpga_xxxx function return value definitions */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 13 | #define FPGA_SUCCESS 0 |
Alexander Dahl | 5a4675a | 2019-06-28 14:41:24 +0200 | [diff] [blame] | 14 | #define FPGA_FAIL 1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 15 | |
| 16 | /* device numbers must be non-negative */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 17 | #define FPGA_INVALID_DEVICE -1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 18 | |
Adrian Fiergolski | b524f8f | 2022-07-22 17:16:14 +0300 | [diff] [blame] | 19 | #define FPGA_ENC_DEV_KEY 0 |
Siva Durga Prasad Paladugu | cedd48e | 2018-05-31 15:10:22 +0530 | [diff] [blame] | 20 | #define FPGA_ENC_USR_KEY 1 |
| 21 | #define FPGA_NO_ENC_OR_NO_AUTH 2 |
| 22 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 23 | /* root data type defintions */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 24 | typedef enum { /* typedef fpga_type */ |
| 25 | fpga_min_type, /* range check value */ |
| 26 | fpga_xilinx, /* Xilinx Family) */ |
| 27 | fpga_altera, /* unimplemented */ |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 28 | fpga_lattice, /* Lattice family */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 29 | fpga_undefined /* invalid range check value */ |
| 30 | } fpga_type; /* end, typedef fpga_type */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 31 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 32 | typedef struct { /* typedef fpga_desc */ |
| 33 | fpga_type devtype; /* switch value to select sub-functions */ |
| 34 | void *devdesc; /* real device descriptor */ |
| 35 | } fpga_desc; /* end, typedef fpga_desc */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 36 | |
Siva Durga Prasad Paladugu | 1a89766 | 2014-03-14 16:35:37 +0530 | [diff] [blame] | 37 | typedef struct { /* typedef fpga_desc */ |
| 38 | unsigned int blocksize; |
| 39 | char *interface; |
| 40 | char *dev_part; |
Tien Fong Chee | 3003c44 | 2019-02-15 15:57:07 +0800 | [diff] [blame] | 41 | const char *filename; |
Siva Durga Prasad Paladugu | 1a89766 | 2014-03-14 16:35:37 +0530 | [diff] [blame] | 42 | int fstype; |
| 43 | } fpga_fs_info; |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 44 | |
Siva Durga Prasad Paladugu | cedd48e | 2018-05-31 15:10:22 +0530 | [diff] [blame] | 45 | struct fpga_secure_info { |
| 46 | u8 *userkey_addr; |
| 47 | u8 authflag; |
| 48 | u8 encflag; |
| 49 | }; |
| 50 | |
Michal Simek | 7a78bd2 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 51 | typedef enum { |
| 52 | BIT_FULL = 0, |
Michal Simek | 6719386 | 2014-05-02 13:43:39 +0200 | [diff] [blame] | 53 | BIT_PARTIAL, |
Siva Durga Prasad Paladugu | ddbcf8f | 2015-12-09 18:46:42 +0530 | [diff] [blame] | 54 | BIT_NONE = 0xFF, |
Michal Simek | 7a78bd2 | 2014-05-02 14:09:30 +0200 | [diff] [blame] | 55 | } bitstream_type; |
| 56 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 57 | /* root function definitions */ |
Michal Simek | 6583505 | 2015-01-14 09:59:00 +0100 | [diff] [blame] | 58 | void fpga_init(void); |
| 59 | int fpga_add(fpga_type devtype, void *desc); |
| 60 | int fpga_count(void); |
Michal Simek | ebd322d | 2015-01-13 16:09:53 +0100 | [diff] [blame] | 61 | const fpga_desc *const fpga_get_desc(int devnum); |
Goldschmidt Simon | 8b93a92 | 2017-11-10 14:17:41 +0000 | [diff] [blame] | 62 | int fpga_is_partial_data(int devnum, size_t img_len); |
Michal Simek | 6583505 | 2015-01-14 09:59:00 +0100 | [diff] [blame] | 63 | int fpga_load(int devnum, const void *buf, size_t bsize, |
Oleksandr Suvorov | 282eed5 | 2022-07-22 17:16:07 +0300 | [diff] [blame] | 64 | bitstream_type bstype, int flags); |
Michal Simek | 6583505 | 2015-01-14 09:59:00 +0100 | [diff] [blame] | 65 | int fpga_fsload(int devnum, const void *buf, size_t size, |
| 66 | fpga_fs_info *fpga_fsinfo); |
Siva Durga Prasad Paladugu | cedd48e | 2018-05-31 15:10:22 +0530 | [diff] [blame] | 67 | int fpga_loads(int devnum, const void *buf, size_t size, |
| 68 | struct fpga_secure_info *fpga_sec_info); |
Michal Simek | 6583505 | 2015-01-14 09:59:00 +0100 | [diff] [blame] | 69 | int fpga_loadbitstream(int devnum, char *fpgadata, size_t size, |
| 70 | bitstream_type bstype); |
| 71 | int fpga_dump(int devnum, const void *buf, size_t bsize); |
| 72 | int fpga_info(int devnum); |
| 73 | const fpga_desc *const fpga_validate(int devnum, const void *buf, |
| 74 | size_t bsize, char *fn); |
Oleksandr Suvorov | 2c60514 | 2022-07-22 17:16:08 +0300 | [diff] [blame] | 75 | int fpga_compatible2flag(int devnum, const char *compatible); |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 76 | |
| 77 | #endif /* _FPGA_H_ */ |