8be26db6082cf6192b6a961927741c6720cd8f53
[coreboot.git] / src / southbridge / via / vt8237r / vt8237r.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007 Rudolf Marek <r.marek@assembler.cz>
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 <device/pci.h>
23 #include <device/pci_ids.h>
24 #include "chip.h"
25
26 /*
27  * Datasheet: http://www.via.com.tw/en/downloads/datasheets/chipsets/
28  *              VT8237R_SouthBridge_Revision2.06_Lead-Free.zip
29  */
30
31 void hard_reset(void)
32 {
33         printk_err("NO HARD RESET ON VT8237R! FIX ME!\n");
34 }
35
36 #if CONFIG_DEFAULT_CONSOLE_LOGLEVEL > 7
37 void writeback(struct device *dev, u16 where, u8 what)
38 {
39         u8 regval;
40
41         pci_write_config8(dev, where, what);
42         regval = pci_read_config8(dev, where);
43
44         if (regval != what) {
45                 print_debug("Writeback to ");
46                 print_debug_hex8(where);
47                 print_debug("failed ");
48                 print_debug_hex8(regval);
49                 print_debug("\n ");     /* TODO: Drop the space? */
50         }
51 }
52 #else
53 void writeback(struct device *dev, u16 where, u8 what)
54 {
55         pci_write_config8(dev, where, what);
56 }
57 #endif
58
59 void dump_south(device_t dev)
60 {
61         int i, j;
62
63         for (i = 0; i < 256; i += 16) {
64                 printk_debug("%02x: ", i);
65                 for (j = 0; j < 16; j++)
66                         printk_debug("%02x ", pci_read_config8(dev, i + j));
67                 printk_debug("\n");
68         }
69 }
70
71 static void vt8237r_enable(struct device *dev)
72 {
73         struct southbridge_via_vt8237r_config *sb =
74             (struct southbridge_via_vt8237r_config *)dev->chip_info;
75
76         pci_write_config8(dev, 0x50, sb->fn_ctrl_lo);
77         pci_write_config8(dev, 0x51, sb->fn_ctrl_hi);
78
79         /* TODO: If SATA is disabled, move IDE to fn0 to conform PCI specs. */
80 }
81
82 struct chip_operations southbridge_via_vt8237r_ops = {
83         CHIP_NAME("VIA VT8237R Southbridge")
84         .enable_dev = vt8237r_enable,
85 };