diff mbox series

[v2,14/15] ppc/pnv: add a "ibm, opal/power-mgt" device tree node on POWER9

Message ID 20190307223548.20516-15-clg@kaod.org
State New
Headers show
Series ppc: add POWER9 support to the PowerNV platform | expand

Commit Message

Cédric Le Goater March 7, 2019, 10:35 p.m. UTC
Activate only stop0 and stop1 levels. We should not need more levels
when under QEMU.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/ppc/pnv.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

David Gibson March 8, 2019, 12:58 a.m. UTC | #1
On Thu, Mar 07, 2019 at 11:35:47PM +0100, Cédric Le Goater wrote:
> Activate only stop0 and stop1 levels. We should not need more levels
> when under QEMU.
> 
> Signed-off-by: Cédric Le Goater <clg@kaod.org>

Applied, although..

> ---
>  hw/ppc/pnv.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index e68d419203e8..8be4d4cbf785 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -438,6 +438,16 @@ static void pnv_dt_isa(PnvMachineState *pnv, void *fdt)
>                         &args);
>  }
>  
> +static void pnv_dt_power_mgt(void *fdt)
> +{
> +    int off;
> +
> +    off = fdt_add_subnode(fdt, 0, "ibm,opal");
> +    off = fdt_add_subnode(fdt, off, "power-mgt");
> +
> +    _FDT(fdt_setprop_cell(fdt, off, "ibm,enabled-stop-levels", 0xc0000000));
> +}
> +
>  static void *pnv_dt_create(MachineState *machine)
>  {
>      const char plat_compat[] = "qemu,powernv\0ibm,powernv";
> @@ -493,6 +503,11 @@ static void *pnv_dt_create(MachineState *machine)
>          pnv_dt_bmc_sensors(pnv->bmc, fdt);
>      }
>  
> +    /* Create an extra node for power management on Power9 */
> +    if (pnv_is_power9(pnv)) {

.. as always, I think specific code calling generic helpers is a
better pattern than generic code conditionally calling specific details.

> +        pnv_dt_power_mgt(fdt);
> +    }
> +
>      return fdt;
>  }
>
diff mbox series

Patch

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index e68d419203e8..8be4d4cbf785 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -438,6 +438,16 @@  static void pnv_dt_isa(PnvMachineState *pnv, void *fdt)
                        &args);
 }
 
+static void pnv_dt_power_mgt(void *fdt)
+{
+    int off;
+
+    off = fdt_add_subnode(fdt, 0, "ibm,opal");
+    off = fdt_add_subnode(fdt, off, "power-mgt");
+
+    _FDT(fdt_setprop_cell(fdt, off, "ibm,enabled-stop-levels", 0xc0000000));
+}
+
 static void *pnv_dt_create(MachineState *machine)
 {
     const char plat_compat[] = "qemu,powernv\0ibm,powernv";
@@ -493,6 +503,11 @@  static void *pnv_dt_create(MachineState *machine)
         pnv_dt_bmc_sensors(pnv->bmc, fdt);
     }
 
+    /* Create an extra node for power management on Power9 */
+    if (pnv_is_power9(pnv)) {
+        pnv_dt_power_mgt(fdt);
+    }
+
     return fdt;
 }