blob: 565ea5660a8ea34bc6f3a0938d440bdcd544944a [file] [log] [blame]
Josef Kellermannbfa7ee52011-05-11 07:47:43 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 Advanced Micro Devices, Inc.
5 * Copyright (C) 2010 Siemens AG, Inc.
6 * (Written by Josef Kellermann <joseph.kellermann@heitec.de> for Siemens AG, Inc.)
Stefan Reinauer5ff7c132011-10-31 12:56:45 -07007 *
Josef Kellermannbfa7ee52011-05-11 07:47:43 +00008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070021
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000022#include <console/console.h>
23#include <device/device.h>
24#include <device/pci.h>
25#include <arch/io.h>
Nico Huberf1730352012-11-13 14:52:56 +010026#include <arch/interrupt.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000027#include <delay.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000028#include <cpu/x86/msr.h>
29#include <cpu/amd/mtrr.h>
30#include <device/pci_def.h>
31#include <pc80/mc146818rtc.h>
32#include <cpu/x86/lapic.h>
33#include <southbridge/amd/sb600/sb600.h>
34#include <southbridge/amd/rs690/chip.h>
35#include <southbridge/amd/rs690/rs690.h>
36#include <superio/ite/it8712f/it8712f.h>
Josef Kellermannbfa7ee52011-05-11 07:47:43 +000037#if CONFIG_PCI_OPTION_ROM_RUN_YABEL
38#include <x86emu/x86emu.h>
39#endif
40#include "int15_func.h"
41
42// ****LCD panel ID support: *****
43// Callback Sub-Function 00h - Get LCD Panel ID
44#define PANEL_TABLE_ID_NO 0 // no LCD
45#define PANEL_TABLE_ID1 1 // 1024x768_65MHz_Dual
46#define PANEL_TABLE_ID2 2 // 920x1200_162MHz
47#define PANEL_TABLE_ID3 3 // 600x1200_162MHz
48#define PANEL_TABLE_ID4 4 // 1024x768_65MHz
49#define PANEL_TABLE_ID5 5 // 1400x1050_108MHz
50#define PANEL_TABLE_ID6 6 // 1680x1050_119MHz
51#define PANEL_TABLE_ID7 7 // 2048x1536_164MHz
52#define PANEL_TABLE_ID8 8 // 1280x1024_108MHz
53#define PANEL_TABLE_ID9 9 // 1366x768_86MHz_chimei_V32B1L01
54
55// Callback Sub-Function 05h – Select Boot-up TV Standard
56#define TV_MODE_00 0x00 /* NTSC */
57#define TV_MODE_01 0x01 /* PAL */
58#define TV_MODE_02 0x02 /* PALM */
59#define TV_MODE_03 0x03 /* PAL60 */
60#define TV_MODE_04 0x04 /* NTSCJ */
61#define TV_MODE_05 0x05 /* PALCN */
62#define TV_MODE_06 0x06 /* PALN */
63#define TV_MODE_09 0x09 /* SCART-RGB */
64#define TV_MODE_NO 0xff /* No TV Support */
65
66#define PLX_VIDDID 0x861610b5
67
68/* 7475 Common Registers */
69#define REG_DEVREV2 0x12 /* ADT7490 only */
70#define REG_VTT 0x1E /* ADT7490 only */
71#define REG_EXTEND3 0x1F /* ADT7490 only */
72#define REG_VOLTAGE_BASE 0x20
73#define REG_TEMP_BASE 0x25
74#define REG_TACH_BASE 0x28
75#define REG_PWM_BASE 0x30
76#define REG_PWM_MAX_BASE 0x38
77#define REG_DEVID 0x3D
78#define REG_VENDID 0x3E
79#define REG_DEVID2 0x3F
80#define REG_STATUS1 0x41
81#define REG_STATUS2 0x42
82#define REG_VID 0x43 /* ADT7476 only */
83#define REG_VOLTAGE_MIN_BASE 0x44
84#define REG_VOLTAGE_MAX_BASE 0x45
85#define REG_TEMP_MIN_BASE 0x4E
86#define REG_TEMP_MAX_BASE 0x4F
87#define REG_TACH_MIN_BASE 0x54
88#define REG_PWM_CONFIG_BASE 0x5C
89#define REG_TEMP_TRANGE_BASE 0x5F
90#define REG_PWM_MIN_BASE 0x64
91#define REG_TEMP_TMIN_BASE 0x67
92#define REG_TEMP_THERM_BASE 0x6A
93#define REG_REMOTE1_HYSTERSIS 0x6D
94#define REG_REMOTE2_HYSTERSIS 0x6E
95#define REG_TEMP_OFFSET_BASE 0x70
96#define REG_CONFIG2 0x73
97#define REG_EXTEND1 0x76
98#define REG_EXTEND2 0x77
99#define REG_CONFIG1 0x40 // ADT7475
100#define REG_CONFIG3 0x78
101#define REG_CONFIG5 0x7C
102#define REG_CONFIG6 0x10 // ADT7475
103#define REG_CONFIG7 0x11 // ADT7475
104#define REG_CONFIG4 0x7D
105#define REG_STATUS4 0x81 /* ADT7490 only */
106#define REG_VTT_MIN 0x84 /* ADT7490 only */
107#define REG_VTT_MAX 0x86 /* ADT7490 only */
108
109#define VID_VIDSEL 0x80 /* ADT7476 only */
110
111#define CONFIG2_ATTN 0x20
112#define CONFIG3_SMBALERT 0x01
113#define CONFIG3_THERM 0x02
114#define CONFIG4_PINFUNC 0x03
115#define CONFIG4_MAXDUTY 0x08
116#define CONFIG4_ATTN_IN10 0x30
117#define CONFIG4_ATTN_IN43 0xC0
118#define CONFIG5_TWOSCOMP 0x01
119#define CONFIG5_TEMPOFFSET 0x02
120#define CONFIG5_VIDGPIO 0x10 /* ADT7476 only */
121#define REMOTE1 0
122#define LOCAL 1
123#define REMOTE2 2
124
125/* ADT7475 Settings */
126#define ADT7475_VOLTAGE_COUNT 5 /* Not counting Vtt */
127#define ADT7475_TEMP_COUNT 3
128#define ADT7475_TACH_COUNT 4
129#define ADT7475_PWM_COUNT 3
130
131/* Macros to easily index the registers */
132#define TACH_REG(idx) (REG_TACH_BASE + ((idx) * 2))
133#define TACH_MIN_REG(idx) (REG_TACH_MIN_BASE + ((idx) * 2))
134
135#define PWM_REG(idx) (REG_PWM_BASE + (idx))
136#define PWM_MAX_REG(idx) (REG_PWM_MAX_BASE + (idx))
137#define PWM_MIN_REG(idx) (REG_PWM_MIN_BASE + (idx))
138#define PWM_CONFIG_REG(idx) (REG_PWM_CONFIG_BASE + (idx))
139
140#define VOLTAGE_REG(idx) (REG_VOLTAGE_BASE + (idx))
141#define VOLTAGE_MIN_REG(idx) (REG_VOLTAGE_MIN_BASE + ((idx) * 2))
142#define VOLTAGE_MAX_REG(idx) (REG_VOLTAGE_MAX_BASE + ((idx) * 2))
143
144#define TEMP_REG(idx) (REG_TEMP_BASE + (idx))
145#define TEMP_MIN_REG(idx) (REG_TEMP_MIN_BASE + ((idx) * 2))
146#define TEMP_MAX_REG(idx) (REG_TEMP_MAX_BASE + ((idx) * 2))
147#define TEMP_TMIN_REG(idx) (REG_TEMP_TMIN_BASE + (idx))
148#define TEMP_THERM_REG(idx) (REG_TEMP_THERM_BASE + (idx))
149#define TEMP_OFFSET_REG(idx) (REG_TEMP_OFFSET_BASE + (idx))
150#define TEMP_TRANGE_REG(idx) (REG_TEMP_TRANGE_BASE + (idx))
151
152#define SMBUS_IO_BASE 0x1000
153#define ADT7475_ADDRESS 0x2E
154
155#define D_OPEN (1 << 6)
156#define D_CLS (1 << 5)
157#define D_LCK (1 << 4)
158#define G_SMRAME (1 << 3)
159#define A_BASE_SEG ((0 << 2) | (1 << 1) | (0 << 0)) // 0x2: SMM space at 640KB-768KB
160
161extern int do_smbus_read_byte(u32 smbus_io_base, u32 device, u32 address);
162extern int do_smbus_write_byte(u32 smbus_io_base, u32 device, u32 address, u8 val);
163
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000164static u32 smbus_io_base = SMBUS_IO_BASE;
165static u32 adt7475_address = ADT7475_ADDRESS;
166
167/* Macro to read the registers */
168#define adt7475_read_byte(reg) \
169 do_smbus_read_byte(smbus_io_base, adt7475_address, reg)
170
171#define adt7475_write_byte(reg, val) \
172 do_smbus_write_byte(smbus_io_base, adt7475_address, reg, val)
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700173
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000174#define TWOS_COMPL 1
175
176struct __table__{
177 const char *info;
178 u8 val;
179};
180
181struct __table__ dutycycles[] = {
182 {"25%", 0x3f},{"30%", 0x4c},{"35%", 0x59},{"40%", 0x66},{"45%", 0x73},
183 {"50%", 0x80},{"55%", 0x8d},{"60%", 0x9a},{"65%", 0xa7},{"70%", 0xb4},
184 {"75%", 0xc1},{"80%", 0xce},{"85%", 0xdb},{"90%", 0xe8},{"95%", 0xf5},
185 {"100%", 0xff}
186};
187#define SIZEOF_DUTYCYCLES sizeof(dutycycles)/sizeof(struct __table__)
188#define DUTYCYCLE(i,d) (i < SIZEOF_DUTYCYCLES) ? dutycycles[i].val : dutycycles[d].val // hopefully d is a correct value !!! fix
189#define DUTYCYCLE_INFO(i) (i < SIZEOF_DUTYCYCLES) ? dutycycles[i].info : "out_of_range"
190#if TWOS_COMPL == 0
191struct __table__ temperatures[] = {
192 {"30°C", 0x5e},{"35°C", 0x63},{"40°C", 0x68},{"45°C", 0x6d},{"50°C", 0x72},
193 {"55°C", 0x77},{"60°C", 0x7c},{"65°C", 0x81},{"70°C", 0x86},{"75°C", 0x8b},
194 {"80°C", 0x90}
195};
196#else
197struct __table__ temperatures[] = {
198 {"30°C", 30},{"35°C", 35},{"40°C", 40},{"45°C", 45},{"50°C", 50},
199 {"55°C", 55},{"60°C", 60},{"65°C", 65},{"70°C", 70},{"75°C", 75},
200 {"80°C", 80}
201};
202#endif
203int trange[] = {2.0,2.5,3.33,4.0,5.0,6.67,8.0,10.0,13.33,16.0,20.0,26.67,32.0,40.0,53.33,80.0};
204
205#define SIZEOF_TEMPERATURES sizeof(temperatures)/sizeof(struct __table__)
206#define TEMPERATURE(i,d) (i < SIZEOF_TEMPERATURES) ? temperatures[i].val : temperatures[d].val // hopefully d is a correct value !!! fix
207#define TEMPERATURE_INFO(i) (i < SIZEOF_TEMPERATURES) ? temperatures[i].info : "out of range"
208
209struct fan_control {
210 unsigned int enable : 1;
211 u8 polarity;
212 u8 t_min;
213 u8 t_max;
214 u8 pwm_min;
215 u8 pwm_max;
216 u8 t_range;
217};
218/* ############################################################################################# */
219#if CONFIG_PCI_OPTION_ROM_RUN_YABEL
220static int int15_handler(void)
221{
222#define BOOT_DISPLAY_DEFAULT 0
223#define BOOT_DISPLAY_CRT (1 << 0)
224#define BOOT_DISPLAY_TV (1 << 1)
225#define BOOT_DISPLAY_EFP (1 << 2)
226#define BOOT_DISPLAY_LCD (1 << 3)
227#define BOOT_DISPLAY_CRT2 (1 << 4)
228#define BOOT_DISPLAY_TV2 (1 << 5)
229#define BOOT_DISPLAY_EFP2 (1 << 6)
230#define BOOT_DISPLAY_LCD2 (1 << 7)
231
232 printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n",
233 __func__, M.x86.R_AX, M.x86.R_BX, M.x86.R_CX, M.x86.R_DX);
234
235 switch (M.x86.R_AX) {
236 case 0x4e08: /* Boot Display */
237 switch (M.x86.R_BX) {
238 case 0x80:
239 M.x86.R_AX &= ~(0xff); // Success
240 M.x86.R_BX &= ~(0xff);
241 printk(BIOS_DEBUG, "Integrated System Information\n");
242 break;
243 case 0x00:
244 M.x86.R_AX &= ~(0xff);
245 M.x86.R_BX = 0x00;
246 printk(BIOS_DEBUG, "Panel ID = 0\n");
247 break;
248 case 0x05:
249 M.x86.R_AX &= ~(0xff);
250 M.x86.R_BX = 0xff;
251 printk(BIOS_DEBUG, "TV = off\n");
252 break;
253 default:
254 return 0;
255 }
256 break;
257 case 0x5f35: /* Boot Display */
258 M.x86.R_AX = 0x005f; // Success
259 M.x86.R_CL = BOOT_DISPLAY_DEFAULT;
260 break;
261 case 0x5f40: /* Boot Panel Type */
262 // M.x86.R_AX = 0x015f; // Supported but failed
263 M.x86.R_AX = 0x005f; // Success
264 M.x86.R_CL = 3; // Display ID
265 break;
266 default:
267 /* Interrupt was not handled */
268 return 0;
269 }
270
271 /* Interrupt handled */
272 return 1;
273}
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000274#endif
275/* ############################################################################################# */
276
277 /**
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700278 * @brief
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000279 *
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700280 * @param
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000281 */
282
283static u8 calc_trange(u8 t_min, u8 t_max) {
284
285 u8 prev;
286 int i;
287 int diff = t_max - t_min;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700288
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000289 // walk through the trange table
290 for(i = 0, prev = 0; i < sizeof(trange)/sizeof(int); i++) {
291 if( trange[i] < diff ) {
292 prev = i; // save last val
293 continue;
294 }
295 if( diff == trange[i] ) return i;
296 if( (diff - trange[prev]) < (trange[i] - diff) ) break; // return with last val index
297 return i;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700298 }
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000299 return prev;
300}
301
302/********************************************************
303* sina uses SB600 GPIO9 to detect IDE_DMA66.
304* IDE_DMA66 is routed to GPIO 9. So we read Gpio 9 to
305* get the cable type, 40 pin or 80 pin?
306********************************************************/
307static void cable_detect(void)
308{
309
310 u8 byte;
311 struct device *sm_dev;
312 struct device *ide_dev;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700313
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000314 /* SMBus Module and ACPI Block (Device 20, Function 0) on SB600 */
315 printk(BIOS_DEBUG, "%s.\n", __func__);
316 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
317
318 byte = pci_read_config8(sm_dev, 0xA9);
319 byte |= (1 << 5); /* Set Gpio9 as input */
320 pci_write_config8(sm_dev, 0xA9, byte);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700321
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000322 /* IDE Controller (Device 20, Function 1) on SB600 */
323 ide_dev = dev_find_slot(0, PCI_DEVFN(0x14, 1));
324
325 byte = pci_read_config8(ide_dev, 9);
326 printk(BIOS_INFO, "IDE controller in %s Mode\n", byte & (1 << 0) ? "Native" : "Compatibility");
327
328 byte = pci_read_config8(ide_dev, 0x56);
329 byte &= ~(7 << 0);
330 if( pci_read_config8(sm_dev, 0xAA) & (1 << 5) )
331 byte |= 2 << 0; /* mode 2 */
332 else
333 byte |= 5 << 0; /* mode 5 */
334 printk(BIOS_INFO, "DMA mode %d selected\n", byte & (7 << 0));
335 pci_write_config8(ide_dev, 0x56, byte);
336}
337
338/**
339 * @brief Detect the ADT7475 device
340 *
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700341 * @param
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000342 */
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700343
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000344static const char * adt7475_detect( void ) {
345
346 int vendid, devid, devid2;
347 const char *name = NULL;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700348
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000349 vendid = adt7475_read_byte(REG_VENDID);
350 devid2 = adt7475_read_byte(REG_DEVID2);
351 if (vendid != 0x41 || /* Analog Devices */
352 (devid2 & 0xf8) != 0x68) {
353 return name;
354 }
355
356 devid = adt7475_read_byte(REG_DEVID);
357 if (devid == 0x73)
358 name = "adt7473";
359 else if (devid == 0x75 && adt7475_address == 0x2e)
360 name = "adt7475";
361 else if (devid == 0x76)
362 name = "adt7476";
363 else if ((devid2 & 0xfc) == 0x6c)
364 name = "adt7490";
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700365
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000366 return name;
367}
368
369// thermal control defaults
370const struct fan_control cpu_fan_control_defaults = {
371 .enable = 0, // disable by default
372 .polarity = 0, // high by default
373 .t_min = 3, // default = 45°C
374 .t_max = 7, // 65°C
375 .pwm_min = 1, // default dutycycle = 30%
376 .pwm_max = 13, // 90%
377};
378const struct fan_control case_fan_control_defaults = {
379 .enable = 0, // disable by default
380 .polarity = 0, // high by default
381 .t_min = 2, // default = 40°C
382 .t_max = 8, // 70°C
383 .pwm_min = 0, // default dutycycle = 25%
384 .pwm_max = 13, // 90%
385};
386
387static void pm_init( void )
388{
389 u16 word;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700390 u8 byte;
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000391 device_t sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
392
393 /* set SB600 GPIO 64 to GPIO with pull-up */
394 byte = pm2_ioread(0x42);
395 byte &= 0x3f;
396 pm2_iowrite(0x42, byte);
397
398 /* set GPIO 64 to tristate */
399 word = pci_read_config16(sm_dev, 0x56);
400 word |= 1 << 7;
401 pci_write_config16(sm_dev, 0x56, word);
402
403 /* set GPIO 64 internal pull-up */
404 byte = pm2_ioread(0xf0);
405 byte &= 0xee;
406 pm2_iowrite(0xf0, byte);
407
408 /* set Talert to be active low */
409 byte = pm_ioread(0x67);
410 byte &= ~(1 << 5);
411 pm_iowrite(0x67, byte);
412
413 /* set Talert to generate ACPI event */
414 byte = pm_ioread(0x3c);
415 byte &= 0xf3;
416 pm_iowrite(0x3c, byte);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700417
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000418 /* set GPM5 to not wake from s5 */
419 byte = pm_ioread(0x77);
420 byte &= ~(1 << 5);
421 pm_iowrite(0x77, byte);
422}
423
424 /**
425 * @brief Setup thermal config on SINA Mainboard
426 *
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700427 * @param
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000428 */
429
430static void set_thermal_config(void)
431{
432 u8 byte, byte2;
433 u8 cpu_pwm_conf, case_pwm_conf;
434 device_t sm_dev;
435 struct fan_control cpu_fan_control, case_fan_control;
436 const char *name = NULL;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700437
438
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000439 sm_dev = dev_find_slot(0, PCI_DEVFN(0x14, 0));
440 smbus_io_base = pci_read_config32(sm_dev, 0x10) & ~(0xf); // get BAR0-Address which holds the SMBUS_IO_BASE
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700441
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000442 if( (name = adt7475_detect()) == NULL ) {
443 printk(BIOS_NOTICE, "Couldn't detect an ADT7473/75/76/90 part at %x:%x\n", smbus_io_base, adt7475_address);
444 return;
445 }
446 printk(BIOS_DEBUG, "Found %s part at %x:%x\n", name, smbus_io_base, adt7475_address);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700447
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000448 cpu_fan_control = cpu_fan_control_defaults;
449 case_fan_control = case_fan_control_defaults;
450
451 if( get_option(&byte, "cpu_fan_control") == -4 ) {
452 printk(BIOS_WARNING, "%s: CMOS checksum invalid, keeping default values\n",__func__);
453 } else {
454 // get all the options needed
455 if( get_option(&byte, "cpu_fan_control") == 0 )
456 cpu_fan_control.enable = byte ? 1 : 0;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700457
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000458 get_option(&cpu_fan_control.polarity, "cpu_fan_polarity");
459 get_option(&cpu_fan_control.t_min, "cpu_t_min");
460 get_option(&cpu_fan_control.t_max, "cpu_t_max");
461 get_option(&cpu_fan_control.pwm_min, "cpu_dutycycle_min");
462 get_option(&cpu_fan_control.pwm_max, "cpu_dutycycle_max");
463
464 if( get_option(&byte, "chassis_fan_control") == 0)
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700465 case_fan_control.enable = byte ? 1 : 0;
466 get_option(&case_fan_control.polarity, "chassis_fan_polarity");
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000467 get_option(&case_fan_control.t_min, "chassis_t_min");
468 get_option(&case_fan_control.t_max, "chassis_t_max");
469 get_option(&case_fan_control.pwm_min, "chassis_dutycycle_min");
470 get_option(&case_fan_control.pwm_max, "chassis_dutycycle_max");
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700471
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000472 }
473
474 printk(BIOS_DEBUG, "cpu_fan_control:%s", cpu_fan_control.enable ? "enable" : "disable");
475 printk(BIOS_DEBUG, " cpu_fan_polarity:%s", cpu_fan_control.polarity ? "low" : "high");
476
477 printk(BIOS_DEBUG, " cpu_t_min:%s", TEMPERATURE_INFO(cpu_fan_control.t_min));
478 cpu_fan_control.t_min = TEMPERATURE(cpu_fan_control.t_min, cpu_fan_control_defaults.t_min);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700479
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000480 printk(BIOS_DEBUG, " cpu_t_max:%s", TEMPERATURE_INFO(cpu_fan_control.t_max));
481 cpu_fan_control.t_max = TEMPERATURE(cpu_fan_control.t_max, cpu_fan_control_defaults.t_max);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700482
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000483 printk(BIOS_DEBUG, " cpu_pwm_min:%s", DUTYCYCLE_INFO(cpu_fan_control.pwm_min));
484 cpu_fan_control.pwm_min = DUTYCYCLE(cpu_fan_control.pwm_min, cpu_fan_control_defaults.pwm_min);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700485
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000486 printk(BIOS_DEBUG, " cpu_pwm_max:%s", DUTYCYCLE_INFO(cpu_fan_control.pwm_max));
487 cpu_fan_control.pwm_max = DUTYCYCLE(cpu_fan_control.pwm_max, cpu_fan_control_defaults.pwm_max);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700488
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000489 cpu_fan_control.t_range = calc_trange(cpu_fan_control.t_min, cpu_fan_control.t_max);
490 printk(BIOS_DEBUG, " cpu_t_range:0x%02x\n", cpu_fan_control.t_range);
491 cpu_fan_control.t_range <<= 4;
492 cpu_fan_control.t_range |= (4 << 0); // 35.3Hz
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700493
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000494 printk(BIOS_DEBUG, "chassis_fan_control:%s", case_fan_control.enable ? "enable" : "disable");
495 printk(BIOS_DEBUG, " chassis_fan_polarity:%s", case_fan_control.polarity ? "low" : "high");
496
497 printk(BIOS_DEBUG, " chassis_t_min:%s", TEMPERATURE_INFO(case_fan_control.t_min));
498 case_fan_control.t_min = TEMPERATURE(case_fan_control.t_min, case_fan_control_defaults.t_min);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700499
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000500 printk(BIOS_DEBUG, " chassis_t_max:%s", TEMPERATURE_INFO(case_fan_control.t_max));
501 case_fan_control.t_max = TEMPERATURE(case_fan_control.t_max, case_fan_control_defaults.t_max);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700502
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000503 printk(BIOS_DEBUG, " chassis_pwm_min:%s", DUTYCYCLE_INFO(case_fan_control.pwm_min));
504 case_fan_control.pwm_min = DUTYCYCLE(case_fan_control.pwm_min, case_fan_control_defaults.pwm_min);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700505
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000506 printk(BIOS_DEBUG, " chassis_pwm_max:%s", DUTYCYCLE_INFO(case_fan_control.pwm_max));
507 case_fan_control.pwm_max = DUTYCYCLE(case_fan_control.pwm_max, case_fan_control_defaults.pwm_max);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700508
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000509 case_fan_control.t_range = calc_trange(case_fan_control.t_min, case_fan_control.t_max);
510 printk(BIOS_DEBUG, " case_t_range:0x%02x\n", case_fan_control.t_range);
511 case_fan_control.t_range <<= 4;
512 case_fan_control.t_range |= (4 << 0); // 35.3Hz
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700513
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000514 cpu_pwm_conf = (((cpu_fan_control.polarity & 0x1) << 4) | 0x2); // bit 4 control polarity of PWMx output
515 case_pwm_conf = (((case_fan_control.polarity & 0x1) << 4) | 0x2); // bit 4 control polarity of PWMx output
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700516 cpu_pwm_conf |= cpu_fan_control.enable ? (0 << 5) : (7 << 5); // manual control
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000517 case_pwm_conf |= case_fan_control.enable ? (1 << 5) : (7 << 5); // local temp
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700518
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000519 /* set adt7475 */
520
521 adt7475_write_byte(REG_CONFIG1, 0x04); // clear register, bit 2 is read only
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700522
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000523 /* Config Register 6: */
524 adt7475_write_byte(REG_CONFIG6, 0x00);
525 /* Config Register 7 */
526 adt7475_write_byte(REG_CONFIG7, 0x00);
527
528 /* Config Register 5: */
529 /* set Offset 64 format, enable THERM on Remote 1& Local */
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700530 adt7475_write_byte(REG_CONFIG5, TWOS_COMPL ? 0x61 : 0x60);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000531 /* No offset for remote 1 */
532 adt7475_write_byte(TEMP_OFFSET_REG(0), 0x00);
533 /* No offset for local */
534 adt7475_write_byte(TEMP_OFFSET_REG(1), 0x00);
535 /* No offset for remote 2 */
536 adt7475_write_byte(TEMP_OFFSET_REG(2), 0x00);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700537
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000538 /* remote 1 low temp limit */
539 adt7475_write_byte(TEMP_MIN_REG(0), 0x00);
540 /* remote 1 High temp limit (90C) */
541 adt7475_write_byte(TEMP_MAX_REG(0), 0x9a);
542
543 /* local Low Temp Limit */
544 adt7475_write_byte(TEMP_MIN_REG(1), 0x00);
545 /* local High Limit (90C) */
546 adt7475_write_byte(TEMP_MAX_REG(1), 0x9a);
547
548 /* remote 1 therm temp limit (95C) */
549 adt7475_write_byte(TEMP_THERM_REG(0), 0x9f);
550 /* local therm temp limit (95C) */
551 adt7475_write_byte(TEMP_THERM_REG(1), 0x9f);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700552
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000553 /* PWM 1 configuration register CPU fan controlled by CPU Thermal Diode */
554 adt7475_write_byte(PWM_CONFIG_REG(0), cpu_pwm_conf);
555 /* PWM 3 configuration register Case fan controlled by ADTxxxx temp */
556 adt7475_write_byte(PWM_CONFIG_REG(2), case_pwm_conf);
557
558 if( cpu_fan_control.enable ) {
559 /* PWM 1 minimum duty cycle (37%) */
560 adt7475_write_byte(PWM_MIN_REG(0), cpu_fan_control.pwm_min);
561 /* PWM 1 Maximum duty cycle (100%) */
562 adt7475_write_byte(PWM_MAX_REG(0), cpu_fan_control.pwm_max);
563 /* Remote 1 temperature Tmin (32C) */
564 adt7475_write_byte(TEMP_TMIN_REG(0), cpu_fan_control.t_min);
565 /* remote 1 Trange (53C ramp range) */
566 adt7475_write_byte(TEMP_TRANGE_REG(0), cpu_fan_control.t_range);
567 } else {
568 adt7475_write_byte(PWM_REG(0), cpu_fan_control.pwm_max);
569 }
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700570
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000571 if( case_fan_control.enable ) {
572 /* PWM 2 minimum duty cycle (37%) */
573 adt7475_write_byte(PWM_MIN_REG(2), case_fan_control.pwm_min);
574 /* PWM 2 Maximum Duty Cycle (100%) */
575 adt7475_write_byte(PWM_MAX_REG(2), case_fan_control.pwm_max);
576 /* local temperature Tmin (32C) */
577 adt7475_write_byte(TEMP_TMIN_REG(1), case_fan_control.t_min);
578 /* local Trange (53C ramp range) */
579 adt7475_write_byte(TEMP_TRANGE_REG(1), case_fan_control.t_range); // Local TRange
580 adt7475_write_byte(TEMP_TRANGE_REG(2), case_fan_control.t_range); // PWM2 Freq
581 } else {
582 adt7475_write_byte(PWM_REG(2), case_fan_control.pwm_max);
583 }
584
585 /* Config Register 3 - enable smbalert & therm */
586 adt7475_write_byte(0x78, 0x03);
587 /* Config Register 4 - enable therm output */
588 adt7475_write_byte(0x7d, 0x09);
589 /* Interrupt Mask Register 2 - Mask SMB alert for Therm Conditions, Fan 3 fault, SmbAlert Fan for Therm Timer event */
590 adt7475_write_byte(0x75, 0x2e);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700591
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000592 /* Config Register 1 Set Start bit */
593 adt7475_write_byte(0x40, 0x05);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700594
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000595 /* Read status register to clear any old errors */
596 byte2 = adt7475_read_byte(0x42);
597 byte = adt7475_read_byte(0x41);
598
599 printk(BIOS_DEBUG, "Init 'Thermal Monitor' end , status 0x42 = 0x%02x, status 0x41 = 0x%02x\n",
600 byte2, byte);
601
602}
603
604 /**
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700605 * @brief
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000606 *
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700607 * @param
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000608 */
609
610static void patch_mmio_nonposted( void )
611{
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700612 unsigned reg, index;
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000613 resource_t rbase, rend;
614 u32 base, limit;
615 struct resource *resource;
616 device_t dev;
617 device_t k8_f1 = dev_find_slot(0, PCI_DEVFN(0x18,1));
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700618
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000619 printk(BIOS_DEBUG,"%s ...\n", __func__);
620
621 dev = dev_find_slot(1, PCI_DEVFN(5,0));
622 // the uma frame buffer
623 index = 0x10;
624 resource = probe_resource(dev, index);
625 if( resource ) {
626 // fixup resource nonposted in k8 mmio
627 /* Get the base address */
628 rbase = (resource->base >> 8) & ~(0xff);
629 /* Get the limit (rounded up) */
630 rend = (resource_end(resource) >> 8) & ~(0xff);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700631
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000632 printk(BIOS_DEBUG,"%s %x base = %0llx limit = %0llx\n", dev_path(dev), index, rbase, rend);
633
634 for( reg = 0xb8; reg >= 0x80; reg -= 8 ) {
635 base = pci_read_config32(k8_f1,reg);
636 limit = pci_read_config32(k8_f1,reg+4);
637 printk(BIOS_DEBUG," %02x[%08x] %02x[%08x]", reg, base, reg+4, limit);
638 if( ((base & ~(0xff)) == rbase) && ((limit & ~(0xff)) == rend) ) {
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700639 limit |= (1 << 7);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000640 printk(BIOS_DEBUG, "\nPatching %s %x <- %08x", dev_path(k8_f1), reg, limit);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700641 pci_write_config32(k8_f1, reg+4, limit);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000642 break;
643 }
644 }
645 printk(BIOS_DEBUG, "\n");
646 }
647}
648
649 /**
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700650 * @brief
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000651 *
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700652 * @param
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000653 */
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700654
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000655struct {
656 unsigned int bus;
657 unsigned int devfn;
658} slot[] = {
659 {0, PCI_DEVFN(0,0)},
660 {0, PCI_DEVFN(18,0)},
661 {0, PCI_DEVFN(19,0)},{0, PCI_DEVFN(19,1)},{0, PCI_DEVFN(19,2)},{0, PCI_DEVFN(19,3)},{0, PCI_DEVFN(19,4)},{0, PCI_DEVFN(19,5)},
662 {0, PCI_DEVFN(20,0)},{0, PCI_DEVFN(20,1)},{0, PCI_DEVFN(20,2)},{0, PCI_DEVFN(20,3)},{0, PCI_DEVFN(20,5)},{0, PCI_DEVFN(20,6)},
663 {0, PCI_DEVFN(5,0)},{0, PCI_DEVFN(5,2)},
664 {255,0},
665};
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700666
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000667
Stefan Reinauer188e3c22012-07-26 12:46:48 -0700668unsigned int plx_present = 0;
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000669
Stefan Reinauer188e3c22012-07-26 12:46:48 -0700670static void update_subsystemid( device_t dev )
671{
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000672 int i;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700673
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000674 dev->subsystem_vendor = 0x110a;
Stefan Reinauer188e3c22012-07-26 12:46:48 -0700675 if( plx_present ){
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000676 dev->subsystem_device = 0x4076; // U1P1 = 0x4076, U1P0 = 0x4077
677 } else {
678 dev->subsystem_device = 0x4077; // U1P0 = 0x4077
679 }
Kyösti Mälkki7baadac2012-10-07 14:57:15 +0200680 printk(BIOS_INFO, "%s [%x/%x]\n", dev_name(dev), dev->subsystem_vendor, dev->subsystem_device );
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000681 for( i=0; slot[i].bus < 255; i++) {
682 device_t d;
683 d = dev_find_slot(slot[i].bus,slot[i].devfn);
684 if( d ) {
685 printk(BIOS_DEBUG,"%s subsystem <- %x/%x\n", dev_path(d), dev->subsystem_vendor, dev->subsystem_device);
686 d->subsystem_device = dev->subsystem_device;
687 }
688 }
689}
690
691 /**
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700692 * @brief
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000693 *
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700694 * @param
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000695 */
696
Stefan Reinauer188e3c22012-07-26 12:46:48 -0700697static void detect_hw_variant( device_t dev )
698{
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000699
700 device_t nb_dev =0, dev2 = 0;
701 struct southbridge_amd_rs690_config *cfg;
702 u32 lc_state, id = 0;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700703
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000704 printk(BIOS_INFO, "Scan for PLX device ...\n");
705 nb_dev = dev_find_slot(0, PCI_DEVFN(0, 0));
706 if (!nb_dev) {
707 die("CAN NOT FIND RS690 DEVICE, HALT!\n");
708 /* NOT REACHED */
709 }
710
711 dev2 = dev_find_slot(0, PCI_DEVFN(2, 0));
712 if (!dev2) {
713 die("CAN NOT FIND GFX DEVICE 2, HALT!\n");
714 /* NOT REACHED */
715 }
716 PcieReleasePortTraining(nb_dev, dev2, 2); // we assume PLX is connected to port 2
717
718 mdelay(40);
719 lc_state = nbpcie_p_read_index(dev2, 0xa5); /* lc_state */
720 printk(BIOS_DEBUG, "lc current state=%x\n", lc_state);
721 /* LC_CURRENT_STATE = bit0-5 */
722 switch( lc_state & 0x3f ){
723 case 0x00:
724 case 0x01:
725 case 0x02:
726 case 0x03:
727 case 0x04:
728 printk(BIOS_NOTICE, "No device present, skipping PLX scan ..\n");
729 break;
730 case 0x07:
731 case 0x10:
732 {
733 struct device dummy;
734 u32 pci_primary_bus, buses;
735 u16 secondary, subordinate;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700736
737 printk(BIOS_DEBUG, "Scan for PLX bridge behind %s[%x]\n", dev_path(dev2), pci_read_config32(dev2, PCI_VENDOR_ID));
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000738 // save the existing primary/secondary/subordinate bus number configuration.
739 secondary = dev2->bus->secondary;
740 subordinate = dev2->bus->subordinate;
741 buses = pci_primary_bus = pci_read_config32(dev2, PCI_PRIMARY_BUS);
742
743 // Configure the bus numbers for this bridge
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700744 // bus number 1 is for internal gfx device, so we start with busnumber 2
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000745
746 buses &= 0xff000000;
747 buses |= ((2 << 8) | (0xff << 16));
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700748 // setup the buses in device 2
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000749 pci_write_config32(dev2,PCI_PRIMARY_BUS, buses);
750
751 // fake a device descriptor for a device behind device 2
752 dummy.bus = dev2->bus;
753 dummy.bus->secondary = (buses >> 8) & 0xff;
754 dummy.bus->subordinate = (buses >> 16) & 0xff;
755 dummy.path.type = DEVICE_PATH_PCI;
756 dummy.path.pci.devfn = PCI_DEVFN(0,0); // PLX: device number 0, function 0
757
758 id = pci_read_config32(&dummy, PCI_VENDOR_ID);
759 /* Have we found something?
760 * Some broken boards return 0 if a slot is empty, but
761 * the expected answer is 0xffffffff
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700762 */
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000763 if ((id == 0xffffffff) || (id == 0x00000000) || (id == 0x0000ffff) || (id == 0xffff0000)) {
764 printk(BIOS_DEBUG, "%s, bad id 0x%x\n", dev_path(&dummy), id);
765 } else {
766 printk(BIOS_DEBUG, "found device [%x]\n", id);
767 }
768 // restore changes made for device 2
769 dev2->bus->secondary = secondary;
770 dev2->bus->secondary = subordinate;
771 pci_write_config32(dev2, PCI_PRIMARY_BUS, pci_primary_bus);
772 }
773 break;
774 default:
775 break;
776 }
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700777
Stefan Reinauer188e3c22012-07-26 12:46:48 -0700778 plx_present = 0;
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000779 if( id == PLX_VIDDID ){
780 printk(BIOS_INFO, "found PLX device\n");
Stefan Reinauer188e3c22012-07-26 12:46:48 -0700781 plx_present = 1;
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000782 cfg = (struct southbridge_amd_rs690_config *)dev2->chip_info;
783 if( cfg->gfx_tmds ) {
784 printk(BIOS_INFO, "Disable 'gfx_tmds' support\n");
785 cfg->gfx_tmds = 0;
786 cfg->gfx_link_width = 4;
787 }
788 return;
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700789 }
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000790}
791
792static void smm_lock( void )
793{
794 /* LOCK the SMM memory window and enable normal SMM.
795 * After running this function, only a full reset can
796 * make the SMM registers writable again.
797 */
798 printk(BIOS_DEBUG, "Locking SMM.\n");
799 pci_write_config8(dev_find_slot(0, PCI_DEVFN(0, 0)), 0x69,
800 D_LCK | G_SMRAME | A_BASE_SEG);
801}
802
803 /**
804 * @brief Init
805 *
806 * @param the root device
807 */
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700808
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000809static void init(device_t dev)
810{
Nico Huberf1730352012-11-13 14:52:56 +0100811#if CONFIG_PCI_OPTION_ROM_RUN_REALMODE
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000812 INT15_function_extensions int15_func;
813#endif
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700814
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000815 printk(BIOS_DEBUG, "%s %s[%x/%x] %s\n",
Kyösti Mälkki7baadac2012-10-07 14:57:15 +0200816 dev_name(dev), dev_path(dev), dev->subsystem_vendor, dev->subsystem_device, __func__);
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700817
Nico Huberf1730352012-11-13 14:52:56 +0100818#if CONFIG_PCI_OPTION_ROM_RUN_REALMODE
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000819 if( get_option(&int15_func.regs.func00_LCD_panel_id, "lcd_panel_id") < 0 )
820 int15_func.regs.func00_LCD_panel_id = PANEL_TABLE_ID_NO;
821 int15_func.regs.func05_TV_standard = TV_MODE_NO;
822 install_INT15_function_extensions(&int15_func);
823#endif
824 set_thermal_config();
825 pm_init();
826 cable_detect();
827 patch_mmio_nonposted();
828 smm_lock();
829}
830
831/*************************************************
832* enable the dedicated function in sina board.
833* This function called early than rs690_enable.
834*************************************************/
835static void enable_dev(device_t dev)
836{
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700837
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000838 printk(BIOS_INFO, "%s %s[%x/%x] %s\n",
Kyösti Mälkki7baadac2012-10-07 14:57:15 +0200839 dev_name(dev), dev_path(dev), dev->subsystem_vendor, dev->subsystem_device, __func__);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000840#if CONFIG_PCI_OPTION_ROM_RUN_YABEL
841 /* Install custom int15 handler for VGA OPROM */
Patrick Georgi89bbcf42012-09-23 18:41:03 +0200842 mainboard_interrupt_handlers(0x15, &int15_handler);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000843#endif
844
845 detect_hw_variant(dev);
846 update_subsystemid(dev);
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000847
Stefan Reinauer5ff7c132011-10-31 12:56:45 -0700848 dev->ops->init = init; // rest of mainboard init later
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000849}
850
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000851struct chip_operations mainboard_ops = {
Josef Kellermannbfa7ee52011-05-11 07:47:43 +0000852 .enable_dev = enable_dev,
853};