ec/lenovo/h8/acpi: Add BDC interface
* Add SSDT generator to add dynamic ACPI code. * Implement GBDC and SBDC for thinkpad_acpi kernel module. Required for BDC power control from userspace. Tested on Lenovo T430: The bluetooth module is detected and can be powercycled using network manager. Change-Id: Ida825196650966194a883945896a038b0790fe45 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/20985 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Alexander Couzens <lynxis@fe80.eu> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
01d2e46ddb
commit
f1114d8918
|
@ -8,6 +8,7 @@ endif
|
|||
ramstage-y += h8.c
|
||||
ramstage-y += bluetooth.c
|
||||
ramstage-y += wwan.c
|
||||
ramstage-$(CONFIG_HAVE_ACPI_TABLES) += ssdt.c
|
||||
smm-y += smm.c
|
||||
|
||||
endif
|
||||
|
|
|
@ -153,4 +153,41 @@ Device (HKEY)
|
|||
{
|
||||
Return (\_SB.PCI0.LPCB.EC.GSTS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the current state:
|
||||
* Bit 0: BT HW present
|
||||
* Bit 1: BT radio enabled
|
||||
* Bit 2: BT state at resume
|
||||
*/
|
||||
Method (GBDC, 0)
|
||||
{
|
||||
If (HBDC) {
|
||||
Store(One, Local0)
|
||||
If(\_SB.PCI0.LPCB.EC.BTEB)
|
||||
{
|
||||
Or(Local0, 2, Local0)
|
||||
}
|
||||
/* FIXME: Implement state at resume, for now Enabled */
|
||||
Or(Local0, 4, Local0)
|
||||
Return (Local0)
|
||||
} Else {
|
||||
Return (0)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the current state:
|
||||
* Bit 1: BT radio enabled
|
||||
* Bit 2: BT state at resume
|
||||
*/
|
||||
Method (SBDC, 1)
|
||||
{
|
||||
If (HBDC) {
|
||||
ShiftRight (And(Arg0, 2), 1, Local0)
|
||||
Store (Local0, \_SB.PCI0.LPCB.EC.BTEB)
|
||||
|
||||
/* FIXME: Store state at resume */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,9 +181,20 @@ static void h8_init(struct device *dev)
|
|||
pc_keyboard_init(NO_AUX_DEVICE);
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
|
||||
static const char *h8_acpi_name(const struct device *dev)
|
||||
{
|
||||
return "EC";
|
||||
}
|
||||
#endif
|
||||
|
||||
struct device_operations h8_dev_ops = {
|
||||
#if IS_ENABLED(CONFIG_GENERATE_SMBIOS_TABLES)
|
||||
.get_smbios_strings = h8_smbios_strings,
|
||||
#endif
|
||||
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
|
||||
.acpi_fill_ssdt_generator = h8_ssdt_generator,
|
||||
.acpi_name = h8_acpi_name,
|
||||
#endif
|
||||
.init = h8_init,
|
||||
};
|
||||
|
|
|
@ -39,6 +39,8 @@ void h8_wwan_enable(int on);
|
|||
bool h8_wwan_nv_enable(void);
|
||||
bool h8_has_wwan(struct device *dev);
|
||||
|
||||
void h8_ssdt_generator(struct device *dev);
|
||||
|
||||
/* EC registers */
|
||||
#define H8_CONFIG0 0x00
|
||||
#define H8_CONFIG0_EVENTS_ENABLE 0x02
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2017 Patrick Rudolph <siro@das-labor.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <console/console.h>
|
||||
#include <arch/acpigen.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "h8.h"
|
||||
#include "chip.h"
|
||||
|
||||
static char *h8_dsdt_scope(struct device *dev, const char *scope)
|
||||
{
|
||||
static char buf[DEVICE_PATH_MAX] = {};
|
||||
const char *path = acpi_device_path(dev);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(buf, sizeof(buf) - 1, "%s.%s", path, scope);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generates EC SSDT.
|
||||
*/
|
||||
void h8_ssdt_generator(struct device *dev)
|
||||
{
|
||||
if (!acpi_device_path(dev))
|
||||
return;
|
||||
|
||||
printk(BIOS_INFO, "ACPI: * H8\n");
|
||||
|
||||
/* Scope HKEY */
|
||||
acpigen_write_scope(h8_dsdt_scope(dev, "HKEY"));
|
||||
|
||||
/* Used by thinkpad_acpi */
|
||||
acpigen_write_name_byte("HBDC", h8_has_bdc(dev) ? ONE_OP : ZERO_OP);
|
||||
|
||||
acpigen_pop_len(); /* Scope HKEY */
|
||||
}
|
Loading…
Reference in New Issue