get rid of even more fam10 and k8 warnings.
[coreboot.git] / src / northbridge / amd / amdfam10 / raminit_sysinfo_in_ram.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Advanced Micro Devices, 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 <delay.h>
21
22 static void set_htic_bit(u8 i, u32 val, u8 bit)
23 {
24         u32 dword;
25         dword = pci_read_config32(NODE_PCI(i, 0), HT_INIT_CONTROL);
26         dword &= ~(1<<bit);
27         dword |= ((val & 1) <<bit);
28         pci_write_config32(NODE_PCI(i, 0), HT_INIT_CONTROL, dword);
29 }
30
31 #ifdef UNUSED_CODE
32 static u32 get_htic_bit(u8 i, u8 bit)
33 {
34         u32 dword;
35         dword = pci_read_config32(NODE_PCI(i, 0), HT_INIT_CONTROL);
36         dword &= (1<<bit);
37         return dword;
38 }
39
40 static void wait_till_sysinfo_in_ram(void)
41 {
42         while(1) {
43                 /* give the NB a break, many CPUs spinning on one bit makes a
44                  * lot of traffic and time is not too important to APs.
45                  */
46                 udelay(1000);
47                 if(get_htic_bit(0, 9)) return;
48         }
49 }
50 #endif
51
52 static void set_sysinfo_in_ram(u32 val)
53 {
54         set_htic_bit(0, val, 9);
55 }
56
57 static void fill_mem_ctrl(u32 controllers, struct mem_controller *ctrl_a, const u8 *spd_addr)
58 {
59         int i;
60         int j;
61         int index = 0;
62         struct mem_controller *ctrl;
63         for(i=0;i<controllers; i++) {
64                 ctrl = &ctrl_a[i];
65                 ctrl->node_id = i;
66                 ctrl->f0 = NODE_PCI(i, 0);
67                 ctrl->f1 = NODE_PCI(i, 1);
68                 ctrl->f2 = NODE_PCI(i, 2);
69                 ctrl->f3 = NODE_PCI(i, 3);
70                 ctrl->f4 = NODE_PCI(i, 4);
71                 ctrl->f5 = NODE_PCI(i, 5);
72
73                 if(spd_addr == (void *)0) continue;
74
75                 ctrl->spd_switch_addr = spd_addr[index++];
76
77                 for(j=0; j < 8; j++) {
78                         ctrl->spd_addr[j] = spd_addr[index++];
79
80                 }
81         }
82 }
83