Re: [PATCH 08/11] ARM: socfpga: Add FPGA programming command

2013-09-17 Thread Jean-Christophe PLAGNIOL-VILLARD
On 10:48 Mon 16 Sep , Sascha Hauer wrote:
 This adds a simple socfpga specific 'fpga' command to load a firmware
 to the FPGA. For the moment this is enough, but should we get more
 FPGA support it might be a good idea to introduce some generic framework
 and command.

I do not like command a devfs instead?

so we can use cp and co
 

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 08/11] ARM: socfpga: Add FPGA programming command

2013-09-16 Thread Sascha Hauer
This adds a simple socfpga specific 'fpga' command to load a firmware
to the FPGA. For the moment this is enough, but should we get more
FPGA support it might be a good idea to introduce some generic framework
and command.

Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
---
 arch/arm/mach-socfpga/Kconfig |   5 +
 arch/arm/mach-socfpga/Makefile|   1 +
 arch/arm/mach-socfpga/fpga.c  | 422 ++
 arch/arm/mach-socfpga/include/mach/socfpga-regs.h |   2 +
 4 files changed, 430 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/fpga.c

diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig
index e6c4c34..eb99ef7 100644
--- a/arch/arm/mach-socfpga/Kconfig
+++ b/arch/arm/mach-socfpga/Kconfig
@@ -4,6 +4,11 @@ config ARCH_SOCFPGA_XLOAD
bool
prompt Build preloader image
 
+config ARCH_SOCFPGA_FPGA
+   depends on COMMAND_SUPPORT
+   bool
+   prompt Enable FPGA load command
+
 config ARCH_TEXT_BASE
hex
default 0x0010 if MACH_SOCFPGA_CYCLONE5
diff --git a/arch/arm/mach-socfpga/Makefile b/arch/arm/mach-socfpga/Makefile
index d8bf067..12585c5 100644
--- a/arch/arm/mach-socfpga/Makefile
+++ b/arch/arm/mach-socfpga/Makefile
@@ -2,3 +2,4 @@ obj-y += generic.o nic301.o bootsource.o reset-manager.o
 pbl-y += init.o freeze-controller.o scan-manager.o system-manager.o
 pbl-y += clock-manager.o iocsr-config-cyclone5.o
 obj-$(CONFIG_ARCH_SOCFPGA_XLOAD) += xload.o
+obj-$(CONFIG_ARCH_SOCFPGA_FPGA) += fpga.o
diff --git a/arch/arm/mach-socfpga/fpga.c b/arch/arm/mach-socfpga/fpga.c
new file mode 100644
index 000..6828001
--- /dev/null
+++ b/arch/arm/mach-socfpga/fpga.c
@@ -0,0 +1,422 @@
+/*
+ *
+ * Copyright (C) 2012 Altera Corporation www.altera.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *  - Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ *  - Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *  - Neither the name of the Altera Corporation nor the
+ *names of its contributors may be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL ALTERA CORPORATION BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#define pr_fmt(fmt) fpgamgr:  fmt
+
+#include command.h
+#include common.h
+#include malloc.h
+#include clock.h
+#include fcntl.h
+#include fs.h
+#include io.h
+#include mach/socfpga-regs.h
+#include mach/reset-manager.h
+#include mach/system-manager.h
+#include mach/sdram.h
+
+#define FPGAMGRREGS_STAT   0x0
+#define FPGAMGRREGS_CTRL   0x4
+#define FPGAMGRREGS_DCLKCNT0x8
+#define FPGAMGRREGS_DCLKSTAT   0xc
+
+#define FPGAMGRREGS_MON_GPIO_PORTA_EOI_ADDRESS 0x84c
+#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_ADDRESS 0x850
+
+#define FPGAMGRREGS_CTRL_CFGWDTH_MASK  0x200
+#define FPGAMGRREGS_CTRL_AXICFGEN_MASK 0x100
+#define FPGAMGRREGS_CTRL_NCONFIGPULL_MASK  0x4
+#define FPGAMGRREGS_CTRL_NCE_MASK  0x2
+#define FPGAMGRREGS_CTRL_EN_MASK   0x1
+#define FPGAMGRREGS_CTRL_CDRATIO_LSB   6
+
+#define FPGAMGRREGS_STAT_MODE_MASK 0x7
+#define FPGAMGRREGS_STAT_MSEL_MASK 0xf8
+#define FPGAMGRREGS_STAT_MSEL_LSB  3
+
+#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_CRC_MASK0x8
+#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_ID_MASK 0x4
+#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_CD_MASK 0x2
+#define FPGAMGRREGS_MON_GPIO_EXT_PORTA_NS_MASK 0x1
+
+/* FPGA Mode */
+#define FPGAMGRREGS_MODE_FPGAOFF   0x0
+#define FPGAMGRREGS_MODE_RESETPHASE0x1
+#define FPGAMGRREGS_MODE_CFGPHASE  0x2
+#define FPGAMGRREGS_MODE_INITPHASE 0x3
+#define FPGAMGRREGS_MODE_USERMODE  0x4
+#define FPGAMGRREGS_MODE_UNKNOWN   0x5
+
+/* FPGA CD Ratio Value */
+#define CDRATIO_x1 0x0
+#define CDRATIO_x2 

Re: [PATCH 08/11] ARM: socfpga: Add FPGA programming command

2013-09-16 Thread Sascha Hauer
Hi Steffen,

On Mon, Sep 16, 2013 at 12:40:41PM +0200, Steffen Trumtrar wrote:
 Hi!
 
 On Mon, Sep 16, 2013 at 10:48:17AM +0200, Sascha Hauer wrote:
  This adds a simple socfpga specific 'fpga' command to load a firmware
  to the FPGA. For the moment this is enough, but should we get more
  FPGA support it might be a good idea to introduce some generic framework
  and command.
  
  Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
  ---
   arch/arm/mach-socfpga/Kconfig |   5 +
   arch/arm/mach-socfpga/Makefile|   1 +
   arch/arm/mach-socfpga/fpga.c  | 422 
  ++
   arch/arm/mach-socfpga/include/mach/socfpga-regs.h |   2 +
   4 files changed, 430 insertions(+)
   create mode 100644 arch/arm/mach-socfpga/fpga.c
  
 
 Why did you chose to have an extra command for fpga loading instead of having
 just a (block)device? Do you see any future advantage in that or is it just
 because of the port from u-boot? I know that they need an extra fpga command, 
 but
 they also have an extra mmcload command and stuff.

Main reason was that I was unsure how good a block device will be when
we get a different firmware format to load (rbf vs. sof vs. something
else)

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 08/11] ARM: socfpga: Add FPGA programming command

2013-09-16 Thread Steffen Trumtrar
On Mon, Sep 16, 2013 at 01:09:14PM +0200, Sascha Hauer wrote:
 Hi Steffen,
 
 On Mon, Sep 16, 2013 at 12:40:41PM +0200, Steffen Trumtrar wrote:
  Hi!
  
  On Mon, Sep 16, 2013 at 10:48:17AM +0200, Sascha Hauer wrote:
   This adds a simple socfpga specific 'fpga' command to load a firmware
   to the FPGA. For the moment this is enough, but should we get more
   FPGA support it might be a good idea to introduce some generic framework
   and command.
   
   Signed-off-by: Sascha Hauer s.ha...@pengutronix.de
   ---
arch/arm/mach-socfpga/Kconfig |   5 +
arch/arm/mach-socfpga/Makefile|   1 +
arch/arm/mach-socfpga/fpga.c  | 422 
   ++
arch/arm/mach-socfpga/include/mach/socfpga-regs.h |   2 +
4 files changed, 430 insertions(+)
create mode 100644 arch/arm/mach-socfpga/fpga.c
   
  
  Why did you chose to have an extra command for fpga loading instead of 
  having
  just a (block)device? Do you see any future advantage in that or is it just
  because of the port from u-boot? I know that they need an extra fpga 
  command, but
  they also have an extra mmcload command and stuff.
 
 Main reason was that I was unsure how good a block device will be when
 we get a different firmware format to load (rbf vs. sof vs. something
 else)
 

Aha, okay. If we want/need to support different formats, than a special
command might be necessary. At least when the format is not easy to
autodetect, I guess.

Steffen

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox