All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] hw/xtensa: xtfpga board improvements
@ 2019-01-22 22:12 Max Filippov
  2019-01-22 22:12 ` [Qemu-devel] [PATCH 1/2] hw/xtensa: xtfpga: fix bootloader placement in SMP Max Filippov
  2019-01-22 22:12 ` [Qemu-devel] [PATCH 2/2] hw/xtensa: xtfpga: use core frequency Max Filippov
  0 siblings, 2 replies; 3+ messages in thread
From: Max Filippov @ 2019-01-22 22:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov

Hello,

this series adds two improvements for the XTFPGA board:
- use BSP core reset vector to place mini bootloader, because AP
  cores may have different reset vector address;
- expose actual core frequency in the FPGA register instead of the
  fixed 10MHz value.

Max Filippov (2):
  hw/xtensa: xtfpga: fix bootloader placement in SMP
  hw/xtensa: xtfpga: use core frequency

 hw/xtensa/xtfpga.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH 1/2] hw/xtensa: xtfpga: fix bootloader placement in SMP
  2019-01-22 22:12 [Qemu-devel] [PATCH 0/2] hw/xtensa: xtfpga board improvements Max Filippov
@ 2019-01-22 22:12 ` Max Filippov
  2019-01-22 22:12 ` [Qemu-devel] [PATCH 2/2] hw/xtensa: xtfpga: use core frequency Max Filippov
  1 sibling, 0 replies; 3+ messages in thread
From: Max Filippov @ 2019-01-22 22:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov

Use BSP reset PC as a place for the mini-bootloader because in SMP
configurations APs and BSP may have different boot addresses.
This fixes SMP linux uImage boot on xtfpga boards.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 hw/xtensa/xtfpga.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 21094319a659..d3afdfc247a7 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -234,10 +234,15 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
     int n;
 
     for (n = 0; n < smp_cpus; n++) {
+        CPUXtensaState *cenv = NULL;
+
         cpu = XTENSA_CPU(cpu_create(machine->cpu_type));
-        env = &cpu->env;
+        cenv = &cpu->env;
+        if (!env) {
+            env = cenv;
+        }
 
-        env->sregs[PRID] = n;
+        cenv->sregs[PRID] = n;
         qemu_register_reset(xtfpga_reset, cpu);
         /* Need MMU initialized prior to ELF loading,
          * so that ELF gets loaded into virtual addresses
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH 2/2] hw/xtensa: xtfpga: use core frequency
  2019-01-22 22:12 [Qemu-devel] [PATCH 0/2] hw/xtensa: xtfpga board improvements Max Filippov
  2019-01-22 22:12 ` [Qemu-devel] [PATCH 1/2] hw/xtensa: xtfpga: fix bootloader placement in SMP Max Filippov
@ 2019-01-22 22:12 ` Max Filippov
  1 sibling, 0 replies; 3+ messages in thread
From: Max Filippov @ 2019-01-22 22:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: Max Filippov

XTFPGA board FPGA peripheral exposes hard-coded 10MHz frequency
regardless of the actual used core frequency. Expose actual core
frequency instead.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 hw/xtensa/xtfpga.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index d3afdfc247a7..7379b3fff427 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -61,6 +61,7 @@ typedef struct XtfpgaBoardDesc {
 
 typedef struct XtfpgaFpgaState {
     MemoryRegion iomem;
+    uint32_t freq;
     uint32_t leds;
     uint32_t switches;
 } XtfpgaFpgaState;
@@ -83,7 +84,7 @@ static uint64_t xtfpga_fpga_read(void *opaque, hwaddr addr,
         return 0x09272011;
 
     case 0x4: /*processor clock frequency, Hz*/
-        return 10000000;
+        return s->freq;
 
     case 0x8: /*LEDs (off = 0, on = 1)*/
         return s->leds;
@@ -119,13 +120,14 @@ static const MemoryRegionOps xtfpga_fpga_ops = {
 };
 
 static XtfpgaFpgaState *xtfpga_fpga_init(MemoryRegion *address_space,
-        hwaddr base)
+                                         hwaddr base, uint32_t freq)
 {
     XtfpgaFpgaState *s = g_malloc(sizeof(XtfpgaFpgaState));
 
     memory_region_init_io(&s->iomem, NULL, &xtfpga_fpga_ops, s,
-            "xtfpga.fpga", 0x10000);
+                          "xtfpga.fpga", 0x10000);
     memory_region_add_subregion(address_space, base, &s->iomem);
+    s->freq = freq;
     xtfpga_fpga_reset(s);
     qemu_register_reset(xtfpga_fpga_reset, s);
     return s;
@@ -231,6 +233,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
     const char *dtb_filename = qemu_opt_get(machine_opts, "dtb");
     const char *initrd_filename = qemu_opt_get(machine_opts, "initrd");
     const unsigned system_io_size = 224 * MiB;
+    uint32_t freq = 10000000;
     int n;
 
     for (n = 0; n < smp_cpus; n++) {
@@ -240,6 +243,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
         cenv = &cpu->env;
         if (!env) {
             env = cenv;
+            freq = env->config->clock_freq_khz * 1000;
         }
 
         cenv->sregs[PRID] = n;
@@ -277,7 +281,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine)
                                  system_io, 0, system_io_size);
         memory_region_add_subregion(system_memory, board->io[1], io);
     }
-    xtfpga_fpga_init(system_io, 0x0d020000);
+    xtfpga_fpga_init(system_io, 0x0d020000, freq);
     if (nd_table[0].used) {
         xtfpga_net_init(system_io, 0x0d030000, 0x0d030400, 0x0d800000,
                 xtensa_get_extint(env, 1), nd_table);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-22 22:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-22 22:12 [Qemu-devel] [PATCH 0/2] hw/xtensa: xtfpga board improvements Max Filippov
2019-01-22 22:12 ` [Qemu-devel] [PATCH 1/2] hw/xtensa: xtfpga: fix bootloader placement in SMP Max Filippov
2019-01-22 22:12 ` [Qemu-devel] [PATCH 2/2] hw/xtensa: xtfpga: use core frequency Max Filippov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.