wdenk | e221174 | 2002-11-02 23:30:20 +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 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 25 | /* Generic FPGA support */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 26 | #include <common.h> /* core U-Boot definitions */ |
| 27 | #include <xilinx.h> /* xilinx specific definitions */ |
| 28 | #include <altera.h> /* altera specific definitions */ |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 29 | #include <lattice.h> |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 30 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 31 | /* Local definitions */ |
| 32 | #ifndef CONFIG_MAX_FPGA_DEVICES |
| 33 | #define CONFIG_MAX_FPGA_DEVICES 5 |
| 34 | #endif |
| 35 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 36 | /* Local static data */ |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 37 | static int next_desc = FPGA_INVALID_DEVICE; |
| 38 | static fpga_desc desc_table[CONFIG_MAX_FPGA_DEVICES]; |
| 39 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 40 | /* |
| 41 | * fpga_no_sup |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 42 | * 'no support' message function |
| 43 | */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 44 | static void fpga_no_sup(char *fn, char *msg) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 45 | { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 46 | if (fn && msg) |
| 47 | printf("%s: No support for %s.\n", fn, msg); |
| 48 | else if (msg) |
| 49 | printf("No support for %s.\n", msg); |
| 50 | else |
| 51 | printf("No FPGA suport!\n"); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | |
| 55 | /* fpga_get_desc |
| 56 | * map a device number to a descriptor |
| 57 | */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 58 | static const fpga_desc *const fpga_get_desc(int devnum) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 59 | { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 60 | fpga_desc *desc = (fpga_desc *)NULL; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 61 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 62 | if ((devnum >= 0) && (devnum < next_desc)) { |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 63 | desc = &desc_table[devnum]; |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 64 | debug("%s: found fpga descriptor #%d @ 0x%p\n", |
| 65 | __func__, devnum, desc); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | return desc; |
| 69 | } |
| 70 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 71 | /* |
| 72 | * fpga_validate |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 73 | * generic parameter checking code |
| 74 | */ |
Michal Simek | 6631db4 | 2013-04-26 15:04:48 +0200 | [diff] [blame^] | 75 | const fpga_desc *const fpga_validate(int devnum, const void *buf, |
| 76 | size_t bsize, char *fn) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 77 | { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 78 | const fpga_desc *desc = fpga_get_desc(devnum); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 79 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 80 | if (!desc) |
| 81 | printf("%s: Invalid device number %d\n", fn, devnum); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 82 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 83 | if (!buf) { |
| 84 | printf("%s: Null buffer.\n", fn); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 85 | return (fpga_desc * const)NULL; |
| 86 | } |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 87 | return desc; |
| 88 | } |
| 89 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 90 | /* |
| 91 | * fpga_dev_info |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 92 | * generic multiplexing code |
| 93 | */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 94 | static int fpga_dev_info(int devnum) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 95 | { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 96 | int ret_val = FPGA_FAIL; /* assume failure */ |
| 97 | const fpga_desc * const desc = fpga_get_desc(devnum); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 98 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 99 | if (desc) { |
| 100 | debug("%s: Device Descriptor @ 0x%p\n", |
| 101 | __func__, desc->devdesc); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 102 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 103 | switch (desc->devtype) { |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 104 | case fpga_xilinx: |
Matthias Fuchs | 0133502 | 2007-12-27 17:12:34 +0100 | [diff] [blame] | 105 | #if defined(CONFIG_FPGA_XILINX) |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 106 | printf("Xilinx Device\nDescriptor @ 0x%p\n", desc); |
| 107 | ret_val = xilinx_info(desc->devdesc); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 108 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 109 | fpga_no_sup((char *)__func__, "Xilinx devices"); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 110 | #endif |
| 111 | break; |
| 112 | case fpga_altera: |
Matthias Fuchs | 0133502 | 2007-12-27 17:12:34 +0100 | [diff] [blame] | 113 | #if defined(CONFIG_FPGA_ALTERA) |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 114 | printf("Altera Device\nDescriptor @ 0x%p\n", desc); |
| 115 | ret_val = altera_info(desc->devdesc); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 116 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 117 | fpga_no_sup((char *)__func__, "Altera devices"); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 118 | #endif |
| 119 | break; |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 120 | case fpga_lattice: |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 121 | #if defined(CONFIG_FPGA_LATTICE) |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 122 | printf("Lattice Device\nDescriptor @ 0x%p\n", desc); |
| 123 | ret_val = lattice_info(desc->devdesc); |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 124 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 125 | fpga_no_sup((char *)__func__, "Lattice devices"); |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 126 | #endif |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 127 | break; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 128 | default: |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 129 | printf("%s: Invalid or unsupported device type %d\n", |
| 130 | __func__, desc->devtype); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 131 | } |
| 132 | } else { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 133 | printf("%s: Invalid device number %d\n", __func__, devnum); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | return ret_val; |
| 137 | } |
| 138 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 139 | /* |
| 140 | * fgpa_init is usually called from misc_init_r() and MUST be called |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 141 | * before any of the other fpga functions are used. |
| 142 | */ |
Peter Tyser | 6385b28 | 2009-09-21 11:20:32 -0500 | [diff] [blame] | 143 | void fpga_init(void) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 144 | { |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 145 | next_desc = 0; |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 146 | memset(desc_table, 0, sizeof(desc_table)); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 147 | |
Michal Simek | ee976c1 | 2013-04-26 09:38:26 +0200 | [diff] [blame] | 148 | debug("%s\n", __func__); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 149 | } |
| 150 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 151 | /* |
| 152 | * fpga_count |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 153 | * Basic interface function to get the current number of devices available. |
| 154 | */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 155 | int fpga_count(void) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 156 | { |
| 157 | return next_desc; |
| 158 | } |
| 159 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 160 | /* |
| 161 | * fpga_add |
Peter Tyser | 6385b28 | 2009-09-21 11:20:32 -0500 | [diff] [blame] | 162 | * Add the device descriptor to the device table. |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 163 | */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 164 | int fpga_add(fpga_type devtype, void *desc) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 165 | { |
| 166 | int devnum = FPGA_INVALID_DEVICE; |
| 167 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 168 | if (next_desc < 0) { |
| 169 | printf("%s: FPGA support not initialized!\n", __func__); |
| 170 | } else if ((devtype > fpga_min_type) && (devtype < fpga_undefined)) { |
| 171 | if (desc) { |
| 172 | if (next_desc < CONFIG_MAX_FPGA_DEVICES) { |
Peter Tyser | 6385b28 | 2009-09-21 11:20:32 -0500 | [diff] [blame] | 173 | devnum = next_desc; |
| 174 | desc_table[next_desc].devtype = devtype; |
| 175 | desc_table[next_desc++].devdesc = desc; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 176 | } else { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 177 | printf("%s: Exceeded Max FPGA device count\n", |
| 178 | __func__); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 179 | } |
| 180 | } else { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 181 | printf("%s: NULL device descriptor\n", __func__); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 182 | } |
| 183 | } else { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 184 | printf("%s: Unsupported FPGA type %d\n", __func__, devtype); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | return devnum; |
| 188 | } |
| 189 | |
| 190 | /* |
Michal Simek | 52c2064 | 2013-04-26 13:12:07 +0200 | [diff] [blame] | 191 | * Convert bitstream data and load into the fpga |
| 192 | */ |
Michal Simek | 23f4bd7 | 2013-05-01 19:02:02 +0200 | [diff] [blame] | 193 | int __weak fpga_loadbitstream(int devnum, char *fpgadata, size_t size) |
Michal Simek | 52c2064 | 2013-04-26 13:12:07 +0200 | [diff] [blame] | 194 | { |
| 195 | printf("Bitstream support not implemented for this FPGA device\n"); |
| 196 | return FPGA_FAIL; |
| 197 | } |
| 198 | |
| 199 | /* |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 200 | * Generic multiplexing code |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 201 | */ |
Wolfgang Denk | e6a857d | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 202 | int fpga_load(int devnum, const void *buf, size_t bsize) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 203 | { |
| 204 | int ret_val = FPGA_FAIL; /* assume failure */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 205 | const fpga_desc *desc = fpga_validate(devnum, buf, bsize, |
| 206 | (char *)__func__); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 207 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 208 | if (desc) { |
| 209 | switch (desc->devtype) { |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 210 | case fpga_xilinx: |
Matthias Fuchs | 0133502 | 2007-12-27 17:12:34 +0100 | [diff] [blame] | 211 | #if defined(CONFIG_FPGA_XILINX) |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 212 | ret_val = xilinx_load(desc->devdesc, buf, bsize); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 213 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 214 | fpga_no_sup((char *)__func__, "Xilinx devices"); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 215 | #endif |
| 216 | break; |
| 217 | case fpga_altera: |
Matthias Fuchs | 0133502 | 2007-12-27 17:12:34 +0100 | [diff] [blame] | 218 | #if defined(CONFIG_FPGA_ALTERA) |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 219 | ret_val = altera_load(desc->devdesc, buf, bsize); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 220 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 221 | fpga_no_sup((char *)__func__, "Altera devices"); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 222 | #endif |
| 223 | break; |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 224 | case fpga_lattice: |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 225 | #if defined(CONFIG_FPGA_LATTICE) |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 226 | ret_val = lattice_load(desc->devdesc, buf, bsize); |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 227 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 228 | fpga_no_sup((char *)__func__, "Lattice devices"); |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 229 | #endif |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 230 | break; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 231 | default: |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 232 | printf("%s: Invalid or unsupported device type %d\n", |
| 233 | __func__, desc->devtype); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
| 237 | return ret_val; |
| 238 | } |
| 239 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 240 | /* |
| 241 | * fpga_dump |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 242 | * generic multiplexing code |
| 243 | */ |
Wolfgang Denk | e6a857d | 2011-07-30 13:33:49 +0000 | [diff] [blame] | 244 | int fpga_dump(int devnum, const void *buf, size_t bsize) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 245 | { |
| 246 | int ret_val = FPGA_FAIL; /* assume failure */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 247 | const fpga_desc *desc = fpga_validate(devnum, buf, bsize, |
| 248 | (char *)__func__); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 249 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 250 | if (desc) { |
| 251 | switch (desc->devtype) { |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 252 | case fpga_xilinx: |
Matthias Fuchs | 0133502 | 2007-12-27 17:12:34 +0100 | [diff] [blame] | 253 | #if defined(CONFIG_FPGA_XILINX) |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 254 | ret_val = xilinx_dump(desc->devdesc, buf, bsize); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 255 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 256 | fpga_no_sup((char *)__func__, "Xilinx devices"); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 257 | #endif |
| 258 | break; |
| 259 | case fpga_altera: |
Matthias Fuchs | 0133502 | 2007-12-27 17:12:34 +0100 | [diff] [blame] | 260 | #if defined(CONFIG_FPGA_ALTERA) |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 261 | ret_val = altera_dump(desc->devdesc, buf, bsize); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 262 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 263 | fpga_no_sup((char *)__func__, "Altera devices"); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 264 | #endif |
| 265 | break; |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 266 | case fpga_lattice: |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 267 | #if defined(CONFIG_FPGA_LATTICE) |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 268 | ret_val = lattice_dump(desc->devdesc, buf, bsize); |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 269 | #else |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 270 | fpga_no_sup((char *)__func__, "Lattice devices"); |
Wolfgang Denk | 439f6f7 | 2010-10-18 21:32:14 +0200 | [diff] [blame] | 271 | #endif |
Stefano Babic | 3b8ac46 | 2010-06-29 11:47:48 +0200 | [diff] [blame] | 272 | break; |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 273 | default: |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 274 | printf("%s: Invalid or unsupported device type %d\n", |
| 275 | __func__, desc->devtype); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 276 | } |
| 277 | } |
| 278 | |
| 279 | return ret_val; |
| 280 | } |
| 281 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 282 | /* |
| 283 | * fpga_info |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 284 | * front end to fpga_dev_info. If devnum is invalid, report on all |
| 285 | * available devices. |
| 286 | */ |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 287 | int fpga_info(int devnum) |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 288 | { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 289 | if (devnum == FPGA_INVALID_DEVICE) { |
| 290 | if (next_desc > 0) { |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 291 | int dev; |
| 292 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 293 | for (dev = 0; dev < next_desc; dev++) |
| 294 | fpga_dev_info(dev); |
| 295 | |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 296 | return FPGA_SUCCESS; |
| 297 | } else { |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 298 | printf("%s: No FPGA devices available.\n", __func__); |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 299 | return FPGA_FAIL; |
| 300 | } |
| 301 | } |
wdenk | e221174 | 2002-11-02 23:30:20 +0000 | [diff] [blame] | 302 | |
Michal Simek | f6555d9 | 2013-04-26 08:46:56 +0200 | [diff] [blame] | 303 | return fpga_dev_info(devnum); |
| 304 | } |