Skip to content
Snippets Groups Projects
Commit b54384e3 authored by Jean-Christophe PLAGNIOL-VILLARD's avatar Jean-Christophe PLAGNIOL-VILLARD Committed by Wolfgang Denk
Browse files

arm: timer and interrupt init rework


actually the timer init use the interrupt_init as init callback
which make the interrupt and timer implementation difficult to follow

so now rename it as int timer_init(void) and use interrupt_init for interrupt

btw also remane the corresponding file to the functionnality implemented

as ixp arch implement two timer - one based on interrupt - so all the timer
related code is moved to timer.c

Signed-off-by: default avatarJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
parent 5b4bebe1
No related branches found
No related tags found
No related merge requests found
Showing
with 51 additions and 48 deletions
...@@ -540,7 +540,7 @@ static ulong div_timer = 1; /* Divisor to convert timer reading ...@@ -540,7 +540,7 @@ static ulong div_timer = 1; /* Divisor to convert timer reading
* - the Integrator/AP timer issues an interrupt * - the Integrator/AP timer issues an interrupt
* each time it reaches zero * each time it reaches zero
*/ */
int interrupt_init (void) int timer_init (void)
{ {
/* Load timer with initial value */ /* Load timer with initial value */
*(volatile ulong *)(CONFIG_SYS_TIMERBASE + 0) = TIMER_LOAD_VAL; *(volatile ulong *)(CONFIG_SYS_TIMERBASE + 0) = TIMER_LOAD_VAL;
......
...@@ -163,7 +163,7 @@ static ulong timestamp; /* U-Boot ticks since startup */ ...@@ -163,7 +163,7 @@ static ulong timestamp; /* U-Boot ticks since startup */
/* starts up a counter /* starts up a counter
* - the Integrator/CP timer can be set up to issue an interrupt */ * - the Integrator/CP timer can be set up to issue an interrupt */
int interrupt_init (void) int timer_init (void)
{ {
/* Load timer with initial value */ /* Load timer with initial value */
*(volatile ulong *)(CONFIG_SYS_TIMERBASE + 0) = TIMER_LOAD_VAL; *(volatile ulong *)(CONFIG_SYS_TIMERBASE + 0) = TIMER_LOAD_VAL;
......
...@@ -61,7 +61,6 @@ static void at91cap9_slowclock_hw_init(void) ...@@ -61,7 +61,6 @@ static void at91cap9_slowclock_hw_init(void)
if (at91_sys_read(AT91_PMC_VER) == ARCH_ID_AT91CAP9_REVC) { if (at91_sys_read(AT91_PMC_VER) == ARCH_ID_AT91CAP9_REVC) {
unsigned i, tmp = at91_sys_read(AT91_SCKCR); unsigned i, tmp = at91_sys_read(AT91_SCKCR);
if ((tmp & AT91CAP9_SCKCR_OSCSEL) == AT91CAP9_SCKCR_OSCSEL_RC) { if ((tmp & AT91CAP9_SCKCR_OSCSEL) == AT91CAP9_SCKCR_OSCSEL_RC) {
extern void timer_init(void);
timer_init(); timer_init();
tmp |= AT91CAP9_SCKCR_OSC32EN; tmp |= AT91CAP9_SCKCR_OSC32EN;
at91_sys_write(AT91_SCKCR, tmp); at91_sys_write(AT91_SCKCR, tmp);
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#ifndef __MISC_H #ifndef __MISC_H
#define __MISC_H #define __MISC_H
extern void timer_init(void);
extern int eth_hw_init(void); extern int eth_hw_init(void);
void dv_display_clk_infos(void); void dv_display_clk_infos(void);
......
...@@ -127,7 +127,7 @@ int board_init(void) ...@@ -127,7 +127,7 @@ int board_init(void)
m501sk_gpio_init(); m501sk_gpio_init();
/* Do interrupt init here, because flash needs timers */ /* Do interrupt init here, because flash needs timers */
interrupt_init(); timer_init();
flash_init(); flash_init();
return 0; return 0;
......
...@@ -48,7 +48,7 @@ int dram_init(void) ...@@ -48,7 +48,7 @@ int dram_init(void)
/* Take the Ethernet controller out of reset and wait /* Take the Ethernet controller out of reset and wait
* for the EEPROM load to complete. */ * for the EEPROM load to complete. */
*((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80; *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80;
udelay(10); /* doesn't work before interrupt_init call */ udelay(10); /* doesn't work before timer_init call */
*((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80; *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80;
udelay(500); udelay(500);
......
...@@ -43,7 +43,7 @@ int dram_init(void) ...@@ -43,7 +43,7 @@ int dram_init(void)
/* Take the Ethernet controller out of reset and wait /* Take the Ethernet controller out of reset and wait
* for the EEPROM load to complete. */ * for the EEPROM load to complete. */
*((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80; *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80;
udelay(10); /* doesn't work before interrupt_init call */ udelay(10); /* doesn't work before timer_init call */
*((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80; *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80;
udelay(500); udelay(500);
......
...@@ -25,7 +25,8 @@ include $(TOPDIR)/config.mk ...@@ -25,7 +25,8 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a LIB = $(obj)lib$(SOC).a
COBJS = interrupts.o generic.o COBJS += generic.o
COBJS += timer.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
......
...@@ -89,9 +89,8 @@ static inline unsigned long long us_to_tick(unsigned long long us) ...@@ -89,9 +89,8 @@ static inline unsigned long long us_to_tick(unsigned long long us)
} }
#endif #endif
/* nothing really to do with interrupts, just starts up a counter. */
/* The 32768Hz 32-bit timer overruns in 131072 seconds */ /* The 32768Hz 32-bit timer overruns in 131072 seconds */
int interrupt_init (void) int timer_init (void)
{ {
int i; int i;
......
...@@ -25,9 +25,10 @@ include $(TOPDIR)/config.mk ...@@ -25,9 +25,10 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a LIB = $(obj)lib$(SOC).a
COBJS = interrupts.o
SOBJS = start.o SOBJS = start.o
COBJS = timer.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
......
...@@ -42,8 +42,7 @@ ...@@ -42,8 +42,7 @@
static ulong timestamp; static ulong timestamp;
static ulong lastinc; static ulong lastinc;
/* nothing really to do with interrupts, just starts up a counter. */ int timer_init (void)
int interrupt_init (void)
{ {
int32_t val; int32_t val;
......
...@@ -28,8 +28,8 @@ include $(TOPDIR)/config.mk ...@@ -28,8 +28,8 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a LIB = $(obj)lib$(SOC).a
COBJS-y = interrupts.o
COBJS-$(CONFIG_S3C6400) += cpu_init.o speed.o COBJS-$(CONFIG_S3C6400) += cpu_init.o speed.o
COBJS-y += timer.o
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
......
...@@ -66,7 +66,7 @@ static unsigned long lastdec; ...@@ -66,7 +66,7 @@ static unsigned long lastdec;
/* Monotonic incrementing timer */ /* Monotonic incrementing timer */
static unsigned long long timestamp; static unsigned long long timestamp;
int interrupt_init(void) int timer_init(void)
{ {
s3c64xx_timers *const timers = s3c64xx_get_base_timers(); s3c64xx_timers *const timers = s3c64xx_get_base_timers();
......
...@@ -110,9 +110,34 @@ static void timer_isr( void *data) { ...@@ -110,9 +110,34 @@ static void timer_isr( void *data) {
static ulong timestamp; static ulong timestamp;
static ulong lastdec; static ulong lastdec;
#if defined(CONFIG_USE_IRQ) && defined(CONFIG_S3C4510B)
int interrupt_init (void) int 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 *)&timestamp;
IRQ_HANDLER[INT_TIMER0].m_func = timer_isr;
return 0;
}
#endif
int timer_init (void)
{
#if defined(CONFIG_NETARM) #if defined(CONFIG_NETARM)
/* disable all interrupts */ /* disable all interrupts */
IRQEN = 0; IRQEN = 0;
...@@ -137,25 +162,6 @@ int interrupt_init (void) ...@@ -137,25 +162,6 @@ int interrupt_init (void)
/* set timer 1 counter */ /* set timer 1 counter */
lastdec = IO_TC1D = TIMER_LOAD_VAL; lastdec = IO_TC1D = TIMER_LOAD_VAL;
#elif defined(CONFIG_S3C4510B) #elif defined(CONFIG_S3C4510B)
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 *)&timestamp;
IRQ_HANDLER[INT_TIMER0].m_func = timer_isr;
/* configure free running timer 0 */ /* configure free running timer 0 */
PUT_REG( REG_TMOD, 0x0); PUT_REG( REG_TMOD, 0x0);
/* Stop timer 0 */ /* Stop timer 0 */
...@@ -187,7 +193,7 @@ int interrupt_init (void) ...@@ -187,7 +193,7 @@ int interrupt_init (void)
PUT32(T0TCR, 1); /* enable timer0 */ PUT32(T0TCR, 1); /* enable timer0 */
#else #else
#error No interrupt_init() defined for this CPU type #error No timer_init() defined for this CPU type
#endif #endif
timestamp = 0; timestamp = 0;
......
...@@ -31,10 +31,10 @@ COBJS += bcm5221.o ...@@ -31,10 +31,10 @@ COBJS += bcm5221.o
COBJS += dm9161.o COBJS += dm9161.o
COBJS += ether.o COBJS += ether.o
COBJS += i2c.o COBJS += i2c.o
COBJS += interrupts.o
COBJS += lxt972.o COBJS += lxt972.o
COBJS += reset.o COBJS += reset.o
COBJS += spi.o COBJS += spi.o
COBJS += timer.o
COBJS += usb.o COBJS += usb.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
......
...@@ -45,7 +45,7 @@ AT91PS_TC tmr; ...@@ -45,7 +45,7 @@ AT91PS_TC tmr;
static ulong timestamp; static ulong timestamp;
static ulong lastinc; static ulong lastinc;
int interrupt_init (void) int timer_init (void)
{ {
tmr = AT91C_BASE_TC0; tmr = AT91C_BASE_TC0;
......
...@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk ...@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a LIB = $(obj)lib$(SOC).a
COBJS = generic.o interrupts.o speed.o COBJS += generic.o
COBJS += speed.o
COBJS += timer.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <arm920t.h> #include <arm920t.h>
#include <asm/arch/imx-regs.h> #include <asm/arch/imx-regs.h>
int interrupt_init (void) int timer_init (void)
{ {
int i; int i;
/* setup GP Timer 1 */ /* setup GP Timer 1 */
......
...@@ -25,9 +25,10 @@ include $(TOPDIR)/config.mk ...@@ -25,9 +25,10 @@ include $(TOPDIR)/config.mk
LIB = $(obj)lib$(SOC).a LIB = $(obj)lib$(SOC).a
COBJS = interrupts.o
SOBJS = lowlevel_init.o SOBJS = lowlevel_init.o
COBJS = timer.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
......
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
#define ks8695_read(a) *((volatile ulong *) (KS8695_IO_BASE + (a))) #define ks8695_read(a) *((volatile ulong *) (KS8695_IO_BASE + (a)))
#define ks8695_write(a,v) *((volatile ulong *) (KS8695_IO_BASE + (a))) = (v) #define ks8695_write(a,v) *((volatile ulong *) (KS8695_IO_BASE + (a))) = (v)
int timer_inited;
ulong timer_ticks; ulong timer_ticks;
int interrupt_init (void) int timer_init (void)
{ {
/* nothing happens here - we don't setup any IRQs */ reset_timer();
return (0);
return 0;
} }
/* /*
...@@ -53,7 +53,6 @@ void reset_timer_masked(void) ...@@ -53,7 +53,6 @@ void reset_timer_masked(void)
ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE); ks8695_write(KS8695_TIMER1_PCOUNT, TIMER_PULSE);
ks8695_write(KS8695_TIMER_CTRL, 0x2); ks8695_write(KS8695_TIMER_CTRL, 0x2);
timer_ticks = 0; timer_ticks = 0;
timer_inited++;
} }
void reset_timer(void) void reset_timer(void)
...@@ -87,9 +86,6 @@ void udelay(ulong usec) ...@@ -87,9 +86,6 @@ void udelay(ulong usec)
ulong start = get_timer_masked(); ulong start = get_timer_masked();
ulong end; ulong end;
if (!timer_inited)
reset_timer();
/* Only 1ms resolution :-( */ /* Only 1ms resolution :-( */
end = usec / 1000; end = usec / 1000;
while (get_timer(start) < end) while (get_timer(start) < end)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment