From 27111d83be815602ac35354e6a8e4e158c5968f9 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Sat, 26 Oct 2013 17:34:58 +0200 Subject: [PATCH] hwstub: fix stmp3600 The microseconds register has a different address Change-Id: I29d2e7feea9eb34b0d539ee217babd092542b612 --- utils/hwstub/stub/stmp/target.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/utils/hwstub/stub/stmp/target.c b/utils/hwstub/stub/stmp/target.c index 9b005063bd..55cb344955 100644 --- a/utils/hwstub/stub/stmp/target.c +++ b/utils/hwstub/stub/stmp/target.c @@ -144,7 +144,10 @@ void clkctrl_reset(void) #define HW_DIGCTL_CTRL (*(volatile uint32_t *)(HW_DIGCTL_BASE + 0)) #define HW_DIGCTL_CTRL__USB_CLKGATE (1 << 2) +/* STMP3700+ */ #define HW_DIGCTL_MICROSECONDS (*(volatile uint32_t *)(HW_DIGCTL_BASE + 0xC0)) +/* STMP3600 */ +#define HW_DIGCTL_MICROSECONDS2 (*(volatile uint32_t *)(HW_DIGCTL_BASE + 0xB0)) #define HW_DIGCTL_CHIPID (*(volatile uint32_t *)(HW_DIGCTL_BASE + 0x310)) #define HW_DIGCTL_CHIPID__PRODUCT_CODE_BP 16 @@ -276,12 +279,13 @@ void target_exit(void) void target_udelay(int us) { - uint32_t cur = HW_DIGCTL_MICROSECONDS; + volatile uint32_t *reg = g_stmp_family == STMP3600 ? &HW_DIGCTL_MICROSECONDS2 : &HW_DIGCTL_MICROSECONDS; + uint32_t cur = *reg; uint32_t end = cur + us; if(cur < end) - while(HW_DIGCTL_MICROSECONDS < end) {} + while(*reg < end) {} else - while(HW_DIGCTL_MICROSECONDS >= cur) {} + while(*reg >= cur) {} } void target_mdelay(int ms)