coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
wacom.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <types.h>
4 #include <console/console.h>
5 #include <acpi/acpigen.h>
6 #include <device/device.h>
7 #include <device/pnp.h>
8 #include <string.h>
9 #include "lenovo.h"
11 
12 static const char tablet_numbers[][5] = {
13  /* X60t. */
14  "6363", "6364", "6365", "6366",
15  "6367", "6368", "7762", "7763",
16  "7764", "7767", "7768", "7769",
17  /* X200t. */
18  "7448", "7449", "7450", "7453",
19  /* X201t. */
20  "0053", "0831", "2985", "3093",
21  "3113", "3144", "3239", "4184",
22  "2263", "2266",
23 };
24 
25 int
27 {
28  const char *pn;
29  int i;
30  static int result = -1;
31  struct device *superio;
32  u8 sioid;
33 
34  if (result != -1)
35  return result;
36 
37  if (CONFIG(DIGITIZER_PRESENT)) {
38  printk (BIOS_INFO, "Digitizer state forced as present\n");
39  return (result = 1);
40  }
41 
42  if (CONFIG(DIGITIZER_ABSENT)) {
43  printk (BIOS_INFO, "Digitizer state forced as absent\n");
44  return (result = 0);
45  }
46 
47  superio = dev_find_slot_pnp (0x164e, 3);
48  if (!superio) {
49  printk (BIOS_INFO, "No Super I/O, skipping wacom\n");
50  return (result = 0);
51  }
52 
53  /* Probe ID. */
54  sioid = pnp_read_config(superio, 0x20);
55  if (sioid == 0xff) {
56  printk (BIOS_INFO, "Super I/O probe failed, skipping wacom\n");
57  return (result = 0);
58  }
59 
61  if (!pn)
62  return (result = 0);
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);
67  return (result = 1);
68  }
69  printk (BIOS_DEBUG, "Lenovo P/N %s is not a tablet\n", pn);
70  return (result = 0);
71 }
72 
73 void
75  int have_dock_serial)
76 {
77  acpigen_write_scope(scope);
78 
80  acpigen_write_device("DTR");
81 
82  acpigen_write_name("_HID");
83  acpigen_emit_eisaid("WACF004");
84 
85  acpigen_write_name("_CRS");
86 
88  acpigen_write_io16(0x200, 0x200, 1, 8, 1);
89  acpigen_write_irq((1 << 5));
90 
92 
93  acpigen_write_STA(0xf);
94 
96  }
97 
98  if (have_dock_serial) {
99  acpigen_write_device("COMA");
100 
101  acpigen_write_name("_HID");
102  acpigen_emit_eisaid("PNP0501");
103  acpigen_write_name("_UID");
104  /* Byte */
105  acpigen_write_byte(0x2);
106 
107  acpigen_write_name("_CRS");
108 
110  acpigen_write_io16(0x3f8, 0x3f8, 1, 8, 1);
111  acpigen_write_irq(1 << 4);
112 
114 
115  acpigen_write_STA(0xf);
116 
117  acpigen_pop_len();
118  }
119 
120  acpigen_pop_len();
121 }
void acpigen_pop_len(void)
Definition: acpigen.c:37
void acpigen_write_scope(const char *name)
Definition: acpigen.c:326
void acpigen_write_resourcetemplate_footer(void)
Definition: acpigen.c:1165
void acpigen_write_irq(u16 mask)
Definition: acpigen.c:1109
void acpigen_write_STA(uint8_t status)
Definition: acpigen.c:783
void acpigen_write_resourcetemplate_header(void)
Definition: acpigen.c:1147
void acpigen_write_byte(unsigned int data)
Definition: acpigen.c:96
void acpigen_emit_eisaid(const char *eisaid)
Definition: acpigen.c:1242
void acpigen_write_device(const char *name)
Definition: acpigen.c:769
void acpigen_write_io16(u16 min, u16 max, u8 align, u8 len, u8 decode16)
Definition: acpigen.c:1123
void acpigen_write_name(const char *name)
Definition: acpigen.c:320
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
DEVTREE_CONST struct device * dev_find_slot_pnp(u16 port, u16 device)
Given a PnP port and a device number, find the device structure.
Definition: device_const.c:331
@ CONFIG
Definition: dsi_common.h:201
const char * lenovo_mainboard_partnumber(void)
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
result
Definition: mrc_cache.c:35
u8 pnp_read_config(struct device *dev, u8 reg)
Definition: pnp_device.c:44
uint8_t u8
Definition: stdint.h:45
int memcmp(const void *s1, const void *s2, size_t n)
Definition: memcmp.c:3
Definition: device.h:107
int drivers_lenovo_is_wacom_present(void)
Definition: wacom.c:26
void drivers_lenovo_serial_ports_ssdt_generate(const char *scope, int have_dock_serial)
Definition: wacom.c:74
static const char tablet_numbers[][5]
Definition: wacom.c:12