blob: f4440933531f41a5ac9a339119200a71bc968f20 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk024a26b2002-08-21 21:35:08 +00002/*
3 * (C) Copyright 2002
4 * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
wdenk024a26b2002-08-21 21:35:08 +00005 */
6
Wolfgang Denk53677ef2008-05-20 16:00:29 +02007#include <linux/types.h> /* for ulong typedef */
wdenk024a26b2002-08-21 21:35:08 +00008
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
wdenk024a26b2002-08-21 21:35:08 +000016/* fpga_xxxx function return value definitions */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020017#define FPGA_SUCCESS 0
18#define FPGA_FAIL -1
wdenk024a26b2002-08-21 21:35:08 +000019
20/* device numbers must be non-negative */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020021#define FPGA_INVALID_DEVICE -1
wdenk024a26b2002-08-21 21:35:08 +000022
23/* root data type defintions */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020024typedef enum { /* typedef fpga_type */
25 fpga_min_type, /* range check value */
26 fpga_xilinx, /* Xilinx Family) */
27 fpga_altera, /* unimplemented */
Stefano Babic3b8ac462010-06-29 11:47:48 +020028 fpga_lattice, /* Lattice family */
Wolfgang Denk53677ef2008-05-20 16:00:29 +020029 fpga_undefined /* invalid range check value */
30} fpga_type; /* end, typedef fpga_type */
wdenk024a26b2002-08-21 21:35:08 +000031
Wolfgang Denk53677ef2008-05-20 16:00:29 +020032typedef 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 */
wdenk024a26b2002-08-21 21:35:08 +000036
Siva Durga Prasad Paladugu1a897662014-03-14 16:35:37 +053037typedef struct { /* typedef fpga_desc */
38 unsigned int blocksize;
39 char *interface;
40 char *dev_part;
41 char *filename;
42 int fstype;
43} fpga_fs_info;
wdenk024a26b2002-08-21 21:35:08 +000044
Michal Simek7a78bd22014-05-02 14:09:30 +020045typedef enum {
46 BIT_FULL = 0,
Michal Simek67193862014-05-02 13:43:39 +020047 BIT_PARTIAL,
Siva Durga Prasad Paladuguddbcf8f2015-12-09 18:46:42 +053048 BIT_NONE = 0xFF,
Michal Simek7a78bd22014-05-02 14:09:30 +020049} bitstream_type;
50
wdenk024a26b2002-08-21 21:35:08 +000051/* root function definitions */
Michal Simek65835052015-01-14 09:59:00 +010052void fpga_init(void);
53int fpga_add(fpga_type devtype, void *desc);
54int fpga_count(void);
Michal Simekebd322d2015-01-13 16:09:53 +010055const fpga_desc *const fpga_get_desc(int devnum);
Goldschmidt Simon8b93a922017-11-10 14:17:41 +000056int fpga_is_partial_data(int devnum, size_t img_len);
Michal Simek65835052015-01-14 09:59:00 +010057int fpga_load(int devnum, const void *buf, size_t bsize,
58 bitstream_type bstype);
59int fpga_fsload(int devnum, const void *buf, size_t size,
60 fpga_fs_info *fpga_fsinfo);
61int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
62 bitstream_type bstype);
63int fpga_dump(int devnum, const void *buf, size_t bsize);
64int fpga_info(int devnum);
65const fpga_desc *const fpga_validate(int devnum, const void *buf,
66 size_t bsize, char *fn);
wdenk024a26b2002-08-21 21:35:08 +000067
68#endif /* _FPGA_H_ */