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 <superio/conf_mode.h>
6 #include <pc80/keyboard.h>
7 #include <superio/common/ssdt.h>
8 #include <acpi/acpi.h>
9 #include "ast2400.h"
10 #include "chip.h"
11 
12 static void ast2400_init(struct device *dev)
13 {
14  struct superio_aspeed_ast2400_config *conf = dev->chip_info;
15 
16  if (!dev->enabled)
17  return;
18 
19  if (conf && conf->use_espi) {
22  /* In ESPI mode must write 0 to IRQ level on every LDN */
23  pnp_write_config(dev, 0x71, 0);
24  pnp_exit_conf_mode(dev);
25  }
26 
27  switch (dev->path.pnp.device) {
28  case AST2400_KBC:
30  break;
31  }
32 }
33 
34 #if CONFIG(HAVE_ACPI_TABLES)
35 /* Provide ACPI HIDs for generic Super I/O SSDT */
36 static const char *ast2400_acpi_hid(const struct device *dev)
37 {
38  /* Sanity checks */
39  if (dev->path.type != DEVICE_PATH_PNP)
40  return NULL;
41  if (dev->path.pnp.port == 0)
42  return NULL;
43  if ((dev->path.pnp.device & 0xff) > AST2400_MAILBOX)
44  return NULL;
45 
46  switch (dev->path.pnp.device & 0xff) {
47  case AST2400_SUART1: /* fallthrough */
48  case AST2400_SUART2: /* fallthrough */
49  case AST2400_SUART3: /* fallthrough */
50  case AST2400_SUART4:
51  return ACPI_HID_COM;
52  case AST2400_KBC:
53  return ACPI_HID_KEYBOARD;
54  default:
55  return ACPI_HID_PNP;
56  }
57 }
58 #endif
59 
60 static struct device_operations ops = {
62  .set_resources = pnp_set_resources,
63  .enable_resources = pnp_enable_resources,
64  .enable = pnp_enable,
65  .init = ast2400_init,
66  .ops_pnp_mode = &pnp_conf_mode_a5a5_aa,
67 #if CONFIG(HAVE_ACPI_TABLES)
68  .acpi_fill_ssdt = superio_common_fill_ssdt_generator,
69  .acpi_name = superio_common_ldn_acpi_name,
70  .acpi_hid = ast2400_acpi_hid,
71 #endif
72 };
73 
74 static struct pnp_info pnp_dev_info[] = {
75  { NULL, AST2400_SUART1, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0xfff8, },
76  { NULL, AST2400_SUART2, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0xfff8, },
78  | PNP_IRQ0, 0xfff8, 0xfff8, 0xfff8, 0xfff8, },
80  | PNP_MSC0, 0xffff, 0xffff, },
81  { NULL, AST2400_GPIO, PNP_IRQ0, }, // GPIO LDN has no IO Region
82  { NULL, AST2400_SUART3, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0xfff8, },
83  { NULL, AST2400_SUART4, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0xfff8, },
85  { NULL, AST2400_MAILBOX, PNP_IO0 | PNP_IRQ0, 0xfffe, },
86 };
87 
88 static void enable_dev(struct device *dev)
89 {
90  struct superio_aspeed_ast2400_config *conf = dev->chip_info;
91 
92  if (conf && conf->use_espi) {
93  /* UART3 and UART4 are not usable in ESPI mode */
94  for (size_t i = 0; i < ARRAY_SIZE(pnp_dev_info); i++) {
95  if ((pnp_dev_info[i].function == AST2400_SUART3) ||
98  }
99  }
100 
102  pnp_dev_info);
103 }
104 
106  CHIP_NAME("ASpeed AST2400/AST2500 Super I/O")
107  .enable_dev = enable_dev,
108 };
static void ast2400_init(struct device *dev)
Definition: superio.c:12
struct chip_operations superio_aspeed_ast2400_ops
Definition: superio.c:105
static void enable_dev(struct device *dev)
Definition: superio.c:88
static struct device_operations ops
Definition: superio.c:60
static struct pnp_info pnp_dev_info[]
Definition: superio.c:74
#define AST2400_SWC
Definition: ast2400.h:8
#define AST2400_SUART3
Definition: ast2400.h:11
#define AST2400_SUART1
Definition: ast2400.h:6
#define AST2400_SUART4
Definition: ast2400.h:12
#define AST2400_SUART2
Definition: ast2400.h:7
#define AST2400_MAILBOX
Definition: ast2400.h:14
#define AST2400_GPIO
Definition: ast2400.h:10
#define AST2400_ILPC2AHB
Definition: ast2400.h:13
#define AST2400_KBC
Definition: ast2400.h:9
#define ARRAY_SIZE(a)
Definition: helpers.h:12
const struct pnp_mode_ops pnp_conf_mode_a5a5_aa
Definition: conf_mode.c:220
#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
@ DEVICE_PATH_PNP
Definition: path.h:10
#define PNP_IRQ1
Definition: pnp.h:48
#define PNP_SKIP_FUNCTION
Definition: pnp.h:39
#define PNP_IO1
Definition: pnp.h:43
#define PNP_IO2
Definition: pnp.h:44
#define PNP_IO0
Definition: pnp.h:42
#define PNP_IRQ0
Definition: pnp.h:47
#define PNP_IO3
Definition: pnp.h:45
#define PNP_MSC0
Definition: pnp.h:52
void pnp_exit_conf_mode(struct device *dev)
Definition: pnp_device.c:17
void pnp_enable(struct device *dev)
Definition: pnp_device.c:181
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_logical_device(struct device *dev)
Definition: pnp_device.c:59
void pnp_set_resources(struct device *dev)
Definition: pnp_device.c:157
void pnp_enter_conf_mode(struct device *dev)
Definition: pnp_device.c:11
void pnp_write_config(struct device *dev, u8 reg, u8 value)
Definition: pnp_device.c:38
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
DEVTREE_CONST void * chip_info
Definition: device.h:164
unsigned int enabled
Definition: device.h:122
Definition: pnp.h:37
u16 function
Definition: pnp.h:40
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