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 <stdint.h>
7 #include <pc80/keyboard.h>
8 
9 #include "w83627uhg.h"
10 
11 /*
12  * Set the UART clock source.
13  *
14  * Possible UART clock source speeds are:
15  *
16  * 0 = 1.8462 MHz (default)
17  * 1 = 2 MHz
18  * 2 = 24 MHz
19  * 3 = 14.769 MHz
20  *
21  * The faster clocks allow for BAUD rates up to 2mbits.
22  *
23  * Warning: The kernel will need to be adjusted since it assumes
24  * a 1.8462 MHz clock.
25  */
26 static void set_uart_clock_source(struct device *dev, u8 uart_clock)
27 {
28  u8 value;
29 
33  value &= ~0x03;
34  value |= (uart_clock & 0x03);
36  pnp_exit_conf_mode(dev);
37 }
38 
39 static void w83627uhg_init(struct device *dev)
40 {
41 
42  if (!dev->enabled)
43  return;
44 
45  switch (dev->path.pnp.device) {
46  case W83627UHG_SP1:
47  set_uart_clock_source(dev, 0);
48  break;
49  case W83627UHG_SP2:
50  set_uart_clock_source(dev, 0);
51  break;
52  case W83627UHG_SP3:
53  set_uart_clock_source(dev, 0);
54  break;
55  case W83627UHG_SP4:
56  set_uart_clock_source(dev, 0);
57  break;
58  case W83627UHG_SP5:
59  set_uart_clock_source(dev, 0);
60  break;
61  case W83627UHG_SP6:
62  set_uart_clock_source(dev, 0);
63  break;
64  case W83627UHG_KBC:
66  break;
67  }
68 }
69 
70 static struct device_operations ops = {
72  .set_resources = pnp_set_resources,
73  .enable_resources = pnp_enable_resources,
74  .enable = pnp_enable,
75  .init = w83627uhg_init,
76  .ops_pnp_mode = &pnp_conf_mode_8787_aa,
77 };
78 
79 static struct pnp_info pnp_dev_info[] = {
80  { NULL, W83627UHG_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
81  { NULL, W83627UHG_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
82  { NULL, W83627UHG_SP1, PNP_IO0 | PNP_IRQ0, 0x07f8, },
83  { NULL, W83627UHG_SP2, PNP_IO0 | PNP_IRQ0, 0x07f8, },
85  0x07ff, 0x07ff, },
86  { NULL, W83627UHG_SP3, PNP_IO0 | PNP_IRQ0, 0x07f8, },
87  { NULL, W83627UHG_GPIO3_4, },
89  { NULL, W83627UHG_GPIO1_2, },
91  { NULL, W83627UHG_HWM, PNP_IO0 | PNP_IRQ0, 0x0ff8, },
93  { NULL, W83627UHG_SP4, PNP_IO0 | PNP_IRQ0, 0x07f8, },
94  { NULL, W83627UHG_SP5, PNP_IO0 | PNP_IRQ0, 0x07f8, },
95  { NULL, W83627UHG_SP6, PNP_IO0 | PNP_IRQ0, 0x07f8, },
96 };
97 
98 static void enable_dev(struct device *dev)
99 {
101 }
102 
104  CHIP_NAME("Winbond W83627UHG Super I/O")
105  .enable_dev = enable_dev,
106 };
pte_t value
Definition: mmu.c:91
#define ARRAY_SIZE(a)
Definition: helpers.h:12
const struct pnp_mode_ops pnp_conf_mode_8787_aa
Definition: conf_mode.c:202
#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 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
#define PNP_IDX_MSC0
Definition: pnp_def.h:14
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
u8 pnp_read_config(struct device *dev, u8 reg)
Definition: pnp_device.c:44
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
uint8_t u8
Definition: stdint.h:45
void(* read_resources)(struct device *dev)
Definition: device.h:39
struct pnp_path pnp
Definition: path.h:117
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 device
Definition: path.h:59
#define W83627UHG_SP4
Definition: w83627uhg.h:18
#define W83627UHG_SP3
Definition: w83627uhg.h:11
#define W83627UHG_SP6
Definition: w83627uhg.h:20
#define W83627UHG_GPIO1_2
Definition: w83627uhg.h:14
#define W83627UHG_SP5
Definition: w83627uhg.h:19
#define W83627UHG_SP1
Definition: w83627uhg.h:8
#define W83627UHG_FDC
Definition: w83627uhg.h:6
#define W83627UHG_ACPI
Definition: w83627uhg.h:15
#define W83627UHG_PP
Definition: w83627uhg.h:7
#define W83627UHG_SP2
Definition: w83627uhg.h:9
#define W83627UHG_WDTO_PLED_GPIO5_6
Definition: w83627uhg.h:13
#define W83627UHG_GPIO3_4
Definition: w83627uhg.h:12
#define W83627UHG_PECI_SST
Definition: w83627uhg.h:17
#define W83627UHG_KBC
Definition: w83627uhg.h:10
#define W83627UHG_HWM
Definition: w83627uhg.h:16
static void enable_dev(struct device *dev)
Definition: superio.c:98
struct chip_operations superio_winbond_w83627uhg_ops
Definition: superio.c:103
static struct device_operations ops
Definition: superio.c:70
static void w83627uhg_init(struct device *dev)
Definition: superio.c:39
static struct pnp_info pnp_dev_info[]
Definition: superio.c:79
static void set_uart_clock_source(struct device *dev, u8 uart_clock)
Definition: superio.c:26