[Armadeus-commitlog] SF.net SVN: armadeus:[862] trunk/target/linux/modules
Brought to you by:
sszy
|
From: <ar...@us...> - 2008-07-29 14:25:01
|
Revision: 862
http://armadeus.svn.sourceforge.net/armadeus/?rev=862&view=rev
Author: artemys
Date: 2008-07-29 14:25:09 +0000 (Tue, 29 Jul 2008)
Log Message:
-----------
[LINUX] Add driver for OpenCore IRQ manager (generated by POD)
Modified Paths:
--------------
trunk/target/linux/modules/Makefile
trunk/target/linux/modules/fpga/Kconfig
Added Paths:
-----------
trunk/target/linux/modules/fpga/Makefile
trunk/target/linux/modules/fpga/irq_manager/
trunk/target/linux/modules/fpga/irq_manager/Kconfig
trunk/target/linux/modules/fpga/irq_manager/Makefile
trunk/target/linux/modules/fpga/irq_manager/README
trunk/target/linux/modules/fpga/irq_manager/main.c
trunk/target/linux/modules/fpga/irq_manager/test.c
Modified: trunk/target/linux/modules/Makefile
===================================================================
--- trunk/target/linux/modules/Makefile 2008-07-28 15:23:57 UTC (rev 861)
+++ trunk/target/linux/modules/Makefile 2008-07-29 14:25:09 UTC (rev 862)
@@ -9,8 +9,7 @@
# Part executed when called from kernel build system:
obj-$(CONFIG_ARMADEUS_DRIVERS) += gpio/ pwm/ backlight/ isp1761/ \
- fpga/ps2keyboard/ imxlkeypad/ fpga/fpga_devtools/ fpga/Wb_led/ fpga/Wb_button/ \
- fpga/i2ctest/ fpga/fpgaaccess/ fpga/serial/
+ imxlkeypad/ fpga/
else
Modified: trunk/target/linux/modules/fpga/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/Kconfig 2008-07-28 15:23:57 UTC (rev 861)
+++ trunk/target/linux/modules/fpga/Kconfig 2008-07-29 14:25:09 UTC (rev 862)
@@ -25,5 +25,7 @@
source "drivers/armadeus/fpga/serial/Kconfig"
+source "drivers/armadeus/fpga/irq_manager/Kconfig"
+
endmenu
Added: trunk/target/linux/modules/fpga/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/Makefile (rev 0)
+++ trunk/target/linux/modules/fpga/Makefile 2008-07-29 14:25:09 UTC (rev 862)
@@ -0,0 +1,42 @@
+#
+# 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_ARMADEUS_FPGA_DRIVERS) += ps2keyboard/ fpga_devtools/ Wb_led/ Wb_button/ \
+ i2ctest/ fpgaaccess/ serial/ irq_manager/
+
+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
+
Property changes on: trunk/target/linux/modules/fpga/Makefile
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/target/linux/modules/fpga/irq_manager/Kconfig
===================================================================
--- trunk/target/linux/modules/fpga/irq_manager/Kconfig (rev 0)
+++ trunk/target/linux/modules/fpga/irq_manager/Kconfig 2008-07-29 14:25:09 UTC (rev 862)
@@ -0,0 +1,10 @@
+#
+#
+
+config ARMADEUS_FPGA_IRG_MANAGER
+ tristate "OpenCore IRQ manager driver"
+ default n
+ depends on ARMADEUS_FPGA_DRIVERS
+ ---help---
+ You need it if you have a POD generated "IP"
+
Added: trunk/target/linux/modules/fpga/irq_manager/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/irq_manager/Makefile (rev 0)
+++ trunk/target/linux/modules/fpga/irq_manager/Makefile 2008-07-29 14:25:09 UTC (rev 862)
@@ -0,0 +1,38 @@
+#
+# Makefile for the Armadeus FPGA OpenCore IRQ manager IP
+#
+
+ifneq ($(KERNELRELEASE),)
+
+# Part executed when called from kernel build system:
+
+obj-m += irq_ocore.o
+irq_ocore-objs := main.o
+
+obj-m += test_irq.o
+test_irq-objs := test.o
+
+else
+
+# Part executed when called from standard make in this directory:
+# (preferably use Makefile in parent directory)
+
+BASE_DIR=../../../../../buildroot
+REL=`grep "BR2_PACKAGE_LINUX_VERSION=" $(BASE_DIR)/.config | \
+ sed "s/BR2_PACKAGE_LINUX_VERSION=\\"//" | sed "s/\\"//"`
+BUILD_ARM=`ls $(BASE_DIR) | grep "^build_arm"`
+ARMADEUS_KERNEL_DIR=$(BASE_DIR)/$(BUILD_ARM)/linux-$(REL)
+KDIR := $(ARMADEUS_KERNEL_DIR)
+PWD := $(shell pwd)
+
+default:
+ $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
+
+clean:
+ rm -f *.*o
+ rm -f Module.symvers
+ rm -rf .*.cmd
+ rm -f *.mod.c
+
+endif
+
Property changes on: trunk/target/linux/modules/fpga/irq_manager/Makefile
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/target/linux/modules/fpga/irq_manager/README
===================================================================
--- trunk/target/linux/modules/fpga/irq_manager/README (rev 0)
+++ trunk/target/linux/modules/fpga/irq_manager/README 2008-07-29 14:25:09 UTC (rev 862)
@@ -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/irq_manager/main.c
===================================================================
--- trunk/target/linux/modules/fpga/irq_manager/main.c (rev 0)
+++ trunk/target/linux/modules/fpga/irq_manager/main.c 2008-07-29 14:25:09 UTC (rev 862)
@@ -0,0 +1,161 @@
+/*
+ * 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 <asm/hardware.h>
+#include <asm/arch/irqs.h>
+#include <asm/irq.h>
+#include <asm/io.h> // readb() & Co
+
+#include <asm/mach/irq.h>
+
+#if 0
+#define DEBUG_FPGA_IRQ(fmt...) printk(fmt)
+#else
+#define DEBUG_FPGA_IRQ(fmt...) do { } while (0)
+#endif
+
+
+/* --- Things to be configured by POD --- */
+#define FPGA_IMR (APF9328_FPGA_VIRT + 0x00) /* Interrupt Mask Register */
+#define FPGA_ISR (APF9328_FPGA_VIRT + 0x02) /* Interrupt Status Register */
+#define NB_IT (16)
+/* -------------------------------------- */
+
+
+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;
+
+ DEBUG_FPGA_IRQ("Initializing FPGA IRQs\n");
+
+ /* 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;
+}
+
+static void __exit ocore_irq_mng_exit(void)
+{
+ /* Should we allow to remove this module ?? */
+ 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/irq_manager/test.c
===================================================================
--- trunk/target/linux/modules/fpga/irq_manager/test.c (rev 0)
+++ trunk/target/linux/modules/fpga/irq_manager/test.c 2008-07-29 14:25:09 UTC (rev 862)
@@ -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");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|