Skip to contentSkip to conversation

ARM: Add Versatile Express board model

PATCH Superseded Peter Maydell 3 participants 6 messages Mar 1, 2011

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ARM: Add Versatile Express board model

This patchset adds support for the ARM Versatile Express board with Cortex-A9 daughterboard. It's based on some vexpress modelling work done by Bahadir Balban and Amit Mahajan at B Labs, overhauled and cleaned up by me (thanks to them for making that work available).

The patchset depends on the MMC cleanup work I posted last week:
http://www.mail-archive.com/[email protected]/msg56148.html
as it wants to wire up the MMC status lines.

Peter Maydell (2):
hw/arm_sysctl.c: Add the Versatile Express system registers hw/vexpress.c: Add model of ARM Versatile Express board

 Makefile.target |    1 +
 hw/arm_sysctl.c |   61 ++++++++++++++
 hw/vexpress.c   |  238 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 300 insertions(+), 0 deletions(-)
 create mode 100644 hw/vexpress.c
#1 lore raw

PATCH 1/2 hw/arm_sysctl.c: Add the Versatile Express system registers

Add support for the Versatile Express SYS_CFG registers, which provide a generic means of reading or writing configuration information from various parts of the board. We only implement shutdown and reset.

Also make the RESETCTL register RAZ/WI on Versatile Express rather than reset the board. Other system registers are generally the same as Versatile and Realview.

---
 hw/arm_sysctl.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)
hw/arm_sysctl.c +61 -0
index 799b007..564b512 100644
@@ -27,6 +27,9 @@ typedef struct {
     uint32_t resetlevel;
     uint32_t proc_id;
     uint32_t sys_mci;
+    uint32_t sys_cfgdata;
+    uint32_t sys_cfgctrl;
+    uint32_t sys_cfgstat;
 } arm_sysctl_state;
 
 static const VMStateDescription vmstate_arm_sysctl = {
@@ -41,6 +44,9 @@ static const VMStateDescription vmstate_arm_sysctl = {
         VMSTATE_UINT32(flags, arm_sysctl_state),
         VMSTATE_UINT32(nvflags, arm_sysctl_state),
         VMSTATE_UINT32(resetlevel, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgdata, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgctrl, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgstat, arm_sysctl_state),
         VMSTATE_END_OF_LIST()
     }
 };
@@ -53,6 +59,7 @@ static const VMStateDescription vmstate_arm_sysctl = {
 #define BOARD_ID_EB 0x140
 #define BOARD_ID_PBA8 0x178
 #define BOARD_ID_PBX 0x182
+#define BOARD_ID_VEXPRESS 0x190
 
 static int board_id(arm_sysctl_state *s)
 {
@@ -104,6 +111,10 @@ static uint32_t arm_sysctl_read(void *opaque, target_phys_addr_t offset)
     case 0x38: /* NVFLAGS */
         return s->nvflags;
     case 0x40: /* RESETCTL */
+        if (board_id(s) == BOARD_ID_VEXPRESS) {
+            /* reserved: RAZ/WI */
+            return 0;
+        }
         return s->resetlevel;
     case 0x44: /* PCICTL */
         return 1;
@@ -142,7 +153,23 @@ static uint32_t arm_sysctl_read(void *opaque, target_phys_addr_t offset)
     case 0xcc: /* SYS_TEST_OSC3 */
     case 0xd0: /* SYS_TEST_OSC4 */
         return 0;
+    case 0xa0: /* SYS_CFGDATA */
+        if (board_id(s) != BOARD_ID_VEXPRESS) {
+            goto bad_reg;
+        }
+        return s->sys_cfgdata;
+    case 0xa4: /* SYS_CFGCTRL */
+        if (board_id(s) != BOARD_ID_VEXPRESS) {
+            goto bad_reg;
+        }
+        return s->sys_cfgctrl;
+    case 0xa8: /* SYS_CFGSTAT */
+        if (board_id(s) != BOARD_ID_VEXPRESS) {
+            goto bad_reg;
+        }
+        return s->sys_cfgstat;
     default:
+    bad_reg:
         printf ("arm_sysctl_read: Bad register offset 0x%x\n", (int)offset);
         return 0;
     }
@@ -190,6 +217,10 @@ static void arm_sysctl_write(void *opaque, target_phys_addr_t offset,
         s->nvflags &= ~val;
         break;
     case 0x40: /* RESETCTL */
+        if (board_id(s) == BOARD_ID_VEXPRESS) {
+            /* reserved: RAZ/WI */
+            break;
+        }
         if (s->lockval == LOCK_VALUE) {
             s->resetlevel = val;
             if (val & 0x100)
@@ -216,7 +247,37 @@ static void arm_sysctl_write(void *opaque, target_phys_addr_t offset,
     case 0x98: /* OSCRESET3 */
     case 0x9c: /* OSCRESET4 */
         break;
+    case 0xa0: /* SYS_CFGDATA */
+        if (board_id(s) != BOARD_ID_VEXPRESS) {
+            goto bad_reg;
+        }
+        s->sys_cfgdata = val;
+        return;
+    case 0xa4: /* SYS_CFGCTRL */
+        if (board_id(s) != BOARD_ID_VEXPRESS) {
+            goto bad_reg;
+        }
+        s->sys_cfgctrl = val & ~(3 << 18);
+        s->sys_cfgstat = 1;            /* complete */
+        switch (s->sys_cfgctrl) {
+        case 0xc0800000:            /* SYS_CFG_SHUTDOWN to motherboard */
+            qemu_system_shutdown_request();
+            break;
+        case 0xc0900000:            /* SYS_CFG_REBOOT to motherboard */
+            qemu_system_reset_request();
+            break;
+        default:
+            s->sys_cfgstat |= 2;        /* error */
+        }
+        return;
+    case 0xa8: /* SYS_CFGSTAT */
+        if (board_id(s) != BOARD_ID_VEXPRESS) {
+            goto bad_reg;
+        }
+        s->sys_cfgstat = val & 3;
+        return;
     default:
+    bad_reg:
         printf ("arm_sysctl_write: Bad register offset 0x%x\n", (int)offset);
         return;
     }
Signature · 1 line
1.7.1
#2 lore raw

[Qemu-devel] Re: [PATCH 1/2] hw/arm_sysctl.c: Add the Versatile Express system registers

Peter Maydell <[email protected]> wrote:

Hi

hw/arm_sysctl.c static const VMStateDescription vmstate_arm_sysctl = { · line 52

Quoted 10 lines
hw/arm_sysctl.c +3 -0
@@ -41,6 +44,9 @@ static const VMStateDescription vmstate_arm_sysctl = {
         VMSTATE_UINT32(flags, arm_sysctl_state),
         VMSTATE_UINT32(nvflags, arm_sysctl_state),
         VMSTATE_UINT32(resetlevel, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgdata, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgctrl, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgstat, arm_sysctl_state),
         VMSTATE_END_OF_LIST()
     }
 };

Three options (about migration):
- left things as they are and become incompatible without changing versions
- if you don't care about backward compatibility, just add +1 to all the version fields and you are done.
- add this fields only for the new version.

IMHO 1st one is the worse option. I will go with the middle one (as far as I know, nobody on arm uses interversion migration (as far as I know, nobody uses migration at all).

If you (or anybody else does), a pointer to one setup that is known to work is welcome.

Later, Juan.

#3 lore raw

[Qemu-devel] Re: [PATCH 1/2] hw/arm_sysctl.c: Add the Versatile Express system registers

2011/3/1 Juan Quintela <[email protected]>:

Quoted 21 lines

Peter Maydell <[email protected]> wrote:

Hi

hw/arm_sysctl.c static const VMStateDescription vmstate_arm_sysctl = { · line 52

Quoted 10 lines
hw/arm_sysctl.c +3 -0
@@ -41,6 +44,9 @@ static const VMStateDescription vmstate_arm_sysctl = {
          VMSTATE_UINT32(flags, arm_sysctl_state),
          VMSTATE_UINT32(nvflags, arm_sysctl_state),
          VMSTATE_UINT32(resetlevel, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgdata, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgctrl, arm_sysctl_state),
+        VMSTATE_UINT32(sys_cfgstat, arm_sysctl_state),
          VMSTATE_END_OF_LIST()
      }
  };

Three options (about migration):
- left things as they are and become incompatible without changing versions
- if you don't care about backward compatibility, just add +1 to all the version fields and you are done.
- add this fields only for the new version.

Quoted 3 lines

IMHO 1st one is the worse option.  I will go with the middle one (as far as I know, nobody on arm uses interversion migration (as far as I know, nobody uses migration at all).

OK, so in:
static const VMStateDescription vmstate_arm_sysctl = {
.name = "realview_sysctl",
.version_id = 1,
.minimum_version_id = 1,

I just bump the '1' in both cases to '2' ?

I've only ever used the save/restore for debugging purposes. We know for certain that nobody can have been doing migration with versatile platforms before this year, because we only added save/load support to arm_sysctl.c in December 2010 :-)

(What's the equivalent version-bump that needs to be done when entries are added to target-arm/machine.c's save and restore code?)

thanks
-- PMM

#4 lore raw

PATCH 2/2 hw/vexpress.c: Add model of ARM Versatile Express board

In reply to Peter Maydell

Add a model of the ARM Versatile Express board (with A9MPx4 daughterboard).

---
 Makefile.target |    1 +
 hw/vexpress.c   |  238 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 239 insertions(+), 0 deletions(-)
 create mode 100644 hw/vexpress.c
Makefile.target +1 -0
index 220589e..949bd4e 100644
@@ -315,6 +315,7 @@ obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
 obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
 obj-arm-y += syborg_virtio.o
+obj-arm-y += vexpress.o
 
 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o
hw/vexpress.c new file +238 -0

238 lines not on this page · raw message

Signature · 1 line
1.7.1
#5 lore raw
In reply to Peter Maydell

Thanks Peter for the efforts.

Quoted 19 lines · Peter Maydell

This patchset adds support for the ARM Versatile Express board with Cortex-A9 daughterboard. It's based on some vexpress modelling work done by Bahadir Balban and Amit Mahajan at B Labs, overhauled and cleaned up by me (thanks to them for making that work available).

The patchset depends on the MMC cleanup work I posted last week:
http://www.mail-archive.com/[email protected]/msg56148.html
as it wants to wire up the MMC status lines.

Peter Maydell (2):
hw/arm_sysctl.c: Add the Versatile Express system registers hw/vexpress.c: Add model of ARM Versatile Express board

 Makefile.target |    1 +
 hw/arm_sysctl.c |   61 ++++++++++++++
 hw/vexpress.c   |  238 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 300 insertions(+), 0 deletions(-)
 create mode 100644 hw/vexpress.c
Signature · 2 lines
Thanks
Amit Mahajan