armadeus-commitlog Mailing List for armadeus (Page 129)
Brought to you by:
sszy
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(43) |
Feb
(8) |
Mar
(7) |
Apr
(8) |
May
(14) |
Jun
(6) |
Jul
(4) |
Aug
(17) |
Sep
(18) |
Oct
(19) |
Nov
(52) |
Dec
(30) |
| 2008 |
Jan
(6) |
Feb
(6) |
Mar
(15) |
Apr
(22) |
May
(13) |
Jun
(11) |
Jul
(41) |
Aug
(10) |
Sep
(14) |
Oct
(21) |
Nov
(4) |
Dec
(66) |
| 2009 |
Jan
(67) |
Feb
(57) |
Mar
(90) |
Apr
(54) |
May
(64) |
Jun
(76) |
Jul
(14) |
Aug
(18) |
Sep
(18) |
Oct
(20) |
Nov
(15) |
Dec
(36) |
| 2010 |
Jan
(28) |
Feb
(25) |
Mar
(32) |
Apr
(23) |
May
(22) |
Jun
(62) |
Jul
(36) |
Aug
(16) |
Sep
(12) |
Oct
(20) |
Nov
(44) |
Dec
(25) |
| 2011 |
Jan
(36) |
Feb
(49) |
Mar
(28) |
Apr
(38) |
May
(26) |
Jun
(52) |
Jul
(33) |
Aug
(32) |
Sep
(19) |
Oct
(26) |
Nov
(13) |
Dec
(32) |
| 2012 |
Jan
(38) |
Feb
(34) |
Mar
(91) |
Apr
(35) |
May
(31) |
Jun
(72) |
Jul
(23) |
Aug
(13) |
Sep
(33) |
Oct
(47) |
Nov
(18) |
Dec
(22) |
| 2013 |
Jan
(31) |
Feb
(22) |
Mar
(26) |
Apr
(11) |
May
(38) |
Jun
(15) |
Jul
(37) |
Aug
(68) |
Sep
(34) |
Oct
(11) |
Nov
(26) |
Dec
(31) |
| 2014 |
Jan
(60) |
Feb
(55) |
Mar
(21) |
Apr
(31) |
May
(17) |
Jun
(35) |
Jul
(24) |
Aug
(17) |
Sep
(11) |
Oct
(23) |
Nov
(10) |
Dec
(23) |
| 2015 |
Jan
(15) |
Feb
(34) |
Mar
(46) |
Apr
(23) |
May
(12) |
Jun
(14) |
Jul
(18) |
Aug
(22) |
Sep
(6) |
Oct
(2) |
Nov
(1) |
Dec
(6) |
| 2016 |
Jan
(5) |
Feb
(7) |
Mar
(10) |
Apr
(10) |
May
(17) |
Jun
(6) |
Jul
(4) |
Aug
(6) |
Sep
(22) |
Oct
(8) |
Nov
(9) |
Dec
(5) |
| 2017 |
Jan
(11) |
Feb
(12) |
Mar
(27) |
Apr
(9) |
May
(1) |
Jun
(5) |
Jul
(11) |
Aug
(10) |
Sep
(6) |
Oct
(10) |
Nov
(4) |
Dec
(6) |
| 2018 |
Jan
(6) |
Feb
(13) |
Mar
(9) |
Apr
(7) |
May
(10) |
Jun
(9) |
Jul
(21) |
Aug
(13) |
Sep
(10) |
Oct
(4) |
Nov
(6) |
Dec
(1) |
| 2019 |
Jan
(6) |
Feb
(2) |
Mar
(5) |
Apr
(6) |
May
(19) |
Jun
(14) |
Jul
(18) |
Aug
(3) |
Sep
(5) |
Oct
(7) |
Nov
(8) |
Dec
(4) |
| 2020 |
Jan
(10) |
Feb
(3) |
Mar
(9) |
Apr
(7) |
May
(2) |
Jun
(18) |
Jul
(3) |
Aug
|
Sep
|
Oct
(7) |
Nov
|
Dec
(1) |
| 2021 |
Jan
(9) |
Feb
(6) |
Mar
(4) |
Apr
(11) |
May
(7) |
Jun
(5) |
Jul
(2) |
Aug
(4) |
Sep
(10) |
Oct
(9) |
Nov
(5) |
Dec
|
| 2022 |
Jan
(2) |
Feb
(12) |
Mar
(3) |
Apr
(5) |
May
(1) |
Jun
(3) |
Jul
(2) |
Aug
(1) |
Sep
(4) |
Oct
(4) |
Nov
(1) |
Dec
(3) |
| 2023 |
Jan
(5) |
Feb
(3) |
Mar
(3) |
Apr
(2) |
May
(1) |
Jun
(3) |
Jul
(3) |
Aug
(2) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
(4) |
| 2024 |
Jan
(2) |
Feb
(3) |
Mar
(8) |
Apr
(4) |
May
(1) |
Jun
(13) |
Jul
(7) |
Aug
(1) |
Sep
(6) |
Oct
(5) |
Nov
(11) |
Dec
(7) |
| 2025 |
Jan
(3) |
Feb
(1) |
Mar
(6) |
Apr
(4) |
May
(4) |
Jun
(1) |
Jul
(1) |
Aug
(7) |
Sep
(4) |
Oct
(4) |
Nov
(4) |
Dec
(1) |
| 2026 |
Jan
(3) |
Feb
(7) |
Mar
(3) |
Apr
(1) |
May
(6) |
Jun
(3) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <Fa...@us...> - 2009-03-09 10:32:51
|
Revision: 1131
http://armadeus.svn.sourceforge.net/armadeus/?rev=1131&view=rev
Author: FabM
Date: 2009-03-09 10:32:47 +0000 (Mon, 09 Mar 2009)
Log Message:
-----------
[LINUX] Updating test programs for led and button in wishbone_example
Modified Paths:
--------------
trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c
trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c
Added Paths:
-----------
trunk/target/linux/modules/fpga/wishbone_example/push-led.c
Added: trunk/target/linux/modules/fpga/wishbone_example/push-led.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/push-led.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/push-led.c 2009-03-09 10:32:47 UTC (rev 1131)
@@ -0,0 +1,103 @@
+/* Enable or disable led when button is pressed
+ * Fabien Marteau <fab...@ar...>
+ * 9 mars 2009
+ * fpgaaccess.h
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ *
+ * A simple driver for reading and writing on
+ * fpga throught a character file /dev/fpgaaccess
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+/* file management */
+#include <sys/stat.h>
+#include <fcntl.h>
+
+/* as name said */
+#include <signal.h>
+
+/* sleep */
+#include <unistd.h>
+
+int fbutton;
+int fled;
+
+void quit(int pouet){
+ close(fbutton);
+ close(fled);
+ exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned short i,j;
+
+ /* quit when Ctrl-C pressed */
+ signal(SIGINT, quit);
+
+ j=0;
+
+ printf( "Blink a led pushing button\n" );
+
+ if(argc < 3){
+ perror("invalid arguments number\npush-led <button_filename> <led_filename>\n");
+ exit(EXIT_FAILURE);
+ }
+
+ fbutton=open(argv[1],O_RDWR);
+ if(fbutton<0){
+ perror("can't open button file\n");
+ exit(EXIT_FAILURE);
+ }
+
+ while(1){
+
+ /* read button value */
+ if(read(fbutton,&j,1)<0){
+ perror("read error\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(lseek(fbutton,0,SEEK_SET)<0){
+ perror("lseek error\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* write led value */
+ fled=open(argv[2],O_RDWR);
+ if(fbutton<0){
+ perror("can't open led file\n");
+ exit(EXIT_FAILURE);
+ }
+
+ if(write(fled,&j,2)<=0){
+ perror("LED write error\n");
+ exit(EXIT_FAILURE);
+ }
+ close(fled);
+ }
+
+ close(fbutton);
+ close(fled);
+ exit(0);
+}
+
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c 2009-03-09 09:52:44 UTC (rev 1130)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c 2009-03-09 10:32:47 UTC (rev 1131)
@@ -1,4 +1,4 @@
-/* a program to write/read values on fpga address map
+/* a program to test button driver
* Fabien Marteau <fab...@ar...>
* 7 april 2008
* fpgaaccess.h
@@ -38,10 +38,10 @@
/* sleep */
#include <unistd.h>
-int fled;
+int fbutton;
void quit(int pouet){
- close(fled);
+ close(fbutton);
exit(0);
}
@@ -57,12 +57,12 @@
printf( "Testing button driver\n" );
if(argc < 2){
- perror("invalide arguments number\ntestled <button_filename>\n");
+ perror("invalide arguments number\ntestbutton <button_filename>\n");
exit(EXIT_FAILURE);
}
- fled=open(argv[1],O_RDWR);
- if(fled<0){
+ fbutton=open(argv[1],O_RDWR);
+ if(fbutton<0){
perror("can't open file\n");
exit(EXIT_FAILURE);
}
@@ -72,19 +72,19 @@
fflush(stdout);
/* read value */
- if(read(fled,&j,1)<0){
+ if(read(fbutton,&j,1)<0){
perror("read error\n");
exit(EXIT_FAILURE);
}
printf("Read %d\n",j);
- if(lseek(fled,0,SEEK_SET)<0){
+ if(lseek(fbutton,0,SEEK_SET)<0){
perror("lseek error\n");
exit(EXIT_FAILURE);
}
}
- close(fled);
+ close(fbutton);
exit(0);
}
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c 2009-03-09 09:52:44 UTC (rev 1130)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c 2009-03-09 10:32:47 UTC (rev 1131)
@@ -1,4 +1,4 @@
-/* a program to write/read values on fpga address map
+/* a program to test led driver
* Fabien Marteau <fab...@ar...>
* 7 april 2008
* fpgaaccess.h
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <th...@us...> - 2009-03-09 09:52:46
|
Revision: 1130
http://armadeus.svn.sourceforge.net/armadeus/?rev=1130&view=rev
Author: thom25
Date: 2009-03-09 09:52:44 +0000 (Mon, 09 Mar 2009)
Log Message:
-----------
[U-BOOT] make "skipping bad block" messages quiet per default
Modified Paths:
--------------
trunk/buildroot/target/device/armadeus/apf27/apf27.h
Modified: trunk/buildroot/target/device/armadeus/apf27/apf27.h
===================================================================
--- trunk/buildroot/target/device/armadeus/apf27/apf27.h 2009-03-08 16:19:09 UTC (rev 1129)
+++ trunk/buildroot/target/device/armadeus/apf27/apf27.h 2009-03-09 09:52:44 UTC (rev 1130)
@@ -145,6 +145,7 @@
"ntpserverip=217.147.208.1\0" \
"mmcroot=/dev/mmcblk0p1\0" \
"mmcrootfstype=ext2\0" \
+ "quiet=1\0" \
"addnfsargs=setenv bootargs ${bootargs} " \
"root=/dev/nfs rw nfsroot=${serverip}:${rootpath}\0" \
"addjffsargs=setenv bootargs ${bootargs} " \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-08 16:19:18
|
Revision: 1129
http://armadeus.svn.sourceforge.net/armadeus/?rev=1129&view=rev
Author: artemys
Date: 2009-03-08 16:19:09 +0000 (Sun, 08 Mar 2009)
Log Message:
-----------
[LINUX] cleanup a little GPIO driver (makes some debug messages silents and removes unneeded loadfpga files)
Modified Paths:
--------------
trunk/target/linux/modules/gpio/core.c
Removed Paths:
-------------
trunk/target/linux/modules/gpio/loadfpga.c
trunk/target/linux/modules/gpio/loadfpga.h
Modified: trunk/target/linux/modules/gpio/core.c
===================================================================
--- trunk/target/linux/modules/gpio/core.c 2009-03-08 16:17:25 UTC (rev 1128)
+++ trunk/target/linux/modules/gpio/core.c 2009-03-08 16:19:09 UTC (rev 1129)
@@ -345,10 +345,10 @@
minor = MINOR(file->f_dentry->d_inode->i_rdev);
- printk("- %s %d byte(s) on minor %d -> %s pin %d\n", __FUNCTION__, count, minor, port_name[gpio->port], gpio->number);
+ pr_debug("- %s %d byte(s) on minor %d -> %s pin %d\n", __FUNCTION__, count, minor, port_name[gpio->port], gpio->number);
- if (down_interruptible(&gpio_sema)) /* Usefull ?? */
- return -ERESTARTSYS;
+ if (down_interruptible(&gpio_sema)) /* Usefull ?? */
+ return -ERESTARTSYS;
count = min(count, (size_t)4);
if (copy_from_user(&value, data, count)) {
@@ -357,11 +357,11 @@
}
if( gpio->nb_pins != 1) {
- printk("Full port write: 0x%x\n", value);
+ pr_debug("Full port write: 0x%x\n", value);
writeOnPort( gpio->port, value );
} else {
value = value ? 1 : 0;
- printk("Single pin write: %d\n", value);
+ pr_debug("Single pin write: %d\n", value);
imx_gpio_set_value( minor, value );
}
ret = count;
@@ -387,7 +387,7 @@
spin_lock_irq(&gpio->lock);
- printk("- %s %d byte(s) on minor %d -> %s pin %d\n", __FUNCTION__, count, minor, port_name[gpio->port], gpio->number);
+ pr_debug("- %s %d byte(s) on minor %d -> %s pin %d\n", __FUNCTION__, count, minor, port_name[gpio->port], gpio->number);
while (!gpio->changed) {
spin_unlock_irq(&gpio->lock);
@@ -404,10 +404,10 @@
if( gpio->nb_pins != 1) {
value = readFromPort( gpio->port );
- printk("Full port read: 0x%x\n", value);
+ pr_debug("Full port read: 0x%x\n", value);
} else {
value = imx_gpio_get_value( minor );
- printk("Single pin read: %d\n", value);
+ pr_debug("Single pin read: %d\n", value);
}
value = readFromPort( minor );
@@ -511,9 +511,9 @@
}
success:
- printk("Opening /dev/gpio%d/%d file port:%d pin:%d\n", major, minor, gpio->port, gpio->number);
+ printk("Opening /dev/gpio%d/%d file port:%d pin:%d\n", major, minor, gpio->port, gpio->number);
gpio->initialized = 1;
- return 0;
+ return 0;
err_irq:
printk("%s error while requesting irq %d\n", __FUNCTION__, irq);
Deleted: trunk/target/linux/modules/gpio/loadfpga.c
===================================================================
--- trunk/target/linux/modules/gpio/loadfpga.c 2009-03-08 16:17:25 UTC (rev 1128)
+++ trunk/target/linux/modules/gpio/loadfpga.c 2009-03-08 16:19:09 UTC (rev 1129)
@@ -1,320 +0,0 @@
-/*
- **********************************************************************
- * 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 "loadfpga.h"
-#include <asm/arch/imx-regs.h>
-
-struct fpga_operations *driver_ops;
-static int fpga_major = FPGA_MAJOR;
-
-//static unsigned long init_map;
-struct semaphore fpga_sema;
-/* global variables */
-
-static unsigned long gParameters[4] = { 0, 0, 0, 0 };
-static int argc_argv;
-//static unsigned char port = PORT_A;
-module_param_array( gParameters, ulong, &argc_argv, 0 );
-
-#define FPGA_BUFFER_SIZE 4096
-static unsigned char gBuffer[FPGA_BUFFER_SIZE];
-static unsigned char gNbOfUsers = 0;
-
-void __exit armadeus_fpga_cleanup(void);
-
-
-//------------------------------------------------
-//
-// Low level functions
-//
-static void initializePorts( void )
-{
- // Ask GPIO driver to configure ports needed by this driver
- // TBDNICO
-}
-
-
-//------------------------------------------------
-//
-// Handles write() done on /dev/fpgaxx
-//
-static ssize_t armadeus_fpga_write(struct file *file, const char* pData, size_t count, loff_t *f_pos)
-{
- unsigned int minor;
- ssize_t ret = 0;
-
- minor = MINOR(file->f_dentry->d_inode->i_rdev);
- printk("armadeus_fpga_write() on minor %d\n", minor);
-
- if( f_pos != &file->f_pos) {
- ret = -ESPIPE;
- goto out;
- }
- // Get exclusive access
- if (down_interruptible(&fpga_sema))
- return -ERESTARTSYS;
-
- if( count > FPGA_BUFFER_SIZE ) {
- count = FPGA_BUFFER_SIZE;
- printk("Buffer truncated while writing data on fpga: %d -> %d\n", count, FPGA_BUFFER_SIZE);
- }
- // Get value to write from user space
- ret = __copy_from_user( gBuffer, pData, count);
- if (ret != 0) {
- //ret = -EFAULT;
- goto out;
- }
-
- // Copy data to fpga
- // TBD NICO
-
- *f_pos += count;
- ret = count;
-
-out:
- // Release exclusive access
- up(&fpga_sema);
-
- return( ret );
-}
-
-//
-// Handles read() done on /dev/fpgaxx
-//
-// static ssize_t armadeus_fpga_read(struct file *file, char *buf, size_t count, loff_t *ppos)
-// {
-// NOT SUPPORTED
-// }
-
-
-static int armadeus_fpga_open(struct inode *inode, struct file *file)
-{
- unsigned minor = MINOR(inode->i_rdev);
-
-// if( minor != MINOR_BYTE && minor !=MINOR_FULL && minor !=MINOR_LED )
-// return( -EINVAL );
-
- // Only one access at a time is permitted
- if( gNbOfUsers > 0 )
- return( -EBUSY );
-
- gNbOfUsers++;
-
- printk("Opening /dev/fpga%d file\n", minor);
- return 0;
-}
-
-static int armadeus_fpga_release(struct inode *inode, struct file *file)
-{
- unsigned minor = MINOR(inode->i_rdev);
-
- printk("Closing access to /dev/fpga%d\n", minor);
- 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 len; /* The number of bytes actually used */
-
- // 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 kernel replies that it has no more information, or until its buffer is filled.
-
- if( (offset > 0) || (buffer_length < /*MIN_SIZE_OF_PROC*/32) )
- {
- return 0;
- }
-
- if (down_interruptible(&fpga_sema))
- return -ERESTARTSYS;
-
- // Get the status of the fpga TBDNICO
-
- // Put status to given buffer
- len = sprintf(buffer, "Ben j'ai trop rien à dire là mais bon ça changera surement :-) !\n");
-
- //*start = buffer;
- *eof = 1;
-
- up(&fpga_sema);
-
- // Return the length
- return len;
-}
-
-
-static int procfile_fpga_write( __attribute__ ((unused)) struct file *file, const char *buf, unsigned long count, void *data)
-{
- int len = 0;
-
- // Do some checks on parameters
- // Get datas to write from user space
-
- printk( "Not supported !\n" );
-
- return len;
-}
-
-//------------------------------------------------
-// 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;
-
- //printk(" ## 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;
-
- minor = MINOR(inode->i_rdev);
- if( minor > FPGA_MAX_MINOR ) {
- printk("Minor outside range: %d !\n", minor);
- return -EFAULT;
- }
-
- // Handle IOCTL command
- switch(cmd)
- {
- /*case PPCLAIM:
- case PPRELEASE:
- break;
- case PPFCONTROL: // Normally not usefull in ur cas because we will ask LCD4LINUX to generate control signals with Data ports
- ret = __get_user(value, (unsigned char *)arg);
- Write ctrl infos on assigned ctrl gpiolines how ???
- printk("/FROB 0x%x/ ", value);
- break;*/
-
- default:
- return -ENOTTY;
- break;
-
- }
-
- up(&fpga_sema);
-
- return ret;
-}
-
-//
-// Create /proc entries for direct access (with echo/cat) to GPIOs config
-//
-static int createProcEntries( void )
-{
- static struct proc_dir_entry *fpga_Proc_File;
- //
- printk("Creating /proc entries: ");
- // Create main directory
- proc_mkdir(FPGA_PROC_DIRNAME, NULL);
- // Create proc file to handle GPIO values
- fpga_Proc_File = create_proc_entry( FPGA_PROC_FILENAME, S_IWUSR |S_IRUSR | S_IRGRP | S_IROTH, NULL );
-
- if( fpga_Proc_File == NULL )
- {
- printk(FPGA_DRIVER_NAME ": Could not register a" FPGA_PROC_FILENAME ". Terminating\n");
- armadeus_fpga_cleanup();
- return -ENOMEM;
- }
- else
- {
- fpga_Proc_File->read_proc = procfile_fpga_read;
- fpga_Proc_File->write_proc = procfile_fpga_write;
- }
-
- printk("OK!\n");
- return(0);
-}
-
-static struct file_operations fpga_fops = {
- .owner = THIS_MODULE,
- .write = armadeus_fpga_write,
-// .read = armadeus_fpga_read,
- .open = armadeus_fpga_open,
- .release = armadeus_fpga_release,
- .ioctl = armadeus_fpga_ioctl,
-};
-
-//
-// Module's initialization function
-//
-int __init armadeus_fpga_init(void)
-{
- static int result;
-
- printk("Initializing Armadeus fpga driver\n");
- //printk("Parameters received: %x %x %x %x\n", port_masks[0], port_masks[1], port_masks[2], port_masks[3] );
-
- // Configure HW ports/GPIOs with default values or given parameters
- initializePorts();
-
- // Register the driver by getting a major number
- result = register_chrdev(fpga_major, FPGA_DRIVER_NAME, &fpga_fops);
- if (result < 0)
- {
- printk(KERN_WARNING FPGA_DRIVER_NAME ": can't get major %d\n", fpga_major);
- return result;
- }
- if( fpga_major == 0 ) fpga_major = result; // dynamic Major allocation
-
- // Creating /proc entries
- result = createProcEntries();
- if( result < 0 ) return( result );
-
- printk(FPGA_DRIVER_NAME " module " FPGA_DRIVER_VERSION " successfully loaded !\n");
- return(0);
-}
-
-//
-// Module's cleanup function
-//
-void __exit armadeus_fpga_cleanup(void)
-{
- printk("Removing " FPGA_DRIVER_NAME " module: ");
-
- // Remove /proc entries
- remove_proc_entry(FPGA_PROC_FILENAME, NULL);
- // De-register /dev interface
- unregister_chrdev(fpga_major, FPGA_DRIVER_NAME);
-
- printk("Ok !\n ");
-}
-
-//------------------------------------------------
-
-module_init(armadeus_fpga_init);
-module_exit(armadeus_fpga_cleanup);
-
-MODULE_AUTHOR("JB / NC");
-MODULE_DESCRIPTION("Armadeus fpga's loading driver");
-MODULE_LICENSE("GPL");
Deleted: trunk/target/linux/modules/gpio/loadfpga.h
===================================================================
--- trunk/target/linux/modules/gpio/loadfpga.h 2009-03-08 16:17:25 UTC (rev 1128)
+++ trunk/target/linux/modules/gpio/loadfpga.h 2009-03-08 16:19:09 UTC (rev 1129)
@@ -1,68 +0,0 @@
-/*
- **********************************************************************
- * 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.
- **********************************************************************
-
- (c) Copyright 2005 Armadeus project
-
-*/
-
-#ifndef __FPGA_GPIO_H__
-#define __FPGA_GPIO_H__
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/errno.h>
-#include <linux/types.h>
-#include <linux/proc_fs.h>
-#include <linux/init.h>
-#include <linux/fs.h>
-#include <linux/fcntl.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-
-
-#define FPGA_PROC_DIRNAME "driver/fpga"
-#define FPGA_PROC_FILENAME FPGA_PROC_DIRNAME "spartan"
-
-#define FPGA_DRIVER_VERSION "v0.0.1"
-#define FPGA_DRIVER_NAME "Armadeus fpga"
-
-// By default, we use dynamic allocation of major numbers
-#define FPGA_MAJOR 0
-#define FPGA_MAX_MINOR 254
-
-/* minor numbers used*/
-#define GPIO_MAX_MINOR 4
-
-// Read/write bitmask that determines input/output pins (1 means output, 0 input)
-#define GPIORDDIRECTION _IOR(PP_IOCTL, 0xF0, int)
-#define GPIOWRDIRECTION _IOW(PP_IOCTL, 0xF1, int)
-
-// Read/write data
-#define GPIORDDATA _IOR(PP_IOCTL, 0xF2, int)
-#define GPIOWRDATA _IOW(PP_IOCTL, 0xF3, int)
-
-#define MAX_NUMBER_OF_PINS 32
-#define TEMPERATURE_BUFFER_SIZE 256
-#define VOLTAGE_BUFFER_SIZE 512
-
-
-#define FPGA_IOCTL 0x12345678 // !! TO BE BETTER DEFINED !!
-
-#endif // __FPGA_GPIO_H__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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] |
|
From: <th...@us...> - 2009-03-08 16:13:27
|
Revision: 1127
http://armadeus.svn.sourceforge.net/armadeus/?rev=1127&view=rev
Author: thom25
Date: 2009-03-08 16:13:12 +0000 (Sun, 08 Mar 2009)
Log Message:
-----------
[LINUX] add kconfig and makefile for ad9889
Modified Paths:
--------------
trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch
Modified: trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch
===================================================================
--- trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch 2009-03-08 15:45:46 UTC (rev 1126)
+++ trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch 2009-03-08 16:13:12 UTC (rev 1127)
@@ -448,3 +448,32 @@
+
+
+#endif /* __LINUX_VIDE0_AD9889_H */
+--- linux-2.6.27.13.orig/drivers/media/video/Makefile 2009-03-08 15:26:08.000000000 +0100
++++ linux-2.6.27.13/drivers/media/video/Makefile 2009-03-07 19:02:17.000000000 +0100
+@@ -46,6 +46,7 @@ obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o
+ obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
+ obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
+ obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o
++obj-$(CONFIG_VIDEO_AD9889) += ad9889.o
+ obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o
+ obj-$(CONFIG_VIDEO_ADV7175) += adv7175.o
+ obj-$(CONFIG_VIDEO_VPX3220) += vpx3220.o
+--- linux-2.6.27.13.orig/drivers/media/video/Kconfig 2009-03-08 15:26:08.000000000 +0100
++++ linux-2.6.27.13.orig/drivers/media/video/Kconfig 2009-03-07 19:02:02.000000000 +0100
+@@ -407,6 +407,16 @@ config VIDEO_SAA7185
+ To compile this driver as a module, choose M here: the
+ module will be called saa7185.
+
++config VIDEO_AD9889
++ tristate "Analog Devices AD9889 digital video encoders"
++ depends on VIDEO_V4L2 && I2C
++ ---help---
++ Support for the Analog Devices AD9889 digital video encoders.
++
++ To compile this driver as a module, choose M here: the
++ module will be called ad9889.
++
++
+ config VIDEO_ADV7170
+ tristate "Analog Devices ADV7170 video encoder"
+ depends on VIDEO_V4L1 && I2C
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-08 15:45:51
|
Revision: 1126
http://armadeus.svn.sourceforge.net/armadeus/?rev=1126&view=rev
Author: artemys
Date: 2009-03-08 15:45:46 +0000 (Sun, 08 Mar 2009)
Log Message:
-----------
[LINUX] fpgaloader driver cleanup (pass2)
Modified Paths:
--------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h
Removed Paths:
-------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-08 15:40:50 UTC (rev 1125)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-08 15:45:46 UTC (rev 1126)
@@ -65,9 +65,9 @@
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;
+ fpga_addr = ioremap( FPGA_BASE_ADDR, 16);
+ if( fpga_addr == NULL )
+ return 0;
return 1;
}
@@ -140,7 +140,7 @@
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);
+ iounmap(fpga_addr);
return 1;
}
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-08 15:40:50 UTC (rev 1125)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-08 15:45:46 UTC (rev 1126)
@@ -30,12 +30,14 @@
#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"
+#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;
@@ -69,7 +71,7 @@
goto out;
}
- ret = xilinx_load( g_current_desc, g_buffer, count );
+ ret = fpga_load( g_current_desc, g_buffer, count );
out:
/* Release exclusive access */
@@ -90,7 +92,7 @@
if( g_nb_users > 0 )
return -EBUSY;
- ret = xilinx_init_load( g_current_desc );
+ ret = fpga_init_load( g_current_desc );
if(!ret) {
printk("Starting FPGA download\n");
g_nb_users++;
@@ -106,7 +108,7 @@
static int armadeus_fpga_release(struct inode *inode, struct file *file)
{
- if( xilinx_finish_load(g_current_desc) )
+ 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));
@@ -170,10 +172,10 @@
/* Extract and test minor */
minor = MINOR(inode->i_rdev);
- if( minor > FPGA_MAX_MINOR ) {
+/* if( minor > FPGA_MAX_MINOR ) {
printk("Minor outside range: %d !\n", minor);
return -EFAULT;
- }
+ }*/
switch(cmd)
{
Deleted: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h 2009-03-08 15:40:50 UTC (rev 1125)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h 2009-03-08 15:45:46 UTC (rev 1126)
@@ -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__
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c 2009-03-08 15:40:50 UTC (rev 1125)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c 2009-03-08 15:45:46 UTC (rev 1126)
@@ -34,27 +34,25 @@
#include "xilinx-fpga-loader.h"
+
#define CONFIG_FPGA_DELAY()
-#define CFG_FPGA_WAIT 20000 // uS
+#define CFG_FPGA_WAIT 20000 /* uS */
-size_t bytecount = 0; // total bytes received
+size_t bytecount = 0; /* total bytes received */
-/*
- * Timeout function
- */
+
+/* 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;
+ 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
- */
+/* dump the given descriptor infos */
static int xilinx_dump_descriptor_info( struct fpga_desc *desc, char* buffer )
{
int len;
@@ -66,9 +64,9 @@
}
/**
- * program the FPGA (serial mode).
+ * 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;
@@ -119,7 +117,7 @@
{
Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
if (fn) {
- unsigned long ts; /* timestamp */
+ unsigned long timestamp;
if(*fn->pre){
(*fn->pre)(); //Run the pre configuration function if there is one.
@@ -129,27 +127,27 @@
(*fn->pgm)(1); /* Assert the program, commit */
/* Wait for INIT state (init low) */
- ts = get_timer(0); /* get current time */
+ timestamp = 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;
- }
+ CONFIG_FPGA_DELAY ();
+ if (get_timer(timestamp) > CFG_FPGA_WAIT) {
+ pr_debug("** 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 */
+ timestamp = 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");
+ CONFIG_FPGA_DELAY ();
+ if (get_timer(timestamp) > CFG_FPGA_WAIT) {
+ pr_debug("** Timeout waiting for INIT to clear.\n");
return -ETIMEDOUT;
- }
+ }
} while ((*fn->init)());
bytecount = 0; /* reset byte count */
@@ -182,7 +180,7 @@
return -ETIMEDOUT;
}
}
- }
+ }
return 0;
}
@@ -194,8 +192,9 @@
static int spartan_parallel_init (struct fpga_desc *desc)
{
Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
+
if (fn) {
- unsigned long ts; /* timestamp */
+ unsigned long timestamp;
/*
* Run the pre configuration function if there is one.
*/
@@ -206,12 +205,12 @@
/* Establish the initial state */
(*fn->pgm) (1); /* Assert the program, commit */
- ts = get_timer (0); /* get current time */
+ timestamp = 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");
+ if (get_timer(timestamp) > CFG_FPGA_WAIT) {
+ pr_debug("** Timeout waiting for INIT to set.\n");
(*fn->abort) (); /* abort the burn */
return -ETIMEDOUT;
}
@@ -222,12 +221,12 @@
CONFIG_FPGA_DELAY ();
(*fn->pgm) (0); /* Deassert the program, commit */
- ts = get_timer (0); /* get current time */
+ timestamp = 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");
+ if (get_timer(timestamp) > CFG_FPGA_WAIT) {
+ pr_debug("** Timeout waiting for INIT to clear.\n");
(*fn->abort) (); /* abort the burn */
return -ETIMEDOUT;
}
@@ -235,15 +234,15 @@
(*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;
+ bytecount = 0; // reset byte count
+ }
+ return 0;
}
/**
- * program the FPGA (parallel mode).
+ * 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;
@@ -251,20 +250,19 @@
if (fn) {
/* Load the data */
- size_t nbbyte = 0; // init local counter
+ size_t nbbyte = 0;
- raw_local_irq_save(flags);
+ 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);
- 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;
@@ -305,69 +303,68 @@
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 )
+
+size_t fpga_load( struct fpga_desc *desc, const char *buf, size_t bsize )
{
- int ret = 0;
+ 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;
+ if( desc ) {
+ switch( desc->family ) /* check family */
+ {
+ case Xilinx_Spartan:
+ {
+ switch( desc->iface ) /* check download 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 fpga_init_load( struct fpga_desc *desc )
{
- int ret = 0;
+ 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;
+ if( desc ) {
+ switch( desc->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: pr_debug("interface not supported!\n"); ret = -ENOSYS; break;
+ }
+ }
+ break;
+ default:
+ pr_debug("family not supported!\n");
+ ret = -ENOSYS;
+ break;
+ }
+ }
+ else {
+ pr_debug("invalid FPGA descriptor!\n");
+ ret = -EINVAL;
+ }
+ return ret;
}
-int xilinx_finish_load( struct fpga_desc *desc )
+int fpga_finish_load( struct fpga_desc *desc )
{
int ret = 0;
@@ -385,28 +382,25 @@
ret = spartan_parallel_finish( desc );
break;
default:
- PRINTF("interface not supported!\n");
+ pr_debug("interface not supported!\n");
ret = -ENOSYS;
break;
}
}
break;
default:
- PRINTF("family not supported!\n");
+ pr_debug("family not supported!\n");
ret = -ENOSYS;
break;
}
} else {
- PRINTF("invalid FPGA descriptor!\n");
+ pr_debug("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;
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h 2009-03-08 15:40:50 UTC (rev 1125)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h 2009-03-08 15:45:46 UTC (rev 1126)
@@ -117,19 +117,19 @@
* 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 );
+size_t fpga_load( struct fpga_desc *desc, const char *buf, size_t bsize );
/**
* initialize the FPGA programming interface
* return 0 if success, <0 if error detected
*/
-int xilinx_init_load( struct fpga_desc *desc );
+int fpga_init_load( struct fpga_desc *desc );
/* terminate FGPA loading */
-int xilinx_finish_load( struct fpga_desc *desc );
+int fpga_finish_load( struct fpga_desc *desc );
/**
- * get the descriptor infos, return the number of char placed in the buffer
+ * get some infos about FPGA download, return the number of char placed in the buffer
*/
int fpga_get_infos( struct fpga_desc *desc, char* buffer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <th...@us...> - 2009-03-08 15:40:56
|
Revision: 1125
http://armadeus.svn.sourceforge.net/armadeus/?rev=1125&view=rev
Author: thom25
Date: 2009-03-08 15:40:50 +0000 (Sun, 08 Mar 2009)
Log Message:
-----------
[LINUX] add ad9889 to apf27.c
Modified Paths:
--------------
trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/281-apf27-armadeus-add_apf27.c.patch
Modified: trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/281-apf27-armadeus-add_apf27.c.patch
===================================================================
--- trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/281-apf27-armadeus-add_apf27.c.patch 2009-03-08 14:35:45 UTC (rev 1124)
+++ trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/281-apf27-armadeus-add_apf27.c.patch 2009-03-08 15:40:50 UTC (rev 1125)
@@ -1,9 +1,6 @@
-PATCH AUTOMATICALLY GENERATED
-DON'T EDIT IT OR YOUR MODIFICATIONS WILL BE LOST
-(Take a look at armadeus/target/linux/ directory to know how to generate it)
--- linux-2.6.27.13.original/arch/arm/mach-mx2/apf27.c
+++ linux-2.6.27.13.mod/arch/arm/mach-mx2/apf27.c
-@@ -0,0 +1,1293 @@
+@@ -0,0 +1,1331 @@
+ /*
+ * apf27.c
+ *
@@ -62,6 +59,7 @@
+#include <linux/spi/max1027.h>
+#include <linux/spi/tsc2102.h>
+#include "../../../drivers/net/can/mcp251x.h"
++#include <media/ad9889.h>
+#if defined(CONFIG_SND) || defined (CONFIG_SND_MODULE)
+#include <mach/imx_dam.h>
+#include <mach/imx_sound.h>
@@ -86,8 +84,10 @@
+#ifdef CONFIG_IMX_BACKLIGHT_MODULE
+#define CONFIG_IMX_BACKLIGHT
+#endif
++#ifdef CONFIG_VIDEO_AD9889_MODULE
++#define CONFIG_VIDEO_AD9889 1
++#endif
+
-+
+/*
+ * APF27 has a Micron 128MiB 1,8V NAND flash, 16 bits width
+ */
@@ -151,6 +151,32 @@
+ },
+};
+
++#ifdef CONFIG_VIDEO_AD9889
++#define AD9889_INT 15
++
++static int ad9889_pins[] = {
++ (GPIO_PORTC | GPIO_IN | GPIO_GPIO | AD9889_INT),
++};
++
++static int ad9889_init(void)
++{
++ return mxc_gpio_setup_multiple(ad9889_pins, ARRAY_SIZE(ad9889_pins), "AD9889");
++}
++
++static int ad9889_exit(void)
++{
++ mxc_gpio_release_multiple(ad9889_pins, ARRAY_SIZE(ad9889_pins));
++ return 0;
++}
++
++static struct ad9889_config apf27_ad9889_config = {
++ .init = ad9889_init,
++ .exit = ad9889_exit,
++ .EDID_I2C_addr = 0x3f
++};
++
++#endif /* CONFIG_VIDEO_AD9889 */
++
+static struct i2c_board_info apf27_i2c_devices_bus1[] = {
+ [0] = {
+ .type = "24c02",
@@ -159,6 +185,15 @@
+ .platform_data = NULL,
+ .irq = 0
+ },
++#ifdef CONFIG_VIDEO_AD9889
++ [1] = {
++ .type = "ad9889",
++ .flags = 0,
++ .addr = 0x39,
++ .platform_data = &apf27_ad9889_config,
++ .irq = IRQ_GPIOC(AD9889_INT)
++ },
++#endif /* CONFIG_VIDEO_AD9889 */
+};
+#endif /* CONFIG_I2C */
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <th...@us...> - 2009-03-08 14:35:59
|
Revision: 1124
http://armadeus.svn.sourceforge.net/armadeus/?rev=1124&view=rev
Author: thom25
Date: 2009-03-08 14:35:45 +0000 (Sun, 08 Mar 2009)
Log Message:
-----------
[LINUX] remove tab from ad9889 commit
Modified Paths:
--------------
trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch
Modified: trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch
===================================================================
--- trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch 2009-03-08 14:01:50 UTC (rev 1123)
+++ trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch 2009-03-08 14:35:45 UTC (rev 1124)
@@ -56,32 +56,32 @@
+
+
+struct ad9889_dev {
-+ struct mutex lock_sync;
++ struct mutex lock_sync;
+ unsigned char edid_ready;
+ int edid_block_map_offset;
+ int next_segment;
+
-+ struct i2c_client *client;
++ struct i2c_client *client;
+ int force_hpd;
-+ struct work_struct work;
++ struct work_struct work;
+ struct i2c_client *edid_ram;
+};
+
+static int ad9889_read(struct i2c_client *client, u8 reg)
+{
-+ return i2c_smbus_read_byte_data(client, reg);
++ return i2c_smbus_read_byte_data(client, reg);
+}
+
+static int ad9889_write(struct i2c_client *client, u8 reg, u8 val)
+{
-+ int i;
++ int i;
+
-+ for (i = 0; i < 3; i++) {
-+ if (i2c_smbus_write_byte_data(client, reg, val) == 0)
-+ return 0;
-+ }
-+ printk(KERN_ERR "I2C Write Problem\n");
-+ return -1;
++ for (i = 0; i < 3; i++) {
++ if (i2c_smbus_write_byte_data(client, reg, val) == 0)
++ return 0;
++ }
++ printk(KERN_ERR "I2C Write Problem\n");
++ return -1;
+}
+
+static void ad9889_av_mute_on(struct i2c_client *client)
@@ -275,70 +275,70 @@
+ interrupt_remain1 = ad9889_read(client, 0x96);
+ interrupt_remain2 = ad9889_read(client, 0x97);
+ }
-+ mutex_unlock(&ad9889->lock_sync);
++ mutex_unlock(&ad9889->lock_sync);
+}
+
+/* ad9889 has new data for us available. */
+static irqreturn_t ad9889_handler(int irq, void *dev_id)
+{
-+ struct ad9889_dev *dev = (struct ad9889_dev *) dev_id;
-+ schedule_work(&dev->work);
-+ return IRQ_HANDLED;
++ struct ad9889_dev *dev = (struct ad9889_dev *) dev_id;
++ schedule_work(&dev->work);
++ return IRQ_HANDLED;
+}
+
+static int ad9889_probe(struct i2c_client *client,
-+ const struct i2c_device_id *id)
++ const struct i2c_device_id *id)
+{
-+ struct ad9889_config *pdata = client->dev.platform_data;
-+ struct ad9889_dev *ad9889;
-+ int err = -EINVAL;
++ struct ad9889_config *pdata = client->dev.platform_data;
++ struct ad9889_dev *ad9889;
++ int err = -EINVAL;
+
-+ /* Check if the adapter supports the needed features */
-+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
-+ return -EIO;
++ /* Check if the adapter supports the needed features */
++ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
++ return -EIO;
+
-+ if (!pdata) {
-+ printk(KERN_ERR "AD9889: Platform data not supplied\n");
-+ return -ENOENT;
-+ }
++ if (!pdata) {
++ printk(KERN_ERR "AD9889: Platform data not supplied\n");
++ return -ENOENT;
++ }
+
-+ if (!client->irq) {
-+ printk(KERN_ERR "AD9889: Invalid irq value\n");
-+ return -ENOENT;
-+ }
++ if (!client->irq) {
++ printk(KERN_ERR "AD9889: Invalid irq value\n");
++ return -ENOENT;
++ }
+
-+ ad9889 = kzalloc(sizeof(struct ad9889_dev), GFP_KERNEL);
++ ad9889 = kzalloc(sizeof(struct ad9889_dev), GFP_KERNEL);
+
-+ if (ad9889 == NULL)
-+ return -ENOMEM;
++ if (ad9889 == NULL)
++ return -ENOMEM;
+
+ ad9889->client = client;
-+ i2c_set_clientdata(client, ad9889);
++ i2c_set_clientdata(client, ad9889);
+
-+ INIT_WORK(&ad9889->work, ad9889_work);
-+ mutex_init(&ad9889->lock_sync);
-+ mutex_lock(&ad9889->lock_sync);
++ INIT_WORK(&ad9889->work, ad9889_work);
++ mutex_init(&ad9889->lock_sync);
++ mutex_lock(&ad9889->lock_sync);
+
+
-+ /* allocate GPIO / IRQ if necessary */
-+ if (pdata->init)
++ /* allocate GPIO / IRQ if necessary */
++ if (pdata->init)
+ pdata->init();
+
-+ if (request_irq(client->irq, ad9889_handler, IRQF_DISABLED | IRQF_SHARED
++ if (request_irq(client->irq, ad9889_handler, IRQF_DISABLED | IRQF_SHARED
+ | IRQF_TRIGGER_FALLING, "ad9889", ad9889)) {
-+ printk(KERN_ERR "Could not allocate touchscreen IRQ (n %d)\n", client->irq);
-+ err = -EINVAL;
-+ goto err_irq;
-+ }
++ printk(KERN_ERR "Could not allocate touchscreen IRQ (n %d)\n", client->irq);
++ err = -EINVAL;
++ goto err_irq;
++ }
+
-+ printk("detecting ad9889 client on address 0x%x\n", client->addr << 1);
++ printk("detecting ad9889 client on address 0x%x\n", client->addr << 1);
+
+ /* check whether the AD9889 is present */
+ if( ad9889_read(client, 0xA5) != 0x04 ){
-+ printk("ad9889 not found\n");
-+ err = -ENODEV;
++ printk("ad9889 not found\n");
++ err = -ENODEV;
+ goto err_presence;
-+ }
++ }
+
+ ad9889->edid_ram = i2c_new_dummy(client->adapter, pdata->EDID_I2C_addr);
+ if( !ad9889->edid_ram ){
@@ -346,7 +346,7 @@
+ goto err_presence;
+ }
+
-+ printk("ad9889 detected!\n");
++ printk("ad9889 detected!\n");
+ /* reset */
+ ad9889_write(client, 0x41, 0X20);
+ mdelay(10);
@@ -366,51 +366,51 @@
+ free_irq(client->irq, ad9889);
+
+err_irq:
-+ flush_scheduled_work();
-+ kfree(i2c_get_clientdata(client));
-+ if (pdata->exit)
++ flush_scheduled_work();
++ kfree(i2c_get_clientdata(client));
++ if (pdata->exit)
+ pdata->exit();
+
-+ return 0;
++ return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static int ad9889_remove(struct i2c_client *client)
+{
-+ struct ad9889_config *pdata = client->dev.platform_data;
++ struct ad9889_config *pdata = client->dev.platform_data;
+ struct ad9889_dev *ad9889 = i2c_get_clientdata(client);
+
+ free_irq(client->irq, ad9889);
+
-+ flush_scheduled_work();
++ flush_scheduled_work();
+
-+ if (pdata->exit)
++ if (pdata->exit)
+ pdata->exit();
+
+ i2c_unregister_device(ad9889->edid_ram);
+
-+ kfree(i2c_get_clientdata(client));
-+ kfree(ad9889);
++ kfree(i2c_get_clientdata(client));
++ kfree(ad9889);
+
+ mutex_unlock(&ad9889->lock_sync);
-+ return 0;
++ return 0;
+}
+
+/* ----------------------------------------------------------------------- */
+
+static struct i2c_device_id ad9889_id[] = {
-+ { "ad9889", 0 }, /* auto-detection */
-+ { }
++ { "ad9889", 0 }, /* auto-detection */
++ { }
+};
+MODULE_DEVICE_TABLE(i2c, ad9889_id);
+
+static struct v4l2_i2c_driver_data v4l2_i2c_data = {
-+ .name = "ad9889",
-+ //.command = ad9889_command,
-+ .probe = ad9889_probe,
-+ .remove = ad9889_remove,
-+ .id_table = ad9889_id,
++ .name = "ad9889",
++ //.command = ad9889_command,
++ .probe = ad9889_probe,
++ .remove = ad9889_remove,
++ .id_table = ad9889_id,
+};
--- linux-2.6.27.13.orig/include/media/ad9889.h 2008-10-10 00:13:53.000000000 +0200
+++ linux-2.6.27.13/include/media/ad9889.h 2009-03-01 08:29:01.000000000 +0100
@@ -439,8 +439,8 @@
+#define __LINUX_VIDE0_AD9889_H
+
+struct ad9889_config {
-+ int (*init)(void);
-+ int (*exit)(void);
++ int (*init)(void);
++ int (*exit)(void);
+ unsigned char EDID_I2C_addr; /*base address of the EDID ram*/
+ unsigned char high_speed_clock; /* set to 1 if pixel clock >80MHz */
+ unsigned char edge_capture; /* set to 1 for positive pixel clock capture*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <th...@us...> - 2009-03-08 14:02:12
|
Revision: 1123
http://armadeus.svn.sourceforge.net/armadeus/?rev=1123&view=rev
Author: thom25
Date: 2009-03-08 14:01:50 +0000 (Sun, 08 Mar 2009)
Log Message:
-----------
[LINUX] working version of the linux apf27 fpga loader
Modified Paths:
--------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-07 18:13:30 UTC (rev 1122)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-08 14:01:50 UTC (rev 1123)
@@ -21,19 +21,17 @@
#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 FPGA_VIRT_ADDR (IO_ADDRESS(FPGA_BASE_ADDR) + 0x0)
#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_RDATA 0xD6000000 /* FPGA data addr */
-#define CFG_FPGA_WDATA 0xD6000000 /* FPGA data addr */
#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 */
@@ -41,7 +39,9 @@
#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)
{
@@ -65,6 +65,9 @@
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;
}
@@ -122,7 +125,7 @@
int apf27_fpga_wdata( unsigned char data )
{
- __raw_writew(data, FPGA_VIRT_ADDR);
+ __raw_writew(data, fpga_addr);
return data;
}
@@ -137,6 +140,7 @@
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;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <th...@us...> - 2009-03-07 18:13:48
|
Revision: 1122
http://armadeus.svn.sourceforge.net/armadeus/?rev=1122&view=rev
Author: thom25
Date: 2009-03-07 18:13:30 +0000 (Sat, 07 Mar 2009)
Log Message:
-----------
[LINUX] add partialy working ad9889 driver
Added Paths:
-----------
trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch
Added: trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch
===================================================================
--- trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch (rev 0)
+++ trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.27.13/314-apf27-armadeus-ad9889.patch 2009-03-07 18:13:30 UTC (rev 1122)
@@ -0,0 +1,450 @@
+--- linux-2.6.27.13.orig/drivers/media/video/ad9889.c 2008-10-10 00:13:53.000000000 +0200
++++ linux-2.6.27.13/drivers/media/video/ad9889.c 2009-03-01 08:29:01.000000000 +0100
+@@ -0,0 +1,411 @@
++/*
++ * ad9889 - Analog Devices AD9889 video encoder driver
++ *
++ * Copyright (C) 2009 Armadeus Systems <nic...@ar...>
++ *
++ *
++ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
++ */
++
++
++#include <linux/kernel.h>
++#include <linux/module.h>
++#include <linux/slab.h>
++#include <linux/i2c.h>
++#include <linux/videodev2.h>
++#include <media/v4l2-common.h>
++#include <media/v4l2-chip-ident.h>
++#include <media/v4l2-i2c-drv.h>
++#include <media/ad9889.h>
++#include <linux/interrupt.h>
++//#include <linux/fb.h>
++#include <linux/delay.h>
++
++#define HPD_INT 0x80
++#define MSEN_INT 0x40
++#define VS_INT 0x20
++#define AUDIO_FIFO_FULL_INT 0x10
++#define ITU656_ERR_INT 0x08
++#define EDID_RDY_INT 0x04
++
++static int video_in_format;
++static int debug;
++
++MODULE_DESCRIPTION("Analog Devices AD9889 video encoder driver");
++MODULE_AUTHOR("Nicolas Colombain");
++MODULE_LICENSE("GPL");
++module_param(video_in_format, int, 0644);
++module_param(debug, int, 0644);
++MODULE_PARM_DESC(debug, "debug");
++MODULE_PARM_DESC(video_in_format, "video in format");
++
++
++struct ad9889_dev {
++ struct mutex lock_sync;
++ unsigned char edid_ready;
++ int edid_block_map_offset;
++ int next_segment;
++
++ struct i2c_client *client;
++ int force_hpd;
++ struct work_struct work;
++ struct i2c_client *edid_ram;
++};
++
++static int ad9889_read(struct i2c_client *client, u8 reg)
++{
++ return i2c_smbus_read_byte_data(client, reg);
++}
++
++static int ad9889_write(struct i2c_client *client, u8 reg, u8 val)
++{
++ int i;
++
++ for (i = 0; i < 3; i++) {
++ if (i2c_smbus_write_byte_data(client, reg, val) == 0)
++ return 0;
++ }
++ printk(KERN_ERR "I2C Write Problem\n");
++ return -1;
++}
++
++static void ad9889_av_mute_on(struct i2c_client *client)
++{
++ /* set chxPwrDwnI2C */
++ ad9889_write(client, 0xa1, 0x38);
++ /* set avmute*/
++ ad9889_write(client, 0x45, 0x40);
++}
++
++static void ad9889_av_mute_off(struct i2c_client *client)
++{
++ /* clear chxPwrDwnI2C */
++ ad9889_write(client, 0xa1, 0x0);
++ /* clear avmute*/
++ ad9889_write(client, 0x45, 0x80);
++}
++
++
++static void ad9889_init(struct i2c_client *client)
++{
++ ad9889_av_mute_on(client);
++ /* enable I2S0 and I2S standard format*/
++ ad9889_write(client, 0x0c, 0x04);
++ /* power up */
++ ad9889_write(client, 0x41, 0x10);
++
++ /* set static reserved registers*/
++ ad9889_write(client,0x0a, 0);
++ ad9889_write(client, 0x98, 0x03);
++ ad9889_write(client, 0x9C, 0x38);
++ /* set low speed pixel clock */
++ ad9889_write(client, 0xA2, 0x84);
++ ad9889_write(client, 0xA3, 0x84);
++
++ ad9889_write(client, 0xBB, 0xff);
++
++ /* set capture edge */
++ ad9889_write(client, 0xba, 0x60);
++ ad9889_write(client, 0x47, 0x80);
++}
++
++static void setup_audio_video(struct i2c_client *client)
++{
++ unsigned char rgb_rgb[24] = {8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0};
++
++ /* dvi*/
++ ad9889_write(client, 0xaf, 0x00);
++ /* write color map */
++ i2c_smbus_write_block_data(client, 0x18,24,rgb_rgb);
++ /* set CSC mode 1*/
++ ad9889_write(client, 0x17, 0x08);
++ /* enable CSC */
++ ad9889_write(client, 0x3b, 0x01);
++ /* check input mode */
++ if( (ad9889_read(client, 0x3E)>>2) == 1)
++ printk("640x480 input mode detected\n");
++ else
++ printk(KERN_ERR "input mode not supported, must be 640x480\n");
++}
++
++/* Returns the number of read bytes */
++int EDID_ram_read_data(struct i2c_client *client, u8 *values)
++{
++ union i2c_smbus_data data;
++ struct ad9889_config* config = client->dev.platform_data;
++ struct ad9889_dev *ad9889 = i2c_get_clientdata(client);
++ int status, i;
++
++ /* EDID ram base address */
++ ad9889_write(client, 0x43, config->EDID_I2C_addr<<1);
++
++ for( i=0; i<256/I2C_SMBUS_BLOCK_MAX; i++){
++ data.block[0] = I2C_SMBUS_BLOCK_MAX;
++ status = i2c_smbus_xfer(ad9889->edid_ram->adapter, config->EDID_I2C_addr,
++ ad9889->edid_ram->flags,
++ I2C_SMBUS_READ, i*32,
++ I2C_SMBUS_I2C_BLOCK_DATA, &data);
++ if (status < 0)
++ return status;
++ memcpy(&(values[i*32]), &data.block[1], data.block[0]);
++ }
++ return 0;
++}
++
++int handle_edid_interrupt(struct i2c_client *client)
++{
++ unsigned char edid_dat[256];
++ struct i2c_client temp_ram_client;
++
++ if( EDID_ram_read_data(client, edid_dat) < 0 )
++ printk(KERN_ERR "error when reading EDID\n");
++ else{
++ int i;
++ int xwidth;
++ int aspect;
++ int freq;
++
++ //printk("ESTABLISHED TIMING\n");
++ //edid_dat[35];
++ //edid_dat[36];
++
++ printk("Standard monitor timings\n");
++ for(i=38; i<53; i+=2 ) {
++ xwidth = edid_dat[i]*8 + 248;
++ aspect = (edid_dat[i+1] & 0xC0) >> 6;
++ freq = (edid_dat[i+1] &0x3f) +60;
++ printk("xwidth:%d, aspect:%s, freq:%d\n", xwidth, aspect?"4:3":"16/9", freq);
++ }
++ }
++ return 0;
++}
++
++static void handle_hpd_interrupt(struct i2c_client *client)
++{
++ if(ad9889_read(client, 0x42)&0x40) {
++ /* wait until the cable is really inserted */
++ mdelay(500);
++ /* set chxPwrDwnI2C down */
++ ad9889_write(client, 0xa1, 0x38);
++ /* power up chip */
++ ad9889_write(client, 0x41, 0x10);
++ ad9889_write(client, 0x94, 0x84);
++ ad9889_write(client, 0x95, 0xC3);
++ }
++}
++
++static void ad9889_work(struct work_struct *work)
++{
++ struct ad9889_dev *ad9889 = container_of(work, struct ad9889_dev, work);
++ struct i2c_client *client = ad9889->client;
++ int error;
++
++ unsigned char interrupt_registers1;
++ unsigned char interrupt_registers2;
++ unsigned char interrupt_code = 0;
++ unsigned char interrupt_remain1 = 0xff;
++ unsigned char interrupt_remain2 = 0xff;
++
++ mutex_lock(&ad9889->lock_sync);
++
++ while((interrupt_remain1&0xC4)|(interrupt_remain2&0xc0)){
++ interrupt_registers1 = ad9889_read(client, 0x96);
++ interrupt_registers2 = ad9889_read(client, 0x97);
++ printk("interrupt reg1 %x, interrupt reg2 %x\n",
++ interrupt_registers1, interrupt_registers2);
++
++ /* check HPD then call hpd handler */
++ if((interrupt_registers1 & HPD_INT) || ad9889->force_hpd ) {
++ handle_hpd_interrupt(client);
++ ad9889->edid_ready = 0;
++ ad9889->edid_block_map_offset = 0;
++ if( ad9889->force_hpd ){
++ ad9889->force_hpd = 0;
++ ad9889_write(client,0x96, HPD_INT);
++ interrupt_registers1 |= HPD_INT;
++ }
++ interrupt_code |= HPD_INT;
++ }
++
++ /* check for EDID ready flag, then call EDID Handler */
++ if((interrupt_registers1 & EDID_RDY_INT)) {
++ if(!ad9889->edid_ready) {
++ ad9889->next_segment = handle_edid_interrupt(client);
++ interrupt_code |= EDID_RDY_INT;
++ }
++ }
++
++ /* re-enable the interrupt before requesting additional EDID */
++ ad9889_write(client,0x96, interrupt_registers1);
++ ad9889_write(client, 0x97, interrupt_registers2);
++
++ /* if final EDID interrupt was processed tell system that EDID is ready and
++ initiate audio video setup */
++
++ if(interrupt_code&EDID_RDY_INT) {
++ if(ad9889->next_segment==0) {
++ ad9889_av_mute_on(client);
++ ad9889_init(client);
++ ad9889->edid_ready = 1;
++ setup_audio_video(client);
++ ad9889_av_mute_off(client);
++ }
++ else
++ ad9889_write(client,0xc4, ad9889->edid_block_map_offset+ad9889->next_segment);
++
++ if(ad9889->next_segment==0x40)
++ ad9889->edid_block_map_offset=0x40;
++ }
++ /*Check if additional interrupts occured during processing*/
++ interrupt_remain1 = ad9889_read(client, 0x96);
++ interrupt_remain2 = ad9889_read(client, 0x97);
++ }
++ mutex_unlock(&ad9889->lock_sync);
++}
++
++/* ad9889 has new data for us available. */
++static irqreturn_t ad9889_handler(int irq, void *dev_id)
++{
++ struct ad9889_dev *dev = (struct ad9889_dev *) dev_id;
++ schedule_work(&dev->work);
++ return IRQ_HANDLED;
++}
++
++static int ad9889_probe(struct i2c_client *client,
++ const struct i2c_device_id *id)
++{
++ struct ad9889_config *pdata = client->dev.platform_data;
++ struct ad9889_dev *ad9889;
++ int err = -EINVAL;
++
++ /* Check if the adapter supports the needed features */
++ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
++ return -EIO;
++
++ if (!pdata) {
++ printk(KERN_ERR "AD9889: Platform data not supplied\n");
++ return -ENOENT;
++ }
++
++ if (!client->irq) {
++ printk(KERN_ERR "AD9889: Invalid irq value\n");
++ return -ENOENT;
++ }
++
++ ad9889 = kzalloc(sizeof(struct ad9889_dev), GFP_KERNEL);
++
++ if (ad9889 == NULL)
++ return -ENOMEM;
++
++ ad9889->client = client;
++ i2c_set_clientdata(client, ad9889);
++
++ INIT_WORK(&ad9889->work, ad9889_work);
++ mutex_init(&ad9889->lock_sync);
++ mutex_lock(&ad9889->lock_sync);
++
++
++ /* allocate GPIO / IRQ if necessary */
++ if (pdata->init)
++ pdata->init();
++
++ if (request_irq(client->irq, ad9889_handler, IRQF_DISABLED | IRQF_SHARED
++ | IRQF_TRIGGER_FALLING, "ad9889", ad9889)) {
++ printk(KERN_ERR "Could not allocate touchscreen IRQ (n %d)\n", client->irq);
++ err = -EINVAL;
++ goto err_irq;
++ }
++
++ printk("detecting ad9889 client on address 0x%x\n", client->addr << 1);
++
++ /* check whether the AD9889 is present */
++ if( ad9889_read(client, 0xA5) != 0x04 ){
++ printk("ad9889 not found\n");
++ err = -ENODEV;
++ goto err_presence;
++ }
++
++ ad9889->edid_ram = i2c_new_dummy(client->adapter, pdata->EDID_I2C_addr);
++ if( !ad9889->edid_ram ){
++ printk("error: can't add i2c device at 0x%x\n", pdata->EDID_I2C_addr);
++ goto err_presence;
++ }
++
++ printk("ad9889 detected!\n");
++ /* reset */
++ ad9889_write(client, 0x41, 0X20);
++ mdelay(10);
++
++ mutex_unlock(&ad9889->lock_sync);
++
++ /* if a monitor is already connected, then simulate interrupt */
++ err = ad9889_read(client, 0x42);
++ if( err & 0x40){
++ ad9889->force_hpd = 1;
++ schedule_work(&ad9889->work);
++ }
++
++ return 0;
++
++err_presence:
++ free_irq(client->irq, ad9889);
++
++err_irq:
++ flush_scheduled_work();
++ kfree(i2c_get_clientdata(client));
++ if (pdata->exit)
++ pdata->exit();
++
++ return 0;
++}
++
++/* ----------------------------------------------------------------------- */
++
++static int ad9889_remove(struct i2c_client *client)
++{
++ struct ad9889_config *pdata = client->dev.platform_data;
++ struct ad9889_dev *ad9889 = i2c_get_clientdata(client);
++
++ free_irq(client->irq, ad9889);
++
++ flush_scheduled_work();
++
++ if (pdata->exit)
++ pdata->exit();
++
++ i2c_unregister_device(ad9889->edid_ram);
++
++ kfree(i2c_get_clientdata(client));
++ kfree(ad9889);
++
++ mutex_unlock(&ad9889->lock_sync);
++ return 0;
++}
++
++/* ----------------------------------------------------------------------- */
++
++static struct i2c_device_id ad9889_id[] = {
++ { "ad9889", 0 }, /* auto-detection */
++ { }
++};
++MODULE_DEVICE_TABLE(i2c, ad9889_id);
++
++static struct v4l2_i2c_driver_data v4l2_i2c_data = {
++ .name = "ad9889",
++ //.command = ad9889_command,
++ .probe = ad9889_probe,
++ .remove = ad9889_remove,
++ .id_table = ad9889_id,
++};
+--- linux-2.6.27.13.orig/include/media/ad9889.h 2008-10-10 00:13:53.000000000 +0200
++++ linux-2.6.27.13/include/media/ad9889.h 2009-03-01 08:29:01.000000000 +0100
+@@ -0,0 +1,33 @@
++/*
++ * AD9889 driver
++ *
++ * Copyright (c) 2009 Armadeus Systems
++ *
++ * This package 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 package 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 package; if not, write to the Free Software
++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++ */
++
++#ifndef __LINUX_VIDE0_AD9889_H
++#define __LINUX_VIDE0_AD9889_H
++
++struct ad9889_config {
++ int (*init)(void);
++ int (*exit)(void);
++ unsigned char EDID_I2C_addr; /*base address of the EDID ram*/
++ unsigned char high_speed_clock; /* set to 1 if pixel clock >80MHz */
++ unsigned char edge_capture; /* set to 1 for positive pixel clock capture*/
++};
++
++
++#endif /* __LINUX_VIDE0_AD9889_H */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-03-07 14:22:20
|
Revision: 1120
http://armadeus.svn.sourceforge.net/armadeus/?rev=1120&view=rev
Author: jorasse
Date: 2009-03-07 13:32:24 +0000 (Sat, 07 Mar 2009)
Log Message:
-----------
[ARMADEUS] copy svn tag release-3.0 to latestrelease
Added Paths:
-----------
tags/latestrelease/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jo...@us...> - 2009-03-07 13:39:34
|
Revision: 1121
http://armadeus.svn.sourceforge.net/armadeus/?rev=1121&view=rev
Author: jorasse
Date: 2009-03-07 13:37:10 +0000 (Sat, 07 Mar 2009)
Log Message:
-----------
[ARMADEUS] remove obsolete branch "toolsupgrade"
Removed Paths:
-------------
branches/toolsupgrade/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-06 20:15:23
|
Revision: 1119
http://armadeus.svn.sourceforge.net/armadeus/?rev=1119&view=rev
Author: artemys
Date: 2009-03-06 20:15:04 +0000 (Fri, 06 Mar 2009)
Log Message:
-----------
[ROOTFS] Adding of /lib/firmware/ in skeleton
Added Paths:
-----------
trunk/buildroot/target/device/armadeus/rootfs/target_skeleton/lib/firmware/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-06 18:39:44
|
Revision: 1118
http://armadeus.svn.sourceforge.net/armadeus/?rev=1118&view=rev
Author: artemys
Date: 2009-03-06 18:39:23 +0000 (Fri, 06 Mar 2009)
Log Message:
-----------
[TEST] Add test for FPGA download (400k)
Added Paths:
-----------
trunk/target/test/test_fpga.sh
Added: trunk/target/test/test_fpga.sh
===================================================================
--- trunk/target/test/test_fpga.sh (rev 0)
+++ trunk/target/test/test_fpga.sh 2009-03-06 18:39:23 UTC (rev 1118)
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+#
+# Script to test Armadeus Software release
+#
+# Copyright (C) 2008 The Armadeus 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.
+#
+
+source ./test_helpers.sh
+source ./test_env.sh
+
+FPGA_LOAD_DEV="/dev/fpgaloader"
+TEST_BITFILE=/tmp/led.bit
+
+test_fpga_load()
+{
+ show_test_banner "FPGA"
+
+ modprobe fpgaloader
+ if [ "$?" != 0 ] || [ ! -c "$FPGA_LOAD_DEV" ] ; then
+ echo "Module failed to load"
+ exit_failed
+ fi
+
+ cat /proc/driver/fpga/loader
+ echo "Downloading bitfile from Internet"
+ # Suppose that network was correctly set before
+ wget http://dl.free.fr/ppbCdFTqs -O $TEST_BITFILE
+
+ dd if=$TEST_BITFILE of=$FPGA_LOAD_DEV
+ if [ "$?" == 0 ]; then
+ ask_user "Did you see the LED on FPGA ? (y/n)"
+ if [ "$response" == "y" ]; then
+ echo_test_ok
+ fi
+ fi
+ rm -f $TEST_BITFILE
+}
+
+test_fpga_load
+
Property changes on: trunk/target/test/test_fpga.sh
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-06 17:48:33
|
Revision: 1117
http://armadeus.svn.sourceforge.net/armadeus/?rev=1117&view=rev
Author: artemys
Date: 2009-03-06 17:48:16 +0000 (Fri, 06 Mar 2009)
Log Message:
-----------
[LINUX] Add APF27 support to fpgaloader (part2)
Modified Paths:
--------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile 2009-03-05 11:22:39 UTC (rev 1116)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile 2009-03-06 17:48:16 UTC (rev 1117)
@@ -6,10 +6,12 @@
obj-$(CONFIG_ARMADEUS_FPGA_TOOL_DRIVER) += fpgaloader.o
ifneq ($(CONFIG_MACH_APF27),)
-fpgaloader-objs := apf27-fpga-loader.o xilinx-fpga-loader.o fpga-loader.o
+fpgaloader-objs := xilinx-fpga-loader.o fpga-loader.o
+obj-y += apf27-fpga-loader.o
endif
ifneq ($(CONFIG_MACH_APF9328),)
-fpgaloader-objs := apf9328-fpga-loader.o xilinx-fpga-loader.o fpga-loader.o
+fpgaloader-objs := xilinx-fpga-loader.o fpga-loader.o
+obj-y += apf9328-fpga-loader.o
endif
else
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-05 11:22:39 UTC (rev 1116)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-06 17:48:16 UTC (rev 1117)
@@ -19,23 +19,21 @@
*
*/
-#include <linux/version.h>
#include <mach/iomux-mx1-mx2.h>
#include <mach/gpio.h>
-#include <asm/io.h>
-#include <linux/kernel.h>
-#include <mach/hardware.h>
+#include <linux/platform_device.h>
#include "xilinx-fpga-loader.h"
+
#define FPGA_BASE_ADDR CS5_BASE_ADDR
#define FPGA_VIRT_ADDR (IO_ADDRESS(FPGA_BASE_ADDR) + 0x0)
#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_RDATA 0xD6000000 /* FPGA data addr */
-#define CFG_FPGA_WDATA 0xD6000000 /* FPGA data addr */
+#define CFG_FPGA_RDATA 0xD6000000 /* FPGA data addr */
+#define CFG_FPGA_WDATA 0xD6000000 /* FPGA data addr */
#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 */
@@ -43,11 +41,9 @@
#define CFG_FPGA_SUSPEND (GPIO_PORTF | 10) /* FPGA done pin */
#define CFG_FPGA_RESET (GPIO_PORTF | 7) /* FPGA done pin */
-#define NB_TARGET_DESC 2
-
/* Initialize GPIO port before download */
-int fpga_pre_fn (void)
+int apf27_fpga_pre(void)
{
gpio_set_value(CFG_FPGA_PWR, 1);
gpio_set_value(CFG_FPGA_PRG, 1);
@@ -75,7 +71,7 @@
/*
* Set the FPGA's active-low program line to the specified level
*/
-int fpga_pgm_fn (int assert)
+int apf27_fpga_pgm(int assert)
{
gpio_set_value( CFG_FPGA_PRG, !assert);
return assert;
@@ -84,7 +80,7 @@
/*
* Set the FPGA's active-high clock line to the specified level
*/
-int fpga_clk_fn (int assert_clk)
+int apf27_fpga_clk(int assert_clk)
{
gpio_set_value( CFG_FPGA_CLK, !assert_clk);
return assert_clk;
@@ -94,7 +90,7 @@
* Test the state of the active-low FPGA INIT line. Return 1 on INIT
* asserted (low).
*/
-int fpga_init_fn (void)
+int apf27_fpga_init(void)
{
int value;
value = gpio_get_value(CFG_FPGA_INIT);
@@ -104,7 +100,7 @@
/*
* Test the state of the active-high FPGA DONE pin
*/
-int fpga_done_fn (void)
+int apf27_fpga_done(void)
{
return(gpio_get_value(CFG_FPGA_DONE));
}
@@ -112,30 +108,30 @@
/*
* Set the FPGA's wr line to the specified level
*/
-int fpga_wr_fn (int assert_write)
+int apf27_fpga_wr(int assert_write)
{
gpio_set_value( CFG_FPGA_RW, !assert_write);
return assert_write;
}
-int fpga_cs_fn (int assert_cs)
+int apf27_fpga_cs(int assert_cs)
{
gpio_set_value( CFG_FPGA_CS, !assert_cs);
return assert_cs;
}
-int fpga_wdata_fn ( unsigned char data )
+int apf27_fpga_wdata( unsigned char data )
{
__raw_writew(data, FPGA_VIRT_ADDR);
return data;
}
-int fpga_busy_fn (void)
+int apf27_fpga_busy(void)
{
return 0;
}
-
-int fpga_post_fn (void)
+
+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);
@@ -144,9 +140,9 @@
return 1;
}
-int fpga_abort_fn (void)
+int apf27_fpga_abort(void)
{
- fpga_post_fn();
+ apf27_fpga_post();
gpio_set_value(CFG_FPGA_PWR, 1);
return 1;
}
@@ -157,30 +153,41 @@
* Just take care about the file size
*/
Xilinx_Spartan3_Slave_Parallel_fns fpga_fns = {
- fpga_pre_fn,
- fpga_pgm_fn,
- fpga_clk_fn,
- fpga_init_fn,
- fpga_done_fn,
- fpga_wr_fn,
- fpga_cs_fn,
- fpga_wdata_fn,
- fpga_busy_fn,
- fpga_abort_fn,
- fpga_post_fn,
+ .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,
};
-Xilinx_desc target_fpga_desc[NB_TARGET_DESC] = {
- {
- Xilinx_Spartan,
- slave_parallel,
- 1196128l/8,
- (void *) &fpga_fns
+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,
},
- {
- Xilinx_Spartan,
- slave_parallel,
- 1887216l/8,
- (void *) &fpga_fns
- },
};
+
+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);
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c 2009-03-05 11:22:39 UTC (rev 1116)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c 2009-03-06 17:48:16 UTC (rev 1117)
@@ -20,16 +20,12 @@
*
*/
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
-#include <asm/arch/hardware.h>
-#else
-#include <mach/hardware.h>
-#endif
#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) */
@@ -45,7 +41,7 @@
/*
* Set the FPGA's active-low program line to the specified level
*/
-int fpga_pgm_fn( int assert )
+static int apf9328_fpga_pgm( int assert )
{
GPIO_WRITE( FPGA_PROGRAM, !assert);
return assert;
@@ -54,7 +50,7 @@
/*
* Set the FPGA's active-high clock line to the specified level
*/
-int fpga_clk_fn( int assert_clk )
+static int apf9328_fpga_clk( int assert_clk )
{
GPIO_WRITE( FPGA_CLOCK, assert_clk);
return assert_clk;
@@ -64,7 +60,7 @@
* Test the state of the active-low FPGA INIT line. Return 1 on INIT
* asserted (low).
*/
-int fpga_init_fn( void )
+static int apf9328_fpga_init( void )
{
return(!GPIO_READ(FPGA_INIT));
}
@@ -72,7 +68,7 @@
/*
* Test the state of the active-high FPGA DONE pin
*/
-int fpga_done_fn( void )
+static int apf9328_fpga_done( void )
{
return(GPIO_READ(FPGA_DONE));
}
@@ -80,13 +76,13 @@
/*
* Set the FPGA's data line to the specified level
*/
-int fpga_wr_fn( int assert_write )
+static int apf9328_fpga_wr( int assert_write )
{
GPIO_WRITE( FPGA_DIN, assert_write);
return assert_write;
}
-int fpga_pre_fn( void )
+static int apf9328_fpga_pre( void )
{
/* Initialize GPIO pins */
imx_gpio_mode (FPGA_INIT | GPIO_GIUS | GPIO_DR | GPIO_IN );
@@ -99,26 +95,36 @@
Xilinx_Spartan_Slave_Serial_fns fpga_fns = {
- fpga_pre_fn,
- fpga_pgm_fn,
- fpga_clk_fn,
- fpga_init_fn,
- fpga_done_fn,
- fpga_wr_fn,
+ .pre = apf9328_fpga_pre,
+ .pgm = apf9328_fpga_pgm,
+ .clk = apf9328_fpga_clk,
+ .init = apf9328_fpga_init,
+ .done = apf9328_fpga_done,
+ .wr = apf9328_fpga_wr,
};
-Xilinx_desc target_fpga_desc[/*NB_TARGET_DESC*/] = {
-
- { /* first supported configuration (default) */
- Xilinx_Spartan,
- slave_serial,
- XILINX_XC3S200_SIZE,
- (void *) &fpga_fns
+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,
},
- { /* second one */
- Xilinx_Spartan,
- slave_serial,
- XILINX_XC3S400_SIZE,
- (void *) &fpga_fns
- },
};
+
+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);
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-05 11:22:39 UTC (rev 1116)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-06 17:48:16 UTC (rev 1117)
@@ -26,18 +26,19 @@
#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.8"
+
+#define DRIVER_VERSION "0.9"
#define DRIVER_NAME "fpgaloader"
-
/* global variables */
-static int fpga_major = FPGA_MAJOR;
-Xilinx_desc* g_current_desc = NULL;
+struct fpga_desc *g_current_desc = NULL;
struct semaphore fpga_sema;
static unsigned char fpga_descriptor = 0; /* use default target_fpga_desc */
@@ -121,7 +122,7 @@
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
@@ -132,11 +133,7 @@
/* we have finished to read, return 0 */
ret = 0;
} else {
- if ( data == NULL ) {
- ret = xilinx_get_descriptor_info( -1, buffer );
- } else {
- ret = xilinx_get_descriptor_info( *((unsigned char*)data), buffer );
- }
+ ret = fpga_get_infos( g_current_desc, buffer );
}
return ret;
@@ -194,10 +191,10 @@
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 ) {
@@ -207,7 +204,7 @@
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);
@@ -223,43 +220,102 @@
.ioctl = armadeus_fpga_ioctl,
};
-int __init armadeus_fpga_init(void)
+#ifdef CONFIG_PM
+static int armadeus_fpga_suspend(struct platform_device *pdev, pm_message_t state)
{
- static int result;
-
- /* Register the driver by getting a major number */
- result = register_chrdev(fpga_major, DRIVER_NAME, &fpga_fops);
- if (result < 0) {
- printk(KERN_WARNING DRIVER_NAME ": can't get major %d\n", fpga_major);
- return result;
+ 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;
}
- if( fpga_major == 0 ) fpga_major = result; /* dynamic MAJOR allocation */
+ /* 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 )
- return result;
+ goto err_misc;
sema_init(&fpga_sema, 1);
/* initialize the current fpga descriptor with the one by default */
- g_current_desc = xilinx_get_descriptor(fpga_descriptor);
- if( g_current_desc == NULL ){
- return -EINVAL;
- }
+ g_current_desc = platform_info;
- printk(DRIVER_NAME " v" DRIVER_VERSION " successfully loaded !\n");
return 0;
+
+err_misc:
+ misc_deregister(&fpgaloader_misc);
+err_no_pdata:
+ return result;
}
-void __exit armadeus_fpga_cleanup(void)
+static int armadeus_fpga_remove(struct platform_device *pdev)
{
remove_proc_entry(FPGA_PROC_FILENAME, NULL);
remove_proc_entry(FPGA_PROC_DIRNAME, NULL);
- unregister_chrdev(fpga_major, DRIVER_NAME);
+ 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_cleanup);
+module_exit(armadeus_fpga_exit);
MODULE_AUTHOR("Julien Boibessot / Nicolas Colombain");
MODULE_DESCRIPTION("Armadeus FPGA loading driver");
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c 2009-03-05 11:22:39 UTC (rev 1116)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c 2009-03-06 17:48:16 UTC (rev 1117)
@@ -3,7 +3,7 @@
* Copyright (C) 2006-2009 Nicolas Colombain <nic...@ar...>
* Armadeus Project / Armadeus systems
*
- * Based on the implementation (U-Boot) of:
+ * Based on the (U-Boot) implementation of:
* Rich Ireland, Enterasys Networks, rir...@en....
* Keith Outwater, kei...@mv...
*
@@ -27,14 +27,10 @@
*
*/
-#include <linux/version.h>
#include <asm/io.h>
#include <linux/time.h>
#include <linux/delay.h>
-#include <linux/kernel.h>
#include <linux/errno.h>
-#include <asm/irqflags.h>
-#include <asm/delay.h>
#include "xilinx-fpga-loader.h"
@@ -42,7 +38,6 @@
#define CFG_FPGA_WAIT 20000 // uS
size_t bytecount = 0; // total bytes received
-extern Xilinx_desc target_fpga_desc[]; // target descriptor table
/*
* Timeout function
@@ -60,55 +55,57 @@
/*
* dump the given descriptor infos
*/
-static int xilinx_dump_descriptor_info( Xilinx_desc *desc, char* buffer )
+static int xilinx_dump_descriptor_info( struct fpga_desc *desc, char* buffer )
{
- int len;
- len = sprintf( buffer, "%s %s %u\n",
- (desc->family == Xilinx_Spartan) ? "spartan":"unknown",
- (desc->iface == slave_serial) ? "slave serial":"slave parallel",
- desc->size );
- return len;
+ 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 (Xilinx_desc *desc, const char* buf, size_t bsize)
+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
+ 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 ++];
+ 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;
+ 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 --;
+ /* 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(".");
+ if(bytecount%4096 == 0)
+ printk(".");
+
return bsize;
}
return -EINVAL;
@@ -118,22 +115,22 @@
* initialize the FPGA programming interface.
* return 0 if success, <0 if error detected
*/
-static int spartan_serial_init (Xilinx_desc *desc)
+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.
- }
+ if(*fn->pre){
+ (*fn->pre)(); //Run the pre configuration function if there is one.
+ }
- /* Establish the initial state */
+ /* Establish the initial state */
(*fn->pgm)(1); /* Assert the program, commit */
- /* Wait for INIT state (init low) */
+ /* Wait for INIT state (init low) */
ts = get_timer(0); /* get current time */
- do {
+ do {
CONFIG_FPGA_DELAY ();
if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */
PRINTF ("** Timeout waiting for INIT to start.\n");
@@ -146,8 +143,8 @@
(*fn->pgm)(0); /* Deassert the program, commit */
ts = get_timer(0); /* get current time */
- /* Now wait for INIT to go high */
- do {
+ /* 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");
@@ -155,14 +152,14 @@
}
} while ((*fn->init)());
- bytecount = 0; // reset byte count
- return 0; // success
- }
- return -EINVAL;
+ bytecount = 0; /* reset byte count */
+ return 0; /* success */
+ }
+ return -EINVAL;
}
/* terminate the FPGA load (serial mode) */
-static int spartan_serial_finish(Xilinx_desc *desc)
+static int spartan_serial_finish(struct fpga_desc *desc)
{
unsigned long timestamp;
Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
@@ -194,7 +191,7 @@
* initialize the FPGA programming interface.
* return 0 if success, <0 if error detected
*/
-static int spartan_parallel_init (Xilinx_desc *desc)
+static int spartan_parallel_init (struct fpga_desc *desc)
{
Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
if (fn) {
@@ -247,7 +244,7 @@
* program the FPGA (parallel mode).
* return 0 if success, >0 while programming, <0 if error detected
*/
-static size_t spartan_parallel_load (Xilinx_desc *desc, const char* buf, size_t bsize)
+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;
@@ -274,7 +271,7 @@
}
/* terminate the FPGA load (parallel mode) */
-static int spartan_parallel_finish(Xilinx_desc *desc)
+static int spartan_parallel_finish(struct fpga_desc *desc)
{
Xilinx_Spartan3_Slave_Parallel_fns *fn = desc->iface_fns;
unsigned long timestamp;
@@ -312,7 +309,7 @@
* program the FPGA.
* return 0 if success, >0 while programming, <0 if error detected
*/
-size_t xilinx_load( Xilinx_desc *desc, const char *buf, size_t bsize )
+size_t xilinx_load( struct fpga_desc *desc, const char *buf, size_t bsize )
{
int ret = 0;
@@ -343,7 +340,7 @@
* initialize the FPGA programming interface.
* return 0 if success, <0 if error detected
*/
-int xilinx_init_load( Xilinx_desc *desc )
+int xilinx_init_load( struct fpga_desc *desc )
{
int ret = 0;
@@ -370,7 +367,7 @@
return ret;
}
-int xilinx_finish_load( Xilinx_desc *desc )
+int xilinx_finish_load( struct fpga_desc *desc )
{
int ret = 0;
@@ -408,35 +405,15 @@
}
/**
- * get the descriptor corresponding to desc_id
- * return NULL if error
+ * get some infos about FPGA download
*/
-#define NB_TARGET_DESC 2
-
-Xilinx_desc * xilinx_get_descriptor( unsigned char desc_id )
+int fpga_get_infos( struct fpga_desc *desc, char* buffer )
{
- if( desc_id < NB_TARGET_DESC ){
- return &(target_fpga_desc[desc_id]);
- }
- return NULL;
-}
+ int len = 0;
-/**
- * get the descriptor infos
- */
-int xilinx_get_descriptor_info( int desc_id, char* buffer )
-{
- int len = 0;
+ if( desc ) {
+ len = xilinx_dump_descriptor_info( desc, buffer );
+ }
- if( desc_id >= 0 ) {
- len = xilinx_dump_descriptor_info( &target_fpga_desc[desc_id], buffer );
- }
- else { // all desc requested
- unsigned char i;
- for( i=0; i<NB_TARGET_DESC; i++ ) {
- len += xilinx_dump_descriptor_info( &target_fpga_desc[i], buffer+len );
- }
- }
-
- return len;
+ return len;
}
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h 2009-03-05 11:22:39 UTC (rev 1116)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h 2009-03-06 17:48:16 UTC (rev 1117)
@@ -31,17 +31,16 @@
#include <linux/types.h>
+
#define FPGA_DEBUG
//#undef FPGA_DEBUG
#ifdef FPGA_DEBUG
-#define PRINTF(fmt,args...) printk (fmt ,##args)
+#define PRINTF(fmt,args...) printk (fmt ,##args)
#else
-#define PRINTF(fmt,args...)
+#define PRINTF(fmt,args...)
#endif
-
-
/* Spartan-III */
#define XILINX_XC3S50_SIZE 439264/8
#define XILINX_XC3S200_SIZE 1047616/8
@@ -53,25 +52,25 @@
#define XILINX_XC3S5000_SIZE 13271936/8
-typedef enum { /* typedef Xilinx_iface */
+typedef enum {
min_xilinx_iface_type, /* low range check value */
- slave_serial, /* serial data and external clock */
- slave_parallel, /* parallel data and external clock */
- max_xilinx_iface_type /* insert all new types before this */
-} Xilinx_iface; /* end, typedef Xilinx_iface */
+ slave_serial, /* serial data and external clock */
+ slave_parallel, /* parallel data and external clock */
+ max_xilinx_iface_type /* insert all new types before this */
+} Xilinx_iface;
-typedef enum { /* typedef Xilinx_Family */
- min_xilinx_type, /* low range check value */
- Xilinx_Spartan, /* Spartan-II Family */
- max_xilinx_type /* insert all new types before this */
-} Xilinx_Family; /* end, typedef Xilinx_Family */
+typedef enum {
+ min_xilinx_type, /* low range check value */
+ Xilinx_Spartan, /* Spartan-II Family */
+ max_xilinx_type /* insert all new types before this */
+} Xilinx_Family;
-typedef struct { /* typedef Xilinx_desc */
- Xilinx_Family family; /* part type */
- Xilinx_iface iface; /* interface type */
- size_t size; /* bytes of data part can accept */
+struct fpga_desc {
+ Xilinx_Family family; /* part type */
+ Xilinx_iface iface; /* interface type */
+ size_t size; /* bytes of data part can accept */
void * iface_fns; /* interface function table */
-} Xilinx_desc; /* end, typedef Xilinx_desc */
+};
/** pointer to target specific low level function */
@@ -115,29 +114,23 @@
/**
- * program the FPGA.
+ * program the FPGA.
* return 0 if success, >0 while programming, <0 if error detected
- */
-size_t xilinx_load( Xilinx_desc *desc, const char *buf, size_t bsize );
+ */
+size_t xilinx_load( struct fpga_desc *desc, const char *buf, size_t bsize );
/**
- * initialize the FPGA programming interface.
+ * initialize the FPGA programming interface
* return 0 if success, <0 if error detected
- */
-int xilinx_init_load( Xilinx_desc *desc );
+ */
+int xilinx_init_load( struct fpga_desc *desc );
/* terminate FGPA loading */
-int xilinx_finish_load( Xilinx_desc *desc );
+int xilinx_finish_load( struct fpga_desc *desc );
-/**
+/**
* get the descriptor infos, return the number of char placed in the buffer
*/
-int xilinx_get_descriptor_info( int desc_id, char* buffer);
+int fpga_get_infos( struct fpga_desc *desc, char* buffer);
-/**
- * get the descriptor corresponding to desc_id
- * return NULL if error
- */
-Xilinx_desc * xilinx_get_descriptor( unsigned char desc_id );
-
#endif // __XILINX_FPGA_H__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Fa...@us...> - 2009-03-05 11:22:57
|
Revision: 1116
http://armadeus.svn.sourceforge.net/armadeus/?rev=1116&view=rev
Author: FabM
Date: 2009-03-05 11:22:39 +0000 (Thu, 05 Mar 2009)
Log Message:
-----------
[FIRMWARE] Fill leds projects directories, with working files
Added Paths:
-----------
trunk/firmware/leds/blinking_led/README
trunk/firmware/leds/blinking_led/blinking_led_xc3s200.bit
trunk/firmware/leds/blinking_led/blinking_led_xc3s400.bit
trunk/firmware/leds/blinking_led/led_wiring.dia
trunk/firmware/leds/blinking_led/src/
trunk/firmware/leds/blinking_led/src/led_blink.ucf
trunk/firmware/leds/blinking_led/src/led_blink.vhd
trunk/firmware/leds/blinking_led/testbench/
trunk/firmware/leds/blinking_led/testbench/led_blink_tb.vhd
trunk/firmware/leds/blinking_led/testbench/tags
trunk/firmware/leds/button_led/clock_divider.vhd
trunk/firmware/leds/button_led/debouncer.vhd
trunk/firmware/leds/button_led/flip_flop.vhd
trunk/firmware/leds/button_led/led.ucf
trunk/firmware/leds/button_led/led_top.bin
trunk/firmware/leds/button_led/led_top.dia
trunk/firmware/leds/button_led/led_top.vhd
trunk/firmware/leds/button_led/led_top_200k.bit
trunk/firmware/leds/button_led/led_top_400k.bit
trunk/firmware/leds/button_led/led_top_tbw_selfcheck_beh.vhd
Removed Paths:
-------------
trunk/firmware/leds/clock_divider.vhd
trunk/firmware/leds/debouncer.vhd
trunk/firmware/leds/flip_flop.vhd
trunk/firmware/leds/led.ucf
trunk/firmware/leds/led_top.bin
trunk/firmware/leds/led_top.dia
trunk/firmware/leds/led_top.vhd
trunk/firmware/leds/led_top_200k.bit
trunk/firmware/leds/led_top_400k.bit
trunk/firmware/leds/led_top_tbw_selfcheck_beh.vhd
Added: trunk/firmware/leds/blinking_led/README
===================================================================
--- trunk/firmware/leds/blinking_led/README (rev 0)
+++ trunk/firmware/leds/blinking_led/README 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,4 @@
+This is a very simple IP that blink a LED. On apf9328-devfull, the led is
+already soldered. On apf9328-devlight, it must be soldered according to
+figure here:
+http://www.armadeus.com/wiki/index.php?title=Une_led_qui_clignote_avec_le_spartan_3
Added: trunk/firmware/leds/blinking_led/blinking_led_xc3s200.bit
===================================================================
(Binary files differ)
Property changes on: trunk/firmware/leds/blinking_led/blinking_led_xc3s200.bit
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/firmware/leds/blinking_led/blinking_led_xc3s400.bit
===================================================================
(Binary files differ)
Property changes on: trunk/firmware/leds/blinking_led/blinking_led_xc3s400.bit
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/firmware/leds/blinking_led/led_wiring.dia
===================================================================
(Binary files differ)
Property changes on: trunk/firmware/leds/blinking_led/led_wiring.dia
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/firmware/leds/blinking_led/src/led_blink.ucf
===================================================================
--- trunk/firmware/leds/blinking_led/src/led_blink.ucf (rev 0)
+++ trunk/firmware/leds/blinking_led/src/led_blink.ucf 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,7 @@
+# Clock at 96MHz
+NET "Clk" LOC = "P55";
+NET "Clk" TNM_NET = "Clk";
+TIMESPEC "TS_Clk" = PERIOD "Clk" 10 ns HIGH 50 %;
+# LED
+NET "led_cathode" LOC = "P118"| IOSTANDARD = LVCMOS33 ;
+NET "led_anode" LOC = "P116"| IOSTANDARD = LVCMOS33 ;
Added: trunk/firmware/leds/blinking_led/src/led_blink.vhd
===================================================================
--- trunk/firmware/leds/blinking_led/src/led_blink.vhd (rev 0)
+++ trunk/firmware/leds/blinking_led/src/led_blink.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,52 @@
+---------------------------------------------------------------------------
+-- Company : ARMades Systems
+-- Author(s) : Fabien Marteau <fab...@ar...>
+--
+-- Creation Date : 05/03/2009
+-- File : led_blink.vhd
+--
+-- Abstract :
+--
+---------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+entity Clk_div_led is
+ Port (
+ Clk : in std_logic;
+ led_cathode : out std_logic;
+ led_anode : out std_logic
+ );
+end Clk_div_led;
+
+architecture RTL of Clk_div_led is
+ constant max_count : natural := 48000000;
+ signal Rst_n : std_logic;
+begin
+
+ Rst_n <= '1';
+ led_cathode <= '0';
+
+ -- compteur de 0 à max_count
+ compteur : process(Clk)
+ variable count : natural range 0 to max_count;
+ begin
+ if Rst_n = '0' then
+ count := 0;
+ led_anode <= '1';
+ elsif rising_edge(Clk) then
+ if count < max_count/2 then
+ led_anode <='1';
+ count := count + 1;
+ elsif count < max_count then
+ led_anode <='0';
+ count := count + 1;
+ else
+ count := 0;
+ led_anode <='1';
+ end if;
+ end if;
+ end process compteur;
+end RTL;
Added: trunk/firmware/leds/blinking_led/testbench/led_blink_tb.vhd
===================================================================
--- trunk/firmware/leds/blinking_led/testbench/led_blink_tb.vhd (rev 0)
+++ trunk/firmware/leds/blinking_led/testbench/led_blink_tb.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,40 @@
+---------------------------------------------------------------------------
+-- Company : ARMades Systems
+-- Author(s) : Fabien Marteau <fab...@ar...>
+--
+-- Creation Date : 05/03/2009
+-- File : led_blink_tb.vhd
+--
+-- Abstract :
+--
+---------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+---------------------------------------------------------------------------
+Entity led_blink_tb is
+---------------------------------------------------------------------------
+end entity;
+
+
+---------------------------------------------------------------------------
+Architecture led_blink_tb_1 of led_blink_tb is
+---------------------------------------------------------------------------
+
+ component Clk_div_led
+ port (
+ Clk : in std_logic;
+ led_cathode : out std_logic;
+ led_anode : out std_logic
+ );
+ end component Clk_div_led;
+
+
+begin
+
+ assert false report "TODO: testbench" severity error;
+
+end architecture led_blink_tb_1;
+
Added: trunk/firmware/leds/blinking_led/testbench/tags
===================================================================
--- trunk/firmware/leds/blinking_led/testbench/tags (rev 0)
+++ trunk/firmware/leds/blinking_led/testbench/tags 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,9 @@
+!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
+!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
+!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhi...@us.../
+!_TAG_PROGRAM_NAME Exuberant Ctags //
+!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
+!_TAG_PROGRAM_VERSION 5.7 //
+Clk_div_led ../src/led_blink.vhd /^entity Clk_div_led is$/;" e
+RTL ../src/led_blink.vhd /^architecture RTL of Clk_div_led is$/;" a
+compteur ../src/led_blink.vhd /^ compteur : process(Clk)$/;" p
Copied: trunk/firmware/leds/button_led/clock_divider.vhd (from rev 1115, trunk/firmware/leds/clock_divider.vhd)
===================================================================
--- trunk/firmware/leds/button_led/clock_divider.vhd (rev 0)
+++ trunk/firmware/leds/button_led/clock_divider.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,70 @@
+----------------------------------------------------------------------------------
+-- Company: Armadeus Project
+-- Engineer: Benoit Canet
+--
+-- Create Date: 22:04:02 04/12/2007
+-- Design Name:
+-- Module Name: clock_divider - behavioral
+-- Project Name:
+-- Target Devices:
+-- Tool versions:
+-- Description:
+--
+-- Dependencies:
+--
+-- Revision:
+-- Revision 0.01 - File Created
+-- Additional Comments:
+--
+----------------------------------------------------------------------------------
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+
+entity clock_divider is
+
+ -- clock division ratio (must be a multiple of 2)
+ generic(ratio : integer := 2);
+
+ port (clk_in : in STD_LOGIC;
+ clk_out : out STD_LOGIC);
+
+end clock_divider;
+
+architecture behavioral of clock_divider is
+
+ signal state : STD_LOGIC := '0';
+
+begin
+
+ process (clk_in)
+
+ variable count : integer range 0 to ratio;
+
+ begin
+
+ if (clk_in'event) and (clk_in = '1') then
+
+ -- count the number of clock change
+ count := count + 1;
+
+ -- if we waited long enough generate one clock change
+ if (count = ratio/2) then
+ state <= not state;
+ count := 0;
+ clk_out <= state;
+ end if;
+
+ end if;
+
+ end process;
+
+
+
+end behavioral;
+
+
+
+
Copied: trunk/firmware/leds/button_led/debouncer.vhd (from rev 1115, trunk/firmware/leds/debouncer.vhd)
===================================================================
--- trunk/firmware/leds/button_led/debouncer.vhd (rev 0)
+++ trunk/firmware/leds/button_led/debouncer.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,64 @@
+----------------------------------------------------------------------------------
+-- Company: Armadeus Project
+-- Engineer: Benoit Canet
+--
+-- Create Date: 21:48:05 04/12/2007
+-- Design Name:
+-- Module Name: debouncer - behavioral
+-- Project Name:
+-- Target Devices:
+-- Tool versions:
+-- Description:
+--
+-- Dependencies:
+--
+-- Revision:
+-- Revision 0.01 - File Created
+-- Additional Comments:
+-- original code comes from Dennis Smith
+-- http://homepage.mac.com/dgsmith1/HANDOUTS/EE452/debounce.vhd.txt
+----------------------------------------------------------------------------------
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+
+entity debouncer is
+ port ( clk_100hz : in STD_LOGIC;
+ button_in : in STD_LOGIC;
+ button_debounced_out : out STD_LOGIC);
+end debouncer;
+
+architecture behavioral of debouncer is
+
+ signal shift_pb : STD_LOGIC_VECTOR(3 DOWNTO 0) := "0000";
+ signal state : STD_LOGIC := '1';
+
+begin
+
+ process(clk_100hz)
+ begin
+ if (clk_100hz'event) and (clk_100hz = '1')
+ then
+ -- shift the register
+ shift_pb(2 DOWNTO 0) <= shift_pb(3 DOWNTO 1);
+ -- input the new sample in the register
+ shift_pb(3) <= button_in;
+ -- change output if needed
+ case shift_pb is
+ when "0000" =>
+ state <= '0';
+ when "1111" =>
+ state <= '1';
+ when others =>
+ state <= state;
+ end case;
+ end if;
+
+ end process;
+
+ button_debounced_out <= state;
+
+end behavioral;
+
Copied: trunk/firmware/leds/button_led/flip_flop.vhd (from rev 1115, trunk/firmware/leds/flip_flop.vhd)
===================================================================
--- trunk/firmware/leds/button_led/flip_flop.vhd (rev 0)
+++ trunk/firmware/leds/button_led/flip_flop.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,55 @@
+----------------------------------------------------------------------------------
+-- Company: Armadeus Project
+-- Engineer: Benoit Canet
+--
+-- Create Date: 21:21:27 04/12/2007
+-- Design Name:
+-- Module Name: flip_flop - Behavioral
+-- Project Name:
+-- Target Devices:
+-- Tool versions:
+-- Description:
+--
+-- Dependencies:
+--
+-- Revision:
+-- Revision 0.01 - File Created
+-- Additional Comments:
+--
+----------------------------------------------------------------------------------
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+
+entity flip_flop is
+ port (clk_100hz : in STD_LOGIC;
+ switch_in_n : in STD_LOGIC;
+ led_out : out STD_LOGIC);
+end flip_flop;
+
+
+architecture behavioral of flip_flop is
+
+begin
+
+ process(clk_100hz)
+ variable state : STD_LOGIC := '0';
+ variable latch : STD_LOGIC := '0';
+ begin
+ if clk_100hz'event and (clk_100hz = '1') then
+ -- switch_in_n is active when down
+ --( the switch is connected via a pullup)
+ if (switch_in_n = '0') and (latch /= switch_in_n) then
+ state := not state;
+ end if;
+ latch := switch_in_n;
+ led_out <= state;
+
+ end if;
+
+ end process;
+
+end behavioral;
+
Copied: trunk/firmware/leds/button_led/led.ucf (from rev 1115, trunk/firmware/leds/led.ucf)
===================================================================
--- trunk/firmware/leds/button_led/led.ucf (rev 0)
+++ trunk/firmware/leds/button_led/led.ucf 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,4 @@
+# pinout
+NET "button" LOC = "P141" | IOSTANDARD = LVCMOS33 ;
+NET "clk" LOC = "P55" | IOSTANDARD = LVCMOS33 ;
+NET "led" LOC = "P116" | IOSTANDARD = LVCMOS33 ;
Copied: trunk/firmware/leds/button_led/led_top.bin (from rev 1115, trunk/firmware/leds/led_top.bin)
===================================================================
(Binary files differ)
Copied: trunk/firmware/leds/button_led/led_top.dia (from rev 1115, trunk/firmware/leds/led_top.dia)
===================================================================
(Binary files differ)
Copied: trunk/firmware/leds/button_led/led_top.vhd (from rev 1115, trunk/firmware/leds/led_top.vhd)
===================================================================
--- trunk/firmware/leds/button_led/led_top.vhd (rev 0)
+++ trunk/firmware/leds/button_led/led_top.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,83 @@
+----------------------------------------------------------------------------------
+-- Company: Armadeus Project
+-- Engineer: Benoit Canet
+--
+-- Create Date: 22:37:46 04/12/2007
+-- Design Name:
+-- Module Name: led_top - structural
+-- Project Name:
+-- Target Devices:
+-- Tool versions:
+-- Description:
+--
+-- Dependencies:
+--
+-- Revision:
+-- Revision 0.01 - File Created
+-- Additional Comments:
+--
+----------------------------------------------------------------------------------
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+entity led_top is
+ port (
+ clk : in STD_LOGIC;
+ button : in STD_LOGIC;
+ led : out STD_LOGIC);
+end led_top;
+
+architecture structural of led_top is
+
+ -- We declare the component we we'll use
+ component clock_divider
+ generic (ratio: integer);
+ port (clk_in : in STD_LOGIC;
+ clk_out : out STD_LOGIC);
+ end component;
+
+ component debouncer
+ port (clk_100hz : in STD_LOGIC;
+ button_in : in STD_LOGIC;
+ button_debounced_out : out STD_LOGIC);
+ end component;
+
+ component flip_flop
+ port (clk_100hz : in STD_LOGIC;
+ switch_in_n : in STD_LOGIC;
+ led_out : out STD_LOGIC);
+ end component;
+
+ -- internal signals
+ signal clk_100hz : STD_LOGIC;
+ signal button_debounced_n : STD_LOGIC;
+
+ begin
+
+ -- instantiate and connect the clock divider
+ -- here we use a 96MHz/100Hz=960000 ratio
+ i_clock_divider_identifier : clock_divider
+ generic map(ratio => 960000)
+ -- for simulation purpose use the following line
+ -- instead of the previous
+ -- generic map(ratio => 2)
+
+ port map (clk_in => clk,
+ clk_out => clk_100hz);
+
+ --instantiate and connect the debouncer
+ i_debouncer_identifier : debouncer
+ port map (button_in => button,
+ clk_100hz => clk_100hz,
+ button_debounced_out => button_debounced_n);
+
+ --instantiate and connect the flip flop
+ i_flip_flop_identifier : flip_flop
+ port map (clk_100hz => clk_100hz,
+ switch_in_n => button_debounced_n,
+ led_out => led);
+
+end structural;
+
Copied: trunk/firmware/leds/button_led/led_top_200k.bit (from rev 1115, trunk/firmware/leds/led_top_200k.bit)
===================================================================
(Binary files differ)
Copied: trunk/firmware/leds/button_led/led_top_400k.bit (from rev 1115, trunk/firmware/leds/led_top_400k.bit)
===================================================================
(Binary files differ)
Copied: trunk/firmware/leds/button_led/led_top_tbw_selfcheck_beh.vhd (from rev 1115, trunk/firmware/leds/led_top_tbw_selfcheck_beh.vhd)
===================================================================
--- trunk/firmware/leds/button_led/led_top_tbw_selfcheck_beh.vhd (rev 0)
+++ trunk/firmware/leds/button_led/led_top_tbw_selfcheck_beh.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -0,0 +1,228 @@
+--------------------------------------------------------------------------------
+-- Copyright (c) 1995-2003 Xilinx, Inc.
+-- All Right Reserved.
+--------------------------------------------------------------------------------
+-- ____ ____
+-- / /\/ /
+-- /___/ \ / Vendor: Xilinx
+-- \ \ \/ Version : 9.1i
+-- \ \ Application : ISE
+-- / / Filename : led_top_tbw_selfcheck.vhw
+-- /___/ /\ Timestamp : Fri Apr 13 22:51:44 2007
+-- \ \ / \
+-- \___\/\___\
+--
+--Command:
+--Design Name: led_top_tbw_selfcheck_beh
+--Device: Xilinx
+--
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+USE IEEE.STD_LOGIC_TEXTIO.ALL;
+USE STD.TEXTIO.ALL;
+
+ENTITY led_top_tbw_selfcheck_beh IS
+END led_top_tbw_selfcheck_beh;
+
+ARCHITECTURE testbench_arch OF led_top_tbw_selfcheck_beh IS
+ COMPONENT led_top
+ PORT (
+ DataxD : InOut std_logic_vector (15 DownTo 0);
+ AddrxDI : In std_logic_vector (12 DownTo 0);
+ WRxBI : In std_logic;
+ RDxBI : In std_logic;
+ CSxBI : In std_logic;
+ clk : In std_logic;
+ button : In std_logic;
+ led : Out std_logic
+ );
+ END COMPONENT;
+
+ SIGNAL DataxD : std_logic_vector (15 DownTo 0) := "0000000000000000";
+ SIGNAL AddrxDI : std_logic_vector (12 DownTo 0) := "0000000000000";
+ SIGNAL WRxBI : std_logic := '0';
+ SIGNAL RDxBI : std_logic := '0';
+ SIGNAL CSxBI : std_logic := '0';
+ SIGNAL clk : std_logic := '0';
+ SIGNAL button : std_logic := '0';
+ SIGNAL led : std_logic := 'U';
+
+ SHARED VARIABLE TX_ERROR : INTEGER := 0;
+ SHARED VARIABLE TX_OUT : LINE;
+
+ constant PERIOD : time := 20 ns;
+ constant DUTY_CYCLE : real := 0.5;
+ constant OFFSET : time := 100 ns;
+
+ BEGIN
+ UUT : led_top
+ PORT MAP (
+ DataxD => DataxD,
+ AddrxDI => AddrxDI,
+ WRxBI => WRxBI,
+ RDxBI => RDxBI,
+ CSxBI => CSxBI,
+ clk => clk,
+ button => button,
+ led => led
+ );
+
+ PROCESS -- clock process for clk
+ BEGIN
+ WAIT for OFFSET;
+ CLOCK_LOOP : LOOP
+ clk <= '0';
+ WAIT FOR (PERIOD - (PERIOD * DUTY_CYCLE));
+ clk <= '1';
+ WAIT FOR (PERIOD * DUTY_CYCLE);
+ END LOOP CLOCK_LOOP;
+ END PROCESS;
+
+ PROCESS
+ PROCEDURE CHECK_led(
+ next_led : std_logic;
+ TX_TIME : INTEGER
+ ) IS
+ VARIABLE TX_STR : String(1 to 4096);
+ VARIABLE TX_LOC : LINE;
+ BEGIN
+ IF (led /= next_led) THEN
+ STD.TEXTIO.write(TX_LOC, string'("Error at time="));
+ STD.TEXTIO.write(TX_LOC, TX_TIME);
+ STD.TEXTIO.write(TX_LOC, string'("ns led="));
+ IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, led);
+ STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
+ IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_led);
+ STD.TEXTIO.write(TX_LOC, string'(" "));
+ TX_STR(TX_LOC.all'range) := TX_LOC.all;
+ STD.TEXTIO.Deallocate(TX_LOC);
+ ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
+ TX_ERROR := TX_ERROR + 1;
+ END IF;
+ END;
+ BEGIN
+ -- ------------- Current Time: 129ns
+ WAIT FOR 129 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 131ns
+ WAIT FOR 2 ns;
+ CHECK_led('0', 131);
+ -- -------------------------------------
+ -- ------------- Current Time: 169ns
+ WAIT FOR 38 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 171ns
+ WAIT FOR 2 ns;
+ CHECK_led('1', 171);
+ -- -------------------------------------
+ -- ------------- Current Time: 189ns
+ WAIT FOR 18 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 209ns
+ WAIT FOR 20 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 249ns
+ WAIT FOR 40 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 269ns
+ WAIT FOR 20 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 309ns
+ WAIT FOR 40 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 369ns
+ WAIT FOR 60 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 549ns
+ WAIT FOR 180 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 669ns
+ WAIT FOR 120 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 809ns
+ WAIT FOR 140 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 1029ns
+ WAIT FOR 220 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 1251ns
+ WAIT FOR 222 ns;
+ CHECK_led('0', 1251);
+ -- -------------------------------------
+ -- ------------- Current Time: 1409ns
+ WAIT FOR 158 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 2709ns
+ WAIT FOR 1300 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 2931ns
+ WAIT FOR 222 ns;
+ CHECK_led('1', 2931);
+ -- -------------------------------------
+ -- ------------- Current Time: 4269ns
+ WAIT FOR 1338 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 4309ns
+ WAIT FOR 40 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 4769ns
+ WAIT FOR 460 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 5429ns
+ WAIT FOR 660 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 5651ns
+ WAIT FOR 222 ns;
+ CHECK_led('0', 5651);
+ -- -------------------------------------
+ -- ------------- Current Time: 6629ns
+ WAIT FOR 978 ns;
+ button <= '1';
+ -- -------------------------------------
+ -- ------------- Current Time: 8269ns
+ WAIT FOR 1640 ns;
+ button <= '0';
+ -- -------------------------------------
+ -- ------------- Current Time: 8491ns
+ WAIT FOR 222 ns;
+ CHECK_led('1', 8491);
+ -- -------------------------------------
+ WAIT FOR 1529 ns;
+
+ IF (TX_ERROR = 0) THEN
+ STD.TEXTIO.write(TX_OUT, string'("No errors or warnings"));
+ ASSERT (FALSE) REPORT
+ "Simulation successful (not a failure). No problems detected."
+ SEVERITY FAILURE;
+ ELSE
+ STD.TEXTIO.write(TX_OUT, TX_ERROR);
+ STD.TEXTIO.write(TX_OUT,
+ string'(" errors found in simulation"));
+ ASSERT (FALSE) REPORT "Errors found during simulation"
+ SEVERITY FAILURE;
+ END IF;
+ END PROCESS;
+
+ END testbench_arch;
+
Deleted: trunk/firmware/leds/clock_divider.vhd
===================================================================
--- trunk/firmware/leds/clock_divider.vhd 2009-03-05 09:49:29 UTC (rev 1115)
+++ trunk/firmware/leds/clock_divider.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -1,70 +0,0 @@
-----------------------------------------------------------------------------------
--- Company: Armadeus Project
--- Engineer: Benoit Canet
---
--- Create Date: 22:04:02 04/12/2007
--- Design Name:
--- Module Name: clock_divider - behavioral
--- Project Name:
--- Target Devices:
--- Tool versions:
--- Description:
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
-----------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.STD_LOGIC_ARITH.ALL;
-use IEEE.STD_LOGIC_UNSIGNED.ALL;
-
-
-entity clock_divider is
-
- -- clock division ratio (must be a multiple of 2)
- generic(ratio : integer := 2);
-
- port (clk_in : in STD_LOGIC;
- clk_out : out STD_LOGIC);
-
-end clock_divider;
-
-architecture behavioral of clock_divider is
-
- signal state : STD_LOGIC := '0';
-
-begin
-
- process (clk_in)
-
- variable count : integer range 0 to ratio;
-
- begin
-
- if (clk_in'event) and (clk_in = '1') then
-
- -- count the number of clock change
- count := count + 1;
-
- -- if we waited long enough generate one clock change
- if (count = ratio/2) then
- state <= not state;
- count := 0;
- clk_out <= state;
- end if;
-
- end if;
-
- end process;
-
-
-
-end behavioral;
-
-
-
-
Deleted: trunk/firmware/leds/debouncer.vhd
===================================================================
--- trunk/firmware/leds/debouncer.vhd 2009-03-05 09:49:29 UTC (rev 1115)
+++ trunk/firmware/leds/debouncer.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -1,64 +0,0 @@
-----------------------------------------------------------------------------------
--- Company: Armadeus Project
--- Engineer: Benoit Canet
---
--- Create Date: 21:48:05 04/12/2007
--- Design Name:
--- Module Name: debouncer - behavioral
--- Project Name:
--- Target Devices:
--- Tool versions:
--- Description:
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
--- original code comes from Dennis Smith
--- http://homepage.mac.com/dgsmith1/HANDOUTS/EE452/debounce.vhd.txt
-----------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.STD_LOGIC_ARITH.ALL;
-use IEEE.STD_LOGIC_UNSIGNED.ALL;
-
-
-entity debouncer is
- port ( clk_100hz : in STD_LOGIC;
- button_in : in STD_LOGIC;
- button_debounced_out : out STD_LOGIC);
-end debouncer;
-
-architecture behavioral of debouncer is
-
- signal shift_pb : STD_LOGIC_VECTOR(3 DOWNTO 0) := "0000";
- signal state : STD_LOGIC := '1';
-
-begin
-
- process(clk_100hz)
- begin
- if (clk_100hz'event) and (clk_100hz = '1')
- then
- -- shift the register
- shift_pb(2 DOWNTO 0) <= shift_pb(3 DOWNTO 1);
- -- input the new sample in the register
- shift_pb(3) <= button_in;
- -- change output if needed
- case shift_pb is
- when "0000" =>
- state <= '0';
- when "1111" =>
- state <= '1';
- when others =>
- state <= state;
- end case;
- end if;
-
- end process;
-
- button_debounced_out <= state;
-
-end behavioral;
-
Deleted: trunk/firmware/leds/flip_flop.vhd
===================================================================
--- trunk/firmware/leds/flip_flop.vhd 2009-03-05 09:49:29 UTC (rev 1115)
+++ trunk/firmware/leds/flip_flop.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -1,55 +0,0 @@
-----------------------------------------------------------------------------------
--- Company: Armadeus Project
--- Engineer: Benoit Canet
---
--- Create Date: 21:21:27 04/12/2007
--- Design Name:
--- Module Name: flip_flop - Behavioral
--- Project Name:
--- Target Devices:
--- Tool versions:
--- Description:
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
-----------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.STD_LOGIC_ARITH.ALL;
-use IEEE.STD_LOGIC_UNSIGNED.ALL;
-
-
-entity flip_flop is
- port (clk_100hz : in STD_LOGIC;
- switch_in_n : in STD_LOGIC;
- led_out : out STD_LOGIC);
-end flip_flop;
-
-
-architecture behavioral of flip_flop is
-
-begin
-
- process(clk_100hz)
- variable state : STD_LOGIC := '0';
- variable latch : STD_LOGIC := '0';
- begin
- if clk_100hz'event and (clk_100hz = '1') then
- -- switch_in_n is active when down
- --( the switch is connected via a pullup)
- if (switch_in_n = '0') and (latch /= switch_in_n) then
- state := not state;
- end if;
- latch := switch_in_n;
- led_out <= state;
-
- end if;
-
- end process;
-
-end behavioral;
-
Deleted: trunk/firmware/leds/led.ucf
===================================================================
--- trunk/firmware/leds/led.ucf 2009-03-05 09:49:29 UTC (rev 1115)
+++ trunk/firmware/leds/led.ucf 2009-03-05 11:22:39 UTC (rev 1116)
@@ -1,4 +0,0 @@
-# pinout
-NET "button" LOC = "P141" | IOSTANDARD = LVCMOS33 ;
-NET "clk" LOC = "P55" | IOSTANDARD = LVCMOS33 ;
-NET "led" LOC = "P116" | IOSTANDARD = LVCMOS33 ;
Deleted: trunk/firmware/leds/led_top.bin
===================================================================
(Binary files differ)
Deleted: trunk/firmware/leds/led_top.dia
===================================================================
(Binary files differ)
Deleted: trunk/firmware/leds/led_top.vhd
===================================================================
--- trunk/firmware/leds/led_top.vhd 2009-03-05 09:49:29 UTC (rev 1115)
+++ trunk/firmware/leds/led_top.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -1,83 +0,0 @@
-----------------------------------------------------------------------------------
--- Company: Armadeus Project
--- Engineer: Benoit Canet
---
--- Create Date: 22:37:46 04/12/2007
--- Design Name:
--- Module Name: led_top - structural
--- Project Name:
--- Target Devices:
--- Tool versions:
--- Description:
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
-----------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.STD_LOGIC_ARITH.ALL;
-use IEEE.STD_LOGIC_UNSIGNED.ALL;
-
-entity led_top is
- port (
- clk : in STD_LOGIC;
- button : in STD_LOGIC;
- led : out STD_LOGIC);
-end led_top;
-
-architecture structural of led_top is
-
- -- We declare the component we we'll use
- component clock_divider
- generic (ratio: integer);
- port (clk_in : in STD_LOGIC;
- clk_out : out STD_LOGIC);
- end component;
-
- component debouncer
- port (clk_100hz : in STD_LOGIC;
- button_in : in STD_LOGIC;
- button_debounced_out : out STD_LOGIC);
- end component;
-
- component flip_flop
- port (clk_100hz : in STD_LOGIC;
- switch_in_n : in STD_LOGIC;
- led_out : out STD_LOGIC);
- end component;
-
- -- internal signals
- signal clk_100hz : STD_LOGIC;
- signal button_debounced_n : STD_LOGIC;
-
- begin
-
- -- instantiate and connect the clock divider
- -- here we use a 96MHz/100Hz=960000 ratio
- i_clock_divider_identifier : clock_divider
- generic map(ratio => 960000)
- -- for simulation purpose use the following line
- -- instead of the previous
- -- generic map(ratio => 2)
-
- port map (clk_in => clk,
- clk_out => clk_100hz);
-
- --instantiate and connect the debouncer
- i_debouncer_identifier : debouncer
- port map (button_in => button,
- clk_100hz => clk_100hz,
- button_debounced_out => button_debounced_n);
-
- --instantiate and connect the flip flop
- i_flip_flop_identifier : flip_flop
- port map (clk_100hz => clk_100hz,
- switch_in_n => button_debounced_n,
- led_out => led);
-
-end structural;
-
Deleted: trunk/firmware/leds/led_top_200k.bit
===================================================================
(Binary files differ)
Deleted: trunk/firmware/leds/led_top_400k.bit
===================================================================
(Binary files differ)
Deleted: trunk/firmware/leds/led_top_tbw_selfcheck_beh.vhd
===================================================================
--- trunk/firmware/leds/led_top_tbw_selfcheck_beh.vhd 2009-03-05 09:49:29 UTC (rev 1115)
+++ trunk/firmware/leds/led_top_tbw_selfcheck_beh.vhd 2009-03-05 11:22:39 UTC (rev 1116)
@@ -1,228 +0,0 @@
---------------------------------------------------------------------------------
--- Copyright (c) 1995-2003 Xilinx, Inc.
--- All Right Reserved.
---------------------------------------------------------------------------------
--- ____ ____
--- / /\/ /
--- /___/ \ / Vendor: Xilinx
--- \ \ \/ Version : 9.1i
--- \ \ Application : ISE
--- / / Filename : led_top_tbw_selfcheck.vhw
--- /___/ /\ Timestamp : Fri Apr 13 22:51:44 2007
--- \ \ / \
--- \___\/\___\
---
---Command:
---Design Name: led_top_tbw_selfcheck_beh
---Device: Xilinx
---
-
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.STD_LOGIC_ARITH.ALL;
-use IEEE.STD_LOGIC_UNSIGNED.ALL;
-USE IEEE.STD_LOGIC_TEXTIO.ALL;
-USE STD.TEXTIO.ALL;
-
-ENTITY led_top_tbw_selfcheck_beh IS
-END led_top_tbw_selfcheck_beh;
-
-ARCHITECTURE testbench_arch OF led_top_tbw_selfcheck_beh IS
- COMPONENT led_top
- PORT (
- DataxD : InOut std_logic_vector (15 DownTo 0);
- AddrxDI : In std_logic_vector (12 DownTo 0);
- WRxBI : In std_logic;
- RDxBI : In std_logic;
- CSxBI : In std_logic;
- clk : In std_logic;
- button : In std_logic;
- led : Out std_logic
- );
- END COMPONENT;
-
- SIGNAL DataxD : std_logic_vector (15 DownTo 0) := "0000000000000000";
- SIGNAL AddrxDI : std_logic_vector (12 DownTo 0) := "0000000000000";
- SIGNAL WRxBI : std_logic := '0';
- SIGNAL RDxBI : std_logic := '0';
- SIGNAL CSxBI : std_logic := '0';
- SIGNAL clk : std_logic := '0';
- SIGNAL button : std_logic := '0';
- SIGNAL led : std_logic := 'U';
-
- SHARED VARIABLE TX_ERROR : INTEGER := 0;
- SHARED VARIABLE TX_OUT : LINE;
-
- constant PERIOD : time := 20 ns;
- constant DUTY_CYCLE : real := 0.5;
- constant OFFSET : time := 100 ns;
-
- BEGIN
- UUT : led_top
- PORT MAP (
- DataxD => DataxD,
- AddrxDI => AddrxDI,
- WRxBI => WRxBI,
- RDxBI => RDxBI,
- CSxBI => CSxBI,
- clk => clk,
- button => button,
- led => led
- );
-
- PROCESS -- clock process for clk
- BEGIN
- WAIT for OFFSET;
- CLOCK_LOOP : LOOP
- clk <= '0';
- WAIT FOR (PERIOD - (PERIOD * DUTY_CYCLE));
- clk <= '1';
- WAIT FOR (PERIOD * DUTY_CYCLE);
- END LOOP CLOCK_LOOP;
- END PROCESS;
-
- PROCESS
- PROCEDURE CHECK_led(
- next_led : std_logic;
- TX_TIME : INTEGER
- ) IS
- VARIABLE TX_STR : String(1 to 4096);
- VARIABLE TX_LOC : LINE;
- BEGIN
- IF (led /= next_led) THEN
- STD.TEXTIO.write(TX_LOC, string'("Error at time="));
- STD.TEXTIO.write(TX_LOC, TX_TIME);
- STD.TEXTIO.write(TX_LOC, string'("ns led="));
- IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, led);
- STD.TEXTIO.write(TX_LOC, string'(", Expected = "));
- IEEE.STD_LOGIC_TEXTIO.write(TX_LOC, next_led);
- STD.TEXTIO.write(TX_LOC, string'(" "));
- TX_STR(TX_LOC.all'range) := TX_LOC.all;
- STD.TEXTIO.Deallocate(TX_LOC);
- ASSERT (FALSE) REPORT TX_STR SEVERITY ERROR;
- TX_ERROR := TX_ERROR + 1;
- END IF;
- END;
- BEGIN
- -- ------------- Current Time: 129ns
- WAIT FOR 129 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 131ns
- WAIT FOR 2 ns;
- CHECK_led('0', 131);
- -- -------------------------------------
- -- ------------- Current Time: 169ns
- WAIT FOR 38 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 171ns
- WAIT FOR 2 ns;
- CHECK_led('1', 171);
- -- -------------------------------------
- -- ------------- Current Time: 189ns
- WAIT FOR 18 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 209ns
- WAIT FOR 20 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 249ns
- WAIT FOR 40 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 269ns
- WAIT FOR 20 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 309ns
- WAIT FOR 40 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 369ns
- WAIT FOR 60 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 549ns
- WAIT FOR 180 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 669ns
- WAIT FOR 120 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 809ns
- WAIT FOR 140 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 1029ns
- WAIT FOR 220 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 1251ns
- WAIT FOR 222 ns;
- CHECK_led('0', 1251);
- -- -------------------------------------
- -- ------------- Current Time: 1409ns
- WAIT FOR 158 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 2709ns
- WAIT FOR 1300 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 2931ns
- WAIT FOR 222 ns;
- CHECK_led('1', 2931);
- -- -------------------------------------
- -- ------------- Current Time: 4269ns
- WAIT FOR 1338 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 4309ns
- WAIT FOR 40 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 4769ns
- WAIT FOR 460 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 5429ns
- WAIT FOR 660 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 5651ns
- WAIT FOR 222 ns;
- CHECK_led('0', 5651);
- -- -------------------------------------
- -- ------------- Current Time: 6629ns
- WAIT FOR 978 ns;
- button <= '1';
- -- -------------------------------------
- -- ------------- Current Time: 8269ns
- WAIT FOR 1640 ns;
- button <= '0';
- -- -------------------------------------
- -- ------------- Current Time: 8491ns
- WAIT FOR 222 ns;
- CHECK_led('1', 8491);
- -- -------------------------------------
- WAIT FOR 1529 ns;
-
- IF (TX_ERROR = 0) THEN
- STD.TEXTIO.write(TX_OUT, string'("No errors or warnings"));
- ASSERT (FALSE) REPORT
- "Simulation successful (not a failure). No problems detected."
- SEVERITY FAILURE;
- ELSE
- STD.TEXTIO.write(TX_OUT, TX_ERROR);
- STD.TEXTIO.write(TX_OUT,
- string'(" errors found in simulation"));
- ASSERT (FALSE) REPORT "Errors found during simulation"
- SEVERITY FAILURE;
- END IF;
- END PROCESS;
-
- END testbench_arch;
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Fa...@us...> - 2009-03-05 09:49:46
|
Revision: 1115
http://armadeus.svn.sourceforge.net/armadeus/?rev=1115&view=rev
Author: FabM
Date: 2009-03-05 09:49:29 +0000 (Thu, 05 Mar 2009)
Log Message:
-----------
[FIRMWARE] Adding sub-directory for leds blinking_led and button_led
Added Paths:
-----------
trunk/firmware/leds/
trunk/firmware/leds/blinking_led/
trunk/firmware/leds/button_led/
trunk/firmware/leds/led.ucf
trunk/firmware/leds/led_top.dia
trunk/firmware/leds/led_top.vhd
trunk/firmware/leds/led_top_200k.bit
trunk/firmware/leds/led_top_400k.bit
Removed Paths:
-------------
trunk/firmware/led/
trunk/firmware/leds/led.ucf
trunk/firmware/leds/led_top.bit
trunk/firmware/leds/led_top.dia
trunk/firmware/leds/led_top.vhd
Deleted: trunk/firmware/leds/led.ucf
===================================================================
--- trunk/firmware/led/led.ucf 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/firmware/leds/led.ucf 2009-03-05 09:49:29 UTC (rev 1115)
@@ -1,44 +0,0 @@
-#PACE: Start of Constraints generated by PACE
-
-#PACE: Start of PACE I/O Pin Assignments
-NET "AddrxDI<0>" LOC = "P21" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<10>" LOC = "P33" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<11>" LOC = "P35" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<12>" LOC = "P36" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<1>" LOC = "P23" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<2>" LOC = "P24" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<3>" LOC = "P25" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<4>" LOC = "P26" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<5>" LOC = "P27" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<6>" LOC = "P28" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<7>" LOC = "P30" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<8>" LOC = "P31" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<9>" LOC = "P32" | IOSTANDARD = LVCMOS33 ;
-NET "button" LOC = "P119" | IOSTANDARD = LVCMOS33 ;
-NET "clk" LOC = "P55" | IOSTANDARD = LVCMOS33 ;
-NET "CSxBI" LOC = "P59" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<0>" LOC = "P1" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<10>" LOC = "P13" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<11>" LOC = "P14" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<12>" LOC = "P15" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<13>" LOC = "P17" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<14>" LOC = "P18" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<15>" LOC = "P20" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<1>" LOC = "P2" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<2>" LOC = "P4" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<3>" LOC = "P5" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<4>" LOC = "P6" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<5>" LOC = "P7" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<6>" LOC = "P8" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<7>" LOC = "P10" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<8>" LOC = "P11" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<9>" LOC = "P12" | IOSTANDARD = LVCMOS33 ;
-NET "led" LOC = "P118" | IOSTANDARD = LVCMOS33 ;
-NET "RDxBI" LOC = "P63" | IOSTANDARD = LVCMOS33 ;
-NET "WRxBI" LOC = "P60" | IOSTANDARD = LVCMOS33 ;
-
-#PACE: Start of PACE Area Constraints
-
-#PACE: Start of PACE Prohibit Constraints
-
-#PACE: End of Constraints generated by PACE
Copied: trunk/firmware/leds/led.ucf (from rev 1111, trunk/firmware/led/led.ucf)
===================================================================
--- trunk/firmware/leds/led.ucf (rev 0)
+++ trunk/firmware/leds/led.ucf 2009-03-05 09:49:29 UTC (rev 1115)
@@ -0,0 +1,4 @@
+# pinout
+NET "button" LOC = "P141" | IOSTANDARD = LVCMOS33 ;
+NET "clk" LOC = "P55" | IOSTANDARD = LVCMOS33 ;
+NET "led" LOC = "P116" | IOSTANDARD = LVCMOS33 ;
Deleted: trunk/firmware/leds/led_top.bit
===================================================================
(Binary files differ)
Deleted: trunk/firmware/leds/led_top.dia
===================================================================
(Binary files differ)
Copied: trunk/firmware/leds/led_top.dia (from rev 1111, trunk/firmware/led/led_top.dia)
===================================================================
(Binary files differ)
Deleted: trunk/firmware/leds/led_top.vhd
===================================================================
--- trunk/firmware/led/led_top.vhd 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/firmware/leds/led_top.vhd 2009-03-05 09:49:29 UTC (rev 1115)
@@ -1,90 +0,0 @@
-----------------------------------------------------------------------------------
--- Company: Armadeus Project
--- Engineer: Benoit Canet
---
--- Create Date: 22:37:46 04/12/2007
--- Design Name:
--- Module Name: led_top - structural
--- Project Name:
--- Target Devices:
--- Tool versions:
--- Description:
---
--- Dependencies:
---
--- Revision:
--- Revision 0.01 - File Created
--- Additional Comments:
---
-----------------------------------------------------------------------------------
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.STD_LOGIC_ARITH.ALL;
-use IEEE.STD_LOGIC_UNSIGNED.ALL;
-
-entity led_top is
- port ( -- Imx pins
- DataxD : inout std_logic_vector(15 downto 0);
- AddrxDI : in std_logic_vector(12 downto 0);
- WRxBI : in std_logic;
- RDxBI : in std_logic;
- CSxBI : in std_logic;
-
- --Our pins
- clk : in STD_LOGIC;
- button : in STD_LOGIC;
- led : out STD_LOGIC);
-end led_top;
-
-architecture structural of led_top is
-
- -- We declare the component we we'll use
- component clock_divider
- generic (ratio: integer);
- port (clk_in : in STD_LOGIC;
- clk_out : out STD_LOGIC);
- end component;
-
- component debouncer
- port (clk_100hz : in STD_LOGIC;
- button_in : in STD_LOGIC;
- button_debounced_out : out STD_LOGIC);
- end component;
-
- component flip_flop
- port (clk_100hz : in STD_LOGIC;
- switch_in_n : in STD_LOGIC;
- led_out : out STD_LOGIC);
- end component;
-
- -- internal signals
- signal clk_100hz : STD_LOGIC;
- signal button_debounced_n : STD_LOGIC;
-
- begin
-
- -- instantiate and connect the clock divider
- -- here we use a 96MHz/100Hz=960000 ratio
- i_clock_divider_identifier : clock_divider
- generic map(ratio => 960000)
- -- for simulation purpose use the following line
- -- instead of the previous
- -- generic map(ratio => 2)
-
- port map (clk_in => clk,
- clk_out => clk_100hz);
-
- --instantiate and connect the debouncer
- i_debouncer_identifier : debouncer
- port map (button_in => button,
- clk_100hz => clk_100hz,
- button_debounced_out => button_debounced_n);
-
- --instantiate and connect the flip flop
- i_flip_flop_identifier : flip_flop
- port map (clk_100hz => clk_100hz,
- switch_in_n => button_debounced_n,
- led_out => led);
-
-end structural;
-
Copied: trunk/firmware/leds/led_top.vhd (from rev 1110, trunk/firmware/led/led_top.vhd)
===================================================================
--- trunk/firmware/leds/led_top.vhd (rev 0)
+++ trunk/firmware/leds/led_top.vhd 2009-03-05 09:49:29 UTC (rev 1115)
@@ -0,0 +1,83 @@
+----------------------------------------------------------------------------------
+-- Company: Armadeus Project
+-- Engineer: Benoit Canet
+--
+-- Create Date: 22:37:46 04/12/2007
+-- Design Name:
+-- Module Name: led_top - structural
+-- Project Name:
+-- Target Devices:
+-- Tool versions:
+-- Description:
+--
+-- Dependencies:
+--
+-- Revision:
+-- Revision 0.01 - File Created
+-- Additional Comments:
+--
+----------------------------------------------------------------------------------
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.STD_LOGIC_ARITH.ALL;
+use IEEE.STD_LOGIC_UNSIGNED.ALL;
+
+entity led_top is
+ port (
+ clk : in STD_LOGIC;
+ button : in STD_LOGIC;
+ led : out STD_LOGIC);
+end led_top;
+
+architecture structural of led_top is
+
+ -- We declare the component we we'll use
+ component clock_divider
+ generic (ratio: integer);
+ port (clk_in : in STD_LOGIC;
+ clk_out : out STD_LOGIC);
+ end component;
+
+ component debouncer
+ port (clk_100hz : in STD_LOGIC;
+ button_in : in STD_LOGIC;
+ button_debounced_out : out STD_LOGIC);
+ end component;
+
+ component flip_flop
+ port (clk_100hz : in STD_LOGIC;
+ switch_in_n : in STD_LOGIC;
+ led_out : out STD_LOGIC);
+ end component;
+
+ -- internal signals
+ signal clk_100hz : STD_LOGIC;
+ signal button_debounced_n : STD_LOGIC;
+
+ begin
+
+ -- instantiate and connect the clock divider
+ -- here we use a 96MHz/100Hz=960000 ratio
+ i_clock_divider_identifier : clock_divider
+ generic map(ratio => 960000)
+ -- for simulation purpose use the following line
+ -- instead of the previous
+ -- generic map(ratio => 2)
+
+ port map (clk_in => clk,
+ clk_out => clk_100hz);
+
+ --instantiate and connect the debouncer
+ i_debouncer_identifier : debouncer
+ port map (button_in => button,
+ clk_100hz => clk_100hz,
+ button_debounced_out => button_debounced_n);
+
+ --instantiate and connect the flip flop
+ i_flip_flop_identifier : flip_flop
+ port map (clk_100hz => clk_100hz,
+ switch_in_n => button_debounced_n,
+ led_out => led);
+
+end structural;
+
Copied: trunk/firmware/leds/led_top_200k.bit (from rev 1111, trunk/firmware/led/led_top_200k.bit)
===================================================================
(Binary files differ)
Copied: trunk/firmware/leds/led_top_400k.bit (from rev 1111, trunk/firmware/led/led_top_400k.bit)
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-04 22:40:56
|
Revision: 1114
http://armadeus.svn.sourceforge.net/armadeus/?rev=1114&view=rev
Author: artemys
Date: 2009-03-04 22:40:51 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
[LINUX] Add fpgaloader as module by default in APF27 2.6.26 default config
Modified Paths:
--------------
trunk/buildroot/target/device/armadeus/apf27/apf27-linux-2.6.27.13.config
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-04 22:37:24 UTC (rev 1113)
+++ trunk/buildroot/target/device/armadeus/apf27/apf27-linux-2.6.27.13.config 2009-03-04 22:40:51 UTC (rev 1114)
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.27.13
-# Mon Feb 23 14:11:31 2009
+# Wed Mar 4 18:26:21 2009
#
CONFIG_ARM=y
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -1097,7 +1097,13 @@
#
# FPGA Drivers
#
-# CONFIG_ARMADEUS_FPGA_DRIVERS is not set
+CONFIG_ARMADEUS_FPGA_DRIVERS=y
+CONFIG_ARMADEUS_FPGA_TEST=y
+CONFIG_ARMADEUS_FPGA_TOOL_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
+# CONFIG_POD_DRIVERS is not set
#
# Handheld related
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-04 22:37:30
|
Revision: 1113
http://armadeus.svn.sourceforge.net/armadeus/?rev=1113&view=rev
Author: artemys
Date: 2009-03-04 22:37:24 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
[LINUX] Cleanup of fpgaloader (pass 1)
Modified Paths:
--------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-04 18:34:02 UTC (rev 1112)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-04 22:37:24 UTC (rev 1113)
@@ -23,30 +23,24 @@
// #define DEBUG
#include <linux/version.h>
-#include "fpga-loader.h"
-#include "xilinx-fpga-loader.h"
-#include <linux/version.h>
#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/fs.h>
-#include <linux/errno.h>
-#include <linux/types.h>
#include <linux/proc_fs.h>
-#include <linux/init.h>
-#include <linux/fs.h>
#include <linux/fcntl.h>
-#include <asm/system.h>
-#include <asm/io.h>
#include <asm/uaccess.h>
-//static unsigned long init_map;
-struct semaphore fpga_sema;
+#include "fpga-loader.h"
+#include "xilinx-fpga-loader.h"
+#define DRIVER_VERSION "0.8"
+#define DRIVER_NAME "fpgaloader"
+
+
/* global variables */
static int fpga_major = FPGA_MAJOR;
Xilinx_desc* g_current_desc = NULL;
+struct semaphore fpga_sema;
-static unsigned char fpga_descriptor = 0; // use default target_fpga_desc
+static unsigned char fpga_descriptor = 0; /* use default target_fpga_desc */
module_param( fpga_descriptor, byte, 0 );
#define FPGA_BUFFER_SIZE 4096
@@ -54,50 +48,46 @@
static unsigned char g_nb_users = 0;
-
-//------------------------------------------------
-//
-// Handles write() done on /dev/fpgaxx
-//
+/* 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;
+ ssize_t ret = 0;
- // Get exclusive access
- if (down_interruptible(&fpga_sema))
- return -ERESTARTSYS;
+ /* Get exclusive access */
+ if (down_interruptible(&fpga_sema))
+ return -ERESTARTSYS;
- if( count > FPGA_BUFFER_SIZE ) {
- count = FPGA_BUFFER_SIZE;
- }
+ 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;
- }
+ /* 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 );
+ ret = xilinx_load( g_current_desc, g_buffer, count );
out:
- // Release exclusive access
- up(&fpga_sema);
+ /* Release exclusive access */
+ up(&fpga_sema);
- return( ret );
+ return ret;
}
static int armadeus_fpga_open(struct inode *inode, struct file *file)
{
- int ret;
+ 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 );
+ /* Only one access at a time is permitted */
+ if( g_nb_users > 0 )
+ return -EBUSY;
ret = xilinx_init_load( g_current_desc );
if(!ret) {
@@ -105,48 +95,51 @@
g_nb_users++;
}
- pr_debug("Opening /dev/fpga/loader%d file, %d %d\n", MINOR(inode->i_rdev), fpga_descriptor, ret);
+ 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;
+ return ret;
}
static int armadeus_fpga_release(struct inode *inode, struct file *file)
{
- if( g_nb_users > 0 )
- g_nb_users--;
-
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));
- return 0;
+ 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 kernel replies that it has no more information, or until its buffer is filled.
+ /* 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 {
- if ( data == NULL ) {
- ret = xilinx_get_descriptor_info( -1, buffer );
- } else {
- ret = xilinx_get_descriptor_info( *((unsigned char*)data), buffer );
- }
+ if ( data == NULL ) {
+ ret = xilinx_get_descriptor_info( -1, buffer );
+ } else {
+ ret = xilinx_get_descriptor_info( *((unsigned char*)data), buffer );
+ }
}
- return ret;
+ return ret;
}
static int procfile_fpga_write( __attribute__ ((unused)) struct file *file, const char *buf, unsigned long count, void *data)
@@ -157,115 +150,112 @@
/* 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;
+ int err = 0; int ret = 0;
+ unsigned int minor;
- // 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));
+ /* 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;
- if (err) return -EFAULT;
+ /* 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));
- // Obtain exclusive access
- 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;
- }
+ if (err) return -EFAULT;
- switch(cmd)
- {
- default:
- return -ENOTTY;
- break;
- }
- // Release exclusive access
- up(&fpga_sema);
+ if (down_interruptible(&fpga_sema))
+ return -ERESTARTSYS;
- return ret;
-}
+ /* Extract and test minor */
+ minor = MINOR(inode->i_rdev);
+ if( minor > FPGA_MAX_MINOR ) {
+ printk("Minor outside range: %d !\n", minor);
+ return -EFAULT;
+ }
-/* Create /proc entries for direct access to FPGA config */
-static int createProcEntries( void )
-{
- static struct proc_dir_entry *fpga_Proc_File;
+ switch(cmd)
+ {
+ default:
+ return -ENOTTY;
+ break;
+ }
- /* Create main directory */
- proc_mkdir(FPGA_PROC_DIRNAME, NULL);
+ up(&fpga_sema);
- /* 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(FPGA_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 ret;
+}
- return 0;
+/* 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,
+ .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,
};
int __init armadeus_fpga_init(void)
{
- static int result;
+ static int result;
+
+ /* Register the driver by getting a major number */
+ result = register_chrdev(fpga_major, DRIVER_NAME, &fpga_fops);
+ if (result < 0) {
+ printk(KERN_WARNING DRIVER_NAME ": can't get major %d\n", fpga_major);
+ return result;
+ }
+ if( fpga_major == 0 ) fpga_major = result; /* dynamic MAJOR allocation */
- /* Register the driver by getting a major number */
- result = register_chrdev(fpga_major, FPGA_DRIVER_NAME, &fpga_fops);
- if (result < 0)
- {
- printk(KERN_WARNING FPGA_DRIVER_NAME ": can't get major %d\n", fpga_major);
- return result;
- }
- if( fpga_major == 0 ) fpga_major = result; /* dynamic MAJOR allocation */
+ result = create_proc_entries();
+ if( result < 0 )
+ return result;
- result = createProcEntries();
- if( result < 0 ) return( result );
-
- sema_init(&fpga_sema, 1);
-
- /* initialize the current fpga descriptor with the one by default */
- g_current_desc = xilinx_get_descriptor(fpga_descriptor);
- if( g_current_desc == NULL ){
- return -EINVAL;
- }
+ sema_init(&fpga_sema, 1);
- printk(FPGA_DRIVER_NAME " v" FPGA_DRIVER_VERSION " successfully loaded !\n");
- return(0);
+ /* initialize the current fpga descriptor with the one by default */
+ g_current_desc = xilinx_get_descriptor(fpga_descriptor);
+ if( g_current_desc == NULL ){
+ return -EINVAL;
+ }
+
+ printk(DRIVER_NAME " v" DRIVER_VERSION " successfully loaded !\n");
+ return 0;
}
void __exit armadeus_fpga_cleanup(void)
{
- pr_debug("Removing " FPGA_DRIVER_NAME ": ");
-
- remove_proc_entry(FPGA_PROC_FILENAME, NULL);
+ remove_proc_entry(FPGA_PROC_FILENAME, NULL);
remove_proc_entry(FPGA_PROC_DIRNAME, NULL);
- unregister_chrdev(fpga_major, FPGA_DRIVER_NAME);
-
- pr_debug("Ok !\n");
+ unregister_chrdev(fpga_major, DRIVER_NAME);
}
module_init(armadeus_fpga_init);
@@ -274,4 +264,3 @@
MODULE_AUTHOR("Julien Boibessot / Nicolas Colombain");
MODULE_DESCRIPTION("Armadeus FPGA loading driver");
MODULE_LICENSE("GPL");
-
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h 2009-03-04 18:34:02 UTC (rev 1112)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h 2009-03-04 22:37:24 UTC (rev 1113)
@@ -28,9 +28,6 @@
#define FPGA_PROC_DIRNAME "driver/fpga"
#define FPGA_PROC_FILENAME FPGA_PROC_DIRNAME "/loader"
-#define FPGA_DRIVER_VERSION "0.8"
-#define FPGA_DRIVER_NAME "fpgaloader"
-
// By default, we use dynamic allocation of major numbers
#define FPGA_MAJOR 0
#define FPGA_MAX_MINOR 254
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ar...@us...> - 2009-03-04 18:34:12
|
Revision: 1112
http://armadeus.svn.sourceforge.net/armadeus/?rev=1112&view=rev
Author: artemys
Date: 2009-03-04 18:34:02 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
[LINUX] Add APF27 support to fpgaloader (part1)
Modified Paths:
--------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h
Added Paths:
-----------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c
Removed Paths:
-------------
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.c
trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.h
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile 2009-03-04 09:51:13 UTC (rev 1111)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/Makefile 2009-03-04 18:34:02 UTC (rev 1112)
@@ -1,17 +1,16 @@
#
# Makefile for the Armadeus FPGA loader driver
-# PATH=$HOME/nico/test/buildroot/build_arm_nofpu/staging_dir/bin:$PATH
-# make ARCH=arm
-# tftp -gr fpgaloader.ko -l /lib/modules/drivers/fpgaloader.ko 192.168.0.3
-# tftp -gr fpga_test.bit 192.168.0.3
-# insmod /lib/modules/drivers/fpgaloader.ko
-# dd if=fpga_test.bit of=/dev/fpga/loader
+#
-
ifneq ($(KERNELRELEASE),)
obj-$(CONFIG_ARMADEUS_FPGA_TOOL_DRIVER) += fpgaloader.o
-fpgaloader-objs := target-fpga-loader.o xilinx-fpga-loader.o fpga-loader.o
+ifneq ($(CONFIG_MACH_APF27),)
+fpgaloader-objs := apf27-fpga-loader.o xilinx-fpga-loader.o fpga-loader.o
+endif
+ifneq ($(CONFIG_MACH_APF9328),)
+fpgaloader-objs := apf9328-fpga-loader.o xilinx-fpga-loader.o fpga-loader.o
+endif
else
@@ -25,8 +24,8 @@
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
- rm -f *.*o \
- rm -f Module.symvers
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
+ rm -f modules.order Module.markers
endif
Added: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf27-fpga-loader.c 2009-03-04 18:34:02 UTC (rev 1112)
@@ -0,0 +1,186 @@
+/*
+ * 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 <linux/version.h>
+#include <mach/iomux-mx1-mx2.h>
+#include <mach/gpio.h>
+#include <asm/io.h>
+#include <linux/kernel.h>
+#include <mach/hardware.h>
+
+#include "xilinx-fpga-loader.h"
+
+#define FPGA_BASE_ADDR CS5_BASE_ADDR
+#define FPGA_VIRT_ADDR (IO_ADDRESS(FPGA_BASE_ADDR) + 0x0)
+
+#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_RDATA 0xD6000000 /* FPGA data addr */
+#define CFG_FPGA_WDATA 0xD6000000 /* FPGA data addr */
+#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 */
+
+#define NB_TARGET_DESC 2
+
+
+/* Initialize GPIO port before download */
+int fpga_pre_fn (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);
+ return 1;
+}
+
+/*
+ * Set the FPGA's active-low program line to the specified level
+ */
+int fpga_pgm_fn (int assert)
+{
+ gpio_set_value( CFG_FPGA_PRG, !assert);
+ return assert;
+}
+
+/*
+ * Set the FPGA's active-high clock line to the specified level
+ */
+int fpga_clk_fn (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 fpga_init_fn (void)
+{
+ int value;
+ value = gpio_get_value(CFG_FPGA_INIT);
+ return !value;
+}
+
+/*
+ * Test the state of the active-high FPGA DONE pin
+ */
+int fpga_done_fn (void)
+{
+ return(gpio_get_value(CFG_FPGA_DONE));
+}
+
+/*
+ * Set the FPGA's wr line to the specified level
+ */
+int fpga_wr_fn (int assert_write)
+{
+ gpio_set_value( CFG_FPGA_RW, !assert_write);
+ return assert_write;
+}
+
+int fpga_cs_fn (int assert_cs)
+{
+ gpio_set_value( CFG_FPGA_CS, !assert_cs);
+ return assert_cs;
+}
+
+int fpga_wdata_fn ( unsigned char data )
+{
+ __raw_writew(data, FPGA_VIRT_ADDR);
+ return data;
+}
+
+int fpga_busy_fn (void)
+{
+ return 0;
+}
+
+int fpga_post_fn (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);
+ return 1;
+}
+
+int fpga_abort_fn (void)
+{
+ fpga_post_fn();
+ 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 = {
+ fpga_pre_fn,
+ fpga_pgm_fn,
+ fpga_clk_fn,
+ fpga_init_fn,
+ fpga_done_fn,
+ fpga_wr_fn,
+ fpga_cs_fn,
+ fpga_wdata_fn,
+ fpga_busy_fn,
+ fpga_abort_fn,
+ fpga_post_fn,
+};
+
+Xilinx_desc target_fpga_desc[NB_TARGET_DESC] = {
+ {
+ Xilinx_Spartan,
+ slave_parallel,
+ 1196128l/8,
+ (void *) &fpga_fns
+ },
+ {
+ Xilinx_Spartan,
+ slave_parallel,
+ 1887216l/8,
+ (void *) &fpga_fns
+ },
+};
Added: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c (rev 0)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/apf9328-fpga-loader.c 2009-03-04 18:34:02 UTC (rev 1112)
@@ -0,0 +1,124 @@
+/*
+ * 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 <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+#include <asm/arch/hardware.h>
+#else
+#include <mach/hardware.h>
+#endif
+#include <asm/io.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
+ */
+int fpga_pgm_fn( int assert )
+{
+ GPIO_WRITE( FPGA_PROGRAM, !assert);
+ return assert;
+}
+
+/*
+ * Set the FPGA's active-high clock line to the specified level
+ */
+int fpga_clk_fn( 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).
+ */
+int fpga_init_fn( void )
+{
+ return(!GPIO_READ(FPGA_INIT));
+}
+
+/*
+ * Test the state of the active-high FPGA DONE pin
+ */
+int fpga_done_fn( void )
+{
+ return(GPIO_READ(FPGA_DONE));
+}
+
+/*
+ * Set the FPGA's data line to the specified level
+ */
+int fpga_wr_fn( int assert_write )
+{
+ GPIO_WRITE( FPGA_DIN, assert_write);
+ return assert_write;
+}
+
+int fpga_pre_fn( 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 = {
+ fpga_pre_fn,
+ fpga_pgm_fn,
+ fpga_clk_fn,
+ fpga_init_fn,
+ fpga_done_fn,
+ fpga_wr_fn,
+};
+
+Xilinx_desc target_fpga_desc[/*NB_TARGET_DESC*/] = {
+
+ { /* first supported configuration (default) */
+ Xilinx_Spartan,
+ slave_serial,
+ XILINX_XC3S200_SIZE,
+ (void *) &fpga_fns
+ },
+ { /* second one */
+ Xilinx_Spartan,
+ slave_serial,
+ XILINX_XC3S400_SIZE,
+ (void *) &fpga_fns
+ },
+};
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-04 09:51:13 UTC (rev 1111)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.c 2009-03-04 18:34:02 UTC (rev 1112)
@@ -1,10 +1,9 @@
/*
- ***********************************************************************
+ * Generic Xilinx FPGA loader
*
- * (c) Copyright 2006 Armadeus project
- * Julien Boibessot <jul...@ar...>
- * Nicolas Colombain <nic...@ar...>
- * 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
@@ -19,20 +18,14 @@
* 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 "fpga-loader.h"
#include "xilinx-fpga-loader.h"
#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
-#include <asm/arch/imx-regs.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-#include <linux/config.h>
-#endif
-#else
-#include <mach/imx-regs.h>
-#endif
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
@@ -61,9 +54,7 @@
static unsigned char g_nb_users = 0;
-void __exit armadeus_fpga_cleanup(void);
-
//------------------------------------------------
//
// Handles write() done on /dev/fpgaxx
@@ -71,7 +62,7 @@
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;
@@ -92,22 +83,33 @@
out:
// Release exclusive access
up(&fpga_sema);
-
+
return( ret );
}
static int armadeus_fpga_open(struct inode *inode, struct file *file)
{
int ret;
-
- // Only one access at a time is permitted
+
+ /* 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 );
- g_nb_users++;
- ret = xilinx_init_load( g_current_desc );
+ ret = xilinx_init_load( g_current_desc );
+ if(!ret) {
+ printk("Starting FPGA download\n");
+ g_nb_users++;
+ }
- PRINTF("Opening /dev/fpga/loader%d file, %d %d\n", MINOR(inode->i_rdev), fpga_descriptor, ret);
+ 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;
}
@@ -116,13 +118,16 @@
if( g_nb_users > 0 )
g_nb_users--;
- PRINTF("Closing access to /dev/fpga/loader%d\n", MINOR(inode->i_rdev));
+ 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));
return 0;
}
-//------------------------------------------------
-// PROC file
-//
+
+/* 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;
@@ -134,10 +139,9 @@
/* we have finished to read, return 0 */
ret = 0;
} else {
- if ( data == NULL ){
+ if ( data == NULL ) {
ret = xilinx_get_descriptor_info( -1, buffer );
- }
- else {
+ } else {
ret = xilinx_get_descriptor_info( *((unsigned char*)data), buffer );
}
}
@@ -145,15 +149,12 @@
return ret;
}
-
static int procfile_fpga_write( __attribute__ ((unused)) struct file *file, const char *buf, unsigned long count, void *data)
{
- return count;
+ return count;
}
-//------------------------------------------------
-// Handling of IOCTL calls
-//
+/* 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;
@@ -182,8 +183,8 @@
printk("Minor outside range: %d !\n", minor);
return -EFAULT;
}
-
- switch(cmd)
+
+ switch(cmd)
{
default:
return -ENOTTY;
@@ -195,96 +196,82 @@
return ret;
}
-//
-// Create /proc entries for direct access (with echo/cat) to GPIOs config
-//
+/* Create /proc entries for direct access to FPGA config */
static int createProcEntries( void )
{
static struct proc_dir_entry *fpga_Proc_File;
- // Create main directory
+
+ /* Create main directory */
proc_mkdir(FPGA_PROC_DIRNAME, NULL);
- // Create proc file to handle GPIO values
- fpga_Proc_File = create_proc_entry( FPGA_PROC_FILENAME, S_IWUSR |S_IRUSR | S_IRGRP | S_IROTH, NULL );
- if( fpga_Proc_File == 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(FPGA_DRIVER_NAME ": Could not register a" FPGA_PROC_FILENAME ". Terminating\n");
- armadeus_fpga_cleanup();
- return -ENOMEM;
- }
- else
- {
- fpga_Proc_File->read_proc = procfile_fpga_read;
+ goto error;
+ } else {
+ fpga_Proc_File->read_proc = procfile_fpga_read;
fpga_Proc_File->write_proc = procfile_fpga_write;
}
-
- return(0);
+
+ 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,
+/* .read = armadeus_fpga_read, Configuration saving not supported yet */
.open = armadeus_fpga_open,
.release = armadeus_fpga_release,
.ioctl = armadeus_fpga_ioctl,
};
-//
-// Module's initialization function
-//
int __init armadeus_fpga_init(void)
{
static int result;
- // Register the driver by getting a major number
+ /* Register the driver by getting a major number */
result = register_chrdev(fpga_major, FPGA_DRIVER_NAME, &fpga_fops);
if (result < 0)
{
printk(KERN_WARNING FPGA_DRIVER_NAME ": can't get major %d\n", fpga_major);
return result;
}
- if( fpga_major == 0 ) fpga_major = result; // dynamic Major allocation
+ if( fpga_major == 0 ) fpga_major = result; /* dynamic MAJOR allocation */
- // Creating /proc entries
result = createProcEntries();
if( result < 0 ) return( result );
- // Initialise FPGA semaphore
sema_init(&fpga_sema, 1);
- // initialize the current fpga descriptor with the one by default
+ /* initialize the current fpga descriptor with the one by default */
g_current_desc = xilinx_get_descriptor(fpga_descriptor);
if( g_current_desc == NULL ){
return -EINVAL;
}
- printk(FPGA_DRIVER_NAME " module " FPGA_DRIVER_VERSION " successfully loaded !\n");
+ printk(FPGA_DRIVER_NAME " v" FPGA_DRIVER_VERSION " successfully loaded !\n");
return(0);
}
-//
-// Module's cleanup function
-//
void __exit armadeus_fpga_cleanup(void)
{
- PRINTF("Removing " FPGA_DRIVER_NAME " module: ");
+ pr_debug("Removing " FPGA_DRIVER_NAME ": ");
- // Remove /proc entries
remove_proc_entry(FPGA_PROC_FILENAME, NULL);
- // Remove /proc directory entry
remove_proc_entry(FPGA_PROC_DIRNAME, NULL);
- // De-register /dev interface
unregister_chrdev(fpga_major, FPGA_DRIVER_NAME);
- PRINTF("Ok !\n");
+ pr_debug("Ok !\n");
}
-//------------------------------------------------
-
module_init(armadeus_fpga_init);
module_exit(armadeus_fpga_cleanup);
-MODULE_AUTHOR("JB / NC");
-MODULE_DESCRIPTION("Armadeus fpga's loading driver");
+MODULE_AUTHOR("Julien Boibessot / Nicolas Colombain");
+MODULE_DESCRIPTION("Armadeus FPGA loading driver");
MODULE_LICENSE("GPL");
+
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h 2009-03-04 09:51:13 UTC (rev 1111)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/fpga-loader.h 2009-03-04 18:34:02 UTC (rev 1112)
@@ -28,7 +28,7 @@
#define FPGA_PROC_DIRNAME "driver/fpga"
#define FPGA_PROC_FILENAME FPGA_PROC_DIRNAME "/loader"
-#define FPGA_DRIVER_VERSION "v0.0.6"
+#define FPGA_DRIVER_VERSION "0.8"
#define FPGA_DRIVER_NAME "fpgaloader"
// By default, we use dynamic allocation of major numbers
Deleted: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.c 2009-03-04 09:51:13 UTC (rev 1111)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.c 2009-03-04 18:34:02 UTC (rev 1112)
@@ -1,121 +0,0 @@
-/*
- **********************************************************************
- * 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.
- **********************************************************************
-
- (c) Copyright 2006 Armadeus project
- Eric Jarrige <eri...@ar...>
- Nicolas Colombain <nic...@ar...>
- Target Xilinx FPGA support
-*/
-
-#include "target-fpga-loader.h"
-#include "xilinx-fpga-loader.h"
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
-#include <asm/arch/hardware.h>
-#else
-#include <mach/hardware.h>
-#endif
-#include <asm/io.h>
-
-#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
- */
-int fpga_pgm_fn( int assert )
-{
- GPIO_WRITE( FPGA_PROGRAM, !assert);
- return assert;
-}
-
-/*
- * Set the FPGA's active-high clock line to the specified level
- */
-int fpga_clk_fn( 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).
- */
-int fpga_init_fn( void )
-{
- return(!GPIO_READ(FPGA_INIT));
-}
-
-/*
- * Test the state of the active-high FPGA DONE pin
- */
-int fpga_done_fn( void )
-{
- return(GPIO_READ(FPGA_DONE));
-}
-
-/*
- * Set the FPGA's data line to the specified level
- */
-int fpga_wr_fn( int assert_write )
-{
- GPIO_WRITE( FPGA_DIN, assert_write);
- return assert_write;
-}
-
-int fpga_pre_fn( 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 = {
- fpga_pre_fn,
- fpga_pgm_fn,
- fpga_clk_fn,
- fpga_init_fn,
- fpga_done_fn,
- fpga_wr_fn,
-};
-
-Xilinx_desc target_fpga_desc[NB_TARGET_DESC] = {
-
- { // first supported configuration (default)
- Xilinx_Spartan,
- slave_serial,
- XILINX_XC3S200_SIZE,
- (void *) &fpga_fns
- },
-
- { // second one
- Xilinx_Spartan,
- slave_serial,
- XILINX_XC3S400_SIZE,
- (void *) &fpga_fns
- }
-};
-
Deleted: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.h 2009-03-04 09:51:13 UTC (rev 1111)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/target-fpga-loader.h 2009-03-04 18:34:02 UTC (rev 1112)
@@ -1,45 +0,0 @@
-/*
- **********************************************************************
- * 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.
- **********************************************************************
-
- (c) Copyright 2006 Armadeus project
- Eric Jarrige <eri...@ar...>
- Nicolas Colombain <nic...@ar...>
- Target Xilinx FPGA support
-
-*/
-#ifndef __TARGET_FPGA_LOADER_H__
-#define __TARGET_FPGA_LOADER_H__
-
-
-#include "xilinx-fpga-loader.h"
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
-#include <asm/arch/imx-regs.h>
-#else
-#include <mach/imx-regs.h>
-#endif
-#include <asm/io.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 NB_TARGET_DESC 2
-
-#endif // __TARGET_FPGA_LOADER_H__
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c 2009-03-04 09:51:13 UTC (rev 1111)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.c 2009-03-04 18:34:02 UTC (rev 1112)
@@ -1,9 +1,9 @@
/*
- * (c) Copyright 2006 Armadeus project
- * Nicolas Colombain <nic...@ar...>
- * Xilinx FPGA support
+ * Xilinx FPGAs download support
+ * Copyright (C) 2006-2009 Nicolas Colombain <nic...@ar...>
+ * Armadeus Project / Armadeus systems
*
- * Based on the implementation(uBoot) of:
+ * Based on the implementation (U-Boot) of:
* Rich Ireland, Enterasys Networks, rir...@en....
* Keith Outwater, kei...@mv...
*
@@ -27,21 +27,19 @@
*
*/
-#include "xilinx-fpga-loader.h"
-#include "target-fpga-loader.h"
#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
-#include <asm/arch/imx-regs.h>
-#else
-#include <mach/imx-regs.h>
-#endif
#include <asm/io.h>
#include <linux/time.h>
+#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/errno.h>
+#include <asm/irqflags.h>
+#include <asm/delay.h>
+#include "xilinx-fpga-loader.h"
+
#define CONFIG_FPGA_DELAY()
-#define CFG_FPGA_WAIT 4000 // uS
+#define CFG_FPGA_WAIT 20000 // uS
size_t bytecount = 0; // total bytes received
extern Xilinx_desc target_fpga_desc[]; // target descriptor table
@@ -66,40 +64,36 @@
{
int len;
len = sprintf( buffer, "%s %s %u\n",
- (desc->family == Xilinx_Spartan) ? "spartan":"unknown",
- (desc->iface == slave_serial) ? "slave serial":"unknown",
+ (desc->family == Xilinx_Spartan) ? "spartan":"unknown",
+ (desc->iface == slave_serial) ? "slave serial":"slave parallel",
desc->size );
return len;
}
/**
- * program the FPGA.
+ * program the FPGA (serial mode).
* return 0 if success, >0 while programming, <0 if error detected
*/
static size_t spartan_serial_load (Xilinx_desc *desc, const char* buf, size_t bsize)
{
Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
+
if (fn) {
- unsigned long ts; /* timestamp */
-
- /* Load the data */
- if( bytecount<=desc->size ) {
int i;
unsigned char val;
size_t nbbyte = 0; // init local counter
while (nbbyte < bsize) {
-
- /* Xilinx detects an error if INIT goes low (active)
+ /* Spartan signals an error if INIT goes low (active)
while DONE is low (inactive) */
if ((*fn->done)() == 0 && (*fn->init)()) {
- PRINTF ("** CRC error during FPGA load.\n");
+ printk("** CRC error during FPGA load.\n");
return -ETIMEDOUT;
}
val = buf[nbbyte ++];
- bytecount++;
+ bytecount++;
i = 8;
- do {
+ do {
/* Deassert the clock */
(*fn->clk)(0);
CONFIG_FPGA_DELAY ();
@@ -111,38 +105,19 @@
CONFIG_FPGA_DELAY ();
val <<= 1;
i --;
- } while (i > 0);
- }
- }
- if( bytecount>=desc->size )
- {
- CONFIG_FPGA_DELAY ();
+ } while (i > 0);
+ }
- /* now check for done signal */
- ts = 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 (ts) > CFG_FPGA_WAIT) { /* check the time */
- PRINTF ("** Timeout waiting for DONE.\n");
- return -ETIMEDOUT;
- }
- }
- }
- return bsize;
- }
+ if(bytecount%4096 == 0) printk(".");
+ return bsize;
+ }
return -EINVAL;
}
/**
- * initialize the FPGA programming interface.
+ * initialize the FPGA programming interface.
* return 0 if success, <0 if error detected
- */
+ */
static int spartan_serial_init (Xilinx_desc *desc)
{
Xilinx_Spartan_Slave_Serial_fns *fn = desc->iface_fns;
@@ -158,7 +133,7 @@
/* Wait for INIT state (init low) */
ts = get_timer(0); /* get current time */
- do {
+ do {
CONFIG_FPGA_DELAY ();
if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */
PRINTF ("** Timeout waiting for INIT to start.\n");
@@ -171,7 +146,7 @@
(*fn->pgm)(0); /* Deassert the program, commit */
ts = get_timer(0); /* get current time */
- /* Now wait for INIT to go high */
+ /* Now wait for INIT to go high */
do {
CONFIG_FPGA_DELAY ();
if (get_timer (ts) > CFG_FPGA_WAIT) { /* check the time */
@@ -186,22 +161,170 @@
return -EINVAL;
}
+/* terminate the FPGA load (serial mode) */
+static int spartan_serial_finish(Xilinx_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;
+}
+
+
/**
- * program the FPGA.
+ * initialize the FPGA programming interface.
+ * return 0 if success, <0 if error detected
+ */
+static int spartan_parallel_init (Xilinx_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 (Xilinx_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(Xilinx_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( Xilinx_desc *desc, const char *buf, size_t bsize )
{
int ret = 0;
if( desc ) {
- switch( desc->family ) // check family
+ switch( desc->family ) /* check family */
{
case Xilinx_Spartan:
{
- switch( desc->iface ) // check donwload hardware interface
+ 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;
}
}
@@ -217,9 +340,9 @@
}
/**
- * initialize the FPGA programming interface.
+ * initialize the FPGA programming interface.
* return 0 if success, <0 if error detected
- */
+ */
int xilinx_init_load( Xilinx_desc *desc )
{
int ret = 0;
@@ -232,6 +355,7 @@
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;
}
}
@@ -246,10 +370,49 @@
return ret;
}
-/**
+int xilinx_finish_load( Xilinx_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 the descriptor corresponding to desc_id
* return NULL if error
*/
+#define NB_TARGET_DESC 2
+
Xilinx_desc * xilinx_get_descriptor( unsigned char desc_id )
{
if( desc_id < NB_TARGET_DESC ){
@@ -258,7 +421,7 @@
return NULL;
}
-/**
+/**
* get the descriptor infos
*/
int xilinx_get_descriptor_info( int desc_id, char* buffer )
@@ -277,6 +440,3 @@
return len;
}
-
-
-
Modified: trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h
===================================================================
--- trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h 2009-03-04 09:51:13 UTC (rev 1111)
+++ trunk/target/linux/modules/fpga/dev_tools/fpga_devtools/xilinx-fpga-loader.h 2009-03-04 18:34:02 UTC (rev 1112)
@@ -1,9 +1,9 @@
/*
- * (c) Copyright 2006 Armadeus project
- * Nicolas Colombain <nic...@ar...>
- * Xilinx FPGA support
+ * Xilinx FPGAs download support
+ * Copyright (C) 2006-2009 Nicolas Colombain <nic...@ar...>
+ * Armadeus Project / Armadeus systems
*
- * Based on the implementation(uBoot) of:
+ * Based on the implementation (U-Boot) of:
* Rich Ireland, Enterasys Networks, rir...@en....
* Keith Outwater, kei...@mv...
*
@@ -31,8 +31,8 @@
#include <linux/types.h>
-//#define FPGA_DEBUG
-#undef FPGA_DEBUG
+#define FPGA_DEBUG
+//#undef FPGA_DEBUG
#ifdef FPGA_DEBUG
#define PRINTF(fmt,args...) printk (fmt ,##args)
@@ -56,6 +56,7 @@
typedef enum { /* typedef Xilinx_iface */
min_xilinx_iface_type, /* low range check value */
slave_serial, /* serial data and external clock */
+ slave_parallel, /* parallel data and external clock */
max_xilinx_iface_type /* insert all new types before this */
} Xilinx_iface; /* end, typedef Xilinx_iface */
@@ -81,6 +82,12 @@
typedef int (*Xilinx_wr_fn)( int assert_write );
typedef int (*Xilinx_pre_fn)(void);
+typedef int (*Xilinx_cs_fn)( int assert_cs);
+typedef int (*Xilinx_wdata_fn)( unsigned char data );
+typedef int (*Xilinx_busy_fn)(void);
+typedef int (*Xilinx_abort_fn)(void);
+typedef int (*Xilinx_post_fn)(void);
+
/** struct of target specific low level functions */
typedef struct {
Xilinx_pre_fn pre;
@@ -91,6 +98,22 @@
Xilinx_wr_fn wr;
} Xilinx_Spartan_Slave_Serial_fns;
+/* Slave Parallel Implementation function table */
+typedef struct {
+ Xilinx_pre_fn pre;
+ Xilinx_pgm_fn pgm;
+ Xilinx_clk_fn clk;
+ Xilinx_init_fn init;
+ Xilinx_done_fn done;
+ Xilinx_wr_fn wr;
+ Xilinx_cs_fn cs;
+ Xilinx_wdata_fn wdata;
+ Xilinx_busy_fn busy;
+ Xilinx_abort_fn abort;
+ Xilinx_post_fn post;
+} Xilinx_Spartan3_Slave_Parallel_fns;
+
+
/**
* program the FPGA.
* return 0 if success, >0 while programming, <0 if error detected
@@ -98,11 +121,14 @@
size_t xilinx_load( Xilinx_desc *desc, const char *buf, size_t bsize );
/**
- * initialize the FPGA programming interface.
+ * initialize the FPGA programming interface.
* return 0 if success, <0 if error detected
*/
int xilinx_init_load( Xilinx_desc *desc );
+/* terminate FGPA loading */
+int xilinx_finish_load( Xilinx_desc *desc );
+
/**
* get the descriptor infos, return the number of char placed in the buffer
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Fa...@us...> - 2009-03-04 09:51:22
|
Revision: 1111
http://armadeus.svn.sourceforge.net/armadeus/?rev=1111&view=rev
Author: FabM
Date: 2009-03-04 09:51:13 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
[FIRMWARE] Modify led example to use led already soldered on devfull apf9328
Modified Paths:
--------------
trunk/firmware/led/led.ucf
trunk/firmware/led/led_top.dia
trunk/firmware/led/led_top_200k.bit
trunk/firmware/led/led_top_400k.bit
Modified: trunk/firmware/led/led.ucf
===================================================================
--- trunk/firmware/led/led.ucf 2009-03-04 09:16:35 UTC (rev 1110)
+++ trunk/firmware/led/led.ucf 2009-03-04 09:51:13 UTC (rev 1111)
@@ -1,4 +1,4 @@
# pinout
-NET "button" LOC = "P119" | IOSTANDARD = LVCMOS33 ;
+NET "button" LOC = "P141" | IOSTANDARD = LVCMOS33 ;
NET "clk" LOC = "P55" | IOSTANDARD = LVCMOS33 ;
-NET "led" LOC = "P118" | IOSTANDARD = LVCMOS33 ;
+NET "led" LOC = "P116" | IOSTANDARD = LVCMOS33 ;
Modified: trunk/firmware/led/led_top.dia
===================================================================
(Binary files differ)
Modified: trunk/firmware/led/led_top_200k.bit
===================================================================
(Binary files differ)
Modified: trunk/firmware/led/led_top_400k.bit
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Fa...@us...> - 2009-03-04 09:16:41
|
Revision: 1110
http://armadeus.svn.sourceforge.net/armadeus/?rev=1110&view=rev
Author: FabM
Date: 2009-03-04 09:16:35 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
[FIRMWARE] Adding 400k led example bitstream, rename 200k bitsream file, and do some modifications on VHDL to suppress warning
Modified Paths:
--------------
trunk/firmware/led/led.ucf
trunk/firmware/led/led_top.vhd
Added Paths:
-----------
trunk/firmware/led/led_top_200k.bit
trunk/firmware/led/led_top_400k.bit
Removed Paths:
-------------
trunk/firmware/led/led_top.bit
Modified: trunk/firmware/led/led.ucf
===================================================================
--- trunk/firmware/led/led.ucf 2009-03-03 16:20:44 UTC (rev 1109)
+++ trunk/firmware/led/led.ucf 2009-03-04 09:16:35 UTC (rev 1110)
@@ -1,44 +1,4 @@
-#PACE: Start of Constraints generated by PACE
-
-#PACE: Start of PACE I/O Pin Assignments
-NET "AddrxDI<0>" LOC = "P21" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<10>" LOC = "P33" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<11>" LOC = "P35" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<12>" LOC = "P36" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<1>" LOC = "P23" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<2>" LOC = "P24" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<3>" LOC = "P25" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<4>" LOC = "P26" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<5>" LOC = "P27" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<6>" LOC = "P28" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<7>" LOC = "P30" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<8>" LOC = "P31" | IOSTANDARD = LVCMOS33 ;
-NET "AddrxDI<9>" LOC = "P32" | IOSTANDARD = LVCMOS33 ;
+# pinout
NET "button" LOC = "P119" | IOSTANDARD = LVCMOS33 ;
NET "clk" LOC = "P55" | IOSTANDARD = LVCMOS33 ;
-NET "CSxBI" LOC = "P59" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<0>" LOC = "P1" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<10>" LOC = "P13" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<11>" LOC = "P14" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<12>" LOC = "P15" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<13>" LOC = "P17" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<14>" LOC = "P18" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<15>" LOC = "P20" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<1>" LOC = "P2" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<2>" LOC = "P4" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<3>" LOC = "P5" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<4>" LOC = "P6" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<5>" LOC = "P7" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<6>" LOC = "P8" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<7>" LOC = "P10" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<8>" LOC = "P11" | IOSTANDARD = LVCMOS33 ;
-NET "DataxD<9>" LOC = "P12" | IOSTANDARD = LVCMOS33 ;
NET "led" LOC = "P118" | IOSTANDARD = LVCMOS33 ;
-NET "RDxBI" LOC = "P63" | IOSTANDARD = LVCMOS33 ;
-NET "WRxBI" LOC = "P60" | IOSTANDARD = LVCMOS33 ;
-
-#PACE: Start of PACE Area Constraints
-
-#PACE: Start of PACE Prohibit Constraints
-
-#PACE: End of Constraints generated by PACE
Deleted: trunk/firmware/led/led_top.bit
===================================================================
(Binary files differ)
Modified: trunk/firmware/led/led_top.vhd
===================================================================
--- trunk/firmware/led/led_top.vhd 2009-03-03 16:20:44 UTC (rev 1109)
+++ trunk/firmware/led/led_top.vhd 2009-03-04 09:16:35 UTC (rev 1110)
@@ -23,14 +23,7 @@
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity led_top is
- port ( -- Imx pins
- DataxD : inout std_logic_vector(15 downto 0);
- AddrxDI : in std_logic_vector(12 downto 0);
- WRxBI : in std_logic;
- RDxBI : in std_logic;
- CSxBI : in std_logic;
-
- --Our pins
+ port (
clk : in STD_LOGIC;
button : in STD_LOGIC;
led : out STD_LOGIC);
Copied: trunk/firmware/led/led_top_200k.bit (from rev 1105, trunk/firmware/led/led_top.bit)
===================================================================
(Binary files differ)
Added: trunk/firmware/led/led_top_400k.bit
===================================================================
(Binary files differ)
Property changes on: trunk/firmware/led/led_top_400k.bit
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Fa...@us...> - 2009-03-03 16:20:48
|
Revision: 1109
http://armadeus.svn.sourceforge.net/armadeus/?rev=1109&view=rev
Author: FabM
Date: 2009-03-03 16:20:44 +0000 (Tue, 03 Mar 2009)
Log Message:
-----------
[LINUX] Drivers for wishbone_example are ready
Modified Paths:
--------------
trunk/target/linux/modules/fpga/wishbone_example/Kconfig
trunk/target/linux/modules/fpga/wishbone_example/Makefile
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Kconfig
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Makefile
trunk/target/linux/modules/fpga/wishbone_example/wb_button/button.h
trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c
Added Paths:
-----------
trunk/target/linux/modules/fpga/wishbone_example/wb_button/board_buttons.c
trunk/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Kconfig
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/README
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/main.c
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/test.c
trunk/target/linux/modules/fpga/wishbone_example/wb_led/
trunk/target/linux/modules/fpga/wishbone_example/wb_led/Kconfig
trunk/target/linux/modules/fpga/wishbone_example/wb_led/Makefile
trunk/target/linux/modules/fpga/wishbone_example/wb_led/board_leds.c
trunk/target/linux/modules/fpga/wishbone_example/wb_led/g_led.c
trunk/target/linux/modules/fpga/wishbone_example/wb_led/led.h
trunk/target/linux/modules/fpga/wishbone_example/wb_led/s_led.c
trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c
Removed Paths:
-------------
trunk/target/linux/modules/fpga/others/Wb_led/
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/
Modified: trunk/target/linux/modules/fpga/wishbone_example/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/Kconfig 2009-03-03 16:03:26 UTC (rev 1108)
+++ trunk/target/linux/modules/fpga/wishbone_example/Kconfig 2009-03-03 16:20:44 UTC (rev 1109)
@@ -5,11 +5,14 @@
#
#
-config WISHBONE_EXAMPLE_DRIVERS
- tristate "Drivers for wishbone example"
+config ARMADEUS_WISHBONE_EXAMPLE_DRIVERS
+ boolean "Drivers for wishbone example"
default n
depends on ARMADEUS_FPGA_DRIVERS
---help---
Drivers used for wishbone example design that can be
found in firmware/wishbone_example/
+source "drivers/armadeus/fpga/wishbone_example/wb_button/Kconfig"
+source "drivers/armadeus/fpga/wishbone_example/wb_led/Kconfig"
+source "drivers/armadeus/fpga/wishbone_example/wb_irq_mngr/Kconfig"
Modified: trunk/target/linux/modules/fpga/wishbone_example/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/Makefile 2009-03-03 16:03:26 UTC (rev 1108)
+++ trunk/target/linux/modules/fpga/wishbone_example/Makefile 2009-03-03 16:20:44 UTC (rev 1109)
@@ -8,21 +8,10 @@
ifneq ($(KERNELRELEASE),)
# Part executed when called from kernel build system:
-obj-$(CONFIG_WISHBONE_EXAMPLE_DRIVERS) +=
+obj-$(CONFIG_ARMADEUS_WISHBONE_EXAMPLE_DRIVERS) += wb_button/ wb_irq_mngr/ wb_led/
else
-# Part executed when called from standard make in this directory:
-
-BASE_DIR:=../../../../buildroot/
-REL:=$(shell grep "BR2_PACKAGE_LINUX_VERSION=" $(BASE_DIR).config | sed -e 's/BR2_PACKAGE_LINUX_VERSION=//' | sed -e 's/"//g')
-#
-ARMADEUS_KERNEL_DIR:=$(BASE_DIR)build_arm/linux-$(REL)
-ifeq ($(LINUX_DIR),)
-LINUX_DIR:=$(ARMADEUS_KERNEL_DIR)
-endif
-PWD:= $(shell pwd)
-
default:
echo "Your Linux source dir is: $(LINUX_DIR)"
$(MAKE) -C $(LINUX_DIR) SUBDIRS=$(PWD) zImage modules
@@ -35,5 +24,15 @@
echo "Installing Armadeus drivers..."
$(MAKE) -C $(LINUX_DIR) SUBDIRS=$(PWD) INSTALL_MOD_PATH=$(TARGET_DIR) modules_install
+clean:
+ rm -f *.*o \
+ rm -f *.mod.c \
+ rm -f *.cmd \
+ rm -f *.o.d \
+ rm -f *.order \
+ rm -f .*.cmd \
+ rm -rf .tmp_versions \
+ rm -f Module.symvers
+
endif
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/Kconfig 2009-03-03 16:03:26 UTC (rev 1108)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Kconfig 2009-03-03 16:20:44 UTC (rev 1109)
@@ -1,8 +1,8 @@
#
#
-config ARMADEUS_BUTTON_DRIVER
+config ARMADEUS_WISHBONE_EXAMPLE_BUTTON_DRIVER
tristate "Wishbone Button driver"
- default n
- depends on ARMADEUS_FPGA_OTHERS_DRIVERS
+ default m
+ depends on ARMADEUS_WISHBONE_EXAMPLE_DRIVERS
---help---
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/Makefile 2009-03-03 16:03:26 UTC (rev 1108)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Makefile 2009-03-03 16:20:44 UTC (rev 1109)
@@ -4,30 +4,32 @@
ifneq ($(KERNELRELEASE),)
-obj-$(CONFIG_ARMADEUS_BUTTON_DRIVER) += button.o
+obj-$(CONFIG_ARMADEUS_WISHBONE_EXAMPLE_BUTTON_DRIVER) += board_buttons.o gbutton.o
-# Part executed when called from standard make in this directory:
-# (preferably use Makefile in parent directory)
-
else
+
ARMADEUS_BASE_DIR=../../../../../..
include $(ARMADEUS_BASE_DIR)/Makefile.in
-KDIR := $(ARMADEUS_LINUX_DIR)
-PWD := $(shell pwd)
+KDIR := $(ARMADEUS_LINUX_DIR)
+PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
- -cp button.ko /tftpboot/
test:
~/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc testbutton.c -o testbutton
chmod 755 testbutton
- cp testbutton /tftpboot/
clean:
rm -f *.*o \
+ rm -f *.mod.c \
+ rm -f *.cmd \
+ rm -f *.o.d \
+ rm -f *.order \
+ rm -f .*.cmd \
+ rm -rf .tmp_versions \
rm -f Module.symvers
endif
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_button/board_buttons.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/board_buttons.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/board_buttons.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,82 @@
+/*
+ ***********************************************************************
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ * Specific button driver for generic button driver
+ *
+ * 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 <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/config.h>
+#endif
+
+/* form module/drivers */
+#include <linux/init.h>
+#include <linux/module.h>
+
+/* for platform device */
+#include <linux/platform_device.h>
+
+#include "button.h"
+
+#define BUTTON0_IRQ IRQ_FPGA(0)
+
+
+static struct plat_button_port plat_button0_data={
+ .name = "BUTTON0",
+ .interrupt_number=BUTTON0_IRQ,
+ .num=0,
+ .membase = (void *)(ARMADEUS_FPGA_BASE_ADDR_VIRT +
+ 0xc),
+ .idnum=3,
+ .idoffset=0x00 * (16 /8)
+};
+
+
+static struct platform_device plat_button0_device={
+ .name = "button",
+ .id=0,
+ .dev={
+ .platform_data = &plat_button0_data
+ },
+};
+
+
+static int __init board_button_init(void)
+{
+ int ret = -1;
+ ret = platform_device_register(&plat_button0_device);
+ if(ret<0)return ret;
+
+ return ret;
+}
+
+static void __exit board_button_exit(void)
+{
+ platform_device_unregister(&plat_button0_device);
+
+}
+
+module_init(board_button_init);
+module_exit(board_button_exit);
+
+MODULE_AUTHOR("Fabien Marteau <fab...@ar...>");
+MODULE_DESCRIPTION("Board specific button driver");
+MODULE_LICENSE("GPL");
+
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_button/button.h
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/button.h 2009-03-03 16:03:26 UTC (rev 1108)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/button.h 2009-03-03 16:20:44 UTC (rev 1109)
@@ -25,8 +25,6 @@
#ifndef __BUTTON_H__
#define __BUTTON_H__
-#include "button_specific.h"
-
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
#include <linux/config.h>
@@ -49,14 +47,19 @@
/* readw() writew() */
#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
/* hardware addresses */
-#include <asm/hardware.h>
+# include <asm/hardware.h>
+# include <asm/semaphore.h>
+#else
+# include <mach/hardware.h>
+# include <linux/semaphore.h>
+#endif
/* interruptions */
#include <linux/interrupt.h>
#include <asm/irq.h>
#include <linux/wait.h>
-#include <asm/semaphore.h>
/* measure time */
#include <linux/jiffies.h>
@@ -78,47 +81,19 @@
# define PDEBUG(fmt,args...) /* no debbuging message */
#endif
+#define BUTTON_NUMBER 1
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Fabien Marteau <fab...@ar...> - ARMadeus Systems");
-MODULE_DESCRIPTION("button device driver");
+#define BUTTON_REG_OFFSET (0x02)
+#define BUTTON_ID_OFFSET (0x00)
-/* main device structure */
-struct button_dev{
- struct cdev cdev; /* Char device structure */
- struct semaphore sem; /* Mutex */
- void * fpga_virtual_base_address; /* fpga register base address*/
- wait_queue_head_t button_queue;
- u8 reading;
+/* platform device */
+struct plat_button_port{
+ const char *name; /*instance name */
+ int interrupt_number; /* interrupt_number */
+ int num; /* instance number */
+ void * membase; /* ioremap base address */
+ int idnum; /* identity number */
+ int idoffset; /* identity relative address */
+ struct button_dev *sdev; /* struct for main device structure*/
};
-/* major and minor number */
-
-#define N_DEV 1
-static dev_t devno; /* to store Major and minor numbers */
-static struct button_dev *buttondev;
-#define BUTTON_LENGTH 1
-struct resource *mem; /* pointer to fpga button */
-
-
-/* to read write button register */
-ssize_t button_read(struct file *fildes, char __user *buff,
- size_t count, loff_t *offp);
-
-int button_open(struct inode *inode, struct file *filp);
-
-int button_release(struct inode *, struct file *filp);
-
-struct file_operations button_fops = {
- .owner = THIS_MODULE,
- .read = button_read,
- .open = button_open,
- .release = button_release,
-};
-
-static irqreturn_t fpga_interrupt(int irq,void *stuff,struct pt_regs *reg);
-
-static void free_all(void);
-
-static ssize_t button_fpga_read(void * addr, u16 *data , struct button_dev *dev);
-static ssize_t button_fpga_write(void * addr, u16 *data, struct button_dev *dev);
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/gbutton.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,369 @@
+/*
+ ***********************************************************************
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ * Generic driver for Wishbone button IP
+ *
+ * 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 <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/config.h>
+#endif
+
+/* form module/drivers */
+#include <linux/init.h>
+#include <linux/module.h>
+
+/* for file operations */
+#include <linux/fs.h>
+#include <linux/cdev.h>
+
+/* copy_to_user function */
+#include <asm/uaccess.h>
+
+/* request_mem_region */
+#include <linux/ioport.h>
+
+/* readw() writew() */
+#include <asm/io.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+/* hardware addresses */
+# include <asm/hardware.h>
+#else
+# include <mach/hardware.h>
+#endif
+
+
+/* for platform device */
+#include <linux/platform_device.h>
+
+/* button */
+#include "button.h"
+
+
+/* for debugging messages*/
+//#define BUTTON_DEBUG
+
+#undef PDEBUG
+#ifdef BUTTON_DEBUG
+# ifdef __KERNEL__
+/* for kernel spage */
+# define PDEBUG(fmt,args...) printk(KERN_DEBUG "BUTTON : " fmt, ##args)
+# else
+/* for user space */
+# define PDEBUG(fmt,args...) printk(stderr, fmt, ##args)
+# endif
+#else
+# define PDEBUG(fmt,args...) /* no debbuging message */
+#endif
+
+/********************************
+ * main device structure
+ * ******************************/
+struct button_dev{
+ char *name; /* name of the instance */
+ struct cdev cdev; /* char device structure */
+ struct semaphore sem; /* mutex */
+ void * membase; /* base address for instance */
+ dev_t devno; /* to store Major and minor numbers */
+ u8 read_in_wait; /* user is waiting for value to read */
+};
+
+/***********************************
+ * characters file /dev operations
+ * *********************************/
+ssize_t button_read(struct file *fildes, char __user *buff,
+ size_t count, loff_t *offp)
+{
+ struct button_dev *ldev = fildes->private_data;
+ u16 data=0;
+ ssize_t retval = 0;
+
+ ldev->read_in_wait = 1;
+
+ if(*offp + count >= 1) /* Only one word can be read */
+ count = 1 - *offp;
+
+ if((retval=down_interruptible(&ldev->sem))<0)
+ {
+ goto out;
+ }
+
+ data=ioread16(ldev->membase+BUTTON_REG_OFFSET);
+ PDEBUG("Read %d at 0x%x\n",data,(unsigned int)ldev->membase+BUTTON_REG_OFFSET);
+
+ /* return data for user */
+ if(copy_to_user(buff,&data,2)){
+ printk(KERN_WARNING "read : copy to user data error\n");
+ retval = -EFAULT;
+ goto out;
+ }
+
+ *offp = *offp + count;
+ retval = 1;
+
+out:
+ ldev->read_in_wait = 0;
+ return retval;
+}
+
+
+int button_open(struct inode *inode, struct file *filp){
+ /* Allocate and fill any data structure to be put in filp->private_data */
+ filp->private_data = container_of(inode->i_cdev,struct button_dev, cdev);
+ return 0;
+}
+
+int button_release(struct inode *inode, struct file *filp)
+{
+ struct button_dev *dev;
+
+ dev = container_of(inode->i_cdev,struct button_dev,cdev);
+ filp->private_data=NULL;
+
+ return 0;
+}
+
+
+static struct file_operations button_fops = {
+ .owner = THIS_MODULE,
+ .read = button_read,
+ .open = button_open,
+ .release = button_release,
+};
+
+/**********************************
+ * irq management
+ * awake read process
+ * ********************************/
+
+static irqreturn_t button_interrupt(int irq,void *dev_id){
+ struct button_dev *ldev = dev_id;
+ /* wake up reading process */
+ if(ldev->read_in_wait)up(&ldev->sem);
+ /* acknowledge irq_mngr */
+ return IRQ_HANDLED;
+}
+
+/**********************************
+ * driver probe
+ **********************************/
+static int button_probe(struct platform_device *pdev)
+{
+ struct plat_button_port *dev = pdev->dev.platform_data;
+
+ int result = 0; /* error return */
+ int button_major,button_minor;
+ u16 data;
+ struct button_dev *sdev;
+
+ PDEBUG("Button probing\n");
+ PDEBUG("Register %s num %d\n",dev->name,dev->num);
+
+ /**************************/
+ /* check if ID is correct */
+ /**************************/
+ data = ioread16(dev->membase+BUTTON_ID_OFFSET);
+ if(data != dev->idnum){
+ result = -1;
+ printk(KERN_WARNING "For %s id:%d doesn't match "
+ "with id read %d,\n is device present ?\n",
+ dev->name,dev->idnum,data);
+ goto error_id;
+ }
+
+ /********************************************/
+ /* allocate memory for sdev structure */
+ /********************************************/
+ sdev = kmalloc(sizeof(struct button_dev),GFP_KERNEL);
+ if(!sdev){
+ result = -ENOMEM;
+ goto error_sdev_alloc;
+ }
+ dev->sdev = sdev;
+ sdev->membase = dev->membase;
+ sdev->name = (char *)kmalloc((1+strlen(dev->name))*sizeof(char),
+ GFP_KERNEL);
+ if (sdev->name == NULL) {
+ printk("Kmalloc name space error\n");
+ goto error_name_alloc;
+ }
+ if (strncpy(sdev->name,dev->name,1+strlen(dev->name)) < 0) {
+ printk("copy error");
+ goto error_name_copy;
+ }
+
+ /******************************************/
+ /* Get the major and minor device numbers */
+ /******************************************/
+ button_major = 251;
+ button_minor = dev->num;
+
+ PDEBUG("%s:Get the major and minor device numbers\n",dev->name);
+ if (button_major) {
+ sdev->devno = MKDEV(button_major, button_minor);
+ result = register_chrdev_region(sdev->devno, 1,dev->name);
+ } else {
+ result = alloc_chrdev_region(&sdev->devno,
+ button_minor,
+ 1,
+ dev->name);
+ button_major = MAJOR(sdev->devno);
+ }
+ if (result < 0) {
+ printk(KERN_WARNING "%s: can't get major %d\n",
+ dev->name,button_major);
+ goto error_devno;
+ }
+ printk(KERN_INFO "%s: MAJOR: %d MINOR: %d\n",
+ dev->name,
+ MAJOR(sdev->devno),
+ MINOR(sdev->devno));
+
+ /* initiate mutex locked */
+ sdev->read_in_wait = 0;
+ init_MUTEX_LOCKED(&sdev->sem);
+
+ /****************************/
+ /* Init the cdev structure */
+ /****************************/
+ PDEBUG("Init the cdev structure\n");
+ cdev_init(&sdev->cdev,&button_fops);
+ sdev->cdev.owner = THIS_MODULE;
+ sdev->cdev.ops = &button_fops;
+
+ /* Add the device to the kernel, connecting cdev to major/minor number */
+ PDEBUG("%s: Add the device to the kernel, "
+ "connecting cdev to major/minor number \n",dev->name);
+ result = cdev_add(&sdev->cdev,sdev->devno,1);
+ if(result < 0){
+ printk(KERN_WARNING "%s: can't add cdev\n",dev->name);
+ goto error_cdev_add;
+ }
+
+ /* irq registering */
+ result = request_irq(dev->interrupt_number,
+ button_interrupt,
+ IRQF_SAMPLE_RANDOM,
+ sdev->name,
+ sdev);
+ if(result < 0){
+ printk(KERN_ERR "Can't register irq %d\n",
+ dev->interrupt_number);
+ goto request_irq_error;
+ }
+ printk(KERN_INFO "button: irq registered : %d\n",
+ dev->interrupt_number);
+
+ /* OK module inserted ! */
+ printk(KERN_INFO "%s insered\n",dev->name);
+ return 0;
+
+ /*********************/
+ /* Errors management */
+ /*********************/
+ /* freeing irq */
+ free_irq(dev->interrupt_number,sdev);
+request_irq_error:
+ /* delete the cdev structure */
+ cdev_del(&sdev->cdev);
+ PDEBUG("%s:cdev deleted\n",dev->name);
+error_cdev_add:
+ /* free major and minor number */
+ unregister_chrdev_region(sdev->devno,1);
+ printk(KERN_INFO "%s: Led deleted\n",dev->name);
+error_devno:
+error_name_copy:
+ kfree(sdev->name);
+error_name_alloc:
+ kfree(sdev);
+error_sdev_alloc:
+ printk(KERN_ERR "%s: not inserted\n", dev->name);
+error_id:
+ return result;
+}
+
+static int __devexit button_remove(struct platform_device *pdev)
+{
+ struct plat_button_port *dev = pdev->dev.platform_data;
+ struct button_dev *sdev = (*dev).sdev;
+ /* freeing irq */
+ free_irq(dev->interrupt_number,sdev);
+//request_irq_error:
+ /* delete the cdev structure */
+ cdev_del(&sdev->cdev);
+ PDEBUG("%s:cdev deleted\n",dev->name);
+//error_cdev_add:
+ /* free major and minor number */
+ unregister_chrdev_region(sdev->devno,1);
+ printk(KERN_INFO "%s: Led deleted\n",dev->name);
+//error_devno:
+//error_name_copy:
+ kfree(sdev->name);
+//error_name_alloc:
+ kfree(sdev);
+//error_sdev_alloc:
+ printk(KERN_INFO "%s: deleted with success\n", dev->name);
+//error_id:
+ return 0;
+
+}
+
+static struct platform_driver plat_button_driver =
+{
+ .probe = button_probe,
+ .remove = __devexit_p(button_remove),
+ .driver =
+ {
+ .name = "button",
+ .owner = THIS_MODULE,
+ },
+};
+
+/**********************************
+ * Module management
+ **********************************/
+static int __init button_init(void)
+{
+ int ret;
+
+ PDEBUG("Platform driver name %s",plat_button_driver.driver.name);
+ ret = platform_driver_register(&plat_button_driver);
+ if (ret) {
+ printk(KERN_ERR "Platform driver register error\n");
+ return ret;
+ }
+ return 0;
+}
+
+static void __exit button_exit(void)
+{
+ platform_driver_unregister(&plat_button_driver);
+}
+
+module_init(button_init);
+module_exit(button_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Fabien Marteau <fab...@ar...> "
+ "- ARMadeus Systems");
+MODULE_DESCRIPTION("button device generic driver");
+
+
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c 2009-03-03 16:03:26 UTC (rev 1108)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/testbutton.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -1,5 +1,3 @@
-
- * ***********************************************************************
/* a program to write/read values on fpga address map
* Fabien Marteau <fab...@ar...>
* 7 april 2008
@@ -27,10 +25,6 @@
**********************************************************************
*/
-
- *
- */
-
#include <stdio.h>
#include <stdlib.h>
@@ -63,7 +57,7 @@
printf( "Testing button driver\n" );
if(argc < 2){
- perror("invalid arguments number\ntestled <button_filename>\n");
+ perror("invalide arguments number\ntestled <button_filename>\n");
exit(EXIT_FAILURE);
}
@@ -93,3 +87,4 @@
close(fled);
exit(0);
}
+
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Kconfig (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Kconfig 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,14 @@
+
+#
+# Armadeus custom drivers configuration
+#
+#
+
+#
+config ARMADEUS_WISHBONE_EXAMPLE_IRQ_MNGR_DRIVER
+ tristate "IRQ manager with wishbone interface"
+ default m
+ depends on ARMADEUS_WISHBONE_EXAMPLE_DRIVERS
+ ---help---
+
+
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,34 @@
+#
+# Makefile for the Armadeus FPGA OpenCore IRQ manager IP
+#
+
+ifneq ($(KERNELRELEASE),)
+
+# Part executed when called from kernel build system:
+
+obj-$(CONFIG_ARMADEUS_WISHBONE_EXAMPLE_IRQ_MNGR_DRIVER) += irq_ocore.o test.o
+irq_ocore-objs := main.o
+
+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:
+ rm -f *.*o \
+ rm -f *.mod.c \
+ rm -f *.cmd \
+ rm -f *.o.d \
+ rm -f *.order \
+ rm -f .*.cmd \
+ rm -rf .tmp_versions \
+ rm -f Module.symvers
+
+endif
+
Property changes on: trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/README
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/README (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/README 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,8 @@
+To compile this driver from here:
+---------------------------------
+ make ARCH=arm CROSS_COMPILE=$PWD/../../../../../buildroot/build_arm/staging_dir/bin/arm-linux-
+
+To install this driver:
+-----------------------
+Copy resulting *.ko files on your target rootfs
+
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/main.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/main.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/main.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,192 @@
+/*
+ * Driver for the IRQ manager loaded in FPGA of the Armadeus boards
+ *
+ * (C) Copyright 2008 Armadeus Systems
+ * Author: Julien Boibessot <jul...@ar...>
+ *
+ * Inspired of linux/arch/arm/mach-imx/irq.c
+ *
+ * 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 <linux/module.h>
+#include <linux/init.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+# include <asm/hardware.h>
+# include <asm/arch/irqs.h>
+#else
+# include <mach/hardware.h>
+# include <mach/irqs.h>
+#endif
+#include <asm/irq.h>
+#include <asm/io.h> // readb() & Co
+
+#include <asm/mach/irq.h>
+
+#if 0
+#define DEBUG_FPGA_IRQ(fmt,args...) printk(KERN_DEBUG "IRQ_MNGR: " fmt,##args)
+#else
+#define DEBUG_FPGA_IRQ(fmt...) do { } while (0)
+#endif
+
+#define IRQ_MNGR_BASE (0x0)
+#define ID (1)
+#define ID_OFFSET (0x02 *(16/8))
+
+
+#define NB_IT (16)
+
+#define FPGA_IMR (APF9328_FPGA_VIRT + IRQ_MNGR_BASE + 0x00) /* Interrupt Mask Register */
+#define FPGA_ISR (APF9328_FPGA_VIRT + IRQ_MNGR_BASE + 0x02) /* Interrupt Status Register */
+
+
+static int
+imx_fpga_irq_type(unsigned int _irq, unsigned int type)
+{
+ return 0;
+}
+
+static void
+imx_fpga_ack_irq(unsigned int irq)
+{
+ int shadow;
+
+ shadow = 1 << ((irq - IRQ_FPGA_START) % NB_IT);
+ DEBUG_FPGA_IRQ("%s: irq %d ack:0x%x\n", __FUNCTION__, irq, shadow);
+ writew( shadow, FPGA_ISR );
+
+ /* if last IT ack GPIO global IRQ */
+ if( readw(FPGA_ISR) == 0 )
+ ISR(IRQ_TO_REG(APF9328_FPGA_IRQ)) = 1 << (APF9328_FPGA_IRQ - IRQ_GPIOA(0));
+}
+
+static void
+imx_fpga_mask_irq(unsigned int irq)
+{
+ int shadow;
+
+ shadow = readw(FPGA_IMR);
+ shadow &= ~( 1 << ((irq - IRQ_FPGA_START) % NB_IT));
+ DEBUG_FPGA_IRQ("%s: irq %d mask:0x%x\n", __FUNCTION__, irq, shadow);
+ writew( shadow, FPGA_IMR );
+}
+
+static void
+imx_fpga_unmask_irq(unsigned int irq)
+{
+ int shadow;
+
+ shadow = readw(FPGA_IMR);
+ shadow |= 1 << ((irq - IRQ_FPGA_START) % NB_IT);
+ DEBUG_FPGA_IRQ("%s: irq %d mask:0x%x\n", __FUNCTION__, irq, shadow);
+ writew( shadow, FPGA_IMR );
+}
+
+static void
+imx_fpga_handler(unsigned int mask, unsigned int irq,
+ struct irq_desc *desc)
+{
+ DEBUG_FPGA_IRQ("%s: mask:0x%x\n", __FUNCTION__, mask);
+ desc = irq_desc + irq;
+ while (mask) {
+ if (mask & 1) {
+ DEBUG_FPGA_IRQ("handling irq %d\n", irq);
+ desc_handle_irq(irq, desc);
+ }
+ irq++;
+ desc++;
+ mask >>= 1;
+ }
+}
+
+static void
+imx_fpga_demux_handler(unsigned int irq_unused, struct irq_desc *desc)
+{
+ unsigned int mask, irq;
+
+ mask = readw(FPGA_ISR);
+ irq = IRQ_FPGA_START;
+ imx_fpga_handler(mask, irq, desc);
+}
+
+static struct irq_chip imx_fpga_chip = {
+ .name = "FPGA",
+ .ack = imx_fpga_ack_irq,
+ .mask = imx_fpga_mask_irq,
+ .unmask = imx_fpga_unmask_irq,
+ .set_type = imx_fpga_irq_type,
+};
+
+
+static int __init ocore_irq_mng_init(void)
+{
+ unsigned int irq;
+ u16 data;
+ int result=0;
+
+ DEBUG_FPGA_IRQ("Initializing FPGA IRQs\n");
+
+ /**************************/
+ /* check if ID is correct */
+ /**************************/
+ data = ioread16(APF9328_FPGA_VIRT+IRQ_MNGR_BASE+ID_OFFSET);
+ if(data != ID)
+ {
+ result = -1;
+ printk(KERN_WARNING "For irq_mngr id:%d doesn't match with id read %d,\n is device present ?\n",ID,data);
+ goto error_id;
+ }
+
+ /* Mask all interrupts initially */
+ writew(0, FPGA_IMR);
+
+ for (irq = IRQ_FPGA(0); irq < IRQ_FPGA(NB_IT-1); irq++) {
+ set_irq_chip_and_handler( irq, &imx_fpga_chip, handle_edge_irq );
+ set_irq_flags(irq, IRQF_VALID);
+ }
+ set_irq_chained_handler(APF9328_FPGA_IRQ, imx_fpga_demux_handler);
+
+ DEBUG_FPGA_IRQ("IRQs initialized\n");
+
+ return 0;
+error_id:
+ return result;
+}
+
+static void __exit ocore_irq_mng_exit(void)
+{
+ unsigned int irq;
+ for (irq = IRQ_FPGA(0); irq < IRQ_FPGA(NB_IT-1); irq++) {
+ set_irq_chip( irq, NULL);
+ set_irq_handler(irq,NULL);
+ set_irq_flags(irq, 0);
+ }
+ set_irq_chained_handler(APF9328_FPGA_IRQ, NULL);
+
+ DEBUG_FPGA_IRQ("%s\n", __FUNCTION__);
+}
+
+module_init(ocore_irq_mng_init);
+module_exit(ocore_irq_mng_exit);
+
+MODULE_AUTHOR("Julien Boibessot, <jul...@ar...>");
+MODULE_DESCRIPTION("Armadeus OpenCore IRQ manager");
+MODULE_LICENSE("GPL");
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/test.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/test.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/test.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,81 @@
+/*
+ * Driver to test OpenCore IRQ manager driver
+ *
+ * Copyright (C) 2008 Armadeus Systems
+ * Author: Julien Boibessot <jul...@ar...>
+ *
+ * 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 <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/config.h>
+#endif
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <asm/irq.h>
+
+
+/* Module's parameters: */
+static int interrupt=IRQ_FPGA(3);
+module_param(interrupt, int, 0000);
+MODULE_PARM_DESC(interrupt, "IT to request");
+
+#define DRIVER_NAME "IRQ test module"
+
+
+static irqreturn_t fpga_interrupt(int irq,void *dev_id,struct pt_regs *reg)
+{
+ printk(KERN_ERR "FPGA IT n°%d\n", irq);
+
+ return IRQ_HANDLED;
+}
+
+unsigned int data;
+
+static int __init irq_mng_test_init(void)
+{
+ int result;
+
+ /* IRQ registering */
+ if( (result=request_irq( interrupt, (irq_handler_t)fpga_interrupt, /*IRQF_SHARED*/0, "ocore_irq_test", &data)) < 0 )
+ {
+ printk(KERN_ERR "Can't request IRQ n°%d\n", interrupt);
+ goto error;
+ }
+
+ printk(KERN_INFO DRIVER_NAME " inserted (IRQ %d reserved), be sure to have correspondig IP loaded in the FPGA !\n", interrupt);
+ return 0;
+
+error:
+ return result;
+}
+
+static void __exit irq_mng_test_exit(void)
+{
+ printk(DRIVER_NAME " unloaded\n");
+ free_irq(interrupt, 0); /* still a bug here ! */
+}
+
+
+module_init(irq_mng_test_init);
+module_exit(irq_mng_test_exit);
+
+MODULE_AUTHOR("Julien Boibessot, <jul...@ar...>");
+MODULE_DESCRIPTION("OpenCore IRQ manager IP's test driver");
+MODULE_LICENSE("GPL");
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_led/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/Kconfig (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/Kconfig 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,9 @@
+#
+#
+
+config ARMADEUS_WISHBONE_EXAMPLE_LED_DRIVER
+ tristate "Wishbone Led driver"
+ default m
+ depends on ARMADEUS_WISHBONE_EXAMPLE_DRIVERS
+ ---help---
+ blink a led
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_led/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/Makefile (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/Makefile 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,36 @@
+#
+# Makefile for the Armadeus FPGA led driver
+#
+
+ifneq ($(KERNELRELEASE),)
+
+obj-$(CONFIG_ARMADEUS_WISHBONE_EXAMPLE_LED_DRIVER) += board_leds.o g_led.o
+
+else
+
+ARMADEUS_BASE_DIR=../../../../../..
+include $(ARMADEUS_BASE_DIR)/Makefile.in
+
+KDIR := $(ARMADEUS_LINUX_DIR)
+PWD := $(shell pwd)
+
+
+default:
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
+
+test:
+ ~/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc -Wall testled.c -o testled
+ chmod 755 testled
+
+clean:
+ rm -f *.*o \
+ rm -f *.mod.c \
+ rm -f *.cmd \
+ rm -f *.o.d \
+ rm -f *.order \
+ rm -f .*.cmd \
+ rm -rf .tmp_versions \
+ rm -f Module.symvers
+
+endif
+
Property changes on: trunk/target/linux/modules/fpga/wishbone_example/wb_led/Makefile
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_led/board_leds.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/board_leds.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/board_leds.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,83 @@
+/*
+ ***********************************************************************
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ * Specific led driver for generic led driver
+ *
+ * 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 <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/config.h>
+#endif
+
+/* form module/drivers */
+#include <linux/init.h>
+#include <linux/module.h>
+
+/* for platform device */
+#include <linux/platform_device.h>
+
+#include"led.h"
+
+static struct plat_led_port plat_led0_data = {
+ .name = "LED0",
+ .num=0,
+ .membase = (void *)(ARMADEUS_FPGA_BASE_ADDR_VIRT + 0x8),
+ .idnum=2,
+ .idoffset=0x01 * (16 /8)
+};
+
+
+void plat_led_release(struct device *dev){
+ PDEBUG("device %s .released\n",dev->bus_id);
+}
+
+static struct platform_device plat_led0_device = {
+ .name = "led",
+ .id=0,
+ .dev={
+ .release = plat_led_release,
+ .platform_data=&plat_led0_data},
+};
+
+
+static int __init sled_init(void)
+{
+ int ret=-1;
+ ret = platform_device_register(&plat_led0_device);
+ if(ret<0)return ret;
+
+ PDEBUG("*led inserted*\n");
+ return ret;
+}
+
+static void __exit sled_exit(void)
+{
+ printk(KERN_WARNING "deleting board_leds\n");
+ platform_device_unregister(&plat_led0_device);
+
+}
+
+module_init(sled_init);
+module_exit(sled_exit);
+
+MODULE_AUTHOR("Fabien Marteau <fab...@ar...>");
+MODULE_DESCRIPTION("Driver to blink blink some leds");
+MODULE_LICENSE("GPL");
+
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_led/g_led.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/g_led.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/g_led.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,360 @@
+/*
+ ***********************************************************************
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ * Generic driver for Wishbone led IP
+ *
+ * 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 <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/config.h>
+#endif
+
+/* form module/drivers */
+#include <linux/init.h>
+#include <linux/module.h>
+
+/* for file operations */
+#include <linux/fs.h>
+#include <linux/cdev.h>
+
+/* copy_to_user function */
+#include <asm/uaccess.h>
+
+/* request_mem_region */
+#include <linux/ioport.h>
+
+/* readw() writew() */
+#include <asm/io.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+/* hardware addresses */
+# include <asm/hardware.h>
+#else
+# include <mach/hardware.h>
+#endif
+
+
+/* for platform device */
+#include <linux/platform_device.h>
+
+/* led */
+#include "led.h"
+
+
+/* for debugging messages*/
+//#define LED_DEBUG
+
+#undef PDEBUG
+#ifdef LED_DEBUG
+# ifdef __KERNEL__
+/* for kernel spage */
+# define PDEBUG(fmt,args...) printk(KERN_DEBUG "LED : " fmt, ##args)
+# else
+/* for user space */
+# define PDEBUG(fmt,args...) printk(stderr, fmt, ##args)
+# endif
+#else
+# define PDEBUG(fmt,args...) /* no debbuging message */
+#endif
+
+/*************************/
+/* main device structure */
+/*************************/
+struct led_dev{
+ char *name; /* the name of the instance */
+ int loaded_led_num;/* number of the led, depends on load order*/
+ struct cdev cdev;/* Char device structure */
+ void * membase; /* base address for instance */
+ dev_t devno; /* to store Major and minor numbers */
+};
+
+/******************************/
+/* to read write led register */
+/******************************/
+ssize_t led_read(struct file *fildes, char __user *buff,
+ size_t count, loff_t *offp);
+
+ssize_t led_write(struct file *fildes, const char __user *
+ buff,size_t count, loff_t *offp);
+int led_open(struct inode *inode, struct file *filp);
+
+int led_release(struct inode *, struct file *filp);
+
+struct file_operations led_fops = {
+ .owner = THIS_MODULE,
+ .read = led_read,
+ .write = led_write,
+ .open = led_open,
+ .release = led_release,
+};
+
+/***********************************
+ * characters file /dev operations
+ * *********************************/
+ssize_t led_read(struct file *fildes, char __user *buff,
+ size_t count, loff_t *offp){
+ struct led_dev *sdev = fildes->private_data;
+ u16 data=0;
+ PDEBUG("Read value\n");
+ if(*offp != 0 ){ /* offset must be 0 */
+ PDEBUG("offset %d\n",(int)*offp);
+ return 0;
+ }
+
+ PDEBUG("count %d\n",count);
+ if(count > 2){ /* 16bits max*/
+ count = 2;
+ }
+
+ data = ioread16(sdev->membase+LED_REG_OFFSET);
+ PDEBUG("Read %d at %x\n",data,(int)(sdev->membase+LED_REG_OFFSET));
+
+ /* return data for user */
+ if(copy_to_user(buff,&data,count)){
+ printk(KERN_WARNING "read : copy to user data error\n");
+ return -EFAULT;
+ }
+ return count;
+}
+
+ssize_t led_write(struct file *fildes, const char __user *
+ buff,size_t count, loff_t *offp){
+ struct led_dev *sdev = fildes->private_data;
+ u16 data=0;
+
+ if(*offp != 0){ /* offset must be 0 */
+ PDEBUG("offset %d\n",(int)*offp);
+ return 0;
+ }
+
+ PDEBUG("count %d\n",count);
+ if(count > 2){ /* 16 bits max)*/
+ count = 2;
+ }
+
+ if(copy_from_user(&data,buff,count)){
+ printk(KERN_WARNING "write : copy from user error\n");
+ return -EFAULT;
+ }
+
+ PDEBUG("Write %d at %x\n",
+ data,
+ (int)(sdev->membase+LED_REG_OFFSET));
+ iowrite16(data,sdev->membase+LED_REG_OFFSET);
+
+ return count;
+}
+
+int led_open(struct inode *inode, struct file *filp){
+ /* Allocate and fill any data structure to be put in filp->private_data */
+ filp->private_data = container_of(inode->i_cdev,struct led_dev, cdev);
+ PDEBUG( "Led opened\n");
+ return 0;
+}
+
+/* ******************************
+ * Init and release functions
+ * ******************************/
+int led_release(struct inode *inode, struct file *filp)
+{
+ struct led_dev *dev;
+
+ dev = container_of(inode->i_cdev,struct led_dev,cdev);
+ PDEBUG( "%s: released\n",dev->name);
+ filp->private_data=NULL;
+
+ return 0;
+}
+
+/**********************************
+ * driver probe
+ **********************************/
+static int led_probe(struct platform_device *pdev)
+{
+ struct plat_led_port *dev = pdev->dev.platform_data;
+
+ int result = 0; /* error return */
+ int led_major,led_minor;
+ u16 data;
+ struct led_dev *sdev;
+
+ PDEBUG("Led probing\n");
+ PDEBUG("Register %s num %d\n",dev->name,dev->num);
+
+ /**************************/
+ /* check if ID is correct */
+ /**************************/
+ data = ioread16(dev->membase+dev->idoffset);
+ if(data != dev->idnum){
+ result = -1;
+ printk(KERN_WARNING "For %s id:%d doesn't match with "
+ "id read %d,\n is device present ?\n",
+ dev->name,dev->idnum,data);
+ goto error_id;
+ }
+
+ /********************************************/
+ /* allocate memory for sdev structure */
+ /********************************************/
+ sdev = kmalloc(sizeof(struct led_dev),GFP_KERNEL);
+ if(!sdev){
+ result = -ENOMEM;
+ goto error_sdev_alloc;
+ }
+ dev->sdev = sdev;
+ sdev->membase = dev->membase;
+ sdev->name = (char *)kmalloc((1+strlen(dev->name))*sizeof(char),
+ GFP_KERNEL);
+ if (sdev->name == NULL) {
+ printk("Kmalloc name space error\n");
+ goto error_name_alloc;
+ }
+ if (strncpy(sdev->name,dev->name,1+strlen(dev->name)) < 0) {
+ printk("copy error");
+ goto error_name_copy;
+ }
+
+ /******************************************/
+ /* Get the major and minor device numbers */
+ /******************************************/
+
+ led_major = 252;
+ led_minor = dev->num ;/* num come from plat_led_port data structure */
+
+ PDEBUG("%s:Get the major and minor device numbers\n",dev->name);
+ if (led_major) {
+ sdev->devno = MKDEV(led_major, led_minor);
+ result = register_chrdev_region(sdev->devno, 1,dev->name);
+ } else {
+ result = alloc_chrdev_region(&sdev->devno, led_minor, 1, dev->name);
+ led_major = MAJOR(sdev->devno);
+ }
+ if (result < 0) {
+ printk(KERN_WARNING "%s: can't get major %d\n",dev->name,led_major);
+ goto error_devno;
+ }
+ printk(KERN_INFO "%s: MAJOR: %d MINOR: %d\n",
+ dev->name,
+ MAJOR(sdev->devno),
+ MINOR(sdev->devno));
+
+ /****************************/
+ /* Init the cdev structure */
+ /****************************/
+ PDEBUG("Init the cdev structure\n");
+ cdev_init(&sdev->cdev, &led_fops);
+ sdev->cdev.owner = THIS_MODULE;
+ sdev->cdev.ops = &led_fops;
+
+ /* Add the device to the kernel, connecting cdev to major/minor number */
+ PDEBUG("%s:Add the device to the kernel, "
+ "connecting cdev to major/minor number \n", dev->name);
+ result = cdev_add(&sdev->cdev, sdev->devno, 1);
+ if (result) {
+ printk(KERN_WARNING "%s: can't add cdev\n", dev->name);
+ goto error_cdev_add;
+ }
+
+ /* initialize led value */
+ data=1;
+ iowrite16(data,sdev->membase);
+ PDEBUG("Wrote %x at %x\n", data,(int)( sdev->membase+LED_REG_OFFSET));
+
+ /* OK module inserted ! */
+ printk(KERN_INFO "Led module %s insered\n", dev->name);
+ return 0;
+
+ /*********************/
+ /* Errors management */
+ /*********************/
+ /* delete the cdev structure */
+ cdev_del(&sdev->cdev);
+ PDEBUG("%s:cdev deleted\n",dev->name);
+error_cdev_add:
+ /* free major and minor number */
+ unregister_chrdev_region(sdev->devno,1);
+ printk(KERN_INFO "%s: Led deleted\n",dev->name);
+error_devno:
+error_name_copy:
+ kfree(sdev->name);
+error_name_alloc:
+ kfree(sdev);
+error_sdev_alloc:
+ printk(KERN_ERR "%s: not inserted\n", dev->name);
+error_id:
+ return result;
+}
+
+static int __devexit led_remove(struct platform_device *pdev)
+{
+ struct plat_led_port *dev = pdev->dev.platform_data;
+ struct led_dev *sdev = (*dev).sdev;
+ PDEBUG("Unregister %s, number %d\n",dev->name,dev->num);
+ /* delete the cdev structure */
+ PDEBUG("cdev name : %s\n",sdev->name);
+ cdev_del(&sdev->cdev);
+ PDEBUG("%s:cdev deleted\n",dev->name);
+ /*error_cdev_add:*/
+ /* free major and minor number */
+ unregister_chrdev_region(sdev->devno,1);
+ /*error_devno:*/
+ /*error_name_copy:*/
+ kfree(sdev->name);
+ /*error_name_alloc:*/
+ kfree(sdev);
+ /*error_sdev_alloc:*/
+ printk(KERN_INFO "%s: deleted with success\n", dev->name);
+ return 0;
+}
+
+static struct platform_driver plat_led_driver = {
+ .probe = led_probe,
+ .remove = __devexit_p(led_remove),
+ .driver = {
+ .name = "led",
+ .owner = THIS_MODULE,
+ },
+};
+
+/**********************************
+ * Module management
+ **********************************/
+static int __init led_init(void)
+{
+ int ret;
+
+ PDEBUG("Platform driver name %s\n", plat_led_driver.driver.name);
+ ret = platform_driver_register(&plat_led_driver);
+ return ret;
+}
+
+static void led_exit(void)
+{
+ platform_driver_unregister(&plat_led_driver);
+ PDEBUG("driver unregistered\n");
+}
+
+module_init(led_init);
+module_exit(led_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Fabien Marteau <fab...@ar...>-ARMadeus Systems");
+MODULE_DESCRIPTION("Led device driver");
+
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_led/led.h
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/led.h (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/led.h 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,98 @@
+/*
+ ***********************************************************************
+ *
+ * (c) Copyright 2007 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ * Driver for Wishbone led IP
+ *
+ * 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 __LED_H__
+#define __LED_H__
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/config.h>
+#endif
+
+/* form module/drivers */
+#include <linux/init.h>
+#include <linux/module.h>
+
+/* for file operations */
+#include <linux/fs.h>
+#include <linux/cdev.h>
+
+/* copy_to_user function */
+#include <asm/uaccess.h>
+
+/* request_mem_region */
+#include <linux/ioport.h>
+
+/* readw() writew() */
+#include <asm/io.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
+/* hardware addresses */
+# include <asm/hardware.h>
+#else
+# include <mach/hardware.h>
+#endif
+
+
+/* for platform device */
+#include <linux/platform_device.h>
+
+#endif
+
+/* for debugging messages*/
+#define LED_DEBUG
+
+#undef PDEBUG
+#ifdef LED_DEBUG
+# ifdef __KERNEL__
+ /* for kernel spage */
+# define PDEBUG(fmt,args...) printk(KERN_DEBUG "LED : " fmt, ##args)
+# else
+ /* for user space */
+# define PDEBUG(fmt,args...) printk(stderr, fmt, ##args)
+# endif
+#else
+# define PDEBUG(fmt,args...) /* no debbuging message */
+#endif
+
+
+#define FPGA_BASE_ADDR IMX_CS1_PHYS
+#define FPGA_MEM_SIZE IMX_CS1_SIZE
+
+#define LED_NUMBER 1
+
+#define LED_REG_OFFSET (0x00)
+#define LED_ID_OFFSET (0x02)
+
+/* platform device */
+struct plat_led_port{
+ const char *name; /* instance name */
+ int num; /* instance number */
+ void *membase; /* virtual base address */
+ int idnum; /* identity number */
+ int idoffset; /* identity relative address */
+ struct led_dev *sdev; /* struct for main device structure*/
+};
+
+
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_led/s_led.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/s_led.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/s_led.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,77 @@
+/*
+ ***********************************************************************
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ * Specific led driver for generic led driver
+ *
+ * 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 <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
+#include <linux/config.h>
+#endif
+
+/* form module/drivers */
+#include <linux/init.h>
+#include <linux/module.h>
+
+/* for platform device */
+#include <linux/platform_device.h>
+
+#include"led.h"
+
+
+static struct plat_led_port plat_led_data[] = {
+ {
+ .name = "led0",
+ .num = 0,
+ .membase = 0x04
+ },
+ {
+ .name = "led1",
+ .num = 1,
+ .membase = 0x06
+ },
+ { },
+};
+
+static struct platform_device plat_led_device = {
+ .name = "led",
+ .id = 0,
+ .dev = {
+ .platform_data = plat_led_data
+ },
+};
+
+static int __init sled_init(void)
+{
+ return platform_device_register(&plat_led_device);
+}
+
+static void __exit sled_exit(void)
+{
+ platform_device_unregister(&plat_led_device);
+}
+
+module_init(sled_init);
+module_exit(sled_exit);
+
+MODULE_AUTHOR("Fabien Marteau <fab...@ar...>");
+MODULE_DESCRIPTION("Driver to blink blink some leds");
+MODULE_LICENSE("GPL");
+
Added: trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_led/testled.c 2009-03-03 16:20:44 UTC (rev 1109)
@@ -0,0 +1,132 @@
+/* a program to write/read values on fpga address map
+ * Fabien Marteau <fab...@ar...>
+ * 7 april 2008
+ * fpgaaccess.h
+ *
+ * (c) Copyright 2008 Armadeus project
+ * Fabien Marteau <fab...@ar...>
+ *
+ * A simple driver for reading and writing on
+ * fpga throught a character file /dev/fpgaaccess
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+/* file management */
+#include <sys/stat.h>
+#include <fcntl.h>
+
+/* as name said */
+#include <signal.h>
+
+/* sleep */
+#include <unistd.h>
+
+int fled;
+
+void quit(int pouet){
+ close(fled);
+ exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+ unsigned short i,j;
+
+ /* quit when Ctrl-C pressed */
+ signal(SIGINT, quit);
+
+ j=0;
+
+ printf( "Testing led driver\n" );
+
+ if(argc < 2){
+ perror("invalid arguments number\ntestled <led_filename>\n");
+ exit(EXIT_FAILURE);
+ }
+
+ while(1){
+ i = (i==0)?1:0;
+ fflush(stdout);
+
+ fled=open(argv[1],O_RDWR);
+ if(fled<0){
+ perror("can't open file \n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* read value */
+ if(read(fled,&j,2)<0){
+ perror("read error\n");
+ exit(EXIT_FAILURE);
+ }
+ printf("Read %d\n",j);
+ close(fled);
+ sleep(1);
+
+ fled=open(argv[1],O_RDWR);
+ if(fled<0){
+ perror("can't open file \n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* write value */
+ j = 0;
+ if(write(fled,&j,2)<=0){
+ perror("write error\n");
+ exit(EXIT_FAILURE);
+ }
+ close(fled);
+ printf("Write 0\n");
+ sleep(1);
+
+ fled=open(argv[1],O_RDWR);
+ if(fled<0){
+ perror("can't open file \n");
+ exit(EXIT_FAILURE);
+ }
+ /* read value */
+ if(read(fled,&j,2)<0){
+ perror("read error\n");
+ exit(EXIT_FAILURE);
+ }
+ close(fled);
+ printf("Read %d\n",j);
+ sleep(1);
+
+ fled=open(argv[1],O_RDWR);
+ if(fled<0){
+ perror("can't open file \n");
+ exit(EXIT_FAILURE);
+ }
+ /* write value */
+ j = 1;
+ if(write(fled,&j,2)<=0){
+ perror("write error\n");
+ exit(EXIT_FAILURE);
+ }
+ close(fled);
+ printf("Write 1\n");
+ sleep(1);
+
+ }
+
+ close(fled);
+ exit(0);
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <Fa...@us...> - 2009-03-03 16:03:32
|
Revision: 1108
http://armadeus.svn.sourceforge.net/armadeus/?rev=1108&view=rev
Author: FabM
Date: 2009-03-03 16:03:26 +0000 (Tue, 03 Mar 2009)
Log Message:
-----------
[FIRMWARE] Updating wishbone_example to be compatible with linux drivers in target/linux/module/fpga/wishbone_example/ directory
Modified Paths:
--------------
trunk/firmware/wishbone_example/Makefile
trunk/firmware/wishbone_example/README
Added Paths:
-----------
trunk/firmware/wishbone_example/src/button.vhd
trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper.vhd
trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper00_mwb16_intercon.vhd
trunk/firmware/wishbone_example/src/irq_mngr.vhd
trunk/firmware/wishbone_example/src/led.vhd
trunk/firmware/wishbone_example/src/rstgen_syscon.vhd
trunk/firmware/wishbone_example/src/top_wishbone_example.vhd
trunk/firmware/wishbone_example/src/wishbone_example.ucf
trunk/firmware/wishbone_example/testbench/apf_test_pkg.vhd
trunk/firmware/wishbone_example/testbench/top_wishbone_example_tb.vhd
Removed Paths:
-------------
trunk/firmware/wishbone_example/src/intercon.vhd
trunk/firmware/wishbone_example/src/wb_button.vhd
trunk/firmware/wishbone_example/src/wb_led.ucf
trunk/firmware/wishbone_example/src/wb_led.vhd
trunk/firmware/wishbone_example/src/wb_top.vhd
trunk/firmware/wishbone_example/src/wishbone/
trunk/firmware/wishbone_example/testbench/wb_top_tb.vhd
Modified: trunk/firmware/wishbone_example/Makefile
===================================================================
--- trunk/firmware/wishbone_example/Makefile 2009-03-03 10:22:12 UTC (rev 1107)
+++ trunk/firmware/wishbone_example/Makefile 2009-03-03 16:03:26 UTC (rev 1108)
@@ -1,237 +1,98 @@
-# Makefile for VHDL synthesis and simulation
-# version 1.0
+# Makefile for ghdl simulation
+# version 1.2
# Fabien Marteau
# project name
-PROJECT=Wb_top
+PROJECT=top_wishbone_example
+
# vhdl files
-FILES = src/Wb_top.vhd src/Wb_button.vhd src/intercon.vhd src/wishbone/imx_wrapper.vhd src/wishbone/irq_mngr.vhd src/Wb_led.vhd src/wishbone/syscon.vhd
-# pin configuration
-UCF_FILE = src/Wb_led.ucf
-# Synthesis constraints file
-XCF_FILE =
+TESTBENCH_FILE=testbench/$(PROJECT)_tb.vhd
+LIBRARY_FILE=testbench/apf_test_pkg.vhd
+SYNTHESIS_FILE=$(PROJECT)_synthesis.vhd
+PLACE_AND_ROUTE_FILE=$(PROJECT)_timesim.vhd
+FILES=src/top_wishbone_example.vhd \
+ src/imx9328_wb16_wrapper.vhd \
+ src/rstgen_syscon.vhd \
+ src/irq_mngr.vhd \
+ src/led.vhd \
+ src/button.vhd \
+ src/imx9328_wb16_wrapper00_mwb16_intercon.vhd \
+ testbench/apf_test_pkg.vhd
+
# testbench
-SIMTOP = wb_top_tb
-SIMFILES = ../apf_pkg/apf_test_pkg.vhd testbench/Wb_top_tb.vhd
+SIMTOP =$(PROJECT)_tb
# Simu break condition
GHDL_SIM_OPT = --assert-level=error
#GHDL_SIM_OPT = --stop-time=500ns
-# FPGA options
-PART = xc3s200-4-tq144
-
-############################
-# Personnals options
-############################
-
-CAT=../Xtools/catcolor
-BRIEF=../Xtools/brief.py
-
-
-############################
-# Xilinx options
-############################
-BIN = bin
-WORK = work
-
-SYNTH = xst
-NGDBUILD = ngdbuild
-MAP = map
-PAR = par
-TRACE = trce
-BITGEN = bitgen
-
-ifdef $(XCF_FILE)
-XCF = -uc $(XCF_FILE)\n
-endif
-
##############################
# GHDL options
##############################
SIMDIR = simu
-SYNTHFILES = bin/bus_led_ise/netgen/synthesis
-GHDL_CMD = ghdl
-GHDL_FLAGS = --ieee=synopsys --warn-no-vital-generic
-#GHDL_FLAGS = --ieee=synopsys -P~/Xilinx92i/coregen/ip/xilinx/primary/com/xilinx/ip/unisim --warn-no-vital-generic
+GHDL_CMD =ghdl
+GHDL_SIMU_FLAGS = --ieee=synopsys --warn-no-vital-generic
+GHDL_SYNTHESIS_FLAGS = --ieee=synopsys -P$$XILINX/ghdl/unisim --warn-no-vital-generic
+GHDL_PANDR_FLAGS = --ieee=synopsys -P$$XILINX/ghdl/simprim --warn-no-vital-generic
VIEW_CMD = /usr/bin/gtkwave
OBJS_FILES = $(patsubst %.vhd, %.o, $(notdir $(FILES)) )
OBJS_SIMFILES = $(patsubst %.vhd, %.o, $(notdir $(SIMFILES)) )
-#################################
-# Synthesis with xst
-#################################
-
-messages : bit
- $(BRIEF) $(BIN)/$(PROJECT)
- @echo bitstream : $(PROJECT).bit
-
-
-bit : $(BIN)/$(PROJECT).ncd trace
- -$(BITGEN) -intstyle xflow -w \
- -g DebugBitstream:No \
- -g Binary:yes \
- -g CRC:Enable \
- -g ConfigRate:6 \
- -g CclkPin:PullUp \
- -g M0Pin:PullUp \
- -g M1Pin:PullUp \
- -g M2Pin:PullUp \
- -g ProgPin:PullUp \
- -g DonePin:PullUp \
- -g TckPin:PullUp \
- -g TdiPin:PullUp \
- -g TdoPin:PullUp \
- -g TmsPin:PullUp \
- -g UnusedPin:PullDown \
- -g UserID:0xFFFFFFFF \
- -g DCMShutdown:Disable \
- -g DCIUpdateMode:AsRequired \
- -g StartUpClk:CClk \
- -g DONE_cycle:4 \
- -g GTS_cycle:5 \
- -g GWE_cycle:6 \
- -g LCK_cycle:NoWait \
- -g Match_cycle:Auto \
- -g Security:None \
- -g DonePipe:No \
- -g DriveDone:No \
- $(BIN)/$(PROJECT).ncd > $(BIN)/$(PROJECT).bitlog
- $(CAT) $(BIN)/$(PROJECT).bitlog
- -cp $(BIN)/$(PROJECT).bit /tftpboot/
- -cp $(BIN)/$(PROJECT).bin /tftpboot/
-
-trace: $(BIN)/$(PROJECT).ncd $(BIN)/$(PROJECT).pcf
- -$(TRACE) -intstyle xflow -e 3 -l 3 -s 4 -xml $(BIN)/$(PROJECT) $(BIN)/$(PROJECT).ncd -o $(BIN)/$(PROJECT).twr $(BIN)/$(PROJECT).pcf
- $(CAT) $(BIN)/$(PROJECT).tracelog
-
-$(BIN)/$(PROJECT).ncd : par
-
-par : $(BIN)/$(PROJECT)_map.ncd $(BIN)/$(PROJECT).pcf
- - sh -c 'pid=$$$$; $(PAR) -w -intstyle xflow -ol std -t 1 $(BIN)/$(PROJECT)_map.ncd $(BIN)/$(PROJECT).ncd $(BIN)/$(PROJECT).pcf | (sed "/^PAR done/q";kill $$pid)' > $(BIN)/$(PROJECT).parlog
- $(CAT) $(BIN)/$(PROJECT).parlog
- - killall -9 par
-
-$(BIN)/$(PROJECT).pcf $(BIN)/$(PROJECT)_map.ncd : map
-
-map : $(BIN)/$(PROJECT).ngd
- - sh -c 'pid=$$$$ ; $(MAP) -intstyle xflow -p $(PART) -cm area -pr b -k 4 -c 100 -o $(BIN)/$(PROJECT)_map.ncd $(BIN)/$(PROJECT).ngd $(BIN)/$(PROJECT).pcf | (sed "/^See MAP report file/q" ; kill $$pid ) ' > $(BIN)/$(PROJECT).maplog
- $(CAT) $(BIN)/$(PROJECT).maplog
- - killall -9 map
-
-$(BIN)/$(PROJECT).ngd : ngdbuild
-
-ngdbuild : $(BIN)/$(PROJECT).ngr $(BIN)/$(PROJECT).ngc $(BIN)/$(PROJECT).lso
- -$(NGDBUILD) -intstyle xflow -dd _ngo -nt timestamp -p $(PART) $(BIN)/$(PROJECT).ngc $(BIN)/$(PROJECT).ngd -uc $(UCF_FILE) > $(BIN)/$(PROJECT).ngdlog
- $(CAT) $(BIN)/$(PROJECT).ngdlog
-
-$(BIN)/$(PROJECT).ngc $(BIN)/$(PROJECT).ngr $(BIN)/$(PROJECT).lso : synthesis
-
-synthesis : $(BIN)/$(PROJECT).prj $(BIN)/$(PROJECT).xst
- $(SYNTH) -ifn $(BIN)/$(PROJECT).xst -ofn $(BIN)/$(PROJECT).log \
- | sed "s/^ERROR/[01\;31mERROR[00m/"\
- | sed "s/^WARNING/[01\;33mWARNING[00m/"\
- | sed "s/^INFO/[01\;32mINFO[0m/"
-
-$(BIN)/$(PROJECT).xst $(BIN)/$(PROJECT).prj :
- @mkdir -p $(BIN)
- @touch $(BIN)/$(PROJECT);
- @for f in $(FILES); do \
- echo vhdl $(WORK) \"$$f\" >> $(BIN)/$(PROJECT).prj;\
- done
- @echo work > $(BIN)/$(PROJECT).lso
- @mkdir -p ./bin/xst/projnav.tmp
- @echo " \
- set -tmpdir "./bin/xst/projnav.tmp" \n\
- set -xsthdpdir "./bin/xst" \n\
- run \n\
- -ifn $(BIN)/$(PROJECT).prj \n\
- -ifmt mixed \n\
- -ofn $(BIN)/$(PROJECT) \n\
- -ofmt NGC \n\
- -p $(PART) \n\
- -top $(PROJECT) \n\
- -opt_mode Speed \n\
- -opt_level 1 \n\
- $(XCF)\
- -iuc NO \n\
- -lso $(BIN)/$(PROJECT).lso \n\
- -keep_hierarchy NO \n\
- -rtlview Yes \n\
- -glob_opt AllClockNets \n\
- -read_cores YES \n\
- -write_timing_constraints NO \n\
- -cross_clock_analysis NO \n\
- -hierarchy_separator / \n\
- -bus_delimiter <> \n\
- -case maintain \n\
- -slice_utilization_ratio 100 \n\
- -bram_utilization_ratio 100 \n\
- -verilog2001 YES \n\
- -fsm_extract YES -fsm_encoding Auto \n\
- -safe_implementation No \n\
- -fsm_style lut \n\
- -ram_extract Yes \n\
- -ram_style Auto \n\
- -rom_extract Yes \n\
- -mux_style Auto \n\
- -decoder_extract YES \n\
- -priority_extract YES \n\
- -shreg_extract YES \n\
- -shift_extract YES \n\
- -xor_collapse YES \n\
- -rom_style Auto \n\
- -auto_bram_packing NO \n\
- -mux_extract YES \n\
- -resource_sharing YES \n\
- -async_to_sync NO \n\
- -mult_style auto \n\
- -iobuf YES \n\
- -max_fanout 500 \n\
- -bufg 8 \n\
- -register_duplication YES \n\
- -register_balancing No \n\
- -slice_packing YES \n\
- -optimize_primitives NO \n\
- -use_clock_enable Yes \n\
- -use_sync_set Yes \n\
- -use_sync_reset Yes \n\
- -iob auto \n\
- -equivalent_register_removal YES \n\
- -slice_utilization_ratio_maxmargin 5\n\
- " >> $(BIN)/$(PROJECT).xst
-
-clean : ghdl-clean
- -rm -rf $(BIN)
- -rm -rf _ngo
- -rm xilinx_device_details.xml
-
########################
# Simulation with GHDL
########################
-ghdl-compile :
+help:
+ @echo 'Cleaning:'
+ @echo ' clean - delete simulation directory'
+ @echo
+ @echo 'simulate:'
+ @echo ' ghdl-simu - make behavioural simulation'
+ @echo ' ghdl-synthesis - make post synthesis simulation'
+ @echo ' ghdl-pr - make post place and route simulation'
+ @echo ' '
+ @echo 'view result:'
+ @echo ' ghdl-view - Launch wave view with gtk-waves'
+
+ghdl-simu : ghdl-compil ghdl-run
+ghdl-synthesis : ghdl-compil-synthesis ghdl-run
+ghdl-pr : ghdl-compil-pr ghdl-run
+
+ghdl-compil :
mkdir -p simu
- $(GHDL_CMD) -i $(GHDL_FLAGS) --workdir=simu --work=work $(SIMFILES) $(FILES)
- $(GHDL_CMD) -m $(GHDL_FLAGS) --workdir=simu --work=work $(SIMTOP)
+ $(GHDL_CMD) -i $(GHDL_SIMU_FLAGS) --workdir=simu --work=work $(TESTBENCH_FILE) $(LIBRARY_FILE) $(FILES)
+ $(GHDL_CMD) -m $(GHDL_SIMU_FLAGS) --workdir=simu --work=work $(SIMTOP)
@mv $(SIMTOP) simu/$(SIMTOP)
-#TODO: make it working !
-ghdl-simsynth :
- $(GHDL_CMD) -i $(GHDL_FLAGS) --workdir=simu --work=work $(SYNTHFILES) $(SIMFILES)
- $(GHDL_CMD) -m $(GHDL_FLAGS) --workdir=simu --work=work $(SIMTOP)
+ghdl-compil-synthesis:
+ @if [ ! -e $(SYNTHESIS_FILE) ] ; then\
+ echo "You have to copy $(SYNTHESIS_FILE), in this directory first" ;\
+ [ -e $(SYNTHESIS_FILE) ];\
+ fi;
+ mkdir -p simu
+ $(GHDL_CMD) -i $(GHDL_SYNTHESIS_FLAGS) --workdir=simu --work=work $(TESTBENCH_FILE) $(LIBRARY_FILE) $(SYNTHESIS_FILE)
+ $(GHDL_CMD) -m $(GHDL_SYNTHESIS_FLAGS) --workdir=simu --work=work $(SIMTOP)
@mv $(SIMTOP) simu/$(SIMTOP)
+ghdl-compil-pr :
+ @if [ ! -e $(PLACE_AND_ROUTE_FILE) ] ; then\
+ echo "You have to copy $(PLACE_AND_ROUTE_FILE), in this directory first" ;\
+ [ -e $(PLACE_AND_ROUTE_FILE) ];\
+ fi;
+ mkdir -p simu
+ $(GHDL_CMD) -i $(GHDL_PANDR_FLAGS) --workdir=simu --work=work $(TESTBENCH_FILE) $(LIBRARY_FILE) $(PLACE_AND_ROUTE_FILE)
+ $(GHDL_CMD) -m $(GHDL_PANDR_FLAGS) --workdir=simu --work=work $(SIMTOP)
+ @mv $(SIMTOP) simu/$(SIMTOP)
+
ghdl-run :
@$(SIMDIR)/$(SIMTOP) $(GHDL_SIM_OPT) --vcdgz=$(SIMDIR)/$(SIMTOP).vcdgz
ghdl-view:
gunzip --stdout $(SIMDIR)/$(SIMTOP).vcdgz | $(VIEW_CMD) --vcd
-ghdl-clean :
- $(GHDL_CMD) --clean --workdir=simu
+clean :
+ $(GHDL_CMD) --clean --workdir=simu
-rm -rf simu
-
Modified: trunk/firmware/wishbone_example/README
===================================================================
--- trunk/firmware/wishbone_example/README 2009-03-03 10:22:12 UTC (rev 1107)
+++ trunk/firmware/wishbone_example/README 2009-03-03 16:03:26 UTC (rev 1108)
@@ -4,18 +4,19 @@
send it to i.mx processor.To manage these irq
two registers are available :
irq_mask ( addr : 0x0000) : enable irq writing 1
- irq_pend/irq_ack (addr : 0x0002) : writing 1 acknowledge irq
- and reading 1 inform that an irq pending.
+ irq_pend/irq_ack (addr : 0x0002) : writing 1 acknowledge irq and
+ reading 1 inform that an irq
+ pending.
This design use one irq for button push and release.
* wb_led : a simple led register, one led is branched on register LSB.
To switch on led write '0' on led register. Address register
is :
- LED (addr : 0x0004) : on/off led
+ LED (addr : 0x0008) : on/off led
* wb_button: Simple button register, when button is pressed, register LSB
is '0', and when it's release LSB is '1'. On each switching
an interuption is send to irq_mngr. Address register is :
- button (addr : 0x0008) : read pressed value
+ button (addr : 0x000e) : read pressed value
see
http://www.armadeus.com/wiki/index.php?title=A_simple_design_with_Wishbone_bus
Added: trunk/firmware/wishbone_example/src/button.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/button.vhd (rev 0)
+++ trunk/firmware/wishbone_example/src/button.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -0,0 +1,98 @@
+---------------------------------------------------------------------------
+-- Company : ARMades Systems
+-- Author(s) : Fabien Marteau <fab...@ar...>
+--
+-- Creation Date : 10/03/2008
+-- File : button.vhd
+--
+-- Abstract :
+--
+---------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+---------------------------------------------------------------------------
+Entity button is
+---------------------------------------------------------------------------
+ generic(
+ id : natural := 2
+ );
+ port
+ (
+ -- global signals
+ gls_reset : in std_logic ;
+ gls_clk : in std_logic ;
+ -- Wishbone signals
+ wbs_add : in std_logic ;
+ wbs_readdata : out std_logic_vector( 15 downto 0);
+ wbs_strobe : in std_logic ;
+ wbs_cycle : in std_logic ;
+ wbs_write : in std_logic ;
+ wbs_ack : out std_logic;
+ -- irq
+ irq : out std_logic ;
+ -- fpga input
+ button : in std_logic
+ );
+end entity;
+
+
+---------------------------------------------------------------------------
+Architecture button_1 of button is
+ ---------------------------------------------------------------------------
+ signal button_r : std_logic ;
+ signal reg : std_logic_vector( 15 downto 0);
+begin
+
+ -- connect button
+ cbutton : process(gls_clk,gls_reset)
+ begin
+ if gls_reset = '1' then
+ reg <= (others => '0');
+ elsif rising_edge(gls_clk) then
+ reg <= "000000000000000"&button;
+ end if;
+ end process cbutton;
+
+
+ -- rise interruption
+ pbutton : process(gls_clk,gls_reset)
+ begin
+ if gls_reset = '1' then
+ irq <= '0';
+ button_r <= '0';
+ elsif rising_edge(gls_clk) then
+ if button_r /= button then
+ irq <= '1';
+ else
+ irq <= '0';
+ end if;
+ button_r <= button;
+ end if;
+ end process pbutton;
+
+ -- register reading process
+ pread : process(gls_clk,gls_reset)
+ begin
+ if(gls_reset = '1') then
+ wbs_ack <= '0';
+ wbs_readdata <= (others => '0');
+ elsif(rising_edge(gls_clk)) then
+ wbs_ack <= '0';
+ if(wbs_strobe = '1' and wbs_write = '0' and wbs_cycle = '1')then
+ wbs_ack <= '1';
+ if wbs_add = '0' then
+ wbs_readdata <= std_logic_vector(to_unsigned(id,16));
+ else
+ wbs_readdata <= reg;
+ end if;
+ else
+ wbs_readdata <= (others => '0');
+ end if;
+ end if;
+ end process pread;
+
+end architecture button_1;
+
Added: trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper.vhd (rev 0)
+++ trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -0,0 +1,95 @@
+-------------------------------------------------------------------------------
+--
+-- File : imx9328_wb16_wrapper.vhd
+-- Related files : (none)
+--
+-- Author(s) : Fabrice Mousset (fab...@la...)
+-- Project : i.MX wrapper to Wishbone bus
+--
+-- Creation Date : 2007/01/19
+--
+-- Description : This is the top file of the IP
+-------------------------------------------------------------------------------
+-- Modifications :
+-----
+-- 2008/03/05
+-- Fabien Marteau (fab...@ar...)
+-- adding comments and changing some signals names
+--
+-------------------------------------------------------------------------------
+
+library IEEE;
+ use IEEE.std_logic_1164.all;
+ use IEEE.numeric_std.all;
+
+-- ----------------------------------------------------------------------------
+ Entity imx9328_wb16_wrapper is
+-- ----------------------------------------------------------------------------
+ port
+ (
+ -- i.MX Signals
+ imx_address : in std_logic_vector(11 downto 0); -- LSB not used
+ imx_data : inout std_logic_vector(15 downto 0);
+ imx_cs_n : in std_logic;
+ imx_oe_n : in std_logic;
+ imx_eb3_n : in std_logic;
+
+ -- Global Signals
+ gls_reset : in std_logic;
+ gls_clk : in std_logic;
+
+ -- Interrupt out for write error
+-- int_err : out std_logic;
+
+ -- Wishbone interface signals
+ wbm_address : out std_logic_vector(12 downto 0); -- Address bus
+ wbm_readdata : in std_logic_vector(15 downto 0); -- Data bus for read access
+ wbm_writedata : out std_logic_vector(15 downto 0); -- Data bus for write access
+ wbm_strobe : out std_logic; -- Data Strobe
+ wbm_write : out std_logic; -- Write access
+ wbm_ack : in std_logic ; -- acknowledge
+ wbm_cycle : out std_logic -- bus cycle in progress
+ );
+ end entity;
+
+-- ----------------------------------------------------------------------------
+ Architecture RTL of imx9328_wb16_wrapper is
+-- ----------------------------------------------------------------------------
+
+signal write : std_logic;
+signal read : std_logic;
+signal strobe : std_logic;
+signal writedata : std_logic_vector(15 downto 0);
+signal address : std_logic_vector(12 downto 0);
+
+begin
+
+-- ----------------------------------------------------------------------------
+-- External signals synchronization process
+-- ----------------------------------------------------------------------------
+process(gls_clk, gls_reset)
+begin
+ if(gls_reset='1') then
+ write <= '0';
+ read <= '0';
+ strobe <= '0';
+ writedata <= (others => '0');
+ address <= (others => '0');
+ elsif(rising_edge(gls_clk)) then
+ strobe <= not (imx_cs_n) and not(imx_oe_n and imx_eb3_n);
+ write <= not (imx_cs_n or imx_eb3_n);
+ read <= not (imx_cs_n or imx_oe_n);
+ address <= imx_address & '0';
+ writedata <= imx_data;
+ end if;
+end process;
+
+wbm_address <= address when (strobe = '1') else (others => '0');
+wbm_writedata <= writedata when (write = '1') else (others => '0');
+wbm_strobe <= strobe;
+wbm_write <= write;
+wbm_cycle <= strobe;
+
+imx_data <= wbm_readdata when(read = '1' ) else (others => 'Z');
+
+end architecture RTL;
Added: trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper00_mwb16_intercon.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper00_mwb16_intercon.vhd (rev 0)
+++ trunk/firmware/wishbone_example/src/imx9328_wb16_wrapper00_mwb16_intercon.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -0,0 +1,168 @@
+---------------------------------------------------------------------------
+-- Company : Automaticaly generated by POD
+-- Author(s) :
+--
+-- Creation Date : 2009-03-03
+-- File : imx9328_wb16_wrapper00_mwb16.vhd
+--
+-- Abstract :
+-- Connect slaves to mwb16 from imx9328_wb16_wrapper00
+--
+---------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+Entity imx9328_wb16_wrapper00_mwb16 is
+ port
+ (
+
+ -- irq_mngr00_swb16 connection
+ irq_mngr00_wbs_s1_address : out std_logic_vector(1 downto 0);
+ irq_mngr00_wbs_s1_readdata : in std_logic_vector(15 downto 0);
+ irq_mngr00_wbs_s1_writedata : out std_logic_vector(15 downto 0);
+ irq_mngr00_wbs_s1_ack : in std_logic;
+ irq_mngr00_wbs_s1_strobe : out std_logic;
+ irq_mngr00_wbs_s1_cycle : out std_logic;
+ irq_mngr00_wbs_s1_write : out std_logic;
+
+ -- irq_mngr00_candr connection
+ irq_mngr00_gls_clk : out std_logic;
+ irq_mngr00_gls_reset : out std_logic;
+
+ -- led0_swb16 connection
+ led0_wbs_add : out std_logic;
+ led0_wbs_writedata : out std_logic_vector(15 downto 0);
+ led0_wbs_readdata : in std_logic_vector(15 downto 0);
+ led0_wbs_strobe : out std_logic;
+ led0_wbs_cycle : out std_logic;
+ led0_wbs_write : out std_logic;
+ led0_wbs_ack : in std_logic;
+
+ -- led0_candr connection
+ led0_gls_reset : out std_logic;
+ led0_gls_clk : out std_logic;
+
+ -- button0_swb16 connection
+ button0_wbs_add : out std_logic;
+ button0_wbs_readdata : in std_logic_vector(15 downto 0);
+ button0_wbs_strobe : out std_logic;
+ button0_wbs_write : out std_logic;
+ button0_wbs_ack : in std_logic;
+ button0_wbs_cycle : out std_logic;
+
+ -- button0_candr connection
+ button0_gls_reset : out std_logic;
+ button0_gls_clk : out std_logic;
+
+ -- imx9328_wb16_wrapper00_mwb16 connection
+ imx9328_wb16_wrapper00_wbm_address : in std_logic_vector(12 downto 0);
+ imx9328_wb16_wrapper00_wbm_readdata : out std_logic_vector(15 downto 0);
+ imx9328_wb16_wrapper00_wbm_writedata : in std_logic_vector(15 downto 0);
+ imx9328_wb16_wrapper00_wbm_strobe : in std_logic;
+ imx9328_wb16_wrapper00_wbm_write : in std_logic;
+ imx9328_wb16_wrapper00_wbm_ack : out std_logic;
+ imx9328_wb16_wrapper00_wbm_cycle : in std_logic;
+
+ -- imx9328_wb16_wrapper00_candr connection
+ imx9328_wb16_wrapper00_gls_reset : out std_logic;
+ imx9328_wb16_wrapper00_gls_clk : out std_logic;
+
+ -- rstgen_syscon00_imx9328_wb16_wrapper00 connection
+ rstgen_syscon00_gls_clk : in std_logic;
+ rstgen_syscon00_gls_reset : in std_logic
+ );
+end entity;
+
+architecture imx9328_wb16_wrapper00_mwb16_1 of imx9328_wb16_wrapper00_mwb16 is
+ signal irq_mngr00_swb16_cs : std_logic := '0' ;
+ signal led0_swb16_cs : std_logic := '0' ;
+ signal button0_swb16_cs : std_logic := '0' ;
+begin
+
+ -- Clock and Reset connection
+ irq_mngr00_gls_clk <= rstgen_syscon00_gls_clk;
+ irq_mngr00_gls_reset <= rstgen_syscon00_gls_reset;
+
+ led0_gls_reset <= rstgen_syscon00_gls_reset;
+ led0_gls_clk <= rstgen_syscon00_gls_clk;
+
+ button0_gls_reset <= rstgen_syscon00_gls_reset;
+ button0_gls_clk <= rstgen_syscon00_gls_clk;
+
+ imx9328_wb16_wrapper00_gls_reset <= rstgen_syscon00_gls_reset;
+ imx9328_wb16_wrapper00_gls_clk <= rstgen_syscon00_gls_clk;
+
+
+ -- Address decoding --
+ -----------------------
+ irq_mngr00_wbs_s1_address <= imx9328_wb16_wrapper00_wbm_address(2 downto 1);
+ led0_wbs_add <= imx9328_wb16_wrapper00_wbm_address(1);
+ button0_wbs_add <= imx9328_wb16_wrapper00_wbm_address(1);
+
+ decodeproc : process(rstgen_syscon00_gls_clk,rstgen_syscon00_gls_reset,imx9328_wb16_wrapper00_wbm_address)
+ begin
+ if rstgen_syscon00_gls_reset='1' then
+ irq_mngr00_swb16_cs <= '0';
+ led0_swb16_cs <= '0';
+ button0_swb16_cs <= '0';
+ elsif rising_edge(rstgen_syscon00_gls_clk) then
+
+ if imx9328_wb16_wrapper00_wbm_address(12 downto 3)="0000000000" and imx9328_wb16_wrapper00_wbm_strobe='1' then
+ irq_mngr00_swb16_cs <= '1';
+ else
+ irq_mngr00_swb16_cs <= '0';
+ end if;
+
+ if imx9328_wb16_wrapper00_wbm_address(12 downto 2)="00000000010" and imx9328_wb16_wrapper00_wbm_strobe='1' then
+ led0_swb16_cs <= '1';
+ else
+ led0_swb16_cs <= '0';
+ end if;
+
+ if imx9328_wb16_wrapper00_wbm_address(12 downto 2)="00000000011" and imx9328_wb16_wrapper00_wbm_strobe='1' then
+ button0_swb16_cs <= '1';
+ else
+ button0_swb16_cs <= '0';
+ end if;
+
+ end if;
+ end process decodeproc;
+
+ -----------------------------
+ -- Control signals to slave
+ -----------------------------
+
+ -- for irq_mngr00
+ irq_mngr00_wbs_s1_strobe <= (imx9328_wb16_wrapper00_wbm_strobe and irq_mngr00_swb16_cs );
+ irq_mngr00_wbs_s1_cycle <= (imx9328_wb16_wrapper00_wbm_cycle and irq_mngr00_swb16_cs );
+ irq_mngr00_wbs_s1_write <= (imx9328_wb16_wrapper00_wbm_write and irq_mngr00_swb16_cs );
+ irq_mngr00_wbs_s1_writedata <= imx9328_wb16_wrapper00_wbm_writedata when (imx9328_wb16_wrapper00_wbm_write and irq_mngr00_swb16_cs ) = '1' else (others => '0');
+
+ -- for led0
+ led0_wbs_strobe <= (imx9328_wb16_wrapper00_wbm_strobe and led0_swb16_cs );
+ led0_wbs_cycle <= (imx9328_wb16_wrapper00_wbm_cycle and led0_swb16_cs );
+ led0_wbs_write <= (imx9328_wb16_wrapper00_wbm_write and led0_swb16_cs );
+ led0_wbs_writedata <= imx9328_wb16_wrapper00_wbm_writedata when (imx9328_wb16_wrapper00_wbm_write and led0_swb16_cs ) = '1' else (others => '0');
+
+ -- for button0
+ button0_wbs_strobe <= (imx9328_wb16_wrapper00_wbm_strobe and button0_swb16_cs );
+ button0_wbs_cycle <= (imx9328_wb16_wrapper00_wbm_cycle and button0_swb16_cs );
+ button0_wbs_write <= '0';
+
+
+ -------------------------------
+ -- Control signal for master --
+ -------------------------------
+ imx9328_wb16_wrapper00_wbm_readdata <= irq_mngr00_wbs_s1_readdata when irq_mngr00_swb16_cs='1' else
+ led0_wbs_readdata when led0_swb16_cs='1' else
+ button0_wbs_readdata when button0_swb16_cs='1' else
+ (others => '0');
+ imx9328_wb16_wrapper00_wbm_ack <= (irq_mngr00_wbs_s1_ack and irq_mngr00_swb16_cs)
+ or
+ (led0_wbs_ack and led0_swb16_cs)
+ or
+ (button0_wbs_ack and button0_swb16_cs);
+
+end architecture imx9328_wb16_wrapper00_mwb16_1;
Deleted: trunk/firmware/wishbone_example/src/intercon.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/intercon.vhd 2009-03-03 10:22:12 UTC (rev 1107)
+++ trunk/firmware/wishbone_example/src/intercon.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -1,157 +0,0 @@
----------------------------------------------------------------------------
--- Company : ARMadeus Systems
--- Author(s) : Fabien Marteau
---
--- Creation Date : 05/03/2008
--- File : intercon.vhd
---
--- Abstract : connect master wishbone device with
--- slave(s) wishbone device
---
------------------------------------------------------------------------------------
--- 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.
-----------------------------------------------------------------------------------
-
-
-library IEEE;
-use IEEE.STD_LOGIC_1164.ALL;
-use IEEE.numeric_std.all;
-
----------------------------------------------------------------------------
-Entity intercon is
----------------------------------------------------------------------------
- port
- (
- -- imx wishbone master connexion
- gls_reset_m1 : out std_logic ;
- gls_clk_m1 : out std_logic ;
-
- wbm_address_m1 : in std_logic_vector( 12 downto 0);
- wbm_readdata_m1 : out std_logic_vector( 15 downto 0);
- wbm_writedata_m1 : in std_logic_vector( 15 downto 0);
- wbm_strobe_m1 : in std_logic ;
- wbm_write_m1 : in std_logic ;
- wbm_sel_m1 : in std_logic_vector( 1 downto 0);
- wbm_ack_m1 : out std_logic ;
- wbm_cycle_m1 : in std_logic ;
-
- -- led wishbone slave connexion
- gls_reset_s1 : out std_logic ;
- gls_clk_s1 : out std_logic ;
- wbs_writedata_s1 : out std_logic_vector( 15 downto 0);
- wbs_readdata_s1 : in std_logic_vector( 15 downto 0);
- wbs_strobe_s1 : out std_logic ;
- wbs_write_s1 : out std_logic ;
- wbs_ack_s1 : in std_logic ;
-
- -- button slave connexion
- gls_reset_s2 : out std_logic ;
- gls_clk_s2 : out std_logic ;
- wbs_readdata_s2 : in std_logic_vector( 15 downto 0);
- wbs_strobe_s2 : out std_logic ;
- wbs_write_s2 : out std_logic ;
- wbs_ack_s2 : in std_logic ;
- wbs_irq_s2 : in std_logic ;
-
- -- irq slave connexion
- gls_reset_s3 : out std_logic ;
- gls_clk_s3 : out std_logic ;
- wbs_address_s3 : out std_logic ;
- wbs_writedata_s3 : out std_logic_vector( 15 downto 0);
- wbs_readdata_s3 : in std_logic_vector( 15 downto 0);
- wbs_strobe_s3 : out std_logic ;
- wbs_write_s3 : out std_logic ;
- wbs_ack_s3 : in std_logic ;
- wbs_irq_s3 : out std_logic ;
-
- -- syscon connection
- gls_reset_sys : in std_logic ;
- gls_clk_sys : in std_logic
- );
-end entity;
-
----------------------------------------------------------------------------
-Architecture intercon_1 of intercon is
----------------------------------------------------------------------------
- signal led_cs : std_logic ;
- signal button_cs : std_logic ;
- signal irq_cs : std_logic ;
- signal cs :std_logic_vector( 2 downto 0);
-begin
-
- -- clock and reset management
- gls_reset_s1 <= gls_reset_sys;
- gls_clk_s1 <= gls_clk_sys;
-
- gls_reset_s2 <= gls_reset_sys;
- gls_clk_s2 <= gls_clk_sys;
-
- gls_reset_s3 <= gls_reset_sys;
- gls_clk_s3 <= gls_clk_sys;
-
- gls_reset_m1 <= gls_reset_sys;
- gls_clk_m1 <= gls_clk_sys;
-
- -----------------------------
- -- master => slave connexions
- -----------------------------
- -- address decode
- irq_cs <= '1' when wbm_address_m1 = "0000000000000" or wbm_address_m1 = "0000000000010"
- else '0';
- led_cs <= '1' when wbm_address_m1 = "0000000000100"
- else '0';
- button_cs <= '1' when wbm_address_m1 = "0000000001000"
- else '0';
-
- wbs_address_s3 <= wbm_address_m1(1);
-
- -- control signals
- -- for led (s1)
- wbs_writedata_s1 <= wbm_writedata_m1 when (wbm_write_m1 and led_cs)='1'
- else (others => '0');
- wbs_strobe_s1 <= (wbm_strobe_m1 and led_cs);
- wbs_write_s1 <= (wbm_write_m1 and led_cs);
- -- for button(s2) read only
- wbs_strobe_s2 <= (wbm_strobe_m1 and button_cs);
- wbs_write_s2 <= '0';
-
- -- for irq (s3)
- wbs_writedata_s3 <= wbm_writedata_m1 when (wbm_write_m1 and irq_cs)='1'
- else (others => '0');
- wbs_strobe_s3 <= (wbm_strobe_m1 and irq_cs);
- wbs_write_s3 <= (wbm_write_m1 and irq_cs);
-
- -----------------------------
- -- slave => master connexions
- -----------------------------
- cs(0) <= led_cs;
- cs(1) <= button_cs;
- cs(2) <= irq_cs;
-
- with cs select
- wbm_readdata_m1 <= wbs_readdata_s1 when "001",
- wbs_readdata_s2 when "010",
- wbs_readdata_s3 when "100",
- (others => '0') when others;
- with cs select
- wbm_ack_m1 <= wbs_ack_s1 when "001",
- wbs_ack_s2 when "010",
- wbs_ack_s3 when "100",
- '0' when others;
-
- -- irq management
- wbs_irq_s3 <= wbs_irq_s2;
-
-end architecture intercon_1;
Added: trunk/firmware/wishbone_example/src/irq_mngr.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/irq_mngr.vhd (rev 0)
+++ trunk/firmware/wishbone_example/src/irq_mngr.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -0,0 +1,154 @@
+-------------------------------------------------------------------------------
+--
+-- File : irq_mnrg.vhd
+-- Related files : (none)
+--
+-- Author(s) : Fabrice Mousset (fab...@la...)
+-- Project : Wishbone Interruption Manager
+--
+-- Creation Date : 2007/01/05
+--
+-- Description : This is the top file of the IP
+-------------------------------------------------------------------------------
+-- Modifications :
+-- 20/10/2008 : Detected rising edge instead of high state
+-- Fabien Marteau <fab...@ar...>
+--
+-------------------------------------------------------------------------------
+
+library IEEE;
+ use IEEE.std_logic_1164.all;
+ use IEEE.numeric_std.all;
+
+-- ----------------------------------------------------------------------------
+ Entity irq_mngr is
+-- ----------------------------------------------------------------------------
+ generic
+ (
+ id : natural := 0;
+ irq_count : integer := 16; -- always 16 default
+ irq_level : std_logic := '1'
+ );
+ port
+ (
+ -- Global Signals
+ gls_clk : in std_logic;
+ gls_reset : in std_logic;
+
+ -- Wishbone interface signals
+ wbs_s1_address : in std_logic_vector(1 downto 0); -- Address bus
+ wbs_s1_readdata : out std_logic_vector(15 downto 0); -- Data bus for read access
+ wbs_s1_writedata : in std_logic_vector(15 downto 0); -- Data bus for write access
+ wbs_s1_ack : out std_logic; -- Access acknowledge
+ wbs_s1_strobe : in std_logic; -- Strobe
+ wbs_s1_cycle : in std_logic ; -- Cycle
+ wbs_s1_write : in std_logic; -- Write access
+
+ -- irq from other IP
+ irqport : in std_logic_vector(irq_count-1 downto 0);
+
+ -- Component external signals
+ gls_irq : out std_logic -- IRQ request
+ );
+ end entity;
+
+-- ----------------------------------------------------------------------------
+ Architecture RTL of irq_mngr is
+-- ----------------------------------------------------------------------------
+
+signal irq_r : std_logic_vector(irq_count-1 downto 0);
+signal irq_old : std_logic_vector(irq_count-1 downto 0);
+
+signal irq_pend : std_logic_vector(irq_count-1 downto 0);
+signal irq_ack : std_logic_vector(irq_count-1 downto 0);
+
+signal irq_mask : std_logic_vector(irq_count-1 downto 0);
+
+signal readdata : std_logic_vector(15 downto 0);
+signal rd_ack : std_logic;
+signal wr_ack : std_logic;
+
+begin
+
+-- ----------------------------------------------------------------------------
+-- External signals synchronization process
+-- ----------------------------------------------------------------------------
+process(gls_clk, gls_reset)
+begin
+ if(gls_reset='1') then
+ irq_r <= (others => '0');
+ irq_old <= (others => '0');
+ elsif(rising_edge(gls_clk)) then
+ irq_r <= irqport;
+ irq_old <= irq_r;
+ end if;
+end process;
+
+-- ----------------------------------------------------------------------------
+-- Interruption requests latching process on rising edge
+-- ----------------------------------------------------------------------------
+process(gls_clk, gls_reset)
+begin
+ if(gls_reset='1') then
+ irq_pend <= (others => '0');
+ elsif(rising_edge(gls_clk)) then
+ irq_pend <= (irq_pend or ((irq_r and (not irq_old))and irq_mask)) and (not irq_ack);
+ end if;
+end process;
+
+-- ----------------------------------------------------------------------------
+-- Register reading process
+-- ----------------------------------------------------------------------------
+process(gls_clk, gls_reset)
+begin
+ if(gls_reset='1') then
+ rd_ack <= '0';
+ readdata <= (others => '0');
+ elsif(rising_edge(gls_clk)) then
+ rd_ack <= '0';
+ if(wbs_s1_strobe = '1' and wbs_s1_write = '0' and wbs_s1_cycle = '1') then
+ rd_ack <= '1';
+ if(wbs_s1_address = "00") then
+ readdata(irq_count-1 downto 0) <= irq_mask;
+ elsif(wbs_s1_address="01") then
+ readdata(irq_count-1 downto 0) <= irq_pend;
+ elsif(wbs_s1_address="10") then
+ readdata <= std_logic_vector(to_unsigned(id,16));
+ else
+ readdata <= (others => '0');
+ end if;
+ end if;
+ end if;
+end process;
+
+-- ----------------------------------------------------------------------------
+-- Register update process
+-- ----------------------------------------------------------------------------
+process(gls_clk, gls_reset)
+begin
+ if(gls_reset='1') then
+ irq_ack <= (others => '0');
+ wr_ack <= '0';
+ irq_mask <= (others => '0');
+ elsif(rising_edge(gls_clk)) then
+ irq_ack <= (others => '0');
+ wr_ack <= '0';
+
+ if(wbs_s1_strobe = '1' and wbs_s1_write = '1' and wbs_s1_cycle = '1') then
+ wr_ack <= '1';
+ if(wbs_s1_address = "00") then
+ irq_mask <= wbs_s1_writedata(irq_count-1 downto 0);
+ elsif(wbs_s1_address = "01") then
+ irq_ack <= wbs_s1_writedata(irq_count-1 downto 0);
+ end if;
+ end if;
+ end if;
+end process;
+
+gls_irq <= irq_level when(unsigned(irq_pend) /= 0 and gls_reset = '0') else
+ not irq_level;
+
+wbs_s1_ack <= rd_ack or wr_ack;
+wbs_s1_readdata <= readdata when (wbs_s1_strobe = '1' and wbs_s1_write = '0' and wbs_s1_cycle = '1') else (others => '0');
+
+end architecture RTL;
Added: trunk/firmware/wishbone_example/src/led.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/led.vhd (rev 0)
+++ trunk/firmware/wishbone_example/src/led.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -0,0 +1,86 @@
+---------------------------------------------------------------------------
+-- Company : ARMadeus Systems
+-- Author(s) : Fabien Marteau
+--
+-- Creation Date : 05/03/2008
+-- File : led.vhd
+--
+-- Abstract : drive one led with Wishbone bus
+--
+---------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+-----------------------------------------------------------------------
+ Entity led is
+-----------------------------------------------------------------------
+ generic(
+ id : natural := 1;
+ wb_size : natural := 16 -- Data port size for wishbone
+ );
+ port
+ (
+ -- Syscon signals
+ gls_reset : in std_logic ;
+ gls_clk : in std_logic ;
+ -- Wishbone signals
+ wbs_add : in std_logic ;
+ wbs_writedata : in std_logic_vector( wb_size-1 downto 0);
+ wbs_readdata : out std_logic_vector( wb_size-1 downto 0);
+ wbs_strobe : in std_logic ;
+ wbs_cycle : in std_logic ;
+ wbs_write : in std_logic ;
+ wbs_ack : out std_logic;
+ -- out signals
+ led : out std_logic
+ );
+end entity led;
+
+
+-----------------------------------------------------------------------
+Architecture led_1 of led is
+-----------------------------------------------------------------------
+ signal reg : std_logic_vector( wb_size-1 downto 0);
+begin
+
+-- connect led
+led <= reg(0);
+
+wbs_ack <= wbs_strobe;
+
+-- manage register
+write_bloc : process(gls_clk,gls_reset)
+begin
+ if gls_reset = '1' then
+ reg <= (others => '0');
+ elsif rising_edge(gls_clk) then
+ if ((wbs_strobe and wbs_write and wbs_cycle) = '1' ) then
+ reg <= wbs_writedata;
+ else
+ reg <= reg;
+ end if;
+ end if;
+
+end process write_bloc;
+
+read_bloc : process(gls_clk, gls_reset)
+begin
+ if gls_reset = '1' then
+ wbs_readdata <= (others => '0');
+ elsif rising_edge(gls_clk) then
+ if (wbs_strobe = '1' and wbs_write = '0' and wbs_cycle = '1' ) then
+ if wbs_add = '0' then
+ wbs_readdata <= reg;
+ else
+ wbs_readdata <= std_logic_vector(to_unsigned(id,wb_size));
+ end if;
+ else
+ wbs_readdata <= (others => '0');
+ end if;
+ end if;
+end process read_bloc;
+
+end architecture led_1;
+
Added: trunk/firmware/wishbone_example/src/rstgen_syscon.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/rstgen_syscon.vhd (rev 0)
+++ trunk/firmware/wishbone_example/src/rstgen_syscon.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -0,0 +1,61 @@
+---------------------------------------------------------------------------
+-- Company : ARMadeus Systems
+-- Author(s) : Fabien Marteau
+--
+-- Creation Date : 05/03/2008
+-- File : rstgen_syscon.vhd
+--
+-- Abstract :
+--
+---------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+---------------------------------------------------------------------------
+Entity rstgen_syscon is
+---------------------------------------------------------------------------
+generic(
+ invert_reset : std_logic := '0' -- 0 : not invert, 1 invert
+);
+port
+(
+ -- external signals
+ ext_clk : in std_logic ;
+ --internal signals
+ gls_clk : out std_logic ;
+ gls_reset : out std_logic
+);
+end entity;
+
+
+---------------------------------------------------------------------------
+Architecture rstgen_syscon_1 of rstgen_syscon is
+---------------------------------------------------------------------------
+
+ signal dly: std_logic := '0';
+ signal rst: std_logic := '0';
+ signal ext_reset : std_logic;
+
+begin
+
+ ext_reset <= '0';
+----------------------------------------------------------------------------
+-- RESET signal generator.
+----------------------------------------------------------------------------
+process(ext_clk)
+begin
+ if(rising_edge(ext_clk)) then
+ dly <= ( not(ext_reset) and dly and not(rst) )
+ or ( not(ext_reset) and not(dly) and rst );
+
+ rst <= ( not(ext_reset) and not(dly) and not(rst) );
+ end if;
+end process;
+
+gls_clk <= ext_clk;
+gls_reset <= rst xor invert_reset ;
+
+end architecture rstgen_syscon_1;
+
Added: trunk/firmware/wishbone_example/src/top_wishbone_example.vhd
===================================================================
--- trunk/firmware/wishbone_example/src/top_wishbone_example.vhd (rev 0)
+++ trunk/firmware/wishbone_example/src/top_wishbone_example.vhd 2009-03-03 16:03:26 UTC (rev 1108)
@@ -0,0 +1,535 @@
+---------------------------------------------------------------------------
+-- Company : Automaticaly generated by POD
+-- Author(s) :
+--
+-- Creation Date : 2009-03-03
+-- File : Top_wishbone_example.vhd
+--
+-- Abstract :
+-- insert a description here
+--
+---------------------------------------------------------------------------
+
+library IEEE;
+use IEEE.STD_LOGIC_1164.ALL;
+use IEEE.numeric_std.all;
+
+entity top_wishbone_example is
+
+ port
+ (
+ imx9328_wb16_wrapper00_imx_data : inout std_logic_vector(15 downto 0);
+ imx9328_wb16_wrapper00_imx_address : in std_logic_vector(11 downto 0);
+ rstgen_syscon00_ext_clk : in std_logic;
+ imx9328_wb16_wrapper00_imx_cs_n : in std_logic;
+ imx9328_wb16_wrapper00_imx_eb3_n : in std_logic;
+ imx9328_wb16_wrapper00_imx_oe_n : in std_logic;
+ irq_mngr00_gls_irq : out std_logic;
+ led0_led : out std_logic;
+ button0_button : in std_logic
+ );
+end entity top_wishbone_example;
+
+architecture top_wishbone_example_1 of top_wishbone_example is
+ -------------------------
+ -- declare components --
+ -------------------------
+
+
+ component rstgen_syscon
+ port (
+ -- candr
+ gls_clk : out std_logic;
+ gls_reset : out std_logic;
+ -- clk_ext
+ ext_clk : in std_logic
+ );
+ end component;
+
+ component led
+ generic(
+ id : natural := 2;
+ wb_size : natural := 16
+ );
+ port (
+ -- int_led
+ led : out std_logic;
+ -- candr
+ gls_reset : in std_logic;
+ gls_clk : in std_logic;
+ -- swb16
+ wbs_add : in std_logic;
+ wbs_writedata : in std_logic_vector(15 downto 0);
+ wbs_readdata : out std_logic_vector(15 downto 0);
+ wbs_strobe : in std_logic;
+ wbs_cycle : in std_logic;
+ wbs_write : in std_logic;
+ wbs_ack : out std_logic
+ );
+ end component;
+
+ component button
+ generic(
+ id : natural := 3
+ );
+ port (
+ -- int_button
+ button : in std_logic;
+ irq : out std_logic;
+ -- candr
+ gls_reset : in std_logic;
+ gls_clk : in std_logic;
+ -- swb16
+ wbs_add : in std_logic;
+ wbs_readdata : out std_logic_vector(15 downto 0);
+ wbs_strobe : in std_logic;
+ wbs_write : in std_logic;
+ wbs_ack : out std_logic;
+ wbs_cycle : in std_logic
+ );
+ end component;
+
+ component imx9328_wb16_wrapper
+ port (
+ -- eim
+ imx_address : in std_logic_vector(11 downto 0);
+ imx_data : inout std_logic_vector(15 downto 0);
+ imx_cs_n : in std_logic;
+ imx_oe_n : in std_logic;
+ imx_eb3_n : in std_logic;
+ -- candr
+ gls_reset : in std_logic;
+ gls_clk : in std_logic;
+ -- mwb16
+ wbm_address : out std_logic_vector(12 downto 0);
+ wbm_readdata : in std_logic_vector(15 downto 0);
+ wbm_writedata : out std_logic_vector(15 downto 0);
+ wbm_strobe : out std_logic;
+ wbm_write : out std_logic;
+ wbm_ack : in std_logic;
+ wbm_cycle : out std_logic
+ );
+ end component;
+
+ component irq_mngr
+ generic(
+ id : natural := 1;
+ irq_level : std_logic := '1';
+ irq_count : integer := 1
+ );
+ port (
+ -- candr
+ gls_clk : in std_logic;
+ gls_reset : in std_logic;
+ -- swb16
+ wbs_s1_address : in std_logic_vector(1 downto 0);
+ wbs_s1_readdata : out std_logic_vector(15 downto 0);
+ wbs_s1_writedata : in std_logic_vector(15 downto 0);
+ wbs_s1_ack : out std_logic;
+ wbs_s1_strobe : in std_logic;
+ wbs_s1_cycle : in std_logic;
+ wbs_s1_write : in std_logic;
+ -- irq
+ irqport : in std_logic_vector(0 downto 0);
+ -- ext_irq
+ gls_irq : out std_logic
+ );
+ end component;
+
+ component imx9328_wb16_wrapper00_mwb16
+ port (
+ -- irq_mngr00_swb16
+ irq_mngr00_wbs_s1_address : out std_logic_vector(1 downto 0);
+ irq_mngr00_wbs_s1_readdata : in std_logic_vector(15 downto 0);
+ irq_mngr00_wbs_s1_writedata : out std_logic_vector(15 downto 0);
+ irq_mngr00_wbs_s1_ack : in std_logic;
+ irq_mngr00_wbs_s1_strobe : out std_logic;
+ irq_mngr00_wbs_s1_cycle : out std_logic;
+ irq_mngr00_wbs_s1_write : out std_logic;
+ -- irq_mngr00_candr
+ irq_mngr00_gls_clk : out std_logic;
+ irq_mngr00_gls_reset : out std_logic;
+ -- led0_swb16
+ led0_wbs_add : out std_logic;
+ led0_wbs_writedata : out std_logic_vector(15 downto 0);
+ led0_wbs_readdata : in std_logic_vector(15 downto 0);
+ led0_wbs_strobe : out std_logic;
+ led0_wbs_cycle : out std_logic;
+ led0_wbs_write : out std_logic;
+ led0_wbs_ack : in std_logic;
+ -- led0_candr
+ led0_gls_reset : out std_logic;
+ led0_gls_clk : out std_logic;
+ -- button0_swb16
+ button0_wbs_add : out std_logic;
+ button0_wbs_readdata : in std_logic_vector(15 downto 0);
+ button0_wbs_strobe : out std_logic;
+ button0_wbs_write : out std_logic;
+ button0_wbs_ack : in std_logic;
+ button0_wbs_cycle : out std_logic;
+ -- button0_candr
+ button0_gls_reset : out std_logic;
+ button0_gls_clk : out std_logic;
+ -- imx9328_wb16_wrapper00_mwb16
+ imx9328_wb16_wrapper00_wbm_address : in std_logic_vector(12 downto 0);
+ imx9328_wb16_wrapper00_wbm_readdata : out std_logic_vector(15 downto 0);
+ imx9328_wb16_wrapper00_wbm_writedata : in std_logic_vector(15 downto 0);
+ imx9328_wb16_wrapper00_wbm_strobe : in std_logic;
+ imx9328_wb16_wrapper00_wbm_write : in std_logic;
+ imx9328_wb16_wrapper00_wbm_ack : out std_logic;
+ imx9328_wb16_wrapper00_wbm_cycle : in std_logic;
+ -- imx9328_wb16_wrapper00_candr
+ imx9328_wb16_wrapper00_gls_reset : out std_logic;
+ imx9328_wb16_wrapper00_gls_clk : out std_logic;
+ -- rstgen_syscon00_imx9328_wb16_wrapper00
+ rstgen_syscon00_gls_clk : in std_logic;
+ rstgen_syscon00_gls_reset : in std_logic
+ );
+ end component;
+ -------------------------
+ -- Signals declaration
+ -------------------------
+
+ -- imx9328_wb16_wrapper00
+ -- eim
+ -- candr
+ signal imx9328_wb16_wrapper00_gls_reset : std_logic;
+ signal imx9328_wb16_wrapper00_gls_clk : std_logic;
+ -- mwb16
+ signal imx9328_wb16_wrapper00_wbm_address : std_logic_vector(12 downto 0);
+ signal imx9328_wb16_wrapper00_wbm_readdata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_wbm_writedata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_wbm_strobe : std_logic;
+ signal imx9328_wb16_wrapper00_wbm_write : std_logic;
+ signal imx9328_wb16_wrapper00_wbm_ack : std_logic;
+ signal imx9328_wb16_wrapper00_wbm_cycle : std_logic;
+
+ -- rstgen_syscon00
+ -- candr
+ signal rstgen_syscon00_gls_clk : std_logic;
+ signal rstgen_syscon00_gls_reset : std_logic;
+ -- clk_ext
+
+ -- irq_mngr00
+ -- candr
+ signal irq_mngr00_gls_clk : std_logic;
+ signal irq_mngr00_gls_reset : std_logic;
+ -- swb16
+ signal irq_mngr00_wbs_s1_address : std_logic_vector(1 downto 0);
+ signal irq_mngr00_wbs_s1_readdata : std_logic_vector(15 downto 0);
+ signal irq_mngr00_wbs_s1_writedata : std_logic_vector(15 downto 0);
+ signal irq_mngr00_wbs_s1_ack : std_logic;
+ signal irq_mngr00_wbs_s1_strobe : std_logic;
+ signal irq_mngr00_wbs_s1_cycle : std_logic;
+ signal irq_mngr00_wbs_s1_write : std_logic;
+ -- irq
+ signal irq_mngr00_irqport : std_logic_vector(0 downto 0);
+ -- ext_irq
+
+ -- led0
+ -- int_led
+ -- candr
+ signal led0_gls_reset : std_logic;
+ signal led0_gls_clk : std_logic;
+ -- swb16
+ signal led0_wbs_add : std_logic;
+ signal led0_wbs_writedata : std_logic_vector(15 downto 0);
+ signal led0_wbs_readdata : std_logic_vector(15 downto 0);
+ signal led0_wbs_strobe : std_logic;
+ signal led0_wbs_cycle : std_logic;
+ signal led0_wbs_write : std_logic;
+ signal led0_wbs_ack : std_logic;
+
+ -- button0
+ -- int_button
+ signal button0_irq : std_logic;
+ -- candr
+ signal button0_gls_reset : std_logic;
+ signal button0_gls_clk : std_logic;
+ -- swb16
+ signal button0_wbs_add : std_logic;
+ signal button0_wbs_readdata : std_logic_vector(15 downto 0);
+ signal button0_wbs_strobe : std_logic;
+ signal button0_wbs_write : std_logic;
+ signal button0_wbs_ack : std_logic;
+ signal button0_wbs_cycle : std_logic;
+
+ -- imx9328_wb16_wrapper00_mwb16_intercon
+ -- irq_mngr00_swb16
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_wbs_s1_address : std_logic_vector(1 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_wbs_s1_readdata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_wbs_s1_writedata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_wbs_s1_ack : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_wbs_s1_strobe : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_wbs_s1_cycle : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_wbs_s1_write : std_logic;
+ -- irq_mngr00_candr
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_gls_clk : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_irq_mngr00_gls_reset : std_logic;
+ -- led0_swb16
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_wbs_add : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_wbs_writedata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_wbs_readdata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_wbs_strobe : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_wbs_cycle : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_wbs_write : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_wbs_ack : std_logic;
+ -- led0_candr
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_gls_reset : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_led0_gls_clk : std_logic;
+ -- button0_swb16
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_wbs_add : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_wbs_readdata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_wbs_strobe : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_wbs_write : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_wbs_ack : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_wbs_cycle : std_logic;
+ -- button0_candr
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_gls_reset : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_button0_gls_clk : std_logic;
+ -- imx9328_wb16_wrapper00_mwb16
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_wbm_address : std_logic_vector(12 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_wbm_readdata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_wbm_writedata : std_logic_vector(15 downto 0);
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_wbm_strobe : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_wbm_write : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_wbm_ack : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_wbm_cycle : std_logic;
+ -- imx9328_wb16_wrapper00_candr
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_gls_reset : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_imx9328_wb16_wrapper00_gls_clk : std_logic;
+ -- rstgen_syscon00_imx9328_wb16_wrapper00
+ signal imx9328_wb16_wrapper00_mwb16_intercon_rstgen_syscon00_gls_clk : std_logic;
+ signal imx9328_wb16_wrapper00_mwb16_intercon_rstgen_syscon00_gls_reset : std_logic;
+
+ -- void pins
+
+begin
+ -------------------------
+ -- declare instances
+ -------------------------
+
+ imx9328_wb16_wrapper00 : imx9328_wb16_wrapper
+ port map (
+ -- eim
+ imx_address => imx9328_wb16_wrapper00_imx_address,
+ imx_data => imx9328_wb16_wrapper00_imx_data,
+ imx_cs_n => imx9328_wb16_wrapper00_imx_cs_n,
+ imx_oe_n => imx9328_wb16_wrapper00_imx_oe_n,
+ imx_eb3_n => imx9328_wb16_wrapper00_imx_eb3_n,
+ -- candr
+ gls_reset => imx9328_wb16_wrapper00_gls_reset,
+ gls_clk => imx9328_wb16_wrapper00_gls_clk,
+ -- mwb16
+ wbm_address => imx9328_wb16_wrapper00_wbm_address,
+ wbm_readdata => imx9328_wb16_wrapper00_wbm_readdata,
+ wbm_writedata => imx9328_wb16_wrapper00_wbm_writedata,
+ wbm_strobe => imx9328_wb16_wrapper00_wbm_strobe,
+ wbm_write => imx9328_wb16_wrapper00_wbm_write,
+ wbm_ack => imx9328_wb16_wrapper00_wbm_ack,
+ wbm_cycle => imx9328_wb16_wrapper00_wbm_cycle
+ );
+
+ rstgen_syscon00 : rstgen_syscon
+ port map (
+ -- candr
+ gls_clk => rstgen_syscon00_gls_clk,
+ gls_reset => rstgen_syscon00_gls_reset,
+ -- clk_ext
+ ext_clk => rstgen_syscon00_ext_clk
+ );
+
+ irq_mngr00 : irq_mngr
+ generic map (
+ id => 1,
+ irq_level => '1',
+ irq_count => 1
+ )
+ port map (
+ -- candr
+ gls_clk => irq_mngr00_gls_clk,
+ gls_reset => irq_mngr00_gls_reset,
+ -- swb16
+ wbs_s1_address => irq_mngr00_wbs_s1_address,
+ wbs_s1_readdata => irq_mngr00_wbs_s1_readdata,
+ wbs_s1_writedata => irq_mngr00_wbs_s1_writedata,
+ wbs_s1_ack => irq_mngr00_wbs_s1_ack,
+ wbs_s1_strobe => irq_mngr00_wbs_s1_strobe,
+ wbs_s1_cycle => irq_mngr00_wbs_s1_cycle,
+ wbs_s1_write => irq_mngr00_wbs_s1_write,
+ -- irq
+ irqport => irq_mngr00_irqport,
+ -- ext_irq
+ gls_irq => irq_mngr00_gls_irq
+ );
+
+ led0 : led
+ generic map (
+ id => 2,
+ wb_size => 16
+ )
+ port map (
+ -- int_led
+ led => led0_led,
+ -- candr
+ gls_reset => led0_gls_reset,
+ gls_clk => led0_gls_clk,
+ -- swb16
+ wbs_add => led0_wbs_add,
+ wb...
[truncated message content] |
|
From: <Fa...@us...> - 2009-03-03 10:22:21
|
Revision: 1107
http://armadeus.svn.sourceforge.net/armadeus/?rev=1107&view=rev
Author: FabM
Date: 2009-03-03 10:22:12 +0000 (Tue, 03 Mar 2009)
Log Message:
-----------
[LINUX] Adding a drivers directory for wishbone example (firmware/wishbone_example)
Modified Paths:
--------------
trunk/target/linux/modules/fpga/Kconfig
trunk/target/linux/modules/fpga/Makefile
trunk/target/linux/modules/fpga/others/Kconfig
trunk/target/linux/modules/fpga/others/Makefile
Added Paths:
-----------
trunk/target/linux/modules/fpga/wishbone_example/
trunk/target/linux/modules/fpga/wishbone_example/Kconfig
trunk/target/linux/modules/fpga/wishbone_example/Makefile
trunk/target/linux/modules/fpga/wishbone_example/wb_button/
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/
Removed Paths:
-------------
trunk/target/linux/modules/fpga/others/Wb_button/
trunk/target/linux/modules/fpga/others/led/
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/Kconfig
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/Makefile
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button.c
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button.h
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button_specific.h
trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/testbutton.c
Modified: trunk/target/linux/modules/fpga/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/Kconfig 2009-03-03 09:56:47 UTC (rev 1106)
+++ trunk/target/linux/modules/fpga/Kconfig 2009-03-03 10:22:12 UTC (rev 1107)
@@ -15,6 +15,8 @@
source "drivers/armadeus/fpga/others/Kconfig"
+source "drivers/armadeus/fpga/wishbone_example/Kconfig"
+
source "drivers/armadeus/fpga/POD/Kconfig"
endmenu
Modified: trunk/target/linux/modules/fpga/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/Makefile 2009-03-03 09:56:47 UTC (rev 1106)
+++ trunk/target/linux/modules/fpga/Makefile 2009-03-03 10:22:12 UTC (rev 1107)
@@ -8,7 +8,7 @@
# Part executed when called from kernel build system:
-obj-$(CONFIG_ARMADEUS_FPGA_DRIVERS) += dev_tools/ others/ POD/
+obj-$(CONFIG_ARMADEUS_FPGA_DRIVERS) += dev_tools/ others/ POD/ wishbone_example/
else
Modified: trunk/target/linux/modules/fpga/others/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/others/Kconfig 2009-03-03 09:56:47 UTC (rev 1106)
+++ trunk/target/linux/modules/fpga/others/Kconfig 2009-03-03 10:22:12 UTC (rev 1107)
@@ -11,7 +11,5 @@
---help---
All drivers for FPGA components
-source "drivers/armadeus/fpga/others/Wb_button/Kconfig"
-source "drivers/armadeus/fpga/others/Wb_led/Kconfig"
source "drivers/armadeus/fpga/others/i2ctest/Kconfig"
source "drivers/armadeus/fpga/others/ps2keyboard/Kconfig"
Modified: trunk/target/linux/modules/fpga/others/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/others/Makefile 2009-03-03 09:56:47 UTC (rev 1106)
+++ trunk/target/linux/modules/fpga/others/Makefile 2009-03-03 10:22:12 UTC (rev 1107)
@@ -8,7 +8,7 @@
# Part executed when called from kernel build system:
-obj-$(CONFIG_ARMADEUS_FPGA_OTHERS_DRIVERS) += Wb_button/ Wb_led/ i2ctest/ ps2keyboard/
+obj-$(CONFIG_ARMADEUS_FPGA_OTHERS_DRIVERS) += i2ctest/ ps2keyboard/
else
Added: trunk/target/linux/modules/fpga/wishbone_example/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/Kconfig (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/Kconfig 2009-03-03 10:22:12 UTC (rev 1107)
@@ -0,0 +1,15 @@
+
+#
+# Armadeus custom drivers configuration
+#
+#
+
+#
+config WISHBONE_EXAMPLE_DRIVERS
+ tristate "Drivers for wishbone example"
+ default n
+ depends on ARMADEUS_FPGA_DRIVERS
+ ---help---
+ Drivers used for wishbone example design that can be
+ found in firmware/wishbone_example/
+
Added: trunk/target/linux/modules/fpga/wishbone_example/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/Makefile (rev 0)
+++ trunk/target/linux/modules/fpga/wishbone_example/Makefile 2009-03-03 10:22:12 UTC (rev 1107)
@@ -0,0 +1,39 @@
+
+#
+# Main Makefile for the Armadeus FPGA related drivers
+#
+# Add your subdirectories to obj- target
+#
+
+ifneq ($(KERNELRELEASE),)
+
+# Part executed when called from kernel build system:
+obj-$(CONFIG_WISHBONE_EXAMPLE_DRIVERS) +=
+
+else
+
+# Part executed when called from standard make in this directory:
+
+BASE_DIR:=../../../../buildroot/
+REL:=$(shell grep "BR2_PACKAGE_LINUX_VERSION=" $(BASE_DIR).config | sed -e 's/BR2_PACKAGE_LINUX_VERSION=//' | sed -e 's/"//g')
+#
+ARMADEUS_KERNEL_DIR:=$(BASE_DIR)build_arm/linux-$(REL)
+ifeq ($(LINUX_DIR),)
+LINUX_DIR:=$(ARMADEUS_KERNEL_DIR)
+endif
+PWD:= $(shell pwd)
+
+default:
+ echo "Your Linux source dir is: $(LINUX_DIR)"
+ $(MAKE) -C $(LINUX_DIR) SUBDIRS=$(PWD) zImage modules
+
+clean:
+ echo "Your Linux source dir is: $(LINUX_DIR)"
+ $(MAKE) -C $(LINUX_DIR) SUBDIRS=$(PWD) clean
+
+install:
+ echo "Installing Armadeus drivers..."
+ $(MAKE) -C $(LINUX_DIR) SUBDIRS=$(PWD) INSTALL_MOD_PATH=$(TARGET_DIR) modules_install
+
+endif
+
Deleted: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_button/Kconfig 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/Kconfig 2009-03-03 10:22:12 UTC (rev 1107)
@@ -1,8 +0,0 @@
-#
-#
-
-config ARMADEUS_BUTTON_DRIVER
- tristate "Wishbone Button driver"
- default n
- depends on ARMADEUS_FPGA_OTHERS_DRIVERS
- ---help---
Deleted: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_button/Makefile 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/Makefile 2009-03-03 10:22:12 UTC (rev 1107)
@@ -1,34 +0,0 @@
-#
-# Makefile for the Armadeus Wb_button drivers
-#
-
-ifneq ($(KERNELRELEASE),)
-
-obj-$(CONFIG_ARMADEUS_BUTTON_DRIVER) += button.o
-
-# Part executed when called from standard make in this directory:
-# (preferably use Makefile in parent directory)
-
-else
-
-ARMADEUS_BASE_DIR=../../../../../..
-include $(ARMADEUS_BASE_DIR)/Makefile.in
-
-KDIR := $(ARMADEUS_LINUX_DIR)
-PWD := $(shell pwd)
-
-default:
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
- -cp button.ko /tftpboot/
-
-test:
- ~/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc testbutton.c -o testbutton
- chmod 755 testbutton
- cp testbutton /tftpboot/
-
-clean:
- rm -f *.*o \
- rm -f Module.symvers
-
-endif
-
Deleted: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button.c
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_button/button.c 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button.c 2009-03-03 10:22:12 UTC (rev 1107)
@@ -1,226 +0,0 @@
-/*
- ***********************************************************************
- *
- * (c) Copyright 2007 Armadeus project
- * Fabien Marteau <fab...@ar...>
- * Driver for Wb_button IP
- *
- * 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 "button.h"
-
-/*********************************
- * simple fpga read/write
- *********************************/
-
-
-static ssize_t button_fpga_read(void * addr,u16 *data,struct button_dev *dev){
- *data = ioread16(addr);/* read the button value */
- return 2;
-}
-
-
-static ssize_t button_fpga_write(void * addr,u16 *data,struct button_dev *dev){
- ssize_t retval;
-
- iowrite16(*data,addr);/* write the button value */
- retval = 2;
- return retval;
-}
-
-/**********************************
- * irq management
- * awake read process
- * ********************************/
-
-static irqreturn_t fpga_interrupt(int irq,void *dev_id,struct pt_regs *reg){
- struct button_dev *ldev = dev_id;
- u16 data;
-
- button_fpga_read(ldev->fpga_virtual_base_address + FPGA_IRQ_PEND,&data,ldev);
- PDEBUG("Interrupt raised %x\n",data);
-
- if(data&WB_BUTTON_IRQ){
- /* wake up reading process */
- if(ldev->reading)up(&ldev->sem);
- /* acknowledge irq_mngr */
- button_fpga_write(ldev->fpga_virtual_base_address + FPGA_IRQ_ACK,&data,ldev);
- return IRQ_HANDLED;
- }else
- return IRQ_NONE;
-
-}
-
-/***********************************
- * characters file /dev operations
- * *********************************/
-ssize_t button_read(struct file *fildes, char __user *buff, size_t count, loff_t *offp){
- struct button_dev *ldev = fildes->private_data;
- u16 data=0;
- ssize_t retval = 0;
- DEFINE_WAIT(wait);
-
- ldev->reading = 1;
-
- if(*offp + count >= 1) /* Only one word can be read */
- count = 1 - *offp;
-
- if((retval=down_interruptible(&ldev->sem))<0)
- goto out;
-
- if((retval = button_fpga_read(ldev->fpga_virtual_base_address + FPGA_BUTTON,&data,ldev))<0)
- goto out;
-
- /* return data for user */
- if(copy_to_user(buff,&data,2)){
- printk(KERN_WARNING "read : copy to user data error\n");
- retval = -EFAULT;
- goto out;
- }
-
- *offp = *offp + count;
- retval = 1;
-
-out:
- PDEBUG("read : Return value %d\n",(int)retval);
- ldev->reading = 0;
- return retval;
-}
-
-
-int button_open(struct inode *inode, struct file *filp){
- /* Allocate and fill any data structure to be put in filp->private_data */
- filp->private_data = container_of(inode->i_cdev,struct button_dev, cdev);
- PDEBUG( "file opened\n");
- return 0;
-}
-
-/* ******************************
- * Init and release functions
- * ******************************/
-int button_release(struct inode *inode, struct file *filp){
- PDEBUG( "released\n");
- return 0;
-}
-
-/**********************************
- * Module management
- **********************************/
-static int __init button_init(void){
-
- int result; /* error return */
- int button_major,button_minor;
- u16 data;
- struct button_dev *sdev;
-
- button_major = 252;
- button_minor = 0;
-
- /* Allocate a private structure and reference it as driver's data */
- sdev = (struct button_dev *)kmalloc(sizeof(struct button_dev),GFP_KERNEL);
- if(sdev == NULL){
- printk(KERN_WARNING "button: unable to allocate private structure\n");
- return -ENOMEM;
- }
-
- /* initiate mutex locked */
- sdev->reading = 0;
- init_MUTEX_LOCKED(&sdev->sem);
-
- /* Get the major and minor device numbers */
- PDEBUG("Get the major and minor device numbers\n");
- if(button_major){
- devno = MKDEV(button_major,button_minor);
- result = register_chrdev_region(devno, N_DEV,BUTTON_NAME);
- }else{
- result = alloc_chrdev_region(&devno,button_minor,N_DEV,BUTTON_NAME);
- button_major = MAJOR(devno);
- }
- printk(KERN_INFO "button: MAJOR: %d MINOR: %d\n",MAJOR(devno),MINOR(devno));
- if(result < 0){
- printk(KERN_WARNING "button: can't get major %d\n",button_major);
- }
-
- /* Init the cdev structure */
- PDEBUG("Init the cdev structure\n");
- cdev_init(&sdev->cdev,&button_fops);
- sdev->cdev.owner = THIS_MODULE;
-
- /* Add the device to the kernel, connecting cdev to major/minor number */
- PDEBUG("Add the device to the kernel, connecting cdev to major/minor number \n");
- result = cdev_add(&sdev->cdev,devno,1);
- if(result < 0)printk(KERN_WARNING "button: can't add cdev\n");
-
- /* Requested I/O memory */
- sdev->fpga_virtual_base_address = (void*)IMX_CS1_VIRT;
-
- /* irq unmask */
- data=1 | ioread16(sdev->fpga_virtual_base_address + FPGA_IRQ_MASK);
- if((result=button_fpga_write(sdev->fpga_virtual_base_address + FPGA_IRQ_MASK,&data,sdev))<0)
- goto error;
-
- /* irq acknowledge */
- data=1;
- if((result=button_fpga_write(sdev->fpga_virtual_base_address + FPGA_IRQ_ACK,&data,sdev))<0)
- goto error;
-
- /* irq registering */
- printk(KERN_INFO "button: fpga irq shared gpioa 1\n");
- if(request_irq(IRQ_GPIOA(1),(irq_handler_t)fpga_interrupt,IRQF_SHARED,BUTTON_IRQ_NAME,sdev)<0){
- printk(KERN_ERR "Can't request fpga irq\n");
- goto error;
- }
-
-
- /* OK module inserted ! */
- buttondev = sdev;
- printk(KERN_INFO "button module insered\n");
- return 0;
-
-
-error:
- printk(KERN_ERR "%s: not inserted\n",BUTTON_NAME);
- free_all();
- return result;
-}
-
-static void __exit button_exit(void){
- free_all();
-}
-
-static void free_all(void){
- struct button_dev *sdev = buttondev;
-
- /* free irq*/
- free_irq(IRQ_GPIOA(1),sdev);
-
- /* delete the cdev structure */
- cdev_del(&sdev->cdev);
-
- /* Free the allocated memory */
- kfree(sdev);
-
- /* Release I/O memories */
- release_mem_region(FPGA_BASE_ADDR,FPGA_MEM_SIZE);
-
- /* free major and minor number */
- unregister_chrdev_region(devno,N_DEV);
- printk(KERN_INFO "button module deleted\n");
-}
-
-module_init(button_init);
-module_exit(button_exit);
Deleted: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button.h
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_button/button.h 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button.h 2009-03-03 10:22:12 UTC (rev 1107)
@@ -1,124 +0,0 @@
-/*
- ***********************************************************************
- *
- * (c) Copyright 2007 Armadeus project
- * Fabien Marteau <fab...@ar...>
- * Driver for Wb_button IP
- *
- * 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 __BUTTON_H__
-#define __BUTTON_H__
-
-#include "button_specific.h"
-
-#include <linux/version.h>
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
-#include <linux/config.h>
-#endif
-
-/* form module/drivers */
-#include <linux/init.h>
-#include <linux/module.h>
-
-/* for file operations */
-#include <linux/fs.h>
-#include <linux/cdev.h>
-
-/* copy_to_user function */
-#include <asm/uaccess.h>
-
-/* request_mem_region */
-#include <linux/ioport.h>
-
-/* readw() writew() */
-#include <asm/io.h>
-
-/* hardware addresses */
-#include <asm/hardware.h>
-
-/* interruptions */
-#include <linux/interrupt.h>
-#include <asm/irq.h>
-#include <linux/wait.h>
-#include <asm/semaphore.h>
-
-/* measure time */
-#include <linux/jiffies.h>
-#endif
-
-/* for debugging messages*/
-/*#define BUTTON_DEBUG*/
-
-#undef PDEBUG
-#ifdef BUTTON_DEBUG
-# ifdef __KERNEL__
- /* for kernel spage */
-# define PDEBUG(fmt,args...) printk(KERN_INFO "button : " fmt, ##args)
-# else
- /* for user space */
-# define PDEBUG(fmt,args...) printk(stderr, fmt, ##args)
-# endif
-#else
-# define PDEBUG(fmt,args...) /* no debbuging message */
-#endif
-
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Fabien Marteau <fab...@ar...> - ARMadeus Systems");
-MODULE_DESCRIPTION("button device driver");
-
-/* main device structure */
-struct button_dev{
- struct cdev cdev; /* Char device structure */
- struct semaphore sem; /* Mutex */
- void * fpga_virtual_base_address; /* fpga register base address*/
- wait_queue_head_t button_queue;
- u8 reading;
-};
-
-/* major and minor number */
-
-#define N_DEV 1
-static dev_t devno; /* to store Major and minor numbers */
-static struct button_dev *buttondev;
-#define BUTTON_LENGTH 1
-struct resource *mem; /* pointer to fpga button */
-
-
-/* to read write button register */
-ssize_t button_read(struct file *fildes, char __user *buff,
- size_t count, loff_t *offp);
-
-int button_open(struct inode *inode, struct file *filp);
-
-int button_release(struct inode *, struct file *filp);
-
-struct file_operations button_fops = {
- .owner = THIS_MODULE,
- .read = button_read,
- .open = button_open,
- .release = button_release,
-};
-
-static irqreturn_t fpga_interrupt(int irq,void *stuff,struct pt_regs *reg);
-
-static void free_all(void);
-
-static ssize_t button_fpga_read(void * addr, u16 *data , struct button_dev *dev);
-static ssize_t button_fpga_write(void * addr, u16 *data, struct button_dev *dev);
Deleted: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button_specific.h
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_button/button_specific.h 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/button_specific.h 2009-03-03 10:22:12 UTC (rev 1107)
@@ -1,14 +0,0 @@
-#define BUTTON_NAME "button"
-#define FPGA_BUTTON 8
-#define FPGA_IRQ_MASK 0
-#define FPGA_IRQ_PEND 2
-#define FPGA_IRQ_ACK 2
-
-/* Fpga base address for led */
-#define FPGA_BASE_ADDR IMX_CS1_PHYS
-#define FPGA_MEM_SIZE IMX_CS1_SIZE
-#define BUTTON_IRQ_NAME "button"
-
-/* interrupt position in irq_mngr */
-#define WB_BUTTON_IRQ 0x0001
-
Deleted: trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/testbutton.c
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_button/testbutton.c 2009-03-02 16:14:50 UTC (rev 1105)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_button/Wb_button/testbutton.c 2009-03-03 10:22:12 UTC (rev 1107)
@@ -1,95 +0,0 @@
-
- * ***********************************************************************
-/* a program to write/read values on fpga address map
- * Fabien Marteau <fab...@ar...>
- * 7 april 2008
- * fpgaaccess.h
- *
- * (c) Copyright 2008 Armadeus project
- * Fabien Marteau <fab...@ar...>
- *
- * A simple driver for reading and writing on
- * fpga throught a character file /dev/fpgaaccess
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-
-/* file management */
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/* as name said */
-#include <signal.h>
-
-/* sleep */
-#include <unistd.h>
-
-int fled;
-
-void quit(int pouet){
- close(fled);
- exit(0);
-}
-
-int main(int argc, char *argv[])
-{
- unsigned short i,j;
-
- /* quit when Ctrl-C pressed */
- signal(SIGINT, quit);
-
- j=0;
-
- printf( "Testing button driver\n" );
-
- if(argc < 2){
- perror("invalid arguments number\ntestled <button_filename>\n");
- exit(EXIT_FAILURE);
- }
-
- fled=open(argv[1],O_RDWR);
- if(fled<0){
- perror("can't open file\n");
- exit(EXIT_FAILURE);
- }
-
- while(1){
- i = (i==0)?1:0;
- fflush(stdout);
-
- /* read value */
- if(read(fled,&j,1)<0){
- perror("read error\n");
- exit(EXIT_FAILURE);
- }
- printf("Read %d\n",j);
-
- if(lseek(fled,0,SEEK_SET)<0){
- perror("lseek error\n");
- exit(EXIT_FAILURE);
- }
- }
-
- close(fled);
- exit(0);
-}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|