]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - arch/powerpc/include/asm/machdep.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
[mirror_ubuntu-eoan-kernel.git] / arch / powerpc / include / asm / machdep.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
b41fc4f8
PM
2#ifndef _ASM_POWERPC_MACHDEP_H
3#define _ASM_POWERPC_MACHDEP_H
143a1dec 4#ifdef __KERNEL__
1da177e4
LT
5
6/*
1da177e4
LT
7 */
8
1da177e4
LT
9#include <linux/seq_file.h>
10#include <linux/init.h>
11#include <linux/dma-mapping.h>
93087948 12#include <linux/export.h>
1da177e4
LT
13
14#include <asm/setup.h>
15
143a1dec
PM
16/* We export this macro for external modules like Alsa to know if
17 * ppc_md.feature_call is implemented or not
18 */
19#define CONFIG_PPC_HAS_FEATURE_CALLS
20
1da177e4
LT
21struct pt_regs;
22struct pci_bus;
23struct device_node;
24struct iommu_table;
25struct rtc_time;
26struct file;
4c9d2800 27struct pci_controller;
3d1229d6 28struct kimage;
d82fb31a 29struct pci_host_bridge;
1da177e4 30
1da177e4 31struct machdep_calls {
e8222502 32 char *name;
143a1dec 33#ifdef CONFIG_PPC64
68a64357 34 void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size,
c766ee72 35 pgprot_t prot, void *caller);
68a64357 36 void (*iounmap)(volatile void __iomem *token);
7e11580b
JB
37
38#ifdef CONFIG_PM
39 void (*iommu_save)(void);
40 void (*iommu_restore)(void);
41#endif
a5d86257
AB
42#ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
43 unsigned long (*memory_block_size)(void);
44#endif
e8222502 45#endif /* CONFIG_PPC64 */
1da177e4 46
11ddce15 47 void (*dma_set_mask)(struct device *dev, u64 dma_mask);
5b6e9ff6 48
e8222502 49 int (*probe)(void);
38db7e74 50 void (*setup_arch)(void); /* Optional, may be NULL */
1da177e4 51 /* Optional, may be NULL. */
d8699e65
PM
52 void (*show_cpuinfo)(struct seq_file *m);
53 void (*show_percpuinfo)(struct seq_file *m, int i);
2299d03a
GS
54 /* Returns the current operating frequency of "cpu" in Hz */
55 unsigned long (*get_proc_freq)(unsigned int cpu);
1da177e4
LT
56
57 void (*init_IRQ)(void);
9b647a30 58
ef24ba70 59 /* Return an irq, or 0 to indicate there are none pending. */
35a84c2f 60 unsigned int (*get_irq)(void);
1da177e4
LT
61
62 /* PCI stuff */
6ec73343 63 /* Called after allocating resources */
1da177e4 64 void (*pcibios_fixup)(void);
f90bb153 65 void (*pci_irq_fixup)(struct pci_dev *dev);
d82fb31a
KSS
66 int (*pcibios_root_bridge_prepare)(struct pci_host_bridge
67 *bridge);
1da177e4 68
4c9d2800
BH
69 /* To setup PHBs when using automatic OF platform driver for PCI */
70 int (*pci_setup_phb)(struct pci_controller *host);
71
95ec77c0
DA
72 void __noreturn (*restart)(char *cmd);
73 void __noreturn (*halt)(void);
ab9dbf77 74 void (*panic)(char *str);
1da177e4
LT
75 void (*cpu_die)(void);
76
143a1dec
PM
77 long (*time_init)(void); /* Optional, may be NULL */
78
1da177e4
LT
79 int (*set_rtc_time)(struct rtc_time *);
80 void (*get_rtc_time)(struct rtc_time *);
5bfd6435 81 time64_t (*get_boot_time)(void);
143a1dec
PM
82 unsigned char (*rtc_read_val)(int addr);
83 void (*rtc_write_val)(int addr, unsigned char val);
1da177e4
LT
84
85 void (*calibrate_decr)(void);
86
87 void (*progress)(char *, unsigned short);
88
1da177e4
LT
89 /* Interface for platform error logging */
90 void (*log_error)(char *buf, unsigned int err_type, int fatal);
91
35499c01
PM
92 unsigned char (*nvram_read_val)(int addr);
93 void (*nvram_write_val)(int addr, unsigned char val);
1da177e4
LT
94 ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index);
95 ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index);
96 ssize_t (*nvram_size)(void);
143a1dec 97 void (*nvram_sync)(void);
1da177e4
LT
98
99 /* Exception handlers */
c902be71 100 int (*system_reset_exception)(struct pt_regs *regs);
1da177e4 101 int (*machine_check_exception)(struct pt_regs *regs);
0869b6fd
MS
102 int (*handle_hmi_exception)(struct pt_regs *regs);
103
104 /* Early exception handlers called in realmode */
105 int (*hmi_exception_early)(struct pt_regs *regs);
a43c1590 106 long (*machine_check_early)(struct pt_regs *regs);
1da177e4 107
55672ecf
MS
108 /* Called during machine check exception to retrive fixup address. */
109 bool (*mce_check_early_recovery)(struct pt_regs *regs);
110
1da177e4
LT
111 /* Motherboard/chipset features. This is a kind of general purpose
112 * hook used to control some machine specific features (like reset
113 * lines, chip power control, etc...).
114 */
115 long (*feature_call)(unsigned int feature, ...);
116
1da177e4
LT
117 /* Get legacy PCI/IDE interrupt mapping */
118 int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
119
120 /* Get access protection for /dev/mem */
121 pgprot_t (*phys_mem_access_prot)(struct file *file,
8b150478 122 unsigned long pfn,
1da177e4
LT
123 unsigned long size,
124 pgprot_t vma_prot);
125
a0652fc9
PM
126 /*
127 * Function for waiting for work with reduced power in idle loop;
128 * called with interrupts disabled.
129 */
130 void (*power_save)(void);
131
143a1dec
PM
132 /* Function to enable performance monitor counters for this
133 platform, called once per cpu. */
180a3362 134 void (*enable_pmcs)(void);
143a1dec 135
446957ba 136 /* Set DABR for this platform, leave empty for default implementation */
4474ef05
MN
137 int (*set_dabr)(unsigned long dabr,
138 unsigned long dabrx);
76032de8 139
446957ba 140 /* Set DAWR for this platform, leave empty for default implementation */
bf99de36
MN
141 int (*set_dawr)(unsigned long dawr,
142 unsigned long dawrx);
143
143a1dec 144#ifdef CONFIG_PPC32 /* XXX for now */
143a1dec
PM
145 /* A general init function, called by ppc_init in init/main.c.
146 May be NULL. */
147 void (*init)(void);
148
143a1dec
PM
149 void (*kgdb_map_scc)(void);
150
143a1dec
PM
151 /*
152 * optional PCI "hooks"
153 */
143a1dec
PM
154 /* Called at then very end of pcibios_init() */
155 void (*pcibios_after_init)(void);
156
3d1229d6 157#endif /* CONFIG_PPC32 */
143a1dec 158
89c2dd62
KG
159 /* Called in indirect_* to avoid touching devices */
160 int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
161
bf5e2ba2
BH
162 /* Called after PPC generic resource fixup to perform
163 machine specific fixups */
164 void (*pcibios_fixup_resources)(struct pci_dev *);
165
166 /* Called for each PCI bus in the system when it's probed */
167 void (*pcibios_fixup_bus)(struct pci_bus *);
168
491b98c3
BH
169 /* Called after scan and before resource survey */
170 void (*pcibios_fixup_phb)(struct pci_controller *hose);
171
988fc3ba
BL
172 /*
173 * Called after device has been added to bus and
174 * before sysfs has been created.
175 */
176 void (*pcibios_bus_add_device)(struct pci_dev *pdev);
177
38274637
YX
178 resource_size_t (*pcibios_default_alignment)(void);
179
6e628c7d
WY
180#ifdef CONFIG_PCI_IOV
181 void (*pcibios_fixup_sriov)(struct pci_dev *pdev);
5350ab3f 182 resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno);
988fc3ba
BL
183 int (*pcibios_sriov_enable)(struct pci_dev *pdev, u16 num_vfs);
184 int (*pcibios_sriov_disable)(struct pci_dev *pdev);
6e628c7d
WY
185#endif /* CONFIG_PCI_IOV */
186
143a1dec
PM
187 /* Called to shutdown machine specific hardware not already controlled
188 * by other drivers.
143a1dec
PM
189 */
190 void (*machine_shutdown)(void);
191
da665885 192#ifdef CONFIG_KEXEC_CORE
50266a1f
AB
193 void (*kexec_cpu_down)(int crash_shutdown, int secondary);
194
143a1dec
PM
195 /* Called to do what every setup is needed on image and the
196 * reboot code buffer. Returns 0 on success.
197 * Provide your own (maybe dummy) implementation if your platform
198 * claims to support kexec.
199 */
200 int (*machine_kexec_prepare)(struct kimage *image);
357574c4
AB
201
202 /* Called to perform the _real_ kexec.
203 * Do NOT allocate memory or fail here. We are past the point of
204 * no return.
205 */
206 void (*machine_kexec)(struct kimage *image);
da665885 207#endif /* CONFIG_KEXEC_CORE */
7ac5dde9
SW
208
209#ifdef CONFIG_SUSPEND
210 /* These are called to disable and enable, respectively, IRQs when
211 * entering a suspend state. If NULL, then the generic versions
212 * will be called. The generic versions disable/enable the
213 * decrementer along with interrupts.
214 */
215 void (*suspend_disable_irqs)(void);
216 void (*suspend_enable_irqs)(void);
217#endif
32d8ad4e 218 int (*suspend_disable_cpu)(void);
12633e80
NF
219
220#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
221 ssize_t (*cpu_probe)(const char *, size_t);
222 ssize_t (*cpu_release)(const char *, size_t);
223#endif
a4da0d50
ME
224
225#ifdef CONFIG_ARCH_RANDOM
01c9348c 226 int (*get_random_seed)(unsigned long *v);
a4da0d50 227#endif
1da177e4
LT
228};
229
fc4033b2 230extern void e500_idle(void);
a0652fc9 231extern void power4_idle(void);
948cf67c 232extern void power7_idle(void);
2201f994 233extern void power9_idle(void);
a0652fc9 234extern void ppc6xx_idle(void);
34d97e07 235extern void book3e_idle(void);
fd899c0c 236
e8222502
BH
237/*
238 * ppc_md contains a copy of the machine description structure for the
239 * current platform. machine_id contains the initial address where the
240 * description was found during boot.
241 */
1da177e4 242extern struct machdep_calls ppc_md;
e8222502
BH
243extern struct machdep_calls *machine_id;
244
245#define __machine_desc __attribute__ ((__section__ (".machine.desc")))
246
d0e15bed
PM
247#define define_machine(name) \
248 extern struct machdep_calls mach_##name; \
249 EXPORT_SYMBOL(mach_##name); \
250 struct machdep_calls mach_##name __machine_desc =
251
e8222502
BH
252#define machine_is(name) \
253 ({ \
254 extern struct machdep_calls mach_##name \
255 __attribute__((weak)); \
256 machine_id == &mach_##name; \
257 })
258
259extern void probe_machine(void);
260
1da177e4
LT
261#ifdef CONFIG_PPC_PMAC
262/*
263 * Power macintoshes have either a CUDA, PMU or SMU controlling
264 * system reset, power, NVRAM, RTC.
265 */
266typedef enum sys_ctrler_kind {
267 SYS_CTRLER_UNKNOWN = 0,
268 SYS_CTRLER_CUDA = 1,
269 SYS_CTRLER_PMU = 2,
270 SYS_CTRLER_SMU = 3,
271} sys_ctrler_t;
272extern sys_ctrler_t sys_ctrler;
273
274#endif /* CONFIG_PPC_PMAC */
275
1da177e4
LT
276static inline void log_error(char *buf, unsigned int err_type, int fatal)
277{
278 if (ppc_md.log_error)
279 ppc_md.log_error(buf, err_type, fatal);
280}
281
7929d407 282#define __define_machine_initcall(mach, fn, id) \
800d68c3
GL
283 static int __init __machine_initcall_##mach##_##fn(void) { \
284 if (machine_is(mach)) return fn(); \
285 return 0; \
286 } \
7929d407
ML
287 __define_initcall(__machine_initcall_##mach##_##fn, id);
288
8d3c941e 289#define machine_early_initcall(mach, fn) __define_machine_initcall(mach, fn, early)
7929d407
ML
290#define machine_core_initcall(mach, fn) __define_machine_initcall(mach, fn, 1)
291#define machine_core_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 1s)
292#define machine_postcore_initcall(mach, fn) __define_machine_initcall(mach, fn, 2)
293#define machine_postcore_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 2s)
294#define machine_arch_initcall(mach, fn) __define_machine_initcall(mach, fn, 3)
295#define machine_arch_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 3s)
296#define machine_subsys_initcall(mach, fn) __define_machine_initcall(mach, fn, 4)
297#define machine_subsys_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 4s)
298#define machine_fs_initcall(mach, fn) __define_machine_initcall(mach, fn, 5)
299#define machine_fs_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 5s)
300#define machine_rootfs_initcall(mach, fn) __define_machine_initcall(mach, fn, rootfs)
301#define machine_device_initcall(mach, fn) __define_machine_initcall(mach, fn, 6)
302#define machine_device_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 6s)
303#define machine_late_initcall(mach, fn) __define_machine_initcall(mach, fn, 7)
304#define machine_late_initcall_sync(mach, fn) __define_machine_initcall(mach, fn, 7s)
800d68c3 305
1da177e4 306#endif /* __KERNEL__ */
b41fc4f8 307#endif /* _ASM_POWERPC_MACHDEP_H */