xref: /openbmc/linux/drivers/acpi/acpi_ffh.c (revision 2fa5ebe3)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Author: Sudeep Holla <sudeep.holla@arm.com>
4  * Copyright 2022 Arm Limited
5  */
6 #include <linux/kernel.h>
7 #include <linux/acpi.h>
8 #include <linux/completion.h>
9 #include <linux/idr.h>
10 #include <linux/io.h>
11 
12 #include <linux/arm-smccc.h>
13 
14 static struct acpi_ffh_info ffh_ctx;
15 
16 int __weak acpi_ffh_address_space_arch_setup(void *handler_ctxt,
17 					     void **region_ctxt)
18 {
19 	return -EOPNOTSUPP;
20 }
21 
22 int __weak acpi_ffh_address_space_arch_handler(acpi_integer *value,
23 					       void *region_context)
24 {
25 	return -EOPNOTSUPP;
26 }
27 
28 static acpi_status
29 acpi_ffh_address_space_setup(acpi_handle region_handle, u32 function,
30 			     void *handler_context,  void **region_context)
31 {
32 	return acpi_ffh_address_space_arch_setup(handler_context,
33 						 region_context);
34 }
35 
36 static acpi_status
37 acpi_ffh_address_space_handler(u32 function, acpi_physical_address addr,
38 			       u32 bits, acpi_integer *value,
39 			       void *handler_context, void *region_context)
40 {
41 	return acpi_ffh_address_space_arch_handler(value, region_context);
42 }
43 
44 void __init acpi_init_ffh(void)
45 {
46 	acpi_status status;
47 
48 	status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
49 						    ACPI_ADR_SPACE_FIXED_HARDWARE,
50 						    &acpi_ffh_address_space_handler,
51 						    &acpi_ffh_address_space_setup,
52 						    &ffh_ctx);
53 	if (ACPI_FAILURE(status))
54 		pr_alert("OperationRegion handler could not be installed\n");
55 }
56