aboutsummaryrefslogtreecommitdiff
path: root/platforms/astbmc/astbmc.h
blob: fb6c68a2055f85b55a0c53b5cd17afa390f2069c (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
/* Copyright 2013-2016 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __ASTBMC_H
#define __ASTBMC_H

#define ST_LOC_PHB(chip_id, phb_idx)    ((chip_id) << 16 | (phb_idx))
#define ST_LOC_DEVFN(dev, fn)	        ((dev) << 3 | (fn))
/*
 * NPU groups are used to allocate device numbers.  There is a 1 to 1
 * correlation between a NPU group and a physical GPU.  Links within a group
 * are allocated as functions within a device, so groups must be numbered
 * sequentially starting at 0.
 */
#define ST_LOC_NPU_GROUP(group_id)	(group_id << 3)

struct slot_table_entry {
	enum slot_table_etype {
		st_end,		/* End of list */
		st_phb,
		st_pluggable_slot,
		st_builtin_dev,
		st_npu_slot
	} etype;
	uint32_t location;
	const char *name;
	const struct slot_table_entry *children;
	uint8_t power_limit;
};

/*
 * Helper to reduce the noise in the PHB table
 */
#define ST_PHB_ENTRY(chip_id, phb_id, child_table) \
{ \
	.etype = st_phb, \
	.location = ST_LOC_PHB(chip_id, phb_id), \
	.children = child_table \
}

/*
 * For the most part the "table" isn't really a table and only contains
 * a single real entry and the etype = st_end terminator. In these cases
 * we can use these helpers. If you need something special in the slot
 * table for each slot (e.g. power limit, devfn != 0) then you need to
 * define the actual structure.
 */
#define ST_BUILTIN_DEV(st_name, slot_name) \
static struct slot_table_entry st_name[] = \
{ \
	{ \
		.etype = st_pluggable_slot, \
		.name = slot_name, \
	}, \
	{ .etype = st_end }, \
}

#define ST_PLUGGABLE(st_name, slot_name) \
static struct slot_table_entry st_name[] = \
{ \
	{ \
		.etype = st_pluggable_slot, \
		.name = slot_name, \
	}, \
	{ .etype = st_end }, \
}

extern const struct bmc_platform astbmc_ami;
extern const struct bmc_platform astbmc_openbmc;

extern void astbmc_early_init(void);
extern int64_t astbmc_ipmi_reboot(void);
extern int64_t astbmc_ipmi_power_down(uint64_t request);
extern void astbmc_init(void);
extern void astbmc_ext_irq_serirq_cpld(unsigned int chip_id);
extern int pnor_init(void);
extern void check_all_slot_table(void);

extern void slot_table_init(const struct slot_table_entry *top_table);
extern void slot_table_get_slot_info(struct phb *phb, struct pci_device * pd);
void dt_slot_get_slot_info(struct phb *phb, struct pci_device *pd);

#endif /* __ASTBMC_H */