From: Jean-Christophe PLAGNIOL-VILLARD Date: Sat, 9 May 2009 15:35:15 +0200 Subject: [U-Boot] [PATCH 3/6] s3c4510b: move interrupts code to soc In-Reply-To: <1241876118-27469-2-git-send-email-plagnioj@jcrosoft.com> References: <1241876118-27469-1-git-send-email-plagnioj@jcrosoft.com> <1241876118-27469-2-git-send-email-plagnioj@jcrosoft.com> Message-ID: <1241876118-27469-3-git-send-email-plagnioj@jcrosoft.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- applied to arm/testing Best Regards, J. cpu/arm720t/Makefile | 4 +- cpu/arm720t/s3c4510b/Makefile | 1 + cpu/arm720t/s3c4510b/interrupts.c | 85 +++++++++++++++++++++++++++++++++ cpu/arm720t/{interrupts.c => timer.c} | 74 ++++------------------------- 4 files changed, 98 insertions(+), 66 deletions(-) create mode 100644 cpu/arm720t/s3c4510b/interrupts.c rename cpu/arm720t/{interrupts.c => timer.c} (78%) diff --git a/cpu/arm720t/Makefile b/cpu/arm720t/Makefile index d5ac7d3..3e9b45a 100644 --- a/cpu/arm720t/Makefile +++ b/cpu/arm720t/Makefile @@ -26,7 +26,9 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(CPU).a START = start.o -COBJS = interrupts.o cpu.o + +COBJS += cpu.o +COBJS += timer.o SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS)) diff --git a/cpu/arm720t/s3c4510b/Makefile b/cpu/arm720t/s3c4510b/Makefile index c099036..91e27fd 100644 --- a/cpu/arm720t/s3c4510b/Makefile +++ b/cpu/arm720t/s3c4510b/Makefile @@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).a COBJS-y += cache.o +COBJS-y += interrupts.o SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) diff --git a/cpu/arm720t/s3c4510b/interrupts.c b/cpu/arm720t/s3c4510b/interrupts.c new file mode 100644 index 0000000..f543569 --- /dev/null +++ b/cpu/arm720t/s3c4510b/interrupts.c @@ -0,0 +1,85 @@ +/* + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH + * Marius Groeger + * + * (C) Copyright 2002 + * Sysgo Real-Time Solutions, GmbH + * Alex Zuepke + * + * See file CREDITS for list of people who contributed to this + * project. + * + * 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 +#include +#include +#include + +# ifndef CONFIG_USE_IRQ +# error CONFIG_USE_IRQ _must_ be defined when using CONFIG_S3C4510B +# endif + +static struct _irq_handler IRQ_HANDLER[N_IRQS]; + +void do_irq (struct pt_regs *pt_regs) +{ + unsigned int pending; + + while ( (pending = GET_REG( REG_INTOFFSET)) != 0x54) { /* sentinal value for no pending interrutps */ + IRQ_HANDLER[pending>>2].m_func( IRQ_HANDLER[pending>>2].m_data); + + /* clear pending interrupt */ + PUT_REG( REG_INTPEND, (1<<(pending>>2))); + } +} + +static void default_isr( void *data) { + printf ("default_isr(): called for IRQ %d\n", (int)data); +} + +void irq_install_handler (int irq, interrupt_handler_t handle_irq, void *data) +{ + if (irq >= N_IRQS || !handle_irq) + return; + + IRQ_HANDLER[irq].m_data = data; + IRQ_HANDLER[irq].m_func = handle_irq; +} + +int arch_interrupt_init (void) +{ + int i; + + /* install default interrupt handlers */ + for (i = 0; i < N_IRQS; i++) + irq_install_handler(i, default_isr, (void *)i); + + /* configure interrupts for IRQ mode */ + PUT_REG( REG_INTMODE, 0x0); + /* clear any pending interrupts */ + PUT_REG( REG_INTPEND, 0x1FFFFF); + + /* + * Enable global interrupt + * Enable timer0 interrupt + */ + CLR_REG( REG_INTMASK, ((1<>2].m_func( IRQ_HANDLER[pending>>2].m_data); - - /* clear pending interrupt */ - PUT_REG( REG_INTPEND, (1<<(pending>>2))); - } -#elif defined(CONFIG_INTEGRATOR) && defined(CONFIG_ARCH_INTEGRATOR) - /* No do_irq() for IntegratorAP/CM720T as yet */ -#elif defined(CONFIG_LPC2292) - void (*pfnct)(void); pfnct = (void (*)(void))VICVectAddr; (*pfnct)(); -#else -#error do_irq() not defined for this CPU type -#endif } #endif -#ifdef CONFIG_S3C4510B -static void default_isr( void *data) { - printf ("default_isr(): called for IRQ %d\n", (int)data); -} +#if defined(CONFIG_INTEGRATOR) && defined(CONFIG_ARCH_INTEGRATOR) + /* Use IntegratorAP routines in board/integratorap.c */ +#else +#if defined(CONFIG_S3C4510B) static void timer_isr( void *data) { unsigned int *pTime = (unsigned int *)data; @@ -103,39 +78,9 @@ static void timer_isr( void *data) { } #endif -#if defined(CONFIG_INTEGRATOR) && defined(CONFIG_ARCH_INTEGRATOR) - /* Use IntegratorAP routines in board/integratorap.c */ -#else - static ulong timestamp; static ulong lastdec; -#if defined(CONFIG_USE_IRQ) && defined(CONFIG_S3C4510B) -int arch_interrupt_init (void) -{ - int i; - - /* install default interrupt handlers */ - for ( i = 0; i < N_IRQS; i++) { - IRQ_HANDLER[i].m_data = (void *)i; - IRQ_HANDLER[i].m_func = default_isr; - } - - /* configure interrupts for IRQ mode */ - PUT_REG( REG_INTMODE, 0x0); - /* clear any pending interrupts */ - PUT_REG( REG_INTPEND, 0x1FFFFF); - - lastdec = 0; - - /* install interrupt handler for timer */ - IRQ_HANDLER[INT_TIMER0].m_data = (void *)×tamp; - IRQ_HANDLER[INT_TIMER0].m_func = timer_isr; - - return 0; -} -#endif - int timer_init (void) { #if defined(CONFIG_NETARM) @@ -176,11 +121,10 @@ int timer_init (void) */ PUT_REG( REG_TDATA0, (CONFIG_SYS_SYS_CLK_FREQ / CONFIG_SYS_HZ)); - /* - * Enable global interrupt - * Enable timer0 interrupt - */ - CLR_REG( REG_INTMASK, ((1<