1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun #ifndef _POWERPC_PROM_H 3*4882a593Smuzhiyun #define _POWERPC_PROM_H 4*4882a593Smuzhiyun #ifdef __KERNEL__ 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun /* 7*4882a593Smuzhiyun * Definitions for talking to the Open Firmware PROM on 8*4882a593Smuzhiyun * Power Macintosh computers. 9*4882a593Smuzhiyun * 10*4882a593Smuzhiyun * Copyright (C) 1996-2005 Paul Mackerras. 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp. 13*4882a593Smuzhiyun */ 14*4882a593Smuzhiyun #include <linux/types.h> 15*4882a593Smuzhiyun #include <asm/irq.h> 16*4882a593Smuzhiyun #include <linux/atomic.h> 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun /* These includes should be removed once implicit includes are cleaned up. */ 19*4882a593Smuzhiyun #include <linux/of.h> 20*4882a593Smuzhiyun #include <linux/of_fdt.h> 21*4882a593Smuzhiyun #include <linux/of_address.h> 22*4882a593Smuzhiyun #include <linux/of_irq.h> 23*4882a593Smuzhiyun #include <linux/platform_device.h> 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ 26*4882a593Smuzhiyun #define OF_DT_END_NODE 0x2 /* End node */ 27*4882a593Smuzhiyun #define OF_DT_PROP 0x3 /* Property: name off, size, 28*4882a593Smuzhiyun * content */ 29*4882a593Smuzhiyun #define OF_DT_NOP 0x4 /* nop */ 30*4882a593Smuzhiyun #define OF_DT_END 0x9 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun #define OF_DT_VERSION 0x10 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun /* 35*4882a593Smuzhiyun * This is what gets passed to the kernel by prom_init or kexec 36*4882a593Smuzhiyun * 37*4882a593Smuzhiyun * The dt struct contains the device tree structure, full pathes and 38*4882a593Smuzhiyun * property contents. The dt strings contain a separate block with just 39*4882a593Smuzhiyun * the strings for the property names, and is fully page aligned and 40*4882a593Smuzhiyun * self contained in a page, so that it can be kept around by the kernel, 41*4882a593Smuzhiyun * each property name appears only once in this page (cheap compression) 42*4882a593Smuzhiyun * 43*4882a593Smuzhiyun * the mem_rsvmap contains a map of reserved ranges of physical memory, 44*4882a593Smuzhiyun * passing it here instead of in the device-tree itself greatly simplifies 45*4882a593Smuzhiyun * the job of everybody. It's just a list of u64 pairs (base/size) that 46*4882a593Smuzhiyun * ends when size is 0 47*4882a593Smuzhiyun */ 48*4882a593Smuzhiyun struct boot_param_header { 49*4882a593Smuzhiyun __be32 magic; /* magic word OF_DT_HEADER */ 50*4882a593Smuzhiyun __be32 totalsize; /* total size of DT block */ 51*4882a593Smuzhiyun __be32 off_dt_struct; /* offset to structure */ 52*4882a593Smuzhiyun __be32 off_dt_strings; /* offset to strings */ 53*4882a593Smuzhiyun __be32 off_mem_rsvmap; /* offset to memory reserve map */ 54*4882a593Smuzhiyun __be32 version; /* format version */ 55*4882a593Smuzhiyun __be32 last_comp_version; /* last compatible version */ 56*4882a593Smuzhiyun /* version 2 fields below */ 57*4882a593Smuzhiyun __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */ 58*4882a593Smuzhiyun /* version 3 fields below */ 59*4882a593Smuzhiyun __be32 dt_strings_size; /* size of the DT strings block */ 60*4882a593Smuzhiyun /* version 17 fields below */ 61*4882a593Smuzhiyun __be32 dt_struct_size; /* size of the DT structure block */ 62*4882a593Smuzhiyun }; 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun /* 65*4882a593Smuzhiyun * OF address retreival & translation 66*4882a593Smuzhiyun */ 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun /* Parse the ibm,dma-window property of an OF node into the busno, phys and 69*4882a593Smuzhiyun * size parameters. 70*4882a593Smuzhiyun */ 71*4882a593Smuzhiyun void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window, 72*4882a593Smuzhiyun unsigned long *busno, unsigned long *phys, 73*4882a593Smuzhiyun unsigned long *size); 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun extern void of_instantiate_rtc(void); 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun extern int of_get_ibm_chip_id(struct device_node *np); 78*4882a593Smuzhiyun 79*4882a593Smuzhiyun struct of_drc_info { 80*4882a593Smuzhiyun char *drc_type; 81*4882a593Smuzhiyun char *drc_name_prefix; 82*4882a593Smuzhiyun u32 drc_index_start; 83*4882a593Smuzhiyun u32 drc_name_suffix_start; 84*4882a593Smuzhiyun u32 num_sequential_elems; 85*4882a593Smuzhiyun u32 sequential_inc; 86*4882a593Smuzhiyun u32 drc_power_domain; 87*4882a593Smuzhiyun u32 last_drc_index; 88*4882a593Smuzhiyun }; 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun extern int of_read_drc_info_cell(struct property **prop, 91*4882a593Smuzhiyun const __be32 **curval, struct of_drc_info *data); 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun /* 95*4882a593Smuzhiyun * There are two methods for telling firmware what our capabilities are. 96*4882a593Smuzhiyun * Newer machines have an "ibm,client-architecture-support" method on the 97*4882a593Smuzhiyun * root node. For older machines, we have to call the "process-elf-header" 98*4882a593Smuzhiyun * method in the /packages/elf-loader node, passing it a fake 32-bit 99*4882a593Smuzhiyun * ELF header containing a couple of PT_NOTE sections that contain 100*4882a593Smuzhiyun * structures that contain various information. 101*4882a593Smuzhiyun */ 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun /* New method - extensible architecture description vector. */ 104*4882a593Smuzhiyun 105*4882a593Smuzhiyun /* Option vector bits - generic bits in byte 1 */ 106*4882a593Smuzhiyun #define OV_IGNORE 0x80 /* ignore this vector */ 107*4882a593Smuzhiyun #define OV_CESSATION_POLICY 0x40 /* halt if unsupported option present*/ 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun /* Option vector 1: processor architectures supported */ 110*4882a593Smuzhiyun #define OV1_PPC_2_00 0x80 /* set if we support PowerPC 2.00 */ 111*4882a593Smuzhiyun #define OV1_PPC_2_01 0x40 /* set if we support PowerPC 2.01 */ 112*4882a593Smuzhiyun #define OV1_PPC_2_02 0x20 /* set if we support PowerPC 2.02 */ 113*4882a593Smuzhiyun #define OV1_PPC_2_03 0x10 /* set if we support PowerPC 2.03 */ 114*4882a593Smuzhiyun #define OV1_PPC_2_04 0x08 /* set if we support PowerPC 2.04 */ 115*4882a593Smuzhiyun #define OV1_PPC_2_05 0x04 /* set if we support PowerPC 2.05 */ 116*4882a593Smuzhiyun #define OV1_PPC_2_06 0x02 /* set if we support PowerPC 2.06 */ 117*4882a593Smuzhiyun #define OV1_PPC_2_07 0x01 /* set if we support PowerPC 2.07 */ 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun #define OV1_PPC_3_00 0x80 /* set if we support PowerPC 3.00 */ 120*4882a593Smuzhiyun #define OV1_PPC_3_1 0x40 /* set if we support PowerPC 3.1 */ 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun /* Option vector 2: Open Firmware options supported */ 123*4882a593Smuzhiyun #define OV2_REAL_MODE 0x20 /* set if we want OF in real mode */ 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun /* Option vector 3: processor options supported */ 126*4882a593Smuzhiyun #define OV3_FP 0x80 /* floating point */ 127*4882a593Smuzhiyun #define OV3_VMX 0x40 /* VMX/Altivec */ 128*4882a593Smuzhiyun #define OV3_DFP 0x20 /* decimal FP */ 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun /* Option vector 4: IBM PAPR implementation */ 131*4882a593Smuzhiyun #define OV4_MIN_ENT_CAP 0x01 /* minimum VP entitled capacity */ 132*4882a593Smuzhiyun 133*4882a593Smuzhiyun /* Option vector 5: PAPR/OF options supported 134*4882a593Smuzhiyun * These bits are also used in firmware_has_feature() to validate 135*4882a593Smuzhiyun * the capabilities reported for vector 5 in the device tree so we 136*4882a593Smuzhiyun * encode the vector index in the define and use the OV5_FEAT() 137*4882a593Smuzhiyun * and OV5_INDX() macros to extract the desired information. 138*4882a593Smuzhiyun */ 139*4882a593Smuzhiyun #define OV5_FEAT(x) ((x) & 0xff) 140*4882a593Smuzhiyun #define OV5_INDX(x) ((x) >> 8) 141*4882a593Smuzhiyun #define OV5_LPAR 0x0280 /* logical partitioning supported */ 142*4882a593Smuzhiyun #define OV5_SPLPAR 0x0240 /* shared-processor LPAR supported */ 143*4882a593Smuzhiyun /* ibm,dynamic-reconfiguration-memory property supported */ 144*4882a593Smuzhiyun #define OV5_DRCONF_MEMORY 0x0220 145*4882a593Smuzhiyun #define OV5_LARGE_PAGES 0x0210 /* large pages supported */ 146*4882a593Smuzhiyun #define OV5_DONATE_DEDICATE_CPU 0x0202 /* donate dedicated CPU support */ 147*4882a593Smuzhiyun #define OV5_MSI 0x0201 /* PCIe/MSI support */ 148*4882a593Smuzhiyun #define OV5_CMO 0x0480 /* Cooperative Memory Overcommitment */ 149*4882a593Smuzhiyun #define OV5_XCMO 0x0440 /* Page Coalescing */ 150*4882a593Smuzhiyun #define OV5_TYPE1_AFFINITY 0x0580 /* Type 1 NUMA affinity */ 151*4882a593Smuzhiyun #define OV5_PRRN 0x0540 /* Platform Resource Reassignment */ 152*4882a593Smuzhiyun #define OV5_HP_EVT 0x0604 /* Hot Plug Event support */ 153*4882a593Smuzhiyun #define OV5_RESIZE_HPT 0x0601 /* Hash Page Table resizing */ 154*4882a593Smuzhiyun #define OV5_PFO_HW_RNG 0x1180 /* PFO Random Number Generator */ 155*4882a593Smuzhiyun #define OV5_PFO_HW_842 0x1140 /* PFO Compression Accelerator */ 156*4882a593Smuzhiyun #define OV5_PFO_HW_ENCR 0x1120 /* PFO Encryption Accelerator */ 157*4882a593Smuzhiyun #define OV5_SUB_PROCESSORS 0x1501 /* 1,2,or 4 Sub-Processors supported */ 158*4882a593Smuzhiyun #define OV5_DRMEM_V2 0x1680 /* ibm,dynamic-reconfiguration-v2 */ 159*4882a593Smuzhiyun #define OV5_XIVE_SUPPORT 0x17C0 /* XIVE Exploitation Support Mask */ 160*4882a593Smuzhiyun #define OV5_XIVE_LEGACY 0x1700 /* XIVE legacy mode Only */ 161*4882a593Smuzhiyun #define OV5_XIVE_EXPLOIT 0x1740 /* XIVE exploitation mode Only */ 162*4882a593Smuzhiyun #define OV5_XIVE_EITHER 0x1780 /* XIVE legacy or exploitation mode */ 163*4882a593Smuzhiyun /* MMU Base Architecture */ 164*4882a593Smuzhiyun #define OV5_MMU_SUPPORT 0x18C0 /* MMU Mode Support Mask */ 165*4882a593Smuzhiyun #define OV5_MMU_HASH 0x1800 /* Hash MMU Only */ 166*4882a593Smuzhiyun #define OV5_MMU_RADIX 0x1840 /* Radix MMU Only */ 167*4882a593Smuzhiyun #define OV5_MMU_EITHER 0x1880 /* Hash or Radix Supported */ 168*4882a593Smuzhiyun #define OV5_MMU_DYNAMIC 0x18C0 /* Hash or Radix Can Switch Later */ 169*4882a593Smuzhiyun #define OV5_NMMU 0x1820 /* Nest MMU Available */ 170*4882a593Smuzhiyun /* Hash Table Extensions */ 171*4882a593Smuzhiyun #define OV5_HASH_SEG_TBL 0x1980 /* In Memory Segment Tables Available */ 172*4882a593Smuzhiyun #define OV5_HASH_GTSE 0x1940 /* Guest Translation Shoot Down Avail */ 173*4882a593Smuzhiyun /* Radix Table Extensions */ 174*4882a593Smuzhiyun #define OV5_RADIX_GTSE 0x1A40 /* Guest Translation Shoot Down Avail */ 175*4882a593Smuzhiyun #define OV5_DRC_INFO 0x1640 /* Redef Prop Structures: drc-info */ 176*4882a593Smuzhiyun 177*4882a593Smuzhiyun /* Option Vector 6: IBM PAPR hints */ 178*4882a593Smuzhiyun #define OV6_LINUX 0x02 /* Linux is our OS */ 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun #endif /* __KERNEL__ */ 181*4882a593Smuzhiyun #endif /* _POWERPC_PROM_H */ 182