Debian Codegraph @

src/southbridge/intel/lynxpoint/early_pch.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <console/console.h>
4 #include <device/pci_ops.h>
5 #include <device/device.h>
6 #include <device/pci_def.h>
7 #include <device/smbus_host.h>
8 #include <southbridge/intel/common/pmbase.h>
9
10 #include "pch.h"
11 #include "chip.h"
12
13 #if CONFIG(INTEL_LYNXPOINT_LP)
14 #include "lp_gpio.h"
15 #else
16 #include <southbridge/intel/common/gpio.h>
17 #endif
18
19 enum pch_platform_type get_pch_platform_type(void)
20 {
21 const u16 did = pci_read_config16(PCH_LPC_DEV, PCI_DEVICE_ID);
22
23 /* Check if this is a LPT-LP or WPT-LP device ID */
24 if ((did & 0xff00) == 0x9c00)
25 return PCH_TYPE_ULT;
26
27 /* Non-LP laptop SKUs have an odd device ID (least significant bit is one) */
28 if (did & 1)
29 return PCH_TYPE_MOBILE;
30
31 /* Desktop and Server SKUs have an even device ID */
32 return PCH_TYPE_DESKTOP;
33 }
34
35 static void pch_enable_bars(void)
36 {
37 pci_write_config32(PCH_LPC_DEV, RCBA, CONFIG_FIXED_RCBA_MMIO_BASE | 1);
38
39 pci_write_config32(PCH_LPC_DEV, PMBASE, DEFAULT_PMBASE | 1);
40 /* Enable ACPI BAR */
41 pci_write_config8(PCH_LPC_DEV, ACPI_CNTL, ACPI_EN);
42
43 pci_write_config32(PCH_LPC_DEV, GPIO_BASE, DEFAULT_GPIOBASE | 1);
44
45 /* Enable GPIO functionality. */
46 pci_write_config8(PCH_LPC_DEV, GPIO_CNTL, 0x10);
47 }
48
49 static void pch_generic_setup(void)
50 {
51 printk(BIOS_DEBUG, "Disabling Watchdog reboot...");
52 RCBA32(GCS) = RCBA32(GCS) | (1 << 5); /* No reset */
53 write_pmbase16(0x60 | 0x08, (1 << 11)); /* halt timer */
54 printk(BIOS_DEBUG, " done.\n");
55 }
56
57 void pch_enable_lpc(void)
58 {
59 const struct device *dev = pcidev_on_root(0x1f, 0);
60 const struct southbridge_intel_lynxpoint_config *config = NULL;
61
62 /* Set COM1/COM2 decode range */
63 pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010);
64
65 /* Enable SuperIO + MC + COM1 + PS/2 Keyboard/Mouse */
66 u16 lpc_config = CNF1_LPC_EN | CNF2_LPC_EN | GAMEL_LPC_EN |
67 COMA_LPC_EN | KBC_LPC_EN | MC_LPC_EN;
68 pci_write_config16(PCH_LPC_DEV, LPC_EN, lpc_config);
69
70 /* Set up generic decode ranges */
71 if (!dev)
72 return;
73 if (dev->chip_info)
74 config = dev->chip_info;
75 if (!config)
76 return;
77
78 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, config->gen1_dec);
79 pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, config->gen2_dec);
80 pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, config->gen3_dec);
81 pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, config->gen4_dec);
82 }
83
84 void __weak mainboard_config_superio(void)
85 {
86 }
87
88 void early_pch_init(void)
89 {
90 pch_enable_bars();
91
92 #if CONFIG(INTEL_LYNXPOINT_LP)
93 setup_pch_lp_gpios(mainboard_lp_gpio_map);
94 #else
95 setup_pch_gpios(&mainboard_gpio_map);
96 #endif
97 pch_generic_setup();
98
99 /* Enable SMBus for reading SPDs. */
100 enable_smbus();
101
102 /* Enable IOAPIC */
103 RCBA16(OIC) = 0x0100;
104
105 /* PCH BWG says to read back the IOAPIC enable register */
106 (void)RCBA16(OIC);
107
108 /* Mainboard RCBA settings */
109 mainboard_config_rcba();
110
111 RCBA32_OR(FD, PCH_DISABLE_ALWAYS);
112
113 RCBA32(0x2088) = 0x00109000;
114
115 RCBA32_OR(0x20ac, 1 << 30);
116
117 if (!pch_is_lp()) {
118 RCBA32_AND_OR(0x2340, ~(0xff << 0), 0x1b << 0);
119 RCBA32_AND_OR(0x2340, ~(0xff << 16), 0x3a << 16);
120
121 RCBA32(0x2324) = 0x00854c74;
122 }
123 }