Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2017 Google Inc. |
| 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 | |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 16 | #include <baseboard/variants.h> |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame^] | 17 | #include <console/console.h> |
| 18 | #include <gpio.h> /* src/include/gpio.h */ |
| 19 | #include <spd_bin.h> |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 20 | #include <variant/gpio.h> |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame^] | 21 | #include <amdblocks/dimm_spd.h> |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 22 | |
Marc Jones | 71f7f0a | 2017-11-21 23:29:55 -0700 | [diff] [blame] | 23 | uint8_t __attribute__((weak)) variant_memory_sku(void) |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 24 | { |
| 25 | gpio_t pads[] = { |
| 26 | [3] = MEM_CONFIG3, |
| 27 | [2] = MEM_CONFIG2, |
| 28 | [1] = MEM_CONFIG1, |
| 29 | [0] = MEM_CONFIG0, |
| 30 | }; |
| 31 | |
Martin Roth | 1cdb6f2 | 2017-11-17 09:25:02 -0700 | [diff] [blame] | 32 | return gpio_base2_value(pads, ARRAY_SIZE(pads)); |
Martin Roth | ac35e62 | 2017-11-07 13:43:02 -0700 | [diff] [blame] | 33 | } |
Marc Jones | fede56b | 2017-11-16 18:53:47 -0700 | [diff] [blame^] | 34 | |
| 35 | int __attribute__((weak)) variant_mainboard_read_spd(uint8_t spdAddress, |
| 36 | char *buf, size_t len) |
| 37 | { |
| 38 | struct region_device spd_rdev; |
| 39 | u8 spd_index = variant_memory_sku(); |
| 40 | |
| 41 | printk(BIOS_INFO, "%s SPD index %d\n", __func__, spd_index); |
| 42 | |
| 43 | if (get_spd_cbfs_rdev(&spd_rdev, spd_index) < 0) { |
| 44 | printk(BIOS_ERR, "Error: spd.bin not found\n"); |
| 45 | return -1; |
| 46 | } |
| 47 | |
| 48 | if (len != region_device_sz(&spd_rdev)) { |
| 49 | printk(BIOS_ERR, "Error: spd.bin is not the correct size\n"); |
| 50 | return -1; |
| 51 | } |
| 52 | |
| 53 | if (rdev_readat(&spd_rdev, buf, 0, len) != len) { |
| 54 | printk(BIOS_ERR, "Error: couldn't read spd.bin\n"); |
| 55 | return -1; |
| 56 | } |
| 57 | |
| 58 | return 0; |
| 59 | } |