1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <acpi/acpigen.h>
6 #include <device/device.h>
7 #include <device/pnp.h>
10 #include "drivers/i2c/at24rf08c/lenovo.h"
12 static const char tablet_numbers
[][5] = {
14 "6363", "6364", "6365", "6366",
15 "6367", "6368", "7762", "7763",
16 "7764", "7767", "7768", "7769",
18 "7448", "7449", "7450", "7453",
20 "0053", "0831", "2985", "3093",
21 "3113", "3144", "3239", "4184",
26 drivers_lenovo_is_wacom_present(void)
30 static int result
= -1;
31 struct device
*superio
;
37 if (CONFIG(DIGITIZER_PRESENT
)) {
38 printk(BIOS_INFO
, "Digitizer state forced as present\n");
42 if (CONFIG(DIGITIZER_ABSENT
)) {
43 printk(BIOS_INFO
, "Digitizer state forced as absent\n");
47 superio
= dev_find_slot_pnp(0x164e, 3);
49 printk(BIOS_INFO
, "No Super I/O, skipping wacom\n");
54 sioid
= pnp_read_config(superio
, 0x20);
56 printk(BIOS_INFO
, "Super I/O probe failed, skipping wacom\n");
60 pn
= lenovo_mainboard_partnumber();
63 printk(BIOS_DEBUG
, "Lenovo P/N is %s\n", pn
);
64 for (i
= 0; i
< ARRAY_SIZE(tablet_numbers
); i
++)
65 if (memcmp(tablet_numbers
[i
], pn
, 4) == 0) {
66 printk(BIOS_DEBUG
, "Lenovo P/N %s is a tablet\n", pn
);
69 printk(BIOS_DEBUG
, "Lenovo P/N %s is not a tablet\n", pn
);
74 drivers_lenovo_serial_ports_ssdt_generate(const char *scope
,
77 acpigen_write_scope(scope
);
79 if (drivers_lenovo_is_wacom_present()) {
80 acpigen_write_device("DTR");
82 acpigen_write_name("_HID");
83 acpigen_emit_eisaid("WACF004");
85 acpigen_write_name("_CRS");
87 acpigen_write_resourcetemplate_header();
88 acpigen_write_io16(0x200, 0x200, 1, 8, 1);
89 acpigen_write_irq((1 << 5));
91 acpigen_write_resourcetemplate_footer();
93 acpigen_write_STA(0xf);
98 if (have_dock_serial
) {
99 acpigen_write_device("COMA");
101 acpigen_write_name("_HID");
102 acpigen_emit_eisaid("PNP0501");
103 acpigen_write_name("_UID");
105 acpigen_write_byte(0x2);
107 acpigen_write_name("_CRS");
109 acpigen_write_resourcetemplate_header();
110 acpigen_write_io16(0x3f8, 0x3f8, 1, 8, 1);
111 acpigen_write_irq(1 << 4);
113 acpigen_write_resourcetemplate_footer();
115 acpigen_write_STA(0xf);