Patch for AMD DBM690T board.
[coreboot.git] / src / mainboard / amd / dbm690t / mainboard.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008 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 <console/console.h>
21 #include <device/device.h>
22 #include <arch/io.h>
23 #include <boot/coreboot_tables.h>
24 #include <cpu/x86/msr.h>
25 #include <cpu/amd/mtrr.h>
26 #include "chip.h"
27
28 /********************************************************
29 * dbm690t uses a BCM5789 as on-board NIC.
30 * It has a pin named LOW_POWER to enable it into LOW POWER state.
31 * In order to run NIC, we should let it out of Low power state. This pin
32 * is controlled by sb600 GPM3.
33 * RRG4.2.3 GPM as GPIO
34 * GPM pins can be used as GPIO. The GPM I/O functions is controlled by three registers:
35 * I/O C50, C51, C52, PM I/O94, 95, 96.
36 * RRG4.2.3.1 GPM pins as Input
37 * RRG4.2.3.2 GPM pins as Output
38 ********************************************************/
39 static void enable_onboard_nic()
40 {
41         u8 byte;
42
43         printk_info("enable_onboard_nic.\n");
44
45         outb(0x13, 0xC50);
46
47         byte = inb(0xC51);
48         byte &= 0x3F;
49         byte |= 0x40;
50         outb(byte, 0xC51);
51
52         byte = inb(0xC52);
53         byte &= ~0x8;
54         outb(byte, 0xC52);
55
56         byte = inb(0xC51);
57         byte &= 0x3F;
58         byte |= 0x80;           /* 7:6=10 */
59         outb(byte, 0xC51);
60
61         byte = inb(0xC52);
62         byte &= ~0x8;
63         outb(byte, 0xC52);
64 }
65
66 /*************************************************
67 * enable the dedicated function in dbm690t board.
68 * This function called early than rs690_enable.
69 *************************************************/
70 void dbm690t_enable(device_t dev)
71 {
72         struct mainboard_amd_dbm690t_config *mainboard =
73             (struct mainboard_amd_dbm690t_config *)dev->chip_info;
74
75 #if (CONFIG_GFXUMA == 1)
76         msr_t msr, msr2;
77
78         /* TOP_MEM: the top of DRAM below 4G */
79         msr = rdmsr(TOP_MEM);
80         printk_info("dbm690t_enable, TOP MEM: msr.lo = 0x%08x, msr.hi = 0x%08x\n", msr.lo, msr.hi);
81
82         /* TOP_MEM2: the top of DRAM above 4G */
83         msr2 = rdmsr(TOP_MEM2);
84         printk_info("dbm690t_enable, TOP MEM2: msr2.lo = 0x%08x, msr2.hi = 0x%08x\n", msr2.lo, msr2.hi);
85
86         switch (msr.lo) {
87                 case 0x10000000: /* 256M system memory */
88                         uma_memory_size = 0x2000000; /* 32M recommended UMA */
89                         break;
90
91                 case 0x18000000: /* 384M system memory */
92                         uma_memory_size = 0x4000000; /* 64M recommended UMA */
93                         break;
94
95                 case 0x20000000: /* 512M system memory */
96                         uma_memory_size = 0x4000000; /* 64M recommended UMA */
97                         break;
98
99                 default: /* 1GB and above system memory */
100                         uma_memory_size = 0x8000000; /* 128M recommended UMA */
101                         break;
102         }
103
104         uma_memory_start = msr.lo - uma_memory_size;/* TOP_MEM1 */
105         printk_info("dbm690t_enable: uma size 0x%08x, memory start 0x%08x\n", uma_memory_size, uma_memory_start);
106
107         /* TODO: TOP_MEM2 */
108 #else
109         uma_memory_size = 0x8000000; /* 128M recommended UMA */
110         uma_memory_start = 0x38000000; /* 1GB  system memory supposed */
111 #endif
112
113         printk_info("dbm690t_enable. dev=0x%x\n", dev);
114
115         enable_onboard_nic();
116 }
117
118 /*
119 * CONFIG_CHIP_NAME defined in Option.lb.
120 */
121 struct chip_operations mainboard_amd_dbm690t_ops = {
122 #if CONFIG_CHIP_NAME == 1
123         CHIP_NAME("AMD Dbm690t   Mainboard")
124 #endif
125         .enable_dev = dbm690t_enable,
126 };