From d293115ed756b0b2912eb62ead1ddee647ec2fee Mon Sep 17 00:00:00 2001 From: Terry Lv Date: Fri, 4 Sep 2009 10:07:20 +0800 Subject: ENGR00116243: I2C support for mx51 3ds board. I2C support for mx51 3ds board. Signed-off-by: Terry Lv --- cpu/arm_cortexa8/mx51/interrupts.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'cpu') diff --git a/cpu/arm_cortexa8/mx51/interrupts.c b/cpu/arm_cortexa8/mx51/interrupts.c index 1277d4e..484b961 100644 --- a/cpu/arm_cortexa8/mx51/interrupts.c +++ b/cpu/arm_cortexa8/mx51/interrupts.c @@ -38,17 +38,30 @@ #define GPTCR_CLKSOURCE_32 (4<<6) /* Clock source */ #define GPTCR_TEN (1) /* Timer enable */ -/* nothing really to do with interrupts, just starts up a counter. */ -int interrupt_init(void) +static inline void setup_gpt() { int i; + static int init_done; + + if (init_done) + return; + + init_done = 1; + /* setup GP Timer 1 */ GPTCR = GPTCR_SWR; for (i = 0; i < 100; i++) - GPTCR = 0; /* We have no udelay by now */ - GPTPR = 0; /* 32Khz */ + GPTCR = 0; /* We have no udelay by now */ + GPTPR = 0; /* 32Khz */ /* Freerun Mode, PERCLK1 input */ GPTCR |= GPTCR_CLKSOURCE_32 | GPTCR_TEN; +} + +/* nothing really to do with interrupts, just starts up a counter. */ +int interrupt_init(void) +{ + setup_gpt(); + return 0; } @@ -84,7 +97,9 @@ void udelay(unsigned long usec) { ulong tmo, tmp; - /* if "big" number, spread normalization to seconds */ + setup_gpt(); + + /* if "big" number, spread normalization to seconds */ if (usec >= 1000) { /* start to normalize for usec to ticks per sec */ tmo = usec / 1000; -- cgit v1.1