1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <console/console.h>
5 #include <device/device.h>
6 #include <device/pci_ops.h>
7 #include <drivers/intel/gma/int15.h>
8 #include <southbridge/intel/bd82x6x/pch.h>
9 #include <southbridge/intel/common/gpio.h>
10 #include <superio/smsc/sch5545/sch5545.h>
12 #include <baseboard/sch5545_ec.h>
16 #define GPIO_CHASSIS_ID0 1
17 #define GPIO_VGA_CABLE_DET_L 4
19 #define GPIO_CHASSIS_ID1 17
20 /* Internal USB header on mainboard */
21 #define FLEXBAY_HEADER_CABLE_DET_L 20
22 #define GPIO_BOARD_REV0 21
23 /* Password clear jumper */
24 #define GPIO_PSWD_CLR 31
27 #define GPIO_CHASSIS_ID2 37
28 /* Front panel presence */
29 #define GPIO_FRONT_PANEL_PRESENT_L 39
30 #define GPIO_INTRUDER_CABLE_DET_L 44
31 #define GPIO_BOARD_REV1 46
32 #define GPIO_BOARD_REV2 68
33 /* Front USB 3.0 ports */
34 #define GPIO_USB_HEADER_DET_L 69
35 /* Differentiate between MT/DT on the Medium Tower and Desktop variants */
36 #define GPIO_FRONT_PANEL_CHASSIS_DET_L 70
38 * This GPIO is connected to the transistor gate. If high, it will pull the
39 * HDA_SDO high. When strapped at PCH_PWROK it will enable the Flash Descriptor
40 * Security Override and disable ME after chipset bringup. Alternative method
41 * is to use the service jumper on the mainboard.
43 #define GPIO_ME_MFG_MODE 74
45 /* These GPIOs are on SCH5545 */
47 /* Detect if the power switch cable is connected */
48 #define SIO_GPIO_FP_CBL_DET_L 25
49 /* Detect internal speaker connected to front cover */
50 #define SIO_GPIO_PCSPKR_DET_L 31
52 static void mainboard_enable(struct device
*dev
)
55 install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_NONE
,
56 GMA_INT15_PANEL_FIT_DEFAULT
,
57 GMA_INT15_BOOT_DISPLAY_DEFAULT
, 0);
59 pin_sts
= get_gpio(GPIO_CHASSIS_ID0
);
60 pin_sts
|= get_gpio(GPIO_CHASSIS_ID1
) << 1;
61 pin_sts
|= get_gpio(GPIO_CHASSIS_ID2
) << 2;
62 pin_sts
|= get_gpio(GPIO_FRONT_PANEL_CHASSIS_DET_L
) << 3;
64 printk(BIOS_DEBUG
, "Chassis type: ");
67 printk(BIOS_DEBUG
, "MT\n");
71 printk(BIOS_DEBUG
, "USFF\n");
74 /* As per table in schematics, but don't know what this is */
75 printk(BIOS_DEBUG
, "Comoros\n");
81 printk(BIOS_DEBUG
, "SFF\n");
84 printk(BIOS_DEBUG
, "DT\n");
87 printk(BIOS_DEBUG
, "Unknown chassis type %u\n", pin_sts
);
91 pin_sts
= get_gpio(GPIO_BOARD_REV0
);
92 pin_sts
|= get_gpio(GPIO_BOARD_REV1
) << 1;
93 pin_sts
|= get_gpio(GPIO_BOARD_REV2
) << 2;
95 printk(BIOS_DEBUG
, "Board revision: %d\n", pin_sts
);
97 pin_sts
= get_gpio(GPIO_SKU0
);
98 pin_sts
|= get_gpio(GPIO_SKU1
) << 1;
99 pin_sts
|= get_gpio(GPIO_SKU2
) << 2;
101 printk(BIOS_DEBUG
, "SKU ID is %d:", pin_sts
);
104 printk(BIOS_DEBUG
, "TPM\n");
107 printk(BIOS_DEBUG
, "TCM\n");
110 printk(BIOS_DEBUG
, "Non TPM/TCM\n");
113 printk(BIOS_DEBUG
, "Unknown/reserved\n");
117 printk(BIOS_DEBUG
, "VGA cable %sconnected\n",
118 get_gpio(GPIO_VGA_CABLE_DET_L
) ? "dis" : "");
120 printk(BIOS_DEBUG
, "Flexbay %sattached to internal USB 2.0 header\n",
121 get_gpio(FLEXBAY_HEADER_CABLE_DET_L
) ? "not " : "");
123 printk(BIOS_DEBUG
, "Password clear jumper %sactive\n",
124 get_gpio(GPIO_PSWD_CLR
) ? "in" : "");
126 if (!get_gpio(GPIO_FRONT_PANEL_PRESENT_L
)) {
127 printk(BIOS_DEBUG
, "Front panel cable connected\n");
129 printk(BIOS_WARNING
, "Front panel cable not connected!\n");
130 printk(BIOS_WARNING
, "Front USB 2.0 ports, SATA LED, microphone"
131 " and speaker jacks will not work!\n");
132 printk(BIOS_WARNING
, "Check the front panel cable!\n");
135 if (!get_gpio(GPIO_INTRUDER_CABLE_DET_L
)) {
136 printk(BIOS_DEBUG
, "Intruder cable connected\n");
138 printk(BIOS_WARNING
, "Intruder cable not connected!\n");
139 printk(BIOS_WARNING
, "Intrusion detection will not work!\n");
140 printk(BIOS_WARNING
, "Check the intruder cable!\n");
143 if (!get_gpio(GPIO_USB_HEADER_DET_L
)) {
144 printk(BIOS_DEBUG
, "Front USB 3.0 cable connected\n");
146 printk(BIOS_WARNING
, "Front USB 3.0 cable not connected!\n");
147 printk(BIOS_WARNING
, "Front USB 3.0 ports will not work!\n");
148 printk(BIOS_WARNING
, "Check the front USB 3.0 cable!\n");
152 static void mainboard_final(void *chip_info
)
155 struct device
*dev
= pcidev_on_root(0x1f, 0);
156 const u8 pirq_routing
= 11;
158 pci_write_config8(dev
, PIRQA_ROUT
, pirq_routing
);
159 pci_write_config8(dev
, PIRQB_ROUT
, pirq_routing
);
160 pci_write_config8(dev
, PIRQC_ROUT
, pirq_routing
);
161 pci_write_config8(dev
, PIRQD_ROUT
, pirq_routing
);
163 pci_write_config8(dev
, PIRQE_ROUT
, pirq_routing
);
164 pci_write_config8(dev
, PIRQF_ROUT
, pirq_routing
);
165 pci_write_config8(dev
, PIRQG_ROUT
, pirq_routing
);
166 pci_write_config8(dev
, PIRQH_ROUT
, pirq_routing
);
168 pin_sts
= sch5545_get_gpio(SIO_PORT
, SIO_GPIO_FP_CBL_DET_L
);
172 printk(BIOS_WARNING
, "Power switch cable not connected!\n");
173 printk(BIOS_WARNING
, "Check power switch cable!\n");
175 printk(BIOS_DEBUG
, "Power switch cable connected\n");
179 pin_sts
= sch5545_get_gpio(SIO_PORT
, SIO_GPIO_PCSPKR_DET_L
);
182 printk(BIOS_DEBUG
, "Internal chassis PC speaker %sconnected\n",
183 pin_sts
? "not " : "");
186 struct chip_operations mainboard_ops
= {
187 .enable_dev
= mainboard_enable
,
188 .final
= mainboard_final
,
191 BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE
, BS_ON_EXIT
, sch5545_ec_hwm_init
, NULL
);