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 "nct5539d.h"
8 
9 #if CONFIG(HAVE_ACPI_TABLES)
10 #include <superio/common/ssdt.h>
11 #include <acpi/acpi.h>
12 #endif
13 
14 static void nct5539d_init(struct device *dev)
15 {
16  if (!dev->enabled)
17  return;
18 
19  switch (dev->path.pnp.device) {
20  case NCT5539D_KBC:
22  break;
23  }
24 }
25 
26 #if CONFIG(HAVE_ACPI_TABLES)
27 /* Provide ACPI HIDs for generic Super I/O SSDT */
28 static const char *nct5539d_acpi_hid(const struct device *dev)
29 {
30  if ((dev->path.type != DEVICE_PATH_PNP) ||
31  (dev->path.pnp.port == 0) ||
32  ((dev->path.pnp.device & 0xff) > NCT5539D_DS))
33  return NULL;
34 
35  switch (dev->path.pnp.device & 0xff) {
36  case NCT5539D_SP1:
37  return ACPI_HID_COM;
38  case NCT5539D_KBC:
39  return ACPI_HID_KEYBOARD;
40  default:
41  return ACPI_HID_PNP;
42  }
43 }
44 #endif
45 
46 static struct device_operations ops = {
48  .set_resources = pnp_set_resources,
49  .enable_resources = pnp_enable_resources,
50  .enable = pnp_alt_enable,
51  .init = nct5539d_init,
52  .ops_pnp_mode = &pnp_conf_mode_8787_aa,
53 #if CONFIG(HAVE_ACPI_TABLES)
54  .acpi_fill_ssdt = superio_common_fill_ssdt_generator,
55  .acpi_name = superio_common_ldn_acpi_name,
56  .acpi_hid = nct5539d_acpi_hid,
57 #endif
58 };
59 
60 static struct pnp_info pnp_dev_info[] = {
62  0x0ff8, },
64  0x0fff, 0x0fff, },
66  0x0ff8, },
67  { NULL, NCT5539D_ACPI},
69  0x0ffe, 0x0ffe, },
70  { NULL, NCT5539D_WDT2},
72  0x0ff8, },
74  { NULL, NCT5539D_WDT1},
75  { NULL, NCT5539D_WDT3},
77  0x0ff8, },
78  { NULL, NCT5539D_GPIO0},
79  { NULL, NCT5539D_GPIO2},
80  { NULL, NCT5539D_GPIO3},
81  { NULL, NCT5539D_GPIO4},
82  { NULL, NCT5539D_GPIO5},
83  { NULL, NCT5539D_GPIO7},
84  { NULL, NCT5539D_GPIO8},
86  { NULL, NCT5539D_SWEC},
87  { NULL, NCT5539D_FLED},
88  { NULL, NCT5539D_DS5},
89  { NULL, NCT5539D_DS3},
90 };
91 
92 static void enable_dev(struct device *dev)
93 {
95 }
96 
98  CHIP_NAME("NUVOTON NCT5539D Super I/O")
99  .enable_dev = enable_dev,
100 };
#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 NCT5539D_SWEC
Definition: nct5539d.h:19
#define NCT5539D_GPIO5
Definition: nct5539d.h:31
#define NCT5539D_DS3
Definition: nct5539d.h:35
#define NCT5539D_HWM_FPLED
Definition: nct5539d.h:14
#define NCT5539D_CIR
Definition: nct5539d.h:9
#define NCT5539D_WDT2
Definition: nct5539d.h:15
#define NCT5539D_WDT3
Definition: nct5539d.h:25
#define NCT5539D_ACPI
Definition: nct5539d.h:13
#define NCT5539D_GPIO_PSO
Definition: nct5539d.h:18
#define NCT5539D_GPIO7
Definition: nct5539d.h:32
#define NCT5539D_DS5
Definition: nct5539d.h:34
#define NCT5539D_GPIO_PP_OD
Definition: nct5539d.h:17
#define NCT5539D_DS
Definition: nct5539d.h:21
#define NCT5539D_WDT1
Definition: nct5539d.h:24
#define NCT5539D_FLED
Definition: nct5539d.h:20
#define NCT5539D_GPIO0
Definition: nct5539d.h:27
#define NCT5539D_GPIO8
Definition: nct5539d.h:33
#define NCT5539D_KBC
Definition: nct5539d.h:8
#define NCT5539D_GPIO4
Definition: nct5539d.h:30
#define NCT5539D_SP1
Definition: nct5539d.h:7
#define NCT5539D_GPIOBASE
Definition: nct5539d.h:26
#define NCT5539D_CIRWUP
Definition: nct5539d.h:16
#define NCT5539D_GPIO3
Definition: nct5539d.h:29
#define NCT5539D_GPIO2
Definition: nct5539d.h:28
struct chip_operations superio_nuvoton_nct5539d_ops
Definition: superio.c:97
static void enable_dev(struct device *dev)
Definition: superio.c:92
static struct device_operations ops
Definition: superio.c:46
static struct pnp_info pnp_dev_info[]
Definition: superio.c:60
static void nct5539d_init(struct device *dev)
Definition: superio.c:14
@ DEVICE_PATH_PNP
Definition: path.h:10
#define PNP_IRQ1
Definition: pnp.h:48
#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