Arthur Heymans has uploaded this change for review.

View Change

[UNTESTED]drivers/lenovo/wacom: Move ssdt generator to nsc/pc87382

This adds a hook to the pc87382 code to specify the ACPI _HID in the
case that a wacom device is hooked up to it.

TODO:
- the wacom code needs to know quite a lot about the SIO and has
weird Kconfig hooks to force stuff that is bound to no work.
- Add a function to detect the sio and disable it, if not found.

Change-Id: Ic1bfebcdaf19798e5ca2fe6c96ac1f9f4cf73e9b
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
---
M src/drivers/lenovo/wacom.c
M src/mainboard/lenovo/x200/mainboard.c
M src/mainboard/lenovo/x201/mainboard.c
M src/mainboard/lenovo/x60/mainboard.c
M src/superio/nsc/pc87382/pc87382.h
M src/superio/nsc/pc87382/superio.c
6 files changed, 66 insertions(+), 42 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/33789/1
diff --git a/src/drivers/lenovo/wacom.c b/src/drivers/lenovo/wacom.c
index dfbd840..45395d3 100644
--- a/src/drivers/lenovo/wacom.c
+++ b/src/drivers/lenovo/wacom.c
@@ -21,6 +21,7 @@
#include <device/device.h>
#include <device/pnp.h>
#include <string.h>
+#include <superio/nsc/pc87382/pc87382.h>
#include "lenovo.h"
#include "drivers/i2c/at24rf08c/lenovo.h"

@@ -84,28 +85,10 @@
return (result = 0);
}

-void drivers_lenovo_serial_ports_ssdt_generate(const char *scope)
+const char *nsc_pc87382_sp1_acpi_hid(void)
{
- acpigen_write_scope(scope);
-
- if (drivers_lenovo_is_wacom_present()) {
- acpigen_write_device("DTR");
-
- acpigen_write_name("_HID");
- acpigen_emit_eisaid("WACF004");
-
- acpigen_write_name("_CRS");
-
- acpigen_write_resourcetemplate_header();
- acpigen_write_io16(0x200, 0x200, 1, 8, 1);
- acpigen_write_irq((1 << 5));
-
- acpigen_write_resourcetemplate_footer();
-
- acpigen_write_STA(0xf);
-
- acpigen_pop_len();
- }
-
- acpigen_pop_len();
+ if (drivers_lenovo_is_wacom_present())
+ return "WACF004";
+ else
+ return "PNP0501";
}
diff --git a/src/mainboard/lenovo/x200/mainboard.c b/src/mainboard/lenovo/x200/mainboard.c
index bcb94b1..2e65e56 100644
--- a/src/mainboard/lenovo/x200/mainboard.c
+++ b/src/mainboard/lenovo/x200/mainboard.c
@@ -17,18 +17,11 @@
#include <drivers/intel/gma/int15.h>
#include <drivers/lenovo/lenovo.h>

-static void fill_ssdt(struct device *device)
-{
- drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB");
-}
-
static void mainboard_enable(struct device *dev)
{
install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS,
GMA_INT15_PANEL_FIT_CENTERING,
GMA_INT15_BOOT_DISPLAY_DEFAULT, 2);
-
- dev->ops->acpi_fill_ssdt_generator = fill_ssdt;
}

struct chip_operations mainboard_ops = {
diff --git a/src/mainboard/lenovo/x201/mainboard.c b/src/mainboard/lenovo/x201/mainboard.c
index 8cd87aa..87a2f0e 100644
--- a/src/mainboard/lenovo/x201/mainboard.c
+++ b/src/mainboard/lenovo/x201/mainboard.c
@@ -56,17 +56,11 @@
printk(BIOS_SPEW, "SPI configured\n");
}

-static void fill_ssdt(struct device *device)
-{
- drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB");
-}
-
static void mainboard_enable(struct device *dev)
{
u16 pmbase;

dev->ops->init = mainboard_init;
- dev->ops->acpi_fill_ssdt_generator = fill_ssdt;

pmbase = pci_read_config32(pcidev_on_root(0x1f, 0),
PMBASE) & 0xff80;
diff --git a/src/mainboard/lenovo/x60/mainboard.c b/src/mainboard/lenovo/x60/mainboard.c
index 9febea5..acf63cb 100644
--- a/src/mainboard/lenovo/x60/mainboard.c
+++ b/src/mainboard/lenovo/x60/mainboard.c
@@ -113,15 +113,9 @@
}
}

-static void fill_ssdt(struct device *device)
-{
- drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB");
-}
-
static void mainboard_enable(struct device *dev)
{
dev->ops->init = mainboard_init;
- dev->ops->acpi_fill_ssdt_generator = fill_ssdt;
}

struct chip_operations mainboard_ops = {
diff --git a/src/superio/nsc/pc87382/pc87382.h b/src/superio/nsc/pc87382/pc87382.h
index 6826f45..480a646 100644
--- a/src/superio/nsc/pc87382/pc87382.h
+++ b/src/superio/nsc/pc87382/pc87382.h
@@ -21,4 +21,6 @@
#define PC87382_SP1 0x03
#define PC87382_GPIO 0x07
#define PC87382_DOCK 0x19
+
+const char *nsc_pc87382_sp1_acpi_hid(void);
#endif
diff --git a/src/superio/nsc/pc87382/superio.c b/src/superio/nsc/pc87382/superio.c
index 7c04023..4d270c0 100644
--- a/src/superio/nsc/pc87382/superio.c
+++ b/src/superio/nsc/pc87382/superio.c
@@ -14,6 +14,8 @@
* GNU General Public License for more details.
*/

+#include <arch/acpigen.h>
+#include <console/console.h>
#include <device/device.h>
#include <device/pnp.h>
#include <stdlib.h>
@@ -33,12 +35,68 @@
}
}

+__weak const char *nsc_pc87382_sp1_acpi_hid(void)
+{
+ return "PNP0501";
+}
+
+#if CONFIG(HAVE_ACPI_TABLES)
+static void pc87382_ssdt(struct device *dev)
+{
+ struct resource *io_res;
+ struct resource *irq_res;
+
+ const char *scope = acpi_device_path(dev);
+ if (!scope) {
+ printk(BIOS_ERR, "%s: Missing ACPI scope\n", dev_path(dev));
+ return;
+ }
+
+ acpigen_write_scope(scope);
+
+ switch (dev->path.pnp.device) {
+ case PC87382_SP1:
+ io_res = find_resource(dev, PNP_IDX_IO0);
+ if (!io_res || !io_res->base) {
+ printk(BIOS_ERR, "PC87382: LDN%u IOBASE not set.\n",
+ PC87382_SP1);
+ break;
+ }
+ irq_res = find_resource(dev, PNP_IDX_IRQ0);
+ if (!irq_res || !irq_res->base) {
+ printk(BIOS_ERR, "PC87382: LDN%u IRQ not set.\n",
+ PC87382_SP1);
+ break;
+ }
+
+ acpigen_write_device("DIR");
+
+ acpigen_write_name("_HID");
+ acpigen_emit_eisaid(nsc_pc87382_sp1_acpi_hid());
+ acpigen_write_name("_CRS");
+
+ acpigen_write_resourcetemplate_header( );
+ acpigen_write_io16(io_res->base, io_res->base, io_res->align,
+ io_res->size, 1);
+ acpigen_write_irq(irq_res->base);
+ acpigen_write_resourcetemplate_footer();
+ acpigen_write_STA(0xf);
+
+ break;
+ }
+ acpigen_pop_len();
+}
+#endif
+
static struct device_operations ops = {
.read_resources = pnp_read_resources,
.set_resources = pnp_set_resources,
.enable_resources = pnp_enable_resources,
.enable = pnp_enable,
.init = init,
+#if CONFIG(HAVE_ACPI_TABLES)
+ .acpi_fill_ssdt_generator = pc87382_ssdt,
+#endif
};

static struct pnp_info pnp_dev_info[] = {

To view, visit change 33789. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ic1bfebcdaf19798e5ca2fe6c96ac1f9f4cf73e9b
Gerrit-Change-Number: 33789
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-MessageType: newchange