Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromtorvalds/linux

Commit1195a09

Browse files
watologo1Matthew Garrett
authored and
Matthew Garrett
committed
ACPI: Provide /sys/kernel/debug/ec/...
This patch provides the same information through debugfs, which previously wasprovided through /proc/acpi/embedded_controller/*/infoThis is the gpe the EC is connected to and whether the global lockgets used.The io ports used are added to /proc/ioports in another patch.Beside the fact that /proc/acpi is deprecated for quite some time,this info is not needed for applications and thus can be movedto debugfs instead of a public interface like /sys.Signed-off-by: Thomas Renninger <trenn@suse.de>CC: Alexey Starikovskiy <astarikovskiy@suse.de>CC: Len Brown <lenb@kernel.org>CC: linux-kernel@vger.kernel.orgCC: linux-acpi@vger.kernel.orgCC: Bjorn Helgaas <bjorn.helgaas@hp.com>CC: platform-driver-x86@vger.kernel.orgSigned-off-by: Matthew Garrett <mjg@redhat.com>
1 parentcd89e08 commit1195a09

File tree

5 files changed

+100
-13
lines changed

5 files changed

+100
-13
lines changed

‎drivers/acpi/Kconfig‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ config ACPI_SYSFS_POWER
104104
help
105105
Say N to disable power /sys interface
106106

107+
config ACPI_EC_DEBUGFS
108+
tristate "EC read/write access through /sys/kernel/debug/ec"
109+
default y
110+
help
111+
Say N to disable Embedded Controller /sys/kernel/debug interface
112+
113+
An Embedded Controller typically is available on laptops and reads
114+
sensor values like battery state and temperature.
115+
The kernel access the EC through ACPI parsed code provided by BIOS
116+
tables.
117+
Thus this option is a debug option that helps to write ACPI drivers
118+
and can be used to identify ACPI code or EC firmware bugs.
119+
107120
config ACPI_PROC_EVENT
108121
bool "Deprecated /proc/acpi/event support"
109122
depends on PROC_FS

‎drivers/acpi/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ obj-$(CONFIG_ACPI_SBS)+= sbshc.o
6060
obj-$(CONFIG_ACPI_SBS)+= sbs.o
6161
obj-$(CONFIG_ACPI_POWER_METER)+= power_meter.o
6262
obj-$(CONFIG_ACPI_HED)+= hed.o
63+
obj-$(CONFIG_ACPI_EC_DEBUGFS)+= ec_sys.o
6364

6465
# processor has its own "processor." module_param namespace
6566
processor-y:= processor_driver.o processor_throttling.o

‎drivers/acpi/ec.c‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@
4343
#include<acpi/acpi_drivers.h>
4444
#include<linux/dmi.h>
4545

46+
#include"internal.h"
47+
4648
#defineACPI_EC_CLASS"embedded_controller"
4749
#defineACPI_EC_DEVICE_NAME"Embedded Controller"
4850
#defineACPI_EC_FILE_INFO"info"
4951

52+
#undef PREFIX
5053
#definePREFIX"ACPI: EC: "
5154

5255
/* EC status register */
@@ -104,19 +107,8 @@ struct transaction {
104107
booldone;
105108
};
106109

107-
staticstructacpi_ec {
108-
acpi_handlehandle;
109-
unsigned longgpe;
110-
unsigned longcommand_addr;
111-
unsigned longdata_addr;
112-
unsigned longglobal_lock;
113-
unsigned longflags;
114-
structmutexlock;
115-
wait_queue_head_twait;
116-
structlist_headlist;
117-
structtransaction*curr;
118-
spinlock_tcurr_lock;
119-
}*boot_ec,*first_ec;
110+
structacpi_ec*boot_ec,*first_ec;
111+
EXPORT_SYMBOL(first_ec);
120112

121113
staticintEC_FLAGS_MSI;/* Out-of-spec MSI controller */
122114
staticintEC_FLAGS_VALIDATE_ECDT;/* ASUStec ECDTs need to be validated */

‎drivers/acpi/ec_sys.c‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#include<linux/kernel.h>
2+
#include<linux/acpi.h>
3+
#include<linux/debugfs.h>
4+
#include"internal.h"
5+
6+
MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
7+
MODULE_DESCRIPTION("ACPI EC sysfs access driver");
8+
MODULE_LICENSE("GPL");
9+
10+
structsysdev_classacpi_ec_sysdev_class= {
11+
.name="ec",
12+
};
13+
14+
staticstructdentry*acpi_ec_debugfs_dir;
15+
16+
intacpi_ec_add_debugfs(structacpi_ec*ec,unsignedintec_device_count)
17+
{
18+
structdentry*dev_dir;
19+
charname[64];
20+
if (ec_device_count==0) {
21+
acpi_ec_debugfs_dir=debugfs_create_dir("ec",NULL);
22+
if (!acpi_ec_debugfs_dir)
23+
return-ENOMEM;
24+
}
25+
26+
sprintf(name,"ec%u",ec_device_count);
27+
dev_dir=debugfs_create_dir(name,acpi_ec_debugfs_dir);
28+
if (!dev_dir) {
29+
if (ec_device_count==0)
30+
debugfs_remove_recursive(acpi_ec_debugfs_dir);
31+
/* TBD: Proper cleanup for multiple ECs */
32+
return-ENOMEM;
33+
}
34+
35+
debugfs_create_x32("gpe",0444,dev_dir, (u32*)&first_ec->gpe);
36+
debugfs_create_bool("use_global_lock",0444,dev_dir,
37+
(u32*)&first_ec->global_lock);
38+
return0;
39+
}
40+
41+
staticint__initacpi_ec_sys_init(void)
42+
{
43+
interr=0;
44+
if (first_ec)
45+
err=acpi_ec_add_debugfs(first_ec,0);
46+
else
47+
err=-ENODEV;
48+
returnerr;
49+
}
50+
51+
staticvoid__exitacpi_ec_sys_exit(void)
52+
{
53+
debugfs_remove_recursive(acpi_ec_debugfs_dir);
54+
}
55+
56+
module_init(acpi_ec_sys_init);
57+
module_exit(acpi_ec_sys_exit);

‎drivers/acpi/internal.h‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
1919
*/
2020

21+
#ifndef_ACPI_INTERNAL_H_
22+
#define_ACPI_INTERNAL_H_
23+
24+
#include<linux/sysdev.h>
25+
2126
#definePREFIX "ACPI: "
2227

2328
intinit_acpi_device_notify(void);
@@ -46,6 +51,23 @@ void acpi_early_processor_set_pdc(void);
4651
/* --------------------------------------------------------------------------
4752
Embedded Controller
4853
-------------------------------------------------------------------------- */
54+
structacpi_ec {
55+
acpi_handlehandle;
56+
unsigned longgpe;
57+
unsigned longcommand_addr;
58+
unsigned longdata_addr;
59+
unsigned longglobal_lock;
60+
unsigned longflags;
61+
structmutexlock;
62+
wait_queue_head_twait;
63+
structlist_headlist;
64+
structtransaction*curr;
65+
spinlock_tcurr_lock;
66+
structsys_devicesysdev;
67+
};
68+
69+
externstructacpi_ec*first_ec;
70+
4971
intacpi_ec_init(void);
5072
intacpi_ec_ecdt_probe(void);
5173
intacpi_boot_ec_enable(void);
@@ -63,3 +85,5 @@ int acpi_sleep_proc_init(void);
6385
#else
6486
staticinlineintacpi_sleep_proc_init(void) {return0; }
6587
#endif
88+
89+
#endif/* _ACPI_INTERNAL_H_ */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp