Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions arch/arm64/configs/asahi.config
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ CONFIG_APPLE_T6041_CIO_RECONFIG=y
CONFIG_APPLE_PMC=y
CONFIG_APPLE_CLUSTER_PWRGATE=y
CONFIG_APPLE_CLPC=y
# Its power modes as platform profiles (/sys/class/platform-profile).
CONFIG_ACPI_PLATFORM_PROFILE=y
CONFIG_APPLE_MCC=y
CONFIG_APPLE_DISPLAY_GATE=y
CONFIG_APPLE_PMP=m
Expand Down
4 changes: 4 additions & 0 deletions drivers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ obj-y += idle/
obj-y += char/ipmi/

obj-$(CONFIG_ACPI) += acpi/
# Without ACPI, of drivers/acpi/ only the platform profile class is built.
ifndef CONFIG_ACPI
obj-$(CONFIG_ACPI_PLATFORM_PROFILE) += acpi/platform_profile.o
endif

# PnP must come after ACPI since it will eventually need to check if acpi
# was used and do nothing if so
Expand Down
8 changes: 5 additions & 3 deletions drivers/acpi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ config ACPI_THERMAL
To compile this driver as a module, choose M here:
the module will be called thermal.

config ACPI_PLATFORM_PROFILE
tristate

config ACPI_CUSTOM_DSDT_FILE
string "Custom DSDT Table file to include"
default ""
Expand Down Expand Up @@ -609,6 +606,11 @@ config ACPI_PRMT

endif # ACPI

# The class interface (/sys/class/platform-profile) needs nothing from ACPI,
# so device tree platforms without ACPI can select it too.
config ACPI_PLATFORM_PROFILE
tristate

config X86_PM_TIMER
bool "Power Management Timer Support" if EXPERT
depends on X86 && (ACPI || JAILHOUSE_GUEST)
Expand Down
35 changes: 27 additions & 8 deletions drivers/acpi/platform_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,32 @@ static ssize_t profile_show(struct device *dev,

static const struct attribute_group platform_profile_group;

/* The legacy /sys/firmware/acpi files exist only where ACPI firmware runs. */
/*
* The legacy /sys/firmware/acpi files exist only where ACPI firmware runs,
* and never in a kernel built without ACPI.
*/
static struct kobject *platform_profile_legacy_kobj(void)
{
#ifdef CONFIG_ACPI
return acpi_kobj;
#else
return NULL;
#endif
}

static void platform_profile_legacy_notify(void)
{
if (acpi_kobj)
sysfs_notify(acpi_kobj, NULL, "platform_profile");
struct kobject *kobj = platform_profile_legacy_kobj();

if (kobj)
sysfs_notify(kobj, NULL, "platform_profile");
}

static int platform_profile_legacy_update(void)
{
return acpi_kobj ? sysfs_update_group(acpi_kobj, &platform_profile_group) : 0;
struct kobject *kobj = platform_profile_legacy_kobj();

return kobj ? sysfs_update_group(kobj, &platform_profile_group) : 0;
}

/**
Expand Down Expand Up @@ -702,17 +718,18 @@ EXPORT_SYMBOL_GPL(devm_platform_profile_register);

static int __init platform_profile_init(void)
{
struct kobject *kobj = platform_profile_legacy_kobj();
int err;

err = class_register(&platform_profile_class);
if (err)
return err;

/* Without ACPI firmware (a device tree boot) only the class interface exists. */
if (!acpi_kobj)
if (!kobj)
return 0;

err = sysfs_create_group(acpi_kobj, &platform_profile_group);
err = sysfs_create_group(kobj, &platform_profile_group);
if (err)
class_unregister(&platform_profile_class);

Expand All @@ -721,8 +738,10 @@ static int __init platform_profile_init(void)

static void __exit platform_profile_exit(void)
{
if (acpi_kobj)
sysfs_remove_group(acpi_kobj, &platform_profile_group);
struct kobject *kobj = platform_profile_legacy_kobj();

if (kobj)
sysfs_remove_group(kobj, &platform_profile_group);
class_unregister(&platform_profile_class);
}
module_init(platform_profile_init);
Expand Down
2 changes: 1 addition & 1 deletion drivers/soc/apple/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ config APPLE_CLPC
depends on ARCH_APPLE || COMPILE_TEST
depends on APPLE_PMC && CPU_FREQ
depends on MFD_MACSMC || !MFD_MACSMC
select ACPI_PLATFORM_PROFILE if ACPI
select ACPI_PLATFORM_PROFILE
default ARCH_APPLE
help
Raises the DRAM controller and SoC fabric performance floors of the
Expand Down
Loading