162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci#ifndef _POWERPC_PROM_H 362306a36Sopenharmony_ci#define _POWERPC_PROM_H 462306a36Sopenharmony_ci#ifdef __KERNEL__ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci/* 762306a36Sopenharmony_ci * Definitions for talking to the Open Firmware PROM on 862306a36Sopenharmony_ci * Power Macintosh computers. 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci * Copyright (C) 1996-2005 Paul Mackerras. 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp. 1362306a36Sopenharmony_ci */ 1462306a36Sopenharmony_ci#include <linux/types.h> 1562306a36Sopenharmony_ci#include <asm/firmware.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistruct device_node; 1862306a36Sopenharmony_cistruct property; 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ 2162306a36Sopenharmony_ci#define OF_DT_END_NODE 0x2 /* End node */ 2262306a36Sopenharmony_ci#define OF_DT_PROP 0x3 /* Property: name off, size, 2362306a36Sopenharmony_ci * content */ 2462306a36Sopenharmony_ci#define OF_DT_NOP 0x4 /* nop */ 2562306a36Sopenharmony_ci#define OF_DT_END 0x9 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define OF_DT_VERSION 0x10 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci/* 3062306a36Sopenharmony_ci * This is what gets passed to the kernel by prom_init or kexec 3162306a36Sopenharmony_ci * 3262306a36Sopenharmony_ci * The dt struct contains the device tree structure, full pathes and 3362306a36Sopenharmony_ci * property contents. The dt strings contain a separate block with just 3462306a36Sopenharmony_ci * the strings for the property names, and is fully page aligned and 3562306a36Sopenharmony_ci * self contained in a page, so that it can be kept around by the kernel, 3662306a36Sopenharmony_ci * each property name appears only once in this page (cheap compression) 3762306a36Sopenharmony_ci * 3862306a36Sopenharmony_ci * the mem_rsvmap contains a map of reserved ranges of physical memory, 3962306a36Sopenharmony_ci * passing it here instead of in the device-tree itself greatly simplifies 4062306a36Sopenharmony_ci * the job of everybody. It's just a list of u64 pairs (base/size) that 4162306a36Sopenharmony_ci * ends when size is 0 4262306a36Sopenharmony_ci */ 4362306a36Sopenharmony_cistruct boot_param_header { 4462306a36Sopenharmony_ci __be32 magic; /* magic word OF_DT_HEADER */ 4562306a36Sopenharmony_ci __be32 totalsize; /* total size of DT block */ 4662306a36Sopenharmony_ci __be32 off_dt_struct; /* offset to structure */ 4762306a36Sopenharmony_ci __be32 off_dt_strings; /* offset to strings */ 4862306a36Sopenharmony_ci __be32 off_mem_rsvmap; /* offset to memory reserve map */ 4962306a36Sopenharmony_ci __be32 version; /* format version */ 5062306a36Sopenharmony_ci __be32 last_comp_version; /* last compatible version */ 5162306a36Sopenharmony_ci /* version 2 fields below */ 5262306a36Sopenharmony_ci __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */ 5362306a36Sopenharmony_ci /* version 3 fields below */ 5462306a36Sopenharmony_ci __be32 dt_strings_size; /* size of the DT strings block */ 5562306a36Sopenharmony_ci /* version 17 fields below */ 5662306a36Sopenharmony_ci __be32 dt_struct_size; /* size of the DT structure block */ 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* 6062306a36Sopenharmony_ci * OF address retreival & translation 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci/* Parse the ibm,dma-window property of an OF node into the busno, phys and 6462306a36Sopenharmony_ci * size parameters. 6562306a36Sopenharmony_ci */ 6662306a36Sopenharmony_civoid of_parse_dma_window(struct device_node *dn, const __be32 *dma_window, 6762306a36Sopenharmony_ci unsigned long *busno, unsigned long *phys, 6862306a36Sopenharmony_ci unsigned long *size); 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciextern void of_instantiate_rtc(void); 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ciextern int of_get_ibm_chip_id(struct device_node *np); 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_cistruct of_drc_info { 7562306a36Sopenharmony_ci char *drc_type; 7662306a36Sopenharmony_ci char *drc_name_prefix; 7762306a36Sopenharmony_ci u32 drc_index_start; 7862306a36Sopenharmony_ci u32 drc_name_suffix_start; 7962306a36Sopenharmony_ci u32 num_sequential_elems; 8062306a36Sopenharmony_ci u32 sequential_inc; 8162306a36Sopenharmony_ci u32 drc_power_domain; 8262306a36Sopenharmony_ci u32 last_drc_index; 8362306a36Sopenharmony_ci}; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ciextern int of_read_drc_info_cell(struct property **prop, 8662306a36Sopenharmony_ci const __be32 **curval, struct of_drc_info *data); 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ciextern unsigned int boot_cpu_node_count; 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/* 9162306a36Sopenharmony_ci * There are two methods for telling firmware what our capabilities are. 9262306a36Sopenharmony_ci * Newer machines have an "ibm,client-architecture-support" method on the 9362306a36Sopenharmony_ci * root node. For older machines, we have to call the "process-elf-header" 9462306a36Sopenharmony_ci * method in the /packages/elf-loader node, passing it a fake 32-bit 9562306a36Sopenharmony_ci * ELF header containing a couple of PT_NOTE sections that contain 9662306a36Sopenharmony_ci * structures that contain various information. 9762306a36Sopenharmony_ci */ 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci/* New method - extensible architecture description vector. */ 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci/* Option vector bits - generic bits in byte 1 */ 10262306a36Sopenharmony_ci#define OV_IGNORE 0x80 /* ignore this vector */ 10362306a36Sopenharmony_ci#define OV_CESSATION_POLICY 0x40 /* halt if unsupported option present*/ 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci/* Option vector 1: processor architectures supported */ 10662306a36Sopenharmony_ci#define OV1_PPC_2_00 0x80 /* set if we support PowerPC 2.00 */ 10762306a36Sopenharmony_ci#define OV1_PPC_2_01 0x40 /* set if we support PowerPC 2.01 */ 10862306a36Sopenharmony_ci#define OV1_PPC_2_02 0x20 /* set if we support PowerPC 2.02 */ 10962306a36Sopenharmony_ci#define OV1_PPC_2_03 0x10 /* set if we support PowerPC 2.03 */ 11062306a36Sopenharmony_ci#define OV1_PPC_2_04 0x08 /* set if we support PowerPC 2.04 */ 11162306a36Sopenharmony_ci#define OV1_PPC_2_05 0x04 /* set if we support PowerPC 2.05 */ 11262306a36Sopenharmony_ci#define OV1_PPC_2_06 0x02 /* set if we support PowerPC 2.06 */ 11362306a36Sopenharmony_ci#define OV1_PPC_2_07 0x01 /* set if we support PowerPC 2.07 */ 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci#define OV1_PPC_3_00 0x80 /* set if we support PowerPC 3.00 */ 11662306a36Sopenharmony_ci#define OV1_PPC_3_1 0x40 /* set if we support PowerPC 3.1 */ 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci/* Option vector 2: Open Firmware options supported */ 11962306a36Sopenharmony_ci#define OV2_REAL_MODE 0x20 /* set if we want OF in real mode */ 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* Option vector 3: processor options supported */ 12262306a36Sopenharmony_ci#define OV3_FP 0x80 /* floating point */ 12362306a36Sopenharmony_ci#define OV3_VMX 0x40 /* VMX/Altivec */ 12462306a36Sopenharmony_ci#define OV3_DFP 0x20 /* decimal FP */ 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci/* Option vector 4: IBM PAPR implementation */ 12762306a36Sopenharmony_ci#define OV4_MIN_ENT_CAP 0x01 /* minimum VP entitled capacity */ 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci/* Option vector 5: PAPR/OF options supported 13062306a36Sopenharmony_ci * These bits are also used in firmware_has_feature() to validate 13162306a36Sopenharmony_ci * the capabilities reported for vector 5 in the device tree so we 13262306a36Sopenharmony_ci * encode the vector index in the define and use the OV5_FEAT() 13362306a36Sopenharmony_ci * and OV5_INDX() macros to extract the desired information. 13462306a36Sopenharmony_ci */ 13562306a36Sopenharmony_ci#define OV5_FEAT(x) ((x) & 0xff) 13662306a36Sopenharmony_ci#define OV5_INDX(x) ((x) >> 8) 13762306a36Sopenharmony_ci#define OV5_LPAR 0x0280 /* logical partitioning supported */ 13862306a36Sopenharmony_ci#define OV5_SPLPAR 0x0240 /* shared-processor LPAR supported */ 13962306a36Sopenharmony_ci/* ibm,dynamic-reconfiguration-memory property supported */ 14062306a36Sopenharmony_ci#define OV5_DRCONF_MEMORY 0x0220 14162306a36Sopenharmony_ci#define OV5_LARGE_PAGES 0x0210 /* large pages supported */ 14262306a36Sopenharmony_ci#define OV5_DONATE_DEDICATE_CPU 0x0202 /* donate dedicated CPU support */ 14362306a36Sopenharmony_ci#define OV5_MSI 0x0201 /* PCIe/MSI support */ 14462306a36Sopenharmony_ci#define OV5_CMO 0x0480 /* Cooperative Memory Overcommitment */ 14562306a36Sopenharmony_ci#define OV5_XCMO 0x0440 /* Page Coalescing */ 14662306a36Sopenharmony_ci#define OV5_FORM1_AFFINITY 0x0580 /* FORM1 NUMA affinity */ 14762306a36Sopenharmony_ci#define OV5_PRRN 0x0540 /* Platform Resource Reassignment */ 14862306a36Sopenharmony_ci#define OV5_FORM2_AFFINITY 0x0520 /* Form2 NUMA affinity */ 14962306a36Sopenharmony_ci#define OV5_HP_EVT 0x0604 /* Hot Plug Event support */ 15062306a36Sopenharmony_ci#define OV5_RESIZE_HPT 0x0601 /* Hash Page Table resizing */ 15162306a36Sopenharmony_ci#define OV5_PFO_HW_RNG 0x1180 /* PFO Random Number Generator */ 15262306a36Sopenharmony_ci#define OV5_PFO_HW_842 0x1140 /* PFO Compression Accelerator */ 15362306a36Sopenharmony_ci#define OV5_PFO_HW_ENCR 0x1120 /* PFO Encryption Accelerator */ 15462306a36Sopenharmony_ci#define OV5_SUB_PROCESSORS 0x1501 /* 1,2,or 4 Sub-Processors supported */ 15562306a36Sopenharmony_ci#define OV5_DRMEM_V2 0x1680 /* ibm,dynamic-reconfiguration-v2 */ 15662306a36Sopenharmony_ci#define OV5_XIVE_SUPPORT 0x17C0 /* XIVE Exploitation Support Mask */ 15762306a36Sopenharmony_ci#define OV5_XIVE_LEGACY 0x1700 /* XIVE legacy mode Only */ 15862306a36Sopenharmony_ci#define OV5_XIVE_EXPLOIT 0x1740 /* XIVE exploitation mode Only */ 15962306a36Sopenharmony_ci#define OV5_XIVE_EITHER 0x1780 /* XIVE legacy or exploitation mode */ 16062306a36Sopenharmony_ci/* MMU Base Architecture */ 16162306a36Sopenharmony_ci#define OV5_MMU_SUPPORT 0x18C0 /* MMU Mode Support Mask */ 16262306a36Sopenharmony_ci#define OV5_MMU_HASH 0x1800 /* Hash MMU Only */ 16362306a36Sopenharmony_ci#define OV5_MMU_RADIX 0x1840 /* Radix MMU Only */ 16462306a36Sopenharmony_ci#define OV5_MMU_EITHER 0x1880 /* Hash or Radix Supported */ 16562306a36Sopenharmony_ci#define OV5_MMU_DYNAMIC 0x18C0 /* Hash or Radix Can Switch Later */ 16662306a36Sopenharmony_ci#define OV5_NMMU 0x1820 /* Nest MMU Available */ 16762306a36Sopenharmony_ci/* Hash Table Extensions */ 16862306a36Sopenharmony_ci#define OV5_HASH_SEG_TBL 0x1980 /* In Memory Segment Tables Available */ 16962306a36Sopenharmony_ci#define OV5_HASH_GTSE 0x1940 /* Guest Translation Shoot Down Avail */ 17062306a36Sopenharmony_ci/* Radix Table Extensions */ 17162306a36Sopenharmony_ci#define OV5_RADIX_GTSE 0x1A40 /* Guest Translation Shoot Down Avail */ 17262306a36Sopenharmony_ci#define OV5_DRC_INFO 0x1640 /* Redef Prop Structures: drc-info */ 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci/* Option Vector 6: IBM PAPR hints */ 17562306a36Sopenharmony_ci#define OV6_LINUX 0x02 /* Linux is our OS */ 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci#endif /* __KERNEL__ */ 17862306a36Sopenharmony_ci#endif /* _POWERPC_PROM_H */ 179