diff options
Diffstat (limited to 'cpu')
-rw-r--r-- | cpu/arm_cortexa8/omap3/sys_info.c | 26 | ||||
-rw-r--r-- | cpu/pxa/interrupts.c | 46 |
2 files changed, 50 insertions, 22 deletions
diff --git a/cpu/arm_cortexa8/omap3/sys_info.c b/cpu/arm_cortexa8/omap3/sys_info.c index 28a1020..b385b91 100644 --- a/cpu/arm_cortexa8/omap3/sys_info.c +++ b/cpu/arm_cortexa8/omap3/sys_info.c @@ -36,6 +36,32 @@ static gpmc_csx_t *gpmc_cs_base = (gpmc_csx_t *)GPMC_CONFIG_CS0_BASE; static sdrc_t *sdrc_base = (sdrc_t *)OMAP34XX_SDRC_BASE; static ctrl_t *ctrl_base = (ctrl_t *)OMAP34XX_CTRL_BASE; +/***************************************************************** + * dieid_num_r(void) - read and set die ID + *****************************************************************/ +void dieid_num_r(void) +{ + ctrl_id_t *id_base = (ctrl_id_t *)OMAP34XX_ID_L4_IO_BASE; + char *uid_s, die_id[34]; + u32 id[4]; + + memset(die_id, 0, sizeof(die_id)); + + uid_s = getenv("dieid#"); + + if (uid_s == NULL) { + id[3] = readl(&id_base->die_id_0); + id[2] = readl(&id_base->die_id_1); + id[1] = readl(&id_base->die_id_2); + id[0] = readl(&id_base->die_id_3); + sprintf(die_id, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]); + setenv("dieid#", die_id); + uid_s = die_id; + } + + printf("Die ID #%s\n", uid_s); +} + /****************************************** * get_cpu_type(void) - extract cpu info ******************************************/ diff --git a/cpu/pxa/interrupts.c b/cpu/pxa/interrupts.c index 40d8bf2..2bc5c50 100644 --- a/cpu/pxa/interrupts.c +++ b/cpu/pxa/interrupts.c @@ -28,6 +28,7 @@ #include <common.h> #include <asm/arch/pxa-regs.h> +#include <div64.h> #ifdef CONFIG_USE_IRQ #error: interrupts not implemented yet @@ -41,6 +42,20 @@ #error "Timer frequency unknown - please config PXA CPU type" #endif +static inline unsigned long long tick_to_time(unsigned long long tick) +{ + tick *= CONFIG_SYS_HZ; + do_div(tick, TIMER_FREQ_HZ); + return tick; +} + +static inline unsigned long long us_to_tick(unsigned long long us) +{ + us = us * TIMER_FREQ_HZ + 999999; + do_div(us, 1000000); + return us; +} + int interrupt_init (void) { /* nothing happens here - we don't setup any IRQs */ @@ -75,33 +90,20 @@ void reset_timer_masked (void) ulong get_timer_masked (void) { - unsigned long long ticks = get_ticks(); - - return (((ticks / TIMER_FREQ_HZ) * 1000) + - ((ticks % TIMER_FREQ_HZ) * 1000) / TIMER_FREQ_HZ); + return tick_to_time(get_ticks()); } void udelay_masked (unsigned long usec) { + unsigned long long tmp; ulong tmo; - ulong endtime; - signed long diff; - - if (usec >= 1000) { - tmo = usec / 1000; - tmo *= TIMER_FREQ_HZ; - tmo /= 1000; - } else { - tmo = usec * TIMER_FREQ_HZ; - tmo /= (1000*1000); - } - - endtime = get_ticks() + tmo; - - do { - ulong now = get_ticks(); - diff = endtime - now; - } while (diff >= 0); + + tmo = us_to_tick(usec); + tmp = get_ticks() + tmo; /* get current timestamp */ + + while (get_ticks() < tmp) /* loop till event */ + /*NOP*/; + } /* |