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