coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootblock.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <bootblock_common.h>
4 #include <device/pnp_def.h>
5 #include <device/pnp_ops.h>
6 #include <device/pnp_type.h>
7 #include <stdint.h>
8 #include <amdblocks/acpimmio.h>
11 
12 /* Ensure Super I/O config address (i.e., 0x2e or 0x4e) matches that of devicetree.cb */
13 #define SUPERIO_ADDRESS 0x4e
14 
15 #define SERIAL_DEV PNP_DEV(SUPERIO_ADDRESS, F71869AD_SP1)
16 #define GPIO_DEV PNP_DEV(SUPERIO_ADDRESS, F71869AD_GPIO)
17 
18 /* GPIO configuration */
19 static void gpio_init(pnp_devfn_t dev)
20 {
23  pnp_set_enable(dev, 0);
24  pnp_write_config(dev, PNP_IDX_IO0, 0x0a); //Base addr high
25  pnp_write_config(dev, 0x61, 0x00); //Base addr low
26  pnp_write_config(dev, 0xe0, 0x04); //GPIO1 output enable
27  pnp_write_config(dev, 0xe1, 0xff); //GPIO1 output data
28  pnp_write_config(dev, 0xe3, 0x04); //GPIO1 drive enable
29  pnp_write_config(dev, 0xe4, 0x00); //GPIO1 PME enable
30  pnp_write_config(dev, 0xe5, 0x00); //GPIO1 input detect select
31  pnp_write_config(dev, 0xe6, 0x40); //GPIO1 event status
32  pnp_write_config(dev, 0xd0, 0x00); //GPIO2 output enable
33  pnp_write_config(dev, 0xd1, 0xff); //GPIO2 output data
34  pnp_write_config(dev, 0xd3, 0x00); //GPIO2 drive enable
35  pnp_write_config(dev, 0xc0, 0x00); //GPIO3 output enable
36  pnp_write_config(dev, 0xc1, 0xff); //GPIO3 output data
37  pnp_write_config(dev, 0xb0, 0x04); //GPIO4 output enable
38  pnp_write_config(dev, 0xb1, 0x04); //GPIO4 output data
39  pnp_write_config(dev, 0xb3, 0x04); //GPIO4 drive enable
40  pnp_write_config(dev, 0xb4, 0x00); //GPIO4 PME enable
41  pnp_write_config(dev, 0xb5, 0x00); //GPIO4 input detect select
42  pnp_write_config(dev, 0xb6, 0x00); //GPIO4 event status
43  pnp_write_config(dev, 0xa0, 0x00); //GPIO5 output enable
44  pnp_write_config(dev, 0xa1, 0x1f); //GPIO5 output data
45  pnp_write_config(dev, 0xa3, 0x00); //GPIO5 drive enable
46  pnp_write_config(dev, 0xa4, 0x00); //GPIO5 PME enable
47  pnp_write_config(dev, 0xa5, 0xff); //GPIO5 input detect select
48  pnp_write_config(dev, 0xa6, 0xe0); //GPIO5 event status
49  pnp_write_config(dev, 0x90, 0x00); //GPIO6 output enable
50  pnp_write_config(dev, 0x91, 0xff); //GPIO6 output data
51  pnp_write_config(dev, 0x93, 0x00); //GPIO6 drive enable
52  pnp_write_config(dev, 0x80, 0x00); //GPIO7 output enable
53  pnp_write_config(dev, 0x81, 0xff); //GPIO7 output data
54  pnp_write_config(dev, 0x83, 0x00); //GPIO7 drive enable
55  pnp_set_enable(dev, 1);
57 }
58 
59 static void sbxxx_enable_48mhzout(void)
60 {
61  /* most likely programming to 48MHz out signal */
62  u32 reg32;
63  reg32 = misc_read32(0x28);
64  reg32 &= 0xffc7ffff;
65  reg32 |= 0x00100000;
66  misc_write32(0x28, reg32);
67 
68  reg32 = misc_read32(0x40);
69  reg32 &= ~0x80u;
70  misc_write32(0x40, reg32);
71 }
72 
74 {
75  /* enable SIO clock */
77 
78  /* Initialize GPIO registers */
80 
81  /* Enable serial console */
82  fintek_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
83 }
static uint32_t misc_read32(uint8_t reg)
Definition: acpimmio.h:266
static void misc_write32(uint8_t reg, uint32_t value)
Definition: acpimmio.h:281
static void pnp_enter_conf_state(pnp_devfn_t dev)
Definition: bootblock.c:13
static void pnp_exit_conf_state(pnp_devfn_t dev)
Definition: bootblock.c:19
void fintek_enable_serial(pnp_devfn_t dev, u16 iobase)
Definition: early_serial.c:47
__weak void bootblock_mainboard_early_init(void)
Definition: bootblock.c:16
#define GPIO_DEV
Definition: bootblock.c:16
static void sbxxx_enable_48mhzout(void)
Definition: bootblock.c:59
static void gpio_init(pnp_devfn_t dev)
Definition: bootblock.c:19
#define SERIAL_DEV
Definition: bootblock.c:15
#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
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
uint32_t u32
Definition: stdint.h:51