Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI: EC: make EC support compile-time conditional

The embedded controller code is mainly used on x86 laptops and cannot
work without PC style I/O port access.

Make this a user-visible configuration option that is default enabled
on x86 but otherwise disabled, and that can never be enabled unless
CONFIG_HAS_IOPORT is also available.

The empty stubs in internal.h help ignore the EC code in configurations
that don't support it. In order to see those stubs, the sbshc code also
has to include this header and drop duplicate declarations.

All the direct callers of ec_read/ec_write already had an x86
dependency and now also need to depend on APCI_EC.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patch.msgid.link/20241011061948.3211423-1-arnd@kernel.org
[ rjw: Subject edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Arnd Bergmann and committed by
Rafael J. Wysocki
a6021aa2 42f7652d

+61 -24
+10 -1
drivers/acpi/Kconfig
··· 132 132 makes it possible to force the kernel to return "5" as the supported 133 133 ACPI revision via the "acpi_rev_override" command line switch. 134 134 135 + config ACPI_EC 136 + bool "Embedded Controller" 137 + depends on HAS_IOPORT 138 + default X86 139 + help 140 + This driver handles communication with the microcontroller 141 + on many x86 laptops and other machines. 142 + 135 143 config ACPI_EC_DEBUGFS 136 144 tristate "EC read/write access through /sys/kernel/debug/ec" 145 + depends on ACPI_EC 137 146 help 138 147 Say N to disable Embedded Controller /sys/kernel/debug interface 139 148 ··· 442 433 443 434 config ACPI_SBS 444 435 tristate "Smart Battery System" 445 - depends on X86 436 + depends on X86 && ACPI_EC 446 437 select POWER_SUPPLY 447 438 help 448 439 This driver supports the Smart Battery System, another
+1 -1
drivers/acpi/Makefile
··· 41 41 acpi-y += acpi_processor.o 42 42 acpi-y += processor_core.o 43 43 acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o 44 - acpi-y += ec.o 44 + acpi-$(CONFIG_ACPI_EC) += ec.o 45 45 acpi-$(CONFIG_ACPI_DOCK) += dock.o 46 46 acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o 47 47 obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o
+25
drivers/acpi/internal.h
··· 215 215 /* External interfaces use first EC only, so remember */ 216 216 typedef int (*acpi_ec_query_func) (void *data); 217 217 218 + #ifdef CONFIG_ACPI_EC 219 + 218 220 void acpi_ec_init(void); 219 221 void acpi_ec_ecdt_probe(void); 220 222 void acpi_ec_dsdt_probe(void); ··· 233 231 bool acpi_ec_dispatch_gpe(void); 234 232 #endif 235 233 234 + #else 235 + 236 + static inline void acpi_ec_init(void) {} 237 + static inline void acpi_ec_ecdt_probe(void) {} 238 + static inline void acpi_ec_dsdt_probe(void) {} 239 + static inline void acpi_ec_block_transactions(void) {} 240 + static inline void acpi_ec_unblock_transactions(void) {} 241 + static inline int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, 242 + acpi_handle handle, acpi_ec_query_func func, 243 + void *data) 244 + { 245 + return -ENXIO; 246 + } 247 + static inline void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) {} 248 + static inline void acpi_ec_register_opregions(struct acpi_device *adev) {} 249 + 250 + static inline void acpi_ec_flush_work(void) {} 251 + static inline bool acpi_ec_dispatch_gpe(void) 252 + { 253 + return false; 254 + } 255 + 256 + #endif 236 257 237 258 /*-------------------------------------------------------------------------- 238 259 Suspend/Resume
+1 -8
drivers/acpi/sbshc.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/interrupt.h> 16 16 #include "sbshc.h" 17 + #include "internal.h" 17 18 18 19 #define ACPI_SMB_HC_CLASS "smbus_host_ctl" 19 20 #define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC" ··· 237 236 return 0; 238 237 } 239 238 240 - typedef int (*acpi_ec_query_func) (void *data); 241 - 242 - extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, 243 - acpi_handle handle, acpi_ec_query_func func, 244 - void *data); 245 - 246 239 static int acpi_smbus_hc_add(struct acpi_device *device) 247 240 { 248 241 int status; ··· 272 277 273 278 return 0; 274 279 } 275 - 276 - extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit); 277 280 278 281 static void acpi_smbus_hc_remove(struct acpi_device *device) 279 282 {
+1
drivers/char/Kconfig
··· 238 238 config SONYPI 239 239 tristate "Sony Vaio Programmable I/O Control Device support" 240 240 depends on X86_32 && PCI && INPUT 241 + depends on ACPI_EC || !ACPI 241 242 help 242 243 This driver enables access to the Sony Programmable I/O Control 243 244 Device which can be found in many (all ?) Sony Vaio laptops.
+2 -1
drivers/hwmon/Kconfig
··· 1752 1752 1753 1753 config SENSORS_OXP 1754 1754 tristate "OneXPlayer EC fan control" 1755 - depends on ACPI 1755 + depends on ACPI_EC 1756 1756 depends on X86 1757 1757 help 1758 1758 If you say yes here you get support for fan readings and control over ··· 2592 2592 config SENSORS_ASUS_EC 2593 2593 tristate "ASUS EC Sensors" 2594 2594 depends on X86 2595 + depends on ACPI_EC 2595 2596 help 2596 2597 If you say yes here you get support for the ACPI embedded controller 2597 2598 hardware monitoring interface found in ASUS motherboards. The driver
+12 -10
drivers/platform/x86/Kconfig
··· 52 52 config HUAWEI_WMI 53 53 tristate "Huawei WMI laptop extras driver" 54 54 depends on ACPI_BATTERY 55 + depends on ACPI_EC 55 56 depends on ACPI_WMI 56 57 depends on INPUT 57 58 select INPUT_SPARSEKMAP ··· 148 147 149 148 config ACERHDF 150 149 tristate "Acer Aspire One temperature and fan driver" 151 - depends on ACPI && THERMAL 150 + depends on ACPI_EC && THERMAL 152 151 select THERMAL_GOV_BANG_BANG 153 152 help 154 153 This is a driver for Acer Aspire One netbooks. It allows to access ··· 187 186 depends on SERIO_I8042 188 187 depends on INPUT 189 188 depends on RFKILL || RFKILL = n 189 + depends on ACPI_EC 190 190 depends on ACPI_WMI 191 191 depends on ACPI_VIDEO || ACPI_VIDEO = n 192 192 depends on HWMON ··· 336 334 337 335 config EEEPC_LAPTOP 338 336 tristate "Eee PC Hotkey Driver" 339 - depends on ACPI 337 + depends on ACPI_EC 340 338 depends on INPUT 341 339 depends on RFKILL || RFKILL = n 342 340 depends on ACPI_VIDEO || ACPI_VIDEO = n ··· 505 503 506 504 config THINKPAD_ACPI 507 505 tristate "ThinkPad ACPI Laptop Extras" 508 - depends on ACPI 506 + depends on ACPI_EC 509 507 depends on ACPI_BATTERY 510 508 depends on INPUT 511 509 depends on RFKILL || RFKILL = n ··· 684 682 685 683 config MSI_EC 686 684 tristate "MSI EC Extras" 687 - depends on ACPI 685 + depends on ACPI_EC 688 686 depends on ACPI_BATTERY 689 687 help 690 688 This driver allows various MSI laptops' functionalities to be ··· 692 690 693 691 config MSI_LAPTOP 694 692 tristate "MSI Laptop Extras" 695 - depends on ACPI 693 + depends on ACPI_EC 696 694 depends on BACKLIGHT_CLASS_DEVICE 697 695 depends on ACPI_VIDEO || ACPI_VIDEO = n 698 696 depends on RFKILL ··· 798 796 799 797 config SAMSUNG_Q10 800 798 tristate "Samsung Q10 Extras" 801 - depends on ACPI 799 + depends on ACPI_EC 802 800 select BACKLIGHT_CLASS_DEVICE 803 801 help 804 802 This driver provides support for backlight control on Samsung Q10 ··· 806 804 807 805 config ACPI_TOSHIBA 808 806 tristate "Toshiba Laptop Extras" 809 - depends on ACPI 807 + depends on ACPI_EC 810 808 depends on ACPI_BATTERY 811 809 depends on ACPI_WMI 812 810 select LEDS_CLASS ··· 906 904 907 905 config COMPAL_LAPTOP 908 906 tristate "Compal (and others) Laptop Extras" 909 - depends on ACPI 907 + depends on ACPI_EC 910 908 depends on BACKLIGHT_CLASS_DEVICE 911 909 depends on ACPI_VIDEO || ACPI_VIDEO = n 912 910 depends on RFKILL ··· 951 949 952 950 config SONY_LAPTOP 953 951 tristate "Sony Laptop Extras" 954 - depends on ACPI 952 + depends on ACPI_EC 955 953 depends on ACPI_VIDEO || ACPI_VIDEO = n 956 954 depends on BACKLIGHT_CLASS_DEVICE 957 955 depends on INPUT ··· 974 972 975 973 config SYSTEM76_ACPI 976 974 tristate "System76 ACPI Driver" 977 - depends on ACPI 975 + depends on ACPI_EC 978 976 depends on ACPI_BATTERY 979 977 depends on HWMON 980 978 depends on INPUT
+1
drivers/platform/x86/dell/Kconfig
··· 194 194 config DELL_WMI_PRIVACY 195 195 bool "Dell WMI Hardware Privacy Support" 196 196 depends on DELL_WMI 197 + depends on ACPI_EC 197 198 help 198 199 This option adds integration with the "Dell Hardware Privacy" 199 200 feature of Dell laptops to the dell-wmi driver.
+1
drivers/platform/x86/hp/Kconfig
··· 37 37 config HP_WMI 38 38 tristate "HP WMI extras" 39 39 default m 40 + depends on ACPI_EC 40 41 depends on ACPI_WMI 41 42 depends on INPUT 42 43 depends on RFKILL || RFKILL = n
+1 -1
drivers/platform/x86/intel/Kconfig
··· 62 62 63 63 config INTEL_OAKTRAIL 64 64 tristate "Intel Oaktrail Platform Extras" 65 - depends on ACPI 65 + depends on ACPI_EC 66 66 depends on ACPI_VIDEO || ACPI_VIDEO=n 67 67 depends on RFKILL && BACKLIGHT_CLASS_DEVICE && ACPI 68 68 help
+6 -2
include/linux/acpi.h
··· 1164 1164 int acpi_subsys_suspend(struct device *dev); 1165 1165 int acpi_subsys_freeze(struct device *dev); 1166 1166 int acpi_subsys_poweroff(struct device *dev); 1167 - void acpi_ec_mark_gpe_for_wake(void); 1168 - void acpi_ec_set_gpe_wake_mask(u8 action); 1169 1167 int acpi_subsys_restore_early(struct device *dev); 1170 1168 #else 1171 1169 static inline int acpi_subsys_prepare(struct device *dev) { return 0; } ··· 1174 1176 static inline int acpi_subsys_freeze(struct device *dev) { return 0; } 1175 1177 static inline int acpi_subsys_poweroff(struct device *dev) { return 0; } 1176 1178 static inline int acpi_subsys_restore_early(struct device *dev) { return 0; } 1179 + #endif 1180 + 1181 + #if defined(CONFIG_ACPI_EC) && defined(CONFIG_PM_SLEEP) 1182 + void acpi_ec_mark_gpe_for_wake(void); 1183 + void acpi_ec_set_gpe_wake_mask(u8 action); 1184 + #else 1177 1185 static inline void acpi_ec_mark_gpe_for_wake(void) {} 1178 1186 static inline void acpi_ec_set_gpe_wake_mask(u8 action) {} 1179 1187 #endif