coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
superio.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <device/device.h>
4 #include <device/pnp.h>
5 #include <pc80/keyboard.h>
6 #include <superio/conf_mode.h>
7 #include <superio/common/ssdt.h>
8 #include <acpi/acpi.h>
9 #include "nct6791d.h"
10 
11 static void nct6791d_init(struct device *dev)
12 {
13  if (!dev->enabled)
14  return;
15 
16  switch (dev->path.pnp.device) {
17  case NCT6791D_KBC:
19  break;
20  }
21 }
22 
23 #if CONFIG(HAVE_ACPI_TABLES)
24 /* Provide ACPI HIDs for generic Super I/O SSDT */
25 static const char *nct6791d_acpi_hid(const struct device *dev)
26 {
27  if ((dev->path.type != DEVICE_PATH_PNP) ||
28  (dev->path.pnp.port == 0) ||
29  ((dev->path.pnp.device & 0xff) > NCT6791D_DS))
30  return NULL;
31 
32  switch (dev->path.pnp.device & 0xff) {
33  case NCT6791D_SP1: /* fallthrough */
34  case NCT6791D_SP2:
35  return ACPI_HID_COM;
36  case NCT6791D_KBC:
37  return ACPI_HID_KEYBOARD;
38  default:
39  return ACPI_HID_PNP;
40  }
41 }
42 #endif
43 
44 static struct device_operations ops = {
46  .set_resources = pnp_set_resources,
47  .enable_resources = pnp_enable_resources,
48  .enable = pnp_alt_enable,
49  .init = nct6791d_init,
50  .ops_pnp_mode = &pnp_conf_mode_8787_aa,
51 #if CONFIG(HAVE_ACPI_TABLES)
52  .acpi_fill_ssdt = superio_common_fill_ssdt_generator,
53  .acpi_name = superio_common_ldn_acpi_name,
54  .acpi_hid = nct6791d_acpi_hid,
55 #endif
56 };
57 
58 static struct pnp_info pnp_dev_info[] = {
60  0x0ff8, },
62  0x0ff8, },
64  0x0ff8, },
66  0x0fff, 0x0fff, },
68  0x0ff8, },
69  { NULL, NCT6791D_ACPI},
71  0x0ffe, 0x0ffe, },
74  0x0ff8, },
77  { NULL, NCT6791D_WDT1},
80  0x0ff8, },
81  { NULL, NCT6791D_GPIO0},
82  { NULL, NCT6791D_GPIO1},
83  { NULL, NCT6791D_GPIO2},
84  { NULL, NCT6791D_GPIO3},
85  { NULL, NCT6791D_GPIO4},
86  { NULL, NCT6791D_GPIO5},
87  { NULL, NCT6791D_GPIO6},
88  { NULL, NCT6791D_GPIO7},
89  { NULL, NCT6791D_GPIO8},
90  { NULL, NCT6791D_DS5},
91  { NULL, NCT6791D_DS3},
95  { NULL, NCT6791D_DSDSS},
96  { NULL, NCT6791D_DSPU},
97 };
98 
99 static void enable_dev(struct device *dev)
100 {
102 }
103 
105  CHIP_NAME("NUVOTON NCT6791D Super I/O")
106  .enable_dev = enable_dev,
107 };
#define ARRAY_SIZE(a)
Definition: helpers.h:12
const struct pnp_mode_ops pnp_conf_mode_8787_aa
Definition: conf_mode.c:202
#define ACPI_HID_COM
Definition: acpi.h:148
#define ACPI_HID_PNP
Definition: acpi.h:150
#define ACPI_HID_KEYBOARD
Definition: acpi.h:146
#define CHIP_NAME(X)
Definition: device.h:32
uint8_t pc_keyboard_init(uint8_t probe_aux)
Definition: keyboard.c:229
#define NO_AUX_DEVICE
Definition: keyboard.h:6
#define NCT6791D_DS3OPT
Definition: nct6791d.h:40
#define NCT6791D_GPIO6
Definition: nct6791d.h:33
#define NCT6791D_PP
Definition: nct6791d.h:7
#define NCT6791D_GPIO2
Definition: nct6791d.h:29
#define NCT6791D_PCHDSW
Definition: nct6791d.h:38
#define NCT6791D_DS3
Definition: nct6791d.h:37
#define NCT6791D_GPIO8
Definition: nct6791d.h:35
#define NCT6791D_GPIO_PP_OD
Definition: nct6791d.h:19
#define NCT6791D_SP2
Definition: nct6791d.h:9
#define NCT6791D_GPIO5
Definition: nct6791d.h:32
#define NCT6791D_GPIO4
Definition: nct6791d.h:31
#define NCT6791D_CIRWUP
Definition: nct6791d.h:18
#define NCT6791D_WDTMEM
Definition: nct6791d.h:25
#define NCT6791D_DSWWOPT
Definition: nct6791d.h:39
#define NCT6791D_GPIO7
Definition: nct6791d.h:34
#define NCT6791D_HWM_FPLED
Definition: nct6791d.h:16
#define NCT6791D_SP1
Definition: nct6791d.h:8
#define NCT6791D_CIR
Definition: nct6791d.h:11
#define NCT6791D_GPIO0
Definition: nct6791d.h:27
#define NCT6791D_DSPU
Definition: nct6791d.h:42
#define NCT6791D_WDT1
Definition: nct6791d.h:24
#define NCT6791D_GPIO1
Definition: nct6791d.h:28
#define NCT6791D_DS
Definition: nct6791d.h:21
#define NCT6791D_DS5
Definition: nct6791d.h:36
#define NCT6791D_KBC
Definition: nct6791d.h:10
#define NCT6791D_BCLK_WDT2_WDTMEM
Definition: nct6791d.h:17
#define NCT6791D_GPIO3
Definition: nct6791d.h:30
#define NCT6791D_GPIOBASE
Definition: nct6791d.h:26
#define NCT6791D_PORT80
Definition: nct6791d.h:20
#define NCT6791D_ACPI
Definition: nct6791d.h:15
#define NCT6791D_DSDSS
Definition: nct6791d.h:41
static void nct6791d_init(struct device *dev)
Definition: superio.c:11
static void enable_dev(struct device *dev)
Definition: superio.c:99
static struct device_operations ops
Definition: superio.c:44
static struct pnp_info pnp_dev_info[]
Definition: superio.c:58
struct chip_operations superio_nuvoton_nct6791d_ops
Definition: superio.c:104
@ DEVICE_PATH_PNP
Definition: path.h:10
#define PNP_IRQ1
Definition: pnp.h:48
#define PNP_DRQ0
Definition: pnp.h:49
#define PNP_IO1
Definition: pnp.h:43
#define PNP_IO0
Definition: pnp.h:42
#define PNP_IRQ0
Definition: pnp.h:47
void pnp_read_resources(struct device *dev)
Definition: pnp_device.c:114
void pnp_enable_devices(struct device *base_dev, struct device_operations *ops, unsigned int functions, struct pnp_info *info)
Definition: pnp_device.c:371
void pnp_set_resources(struct device *dev)
Definition: pnp_device.c:157
void pnp_alt_enable(struct device *dev)
Definition: pnp_device.c:191
void pnp_enable_resources(struct device *dev)
Definition: pnp_device.c:173
#define NULL
Definition: stddef.h:19
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct pnp_path pnp
Definition: path.h:117
enum device_path_type type
Definition: path.h:114
Definition: device.h:107
struct device_path path
Definition: device.h:115
unsigned int enabled
Definition: device.h:122
Definition: pnp.h:37
unsigned int port
Definition: path.h:58
unsigned int device
Definition: path.h:59
const char * superio_common_ldn_acpi_name(const struct device *dev)
Definition: ssdt.c:128
void superio_common_fill_ssdt_generator(const struct device *dev)
Definition: ssdt.c:162