blob: 9f27866e3126d82d9e1e051f3a0b82995cc0217c [file] [log] [blame]
Paul Mackerras9b6b5632005-10-06 12:06:20 +10001#ifndef _POWERPC_PROM_H
2#define _POWERPC_PROM_H
3#ifdef __KERNEL__
4
5/*
6 * Definitions for talking to the Open Firmware PROM on
7 * Power Macintosh computers.
8 *
9 * Copyright (C) 1996-2005 Paul Mackerras.
10 *
11 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18#include <linux/types.h>
Andrew Morton99ddef92007-02-17 18:17:16 -070019#include <asm/irq.h>
Arun Sharma600634972011-07-26 16:09:06 -070020#include <linux/atomic.h>
Paul Mackerras9b6b5632005-10-06 12:06:20 +100021
Rob Herring5c19c5c2013-09-17 14:34:00 -050022/* These includes should be removed once implicit includes are cleaned up. */
23#include <linux/of.h>
24#include <linux/of_fdt.h>
25#include <linux/of_address.h>
26#include <linux/of_irq.h>
27#include <linux/platform_device.h>
Paul Mackerras9b6b5632005-10-06 12:06:20 +100028
Rob Herringc3fc9522014-04-01 22:55:14 -050029#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
30#define OF_DT_END_NODE 0x2 /* End node */
31#define OF_DT_PROP 0x3 /* Property: name off, size,
32 * content */
33#define OF_DT_NOP 0x4 /* nop */
34#define OF_DT_END 0x9
35
36#define OF_DT_VERSION 0x10
37
38/*
39 * This is what gets passed to the kernel by prom_init or kexec
40 *
41 * The dt struct contains the device tree structure, full pathes and
42 * property contents. The dt strings contain a separate block with just
43 * the strings for the property names, and is fully page aligned and
44 * self contained in a page, so that it can be kept around by the kernel,
45 * each property name appears only once in this page (cheap compression)
46 *
47 * the mem_rsvmap contains a map of reserved ranges of physical memory,
48 * passing it here instead of in the device-tree itself greatly simplifies
49 * the job of everybody. It's just a list of u64 pairs (base/size) that
50 * ends when size is 0
51 */
52struct boot_param_header {
53 __be32 magic; /* magic word OF_DT_HEADER */
54 __be32 totalsize; /* total size of DT block */
55 __be32 off_dt_struct; /* offset to structure */
56 __be32 off_dt_strings; /* offset to strings */
57 __be32 off_mem_rsvmap; /* offset to memory reserve map */
58 __be32 version; /* format version */
59 __be32 last_comp_version; /* last compatible version */
60 /* version 2 fields below */
61 __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */
62 /* version 3 fields below */
63 __be32 dt_strings_size; /* size of the DT strings block */
64 /* version 17 fields below */
65 __be32 dt_struct_size; /* size of the DT structure block */
66};
67
Benjamin Herrenschmidtd1405b82005-11-23 17:53:42 +110068/*
Benjamin Herrenschmidtd2dd4822005-11-30 16:57:28 +110069 * OF address retreival & translation
70 */
71
Jeremy Kerrd4ad66f2006-05-18 18:05:15 +100072/* Parse the ibm,dma-window property of an OF node into the busno, phys and
73 * size parameters.
74 */
Anton Blanchard2083f682013-08-07 02:01:36 +100075void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
76 unsigned long *busno, unsigned long *phys,
77 unsigned long *size);
Jeremy Kerrd4ad66f2006-05-18 18:05:15 +100078
Grant Likely129ac792010-06-29 09:26:53 -070079extern void of_instantiate_rtc(void);
80
Benjamin Herrenschmidtb37193b2013-07-15 13:03:10 +100081extern int of_get_ibm_chip_id(struct device_node *np);
82
Nathan Fontenot530b5e12013-04-24 05:53:10 +000083/*
84 * There are two methods for telling firmware what our capabilities are.
85 * Newer machines have an "ibm,client-architecture-support" method on the
86 * root node. For older machines, we have to call the "process-elf-header"
87 * method in the /packages/elf-loader node, passing it a fake 32-bit
88 * ELF header containing a couple of PT_NOTE sections that contain
89 * structures that contain various information.
90 */
91
92/* New method - extensible architecture description vector. */
93
94/* Option vector bits - generic bits in byte 1 */
95#define OV_IGNORE 0x80 /* ignore this vector */
96#define OV_CESSATION_POLICY 0x40 /* halt if unsupported option present*/
97
98/* Option vector 1: processor architectures supported */
99#define OV1_PPC_2_00 0x80 /* set if we support PowerPC 2.00 */
100#define OV1_PPC_2_01 0x40 /* set if we support PowerPC 2.01 */
101#define OV1_PPC_2_02 0x20 /* set if we support PowerPC 2.02 */
102#define OV1_PPC_2_03 0x10 /* set if we support PowerPC 2.03 */
103#define OV1_PPC_2_04 0x08 /* set if we support PowerPC 2.04 */
104#define OV1_PPC_2_05 0x04 /* set if we support PowerPC 2.05 */
105#define OV1_PPC_2_06 0x02 /* set if we support PowerPC 2.06 */
106#define OV1_PPC_2_07 0x01 /* set if we support PowerPC 2.07 */
107
Paul Mackerrascc3d2942017-01-30 21:21:36 +1100108#define OV1_PPC_3_00 0x80 /* set if we support PowerPC 3.00 */
109
Nathan Fontenot530b5e12013-04-24 05:53:10 +0000110/* Option vector 2: Open Firmware options supported */
111#define OV2_REAL_MODE 0x20 /* set if we want OF in real mode */
112
113/* Option vector 3: processor options supported */
114#define OV3_FP 0x80 /* floating point */
115#define OV3_VMX 0x40 /* VMX/Altivec */
116#define OV3_DFP 0x20 /* decimal FP */
117
118/* Option vector 4: IBM PAPR implementation */
119#define OV4_MIN_ENT_CAP 0x01 /* minimum VP entitled capacity */
120
Nathan Fontenotf0ff7eb2013-04-24 05:57:18 +0000121/* Option vector 5: PAPR/OF options supported
122 * These bits are also used in firmware_has_feature() to validate
123 * the capabilities reported for vector 5 in the device tree so we
124 * encode the vector index in the define and use the OV5_FEAT()
125 * and OV5_INDX() macros to extract the desired information.
126 */
127#define OV5_FEAT(x) ((x) & 0xff)
128#define OV5_INDX(x) ((x) >> 8)
129#define OV5_LPAR 0x0280 /* logical partitioning supported */
130#define OV5_SPLPAR 0x0240 /* shared-processor LPAR supported */
Nathan Fontenot530b5e12013-04-24 05:53:10 +0000131/* ibm,dynamic-reconfiguration-memory property supported */
Nathan Fontenotf0ff7eb2013-04-24 05:57:18 +0000132#define OV5_DRCONF_MEMORY 0x0220
133#define OV5_LARGE_PAGES 0x0210 /* large pages supported */
134#define OV5_DONATE_DEDICATE_CPU 0x0202 /* donate dedicated CPU support */
135#define OV5_MSI 0x0201 /* PCIe/MSI support */
136#define OV5_CMO 0x0480 /* Cooperative Memory Overcommitment */
137#define OV5_XCMO 0x0440 /* Page Coalescing */
138#define OV5_TYPE1_AFFINITY 0x0580 /* Type 1 NUMA affinity */
Jesse Larrew5d88aa82013-04-24 06:00:35 +0000139#define OV5_PRRN 0x0540 /* Platform Resource Reassignment */
Michael Roth3dbbaf22017-02-20 19:12:18 -0600140#define OV5_HP_EVT 0x0604 /* Hot Plug Event support */
David Gibson0de0fb02016-12-09 11:07:37 +1100141#define OV5_RESIZE_HPT 0x0601 /* Hash Page Table resizing */
Paul Mackerras3f4ab2f2017-01-30 21:21:35 +1100142#define OV5_PFO_HW_RNG 0x1180 /* PFO Random Number Generator */
143#define OV5_PFO_HW_842 0x1140 /* PFO Compression Accelerator */
144#define OV5_PFO_HW_ENCR 0x1120 /* PFO Encryption Accelerator */
145#define OV5_SUB_PROCESSORS 0x1501 /* 1,2,or 4 Sub-Processors supported */
Nathan Fontenot0c38ed62017-12-01 10:48:03 -0600146#define OV5_DRMEM_V2 0x1680 /* ibm,dynamic-reconfiguration-v2 */
Cédric Le Goaterac5e5a52017-08-30 21:46:16 +0200147#define OV5_XIVE_SUPPORT 0x17C0 /* XIVE Exploitation Support Mask */
148#define OV5_XIVE_LEGACY 0x1700 /* XIVE legacy mode Only */
149#define OV5_XIVE_EXPLOIT 0x1740 /* XIVE exploitation mode Only */
150#define OV5_XIVE_EITHER 0x1780 /* XIVE legacy or exploitation mode */
Suraj Jitindar Singh014d02c2017-02-28 17:03:48 +1100151/* MMU Base Architecture */
152#define OV5_MMU_SUPPORT 0x18C0 /* MMU Mode Support Mask */
153#define OV5_MMU_HASH 0x1800 /* Hash MMU Only */
154#define OV5_MMU_RADIX 0x1840 /* Radix MMU Only */
155#define OV5_MMU_EITHER 0x1880 /* Hash or Radix Supported */
156#define OV5_MMU_DYNAMIC 0x18C0 /* Hash or Radix Can Switch Later */
157#define OV5_NMMU 0x1820 /* Nest MMU Available */
158/* Hash Table Extensions */
159#define OV5_HASH_SEG_TBL 0x1980 /* In Memory Segment Tables Available */
160#define OV5_HASH_GTSE 0x1940 /* Guest Translation Shoot Down Avail */
161/* Radix Table Extensions */
162#define OV5_RADIX_GTSE 0x1A40 /* Guest Translation Shoot Down Avail */
Nathan Fontenot530b5e12013-04-24 05:53:10 +0000163
164/* Option Vector 6: IBM PAPR hints */
165#define OV6_LINUX 0x02 /* Linux is our OS */
166
Paul Mackerras9b6b5632005-10-06 12:06:20 +1000167#endif /* __KERNEL__ */
168#endif /* _POWERPC_PROM_H */