[U-Boot] [PATCH v4 3/4] apf27: add FPGA support for the apf27 board

2013-07-28 Thread Philippe Reynes
Signed-off-by: Philippe Reynes trem...@yahoo.fr
Signed-off-by: Eric Jarrige eric.jarr...@armadeus.org
---
 board/armadeus/apf27/Makefile |3 +
 board/armadeus/apf27/apf27.c  |   18 +++
 board/armadeus/apf27/fpga.c   |  250 +
 board/armadeus/apf27/fpga.h   |   39 +++
 4 files changed, 310 insertions(+), 0 deletions(-)
 create mode 100644 board/armadeus/apf27/fpga.c
 create mode 100644 board/armadeus/apf27/fpga.h

diff --git a/board/armadeus/apf27/Makefile b/board/armadeus/apf27/Makefile
index 08d5d8d..11562a2 100644
--- a/board/armadeus/apf27/Makefile
+++ b/board/armadeus/apf27/Makefile
@@ -29,6 +29,9 @@ LIB   = $(obj)lib$(BOARD).o
 
 ifndef CONFIG_SPL_BUILD
 COBJS  := apf27.o
+ifdef CONFIG_FPGA
+COBJS  += fpga.o
+endif
 endif
 
 ifdef CONFIG_SPL_BUILD
diff --git a/board/armadeus/apf27/apf27.c b/board/armadeus/apf27/apf27.c
index f64c71a..7c10539 100644
--- a/board/armadeus/apf27/apf27.c
+++ b/board/armadeus/apf27/apf27.c
@@ -30,6 +30,7 @@
 #include asm/errno.h
 #include apf27.h
 #include crc.h
+#include fpga.h
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -321,6 +322,23 @@ int misc_init_r(void)
struct mtd_device *dev;
struct part_info *part;
 
+#if defined(CONFIG_FPGA)
+   /* init and download fpga */
+   if ((autoload)  (0 == strcmp(autoload, 1))) {
+   if (mtdparts_init() == 0)
+   if (find_dev_and_part(firmware,
+ dev, pnum, part) == 0) {
+   size = part-size;
+   if (nand_read_skip_bad(nand_info[0],
+  part-offset, size,
+  NULL, part-size,
+  firmware_buffer))
+   size = 0;
+   }
+   }
+   APF27_init_fpga(firmware_buffer, size);
+#endif
+
/* detect compatibility issue of environment version */
s = getenv(env_version);
if ((NULL == s) || (0 != strcmp(s, CONFIG_ENV_VERSION))) {
diff --git a/board/armadeus/apf27/fpga.c b/board/armadeus/apf27/fpga.c
new file mode 100644
index 000..4c49667
--- /dev/null
+++ b/board/armadeus/apf27/fpga.c
@@ -0,0 +1,250 @@
+/*
+ * (C) Copyright 2002-2012
+ * Eric Jarrige eric.jarr...@armadeus.org
+ * Rich Ireland, Enterasys Networks, rirel...@enterasys.com.
+ * Keith Outwater, keith_outwa...@mvis.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
+ *
+ */
+#include common.h
+
+#include asm/arch/imx-regs.h
+#include asm/gpio.h
+#include asm/io.h
+#include command.h
+#include config.h
+#include fpga.h
+#include spartan3.h
+#include apf27.h
+
+/*
+ * Note that these are pointers to code that is in Flash.  They will be
+ * relocated at runtime.
+ * Spartan2 code is used to download our Spartan 3 :) code is compatible.
+ * Just take care about the file size
+ */
+Xilinx_Spartan3_Slave_Parallel_fns fpga_fns = {
+   fpga_pre_fn,
+   fpga_pgm_fn,
+   fpga_init_fn,
+   NULL,
+   fpga_done_fn,
+   fpga_clk_fn,
+   fpga_cs_fn,
+   fpga_wr_fn,
+   fpga_rdata_fn,
+   fpga_wdata_fn,
+   fpga_busy_fn,
+   fpga_abort_fn,
+   fpga_post_fn,
+};
+
+Xilinx_desc fpga[CONFIG_FPGA_COUNT] = {
+   {Xilinx_Spartan3,
+slave_parallel,
+1196128l/8,
+(void *)fpga_fns,
+0}
+};
+
+/*
+ * Initialize GPIO port B before download
+ */
+int fpga_pre_fn(int cookie)
+{
+   /* Initialize GPIO pins */
+   gpio_set_value(ACFG_FPGA_PWR, 1);
+   imx_gpio_mode(ACFG_FPGA_INIT | GPIO_IN | GPIO_PUEN | GPIO_GPIO);
+   imx_gpio_mode(ACFG_FPGA_DONE | GPIO_IN | GPIO_PUEN | GPIO_GPIO);
+   imx_gpio_mode(ACFG_FPGA_PRG | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+   imx_gpio_mode(ACFG_FPGA_CLK | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+   imx_gpio_mode(ACFG_FPGA_RW | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+   imx_gpio_mode(ACFG_FPGA_CS | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+   imx_gpio_mode(ACFG_FPGA_SUSPEND|GPIO_OUT|GPIO_PUEN|GPIO_GPIO);
+   gpio_set_value(ACFG_FPGA_RESET, 1);
+   imx_gpio_mode(ACFG_FPGA_RESET | GPIO_OUT | GPIO_PUEN 

Re: [U-Boot] [PATCH v4 3/4] apf27: add FPGA support for the apf27 board

2013-07-28 Thread Wolfgang Denk
Dear Philippe Reynes,

In message 1375042616-24680-4-git-send-email-trem...@yahoo.fr you wrote:

 --- /dev/null
 +++ b/board/armadeus/apf27/fpga.c
 @@ -0,0 +1,250 @@
 +/*
 + * (C) Copyright 2002-2012
 + * Eric Jarrige eric.jarr...@armadeus.org
 + * Rich Ireland, Enterasys Networks, rirel...@enterasys.com.
 + * Keith Outwater, keith_outwa...@mvis.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

Please drop the full header and use a SPDX-License-Identifier instead.
Please fix globally.

Thanks.


Best regards,

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
No user-servicable parts inside. Refer to qualified service personnel.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot