Skip to contentSkip to conversation

hw/ppc/40p: Move the MC146818 RTC to the board where it belongs

PATCH Applied Philippe Mathieu-Daudé 2 participants 6 messages May 5, 2019 – May 6, 2019

lore
Share & tools
lore
#0 lore raw

cover hw/ppc/40p: Move the MC146818 RTC to the board where it belongs

Hi,

This series is to properly do the fix sent by Artyom here:
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02264.html

There is no RTC on the i82378, move it to the board code, set the base year there.

Regards,

Phil.

Artyom Tarasenko (1):
hw/ppc/40p: use 1900 as a base year

Philippe Mathieu-Daudé (2):
hw/ppc/prep: use TYPE_MC146818_RTC instead of a hardcoded string hw/ppc/40p: Move the MC146818 RTC to the board where it belongs

 hw/isa/i82378.c | 4 ----
 hw/ppc/prep.c   | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/3 hw/ppc/prep: use TYPE_MC146818_RTC instead of a hardcoded string

---
 hw/ppc/prep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/prep.c +1 -1
index b7f459d4754..ebee3211480 100644
@@ -601,7 +601,7 @@ static int prep_set_cmos_checksum(DeviceState *dev, void *opaque)
     uint16_t checksum = *(uint16_t *)opaque;
     ISADevice *rtc;
 
-    if (object_dynamic_cast(OBJECT(dev), "mc146818rtc")) {
+    if (object_dynamic_cast(OBJECT(dev), TYPE_MC146818_RTC)) {
         rtc = ISA_DEVICE(dev);
         rtc_set_memory(rtc, 0x2e, checksum & 0xff);
         rtc_set_memory(rtc, 0x3e, checksum & 0xff);
Signature · 1 line
2.20.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] hw/ppc/prep: use TYPE_MC146818_RTC instead of a hardcoded string

Quoted 1 line · Philippe Mathieu-Daudé

Certainly a good fix, but looks like there's places in hw/timer/mc146818rtc.c itself and in vl.c which could also do with this.

Quoted 17 lines
---
 hw/ppc/prep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/prep.c +1 -1
index b7f459d4754..ebee3211480 100644
@@ -601,7 +601,7 @@ static int prep_set_cmos_checksum(DeviceState *dev, void *opaque)
     uint16_t checksum = *(uint16_t *)opaque;
     ISADevice *rtc;
 
-    if (object_dynamic_cast(OBJECT(dev), "mc146818rtc")) {
+    if (object_dynamic_cast(OBJECT(dev), TYPE_MC146818_RTC)) {
         rtc = ISA_DEVICE(dev);
         rtc_set_memory(rtc, 0x2e, checksum & 0xff);
         rtc_set_memory(rtc, 0x3e, checksum & 0xff);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw

PATCH 2/3 hw/ppc/40p: Move the MC146818 RTC to the board where it belongs

In reply to Philippe Mathieu-Daudé

The MC146818 RTC was incorrectly added to the i82378 chipset in commit a04ff940974a. In the next commit (506b7ddf8893) the PReP machine use the i82378.
Since the MC146818 is specific to the PReP machine, move its use there.

Fixes a04ff940974a
---
 hw/isa/i82378.c | 4 ----
 hw/ppc/prep.c   | 3 +++
 2 files changed, 3 insertions(+), 4 deletions(-)
hw/isa/i82378.c +0 -4
index a5d67bc6d7a..c08970b24a2 100644
@@ -21,7 +21,6 @@
 #include "hw/pci/pci.h"
 #include "hw/i386/pc.h"
 #include "hw/timer/i8254.h"
-#include "hw/timer/mc146818rtc.h"
 #include "hw/audio/pcspk.h"
 
 #define TYPE_I82378 "i82378"
@@ -105,9 +104,6 @@ static void i82378_realize(PCIDevice *pci, Error **errp)
 
     /* 2 82C37 (dma) */
     isa = isa_create_simple(isabus, "i82374");
-
-    /* timer */
-    isa_create_simple(isabus, TYPE_MC146818_RTC);
 }
 
 static void i82378_init(Object *obj)
hw/ppc/prep.c +3 -0
index ebee3211480..7a0d311d43c 100644
@@ -675,6 +675,9 @@ static void ibm_40p_init(MachineState *machine)
     qdev_prop_set_uint32(dev, "ram-size", machine->ram_size);
     qdev_init_nofail(dev);
 
+    /* RTC */
+    isa_create_simple(isa_bus, TYPE_MC146818_RTC);
+
     /* initialize CMOS checksums */
     cmos_checksum = 0x6aa9;
     qbus_walk_children(BUS(isa_bus), prep_set_cmos_checksum, NULL, NULL, NULL,
Signature · 1 line
2.20.1
#4 lore raw

PATCH 3/3 hw/ppc/40p: use 1900 as a base year

In reply to Philippe Mathieu-Daudé

From: Artyom Tarasenko <[email protected]>

AIX 5.1 expects the base year to be 1900. Adjust accordingly.

---
 hw/ppc/prep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/ppc/prep.c +3 -1
index 7a0d311d43c..2a8009e20b4 100644
@@ -676,7 +676,9 @@ static void ibm_40p_init(MachineState *machine)
     qdev_init_nofail(dev);
 
     /* RTC */
-    isa_create_simple(isa_bus, TYPE_MC146818_RTC);
+    dev = DEVICE(isa_create(isa_bus, TYPE_MC146818_RTC));
+    qdev_prop_set_int32(dev, "base_year", 1900);
+    qdev_init_nofail(dev);
 
     /* initialize CMOS checksums */
     cmos_checksum = 0x6aa9;
Signature · 1 line
2.20.1
Applied
#5 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

Hi,

This series is to properly do the fix sent by Artyom here:
https://lists.gnu.org/archive/html/qemu-devel/2019-04/msg02264.html

There is no RTC on the i82378, move it to the board code, set the base year there.

Applied to ppc-for-4.1, although see comment for a possible followup.

Quoted 16 lines

Regards,

Phil.

Artyom Tarasenko (1):
hw/ppc/40p: use 1900 as a base year

Philippe Mathieu-Daudé (2):
hw/ppc/prep: use TYPE_MC146818_RTC instead of a hardcoded string hw/ppc/40p: Move the MC146818 RTC to the board where it belongs

 hw/isa/i82378.c | 4 ----
 hw/ppc/prep.c   | 7 ++++++-
 2 files changed, 6 insertions(+), 5 deletions(-)
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson