d54c533aeeb813bdea239fd47f5bf8d829aa22c2
[coreboot.git] / src / southbridge / via / vt8237r / vt8237r.h
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 #ifndef SOUTHBRIDGE_VIA_VT8237R_VT8237R_H
21 #define SOUTHBRIDGE_VIA_VT8237R_VT8237R_H
22
23 #include <stdint.h>
24
25 /* Static resources for the VT8237R southbridge */
26
27 #define VT8237R_APIC_ID                 0x2
28 #define VT8237R_ACPI_IO_BASE            0x500
29 #define VT8237R_SMBUS_IO_BASE           0x400
30 /* 0x0 disabled, 0x2 reserved, 0xf = IRQ15 */
31 #define VT8237R_ACPI_IRQ                0x9
32 #if defined(__GNUC__)
33 #define VT8237S_SPI_MEM_BASE            0xfed02000ULL
34 #else
35 #define VT8237S_SPI_MEM_BASE            0xfed02000UL
36 #endif
37 #define VT8237R_HPET_ADDR               0xfed00000ULL
38 #define VT8237R_APIC_BASE               0xfec00000ULL
39
40 /* IDE */
41 #define IDE_CS                          0x40
42 #define IDE_CONF_I                      0x41
43 #define IDE_CONF_II                     0x42
44 #define IDE_CONF_FIFO                   0x43
45 #define IDE_MISC_I                      0x44
46 #define IDE_MISC_II                     0x45
47 #define IDE_UDMA                        0x50
48
49 /* SMBus */
50 #define VT8237R_PSON                    0x82
51 #define VT8237R_POWER_WELL              0x94
52 #define VT8237R_SMBUS_IO_BASE_REG       0xd0
53 #define VT8237R_SMBUS_HOST_CONF         0xd2
54
55 #define SMBHSTSTAT                      (VT8237R_SMBUS_IO_BASE + 0x0)
56 #define SMBSLVSTAT                      (VT8237R_SMBUS_IO_BASE + 0x1)
57 #define SMBHSTCTL                       (VT8237R_SMBUS_IO_BASE + 0x2)
58 #define SMBHSTCMD                       (VT8237R_SMBUS_IO_BASE + 0x3)
59 #define SMBXMITADD                      (VT8237R_SMBUS_IO_BASE + 0x4)
60 #define SMBHSTDAT0                      (VT8237R_SMBUS_IO_BASE + 0x5)
61
62 #define HOST_RESET                      0xff
63 /* 1 in the 0 bit of SMBHSTADD states to READ. */
64 #define READ_CMD                        0x01
65 #define SMBUS_TIMEOUT                   (100 * 1000 * 10)
66 #define I2C_TRANS_CMD                   0x40
67 #define CLOCK_SLAVE_ADDRESS             0x69
68
69 #if CONFIG_DEBUG_SMBUS
70 #define PRINT_DEBUG(x)          print_debug(x)
71 #define PRINT_DEBUG_HEX16(x)    print_debug_hex16(x)
72 #else
73 #define PRINT_DEBUG(x)
74 #define PRINT_DEBUG_HEX16(x)
75 #endif
76
77 #define SMBUS_DELAY() inb(0x80)
78
79 struct vt8237_network_rom {
80         u8 mac_address[6];
81         u8 phy_addr;
82         u8 res1;
83         u16 sub_sid;
84         u16 sub_vid;
85         u16 pid;
86         u16 vid;
87         u8 pmcc;
88         u8 data_sel;
89         u8 pmu_data_reg;
90         u8 aux_curr;
91         u16 reserved;
92         u8 min_gnt;
93         u8 max_lat;
94         u8 bcr0;
95         u8 bcr1;
96         u8 cfg_a;
97         u8 cfg_b;
98         u8 cfg_c;
99         u8 cfg_d;
100         u8 checksum;
101 }
102 #if defined(__GNUC__)
103 __attribute__ ((packed))
104 #endif
105 ;
106
107 #ifdef __PRE_RAM__
108 #ifndef __ROMCC__
109 u8 smbus_read_byte(u8 dimm, u8 offset);
110 void enable_smbus(void);
111 void smbus_fixup(const struct mem_controller *ctrl);
112 // these are in vt8237_early_smbus.c - do they really belong there?
113 void vt8237_sb_enable_fid_vid(void);
114 void enable_rom_decode(void);
115 void vt8237_early_spi_init(void);
116 int vt8237_early_network_init(struct vt8237_network_rom *rom);
117 #endif
118 #else
119 #include <device/device.h>
120 void writeback(struct device *dev, u16 where, u8 what);
121 void dump_south(device_t dev);
122 #endif
123
124 #endif