xref: /rk3399_rockchip-uboot/include/fpga.h (revision 23f4bd756d5177ecedbbc32163ae456807b0fa66)
1024a26bcSwdenk /*
2024a26bcSwdenk  * (C) Copyright 2002
3024a26bcSwdenk  * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
4024a26bcSwdenk  *
5024a26bcSwdenk  * See file CREDITS for list of people who contributed to this
6024a26bcSwdenk  * project.
7024a26bcSwdenk  *
8024a26bcSwdenk  * This program is free software; you can redistribute it and/or
9024a26bcSwdenk  * modify it under the terms of the GNU General Public License as
10024a26bcSwdenk  * published by the Free Software Foundation; either version 2 of
11024a26bcSwdenk  * the License, or (at your option) any later version.
12024a26bcSwdenk  *
13024a26bcSwdenk  * This program is distributed in the hope that it will be useful,
14024a26bcSwdenk  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15024a26bcSwdenk  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16024a26bcSwdenk  * GNU General Public License for more details.
17024a26bcSwdenk  *
18024a26bcSwdenk  * You should have received a copy of the GNU General Public License
19024a26bcSwdenk  * along with this program; if not, write to the Free Software
20024a26bcSwdenk  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21024a26bcSwdenk  * MA 02111-1307 USA
22024a26bcSwdenk  *
23024a26bcSwdenk  */
24024a26bcSwdenk 
25024a26bcSwdenk #include <linux/types.h>	       /* for ulong typedef */
26024a26bcSwdenk 
27024a26bcSwdenk #ifndef _FPGA_H_
28024a26bcSwdenk #define _FPGA_H_
29024a26bcSwdenk 
30024a26bcSwdenk #ifndef CONFIG_MAX_FPGA_DEVICES
31024a26bcSwdenk #define CONFIG_MAX_FPGA_DEVICES		5
32024a26bcSwdenk #endif
33024a26bcSwdenk 
34024a26bcSwdenk /* CONFIG_FPGA bit assignments */
356d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #define CONFIG_SYS_FPGA_MAN(x)		(x)
366d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #define CONFIG_SYS_FPGA_DEV(x)		((x) << 8 )
376d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #define CONFIG_SYS_FPGA_IF(x)		((x) << 16 )
38024a26bcSwdenk 
39024a26bcSwdenk /* FPGA Manufacturer bits in CONFIG_FPGA */
406d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #define CONFIG_SYS_FPGA_XILINX		CONFIG_SYS_FPGA_MAN( 0x1 )
416d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #define CONFIG_SYS_FPGA_ALTERA		CONFIG_SYS_FPGA_MAN( 0x2 )
42024a26bcSwdenk 
43024a26bcSwdenk 
44024a26bcSwdenk /* fpga_xxxx function return value definitions */
45024a26bcSwdenk #define FPGA_SUCCESS		0
46024a26bcSwdenk #define FPGA_FAIL		-1
47024a26bcSwdenk 
48024a26bcSwdenk /* device numbers must be non-negative */
49024a26bcSwdenk #define FPGA_INVALID_DEVICE	-1
50024a26bcSwdenk 
51024a26bcSwdenk /* root data type defintions */
52024a26bcSwdenk typedef enum {			/* typedef fpga_type */
53024a26bcSwdenk 	fpga_min_type,		/* range check value */
54024a26bcSwdenk 	fpga_xilinx,		/* Xilinx Family) */
55024a26bcSwdenk 	fpga_altera,		/* unimplemented */
563b8ac464SStefano Babic 	fpga_lattice,		/* Lattice family */
57024a26bcSwdenk 	fpga_undefined		/* invalid range check value */
58024a26bcSwdenk } fpga_type;			/* end, typedef fpga_type */
59024a26bcSwdenk 
60024a26bcSwdenk typedef struct {		/* typedef fpga_desc */
61024a26bcSwdenk 	fpga_type devtype;	/* switch value to select sub-functions */
62024a26bcSwdenk 	void *devdesc;		/* real device descriptor */
63024a26bcSwdenk } fpga_desc;			/* end, typedef fpga_desc */
64024a26bcSwdenk 
65024a26bcSwdenk 
66024a26bcSwdenk /* root function definitions */
676385b281SPeter Tyser extern void fpga_init(void);
68024a26bcSwdenk extern int fpga_add(fpga_type devtype, void *desc);
6977ddac94SWolfgang Denk extern int fpga_count(void);
70e6a857daSWolfgang Denk extern int fpga_load(int devnum, const void *buf, size_t bsize);
71*23f4bd75SMichal Simek extern int fpga_loadbitstream(int devnum, char *fpgadata, size_t size);
72e6a857daSWolfgang Denk extern int fpga_dump(int devnum, const void *buf, size_t bsize);
73024a26bcSwdenk extern int fpga_info(int devnum);
74024a26bcSwdenk 
75024a26bcSwdenk #endif	/* _FPGA_H_ */
76