Commit a6021aa2 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Rafael J. Wysocki
Browse files

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: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
Acked-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://patch.msgid.link/20241011061948.3211423-1-arnd@kernel.org


[ rjw: Subject edits ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 42f7652d
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -132,8 +132,17 @@ config ACPI_REV_OVERRIDE_POSSIBLE
	  makes it possible to force the kernel to return "5" as the supported
	  ACPI revision via the "acpi_rev_override" command line switch.

config ACPI_EC
	bool "Embedded Controller"
	depends on HAS_IOPORT
	default X86
	help
	  This driver handles communication with the microcontroller
	  on many x86 laptops and other machines.

config ACPI_EC_DEBUGFS
	tristate "EC read/write access through /sys/kernel/debug/ec"
	depends on ACPI_EC
	help
	  Say N to disable Embedded Controller /sys/kernel/debug interface

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

config ACPI_SBS
	tristate "Smart Battery System"
	depends on X86
	depends on X86 && ACPI_EC
	select POWER_SUPPLY
	help
	  This driver supports the Smart Battery System, another
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ acpi-y += resource.o
acpi-y				+= acpi_processor.o
acpi-y				+= processor_core.o
acpi-$(CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC) += processor_pdc.o
acpi-y				+= ec.o
acpi-$(CONFIG_ACPI_EC)		+= ec.o
acpi-$(CONFIG_ACPI_DOCK)	+= dock.o
acpi-$(CONFIG_PCI)		+= pci_root.o pci_link.o pci_irq.o
obj-$(CONFIG_ACPI_MCFG)		+= pci_mcfg.o
+25 −0
Original line number Diff line number Diff line
@@ -215,6 +215,8 @@ extern struct acpi_ec *first_ec;
/* External interfaces use first EC only, so remember */
typedef int (*acpi_ec_query_func) (void *data);

#ifdef CONFIG_ACPI_EC

void acpi_ec_init(void);
void acpi_ec_ecdt_probe(void);
void acpi_ec_dsdt_probe(void);
@@ -231,6 +233,29 @@ void acpi_ec_flush_work(void);
bool acpi_ec_dispatch_gpe(void);
#endif

#else

static inline void acpi_ec_init(void) {}
static inline void acpi_ec_ecdt_probe(void) {}
static inline void acpi_ec_dsdt_probe(void) {}
static inline void acpi_ec_block_transactions(void) {}
static inline void acpi_ec_unblock_transactions(void) {}
static inline int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
			      acpi_handle handle, acpi_ec_query_func func,
			      void *data)
{
	return -ENXIO;
}
static inline void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit) {}
static inline void acpi_ec_register_opregions(struct acpi_device *adev) {}

static inline void acpi_ec_flush_work(void) {}
static inline bool acpi_ec_dispatch_gpe(void)
{
	return false;
}

#endif

/*--------------------------------------------------------------------------
                                  Suspend/Resume
+1 −8
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/interrupt.h>
#include "sbshc.h"
#include "internal.h"

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

typedef int (*acpi_ec_query_func) (void *data);

extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
			      acpi_handle handle, acpi_ec_query_func func,
			      void *data);

static int acpi_smbus_hc_add(struct acpi_device *device)
{
	int status;
@@ -278,8 +273,6 @@ static int acpi_smbus_hc_add(struct acpi_device *device)
	return 0;
}

extern void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit);

static void acpi_smbus_hc_remove(struct acpi_device *device)
{
	struct acpi_smb_hc *hc;
+1 −0
Original line number Diff line number Diff line
@@ -238,6 +238,7 @@ config APPLICOM
config SONYPI
	tristate "Sony Vaio Programmable I/O Control Device support"
	depends on X86_32 && PCI && INPUT
	depends on ACPI_EC || !ACPI
	help
	  This driver enables access to the Sony Programmable I/O Control
	  Device which can be found in many (all ?) Sony Vaio laptops.
Loading