tree: drop last paragraph of GPL copyright header
[coreboot.git] / src / drivers / lenovo / wacom.c
blobd1464d76b69d11d44cc4edd550fdbecf8ae226d7
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2014 Vladimir Serbinenko
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2, or (at your
9 * option) any later version, of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <types.h>
18 #include <console/console.h>
19 #include <arch/acpi.h>
20 #include <arch/acpigen.h>
21 #include <device/device.h>
22 #include <device/pnp.h>
23 #include <string.h>
24 #include "lenovo.h"
25 #include "drivers/i2c/at24rf08c/lenovo.h"
27 static const char tablet_numbers[][5] = {
28 /* X60t. */
29 "6363", "6364", "6365", "6366",
30 "6367", "6368", "7762", "7763",
31 "7764", "7767", "7768", "7769",
32 /* X200t. */
33 "7448", "7449", "7450", "7453",
34 /* X201t. */
35 "0053", "0831", "2985", "3093",
36 "3113", "3144", "3239", "4184",
37 "2263", "2266",
40 int
41 drivers_lenovo_is_wacom_present(void)
43 const char *pn;
44 int i;
45 static int result = -1;
46 device_t superio;
47 u8 sioid;
49 if (result != -1)
50 return result;
52 if (IS_ENABLED(CONFIG_DIGITIZER_PRESENT)) {
53 printk (BIOS_INFO, "Digitizer state forced as present\n");
54 return (result = 1);
57 if (IS_ENABLED(CONFIG_DIGITIZER_ABSENT)) {
58 printk (BIOS_INFO, "Digitizer state forced as absent\n");
59 return (result = 0);
62 superio = dev_find_slot_pnp (0x164e, 3);
63 if (!superio) {
64 printk (BIOS_INFO, "No Super I/O, skipping wacom\n");
65 return (result = 0);
68 /* Probe ID. */
69 sioid = pnp_read_config(superio, 0x20);
70 if (sioid == 0xff) {
71 printk (BIOS_INFO, "Super I/O probe failed, skipping wacom\n");
72 return (result = 0);
75 pn = lenovo_mainboard_partnumber();
76 if (!pn)
77 return (result = 0);
78 printk (BIOS_DEBUG, "Lenovo P/N is %s\n", pn);
79 for (i = 0; i < ARRAY_SIZE (tablet_numbers); i++)
80 if (memcmp (tablet_numbers[i], pn, 4) == 0) {
81 printk (BIOS_DEBUG, "Lenovo P/N %s is a tablet\n", pn);
82 return (result = 1);
84 printk (BIOS_DEBUG, "Lenovo P/N %s is not a tablet\n", pn);
85 return (result = 0);
88 void
89 drivers_lenovo_serial_ports_ssdt_generate(const char *scope,
90 int have_dock_serial)
92 acpigen_write_scope(scope);
94 if (drivers_lenovo_is_wacom_present()) {
95 acpigen_write_device("DTR");
97 acpigen_write_name("_HID");
98 acpigen_emit_eisaid("WACF004");
100 acpigen_write_name("_CRS");
102 acpigen_write_resourcetemplate_header();
103 acpigen_write_io16(0x200, 0x200, 1, 8, 1);
104 acpigen_write_irq((1 << 5));
106 acpigen_write_resourcetemplate_footer();
108 acpigen_write_method("_STA", 0);
109 /* return */
110 acpigen_emit_byte(0xa4);
111 acpigen_write_byte(0xf);
112 acpigen_pop_len();
114 acpigen_pop_len();
117 if (have_dock_serial) {
118 acpigen_write_device("COMA");
120 acpigen_write_name("_HID");
121 acpigen_emit_eisaid("PNP0501");
122 acpigen_write_name("_UID");
123 /* Byte */
124 acpigen_write_byte(0x2);
126 acpigen_write_name("_CRS");
128 acpigen_write_resourcetemplate_header();
129 acpigen_write_io16(0x3f8, 0x3f8, 1, 8, 1);
130 acpigen_write_irq(1 << 4);
132 acpigen_write_resourcetemplate_footer();
134 /* method op */
135 acpigen_write_method("_STA", 0);
136 /* return */
137 acpigen_emit_byte(0xa4);
138 acpigen_write_byte(0xf);
139 acpigen_pop_len();
141 acpigen_pop_len();
144 acpigen_pop_len();