2019-05-27 13:55:01 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-09-20 01:27:58 +07:00
|
|
|
/*
|
|
|
|
* PowerNV OPAL definitions.
|
|
|
|
*
|
|
|
|
* Copyright 2011 IBM Corp.
|
|
|
|
*/
|
|
|
|
|
2015-02-17 16:01:53 +07:00
|
|
|
#ifndef _ASM_POWERPC_OPAL_H
|
|
|
|
#define _ASM_POWERPC_OPAL_H
|
2011-09-20 01:27:58 +07:00
|
|
|
|
2015-02-17 16:01:53 +07:00
|
|
|
#include <asm/opal-api.h>
|
2014-12-10 01:56:51 +07:00
|
|
|
|
2011-09-20 00:44:57 +07:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2014-03-25 07:43:08 +07:00
|
|
|
#include <linux/notifier.h>
|
|
|
|
|
2015-02-17 16:01:53 +07:00
|
|
|
/* We calculate number of sg entries based on PAGE_SIZE */
|
|
|
|
#define SG_ENTRIES_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct opal_sg_entry))
|
2014-12-14 01:01:05 +07:00
|
|
|
|
2018-04-10 18:49:31 +07:00
|
|
|
/* Default time to sleep or delay between OPAL_BUSY/OPAL_BUSY_EVENT loops */
|
|
|
|
#define OPAL_BUSY_DELAY_MS 10
|
|
|
|
|
2013-08-27 16:39:52 +07:00
|
|
|
/* /sys/firmware/opal */
|
|
|
|
extern struct kobject *opal_kobj;
|
|
|
|
|
2014-04-01 10:58:19 +07:00
|
|
|
/* /ibm,opal */
|
|
|
|
extern struct device_node *opal_node;
|
|
|
|
|
2011-09-20 00:44:57 +07:00
|
|
|
/* API functions */
|
2014-04-01 10:58:20 +07:00
|
|
|
int64_t opal_invalid_call(void);
|
2017-04-03 16:51:44 +07:00
|
|
|
int64_t opal_npu_destroy_context(uint64_t phb_id, uint64_t pid, uint64_t bdf);
|
|
|
|
int64_t opal_npu_init_context(uint64_t phb_id, int pasid, uint64_t msr,
|
|
|
|
uint64_t bdf);
|
|
|
|
int64_t opal_npu_map_lpar(uint64_t phb_id, uint64_t bdf, uint64_t lparid,
|
|
|
|
uint64_t lpcr);
|
2018-01-23 18:31:38 +07:00
|
|
|
int64_t opal_npu_spa_setup(uint64_t phb_id, uint32_t bdfn,
|
|
|
|
uint64_t addr, uint64_t PE_mask);
|
|
|
|
int64_t opal_npu_spa_clear_cache(uint64_t phb_id, uint32_t bdfn,
|
|
|
|
uint64_t PE_handle);
|
|
|
|
int64_t opal_npu_tl_set(uint64_t phb_id, uint32_t bdfn, long cap,
|
|
|
|
uint64_t rate_phys, uint32_t size);
|
2019-09-11 21:50:12 +07:00
|
|
|
|
2013-09-23 09:05:02 +07:00
|
|
|
int64_t opal_console_write(int64_t term_number, __be64 *length,
|
2011-09-20 00:44:57 +07:00
|
|
|
const uint8_t *buffer);
|
2013-09-23 09:05:02 +07:00
|
|
|
int64_t opal_console_read(int64_t term_number, __be64 *length,
|
2011-09-20 00:44:57 +07:00
|
|
|
uint8_t *buffer);
|
|
|
|
int64_t opal_console_write_buffer_space(int64_t term_number,
|
2013-09-23 09:05:02 +07:00
|
|
|
__be64 *length);
|
2016-01-13 08:04:32 +07:00
|
|
|
int64_t opal_console_flush(int64_t term_number);
|
2013-09-23 09:05:05 +07:00
|
|
|
int64_t opal_rtc_read(__be32 *year_month_day,
|
|
|
|
__be64 *hour_minute_second_millisecond);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_rtc_write(uint32_t year_month_day,
|
|
|
|
uint64_t hour_minute_second_millisecond);
|
2014-10-14 15:38:36 +07:00
|
|
|
int64_t opal_tpo_read(uint64_t token, __be32 *year_mon_day, __be32 *hour_min);
|
|
|
|
int64_t opal_tpo_write(uint64_t token, uint32_t year_mon_day,
|
|
|
|
uint32_t hour_min);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_cec_power_down(uint64_t request);
|
|
|
|
int64_t opal_cec_reboot(void);
|
2017-07-19 13:59:10 +07:00
|
|
|
int64_t opal_cec_reboot2(uint32_t reboot_type, const char *diag);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_read_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
|
|
|
|
int64_t opal_write_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
|
2013-09-23 09:05:06 +07:00
|
|
|
int64_t opal_handle_interrupt(uint64_t isn, __be64 *outstanding_event_mask);
|
2013-09-23 09:05:02 +07:00
|
|
|
int64_t opal_poll_events(__be64 *outstanding_event_mask);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_pci_set_hub_tce_memory(uint64_t hub_id, uint64_t tce_mem_addr,
|
|
|
|
uint64_t tce_mem_size);
|
|
|
|
int64_t opal_pci_set_phb_tce_memory(uint64_t phb_id, uint64_t tce_mem_addr,
|
|
|
|
uint64_t tce_mem_size);
|
|
|
|
int64_t opal_pci_config_read_byte(uint64_t phb_id, uint64_t bus_dev_func,
|
|
|
|
uint64_t offset, uint8_t *data);
|
|
|
|
int64_t opal_pci_config_read_half_word(uint64_t phb_id, uint64_t bus_dev_func,
|
2013-09-23 09:05:06 +07:00
|
|
|
uint64_t offset, __be16 *data);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_pci_config_read_word(uint64_t phb_id, uint64_t bus_dev_func,
|
2013-09-23 09:05:06 +07:00
|
|
|
uint64_t offset, __be32 *data);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_pci_config_write_byte(uint64_t phb_id, uint64_t bus_dev_func,
|
|
|
|
uint64_t offset, uint8_t data);
|
|
|
|
int64_t opal_pci_config_write_half_word(uint64_t phb_id, uint64_t bus_dev_func,
|
|
|
|
uint64_t offset, uint16_t data);
|
|
|
|
int64_t opal_pci_config_write_word(uint64_t phb_id, uint64_t bus_dev_func,
|
|
|
|
uint64_t offset, uint32_t data);
|
|
|
|
int64_t opal_set_xive(uint32_t isn, uint16_t server, uint8_t priority);
|
2013-09-23 09:05:06 +07:00
|
|
|
int64_t opal_get_xive(uint32_t isn, __be16 *server, uint8_t *priority);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_register_exception_handler(uint64_t opal_exception,
|
|
|
|
uint64_t handler_address,
|
|
|
|
uint64_t glue_cache_line);
|
|
|
|
int64_t opal_pci_eeh_freeze_status(uint64_t phb_id, uint64_t pe_number,
|
|
|
|
uint8_t *freeze_state,
|
2013-09-23 09:05:06 +07:00
|
|
|
__be16 *pci_error_type,
|
|
|
|
__be64 *phb_status);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number,
|
|
|
|
uint64_t eeh_action_token);
|
2014-07-21 11:42:31 +07:00
|
|
|
int64_t opal_pci_eeh_freeze_set(uint64_t phb_id, uint64_t pe_number,
|
|
|
|
uint64_t eeh_action_token);
|
2014-09-30 09:38:55 +07:00
|
|
|
int64_t opal_pci_err_inject(uint64_t phb_id, uint32_t pe_no, uint32_t type,
|
|
|
|
uint32_t func, uint64_t addr, uint64_t mask);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_pci_shpc(uint64_t phb_id, uint64_t shpc_action, uint8_t *state);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int64_t opal_pci_phb_mmio_enable(uint64_t phb_id, uint16_t window_type,
|
|
|
|
uint16_t window_num, uint16_t enable);
|
|
|
|
int64_t opal_pci_set_phb_mem_window(uint64_t phb_id, uint16_t window_type,
|
|
|
|
uint16_t window_num,
|
|
|
|
uint64_t starting_real_address,
|
|
|
|
uint64_t starting_pci_address,
|
2014-07-21 11:42:30 +07:00
|
|
|
uint64_t size);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_pci_map_pe_mmio_window(uint64_t phb_id, uint16_t pe_number,
|
|
|
|
uint16_t window_type, uint16_t window_num,
|
|
|
|
uint16_t segment_num);
|
|
|
|
int64_t opal_pci_set_phb_table_memory(uint64_t phb_id, uint64_t rtt_addr,
|
|
|
|
uint64_t ivt_addr, uint64_t ivt_len,
|
|
|
|
uint64_t reject_array_addr,
|
|
|
|
uint64_t peltv_addr);
|
|
|
|
int64_t opal_pci_set_pe(uint64_t phb_id, uint64_t pe_number, uint64_t bus_dev_func,
|
|
|
|
uint8_t bus_compare, uint8_t dev_compare, uint8_t func_compare,
|
|
|
|
uint8_t pe_action);
|
|
|
|
int64_t opal_pci_set_peltv(uint64_t phb_id, uint32_t parent_pe, uint32_t child_pe,
|
|
|
|
uint8_t state);
|
|
|
|
int64_t opal_pci_set_mve(uint64_t phb_id, uint32_t mve_number, uint32_t pe_number);
|
|
|
|
int64_t opal_pci_set_mve_enable(uint64_t phb_id, uint32_t mve_number,
|
|
|
|
uint32_t state);
|
|
|
|
int64_t opal_pci_get_xive_reissue(uint64_t phb_id, uint32_t xive_number,
|
|
|
|
uint8_t *p_bit, uint8_t *q_bit);
|
|
|
|
int64_t opal_pci_set_xive_reissue(uint64_t phb_id, uint32_t xive_number,
|
|
|
|
uint8_t p_bit, uint8_t q_bit);
|
2013-04-26 02:20:59 +07:00
|
|
|
int64_t opal_pci_msi_eoi(uint64_t phb_id, uint32_t hw_irq);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_pci_set_xive_pe(uint64_t phb_id, uint32_t pe_number,
|
|
|
|
uint32_t xive_num);
|
|
|
|
int64_t opal_get_xive_source(uint64_t phb_id, uint32_t xive_num,
|
2013-09-23 09:05:06 +07:00
|
|
|
__be32 *interrupt_source_number);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_get_msi_32(uint64_t phb_id, uint32_t mve_number, uint32_t xive_num,
|
2013-09-23 09:05:06 +07:00
|
|
|
uint8_t msi_range, __be32 *msi_address,
|
|
|
|
__be32 *message_data);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_get_msi_64(uint64_t phb_id, uint32_t mve_number,
|
|
|
|
uint32_t xive_num, uint8_t msi_range,
|
2013-09-23 09:05:06 +07:00
|
|
|
__be64 *msi_address, __be32 *message_data);
|
2011-09-20 00:44:57 +07:00
|
|
|
int64_t opal_start_cpu(uint64_t thread_number, uint64_t start_address);
|
|
|
|
int64_t opal_query_cpu_status(uint64_t thread_number, uint8_t *thread_status);
|
|
|
|
int64_t opal_write_oppanel(oppanel_line_t *lines, uint64_t num_lines);
|
|
|
|
int64_t opal_pci_map_pe_dma_window(uint64_t phb_id, uint16_t pe_number, uint16_t window_id,
|
|
|
|
uint16_t tce_levels, uint64_t tce_table_addr,
|
|
|
|
uint64_t tce_table_size, uint64_t tce_page_size);
|
|
|
|
int64_t opal_pci_map_pe_dma_window_real(uint64_t phb_id, uint16_t pe_number,
|
|
|
|
uint16_t dma_window_number, uint64_t pci_start_addr,
|
|
|
|
uint64_t pci_mem_size);
|
2016-05-20 13:41:38 +07:00
|
|
|
int64_t opal_pci_reset(uint64_t id, uint8_t reset_scope, uint8_t assert_state);
|
2011-09-20 00:44:57 +07:00
|
|
|
|
2013-06-20 12:21:05 +07:00
|
|
|
int64_t opal_pci_get_hub_diag_data(uint64_t hub_id, void *diag_buffer,
|
|
|
|
uint64_t diag_buffer_len);
|
|
|
|
int64_t opal_pci_get_phb_diag_data(uint64_t phb_id, void *diag_buffer,
|
|
|
|
uint64_t diag_buffer_len);
|
|
|
|
int64_t opal_pci_get_phb_diag_data2(uint64_t phb_id, void *diag_buffer,
|
|
|
|
uint64_t diag_buffer_len);
|
2011-11-30 01:22:50 +07:00
|
|
|
int64_t opal_pci_fence_phb(uint64_t phb_id);
|
2014-01-03 16:47:13 +07:00
|
|
|
int64_t opal_pci_reinit(uint64_t phb_id, uint64_t reinit_scope, uint64_t data);
|
2011-11-30 01:22:50 +07:00
|
|
|
int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action);
|
|
|
|
int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action);
|
2015-07-08 18:06:01 +07:00
|
|
|
int64_t opal_get_epow_status(__be16 *epow_status, __be16 *num_epow_classes);
|
|
|
|
int64_t opal_get_dpo_status(__be64 *dpo_timeout);
|
2011-11-30 01:22:50 +07:00
|
|
|
int64_t opal_set_system_attention_led(uint8_t led_action);
|
2014-06-09 15:58:51 +07:00
|
|
|
int64_t opal_pci_next_error(uint64_t phb_id, __be64 *first_frozen_pe,
|
|
|
|
__be16 *pci_error_type, __be16 *severity);
|
2016-05-20 13:41:38 +07:00
|
|
|
int64_t opal_pci_poll(uint64_t id);
|
2013-08-21 10:03:20 +07:00
|
|
|
int64_t opal_return_cpu(void);
|
2014-08-19 11:47:59 +07:00
|
|
|
int64_t opal_check_token(uint64_t token);
|
2014-05-20 08:01:28 +07:00
|
|
|
int64_t opal_reinit_cpus(uint64_t flags);
|
2011-11-30 01:22:50 +07:00
|
|
|
|
2014-02-28 12:20:29 +07:00
|
|
|
int64_t opal_xscom_read(uint32_t gcid, uint64_t pcb_addr, __be64 *val);
|
|
|
|
int64_t opal_xscom_write(uint32_t gcid, uint64_t pcb_addr, uint64_t val);
|
2013-07-15 10:03:09 +07:00
|
|
|
|
|
|
|
int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type,
|
|
|
|
uint32_t addr, uint32_t data, uint32_t sz);
|
|
|
|
int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type,
|
2013-12-13 11:56:06 +07:00
|
|
|
uint32_t addr, __be32 *data, uint32_t sz);
|
powerpc/powernv: Read OPAL error log and export it through sysfs
Based on a patch by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
This patch adds support to read error logs from OPAL and export
them to userspace through a sysfs interface.
We export each log entry as a directory in /sys/firmware/opal/elog/
Currently, OPAL will buffer up to 128 error log records, we don't
need to have any knowledge of this limit on the Linux side as that
is actually largely transparent to us.
Each error log entry has the following files: id, type, acknowledge, raw.
Currently we just export the raw binary error log in the 'raw' attribute.
In a future patch, we may parse more of the error log to make it a bit
easier for userspace (e.g. to be able to display a brief summary in
petitboot without having to have a full parser).
If we have >128 logs from OPAL, we'll only be notified of 128 until
userspace starts acknowledging them. This limitation may be lifted in
the future and with this patch, that should "just work" from the linux side.
A userspace daemon should:
- wait for error log entries using normal mechanisms (we announce creation)
- read error log entry
- save error log entry safely to disk
- acknowledge the error log entry
- rinse, repeat.
On the Linux side, we read the error log when we're notified of it. This
possibly isn't ideal as it would be better to only read them on-demand.
However, this doesn't really work with current OPAL interface, so we
read the error log immediately when notified at the moment.
I've tested this pretty extensively and am rather confident that the
linux side of things works rather well. There is currently an issue with
the service processor side of things for >128 error logs though.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-02-28 07:58:32 +07:00
|
|
|
|
2014-04-22 12:01:22 +07:00
|
|
|
int64_t opal_read_elog(uint64_t buffer, uint64_t size, uint64_t log_id);
|
2014-04-22 12:01:25 +07:00
|
|
|
int64_t opal_get_elog_size(__be64 *log_id, __be64 *size, __be64 *elog_type);
|
powerpc/powernv: Read OPAL error log and export it through sysfs
Based on a patch by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
This patch adds support to read error logs from OPAL and export
them to userspace through a sysfs interface.
We export each log entry as a directory in /sys/firmware/opal/elog/
Currently, OPAL will buffer up to 128 error log records, we don't
need to have any knowledge of this limit on the Linux side as that
is actually largely transparent to us.
Each error log entry has the following files: id, type, acknowledge, raw.
Currently we just export the raw binary error log in the 'raw' attribute.
In a future patch, we may parse more of the error log to make it a bit
easier for userspace (e.g. to be able to display a brief summary in
petitboot without having to have a full parser).
If we have >128 logs from OPAL, we'll only be notified of 128 until
userspace starts acknowledging them. This limitation may be lifted in
the future and with this patch, that should "just work" from the linux side.
A userspace daemon should:
- wait for error log entries using normal mechanisms (we announce creation)
- read error log entry
- save error log entry safely to disk
- acknowledge the error log entry
- rinse, repeat.
On the Linux side, we read the error log when we're notified of it. This
possibly isn't ideal as it would be better to only read them on-demand.
However, this doesn't really work with current OPAL interface, so we
read the error log immediately when notified at the moment.
I've tested this pretty extensively and am rather confident that the
linux side of things works rather well. There is currently an issue with
the service processor side of things for >128 error logs though.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-02-28 07:58:32 +07:00
|
|
|
int64_t opal_write_elog(uint64_t buffer, uint64_t size, uint64_t offset);
|
|
|
|
int64_t opal_send_ack_elog(uint64_t log_id);
|
|
|
|
void opal_resend_pending_logs(void);
|
|
|
|
|
2013-10-24 17:34:58 +07:00
|
|
|
int64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result);
|
|
|
|
int64_t opal_manage_flash(uint8_t op);
|
|
|
|
int64_t opal_update_flash(uint64_t blk_list);
|
2014-03-03 06:25:42 +07:00
|
|
|
int64_t opal_dump_init(uint8_t dump_type);
|
2014-04-22 12:01:27 +07:00
|
|
|
int64_t opal_dump_info(__be32 *dump_id, __be32 *dump_size);
|
|
|
|
int64_t opal_dump_info2(__be32 *dump_id, __be32 *dump_size, __be32 *dump_type);
|
2014-03-03 06:25:42 +07:00
|
|
|
int64_t opal_dump_read(uint32_t dump_id, uint64_t buffer);
|
|
|
|
int64_t opal_dump_ack(uint32_t dump_id);
|
|
|
|
int64_t opal_dump_resend_notification(void);
|
2013-07-15 10:03:09 +07:00
|
|
|
|
2014-04-22 12:01:22 +07:00
|
|
|
int64_t opal_get_msg(uint64_t buffer, uint64_t size);
|
2016-06-29 10:38:39 +07:00
|
|
|
int64_t opal_write_oppanel_async(uint64_t token, oppanel_line_t *lines,
|
|
|
|
uint64_t num_lines);
|
2014-04-22 12:01:22 +07:00
|
|
|
int64_t opal_check_completion(uint64_t buffer, uint64_t size, uint64_t token);
|
2014-01-15 13:02:04 +07:00
|
|
|
int64_t opal_sync_host_reboot(void);
|
2014-03-07 12:32:09 +07:00
|
|
|
int64_t opal_get_param(uint64_t token, uint32_t param_id, uint64_t buffer,
|
2014-04-22 12:01:22 +07:00
|
|
|
uint64_t length);
|
2014-03-07 12:32:09 +07:00
|
|
|
int64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer,
|
2014-04-22 12:01:22 +07:00
|
|
|
uint64_t length);
|
2014-03-28 12:34:10 +07:00
|
|
|
int64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data);
|
2018-05-07 17:25:36 +07:00
|
|
|
int64_t opal_sensor_read_u64(u32 sensor_hndl, int token, __be64 *sensor_data);
|
2014-07-29 20:10:07 +07:00
|
|
|
int64_t opal_handle_hmi(void);
|
2019-03-05 02:42:19 +07:00
|
|
|
int64_t opal_handle_hmi2(__be64 *out_flags);
|
2014-08-09 12:45:45 +07:00
|
|
|
int64_t opal_register_dump_region(uint32_t id, uint64_t start, uint64_t end);
|
|
|
|
int64_t opal_unregister_dump_region(uint32_t id);
|
2014-12-10 01:56:53 +07:00
|
|
|
int64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val);
|
2015-04-20 12:02:58 +07:00
|
|
|
int64_t opal_config_cpu_idle_state(uint64_t state, uint64_t flag);
|
2014-10-08 15:54:59 +07:00
|
|
|
int64_t opal_pci_set_phb_cxl_mode(uint64_t phb_id, uint64_t mode, uint64_t pe_number);
|
2018-03-02 16:56:11 +07:00
|
|
|
int64_t opal_pci_get_pbcq_tunnel_bar(uint64_t phb_id, uint64_t *addr);
|
|
|
|
int64_t opal_pci_set_pbcq_tunnel_bar(uint64_t phb_id, uint64_t addr);
|
2014-11-06 10:38:27 +07:00
|
|
|
int64_t opal_ipmi_send(uint64_t interface, struct opal_ipmi_msg *msg,
|
|
|
|
uint64_t msg_len);
|
|
|
|
int64_t opal_ipmi_recv(uint64_t interface, struct opal_ipmi_msg *msg,
|
|
|
|
uint64_t *msg_len);
|
2014-12-14 01:01:05 +07:00
|
|
|
int64_t opal_i2c_request(uint64_t async_token, uint32_t bus_id,
|
|
|
|
struct opal_i2c_request *oreq);
|
2015-06-04 20:51:47 +07:00
|
|
|
int64_t opal_prd_msg(struct opal_prd_msg *msg);
|
2015-08-19 23:49:52 +07:00
|
|
|
int64_t opal_leds_get_ind(char *loc_code, __be64 *led_mask,
|
|
|
|
__be64 *led_value, __be64 *max_led_type);
|
|
|
|
int64_t opal_leds_set_ind(uint64_t token, char *loc_code, const u64 led_mask,
|
|
|
|
const u64 led_value, __be64 *max_led_type);
|
2013-11-18 17:05:58 +07:00
|
|
|
|
2015-04-01 13:05:30 +07:00
|
|
|
int64_t opal_flash_read(uint64_t id, uint64_t offset, uint64_t buf,
|
|
|
|
uint64_t size, uint64_t token);
|
|
|
|
int64_t opal_flash_write(uint64_t id, uint64_t offset, uint64_t buf,
|
|
|
|
uint64_t size, uint64_t token);
|
|
|
|
int64_t opal_flash_erase(uint64_t id, uint64_t offset, uint64_t size,
|
|
|
|
uint64_t token);
|
2016-05-20 13:41:41 +07:00
|
|
|
int64_t opal_get_device_tree(uint32_t phandle, uint64_t buf, uint64_t len);
|
|
|
|
int64_t opal_pci_get_presence_state(uint64_t id, uint64_t data);
|
|
|
|
int64_t opal_pci_get_power_state(uint64_t id, uint64_t data);
|
|
|
|
int64_t opal_pci_set_power_state(uint64_t async_token, uint64_t id,
|
|
|
|
uint64_t data);
|
|
|
|
int64_t opal_pci_poll2(uint64_t id, uint64_t data);
|
2015-04-01 13:05:30 +07:00
|
|
|
|
2016-07-08 13:37:05 +07:00
|
|
|
int64_t opal_int_get_xirr(uint32_t *out_xirr, bool just_poll);
|
|
|
|
int64_t opal_int_set_cppr(uint8_t cppr);
|
|
|
|
int64_t opal_int_eoi(uint32_t xirr);
|
|
|
|
int64_t opal_int_set_mfrr(uint32_t cpu, uint8_t mfrr);
|
2016-07-08 13:37:11 +07:00
|
|
|
int64_t opal_pci_tce_kill(uint64_t phb_id, uint32_t kill_type,
|
|
|
|
uint32_t pe_num, uint32_t tce_size,
|
|
|
|
uint64_t dma_addr, uint32_t npages);
|
2016-12-14 09:36:51 +07:00
|
|
|
int64_t opal_nmmu_set_ptcr(uint64_t chip_id, uint64_t ptcr);
|
2017-04-06 06:01:33 +07:00
|
|
|
int64_t opal_xive_reset(uint64_t version);
|
|
|
|
int64_t opal_xive_get_irq_info(uint32_t girq,
|
|
|
|
__be64 *out_flags,
|
|
|
|
__be64 *out_eoi_page,
|
|
|
|
__be64 *out_trig_page,
|
|
|
|
__be32 *out_esb_shift,
|
|
|
|
__be32 *out_src_chip);
|
|
|
|
int64_t opal_xive_get_irq_config(uint32_t girq, __be64 *out_vp,
|
|
|
|
uint8_t *out_prio, __be32 *out_lirq);
|
|
|
|
int64_t opal_xive_set_irq_config(uint32_t girq, uint64_t vp, uint8_t prio,
|
|
|
|
uint32_t lirq);
|
|
|
|
int64_t opal_xive_get_queue_info(uint64_t vp, uint32_t prio,
|
|
|
|
__be64 *out_qpage,
|
|
|
|
__be64 *out_qsize,
|
|
|
|
__be64 *out_qeoi_page,
|
|
|
|
__be32 *out_escalate_irq,
|
|
|
|
__be64 *out_qflags);
|
|
|
|
int64_t opal_xive_set_queue_info(uint64_t vp, uint32_t prio,
|
|
|
|
uint64_t qpage,
|
|
|
|
uint64_t qsize,
|
|
|
|
uint64_t qflags);
|
|
|
|
int64_t opal_xive_donate_page(uint32_t chip_id, uint64_t addr);
|
|
|
|
int64_t opal_xive_alloc_vp_block(uint32_t alloc_order);
|
|
|
|
int64_t opal_xive_free_vp_block(uint64_t vp);
|
|
|
|
int64_t opal_xive_get_vp_info(uint64_t vp,
|
|
|
|
__be64 *out_flags,
|
|
|
|
__be64 *out_cam_value,
|
|
|
|
__be64 *out_report_cl_pair,
|
|
|
|
__be32 *out_chip_id);
|
|
|
|
int64_t opal_xive_set_vp_info(uint64_t vp,
|
|
|
|
uint64_t flags,
|
|
|
|
uint64_t report_cl_pair);
|
2019-09-11 22:52:18 +07:00
|
|
|
int64_t opal_xive_allocate_irq_raw(uint32_t chip_id);
|
2017-04-06 06:01:33 +07:00
|
|
|
int64_t opal_xive_free_irq(uint32_t girq);
|
|
|
|
int64_t opal_xive_sync(uint32_t type, uint32_t id);
|
|
|
|
int64_t opal_xive_dump(uint32_t type, uint32_t id);
|
2019-04-11 00:04:33 +07:00
|
|
|
int64_t opal_xive_get_queue_state(uint64_t vp, uint32_t prio,
|
|
|
|
__be32 *out_qtoggle,
|
|
|
|
__be32 *out_qindex);
|
|
|
|
int64_t opal_xive_set_queue_state(uint64_t vp, uint32_t prio,
|
|
|
|
uint32_t qtoggle,
|
|
|
|
uint32_t qindex);
|
|
|
|
int64_t opal_xive_get_vp_state(uint64_t vp, __be64 *out_w01);
|
2016-07-08 13:37:05 +07:00
|
|
|
|
2017-07-19 04:36:32 +07:00
|
|
|
int64_t opal_imc_counters_init(uint32_t type, uint64_t address,
|
|
|
|
uint64_t cpu_pir);
|
|
|
|
int64_t opal_imc_counters_start(uint32_t type, uint64_t cpu_pir);
|
|
|
|
int64_t opal_imc_counters_stop(uint32_t type, uint64_t cpu_pir);
|
|
|
|
|
2017-08-10 10:31:18 +07:00
|
|
|
int opal_get_powercap(u32 handle, int token, u32 *pcap);
|
|
|
|
int opal_set_powercap(u32 handle, int token, u32 pcap);
|
2017-08-10 10:31:19 +07:00
|
|
|
int opal_get_power_shift_ratio(u32 handle, int token, u32 *psr);
|
|
|
|
int opal_set_power_shift_ratio(u32 handle, int token, u32 psr);
|
2017-08-10 10:31:20 +07:00
|
|
|
int opal_sensor_group_clear(u32 group_hndl, int token);
|
2018-07-24 16:13:08 +07:00
|
|
|
int opal_sensor_group_enable(u32 group_hndl, int token, bool enable);
|
2018-06-13 14:32:40 +07:00
|
|
|
int opal_nx_coproc_init(uint32_t chip_id, uint32_t ct);
|
2017-08-10 10:31:18 +07:00
|
|
|
|
2019-09-11 21:50:12 +07:00
|
|
|
s64 opal_mpipl_update(enum opal_mpipl_ops op, u64 src, u64 dest, u64 size);
|
|
|
|
s64 opal_mpipl_register_tag(enum opal_mpipl_tags tag, u64 addr);
|
|
|
|
s64 opal_mpipl_query_tag(enum opal_mpipl_tags tag, u64 *addr);
|
|
|
|
|
2017-09-29 10:29:42 +07:00
|
|
|
s64 opal_signal_system_reset(s32 cpu);
|
2018-05-10 19:21:48 +07:00
|
|
|
s64 opal_quiesce(u64 shutdown_type, s32 cpu);
|
2017-09-29 10:29:42 +07:00
|
|
|
|
2011-09-20 00:44:57 +07:00
|
|
|
/* Internal functions */
|
2014-04-22 12:01:23 +07:00
|
|
|
extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
|
|
|
|
int depth, void *data);
|
2013-12-16 12:16:24 +07:00
|
|
|
extern int early_init_dt_scan_recoverable_ranges(unsigned long node,
|
|
|
|
const char *uname, int depth, void *data);
|
2016-07-05 12:03:49 +07:00
|
|
|
extern void opal_configure_cores(void);
|
2011-09-20 00:44:57 +07:00
|
|
|
|
|
|
|
extern int opal_get_chars(uint32_t vtermno, char *buf, int count);
|
|
|
|
extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);
|
2018-04-30 21:55:51 +07:00
|
|
|
extern int opal_put_chars_atomic(uint32_t vtermno, const char *buf, int total_len);
|
2018-04-30 21:55:58 +07:00
|
|
|
extern int opal_flush_chars(uint32_t vtermno, bool wait);
|
2018-04-30 21:55:48 +07:00
|
|
|
extern int opal_flush_console(uint32_t vtermno);
|
2011-09-20 00:44:57 +07:00
|
|
|
|
|
|
|
extern void hvc_opal_init_early(void);
|
|
|
|
|
2013-06-20 17:13:22 +07:00
|
|
|
extern int opal_notifier_register(struct notifier_block *nb);
|
2014-03-28 09:36:31 +07:00
|
|
|
extern int opal_notifier_unregister(struct notifier_block *nb);
|
|
|
|
|
2015-02-17 16:01:54 +07:00
|
|
|
extern int opal_message_notifier_register(enum opal_msg_type msg_type,
|
2013-11-18 17:05:58 +07:00
|
|
|
struct notifier_block *nb);
|
2015-03-26 16:03:16 +07:00
|
|
|
extern int opal_message_notifier_unregister(enum opal_msg_type msg_type,
|
2015-02-11 13:27:23 +07:00
|
|
|
struct notifier_block *nb);
|
2013-06-20 17:13:22 +07:00
|
|
|
extern void opal_notifier_enable(void);
|
|
|
|
extern void opal_notifier_disable(void);
|
|
|
|
extern void opal_notifier_update_evt(uint64_t evt_mask, uint64_t evt_val);
|
|
|
|
|
2014-03-07 12:30:24 +07:00
|
|
|
extern int opal_async_get_token_interruptible(void);
|
|
|
|
extern int opal_async_release_token(int token);
|
|
|
|
extern int opal_async_wait_response(uint64_t token, struct opal_msg *msg);
|
2017-11-03 09:41:44 +07:00
|
|
|
extern int opal_async_wait_response_interruptible(uint64_t token,
|
|
|
|
struct opal_msg *msg);
|
2014-03-07 12:33:27 +07:00
|
|
|
extern int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data);
|
2018-05-07 17:25:36 +07:00
|
|
|
extern int opal_get_sensor_data_u64(u32 sensor_hndl, u64 *sensor_data);
|
2018-07-24 16:13:08 +07:00
|
|
|
extern int sensor_group_enable(u32 grp_hndl, bool enable);
|
2014-03-07 12:30:24 +07:00
|
|
|
|
2011-09-20 00:45:01 +07:00
|
|
|
struct rtc_time;
|
2018-04-23 15:36:40 +07:00
|
|
|
extern time64_t opal_get_boot_time(void);
|
2011-09-20 00:45:01 +07:00
|
|
|
extern void opal_nvram_init(void);
|
2015-04-01 13:05:30 +07:00
|
|
|
extern void opal_flash_update_init(void);
|
powerpc/powernv: Always stop secondaries before reboot/shutdown
Currently powernv reboot and shutdown requests just leave secondaries
to do their own things. This is undesirable because they can trigger
any number of watchdogs while waiting for reboot, but also we don't
know what else they might be doing -- they might be causing trouble,
trampling memory, etc.
The opal scheduled flash update code already ran into watchdog problems
due to flashing taking a long time, and it was fixed with 2196c6f1ed
("powerpc/powernv: Return secondary CPUs to firmware before FW update"),
which returns secondaries to opal. It's been found that regular reboots
can take over 10 seconds, which can result in the hard lockup watchdog
firing,
reboot: Restarting system
[ 360.038896709,5] OPAL: Reboot request...
Watchdog CPU:0 Hard LOCKUP
Watchdog CPU:44 detected Hard LOCKUP other CPUS:16
Watchdog CPU:16 Hard LOCKUP
watchdog: BUG: soft lockup - CPU#16 stuck for 3s! [swapper/16:0]
This patch removes the special case for flash update, and calls
smp_send_stop in all cases before calling reboot/shutdown.
smp_send_stop could return CPUs to OPAL, the main reason not to is
that the request could come from a NMI that interrupts OPAL code,
so re-entry to OPAL can cause a number of problems. Putting
secondaries into simple spin loops improves the chances of a
successful reboot.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2018-04-01 17:36:15 +07:00
|
|
|
extern void opal_flash_update_print_message(void);
|
powerpc/powernv: Read OPAL error log and export it through sysfs
Based on a patch by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
This patch adds support to read error logs from OPAL and export
them to userspace through a sysfs interface.
We export each log entry as a directory in /sys/firmware/opal/elog/
Currently, OPAL will buffer up to 128 error log records, we don't
need to have any knowledge of this limit on the Linux side as that
is actually largely transparent to us.
Each error log entry has the following files: id, type, acknowledge, raw.
Currently we just export the raw binary error log in the 'raw' attribute.
In a future patch, we may parse more of the error log to make it a bit
easier for userspace (e.g. to be able to display a brief summary in
petitboot without having to have a full parser).
If we have >128 logs from OPAL, we'll only be notified of 128 until
userspace starts acknowledging them. This limitation may be lifted in
the future and with this patch, that should "just work" from the linux side.
A userspace daemon should:
- wait for error log entries using normal mechanisms (we announce creation)
- read error log entry
- save error log entry safely to disk
- acknowledge the error log entry
- rinse, repeat.
On the Linux side, we read the error log when we're notified of it. This
possibly isn't ideal as it would be better to only read them on-demand.
However, this doesn't really work with current OPAL interface, so we
read the error log immediately when notified at the moment.
I've tested this pretty extensively and am rather confident that the
linux side of things works rather well. There is currently an issue with
the service processor side of things for >128 error logs though.
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-02-28 07:58:32 +07:00
|
|
|
extern int opal_elog_init(void);
|
2014-03-03 06:25:42 +07:00
|
|
|
extern void opal_platform_dump_init(void);
|
2014-03-07 12:32:09 +07:00
|
|
|
extern void opal_sys_param_init(void);
|
2014-04-01 10:58:19 +07:00
|
|
|
extern void opal_msglog_init(void);
|
2016-02-09 14:17:48 +07:00
|
|
|
extern void opal_msglog_sysfs_init(void);
|
2015-05-15 11:06:36 +07:00
|
|
|
extern int opal_async_comp_init(void);
|
|
|
|
extern int opal_sensor_init(void);
|
|
|
|
extern int opal_hmi_handler_init(void);
|
2015-05-15 11:06:37 +07:00
|
|
|
extern int opal_event_init(void);
|
2018-12-13 12:47:31 +07:00
|
|
|
int opal_power_control_init(void);
|
2011-09-20 00:45:01 +07:00
|
|
|
|
2011-09-20 00:45:04 +07:00
|
|
|
extern int opal_machine_check(struct pt_regs *regs);
|
2013-12-16 12:16:24 +07:00
|
|
|
extern bool opal_mce_check_early_recovery(struct pt_regs *regs);
|
2014-07-29 20:10:01 +07:00
|
|
|
extern int opal_hmi_exception_early(struct pt_regs *regs);
|
2019-03-05 02:42:19 +07:00
|
|
|
extern int opal_hmi_exception_early2(struct pt_regs *regs);
|
2014-07-29 20:10:01 +07:00
|
|
|
extern int opal_handle_hmi_exception(struct pt_regs *regs);
|
2011-09-20 00:45:04 +07:00
|
|
|
|
2013-05-10 13:59:18 +07:00
|
|
|
extern void opal_shutdown(void);
|
2014-02-26 07:08:43 +07:00
|
|
|
extern int opal_resync_timebase(void);
|
2013-05-10 13:59:18 +07:00
|
|
|
|
2013-07-15 10:03:11 +07:00
|
|
|
extern void opal_lpc_init(void);
|
|
|
|
|
2015-11-27 13:23:07 +07:00
|
|
|
extern void opal_kmsg_init(void);
|
|
|
|
|
2015-05-15 11:06:37 +07:00
|
|
|
extern int opal_event_request(unsigned int opal_event_nr);
|
|
|
|
|
2014-04-22 12:01:26 +07:00
|
|
|
struct opal_sg_list *opal_vmalloc_to_sg_list(void *vmalloc_addr,
|
|
|
|
unsigned long vmalloc_size);
|
|
|
|
void opal_free_sg_list(struct opal_sg_list *sg);
|
|
|
|
|
2015-03-30 17:06:09 +07:00
|
|
|
extern int opal_error_code(int rc);
|
|
|
|
|
2016-02-09 14:17:48 +07:00
|
|
|
ssize_t opal_msglog_copy(char *to, loff_t pos, size_t count);
|
|
|
|
|
2016-06-29 10:38:38 +07:00
|
|
|
static inline int opal_get_async_rc(struct opal_msg msg)
|
|
|
|
{
|
|
|
|
if (msg.msg_type != OPAL_MSG_ASYNC_COMP)
|
|
|
|
return OPAL_PARAMETER;
|
|
|
|
else
|
|
|
|
return be64_to_cpu(msg.params[1]);
|
|
|
|
}
|
|
|
|
|
2016-07-04 11:51:44 +07:00
|
|
|
void opal_wake_poller(void);
|
|
|
|
|
2017-08-10 10:31:18 +07:00
|
|
|
void opal_powercap_init(void);
|
2017-08-10 10:31:19 +07:00
|
|
|
void opal_psr_init(void);
|
2017-08-10 10:31:20 +07:00
|
|
|
void opal_sensor_groups_init(void);
|
2017-08-10 10:31:18 +07:00
|
|
|
|
2011-09-20 00:44:57 +07:00
|
|
|
#endif /* __ASSEMBLY__ */
|
2011-09-20 01:27:58 +07:00
|
|
|
|
2015-02-17 16:01:53 +07:00
|
|
|
#endif /* _ASM_POWERPC_OPAL_H */
|