162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * PowerNV OPAL definitions.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2011 IBM Corp.
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef _ASM_POWERPC_OPAL_H
962306a36Sopenharmony_ci#define _ASM_POWERPC_OPAL_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include <asm/opal-api.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#ifndef __ASSEMBLY__
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#include <linux/notifier.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/* We calculate number of sg entries based on PAGE_SIZE */
1862306a36Sopenharmony_ci#define SG_ENTRIES_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct opal_sg_entry))
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/* Default time to sleep or delay between OPAL_BUSY/OPAL_BUSY_EVENT loops */
2162306a36Sopenharmony_ci#define OPAL_BUSY_DELAY_MS	10
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/* /sys/firmware/opal */
2462306a36Sopenharmony_ciextern struct kobject *opal_kobj;
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* /ibm,opal */
2762306a36Sopenharmony_ciextern struct device_node *opal_node;
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci/* API functions */
3062306a36Sopenharmony_ciint64_t opal_invalid_call(void);
3162306a36Sopenharmony_ciint64_t opal_npu_map_lpar(uint64_t phb_id, uint64_t bdf, uint64_t lparid,
3262306a36Sopenharmony_ci			uint64_t lpcr);
3362306a36Sopenharmony_ciint64_t opal_npu_spa_setup(uint64_t phb_id, uint32_t bdfn,
3462306a36Sopenharmony_ci			uint64_t addr, uint64_t PE_mask);
3562306a36Sopenharmony_ciint64_t opal_npu_spa_clear_cache(uint64_t phb_id, uint32_t bdfn,
3662306a36Sopenharmony_ci				uint64_t PE_handle);
3762306a36Sopenharmony_ciint64_t opal_npu_tl_set(uint64_t phb_id, uint32_t bdfn, long cap,
3862306a36Sopenharmony_ci			uint64_t rate_phys, uint32_t size);
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciint64_t opal_console_write(int64_t term_number, __be64 *length,
4162306a36Sopenharmony_ci			   const uint8_t *buffer);
4262306a36Sopenharmony_ciint64_t opal_console_read(int64_t term_number, __be64 *length,
4362306a36Sopenharmony_ci			  uint8_t *buffer);
4462306a36Sopenharmony_ciint64_t opal_console_write_buffer_space(int64_t term_number,
4562306a36Sopenharmony_ci					__be64 *length);
4662306a36Sopenharmony_ciint64_t opal_console_flush(int64_t term_number);
4762306a36Sopenharmony_ciint64_t opal_rtc_read(__be32 *year_month_day,
4862306a36Sopenharmony_ci		      __be64 *hour_minute_second_millisecond);
4962306a36Sopenharmony_ciint64_t opal_rtc_write(uint32_t year_month_day,
5062306a36Sopenharmony_ci		       uint64_t hour_minute_second_millisecond);
5162306a36Sopenharmony_ciint64_t opal_tpo_read(uint64_t token, __be32 *year_mon_day, __be32 *hour_min);
5262306a36Sopenharmony_ciint64_t opal_tpo_write(uint64_t token, uint32_t year_mon_day,
5362306a36Sopenharmony_ci		       uint32_t hour_min);
5462306a36Sopenharmony_ciint64_t opal_cec_power_down(uint64_t request);
5562306a36Sopenharmony_ciint64_t opal_cec_reboot(void);
5662306a36Sopenharmony_ciint64_t opal_cec_reboot2(uint32_t reboot_type, const char *diag);
5762306a36Sopenharmony_ciint64_t opal_read_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
5862306a36Sopenharmony_ciint64_t opal_write_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
5962306a36Sopenharmony_ciint64_t opal_handle_interrupt(uint64_t isn, __be64 *outstanding_event_mask);
6062306a36Sopenharmony_ciint64_t opal_poll_events(__be64 *outstanding_event_mask);
6162306a36Sopenharmony_ciint64_t opal_pci_set_hub_tce_memory(uint64_t hub_id, uint64_t tce_mem_addr,
6262306a36Sopenharmony_ci				    uint64_t tce_mem_size);
6362306a36Sopenharmony_ciint64_t opal_pci_set_phb_tce_memory(uint64_t phb_id, uint64_t tce_mem_addr,
6462306a36Sopenharmony_ci				    uint64_t tce_mem_size);
6562306a36Sopenharmony_ciint64_t opal_pci_config_read_byte(uint64_t phb_id, uint64_t bus_dev_func,
6662306a36Sopenharmony_ci				  uint64_t offset, uint8_t *data);
6762306a36Sopenharmony_ciint64_t opal_pci_config_read_half_word(uint64_t phb_id, uint64_t bus_dev_func,
6862306a36Sopenharmony_ci				       uint64_t offset, __be16 *data);
6962306a36Sopenharmony_ciint64_t opal_pci_config_read_word(uint64_t phb_id, uint64_t bus_dev_func,
7062306a36Sopenharmony_ci				  uint64_t offset, __be32 *data);
7162306a36Sopenharmony_ciint64_t opal_pci_config_write_byte(uint64_t phb_id, uint64_t bus_dev_func,
7262306a36Sopenharmony_ci				   uint64_t offset, uint8_t data);
7362306a36Sopenharmony_ciint64_t opal_pci_config_write_half_word(uint64_t phb_id, uint64_t bus_dev_func,
7462306a36Sopenharmony_ci					uint64_t offset, uint16_t data);
7562306a36Sopenharmony_ciint64_t opal_pci_config_write_word(uint64_t phb_id, uint64_t bus_dev_func,
7662306a36Sopenharmony_ci				   uint64_t offset, uint32_t data);
7762306a36Sopenharmony_ciint64_t opal_set_xive(uint32_t isn, uint16_t server, uint8_t priority);
7862306a36Sopenharmony_ciint64_t opal_get_xive(uint32_t isn, __be16 *server, uint8_t *priority);
7962306a36Sopenharmony_ciint64_t opal_register_exception_handler(uint64_t opal_exception,
8062306a36Sopenharmony_ci					uint64_t handler_address,
8162306a36Sopenharmony_ci					uint64_t glue_cache_line);
8262306a36Sopenharmony_ciint64_t opal_pci_eeh_freeze_status(uint64_t phb_id, uint64_t pe_number,
8362306a36Sopenharmony_ci				   uint8_t *freeze_state,
8462306a36Sopenharmony_ci				   __be16 *pci_error_type,
8562306a36Sopenharmony_ci				   __be64 *phb_status);
8662306a36Sopenharmony_ciint64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number,
8762306a36Sopenharmony_ci				  uint64_t eeh_action_token);
8862306a36Sopenharmony_ciint64_t opal_pci_eeh_freeze_set(uint64_t phb_id, uint64_t pe_number,
8962306a36Sopenharmony_ci				uint64_t eeh_action_token);
9062306a36Sopenharmony_ciint64_t opal_pci_err_inject(uint64_t phb_id, uint32_t pe_no, uint32_t type,
9162306a36Sopenharmony_ci			    uint32_t func, uint64_t addr, uint64_t mask);
9262306a36Sopenharmony_ciint64_t opal_pci_shpc(uint64_t phb_id, uint64_t shpc_action, uint8_t *state);
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ciint64_t opal_pci_phb_mmio_enable(uint64_t phb_id, uint16_t window_type,
9762306a36Sopenharmony_ci				 uint16_t window_num, uint16_t enable);
9862306a36Sopenharmony_ciint64_t opal_pci_set_phb_mem_window(uint64_t phb_id, uint16_t window_type,
9962306a36Sopenharmony_ci				    uint16_t window_num,
10062306a36Sopenharmony_ci				    uint64_t starting_real_address,
10162306a36Sopenharmony_ci				    uint64_t starting_pci_address,
10262306a36Sopenharmony_ci				    uint64_t size);
10362306a36Sopenharmony_ciint64_t opal_pci_map_pe_mmio_window(uint64_t phb_id, uint16_t pe_number,
10462306a36Sopenharmony_ci				    uint16_t window_type, uint16_t window_num,
10562306a36Sopenharmony_ci				    uint16_t segment_num);
10662306a36Sopenharmony_ciint64_t opal_pci_set_phb_table_memory(uint64_t phb_id, uint64_t rtt_addr,
10762306a36Sopenharmony_ci				      uint64_t ivt_addr, uint64_t ivt_len,
10862306a36Sopenharmony_ci				      uint64_t reject_array_addr,
10962306a36Sopenharmony_ci				      uint64_t peltv_addr);
11062306a36Sopenharmony_ciint64_t opal_pci_set_pe(uint64_t phb_id, uint64_t pe_number, uint64_t bus_dev_func,
11162306a36Sopenharmony_ci			uint8_t bus_compare, uint8_t dev_compare, uint8_t func_compare,
11262306a36Sopenharmony_ci			uint8_t pe_action);
11362306a36Sopenharmony_ciint64_t opal_pci_set_peltv(uint64_t phb_id, uint32_t parent_pe, uint32_t child_pe,
11462306a36Sopenharmony_ci			   uint8_t state);
11562306a36Sopenharmony_ciint64_t opal_pci_get_xive_reissue(uint64_t phb_id, uint32_t xive_number,
11662306a36Sopenharmony_ci				  uint8_t *p_bit, uint8_t *q_bit);
11762306a36Sopenharmony_ciint64_t opal_pci_set_xive_reissue(uint64_t phb_id, uint32_t xive_number,
11862306a36Sopenharmony_ci				  uint8_t p_bit, uint8_t q_bit);
11962306a36Sopenharmony_ciint64_t opal_pci_msi_eoi(uint64_t phb_id, uint32_t hw_irq);
12062306a36Sopenharmony_ciint64_t opal_pci_set_xive_pe(uint64_t phb_id, uint32_t pe_number,
12162306a36Sopenharmony_ci			     uint32_t xive_num);
12262306a36Sopenharmony_ciint64_t opal_get_xive_source(uint64_t phb_id, uint32_t xive_num,
12362306a36Sopenharmony_ci			     __be32 *interrupt_source_number);
12462306a36Sopenharmony_ciint64_t opal_get_msi_32(uint64_t phb_id, uint32_t mve_number, uint32_t xive_num,
12562306a36Sopenharmony_ci			uint8_t msi_range, __be32 *msi_address,
12662306a36Sopenharmony_ci			__be32 *message_data);
12762306a36Sopenharmony_ciint64_t opal_get_msi_64(uint64_t phb_id, uint32_t mve_number,
12862306a36Sopenharmony_ci			uint32_t xive_num, uint8_t msi_range,
12962306a36Sopenharmony_ci			__be64 *msi_address, __be32 *message_data);
13062306a36Sopenharmony_ciint64_t opal_start_cpu(uint64_t thread_number, uint64_t start_address);
13162306a36Sopenharmony_ciint64_t opal_query_cpu_status(uint64_t thread_number, uint8_t *thread_status);
13262306a36Sopenharmony_ciint64_t opal_write_oppanel(oppanel_line_t *lines, uint64_t num_lines);
13362306a36Sopenharmony_ciint64_t opal_pci_map_pe_dma_window(uint64_t phb_id, uint16_t pe_number, uint16_t window_id,
13462306a36Sopenharmony_ci				   uint16_t tce_levels, uint64_t tce_table_addr,
13562306a36Sopenharmony_ci				   uint64_t tce_table_size, uint64_t tce_page_size);
13662306a36Sopenharmony_ciint64_t opal_pci_map_pe_dma_window_real(uint64_t phb_id, uint16_t pe_number,
13762306a36Sopenharmony_ci					uint16_t dma_window_number, uint64_t pci_start_addr,
13862306a36Sopenharmony_ci					uint64_t pci_mem_size);
13962306a36Sopenharmony_ciint64_t opal_pci_reset(uint64_t id, uint8_t reset_scope, uint8_t assert_state);
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ciint64_t opal_pci_get_hub_diag_data(uint64_t hub_id, void *diag_buffer,
14262306a36Sopenharmony_ci				   uint64_t diag_buffer_len);
14362306a36Sopenharmony_ciint64_t opal_pci_get_phb_diag_data(uint64_t phb_id, void *diag_buffer,
14462306a36Sopenharmony_ci				   uint64_t diag_buffer_len);
14562306a36Sopenharmony_ciint64_t opal_pci_get_phb_diag_data2(uint64_t phb_id, void *diag_buffer,
14662306a36Sopenharmony_ci				    uint64_t diag_buffer_len);
14762306a36Sopenharmony_ciint64_t opal_pci_fence_phb(uint64_t phb_id);
14862306a36Sopenharmony_ciint64_t opal_pci_reinit(uint64_t phb_id, uint64_t reinit_scope, uint64_t data);
14962306a36Sopenharmony_ciint64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action);
15062306a36Sopenharmony_ciint64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action);
15162306a36Sopenharmony_ciint64_t opal_get_epow_status(__be16 *epow_status, __be16 *num_epow_classes);
15262306a36Sopenharmony_ciint64_t opal_get_dpo_status(__be64 *dpo_timeout);
15362306a36Sopenharmony_ciint64_t opal_set_system_attention_led(uint8_t led_action);
15462306a36Sopenharmony_ciint64_t opal_pci_next_error(uint64_t phb_id, __be64 *first_frozen_pe,
15562306a36Sopenharmony_ci			    __be16 *pci_error_type, __be16 *severity);
15662306a36Sopenharmony_ciint64_t opal_pci_poll(uint64_t id);
15762306a36Sopenharmony_ciint64_t opal_return_cpu(void);
15862306a36Sopenharmony_ciint64_t opal_check_token(uint64_t token);
15962306a36Sopenharmony_ciint64_t opal_reinit_cpus(uint64_t flags);
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ciint64_t opal_xscom_read(uint32_t gcid, uint64_t pcb_addr, __be64 *val);
16262306a36Sopenharmony_ciint64_t opal_xscom_write(uint32_t gcid, uint64_t pcb_addr, uint64_t val);
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ciint64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type,
16562306a36Sopenharmony_ci		       uint32_t addr, uint32_t data, uint32_t sz);
16662306a36Sopenharmony_ciint64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type,
16762306a36Sopenharmony_ci		      uint32_t addr, __be32 *data, uint32_t sz);
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ciint64_t opal_read_elog(uint64_t buffer, uint64_t size, uint64_t log_id);
17062306a36Sopenharmony_ciint64_t opal_get_elog_size(__be64 *log_id, __be64 *size, __be64 *elog_type);
17162306a36Sopenharmony_ciint64_t opal_write_elog(uint64_t buffer, uint64_t size, uint64_t offset);
17262306a36Sopenharmony_ciint64_t opal_send_ack_elog(uint64_t log_id);
17362306a36Sopenharmony_civoid opal_resend_pending_logs(void);
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ciint64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result);
17662306a36Sopenharmony_ciint64_t opal_manage_flash(uint8_t op);
17762306a36Sopenharmony_ciint64_t opal_update_flash(uint64_t blk_list);
17862306a36Sopenharmony_ciint64_t opal_dump_init(uint8_t dump_type);
17962306a36Sopenharmony_ciint64_t opal_dump_info(__be32 *dump_id, __be32 *dump_size);
18062306a36Sopenharmony_ciint64_t opal_dump_info2(__be32 *dump_id, __be32 *dump_size, __be32 *dump_type);
18162306a36Sopenharmony_ciint64_t opal_dump_read(uint32_t dump_id, uint64_t buffer);
18262306a36Sopenharmony_ciint64_t opal_dump_ack(uint32_t dump_id);
18362306a36Sopenharmony_ciint64_t opal_dump_resend_notification(void);
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ciint64_t opal_get_msg(uint64_t buffer, uint64_t size);
18662306a36Sopenharmony_ciint64_t opal_write_oppanel_async(uint64_t token, oppanel_line_t *lines,
18762306a36Sopenharmony_ci					uint64_t num_lines);
18862306a36Sopenharmony_ciint64_t opal_check_completion(uint64_t buffer, uint64_t size, uint64_t token);
18962306a36Sopenharmony_ciint64_t opal_sync_host_reboot(void);
19062306a36Sopenharmony_ciint64_t opal_get_param(uint64_t token, uint32_t param_id, uint64_t buffer,
19162306a36Sopenharmony_ci		uint64_t length);
19262306a36Sopenharmony_ciint64_t opal_set_param(uint64_t token, uint32_t param_id, uint64_t buffer,
19362306a36Sopenharmony_ci		uint64_t length);
19462306a36Sopenharmony_ciint64_t opal_sensor_read(uint32_t sensor_hndl, int token, __be32 *sensor_data);
19562306a36Sopenharmony_ciint64_t opal_sensor_read_u64(u32 sensor_hndl, int token, __be64 *sensor_data);
19662306a36Sopenharmony_ciint64_t opal_handle_hmi(void);
19762306a36Sopenharmony_ciint64_t opal_handle_hmi2(__be64 *out_flags);
19862306a36Sopenharmony_ciint64_t opal_register_dump_region(uint32_t id, uint64_t start, uint64_t end);
19962306a36Sopenharmony_ciint64_t opal_unregister_dump_region(uint32_t id);
20062306a36Sopenharmony_ciint64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val);
20162306a36Sopenharmony_ciint64_t opal_config_cpu_idle_state(uint64_t state, uint64_t flag);
20262306a36Sopenharmony_ciint64_t opal_pci_set_phb_cxl_mode(uint64_t phb_id, uint64_t mode, uint64_t pe_number);
20362306a36Sopenharmony_ciint64_t opal_pci_get_pbcq_tunnel_bar(uint64_t phb_id, uint64_t *addr);
20462306a36Sopenharmony_ciint64_t opal_pci_set_pbcq_tunnel_bar(uint64_t phb_id, uint64_t addr);
20562306a36Sopenharmony_ciint64_t opal_ipmi_send(uint64_t interface, struct opal_ipmi_msg *msg,
20662306a36Sopenharmony_ci		uint64_t msg_len);
20762306a36Sopenharmony_ciint64_t opal_ipmi_recv(uint64_t interface, struct opal_ipmi_msg *msg,
20862306a36Sopenharmony_ci		uint64_t *msg_len);
20962306a36Sopenharmony_ciint64_t opal_i2c_request(uint64_t async_token, uint32_t bus_id,
21062306a36Sopenharmony_ci			 struct opal_i2c_request *oreq);
21162306a36Sopenharmony_ciint64_t opal_prd_msg(struct opal_prd_msg *msg);
21262306a36Sopenharmony_ciint64_t opal_leds_get_ind(char *loc_code, __be64 *led_mask,
21362306a36Sopenharmony_ci			  __be64 *led_value, __be64 *max_led_type);
21462306a36Sopenharmony_ciint64_t opal_leds_set_ind(uint64_t token, char *loc_code, const u64 led_mask,
21562306a36Sopenharmony_ci			  const u64 led_value, __be64 *max_led_type);
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ciint64_t opal_flash_read(uint64_t id, uint64_t offset, uint64_t buf,
21862306a36Sopenharmony_ci		uint64_t size, uint64_t token);
21962306a36Sopenharmony_ciint64_t opal_flash_write(uint64_t id, uint64_t offset, uint64_t buf,
22062306a36Sopenharmony_ci		uint64_t size, uint64_t token);
22162306a36Sopenharmony_ciint64_t opal_flash_erase(uint64_t id, uint64_t offset, uint64_t size,
22262306a36Sopenharmony_ci		uint64_t token);
22362306a36Sopenharmony_ciint64_t opal_get_device_tree(uint32_t phandle, uint64_t buf, uint64_t len);
22462306a36Sopenharmony_ciint64_t opal_pci_get_presence_state(uint64_t id, uint64_t data);
22562306a36Sopenharmony_ciint64_t opal_pci_get_power_state(uint64_t id, uint64_t data);
22662306a36Sopenharmony_ciint64_t opal_pci_set_power_state(uint64_t async_token, uint64_t id,
22762306a36Sopenharmony_ci				 uint64_t data);
22862306a36Sopenharmony_ciint64_t opal_pci_poll2(uint64_t id, uint64_t data);
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ciint64_t opal_int_get_xirr(uint32_t *out_xirr, bool just_poll);
23162306a36Sopenharmony_ciint64_t opal_int_set_cppr(uint8_t cppr);
23262306a36Sopenharmony_ciint64_t opal_int_eoi(uint32_t xirr);
23362306a36Sopenharmony_ciint64_t opal_int_set_mfrr(uint32_t cpu, uint8_t mfrr);
23462306a36Sopenharmony_ciint64_t opal_pci_tce_kill(uint64_t phb_id, uint32_t kill_type,
23562306a36Sopenharmony_ci			  uint32_t pe_num, uint32_t tce_size,
23662306a36Sopenharmony_ci			  uint64_t dma_addr, uint32_t npages);
23762306a36Sopenharmony_ciint64_t opal_nmmu_set_ptcr(uint64_t chip_id, uint64_t ptcr);
23862306a36Sopenharmony_ciint64_t opal_xive_reset(uint64_t version);
23962306a36Sopenharmony_ciint64_t opal_xive_get_irq_info(uint32_t girq,
24062306a36Sopenharmony_ci			       __be64 *out_flags,
24162306a36Sopenharmony_ci			       __be64 *out_eoi_page,
24262306a36Sopenharmony_ci			       __be64 *out_trig_page,
24362306a36Sopenharmony_ci			       __be32 *out_esb_shift,
24462306a36Sopenharmony_ci			       __be32 *out_src_chip);
24562306a36Sopenharmony_ciint64_t opal_xive_get_irq_config(uint32_t girq, __be64 *out_vp,
24662306a36Sopenharmony_ci				 uint8_t *out_prio, __be32 *out_lirq);
24762306a36Sopenharmony_ciint64_t opal_xive_set_irq_config(uint32_t girq, uint64_t vp, uint8_t prio,
24862306a36Sopenharmony_ci				 uint32_t lirq);
24962306a36Sopenharmony_ciint64_t opal_xive_get_queue_info(uint64_t vp, uint32_t prio,
25062306a36Sopenharmony_ci				 __be64 *out_qpage,
25162306a36Sopenharmony_ci				 __be64 *out_qsize,
25262306a36Sopenharmony_ci				 __be64 *out_qeoi_page,
25362306a36Sopenharmony_ci				 __be32 *out_escalate_irq,
25462306a36Sopenharmony_ci				 __be64 *out_qflags);
25562306a36Sopenharmony_ciint64_t opal_xive_set_queue_info(uint64_t vp, uint32_t prio,
25662306a36Sopenharmony_ci				 uint64_t qpage,
25762306a36Sopenharmony_ci				 uint64_t qsize,
25862306a36Sopenharmony_ci				 uint64_t qflags);
25962306a36Sopenharmony_ciint64_t opal_xive_donate_page(uint32_t chip_id, uint64_t addr);
26062306a36Sopenharmony_ciint64_t opal_xive_alloc_vp_block(uint32_t alloc_order);
26162306a36Sopenharmony_ciint64_t opal_xive_free_vp_block(uint64_t vp);
26262306a36Sopenharmony_ciint64_t opal_xive_get_vp_info(uint64_t vp,
26362306a36Sopenharmony_ci			      __be64 *out_flags,
26462306a36Sopenharmony_ci			      __be64 *out_cam_value,
26562306a36Sopenharmony_ci			      __be64 *out_report_cl_pair,
26662306a36Sopenharmony_ci			      __be32 *out_chip_id);
26762306a36Sopenharmony_ciint64_t opal_xive_set_vp_info(uint64_t vp,
26862306a36Sopenharmony_ci			      uint64_t flags,
26962306a36Sopenharmony_ci			      uint64_t report_cl_pair);
27062306a36Sopenharmony_ciint64_t opal_xive_allocate_irq_raw(uint32_t chip_id);
27162306a36Sopenharmony_ciint64_t opal_xive_free_irq(uint32_t girq);
27262306a36Sopenharmony_ciint64_t opal_xive_sync(uint32_t type, uint32_t id);
27362306a36Sopenharmony_ciint64_t opal_xive_dump(uint32_t type, uint32_t id);
27462306a36Sopenharmony_ciint64_t opal_xive_get_queue_state(uint64_t vp, uint32_t prio,
27562306a36Sopenharmony_ci				  __be32 *out_qtoggle,
27662306a36Sopenharmony_ci				  __be32 *out_qindex);
27762306a36Sopenharmony_ciint64_t opal_xive_set_queue_state(uint64_t vp, uint32_t prio,
27862306a36Sopenharmony_ci				  uint32_t qtoggle,
27962306a36Sopenharmony_ci				  uint32_t qindex);
28062306a36Sopenharmony_ciint64_t opal_xive_get_vp_state(uint64_t vp, __be64 *out_w01);
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ciint64_t opal_imc_counters_init(uint32_t type, uint64_t address,
28362306a36Sopenharmony_ci							uint64_t cpu_pir);
28462306a36Sopenharmony_ciint64_t opal_imc_counters_start(uint32_t type, uint64_t cpu_pir);
28562306a36Sopenharmony_ciint64_t opal_imc_counters_stop(uint32_t type, uint64_t cpu_pir);
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ciint opal_get_powercap(u32 handle, int token, u32 *pcap);
28862306a36Sopenharmony_ciint opal_set_powercap(u32 handle, int token, u32 pcap);
28962306a36Sopenharmony_ciint opal_get_power_shift_ratio(u32 handle, int token, u32 *psr);
29062306a36Sopenharmony_ciint opal_set_power_shift_ratio(u32 handle, int token, u32 psr);
29162306a36Sopenharmony_ciint opal_sensor_group_clear(u32 group_hndl, int token);
29262306a36Sopenharmony_ciint opal_sensor_group_enable(u32 group_hndl, int token, bool enable);
29362306a36Sopenharmony_ciint opal_nx_coproc_init(uint32_t chip_id, uint32_t ct);
29462306a36Sopenharmony_ci
29562306a36Sopenharmony_ciint opal_secvar_get(const char *key, uint64_t key_len, u8 *data,
29662306a36Sopenharmony_ci		    uint64_t *data_size);
29762306a36Sopenharmony_ciint opal_secvar_get_next(const char *key, uint64_t *key_len,
29862306a36Sopenharmony_ci			 uint64_t key_buf_size);
29962306a36Sopenharmony_ciint opal_secvar_enqueue_update(const char *key, uint64_t key_len, u8 *data,
30062306a36Sopenharmony_ci			       uint64_t data_size);
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_cis64 opal_mpipl_update(enum opal_mpipl_ops op, u64 src, u64 dest, u64 size);
30362306a36Sopenharmony_cis64 opal_mpipl_register_tag(enum opal_mpipl_tags tag, u64 addr);
30462306a36Sopenharmony_cis64 opal_mpipl_query_tag(enum opal_mpipl_tags tag, __be64 *addr);
30562306a36Sopenharmony_ci
30662306a36Sopenharmony_cis64 opal_signal_system_reset(s32 cpu);
30762306a36Sopenharmony_cis64 opal_quiesce(u64 shutdown_type, s32 cpu);
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci/* Internal functions */
31062306a36Sopenharmony_ciextern int early_init_dt_scan_opal(unsigned long node, const char *uname,
31162306a36Sopenharmony_ci				   int depth, void *data);
31262306a36Sopenharmony_ciextern int early_init_dt_scan_recoverable_ranges(unsigned long node,
31362306a36Sopenharmony_ci				 const char *uname, int depth, void *data);
31462306a36Sopenharmony_civoid __init opal_configure_cores(void);
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ciextern int opal_get_chars(uint32_t vtermno, char *buf, int count);
31762306a36Sopenharmony_ciextern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);
31862306a36Sopenharmony_ciextern int opal_put_chars_atomic(uint32_t vtermno, const char *buf, int total_len);
31962306a36Sopenharmony_ciextern int opal_flush_chars(uint32_t vtermno, bool wait);
32062306a36Sopenharmony_ciextern int opal_flush_console(uint32_t vtermno);
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ciextern void hvc_opal_init_early(void);
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ciextern int opal_message_notifier_register(enum opal_msg_type msg_type,
32562306a36Sopenharmony_ci						struct notifier_block *nb);
32662306a36Sopenharmony_ciextern int opal_message_notifier_unregister(enum opal_msg_type msg_type,
32762306a36Sopenharmony_ci					    struct notifier_block *nb);
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ciextern int opal_async_get_token_interruptible(void);
33062306a36Sopenharmony_ciextern int opal_async_release_token(int token);
33162306a36Sopenharmony_ciextern int opal_async_wait_response(uint64_t token, struct opal_msg *msg);
33262306a36Sopenharmony_ciextern int opal_async_wait_response_interruptible(uint64_t token,
33362306a36Sopenharmony_ci		struct opal_msg *msg);
33462306a36Sopenharmony_ciextern int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data);
33562306a36Sopenharmony_ciextern int opal_get_sensor_data_u64(u32 sensor_hndl, u64 *sensor_data);
33662306a36Sopenharmony_ciextern int sensor_group_enable(u32 grp_hndl, bool enable);
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_cistruct rtc_time;
33962306a36Sopenharmony_ciextern time64_t opal_get_boot_time(void);
34062306a36Sopenharmony_ciextern void opal_nvram_init(void);
34162306a36Sopenharmony_ciextern void opal_flash_update_init(void);
34262306a36Sopenharmony_ciextern void opal_flash_update_print_message(void);
34362306a36Sopenharmony_ciextern int opal_elog_init(void);
34462306a36Sopenharmony_ciextern void opal_platform_dump_init(void);
34562306a36Sopenharmony_ciextern void opal_sys_param_init(void);
34662306a36Sopenharmony_ciextern void opal_msglog_init(void);
34762306a36Sopenharmony_ciextern void opal_msglog_sysfs_init(void);
34862306a36Sopenharmony_ciextern int opal_async_comp_init(void);
34962306a36Sopenharmony_ciextern int opal_sensor_init(void);
35062306a36Sopenharmony_ciextern int opal_hmi_handler_init(void);
35162306a36Sopenharmony_ciextern int opal_event_init(void);
35262306a36Sopenharmony_ciint opal_power_control_init(void);
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ciextern int opal_machine_check(struct pt_regs *regs);
35562306a36Sopenharmony_ciextern bool opal_mce_check_early_recovery(struct pt_regs *regs);
35662306a36Sopenharmony_ciextern int opal_hmi_exception_early(struct pt_regs *regs);
35762306a36Sopenharmony_ciextern int opal_hmi_exception_early2(struct pt_regs *regs);
35862306a36Sopenharmony_ciextern int opal_handle_hmi_exception(struct pt_regs *regs);
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ciextern void opal_shutdown(void);
36162306a36Sopenharmony_ciextern int opal_resync_timebase(void);
36262306a36Sopenharmony_ci
36362306a36Sopenharmony_ciextern void opal_lpc_init(void);
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_ciextern void opal_kmsg_init(void);
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ciextern int opal_event_request(unsigned int opal_event_nr);
36862306a36Sopenharmony_ci
36962306a36Sopenharmony_cistruct opal_sg_list *opal_vmalloc_to_sg_list(void *vmalloc_addr,
37062306a36Sopenharmony_ci					     unsigned long vmalloc_size);
37162306a36Sopenharmony_civoid opal_free_sg_list(struct opal_sg_list *sg);
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_ciextern int opal_error_code(int rc);
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_cissize_t opal_msglog_copy(char *to, loff_t pos, size_t count);
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_cistatic inline int opal_get_async_rc(struct opal_msg msg)
37862306a36Sopenharmony_ci{
37962306a36Sopenharmony_ci	if (msg.msg_type != OPAL_MSG_ASYNC_COMP)
38062306a36Sopenharmony_ci		return OPAL_PARAMETER;
38162306a36Sopenharmony_ci	else
38262306a36Sopenharmony_ci		return be64_to_cpu(msg.params[1]);
38362306a36Sopenharmony_ci}
38462306a36Sopenharmony_ci
38562306a36Sopenharmony_civoid opal_wake_poller(void);
38662306a36Sopenharmony_ci
38762306a36Sopenharmony_civoid opal_powercap_init(void);
38862306a36Sopenharmony_civoid opal_psr_init(void);
38962306a36Sopenharmony_civoid opal_sensor_groups_init(void);
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
39262306a36Sopenharmony_ci
39362306a36Sopenharmony_ci#endif /* _ASM_POWERPC_OPAL_H */
394