Skip to contentSkip to conversation

hw/arm/musicpal: Map the UART devices unconditionally

RFC PATCH Applied Philippe Mathieu-Daudé 3 participants 4 messages May 5, 2020 – May 11, 2020

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 hw/arm/musicpal: Map the UART devices unconditionally

I can't find proper documentation or datasheet, but it is likely a MMIO mapped serial device mapped in the 0x80000000..0x8000ffff range belongs to the SoC address space, thus is always mapped in the memory bus.
Map the devices on the bus regardless a chardev is attached to it.

---
from 2019... found while doing housekeeping

---
 hw/arm/musicpal.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
hw/arm/musicpal.c +4 -8
index b2d0cfdac8..92f33ed87e 100644
@@ -1619,14 +1619,10 @@ static void musicpal_init(MachineState *machine)
                           pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
                           pic[MP_TIMER4_IRQ], NULL);
 
-    if (serial_hd(0)) {
-        serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ],
-                       1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN);
-    }
-    if (serial_hd(1)) {
-        serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ],
-                       1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN);
-    }
+    serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ],
+                   1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN);
+    serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ],
+                   1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN);
 
     /* Register flash */
     dinfo = drive_get(IF_PFLASH, 0, 0);
Signature · 1 line
2.21.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Philippe Mathieu-Daudé

I can't find proper documentation or datasheet, but it is likely a MMIO mapped serial device mapped in the 0x80000000..0x8000ffff range belongs to the SoC address space, thus is always mapped in the memory bus.
Map the devices on the bus regardless a chardev is attached to it.

---
from 2019... found while doing housekeeping

---
  hw/arm/musicpal.c | 12 ++++--------
  1 file changed, 4 insertions(+), 8 deletions(-)
hw/arm/musicpal.c +0 -5
index b2d0cfdac8..92f33ed87e 100644
@@ -1619,14 +1619,10 @@ static void musicpal_init(MachineState *machine)
                            pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
                            pic[MP_TIMER4_IRQ], NULL);
 
-    if (serial_hd(0)) {
-        serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ],
-                       1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN);
-    }
-    if (serial_hd(1)) {

hw/arm/musicpal.c static void musicpal_init(MachineState *machine) · line 1628

Quoted 10 lines
hw/arm/musicpal.c +4 -3
-        serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ],
-                       1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN);
-    }
+    serial_mm_init(address_space_mem, MP_UART1_BASE, 2, pic[MP_UART1_IRQ],
+                   1825000, serial_hd(0), DEVICE_NATIVE_ENDIAN);
+    serial_mm_init(address_space_mem, MP_UART2_BASE, 2, pic[MP_UART2_IRQ],
+                   1825000, serial_hd(1), DEVICE_NATIVE_ENDIAN);
 
      /* Register flash */
      dinfo = drive_get(IF_PFLASH, 0, 0);

I don't recall details anymore either (more than 10 year ago now...), but this looks reasonable.

Jan

#2 lore raw
Quoted 4 lines · Jan Kiszka

On 05.05.20 11:59, Philippe Mathieu-Daudé wrote:
I don't recall details anymore either (more than 10 year ago now...), but this looks reasonable.

My guess is that it dates back to when the serial code would crash if passed a NULL pointer for the backend rather than treating it as "same as if connected to a /dev/null backend".

thanks
-- PMM

#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

I can't find proper documentation or datasheet, but it is likely a MMIO mapped serial device mapped in the 0x80000000..0x8000ffff range belongs to the SoC address space, thus is always mapped in the memory bus.
Map the devices on the bus regardless a chardev is attached to it.

---
from 2019... found while doing housekeeping
---

Applied to target-arm.next, thanks.

-- PMM