Angel Pons | 89ab250 | 2020-04-03 01:22:28 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 2 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 3 | #include <device/pci_ops.h> |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 4 | #include <console/console.h> |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 5 | #include <northbridge/intel/sandybridge/raminit.h> |
Elyes HAOUAS | 4ad1446 | 2018-06-16 18:29:33 +0200 | [diff] [blame] | 6 | #include <southbridge/intel/bd82x6x/pch.h> |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 7 | #include <southbridge/intel/common/gpio.h> |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 8 | #include "ec.h" |
| 9 | |
Arthur Heymans | 2b28a16 | 2019-11-12 17:21:08 +0100 | [diff] [blame] | 10 | void mainboard_pch_lpc_setup(void) |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 11 | { |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 12 | /* Memory map KB9012 EC registers */ |
| 13 | pci_write_config32( |
Peter Lemenkov | 9b7ae2f | 2018-10-09 13:09:07 +0200 | [diff] [blame] | 14 | PCH_LPC_DEV, LGMR, |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 15 | CONFIG_EC_BASE_ADDRESS | 1); |
Peter Lemenkov | 9b7ae2f | 2018-10-09 13:09:07 +0200 | [diff] [blame] | 16 | pci_write_config16(PCH_LPC_DEV, BIOS_DEC_EN1, 0xffc0); |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 17 | |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 18 | /* Enable external USB port power. */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 19 | if (CONFIG(USBDEBUG)) |
Martin Roth | 5ef5c00 | 2017-03-24 11:08:32 -0600 | [diff] [blame] | 20 | ec_mm_set_bit(0x3b, 4); |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 21 | } |
| 22 | |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 23 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
| 24 | { 1, 1, 0 }, |
| 25 | { 1, 0, 0 }, |
| 26 | { 1, 1, 1 }, |
| 27 | { 1, 0, 1 }, |
| 28 | { 1, 1, 2 }, |
| 29 | { 1, 0, 2 }, |
| 30 | { 0, 0, 3 }, |
| 31 | { 0, 1, 3 }, |
| 32 | { 1, 0, 4 }, |
| 33 | { 1, 1, 4 }, |
| 34 | { 1, 1, 5 }, |
| 35 | { 1, 1, 5 }, |
| 36 | { 1, 1, 6 }, |
| 37 | { 1, 1, 6 }, |
| 38 | }; |
| 39 | |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 40 | static const char *mainboard_spd_names[9] = { |
| 41 | "ELPIDA 4GB", |
| 42 | "SAMSUNG 4GB", |
| 43 | "HYNIX 4GB", |
| 44 | "ELPIDA 8GB", |
| 45 | "SAMSUNG 8GB", |
| 46 | "HYNIX 8GB", |
| 47 | "ELPIDA 2GB", |
| 48 | "SAMSUNG 2GB", |
| 49 | "HYNIX 2GB", |
| 50 | }; |
| 51 | |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 52 | static unsigned int get_spd_index(void) |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 53 | { |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 54 | const int spd_gpios[] = {71, 70, 16, 48, -1}; |
| 55 | |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 56 | unsigned int spd_index = get_gpios(spd_gpios); |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 57 | if (spd_index >= ARRAY_SIZE(mainboard_spd_names)) { |
| 58 | /* Fallback to pessimistic 2GB image (ELPIDA 2GB) */ |
| 59 | spd_index = 6; |
| 60 | } |
| 61 | |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 62 | return spd_index; |
| 63 | } |
| 64 | |
| 65 | void mb_get_spd_map(struct spd_info *spdi) |
| 66 | { |
| 67 | unsigned int spd_index = get_spd_index(); |
| 68 | |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 69 | printk(BIOS_INFO, "SPD index %d (%s)\n", |
| 70 | spd_index, mainboard_spd_names[spd_index]); |
| 71 | |
Peter Lemenkov | 6b7d40a | 2020-01-22 11:40:16 +0100 | [diff] [blame] | 72 | /* C0S0 is a soldered RAM with no real SPD. Use stored SPD. */ |
Keith Hui | 45e4ab4 | 2023-07-22 12:49:05 -0400 | [diff] [blame] | 73 | spdi->addresses[0] = SPD_MEMORY_DOWN; |
| 74 | spdi->spd_index = spd_index; |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 75 | } |