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>
This commit is contained in:
Vladimir Serbinenko
2014-02-15 17:00:46 +01:00
parent c2956e7752
commit f2b3cd63cf
14 changed files with 242 additions and 7 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1 @@
ramstage-$(CONFIG_DRIVERS_LENOVO_WACOM) += wacom.c

View File

@@ -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);

176
src/drivers/lenovo/wacom.c Normal file
View File

@@ -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);
}