remove trailing whitespace
[coreboot.git] / src / southbridge / amd / sr5650 / cmn.h
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2010 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 #ifndef __SR5650_CMN_H__
21 #define __SR5650_CMN_H__
22
23 #include <arch/io.h>
24
25 #define NBMISC_INDEX    0x60
26 #define NBHTIU_INDEX    0x94 /* Note: It is different with RS690, whose HTIU index is 0xA8 */
27 #define NBMC_INDEX      0xE8
28 #define NBPCIE_INDEX    0xE0
29 #define EXT_CONF_BASE_ADDRESS   CONFIG_MMCONF_BASE_ADDRESS
30 #define TEMP_MMIO_BASE_ADDRESS  0xC0000000
31
32 #define axindxc_reg(reg, mask, val) \
33         alink_ax_indx(0, (reg), (mask), (val))
34
35 #define AB_INDX   0xCD8
36 #define AB_DATA   (AB_INDX+4)
37
38 static inline u32 nb_read_index(device_t dev, u32 index_reg, u32 index)
39 {
40         pci_write_config32(dev, index_reg, index);
41         return pci_read_config32(dev, index_reg + 0x4);
42 }
43
44 static inline void nb_write_index(device_t dev, u32 index_reg, u32 index, u32 data)
45 {
46         pci_write_config32(dev, index_reg, index);
47         pci_write_config32(dev, index_reg + 0x4, data);
48 }
49
50 static inline u32 nbmisc_read_index(device_t nb_dev, u32 index)
51 {
52         return nb_read_index((nb_dev), NBMISC_INDEX, (index));
53 }
54
55 static inline void nbmisc_write_index(device_t nb_dev, u32 index, u32 data)
56 {
57         nb_write_index((nb_dev), NBMISC_INDEX, ((index) | 0x80), (data));
58 }
59
60 static inline void set_nbmisc_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask,
61                                    u32 val)
62 {
63         u32 reg_old, reg;
64         reg = reg_old = nbmisc_read_index(nb_dev, reg_pos);
65         reg &= ~mask;
66         reg |= val;
67         if (reg != reg_old) {
68                 nbmisc_write_index(nb_dev, reg_pos, reg);
69         }
70 }
71
72 static inline u32 htiu_read_index(device_t nb_dev, u32 index)
73 {
74         return nb_read_index((nb_dev), NBHTIU_INDEX, (index));
75 }
76
77 static inline void htiu_write_index(device_t nb_dev, u32 index, u32 data)
78 {
79         nb_write_index((nb_dev), NBHTIU_INDEX, ((index) | 0x100), (data));
80 }
81
82 static inline u32 nbmc_read_index(device_t nb_dev, u32 index)
83 {
84         return nb_read_index((nb_dev), NBMC_INDEX, (index));
85 }
86
87 static inline void nbmc_write_index(device_t nb_dev, u32 index, u32 data)
88 {
89         nb_write_index((nb_dev), NBMC_INDEX, ((index) | 1 << 9), (data));
90 }
91
92 static inline void set_htiu_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask,
93                                  u32 val)
94 {
95         u32 reg_old, reg;
96         reg = reg_old = htiu_read_index(nb_dev, reg_pos);
97         reg &= ~mask;
98         reg |= val;
99         if (reg != reg_old) {
100                 htiu_write_index(nb_dev, reg_pos, reg);
101         }
102 }
103
104 static inline void set_nbcfg_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask,
105                                   u32 val)
106 {
107         u32 reg_old, reg;
108         reg = reg_old = pci_read_config32(nb_dev, reg_pos);
109         reg &= ~mask;
110         reg |= val;
111         if (reg != reg_old) {
112                 pci_write_config32(nb_dev, reg_pos, reg);
113         }
114 }
115
116 static inline void set_nbcfg_enable_bits_8(device_t nb_dev, u32 reg_pos, u8 mask,
117                                     u8 val)
118 {
119         u8 reg_old, reg;
120         reg = reg_old = pci_read_config8(nb_dev, reg_pos);
121         reg &= ~mask;
122         reg |= val;
123         if (reg != reg_old) {
124                 pci_write_config8(nb_dev, reg_pos, reg);
125         }
126 }
127
128 static inline void set_nbmc_enable_bits(device_t nb_dev, u32 reg_pos, u32 mask,
129                                  u32 val)
130 {
131         u32 reg_old, reg;
132         reg = reg_old = nbmc_read_index(nb_dev, reg_pos);
133         reg &= ~mask;
134         reg |= val;
135         if (reg != reg_old) {
136                 nbmc_write_index(nb_dev, reg_pos, reg);
137         }
138 }
139
140 static inline void set_pcie_enable_bits(device_t dev, u32 reg_pos, u32 mask, u32 val)
141 {
142         u32 reg_old, reg;
143         reg = reg_old = nb_read_index(dev, NBPCIE_INDEX, reg_pos);
144         reg &= ~mask;
145         reg |= val;
146         if (reg != reg_old) {
147                 nb_write_index(dev, NBPCIE_INDEX, reg_pos, reg);
148         }
149 }
150 #endif /* __SR5650_CMN_H__ */