Skip to content

Commit a6021aa

Browse files
arndbrafaeljw
authored andcommitted
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>
1 parent 42f7652 commit a6021aa

File tree

11 files changed

+61
-24
lines changed

11 files changed

+61
-24
lines changed

drivers/acpi/Kconfig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,17 @@ config ACPI_REV_OVERRIDE_POSSIBLE
132132
makes it possible to force the kernel to return "5" as the supported
133133
ACPI revision via the "acpi_rev_override" command line switch.
134134

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+
135143
config ACPI_EC_DEBUGFS
136144
tristate "EC read/write access through /sys/kernel/debug/ec"
145+
depends on ACPI_EC
137146
help
138147
Say N to disable Embedded Controller /sys/kernel/debug interface
139148

@@ -433,7 +442,7 @@ config ACPI_HOTPLUG_IOAPIC
433442

434443
config ACPI_SBS
435444
tristate "Smart Battery System"
436-
depends on X86
445+
depends on X86 && ACPI_EC
437446
select POWER_SUPPLY
438447
help
439448
This driver supports the Smart Battery System, another

drivers/acpi/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ acpi-y += resource.o
4141
acpi-y += acpi_processor.o
4242
acpi-y += processor_core.o
4343
acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o
44-
acpi-y += ec.o
44+
acpi-$(CONFIG_ACPI_EC) += ec.o
4545
acpi-$(CONFIG_ACPI_DOCK) += dock.o
4646
acpi-$(CONFIG_PCI) += pci_root.o pci_link.o pci_irq.o
4747
obj-$(CONFIG_ACPI_MCFG) += pci_mcfg.o

drivers/acpi/internal.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ extern struct acpi_ec *first_ec;
215215
/* External interfaces use first EC only, so remember */
216216
typedef int (*acpi_ec_query_func) (void *data);
217217

218+
#ifdef CONFIG_ACPI_EC
219+
218220
void acpi_ec_init(void);
219221
void acpi_ec_ecdt_probe(void);
220222
void acpi_ec_dsdt_probe(void);
@@ -231,6 +233,29 @@ void acpi_ec_flush_work(void);
231233
bool acpi_ec_dispatch_gpe(void);
232234
#endif
233235

236+
#else
237+
238+
static inline void acpi_ec_init(void) {}
239+
static inline void acpi_ec_ecdt_probe(void) {}
240+
static inline void acpi_ec_dsdt_probe(void) {}
241+
static inline void acpi_ec_block_transactions(void) {}
242+
static inline void acpi_ec_unblock_transactions(void) {}
243+
static inline int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
244+
acpi_handle handle, acpi_ec_query_func func,
245+
void *data)
246+
{
247+
return -ENXIO;
248+
}
249+
static inline void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) {}
250+
static inline void acpi_ec_register_opregions(struct acpi_device *adev) {}
251+
252+
static inline void acpi_ec_flush_work(void) {}
253+
static inline bool acpi_ec_dispatch_gpe(void)
254+
{
255+
return false;
256+
}
257+
258+
#endif
234259

235260
/*--------------------------------------------------------------------------
236261
Suspend/Resume

drivers/acpi/sbshc.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/module.h>
1515
#include <linux/interrupt.h>
1616
#include "sbshc.h"
17+
#include "internal.h"
1718

1819
#define ACPI_SMB_HC_CLASS "smbus_host_ctl"
1920
#define ACPI_SMB_HC_DEVICE_NAME "ACPI SMBus HC"
@@ -236,12 +237,6 @@ static int smbus_alarm(void *context)
236237
return 0;
237238
}
238239

239-
typedef int (*acpi_ec_query_func) (void *data);
240-
241-
extern 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-
245240
static int acpi_smbus_hc_add(struct acpi_device *device)
246241
{
247242
int status;
@@ -278,8 +273,6 @@ static int acpi_smbus_hc_add(struct acpi_device *device)
278273
return 0;
279274
}
280275

281-
extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);
282-
283276
static void acpi_smbus_hc_remove(struct acpi_device *device)
284277
{
285278
struct acpi_smb_hc *hc;

drivers/char/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ config APPLICOM
238238
config SONYPI
239239
tristate "Sony Vaio Programmable I/O Control Device support"
240240
depends on X86_32 && PCI && INPUT
241+
depends on ACPI_EC || !ACPI
241242
help
242243
This driver enables access to the Sony Programmable I/O Control
243244
Device which can be found in many (all ?) Sony Vaio laptops.

drivers/hwmon/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ source "drivers/hwmon/occ/Kconfig"
17521752

17531753
config SENSORS_OXP
17541754
tristate "OneXPlayer EC fan control"
1755-
depends on ACPI
1755+
depends on ACPI_EC
17561756
depends on X86
17571757
help
17581758
If you say yes here you get support for fan readings and control over
@@ -2592,6 +2592,7 @@ config SENSORS_ASUS_WMI
25922592
config SENSORS_ASUS_EC
25932593
tristate "ASUS EC Sensors"
25942594
depends on X86
2595+
depends on ACPI_EC
25952596
help
25962597
If you say yes here you get support for the ACPI embedded controller
25972598
hardware monitoring interface found in ASUS motherboards. The driver

drivers/platform/x86/Kconfig

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ config WMI_BMOF
5252
config HUAWEI_WMI
5353
tristate "Huawei WMI laptop extras driver"
5454
depends on ACPI_BATTERY
55+
depends on ACPI_EC
5556
depends on ACPI_WMI
5657
depends on INPUT
5758
select INPUT_SPARSEKMAP
@@ -147,7 +148,7 @@ config YT2_1380
147148

148149
config ACERHDF
149150
tristate "Acer Aspire One temperature and fan driver"
150-
depends on ACPI && THERMAL
151+
depends on ACPI_EC && THERMAL
151152
select THERMAL_GOV_BANG_BANG
152153
help
153154
This is a driver for Acer Aspire One netbooks. It allows to access
@@ -186,6 +187,7 @@ config ACER_WMI
186187
depends on SERIO_I8042
187188
depends on INPUT
188189
depends on RFKILL || RFKILL = n
190+
depends on ACPI_EC
189191
depends on ACPI_WMI
190192
depends on ACPI_VIDEO || ACPI_VIDEO = n
191193
depends on HWMON
@@ -334,7 +336,7 @@ config MERAKI_MX100
334336

335337
config EEEPC_LAPTOP
336338
tristate "Eee PC Hotkey Driver"
337-
depends on ACPI
339+
depends on ACPI_EC
338340
depends on INPUT
339341
depends on RFKILL || RFKILL = n
340342
depends on ACPI_VIDEO || ACPI_VIDEO = n
@@ -503,7 +505,7 @@ config SENSORS_HDAPS
503505

504506
config THINKPAD_ACPI
505507
tristate "ThinkPad ACPI Laptop Extras"
506-
depends on ACPI
508+
depends on ACPI_EC
507509
depends on ACPI_BATTERY
508510
depends on INPUT
509511
depends on RFKILL || RFKILL = n
@@ -682,15 +684,15 @@ config MEEGOPAD_ANX7428
682684

683685
config MSI_EC
684686
tristate "MSI EC Extras"
685-
depends on ACPI
687+
depends on ACPI_EC
686688
depends on ACPI_BATTERY
687689
help
688690
This driver allows various MSI laptops' functionalities to be
689691
controlled from userspace, including battery charge threshold.
690692

691693
config MSI_LAPTOP
692694
tristate "MSI Laptop Extras"
693-
depends on ACPI
695+
depends on ACPI_EC
694696
depends on BACKLIGHT_CLASS_DEVICE
695697
depends on ACPI_VIDEO || ACPI_VIDEO = n
696698
depends on RFKILL
@@ -796,15 +798,15 @@ config SAMSUNG_LAPTOP
796798

797799
config SAMSUNG_Q10
798800
tristate "Samsung Q10 Extras"
799-
depends on ACPI
801+
depends on ACPI_EC
800802
select BACKLIGHT_CLASS_DEVICE
801803
help
802804
This driver provides support for backlight control on Samsung Q10
803805
and related laptops, including Dell Latitude X200.
804806

805807
config ACPI_TOSHIBA
806808
tristate "Toshiba Laptop Extras"
807-
depends on ACPI
809+
depends on ACPI_EC
808810
depends on ACPI_BATTERY
809811
depends on ACPI_WMI
810812
select LEDS_CLASS
@@ -904,7 +906,7 @@ config ACPI_CMPC
904906

905907
config COMPAL_LAPTOP
906908
tristate "Compal (and others) Laptop Extras"
907-
depends on ACPI
909+
depends on ACPI_EC
908910
depends on BACKLIGHT_CLASS_DEVICE
909911
depends on ACPI_VIDEO || ACPI_VIDEO = n
910912
depends on RFKILL
@@ -949,7 +951,7 @@ config PANASONIC_LAPTOP
949951

950952
config SONY_LAPTOP
951953
tristate "Sony Laptop Extras"
952-
depends on ACPI
954+
depends on ACPI_EC
953955
depends on ACPI_VIDEO || ACPI_VIDEO = n
954956
depends on BACKLIGHT_CLASS_DEVICE
955957
depends on INPUT
@@ -972,7 +974,7 @@ config SONYPI_COMPAT
972974

973975
config SYSTEM76_ACPI
974976
tristate "System76 ACPI Driver"
975-
depends on ACPI
977+
depends on ACPI_EC
976978
depends on ACPI_BATTERY
977979
depends on HWMON
978980
depends on INPUT

drivers/platform/x86/dell/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ config DELL_WMI
194194
config DELL_WMI_PRIVACY
195195
bool "Dell WMI Hardware Privacy Support"
196196
depends on DELL_WMI
197+
depends on ACPI_EC
197198
help
198199
This option adds integration with the "Dell Hardware Privacy"
199200
feature of Dell laptops to the dell-wmi driver.

drivers/platform/x86/hp/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ config HP_ACCEL
3737
config HP_WMI
3838
tristate "HP WMI extras"
3939
default m
40+
depends on ACPI_EC
4041
depends on ACPI_WMI
4142
depends on INPUT
4243
depends on RFKILL || RFKILL = n

drivers/platform/x86/intel/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ config INTEL_INT0002_VGPIO
6262

6363
config INTEL_OAKTRAIL
6464
tristate "Intel Oaktrail Platform Extras"
65-
depends on ACPI
65+
depends on ACPI_EC
6666
depends on ACPI_VIDEO || ACPI_VIDEO=n
6767
depends on RFKILL && BACKLIGHT_CLASS_DEVICE && ACPI
6868
help

0 commit comments

Comments
 (0)