]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/powerpc/powernv/opal.h
Add LLVM openmp trunk r351319 (just before the release_80 branch point)
[FreeBSD/FreeBSD.git] / sys / powerpc / powernv / opal.h
1 /*-
2  * Copyright (c) 2015 Nathan Whitehorn
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #ifndef _POWERNV_OPAL_H
30 #define _POWERNV_OPAL_H
31
32 #include <sys/cdefs.h>
33 #include <sys/types.h>
34
35 /* Check if OPAL is correctly instantiated. Will try to instantiate it. */
36 int opal_check(void);
37
38 /* Call an OPAL method. Any pointers passed must be real-mode accessible! */
39 int opal_call(uint64_t token, ...);
40
41 #define OPAL_CONSOLE_WRITE              1
42 #define OPAL_CONSOLE_READ               2
43 #define OPAL_RTC_READ                   3
44 #define OPAL_RTC_WRITE                  4
45 #define OPAL_CEC_POWER_DOWN             5
46 #define OPAL_CEC_REBOOT                 6
47 #define OPAL_HANDLE_INTERRUPT           9
48 #define OPAL_POLL_EVENTS                10
49 #define OPAL_PCI_CONFIG_READ_BYTE       13
50 #define OPAL_PCI_CONFIG_READ_HALF_WORD  14
51 #define OPAL_PCI_CONFIG_READ_WORD       15
52 #define OPAL_PCI_CONFIG_WRITE_BYTE      16
53 #define OPAL_PCI_CONFIG_WRITE_HALF_WORD 17
54 #define OPAL_PCI_CONFIG_WRITE_WORD      18
55 #define OPAL_PCI_EEH_FREEZE_CLEAR       26
56 #define OPAL_PCI_PHB_MMIO_ENABLE        27
57 #define OPAL_PCI_SET_PHB_MEM_WINDOW     28
58 #define OPAL_PCI_MAP_PE_MMIO_WINDOW     29
59 #define OPAL_PCI_SET_XIVE_PE            37
60 #define OPAL_PCI_RESET                  49
61 #define OPAL_PCI_POLL                   62
62 #define OPAL_SET_XIVE                   19
63 #define OPAL_GET_XIVE                   20
64 #define OPAL_PCI_SET_PE                 31
65 #define OPAL_GET_MSI_32                 39
66 #define OPAL_GET_MSI_64                 40
67 #define OPAL_PCI_MSI_EOI                63
68 #define OPAL_PCI_GET_PHB_DIAG_DATA2     64
69 #define OPAL_START_CPU                  41
70 #define OPAL_PCI_MAP_PE_DMA_WINDOW      44
71 #define OPAL_PCI_MAP_PE_DMA_WINDOW_REAL 45
72 #define OPAL_RETURN_CPU                 69
73 #define OPAL_REINIT_CPUS                70
74 #define OPAL_CHECK_ASYNC_COMPLETION     86
75 #define OPAL_SENSOR_READ                88
76 #define OPAL_IPMI_SEND                  107
77 #define OPAL_IPMI_RECV                  108
78 #define OPAL_I2C_REQUEST                109
79 #define OPAL_FLASH_READ                 110
80 #define OPAL_FLASH_WRITE                111
81 #define OPAL_FLASH_ERASE                111
82 #define OPAL_INT_GET_XIRR               122
83 #define OPAL_INT_SET_CPPR               123
84 #define OPAL_INT_EOI                    124
85 #define OPAL_INT_SET_MFRR               125
86 #define OPAL_PCI_TCE_KILL               126
87 #define OPAL_XIVE_RESET                 128
88 #define OPAL_XIVE_GET_IRQ_INFO          129
89 #define OPAL_XIVE_GET_IRQ_CONFIG        130
90 #define OPAL_XIVE_SET_IRQ_CONFIG        131
91 #define OPAL_XIVE_GET_QUEUE_INFO        132
92 #define OPAL_XIVE_SET_QUEUE_INFO        133
93 #define OPAL_XIVE_DONATE_PAGE           134
94 #define OPAL_XIVE_ALLOCATE_VP_BLOCK     135
95 #define OPAL_XIVE_FREE_VP_BLOCK         136
96 #define OPAL_XIVE_GET_VP_INFO           137
97 #define OPAL_XIVE_SET_VP_INFO           138
98 #define OPAL_XIVE_ALLOCATE_IRQ          139
99 #define OPAL_XIVE_FREE_IRQ              140
100 #define OPAL_XIVE_SYNC                  141
101 #define OPAL_XIVE_DUMP                  142
102 #define OPAL_SENSOR_GROUP_CLEAR         156
103 #define OPAL_SENSOR_READ_U64            162
104 #define OPAL_SENSOR_GROUP_ENABLE        163
105
106 /* For OPAL_PCI_SET_PE */
107 #define OPAL_UNMAP_PE                   0
108 #define OPAL_MAP_PE                     1
109
110 #define OPAL_PCI_BUS_ANY                0
111 #define OPAL_PCI_BUS_3BITS              2
112 #define OPAL_PCI_BUS_4BITS              3
113 #define OPAL_PCI_BUS_5BITS              4
114 #define OPAL_PCI_BUS_6BITS              5
115 #define OPAL_PCI_BUS_7BITS              6
116 #define OPAL_PCI_BUS_ALL                7 /* Match bus number exactly */
117
118 #define OPAL_IGNORE_RID_DEVICE_NUMBER   0
119 #define OPAL_COMPARE_RID_DEVICE_NUMBER  1
120
121 #define OPAL_IGNORE_RID_FUNC_NUMBER     0
122 #define OPAL_COMPARE_RID_FUNC_NUMBER    1
123
124 #define OPAL_SUCCESS                    0
125 #define OPAL_PARAMETER                  -1
126 #define OPAL_BUSY                       -2
127 #define OPAL_CLOSED                     -5
128 #define OPAL_HARDWARE                   -6
129 #define OPAL_UNSUPPORTED                -7
130 #define OPAL_RESOURCE                   -10
131 #define OPAL_BUSY_EVENT                 -12
132 #define OPAL_ASYNC_COMPLETION           -15
133 #define OPAL_EMPTY                      -16
134 #define OPAL_XIVE_PROVISIONING          -31
135 #define OPAL_XIVE_FREE_ACTIVE           -32
136
137 #define OPAL_XIVE_XICS_MODE_EMU 0
138 #define OPAL_XIVE_XICS_MODE_EXP 1
139
140 #define OPAL_XIVE_VP_ENABLED            0x00000001
141 #define OPAL_XIVE_VP_SINGLE_ESCALATION  0x00000002
142
143 #define OPAL_XIVE_EQ_ENABLED            0x00000001
144 #define OPAL_XIVE_EQ_ALWAYS_NOTIFY      0x00000002
145 #define OPAL_XIVE_EQ_ESCALATE           0x00000004
146
147 struct opal_msg {
148         uint32_t msg_type;
149         uint32_t reserved;
150         uint64_t params[8];
151 };
152
153 enum opal_msg_type {
154         OPAL_MSG_ASYNC_COMP     = 0,
155         OPAL_MSG_MEM_ERR        = 1,
156         OPAL_MSG_EPOW           = 2,
157         OPAL_MSG_SHUTDOWN       = 3,
158         OPAL_MSG_HMI_EVT        = 4,
159         OPAL_MSG_DPO            = 5,
160         OPAL_MSG_PRD            = 6,
161         OPAL_MSG_OCC            = 7,
162         OPAL_MSG_TYPE_MAX,
163 };
164
165 #define OPAL_IPMI_MSG_FORMAT_VERSION_1  1
166
167 struct opal_ipmi_msg {
168         uint8_t version;
169         uint8_t netfn;
170         uint8_t cmd;
171         uint8_t data[];
172 };
173
174 int     opal_init_async_tokens(int);
175 int     opal_alloc_async_token(void);
176 void    opal_free_async_token(int);
177 int     opal_wait_completion(void *, uint64_t, uint64_t);
178
179 #endif