2018-01-11 07:40:06 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2015 Nathan Whitehorn
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _POWERNV_OPAL_H
|
|
|
|
#define _POWERNV_OPAL_H
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <sys/types.h>
|
Extract eventfilter declarations to sys/_eventfilter.h
This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h"
in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header
pollution substantially.
EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c
files into appropriate headers (e.g., sys/proc.h, powernv/opal.h).
As a side effect of reduced header pollution, many .c files and headers no
longer contain needed definitions. The remainder of the patch addresses
adding appropriate includes to fix those files.
LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by
sys/mutex.h since r326106 (but silently protected by header pollution prior
to this change).
No functional change (intended). Of course, any out of tree modules that
relied on header pollution for sys/eventhandler.h, sys/lock.h, or
sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped.
2019-05-20 00:38:23 +00:00
|
|
|
#include <sys/_eventhandler.h>
|
2018-01-11 07:40:06 +00:00
|
|
|
|
|
|
|
/* Check if OPAL is correctly instantiated. Will try to instantiate it. */
|
|
|
|
int opal_check(void);
|
|
|
|
|
|
|
|
/* Call an OPAL method. Any pointers passed must be real-mode accessible! */
|
|
|
|
int opal_call(uint64_t token, ...);
|
|
|
|
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_CONSOLE_WRITE 1
|
|
|
|
#define OPAL_CONSOLE_READ 2
|
2018-01-12 12:14:52 +00:00
|
|
|
#define OPAL_RTC_READ 3
|
|
|
|
#define OPAL_RTC_WRITE 4
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_CEC_POWER_DOWN 5
|
|
|
|
#define OPAL_CEC_REBOOT 6
|
2019-09-14 03:30:34 +00:00
|
|
|
#define OPAL_READ_NVRAM 7
|
|
|
|
#define OPAL_WRITE_NVRAM 8
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_HANDLE_INTERRUPT 9
|
2018-01-12 12:14:52 +00:00
|
|
|
#define OPAL_POLL_EVENTS 10
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_PCI_CONFIG_READ_BYTE 13
|
|
|
|
#define OPAL_PCI_CONFIG_READ_HALF_WORD 14
|
|
|
|
#define OPAL_PCI_CONFIG_READ_WORD 15
|
|
|
|
#define OPAL_PCI_CONFIG_WRITE_BYTE 16
|
|
|
|
#define OPAL_PCI_CONFIG_WRITE_HALF_WORD 17
|
|
|
|
#define OPAL_PCI_CONFIG_WRITE_WORD 18
|
2019-08-01 03:59:25 +00:00
|
|
|
#define OPAL_PCI_EEH_FREEZE_STATUS 23
|
2021-04-16 22:51:15 +00:00
|
|
|
#define OPAL_CONSOLE_WRITE_BUFFER_SPACE 25
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_PCI_EEH_FREEZE_CLEAR 26
|
|
|
|
#define OPAL_PCI_PHB_MMIO_ENABLE 27
|
|
|
|
#define OPAL_PCI_SET_PHB_MEM_WINDOW 28
|
|
|
|
#define OPAL_PCI_MAP_PE_MMIO_WINDOW 29
|
|
|
|
#define OPAL_PCI_SET_XIVE_PE 37
|
|
|
|
#define OPAL_PCI_RESET 49
|
|
|
|
#define OPAL_PCI_POLL 62
|
2018-01-16 06:24:19 +00:00
|
|
|
#define OPAL_SET_XIVE 19
|
|
|
|
#define OPAL_GET_XIVE 20
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_PCI_SET_PE 31
|
|
|
|
#define OPAL_GET_MSI_32 39
|
|
|
|
#define OPAL_GET_MSI_64 40
|
|
|
|
#define OPAL_PCI_MSI_EOI 63
|
2018-01-17 07:39:11 +00:00
|
|
|
#define OPAL_PCI_GET_PHB_DIAG_DATA2 64
|
2018-01-12 12:14:52 +00:00
|
|
|
#define OPAL_START_CPU 41
|
2018-01-17 07:39:11 +00:00
|
|
|
#define OPAL_PCI_MAP_PE_DMA_WINDOW 44
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_PCI_MAP_PE_DMA_WINDOW_REAL 45
|
|
|
|
#define OPAL_RETURN_CPU 69
|
|
|
|
#define OPAL_REINIT_CPUS 70
|
2019-03-23 03:23:20 +00:00
|
|
|
#define OPAL_CHECK_TOKEN 80
|
2019-04-02 04:00:01 +00:00
|
|
|
#define OPAL_GET_MSG 85
|
2018-03-01 14:11:07 +00:00
|
|
|
#define OPAL_CHECK_ASYNC_COMPLETION 86
|
2018-05-22 02:42:53 +00:00
|
|
|
#define OPAL_SENSOR_READ 88
|
2019-03-23 03:23:20 +00:00
|
|
|
#define OPAL_HANDLE_HMI 98
|
2018-05-22 03:57:32 +00:00
|
|
|
#define OPAL_IPMI_SEND 107
|
|
|
|
#define OPAL_IPMI_RECV 108
|
2018-03-01 14:11:07 +00:00
|
|
|
#define OPAL_I2C_REQUEST 109
|
2019-03-01 04:36:55 +00:00
|
|
|
#define OPAL_FLASH_READ 110
|
|
|
|
#define OPAL_FLASH_WRITE 111
|
2019-04-06 02:39:56 +00:00
|
|
|
#define OPAL_FLASH_ERASE 112
|
2018-05-20 03:23:17 +00:00
|
|
|
#define OPAL_INT_GET_XIRR 122
|
|
|
|
#define OPAL_INT_SET_CPPR 123
|
|
|
|
#define OPAL_INT_EOI 124
|
|
|
|
#define OPAL_INT_SET_MFRR 125
|
2018-01-17 07:39:11 +00:00
|
|
|
#define OPAL_PCI_TCE_KILL 126
|
2019-12-15 21:20:18 +00:00
|
|
|
#define OPAL_NMMU_SET_PTCR 127
|
2018-05-20 03:23:17 +00:00
|
|
|
#define OPAL_XIVE_RESET 128
|
2019-02-02 04:15:16 +00:00
|
|
|
#define OPAL_XIVE_GET_IRQ_INFO 129
|
|
|
|
#define OPAL_XIVE_GET_IRQ_CONFIG 130
|
|
|
|
#define OPAL_XIVE_SET_IRQ_CONFIG 131
|
|
|
|
#define OPAL_XIVE_GET_QUEUE_INFO 132
|
|
|
|
#define OPAL_XIVE_SET_QUEUE_INFO 133
|
|
|
|
#define OPAL_XIVE_DONATE_PAGE 134
|
|
|
|
#define OPAL_XIVE_ALLOCATE_VP_BLOCK 135
|
|
|
|
#define OPAL_XIVE_FREE_VP_BLOCK 136
|
|
|
|
#define OPAL_XIVE_GET_VP_INFO 137
|
|
|
|
#define OPAL_XIVE_SET_VP_INFO 138
|
|
|
|
#define OPAL_XIVE_ALLOCATE_IRQ 139
|
|
|
|
#define OPAL_XIVE_FREE_IRQ 140
|
|
|
|
#define OPAL_XIVE_SYNC 141
|
|
|
|
#define OPAL_XIVE_DUMP 142
|
2018-05-22 02:42:53 +00:00
|
|
|
#define OPAL_SENSOR_GROUP_CLEAR 156
|
|
|
|
#define OPAL_SENSOR_READ_U64 162
|
|
|
|
#define OPAL_SENSOR_GROUP_ENABLE 163
|
2019-03-23 03:23:20 +00:00
|
|
|
#define OPAL_HANDLE_HMI2 166
|
2018-01-12 07:55:49 +00:00
|
|
|
|
|
|
|
/* For OPAL_PCI_SET_PE */
|
|
|
|
#define OPAL_UNMAP_PE 0
|
|
|
|
#define OPAL_MAP_PE 1
|
|
|
|
|
2018-05-19 04:01:15 +00:00
|
|
|
#define OPAL_PCI_BUS_ANY 0
|
|
|
|
#define OPAL_PCI_BUS_3BITS 2
|
|
|
|
#define OPAL_PCI_BUS_4BITS 3
|
|
|
|
#define OPAL_PCI_BUS_5BITS 4
|
|
|
|
#define OPAL_PCI_BUS_6BITS 5
|
|
|
|
#define OPAL_PCI_BUS_7BITS 6
|
|
|
|
#define OPAL_PCI_BUS_ALL 7 /* Match bus number exactly */
|
|
|
|
|
|
|
|
#define OPAL_IGNORE_RID_DEVICE_NUMBER 0
|
|
|
|
#define OPAL_COMPARE_RID_DEVICE_NUMBER 1
|
|
|
|
|
|
|
|
#define OPAL_IGNORE_RID_FUNC_NUMBER 0
|
|
|
|
#define OPAL_COMPARE_RID_FUNC_NUMBER 1
|
|
|
|
|
2019-11-10 04:24:36 +00:00
|
|
|
/* For OPAL_PCI_TCE_KILL */
|
|
|
|
#define OPAL_PCI_TCE_KILL_PAGE 0
|
|
|
|
#define OPAL_PCI_TCE_KILL_PE 1
|
|
|
|
#define OPAL_PCI_TCE_KILL_ALL 2
|
|
|
|
|
2018-03-01 14:11:07 +00:00
|
|
|
#define OPAL_SUCCESS 0
|
|
|
|
#define OPAL_PARAMETER -1
|
|
|
|
#define OPAL_BUSY -2
|
2020-12-31 01:00:28 +00:00
|
|
|
#define OPAL_PARTIAL -3
|
|
|
|
#define OPAL_CONSTRAINED -4
|
2018-03-01 14:11:07 +00:00
|
|
|
#define OPAL_CLOSED -5
|
2018-05-22 03:57:32 +00:00
|
|
|
#define OPAL_HARDWARE -6
|
|
|
|
#define OPAL_UNSUPPORTED -7
|
2020-12-31 01:00:28 +00:00
|
|
|
#define OPAL_PERMISSION -8
|
|
|
|
#define OPAL_NO_MEM -9
|
2018-05-22 03:57:32 +00:00
|
|
|
#define OPAL_RESOURCE -10
|
2020-12-31 01:00:28 +00:00
|
|
|
#define OPAL_INTERNAL_ERROR -11
|
2018-01-12 07:55:49 +00:00
|
|
|
#define OPAL_BUSY_EVENT -12
|
2020-12-31 01:00:28 +00:00
|
|
|
#define OPAL_HARDWARE_FROZEN -13
|
|
|
|
#define OPAL_WRONG_STATE -14
|
2018-03-01 14:11:07 +00:00
|
|
|
#define OPAL_ASYNC_COMPLETION -15
|
2018-05-22 03:57:32 +00:00
|
|
|
#define OPAL_EMPTY -16
|
2020-12-31 01:00:28 +00:00
|
|
|
#define OPAL_I2C_TIMEOUT -17
|
|
|
|
#define OPAL_I2C_INVALID_CMD -18
|
|
|
|
#define OPAL_I2C_LBUS_PARITY -19
|
|
|
|
#define OPAL_I2C_BKEND_OVERRUN -20
|
|
|
|
#define OPAL_I2C_BKEND_ACCESS -21
|
|
|
|
#define OPAL_I2C_ARBT_LOST -22
|
|
|
|
#define OPAL_I2C_NACK_RCVD -23
|
|
|
|
#define OPAL_I2C_STOP_ERR -24
|
|
|
|
#define OPAL_XSCOM_PARTIAL_GOOD -25
|
|
|
|
#define OPAL_XSCOM_ADDR_ERROR -26
|
|
|
|
#define OPAL_XSCOM_CLOCK_ERROR -27
|
|
|
|
#define OPAL_XSCOM_PARITY_ERROR -28
|
|
|
|
#define OPAL_XSCOM_TIMEOUT -29
|
|
|
|
#define OPAL_XSCOM_CTR_OFFLINED -30
|
2019-02-02 04:15:16 +00:00
|
|
|
#define OPAL_XIVE_PROVISIONING -31
|
|
|
|
#define OPAL_XIVE_FREE_ACTIVE -32
|
2020-12-31 01:00:28 +00:00
|
|
|
#define OPAL_TIMEOUT -33
|
2019-02-02 04:15:16 +00:00
|
|
|
|
2019-03-23 03:23:20 +00:00
|
|
|
#define OPAL_TOKEN_ABSENT 0
|
|
|
|
#define OPAL_TOKEN_PRESENT 1
|
|
|
|
|
2019-04-02 04:00:01 +00:00
|
|
|
#define OPAL_EVENT_OPAL_INTERNAL 0x1
|
|
|
|
#define OPAL_EVENT_NVRAM 0x2
|
|
|
|
#define OPAL_EVENT_RTC 0x4
|
|
|
|
#define OPAL_EVENT_CONSOLE_INPUT 0x8
|
|
|
|
#define OPAL_EVENT_CONSOLE_OUTPUT 0x10
|
|
|
|
#define OPAL_EVENT_ERROR_LOG_AVAIL 0x20
|
|
|
|
#define OPAL_EVENT_ERROR_LOG 0x40
|
|
|
|
#define OPAL_EVENT_EPOW 0x80
|
|
|
|
#define OPAL_EVENT_LED_STATUS 0x100
|
|
|
|
#define OPAL_EVENT_PCI_ERROR 0x200
|
|
|
|
#define OPAL_EVENT_DUMP_AVAIL 0x400
|
|
|
|
#define OPAL_EVENT_MSG_PENDING 0x800
|
|
|
|
|
2019-03-23 03:23:20 +00:00
|
|
|
#define OPAL_HMI_FLAGS_TB_RESYNC (1ull << 0)
|
|
|
|
#define OPAL_HMI_FLAGS_DEC_LOST (1ull << 1)
|
|
|
|
#define OPAL_HMI_FLAGS_HDEC_LOST (1ull << 2)
|
|
|
|
#define OPAL_HMI_FLAGS_TOD_TB_FAIL (1ull << 3)
|
|
|
|
#define OPAL_HMI_FLAGS_NEW_EVENT (1ull << 63)
|
|
|
|
|
2019-02-02 04:15:16 +00:00
|
|
|
#define OPAL_XIVE_XICS_MODE_EMU 0
|
|
|
|
#define OPAL_XIVE_XICS_MODE_EXP 1
|
|
|
|
|
2020-08-21 03:23:10 +00:00
|
|
|
#define OPAL_XIVE_SYNC_EAS 0x00000001
|
|
|
|
#define OPAL_XIVE_SYNC_QUEUE 0x00000002
|
|
|
|
|
2019-02-02 04:15:16 +00:00
|
|
|
#define OPAL_XIVE_VP_ENABLED 0x00000001
|
|
|
|
#define OPAL_XIVE_VP_SINGLE_ESCALATION 0x00000002
|
|
|
|
|
|
|
|
#define OPAL_XIVE_EQ_ENABLED 0x00000001
|
|
|
|
#define OPAL_XIVE_EQ_ALWAYS_NOTIFY 0x00000002
|
|
|
|
#define OPAL_XIVE_EQ_ESCALATE 0x00000004
|
2018-03-01 14:11:07 +00:00
|
|
|
|
|
|
|
struct opal_msg {
|
|
|
|
uint32_t msg_type;
|
|
|
|
uint32_t reserved;
|
|
|
|
uint64_t params[8];
|
|
|
|
};
|
|
|
|
|
|
|
|
enum opal_msg_type {
|
|
|
|
OPAL_MSG_ASYNC_COMP = 0,
|
|
|
|
OPAL_MSG_MEM_ERR = 1,
|
|
|
|
OPAL_MSG_EPOW = 2,
|
|
|
|
OPAL_MSG_SHUTDOWN = 3,
|
|
|
|
OPAL_MSG_HMI_EVT = 4,
|
|
|
|
OPAL_MSG_DPO = 5,
|
|
|
|
OPAL_MSG_PRD = 6,
|
|
|
|
OPAL_MSG_OCC = 7,
|
|
|
|
OPAL_MSG_TYPE_MAX,
|
|
|
|
};
|
2018-01-11 07:40:06 +00:00
|
|
|
|
2018-05-22 03:57:32 +00:00
|
|
|
#define OPAL_IPMI_MSG_FORMAT_VERSION_1 1
|
|
|
|
|
|
|
|
struct opal_ipmi_msg {
|
|
|
|
uint8_t version;
|
|
|
|
uint8_t netfn;
|
|
|
|
uint8_t cmd;
|
|
|
|
uint8_t data[];
|
|
|
|
};
|
|
|
|
|
2019-03-01 02:49:47 +00:00
|
|
|
int opal_init_async_tokens(int);
|
|
|
|
int opal_alloc_async_token(void);
|
|
|
|
void opal_free_async_token(int);
|
2019-04-06 02:31:01 +00:00
|
|
|
int opal_wait_completion(void *, uint64_t, int);
|
2019-03-01 02:49:47 +00:00
|
|
|
|
2019-04-02 04:00:01 +00:00
|
|
|
typedef void (*opal_msg_handler_fn)(void *, struct opal_msg *);
|
|
|
|
EVENTHANDLER_DECLARE(OPAL_ASYNC_COMP, opal_msg_handler_fn);
|
|
|
|
EVENTHANDLER_DECLARE(OPAL_EPOW, opal_msg_handler_fn);
|
|
|
|
EVENTHANDLER_DECLARE(OPAL_SHUTDOWN, opal_msg_handler_fn);
|
|
|
|
EVENTHANDLER_DECLARE(OPAL_HMI_EVT, opal_msg_handler_fn);
|
|
|
|
EVENTHANDLER_DECLARE(OPAL_DPO, opal_msg_handler_fn);
|
|
|
|
EVENTHANDLER_DECLARE(OPAL_OCC, opal_msg_handler_fn);
|
|
|
|
EVENTHANDLER_LIST_DECLARE(OPAL_ASYNC_COMP);
|
|
|
|
EVENTHANDLER_LIST_DECLARE(OPAL_EPOW);
|
|
|
|
EVENTHANDLER_LIST_DECLARE(OPAL_SHUTDOWN);
|
|
|
|
EVENTHANDLER_LIST_DECLARE(OPAL_HMI_EVT);
|
|
|
|
EVENTHANDLER_LIST_DECLARE(OPAL_DPO);
|
|
|
|
EVENTHANDLER_LIST_DECLARE(OPAL_OCC);
|
2018-01-11 07:40:06 +00:00
|
|
|
#endif
|