[Armadeus-commitlog] SF.net SVN: armadeus:[869] trunk/target/linux/modules/fpga
Brought to you by:
sszy
|
From: <Fa...@us...> - 2008-08-08 13:29:10
|
Revision: 869
http://armadeus.svn.sourceforge.net/armadeus/?rev=869&view=rev
Author: FabM
Date: 2008-08-08 13:29:18 +0000 (Fri, 08 Aug 2008)
Log Message:
-----------
[drivers][POD] POD integration
Modified Paths:
--------------
trunk/target/linux/modules/fpga/Kconfig
trunk/target/linux/modules/fpga/Makefile
trunk/target/linux/modules/fpga/others/Wb_button/testbutton.c
trunk/target/linux/modules/fpga/others/Wb_led/Makefile
trunk/target/linux/modules/fpga/others/Wb_led/led.c
trunk/target/linux/modules/fpga/others/Wb_led/led.h
Added Paths:
-----------
trunk/target/linux/modules/fpga/others/Wb_led/testled.c
trunk/target/linux/modules/fpga/podscript.sh
Removed Paths:
-------------
trunk/target/linux/modules/fpga/others/Wb_led/led_specific.h
Modified: trunk/target/linux/modules/fpga/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/Kconfig 2008-08-05 15:28:22 UTC (rev 868)
+++ trunk/target/linux/modules/fpga/Kconfig 2008-08-08 13:29:18 UTC (rev 869)
@@ -15,5 +15,7 @@
source "drivers/armadeus/fpga/others/Kconfig"
+source "drivers/armadeus/fpga/POD/Kconfig"
+
endmenu
Modified: trunk/target/linux/modules/fpga/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/Makefile 2008-08-05 15:28:22 UTC (rev 868)
+++ trunk/target/linux/modules/fpga/Makefile 2008-08-08 13:29:18 UTC (rev 869)
@@ -8,7 +8,7 @@
# Part executed when called from kernel build system:
-obj-$(CONFIG_ARMADEUS_FPGA_DRIVERS) += dev_tools/ others/
+obj-$(CONFIG_ARMADEUS_FPGA_DRIVERS) += dev_tools/ others/ POD/
else
Modified: trunk/target/linux/modules/fpga/others/Wb_button/testbutton.c
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_button/testbutton.c 2008-08-05 15:28:22 UTC (rev 868)
+++ trunk/target/linux/modules/fpga/others/Wb_button/testbutton.c 2008-08-08 13:29:18 UTC (rev 869)
@@ -63,7 +63,7 @@
printf( "Testing button driver\n" );
if(argc < 2){
- perror("invalide arguments number\ntestled <button_filename>\n");
+ perror("invalid arguments number\ntestled <button_filename>\n");
exit(EXIT_FAILURE);
}
Modified: trunk/target/linux/modules/fpga/others/Wb_led/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_led/Makefile 2008-08-05 15:28:22 UTC (rev 868)
+++ trunk/target/linux/modules/fpga/others/Wb_led/Makefile 2008-08-08 13:29:18 UTC (rev 869)
@@ -2,7 +2,7 @@
# Makefile for the Armadeus Wb_led drivers
#
-BASE_DIR="../../../../../buildroot/"
+BASE_DIR="../../../../../../buildroot/"
REL=`grep "BR2_PACKAGE_LINUX_VERSION=" $(BASE_DIR).config | \
sed "s/BR2_PACKAGE_LINUX_VERSION=\\"//" | sed "s/\\"//"`
@@ -25,7 +25,7 @@
-cp led.ko /tftpboot/
test:
- ~/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc testled.c -o testled
+ ~/armadeus/buildroot/build_arm/staging_dir/bin/arm-linux-gcc -Wall testled.c -o testled
chmod 755 testled
cp testled /tftpboot/
Modified: trunk/target/linux/modules/fpga/others/Wb_led/led.c
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_led/led.c 2008-08-05 15:28:22 UTC (rev 868)
+++ trunk/target/linux/modules/fpga/others/Wb_led/led.c 2008-08-08 13:29:18 UTC (rev 869)
@@ -23,275 +23,196 @@
#include "led.h"
-/*********************************
- * simple fpga read/write
- *********************************/
-
-static ssize_t led_fpga_read(void * addr,u16 *data,struct led_dev *dev){
- *data = ioread16(addr);/* read the led value */
- // PDEBUG( "read : value read : %x\n",*data);
- return 2;
-}
-
-static ssize_t led_fpga_write(void * addr,u16 *data,struct led_dev *dev){
- ssize_t retval;
-
- iowrite16(*data,addr);/* write the led value */
- retval = 2;
- return retval;
-}
-
-/* *********************************
- * Sysfs operations
- * *********************************/
-
-static void kobj_release(struct kobject *kobj){
- PDEBUG("led kobject released\n");
-}
-
-static int init_sysinterface(struct led_dev *ldev){
- int ret = 0;
-
- /* initializing kobject to 0 */
- memset(&ldev->kobj,0,sizeof(struct kobject));
- /* set kobject name */
- if(unlikely(ret = kobject_set_name(&ldev->kobj,LED_NAME)))
- goto out;
- /* register */
- if(unlikely(ret=kobject_register(&ldev->kobj)))
- goto out;
- /* register the kobj_type */
- ldev->kobj.ktype = &kobjtype;
- /* add status attribute */
- if(unlikely(ret=sysfs_create_file(&ldev->kobj,&led_status_attr)));
-
-out:
- return ret;
-}
-
-static ssize_t led_show_status(struct kobject *kobj,struct attribute *attr,char *buf){
- ssize_t ret_size = 0;
- struct led_dev *dev;
- u16 data;
-
- dev = container_of(kobj,struct led_dev,kobj);
-
- if(down_interruptible(&dev->sem)){ /* take mutex */
- printk(KERN_WARNING "led_show_status:can't take mutex\n");
- return -ERESTARTSYS;
- }
-
- if((ret_size=led_fpga_read(dev->fpga_virtual_base_address + FPGA_LED,&data,dev))<0)
- goto out;
-
- PDEBUG("data : %d\n",data);
- if(data&0x0001)ret_size = (ssize_t)sprintf(buf,"1\n");
- else ret_size = (ssize_t)sprintf(buf,"0\n");
-
-out:
- up(&dev->sem);
- return ret_size;
-}
-
-static ssize_t led_store_status(struct kobject *kobj,struct attribute *attr,
- const char *buff, size_t size){
- struct led_dev *ldev = container_of(kobj,struct led_dev,kobj);
- u16 data;
-
- if(buff[0]=='1')
- data=0x0001;
- else if(buff[0]=='0')
- data=0x0000;
- else
- return size;
-
- if(down_interruptible(&ldev->sem))
- return -ERESTARTSYS;
-
- size=led_fpga_write(ldev->fpga_virtual_base_address + FPGA_LED,&data,ldev);
-
- up(&ldev->sem);
- return size ;
-}
-
/***********************************
* characters file /dev operations
* *********************************/
-ssize_t led_read(struct file *fildes, char __user *buff, size_t count, loff_t *offp){
- struct led_dev *ldev = fildes->private_data;
- u16 data=0;
- ssize_t retval = 0;
+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( "read : offset %d, count %d\n",(int)*offp,(int)count);
- if(down_interruptible(&ldev->sem)) /* take mutex */
- return -ERESTARTSYS;
- if(*offp >= 1){ /* offset must be 0 or 1 */
- goto out;
- }
- if(*offp + count >= 1) /* Only one word can be read */
- count = 1 - *offp;
+ PDEBUG("count %d\n",count);
+ if(count > 2){ /* 16bits max*/
+ count = 2;
+ }
- if((retval = led_fpga_read(ldev->fpga_virtual_base_address + FPGA_LED,&data,ldev))<0)
- goto out;
+ data = ioread16(sdev->fpga_virtual_base_address + sdev->membase);
+ PDEBUG("Read %d at %x\n",data,sdev->membase);
- /* 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:
- up(&ldev->sem); /* free mutex */
- PDEBUG("read : Return value %d\n",(int)retval);
- return retval;
+ /* 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 *ldev = fildes->private_data;
- u16 data=0;
- ssize_t retval = 0;
+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("write : offset %d, count %d\n",(int)*offp,(int)count);
- if(down_interruptible(&ldev->sem))
- return -ERESTARTSYS;
- if(*offp != 0){ /* offset must be 0 */
- goto out;
- }
- if(count != 1) /* Only one word can be read */
- count = 1;
+ PDEBUG("count %d\n",count);
+ if(count > 2){ /* 16 bits max)*/
+ count = 2;
+ }
- if(copy_from_user(&data,buff,1)){
- printk(KERN_WARNING "write : copy from user error\n");
- retval = -EFAULT;
- goto out;
- }
-
- if((retval=led_fpga_write(ldev->fpga_virtual_base_address + FPGA_LED,&data,ldev))<0){
- goto out;
- }
+ 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,sdev->membase);
+ iowrite16(data,sdev->fpga_virtual_base_address + sdev->membase);
-out:
- up(&ldev->sem);
- return retval;
-
+ 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;
+ /* 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){
- PDEBUG( "Led released\n");
- return 0;
+ 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;
}
-/**********************************
- * Module management
- **********************************/
-static int __init led_init(void){
+int register_led(struct plat_led_port *dev){
+ int result = 0; /* error return */
+ int led_major,led_minor;
+ u16 data;
+ struct led_dev *sdev = &led_device[dev->num];
+ PDEBUG("Register %d led\n",dev->num);
+ /* major and minor number */
+ led_major = 253;
+ led_minor = dev->num ;
- int result; /* error return */
- int led_major,led_minor;
- u16 data;
- struct led_dev *sdev;
+ sdev->fpga_virtual_base_address = (void*)IMX_CS1_VIRT;
+ sdev->membase = dev->membase;
- led_major = 253;
- led_minor = 0;
+ /* name and address of the instance */
+ sdev->name = (char *)kmalloc((1+strlen(dev->name))*sizeof(char),GFP_KERNEL);
+ if(sdev->name == NULL){
+ printk("Kmalloc name space error\n");
+ goto error;
+ }
+ if(strncpy(sdev->name,dev->name,1+strlen(dev->name)) < 0){
+ printk("copy error");
+ goto error;
+ }
- /* Allocate a private structure and reference it as driver's data */
- PDEBUG("Allocate a private structure and reference it as driver s data\n");
- sdev = (struct led_dev *)kmalloc(sizeof(struct led_dev),GFP_KERNEL);
- if(sdev == NULL){
- printk(KERN_WARNING "LED: unable to allocate private structure\n");
- return -ENOMEM;
- }
+ /* Get the major and minor device numbers */
+ 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);
+ }
- /* initiate mutex for accessing led */
- PDEBUG("initiate mutex for accessing led\n");
- init_MUTEX(&sdev->sem);
+ printk(KERN_INFO "%s: MAJOR: %d MINOR: %d\n",dev->name,MAJOR(sdev->devno),MINOR(sdev->devno));
+ if(result < 0){
+ printk(KERN_WARNING "%s: can't get major %d\n",dev->name,led_major);
+ goto error;
+ }
- /* Get the major and minor device numbers */
- PDEBUG("Get the major and minor device numbers\n");
- if(led_major){
- devno = MKDEV(led_major,led_minor);
- result = register_chrdev_region(devno, N_DEV,LED_NAME);
- }else{
- result = alloc_chrdev_region(&devno,led_minor,N_DEV,LED_NAME);
- led_major = MAJOR(devno);
- }
- printk(KERN_INFO "LED: MAJOR: %d MINOR: %d\n",MAJOR(devno),MINOR(devno));
- if(result < 0){
- printk(KERN_WARNING "LED: can't get major %d\n",led_major);
- }
+ /* Init the cdev structure */
+ PDEBUG("%s:Init the cdev structure\n",dev->name);
+ cdev_init(&sdev->cdev,&led_fops);
+ sdev->cdev.owner = THIS_MODULE;
+ sdev->cdev.ops = &led_fops;
- /* Init the cdev structure */
- PDEBUG("Init the cdev structure\n");
- cdev_init(&sdev->cdev,&led_fops);
- sdev->cdev.owner = THIS_MODULE;
+ /* 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;
+ }
- /* 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 "LED: can't add cdev\n");
+ /* initialize led value */
+ data=1;
+ iowrite16(data,sdev->fpga_virtual_base_address + sdev->membase);
+ PDEBUG("Wrote %x at %x\n",data,sdev->membase);
- sdev->fpga_virtual_base_address = (void*)IMX_CS1_VIRT;
+ /* OK module inserted ! */
+ printk(KERN_INFO "Led module %s insered\n",dev->name);
+ return 0;
- /* initialyzing sysfs */
- PDEBUG(" initialyzing sysfs\n");
- if(unlikely(result = init_sysinterface(sdev)))
- goto error;
+error:
+ printk(KERN_ERR "%s: not inserted\n",dev->name);
+ free_all(dev);
+ return result;
+}
- /* initialize led value */
- data=1;
- if((result=led_fpga_write(sdev->fpga_virtual_base_address + FPGA_LED,&data,sdev))<0)
- goto error;
+/**********************************
+ * driver probe
+ **********************************/
+static int led_probe(struct platform_device *dev){
- sdev->previousint = jiffies;
- /* OK module inserted ! */
- leddev=sdev;
- printk(KERN_INFO "Led module insered\n");
- return 0;
-
-error:
- printk(KERN_ERR "%s: not inserted\n",LED_NAME);
- free_all();
- return result;
+ /* new code for led with platform device */
+ struct plat_led_port *p = dev->dev.platform_data;
+ int ret,i;
+
+ PDEBUG("Led probing\n");
+ /* register each led in plat_led_port tab */
+ for (i = 0; p->name!=NULL ; p++, i++) {
+ PDEBUG("%s:register led number %d\n",p->name,i);
+ ret = register_led(p);
+ if(ret){
+ printk(KERN_WARNING "Unable to register led %s\n",p->name);
+ }
+ }
+ /* end of new code */
+ PDEBUG("All devices loaded\n");
+ return 0 ;
}
-static void __exit led_exit(void){
- free_all();
+static int led_remove(struct platform_device *dev){
+ struct plat_led_port *p = dev->dev.platform_data;
+ int i;
+ PDEBUG("Removing leds\n");
+ for (i = 0; p->name!=NULL ; p++, i++) {
+ PDEBUG("Remove led %d\n",i);
+ free_all(p);
+ }
+ return 0;
}
-static void free_all(void){
- struct led_dev *sdev;
- sdev = leddev;
-
- /* unregister kobj */
- kobject_unregister(&sdev->kobj);
+static int free_all(struct plat_led_port *dev){
+ struct led_dev *sdev = &led_device[dev->num];
- /* delete the cdev structure */
- cdev_del(&sdev->cdev);
+ PDEBUG("Unregister %s, number %d\n",dev->name,dev->num);
- /* Free the allocated memory */
- kfree(sdev);
+ /* delete the cdev structure */
+ cdev_del(&sdev->cdev);
+ PDEBUG("%s:cdev deleted\n",dev->name);
- /* 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 "Led module deleted\n");
+ /* free major and minor number */
+ unregister_chrdev_region(sdev->devno,1);
+ printk(KERN_INFO "%s: Led deleted\n",dev->name);
+ return 0;
}
module_init(led_init);
Modified: trunk/target/linux/modules/fpga/others/Wb_led/led.h
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_led/led.h 2008-08-05 15:28:22 UTC (rev 868)
+++ trunk/target/linux/modules/fpga/others/Wb_led/led.h 2008-08-08 13:29:18 UTC (rev 869)
@@ -30,18 +30,16 @@
#include <linux/config.h>
#endif
-/* specific header generated by orchestra */
-#include "led_specific.h"
-
/* form module/drivers */
#include <linux/init.h>
#include <linux/module.h>
-/* linux device model */
-#include <linux/kobject.h>
-#include <linux/sysfs.h>
-#include <linux/sysdev.h>
-#include <linux/device.h>
+/* linux device model
+*#include <linux/kobject.h>
+*#include <linux/sysfs.h>
+*#include <linux/sysdev.h>
+*#include <linux/device.h>
+*/
/* for file operations */
#include <linux/fs.h>
@@ -59,6 +57,9 @@
/* hardware addresses */
#include <asm/hardware.h>
+/* for platform device */
+#include <linux/platform_device.h>
+
#endif
/* for debugging messages*/
@@ -68,7 +69,7 @@
#ifdef LED_DEBUG
# ifdef __KERNEL__
/* for kernel spage */
-# define PDEBUG(fmt,args...) printk(KERN_DEBUG "led : " fmt, ##args)
+# define PDEBUG(fmt,args...) printk(KERN_DEBUG "LED : " fmt, ##args)
# else
/* for user space */
# define PDEBUG(fmt,args...) printk(stderr, fmt, ##args)
@@ -77,26 +78,104 @@
# define PDEBUG(fmt,args...) /* no debbuging message */
#endif
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Fabien Marteau <fab...@ar...> - ARMadeus Systems");
-MODULE_DESCRIPTION("Led device driver");
-/* major and minor number */
-#define N_DEV 1
+#define FPGA_BASE_ADDR IMX_CS1_PHYS
+#define FPGA_MEM_SIZE IMX_CS1_SIZE
+#define LED_NUMBER 2
+
+/* platform device */
+struct plat_led_port{
+ const char *name; /* instance name */
+ int num; /* instance number */
+ unsigned int membase; /* ioremap base address */
+};
+
+static struct plat_led_port plat_led_data[] = {
+ {
+ .name = "led0",
+ .num = 0,
+ .membase = 0x04
+ },
+ {
+ .name = "led1",
+ .num = 1,
+ .membase = 0x06
+ },
+ {
+ .name = NULL
+ },
+};
+
+static struct platform_device plat_led_device = {
+ .name = "led",
+ .id = 0,
+ .dev = {
+ .platform_data = plat_led_data
+ },
+};
+
+
+static int led_probe(struct platform_device *plat_led_device);
+static int led_remove(struct platform_device *plat_led_device);
+
+static struct platform_driver plat_led_driver = {
+ .probe = led_probe,
+ .remove = led_remove,
+ .driver = {
+ .name = "led",
+ .owner = THIS_MODULE,
+ },
+};
+
+/************************************
+ * module init and exit
+ ***********************************/
+
+static int __init led_init(void){
+ int ret;
+ PDEBUG("init Led platform driver\n");
+ PDEBUG("Platform driver name %s\n",plat_led_driver.driver.name);
+ ret = platform_driver_register(&plat_led_driver);
+ if(ret){
+ printk(KERN_ERR "Platform driver register error\n");
+ return ret;
+ }
+ PDEBUG("Driver registered\n");
+ ret = platform_device_add(&plat_led_device);
+ if(ret){
+ printk(KERN_ERR "Platform device adding problem\n");
+ return ret;
+ }
+ return 0;
+}
+
+static void __exit led_exit(void){
+ PDEBUG("Exit function \n");
+ platform_driver_unregister(&plat_led_driver);
+ PDEBUG("driver unregistered\n");
+ //platform_device_unregister(&plat_led_device);
+ //PDEBUG("device unregistered\n");
+
+}
+
+/*************************/
/* main device structure */
+/*************************/
struct led_dev{
- struct cdev cdev; /* Char device structure */
- struct semaphore sem; /* Mutex */
- struct kobject kobj; /* kobject for sysfs entry */
- void * fpga_virtual_base_address; /* fpga register base address*/
- unsigned long previousint; /* last interruption time */
+ char *name; /* the name of the instance */
+ struct cdev cdev; /* Char device structure */
+ void * fpga_virtual_base_address; /* fpga register base address*/
+ unsigned int membase; /* base address for instance relative to
+ fpga_virtual_base_address */
+ dev_t devno; /* to store Major and minor numbers */
};
-static void kobj_release(struct kobject *);
-static dev_t devno; /* to store Major and minor numbers */
-static struct led_dev *leddev;
+static struct led_dev led_device[LED_NUMBER];
+
+/******************************/
/* to read write led register */
+/******************************/
ssize_t led_read(struct file *fildes, char __user *buff,
size_t count, loff_t *offp);
@@ -106,7 +185,7 @@
int led_release(struct inode *, struct file *filp);
-struct file_operations led_fops = {
+static struct file_operations led_fops = {
.owner = THIS_MODULE,
.read = led_read,
.write = led_write,
@@ -114,28 +193,14 @@
.release = led_release,
};
-/* Sysfs operation */
-static struct attribute led_status_attr = {
- .name = "status",
- .owner = THIS_MODULE,
- .mode = 0666,
-};
+/****************************
+ * personnal functions
+ ***************************/
-static int init_sysinterface(struct led_dev *pdev);
-static ssize_t led_show_status(struct kobject *kobj,struct attribute *attr,char *buf);
-static ssize_t led_store_status(struct kobject *kobj,struct attribute *attr, const char *buff, size_t size);
+static int free_all(struct plat_led_port *);
-static struct sysfs_ops led_status_fs_ops = {
- .show = led_show_status,
- .store = led_store_status,
-};
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Fabien Marteau <fab...@ar...> - ARMadeus Systems");
+MODULE_DESCRIPTION("Led device driver");
-struct kobj_type kobjtype = {
- .release = kobj_release,
- .sysfs_ops = &led_status_fs_ops,
-};
-static void free_all(void);
-
-static ssize_t led_fpga_read(void * addr, u16 *data , struct led_dev *dev);
-static ssize_t led_fpga_write(void * addr, u16 *data, struct led_dev *dev);
Deleted: trunk/target/linux/modules/fpga/others/Wb_led/led_specific.h
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_led/led_specific.h 2008-08-05 15:28:22 UTC (rev 868)
+++ trunk/target/linux/modules/fpga/others/Wb_led/led_specific.h 2008-08-08 13:29:18 UTC (rev 869)
@@ -1,12 +0,0 @@
-/* this file as been generated by orchestra
- * do not modify it manualy
- */
-
-#define FPGA_LED 4
-#define FPGA_IRQ_MASK 0
-#define FPGA_IRQ_PEND 2
-#define FPGA_IRQ_ACK 2
-
-#define FPGA_BASE_ADDR IMX_CS1_PHYS
-#define FPGA_MEM_SIZE IMX_CS1_SIZE
-#define LED_NAME "led"
Added: trunk/target/linux/modules/fpga/others/Wb_led/testled.c
===================================================================
--- trunk/target/linux/modules/fpga/others/Wb_led/testled.c (rev 0)
+++ trunk/target/linux/modules/fpga/others/Wb_led/testled.c 2008-08-08 13:29:18 UTC (rev 869)
@@ -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);
+}
Added: trunk/target/linux/modules/fpga/podscript.sh
===================================================================
--- trunk/target/linux/modules/fpga/podscript.sh (rev 0)
+++ trunk/target/linux/modules/fpga/podscript.sh 2008-08-08 13:29:18 UTC (rev 869)
@@ -0,0 +1,86 @@
+#!/bin/bash
+
+FPGADIR="target/linux/modules/fpga"
+PODDIR="/POD"
+
+echo "***********************"
+echo "*Generating POD config*"
+echo "***********************"
+
+echo """
+#
+# Armadeus custom drivers configuration
+#
+#
+
+#
+config POD_DRIVERS
+ boolean \"Drivers generated by POD\"
+ default n
+ depends on ARMADEUS_FPGA_DRIVERS
+ ---help---
+ All drivers for FPGA components
+
+""" > $FPGADIR$PODDIR/Kconfig
+
+
+line=""
+for i in `tree -fid $FPGADIR$PODDIR | grep -v "$PODDIR\$" | grep "$PODDIR"`
+do
+ echo $i
+ IFS='/'
+ name=(${i})
+
+echo """
+source \"drivers/armadeus/fpga/POD/${name[5]}/Kconfig\"
+""" >> "${FPGADIR}${PODDIR}/Kconfig"
+
+ line="${line} ${name[5]}/"
+done;
+
+# fill Makefile
+echo """
+#
+# 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_POD_DRIVERS) += ${line}
+
+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')
+#`grep \"BR2_PACKAGE_LINUX_VERSION=\" \$(BASE_DIR).config | \
+# sed \"s/BR2_PACKAGE_LINUX_VERSION=\\\"//\" | sed \"s/\\\"//\"`
+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
+
+""" > "${FPGADIR}${PODDIR}/Makefile";
+# ok config generated
+touch "$FPGADIR$PODDIR/.pod"
+echo "ok"
Property changes on: trunk/target/linux/modules/fpga/podscript.sh
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|