1 // SPDX-License-Identifier: GPL-2.0
3 * Ultravisor high level interfaces
5 * Copyright 2019, IBM Corporation.
8 #include <linux/init.h>
9 #include <linux/printk.h>
10 #include <linux/of_fdt.h>
13 #include <asm/ultravisor.h>
14 #include <asm/firmware.h>
15 #include <asm/machdep.h>
19 static struct kobject
*ultravisor_kobj
;
21 int __init
early_init_dt_scan_ultravisor(unsigned long node
, const char *uname
,
22 int depth
, void *data
)
24 if (!of_flat_dt_is_compatible(node
, "ibm,ultravisor"))
27 powerpc_firmware_features
|= FW_FEATURE_ULTRAVISOR
;
28 pr_debug("Ultravisor detected!\n");
32 static struct memcons
*uv_memcons
;
34 static ssize_t
uv_msglog_read(struct file
*file
, struct kobject
*kobj
,
35 struct bin_attribute
*bin_attr
, char *to
,
36 loff_t pos
, size_t count
)
38 return memcons_copy(uv_memcons
, to
, pos
, count
);
41 static struct bin_attribute uv_msglog_attr
= {
42 .attr
= {.name
= "msglog", .mode
= 0400},
43 .read
= uv_msglog_read
46 static int __init
uv_init(void)
48 struct device_node
*node
;
50 if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR
))
53 node
= of_find_compatible_node(NULL
, NULL
, "ibm,uv-firmware");
57 uv_memcons
= memcons_init(node
, "memcons");
61 uv_msglog_attr
.size
= memcons_get_size(uv_memcons
);
63 ultravisor_kobj
= kobject_create_and_add("ultravisor", firmware_kobj
);
67 return sysfs_create_bin_file(ultravisor_kobj
, &uv_msglog_attr
);
69 machine_subsys_initcall(powernv
, uv_init
);