Drop per-board ram_check() calls for now.
[coreboot.git] / src / mainboard / lippert / frontrunner / romstage.c
1 #include <stdint.h>
2 #include <spd.h>
3 #include <device/pci_def.h>
4 #include <arch/io.h>
5 #include <device/pnp_def.h>
6 #include <arch/hlt.h>
7 #include <console/console.h>
8 #include "superio/winbond/w83627hf/w83627hf_early_serial.c"
9 #include "cpu/x86/bist.h"
10 #include "cpu/x86/msr.h"
11 #include <cpu/amd/gx2def.h>
12 #include <cpu/amd/geode_post_code.h>
13 #include "southbridge/amd/cs5535/cs5535.h"
14 #include "southbridge/amd/cs5535/cs5535_early_smbus.c"
15 #include "southbridge/amd/cs5535/cs5535_early_setup.c"
16
17 #define SERIAL_DEV PNP_DEV(0x2e, W83627HF_SP1)
18
19 static const unsigned char spdbytes[] = {       /* 4x Qimonda HYB25DC512160CF-6 */
20         0xFF, 0xFF,                             /* only values used by raminit.c are set */
21         [SPD_MEMORY_TYPE]               = SPD_MEMORY_TYPE_SDRAM_DDR,    /* (Fundamental) memory type */
22         [SPD_NUM_ROWS]                  = 0x0D, /* Number of row address bits [13] */
23         [SPD_NUM_COLUMNS]               = 0x0A, /* Number of column address bits [10] */
24         [SPD_NUM_DIMM_BANKS]            = 1,    /* Number of module rows (banks) */
25         0xFF, 0xFF, 0xFF,
26         [SPD_MIN_CYCLE_TIME_AT_CAS_MAX] = 0x60, /* SDRAM cycle time (highest CAS latency), RAS access time (tRAC) [6.0 ns in BCD] */
27         0xFF, 0xFF,
28         [SPD_REFRESH]                   = 0x82, /* Refresh rate/type [Self Refresh, 7.8 us] */
29         [SPD_PRIMARY_SDRAM_WIDTH]       = 64,   /* SDRAM width (primary SDRAM) [64 bits] */
30         0xFF, 0xFF, 0xFF,
31         [SPD_NUM_BANKS_PER_SDRAM]       = 4,    /* SDRAM device attributes, number of banks on SDRAM device */
32         [SPD_ACCEPTABLE_CAS_LATENCIES]  = 0x1C, /* SDRAM device attributes, CAS latency [3, 2.5, 2] */
33         0xFF, 0xFF,
34         [SPD_MODULE_ATTRIBUTES]         = 0x20, /* SDRAM module attributes [differential clk] */
35         [SPD_DEVICE_ATTRIBUTES_GENERAL] = 0x40, /* SDRAM device attributes, general [Concurrent AP] */
36         [SPD_SDRAM_CYCLE_TIME_2ND]      = 0x60, /* SDRAM cycle time (2nd highest CAS latency) [6.0 ns in BCD] */
37         0xFF,
38         [SPD_SDRAM_CYCLE_TIME_3RD]      = 0x75, /* SDRAM cycle time (3rd highest CAS latency) [7.5 ns in BCD] */
39         0xFF,
40         [SPD_tRP]                       = 72,   /* Min. row precharge time [18 ns in units of 0.25 ns] */
41         [SPD_tRRD]                      = 48,   /* Min. row active to row active [12 ns in units of 0.25 ns] */
42         [SPD_tRCD]                      = 72,   /* Min. RAS to CAS delay [18 ns in units of 0.25 ns] */
43         [SPD_tRAS]                      = 42,   /* Min. RAS pulse width = active to precharge delay [42 ns] */
44         [SPD_BANK_DENSITY]              = 0x40, /* Density of each row on module [256 MB] */
45         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
46         [SPD_tRFC]                      = 72    /* SDRAM Device Minimum Auto Refresh to Active/Auto Refresh [72 ns] */
47 };
48
49 static inline int spd_read_byte(unsigned int device, unsigned int address)
50 {
51         if (device != DIMM0)
52                 return 0xFF;    /* No DIMM1, don't even try. */
53
54 #if CONFIG_DEBUG_SMBUS
55         if (address >= sizeof(spdbytes) || spdbytes[address] == 0xFF) {
56                 print_err("ERROR: spd_read_byte(DIMM0, 0x");
57                 print_err_hex8(address);
58                 print_err(") returns 0xff\n");
59         }
60 #endif
61
62         /* Fake SPD ROM value */
63         return (address < sizeof(spdbytes)) ? spdbytes[address] : 0xFF;
64 }
65
66 #include "northbridge/amd/gx2/raminit.h"
67 #include "northbridge/amd/gx2/pll_reset.c"
68 #include "northbridge/amd/gx2/raminit.c"
69 #include "lib/generic_sdram.c"
70 #include "cpu/amd/model_gx2/cpureginit.c"
71 #include "cpu/amd/model_gx2/syspreinit.c"
72 #include "cpu/amd/model_lx/msrinit.c"
73
74 void main(unsigned long bist)
75 {
76         static const struct mem_controller memctrl [] = {
77                 {.channel0 = {DIMM0, DIMM1}}
78         };
79         unsigned char temp;
80
81         SystemPreInit();
82         msr_init();
83
84         w83627hf_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
85         uart_init();
86         console_init();
87
88         cs5535_early_setup();
89         print_err("done cs5535 early\n");
90
91         /* Halt if there was a built in self test failure */
92         report_bist_failure(bist);
93
94         pll_reset();
95         print_err("done pll_reset\n");
96
97         cpuRegInit();
98         print_err("done cpuRegInit\n");
99
100         sdram_initialize(1, memctrl);
101
102         print_err("Done sdram_initialize\n");
103         print_err("Disable watchdog\n");
104         outb( 0x87, 0x4E);                            //enter SuperIO configuration mode
105         outb( 0x87, 0x4E);
106
107         outb(0x20, 0x4e);
108         temp = inb(0x4f);
109         print_debug_hex8(temp);
110         if (temp != 0x52){
111                 print_err("CAN NOT READ SUPERIO VID\n");
112         }
113
114         outb(0x29, 0x4e);
115         outb(0x7c, 0x4f);
116
117         outb( 0x07, 0x4E);                            //enable logical device 9
118         outb( 0x09, 0x4F);
119         outb(0x30, 0x4e);
120         outb(1, 0x4f);
121         outb( 0xF0, 0x4E);                            //set GP33 as outbut in configuration register F0h     Bit4 = \u20180\u2019
122         outb( 0xC7, 0x4F);
123         outb( 0xF1, 0x4E);                            //clr GP33 (Bit4) value in cofiguration register F1h to \u20181\u2019 disables
124         temp = inb(0x4F);                            //watchdog function. Make sure to let the other Bits unchanged!
125         print_debug_hex8(temp);print_debug(":");
126         temp = temp & ~8;
127         outb( temp, 0x4F);
128         temp = inb(0x4F);                            //watchdog function. Make sure to let the other Bits unchanged!
129         print_debug_hex8(temp);print_debug("\n");
130 }