1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2026 Beckhoff Automation GmbH & Co. KG
5 */
6
7 #include <sys/param.h>
8 #include <sys/systm.h>
9 #include <sys/bus.h>
10 #include <sys/gpio.h>
11 #include <sys/kernel.h>
12 #include <sys/module.h>
13
14 #include <contrib/dev/acpica/include/acpi.h>
15
16 #include <dev/acpica/acpivar.h>
17 #include <dev/gpio/gpiobusvar.h>
18
19 #include "intelgpio.h"
20
21 #include "gpio_if.h"
22 #include "opt_acpi.h"
23
24 static const struct intelgpio_padgroup adln_com0_groups[] = {
25 { .first_pad = 0, .npads = 26, .gpio_base = 0, .name = "GPP_B" },
26 { .first_pad = 26, .npads = 16, .gpio_base = 32, .name = "GPP_T" },
27 { .first_pad = 42, .npads = 25, .gpio_base = 64, .name = "GPP_A" },
28 };
29
30 static const struct intelgpio_padgroup adln_com1_groups[] = {
31 { .first_pad = 67, .npads = 8, .gpio_base = 96, .name = "GPP_S" },
32 { .first_pad = 75, .npads = 20, .gpio_base = 128, .name = "GPP_I" },
33 { .first_pad = 95, .npads = 24, .gpio_base = 160, .name = "GPP_H" },
34 { .first_pad = 119, .npads = 21, .gpio_base = 192, .name = "GPP_D" },
35 { .first_pad = 140, .npads = 29, .gpio_base = 224, .name = "vGPIO" },
36 };
37
38 static const struct intelgpio_padgroup adln_com4_groups[] = {
39 { .first_pad = 169, .npads = 24, .gpio_base = 256, .name = "GPP_C" },
40 { .first_pad = 193, .npads = 25, .gpio_base = 288, .name = "GPP_F" },
41 { .first_pad = 218,
42 .npads = 6,
43 .gpio_base = INTELGPIO_GPIO_NOMAP,
44 .name = "HVCMOS" },
45 { .first_pad = 224, .npads = 25, .gpio_base = 320, .name = "GPP_E" },
46 };
47
48 static const struct intelgpio_padgroup adln_com5_groups[] = {
49 { .first_pad = 249, .npads = 8, .gpio_base = 352, .name = "GPP_R" },
50 };
51
52 static const struct intelgpio_community adln_communities[] = {
53 { .ngroups = nitems(adln_com0_groups), .groups = adln_com0_groups },
54 { .ngroups = nitems(adln_com1_groups), .groups = adln_com1_groups },
55 { .ngroups = nitems(adln_com4_groups), .groups = adln_com4_groups },
56 { .ngroups = nitems(adln_com5_groups), .groups = adln_com5_groups },
57 };
58
59 static char *adln_hids[] = { "INTC1056", "INTC1057", "INTC1085", NULL };
60
61 static const struct intelgpio_platform adln_platform = {
62 .communities = adln_communities,
63 .ncommunities = nitems(adln_communities),
64 .hids = adln_hids,
65 .desc = "Intel Alder Lake-N GPIO",
66 };
67
68 static int
adln_probe(device_t dev)69 adln_probe(device_t dev)
70 {
71 return (intelgpio_probe(dev, &adln_platform));
72 }
73
74 static int
adln_attach(device_t dev)75 adln_attach(device_t dev)
76 {
77 return (intelgpio_attach(dev, &adln_platform));
78 }
79
80 static device_method_t adln_methods[] = {
81 DEVMETHOD(device_probe, adln_probe),
82 DEVMETHOD(device_attach, adln_attach),
83
84 DEVMETHOD_END
85 };
86
87 DEFINE_CLASS_1(gpio, adln_driver, adln_methods,
88 sizeof(struct intelgpio_softc), intelgpio_driver);
89
90 DRIVER_MODULE(adlngpio, acpi, adln_driver, NULL, NULL);
91 MODULE_DEPEND(adlngpio, acpi, 1, 1, 1);
92 MODULE_DEPEND(adlngpio, gpiobus, 1, 1, 1);
93 MODULE_VERSION(adlngpio, 1);
94 ACPI_PNP_INFO(adln_hids);
95