coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_serial.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <arch/io.h>
4 #include <device/pnp_ops.h>
5 #include <device/pnp.h>
6 #include <stdint.h>
7 #include "ite.h"
8 
9 /* Global configuration registers. */
10 #define ITE_CONFIG_REG_CC 0x02 /* Configure Control (write-only). */
11 #define ITE_CONFIG_REG_LDN 0x07 /* Logical Device Number. */
12 #define ITE_CONFIG_REG_CLOCKSEL 0x23 /* Clock Selection. */
13 #define ITE_CONFIG_REG_SWSUSP 0x24 /* Software Suspend, Flash I/F. */
14 #define ITE_CONFIG_REG_MFC 0x2a /* multi function pin */
15 #define ITE_CONFIG_REG_WATCHDOG 0x72 /* watchdog config */
16 
17 /* Helper procedure */
18 static void ite_sio_write(pnp_devfn_t dev, u8 reg, u8 value)
19 {
21  pnp_write_config(dev, reg, value);
22 }
23 
24 /* Enable configuration */
26 {
27  u16 port = dev >> 8;
28 
29  outb(0x87, port);
30  outb(0x01, port);
31  outb(0x55, port);
32  outb((port == 0x4e) ? 0xaa : 0x55, port);
33 }
34 
35 /* Disable configuration */
37 {
38  ite_sio_write(dev, ITE_CONFIG_REG_CC, 0x02);
39 }
40 
42 {
44  ite_sio_write(dev, reg, value);
46 }
47 
48 /*
49  * in romstage.c
50  * #define CLKIN_DEV PNP_DEV(0x2e, ITE_GPIO)
51  * and pass: CLKIN_DEV
52  * ITE_UART_CLK_PREDIVIDE_24
53  * ITE_UART_CLK_PREDIVIDE_48 (default)
54  */
55 void ite_conf_clkin(pnp_devfn_t dev, u8 predivide)
56 {
57  ite_reg_write(dev, ITE_CONFIG_REG_CLOCKSEL, (0x1 & predivide));
58 }
59 
60 /* Bring up early serial debugging output before the RAM is initialized. */
62 {
65  pnp_set_enable(dev, 0);
66  pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
67  pnp_set_enable(dev, 1);
69 }
70 
71 /*
72  *
73  * LDN 7, reg 0x2a - needed for S3, or memory power will be cut off
74  * this was documented only in IT8712F_V0.9.2!
75  *
76  * Enable 3VSBSW#. (For System Suspend-to-RAM)
77  * 0: 3VSBSW# will be always inactive.
78  * 1: 3VSBSW# enabled. It will be (NOT SUSB#) NAND SUSC#.
79  *
80  * in romstage.c
81  * #define GPIO_DEV PNP_DEV(0x2e, ITE_GPIO)
82  * and pass: GPIO_DEV
83  */
84 
86 {
87  u8 tmp;
91  tmp |= 0x80;
94 }
95 
96 /*
97  *
98  * LDN 7, reg 0x2a, bit 0 - delay PWRGD3 rising edge after 3VSBSW# rising edge
99  * This can be needed for S3 resume.
100  * Documented in IT8728F V0.4.2 but also applies to IT8720F where it is marked
101  * as reserved.
102  *
103  * Delay PWRGD3 assertion after setting 3VSBSW#.
104  * 0: There will be no extra delay before PWRGD3 is set.
105  * 1: The delay after 3VSBSW# rising edge before PWRGD3 is set is increased.
106  *
107  * in romstage.c
108  * #define GPIO_DEV PNP_DEV(0x2e, ITE_GPIO)
109  * and pass: GPIO_DEV
110  */
111 
113 {
114  u8 tmp;
118  tmp |= 0x01;
120  pnp_exit_conf_state(dev);
121 }
122 
123 /*
124  * in romstage.c
125  * #define GPIO_DEV PNP_DEV(0x2e, ITE_GPIO)
126  * and pass: GPIO_DEV
127 */
128 
130 {
133  pnp_exit_conf_state(dev);
134 }
pte_t value
Definition: mmu.c:91
void pnp_exit_conf_state(pnp_devfn_t dev)
Definition: early_serial.c:38
void pnp_enter_conf_state(pnp_devfn_t dev)
Definition: early_serial.c:30
void outb(u8 val, u16 port)
port
Definition: i915.h:29
#define ITE_CONFIG_REG_CLOCKSEL
Definition: early_serial.c:12
void ite_delay_pwrgd3(pnp_devfn_t dev)
Definition: early_serial.c:112
void ite_enable_serial(pnp_devfn_t dev, u16 iobase)
Definition: early_serial.c:61
void ite_reg_write(pnp_devfn_t dev, u8 reg, u8 value)
Definition: early_serial.c:41
void ite_kill_watchdog(pnp_devfn_t dev)
Definition: early_serial.c:129
static void ite_sio_write(pnp_devfn_t dev, u8 reg, u8 value)
Definition: early_serial.c:18
void ite_conf_clkin(pnp_devfn_t dev, u8 predivide)
Definition: early_serial.c:55
void ite_enable_3vsbsw(pnp_devfn_t dev)
Definition: early_serial.c:85
#define ITE_CONFIG_REG_WATCHDOG
Definition: early_serial.c:15
#define ITE_CONFIG_REG_CC
Definition: early_serial.c:10
#define ITE_CONFIG_REG_MFC
Definition: early_serial.c:14
#define PNP_IDX_IO0
Definition: pnp_def.h:5
void pnp_set_logical_device(struct device *dev)
Definition: pnp_device.c:59
void pnp_set_enable(struct device *dev, int enable)
Definition: pnp_device.c:64
u8 pnp_read_config(struct device *dev, u8 reg)
Definition: pnp_device.c:44
void pnp_set_iobase(struct device *dev, u8 index, u16 iobase)
Definition: pnp_device.c:93
void pnp_write_config(struct device *dev, u8 reg, u8 value)
Definition: pnp_device.c:38
u32 pnp_devfn_t
Definition: pnp_type.h:8
uint16_t u16
Definition: stdint.h:48
uint8_t u8
Definition: stdint.h:45