Skip to content

Commit e81c782

Browse files
sudeep-hollarafaeljw
authored andcommitted
ACPI: Implement a generic FFH Opregion handler
This registers the FFH OpRegion handler before ACPI tables are loaded. The platform support for the same is checked via Platform-Wide OSPM Capabilities(OSC) before registering the OpRegion handler. It relies on the special context data passed to offset and the length. However the interpretation of the values is platform/architecture specific. This generic handler just passed all the information to the platform/architecture specific callback. It also implements the default callbacks which return as not supported. Signed-off-by: Sudeep Holla <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 094226a commit e81c782

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

drivers/acpi/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,16 @@ config ACPI_PCC
564564
Enable this feature if you want to set up and install the PCC Address
565565
Space handler to handle PCC OpRegion in the firmware.
566566

567+
config ACPI_FFH
568+
bool "ACPI FFH Address Space"
569+
default n
570+
help
571+
The FFH(Fixed Function Hardware) Address Space also referred as FFH
572+
Operation Region allows to define platform specific opregion.
573+
574+
Enable this feature if you want to set up and install the FFH Address
575+
Space handler to handle FFH OpRegion in the firmware.
576+
567577
source "drivers/acpi/pmic/Kconfig"
568578

569579
config ACPI_VIOT

drivers/acpi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ acpi-$(CONFIG_ACPI_GENERIC_GSI) += irq.o
6868
acpi-$(CONFIG_ACPI_WATCHDOG) += acpi_watchdog.o
6969
acpi-$(CONFIG_ACPI_PRMT) += prmt.o
7070
acpi-$(CONFIG_ACPI_PCC) += acpi_pcc.o
71+
acpi-$(CONFIG_ACPI_FFH) += acpi_ffh.o
7172

7273
# Address translation
7374
acpi-$(CONFIG_ACPI_ADXL) += acpi_adxl.o

drivers/acpi/acpi_ffh.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Author: Sudeep Holla <[email protected]>
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+
}

drivers/acpi/bus.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ EXPORT_SYMBOL_GPL(osc_sb_native_usb4_support_confirmed);
300300

301301
bool osc_sb_cppc2_support_acked;
302302

303+
bool osc_sb_ffh_opregion_support_confirmed;
304+
303305
static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
304306
static void acpi_bus_osc_negotiate_platform_control(void)
305307
{
@@ -383,6 +385,8 @@ static void acpi_bus_osc_negotiate_platform_control(void)
383385
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
384386
osc_cpc_flexible_adr_space_confirmed =
385387
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_CPC_FLEXIBLE_ADR_SPACE;
388+
osc_sb_ffh_opregion_support_confirmed =
389+
capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_FFH_OPR_SUPPORT;
386390
}
387391

388392
kfree(context.ret.pointer);
@@ -1408,6 +1412,8 @@ static int __init acpi_init(void)
14081412
disable_acpi();
14091413
return result;
14101414
}
1415+
if (osc_sb_ffh_opregion_support_confirmed)
1416+
acpi_init_ffh();
14111417

14121418
pci_mmcfg_late_init();
14131419
acpi_iort_init();

include/linux/acpi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context);
586586
#define OSC_SB_CPC_FLEXIBLE_ADR_SPACE 0x00004000
587587
#define OSC_SB_NATIVE_USB4_SUPPORT 0x00040000
588588
#define OSC_SB_PRM_SUPPORT 0x00200000
589+
#define OSC_SB_FFH_OPR_SUPPORT 0x00400000
589590

590591
extern bool osc_sb_apei_support_acked;
591592
extern bool osc_pc_lpi_support_confirmed;
@@ -1488,6 +1489,12 @@ void acpi_init_pcc(void);
14881489
static inline void acpi_init_pcc(void) { }
14891490
#endif
14901491

1492+
#ifdef CONFIG_ACPI_FFH
1493+
void acpi_init_ffh(void);
1494+
#else
1495+
static inline void acpi_init_ffh(void) { }
1496+
#endif
1497+
14911498
#ifdef CONFIG_ACPI
14921499
extern void acpi_device_notify(struct device *dev);
14931500
extern void acpi_device_notify_remove(struct device *dev);

0 commit comments

Comments
 (0)