xref: /linux/arch/powerpc/include/asm/prom.h (revision 0eacd06bb8adea8dd9edb0a30144166d9f227e64)
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>
15b8b572e1SStephen Rothwell #include <asm/irq.h>
1660063497SArun Sharma #include <linux/atomic.h>
17b8b572e1SStephen Rothwell 
185c19c5c6SRob Herring /* These includes should be removed once implicit includes are cleaned up. */
195c19c5c6SRob Herring #include <linux/of.h>
205c19c5c6SRob Herring #include <linux/of_fdt.h>
215c19c5c6SRob Herring #include <linux/of_address.h>
225c19c5c6SRob Herring #include <linux/of_irq.h>
235c19c5c6SRob Herring #include <linux/platform_device.h>
24b8b572e1SStephen Rothwell 
25c3fc952dSRob Herring #define OF_DT_BEGIN_NODE	0x1		/* Start of node, full name */
26c3fc952dSRob Herring #define OF_DT_END_NODE		0x2		/* End node */
27c3fc952dSRob Herring #define OF_DT_PROP		0x3		/* Property: name off, size,
28c3fc952dSRob Herring 						 * content */
29c3fc952dSRob Herring #define OF_DT_NOP		0x4		/* nop */
30c3fc952dSRob Herring #define OF_DT_END		0x9
31c3fc952dSRob Herring 
32c3fc952dSRob Herring #define OF_DT_VERSION		0x10
33c3fc952dSRob Herring 
34c3fc952dSRob Herring /*
35c3fc952dSRob Herring  * This is what gets passed to the kernel by prom_init or kexec
36c3fc952dSRob Herring  *
37c3fc952dSRob Herring  * The dt struct contains the device tree structure, full pathes and
38c3fc952dSRob Herring  * property contents. The dt strings contain a separate block with just
39c3fc952dSRob Herring  * the strings for the property names, and is fully page aligned and
40c3fc952dSRob Herring  * self contained in a page, so that it can be kept around by the kernel,
41c3fc952dSRob Herring  * each property name appears only once in this page (cheap compression)
42c3fc952dSRob Herring  *
43c3fc952dSRob Herring  * the mem_rsvmap contains a map of reserved ranges of physical memory,
44c3fc952dSRob Herring  * passing it here instead of in the device-tree itself greatly simplifies
45c3fc952dSRob Herring  * the job of everybody. It's just a list of u64 pairs (base/size) that
46c3fc952dSRob Herring  * ends when size is 0
47c3fc952dSRob Herring  */
48c3fc952dSRob Herring struct boot_param_header {
49c3fc952dSRob Herring 	__be32	magic;			/* magic word OF_DT_HEADER */
50c3fc952dSRob Herring 	__be32	totalsize;		/* total size of DT block */
51c3fc952dSRob Herring 	__be32	off_dt_struct;		/* offset to structure */
52c3fc952dSRob Herring 	__be32	off_dt_strings;		/* offset to strings */
53c3fc952dSRob Herring 	__be32	off_mem_rsvmap;		/* offset to memory reserve map */
54c3fc952dSRob Herring 	__be32	version;		/* format version */
55c3fc952dSRob Herring 	__be32	last_comp_version;	/* last compatible version */
56c3fc952dSRob Herring 	/* version 2 fields below */
57c3fc952dSRob Herring 	__be32	boot_cpuid_phys;	/* Physical CPU id we're booting on */
58c3fc952dSRob Herring 	/* version 3 fields below */
59c3fc952dSRob Herring 	__be32	dt_strings_size;	/* size of the DT strings block */
60c3fc952dSRob Herring 	/* version 17 fields below */
61c3fc952dSRob Herring 	__be32	dt_struct_size;		/* size of the DT structure block */
62c3fc952dSRob Herring };
63c3fc952dSRob Herring 
64b8b572e1SStephen Rothwell /*
65b8b572e1SStephen Rothwell  * OF address retreival & translation
66b8b572e1SStephen Rothwell  */
67b8b572e1SStephen Rothwell 
68b8b572e1SStephen Rothwell /* Parse the ibm,dma-window property of an OF node into the busno, phys and
69b8b572e1SStephen Rothwell  * size parameters.
70b8b572e1SStephen Rothwell  */
712083f681SAnton Blanchard void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
722083f681SAnton Blanchard 			 unsigned long *busno, unsigned long *phys,
732083f681SAnton Blanchard 			 unsigned long *size);
74b8b572e1SStephen Rothwell 
75129ac799SGrant Likely extern void of_instantiate_rtc(void);
76129ac799SGrant Likely 
77b37193b7SBenjamin Herrenschmidt extern int of_get_ibm_chip_id(struct device_node *np);
78b37193b7SBenjamin Herrenschmidt 
79e83636acSMichael Bringmann struct of_drc_info {
80e83636acSMichael Bringmann 	char *drc_type;
81e83636acSMichael Bringmann 	char *drc_name_prefix;
82e83636acSMichael Bringmann 	u32 drc_index_start;
83e83636acSMichael Bringmann 	u32 drc_name_suffix_start;
84e83636acSMichael Bringmann 	u32 num_sequential_elems;
85e83636acSMichael Bringmann 	u32 sequential_inc;
86e83636acSMichael Bringmann 	u32 drc_power_domain;
87e83636acSMichael Bringmann 	u32 last_drc_index;
88e83636acSMichael Bringmann };
89e83636acSMichael Bringmann 
90e83636acSMichael Bringmann extern int of_read_drc_info_cell(struct property **prop,
91e83636acSMichael Bringmann 			const __be32 **curval, struct of_drc_info *data);
92e83636acSMichael Bringmann 
93e83636acSMichael Bringmann 
94530b5e14SNathan Fontenot /*
95530b5e14SNathan Fontenot  * There are two methods for telling firmware what our capabilities are.
96530b5e14SNathan Fontenot  * Newer machines have an "ibm,client-architecture-support" method on the
97530b5e14SNathan Fontenot  * root node.  For older machines, we have to call the "process-elf-header"
98530b5e14SNathan Fontenot  * method in the /packages/elf-loader node, passing it a fake 32-bit
99530b5e14SNathan Fontenot  * ELF header containing a couple of PT_NOTE sections that contain
100530b5e14SNathan Fontenot  * structures that contain various information.
101530b5e14SNathan Fontenot  */
102530b5e14SNathan Fontenot 
103530b5e14SNathan Fontenot /* New method - extensible architecture description vector. */
104530b5e14SNathan Fontenot 
105530b5e14SNathan Fontenot /* Option vector bits - generic bits in byte 1 */
106530b5e14SNathan Fontenot #define OV_IGNORE		0x80	/* ignore this vector */
107530b5e14SNathan Fontenot #define OV_CESSATION_POLICY	0x40	/* halt if unsupported option present*/
108530b5e14SNathan Fontenot 
109530b5e14SNathan Fontenot /* Option vector 1: processor architectures supported */
110530b5e14SNathan Fontenot #define OV1_PPC_2_00		0x80	/* set if we support PowerPC 2.00 */
111530b5e14SNathan Fontenot #define OV1_PPC_2_01		0x40	/* set if we support PowerPC 2.01 */
112530b5e14SNathan Fontenot #define OV1_PPC_2_02		0x20	/* set if we support PowerPC 2.02 */
113530b5e14SNathan Fontenot #define OV1_PPC_2_03		0x10	/* set if we support PowerPC 2.03 */
114530b5e14SNathan Fontenot #define OV1_PPC_2_04		0x08	/* set if we support PowerPC 2.04 */
115530b5e14SNathan Fontenot #define OV1_PPC_2_05		0x04	/* set if we support PowerPC 2.05 */
116530b5e14SNathan Fontenot #define OV1_PPC_2_06		0x02	/* set if we support PowerPC 2.06 */
117530b5e14SNathan Fontenot #define OV1_PPC_2_07		0x01	/* set if we support PowerPC 2.07 */
118530b5e14SNathan Fontenot 
119cc3d2940SPaul Mackerras #define OV1_PPC_3_00		0x80	/* set if we support PowerPC 3.00 */
120a3ea40d5SAlistair Popple #define OV1_PPC_3_1			0x40	/* set if we support PowerPC 3.1 */
121cc3d2940SPaul Mackerras 
122530b5e14SNathan Fontenot /* Option vector 2: Open Firmware options supported */
123530b5e14SNathan Fontenot #define OV2_REAL_MODE		0x20	/* set if we want OF in real mode */
124530b5e14SNathan Fontenot 
125530b5e14SNathan Fontenot /* Option vector 3: processor options supported */
126530b5e14SNathan Fontenot #define OV3_FP			0x80	/* floating point */
127530b5e14SNathan Fontenot #define OV3_VMX			0x40	/* VMX/Altivec */
128530b5e14SNathan Fontenot #define OV3_DFP			0x20	/* decimal FP */
129530b5e14SNathan Fontenot 
130530b5e14SNathan Fontenot /* Option vector 4: IBM PAPR implementation */
131530b5e14SNathan Fontenot #define OV4_MIN_ENT_CAP		0x01	/* minimum VP entitled capacity */
132530b5e14SNathan Fontenot 
133f0ff7eb4SNathan Fontenot /* Option vector 5: PAPR/OF options supported
134f0ff7eb4SNathan Fontenot  * These bits are also used in firmware_has_feature() to validate
135f0ff7eb4SNathan Fontenot  * the capabilities reported for vector 5 in the device tree so we
136f0ff7eb4SNathan Fontenot  * encode the vector index in the define and use the OV5_FEAT()
137f0ff7eb4SNathan Fontenot  * and OV5_INDX() macros to extract the desired information.
138f0ff7eb4SNathan Fontenot  */
139f0ff7eb4SNathan Fontenot #define OV5_FEAT(x)	((x) & 0xff)
140f0ff7eb4SNathan Fontenot #define OV5_INDX(x)	((x) >> 8)
141f0ff7eb4SNathan Fontenot #define OV5_LPAR		0x0280	/* logical partitioning supported */
142f0ff7eb4SNathan Fontenot #define OV5_SPLPAR		0x0240	/* shared-processor LPAR supported */
143530b5e14SNathan Fontenot /* ibm,dynamic-reconfiguration-memory property supported */
144f0ff7eb4SNathan Fontenot #define OV5_DRCONF_MEMORY	0x0220
145f0ff7eb4SNathan Fontenot #define OV5_LARGE_PAGES		0x0210	/* large pages supported */
146f0ff7eb4SNathan Fontenot #define OV5_DONATE_DEDICATE_CPU	0x0202	/* donate dedicated CPU support */
147f0ff7eb4SNathan Fontenot #define OV5_MSI			0x0201	/* PCIe/MSI support */
148f0ff7eb4SNathan Fontenot #define OV5_CMO			0x0480	/* Cooperative Memory Overcommitment */
149f0ff7eb4SNathan Fontenot #define OV5_XCMO		0x0440	/* Page Coalescing */
150*0eacd06bSAneesh Kumar K.V #define OV5_FORM1_AFFINITY	0x0580	/* FORM1 NUMA affinity */
1515d88aa85SJesse Larrew #define OV5_PRRN		0x0540	/* Platform Resource Reassignment */
1523dbbaf20SMichael Roth #define OV5_HP_EVT		0x0604	/* Hot Plug Event support */
1530de0fb09SDavid Gibson #define OV5_RESIZE_HPT		0x0601	/* Hash Page Table resizing */
1543f4ab2f8SPaul Mackerras #define OV5_PFO_HW_RNG		0x1180	/* PFO Random Number Generator */
1553f4ab2f8SPaul Mackerras #define OV5_PFO_HW_842		0x1140	/* PFO Compression Accelerator */
1563f4ab2f8SPaul Mackerras #define OV5_PFO_HW_ENCR		0x1120	/* PFO Encryption Accelerator */
1573f4ab2f8SPaul Mackerras #define OV5_SUB_PROCESSORS	0x1501	/* 1,2,or 4 Sub-Processors supported */
1580c38ed6fSNathan Fontenot #define OV5_DRMEM_V2		0x1680	/* ibm,dynamic-reconfiguration-v2 */
159ac5e5a54SCédric Le Goater #define OV5_XIVE_SUPPORT	0x17C0	/* XIVE Exploitation Support Mask */
160ac5e5a54SCédric Le Goater #define OV5_XIVE_LEGACY		0x1700	/* XIVE legacy mode Only */
161ac5e5a54SCédric Le Goater #define OV5_XIVE_EXPLOIT	0x1740	/* XIVE exploitation mode Only */
162ac5e5a54SCédric Le Goater #define OV5_XIVE_EITHER		0x1780	/* XIVE legacy or exploitation mode */
163014d02cbSSuraj Jitindar Singh /* MMU Base Architecture */
164014d02cbSSuraj Jitindar Singh #define OV5_MMU_SUPPORT		0x18C0	/* MMU Mode Support Mask */
165014d02cbSSuraj Jitindar Singh #define OV5_MMU_HASH		0x1800	/* Hash MMU Only */
166014d02cbSSuraj Jitindar Singh #define OV5_MMU_RADIX		0x1840	/* Radix MMU Only */
167014d02cbSSuraj Jitindar Singh #define OV5_MMU_EITHER		0x1880	/* Hash or Radix Supported */
168014d02cbSSuraj Jitindar Singh #define OV5_MMU_DYNAMIC		0x18C0	/* Hash or Radix Can Switch Later */
169014d02cbSSuraj Jitindar Singh #define OV5_NMMU		0x1820	/* Nest MMU Available */
170014d02cbSSuraj Jitindar Singh /* Hash Table Extensions */
171014d02cbSSuraj Jitindar Singh #define OV5_HASH_SEG_TBL	0x1980	/* In Memory Segment Tables Available */
172014d02cbSSuraj Jitindar Singh #define OV5_HASH_GTSE		0x1940	/* Guest Translation Shoot Down Avail */
173014d02cbSSuraj Jitindar Singh /* Radix Table Extensions */
174014d02cbSSuraj Jitindar Singh #define OV5_RADIX_GTSE		0x1A40	/* Guest Translation Shoot Down Avail */
1753f38000eSMichael Bringmann #define OV5_DRC_INFO		0x1640	/* Redef Prop Structures: drc-info   */
176530b5e14SNathan Fontenot 
177530b5e14SNathan Fontenot /* Option Vector 6: IBM PAPR hints */
178530b5e14SNathan Fontenot #define OV6_LINUX		0x02	/* Linux is our OS */
179530b5e14SNathan Fontenot 
180b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
181b8b572e1SStephen Rothwell #endif /* _POWERPC_PROM_H */
182