Merge branch 'master' of git://git.denx.de/u-boot-video
[oweals/u-boot.git] / drivers / fpga / fpga.c
index 43bdf4fd25c4548e6a6bcb904db0868656fb5f08..e0fb1b4e783b7527bf43185cf7c053fc7c3fa0d9 100644 (file)
@@ -2,24 +2,7 @@
  * (C) Copyright 2002
  * Rich Ireland, Enterasys Networks, rireland@enterasys.com.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /* Generic FPGA support */
@@ -48,14 +31,14 @@ static void fpga_no_sup(char *fn, char *msg)
        else if (msg)
                printf("No support for %s.\n", msg);
        else
-               printf("No FPGA suport!\n");
+               printf("No FPGA support!\n");
 }
 
 
 /* fpga_get_desc
  *     map a device number to a descriptor
  */
-static const fpga_desc *const fpga_get_desc(int devnum)
+const fpga_desc *const fpga_get_desc(int devnum)
 {
        fpga_desc *desc = (fpga_desc *)NULL;
 
@@ -72,8 +55,8 @@ static const fpga_desc *const fpga_get_desc(int devnum)
  * fpga_validate
  *     generic parameter checking code
  */
-static const fpga_desc *const fpga_validate(int devnum, const void *buf,
-                                        size_t bsize, char *fn)
+const fpga_desc *const fpga_validate(int devnum, const void *buf,
+                                    size_t bsize, char *fn)
 {
        const fpga_desc *desc = fpga_get_desc(devnum);
 
@@ -137,7 +120,7 @@ static int fpga_dev_info(int devnum)
 }
 
 /*
- * fgpa_init is usually called from misc_init_r() and MUST be called
+ * fpga_init is usually called from misc_init_r() and MUST be called
  * before any of the other fpga functions are used.
  */
 void fpga_init(void)
@@ -187,10 +170,48 @@ int fpga_add(fpga_type devtype, void *desc)
        return devnum;
 }
 
+/*
+ * Convert bitstream data and load into the fpga
+ */
+int __weak fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
+                             bitstream_type bstype)
+{
+       printf("Bitstream support not implemented for this FPGA device\n");
+       return FPGA_FAIL;
+}
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+int fpga_fsload(int devnum, const void *buf, size_t size,
+                fpga_fs_info *fpga_fsinfo)
+{
+       int ret_val = FPGA_FAIL;           /* assume failure */
+       const fpga_desc *desc = fpga_validate(devnum, buf, size,
+                                             (char *)__func__);
+
+       if (desc) {
+               switch (desc->devtype) {
+               case fpga_xilinx:
+#if defined(CONFIG_FPGA_XILINX)
+                       ret_val = xilinx_loadfs(desc->devdesc, buf, size,
+                                               fpga_fsinfo);
+#else
+                       fpga_no_sup((char *)__func__, "Xilinx devices");
+#endif
+                       break;
+               default:
+                       printf("%s: Invalid or unsupported device type %d\n",
+                              __func__, desc->devtype);
+               }
+       }
+
+       return ret_val;
+}
+#endif
+
 /*
  * Generic multiplexing code
  */
-int fpga_load(int devnum, const void *buf, size_t bsize)
+int fpga_load(int devnum, const void *buf, size_t bsize, bitstream_type bstype)
 {
        int ret_val = FPGA_FAIL;           /* assume failure */
        const fpga_desc *desc = fpga_validate(devnum, buf, bsize,
@@ -200,7 +221,8 @@ int fpga_load(int devnum, const void *buf, size_t bsize)
                switch (desc->devtype) {
                case fpga_xilinx:
 #if defined(CONFIG_FPGA_XILINX)
-                       ret_val = xilinx_load(desc->devdesc, buf, bsize);
+                       ret_val = xilinx_load(desc->devdesc, buf, bsize,
+                                             bstype);
 #else
                        fpga_no_sup((char *)__func__, "Xilinx devices");
 #endif