Message-ID: From: Mathieu Rondonneau Date: Fri, 13 Nov 2015 21:31:23 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Xenomai] [PATCH] IPIPE patch for BCM2709/RPI2. List-Id: Discussions about the Xenomai project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: xenomai@xenomai.org, Gilles Chanteperdrix >From 6f985ebdd2c99257fb3873b9cb83ba6572dff60a Mon Sep 17 00:00:00 2001 From: Mathieu Rondonneau Date: Fri, 13 Nov 2015 20:59:49 -0800 Subject: [PATCH] IPIPE patch for BCM2709. - kernel: https://github.com/raspberrypi/linux (rpi-3.18.y) - 1bb18c8f721ef674a447f3622273f2e2de7a205c - xenomai: git://git.xenomai.org/xenomai-3.git (stable-3.0.x) - cb72996a06ae4f29e403e3397324069f1983145e --- arch/arm/mach-bcm2709/armctrl.c | 20 ++++++++++++++++++++ arch/arm/mach-bcm2709/bcm2708_gpio.c | 13 ++++++++++++- arch/arm/mach-bcm2709/bcm2709.c | 9 +++++++++ arch/arm/mach-bcm2709/include/mach/entry-macro.S | 12 ++++++++++-- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-bcm2709/armctrl.c b/arch/arm/mach-bcm2709/armctrl.c index fc6cb8b..f69ceb8 100644 --- a/arch/arm/mach-bcm2709/armctrl.c +++ b/arch/arm/mach-bcm2709/armctrl.c @@ -29,6 +29,14 @@ #include #include #include "armctrl.h" +#include + +#ifdef CONFIG_IPIPE +#include +static IPIPE_DEFINE_RAW_SPINLOCK(irq_controller_lock); +#else +static DEFINE_RAW_SPINLOCK(irq_controller_lock); +#endif /* For support of kernels >= 3.0 assume only one VIC for now*/ static unsigned int remap_irqs[(INTERRUPT_ARASANSDIO + 1) - INTERRUPT_JPEG] = { @@ -54,6 +62,9 @@ static void armctrl_mask_irq(struct irq_data *d) 0 }; int i; + unsigned long flags; + + raw_spin_lock_irqsave_cond(&irq_controller_lock, flags); if (d->irq >= FIQ_START) { writel(0, __io_address(ARM_IRQ_FAST)); } else if (d->irq >= IRQ_ARM_LOCAL_CNTPSIRQ && d->irq < IRQ_ARM_LOCAL_CNTPSIRQ + 4) { @@ -79,6 +90,7 @@ static void armctrl_mask_irq(struct irq_data *d) } else if (d->irq == INTERRUPT_ARM_LOCAL_PMU_FAST) { writel(0xf, __io_address(ARM_LOCAL_PM_ROUTING_CLR)); } else { printk("%s: %d\n", __func__, d->irq); BUG(); } + raw_spin_unlock_irqrestore_cond(&irq_controller_lock, flags); } static void armctrl_unmask_irq(struct irq_data *d) @@ -90,6 +102,9 @@ static void armctrl_unmask_irq(struct irq_data *d) 0 }; int i; + unsigned long flags; + + raw_spin_lock_irqsave_cond(&irq_controller_lock, flags); if (d->irq >= FIQ_START) { unsigned int data; if (num_online_cpus() > 1) { @@ -124,6 +139,7 @@ static void armctrl_unmask_irq(struct irq_data *d) } else if (d->irq == INTERRUPT_ARM_LOCAL_PMU_FAST) { writel(0xf, __io_address(ARM_LOCAL_PM_ROUTING_SET)); } else { printk("%s: %d\n", __func__, d->irq); BUG(); } + raw_spin_unlock_irqrestore_cond(&irq_controller_lock, flags); } #ifdef CONFIG_OF @@ -333,6 +349,10 @@ static struct irq_chip armctrl_chip = { .irq_mask = armctrl_mask_irq, .irq_unmask = armctrl_unmask_irq, .irq_set_wake = armctrl_set_wake, +#ifdef CONFIG_IPIPE + .irq_hold = armctrl_mask_irq, + .irq_release = armctrl_unmask_irq, +#endif }; /** diff --git a/arch/arm/mach-bcm2709/bcm2708_gpio.c b/arch/arm/mach-bcm2709/bcm2708_gpio.c index c1e9254..49485ab 100644 --- a/arch/arm/mach-bcm2709/bcm2708_gpio.c +++ b/arch/arm/mach-bcm2709/bcm2708_gpio.c @@ -24,6 +24,9 @@ #include #include +#ifdef CONFIG_IPIPE +#include +#endif #define BCM_GPIO_DRIVER_NAME "bcm2708_gpio" #define DRIVER_NAME BCM_GPIO_DRIVER_NAME @@ -56,7 +59,11 @@ enum { GPIO_FSEL_INPUT, GPIO_FSEL_OUTPUT, * the GPIO code. This also makes the case of a GPIO routine call from * the IRQ code simpler. */ -static DEFINE_SPINLOCK(lock); /* GPIO registers */ +#ifdef CONFIG_IPIPE +static IPIPE_DEFINE_SPINLOCK(lock); /* GPIO registers */ +#else +static DEFINE_SPINLOCK(lock); /* GPIO registers */ +#endif struct bcm2708_gpio { struct list_head list; @@ -294,7 +301,11 @@ static irqreturn_t bcm2708_gpio_interrupt(int irq, void *dev_id) if (!(level_bits & (1<