SMM for AMD K8 Part 1/2
[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 /* Static resources for the VT8237R southbridge */
24
25 #define VT8237R_APIC_ID                 0x2
26 #define VT8237R_ACPI_IO_BASE            0x500
27 #define DEFAULT_PMBASE                  VT8237R_ACPI_IO_BASE
28 #define VT8237R_SMBUS_IO_BASE           0x400
29 /* 0x0 disabled, 0x2 reserved, 0xf = IRQ15 */
30 #define VT8237R_ACPI_IRQ                0x9
31 #if defined(__GNUC__)
32 #define VT8237S_SPI_MEM_BASE            0xfed02000ULL
33 #else
34 #define VT8237S_SPI_MEM_BASE            0xfed02000UL
35 #endif
36 #define VT8237R_HPET_ADDR               0xfed00000ULL
37
38 /* PMBASE FIXME mostly taken from ich7 */
39 #define PM1_STS         0x00
40 #define   WAK_STS       (1 << 15)
41 #define   PCIEXPWAK_STS (1 << 14)
42 #define   PRBTNOR_STS   (1 << 11)
43 #define   RTC_STS       (1 << 10)
44 #define   PWRBTN_STS    (1 << 8)
45 #define   GBL_STS       (1 << 5)
46 #define   BM_STS        (1 << 4)
47 #define   TMROF_STS     (1 << 0)
48 #define PM1_EN          0x02
49 #define   PCIEXPWAK_DIS (1 << 14)
50 #define   RTC_EN        (1 << 10)
51 #define   PWRBTN_EN     (1 << 8)
52 #define   GBL_EN        (1 << 5)
53 #define   TMROF_EN      (1 << 0)
54 #define PM1_CNT         0x04
55 #define   SLP_EN        (1 << 13)
56 #define   SLP_TYP       (7 << 10)
57 #define   GBL_RLS       (1 << 2)
58 #define   BM_RLD        (1 << 1)
59 #define   SCI_EN        (1 << 0)
60 #define PM1_TMR         0x08
61 #define PROC_CNT        0x10
62 #define LV2             0x14
63 #define LV3             0x15
64 #define SMI_STS         0x28
65 #define SMI_EN          0x2d
66 #define EOS             (1 << 0)
67
68 /* IDE */
69 #define IDE_CS                          0x40
70 #define IDE_CONF_I                      0x41
71 #define IDE_CONF_II                     0x42
72 #define IDE_CONF_FIFO                   0x43
73 #define IDE_MISC_I                      0x44
74 #define IDE_MISC_II                     0x45
75 #define IDE_UDMA                        0x50
76
77 #define VT8237R_IDE0_80PIN_CABLE ((1UL<<28)|(1UL<<20))
78 #define VT8237R_IDE1_80PIN_CABLE ((1UL<<12)|(1UL<< 4))
79 #define VT8237R_IDE_CABLESEL_MASK (VT8237R_IDE0_80PIN_CABLE|VT8237R_IDE1_80PIN_CABLE)
80
81 /* SMBus */
82 #define VT8237R_PSON                    0x82
83 #define VT8237R_POWER_WELL              0x94
84 #define VT8237R_SMBUS_IO_BASE_REG       0xd0
85 #define VT8237R_SMBUS_HOST_CONF         0xd2
86
87 #define SMBHSTSTAT                      (VT8237R_SMBUS_IO_BASE + 0x0)
88 #define SMBSLVSTAT                      (VT8237R_SMBUS_IO_BASE + 0x1)
89 #define SMBHSTCTL                       (VT8237R_SMBUS_IO_BASE + 0x2)
90 #define SMBHSTCMD                       (VT8237R_SMBUS_IO_BASE + 0x3)
91 #define SMBXMITADD                      (VT8237R_SMBUS_IO_BASE + 0x4)
92 #define SMBHSTDAT0                      (VT8237R_SMBUS_IO_BASE + 0x5)
93
94 #define HOST_RESET                      0xff
95 /* 1 in the 0 bit of SMBHSTADD states to READ. */
96 #define READ_CMD                        0x01
97 #define SMBUS_TIMEOUT                   (100 * 1000 * 10)
98 #define I2C_TRANS_CMD                   0x40
99 #define CLOCK_SLAVE_ADDRESS             0x69
100
101 #if CONFIG_DEBUG_SMBUS
102 #define PRINT_DEBUG(x)          print_debug(x)
103 #define PRINT_DEBUG_HEX16(x)    print_debug_hex16(x)
104 #else
105 #define PRINT_DEBUG(x)
106 #define PRINT_DEBUG_HEX16(x)
107 #endif
108
109 #define SMBUS_DELAY() inb(0x80)
110
111 struct vt8237_network_rom {
112         u8 mac_address[6];
113         u8 phy_addr;
114         u8 res1;
115         u16 sub_sid;
116         u16 sub_vid;
117         u16 pid;
118         u16 vid;
119         u8 pmcc;
120         u8 data_sel;
121         u8 pmu_data_reg;
122         u8 aux_curr;
123         u16 reserved;
124         u8 min_gnt;
125         u8 max_lat;
126         u8 bcr0;
127         u8 bcr1;
128         u8 cfg_a;
129         u8 cfg_b;
130         u8 cfg_c;
131         u8 cfg_d;
132         u8 checksum;
133 }
134 #if defined(__GNUC__)
135 __attribute__ ((packed))
136 #endif
137 ;
138
139 #define MAINBOARD_POWER_OFF     0
140 #define MAINBOARD_POWER_ON      1
141 #define MAINBOARD_POWER_KEEP    2
142
143 #ifndef CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL
144 #define CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL MAINBOARD_POWER_ON
145 #endif
146
147
148 #ifdef __PRE_RAM__
149 #ifndef __ROMCC__
150 u8 smbus_read_byte(u8 dimm, u8 offset);
151 void enable_smbus(void);
152 void smbus_fixup(const struct mem_controller *ctrl);
153 // these are in vt8237_early_smbus.c - do they really belong there?
154 void vt8237_sb_enable_fid_vid(void);
155 void enable_rom_decode(void);
156 void vt8237_early_spi_init(void);
157 int vt8237_early_network_init(struct vt8237_network_rom *rom);
158 #endif
159 #else
160 void writeback(device_t dev, u16 where, u8 what);
161 void dump_south(device_t dev);
162 u32 vt8237_ide_80pin_detect(device_t dev);
163 #endif
164
165 #endif