[Armadeus-commitlog] SF.net SVN: armadeus:[1340] trunk
Brought to you by:
sszy
|
From: <ar...@us...> - 2009-06-08 19:34:16
|
Revision: 1340
http://armadeus.svn.sourceforge.net/armadeus/?rev=1340&view=rev
Author: artemys
Date: 2009-06-08 19:34:07 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
[LINUX] Makes ocore_irq_mng driver a platform_driver + updates apf27.c & apf9328.c accordingly
Modified Paths:
--------------
trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/021-armadeus-apf9328.patch
trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/281-apf27-armadeus-add_apf27.c.patch
trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/322-apf27-armadeus-add_mach_fpga_h.patch
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile
trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/main.c
Modified: trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/021-armadeus-apf9328.patch
===================================================================
--- trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/021-armadeus-apf9328.patch 2009-06-08 17:28:39 UTC (rev 1339)
+++ trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/021-armadeus-apf9328.patch 2009-06-08 19:34:07 UTC (rev 1340)
@@ -1,11 +1,11 @@
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)
-Index: linux-2.6.29/arch/arm/mach-imx/apf9328.c
+Index: linux-2.6.29.4/arch/arm/mach-imx/apf9328.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29/arch/arm/mach-imx/apf9328.c 2009-05-27 09:33:57.000000000 +0200
-@@ -0,0 +1,816 @@
++++ linux-2.6.29.4/arch/arm/mach-imx/apf9328.c 2009-06-08 19:07:17.000000000 +0200
+@@ -0,0 +1,849 @@
+/*
+ * linux/arch/arm/mach-imx/apf9328.c
+ *
@@ -59,6 +59,9 @@
+#ifdef CONFIG_DM9000
+#include <linux/dm9000.h>
+#endif
++#ifdef CONFIG_MACH_APF9328_FPGA
++#include "../plat-mxc/include/mach/fpga.h" /* To be removed when MX1 arch is fully integrated */
++#endif
+
+#include "generic.h"
+
@@ -703,7 +706,35 @@
+ .num_resources = 1,
+};
+
++#ifdef CONFIG_MACH_APF9328_FPGA
++static int apf9328_fpga_irq_init(struct platform_device *pdev)
++{
++ int res = 0;
+
++ /* TODO */
++ set_irq_type(APF9328_FPGA_IRQ, IRQF_TRIGGER_RISING);
++
++ return res;
++}
++
++static void apf9328_fpga_irq_exit(struct platform_device *pdev)
++{
++ /* TODO */
++}
++
++struct fpga_irq_mng_platform_data apf9328_fpga_irq = {
++ .init = apf9328_fpga_irq_init,
++ .exit = apf9328_fpga_irq_exit,
++};
++
++struct platform_device apf9328_ocore_irq_mng_device = {
++ .name = "ocore_irq_mng",
++ .id = 0,
++ .dev = { .platform_data = &apf9328_fpga_irq, },
++};
++#endif /* CONFIG_MACH_APF9328_FPGA */
++
++
+static struct platform_device *devices[] __initdata = {
+ &imx_uart1_device,
+ &imx_uart2_device,
@@ -728,6 +759,9 @@
+ &devfull_isp1761_device,
+#endif
+ &apf9328_flash_device,
++#ifdef CONFIG_MACH_APF9328_FPGA
++ &apf9328_ocore_irq_mng_device,
++#endif
+};
+
+static void __init apf9328_init(void)
@@ -778,8 +812,10 @@
+ .type = MT_DEVICE
+ },
+#endif
++#ifdef CONFIG_MACH_APF9328_FPGA
+ /* FPGA Memory mapping */
+ {.virtual = IMX_CS1_VIRT, .pfn = __phys_to_pfn(IMX_CS1_PHYS), .length = IMX_CS1_SIZE, .type = MT_DEVICE},
++#endif
+};
+
+void __init apf9328_map_io(void)
@@ -803,9 +839,6 @@
+#ifdef CONFIG_CAN_MCP251X
+ set_irq_type( IRQ_GPIOC(CAN_MPC251X_INT_GPIOC), IRQF_TRIGGER_FALLING );
+#endif
-+#ifdef CONFIG_ARMADEUS_FPGA_DRIVERS
-+ set_irq_type( APF9328_FPGA_IRQ, IRQF_TRIGGER_RISING );
-+#endif
+#ifdef CONFIG_ARMADEUS_ISP1761
+ set_irq_type( ISP1761_IRQ, IRQF_TRIGGER_FALLING );
+#endif
@@ -822,10 +855,10 @@
+ .timer = &imx_timer,
+ .init_machine = apf9328_init,
+MACHINE_END
-Index: linux-2.6.29/arch/arm/mach-imx/apf9328_lcd_config.h
+Index: linux-2.6.29.4/arch/arm/mach-imx/apf9328_lcd_config.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29/arch/arm/mach-imx/apf9328_lcd_config.h 2009-05-27 17:11:00.000000000 +0200
++++ linux-2.6.29.4/arch/arm/mach-imx/apf9328_lcd_config.h 2009-06-08 18:35:27.000000000 +0200
@@ -0,0 +1,301 @@
+/*
+ *
@@ -1128,10 +1161,10 @@
+#endif /* CONFIG_FB_IMX */
+
+#endif /* APF_LCD_CONFIG_H */
-Index: linux-2.6.29/arch/arm/mach-imx/include/mach/apf9328.h
+Index: linux-2.6.29.4/arch/arm/mach-imx/include/mach/apf9328.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29/arch/arm/mach-imx/include/mach/apf9328.h 2009-05-27 09:33:57.000000000 +0200
++++ linux-2.6.29.4/arch/arm/mach-imx/include/mach/apf9328.h 2009-06-08 18:35:27.000000000 +0200
@@ -0,0 +1,63 @@
+/*
+ * linux/include/asm-arm/arch-imx/apf9328.h
Modified: trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/281-apf27-armadeus-add_apf27.c.patch
===================================================================
--- trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/281-apf27-armadeus-add_apf27.c.patch 2009-06-08 17:28:39 UTC (rev 1339)
+++ trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/281-apf27-armadeus-add_apf27.c.patch 2009-06-08 19:34:07 UTC (rev 1340)
@@ -1,11 +1,11 @@
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)
-Index: linux-2.6.29/arch/arm/mach-mx2/apf27.c
+Index: linux-2.6.29.4/arch/arm/mach-mx2/apf27.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29/arch/arm/mach-mx2/apf27.c 2009-06-02 15:40:48.000000000 +0200
-@@ -0,0 +1,1572 @@
++++ linux-2.6.29.4/arch/arm/mach-mx2/apf27.c 2009-06-08 18:01:09.000000000 +0200
+@@ -0,0 +1,1583 @@
+ /*
+ * apf27.c
+ *
@@ -82,6 +82,9 @@
+#endif
+#include <mach/board-apf27.h>
+#include <asm/mach/map.h>
++#ifdef CONFIG_MACH_APF27_FPGA
++#include <mach/fpga.h>
++#endif
+#include "devices.h"
+#include "crm_regs.h"
+
@@ -1455,12 +1458,12 @@
+
+
+/* FPGA */
-+#ifdef CONFIG_ARMADEUS_FPGA_DRIVERS
++#ifdef CONFIG_MACH_APF27_FPGA
+static int fpga_pins[] = {
+ (APF27_FPGA_INT_PIN | GPIO_IN | GPIO_GPIO),
+};
+
-+static int apf27_fpga_init(void)
++static int apf27_fpga_irq_init(struct platform_device *pdev)
+{
+ int res;
+
@@ -1470,16 +1473,24 @@
+
+ return res;
+}
-+# if 0
-+static int apf27_fpga_exit(void)
++
++static void apf27_fpga_irq_exit(struct platform_device *pdev)
+{
-+ mxc_gpio_release_multiple(fpga_pins, ARRAY_SIZE(fpga_pins));
-+ return 0;
++ mxc_gpio_release_multiple_pins(fpga_pins, ARRAY_SIZE(fpga_pins));
+}
-+# endif
-+#endif /* CONFIG_ARMADEUS_FPGA_DRIVERS */
+
++struct fpga_irq_mng_platform_data apf27_fpga_irq = {
++ .init = apf27_fpga_irq_init,
++ .exit = apf27_fpga_irq_exit,
++};
+
++struct platform_device apf27_ocore_irq_mng_device = {
++ .name = "ocore_irq_mng",
++ .id = 0,
++};
++#endif /* CONFIG_MACH_APF27_FPGA */
++
++
+static void __init apf27_init(void)
+{
+ sysdev_class_register(&apf27_pm_sysclass);
@@ -1536,8 +1547,8 @@
+#ifdef CONFIG_VIDEO_MX27
+ mxc_register_device(&mx27_camera_device, &apf27_camera);
+#endif
-+#ifdef CONFIG_ARMADEUS_FPGA_DRIVERS
-+ apf27_fpga_init();
++#ifdef CONFIG_MACH_APF27_FPGA
++ mxc_register_device(&apf27_ocore_irq_mng_device, &apf27_fpga_irq);
+#endif
+
+ printk("i.MX27 chip revision: %d\n", mx27_revision() );
Modified: trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/322-apf27-armadeus-add_mach_fpga_h.patch
===================================================================
--- trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/322-apf27-armadeus-add_mach_fpga_h.patch 2009-06-08 17:28:39 UTC (rev 1339)
+++ trunk/buildroot/target/device/armadeus/linux/kernel-patches/2.6.29/322-apf27-armadeus-add_mach_fpga_h.patch 2009-06-08 19:34:07 UTC (rev 1340)
@@ -1,8 +1,8 @@
-Index: linux-2.6.29/arch/arm/plat-mxc/include/mach/fpga.h
+Index: linux-2.6.29.4/arch/arm/plat-mxc/include/mach/fpga.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29/arch/arm/plat-mxc/include/mach/fpga.h 2009-05-22 18:24:02.000000000 +0200
-@@ -0,0 +1,38 @@
++++ linux-2.6.29.4/arch/arm/plat-mxc/include/mach/fpga.h 2009-06-08 17:40:21.000000000 +0200
+@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2009 Armadeus Systems
+ *
@@ -31,6 +31,7 @@
+#else
+/* To complete when MX1 platform merged */
+#endif
++#include <linux/platform_device.h>
+
+/* FPGA interrupts number */
+#ifdef CONFIG_MACH_APF27
@@ -39,5 +40,9 @@
+#define IRQ_FPGA(x) (IRQ_FPGA_START + x)
+#define NR_IRQS_FPGA (MXC_BOARD_IRQS)
+
++struct fpga_irq_mng_platform_data {
++ int (*init)(struct platform_device*);
++ void (*exit)(struct platform_device*);
++};
++
+#endif /* __ASM_ARCH_ARMADEUS_FPGA_H__ */
-+
Modified: trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile 2009-06-08 17:28:39 UTC (rev 1339)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/Makefile 2009-06-08 19:34:07 UTC (rev 1340)
@@ -17,18 +17,8 @@
KDIR := $(ARMADEUS_LINUX_DIR)
PWD := $(shell pwd)
-default:
- $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
+# Armadeus custom drivers common targets (default, clean, etc...)
+include ../../../Makefile.in
-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_irq_mngr/main.c
===================================================================
--- trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/main.c 2009-06-08 17:28:39 UTC (rev 1339)
+++ trunk/target/linux/modules/fpga/wishbone_example/wb_irq_mngr/main.c 2009-06-08 19:34:07 UTC (rev 1340)
@@ -1,5 +1,6 @@
/*
- * Driver for the IRQ manager loaded in FPGA of the Armadeus boards
+ * Driver for the IRQ manager (OpenCore/Wishbone based) loaded in the FPGA of
+ * the Armadeus boards.
*
* (C) Copyright 2008 Armadeus Systems
* Author: Julien Boibessot <jul...@ar...>
@@ -22,21 +23,21 @@
*
*/
-/*#define DEBUG*/
+/* #define DEBUG */
#include <linux/module.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/interrupt.h>
-
+#include <linux/platform_device.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
-# include <asm/hardware.h>
-# include <asm/arch/irqs.h>
+# include <asm/hardware.h>
+# include <asm/arch/irqs.h>
#else
-# include <mach/hardware.h>
-# include <mach/irqs.h>
+# include <mach/hardware.h>
+# include <mach/irqs.h>
#endif
#include <asm/irq.h>
#include <asm/io.h> /* readb() & Co */
@@ -47,6 +48,10 @@
#else
#define VA_GPIO_BASE IO_ADDRESS(IMX_GPIO_BASE)
#define MXC_ISR(x) (0x34 + ((x) << 8))
+struct fpga_irq_mng_platform_data { /* To remove when MX1 platform merged */
+ int (*init)(struct platform_device*);
+ void (*exit)(struct platform_device*);
+};
#endif
@@ -59,7 +64,9 @@
#define FPGA_IMR (ARMADEUS_FPGA_BASE_ADDR_VIRT + IRQ_MNGR_BASE + 0x00) /* Interrupt Mask Register */
#define FPGA_ISR (ARMADEUS_FPGA_BASE_ADDR_VIRT + IRQ_MNGR_BASE + 0x02) /* Interrupt Status Register */
+#define DRIVER_NAME "ocore_irq_mng"
+
static int
imx_fpga_irq_type(unsigned int _irq, unsigned int type)
{
@@ -73,10 +80,10 @@
shadow = 1 << ((irq - IRQ_FPGA_START) % NB_IT);
pr_debug("%s: irq %d ack:0x%x\n", __FUNCTION__, irq, shadow);
- writew( shadow, FPGA_ISR );
+ writew(shadow, FPGA_ISR);
/* if last IT, ack GPIO global IRQ */
- if( readw(FPGA_ISR) == 0 ) {
+ if (readw(FPGA_ISR) == 0) {
__raw_writel(1 << (ARMADEUS_FPGA_IRQ & 0x1f),
VA_GPIO_BASE + MXC_ISR(IRQ_TO_REG(ARMADEUS_FPGA_IRQ)));
}
@@ -90,7 +97,7 @@
shadow = readw(FPGA_IMR);
shadow &= ~( 1 << ((irq - IRQ_FPGA_START) % NB_IT));
pr_debug("%s: irq %d mask:0x%x\n", __FUNCTION__, irq, shadow);
- writew( shadow, FPGA_IMR );
+ writew(shadow, FPGA_IMR);
}
static void
@@ -140,26 +147,67 @@
};
-static int __init ocore_irq_mng_init(void)
+#ifdef CONFIG_PM
+static int ocore_irq_mng_suspend(struct platform_device *pdev, pm_message_t state)
{
+ struct fpga_irq_mng_platform_data *pdata = pdev->dev.platform_data;
+
+ dev_dbg(&pdev->dev, "suspended\n");
+ if (pdata->exit)
+ pdata->exit(pdev);
+
+ return 0;
+}
+
+static int ocore_irq_mng_resume(struct platform_device *pdev)
+{
+ struct fpga_irq_mng_platform_data *pdata = pdev->dev.platform_data;
+
+ dev_dbg(&pdev->dev, "resumed\n");
+ if (pdata->init)
+ pdata->init(pdev);
+
+ return 0;
+}
+#else
+
+# define ocore_irq_mng_suspend NULL
+# define ocore_irq_mng_resume NULL
+
+#endif /* CONFIG_PM */
+
+static int __devinit ocore_irq_mng_probe(struct platform_device *pdev)
+{
unsigned int irq;
u16 data;
- int result = 0;
+ int ret = 0;
+ struct fpga_irq_mng_platform_data *pdata;
pr_debug("Initializing FPGA IRQs\n");
/* check if ID is correct */
data = ioread16(ARMADEUS_FPGA_BASE_ADDR_VIRT + IRQ_MNGR_BASE + ID_OFFSET);
if (data != ID) {
- result = -ENODEV;
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;
+ return -ENODEV;
}
+ pdata = pdev->dev.platform_data;
+ if (!pdata) {
+ dev_err(&pdev->dev,"No platform_data available\n");
+ return -ENOMEM;
+ }
+
/* Mask all interrupts initially */
writew(0, FPGA_IMR);
+ if (pdata->init) {
+ ret = pdata->init(pdev);
+ if (ret)
+ goto failed_platform_init;
+ }
+
for (irq = IRQ_FPGA(0); irq < IRQ_FPGA(NB_IT); irq++) {
pr_debug("IRQ %d\n", irq);
set_irq_chip_and_handler(irq, &imx_fpga_chip, handle_edge_irq);
@@ -169,26 +217,50 @@
}
set_irq_chained_handler(ARMADEUS_FPGA_IRQ, imx_fpga_demux_handler);
- pr_debug("IRQs initialized\n");
+ pr_debug("FPGA IRQs initialized (Parent=%d)\n", ARMADEUS_FPGA_IRQ);
return 0;
-error_id:
- return result;
+
+failed_platform_init:
+ return ret;
}
-static void __exit ocore_irq_mng_exit(void)
+static int __devexit ocore_irq_mng_remove(struct platform_device *pdev)
{
unsigned int irq;
+
for (irq = IRQ_FPGA(0); irq < IRQ_FPGA(NB_IT); irq++) {
- set_irq_chip( irq, NULL);
+ set_irq_chip(irq, NULL);
set_irq_handler(irq,NULL);
set_irq_flags(irq, 0);
}
set_irq_chained_handler(ARMADEUS_FPGA_IRQ, NULL);
pr_debug("%s\n", __FUNCTION__);
+
+ return 0;
}
+static struct platform_driver ocore_irq_mng_driver = {
+ .probe = ocore_irq_mng_probe,
+ .remove = ocore_irq_mng_remove,
+ .suspend = ocore_irq_mng_suspend,
+ .resume = ocore_irq_mng_resume,
+ .driver = {
+ .name = DRIVER_NAME,
+ },
+};
+
+static int __init ocore_irq_mng_init(void)
+{
+ return platform_driver_register(&ocore_irq_mng_driver);
+}
+
+static void __exit ocore_irq_mng_exit(void)
+{
+ platform_driver_unregister(&ocore_irq_mng_driver);
+}
+
module_init(ocore_irq_mng_init);
module_exit(ocore_irq_mng_exit);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|