@@ -1,3 +1,6 @@
+.cproject
+.project
+.settings
config-devices.*
config-all-devices.*
config-host.*
@@ -394,27 +394,26 @@ static uint32_t pllcfg_fury[16] = {
#define DID0_CLASS_MASK 0x00FF0000
#define DID0_CLASS_SANDSTORM 0x00000000
#define DID0_CLASS_FURY 0x00010000
+#define DID0_CLASS_UNKNOWN 0xFFFFFFFF
-static bool ssys_is_sandstorm(ssys_state *s)
+static int ssys_board_class(const ssys_state *s)
{
uint32_t did0 = s->board->did0;
-
switch (did0 & DID0_VER_MASK) {
case DID0_VER_0:
- return 1;
+ return DID0_CLASS_SANDSTORM;
case DID0_VER_1:
- return ((did0 & DID0_CLASS_MASK) == DID0_CLASS_SANDSTORM);
+ switch (did0 & DID0_CLASS_MASK) {
+ case DID0_CLASS_SANDSTORM:
+ case DID0_CLASS_FURY:
+ return did0 & DID0_CLASS_MASK;
+ }
+ /* Unless the class is not known so far, fall to default: */
default:
- return 0;
+ hw_error("ssys_board_class: Unknown class 0x%08x\n", did0);
}
-}
-
-static bool ssys_is_fury(ssys_state *s)
-{
- uint32_t did0 = s->board->did0;
-
- return (((did0 & DID0_VER_MASK) == DID0_VER_1)
- && ((did0 & DID0_CLASS_MASK) == DID0_CLASS_FURY));
+ /* we should be abort()ed by now */
+ return DID0_CLASS_UNKNOWN;
}
static uint32_t ssys_read(void *opaque, target_phys_addr_t offset)
@@ -460,10 +459,14 @@ static uint32_t ssys_read(void *opaque, target_phys_addr_t offset)
{
int xtal;
xtal = (s->rcc >> 6) & 0xf;
- if (ssys_is_fury(s)) {
+ switch (ssys_board_class(s)) {
+ case DID0_CLASS_FURY:
return pllcfg_fury[xtal];
- } else {
+ case DID0_CLASS_SANDSTORM:
return pllcfg_sandstorm[xtal];
+ default:
+ hw_error("ssys_read: Unhandled class for PLLCFG read.\n");
+ return 0;
}
}
case 0x070: /* RCC2 */
@@ -551,7 +554,7 @@ static void ssys_write(void *opaque, target_phys_addr_t offset, uint32_t value)
ssys_calculate_system_clock(s);
break;
case 0x070: /* RCC2 */
- if (ssys_is_sandstorm(s)) {
+ if (ssys_board_class(s) == DID0_CLASS_SANDSTORM) {
break;
}
@@ -620,7 +623,7 @@ static void ssys_reset(void *opaque)
s->pborctl = 0x7ffd;
s->rcc = 0x078e3ac0;
- if (ssys_is_sandstorm(s)) {
+ if (ssys_board_class(s) == DID0_CLASS_SANDSTORM) {
s->rcc2 = 0;
} else {
s->rcc2 = 0x07802810;
Cc: vijaykumar@bravegnu.org Signed-off-by: Engin AYDOGAN <engin@bzzzt.biz> --- .gitignore | 3 +++ hw/stellaris.c | 37 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-)