summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Serbinenko <phcoder@gmail.com>2014-02-15 17:00:46 +0100
committerVladimir Serbinenko <phcoder@gmail.com>2014-07-19 14:24:29 +0200
commitf2b3cd63cfa2fcf7874b1947c60c22b664a277c7 (patch)
tree0f7ccfa29cfe00a3334f055333492157f96c4d3b
parentc2956e7752213f9eae5064e63d16afa84b7cc23f (diff)
lenovo/x60: Support digitizer on X60t and X201t.
Change-Id: I5b0399a8edca3b73aa7d515d2c446c31b3239fa5 Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-on: http://review.coreboot.org/5239 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--src/drivers/Kconfig1
-rw-r--r--src/drivers/Makefile.inc1
-rw-r--r--src/drivers/lenovo/Kconfig29
-rw-r--r--src/drivers/lenovo/Makefile.inc1
-rw-r--r--src/drivers/lenovo/lenovo.h3
-rw-r--r--src/drivers/lenovo/wacom.c176
-rw-r--r--src/mainboard/lenovo/Kconfig4
-rw-r--r--src/mainboard/lenovo/x201/Kconfig4
-rw-r--r--src/mainboard/lenovo/x201/acpi_tables.c2
-rw-r--r--src/mainboard/lenovo/x201/devicetree.cb14
-rw-r--r--src/mainboard/lenovo/x201/romstage.c2
-rw-r--r--src/mainboard/lenovo/x60/Kconfig3
-rw-r--r--src/mainboard/lenovo/x60/acpi_tables.c2
-rw-r--r--src/mainboard/lenovo/x60/devicetree.cb7
14 files changed, 242 insertions, 7 deletions
diff --git a/src/drivers/Kconfig b/src/drivers/Kconfig
index 874ec751fc..42d1583baf 100644
--- a/src/drivers/Kconfig
+++ b/src/drivers/Kconfig
@@ -26,6 +26,7 @@ source src/drivers/i2c/Kconfig
source src/drivers/ics/Kconfig
source src/drivers/intel/Kconfig
source src/drivers/ipmi/Kconfig
+source src/drivers/lenovo/Kconfig
source src/drivers/maxim/Kconfig
source src/drivers/parade/Kconfig
if PC80_SYSTEM
diff --git a/src/drivers/Makefile.inc b/src/drivers/Makefile.inc
index 66fe7b8eb8..cb2664396e 100644
--- a/src/drivers/Makefile.inc
+++ b/src/drivers/Makefile.inc
@@ -23,6 +23,7 @@ subdirs-y += emulation
subdirs-y += generic
subdirs-y += i2c
subdirs-y += intel
+subdirs-y += lenovo
subdirs-y += maxim
subdirs-y += net
subdirs-y += parade
diff --git a/src/drivers/lenovo/Kconfig b/src/drivers/lenovo/Kconfig
new file mode 100644
index 0000000000..30bacb90ea
--- /dev/null
+++ b/src/drivers/lenovo/Kconfig
@@ -0,0 +1,29 @@
+config DRIVERS_LENOVO_WACOM
+ bool
+ default n
+
+if DRIVERS_LENOVO_WACOM
+
+choice
+ prompt "Digitizer"
+ default DIGITIZER_AUTODETECT
+
+config DIGITIZER_AUTODETECT
+ bool "Autodetect"
+ help
+ The presence of digitizer is inferred from model number stored in
+ AT24RF chip.
+
+config DIGITIZER_PRESENT
+ bool "Present"
+ help
+ The digitizer is assumed to be present.
+
+config DIGITIZER_ABSENT
+ bool "Absent"
+ help
+ The digitizer is assumed to be absent.
+
+endchoice
+
+endif
diff --git a/src/drivers/lenovo/Makefile.inc b/src/drivers/lenovo/Makefile.inc
new file mode 100644
index 0000000000..c50db5b8be
--- /dev/null
+++ b/src/drivers/lenovo/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_LENOVO_WACOM) += wacom.c
diff --git a/src/drivers/lenovo/lenovo.h b/src/drivers/lenovo/lenovo.h
new file mode 100644
index 0000000000..4c441198b7
--- /dev/null
+++ b/src/drivers/lenovo/lenovo.h
@@ -0,0 +1,3 @@
+int drivers_lenovo_is_wacom_present(void);
+void drivers_lenovo_serial_ports_ssdt_generate(const char *scope,
+ int have_dock_serial);
diff --git a/src/drivers/lenovo/wacom.c b/src/drivers/lenovo/wacom.c
new file mode 100644
index 0000000000..33a287910e
--- /dev/null
+++ b/src/drivers/lenovo/wacom.c
@@ -0,0 +1,176 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Vladimir Serbinenko
+ *
+ * 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, or (at your
+ * option) any later version, 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include <types.h>
+#include <console/console.h>
+#include <arch/acpi.h>
+#include <arch/acpigen.h>
+#include <device/device.h>
+#include <device/pnp.h>
+#include <string.h>
+#include "lenovo.h"
+#include "drivers/i2c/at24rf08c/lenovo.h"
+
+static const char tablet_numbers[][5] = {
+ /* X60t. */
+ "6363", "6364", "6365", "6366",
+ "6367", "6368", "7762", "7763",
+ "7764", "7767", "7768", "7769",
+ /* X201t. */
+ "0053", "0831", "2985", "3093",
+ "3113", "3144", "3239", "4184",
+ "7448", "7449", "7450", "7453",
+ "2263", "2266",
+};
+
+int
+drivers_lenovo_is_wacom_present(void)
+{
+ const char *pn;
+ int i;
+ static int result = -1;
+ device_t superio;
+ u8 sioid;
+
+ if (result != -1)
+ return result;
+
+ if (IS_ENABLED(CONFIG_DIGITIZER_PRESENT)) {
+ printk (BIOS_INFO, "Digitizer state forced as present\n");
+ return (result = 1);
+ }
+
+ if (IS_ENABLED(CONFIG_DIGITIZER_ABSENT)) {
+ printk (BIOS_INFO, "Digitizer state forced as absent\n");
+ return (result = 0);
+ }
+
+ superio = dev_find_slot_pnp (0x164e, 3);
+ if (!superio) {
+ printk (BIOS_INFO, "No Super I/O, skipping wacom\n");
+ return (result = 0);
+ }
+
+ /* Probe ID. */
+ sioid = pnp_read_config(superio, 0x20);
+ if (sioid == 0xff) {
+ printk (BIOS_INFO, "Super I/O probe failed, skipping wacom\n");
+ return (result = 0);
+ }
+
+ pn = lenovo_mainboard_partnumber();
+ if (!pn)
+ return (result = 0);
+ printk (BIOS_DEBUG, "Lenovo P/N is %s\n", pn);
+ for (i = 0; i < ARRAY_SIZE (tablet_numbers); i++)
+ if (memcmp (tablet_numbers[i], pn, 4) == 0) {
+ printk (BIOS_DEBUG, "Lenovo P/N %s is a tablet\n", pn);
+ return (result = 1);
+ }
+ printk (BIOS_DEBUG, "Lenovo P/N %s is not a tablet\n", pn);
+ return (result = 0);
+}
+
+void
+drivers_lenovo_serial_ports_ssdt_generate(const char *scope,
+ int have_dock_serial)
+{
+ int scopelen, devicelen, reslen, methodlen;
+
+ scopelen = acpigen_write_scope(scope);
+
+ if (drivers_lenovo_is_wacom_present()) {
+ /* Device op. */
+ scopelen += acpigen_emit_byte(0x5b);
+ scopelen += acpigen_emit_byte(0x82);
+ devicelen = acpigen_write_len_f();
+ devicelen += acpigen_emit_namestring("DTR");
+
+ devicelen += acpigen_write_name("_HID");
+ devicelen += acpigen_emit_eisaid("WACF004");
+
+ devicelen += acpigen_write_name("_CRS");
+
+ reslen = acpigen_write_resourcetemplate_header();
+ reslen += acpigen_write_io16(0x200, 0x200, 1, 8, 1);
+ reslen += acpigen_write_irq((1 << 5));
+
+ devicelen += reslen;
+ devicelen += acpigen_write_resourcetemplate_footer(reslen);
+
+ /* method op */
+ devicelen += acpigen_emit_byte(0x14);
+ methodlen = acpigen_write_len_f();
+ methodlen += acpigen_emit_namestring("_STA");
+ /* no fnarg */
+ methodlen += acpigen_emit_byte(0x00);
+ /* return */
+ methodlen += acpigen_emit_byte(0xa4);
+ methodlen += acpigen_write_byte(0xf);
+
+ acpigen_patch_len(methodlen);
+ devicelen += methodlen;
+
+ acpigen_patch_len(devicelen - 1);
+ scopelen += devicelen;
+ }
+
+ if (have_dock_serial) {
+ /* Device op. */
+ scopelen += acpigen_emit_byte(0x5b);
+ scopelen += acpigen_emit_byte(0x82);
+ devicelen = acpigen_write_len_f();
+ devicelen += acpigen_emit_namestring("COMA");
+
+ devicelen += acpigen_write_name("_HID");
+ devicelen += acpigen_emit_eisaid("PNP0501");
+ devicelen += acpigen_write_name("_UID");
+ /* Byte */
+ devicelen += acpigen_write_byte(0x2);
+
+ devicelen += acpigen_write_name("_CRS");
+
+ reslen = acpigen_write_resourcetemplate_header();
+ reslen += acpigen_write_io16(0x3f8, 0x3f8, 1, 8, 1);
+ reslen += acpigen_write_irq(1 << 4);
+
+ devicelen += reslen;
+ devicelen += acpigen_write_resourcetemplate_footer(reslen);
+
+ /* method op */
+ devicelen += acpigen_emit_byte(0x14);
+ methodlen = acpigen_write_len_f();
+ methodlen += acpigen_emit_namestring("_STA");
+ /* no fnarg */
+ methodlen += acpigen_emit_byte(0x00);
+ /* return */
+ methodlen += acpigen_emit_byte(0xa4);
+ methodlen += acpigen_write_byte(0xf);
+ acpigen_patch_len(methodlen);
+
+ devicelen += methodlen;
+
+ acpigen_patch_len(devicelen - 1);
+ scopelen += devicelen;
+ }
+
+ acpigen_patch_len(scopelen - 1);
+}
diff --git a/src/mainboard/lenovo/Kconfig b/src/mainboard/lenovo/Kconfig
index c1dec85975..583efc842d 100644
--- a/src/mainboard/lenovo/Kconfig
+++ b/src/mainboard/lenovo/Kconfig
@@ -4,7 +4,7 @@ choice
prompt "Mainboard model"
config BOARD_LENOVO_X60
- bool "ThinkPad X60 / X60s"
+ bool "ThinkPad X60 / X60s / X60t"
help
The following X60 series ThinkPad machines have been verified to
work correctly:
@@ -13,7 +13,7 @@ config BOARD_LENOVO_X60
ThinkPad X60 (Model 1709)
config BOARD_LENOVO_X201
- bool "ThinkPad X201"
+ bool "ThinkPad X201 / X201s / X201t"
help
Lenovo X201 laptop. Consult wiki for details.
diff --git a/src/mainboard/lenovo/x201/Kconfig b/src/mainboard/lenovo/x201/Kconfig
index 803ce65eca..c82971f568 100644
--- a/src/mainboard/lenovo/x201/Kconfig
+++ b/src/mainboard/lenovo/x201/Kconfig
@@ -16,6 +16,8 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select HAVE_ACPI_RESUME
select MAINBOARD_HAS_NATIVE_VGA_INIT
select MAINBOARD_HAS_NATIVE_VGA_INIT_TEXTMODECFG
+ select SUPERIO_NSC_PC87382
+ select DRIVERS_LENOVO_WACOM
config MAINBOARD_DIR
string
@@ -27,7 +29,7 @@ config MAINBOARD_PART_NUMBER
config MAINBOARD_VERSION
string
- default "ThinkPad X201"
+ default "ThinkPad X201 / X201s / X201t"
config MAINBOARD_VENDOR
string
diff --git a/src/mainboard/lenovo/x201/acpi_tables.c b/src/mainboard/lenovo/x201/acpi_tables.c
index 165de0d404..b6e99dd87c 100644
--- a/src/mainboard/lenovo/x201/acpi_tables.c
+++ b/src/mainboard/lenovo/x201/acpi_tables.c
@@ -31,6 +31,7 @@
#include <device/pci.h>
#include <device/pci_ids.h>
#include "southbridge/intel/ibexpeak/nvs.h"
+#include "drivers/lenovo/lenovo.h"
extern const unsigned char AmlCode[];
#if CONFIG_HAVE_ACPI_SLIC
@@ -93,6 +94,7 @@ unsigned long acpi_fill_ssdt_generator(unsigned long current,
const char *oem_table_id)
{
generate_cpu_entries();
+ drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB", 0);
return (unsigned long)(acpigen_get_current());
}
diff --git a/src/mainboard/lenovo/x201/devicetree.cb b/src/mainboard/lenovo/x201/devicetree.cb
index 9053f8935e..1db5bf055e 100644
--- a/src/mainboard/lenovo/x201/devicetree.cb
+++ b/src/mainboard/lenovo/x201/devicetree.cb
@@ -143,6 +143,20 @@ chip northbridge/intel/nehalem
end
device pci 1f.0 on # PCI-LPC bridge
subsystemid 0x17aa 0x2166
+ chip superio/nsc/pc87382
+ device pnp 164e.3 on # Digitizer
+ io 0x60 = 0x200
+ irq 0x29 = 0xb0
+ irq 0x70 = 0x5
+ irq 0xf0 = 0x82
+ end
+ # IR, not connected
+ device pnp 164e.2 off end
+ # GPIO, not connected
+ device pnp 164e.7 off end
+ # DLPC, not connected
+ device pnp 164e.19 off end
+ end
end
device pci 1f.2 on # IDE/SATA
subsystemid 0x17aa 0x2168
diff --git a/src/mainboard/lenovo/x201/romstage.c b/src/mainboard/lenovo/x201/romstage.c
index a18536aae4..2f4efc8baf 100644
--- a/src/mainboard/lenovo/x201/romstage.c
+++ b/src/mainboard/lenovo/x201/romstage.c
@@ -54,7 +54,7 @@ static void pch_enable_lpc(void)
/* Enable EC, PS/2 Keyboard/Mouse */
pci_write_config16(PCH_LPC_DEV, LPC_EN,
CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN |
- COMA_LPC_EN);
+ COMA_LPC_EN | GAMEL_LPC_EN);
pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601);
pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1);
diff --git a/src/mainboard/lenovo/x60/Kconfig b/src/mainboard/lenovo/x60/Kconfig
index f70202d3f3..4610547f81 100644
--- a/src/mainboard/lenovo/x60/Kconfig
+++ b/src/mainboard/lenovo/x60/Kconfig
@@ -23,6 +23,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
select USE_OPTION_TABLE
select MAINBOARD_HAS_NATIVE_VGA_INIT
select H8_DOCK_EARLY_INIT
+ select DRIVERS_LENOVO_WACOM
config MAINBOARD_DIR
string
@@ -38,7 +39,7 @@ config DCACHE_RAM_SIZE
config MAINBOARD_PART_NUMBER
string
- default "ThinkPad X60 / X60s"
+ default "ThinkPad X60 / X60s / X60t"
config MMCONF_BASE_ADDRESS
hex
diff --git a/src/mainboard/lenovo/x60/acpi_tables.c b/src/mainboard/lenovo/x60/acpi_tables.c
index f6ed4ae6dd..cf07067a96 100644
--- a/src/mainboard/lenovo/x60/acpi_tables.c
+++ b/src/mainboard/lenovo/x60/acpi_tables.c
@@ -29,6 +29,7 @@
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
+#include "drivers/lenovo/lenovo.h"
extern const unsigned char AmlCode[];
#if CONFIG_HAVE_ACPI_SLIC
@@ -86,6 +87,7 @@ unsigned long acpi_fill_madt(unsigned long current)
unsigned long acpi_fill_ssdt_generator(unsigned long current, const char *oem_table_id)
{
generate_cpu_entries();
+ drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB", 1);
return (unsigned long) (acpigen_get_current());
}
diff --git a/src/mainboard/lenovo/x60/devicetree.cb b/src/mainboard/lenovo/x60/devicetree.cb
index fbef3bfb0d..81648bda7d 100644
--- a/src/mainboard/lenovo/x60/devicetree.cb
+++ b/src/mainboard/lenovo/x60/devicetree.cb
@@ -127,8 +127,11 @@ chip northbridge/intel/i945
io 0x60 = 0x2f8
end
- device pnp 164e.3 off # Serial Port
- io 0x60 = 0x3f8
+ device pnp 164e.3 on # Digitizer
+ io 0x60 = 0x200
+ irq 0x29 = 0xb0
+ irq 0x70 = 0x5
+ irq 0xf0 = 0x82
end
device pnp 164e.7 on # GPIO