Debian Codegraph @

src/mainboard/google/link/mainboard.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <types.h>
4 #include <device/device.h>
5 #include <device/pci_ops.h>
6 #include <ec/ec.h>
7 #include <console/console.h>
8 #if CONFIG(VGA_ROM_RUN)
9 #include <x86emu/x86emu.h>
10 #endif
11 #include <arch/io.h>
12 #include <arch/interrupt.h>
13 #include "onboard.h"
14 #include "ec.h"
15 #include <southbridge/intel/bd82x6x/pch.h>
16 #include <southbridge/intel/common/gpio.h>
17 #include <smbios.h>
18 #include <ec/google/chromeec/ec.h>
19
20 #if CONFIG(VGA_ROM_RUN)
21 static int int15_handler(void)
22 {
23 int res = 0;
24
25 printk(BIOS_DEBUG, "%s: INT15 function %04x!\n",
26 __func__, X86_AX);
27
28 switch (X86_AX) {
29 case 0x5f34:
30 /*
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
36 */
37 X86_AX = 0x005f;
38 X86_CL = 0x00; /* Use video BIOS default */
39 res = 1;
40 break;
41 case 0x5f35:
42 /*
43 * Boot Display Device Hook:
44 * bit 0 = CRT
45 * bit 1 = TV (eDP)
46 * bit 2 = EFP
47 * bit 3 = LFP
48 * bit 4 = CRT2
49 * bit 5 = TV2 (eDP)
50 * bit 6 = EFP2
51 * bit 7 = LFP2
52 */
53 X86_AX = 0x005f;
54 X86_CX = 0x0000; /* Use video BIOS default */
55 res = 1;
56 break;
57 case 0x5f51:
58 /*
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
64 */
65 X86_AX = 0x005f;
66 X86_CX = 0x0003; /* eDP */
67 res = 1;
68 break;
69 case 0x5f70:
70 switch (X86_CH) {
71 case 0:
72 /* Get Mux */
73 X86_AX = 0x005f;
74 X86_CX = 0x0000;
75 res = 1;
76 break;
77 case 1:
78 /* Set Mux */
79 X86_AX = 0x005f;
80 X86_CX = 0x0000;
81 res = 1;
82 break;
83 case 2:
84 /* Get SG/Non-SG mode */
85 X86_AX = 0x005f;
86 X86_CX = 0x0000;
87 res = 1;
88 break;
89 default:
90 /* Interrupt was not handled */
91 printk(BIOS_DEBUG, "Unknown INT15 5f70 function: 0x%02x\n",
92 X86_CH);
93 break;
94 }
95 break;
96 case 0x5fac:
97 res = 1;
98 break;
99 default:
100 printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n", X86_AX);
101 break;
102 }
103 return res;
104 }
105 #endif
106
107 static void mainboard_init(struct device *dev)
108 {
109 uint32_t board_version = 0;
110
111 /* Initialize the Embedded Controller */
112 mainboard_ec_init();
113
114 google_chromeec_get_board_version(&board_version);
115 if (board_version == 0) {
116 /* If running on proto1 - enable reversion of gpio11. */
117 gpio_invert(11, true);
118 }
119 }
120
121 static int link_onboard_smbios_data(struct device *dev, int *handle,
122 unsigned long *current)
123 {
124 int len = 0;
125
126 len += smbios_write_type41(
127 current, handle,
128 BOARD_LIGHTSENSOR_NAME, /* name */
129 BOARD_LIGHTSENSOR_IRQ, /* instance */
130 0, /* segment */
131 BOARD_LIGHTSENSOR_I2C_ADDR, /* bus */
132 0, /* device */
133 0, /* function */
134 SMBIOS_DEVICE_TYPE_OTHER); /* device type */
135
136 len += smbios_write_type41(
137 current, handle,
138 BOARD_TRACKPAD_NAME, /* name */
139 BOARD_TRACKPAD_IRQ, /* instance */
140 0, /* segment */
141 BOARD_TRACKPAD_I2C_ADDR, /* bus */
142 0, /* device */
143 0, /* function */
144 SMBIOS_DEVICE_TYPE_OTHER); /* device type */
145
146 len += smbios_write_type41(
147 current, handle,
148 BOARD_TOUCHSCREEN_NAME, /* name */
149 BOARD_TOUCHSCREEN_IRQ, /* instance */
150 0, /* segment */
151 BOARD_TOUCHSCREEN_I2C_ADDR, /* bus */
152 0, /* device */
153 0, /* function */
154 SMBIOS_DEVICE_TYPE_OTHER); /* device type */
155
156 return len;
157 }
158
159 static void mainboard_enable(struct device *dev)
160 {
161 dev->ops->init = mainboard_init;
162 dev->ops->get_smbios_data = link_onboard_smbios_data;
163 #if CONFIG(VGA_ROM_RUN)
164 /* Install custom int15 handler for VGA OPROM */
165 mainboard_interrupt_handlers(0x15, &int15_handler);
166 #endif
167 }
168
169 struct chip_operations mainboard_ops = {
170 .enable_dev = mainboard_enable,
171 };