diff mbox

[2/3] target-xtensa: xtfpga: attach FLASH to system IO

Message ID 1443374214-27149-3-git-send-email-jcmvbkbc@gmail.com
State New
Headers show

Commit Message

Max Filippov Sept. 27, 2015, 5:16 p.m. UTC
XTFPGA FLASH is tied to XTFPGA system IO block. It's not very important
for systems with MMU where system IO block is visible at single
location, but it's important for noMMU systems, where system IO block is
accessible through two separate physical address ranges.

Map XTFPGA FLASH to system IO block and fix offsets used for mapping.

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

Comments

Peter Crosthwaite Sept. 27, 2015, 5:42 p.m. UTC | #1
On Sun, Sep 27, 2015 at 10:16 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> XTFPGA FLASH is tied to XTFPGA system IO block. It's not very important
> for systems with MMU where system IO block is visible at single
> location,

Are your relying on a matching change in the guest for MMU setup here?
Can you explain a little more how the MMU allows a physical address
remap of the underlying hardware as this looks like a non
backwards-compatible board design rev.

Regards,
Peter

but it's important for noMMU systems, where system IO block is
> accessible through two separate physical address ranges.
>
> Map XTFPGA FLASH to system IO block and fix offsets used for mapping.
>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  hw/xtensa/xtfpga.c | 24 ++++++++++++++----------
>  1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
> index 72350f1..d4b9afb 100644
> --- a/hw/xtensa/xtfpga.c
> +++ b/hw/xtensa/xtfpga.c
> @@ -247,16 +247,20 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
>
>      dinfo = drive_get(IF_PFLASH, 0, 0);
>      if (dinfo) {
> -        flash = pflash_cfi01_register(board->flash_base,
> -                NULL, "lx60.io.flash", board->flash_size,
> -                blk_by_legacy_dinfo(dinfo),
> -                board->flash_sector_size,
> -                board->flash_size / board->flash_sector_size,
> -                4, 0x0000, 0x0000, 0x0000, 0x0000, be);
> +        SysBusDevice *s;
> +
> +        flash = pflash_cfi01_init(NULL, "lx60.io.flash", board->flash_size,
> +                                  blk_by_legacy_dinfo(dinfo),
> +                                  board->flash_sector_size,
> +                                  board->flash_size / board->flash_sector_size,
> +                                  4, 0x0000, 0x0000, 0x0000, 0x0000, be);
>          if (flash == NULL) {
>              error_report("unable to mount pflash");
>              exit(EXIT_FAILURE);
>          }
> +        s = SYS_BUS_DEVICE(flash);
> +        memory_region_add_subregion(system_io, board->flash_base,
> +                                    sysbus_mmio_get_region(s, 0));
>      }
>
>      /* Use presence of kernel file name as 'boot from SRAM' switch. */
> @@ -386,7 +390,7 @@ static void lx_init(const LxBoardDesc *board, MachineState *machine)
>  static void xtensa_lx60_init(MachineState *machine)
>  {
>      static const LxBoardDesc lx60_board = {
> -        .flash_base = 0xf8000000,
> +        .flash_base = 0x08000000,
>          .flash_size = 0x00400000,
>          .flash_sector_size = 0x10000,
>          .sram_size = 0x20000,
> @@ -397,7 +401,7 @@ static void xtensa_lx60_init(MachineState *machine)
>  static void xtensa_lx200_init(MachineState *machine)
>  {
>      static const LxBoardDesc lx200_board = {
> -        .flash_base = 0xf8000000,
> +        .flash_base = 0x08000000,
>          .flash_size = 0x01000000,
>          .flash_sector_size = 0x20000,
>          .sram_size = 0x2000000,
> @@ -408,7 +412,7 @@ static void xtensa_lx200_init(MachineState *machine)
>  static void xtensa_ml605_init(MachineState *machine)
>  {
>      static const LxBoardDesc ml605_board = {
> -        .flash_base = 0xf8000000,
> +        .flash_base = 0x08000000,
>          .flash_size = 0x01000000,
>          .flash_sector_size = 0x20000,
>          .sram_size = 0x2000000,
> @@ -419,7 +423,7 @@ static void xtensa_ml605_init(MachineState *machine)
>  static void xtensa_kc705_init(MachineState *machine)
>  {
>      static const LxBoardDesc kc705_board = {
> -        .flash_base = 0xf0000000,
> +        .flash_base = 0x00000000,
>          .flash_size = 0x08000000,
>          .flash_boot_base = 0x06000000,
>          .flash_sector_size = 0x20000,
> --
> 1.8.1.4
>
>
Max Filippov Sept. 27, 2015, 6:01 p.m. UTC | #2
On Sun, Sep 27, 2015 at 8:42 PM, Peter Crosthwaite
<crosthwaitepeter@gmail.com> wrote:
> On Sun, Sep 27, 2015 at 10:16 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> XTFPGA FLASH is tied to XTFPGA system IO block. It's not very important
>> for systems with MMU where system IO block is visible at single
>> location,
>
> Are your relying on a matching change in the guest for MMU setup here?
>
> Can you explain a little more how the MMU allows a physical address
> remap of the underlying hardware as this looks like a non
> backwards-compatible board design rev.

No change is needed as this change doesn't affect memory map.
It only detaches FLASH from the system memory and attaches it
to the system IO region, at the same physical address as before.
Peter Crosthwaite Sept. 27, 2015, 6:36 p.m. UTC | #3
On Sun, Sep 27, 2015 at 11:01 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> On Sun, Sep 27, 2015 at 8:42 PM, Peter Crosthwaite
> <crosthwaitepeter@gmail.com> wrote:
>> On Sun, Sep 27, 2015 at 10:16 AM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>>> XTFPGA FLASH is tied to XTFPGA system IO block. It's not very important
>>> for systems with MMU where system IO block is visible at single
>>> location,
>>
>> Are your relying on a matching change in the guest for MMU setup here?
>>
>> Can you explain a little more how the MMU allows a physical address
>> remap of the underlying hardware as this looks like a non
>> backwards-compatible board design rev.
>
> No change is needed as this change doesn't affect memory map.
> It only detaches FLASH from the system memory and attaches it
> to the system IO region, at the same physical address as before.
>

Ok I get it now :). Commit message confused me a little with the MMU
stuff but reading it again it makes sense. Change looks good. I'll
wait for resolution on P1 before putting an RB.

Regards,
Peter

> --
> Thanks.
> -- Max
diff mbox

Patch

diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 72350f1..d4b9afb 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -247,16 +247,20 @@  static void lx_init(const LxBoardDesc *board, MachineState *machine)
 
     dinfo = drive_get(IF_PFLASH, 0, 0);
     if (dinfo) {
-        flash = pflash_cfi01_register(board->flash_base,
-                NULL, "lx60.io.flash", board->flash_size,
-                blk_by_legacy_dinfo(dinfo),
-                board->flash_sector_size,
-                board->flash_size / board->flash_sector_size,
-                4, 0x0000, 0x0000, 0x0000, 0x0000, be);
+        SysBusDevice *s;
+
+        flash = pflash_cfi01_init(NULL, "lx60.io.flash", board->flash_size,
+                                  blk_by_legacy_dinfo(dinfo),
+                                  board->flash_sector_size,
+                                  board->flash_size / board->flash_sector_size,
+                                  4, 0x0000, 0x0000, 0x0000, 0x0000, be);
         if (flash == NULL) {
             error_report("unable to mount pflash");
             exit(EXIT_FAILURE);
         }
+        s = SYS_BUS_DEVICE(flash);
+        memory_region_add_subregion(system_io, board->flash_base,
+                                    sysbus_mmio_get_region(s, 0));
     }
 
     /* Use presence of kernel file name as 'boot from SRAM' switch. */
@@ -386,7 +390,7 @@  static void lx_init(const LxBoardDesc *board, MachineState *machine)
 static void xtensa_lx60_init(MachineState *machine)
 {
     static const LxBoardDesc lx60_board = {
-        .flash_base = 0xf8000000,
+        .flash_base = 0x08000000,
         .flash_size = 0x00400000,
         .flash_sector_size = 0x10000,
         .sram_size = 0x20000,
@@ -397,7 +401,7 @@  static void xtensa_lx60_init(MachineState *machine)
 static void xtensa_lx200_init(MachineState *machine)
 {
     static const LxBoardDesc lx200_board = {
-        .flash_base = 0xf8000000,
+        .flash_base = 0x08000000,
         .flash_size = 0x01000000,
         .flash_sector_size = 0x20000,
         .sram_size = 0x2000000,
@@ -408,7 +412,7 @@  static void xtensa_lx200_init(MachineState *machine)
 static void xtensa_ml605_init(MachineState *machine)
 {
     static const LxBoardDesc ml605_board = {
-        .flash_base = 0xf8000000,
+        .flash_base = 0x08000000,
         .flash_size = 0x01000000,
         .flash_sector_size = 0x20000,
         .sram_size = 0x2000000,
@@ -419,7 +423,7 @@  static void xtensa_ml605_init(MachineState *machine)
 static void xtensa_kc705_init(MachineState *machine)
 {
     static const LxBoardDesc kc705_board = {
-        .flash_base = 0xf0000000,
+        .flash_base = 0x00000000,
         .flash_size = 0x08000000,
         .flash_boot_base = 0x06000000,
         .flash_sector_size = 0x20000,