1b8b572e1SStephen Rothwell #ifndef _POWERPC_RTAS_H 2b8b572e1SStephen Rothwell #define _POWERPC_RTAS_H 3b8b572e1SStephen Rothwell #ifdef __KERNEL__ 4b8b572e1SStephen Rothwell 5b8b572e1SStephen Rothwell #include <linux/spinlock.h> 6b8b572e1SStephen Rothwell #include <asm/page.h> 7b8b572e1SStephen Rothwell 8b8b572e1SStephen Rothwell /* 9b8b572e1SStephen Rothwell * Definitions for talking to the RTAS on CHRP machines. 10b8b572e1SStephen Rothwell * 11b8b572e1SStephen Rothwell * Copyright (C) 2001 Peter Bergner 12b8b572e1SStephen Rothwell * Copyright (C) 2001 PPC 64 Team, IBM Corp 13b8b572e1SStephen Rothwell * 14b8b572e1SStephen Rothwell * This program is free software; you can redistribute it and/or 15b8b572e1SStephen Rothwell * modify it under the terms of the GNU General Public License 16b8b572e1SStephen Rothwell * as published by the Free Software Foundation; either version 17b8b572e1SStephen Rothwell * 2 of the License, or (at your option) any later version. 18b8b572e1SStephen Rothwell */ 19b8b572e1SStephen Rothwell 20b8b572e1SStephen Rothwell #define RTAS_UNKNOWN_SERVICE (-1) 21fe333321SIngo Molnar #define RTAS_INSTANTIATE_MAX (1ULL<<30) /* Don't instantiate rtas at/above this value */ 22b8b572e1SStephen Rothwell 23b8b572e1SStephen Rothwell /* Buffer size for ppc_rtas system call. */ 24b8b572e1SStephen Rothwell #define RTAS_RMOBUF_MAX (64 * 1024) 25b8b572e1SStephen Rothwell 26b8b572e1SStephen Rothwell /* RTAS return status codes */ 27b8b572e1SStephen Rothwell #define RTAS_NOT_SUSPENDABLE -9004 28b8b572e1SStephen Rothwell #define RTAS_BUSY -2 /* RTAS Busy */ 29b8b572e1SStephen Rothwell #define RTAS_EXTENDED_DELAY_MIN 9900 30b8b572e1SStephen Rothwell #define RTAS_EXTENDED_DELAY_MAX 9905 31b8b572e1SStephen Rothwell 32b8b572e1SStephen Rothwell /* 33b8b572e1SStephen Rothwell * In general to call RTAS use rtas_token("string") to lookup 34b8b572e1SStephen Rothwell * an RTAS token for the given string (e.g. "event-scan"). 35b8b572e1SStephen Rothwell * To actually perform the call use 36b8b572e1SStephen Rothwell * ret = rtas_call(token, n_in, n_out, ...) 37b8b572e1SStephen Rothwell * Where n_in is the number of input parameters and 38b8b572e1SStephen Rothwell * n_out is the number of output parameters 39b8b572e1SStephen Rothwell * 40b8b572e1SStephen Rothwell * If the "string" is invalid on this system, RTAS_UNKNOWN_SERVICE 41b8b572e1SStephen Rothwell * will be returned as a token. rtas_call() does look for this 42b8b572e1SStephen Rothwell * token and error out gracefully so rtas_call(rtas_token("str"), ...) 43b8b572e1SStephen Rothwell * may be safely used for one-shot calls to RTAS. 44b8b572e1SStephen Rothwell * 45b8b572e1SStephen Rothwell */ 46b8b572e1SStephen Rothwell 47b8b572e1SStephen Rothwell typedef u32 rtas_arg_t; 48b8b572e1SStephen Rothwell 49b8b572e1SStephen Rothwell struct rtas_args { 50b8b572e1SStephen Rothwell u32 token; 51b8b572e1SStephen Rothwell u32 nargs; 52b8b572e1SStephen Rothwell u32 nret; 53b8b572e1SStephen Rothwell rtas_arg_t args[16]; 54b8b572e1SStephen Rothwell rtas_arg_t *rets; /* Pointer to return values in args[]. */ 55b8b572e1SStephen Rothwell }; 56b8b572e1SStephen Rothwell 57b8b572e1SStephen Rothwell struct rtas_t { 58b8b572e1SStephen Rothwell unsigned long entry; /* physical address pointer */ 59b8b572e1SStephen Rothwell unsigned long base; /* physical address pointer */ 60b8b572e1SStephen Rothwell unsigned long size; 61445c8951SThomas Gleixner arch_spinlock_t lock; 62b8b572e1SStephen Rothwell struct rtas_args args; 63b8b572e1SStephen Rothwell struct device_node *dev; /* virtual address pointer */ 64b8b572e1SStephen Rothwell }; 65b8b572e1SStephen Rothwell 668fe93f8dSBrian King struct rtas_suspend_me_data { 678fe93f8dSBrian King atomic_t working; /* number of cpus accessing this struct */ 688fe93f8dSBrian King atomic_t done; 698fe93f8dSBrian King int token; /* ibm,suspend-me */ 708fe93f8dSBrian King atomic_t error; 718fe93f8dSBrian King struct completion *complete; /* wait on this until working == 0 */ 728fe93f8dSBrian King }; 738fe93f8dSBrian King 74b8b572e1SStephen Rothwell /* RTAS event classes */ 75b8b572e1SStephen Rothwell #define RTAS_INTERNAL_ERROR 0x80000000 /* set bit 0 */ 76b8b572e1SStephen Rothwell #define RTAS_EPOW_WARNING 0x40000000 /* set bit 1 */ 77b8b572e1SStephen Rothwell #define RTAS_HOTPLUG_EVENTS 0x10000000 /* set bit 3 */ 784a9f9506SAnton Blanchard #define RTAS_IO_EVENTS 0x08000000 /* set bit 4 */ 794a9f9506SAnton Blanchard #define RTAS_EVENT_SCAN_ALL_EVENTS 0xffffffff 80b8b572e1SStephen Rothwell 81b8b572e1SStephen Rothwell /* RTAS event severity */ 82b8b572e1SStephen Rothwell #define RTAS_SEVERITY_FATAL 0x5 83b8b572e1SStephen Rothwell #define RTAS_SEVERITY_ERROR 0x4 84b8b572e1SStephen Rothwell #define RTAS_SEVERITY_ERROR_SYNC 0x3 85b8b572e1SStephen Rothwell #define RTAS_SEVERITY_WARNING 0x2 86b8b572e1SStephen Rothwell #define RTAS_SEVERITY_EVENT 0x1 87b8b572e1SStephen Rothwell #define RTAS_SEVERITY_NO_ERROR 0x0 88b8b572e1SStephen Rothwell 89b8b572e1SStephen Rothwell /* RTAS event disposition */ 90b8b572e1SStephen Rothwell #define RTAS_DISP_FULLY_RECOVERED 0x0 91b8b572e1SStephen Rothwell #define RTAS_DISP_LIMITED_RECOVERY 0x1 92b8b572e1SStephen Rothwell #define RTAS_DISP_NOT_RECOVERED 0x2 93b8b572e1SStephen Rothwell 94b8b572e1SStephen Rothwell /* RTAS event initiator */ 95b8b572e1SStephen Rothwell #define RTAS_INITIATOR_UNKNOWN 0x0 96b8b572e1SStephen Rothwell #define RTAS_INITIATOR_CPU 0x1 97b8b572e1SStephen Rothwell #define RTAS_INITIATOR_PCI 0x2 98b8b572e1SStephen Rothwell #define RTAS_INITIATOR_ISA 0x3 99b8b572e1SStephen Rothwell #define RTAS_INITIATOR_MEMORY 0x4 100b8b572e1SStephen Rothwell #define RTAS_INITIATOR_POWERMGM 0x5 101b8b572e1SStephen Rothwell 102b8b572e1SStephen Rothwell /* RTAS event target */ 103b8b572e1SStephen Rothwell #define RTAS_TARGET_UNKNOWN 0x0 104b8b572e1SStephen Rothwell #define RTAS_TARGET_CPU 0x1 105b8b572e1SStephen Rothwell #define RTAS_TARGET_PCI 0x2 106b8b572e1SStephen Rothwell #define RTAS_TARGET_ISA 0x3 107b8b572e1SStephen Rothwell #define RTAS_TARGET_MEMORY 0x4 108b8b572e1SStephen Rothwell #define RTAS_TARGET_POWERMGM 0x5 109b8b572e1SStephen Rothwell 110b8b572e1SStephen Rothwell /* RTAS event type */ 111b8b572e1SStephen Rothwell #define RTAS_TYPE_RETRY 0x01 112b8b572e1SStephen Rothwell #define RTAS_TYPE_TCE_ERR 0x02 113b8b572e1SStephen Rothwell #define RTAS_TYPE_INTERN_DEV_FAIL 0x03 114b8b572e1SStephen Rothwell #define RTAS_TYPE_TIMEOUT 0x04 115b8b572e1SStephen Rothwell #define RTAS_TYPE_DATA_PARITY 0x05 116b8b572e1SStephen Rothwell #define RTAS_TYPE_ADDR_PARITY 0x06 117b8b572e1SStephen Rothwell #define RTAS_TYPE_CACHE_PARITY 0x07 118b8b572e1SStephen Rothwell #define RTAS_TYPE_ADDR_INVALID 0x08 119b8b572e1SStephen Rothwell #define RTAS_TYPE_ECC_UNCORR 0x09 120b8b572e1SStephen Rothwell #define RTAS_TYPE_ECC_CORR 0x0a 121b8b572e1SStephen Rothwell #define RTAS_TYPE_EPOW 0x40 122b8b572e1SStephen Rothwell #define RTAS_TYPE_PLATFORM 0xE0 123b8b572e1SStephen Rothwell #define RTAS_TYPE_IO 0xE1 124b8b572e1SStephen Rothwell #define RTAS_TYPE_INFO 0xE2 125b8b572e1SStephen Rothwell #define RTAS_TYPE_DEALLOC 0xE3 126b8b572e1SStephen Rothwell #define RTAS_TYPE_DUMP 0xE4 127b8b572e1SStephen Rothwell /* I don't add PowerMGM events right now, this is a different topic */ 128b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_POWER_SW_ON 0x60 129b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_POWER_SW_OFF 0x61 130b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_LID_OPEN 0x62 131b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_LID_CLOSE 0x63 132b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_SLEEP_BTN 0x64 133b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_WAKE_BTN 0x65 134b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_BATTERY_WARN 0x66 135b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_BATTERY_CRIT 0x67 136b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_SWITCH_TO_BAT 0x68 137b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_SWITCH_TO_AC 0x69 138b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_KBD_OR_MOUSE 0x6a 139b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_ENCLOS_OPEN 0x6b 140b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_ENCLOS_CLOSED 0x6c 141b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_RING_INDICATE 0x6d 142b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_LAN_ATTENTION 0x6e 143b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_TIME_ALARM 0x6f 144b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_CONFIG_CHANGE 0x70 145b8b572e1SStephen Rothwell #define RTAS_TYPE_PMGM_SERVICE_PROC 0x71 14649c68a85SJesse Larrew /* Platform Resource Reassignment Notification */ 14749c68a85SJesse Larrew #define RTAS_TYPE_PRRN 0xA0 148b8b572e1SStephen Rothwell 149b08e281bSMark Nelson /* RTAS check-exception vector offset */ 150b08e281bSMark Nelson #define RTAS_VECTOR_EXTERNAL_INTERRUPT 0x500 151b08e281bSMark Nelson 152b8b572e1SStephen Rothwell struct rtas_error_log { 153b8b572e1SStephen Rothwell unsigned long version:8; /* Architectural version */ 154b8b572e1SStephen Rothwell unsigned long severity:3; /* Severity level of error */ 155b8b572e1SStephen Rothwell unsigned long disposition:2; /* Degree of recovery */ 156b8b572e1SStephen Rothwell unsigned long extended:1; /* extended log present? */ 157b8b572e1SStephen Rothwell unsigned long /* reserved */ :2; /* Reserved for future use */ 158b8b572e1SStephen Rothwell unsigned long initiator:4; /* Initiator of event */ 159b8b572e1SStephen Rothwell unsigned long target:4; /* Target of failed operation */ 160b8b572e1SStephen Rothwell unsigned long type:8; /* General event or error*/ 161b8b572e1SStephen Rothwell unsigned long extended_log_length:32; /* length in bytes */ 1624cb46380STseng-Hui (Frank) Lin unsigned char buffer[1]; /* Start of extended log */ 1634cb46380STseng-Hui (Frank) Lin /* Variable length. */ 1644cb46380STseng-Hui (Frank) Lin }; 1654cb46380STseng-Hui (Frank) Lin 1664cb46380STseng-Hui (Frank) Lin #define RTAS_V6EXT_LOG_FORMAT_EVENT_LOG 14 1674cb46380STseng-Hui (Frank) Lin 1684cb46380STseng-Hui (Frank) Lin #define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8)) 1694cb46380STseng-Hui (Frank) Lin 1704cb46380STseng-Hui (Frank) Lin /* RTAS general extended event log, Version 6. The extended log starts 1714cb46380STseng-Hui (Frank) Lin * from "buffer" field of struct rtas_error_log defined above. 1724cb46380STseng-Hui (Frank) Lin */ 1734cb46380STseng-Hui (Frank) Lin struct rtas_ext_event_log_v6 { 1744cb46380STseng-Hui (Frank) Lin /* Byte 0 */ 1754cb46380STseng-Hui (Frank) Lin uint32_t log_valid:1; /* 1:Log valid */ 1764cb46380STseng-Hui (Frank) Lin uint32_t unrecoverable_error:1; /* 1:Unrecoverable error */ 1774cb46380STseng-Hui (Frank) Lin uint32_t recoverable_error:1; /* 1:recoverable (correctable */ 1784cb46380STseng-Hui (Frank) Lin /* or successfully retried) */ 1794cb46380STseng-Hui (Frank) Lin uint32_t degraded_operation:1; /* 1:Unrecoverable err, bypassed*/ 1804cb46380STseng-Hui (Frank) Lin /* - degraded operation (e.g. */ 1814cb46380STseng-Hui (Frank) Lin /* CPU or mem taken off-line) */ 1824cb46380STseng-Hui (Frank) Lin uint32_t predictive_error:1; 1834cb46380STseng-Hui (Frank) Lin uint32_t new_log:1; /* 1:"New" log (Always 1 for */ 1844cb46380STseng-Hui (Frank) Lin /* data returned from RTAS */ 1854cb46380STseng-Hui (Frank) Lin uint32_t big_endian:1; /* 1: Big endian */ 1864cb46380STseng-Hui (Frank) Lin uint32_t :1; /* reserved */ 1874cb46380STseng-Hui (Frank) Lin /* Byte 1 */ 1884cb46380STseng-Hui (Frank) Lin uint32_t :8; /* reserved */ 1894cb46380STseng-Hui (Frank) Lin /* Byte 2 */ 1904cb46380STseng-Hui (Frank) Lin uint32_t powerpc_format:1; /* Set to 1 (indicating log is */ 1914cb46380STseng-Hui (Frank) Lin /* in PowerPC format */ 1924cb46380STseng-Hui (Frank) Lin uint32_t :3; /* reserved */ 1934cb46380STseng-Hui (Frank) Lin uint32_t log_format:4; /* Log format indicator. Define */ 1944cb46380STseng-Hui (Frank) Lin /* format used for byte 12-2047 */ 1954cb46380STseng-Hui (Frank) Lin /* Byte 3 */ 1964cb46380STseng-Hui (Frank) Lin uint32_t :8; /* reserved */ 1974cb46380STseng-Hui (Frank) Lin /* Byte 4-11 */ 1984cb46380STseng-Hui (Frank) Lin uint8_t reserved[8]; /* reserved */ 1994cb46380STseng-Hui (Frank) Lin /* Byte 12-15 */ 2004cb46380STseng-Hui (Frank) Lin uint32_t company_id; /* Company ID of the company */ 2014cb46380STseng-Hui (Frank) Lin /* that defines the format for */ 2024cb46380STseng-Hui (Frank) Lin /* the vendor specific log type */ 2034cb46380STseng-Hui (Frank) Lin /* Byte 16-end of log */ 2044cb46380STseng-Hui (Frank) Lin uint8_t vendor_log[1]; /* Start of vendor specific log */ 2054cb46380STseng-Hui (Frank) Lin /* Variable length. */ 206b8b572e1SStephen Rothwell }; 207b8b572e1SStephen Rothwell 2086431f208SAnton Blanchard /* pSeries event log format */ 2096431f208SAnton Blanchard 2106431f208SAnton Blanchard /* Two bytes ASCII section IDs */ 2116431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_PRIV_HDR (('P' << 8) | 'H') 2126431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_USER_HDR (('U' << 8) | 'H') 2136431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_PRIMARY_SRC (('P' << 8) | 'S') 2146431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_EXTENDED_UH (('E' << 8) | 'H') 2156431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_FAILING_MTMS (('M' << 8) | 'T') 2166431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_SECONDARY_SRC (('S' << 8) | 'S') 2176431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_DUMP_LOCATOR (('D' << 8) | 'H') 2186431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_FW_ERROR (('S' << 8) | 'W') 2196431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_IMPACT_PART_ID (('L' << 8) | 'P') 2206431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_LOGIC_RESOURCE_ID (('L' << 8) | 'R') 2216431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_HMC_ID (('H' << 8) | 'M') 2226431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_EPOW (('E' << 8) | 'P') 2236431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_IO_EVENT (('I' << 8) | 'E') 2246431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_MANUFACT_INFO (('M' << 8) | 'I') 2256431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H') 2266431f208SAnton Blanchard #define PSERIES_ELOG_SECT_ID_USER_DEF (('U' << 8) | 'D') 2276431f208SAnton Blanchard 2286431f208SAnton Blanchard /* Vendor specific Platform Event Log Format, Version 6, section header */ 2296431f208SAnton Blanchard struct pseries_errorlog { 2306431f208SAnton Blanchard uint16_t id; /* 0x00 2-byte ASCII section ID */ 2316431f208SAnton Blanchard uint16_t length; /* 0x02 Section length in bytes */ 2326431f208SAnton Blanchard uint8_t version; /* 0x04 Section version */ 2336431f208SAnton Blanchard uint8_t subtype; /* 0x05 Section subtype */ 2346431f208SAnton Blanchard uint16_t creator_component; /* 0x06 Creator component ID */ 2356431f208SAnton Blanchard uint8_t data[]; /* 0x08 Start of section data */ 2366431f208SAnton Blanchard }; 2376431f208SAnton Blanchard 2386431f208SAnton Blanchard struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, 2396431f208SAnton Blanchard uint16_t section_id); 2406431f208SAnton Blanchard 241b8b572e1SStephen Rothwell /* 242b8b572e1SStephen Rothwell * This can be set by the rtas_flash module so that it can get called 243b8b572e1SStephen Rothwell * as the absolutely last thing before the kernel terminates. 244b8b572e1SStephen Rothwell */ 245b8b572e1SStephen Rothwell extern void (*rtas_flash_term_hook)(int); 246b8b572e1SStephen Rothwell 247b8b572e1SStephen Rothwell extern struct rtas_t rtas; 248b8b572e1SStephen Rothwell 249b8b572e1SStephen Rothwell extern void enter_rtas(unsigned long); 250b8b572e1SStephen Rothwell extern int rtas_token(const char *service); 251b8b572e1SStephen Rothwell extern int rtas_service_present(const char *service); 252b8b572e1SStephen Rothwell extern int rtas_call(int token, int, int, int *, ...); 253b8b572e1SStephen Rothwell extern void rtas_restart(char *cmd); 254b8b572e1SStephen Rothwell extern void rtas_power_off(void); 255b8b572e1SStephen Rothwell extern void rtas_halt(void); 256b8b572e1SStephen Rothwell extern void rtas_os_term(char *str); 257b8b572e1SStephen Rothwell extern int rtas_get_sensor(int sensor, int index, int *state); 258b8b572e1SStephen Rothwell extern int rtas_get_power_level(int powerdomain, int *level); 259b8b572e1SStephen Rothwell extern int rtas_set_power_level(int powerdomain, int level, int *setlevel); 260edc72ac4SNathan Lynch extern bool rtas_indicator_present(int token, int *maxindex); 261b8b572e1SStephen Rothwell extern int rtas_set_indicator(int indicator, int index, int new_value); 262b8b572e1SStephen Rothwell extern int rtas_set_indicator_fast(int indicator, int index, int new_value); 263b8b572e1SStephen Rothwell extern void rtas_progress(char *s, unsigned short hex); 264b8b572e1SStephen Rothwell extern void rtas_initialize(void); 2658fe93f8dSBrian King extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data); 2668fe93f8dSBrian King extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data); 267120496acSRobert Jennings extern int rtas_online_cpus_mask(cpumask_var_t cpus); 268120496acSRobert Jennings extern int rtas_offline_cpus_mask(cpumask_var_t cpus); 269d8862be1SNathan Fontenot extern int rtas_ibm_suspend_me(struct rtas_args *); 270b8b572e1SStephen Rothwell 271b8b572e1SStephen Rothwell struct rtc_time; 272b8b572e1SStephen Rothwell extern unsigned long rtas_get_boot_time(void); 273b8b572e1SStephen Rothwell extern void rtas_get_rtc_time(struct rtc_time *rtc_time); 274b8b572e1SStephen Rothwell extern int rtas_set_rtc_time(struct rtc_time *rtc_time); 275b8b572e1SStephen Rothwell 276b8b572e1SStephen Rothwell extern unsigned int rtas_busy_delay_time(int status); 277b8b572e1SStephen Rothwell extern unsigned int rtas_busy_delay(int status); 278b8b572e1SStephen Rothwell 279b8b572e1SStephen Rothwell extern int early_init_dt_scan_rtas(unsigned long node, 280b8b572e1SStephen Rothwell const char *uname, int depth, void *data); 281b8b572e1SStephen Rothwell 282b8b572e1SStephen Rothwell extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal); 283b8b572e1SStephen Rothwell 284762ec157SNathan Fontenot #ifdef CONFIG_PPC_PSERIES 285762ec157SNathan Fontenot extern int pseries_devicetree_update(s32 scope); 286762ec157SNathan Fontenot #endif 287762ec157SNathan Fontenot 288df17f56dSRavi K. Nittala #ifdef CONFIG_PPC_RTAS_DAEMON 289df17f56dSRavi K. Nittala extern void rtas_cancel_event_scan(void); 290df17f56dSRavi K. Nittala #else 291df17f56dSRavi K. Nittala static inline void rtas_cancel_event_scan(void) { } 292df17f56dSRavi K. Nittala #endif 293df17f56dSRavi K. Nittala 294b8b572e1SStephen Rothwell /* Error types logged. */ 295b8b572e1SStephen Rothwell #define ERR_FLAG_ALREADY_LOGGED 0x0 296b8b572e1SStephen Rothwell #define ERR_FLAG_BOOT 0x1 /* log was pulled from NVRAM on boot */ 297b8b572e1SStephen Rothwell #define ERR_TYPE_RTAS_LOG 0x2 /* from rtas event-scan */ 2986c493685SJim Keniston #define ERR_TYPE_KERNEL_PANIC 0x4 /* from die()/panic() */ 2996c493685SJim Keniston #define ERR_TYPE_KERNEL_PANIC_GZ 0x8 /* ditto, compressed */ 300b8b572e1SStephen Rothwell 301b8b572e1SStephen Rothwell /* All the types and not flags */ 3026c493685SJim Keniston #define ERR_TYPE_MASK \ 3036c493685SJim Keniston (ERR_TYPE_RTAS_LOG | ERR_TYPE_KERNEL_PANIC | ERR_TYPE_KERNEL_PANIC_GZ) 304b8b572e1SStephen Rothwell 305b8b572e1SStephen Rothwell #define RTAS_DEBUG KERN_DEBUG "RTAS: " 306b8b572e1SStephen Rothwell 307b8b572e1SStephen Rothwell #define RTAS_ERROR_LOG_MAX 2048 308b8b572e1SStephen Rothwell 309b8b572e1SStephen Rothwell /* 310b8b572e1SStephen Rothwell * Return the firmware-specified size of the error log buffer 311b8b572e1SStephen Rothwell * for all rtas calls that require an error buffer argument. 312b8b572e1SStephen Rothwell * This includes 'check-exception' and 'rtas-last-error'. 313b8b572e1SStephen Rothwell */ 314b8b572e1SStephen Rothwell extern int rtas_get_error_log_max(void); 315b8b572e1SStephen Rothwell 316b8b572e1SStephen Rothwell /* Event Scan Parameters */ 317b8b572e1SStephen Rothwell #define EVENT_SCAN_ALL_EVENTS 0xf0000000 318b8b572e1SStephen Rothwell #define SURVEILLANCE_TOKEN 9000 319b8b572e1SStephen Rothwell #define LOG_NUMBER 64 /* must be a power of two */ 320b8b572e1SStephen Rothwell #define LOG_NUMBER_MASK (LOG_NUMBER-1) 321b8b572e1SStephen Rothwell 322b8b572e1SStephen Rothwell /* Some RTAS ops require a data buffer and that buffer must be < 4G. 323b8b572e1SStephen Rothwell * Rather than having a memory allocator, just use this buffer 324b8b572e1SStephen Rothwell * (get the lock first), make the RTAS call. Copy the data instead 325b8b572e1SStephen Rothwell * of holding the buffer for long. 326b8b572e1SStephen Rothwell */ 327b8b572e1SStephen Rothwell 328b8b572e1SStephen Rothwell #define RTAS_DATA_BUF_SIZE 4096 329b8b572e1SStephen Rothwell extern spinlock_t rtas_data_buf_lock; 330b8b572e1SStephen Rothwell extern char rtas_data_buf[RTAS_DATA_BUF_SIZE]; 331b8b572e1SStephen Rothwell 332b8b572e1SStephen Rothwell /* RMO buffer reserved for user-space RTAS use */ 333b8b572e1SStephen Rothwell extern unsigned long rtas_rmo_buf; 334b8b572e1SStephen Rothwell 335b8b572e1SStephen Rothwell #define GLOBAL_INTERRUPT_QUEUE 9005 336b8b572e1SStephen Rothwell 337b8b572e1SStephen Rothwell /** 338b8b572e1SStephen Rothwell * rtas_config_addr - Format a busno, devfn and reg for RTAS. 339b8b572e1SStephen Rothwell * @busno: The bus number. 340b8b572e1SStephen Rothwell * @devfn: The device and function number as encoded by PCI_DEVFN(). 341b8b572e1SStephen Rothwell * @reg: The register number. 342b8b572e1SStephen Rothwell * 343b8b572e1SStephen Rothwell * This function encodes the given busno, devfn and register number as 344b8b572e1SStephen Rothwell * required for RTAS calls that take a "config_addr" parameter. 345b8b572e1SStephen Rothwell * See PAPR requirement 7.3.4-1 for more info. 346b8b572e1SStephen Rothwell */ 347b8b572e1SStephen Rothwell static inline u32 rtas_config_addr(int busno, int devfn, int reg) 348b8b572e1SStephen Rothwell { 349b8b572e1SStephen Rothwell return ((reg & 0xf00) << 20) | ((busno & 0xff) << 16) | 350b8b572e1SStephen Rothwell (devfn << 8) | (reg & 0xff); 351b8b572e1SStephen Rothwell } 352b8b572e1SStephen Rothwell 353c4007a2fSBenjamin Herrenschmidt extern void __cpuinit rtas_give_timebase(void); 354c4007a2fSBenjamin Herrenschmidt extern void __cpuinit rtas_take_timebase(void); 355c4007a2fSBenjamin Herrenschmidt 3568a3e3d31Ssukadev@linux.vnet.ibm.com #ifdef CONFIG_PPC_RTAS 3578a3e3d31Ssukadev@linux.vnet.ibm.com static inline int page_is_rtas_user_buf(unsigned long pfn) 3588a3e3d31Ssukadev@linux.vnet.ibm.com { 3598a3e3d31Ssukadev@linux.vnet.ibm.com unsigned long paddr = (pfn << PAGE_SHIFT); 3608a3e3d31Ssukadev@linux.vnet.ibm.com if (paddr >= rtas_rmo_buf && paddr < (rtas_rmo_buf + RTAS_RMOBUF_MAX)) 3618a3e3d31Ssukadev@linux.vnet.ibm.com return 1; 3628a3e3d31Ssukadev@linux.vnet.ibm.com return 0; 3638a3e3d31Ssukadev@linux.vnet.ibm.com } 364f459d63eSNathan Fontenot 365f459d63eSNathan Fontenot /* Not the best place to put pSeries_coalesce_init, will be fixed when we 366f459d63eSNathan Fontenot * move some of the rtas suspend-me stuff to pseries */ 367f459d63eSNathan Fontenot extern void pSeries_coalesce_init(void); 3688a3e3d31Ssukadev@linux.vnet.ibm.com #else 3698a3e3d31Ssukadev@linux.vnet.ibm.com static inline int page_is_rtas_user_buf(unsigned long pfn) { return 0;} 370f459d63eSNathan Fontenot static inline void pSeries_coalesce_init(void) { } 3718a3e3d31Ssukadev@linux.vnet.ibm.com #endif 3728a3e3d31Ssukadev@linux.vnet.ibm.com 373ae3a197eSDavid Howells extern int call_rtas(const char *, int, int, unsigned long *, ...); 374ae3a197eSDavid Howells 375b8b572e1SStephen Rothwell #endif /* __KERNEL__ */ 376b8b572e1SStephen Rothwell #endif /* _POWERPC_RTAS_H */ 377