xref: /openbmc/linux/drivers/acpi/acpi_ffh.c (revision b755c25f)
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 static struct acpi_ffh_info ffh_ctx;
13 
14 int __weak acpi_ffh_address_space_arch_setup(void *handler_ctxt,
15 					     void **region_ctxt)
16 {
17 	return -EOPNOTSUPP;
18 }
19 
20 int __weak acpi_ffh_address_space_arch_handler(acpi_integer *value,
21 					       void *region_context)
22 {
23 	return -EOPNOTSUPP;
24 }
25 
26 static acpi_status
27 acpi_ffh_address_space_setup(acpi_handle region_handle, u32 function,
28 			     void *handler_context,  void **region_context)
29 {
30 	return acpi_ffh_address_space_arch_setup(handler_context,
31 						 region_context);
32 }
33 
34 static acpi_status
35 acpi_ffh_address_space_handler(u32 function, acpi_physical_address addr,
36 			       u32 bits, acpi_integer *value,
37 			       void *handler_context, void *region_context)
38 {
39 	return acpi_ffh_address_space_arch_handler(value, region_context);
40 }
41 
42 void __init acpi_init_ffh(void)
43 {
44 	acpi_status status;
45 
46 	status = acpi_install_address_space_handler(ACPI_ROOT_OBJECT,
47 						    ACPI_ADR_SPACE_FIXED_HARDWARE,
48 						    &acpi_ffh_address_space_handler,
49 						    &acpi_ffh_address_space_setup,
50 						    &ffh_ctx);
51 	if (ACPI_FAILURE(status))
52 		pr_alert("OperationRegion handler could not be installed\n");
53 }
54