blob: b83eeaec73e7051257daaf397e803304033fa936 [file] [log] [blame]
Tobias Diedrichcee930a2017-02-12 14:09:06 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2017 Tobias Diedrich <ranma+coreboot@tdiedrich.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <stdint.h>
17#include <string.h>
18#include <cbfs.h>
19#include <lib.h>
20#include <timestamp.h>
21#include <arch/byteorder.h>
22#include <arch/io.h>
23#include <device/pci_def.h>
24#include <device/pnp_def.h>
25#include <cpu/x86/lapic.h>
26#include <arch/acpi.h>
27#include <console/console.h>
28#include "northbridge/intel/sandybridge/sandybridge.h"
29#include "northbridge/intel/sandybridge/raminit_native.h"
30#include "southbridge/intel/bd82x6x/pch.h"
31#include <southbridge/intel/common/gpio.h>
32#include <arch/cpu.h>
33#include <cpu/x86/msr.h>
34#include "ec.h"
35
36#define SPD_LEN 256
37
38void pch_enable_lpc(void)
39{
40 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0x82, 0x0c00);
41 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x84, 0x00000000);
42 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x88, 0x000c0701);
43 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x8c, 0x000c0069);
44 pci_write_config32(PCI_DEV(0, 0x1f, 0), 0x90, 0x000c06a1);
Patrick Rudolphac27d362017-05-04 19:00:33 +020045 pci_write_config32(PCI_DEV(0, 0x1f, 0), ETR3, 0x10000);
Tobias Diedrichcee930a2017-02-12 14:09:06 +010046
47 /* Memory map KB9012 EC registers */
48 pci_write_config32(
49 PCI_DEV(0, 0x1f, 0), 0x98,
50 CONFIG_EC_BASE_ADDRESS | 1);
51 pci_write_config16(PCI_DEV(0, 0x1f, 0), 0xd8, 0xffc0);
52
Tobias Diedrichcee930a2017-02-12 14:09:06 +010053 /* Enable external USB port power. */
Martin Roth5ef5c002017-03-24 11:08:32 -060054 if (IS_ENABLED(CONFIG_USBDEBUG))
55 ec_mm_set_bit(0x3b, 4);
Tobias Diedrichcee930a2017-02-12 14:09:06 +010056}
57
Nico Huberff4025c2018-01-14 12:34:43 +010058void mainboard_rcba_config(void)
Tobias Diedrichcee930a2017-02-12 14:09:06 +010059{
60 /* Disable devices. */
61 RCBA32(0x3414) = 0x00000020;
Tobias Diedrichcee930a2017-02-12 14:09:06 +010062}
63const struct southbridge_usb_port mainboard_usb_ports[] = {
64 { 1, 1, 0 },
65 { 1, 0, 0 },
66 { 1, 1, 1 },
67 { 1, 0, 1 },
68 { 1, 1, 2 },
69 { 1, 0, 2 },
70 { 0, 0, 3 },
71 { 0, 1, 3 },
72 { 1, 0, 4 },
73 { 1, 1, 4 },
74 { 1, 1, 5 },
75 { 1, 1, 5 },
76 { 1, 1, 6 },
77 { 1, 1, 6 },
78};
79
80void mainboard_early_init(int s3resume)
81{
82}
83
84void mainboard_config_superio(void)
85{
86}
87
88static const char *mainboard_spd_names[9] = {
89 "ELPIDA 4GB",
90 "SAMSUNG 4GB",
91 "HYNIX 4GB",
92 "ELPIDA 8GB",
93 "SAMSUNG 8GB",
94 "HYNIX 8GB",
95 "ELPIDA 2GB",
96 "SAMSUNG 2GB",
97 "HYNIX 2GB",
98};
99
100void mainboard_get_spd(spd_raw_data *spd, bool id_only)
101{
102 void *spd_file;
103 size_t spd_file_len = 0;
104 const int spd_gpios[] = {71, 70, 16, 48, -1};
105
106 u32 spd_index = get_gpios(spd_gpios);
107 if (spd_index >= ARRAY_SIZE(mainboard_spd_names)) {
108 /* Fallback to pessimistic 2GB image (ELPIDA 2GB) */
109 spd_index = 6;
110 }
111
112 printk(BIOS_INFO, "SPD index %d (%s)\n",
113 spd_index, mainboard_spd_names[spd_index]);
114
115 /* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */
116 spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD,
117 &spd_file_len);
118
119 if (!spd_file || spd_file_len < SPD_LEN * spd_index + SPD_LEN)
120 die("SPD data not found.");
121
122 memcpy(spd, spd_file + SPD_LEN * spd_index, SPD_LEN);
123}