Tom Warren | 64982c50 | 2014-01-23 13:37:50 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2014 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 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include <console/console.h> |
| 21 | #include <soc/nvidia/tegra124/sdram.h> |
| 22 | #include "sdram_configs.h" |
| 23 | |
| 24 | /* |
| 25 | * Note for board bring up, we've temporarily filled SDRAM table with |
| 26 | * hynix-2GB-204 configuration (except the hynix-4GB-204 entry for 0100). |
| 27 | */ |
| 28 | static struct sdram_params sdram_configs[] = { |
| 29 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 0000 */ |
| 30 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 0001 */ |
| 31 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 0010 */ |
| 32 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 0011 */ |
| 33 | #include "bct/sdram-hynix-4GB-204.inc" /* ram_code = 0100 */ |
| 34 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 0101 */ |
| 35 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 0110 */ |
| 36 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 0111 */ |
| 37 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1000 */ |
| 38 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1001 */ |
| 39 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1010 */ |
| 40 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1011 */ |
| 41 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1100 */ |
| 42 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1101 */ |
| 43 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1110 */ |
| 44 | #include "bct/sdram-hynix-2GB-204.inc" /* ram_code = 1111 */ |
| 45 | }; |
| 46 | |
| 47 | const struct sdram_params *get_sdram_config() |
| 48 | { |
| 49 | uint32_t ramcode = sdram_get_ram_code(); |
| 50 | /* |
| 51 | * If we need to apply some special hacks to RAMCODE mapping (ex, by |
| 52 | * board_id), do that now. |
| 53 | */ |
| 54 | |
| 55 | printk(BIOS_SPEW, "%s: RAMCODE=%d\n", __func__, ramcode); |
| 56 | if (ramcode >= sizeof(sdram_configs) / sizeof(sdram_configs[0]) || |
| 57 | sdram_configs[ramcode].MemoryType == NvBootMemoryType_Unused) { |
| 58 | die("Invalid RAMCODE."); |
| 59 | } |
| 60 | |
| 61 | return &sdram_configs[ramcode]; |
| 62 | } |