xref: /linux/arch/powerpc/include/asm/prom.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2b8b572e1SStephen Rothwell #ifndef _POWERPC_PROM_H
3b8b572e1SStephen Rothwell #define _POWERPC_PROM_H
4b8b572e1SStephen Rothwell #ifdef __KERNEL__
5b8b572e1SStephen Rothwell 
6b8b572e1SStephen Rothwell /*
7b8b572e1SStephen Rothwell  * Definitions for talking to the Open Firmware PROM on
8b8b572e1SStephen Rothwell  * Power Macintosh computers.
9b8b572e1SStephen Rothwell  *
10b8b572e1SStephen Rothwell  * Copyright (C) 1996-2005 Paul Mackerras.
11b8b572e1SStephen Rothwell  *
12b8b572e1SStephen Rothwell  * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
13b8b572e1SStephen Rothwell  */
14b8b572e1SStephen Rothwell #include <linux/types.h>
1546d60bdbSChristophe Leroy #include <asm/firmware.h>
16b8b572e1SStephen Rothwell 
1736afe687SChristophe Leroy struct device_node;
1836afe687SChristophe Leroy struct property;
19b8b572e1SStephen Rothwell 
20c3fc952dSRob Herring #define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
21c3fc952dSRob Herring #define OF_DT_END_NODE		0x2		/* End node */
22c3fc952dSRob Herring #define OF_DT_PROP		0x3		/* Property: name off, size,
23c3fc952dSRob Herring 						 * content */
24c3fc952dSRob Herring #define OF_DT_NOP		0x4		/* nop */
25c3fc952dSRob Herring #define OF_DT_END		0x9
26c3fc952dSRob Herring 
27c3fc952dSRob Herring #define OF_DT_VERSION		0x10
28c3fc952dSRob Herring 
29c3fc952dSRob Herring /*
30c3fc952dSRob Herring  * This is what gets passed to the kernel by prom_init or kexec
31c3fc952dSRob Herring  *
32c3fc952dSRob Herring  * The dt struct contains the device tree structure, full pathes and
33c3fc952dSRob Herring  * property contents. The dt strings contain a separate block with just
34c3fc952dSRob Herring  * the strings for the property names, and is fully page aligned and
35c3fc952dSRob Herring  * self contained in a page, so that it can be kept around by the kernel,
36c3fc952dSRob Herring  * each property name appears only once in this page (cheap compression)
37c3fc952dSRob Herring  *
38c3fc952dSRob Herring  * the mem_rsvmap contains a map of reserved ranges of physical memory,
39c3fc952dSRob Herring  * passing it here instead of in the device-tree itself greatly simplifies
40c3fc952dSRob Herring  * the job of everybody. It's just a list of u64 pairs (base/size) that
41c3fc952dSRob Herring  * ends when size is 0
42c3fc952dSRob Herring  */
43c3fc952dSRob Herring struct boot_param_header {
44c3fc952dSRob Herring 	__be32	magic;			/* magic word OF_DT_HEADER */
45c3fc952dSRob Herring 	__be32	totalsize;		/* total size of DT block */
46c3fc952dSRob Herring 	__be32	off_dt_struct;		/* offset to structure */
47c3fc952dSRob Herring 	__be32	off_dt_strings;		/* offset to strings */
48c3fc952dSRob Herring 	__be32	off_mem_rsvmap;		/* offset to memory reserve map */
49c3fc952dSRob Herring 	__be32	version;		/* format version */
50c3fc952dSRob Herring 	__be32	last_comp_version;	/* last compatible version */
51c3fc952dSRob Herring 	/* version 2 fields below */
52c3fc952dSRob Herring 	__be32	boot_cpuid_phys;	/* Physical CPU id we're booting on */
53c3fc952dSRob Herring 	/* version 3 fields below */
54c3fc952dSRob Herring 	__be32	dt_strings_size;	/* size of the DT strings block */
55c3fc952dSRob Herring 	/* version 17 fields below */
56c3fc952dSRob Herring 	__be32	dt_struct_size;		/* size of the DT structure block */
57c3fc952dSRob Herring };
58c3fc952dSRob Herring 
59b8b572e1SStephen Rothwell /*
60b8b572e1SStephen Rothwell  * OF address retreival & translation
61b8b572e1SStephen Rothwell  */
62b8b572e1SStephen Rothwell 
63b8b572e1SStephen Rothwell /* Parse the ibm,dma-window property of an OF node into the busno, phys and
64b8b572e1SStephen Rothwell  * size parameters.
65b8b572e1SStephen Rothwell  */
662083f681SAnton Blanchard void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
672083f681SAnton Blanchard 			 unsigned long *busno, unsigned long *phys,
682083f681SAnton Blanchard 			 unsigned long *size);
69b8b572e1SStephen Rothwell 
70129ac799SGrant Likely extern void of_instantiate_rtc(void);
71129ac799SGrant Likely 
72b37193b7SBenjamin Herrenschmidt extern int of_get_ibm_chip_id(struct device_node *np);
73b37193b7SBenjamin Herrenschmidt 
74e83636acSMichael Bringmann struct of_drc_info {
75e83636acSMichael Bringmann 	char *drc_type;
76e83636acSMichael Bringmann 	char *drc_name_prefix;
77e83636acSMichael Bringmann 	u32 drc_index_start;
78e83636acSMichael Bringmann 	u32 drc_name_suffix_start;
79e83636acSMichael Bringmann 	u32 num_sequential_elems;
80e83636acSMichael Bringmann 	u32 sequential_inc;
81e83636acSMichael Bringmann 	u32 drc_power_domain;
82e83636acSMichael Bringmann 	u32 last_drc_index;
83e83636acSMichael Bringmann };
84e83636acSMichael Bringmann 
85e83636acSMichael Bringmann extern int of_read_drc_info_cell(struct property **prop,
86e83636acSMichael Bringmann 			const __be32 **curval, struct of_drc_info *data);
87e83636acSMichael Bringmann 
88*e13d23a4SLaurent Dufour extern unsigned int boot_cpu_node_count;
89e83636acSMichael Bringmann 
90530b5e14SNathan Fontenot /*
91530b5e14SNathan Fontenot  * There are two methods for telling firmware what our capabilities are.
92530b5e14SNathan Fontenot  * Newer machines have an "ibm,client-architecture-support" method on the
93530b5e14SNathan Fontenot  * root node.  For older machines, we have to call the "process-elf-header"
94530b5e14SNathan Fontenot  * method in the /packages/elf-loader node, passing it a fake 32-bit
95530b5e14SNathan Fontenot  * ELF header containing a couple of PT_NOTE sections that contain
96530b5e14SNathan Fontenot  * structures that contain various information.
97530b5e14SNathan Fontenot  */
98530b5e14SNathan Fontenot 
99530b5e14SNathan Fontenot /* New method - extensible architecture description vector. */
100530b5e14SNathan Fontenot 
101530b5e14SNathan Fontenot /* Option vector bits - generic bits in byte 1 */
102530b5e14SNathan Fontenot #define OV_IGNORE		0x80	/* ignore this vector */
103530b5e14SNathan Fontenot #define OV_CESSATION_POLICY	0x40	/* halt if unsupported option present*/
104530b5e14SNathan Fontenot 
105530b5e14SNathan Fontenot /* Option vector 1: processor architectures supported */
106530b5e14SNathan Fontenot #define OV1_PPC_2_00		0x80	/* set if we support PowerPC 2.00 */
107530b5e14SNathan Fontenot #define OV1_PPC_2_01		0x40	/* set if we support PowerPC 2.01 */
108530b5e14SNathan Fontenot #define OV1_PPC_2_02		0x20	/* set if we support PowerPC 2.02 */
109530b5e14SNathan Fontenot #define OV1_PPC_2_03		0x10	/* set if we support PowerPC 2.03 */
110530b5e14SNathan Fontenot #define OV1_PPC_2_04		0x08	/* set if we support PowerPC 2.04 */
111530b5e14SNathan Fontenot #define OV1_PPC_2_05		0x04	/* set if we support PowerPC 2.05 */
112530b5e14SNathan Fontenot #define OV1_PPC_2_06		0x02	/* set if we support PowerPC 2.06 */
113530b5e14SNathan Fontenot #define OV1_PPC_2_07		0x01	/* set if we support PowerPC 2.07 */
114530b5e14SNathan Fontenot 
115cc3d2940SPaul Mackerras #define OV1_PPC_3_00		0x80	/* set if we support PowerPC 3.00 */
116a3ea40d5SAlistair Popple #define OV1_PPC_3_1			0x40	/* set if we support PowerPC 3.1 */
117cc3d2940SPaul Mackerras 
118530b5e14SNathan Fontenot /* Option vector 2: Open Firmware options supported */
119530b5e14SNathan Fontenot #define OV2_REAL_MODE		0x20	/* set if we want OF in real mode */
120530b5e14SNathan Fontenot 
121530b5e14SNathan Fontenot /* Option vector 3: processor options supported */
122530b5e14SNathan Fontenot #define OV3_FP			0x80	/* floating point */
123530b5e14SNathan Fontenot #define OV3_VMX			0x40	/* VMX/Altivec */
124530b5e14SNathan Fontenot #define OV3_DFP			0x20	/* decimal FP */
125530b5e14SNathan Fontenot 
126530b5e14SNathan Fontenot /* Option vector 4: IBM PAPR implementation */
127530b5e14SNathan Fontenot #define OV4_MIN_ENT_CAP		0x01	/* minimum VP entitled capacity */
128530b5e14SNathan Fontenot 
129f0ff7eb4SNathan Fontenot /* Option vector 5: PAPR/OF options supported
130f0ff7eb4SNathan Fontenot  * These bits are also used in firmware_has_feature() to validate
131f0ff7eb4SNathan Fontenot  * the capabilities reported for vector 5 in the device tree so we
132f0ff7eb4SNathan Fontenot  * encode the vector index in the define and use the OV5_FEAT()
133f0ff7eb4SNathan Fontenot  * and OV5_INDX() macros to extract the desired information.
134f0ff7eb4SNathan Fontenot  */
135f0ff7eb4SNathan Fontenot #define OV5_FEAT(x)	((x) & 0xff)
136f0ff7eb4SNathan Fontenot #define OV5_INDX(x)	((x) >> 8)
137f0ff7eb4SNathan Fontenot #define OV5_LPAR		0x0280	/* logical partitioning supported */
138f0ff7eb4SNathan Fontenot #define OV5_SPLPAR		0x0240	/* shared-processor LPAR supported */
139530b5e14SNathan Fontenot /* ibm,dynamic-reconfiguration-memory property supported */
140f0ff7eb4SNathan Fontenot #define OV5_DRCONF_MEMORY	0x0220
141f0ff7eb4SNathan Fontenot #define OV5_LARGE_PAGES		0x0210	/* large pages supported */
142f0ff7eb4SNathan Fontenot #define OV5_DONATE_DEDICATE_CPU	0x0202	/* donate dedicated CPU support */
143f0ff7eb4SNathan Fontenot #define OV5_MSI			0x0201	/* PCIe/MSI support */
144f0ff7eb4SNathan Fontenot #define OV5_CMO			0x0480	/* Cooperative Memory Overcommitment */
145f0ff7eb4SNathan Fontenot #define OV5_XCMO		0x0440	/* Page Coalescing */
1460eacd06bSAneesh Kumar K.V #define OV5_FORM1_AFFINITY	0x0580	/* FORM1 NUMA affinity */
1475d88aa85SJesse Larrew #define OV5_PRRN		0x0540	/* Platform Resource Reassignment */
1481c6b5a7eSAneesh Kumar K.V #define OV5_FORM2_AFFINITY	0x0520	/* Form2 NUMA affinity */
1493dbbaf20SMichael Roth #define OV5_HP_EVT		0x0604	/* Hot Plug Event support */
1500de0fb09SDavid Gibson #define OV5_RESIZE_HPT		0x0601	/* Hash Page Table resizing */
1513f4ab2f8SPaul Mackerras #define OV5_PFO_HW_RNG		0x1180	/* PFO Random Number Generator */
1523f4ab2f8SPaul Mackerras #define OV5_PFO_HW_842		0x1140	/* PFO Compression Accelerator */
1533f4ab2f8SPaul Mackerras #define OV5_PFO_HW_ENCR		0x1120	/* PFO Encryption Accelerator */
1543f4ab2f8SPaul Mackerras #define OV5_SUB_PROCESSORS	0x1501	/* 1,2,or 4 Sub-Processors supported */
1550c38ed6fSNathan Fontenot #define OV5_DRMEM_V2		0x1680	/* ibm,dynamic-reconfiguration-v2 */
156ac5e5a54SCédric Le Goater #define OV5_XIVE_SUPPORT	0x17C0	/* XIVE Exploitation Support Mask */
157ac5e5a54SCédric Le Goater #define OV5_XIVE_LEGACY		0x1700	/* XIVE legacy mode Only */
158ac5e5a54SCédric Le Goater #define OV5_XIVE_EXPLOIT	0x1740	/* XIVE exploitation mode Only */
159ac5e5a54SCédric Le Goater #define OV5_XIVE_EITHER		0x1780	/* XIVE legacy or exploitation mode */
160014d02cbSSuraj Jitindar Singh /* MMU Base Architecture */
161014d02cbSSuraj Jitindar Singh #define OV5_MMU_SUPPORT		0x18C0	/* MMU Mode Support Mask */
162014d02cbSSuraj Jitindar Singh #define OV5_MMU_HASH		0x1800	/* Hash MMU Only */
163014d02cbSSuraj Jitindar Singh #define OV5_MMU_RADIX		0x1840	/* Radix MMU Only */
164014d02cbSSuraj Jitindar Singh #define OV5_MMU_EITHER		0x1880	/* Hash or Radix Supported */
165014d02cbSSuraj Jitindar Singh #define OV5_MMU_DYNAMIC		0x18C0	/* Hash or Radix Can Switch Later */
166014d02cbSSuraj Jitindar Singh #define OV5_NMMU		0x1820	/* Nest MMU Available */
167014d02cbSSuraj Jitindar Singh /* Hash Table Extensions */
168014d02cbSSuraj Jitindar Singh #define OV5_HASH_SEG_TBL	0x1980	/* In Memory Segment Tables Available */
169014d02cbSSuraj Jitindar Singh #define OV5_HASH_GTSE		0x1940	/* Guest Translation Shoot Down Avail */
170014d02cbSSuraj Jitindar Singh /* Radix Table Extensions */
171014d02cbSSuraj Jitindar Singh #define OV5_RADIX_GTSE		0x1A40	/* Guest Translation Shoot Down Avail */
1723f38000eSMichael Bringmann #define OV5_DRC_INFO		0x1640	/* Redef Prop Structures: drc-info   */
173530b5e14SNathan Fontenot 
174530b5e14SNathan Fontenot /* Option Vector 6: IBM PAPR hints */
175530b5e14SNathan Fontenot #define OV6_LINUX		0x02	/* Linux is our OS */
176530b5e14SNathan Fontenot 
177b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
178b8b572e1SStephen Rothwell #endif /* _POWERPC_PROM_H */
179