wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Rich Ireland, Enterasys Networks, rireland@enterasys.com. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | * |
| 23 | */ |
| 24 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 25 | #include <linux/types.h> /* for ulong typedef */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 26 | |
| 27 | #ifndef _FPGA_H_ |
| 28 | #define _FPGA_H_ |
| 29 | |
| 30 | #ifndef CONFIG_MAX_FPGA_DEVICES |
| 31 | #define CONFIG_MAX_FPGA_DEVICES 5 |
| 32 | #endif |
| 33 | |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 34 | /* CONFIG_FPGA bit assignments */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 35 | #define CONFIG_SYS_FPGA_MAN(x) (x) |
| 36 | #define CONFIG_SYS_FPGA_DEV(x) ((x) << 8 ) |
| 37 | #define CONFIG_SYS_FPGA_IF(x) ((x) << 16 ) |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 38 | |
| 39 | /* FPGA Manufacturer bits in CONFIG_FPGA */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | #define CONFIG_SYS_FPGA_XILINX CONFIG_SYS_FPGA_MAN( 0x1 ) |
| 41 | #define CONFIG_SYS_FPGA_ALTERA CONFIG_SYS_FPGA_MAN( 0x2 ) |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 42 | |
| 43 | |
| 44 | /* fpga_xxxx function return value definitions */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 45 | #define FPGA_SUCCESS 0 |
| 46 | #define FPGA_FAIL -1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 47 | |
| 48 | /* device numbers must be non-negative */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 49 | #define FPGA_INVALID_DEVICE -1 |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 50 | |
| 51 | /* root data type defintions */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 52 | typedef enum { /* typedef fpga_type */ |
| 53 | fpga_min_type, /* range check value */ |
| 54 | fpga_xilinx, /* Xilinx Family) */ |
| 55 | fpga_altera, /* unimplemented */ |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 56 | fpga_lattice, /* Lattice family */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 57 | fpga_undefined /* invalid range check value */ |
| 58 | } fpga_type; /* end, typedef fpga_type */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 59 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 60 | typedef struct { /* typedef fpga_desc */ |
| 61 | fpga_type devtype; /* switch value to select sub-functions */ |
| 62 | void *devdesc; /* real device descriptor */ |
| 63 | } fpga_desc; /* end, typedef fpga_desc */ |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 64 | |
| 65 | |
| 66 | /* root function definitions */ |
Wolfgang Denk | e6a857d | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 67 | extern void fpga_init(void); |
| 68 | extern int fpga_add(fpga_type devtype, void *desc); |
| 69 | extern int fpga_count(void); |
| 70 | extern int fpga_load(int devnum, const void *buf, size_t bsize); |
Michal Simek | 23f4bd7 | 2013-05-01 19:02:02 +0200 | [diff] [blame^] | 71 | extern int fpga_loadbitstream(int devnum, char *fpgadata, size_t size); |
Wolfgang Denk | e6a857d | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 72 | extern int fpga_dump(int devnum, const void *buf, size_t bsize); |
| 73 | extern int fpga_info(int devnum); |
wdenk | 024a26b | 2002-08-21 21:35:08 +0000 | [diff] [blame] | 74 | |
| 75 | #endif /* _FPGA_H_ */ |