2018-05-07 05:58:06 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2002-08-22 05:35:08 +08:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Rich Ireland, Enterasys Networks, rireland@enterasys.com.
|
|
|
|
*/
|
|
|
|
|
2008-05-20 22:00:29 +08:00
|
|
|
#include <linux/types.h> /* for ulong typedef */
|
2002-08-22 05:35:08 +08:00
|
|
|
|
|
|
|
#ifndef _FPGA_H_
|
|
|
|
#define _FPGA_H_
|
|
|
|
|
|
|
|
#ifndef CONFIG_MAX_FPGA_DEVICES
|
|
|
|
#define CONFIG_MAX_FPGA_DEVICES 5
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* fpga_xxxx function return value definitions */
|
2008-05-20 22:00:29 +08:00
|
|
|
#define FPGA_SUCCESS 0
|
|
|
|
#define FPGA_FAIL -1
|
2002-08-22 05:35:08 +08:00
|
|
|
|
|
|
|
/* device numbers must be non-negative */
|
2008-05-20 22:00:29 +08:00
|
|
|
#define FPGA_INVALID_DEVICE -1
|
2002-08-22 05:35:08 +08:00
|
|
|
|
2018-05-31 17:40:22 +08:00
|
|
|
#define FPGA_ENC_USR_KEY 1
|
|
|
|
#define FPGA_NO_ENC_OR_NO_AUTH 2
|
|
|
|
|
2002-08-22 05:35:08 +08:00
|
|
|
/* root data type defintions */
|
2008-05-20 22:00:29 +08:00
|
|
|
typedef enum { /* typedef fpga_type */
|
|
|
|
fpga_min_type, /* range check value */
|
|
|
|
fpga_xilinx, /* Xilinx Family) */
|
|
|
|
fpga_altera, /* unimplemented */
|
2010-06-29 17:47:48 +08:00
|
|
|
fpga_lattice, /* Lattice family */
|
2008-05-20 22:00:29 +08:00
|
|
|
fpga_undefined /* invalid range check value */
|
|
|
|
} fpga_type; /* end, typedef fpga_type */
|
2002-08-22 05:35:08 +08:00
|
|
|
|
2008-05-20 22:00:29 +08:00
|
|
|
typedef struct { /* typedef fpga_desc */
|
|
|
|
fpga_type devtype; /* switch value to select sub-functions */
|
|
|
|
void *devdesc; /* real device descriptor */
|
|
|
|
} fpga_desc; /* end, typedef fpga_desc */
|
2002-08-22 05:35:08 +08:00
|
|
|
|
2014-03-14 19:05:37 +08:00
|
|
|
typedef struct { /* typedef fpga_desc */
|
|
|
|
unsigned int blocksize;
|
|
|
|
char *interface;
|
|
|
|
char *dev_part;
|
2019-02-15 15:57:07 +08:00
|
|
|
const char *filename;
|
2014-03-14 19:05:37 +08:00
|
|
|
int fstype;
|
|
|
|
} fpga_fs_info;
|
2002-08-22 05:35:08 +08:00
|
|
|
|
2018-05-31 17:40:22 +08:00
|
|
|
struct fpga_secure_info {
|
|
|
|
u8 *userkey_addr;
|
|
|
|
u8 authflag;
|
|
|
|
u8 encflag;
|
|
|
|
};
|
|
|
|
|
2014-05-02 20:09:30 +08:00
|
|
|
typedef enum {
|
|
|
|
BIT_FULL = 0,
|
2014-05-02 19:43:39 +08:00
|
|
|
BIT_PARTIAL,
|
2015-12-09 21:16:42 +08:00
|
|
|
BIT_NONE = 0xFF,
|
2014-05-02 20:09:30 +08:00
|
|
|
} bitstream_type;
|
|
|
|
|
2002-08-22 05:35:08 +08:00
|
|
|
/* root function definitions */
|
2015-01-14 16:59:00 +08:00
|
|
|
void fpga_init(void);
|
|
|
|
int fpga_add(fpga_type devtype, void *desc);
|
|
|
|
int fpga_count(void);
|
2015-01-13 23:09:53 +08:00
|
|
|
const fpga_desc *const fpga_get_desc(int devnum);
|
2017-11-10 22:17:41 +08:00
|
|
|
int fpga_is_partial_data(int devnum, size_t img_len);
|
2015-01-14 16:59:00 +08:00
|
|
|
int fpga_load(int devnum, const void *buf, size_t bsize,
|
|
|
|
bitstream_type bstype);
|
|
|
|
int fpga_fsload(int devnum, const void *buf, size_t size,
|
|
|
|
fpga_fs_info *fpga_fsinfo);
|
2018-05-31 17:40:22 +08:00
|
|
|
int fpga_loads(int devnum, const void *buf, size_t size,
|
|
|
|
struct fpga_secure_info *fpga_sec_info);
|
2015-01-14 16:59:00 +08:00
|
|
|
int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
|
|
|
|
bitstream_type bstype);
|
|
|
|
int fpga_dump(int devnum, const void *buf, size_t bsize);
|
|
|
|
int fpga_info(int devnum);
|
|
|
|
const fpga_desc *const fpga_validate(int devnum, const void *buf,
|
|
|
|
size_t bsize, char *fn);
|
2002-08-22 05:35:08 +08:00
|
|
|
|
|
|
|
#endif /* _FPGA_H_ */
|