| 1 |
|
| 2 |
#include <cbfs.h> |
| 3 |
#include <console/console.h> |
| 4 |
#include <device/dram/ddr3.h> |
| 5 |
#include <spd.h> |
| 6 |
#include <stdint.h> |
| 7 |
#include <string.h> |
| 8 |
|
| 9 |
#include "boardid.h" |
| 10 |
#include "spd.h" |
| 11 |
|
| 12 |
void mainboard_fill_dq_map_data(void *dq_map_ch0, void *dq_map_ch1) |
| 13 |
{ |
| 14 |
|
| 15 |
const u8 dq_map[2][12] = { |
| 16 |
{ 0x0F, 0xF0, 0x00, 0xF0, 0x0F, 0xF0, |
| 17 |
0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00 }, |
| 18 |
{ 0x0F, 0xF0, 0x00, 0xF0, 0x0F, 0xF0, |
| 19 |
0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00 } }; |
| 20 |
memcpy(dq_map_ch0, dq_map[0], sizeof(dq_map[0])); |
| 21 |
memcpy(dq_map_ch1, dq_map[1], sizeof(dq_map[1])); |
| 22 |
} |
| 23 |
|
| 24 |
void mainboard_fill_dqs_map_data(void *dqs_map_ch0, void *dqs_map_ch1) |
| 25 |
{ |
| 26 |
|
| 27 |
const u8 dqs_map[2][8] = { |
| 28 |
{ 0, 1, 3, 2, 6, 5, 4, 7 }, |
| 29 |
{ 2, 3, 0, 1, 6, 7, 4, 5 } }; |
| 30 |
memcpy(dqs_map_ch0, dqs_map[0], sizeof(dqs_map[0])); |
| 31 |
memcpy(dqs_map_ch1, dqs_map[1], sizeof(dqs_map[1])); |
| 32 |
} |
| 33 |
|
| 34 |
void mainboard_fill_rcomp_res_data(void *rcomp_ptr) |
| 35 |
{ |
| 36 |
|
| 37 |
const u16 RcompResistor[3] = { 200, 81, 162 }; |
| 38 |
memcpy(rcomp_ptr, RcompResistor, |
| 39 |
sizeof(RcompResistor)); |
| 40 |
} |
| 41 |
|
| 42 |
void mainboard_fill_rcomp_strength_data(void *rcomp_strength_ptr) |
| 43 |
{ |
| 44 |
int mem_cfg_id; |
| 45 |
|
| 46 |
mem_cfg_id = get_spd_index(); |
| 47 |
|
| 48 |
static const u16 RcompTarget[5] = { |
| 49 |
100, 40, 40, 23, 40 }; |
| 50 |
|
| 51 |
|
| 52 |
static const u16 StrengthendRcompTarget[5] = { |
| 53 |
100, 40, 40, 21, 40 }; |
| 54 |
|
| 55 |
if (mem_cfg_id == K4E6E304EE_MEM_ID) { |
| 56 |
memcpy(rcomp_strength_ptr, StrengthendRcompTarget, |
| 57 |
sizeof(StrengthendRcompTarget)); |
| 58 |
} else { |
| 59 |
memcpy(rcomp_strength_ptr, RcompTarget, sizeof(RcompTarget)); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
uintptr_t mainboard_get_spd_data(void) |
| 64 |
{ |
| 65 |
char *spd_file; |
| 66 |
int spd_index, spd_span; |
| 67 |
size_t spd_file_len; |
| 68 |
|
| 69 |
spd_index = get_spd_index(); |
| 70 |
printk(BIOS_INFO, "SPD index %d\n", spd_index); |
| 71 |
|
| 72 |
|
| 73 |
spd_file = cbfs_map("spd.bin", &spd_file_len); |
| 74 |
if (!spd_file) |
| 75 |
die("SPD data not found."); |
| 76 |
|
| 77 |
|
| 78 |
if (spd_file_len < SPD_SIZE_MAX_DDR3) |
| 79 |
die("Missing SPD data."); |
| 80 |
|
| 81 |
|
| 82 |
if (spd_file_len < ((spd_index + 1) * SPD_SIZE_MAX_DDR3)) { |
| 83 |
printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n"); |
| 84 |
spd_index = 0; |
| 85 |
} |
| 86 |
|
| 87 |
spd_span = spd_index * SPD_SIZE_MAX_DDR3; |
| 88 |
return (uintptr_t)(spd_file + spd_span); |
| 89 |
} |
| 90 |
|
| 91 |
int mainboard_has_dual_channel_mem(void) |
| 92 |
{ |
| 93 |
int spd_index; |
| 94 |
|
| 95 |
spd_index = get_spd_index(); |
| 96 |
|
| 97 |
if (spd_index != HYNIX_SINGLE_CHAN && spd_index != SAMSUNG_SINGLE_CHAN |
| 98 |
&& spd_index != MIC_SINGLE_CHAN) { |
| 99 |
printk(BIOS_INFO, |
| 100 |
"Dual channel SPD detected writing second channel\n"); |
| 101 |
return 1; |
| 102 |
} |
| 103 |
return 0; |
| 104 |
} |