1 // SPDX-License-Identifier: GPL-2.0-only
3 * ePAPR para-virtualization support.
5 * Copyright (C) 2012 Freescale Semiconductor, Inc.
9 #include <linux/of_fdt.h>
10 #include <asm/epapr_hcalls.h>
11 #include <asm/cacheflush.h>
12 #include <asm/code-patching.h>
13 #include <asm/machdep.h>
15 #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
16 extern void epapr_ev_idle(void);
17 extern u32 epapr_ev_idle_start
[];
20 bool epapr_paravirt_enabled
;
21 static bool __maybe_unused epapr_has_idle
;
23 static int __init
early_init_dt_scan_epapr(unsigned long node
,
25 int depth
, void *data
)
31 insts
= of_get_flat_dt_prop(node
, "hcall-instructions", &len
);
35 if (len
% 4 || len
> (4 * 4))
38 for (i
= 0; i
< (len
/ 4); i
++) {
39 u32 inst
= be32_to_cpu(insts
[i
]);
40 patch_instruction(epapr_hypercall_start
+ i
, inst
);
41 #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
42 patch_instruction(epapr_ev_idle_start
+ i
, inst
);
46 #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
47 if (of_get_flat_dt_prop(node
, "has-idle", NULL
))
48 epapr_has_idle
= true;
51 epapr_paravirt_enabled
= true;
56 int __init
epapr_paravirt_early_init(void)
58 of_scan_flat_dt(early_init_dt_scan_epapr
, NULL
);
63 static int __init
epapr_idle_init(void)
65 #if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
67 ppc_md
.power_save
= epapr_ev_idle
;
73 postcore_initcall(epapr_idle_init
);