[Armadeus-commitlog] SF.net SVN: armadeus:[1128] trunk
Brought to you by:
sszy
|
From: <ar...@us...> - 2009-03-08 16:17:45
|
Revision: 1128
http://armadeus.svn.sourceforge.net/armadeus/?rev=1128&view=rev
Author: artemys
Date: 2009-03-08 16:17:25 +0000 (Sun, 08 Mar 2009)
Log Message:
-----------
[LINUX] rename fpgaloader directory
Modified Paths:
--------------
trunk/buildroot/target/device/armadeus/apf27/apf27-linux-2.6.27.13.config
trunk/buildroot/target/device/armadeus/apf9328/apf9328-linux-2.6.27.13.config
trunk/target/linux/modules/fpga/dev_tools/Kconfig
trunk/target/linux/modules/fpga/dev_tools/Makefile
Added Paths:
-----------
trunk/target/linux/modules/fpga/dev_tools/loader/
trunk/target/linux/modules/fpga/dev_tools/loader/Kconfig
trunk/target/linux/modules/fpga/dev_tools/loader/Makefile
trunk/target/linux/modules/fpga/dev_tools/loader/apf27-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/apf9328-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/fpgaloader.sh
trunk/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.h
Removed Paths:
-------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/
trunk/target/linux/modules/fpga/dev_tools/loader/Kconfig
trunk/target/linux/modules/fpga/dev_tools/loader/Makefile
trunk/target/linux/modules/fpga/dev_tools/loader/apf27-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/apf9328-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.h
trunk/target/linux/modules/fpga/dev_tools/loader/fpgaloader.sh
trunk/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.h
Modified: trunk/buildroot/target/device/armadeus/apf27/apf27-linux-2.6.27.13.config
===================================================================
--- trunk/buildroot/target/device/armadeus/apf27/apf27-linux-2.6.27.13.config 2009-03-08 16:13:12 UTC (rev 1127)
+++ trunk/buildroot/target/device/armadeus/apf27/apf27-linux-2.6.27.13.config 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1099,7 +1099,7 @@
#
CONFIG_ARMADEUS_FPGA_DRIVERS=y
CONFIG_ARMADEUS_FPGA_TEST=y
-CONFIG_ARMADEUS_FPGA_TOOL_DRIVER=m
+CONFIG_ARMADEUS_FPGA_LOADER_DRIVER=m
# CONFIG_ARMADEUS_FPGAACCESS_DRIVER is not set
# CONFIG_ARMADEUS_FPGA_OTHERS_DRIVERS is not set
# CONFIG_ARMADEUS_WISHBONE_EXAMPLE_DRIVERS is not set
Modified: trunk/buildroot/target/device/armadeus/apf9328/apf9328-linux-2.6.27.13.config
===================================================================
--- trunk/buildroot/target/device/armadeus/apf9328/apf9328-linux-2.6.27.13.config 2009-03-08 16:13:12 UTC (rev 1127)
+++ trunk/buildroot/target/device/armadeus/apf9328/apf9328-linux-2.6.27.13.config 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1121,7 +1121,7 @@
#
CONFIG_ARMADEUS_FPGA_DRIVERS=y
CONFIG_ARMADEUS_FPGA_TEST=y
-CONFIG_ARMADEUS_FPGA_TOOL_DRIVER=m
+CONFIG_ARMADEUS_FPGA_LOADER_DRIVER=m
CONFIG_ARMADEUS_FPGAACCESS_DRIVER=m
CONFIG_ARMADEUS_FPGA_OTHERS_DRIVERS=y
# CONFIG_ARMADEUS_BUTTON_DRIVER is not set
Modified: trunk/target/linux/modules/fpga/dev_tools/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/Kconfig 2009-03-08 16:13:12 UTC (rev 1127)
+++ trunk/target/linux/modules/fpga/dev_tools/Kconfig 2009-03-08 16:17:25 UTC (rev 1128)
@@ -2,11 +2,11 @@
# Armadeus custom drivers configuration
#
config ARMADEUS_FPGA_TEST
- boolean "Driver for configuring and testing fpga"
+ boolean "Driver for configuring and testing FPGA"
default n
depends on ARMADEUS_FPGA_DRIVERS
---help---
All drivers for FPGA components
-source "drivers/armadeus/fpga/dev_tools/fpga_devtools/Kconfig"
+source "drivers/armadeus/fpga/dev_tools/loader/Kconfig"
source "drivers/armadeus/fpga/dev_tools/fpgaaccess/Kconfig"
Modified: trunk/target/linux/modules/fpga/dev_tools/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/Makefile 2009-03-08 16:13:12 UTC (rev 1127)
+++ trunk/target/linux/modules/fpga/dev_tools/Makefile 2009-03-08 16:17:25 UTC (rev 1128)
@@ -8,7 +8,7 @@
# Part executed when called from kernel build system:
-obj-$(CONFIG_ARMADEUS_FPGA_TEST) += fpga_devtools/ fpgaaccess/
+obj-$(CONFIG_ARMADEUS_FPGA_TEST) += loader/ fpgaaccess/
else
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Kconfig 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/Kconfig 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,9 +0,0 @@
-#
-
-#
-config ARMADEUS_FPGA_TOOL_DRIVER
- tristate "Armadeus FPGA configuration driver"
- default n
- depends on ARMADEUS_FPGA_TEST
- ---help---
-
Copied: trunk/target/linux/modules/fpga/dev_tools/loader/Kconfig (from rev 1127, trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Kconfig)
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/loader/Kconfig (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/Kconfig 2009-03-08 16:17:25 UTC (rev 1128)
@@ -0,0 +1,9 @@
+#
+
+#
+config ARMADEUS_FPGA_LOADER_DRIVER
+ tristate "Armadeus FPGA configuration driver (= loader)"
+ default n
+ depends on ARMADEUS_FPGA_TEST
+ ---help---
+
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/Makefile 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,33 +0,0 @@
-#
-# Makefile for the Armadeus FPGA loader driver
-#
-
-ifneq ($(KERNELRELEASE),)
-
-obj-$(CONFIG_ARMADEUS_FPGA_TOOL_DRIVER) += fpgaloader.o
-ifneq ($(CONFIG_MACH_APF27),)
-fpgaloader-objs := xilinx-fpga-loader.o fpga-loader.o
-obj-y += apf27-fpga-loader.o
-endif
-ifneq ($(CONFIG_MACH_APF9328),)
-fpgaloader-objs := xilinx-fpga-loader.o fpga-loader.o
-obj-y += apf9328-fpga-loader.o
-endif
-
-else
-
-ARMADEUS_BASE_DIR=../../../../../..
-include $(ARMADEUS_BASE_DIR)/Makefile.in
-
-KDIR := $(ARMADEUS_LINUX_DIR)
-PWD := $(shell pwd)
-
-default:
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
-
-clean:
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
- rm -f modules.order Module.markers
-
-endif
-
Copied: trunk/target/linux/modules/fpga/dev_tools/loader/Makefile (from rev 1127, trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile)
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/loader/Makefile (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/Makefile 2009-03-08 16:17:25 UTC (rev 1128)
@@ -0,0 +1,33 @@
+#
+# Makefile for the Armadeus FPGA loader driver
+#
+
+ifneq ($(KERNELRELEASE),)
+
+obj-$(CONFIG_ARMADEUS_FPGA_TOOL_DRIVER) += fpgaloader.o
+ifneq ($(CONFIG_MACH_APF27),)
+fpgaloader-objs := xilinx-fpga-loader.o fpga-loader.o
+obj-y += apf27-fpga-loader.o
+endif
+ifneq ($(CONFIG_MACH_APF9328),)
+fpgaloader-objs := xilinx-fpga-loader.o fpga-loader.o
+obj-y += apf9328-fpga-loader.o
+endif
+
+else
+
+ARMADEUS_BASE_DIR=../../../../../..
+include $(ARMADEUS_BASE_DIR)/Makefile.in
+
+KDIR := $(ARMADEUS_LINUX_DIR)
+PWD := $(shell pwd)
+
+default:
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
+
+clean:
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
+ rm -f modules.order Module.markers
+
+endif
+
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/apf27-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/apf27-fpga-loader.c 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,197 +0,0 @@
-/*
- * APF27 Xilinx FPGA download support
- * Copyright (C) 2009 Nicolas Colombain <nic...@ar...>
- * Armadeus Project / Armadeus systems
- *
- * 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <mach/iomux-mx1-mx2.h>
-#include <mach/gpio.h>
-#include <asm/io.h>
-#include <linux/platform_device.h>
-
-#include "xilinx-fpga-loader.h"
-
-
-#define FPGA_BASE_ADDR CS5_BASE_ADDR
-
-#define CFG_FPGA_PWR (GPIO_PORTF | 19) /* FPGA prog pin */
-#define CFG_FPGA_PRG (GPIO_PORTF | 11) /* FPGA prog pin */
-#define CFG_FPGA_CLK (GPIO_PORTF | 15) /* FPGA clk pin */
-#define CFG_FPGA_INIT (GPIO_PORTF | 12) /* FPGA init pin */
-#define CFG_FPGA_DONE (GPIO_PORTF | 9) /* FPGA done pin */
-#define CFG_FPGA_RW (GPIO_PORTF | 21) /* FPGA done pin */
-#define CFG_FPGA_CS (GPIO_PORTF | 22) /* FPGA done pin */
-#define CFG_FPGA_SUSPEND (GPIO_PORTF | 10) /* FPGA done pin */
-#define CFG_FPGA_RESET (GPIO_PORTF | 7) /* FPGA done pin */
-
-static void __iomem *fpga_addr;
-
-
-/* Initialize GPIO port before download */
-int apf27_fpga_pre(void)
-{
- gpio_set_value(CFG_FPGA_PWR, 1);
- gpio_set_value(CFG_FPGA_PRG, 1);
- gpio_set_value(CFG_FPGA_CLK, 1);
- gpio_set_value(CFG_FPGA_RW, 1);
- gpio_set_value(CFG_FPGA_CS, 1);
- gpio_set_value(CFG_FPGA_SUSPEND, 0);
- gpio_set_value(CFG_FPGA_RESET, 0);
-
- /* Initialize GPIO pins */
- mxc_gpio_mode(CFG_FPGA_PWR | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_INIT | GPIO_IN | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_DONE | GPIO_IN | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_PRG | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_CLK | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_RW | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_CS | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_SUSPEND | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
- mxc_gpio_mode(CFG_FPGA_RESET | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
-
- gpio_set_value(CFG_FPGA_PWR, 0);
- fpga_addr = ioremap( FPGA_BASE_ADDR, 16);
- if( fpga_addr == NULL )
- return 0;
- return 1;
-}
-
-/*
- * Set the FPGA's active-low program line to the specified level
- */
-int apf27_fpga_pgm(int assert)
-{
- gpio_set_value( CFG_FPGA_PRG, !assert);
- return assert;
-}
-
-/*
- * Set the FPGA's active-high clock line to the specified level
- */
-int apf27_fpga_clk(int assert_clk)
-{
- gpio_set_value( CFG_FPGA_CLK, !assert_clk);
- return assert_clk;
-}
-
-/*
- * Test the state of the active-low FPGA INIT line. Return 1 on INIT
- * asserted (low).
- */
-int apf27_fpga_init(void)
-{
- int value;
- value = gpio_get_value(CFG_FPGA_INIT);
- return !value;
-}
-
-/*
- * Test the state of the active-high FPGA DONE pin
- */
-int apf27_fpga_done(void)
-{
- return(gpio_get_value(CFG_FPGA_DONE));
-}
-
-/*
- * Set the FPGA's wr line to the specified level
- */
-int apf27_fpga_wr(int assert_write)
-{
- gpio_set_value( CFG_FPGA_RW, !assert_write);
- return assert_write;
-}
-
-int apf27_fpga_cs(int assert_cs)
-{
- gpio_set_value( CFG_FPGA_CS, !assert_cs);
- return assert_cs;
-}
-
-int apf27_fpga_wdata( unsigned char data )
-{
- __raw_writew(data, fpga_addr);
- return data;
-}
-
-int apf27_fpga_busy(void)
-{
- return 0;
-}
-
-int apf27_fpga_post(void)
-{
- mxc_gpio_mode (CFG_FPGA_RW | GPIO_PF | GPIO_PUEN);
- mxc_gpio_mode (CFG_FPGA_CS | GPIO_PF | GPIO_PUEN);
- mxc_gpio_mode (CFG_FPGA_CLK | GPIO_PF | GPIO_PUEN);
- gpio_set_value(CFG_FPGA_PRG, 1);
- iounmap(fpga_addr);
- return 1;
-}
-
-int apf27_fpga_abort(void)
-{
- apf27_fpga_post();
- gpio_set_value(CFG_FPGA_PWR, 1);
- return 1;
-}
-
-/* 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 = {
- .pre = apf27_fpga_pre,
- .pgm = apf27_fpga_pgm,
- .clk = apf27_fpga_clk,
- .init = apf27_fpga_init,
- .done = apf27_fpga_done,
- .wr = apf27_fpga_wr,
- .cs = apf27_fpga_cs,
- .wdata = apf27_fpga_wdata,
- .busy = apf27_fpga_busy,
- .abort = apf27_fpga_abort,
- .post = apf27_fpga_post,
-};
-
-struct fpga_desc apf27_fpga_desc = {
- .family = Xilinx_Spartan,
- .iface = slave_parallel,
- .iface_fns = (void *) &fpga_fns
-};
-
-static struct platform_device fpga_device = {
- .name = "fpgaloader",
- .id = 0,
- .dev = {
- .platform_data = &apf27_fpga_desc,
- },
-};
-
-static struct platform_device *devices[] __initdata = {
- &fpga_device,
-};
-
-static int __init apf27_fpga_initialize(void)
-{
- platform_add_devices(devices, ARRAY_SIZE(devices));
- return 0;
-}
-
-device_initcall(apf27_fpga_initialize);
Copied: trunk/target/linux/modules/fpga/dev_tools/loader/apf27-fpga-loader.c (from rev 1127, trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c)
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/loader/apf27-fpga-loader.c (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/apf27-fpga-loader.c 2009-03-08 16:17:25 UTC (rev 1128)
@@ -0,0 +1,197 @@
+/*
+ * APF27 Xilinx FPGA download support
+ * Copyright (C) 2009 Nicolas Colombain <nic...@ar...>
+ * Armadeus Project / Armadeus systems
+ *
+ * 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <mach/iomux-mx1-mx2.h>
+#include <mach/gpio.h>
+#include <asm/io.h>
+#include <linux/platform_device.h>
+
+#include "xilinx-fpga-loader.h"
+
+
+#define FPGA_BASE_ADDR CS5_BASE_ADDR
+
+#define CFG_FPGA_PWR (GPIO_PORTF | 19) /* FPGA prog pin */
+#define CFG_FPGA_PRG (GPIO_PORTF | 11) /* FPGA prog pin */
+#define CFG_FPGA_CLK (GPIO_PORTF | 15) /* FPGA clk pin */
+#define CFG_FPGA_INIT (GPIO_PORTF | 12) /* FPGA init pin */
+#define CFG_FPGA_DONE (GPIO_PORTF | 9) /* FPGA done pin */
+#define CFG_FPGA_RW (GPIO_PORTF | 21) /* FPGA done pin */
+#define CFG_FPGA_CS (GPIO_PORTF | 22) /* FPGA done pin */
+#define CFG_FPGA_SUSPEND (GPIO_PORTF | 10) /* FPGA done pin */
+#define CFG_FPGA_RESET (GPIO_PORTF | 7) /* FPGA done pin */
+
+static void __iomem *fpga_addr;
+
+
+/* Initialize GPIO port before download */
+int apf27_fpga_pre(void)
+{
+ gpio_set_value(CFG_FPGA_PWR, 1);
+ gpio_set_value(CFG_FPGA_PRG, 1);
+ gpio_set_value(CFG_FPGA_CLK, 1);
+ gpio_set_value(CFG_FPGA_RW, 1);
+ gpio_set_value(CFG_FPGA_CS, 1);
+ gpio_set_value(CFG_FPGA_SUSPEND, 0);
+ gpio_set_value(CFG_FPGA_RESET, 0);
+
+ /* Initialize GPIO pins */
+ mxc_gpio_mode(CFG_FPGA_PWR | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_INIT | GPIO_IN | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_DONE | GPIO_IN | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_PRG | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_CLK | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_RW | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_CS | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_SUSPEND | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+ mxc_gpio_mode(CFG_FPGA_RESET | GPIO_OUT | GPIO_PUEN | GPIO_GPIO);
+
+ gpio_set_value(CFG_FPGA_PWR, 0);
+ fpga_addr = ioremap( FPGA_BASE_ADDR, 16);
+ if( fpga_addr == NULL )
+ return 0;
+ return 1;
+}
+
+/*
+ * Set the FPGA's active-low program line to the specified level
+ */
+int apf27_fpga_pgm(int assert)
+{
+ gpio_set_value( CFG_FPGA_PRG, !assert);
+ return assert;
+}
+
+/*
+ * Set the FPGA's active-high clock line to the specified level
+ */
+int apf27_fpga_clk(int assert_clk)
+{
+ gpio_set_value( CFG_FPGA_CLK, !assert_clk);
+ return assert_clk;
+}
+
+/*
+ * Test the state of the active-low FPGA INIT line. Return 1 on INIT
+ * asserted (low).
+ */
+int apf27_fpga_init(void)
+{
+ int value;
+ value = gpio_get_value(CFG_FPGA_INIT);
+ return !value;
+}
+
+/*
+ * Test the state of the active-high FPGA DONE pin
+ */
+int apf27_fpga_done(void)
+{
+ return(gpio_get_value(CFG_FPGA_DONE));
+}
+
+/*
+ * Set the FPGA's wr line to the specified level
+ */
+int apf27_fpga_wr(int assert_write)
+{
+ gpio_set_value( CFG_FPGA_RW, !assert_write);
+ return assert_write;
+}
+
+int apf27_fpga_cs(int assert_cs)
+{
+ gpio_set_value( CFG_FPGA_CS, !assert_cs);
+ return assert_cs;
+}
+
+int apf27_fpga_wdata( unsigned char data )
+{
+ __raw_writew(data, fpga_addr);
+ return data;
+}
+
+int apf27_fpga_busy(void)
+{
+ return 0;
+}
+
+int apf27_fpga_post(void)
+{
+ mxc_gpio_mode (CFG_FPGA_RW | GPIO_PF | GPIO_PUEN);
+ mxc_gpio_mode (CFG_FPGA_CS | GPIO_PF | GPIO_PUEN);
+ mxc_gpio_mode (CFG_FPGA_CLK | GPIO_PF | GPIO_PUEN);
+ gpio_set_value(CFG_FPGA_PRG, 1);
+ iounmap(fpga_addr);
+ return 1;
+}
+
+int apf27_fpga_abort(void)
+{
+ apf27_fpga_post();
+ gpio_set_value(CFG_FPGA_PWR, 1);
+ return 1;
+}
+
+/* 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 = {
+ .pre = apf27_fpga_pre,
+ .pgm = apf27_fpga_pgm,
+ .clk = apf27_fpga_clk,
+ .init = apf27_fpga_init,
+ .done = apf27_fpga_done,
+ .wr = apf27_fpga_wr,
+ .cs = apf27_fpga_cs,
+ .wdata = apf27_fpga_wdata,
+ .busy = apf27_fpga_busy,
+ .abort = apf27_fpga_abort,
+ .post = apf27_fpga_post,
+};
+
+struct fpga_desc apf27_fpga_desc = {
+ .family = Xilinx_Spartan,
+ .iface = slave_parallel,
+ .iface_fns = (void *) &fpga_fns
+};
+
+static struct platform_device fpga_device = {
+ .name = "fpgaloader",
+ .id = 0,
+ .dev = {
+ .platform_data = &apf27_fpga_desc,
+ },
+};
+
+static struct platform_device *devices[] __initdata = {
+ &fpga_device,
+};
+
+static int __init apf27_fpga_initialize(void)
+{
+ platform_add_devices(devices, ARRAY_SIZE(devices));
+ return 0;
+}
+
+device_initcall(apf27_fpga_initialize);
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/apf9328-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/apf9328-fpga-loader.c 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,130 +0,0 @@
-/*
- * APF9328 Xilinx FPGA download support
- * Copyright (C) 2006-2009 Nicolas Colombain <nic...@ar...>
- * Copyright (C) 2006-2009 Eric Jarrige <eri...@ar...>
- * Armadeus Project / Armadeus systems
- *
- * 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <asm/io.h>
-#include <linux/platform_device.h>
-
-#include "xilinx-fpga-loader.h"
-
-
-#define FPGA_INIT (GPIO_PORTB | 15) /* FPGA init pin (SSI input) */
-#define FPGA_DONE (GPIO_PORTB | 16) /* FPGA done pin (SSI input) */
-#define FPGA_DIN (GPIO_PORTB | 17) /* FPGA data pin (SSI output) */
-#define FPGA_PROGRAM (GPIO_PORTB | 18) /* FPGA prog pin (SSI output) */
-#define FPGA_CLOCK (GPIO_PORTB | 19) /* FPGA clk pin (SSI output) */
-
-#define GPIO_PORT(x) ((x >> 5) & 3)
-#define GPIO_SET(x) (DR(GPIO_PORT(x)) |= (1<<(x & GPIO_PIN_MASK)))
-#define GPIO_CLEAR(x) (DR(GPIO_PORT(x)) &= ~(1<<(x & GPIO_PIN_MASK)))
-#define GPIO_WRITE(x,y) ( y ? GPIO_SET(x) : GPIO_CLEAR(x) )
-#define GPIO_READ(x) ((SSR (GPIO_PORT(x)) & (1<<(x & GPIO_PIN_MASK))))
-
-/*
- * Set the FPGA's active-low program line to the specified level
- */
-static int apf9328_fpga_pgm( int assert )
-{
- GPIO_WRITE( FPGA_PROGRAM, !assert);
- return assert;
-}
-
-/*
- * Set the FPGA's active-high clock line to the specified level
- */
-static int apf9328_fpga_clk( int assert_clk )
-{
- GPIO_WRITE( FPGA_CLOCK, assert_clk);
- return assert_clk;
-}
-
-/*
- * Test the state of the active-low FPGA INIT line. Return 1 on INIT
- * asserted (low).
- */
-static int apf9328_fpga_init( void )
-{
- return(!GPIO_READ(FPGA_INIT));
-}
-
-/*
- * Test the state of the active-high FPGA DONE pin
- */
-static int apf9328_fpga_done( void )
-{
- return(GPIO_READ(FPGA_DONE));
-}
-
-/*
- * Set the FPGA's data line to the specified level
- */
-static int apf9328_fpga_wr( int assert_write )
-{
- GPIO_WRITE( FPGA_DIN, assert_write);
- return assert_write;
-}
-
-static int apf9328_fpga_pre( void )
-{
- /* Initialize GPIO pins */
- imx_gpio_mode (FPGA_INIT | GPIO_GIUS | GPIO_DR | GPIO_IN );
- imx_gpio_mode (FPGA_DONE | GPIO_GIUS | GPIO_DR | GPIO_IN );
- imx_gpio_mode (FPGA_DIN | GPIO_GIUS | GPIO_DR | GPIO_OUT );
- imx_gpio_mode (FPGA_PROGRAM | GPIO_GIUS | GPIO_DR | GPIO_OUT );
- imx_gpio_mode (FPGA_CLOCK | GPIO_GIUS | GPIO_DR | GPIO_OUT );
- return 1;
-}
-
-
-Xilinx_Spartan_Slave_Serial_fns fpga_fns = {
- .pre = apf9328_fpga_pre,
- .pgm = apf9328_fpga_pgm,
- .clk = apf9328_fpga_clk,
- .init = apf9328_fpga_init,
- .done = apf9328_fpga_done,
- .wr = apf9328_fpga_wr,
-};
-
-struct fpga_desc apf9328_fpga_desc = {
- .family = Xilinx_Spartan,
- .iface = slave_serial,
- .iface_fns = (void *) &fpga_fns
-};
-
-static struct platform_device fpga_device = {
- .name = "fpgaloader",
- .id = 0,
- .dev = {
- .platform_data = &apf9328_fpga_desc,
- },
-};
-
-static struct platform_device *devices[] __initdata = {
- &fpga_device,
-};
-
-static int __init apf9328_fpga_initialize(void)
-{
- platform_add_devices(devices, ARRAY_SIZE(devices));
- return 0;
-}
-
-device_initcall(apf9328_fpga_initialize);
Copied: trunk/target/linux/modules/fpga/dev_tools/loader/apf9328-fpga-loader.c (from rev 1127, trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c)
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/loader/apf9328-fpga-loader.c (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/apf9328-fpga-loader.c 2009-03-08 16:17:25 UTC (rev 1128)
@@ -0,0 +1,130 @@
+/*
+ * APF9328 Xilinx FPGA download support
+ * Copyright (C) 2006-2009 Nicolas Colombain <nic...@ar...>
+ * Copyright (C) 2006-2009 Eric Jarrige <eri...@ar...>
+ * Armadeus Project / Armadeus systems
+ *
+ * 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <asm/io.h>
+#include <linux/platform_device.h>
+
+#include "xilinx-fpga-loader.h"
+
+
+#define FPGA_INIT (GPIO_PORTB | 15) /* FPGA init pin (SSI input) */
+#define FPGA_DONE (GPIO_PORTB | 16) /* FPGA done pin (SSI input) */
+#define FPGA_DIN (GPIO_PORTB | 17) /* FPGA data pin (SSI output) */
+#define FPGA_PROGRAM (GPIO_PORTB | 18) /* FPGA prog pin (SSI output) */
+#define FPGA_CLOCK (GPIO_PORTB | 19) /* FPGA clk pin (SSI output) */
+
+#define GPIO_PORT(x) ((x >> 5) & 3)
+#define GPIO_SET(x) (DR(GPIO_PORT(x)) |= (1<<(x & GPIO_PIN_MASK)))
+#define GPIO_CLEAR(x) (DR(GPIO_PORT(x)) &= ~(1<<(x & GPIO_PIN_MASK)))
+#define GPIO_WRITE(x,y) ( y ? GPIO_SET(x) : GPIO_CLEAR(x) )
+#define GPIO_READ(x) ((SSR (GPIO_PORT(x)) & (1<<(x & GPIO_PIN_MASK))))
+
+/*
+ * Set the FPGA's active-low program line to the specified level
+ */
+static int apf9328_fpga_pgm( int assert )
+{
+ GPIO_WRITE( FPGA_PROGRAM, !assert);
+ return assert;
+}
+
+/*
+ * Set the FPGA's active-high clock line to the specified level
+ */
+static int apf9328_fpga_clk( int assert_clk )
+{
+ GPIO_WRITE( FPGA_CLOCK, assert_clk);
+ return assert_clk;
+}
+
+/*
+ * Test the state of the active-low FPGA INIT line. Return 1 on INIT
+ * asserted (low).
+ */
+static int apf9328_fpga_init( void )
+{
+ return(!GPIO_READ(FPGA_INIT));
+}
+
+/*
+ * Test the state of the active-high FPGA DONE pin
+ */
+static int apf9328_fpga_done( void )
+{
+ return(GPIO_READ(FPGA_DONE));
+}
+
+/*
+ * Set the FPGA's data line to the specified level
+ */
+static int apf9328_fpga_wr( int assert_write )
+{
+ GPIO_WRITE( FPGA_DIN, assert_write);
+ return assert_write;
+}
+
+static int apf9328_fpga_pre( void )
+{
+ /* Initialize GPIO pins */
+ imx_gpio_mode (FPGA_INIT | GPIO_GIUS | GPIO_DR | GPIO_IN );
+ imx_gpio_mode (FPGA_DONE | GPIO_GIUS | GPIO_DR | GPIO_IN );
+ imx_gpio_mode (FPGA_DIN | GPIO_GIUS | GPIO_DR | GPIO_OUT );
+ imx_gpio_mode (FPGA_PROGRAM | GPIO_GIUS | GPIO_DR | GPIO_OUT );
+ imx_gpio_mode (FPGA_CLOCK | GPIO_GIUS | GPIO_DR | GPIO_OUT );
+ return 1;
+}
+
+
+Xilinx_Spartan_Slave_Serial_fns fpga_fns = {
+ .pre = apf9328_fpga_pre,
+ .pgm = apf9328_fpga_pgm,
+ .clk = apf9328_fpga_clk,
+ .init = apf9328_fpga_init,
+ .done = apf9328_fpga_done,
+ .wr = apf9328_fpga_wr,
+};
+
+struct fpga_desc apf9328_fpga_desc = {
+ .family = Xilinx_Spartan,
+ .iface = slave_serial,
+ .iface_fns = (void *) &fpga_fns
+};
+
+static struct platform_device fpga_device = {
+ .name = "fpgaloader",
+ .id = 0,
+ .dev = {
+ .platform_data = &apf9328_fpga_desc,
+ },
+};
+
+static struct platform_device *devices[] __initdata = {
+ &fpga_device,
+};
+
+static int __init apf9328_fpga_initialize(void)
+{
+ platform_add_devices(devices, ARRAY_SIZE(devices));
+ return 0;
+}
+
+device_initcall(apf9328_fpga_initialize);
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,322 +0,0 @@
-/*
- * Generic Xilinx FPGA loader
- *
- * Copyright (C) 2006-2009 Julien Boibessot <jul...@ar...>
- * Nicolas Colombain <nic...@ar...>
- * Armadeus Project / Armadeus systems
- *
- * 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-// #define DEBUG
-
-#include <linux/version.h>
-#include <linux/module.h>
-#include <linux/proc_fs.h>
-#include <linux/fcntl.h>
-#include <linux/platform_device.h>
-#include <linux/miscdevice.h>
-#include <asm/uaccess.h>
-
-#include "fpga-loader.h"
-#include "xilinx-fpga-loader.h"
-
-
-#define DRIVER_VERSION "0.9"
-#define DRIVER_NAME "fpgaloader"
-
-/* global variables */
-struct fpga_desc *g_current_desc = NULL;
-struct semaphore fpga_sema;
-
-static unsigned char fpga_descriptor = 0; /* use default target_fpga_desc */
-module_param( fpga_descriptor, byte, 0 );
-
-#define FPGA_BUFFER_SIZE 4096
-static unsigned char g_buffer[FPGA_BUFFER_SIZE];
-static unsigned char g_nb_users = 0;
-
-
-/* Handles write() done on /dev/fpga/loader */
-static ssize_t armadeus_fpga_write(struct file *file, const char* pData, size_t count, loff_t *f_pos)
-{
- ssize_t ret = 0;
-
- /* Get exclusive access */
- if (down_interruptible(&fpga_sema))
- return -ERESTARTSYS;
-
- if( count > FPGA_BUFFER_SIZE ) {
- count = FPGA_BUFFER_SIZE;
- }
-
- /* Get value to write from user space */
- ret = __copy_from_user( g_buffer, pData, count);
- if (ret != 0) {
- ret = -EFAULT;
- goto out;
- }
-
- ret = xilinx_load( g_current_desc, g_buffer, count );
-
-out:
- /* Release exclusive access */
- up(&fpga_sema);
-
- return ret;
-}
-
-static int armadeus_fpga_open(struct inode *inode, struct file *file)
-{
- int ret;
-
- /* Get exclusive access */
- if (down_interruptible(&fpga_sema))
- return -ERESTARTSYS;
-
- /* Only one access at a time is permitted */
- if( g_nb_users > 0 )
- return -EBUSY;
-
- ret = xilinx_init_load( g_current_desc );
- if(!ret) {
- printk("Starting FPGA download\n");
- g_nb_users++;
- }
-
- pr_debug("Opening /dev/fpga/loader%d file, %d %d\n", MINOR(inode->i_rdev), fpga_descriptor, ret);
-
- /* Release exclusive access */
- up(&fpga_sema);
-
- return ret;
-}
-
-static int armadeus_fpga_release(struct inode *inode, struct file *file)
-{
- if( xilinx_finish_load(g_current_desc) )
- printk("Failed to load FPGA !\n");
-
- pr_debug("Closing access to /dev/fpga/loader%d\n", MINOR(inode->i_rdev));
-
- if( g_nb_users > 0 )
- g_nb_users--;
-
- return 0;
-}
-
-
-/* PROC file */
-static int procfile_fpga_read( char *buffer, __attribute__ ((unused)) char **start, off_t offset, int buffer_length, int *eof, __attribute__ ((unused)) void* data)
-{
- int ret;
-
- /* We give all of our information in one go, so if the user asks us if
- we have more information the answer should always be no.
- This is important because the standard read function from the
- library would continue to issue the read system call until the
- the kernel replies that it has no more information, or until
- its buffer is filled */
- if( offset > 0 ) {
- /* we have finished to read, return 0 */
- ret = 0;
- } else {
- ret = fpga_get_infos( g_current_desc, buffer );
- }
-
- return ret;
-}
-
-static int procfile_fpga_write( __attribute__ ((unused)) struct file *file, const char *buf, unsigned long count, void *data)
-{
- return count;
-}
-
-/* Handling of IOCTL calls */
-int armadeus_fpga_ioctl( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg )
-{
- int err = 0; int ret = 0;
- unsigned int minor;
-
- /* PRINTF( DRIVER_NAME " ## IOCTL received: (0x%x) ##\n", cmd ); */
- /* Extract the type and number bitfields, and don't decode wrong cmds:
- return ENOTTY (inappropriate ioctl) before access_ok() */
- if (_IOC_TYPE(cmd) != FPGA_IOCTL) return -ENOTTY;
-
- /* The direction is a bitmask, and VERIFY_WRITE catches R/W transfers.
- `Type' is user-oriented, while access_ok is kernel-oriented,
- so the concept of "read" and "write" is reversed */
- if (_IOC_DIR(cmd) & _IOC_READ)
- err = !access_ok(VERIFY_WRITE, (void *)arg, _IOC_SIZE(cmd));
- else if (_IOC_DIR(cmd) & _IOC_WRITE)
- err = !access_ok(VERIFY_READ, (void *)arg, _IOC_SIZE(cmd));
-
- if (err) return -EFAULT;
-
- if (down_interruptible(&fpga_sema))
- return -ERESTARTSYS;
-
- /* Extract and test minor */
- minor = MINOR(inode->i_rdev);
- if( minor > FPGA_MAX_MINOR ) {
- printk("Minor outside range: %d !\n", minor);
- return -EFAULT;
- }
-
- switch(cmd)
- {
- default:
- return -ENOTTY;
- break;
- }
-
- up(&fpga_sema);
-
- return ret;
-}
-
-/* Create /proc entries for direct access to FPGA config */
-static int create_proc_entries( void )
-{
- static struct proc_dir_entry *fpga_Proc_File;
-
- /* Create main directory */
- proc_mkdir(FPGA_PROC_DIRNAME, NULL);
-
- /* Create proc file */
- fpga_Proc_File = create_proc_entry( FPGA_PROC_FILENAME, S_IWUSR |S_IRUSR | S_IRGRP | S_IROTH, NULL );
- if( fpga_Proc_File == NULL ) {
- printk(DRIVER_NAME ": Could not register a" FPGA_PROC_FILENAME ". Terminating\n");
- goto error;
- } else {
- fpga_Proc_File->read_proc = procfile_fpga_read;
- fpga_Proc_File->write_proc = procfile_fpga_write;
- }
-
- return 0;
-error:
- remove_proc_entry(FPGA_PROC_DIRNAME, NULL);
- return -ENOMEM;
-}
-
-static struct file_operations fpga_fops = {
- .owner = THIS_MODULE,
- .write = armadeus_fpga_write,
- /* .read = armadeus_fpga_read, Configuration saving not supported yet */
- .open = armadeus_fpga_open,
- .release = armadeus_fpga_release,
- .ioctl = armadeus_fpga_ioctl,
-};
-
-#ifdef CONFIG_PM
-static int armadeus_fpga_suspend(struct platform_device *pdev, pm_message_t state)
-{
- return 0;
-}
-
-static int armadeus_fpga_resume(struct platform_device *pdev)
-{
- return 0;
-}
-#else
-#define armadeus_fpga_suspend NULL
-#define armadeus_fpga_resume NULL
-#endif
-
-static struct miscdevice fpgaloader_misc = {
- .minor = MISC_DYNAMIC_MINOR,
- .name = DRIVER_NAME,
- .fops = &fpga_fops,
-};
-
-
-static int armadeus_fpga_probe(struct platform_device *pdev)
-{
- int result;
- struct device *dev = &pdev->dev;
- struct fpga_desc *platform_info;
-
- platform_info = dev->platform_data;
- if (platform_info == NULL) {
- dev_err(&pdev->dev, "probe - no platform data supplied\n");
- result = -ENODEV;
- goto err_no_pdata;
- }
-
- /* Register the driver through misc layer to get MAJOR/MINOR */
- result = misc_register(&fpgaloader_misc);
- if (result) {
- printk(KERN_ERR "%s:%u: misc_register failed %d\n",
- __func__, __LINE__, result);
- goto err_no_pdata;
- }
-
- dev_dbg(&pdev->dev, "%s:%u: registered misc device %d\n",
- __func__, __LINE__, fpgaloader_misc.minor);
-
- result = create_proc_entries();
- if( result < 0 )
- goto err_misc;
-
- sema_init(&fpga_sema, 1);
-
- /* initialize the current fpga descriptor with the one by default */
- g_current_desc = platform_info;
-
- return 0;
-
-err_misc:
- misc_deregister(&fpgaloader_misc);
-err_no_pdata:
- return result;
-}
-
-static int armadeus_fpga_remove(struct platform_device *pdev)
-{
- remove_proc_entry(FPGA_PROC_FILENAME, NULL);
- remove_proc_entry(FPGA_PROC_DIRNAME, NULL);
- misc_deregister(&fpgaloader_misc);
-
- return 0;
-}
-
-static struct platform_driver armadeus_fpga_driver = {
- .probe = armadeus_fpga_probe,
- .remove = armadeus_fpga_remove,
- .suspend = armadeus_fpga_suspend,
- .resume = armadeus_fpga_resume,
- .driver = {
- .name = DRIVER_NAME,
- },
-};
-
-static int __init armadeus_fpga_init(void)
-{
- printk(DRIVER_NAME " v" DRIVER_VERSION "\n");
-
- return platform_driver_register(&armadeus_fpga_driver);
-}
-
-static void __exit armadeus_fpga_exit(void)
-{
- platform_driver_unregister(&armadeus_fpga_driver);
-}
-
-module_init(armadeus_fpga_init);
-module_exit(armadeus_fpga_exit);
-
-MODULE_AUTHOR("Julien Boibessot / Nicolas Colombain");
-MODULE_DESCRIPTION("Armadeus FPGA loading driver");
-MODULE_LICENSE("GPL");
Copied: trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c (from rev 1127, trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c)
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.c 2009-03-08 16:17:25 UTC (rev 1128)
@@ -0,0 +1,324 @@
+/*
+ * Generic Xilinx FPGA loader
+ *
+ * Copyright (C) 2006-2009 Julien Boibessot <jul...@ar...>
+ * Nicolas Colombain <nic...@ar...>
+ * Armadeus Project / Armadeus systems
+ *
+ * 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+// #define DEBUG
+
+#include <linux/version.h>
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/fcntl.h>
+#include <linux/platform_device.h>
+#include <linux/miscdevice.h>
+#include <asm/uaccess.h>
+
+#include "xilinx-fpga-loader.h"
+
+
+#define DRIVER_VERSION "0.9"
+#define DRIVER_NAME "fpgaloader"
+#define FPGA_PROC_DIRNAME "driver/fpga"
+#define FPGA_PROC_FILENAME FPGA_PROC_DIRNAME "/loader"
+#define FPGA_IOCTL 0x10000000 /* !! TO BE BETTER DEFINED !! */
+
+/* global variables */
+struct fpga_desc *g_current_desc = NULL;
+struct semaphore fpga_sema;
+
+static unsigned char fpga_descriptor = 0; /* use default target_fpga_desc */
+module_param( fpga_descriptor, byte, 0 );
+
+#define FPGA_BUFFER_SIZE 4096
+static unsigned char g_buffer[FPGA_BUFFER_SIZE];
+static unsigned char g_nb_users = 0;
+
+
+/* Handles write() done on /dev/fpga/loader */
+static ssize_t armadeus_fpga_write(struct file *file, const char* pData, size_t count, loff_t *f_pos)
+{
+ ssize_t ret = 0;
+
+ /* Get exclusive access */
+ if (down_interruptible(&fpga_sema))
+ return -ERESTARTSYS;
+
+ if( count > FPGA_BUFFER_SIZE ) {
+ count = FPGA_BUFFER_SIZE;
+ }
+
+ /* Get value to write from user space */
+ ret = __copy_from_user( g_buffer, pData, count);
+ if (ret != 0) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ ret = fpga_load( g_current_desc, g_buffer, count );
+
+out:
+ /* Release exclusive access */
+ up(&fpga_sema);
+
+ return ret;
+}
+
+static int armadeus_fpga_open(struct inode *inode, struct file *file)
+{
+ int ret;
+
+ /* Get exclusive access */
+ if (down_interruptible(&fpga_sema))
+ return -ERESTARTSYS;
+
+ /* Only one access at a time is permitted */
+ if( g_nb_users > 0 )
+ return -EBUSY;
+
+ ret = fpga_init_load( g_current_desc );
+ if(!ret) {
+ printk("Starting FPGA download\n");
+ g_nb_users++;
+ }
+
+ pr_debug("Opening /dev/fpga/loader%d file, %d %d\n", MINOR(inode->i_rdev), fpga_descriptor, ret);
+
+ /* Release exclusive access */
+ up(&fpga_sema);
+
+ return ret;
+}
+
+static int armadeus_fpga_release(struct inode *inode, struct file *file)
+{
+ if( fpga_finish_load(g_current_desc) )
+ printk("Failed to load FPGA !\n");
+
+ pr_debug("Closing access to /dev/fpga/loader%d\n", MINOR(inode->i_rdev));
+
+ if( g_nb_users > 0 )
+ g_nb_users--;
+
+ return 0;
+}
+
+
+/* PROC file */
+static int procfile_fpga_read( char *buffer, __attribute__ ((unused)) char **start, off_t offset, int buffer_length, int *eof, __attribute__ ((unused)) void* data)
+{
+ int ret;
+
+ /* We give all of our information in one go, so if the user asks us if
+ we have more information the answer should always be no.
+ This is important because the standard read function from the
+ library would continue to issue the read system call until the
+ the kernel replies that it has no more information, or until
+ its buffer is filled */
+ if( offset > 0 ) {
+ /* we have finished to read, return 0 */
+ ret = 0;
+ } else {
+ ret = fpga_get_infos( g_current_desc, buffer );
+ }
+
+ return ret;
+}
+
+static int procfile_fpga_write( __attribute__ ((unused)) struct file *file, const char *buf, unsigned long count, void *data)
+{
+ return count;
+}
+
+/* Handling of IOCTL calls */
+int armadeus_fpga_ioctl( struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg )
+{
+ int err = 0; int ret = 0;
+ unsigned int minor;
+
+ /* PRINTF( DRIVER_NAME " ## IOCTL received: (0x%x) ##\n", cmd ); */
+ /* Extract the type and number bitfields, and don't decode wrong cmds:
+ return ENOTTY (inappropriate ioctl) before access_ok() */
+ if (_IOC_TYPE(cmd) != FPGA_IOCTL) return -ENOTTY;
+
+ /* The direction is a bitmask, and VERIFY_WRITE catches R/W transfers.
+ `Type' is user-oriented, while access_ok is kernel-oriented,
+ so the concept of "read" and "write" is reversed */
+ if (_IOC_DIR(cmd) & _IOC_READ)
+ err = !access_ok(VERIFY_WRITE, (void *)arg, _IOC_SIZE(cmd));
+ else if (_IOC_DIR(cmd) & _IOC_WRITE)
+ err = !access_ok(VERIFY_READ, (void *)arg, _IOC_SIZE(cmd));
+
+ if (err) return -EFAULT;
+
+ if (down_interruptible(&fpga_sema))
+ return -ERESTARTSYS;
+
+ /* Extract and test minor */
+ minor = MINOR(inode->i_rdev);
+/* if( minor > FPGA_MAX_MINOR ) {
+ printk("Minor outside range: %d !\n", minor);
+ return -EFAULT;
+ }*/
+
+ switch(cmd)
+ {
+ default:
+ return -ENOTTY;
+ break;
+ }
+
+ up(&fpga_sema);
+
+ return ret;
+}
+
+/* Create /proc entries for direct access to FPGA config */
+static int create_proc_entries( void )
+{
+ static struct proc_dir_entry *fpga_Proc_File;
+
+ /* Create main directory */
+ proc_mkdir(FPGA_PROC_DIRNAME, NULL);
+
+ /* Create proc file */
+ fpga_Proc_File = create_proc_entry( FPGA_PROC_FILENAME, S_IWUSR |S_IRUSR | S_IRGRP | S_IROTH, NULL );
+ if( fpga_Proc_File == NULL ) {
+ printk(DRIVER_NAME ": Could not register a" FPGA_PROC_FILENAME ". Terminating\n");
+ goto error;
+ } else {
+ fpga_Proc_File->read_proc = procfile_fpga_read;
+ fpga_Proc_File->write_proc = procfile_fpga_write;
+ }
+
+ return 0;
+error:
+ remove_proc_entry(FPGA_PROC_DIRNAME, NULL);
+ return -ENOMEM;
+}
+
+static struct file_operations fpga_fops = {
+ .owner = THIS_MODULE,
+ .write = armadeus_fpga_write,
+ /* .read = armadeus_fpga_read, Configuration saving not supported yet */
+ .open = armadeus_fpga_open,
+ .release = armadeus_fpga_release,
+ .ioctl = armadeus_fpga_ioctl,
+};
+
+#ifdef CONFIG_PM
+static int armadeus_fpga_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ return 0;
+}
+
+static int armadeus_fpga_resume(struct platform_device *pdev)
+{
+ return 0;
+}
+#else
+#define armadeus_fpga_suspend NULL
+#define armadeus_fpga_resume NULL
+#endif
+
+static struct miscdevice fpgaloader_misc = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = DRIVER_NAME,
+ .fops = &fpga_fops,
+};
+
+
+static int armadeus_fpga_probe(struct platform_device *pdev)
+{
+ int result;
+ struct device *dev = &pdev->dev;
+ struct fpga_desc *platform_info;
+
+ platform_info = dev->platform_data;
+ if (platform_info == NULL) {
+ dev_err(&pdev->dev, "probe - no platform data supplied\n");
+ result = -ENODEV;
+ goto err_no_pdata;
+ }
+
+ /* Register the driver through misc layer to get MAJOR/MINOR */
+ result = misc_register(&fpgaloader_misc);
+ if (result) {
+ printk(KERN_ERR "%s:%u: misc_register failed %d\n",
+ __func__, __LINE__, result);
+ goto err_no_pdata;
+ }
+
+ dev_dbg(&pdev->dev, "%s:%u: registered misc device %d\n",
+ __func__, __LINE__, fpgaloader_misc.minor);
+
+ result = create_proc_entries();
+ if( result < 0 )
+ goto err_misc;
+
+ sema_init(&fpga_sema, 1);
+
+ /* initialize the current fpga descriptor with the one by default */
+ g_current_desc = platform_info;
+
+ return 0;
+
+err_misc:
+ misc_deregister(&fpgaloader_misc);
+err_no_pdata:
+ return result;
+}
+
+static int armadeus_fpga_remove(struct platform_device *pdev)
+{
+ remove_proc_entry(FPGA_PROC_FILENAME, NULL);
+ remove_proc_entry(FPGA_PROC_DIRNAME, NULL);
+ misc_deregister(&fpgaloader_misc);
+
+ return 0;
+}
+
+static struct platform_driver armadeus_fpga_driver = {
+ .probe = armadeus_fpga_probe,
+ .remove = armadeus_fpga_remove,
+ .suspend = armadeus_fpga_suspend,
+ .resume = armadeus_fpga_resume,
+ .driver = {
+ .name = DRIVER_NAME,
+ },
+};
+
+static int __init armadeus_fpga_init(void)
+{
+ printk(DRIVER_NAME " v" DRIVER_VERSION "\n");
+
+ return platform_driver_register(&armadeus_fpga_driver);
+}
+
+static void __exit armadeus_fpga_exit(void)
+{
+ platform_driver_unregister(&armadeus_fpga_driver);
+}
+
+module_init(armadeus_fpga_init);
+module_exit(armadeus_fpga_exit);
+
+MODULE_AUTHOR("Julien Boibessot / Nicolas Colombain");
+MODULE_DESCRIPTION("Armadeus FPGA loading driver");
+MODULE_LICENSE("GPL");
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/fpga-loader.h 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,37 +0,0 @@
-/*
- ***********************************************************************
- *
- * (c) Copyright 2006 Armadeus project
- * Julien Boibessot <jul...@ar...>
- * Nicolas Colombain <nic...@ar...>
- * Generic Xilinx FPGA loader
- *
- * 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- **********************************************************************
- */
-
-#ifndef __FPGA_LOADER_H__
-#define __FPGA_LOADER_H__
-
-#define FPGA_PROC_DIRNAME "driver/fpga"
-#define FPGA_PROC_FILENAME FPGA_PROC_DIRNAME "/loader"
-
-// By default, we use dynamic allocation of major numbers
-#define FPGA_MAJOR 0
-#define FPGA_MAX_MINOR 254
-
-#define FPGA_IOCTL 0x10000000 // !! TO BE BETTER DEFINED !!
-
-#endif // __FPGA_LOADER_H__
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/fpgaloader.sh
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpgaloader.sh 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/fpgaloader.sh 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,11 +0,0 @@
-#!/bin/sh
-# Load FPGA main module
-modprobe fpgaloader fpga_descriptor=0
-
-FPGA_MAJOR=`cat /proc/devices | grep fpgaloader | cut -d " " -f 1`
-mkdir -p /dev/fpga
-
-# For general usage
-if [ ! -e /dev/fpga/fpgaloader ] ; then
- mknod /dev/fpga/fpgaloader c $FPGA_MAJOR 0
-fi
Copied: trunk/target/linux/modules/fpga/dev_tools/loader/fpgaloader.sh (from rev 1127, trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpgaloader.sh)
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/loader/fpgaloader.sh (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/fpgaloader.sh 2009-03-08 16:17:25 UTC (rev 1128)
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Load FPGA main module
+modprobe fpgaloader fpga_descriptor=0
+
+FPGA_MAJOR=`cat /proc/devices | grep fpgaloader | cut -d " " -f 1`
+mkdir -p /dev/fpga
+
+# For general usage
+if [ ! -e /dev/fpga/fpgaloader ] ; then
+ mknod /dev/fpga/fpgaloader c $FPGA_MAJOR 0
+fi
Deleted: trunk/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c 2009-03-08 16:17:25 UTC (rev 1128)
@@ -1,419 +0,0 @@
-/*
- * Xilinx FPGAs download support
- * Copyright (C) 2006-2009 Nicolas Colombain <nic...@ar...>
- * Armadeus Project / Armadeus systems
- *
- * Based on the (U-Boot) implementation of:
- * Rich Ireland, Enterasys Networks, rir...@en....
- * Keith Outwater, kei...@mv...
- *
- * 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 <asm/io.h>
-#include <linux/time.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-
-#include "xilinx-fpga-loader.h"
-
-#define CONFIG_FPGA_DELAY()
-#define CFG_FPGA_WAIT 20000 // uS
-
-size_t bytecount = 0; // total bytes received
-
-/*
- * Timeout function
- */
-static unsigned long get_timer(unsigned long initTime)
-{
- struct timeval tv;
- do_gettimeofday(&tv);
- if( tv.tv_usec > initTime ) // avoid overflow pb
- return tv.tv_usec - initTime;
- else
- return initTime - tv.tv_usec;
-}
-
-/*
- * dump the given descriptor infos
- */
-static int xilinx_dump_descriptor_info( struct fpga_desc *desc, char* buffer )
-{
- int len;
- len = sprintf( buffer, "%s %s\n",
- (desc->family == Xilinx_Spartan) ? "spartan":"unknown",
- (desc->iface == slave_serial) ? "slave serial":"slave parallel"
- );
- return len;
-}
-
-/**
- * program the FPGA (serial mode).
- * return 0 if success, >0 while programming, <0 if error detected
- */
-static size_t spartan_serial_load (struct fpga_desc *desc, const char* buf, size_t bsize)
-{
- Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
-
- if (fn) {
- int i;
- unsigned char val;
- size_t nbbyte = 0; /* init local counter */
-
- while (nbbyte < bsize) {
- /* Spartan signals an error if INIT goes low (active)
- while DONE is low (inactive) */
- if ((*fn->done)() == 0 && (*fn->init)()) {
- printk("** CRC error during FPGA load.\n");
- return -ETIMEDOUT;
- }
- val = buf[nbbyte ++];
- bytecount++;
- i = 8;
- do {
- /* Deassert the clock */
- (*fn->clk)(0);
- CONFIG_FPGA_DELAY();
- /* Write data */
- (*fn->wr)(val & 0x80);
- CONFIG_FPGA_DELAY();
- /* Assert the clock */
- (*fn->clk)(1);
- CONFIG_FPGA_DELAY();
- val <<= 1;
- i --;
- } while (i > 0);
- }
-
- if(bytecount%4096 == 0)
- printk(".");
-
- return bsize;
- }
- return -EINVAL;
-}
-
-/**
- * initialize the FPGA programming interface.
- * return 0 if success, <0 if error detected
- */
-static int spartan_serial_init (struct fpga_desc *desc)
-{
- Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
- if (fn) {
- unsigned long ts; /* timestamp */
-
- if(*fn->pre){
- (*fn->pre)(); //Run the pre configuration function if there is one.
- }
-
- /* Establish the initial state */
- (*fn->pgm)(1); /* Assert the program, commit */
-
- /* Wait for INIT state (init low) */
- ts = get_timer(0); /* get current time */
- do {
- CONFIG_FPGA_DELAY ();
- if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */
- PRINTF ("** Timeout waiting for INIT to start.\n");
- return -ETIMEDOUT;
- }
- } while (!(*fn->init)());
-
- /* Get ready for the burn */
- CONFIG_FPGA_DELAY ();
- (*fn->pgm)(0); /* Deassert the program, commit */
-
- ts = get_timer(0); /* get current time */
- /* Now wait for INIT to go high */
- do {
- CONFIG_FPGA_DELAY ();
- if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */
- PRINTF ("** Timeout waiting for INIT to clear.\n");
- return -ETIMEDOUT;
- }
- } while ((*fn->init)());
-
- bytecount = 0; /* reset byte count */
- return 0; /* success */
- }
- return -EINVAL;
-}
-
-/* terminate the FPGA load (serial mode) */
-static int spartan_serial_finish(struct fpga_desc *desc)
-{
- unsigned long timestamp;
- Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
-
- if (fn) {
- CONFIG_FPGA_DELAY ();
-
- /* now check for done signal */
- timestamp = get_timer(0); /* get current time */
- (*fn->wr)(1);
-
- while (! (*fn->done)()) {
- CONFIG_FPGA_DELAY ();
- (*fn->clk)(0); /* Deassert the clock pin */
- CONFIG_FPGA_DELAY ();
- (*fn->clk)(1); /* Assert the clock pin */
-
- if (get_timer(timestamp) > CFG_FPGA_WAIT) {
- pr_debug("** Timeout waiting for DONE.\n");
- return -ETIMEDOUT;
- }
- }
- }
- return 0;
-}
-
-
-/**
- * initialize the FPGA programming interface.
- * return 0 if success, <0 if error detected
- */
-static int spartan_parallel_init (struct fpga_desc *desc)
-{
- Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
- if (fn) {
- unsigned long ts; /* timestamp */
- /*
- * Run the pre configuration function if there is one.
- */
- if (*fn->pre) {
- (*fn->pre) ();
- }
- mdelay(100);
-
- /* Establish the initial state */
- (*fn->pgm) (1); /* Assert the program, commit */
- ts = get_timer (0); /* get current time */
- /* Now wait for INIT to go down */
- do {
- CONFIG_FPGA_DELAY ();
- if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */
- PRINTF ("** Timeout waiting for INIT to set.\n");
- (*fn->abort) (); /* abort the burn */
- return -ETIMEDOUT;
- }
- } while (!(*fn->init) () );
-
-
- /* Get ready for the burn */
- CONFIG_FPGA_DELAY ();
- (*fn->pgm) (0); /* Deassert the program, commit */
-
- ts = get_timer (0); /* get current time */
- /* Now wait for INIT and BUSY to go high */
- do {
- CONFIG_FPGA_DELAY ();
- if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */
- PRINTF ("** Timeout waiting for INIT to clear.\n");
- (*fn->abort) (); /* abort the burn */
- return -ETIMEDOUT;
- }
- } while ((*fn->init) ());
- (*fn->wr) (1); /* Assert write, commit */
- (*fn->cs) (1); /* Assert chip select, commit */
- (*fn->clk) (1); /* Assert the clock pin */
- bytecount = 0; // reset byte count
- }
- return 0;
-}
-
-/**
- * program the FPGA (parallel mode).
- * return 0 if success, >0 while programming, <0 if error detected
- */
-static size_t spartan_parallel_load (struct fpga_desc *desc, const char* buf, size_t bsize)
-{
- unsigned long flags;
- Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
-
- if (fn) {
- /* Load the data */
- size_t nbbyte = 0; // init local counter
-
- raw_local_irq_save(flags);
-
- while (nbbyte < bsize) {
- (*fn->clk) (1); /* Assert the clock pin */
- CONFIG_FPGA_DELAY ();
- (*fn->wdata) (buf[nbbyte++]); /* write the data */
- CONFIG_FPGA_DELAY ();
- (*fn->clk) (0); /* Deassert the clock pin */
- bytecount++;
- }
- raw_local_irq_restore(flags);
-
- return bsize;
- }
- return -EINVAL;
-}
-
-/* terminate the FPGA load (parallel mode) */
-static int spartan_parallel_finish(struct fpga_desc *desc)
-{
- Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
- unsigned long timestamp;
-
- if (fn) {
- /* now check for done signal */
- timestamp = get_timer(0); /* get current time */
- while (!(*fn->done) ()) {
- CONFIG_FPGA_DELAY ();
- (*fn->clk) (0); /* Deassert the clock pin */
- CONFIG_FPGA_DELAY ();
- (*fn->clk) (1); /* Assert the clock pin */
-
- if (get_timer(timestamp) > CFG_FPGA_WAIT) {
- printk("** Timeout waiting for DONE to clear. %d \n", bytecount);
- (*fn->abort) (); /* abort the burn */
- return -ETIMEDOUT;
- }
- }
- /* Spartan signals an error if INIT goes low (active) */
- if (!(*fn->init)()) {
- printk("** CRC error during FPGA load.\n");
- (*fn->abort) (); /* abort the burn */
- return -ETIMEDOUT;
- }
-
- (*fn->cs) (0); /* Deassert the chip select */
- (*fn->wr) (0); /* Deassert the write pin */
- }
-
- return 0;
-}
-
-/**
- * program the FPGA.
- * return 0 if success, >0 while programming, <0 if error detected
- */
-size_t xilinx_load( struct fpga_desc *desc, const char *buf, size_t bsize )
-{
- int ret = 0;
-
- if( desc ) {
- switch( desc->family ) /* check family */
- {
- case Xilinx_Spartan:
- {
- switch( desc->iface ) /* check donwload hardware interface */
- {
- case slave_serial: ret = spartan_serial_load( desc, buf, bsize ); break;
- case slave_parallel: ret = spartan_parallel_load (desc, buf, bsize); break;
- default: PRINTF("interface not supported!\n"); ret = -ENOSYS; break;
- }
- }
- break;
- default: PRINTF("family not supported!\n"); ret = -ENOSYS; break;
- }
- }
- else {
- PRINTF("invalid FPGA descriptor!\n");
- ret = -EINVAL;
- }
- return ret;
-}
-
-/**
- * initialize the FPGA programming interface.
- * return 0 if success, <0 if error detected
- */
-int xilinx_init_load( struct fpga_desc *desc )
-{
- int ret = 0;
-
- if( desc ) {
- switch( desc->family ) // check family
- {
- case Xilinx_Spartan:
- {
- switch( desc->iface ) // check donwload hardware interface
- {
- case slave_serial: ret = spartan_serial_init( desc ); break;
- case slave_parallel: ret = spartan_parallel_init( desc ); break;
- default: PRINTF("interface not supported!\n"); ret = -ENOSYS; break;
- }
- }
- break;
- default: PRINTF("family not supported!\n"); ret = -ENOSYS; break;
- }
- }
- else {
- PRINTF("invalid FPGA descriptor!\n");
- ret = -EINVAL;
- }
- return ret;
-}
-
-int xilinx_finish_load( struct fpga_desc *desc )
-{
- int ret = 0;
-
- if( desc ) {
- switch( desc->family )
- {
- case Xilinx_Spartan:
- {
- switch( desc->iface ) /* check donwload hardware interface */
- {
- case slave_serial:
- ret = spartan_serial_finish( desc );
- break;
- case slave_parallel:
- ret = spartan_parallel_finish( desc );
- break;
- default:
- PRINTF("interface not supported!\n");
- ret = -ENOSYS;
- break;
- }
- }
- break;
- default:
- PRINTF("family not supported!\n");
- ret = -ENOSYS;
- break;
- }
- } else {
- PRINTF("invalid FPGA descriptor!\n");
- ret = -EINVAL;
- }
-
- return ret;
-}
-
-/**
- * get some infos about FPGA download
- */
-int fpga_get_infos( struct fpga_desc *desc, char* buffer )
-{
- int len = 0;
-
- if( desc ) {
- len = xilinx_dump_descriptor_info( desc, buffer );
- }
-
- return len;
-}
Copied: trunk/target/linux/modules/fpga/dev_tools/loader/xilinx-fpga-loader.c (from rev 1127, trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx...
[truncated message content] |