[Armadeus-commitlog] armadeus branch, master, updated. armadeus-4.0-2497-gcddf6b4
Brought to you by:
sszy
|
From: Fabien M <fa...@us...> - 2011-09-05 14:32:17
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via cddf6b48496584c2a5f6ead33f7634a5394539dc (commit)
from d597593aa89f975da0c0e7efe3be0207fe5ae07b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit cddf6b48496584c2a5f6ead33f7634a5394539dc
Author: Fabien Marteau <fab...@ar...>
Date: Mon Sep 5 16:31:36 2011 +0200
[kernel] adding anybus_interface driver
-----------------------------------------------------------------------
Summary of changes:
.../linux/modules/fpga/virtual_components/Kconfig | 1 +
.../linux/modules/fpga/virtual_components/Makefile | 2 +-
.../virtual_components/anybus_interface/Kconfig | 8 +
.../virtual_components/anybus_interface/Makefile | 3 +
.../anybus_interface/anybus_interface.c | 194 ++++++++++++++++++++
.../anybus_interface.h} | 10 +-
6 files changed, 211 insertions(+), 7 deletions(-)
create mode 100644 target/linux/modules/fpga/virtual_components/anybus_interface/Kconfig
create mode 100644 target/linux/modules/fpga/virtual_components/anybus_interface/Makefile
create mode 100644 target/linux/modules/fpga/virtual_components/anybus_interface/anybus_interface.c
copy target/linux/modules/fpga/virtual_components/{pod_gpio/pod_gpio.h => anybus_interface/anybus_interface.h} (83%)
diff --git a/target/linux/modules/fpga/virtual_components/Kconfig b/target/linux/modules/fpga/virtual_components/Kconfig
index cb048a7..ca6166b 100644
--- a/target/linux/modules/fpga/virtual_components/Kconfig
+++ b/target/linux/modules/fpga/virtual_components/Kconfig
@@ -10,3 +10,4 @@ source "drivers/armadeus/fpga/virtual_components/irq_mngr/Kconfig"
source "drivers/armadeus/fpga/virtual_components/button/Kconfig"
source "drivers/armadeus/fpga/virtual_components/led/Kconfig"
source "drivers/armadeus/fpga/virtual_components/pod_gpio/Kconfig"
+source "drivers/armadeus/fpga/virtual_components/anybus_interface/Kconfig"
diff --git a/target/linux/modules/fpga/virtual_components/Makefile b/target/linux/modules/fpga/virtual_components/Makefile
index a2e2c2b..d52b84d 100644
--- a/target/linux/modules/fpga/virtual_components/Makefile
+++ b/target/linux/modules/fpga/virtual_components/Makefile
@@ -1,3 +1,3 @@
-obj-$(CONFIG_ARMADEUS_FPGA_VIRTUAL_COMPONENTS) += button/ irq_mngr/ led/ pod_gpio/
+obj-$(CONFIG_ARMADEUS_FPGA_VIRTUAL_COMPONENTS) += button/ irq_mngr/ led/ pod_gpio/ anybus_interface/
diff --git a/target/linux/modules/fpga/virtual_components/anybus_interface/Kconfig b/target/linux/modules/fpga/virtual_components/anybus_interface/Kconfig
new file mode 100644
index 0000000..fee6808
--- /dev/null
+++ b/target/linux/modules/fpga/virtual_components/anybus_interface/Kconfig
@@ -0,0 +1,8 @@
+
+config ARMADEUS_FPGA_VIRTUAL_COMPONENT_ANYBUS_INTERFACE
+ tristate "Anybus interface"
+ default n
+ depends on ARMADEUS_FPGA_VIRTUAL_COMPONENTS
+ ---help---
+ Armadeus driver for anybus interface component
+ kernel >= 2.6.38 is required
diff --git a/target/linux/modules/fpga/virtual_components/anybus_interface/Makefile b/target/linux/modules/fpga/virtual_components/anybus_interface/Makefile
new file mode 100644
index 0000000..29d7e39
--- /dev/null
+++ b/target/linux/modules/fpga/virtual_components/anybus_interface/Makefile
@@ -0,0 +1,3 @@
+
+obj-$(CONFIG_ARMADEUS_FPGA_VIRTUAL_COMPONENT_ANYBUS_INTERFACE) += anybus_interface.o
+
diff --git a/target/linux/modules/fpga/virtual_components/anybus_interface/anybus_interface.c b/target/linux/modules/fpga/virtual_components/anybus_interface/anybus_interface.c
new file mode 100644
index 0000000..244d45f
--- /dev/null
+++ b/target/linux/modules/fpga/virtual_components/anybus_interface/anybus_interface.c
@@ -0,0 +1,194 @@
+/*
+ * ARMadeus driver for the POD component anybus_interface
+ *
+ * (C) Copyright 2011 - Armadeus Systems <su...@ar...>
+ * Author: Kevin JOLY jol...@gm...
+ *
+ * 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/platform_device.h>
+#include <linux/cdev.h>
+#include <linux/io.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+
+#include "anybus_interface.h"
+
+#define ANYBUS_ID_REGISTER 0x00
+
+struct anybus_device {
+ struct class *anybus_class;
+ void __iomem *reg_base;
+ struct cdev *cdev;
+ unsigned long start_register;
+} *anybus_dev;
+
+static u16 pod_anybus_interface_read_reg(int reg)
+{
+ return ioread16(anybus_dev->reg_base + reg);
+}
+
+static int mmap_anybus(struct file *file, struct vm_area_struct *vma)
+{
+ vma->vm_pgoff = anybus_dev->start_register >> PAGE_SHIFT;
+
+ vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+
+ if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,vma->vm_end - vma->vm_start, vma->vm_page_prot)) {
+ return -EAGAIN;
+ }
+
+ return 0;
+}
+
+static const struct file_operations anybus_fops = {
+ .mmap = mmap_anybus,
+};
+
+static int pod_anybus_interface_probe(struct platform_device *pdev)
+{
+ struct resource *resource_memory, *resource_irq;
+ /*struct anybus_device *anybus_dev;*/
+ u16 id;
+ /*struct cdev *cdev = cdev_alloc();*/
+ int err;
+
+ resource_memory = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ resource_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+
+ if (!resource_memory) {
+ err = -ENODEV;
+ dev_err(&pdev->dev, "Device Anybus not found\n");
+ goto exit;
+ }
+
+ anybus_dev = kzalloc(sizeof(struct anybus_device), GFP_KERNEL);
+ anybus_dev->reg_base = ioremap_nocache(resource_memory->start, resource_size(resource_memory));
+ anybus_dev->start_register = resource_memory->start;
+
+ /*dev_set_drvdata(&pdev->dev, anybus_dev);*/
+
+ if (!request_mem_region(resource_memory->start,
+ resource_size(resource_memory), ANYBUS_INTERFACE_DRIVER_NAME)) {
+ dev_err(&pdev->dev, "Can't request memory region %x to %x\n",
+ resource_memory->start, resource_memory->start +
+ resource_memory->end);
+ err = -ENOMEM;
+ goto exit_free;
+ }
+
+ /*Check if ID is correct*/
+ id = pod_anybus_interface_read_reg(ANYBUS_ID_REGISTER);
+ if (pdev->id != id) {
+ dev_err(&pdev->dev,
+ "Driver id %d doesn't match with the device id %d\n",
+ pdev->id, id);
+ err = -ENODEV;
+ goto exit_iounmap;
+ }
+
+ anybus_dev->cdev = cdev_alloc();
+ err = alloc_chrdev_region(&anybus_dev->cdev->dev, 1, 1, ANYBUS_INTERFACE_DRIVER_NAME);
+ if (err) {
+ dev_err(&pdev->dev, "Unable to allocate device numbers\n");
+ goto exit_iounmap;
+ }
+
+ anybus_dev->cdev->owner = THIS_MODULE;
+ anybus_dev->cdev->ops = &anybus_fops;
+ err = cdev_add(anybus_dev->cdev, anybus_dev->cdev->dev, 256);
+ if(err) {
+ dev_err(&pdev->dev, "Unable to add cdev\n");
+ goto exit_unreg;
+ }
+
+ anybus_dev->anybus_class = class_create(THIS_MODULE, ANYBUS_INTERFACE_DRIVER_NAME);
+ if (IS_ERR(anybus_dev->anybus_class)) {
+ dev_err(&pdev->dev, "Unable to create anybus class device\n");
+ err = PTR_ERR(anybus_dev->anybus_class);
+ goto exit_unreg;
+ }
+
+ if(device_create(anybus_dev->anybus_class, NULL, anybus_dev->cdev->dev, NULL, ANYBUS_INTERFACE_DRIVER_NAME) == NULL) {
+ dev_err(&pdev->dev, "Unable to create device\n");
+ goto exit_class_destroy;
+ }
+
+ dev_info(&pdev->dev, "Anybus interface probed.\n");
+
+ return 0;
+
+exit_class_destroy :
+ class_destroy(anybus_dev->anybus_class);
+exit_unreg :
+ unregister_chrdev_region(anybus_dev->cdev->dev, 1);
+exit_iounmap:
+ iounmap(anybus_dev->reg_base);
+ release_mem_region(resource_memory->start,
+ resource_size(resource_memory));
+exit_free:
+ kfree(anybus_dev);
+exit:
+ return err;
+}
+
+static int pod_anybus_interface_remove(struct platform_device *pdev)
+{
+ struct resource *resource_memory, *resource_irq;
+ /*struct anybus_device *anybus_dev = dev_get_drvdata(&pdev->dev);*/
+
+ device_destroy(anybus_dev->anybus_class, anybus_dev->cdev->dev);
+ class_destroy(anybus_dev->anybus_class);
+ unregister_chrdev_region(anybus_dev->cdev->dev, 1);
+
+ resource_memory = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ resource_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+
+ iounmap(anybus_dev->reg_base);
+
+ release_mem_region(resource_memory->start,
+ resource_size(resource_memory));
+
+ dev_set_drvdata(&pdev->dev, NULL);
+
+ return 0;
+}
+
+static struct platform_driver pod_anybus_interface_drv = {
+ .driver = {
+ .name = ANYBUS_INTERFACE_DRIVER_NAME,
+ .owner = THIS_MODULE,
+ },
+ .probe = pod_anybus_interface_probe,
+ .remove = pod_anybus_interface_remove
+};
+
+static int __init pod_anybus_interface_init(void)
+{
+ return platform_driver_register(&pod_anybus_interface_drv);
+}
+module_init(pod_anybus_interface_init);
+
+static void __exit pod_anybus_interface_exit(void)
+{
+ platform_driver_unregister(&pod_anybus_interface_drv);
+}
+module_exit(pod_anybus_interface_exit);
+
+MODULE_AUTHOR("Kevin Joly <jol...@gm...>");
+MODULE_DESCRIPTION("Driver for anybus_interface component of POD");
+MODULE_LICENSE("GPL");
diff --git a/target/linux/modules/fpga/virtual_components/pod_gpio/pod_gpio.h b/target/linux/modules/fpga/virtual_components/anybus_interface/anybus_interface.h
similarity index 83%
copy from target/linux/modules/fpga/virtual_components/pod_gpio/pod_gpio.h
copy to target/linux/modules/fpga/virtual_components/anybus_interface/anybus_interface.h
index ce335e5..52560f2 100644
--- a/target/linux/modules/fpga/virtual_components/pod_gpio/pod_gpio.h
+++ b/target/linux/modules/fpga/virtual_components/anybus_interface/anybus_interface.h
@@ -1,5 +1,5 @@
/*
- * ARMadeus definitions for the POD component pod_gpio
+ * ARMadeus definitions for the POD component anybus_interface
*
* (C) Copyright 2011 - Armadeus Systems <su...@ar...>
* Author: Kevin JOLY jol...@gm...
@@ -19,15 +19,13 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifndef LINUX_pod_gpio
-#define LINUX_pod_gpio
+#ifndef LINUX_ANYBUS_INTERFACE
+#define LINUX_ANYBUS_INTERFACE
#ifndef CONFIG_MACH_APF9328
# include <mach/fpga.h> /* To remove when MX1 platform is merged */
#endif
-#define IRQ_GPIO_POD(x) IRQ_FPGA(x+16)
-
-#define pod_gpio_DRIVER_NAME "pod_gpio"
+#define ANYBUS_INTERFACE_DRIVER_NAME "pod_anybus_interface"
#endif
hooks/post-receive
--
armadeus
|