Linux Audio

Check our new training course

Loading...
v6.2
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * ePAPR para-virtualization support.
 4 *
 5 * Copyright (C) 2012 Freescale Semiconductor, Inc.
 6 */
 7
 8#include <linux/of.h>
 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>
14#include <asm/inst.h>
15
16#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
17extern void epapr_ev_idle(void);
18extern u32 epapr_ev_idle_start[];
19#endif
20
21bool epapr_paravirt_enabled;
22static bool __maybe_unused epapr_has_idle;
23
24static int __init early_init_dt_scan_epapr(unsigned long node,
25					   const char *uname,
26					   int depth, void *data)
27{
28	const u32 *insts;
29	int len;
30	int i;
31
32	insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
33	if (!insts)
34		return 0;
35
36	if (len % 4 || len > (4 * 4))
37		return -1;
38
39	for (i = 0; i < (len / 4); i++) {
40		ppc_inst_t inst = ppc_inst(be32_to_cpu(insts[i]));
41		patch_instruction(epapr_hypercall_start + i, inst);
42#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
43		patch_instruction(epapr_ev_idle_start + i, inst);
44#endif
45	}
46
47#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
48	if (of_get_flat_dt_prop(node, "has-idle", NULL))
49		epapr_has_idle = true;
50#endif
51
52	epapr_paravirt_enabled = true;
53
54	return 1;
55}
56
57int __init epapr_paravirt_early_init(void)
58{
59	of_scan_flat_dt(early_init_dt_scan_epapr, NULL);
60
61	return 0;
62}
63
64static int __init epapr_idle_init(void)
65{
66#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
67	if (epapr_has_idle)
68		ppc_md.power_save = epapr_ev_idle;
69#endif
70
71	return 0;
72}
73
74postcore_initcall(epapr_idle_init);
v5.4
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 3 * ePAPR para-virtualization support.
 4 *
 5 * Copyright (C) 2012 Freescale Semiconductor, Inc.
 6 */
 7
 8#include <linux/of.h>
 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>
 
14
15#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
16extern void epapr_ev_idle(void);
17extern u32 epapr_ev_idle_start[];
18#endif
19
20bool epapr_paravirt_enabled;
21static bool __maybe_unused epapr_has_idle;
22
23static int __init early_init_dt_scan_epapr(unsigned long node,
24					   const char *uname,
25					   int depth, void *data)
26{
27	const u32 *insts;
28	int len;
29	int i;
30
31	insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
32	if (!insts)
33		return 0;
34
35	if (len % 4 || len > (4 * 4))
36		return -1;
37
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);
43#endif
44	}
45
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;
49#endif
50
51	epapr_paravirt_enabled = true;
52
53	return 1;
54}
55
56int __init epapr_paravirt_early_init(void)
57{
58	of_scan_flat_dt(early_init_dt_scan_epapr, NULL);
59
60	return 0;
61}
62
63static int __init epapr_idle_init(void)
64{
65#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
66	if (epapr_has_idle)
67		ppc_md.power_save = epapr_ev_idle;
68#endif
69
70	return 0;
71}
72
73postcore_initcall(epapr_idle_init);