2 * Copyright (c) 2015 Nathan Whitehorn
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
29 #ifndef _POWERNV_OPAL_H
30 #define _POWERNV_OPAL_H
32 #include <sys/cdefs.h>
33 #include <sys/types.h>
35 /* Check if OPAL is correctly instantiated. Will try to instantiate it. */
38 /* Call an OPAL method. Any pointers passed must be real-mode accessible! */
39 int opal_call(uint64_t token, ...);
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_PCI_TCE_KILL 126
76 /* For OPAL_PCI_SET_PE */
77 #define OPAL_UNMAP_PE 0
80 #define OPAL_SUCCESS 0
81 #define OPAL_PARAMETER -1
82 #define OPAL_CLOSED -5
83 #define OPAL_BUSY_EVENT -12