fix further build.h dependencies that were undetected before we enabled it on
[coreboot.git] / src / mainboard / jetway / j7f24 / auto.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 VIA Technologies, Inc.
5  * (Written by Aaron Lwe <aaron.lwe@gmail.com> for VIA)
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
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  */
21
22 #define ASSEMBLY 1
23 #define __PRE_RAM__
24
25 #include <stdint.h>
26 #include <device/pci_def.h>
27 #include <device/pci_ids.h>
28 #include <arch/io.h>
29 #include <device/pnp_def.h>
30 #include <arch/romcc_io.h>
31 #include <arch/hlt.h>
32 #include "pc80/serial.c"
33 #include "arch/i386/lib/console.c"
34 #include "lib/ramtest.c"
35 #include "northbridge/via/cn700/raminit.h"
36 #include "cpu/x86/mtrr/earlymtrr.c"
37 #include "cpu/x86/bist.h"
38 #include "pc80/udelay_io.c"
39 #include "lib/delay.c"
40 #include "cpu/x86/lapic/boot_cpu.c"
41 #include "southbridge/via/vt8237r/vt8237r_early_smbus.c"
42 #include "superio/fintek/f71805f/f71805f_early_serial.c"
43
44 #if CONFIG_TTYS0_BASE == 0x2f8
45 #define SERIAL_DEV PNP_DEV(0x2e, F71805F_SP2)
46 #else
47 #define SERIAL_DEV PNP_DEV(0x2e, F71805F_SP1)
48 #endif
49
50 static void memreset_setup(void)
51 {
52 }
53
54 static inline int spd_read_byte(unsigned device, unsigned address)
55 {
56         return smbus_read_byte(device, address);
57 }
58
59 #include "northbridge/via/cn700/raminit.c"
60
61 static void enable_mainboard_devices(void)
62 {
63         device_t dev;
64
65         dev = pci_locate_device(PCI_ID(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT8237R_LPC), 0);
66         if (dev == PCI_DEV_INVALID)
67                 die("Southbridge not found!!!\n");
68
69         /* bit=0 means enable function (per CX700 datasheet)
70          *   5 16.1 USB 2
71          *   4 16.0 USB 1
72          *   3 15.0 SATA and PATA
73          *   2 16.2 USB 3
74          *   1 16.4 USB EHCI
75          */
76         pci_write_config8(dev, 0x50, 0x80);
77
78         /* bit=1 means enable internal function (per CX700 datasheet)
79          *   3 Internal RTC
80          *   2 Internal PS2 Mouse
81          *   1 Internal KBC Configuration
82          *   0 Internal Keyboard Controller
83          */
84         pci_write_config8(dev, 0x51, 0x1d);
85 }
86
87 static const struct mem_controller ctrl = {
88         .d0f0 = 0x0000,
89         .d0f2 = 0x2000,
90         .d0f3 = 0x3000,
91         .d0f4 = 0x4000,
92         .d0f7 = 0x7000,
93         .d1f0 = 0x8000,
94         .channel0 = { 0x50 },
95 };
96
97 static void main(unsigned long bist)
98 {
99         unsigned long x;
100         device_t dev;
101
102         /* Enable multifunction for northbridge. */
103         pci_write_config8(ctrl.d0f0, 0x4f, 0x01);
104
105         f71805f_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
106         uart_init();
107         console_init();
108
109         print_spew("In auto.c:main()\r\n");
110
111         enable_smbus();
112         smbus_fixup(&ctrl);
113
114         if (bist == 0) {
115                 print_debug("doing early_mtrr\r\n");
116                 early_mtrr_init();
117         }
118
119         /* Halt if there was a built-in self test failure. */
120         report_bist_failure(bist);
121
122         print_debug("Enabling mainboard devices\r\n");
123         enable_mainboard_devices();
124
125         ddr_ram_setup(&ctrl);
126
127         /* ram_check(0, 640 * 1024); */
128
129         print_spew("Leaving auto.c:main()\r\n");
130 }