Merge branches 'acpi-drivers', 'acpi-misc' and 'acpi-tools'
[deliverable/linux.git] / arch / powerpc / kernel / epapr_paravirt.c
CommitLineData
2e1ae9c0
LYB
1/*
2 * ePAPR para-virtualization support.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 *
17 * Copyright (C) 2012 Freescale Semiconductor, Inc.
18 */
19
20#include <linux/of.h>
26a2056e 21#include <linux/of_fdt.h>
2e1ae9c0
LYB
22#include <asm/epapr_hcalls.h>
23#include <asm/cacheflush.h>
24#include <asm/code-patching.h>
2f979de8
LYB
25#include <asm/machdep.h>
26
f9294e98 27#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
2f979de8
LYB
28extern void epapr_ev_idle(void);
29extern u32 epapr_ev_idle_start[];
f9294e98 30#endif
2e1ae9c0
LYB
31
32bool epapr_paravirt_enabled;
8067bd8a 33static bool __maybe_unused epapr_has_idle;
2e1ae9c0 34
4e21b94c
LT
35static int __init early_init_dt_scan_epapr(unsigned long node,
36 const char *uname,
37 int depth, void *data)
2e1ae9c0 38{
2e1ae9c0 39 const u32 *insts;
9d0c4dfe 40 int len;
4e21b94c 41 int i;
2e1ae9c0 42
4e21b94c 43 insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
2e1ae9c0 44 if (!insts)
4e21b94c 45 return 0;
2e1ae9c0
LYB
46
47 if (len % 4 || len > (4 * 4))
4e21b94c 48 return -1;
2e1ae9c0 49
2f979de8 50 for (i = 0; i < (len / 4); i++) {
235959be
AG
51 u32 inst = be32_to_cpu(insts[i]);
52 patch_instruction(epapr_hypercall_start + i, inst);
f9294e98 53#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
235959be 54 patch_instruction(epapr_ev_idle_start + i, inst);
f9294e98 55#endif
2f979de8
LYB
56 }
57
f9294e98 58#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
4e21b94c 59 if (of_get_flat_dt_prop(node, "has-idle", NULL))
83e267d7 60 epapr_has_idle = true;
f9294e98 61#endif
2e1ae9c0
LYB
62
63 epapr_paravirt_enabled = true;
64
4e21b94c
LT
65 return 1;
66}
67
68int __init epapr_paravirt_early_init(void)
69{
70 of_scan_flat_dt(early_init_dt_scan_epapr, NULL);
71
2e1ae9c0
LYB
72 return 0;
73}
74
83e267d7
SY
75static int __init epapr_idle_init(void)
76{
440d74d1 77#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
83e267d7
SY
78 if (epapr_has_idle)
79 ppc_md.power_save = epapr_ev_idle;
440d74d1 80#endif
83e267d7
SY
81
82 return 0;
83}
84
85postcore_initcall(epapr_idle_init);
This page took 0.343469 seconds and 5 git commands to generate.