1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/device.h>
5 #include <device/pci_ops.h>
7 #include <console/console.h>
8 #if CONFIG(VGA_ROM_RUN)
9 #include <x86emu/x86emu.h>
12 #include <arch/interrupt.h>
15 #include <southbridge/intel/bd82x6x/pch.h>
16 #include <southbridge/intel/common/gpio.h>
18 #include <ec/google/chromeec/ec.h>
20 #if CONFIG(VGA_ROM_RUN)
21 static int int15_handler(void)
25 printk(BIOS_DEBUG
, "%s: INT15 function %04x!\n",
31 * Set Panel Fitting Hook:
32 * bit 2 = Graphics Stretching
33 * bit 1 = Text Stretching
34 * bit 0 = Centering (do not set with bit1 or bit2)
35 * 0 = video BIOS default
38 X86_CL
= 0x00; /* Use video BIOS default */
43 * Boot Display Device Hook:
54 X86_CX
= 0x0000; /* Use video BIOS default */
59 * Hook to select active LFP configuration:
60 * 00h = No LVDS, VBIOS does not enable LVDS
61 * 01h = Int-LVDS, LFP driven by integrated LVDS decoder
62 * 02h = SVDO-LVDS, LFP driven by SVDO decoder
63 * 03h = eDP, LFP Driven by Int-DisplayPort encoder
66 X86_CX
= 0x0003; /* eDP */
84 /* Get SG/Non-SG mode */
90 /* Interrupt was not handled */
91 printk(BIOS_DEBUG
, "Unknown INT15 5f70 function: 0x%02x\n",
100 printk(BIOS_DEBUG
, "Unknown INT15 function %04x!\n", X86_AX
);
107 static void mainboard_init(struct device
*dev
)
109 uint32_t board_version
= 0;
111 /* Initialize the Embedded Controller */
114 google_chromeec_get_board_version(&board_version
);
115 if (board_version
== 0) {
116 /* If running on proto1 - enable reversion of gpio11. */
118 u16 gpio_base
= pci_read_config16
119 (pcidev_on_root(0x1f, 0), GPIO_BASE
) &
121 u16 gpio_inv_addr
= gpio_base
+ GPI_INV
;
122 gpio_inv
= inl(gpio_inv_addr
);
123 outl(gpio_inv
| (1 << 11), gpio_inv_addr
);
127 static int link_onboard_smbios_data(struct device
*dev
, int *handle
,
128 unsigned long *current
)
132 len
+= smbios_write_type41(
134 BOARD_LIGHTSENSOR_NAME
, /* name */
135 BOARD_LIGHTSENSOR_IRQ
, /* instance */
137 BOARD_LIGHTSENSOR_I2C_ADDR
, /* bus */
140 SMBIOS_DEVICE_TYPE_OTHER
); /* device type */
142 len
+= smbios_write_type41(
144 BOARD_TRACKPAD_NAME
, /* name */
145 BOARD_TRACKPAD_IRQ
, /* instance */
147 BOARD_TRACKPAD_I2C_ADDR
, /* bus */
150 SMBIOS_DEVICE_TYPE_OTHER
); /* device type */
152 len
+= smbios_write_type41(
154 BOARD_TOUCHSCREEN_NAME
, /* name */
155 BOARD_TOUCHSCREEN_IRQ
, /* instance */
157 BOARD_TOUCHSCREEN_I2C_ADDR
, /* bus */
160 SMBIOS_DEVICE_TYPE_OTHER
); /* device type */
165 static void mainboard_enable(struct device
*dev
)
167 dev
->ops
->init
= mainboard_init
;
168 dev
->ops
->get_smbios_data
= link_onboard_smbios_data
;
169 #if CONFIG(VGA_ROM_RUN)
170 /* Install custom int15 handler for VGA OPROM */
171 mainboard_interrupt_handlers(0x15, &int15_handler
);
175 struct chip_operations mainboard_ops
= {
176 .enable_dev
= mainboard_enable
,