summaryrefslogtreecommitdiff
path: root/src/northbridge/intel/common/fixed_bars.h
blob: 79fd1559f56c9964370b5460b01c1f8319a639f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef NORTHBRIDGE_INTEL_COMMON_FIXED_BARS_H
#define NORTHBRIDGE_INTEL_COMMON_FIXED_BARS_H

#include <device/mmio.h>
#include <stdint.h>

_Static_assert(CONFIG_FIXED_MCHBAR_MMIO_BASE != 0, "MCHBAR base address is zero");

static __always_inline uint8_t mchbar_read8(const uintptr_t offset)
{
	return read8p(CONFIG_FIXED_MCHBAR_MMIO_BASE + offset);
}

static __always_inline uint16_t mchbar_read16(const uintptr_t offset)
{
	return read16p(CONFIG_FIXED_MCHBAR_MMIO_BASE + offset);
}

static __always_inline uint32_t mchbar_read32(const uintptr_t offset)
{
	return read32p(CONFIG_FIXED_MCHBAR_MMIO_BASE + offset);
}

static __always_inline void mchbar_write8(const uintptr_t offset, const uint8_t value)
{
	write8p(CONFIG_FIXED_MCHBAR_MMIO_BASE + offset, value);
}

static __always_inline void mchbar_write16(const uintptr_t offset, const uint16_t value)
{
	write16p(CONFIG_FIXED_MCHBAR_MMIO_BASE + offset, value);
}

static __always_inline void mchbar_write32(const uintptr_t offset, const uint32_t value)
{
	write32p(CONFIG_FIXED_MCHBAR_MMIO_BASE + offset, value);
}

static __always_inline void mchbar_clrsetbits8(uintptr_t offset, uint8_t clear, uint8_t set)
{
	clrsetbits8((void *)((uintptr_t)CONFIG_FIXED_MCHBAR_MMIO_BASE + offset), clear, set);
}

static __always_inline void mchbar_clrsetbits16(uintptr_t offset, uint16_t clear, uint16_t set)
{
	clrsetbits16((void *)((uintptr_t)CONFIG_FIXED_MCHBAR_MMIO_BASE + offset), clear, set);
}

static __always_inline void mchbar_clrsetbits32(uintptr_t offset, uint32_t clear, uint32_t set)
{
	clrsetbits32((void *)((uintptr_t)CONFIG_FIXED_MCHBAR_MMIO_BASE + offset), clear, set);
}

#define mchbar_setbits8(addr, set)		mchbar_clrsetbits8(addr, 0, set)
#define mchbar_setbits16(addr, set)		mchbar_clrsetbits16(addr, 0, set)
#define mchbar_setbits32(addr, set)		mchbar_clrsetbits32(addr, 0, set)

#define mchbar_clrbits8(addr, clear)		mchbar_clrsetbits8(addr, clear, 0)
#define mchbar_clrbits16(addr, clear)		mchbar_clrsetbits16(addr, clear, 0)
#define mchbar_clrbits32(addr, clear)		mchbar_clrsetbits32(addr, clear, 0)

_Static_assert(CONFIG_FIXED_DMIBAR_MMIO_BASE != 0, "DMIBAR base address is zero");

static __always_inline uint8_t dmibar_read8(const uintptr_t offset)
{
	return read8p(CONFIG_FIXED_DMIBAR_MMIO_BASE + offset);
}

static __always_inline uint16_t dmibar_read16(const uintptr_t offset)
{
	return read16p(CONFIG_FIXED_DMIBAR_MMIO_BASE + offset);
}

static __always_inline uint32_t dmibar_read32(const uintptr_t offset)
{
	return read32p(CONFIG_FIXED_DMIBAR_MMIO_BASE + offset);
}

static __always_inline void dmibar_write8(const uintptr_t offset, const uint8_t value)
{
	write8p(CONFIG_FIXED_DMIBAR_MMIO_BASE + offset, value);
}

static __always_inline void dmibar_write16(const uintptr_t offset, const uint16_t value)
{
	write16p(CONFIG_FIXED_DMIBAR_MMIO_BASE + offset, value);
}

static __always_inline void dmibar_write32(const uintptr_t offset, const uint32_t value)
{
	write32p(CONFIG_FIXED_DMIBAR_MMIO_BASE + offset, value);
}

static __always_inline void dmibar_clrsetbits8(uintptr_t offset, uint8_t clear, uint8_t set)
{
	clrsetbits8((void *)((uintptr_t)CONFIG_FIXED_DMIBAR_MMIO_BASE + offset), clear, set);
}

static __always_inline void dmibar_clrsetbits16(uintptr_t offset, uint16_t clear, uint16_t set)
{
	clrsetbits16((void *)((uintptr_t)CONFIG_FIXED_DMIBAR_MMIO_BASE + offset), clear, set);
}

static __always_inline void dmibar_clrsetbits32(uintptr_t offset, uint32_t clear, uint32_t set)
{
	clrsetbits32((void *)((uintptr_t)CONFIG_FIXED_DMIBAR_MMIO_BASE + offset), clear, set);
}

#define dmibar_setbits8(addr, set)		dmibar_clrsetbits8(addr, 0, set)
#define dmibar_setbits16(addr, set)		dmibar_clrsetbits16(addr, 0, set)
#define dmibar_setbits32(addr, set)		dmibar_clrsetbits32(addr, 0, set)

#define dmibar_clrbits8(addr, clear)		dmibar_clrsetbits8(addr, clear, 0)
#define dmibar_clrbits16(addr, clear)		dmibar_clrsetbits16(addr, clear, 0)
#define dmibar_clrbits32(addr, clear)		dmibar_clrsetbits32(addr, clear, 0)

_Static_assert(CONFIG_FIXED_EPBAR_MMIO_BASE  != 0,  "EPBAR base address is zero");

static __always_inline uint8_t epbar_read8(const uintptr_t offset)
{
	return read8p(CONFIG_FIXED_EPBAR_MMIO_BASE + offset);
}

static __always_inline uint16_t epbar_read16(const uintptr_t offset)
{
	return read16p(CONFIG_FIXED_EPBAR_MMIO_BASE + offset);
}

static __always_inline uint32_t epbar_read32(const uintptr_t offset)
{
	return read32p(CONFIG_FIXED_EPBAR_MMIO_BASE + offset);
}

static __always_inline void epbar_write8(const uintptr_t offset, const uint8_t value)
{
	write8p(CONFIG_FIXED_EPBAR_MMIO_BASE + offset, value);
}

static __always_inline void epbar_write16(const uintptr_t offset, const uint16_t value)
{
	write16p(CONFIG_FIXED_EPBAR_MMIO_BASE + offset, value);
}

static __always_inline void epbar_write32(const uintptr_t offset, const uint32_t value)
{
	write32p(CONFIG_FIXED_EPBAR_MMIO_BASE + offset, value);
}

static __always_inline void epbar_clrsetbits8(uintptr_t offset, uint8_t clear, uint8_t set)
{
	clrsetbits8((void *)((uintptr_t)CONFIG_FIXED_EPBAR_MMIO_BASE + offset), clear, set);
}

static __always_inline void epbar_clrsetbits16(uintptr_t offset, uint16_t clear, uint16_t set)
{
	clrsetbits16((void *)((uintptr_t)CONFIG_FIXED_EPBAR_MMIO_BASE + offset), clear, set);
}

static __always_inline void epbar_clrsetbits32(uintptr_t offset, uint32_t clear, uint32_t set)
{
	clrsetbits32((void *)((uintptr_t)CONFIG_FIXED_EPBAR_MMIO_BASE + offset), clear, set);
}

#define epbar_setbits8(addr, set)		epbar_clrsetbits8(addr, 0, set)
#define epbar_setbits16(addr, set)		epbar_clrsetbits16(addr, 0, set)
#define epbar_setbits32(addr, set)		epbar_clrsetbits32(addr, 0, set)

#define epbar_clrbits8(addr, clear)		epbar_clrsetbits8(addr, clear, 0)
#define epbar_clrbits16(addr, clear)		epbar_clrsetbits16(addr, clear, 0)
#define epbar_clrbits32(addr, clear)		epbar_clrsetbits32(addr, clear, 0)

#endif	/* ! NORTHBRIDGE_INTEL_COMMON_FIXED_BARS_H */