1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/device.h>
5 #include <device/pci_ops.h>
6 #include <console/console.h>
7 #if CONFIG(VGA_ROM_RUN)
8 #include <x86emu/x86emu.h>
11 #include <arch/interrupt.h>
14 #include <southbridge/intel/bd82x6x/pch.h>
15 #include <southbridge/intel/common/gpio.h>
17 #include <ec/google/chromeec/ec.h>
19 #if CONFIG(VGA_ROM_RUN)
20 static int int15_handler(void)
24 printk(BIOS_DEBUG
, "%s: INT15 function %04x!\n",
30 * Set Panel Fitting Hook:
31 * bit 2 = Graphics Stretching
32 * bit 1 = Text Stretching
33 * bit 0 = Centering (do not set with bit1 or bit2)
34 * 0 = video BIOS default
37 X86_CL
= 0x00; /* Use video BIOS default */
42 * Boot Display Device Hook:
53 X86_CX
= 0x0000; /* Use video BIOS default */
58 * Hook to select active LFP configuration:
59 * 00h = No LVDS, VBIOS does not enable LVDS
60 * 01h = Int-LVDS, LFP driven by integrated LVDS decoder
61 * 02h = SVDO-LVDS, LFP driven by SVDO decoder
62 * 03h = eDP, LFP Driven by Int-DisplayPort encoder
65 X86_CX
= 0x0003; /* eDP */
83 /* Get SG/Non-SG mode */
89 /* Interrupt was not handled */
90 printk(BIOS_DEBUG
, "Unknown INT15 5f70 function: 0x%02x\n",
99 printk(BIOS_DEBUG
, "Unknown INT15 function %04x!\n", X86_AX
);
106 static void mainboard_init(struct device
*dev
)
108 uint32_t board_version
= 0;
110 /* Initialize the Embedded Controller */
113 google_chromeec_get_board_version(&board_version
);
114 if (board_version
== 0) {
115 /* If running on proto1 - enable reversion of gpio11. */
117 u16 gpio_base
= pci_read_config16
118 (pcidev_on_root(0x1f, 0), GPIO_BASE
) &
120 u16 gpio_inv_addr
= gpio_base
+ GPI_INV
;
121 gpio_inv
= inl(gpio_inv_addr
);
122 outl(gpio_inv
| (1 << 11), gpio_inv_addr
);
126 static int link_onboard_smbios_data(struct device
*dev
, int *handle
,
127 unsigned long *current
)
131 len
+= smbios_write_type41(
133 BOARD_LIGHTSENSOR_NAME
, /* name */
134 BOARD_LIGHTSENSOR_IRQ
, /* instance */
136 BOARD_LIGHTSENSOR_I2C_ADDR
, /* bus */
139 SMBIOS_DEVICE_TYPE_OTHER
); /* device type */
141 len
+= smbios_write_type41(
143 BOARD_TRACKPAD_NAME
, /* name */
144 BOARD_TRACKPAD_IRQ
, /* instance */
146 BOARD_TRACKPAD_I2C_ADDR
, /* bus */
149 SMBIOS_DEVICE_TYPE_OTHER
); /* device type */
151 len
+= smbios_write_type41(
153 BOARD_TOUCHSCREEN_NAME
, /* name */
154 BOARD_TOUCHSCREEN_IRQ
, /* instance */
156 BOARD_TOUCHSCREEN_I2C_ADDR
, /* bus */
159 SMBIOS_DEVICE_TYPE_OTHER
); /* device type */
164 // mainboard_enable is executed as first thing after
165 // enumerate_buses().
167 static void mainboard_enable(struct device
*dev
)
169 dev
->ops
->init
= mainboard_init
;
170 dev
->ops
->get_smbios_data
= link_onboard_smbios_data
;
171 #if CONFIG(VGA_ROM_RUN)
172 /* Install custom int15 handler for VGA OPROM */
173 mainboard_interrupt_handlers(0x15, &int15_handler
);
177 struct chip_operations mainboard_ops
= {
178 .enable_dev
= mainboard_enable
,