Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 1 | /* |
| 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> |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 19 | #include <arch/byteorder.h> |
| 20 | #include <arch/io.h> |
| 21 | #include <device/pci_def.h> |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 22 | #include <console/console.h> |
Elyes HAOUAS | 4ad1446 | 2018-06-16 18:29:33 +0200 | [diff] [blame] | 23 | #include <northbridge/intel/sandybridge/sandybridge.h> |
| 24 | #include <northbridge/intel/sandybridge/raminit_native.h> |
| 25 | #include <southbridge/intel/bd82x6x/pch.h> |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 26 | #include <southbridge/intel/common/gpio.h> |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 27 | #include "ec.h" |
| 28 | |
| 29 | #define SPD_LEN 256 |
| 30 | |
| 31 | void pch_enable_lpc(void) |
| 32 | { |
Peter Lemenkov | 9b7ae2f | 2018-10-09 13:09:07 +0200 | [diff] [blame] | 33 | pci_write_config16(PCH_LPC_DEV, LPC_EN, MC_LPC_EN | KBC_LPC_EN); |
| 34 | pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc0701); |
| 35 | pci_write_config32(PCH_LPC_DEV, LPC_GEN3_DEC, 0xc0069); |
| 36 | pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0xc06a1); |
| 37 | pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 38 | |
| 39 | /* Memory map KB9012 EC registers */ |
| 40 | pci_write_config32( |
Peter Lemenkov | 9b7ae2f | 2018-10-09 13:09:07 +0200 | [diff] [blame] | 41 | PCH_LPC_DEV, LGMR, |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 42 | CONFIG_EC_BASE_ADDRESS | 1); |
Peter Lemenkov | 9b7ae2f | 2018-10-09 13:09:07 +0200 | [diff] [blame] | 43 | pci_write_config16(PCH_LPC_DEV, BIOS_DEC_EN1, 0xffc0); |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 44 | |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 45 | /* Enable external USB port power. */ |
Martin Roth | 5ef5c00 | 2017-03-24 11:08:32 -0600 | [diff] [blame] | 46 | if (IS_ENABLED(CONFIG_USBDEBUG)) |
| 47 | ec_mm_set_bit(0x3b, 4); |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 48 | } |
| 49 | |
Nico Huber | ff4025c | 2018-01-14 12:34:43 +0100 | [diff] [blame] | 50 | void mainboard_rcba_config(void) |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 51 | { |
| 52 | /* Disable devices. */ |
Peter Lemenkov | 9b7ae2f | 2018-10-09 13:09:07 +0200 | [diff] [blame] | 53 | RCBA32(BUC) = 0x00000020; |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 54 | } |
| 55 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
| 56 | { 1, 1, 0 }, |
| 57 | { 1, 0, 0 }, |
| 58 | { 1, 1, 1 }, |
| 59 | { 1, 0, 1 }, |
| 60 | { 1, 1, 2 }, |
| 61 | { 1, 0, 2 }, |
| 62 | { 0, 0, 3 }, |
| 63 | { 0, 1, 3 }, |
| 64 | { 1, 0, 4 }, |
| 65 | { 1, 1, 4 }, |
| 66 | { 1, 1, 5 }, |
| 67 | { 1, 1, 5 }, |
| 68 | { 1, 1, 6 }, |
| 69 | { 1, 1, 6 }, |
| 70 | }; |
| 71 | |
| 72 | void mainboard_early_init(int s3resume) |
| 73 | { |
| 74 | } |
| 75 | |
| 76 | void mainboard_config_superio(void) |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | static const char *mainboard_spd_names[9] = { |
| 81 | "ELPIDA 4GB", |
| 82 | "SAMSUNG 4GB", |
| 83 | "HYNIX 4GB", |
| 84 | "ELPIDA 8GB", |
| 85 | "SAMSUNG 8GB", |
| 86 | "HYNIX 8GB", |
| 87 | "ELPIDA 2GB", |
| 88 | "SAMSUNG 2GB", |
| 89 | "HYNIX 2GB", |
| 90 | }; |
| 91 | |
| 92 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) |
| 93 | { |
| 94 | void *spd_file; |
| 95 | size_t spd_file_len = 0; |
| 96 | const int spd_gpios[] = {71, 70, 16, 48, -1}; |
| 97 | |
| 98 | u32 spd_index = get_gpios(spd_gpios); |
| 99 | if (spd_index >= ARRAY_SIZE(mainboard_spd_names)) { |
| 100 | /* Fallback to pessimistic 2GB image (ELPIDA 2GB) */ |
| 101 | spd_index = 6; |
| 102 | } |
| 103 | |
| 104 | printk(BIOS_INFO, "SPD index %d (%s)\n", |
| 105 | spd_index, mainboard_spd_names[spd_index]); |
| 106 | |
| 107 | /* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */ |
| 108 | spd_file = cbfs_boot_map_with_leak("spd.bin", CBFS_TYPE_SPD, |
| 109 | &spd_file_len); |
| 110 | |
| 111 | if (!spd_file || spd_file_len < SPD_LEN * spd_index + SPD_LEN) |
| 112 | die("SPD data not found."); |
| 113 | |
| 114 | memcpy(spd, spd_file + SPD_LEN * spd_index, SPD_LEN); |
| 115 | } |