xref: /aosp_15_r20/external/coreboot/src/include/device/path.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef DEVICE_PATH_H
4 #define DEVICE_PATH_H
5 
6 #include <stdint.h>
7 
8 enum device_path_type {
9 	DEVICE_PATH_NONE = 0,
10 	DEVICE_PATH_ROOT,
11 	DEVICE_PATH_PCI,
12 	DEVICE_PATH_PNP,
13 	DEVICE_PATH_I2C,
14 	DEVICE_PATH_APIC,
15 	DEVICE_PATH_DOMAIN,
16 	DEVICE_PATH_CPU_CLUSTER,
17 	DEVICE_PATH_CPU,
18 	DEVICE_PATH_CPU_BUS,
19 	DEVICE_PATH_IOAPIC,
20 	DEVICE_PATH_GENERIC,
21 	DEVICE_PATH_SPI,
22 	DEVICE_PATH_USB,
23 	DEVICE_PATH_MMIO,
24 	DEVICE_PATH_GPIO,
25 	DEVICE_PATH_MDIO,
26 	DEVICE_PATH_GICC_V3,
27 
28 	/*
29 	 * When adding path types to this table, please also update the
30 	 * DEVICE_PATH_NAMES macro below.
31 	 */
32 };
33 
34 #define DEVICE_PATH_NAMES {			\
35 		"DEVICE_PATH_NONE",		\
36 		"DEVICE_PATH_ROOT",		\
37 		"DEVICE_PATH_PCI",		\
38 		"DEVICE_PATH_PNP",		\
39 		"DEVICE_PATH_I2C",		\
40 		"DEVICE_PATH_APIC",		\
41 		"DEVICE_PATH_DOMAIN",		\
42 		"DEVICE_PATH_CPU_CLUSTER",	\
43 		"DEVICE_PATH_CPU",		\
44 		"DEVICE_PATH_CPU_BUS",		\
45 		"DEVICE_PATH_IOAPIC",		\
46 		"DEVICE_PATH_GENERIC",		\
47 		"DEVICE_PATH_SPI",		\
48 		"DEVICE_PATH_USB",		\
49 		"DEVICE_PATH_MMIO",		\
50 		"DEVICE_PATH_GPIO",		\
51 		"DEVICE_PATH_MDIO",		\
52 		"DEVICE_PATH_GICC_V3",		\
53 }
54 
55 struct domain_path {
56 	unsigned int domain;
57 };
58 
59 struct pci_path {
60 	unsigned int devfn;
61 };
62 
63 struct pnp_path {
64 	unsigned int port;
65 	unsigned int device;
66 };
67 
68 struct i2c_path {
69 	unsigned int device;
70 	unsigned int mode_10bit;
71 };
72 
73 struct spi_path {
74 	unsigned int cs;
75 };
76 
77 struct apic_path {
78 	unsigned int initial_lapicid;
79 	unsigned int apic_id;
80 	unsigned int package_id;
81 	unsigned int node_id;
82 	unsigned int core_id;
83 	unsigned int thread_id;
84 	unsigned char core_type;
85 };
86 
87 struct ioapic_path {
88 	unsigned int ioapic_id;
89 };
90 
91 struct cpu_cluster_path {
92 	unsigned int cluster;
93 };
94 
95 struct cpu_path {
96 	unsigned int id;
97 };
98 
99 struct cpu_bus_path {
100 	unsigned int id;
101 };
102 
103 struct generic_path {
104 	unsigned int id;
105 	unsigned int subid;
106 };
107 
108 struct usb_path {
109 	unsigned int port_type;
110 	unsigned int port_id;
111 };
112 
113 struct mmio_path {
114 	uintptr_t addr;
115 };
116 
117 struct gpio_path {
118 	unsigned int id;
119 };
120 
121 struct mdio_path {
122 	unsigned int addr;
123 };
124 
125 struct gicc_v3_path {
126 	unsigned long long mpidr;
127 	unsigned int vgic_mi;
128 	unsigned int pi_gsiv;
129 };
130 
131 struct device_path {
132 	enum device_path_type type;
133 	union {
134 		struct pci_path		pci;
135 		struct pnp_path		pnp;
136 		struct i2c_path		i2c;
137 		struct apic_path	apic;
138 		struct ioapic_path	ioapic;
139 		struct domain_path	domain;
140 		struct cpu_cluster_path cpu_cluster;
141 		struct cpu_path		cpu;
142 		struct cpu_bus_path	cpu_bus;
143 		struct generic_path	generic;
144 		struct spi_path		spi;
145 		struct usb_path		usb;
146 		struct mmio_path	mmio;
147 		struct gpio_path	gpio;
148 		struct mdio_path	mdio;
149 		struct gicc_v3_path	gicc_v3;
150 	};
151 };
152 
153 #define DEVICE_PATH_MAX 40
154 #define BUS_PATH_MAX (DEVICE_PATH_MAX+10)
155 
156 extern const char *dev_path_name(enum device_path_type type);
157 
158 #endif /* DEVICE_PATH_H */
159