xref: /rk3399_rockchip-uboot/include/fpga.h (revision 77ddac9480d63a80b6bb76d7ee4dcc2d1070867e)
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 /* these probably belong somewhere else */
35024a26bcSwdenk #ifndef FALSE
36024a26bcSwdenk #define FALSE	(0)
37024a26bcSwdenk #endif
38024a26bcSwdenk #ifndef TRUE
39024a26bcSwdenk #define TRUE 	(!FALSE)
40024a26bcSwdenk #endif
41024a26bcSwdenk 
42024a26bcSwdenk /* CONFIG_FPGA bit assignments */
43024a26bcSwdenk #define CFG_FPGA_MAN(x)	(x)
44024a26bcSwdenk #define CFG_FPGA_DEV(x)	((x) << 8 )
45024a26bcSwdenk #define CFG_FPGA_IF(x)	((x) << 16 )
46024a26bcSwdenk 
47024a26bcSwdenk /* FPGA Manufacturer bits in CONFIG_FPGA */
48024a26bcSwdenk #define CFG_FPGA_XILINX 		CFG_FPGA_MAN( 0x1 )
49024a26bcSwdenk #define CFG_FPGA_ALTERA			CFG_FPGA_MAN( 0x2 )
50024a26bcSwdenk 
51024a26bcSwdenk 
52024a26bcSwdenk /* fpga_xxxx function return value definitions */
53024a26bcSwdenk #define FPGA_SUCCESS         0
54024a26bcSwdenk #define FPGA_FAIL           -1
55024a26bcSwdenk 
56024a26bcSwdenk /* device numbers must be non-negative */
57024a26bcSwdenk #define FPGA_INVALID_DEVICE -1
58024a26bcSwdenk 
59024a26bcSwdenk /* root data type defintions */
60024a26bcSwdenk typedef enum {                 /* typedef fpga_type */
61024a26bcSwdenk 	fpga_min_type,             /* range check value */
62024a26bcSwdenk     fpga_xilinx,               /* Xilinx Family) */
63024a26bcSwdenk     fpga_altera,               /* unimplemented */
64024a26bcSwdenk     fpga_undefined             /* invalid range check value */
65024a26bcSwdenk } fpga_type;                   /* end, typedef fpga_type */
66024a26bcSwdenk 
67024a26bcSwdenk typedef struct {               /* typedef fpga_desc */
68024a26bcSwdenk     fpga_type   devtype;       /* switch value to select sub-functions */
69024a26bcSwdenk     void *      devdesc;       /* real device descriptor */
70024a26bcSwdenk } fpga_desc;                   /* end, typedef fpga_desc */
71024a26bcSwdenk 
72024a26bcSwdenk 
73024a26bcSwdenk /* root function definitions */
74024a26bcSwdenk extern void fpga_init( ulong reloc_off );
75024a26bcSwdenk extern int fpga_add( fpga_type devtype, void *desc );
76*77ddac94SWolfgang Denk extern int fpga_count( void );
77024a26bcSwdenk extern int fpga_load( int devnum, void *buf, size_t bsize );
78024a26bcSwdenk extern int fpga_dump( int devnum, void *buf, size_t bsize );
79024a26bcSwdenk extern int fpga_info( int devnum );
80024a26bcSwdenk 
81024a26bcSwdenk #endif	/* _FPGA_H_ */
82