summaryrefslogtreecommitdiffstats
path: root/src/soc/intel/denverton_ns/include/soc/soc_util.h
blob: 5309f150213bb1d5d12e021de7865c2d711d471e (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
/* SPDX-License-Identifier: GPL-2.0-only */
/* This file is part of the coreboot project. */

#ifndef _DENVERTON_NS_SOC_UTIL_H_
#define _DENVERTON_NS_SOC_UTIL_H_

#ifndef __ACPI__
#include <device/device.h>
#include <string.h>

/* Silicon revisions */
typedef enum {
	SILICON_REV_DENVERTON_A0 = 0x00,
	SILICON_REV_DENVERTON_A1 = 0x01,
	SILICON_REV_DENVERTON_B0 = 0x02,
} silicon_revision;

/* soc_util.c */
#ifdef __SIMPLE_DEVICE__
pci_devfn_t get_hostbridge_dev(void);
pci_devfn_t get_lpc_dev(void);
pci_devfn_t get_pmc_dev(void);
pci_devfn_t get_smbus_dev(void);
#else
struct device *get_hostbridge_dev(void);
struct device *get_lpc_dev(void);
struct device *get_pmc_dev(void);
struct device *get_smbus_dev(void);
#endif

uint32_t get_pciebase(void);
uint32_t get_pcielength(void);
uint32_t get_tseg_memory(void);
uint32_t get_top_of_low_memory(void);
uint64_t get_top_of_upper_memory(void);
uint16_t get_pmbase(void);
uint16_t get_tcobase(void);

/*
* Secure functions.
*/
void *memcpy_s(void *dest, const void *src, size_t n);

void mmio_andthenor32(void *addr, uint32_t val2and, uint32_t val2or);
uint8_t silicon_stepping(void);

/*
* MMIO Read/Write
*/
#define MMIO8(x) (*((volatile u8 *)(x)))
#define MMIO16(x) (*((volatile u16 *)(x)))
#define MMIO32(x) (*((volatile u32 *)(x)))

#define MMIO_AND_OR(bits, x, and, or) \
	(MMIO##bits(x) = ((MMIO##bits(x) & (and)) | (or)))

#define MMIO8_AND_OR(x, and, or) MMIO_AND_OR(8, x, and, or)
#define MMIO16_AND_OR(x, and, or) MMIO_AND_OR(16, x, and, or)
#define MMIO32_AND_OR(x, and, or) MMIO_AND_OR(32, x, and, or)
#define MMIO32_OR(x, or) MMIO_AND_OR(32, x, ~0UL, or)
#define MMIO32_AND(x, and) MMIO_AND_OR(32, x, and, 0UL)

#endif //__ACPI__

#endif /* _DENVERTON_NS_SOC_UTIL_H_ */