Skip to contentSkip to conversation

hw/ppc: e500: Use a macro for the platform clock frequency

PATCH Superseded Bin Meng 2 participants 4 messages Feb 3, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/2 hw/ppc: e500: Use a macro for the platform clock frequency

From: Bin Meng <[email protected]>

At present the platform clock frequency is using a magic number. Convert it to a macro and use it everywhere.

---

 hw/ppc/e500.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
hw/ppc/e500.c +5 -3
index c64b5d0..672ccd5 100644
@@ -74,6 +74,8 @@
 #define MPC8544_I2C_IRQ            43
 #define RTC_REGS_OFFSET            0x68
 
+#define PLATFORM_CLK_FREQ          400000000
+
 struct boot_info
 {
     uint32_t dt_base;
@@ -320,8 +322,8 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms,
     int fdt_size;
     void *fdt;
     uint8_t hypercall[16];
-    uint32_t clock_freq = 400000000;
-    uint32_t tb_freq = 400000000;
+    uint32_t clock_freq = PLATFORM_CLK_FREQ;
+    uint32_t tb_freq = PLATFORM_CLK_FREQ;
     int i;
     char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus";
     char *soc;
@@ -890,7 +892,7 @@ void ppce500_init(MachineState *machine)
         env->spr_cb[SPR_BOOKE_PIR].default_value = cs->cpu_index = i;
         env->mpic_iack = pmc->ccsrbar_base + MPC8544_MPIC_REGS_OFFSET + 0xa0;
 
-        ppc_booke_timers_init(cpu, 400000000, PPC_TIMER_E500);
+        ppc_booke_timers_init(cpu, PLATFORM_CLK_FREQ, PPC_TIMER_E500);
 
         /* Register reset handler */
         if (!i) {
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes

From: Bin Meng <[email protected]>

At present the <clock-frequency> property of the serial node is populated with value zero. U-Boot's ns16550 driver is not happy about this, so let's fill in a meaningful value.

---

 hw/ppc/e500.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/e500.c +1 -1
index 672ccd5..e4677af 100644
@@ -126,7 +126,7 @@ static void dt_serial_create(void *fdt, unsigned long long offset,
     qemu_fdt_setprop_string(fdt, ser, "compatible", "ns16550");
     qemu_fdt_setprop_cells(fdt, ser, "reg", offset, 0x100);
     qemu_fdt_setprop_cell(fdt, ser, "cell-index", idx);
-    qemu_fdt_setprop_cell(fdt, ser, "clock-frequency", 0);
+    qemu_fdt_setprop_cell(fdt, ser, "clock-frequency", PLATFORM_CLK_FREQ);
     qemu_fdt_setprop_cells(fdt, ser, "interrupts", 42, 2);
     qemu_fdt_setprop_phandle(fdt, ser, "interrupt-parent", mpic);
     qemu_fdt_setprop_string(fdt, "/aliases", alias, ser);
Signature · 1 line
2.7.4
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] hw/ppc: e500: Fill in correct <clock-frequency> for the serial nodes

Quoted 11 lines · Bin Meng

From: Bin Meng <[email protected]>

At present the <clock-frequency> property of the serial node is populated with value zero. U-Boot's ns16550 driver is not happy about this, so let's fill in a meaningful value.

---

 hw/ppc/e500.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v1 1/2
#3 lore raw
In reply to Bin Meng
Quoted 16 lines · Bin Meng

From: Bin Meng <[email protected]>

At present the platform clock frequency is using a magic number. Convert it to a macro and use it everywhere.

---

 hw/ppc/e500.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
hw/ppc/e500.c +0 -0
index c64b5d0..672ccd5 100644

hw/ppc/e500.c line 77

Quoted 4 lines
hw/ppc/e500.c +1 -0
@@ -74,6 +74,8 @@
 #define MPC8544_I2C_IRQ            43
 #define RTC_REGS_OFFSET            0x68
 
+#define PLATFORM_CLK_FREQ          400000000

Consider 1/ using unit in variable name and 2/ decompose:

#define PLATFORM_CLK_FREQ_HZ (400 * 1000 * 1000)

Regardless: