mb/google/brya/var/omnigul: Modify NVMe and UFS Storage support
[coreboot.git] / src / mainboard / google / link / mainboard.c
blob4fdfd14f6ea4613e26ef490a997b02ad2912ae5b
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <types.h>
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>
9 #endif
10 #include <arch/io.h>
11 #include <arch/interrupt.h>
12 #include "onboard.h"
13 #include "ec.h"
14 #include <southbridge/intel/bd82x6x/pch.h>
15 #include <southbridge/intel/common/gpio.h>
16 #include <smbios.h>
17 #include <ec/google/chromeec/ec.h>
19 #if CONFIG(VGA_ROM_RUN)
20 static int int15_handler(void)
22 int res = 0;
24 printk(BIOS_DEBUG, "%s: INT15 function %04x!\n",
25 __func__, X86_AX);
27 switch (X86_AX) {
28 case 0x5f34:
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
36 X86_AX = 0x005f;
37 X86_CL = 0x00; /* Use video BIOS default */
38 res = 1;
39 break;
40 case 0x5f35:
42 * Boot Display Device Hook:
43 * bit 0 = CRT
44 * bit 1 = TV (eDP)
45 * bit 2 = EFP
46 * bit 3 = LFP
47 * bit 4 = CRT2
48 * bit 5 = TV2 (eDP)
49 * bit 6 = EFP2
50 * bit 7 = LFP2
52 X86_AX = 0x005f;
53 X86_CX = 0x0000; /* Use video BIOS default */
54 res = 1;
55 break;
56 case 0x5f51:
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
64 X86_AX = 0x005f;
65 X86_CX = 0x0003; /* eDP */
66 res = 1;
67 break;
68 case 0x5f70:
69 switch (X86_CH) {
70 case 0:
71 /* Get Mux */
72 X86_AX = 0x005f;
73 X86_CX = 0x0000;
74 res = 1;
75 break;
76 case 1:
77 /* Set Mux */
78 X86_AX = 0x005f;
79 X86_CX = 0x0000;
80 res = 1;
81 break;
82 case 2:
83 /* Get SG/Non-SG mode */
84 X86_AX = 0x005f;
85 X86_CX = 0x0000;
86 res = 1;
87 break;
88 default:
89 /* Interrupt was not handled */
90 printk(BIOS_DEBUG, "Unknown INT15 5f70 function: 0x%02x\n",
91 X86_CH);
92 break;
94 break;
95 case 0x5fac:
96 res = 1;
97 break;
98 default:
99 printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n", X86_AX);
100 break;
102 return res;
104 #endif
106 static void mainboard_init(struct device *dev)
108 uint32_t board_version = 0;
110 /* Initialize the Embedded Controller */
111 link_ec_init();
113 google_chromeec_get_board_version(&board_version);
114 if (board_version == 0) {
115 /* If running on proto1 - enable reversion of gpio11. */
116 u32 gpio_inv;
117 u16 gpio_base = pci_read_config16
118 (pcidev_on_root(0x1f, 0), GPIO_BASE) &
119 0xfffc;
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)
129 int len = 0;
131 len += smbios_write_type41(
132 current, handle,
133 BOARD_LIGHTSENSOR_NAME, /* name */
134 BOARD_LIGHTSENSOR_IRQ, /* instance */
135 0, /* segment */
136 BOARD_LIGHTSENSOR_I2C_ADDR, /* bus */
137 0, /* device */
138 0, /* function */
139 SMBIOS_DEVICE_TYPE_OTHER); /* device type */
141 len += smbios_write_type41(
142 current, handle,
143 BOARD_TRACKPAD_NAME, /* name */
144 BOARD_TRACKPAD_IRQ, /* instance */
145 0, /* segment */
146 BOARD_TRACKPAD_I2C_ADDR, /* bus */
147 0, /* device */
148 0, /* function */
149 SMBIOS_DEVICE_TYPE_OTHER); /* device type */
151 len += smbios_write_type41(
152 current, handle,
153 BOARD_TOUCHSCREEN_NAME, /* name */
154 BOARD_TOUCHSCREEN_IRQ, /* instance */
155 0, /* segment */
156 BOARD_TOUCHSCREEN_I2C_ADDR, /* bus */
157 0, /* device */
158 0, /* function */
159 SMBIOS_DEVICE_TYPE_OTHER); /* device type */
161 return len;
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);
174 #endif
177 struct chip_operations mainboard_ops = {
178 .enable_dev = mainboard_enable,